Skip to content

numpy.nanstd cannot be compatible with quantities #223

Description

@disadone

While running

import quantities as pq
import numpy as np
assert(pq.__version__== '0.14.1')
assert(np.__version__== '1.23.5')
np.nanstd([1.,2.]*pq.ms)

It reports:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/numpy/core/fromnumeric.py", line 2298, in sum
    return _wrapreduction(a, np.add, 'sum', axis, dtype, out, keepdims=keepdims,
  File "/usr/local/lib/python3.10/dist-packages/numpy/core/fromnumeric.py", line 84, in _wrapreduction
    return reduction(axis=axis, out=out, **passkwargs)
TypeError: Quantity.sum() got an unexpected keyword argument 'keepdims'

However

np.mean([1.,2.]*pq.ms)
np.std([1.,2.]*pq.ms)
np.nanmean([1.,2.]*pq.ms)

all works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions