scipp / scipp/scipp

Exceptions with strided coords in `bin`

Open
#3,660 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
146
Forks
23
Avg merge
2d 7h
Merged PRs (30d)
7

Description

Similar to #3255, scipp.bin still raises DimensionError: View over subspan can only be created for contiguous range of data. in some cases. Minimal example:

import scipp as sc


def make_vec_components(scale: sc.Variable) -> dict[str, sc.Variable]:
    vec = scale * sc.vector(value=[1, 2, 3], unit='m')
    return {'x': vec.fields.x, 'y': vec.fields.y, 'z': vec.fields.z}


scale = sc.linspace('point', 0.0, 1.0, num=10)

da = sc.DataArray(sc.ones_like(scale), coords={'scale': scale})
da = da.transform_coords(('x', 'y', 'z'), graph={('x', 'y', 'z'): make_vec_components})
da.hist(x=2)  # ok
da.bin(x=2)  # exception
da.hist(x=2, y=2)  # exception since using `bin` internally

Originally reported in scipp/scippneutron#603.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal Python example in the issue and compare the successful hist(x=2) call with bin(x=2) and hist(x=2, y=2). Trace the bin path involved in handling transformed, strided coordinates; done means bin no longer raises DimensionError and the two-dimensional hist case also succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.