Ask Your Question
0

numpy.int64 vs. sage.rings.integer.Integer [closed]

asked 2014-07-11 04:32:49 +0100

mresimulator gravatar image

Hi experts!

I have a list (A) with many list generated by NetworkX. Each list have numpy.int64 numbers A=[A1,....,An], where Aj are lists of numpy.int64 integers numbers.

I want to compare this numpy.int64 numbers with sage.rings.integer.Integer numbers.

How can I do this?

Thanks a lot!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by mresimulator
close date 2014-07-12 18:38:51.442980

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-07-11 20:15:51 +0100

tmonteil gravatar image

Just use == :

sage: import numpy
sage: a = numpy.int64(123) ; a
123
sage: type(a)
<type 'numpy.int64'>
sage: b = ZZ(123) ; b
123
sage: a == b
True
sage: type(b)
<type 'sage.rings.integer.Integer'>
sage: c = ZZ(1234)
sage: a == c
False
sage: A = [[numpy.int64(1), numpy.int64(2)], [numpy.int64(3), numpy.int64(4)]]
sage: B = [[ZZ(1), ZZ(2)], [ZZ(3), ZZ(4)]]
sage: A
[[1, 2], [3, 4]]
sage: B
[[1, 2], [3, 4]]
sage: A == B
True
sage: C = [[ZZ(1), ZZ(2)], [ZZ(3), ZZ(5)]]
sage: A == C
False
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-07-11 04:32:49 +0100

Seen: 1,060 times

Last updated: Jul 11 '14