Skip to content

Confusing error message from binning empty data #3209

@YooSunYoung

Description

@YooSunYoung

When binning is attempted on an empty data, it's throwing BinEdgeError with the error message Bin edges in dim {coord-name} must be sorted..

Maybe it should catch the error earlier and throw a more specific error.

Code snippet to reproduce this error is below the image.

image

Code snippet to reproduce the issue

import scipp as sc
import numpy as np
rng = np.random.default_rng(123)
da = sc.DataArray(data=sc.ones(sizes={"row": 1000}, unit="counts"),
                  coords={'longi': sc.array(dims=['row'], values=rng.random(1000)),
                          'lati': sc.array(dims=['row'], values=rng.random(1000)),
                          'time': sc.array(dims=['row'], values=rng.random(1000))})
empty_b = da.bin(lati=sc.array(dims=['lati'], values=[0.0, 1.2, 2.0]))['lati', 1]
empty_b.bin(longi=10)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions