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

Fixes for scipp-0.14 #33

Merged
merged 4 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ python-dateutil==2.8.2
# via -r requirements/base.in
pyyaml==6.0
# via confuse
scipp==0.13.1
scipp==0.14.0
# via -r requirements/base.in
scipy==1.8.0
# via -r requirements/base.in
Expand Down
2 changes: 1 addition & 1 deletion src/scippnexus/nxevent_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _getitem(self, select: ScippIndex) -> sc.DataArray:

try:
binned = sc.bins(data=events, dim=_event_dimension, begin=begins, end=ends)
except sc.SliceError as e:
except IndexError as e:
raise IndexError(
f"Invalid index in NXevent_data at {self.name}/event_index:\n{e}.")

Expand Down
10 changes: 10 additions & 0 deletions tests/nexus_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,16 @@ def test_negative_event_index_converted_to_num_event(nxroot):
assert events.bins.size().values[3] == 0


def test_bad_event_index_raises_IndexError(nxroot):
event_data = nxroot['entry'].create_class('events_0', NX_class.NXevent_data)
event_data['event_id'] = sc.array(dims=[''], unit=None, values=[1, 2, 4, 1, 2])
event_data['event_time_offset'] = sc.array(dims=[''], unit='s', values=[0, 0, 0, 0])
event_data['event_time_zero'] = sc.array(dims=[''], unit='s', values=[1, 2, 3, 4])
event_data['event_index'] = sc.array(dims=[''], unit=None, values=[0, 3, 3, 666])
with pytest.raises(IndexError):
nxroot['entry/events_0'][...]


def create_event_data_without_event_id(group):
group['event_time_offset'] = sc.array(dims=[''],
unit='s',
Expand Down
4 changes: 2 additions & 2 deletions tests/nxdetector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ def test_loading_event_data_with_full_selection_and_automatic_detector_numbers_w
detector = nxroot.create_class('detector0', NX_class.NXdetector)
create_event_data_ids_1234(detector.create_class('events', NX_class.NXevent_data))
assert detector.dims == ['detector_number']
assert detector[...].shape == [4]
assert detector[()].shape == [4]
assert tuple(detector[...].shape) == (4, )
assert tuple(detector[()].shape) == (4, )
Copy link
Member

Choose a reason for hiding this comment

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

Looks odd. Why does this convert the LHS to a tuple and then test with a tuple on the RHS? Looks like the LHS should have already been a tuple to warrant a change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because we are running tests against both the latest (current frozen) scipp as well as an old version of scipp (which still gives a list).



def test_event_data_field_dims_labels(nxroot):
Expand Down