[Numpy-discussion] Rationale for returning type-wrapped min() / max() scalars? (was: Problem with ufunc of a numpy.ndarray derived class)

eat e.antero.tammi at gmail.com
Sun Jul 31 13:44:06 EDT 2011


Hi,

On Sun, Jul 31, 2011 at 7:36 PM, Charles R Harris <charlesr.harris at gmail.com
> wrote:

>
>
> On Sun, Jul 31, 2011 at 12:50 AM, Hans Meine <
> meine at informatik.uni-hamburg.de> wrote:
>
>> Am 29.07.2011 um 20:23 schrieb Nathaniel Smith:
>> > Even so, surely this behavior should be consistent between base class
>> > ndarrays and subclasses? If returning 0d arrays is a good idea, then
>> > we should do it everywhere. If it's a bad idea, then we shouldn't do
>> > it at all...?
>>
>> Very well put.  That's exactly the reason why I am insisting on this
>> discussion, and why I believe that the behavior change is not intentional.
>>  Otherwise, ndarray and matrix should behave like my subclass.  (BTW: I did
>> not check masked_array yet.)
>>
>> > (In reality, it sounds like this might be some mishap in the
>> > __array_wrap__ mechanism?)
>>
>> That's exactly my guess.  (That could also explain why Mark did not see
>> anything obvious in the code.)
>>
>>
> Maybe. There isn't a problem for plain old zero dimensional arrays.
>
> In [1]: a = array(1)
>
> In [2]: a.dtype
> Out[2]: dtype('int64')
>
> In [3]: reshape(a, (1,1), order='f')
> Out[3]: array([[1]])
>
FWIW:
In []: sys.version
Out[]: '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'
In []: np.version.version
Out[]: '1.6.0'

In []: a= array(1)

In []: a.reshape((1, 1), order= 'F').flags
Out[]:
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

In []: a.reshape((1, 1), order= 'C').flags
Out[]:
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

Seems to be slightly inconsistent, but does it really matter?

-eat

>
> This on Linux 64 with latest master.
>
> Chuck
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110731/72eaf833/attachment.html>


More information about the NumPy-Discussion mailing list