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

Change epoch tags to property #1935

Merged
merged 6 commits into from
Jul 18, 2024
Merged

Change epoch tags to property #1935

merged 6 commits into from
Jul 18, 2024

Conversation

stephprince
Copy link
Contributor

@stephprince stephprince commented Jul 18, 2024

Motivation

epoch_tags could be assigned in the NWBFile constructor, but it was never written to disk. It could also be out of sync with the epochs table. It seems that it was maybe originally meant to be a shortcut for getting all of the unique epoch tags from the epochs table.

As a side effect of this change, epoch_tags would no longer be displayed by __repr__ or _repr_html_ (I looked a little into getting it to display, but if we include properties in the reprs it makes several other different datatype print outs less clean).

See related discussion about deprecating here: #1521 (comment)

How to test the behavior?

from datetime import datetime
from dateutil.tz import tzlocal
from pynwb import NWBFile, NWBHDF5IO

nwbfile = NWBFile(
    session_id='test',
    session_description='test',
    identifier='12345',
    session_start_time=(
        datetime.now(tzlocal())
    ),
)
nwbfile.add_epoch(start_time=1.0, stop_time=10.0, tags=["tag1", "tag2"])
nwbfile.add_epoch(start_time=10.0, stop_time=20.0, tags=["tag1", "tag3"])
nwbfile.add_epoch(start_time=1.0, stop_time=10.0, tags="tag4")
print(f'memory: {nwbfile.epoch_tags}').  # memory: {'tag3', 'tag1', 'tag4', 'tag2'}

path = 'test1.nwb'
with NWBHDF5IO(path, 'w') as io:
    io.write(nwbfile)

with NWBHDF5IO(path, 'r') as io:
    nwb_read = io.read()
    print(f'disk: {nwb_read.epoch_tags}'). # disk: {'tag3', 'tag1', 'tag4', 'tag2'}

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Have you checked our Contributing document?
  • Have you ensured the PR clearly describes the problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running ruff check . && codespell from the source directory.
  • Have you checked to ensure that there aren't other open Pull Requests for the same change?
  • Have you included the relevant issue number using "Fix #XXX" notation where XXX is the issue number? By including "Fix #XXX" you allow GitHub to close issue #XXX when the PR is merged.

Copy link

codecov bot commented Jul 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.20%. Comparing base (a9f6332) to head (bc716a9).
Report is 16 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1935   +/-   ##
=======================================
  Coverage   92.20%   92.20%           
=======================================
  Files          27       27           
  Lines        2656     2656           
  Branches      693      693           
=======================================
  Hits         2449     2449           
  Misses        134      134           
  Partials       73       73           
Flag Coverage Δ
integration 73.15% <66.66%> (ø)
unit 83.77% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stephprince stephprince requested a review from rly July 18, 2024 16:14
@stephprince stephprince marked this pull request as ready for review July 18, 2024 20:58
@stephprince stephprince merged commit fcd7008 into dev Jul 18, 2024
25 checks passed
@stephprince stephprince deleted the write-epoch-tags branch July 18, 2024 20:59
bjhardcastle added a commit to AllenInstitute/npc_sessions that referenced this pull request Sep 20, 2024
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.

[Bug]: epoch_tags not written to disk [Bug]: EpochTags
2 participants