numpy int64 vs. Integer max/min problem

14 views
Skip to first unread message

Ryan Hinton

unread,
May 29, 2010, 4:58:33 PM5/29/10
to sage-devel
The following results are strange.

sage: import numpy as np
sage: t1 = np.array([3+1])
sage: t2 = t1[0]
sage: t3 = 0
sage: max(t2, t3)
0
sage: min(t2, t3)
4

I get the same results putting t2 and t3 in a tuple for the other max/
min calling convention. But the comparison operator seems to be fine.

sage: t2 > t3
True

Any ideas?

- Ryan

Jason Grout

unread,
May 29, 2010, 5:10:21 PM5/29/10
to sage-...@googlegroups.com


Did you set min and max to be variables? Can you try reset('min,max')

Things work fine for me:

sage: sage: import numpy as np
sage: sage: t1 = np.array([3+1])
sage: sage: t2 = t1[0]
sage: sage: t3 = 0
sage: sage: max(t2, t3)
4
sage: sage: min(t2, t3)
0
sage: version()
'Sage Version 4.4.2, Release Date: 2010-05-19'

(I have one or two patches on top of that, though)

Jason


Ryan Hinton

unread,
May 29, 2010, 5:31:08 PM5/29/10
to sage-devel
I reproduced the error on alpha.sagenb.org.

sage: version()
'Sage Version 4.4.1, Release Date: 2010-05-02'

And the max/min names are not overloaded.

sage: min
<built-in function min>

I agree the behavior is strange. I had a hard time reproducing it at
first. Again, ideas are welcome.

- Ryan

Jason Grout

unread,
May 29, 2010, 6:20:59 PM5/29/10
to sage-...@googlegroups.com
On 5/29/10 4:31 PM, Ryan Hinton wrote:
> sage: import numpy as np
>> > sage: t1 = np.array([3+1])
>> > sage: t2 = t1[0]
>> > sage: t3 = 0
>> > sage: max(t2, t3)
>> > 0
>> > sage: min(t2, t3)

I just reproduced the bug on sagenb.org and an almost-stock 4.4.2
running on linux. However, my stock 4.4.2 (OSX 10.6) (i.e., all patches
popped and sage -br run) still gives:

sage: import numpy as np
sage: t1 = np.array([3+1])
sage: t2 = t1[0]
sage: t3 = 0
sage: max(t2, t3)

4
sage: min(t2, t3)
0

Very curious! Maybe I have an updated spkg installed that is not
installed in 4.4.2. I think I have an updated maxima spkg installed,
for example.

Jason

Reply all
Reply to author
Forward
0 new messages