Skip to content

Commit

Permalink
update change log; fix print usage; more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sbailey committed Sep 25, 2020
1 parent b3659a8 commit ed967e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Change Log
3.0.4 (unreleased)
------------------

* Add `Timer` class to standardize timing reports (PR `#151`_).
* Add `Timer` class to standardize timing reports (PRs `#151`_, `#152`_).

.. _`#151`: https://github.com/desihub/desiutil/pull/151
.. _`#152`: https://github.com/desihub/desiutil/pull/152

3.0.3 (2020-08-04)
------------------
Expand Down
7 changes: 6 additions & 1 deletion py/desiutil/test/test_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ def test_parsetime(self):

@unittest.skipUnless(dateutil_installed, "dateutil not installed")
def test_parsetime_dateutil(self):
"""If dateutil installed, test fancy date string parsing"""
"""If dateutil installed, test ISO-8601 date string parsing
Fancier "Tue Sep 22 13:42:26 PDT 2020" parsing may or may not
work depending upon timezone knowledge of host machine; not
tested or supported for now, but may be re-added later if needed.
"""
# t0 = parsetime("Tue Sep 22 13:42:26 PDT 2020")
# self.assertAlmostEqual(t0, 1600807346.0)
t1 = parsetime("2020-09-22T13:42:26-07:00")
Expand Down
4 changes: 2 additions & 2 deletions py/desiutil/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ def cancel(self, name):
isotime = datetime.datetime.fromtimestamp(t1).isoformat()
if name in self.timers:
dt = t1 - self.timers[name]['start']
print(self._prefix('CANCEL'), f'Canceling timer {name} at {isotime} after {dt:.2f} seconds')
self._print('CANCEL', f'Canceling timer {name} at {isotime} after {dt:.2f} seconds')
del self.timers[name]
else:
print(self._prefix('WARNING'), f'Attempt to cancel non-existent timer {name} at {isotime}')
self._print('WARNING', f'Attempt to cancel non-existent timer {name} at {isotime}')

@contextmanager
def time(self, name):
Expand Down

0 comments on commit ed967e4

Please sign in to comment.