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

Add optional parameters to OpticalSeries constructor #2023

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

bendichter
Copy link
Contributor

fix #1616

Motivation

The OpticalSeries class in PyNWB currently requires the fields 'distance', 'orientation', and 'field_of_view' in its constructor, but according to the NWB schema these fields should be optional. This PR fixes this discrepancy by making these fields optional in the code to match the schema specification.

How to test the behavior?

from pynwb.image import OpticalSeries

# Create OpticalSeries without the optional fields
optical_series = OpticalSeries(
    name='test_optical_series',
    data=np.ones((2, 2, 2)),  # example data
    unit='pixels',
    timestamps=[1.0, 2.0]
)

# All these fields should be None
assert optical_series.distance is None
assert optical_series.field_of_view is None
assert optical_series.orientation is None

Checklist

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

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.32%. Comparing base (c0ba7e1) to head (add7b31).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2023      +/-   ##
==========================================
- Coverage   91.73%   91.32%   -0.41%     
==========================================
  Files          27       27              
  Lines        2722     2722              
  Branches      710      710              
==========================================
- Hits         2497     2486      -11     
- Misses        149      159      +10     
- Partials       76       77       +1     
Flag Coverage Δ
integration 72.55% <ø> (-0.41%) ⬇️
unit 82.40% <ø> (+0.11%) ⬆️

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.

format="external",
timestamps=[1.0, 2.0],
)
self.assertIsNone(ts.distance)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a roundtrip test to make sure read/write is ok?

self.assertIsNone(ts.field_of_view)
self.assertIsNone(ts.orientation)

def test_roundtrip_optional_fields(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this test to tests/integration/hdf5/test_image.py with the other roundtrip image tests?

This test is currently failing in Windows due to a file access issue. The NWBH5IOMixin could also be used to simplify the file setup for read/write testing.

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]: OpticalSeries distance, orientation, and field of view should be optional
2 participants