Skip to content

scipy.statsbinned_statistic_2d: incorrect binnumbers returned #7010

@pbranson

Description

@pbranson

For certain inputs binned_statistic_2d returns incorrect bin numbers

xEdges = np.arange(79950.,500050.,100.)
yEdges = np.arange(7489950.,7860050.,100.)
x = 356643.378
y = 7813944.500
binned, xedges, yedges, binnums = binned_statistic_2d((x,), (y,), (0.5,), 'mean', bins=[xEdges,yEdges],expand_binnumbers=True)

The binnums seem to be incorrect:
> binnums Returns: array([[3678], [1291]])
> np.where(np.isfinite(binned)) Returns: (array([2766]), array([3239]))

I worked around this using the following code to calculate the bin numbers:

x_inds = np.searchsorted(xEdges, x)
y_inds = np.searchsorted(yEdges , y)

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.stats

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions