Skip to content

Conversation

sjvenditto
Copy link
Collaborator

Complementing the drop_info() method, a restrict_info() method has been added to all objects with metadata. This method allows you to specify which metadata columns to keep, dropping all other metadata columns. For TsGroup objects, rate will always be kept even if it is not specified.

>>> import pynapple as nap
>>> import numpy as np
>>> tmp = {0:nap.Ts(t=np.arange(0,200), time_units='s'),
... 1:nap.Ts(t=np.arange(0,200,0.5), time_units='s'),
... 2:nap.Ts(t=np.arange(0,300,0.25), time_units='s'),
... }
>>> metadata = {"l1": [1, 2, 3], "l2": ["x", "x", "y"], "l3": [4, 5, 6]}
>>> tsgroup = nap.TsGroup(tmp,metadata=metadata)
>>> print(tsgroup)
  Index     rate    l1  l2      l3
-------  -------  ----  ----  ----
      0  0.66722     1  x        4
      1  1.33445     2  x        5
      2  4.00334     3  y        6

>>> tsgroup.restrict_info(["l2", "l3"])
>>> tsgroup
  Index     rate  l2      l3
-------  -------  ----  ----
      0  0.66722  x        4
      1  1.33445  x        5
      2  4.00334  y        6

Class-specific docstring examples have been added, as well as a new section under the Metadata user guide page in the docs

@sjvenditto sjvenditto requested a review from gviejo as a code owner July 30, 2025 16:53
Copy link

codecov bot commented Jul 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
pynapple/core/interval_set.py 97.13% <100.00%> (+0.02%) ⬆️
pynapple/core/metadata_class.py 92.42% <100.00%> (+0.31%) ⬆️
pynapple/core/time_series.py 93.33% <100.00%> (+0.02%) ⬆️
pynapple/core/ts_group.py 92.93% <100.00%> (+0.04%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gviejo gviejo merged commit b6d8076 into dev Sep 9, 2025
16 checks passed
@gviejo gviejo deleted the restrict_info branch September 9, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants