On Tue, Sep 29, 2015 at 6:35 PM, Charles R Harris <charlesr.har...@gmail.com
> wrote:

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

exactly -- it seems to me that a special case for numpy arrays as objects
in object arrays makes sense, so you'd get:

In [6]: oa
Out[6]:
array([[1.0, 1.0, 1.0],
       [-1.0, -1.0, -1.0]], dtype=object)

In [7]: np.sign(oa)
Out[7]:
array([[1, 1, 1],
       [-1, -1, -1]], dtype=object)

(which you do now in the version I'm running).

Though rather than the special case, maybe we really need dtype=ndarray
arrays?

 oa = np.array([a1, a2], dtype=np.ndarray)

Then we could count on everything in the array being an array.....

-CHB

-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

chris.bar...@noaa.gov
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to