Skip to content

Commit

Permalink
Avoid deprecation warnings in scipp dev builds and next release
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHeybrock committed Jun 21, 2022
1 parent f3184b6 commit cb9c68c
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 cb9c68c

Please sign in to comment.