Skip to content

Commit ad2e1e4

Browse files
committed
Remove workaround and use new scipp.bin dim arg
1 parent 3d0c1e0 commit ad2e1e4

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

src/ess/powder/grouping.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
33
"""Grouping and merging of pixels / voxels."""
44

5-
import scipp as sc
6-
75
from .types import (
86
DspacingBins,
97
DspacingData,
@@ -14,28 +12,11 @@
1412
)
1513

1614

17-
def _drop_grouping_and_bin(
18-
data: sc.DataArray, *, dims_to_reduce: tuple[str, ...] | None = None, edges: dict
19-
) -> sc.DataArray:
20-
all_pixels = data if dims_to_reduce == () else data.bins.concat(dims_to_reduce)
21-
# all_pixels may just have a single bin now, which currently yields
22-
# inferior performance when binning (no/bad multi-threading?).
23-
# We operate on the content buffer for better multi-threaded performance.
24-
if all_pixels.ndim == 0:
25-
return (
26-
all_pixels.value.bin(**edges)
27-
.assign_coords(all_pixels.coords)
28-
.assign_masks(all_pixels.masks)
29-
)
30-
else:
31-
return all_pixels.bin(**edges)
32-
33-
3415
def focus_data_dspacing(
3516
data: DspacingData[RunType], dspacing_bins: DspacingBins
3617
) -> FocussedDataDspacing[RunType]:
3718
return FocussedDataDspacing[RunType](
38-
_drop_grouping_and_bin(data, edges={dspacing_bins.dim: dspacing_bins})
19+
data.bin({dspacing_bins.dim: dspacing_bins}, dim=data.dims)
3920
)
4021

4122

@@ -45,9 +26,7 @@ def focus_data_dspacing_and_two_theta(
4526
twotheta_bins: TwoThetaBins,
4627
) -> FocussedDataDspacingTwoTheta[RunType]:
4728
return FocussedDataDspacingTwoTheta[RunType](
48-
data.bin({twotheta_bins.dim: twotheta_bins}).bin(
49-
{dspacing_bins.dim: dspacing_bins}
50-
)
29+
data.bin({twotheta_bins.dim: twotheta_bins, dspacing_bins.dim: dspacing_bins})
5130
)
5231

5332

0 commit comments

Comments
 (0)