Skip to content

Commit

Permalink
Merge pull request #37 from scipp/future-scipp-support
Browse files Browse the repository at this point in the history
Avoid deprecation warnings in scipp dev builds and next release
  • Loading branch information
SimonHeybrock authored Jun 21, 2022
2 parents f3184b6 + cb9c68c commit 978b3b6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/scippnexus/nxdetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
from .nxevent_data import NXevent_data


def group(da: sc.DataArray, groups: sc.Variable) -> sc.DataArray:
if hasattr(da, 'group'):
return da.group(groups)
else:
return sc.bin(da, groups=[groups])


class EventSelector:
"""A proxy object for creating an NXdetector based on a selection of events.
"""
Expand Down Expand Up @@ -95,7 +102,7 @@ def __getitem__(self, select: ScippIndex) -> sc.DataArray:
# is contiguous and that there is no masking. We can therefore use the
# more efficient approach of binning from scratch instead of erasing the
# 'pulse' binning defined by NXevent_data.
event_data = sc.bin(event_data.bins.constituents['data'], groups=[event_id])
event_data = group(event_data.bins.constituents['data'], groups=event_id)
if self._grouping is None:
event_data.coords[self._grouping_key] = event_data.coords.pop('event_id')
else:
Expand Down

0 comments on commit 978b3b6

Please sign in to comment.