Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to have a Tsd as an index #314

Merged
merged 35 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
daf4de7
rebased
vigji Jul 15, 2024
7747547
Update pynapple/core/time_series.py
vigji Jul 23, 2024
1c1f290
Merge branch 'dev' into tsdataframe-index
vigji Jul 23, 2024
a77978a
blacked
vigji Jul 23, 2024
19ce7a5
Fixed test error
vigji Jul 26, 2024
869226b
TsdBase instead of Tsd
vigji Jul 26, 2024
4b33f23
added tests
vigji Aug 1, 2024
81ac533
added tests for tsd
vigji Aug 1, 2024
fc043d3
added tests for __setitem__ and fixed bug
vigji Aug 1, 2024
d0493bb
fixed commit bug
vigji Aug 1, 2024
6d07a63
blacked
vigji Aug 2, 2024
9222129
Merge remote-tracking branch 'upstream/dev' into tsdataframe-index
vigji Sep 27, 2024
03bbc3b
TsdTensor tests
vigji Sep 27, 2024
958f773
TsdTensor tests cleaned
vigji Sep 27, 2024
5cdfecb
TsdTensor tests cleaned
vigji Sep 27, 2024
a162e1d
gitignore
vigji Sep 27, 2024
4c26b8e
test setitem
vigji Sep 27, 2024
2a82110
renamed test classes for readability
vigji Sep 27, 2024
bba00d6
blacked
vigji Sep 27, 2024
2400690
fix test
vigji Sep 27, 2024
ba1d074
removed print
vigji Sep 28, 2024
1e34264
removed print
vigji Sep 28, 2024
3b3a096
fixed typo
vigji Sep 28, 2024
30ff051
Update pynapple/core/time_series.py
vigji Oct 3, 2024
b4e63e6
Update pynapple/core/time_series.py
vigji Oct 3, 2024
98b7214
added some plots to glm
vigji Oct 8, 2024
b25651e
Update pynapple/core/time_series.py
vigji Oct 17, 2024
9d96d37
Merge branch 'tsdataframe-index' of https://github.com/iurillilab/pyn…
vigji Oct 17, 2024
fce007e
fix
vigji Oct 17, 2024
79b4871
removed args, kwargs
vigji Oct 17, 2024
2631af6
blacked
vigji Oct 17, 2024
a7f6c04
added check on timeseries
vigji Nov 5, 2024
86eceb4
fixed tests
vigji Nov 5, 2024
cd42c02
Merge remote-tracking branch 'upstream/dev' into tsdataframe-index
vigji Nov 5, 2024
4c912c7
fixed tests after merging
vigji Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pynapple/core/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def __init__(self, t, d, time_units="s", time_support=None, load_array=True):

def __setitem__(self, key, value):
"""setter for time series"""
if isinstance(key, Tsd):
vigji marked this conversation as resolved.
Show resolved Hide resolved
key = key.d
try:
self.values.__setitem__(key, value)
except IndexError:
Expand Down Expand Up @@ -1237,14 +1239,18 @@ def __repr__(self):
return tabulate([], headers=headers) + "\n" + bottom

def __getitem__(self, key, *args, **kwargs):
vigji marked this conversation as resolved.
Show resolved Hide resolved
if isinstance(key, Tsd):
vigji marked this conversation as resolved.
Show resolved Hide resolved
key = key.d

output = self.values.__getitem__(key)

if isinstance(key, tuple):
index = self.index.__getitem__(key[0])
elif isinstance(index, Number):
index = np.array([index])
vigji marked this conversation as resolved.
Show resolved Hide resolved
else:
index = self.index.__getitem__(key)

if isinstance(index, Number):
index = np.array([index])


if all(is_array_like(a) for a in [index, output]):
if output.shape[0] == index.shape[0]:
Expand Down
6 changes: 4 additions & 2 deletions pynapple/io/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .suite2p import Suite2P


def load_file(path):
def load_file(path, lazy_loading=True):
"""Load file. Current format supported is (npz,nwb,)

.npz -> If the file is compatible with a pynapple format, the function will return a pynapple object.
Expand All @@ -34,6 +34,8 @@ def load_file(path):
----------
path : str
Path to the file
lazy_loading : bool
Lazy loading of the data, used only for NWB files

Returns
-------
Expand All @@ -49,7 +51,7 @@ def load_file(path):
if path.endswith(".npz"):
return NPZFile(path).load()
elif path.endswith(".nwb"):
return NWBFile(path)
return NWBFile(path, lazy_loading=lazy_loading)
else:
raise RuntimeError("File format not supported")
else:
Expand Down
Loading