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

make untyped dataset of references expandable #1188

Merged
merged 6 commits into from
Oct 23, 2024
Merged

Conversation

stephprince
Copy link
Contributor

@stephprince stephprince commented Sep 5, 2024

Motivation

Fix #1181

To do:

  • add tests

How to test the behavior?

from datetime import datetime
from uuid import uuid4
from dateutil import tz

from pynwb import NWBHDF5IO, NWBFile, H5DataIO

session_start_time = datetime(2018, 4, 25, 2, 30, 3, tzinfo=tz.gettz("US/Pacific"))

# setup NWBFile
nwbfile = NWBFile(
    session_description="Mouse exploring an open field",  # required
    identifier=str(uuid4()),  # required
    session_start_time=session_start_time,  # required
)

# add column
device = nwbfile.create_device(name="array", description="an array", manufacturer="company")

# create an electrode group
electrode_group = nwbfile.create_electrode_group(
    name="shank0",
    description="electrode group for shank 0",
    device=device,
    location="brain area",
)

# add electrode to the electrode table
nwbfile.add_electrode(group=electrode_group, location="brain area",)
nwbfile.electrodes.id.set_data_io(H5DataIO, {'maxshape': (None,), 'chunks': True})
nwbfile.electrodes.group.set_data_io(H5DataIO, {'maxshape': (None,), 'chunks': True})
nwbfile.electrodes.group_name.set_data_io(H5DataIO, {'maxshape': (None,), 'chunks': True})
nwbfile.electrodes.location.set_data_io(H5DataIO, {'maxshape': (None,), 'chunks': True})

with NWBHDF5IO("test_append_electrodes_table.nwb", "w") as io:
    io.write(nwbfile)

with NWBHDF5IO("test_append_electrodes_table.nwb", mode="a") as io:
    nwbfile = io.read()
    electrode_group = nwbfile.electrode_groups["shank0"]
    
    nchannels = 4
    for ielec in range(nchannels):
        nwbfile.add_electrode(
            group=electrode_group,
            location="brain area",
        )

    io.write(nwbfile)

with NWBHDF5IO("test_append_electrodes_table.nwb", "r") as io:
    nwbfile = io.read()
    print(nwbfile.electrodes.to_dataframe())

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Does the PR clearly describe the problem and the solution?
  • Have you reviewed our Contributing Guide?
  • Does the PR use "Fix #XXX" notation to tell GitHub to close the relevant issue numbered XXX when the PR is merged?

@stephprince
Copy link
Contributor Author

@mavaylon1 These are the changes related to our issue triaging that we will discuss testing set up for next week.

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.03%. Comparing base (dedc1dd) to head (d068f8e).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1188   +/-   ##
=======================================
  Coverage   89.03%   89.03%           
=======================================
  Files          45       45           
  Lines        9883     9887    +4     
  Branches     2813     2815    +2     
=======================================
+ Hits         8799     8803    +4     
  Misses        767      767           
  Partials      317      317           

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

@stephprince stephprince marked this pull request as ready for review October 16, 2024 21:55
@mavaylon1 mavaylon1 merged commit b7a5fe2 into dev Oct 23, 2024
29 checks passed
@mavaylon1 mavaylon1 deleted the expand-untyped-ref-dset branch October 23, 2024 22:58
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]: untyped dataset of references cannot be set as expandable
2 participants