Skip to content

Commit

Permalink
Fixing method of determining if value is numpy (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenkehoe authored Mar 17, 2023
1 parent c082d3f commit e4919a1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions act/plotting/timeseriesdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,16 @@ def set_xrng(self, xrng, subplot_index=(0,)):
# If the xlim is set to the same value for range it will throw a warning
# This is to catch that and expand the range so we avoid the warning.
if xrng[0] == xrng[1]:
if isinstance(xrng[0], np.ndarray) and np.issubdtype(xrng[0].dtype, np.datetime64):
if isinstance(xrng[0], np.datetime64):
print(f'\nAttempting to set xlim range to single value {xrng[0]}. '
'Expanding range by 2 seconds.\n')
xrng[0] = xrng[0] - np.timedelta64(1, 's')
xrng[1] = xrng[1] + np.timedelta64(1, 's')
xrng[0] -= np.timedelta64(1, 's')
xrng[1] += np.timedelta64(1, 's')
elif isinstance(xrng[0], dt.datetime):
print(f'\nAttempting to set xlim range to single value {xrng[0]}. '
'Expanding range by 2 seconds.\n')
xrng[0] = xrng[0] - dt.timedelta(seconds=1)
xrng[1] = xrng[1] + dt.timedelta(seconds=1)
xrng[0] -= dt.timedelta(seconds=1)
xrng[1] += dt.timedelta(seconds=1)

self.axes[subplot_index].set_xlim(xrng)

Expand Down

0 comments on commit e4919a1

Please sign in to comment.