Skip to content

Decision for some __array_function__ overrides #9462

@mhvk

Description

@mhvk

Separating some things out of #8825, since these are important to decide upon before 4.0, since after we cannot seriously change it any more: for a number of numpy functions, a decision still needs to be made, mostly on whether to stick exactly to the numpy docstring or to make adjustments to parameter defaults that make the function more useful for Quantity

  • np.isclose, np.allclose: these were never all that useful since internally they calculate abs(a - b) < atol + rtol * abs(a) and atol is given as a small number, which is interpreted as dimensionless. For Quantity, we could either set it to 0 or assume the units of a, but in either case it would become inconsistent with the docstring that users actually see.
  • np.broadcast_arrays and np.broadcast_to by default return plain arrays, needing subok=True to work for Quantity. We could change the default if a Quantity is present. Again, the possible issue is that the docstring will no longer be correct.

My own sense is to adjust isclose and allclose, since that allows things to "just work". But the question is how (0 or small number times unit of first).

For broadcast*, though, I think there may be code relying on it always returning plain ndarray, so probably it is best not to change the default.

cc @adrn

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions