Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
3f5cef69
Commit
3f5cef69
authored
Jun 25, 2018
by
Chris Shallue
Committed by
Christopher Shallue
Jun 25, 2018
Browse files
Add __str__ and __repr__ to periodic_event.Event.
PiperOrigin-RevId: 202034513
parent
f82ca018
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
research/astronet/light_curve_util/periodic_event.py
research/astronet/light_curve_util/periodic_event.py
+7
-0
research/astronet/light_curve_util/periodic_event_test.py
research/astronet/light_curve_util/periodic_event_test.py
+8
-1
No files found.
research/astronet/light_curve_util/periodic_event.py
View file @
3f5cef69
...
@@ -36,6 +36,13 @@ class Event(object):
...
@@ -36,6 +36,13 @@ class Event(object):
self
.
_duration
=
duration
self
.
_duration
=
duration
self
.
_t0
=
t0
self
.
_t0
=
t0
def
__str__
(
self
):
return
"<period={}, duration={}, t0={}>"
.
format
(
self
.
period
,
self
.
duration
,
self
.
t0
)
def
__repr__
(
self
):
return
"Event({})"
.
format
(
str
(
self
))
@
property
@
property
def
period
(
self
):
def
period
(
self
):
return
self
.
_period
return
self
.
_period
...
...
research/astronet/light_curve_util/periodic_event_test.py
View file @
3f5cef69
...
@@ -25,6 +25,13 @@ from light_curve_util.periodic_event import Event
...
@@ -25,6 +25,13 @@ from light_curve_util.periodic_event import Event
class
EventTest
(
absltest
.
TestCase
):
class
EventTest
(
absltest
.
TestCase
):
def
testStr
(
self
):
self
.
assertEqual
(
str
(
Event
(
1
,
2
,
3
)),
"<period=1, duration=2, t0=3>"
)
def
testRepr
(
self
):
self
.
assertEqual
(
repr
(
Event
(
1
,
2
,
3
)),
"Event(<period=1, duration=2, t0=3>)"
)
def
testEquals
(
self
):
def
testEquals
(
self
):
event
=
Event
(
period
=
100
,
duration
=
5
,
t0
=
2
)
event
=
Event
(
period
=
100
,
duration
=
5
,
t0
=
2
)
...
@@ -72,5 +79,5 @@ class EventTest(absltest.TestCase):
...
@@ -72,5 +79,5 @@ class EventTest(absltest.TestCase):
event
.
equals
(
Event
(
period
=
100
,
duration
=
5
,
t0
=
10
),
t0_durations
=
2
))
event
.
equals
(
Event
(
period
=
100
,
duration
=
5
,
t0
=
10
),
t0_durations
=
2
))
if
__name__
==
'
__main__
'
:
if
__name__
==
"
__main__
"
:
absltest
.
main
()
absltest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment