Median calling ndarray.partition: AttributeError

Issue #12 resolved
Former user created an issue

Calling the median over an ndarray raises an AttributeError:

>>>> import numpy as np
>>>> foo = np.zeros((1,5))
>>>> np.median(foo)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ester/PhD/pypy2/site-packages/numpy/lib/function_base.py", line 2703, in median
    part = partition(a, (sz - 1) // 2, axis=axis)
  File "/home/ester/PhD/pypy2/site-packages/numpy/core/fromnumeric.py", line 619, in partition
    a.partition(kth, axis=axis, kind=kind, order=order)
AttributeError: 'numpy.ndarray' object has no attribute 'partition'
>>>> np.__version__
'1.8.1'

Comments (5)

  1. Maksym Ganenko

    The same error with numpy.percentile(..)

    >>>> import numpy as np
    >>>> x = np.array([1,2,3])
    >>>> np.percentile(x, 75)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/root/pypy-2.6-linux_x86_64-portable/site-packages/numpy/lib/function_base.py", line 3042, in percentile
        interpolation=interpolation)
      File "/root/pypy-2.6-linux_x86_64-portable/site-packages/numpy/lib/function_base.py", line 2791, in _ureduce
        r = func(a, **kwargs)
      File "/root/pypy-2.6-linux_x86_64-portable/site-packages/numpy/lib/function_base.py", line 3130, in _percentile
        ap.partition(concatenate((indices_below, indices_above)), axis=axis)
    AttributeError: 'numpy.ndarray' object has no attribute 'partition'
    >>>> np.__version__
    '1.9.0'
    
  2. Terry Jones

    I've hit the same issue (np.version 1.10.0). I tried using overwrite_input=True just in case it helped, but it doesn't.

    It doesn't feel like this should be a hard problem to fix, but I know nothing about numpy/pypy so don't know where to look. Any hints?

  3. Log in to comment