Skip to content

Commit

Permalink
Fixing __repr__ for fastplotlib
Browse files Browse the repository at this point in the history
  • Loading branch information
gviejo committed Oct 31, 2023
1 parent c2976b5 commit 941e918
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions pynapple/core/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: gviejo
# @Date: 2022-01-27 18:33:31
# @Last Modified by: Guillaume Viejo
# @Last Modified time: 2023-10-30 16:43:22
# @Last Modified time: 2023-10-31 19:13:54

"""
Expand Down Expand Up @@ -772,7 +772,7 @@ def get(self, start, end=None, time_units="s"):

if end is None:
start = TsIndex.format_timestamps(np.array([start]), time_units)[0]
idx = np.searchsorted(time_array, start)
idx = int(np.searchsorted(time_array, start))
if idx == 0:
return self[idx]
elif idx >= self.shape[0]:
Expand Down Expand Up @@ -903,7 +903,10 @@ def create_str(array):
for i, array in zip(self.index[0:5], self.values[0:5]):
_str_.append([i.__repr__(), create_str(array)])
_str_.append(["...", ""])
for i, array in zip(self.index[-5:], self.values[-5:]):
for i, array in zip(
self.index[-5:],
self.values[self.values.shape[0] - 5 : self.values.shape[0]],
):
_str_.append([i.__repr__(), create_str(array)])

return tabulate(_str_, headers=headers, colalign=("left",)) + "\n" + bottom
Expand Down Expand Up @@ -1109,7 +1112,12 @@ def __repr__(self):
for i, array in zip(self.index[0:5], self.values[0:5, 0:max_cols]):
table.append([i] + [k for k in array] + end)
table.append(["..."])
for i, array in zip(self.index[-5:], self.values[-5:, 0:max_cols]):
for i, array in zip(
self.index[-5:],
self.values[
self.values.shape[0] - 5 : self.values.shape[0], 0:max_cols
],
):
table.append([i] + [k for k in array] + end)
return tabulate(table, headers=headers) + "\n" + bottom
else:
Expand Down Expand Up @@ -1363,7 +1371,10 @@ def __repr__(self):
for i, v in zip(self.index[0:5], self.values[0:5]):
table.append([i, v])
table.append(["..."])
for i, v in zip(self.index[-5:], self.values[-5:]):
for i, v in zip(
self.index[-5:],
self.values[self.values.shape[0] - 5 : self.values.shape[0]],
):
table.append([i, v])

return (
Expand Down

0 comments on commit 941e918

Please sign in to comment.