On Tue, Sep 29, 2015 at 7:31 PM, Charles R Harris wrote: On Tue, Sep 29, 2015 at 6:58 PM, Chris Barker - NOAA Federal <
chris.barker@noaa.gov> wrote: One of the usecases that has sneaked in during the last few numpy
versions is that object arrays contain numerical arrays where the shapes
don't add up to a rectangular array. I think that's the wrong way to dve that problem -- we really should have
a "proper" ragged array implementation. But is is the easiest way at this
point. For this, and other use-cases, special casing Numpy arrays stored in
object arrays does make sense: "If this is s a Numpy array, pass the operation through." Because we now (development) use rich compare, the result looks like In [1]: a = ones(3) In [2]: b = array([a, -a], object) In [3]: b
Out[3]:
array([[1.0, 1.0, 1.0],
[-1.0, -1.0, -1.0]], dtype=object) In [4]: sign(b)
Out[4]:
array([[1L, 1L, 1L],
[-1L, -1L, -1L]], dtype=object) The function returns long integers in order to not special case Python 3.
Hmm, wonder if we might want to change that. Oops, not what was intended. In fact it raises an error
In [7]: b
Out[7]: array([array([ 1., 1., 1.]), array([-1., -1., -1.])],
dtype=object)
In [8]: sign(b)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-8-3b1a81271d2e> in <module>()
----> 1 sign(b)
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()
Chuck Chuck