From fd24a863d0e44b6244b4667ea6474e8fdc89183e Mon Sep 17 00:00:00 2001 From: Guillaume Viejo Date: Wed, 20 Nov 2024 16:02:33 -0500 Subject: [PATCH] smallc hanges --- doc/user_guide/04_core_methods.md | 7 ++++--- pynapple/core/interval_set.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/user_guide/04_core_methods.md b/doc/user_guide/04_core_methods.md index 8b61438a..0f7b3559 100644 --- a/doc/user_guide/04_core_methods.md +++ b/doc/user_guide/04_core_methods.md @@ -353,7 +353,7 @@ print( ## Metadata Metadata can be added to `TsGroup`, `IntervalSet`, and `TsdFrame` objects at initialization or after an object has been created. - `TsGroup` metadata is information associated with each Ts/Tsd object, such as brain region or unit type. -- `IntervalSet` metadata is information assocaited with each interval, such as a trial label or stimulus condition. +- `IntervalSet` metadata is information associated with each interval, such as a trial label or stimulus condition. - `TsdFrame` metadata is information associated with each column, such as a channel or position. @@ -487,8 +487,9 @@ print(tsgroup.get_info("region")) ### Metadata properties User-set metadata is mutable and can be overwritten. ```{code-cell} ipython3 +print(tsgroup, "\n") tsgroup.set_info(region=["A","B","C"]) -print(tsgroup.get_info("region")) +print(tsgroup) ``` If the metadata name does not overlap with an existing class column, it can be set and accessed via key indexing (i.e. using square brackets). @@ -514,7 +515,7 @@ tsgroup.coords = [[1,0],[0,1],[1,1]] print(tsgroup.coords) ``` -### Filtering +### Using metadata to slice object Metadata can be used to filter or threshold objects based on metadata values. ```{code-cell} ipython3 print(tsgroup[tsgroup.unit_type == "good"]) diff --git a/pynapple/core/interval_set.py b/pynapple/core/interval_set.py index 3f6eda0c..a1ab06be 100644 --- a/pynapple/core/interval_set.py +++ b/pynapple/core/interval_set.py @@ -47,10 +47,12 @@ class IntervalSet(NDArrayOperatorsMixin, _MetadataMixin): The `IntervalSet` object behaves like a numpy ndarray with the limitation that the object is not mutable. If start and end are not aligned, meaning that: + 1. len(start) != len(end) 2. end[i] > start[i] 3. start[i+1] > end[i] 4. start and end are not sorted, + IntervalSet will try to "fix" the data by eliminating some of the start and end data points. Parameters