[Numpy-discussion] numpy.all docstring reality check

Benjamin Root ben.root@ou....
Thu Jul 1 23:51:21 CDT 2010


This behavior is quite curious.  While it is consistent and it behaves
exactly as documented (after clarification), I am curious about the
rational.  Is it merely an unavoidable consequence of passing in the output
array?

Certainly a few examples from the above emails would make this extremely
clear.  I particularly liked the 'a3' dtype example.

Ben Root

On Tue, Jun 29, 2010 at 9:38 PM, David Goldsmith <d.l.goldsmith@gmail.com>wrote:

> OK, now I understand: dtype(out) is preserved, whatever that happens to be,
> not dtype(a) (which is what I thought it meant) - I better clarify.  Thanks!
>
> DG
>
>
> On Tue, Jun 29, 2010 at 7:28 PM, Skipper Seabold <jsseabold@gmail.com>wrote:
>
>> On Tue, Jun 29, 2010 at 8:50 PM, David Goldsmith
>> <d.l.goldsmith@gmail.com> wrote:
>> > Hi, folks.  Under Parameters, the docstring for
>> numpy.core.fromnumeric.all
>> > says:
>> >
>> > "out : ndarray, optionalAlternative output array in which to place the
>> > result. It must have the same shape as the expected output and the type
>> is
>> > preserved." [emphasis added].I assume this is a
>> > copy-and-paste-from-another-docstring "typo" (shouldn't it be (possibly
>> > ndarray of) bool), but I just wanted to double check.
>> >
>>
>> Looks right to me though there is no
>>
>> In [255]: a = np.ones(10)
>>
>> In [256]: b = np.empty(1,dtype=int)
>>
>> In [257]: np.core.fromnumeric.all(a,out=b)
>> Out[257]: array([1])
>>
>> In [258]: b.dtype
>> Out[258]: dtype('int64')
>>
>> In [259]: b = np.empty(1,dtype=bool)
>>
>> In [260]: np.core.fromnumeric.all(a,out=b)
>> Out[260]: array([ True], dtype=bool)
>>
>> In [261]: b.dtype
>> Out[261]: dtype('bool')
>>
>> In [262]: b = np.empty(1)
>>
>> In [263]: np.core.fromnumeric.all(a,out=b)
>> Out[263]: array([ 1.])
>>
>> In [264]: b.dtype
>> Out[264]: dtype('float64')
>>
>> In [265]: a2 =
>> np.column_stack((np.ones(10),np.ones(10),np.random.randint(0,2,10)))
>>
>> In [266]: b = np.empty(3,dtype=int)
>>
>> In [267]: np.core.fromnumeric.all(a2,axis=0,out=b)
>> Out[267]: array([1, 1, 0])
>>
>> In [268]: b.dtype
>> Out[268]: dtype('int64')
>>
>> This is interesting
>>
>> In [300]: b = np.ones(3,dtype='a3')
>>
>> In [301]: np.core.fromnumeric.all(a2,axis=0,out=b)
>> Out[301]:
>> array(['Tru', 'Tru', 'Fal'],
>>      dtype='|S3')
>>
>> Skipper
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>
>
>
> --
> Mathematician: noun, someone who disavows certainty when their uncertainty
> set is non-empty, even if that set has measure zero.
>
> Hope: noun, that delusive spirit which escaped Pandora's jar and, with her
> lies, prevents mankind from committing a general suicide.  (As interpreted
> by Robert Graves)
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100701/fca337c0/attachment.html 


More information about the NumPy-Discussion mailing list