Skip to content

np.ma.count and np.ma.copy on list input #8019

@MSeifert04

Description

@MSeifert04

The np.ma.count and np.ma.copy behave strangly if the input is a list or tuple (probably also other python builtins).

>>> np.ma.copy([1,2,3])  # unexpected behaviour
[1, 2, 3]

>>> np.copy([1,2,3])  # expected behaviour
array([1, 2, 3])

>>> np.ma.count([1,2,3])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Programming\Anaconda\envs\test\lib\site-packages\numpy\ma\core.py", line 6389, in __call__
    return method(*args, **params)
TypeError: count() takes exactly one argument (0 given)

The reason for this behaviour is that list has a count and copy method and np.ma._frommethod tries to call it instead of np.ma.MaskedArray.count (and copy).

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