8000 numpy.average not working with units · Issue #5421 · astropy/astropy · GitHub
[go: up one dir, main page]

Skip to content
numpy.average not working with units #5421
@maxnoe

Description

@maxnoe

While numpy.mean works fine with astropy.units.Quantity, numpy.average does not.

In [1]: import numpy as np

In [2]: import astropy.units as u

In [3]: a = np.linspace(0, 1, 10) * u.meter

In [4]: np.mean(a)
Out[4]: <Quantity 0.5 m>

In [5]: np.average(a)
Out[5]: 0.5

In [6]: b = np.linspace(0, 1, 10) * u.centimeter

In [7]: np.average(a) == np.average(b)
Out[7]: True

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0