Skip to content

Commit

Permalink
Merge pull request #33 from scipp/scipp-0.14
Browse files Browse the repository at this point in the history
Fixes for scipp-0.14
  • Loading branch information
SimonHeybrock authored Jun 1, 2022
2 parents fbb4822 + 606a58a commit e79af12
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
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, )


def test_event_data_field_dims_labels(nxroot):
Expand Down

0 comments on commit e79af12

Please sign in to comment.