[Numpy-discussion] creating a masked array with a sequence containing a masked scalar array

Michael Sorich michael.sorich at gmail.com
Tue Sep 12 02:38:55 CDT 2006


It seems that ma.array does not accept a sequence which contains a
masked scalar array (not sure if this is the correct term). Is this
deliberate?

#numpy 1.0b5, python 2.3.x, winXP
import numpy as N
print N.ma.array([1,2,3, N.ma.array(1, mask=True)])

Traceback (most recent call last):
  File "C:\eclipse\plugins\org.python.pydev.debug_1.2.2\pysrc\pydevd_comm.py",
line 529, in doIt
    result = pydevd_vars.evaluateExpression( self.thread_id,
self.frame_id, self.expression, self.doExec )
  File "C:\eclipse\plugins\org.python.pydev.debug_1.2.2\pysrc\pydevd_vars.py",
line 258, in evaluateExpression
    exec expression in frame.f_globals, frame.f_locals
  File "<string>", line 1, in ?
  File "C:\Python23\Lib\site-packages\numpy\core\ma.py", line 562, in __init__
    c = numeric.array(data, dtype=tc, copy=True, order=order)
TypeError: an integer is required

#works fine if scalar masked array is not masked
print N.ma.array([1,2,3, N.ma.array(1)])

[1 2 3 1]




More information about the Numpy-discussion mailing list