Skip to content

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

Closed

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).

Activity

  1. added a commit that references this issue on Feb 22, 2017
    0a47600
  2. added a commit that references this issue on Mar 4, 2017
    6a1a029
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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