Export to GitHub

gmpy - issue #1

unit test failure


Posted on May 22, 2007 by Massive Ox

root@wombat:/usr/local/src/gmpy-1.02/test# uname -a Linux wombat 2.6.20-15-generic #2 SMP Sun Apr 15 06:17:24 UTC 2007 x86_64 GNU/Linux

root@wombat:/usr/local/src/gmpy-1.02/test# python gmpy_test.py Unit tests for gmpy 1.02 release candidate on Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:12:50) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] Testing gmpy 1.02 (GMP 4.2.1), default caching (20, 20, -2..11) gmpy_test_cvr 270 tests, 0 failures gmpy_test_rnd 26 tests, 0 failures gmpy_test_mpf 155 tests, 0 failures gmpy_test_mpq 264 tests, 0 failures


File "/usr/local/src/gmpy-1.02/test/gmpy_test_mpz.py", line ?, in gmpy_test_mpz.test.binio Failed example: hash(z) Expected: -791330233 Got: 1634524889


File "/usr/local/src/gmpy-1.02/test/gmpy_test_mpz.py", line ?, in gmpy_test_mpz.test.index Failed example: ix(_g.mpz(sys.maxint)) == sys.maxint Expected: True Got: False


2 items had failures: 2 of 34 in gmpy_test_mpz.test.binio 1 of 14 in gmpy_test_mpz.test.index Test Failed 3 failures. gmpy_test_mpz 400 tests, 3 failures


2 items had failures: 2 of 34 in gmpy_test_mpz.test.binio 1 of 14 in gmpy_test_mpz.test.index Test Failed 3 failures. gmpy_test_dec 16 tests, 0 failures 7 items had no tests: gmpy_test_cvr._test gmpy_test_dec._test gmpy_test_mpf._test gmpy_test_mpq._test gmpy_test_mpz._memsize gmpy_test_mpz._test gmpy_test_rnd._test 29 items passed all tests: 6 tests in gmpy_test_cvr 12 tests in gmpy_test_cvr.test.misc_stuff 252 tests in gmpy_test_cvr.test.user_errors 1 tests in gmpy_test_dec 15 tests in gmpy_test_dec.test.elemop 1 tests in gmpy_test_mpf 32 tests in gmpy_test_mpf.test.binio 33 tests in gmpy_test_mpf.test.cmpr 49 tests in gmpy_test_mpf.test.elemop 34 tests in gmpy_test_mpf.test.format 6 tests in gmpy_test_mpf.test.newdiv 2 tests in gmpy_test_mpq 26 tests in gmpy_test_mpq.test.binio 62 tests in gmpy_test_mpq.test.cmpr 66 tests in gmpy_test_mpq.test.elemop 54 tests in gmpy_test_mpq.test.format 12 tests in gmpy_test_mpq.test.newdiv 18 tests in gmpy_test_mpq.test.power 24 tests in gmpy_test_mpq.test.qdiv 4 tests in gmpy_test_mpz 62 tests in gmpy_test_mpz.test.bitops 48 tests in gmpy_test_mpz.test.cmpr 42 tests in gmpy_test_mpz.test.elemop 36 tests in gmpy_test_mpz.test.format 12 tests in gmpy_test_mpz.test.newdiv 144 tests in gmpy_test_mpz.test.number 4 tests in gmpy_test_mpz.factorize 1 tests in gmpy_test_rnd 25 tests in gmpy_test_rnd.test.rand


2 items had failures: 2 of 34 in gmpy_test_mpz.test.binio 1 of 14 in gmpy_test_mpz.test.index 1131 tests in 38 items. 1128 passed and 3 failed. Test Failed 3 failures.

Comment #1

Posted on May 23, 2007 by Quick Dog

definitely look like problems specific to x86-64 and probably specific to the unit tests. Thanks for reporting them! Unfortunately I don't have a 64-bit Linux box to check them in more depth. The hash(z) problem appears to be fixed in the current svn HEAD, since that specific test has changed; that change was part of revision 14, i.e. brain:~/gmpy/test alex$ svn diff -r13 gmpy_test_mpz.py [snip] ->>> hash(z) --791330233 +>>> hash(z) == hash(long(z)) +True

The other issue, however -- the one with: ix(_g.mpz(sys.maxint)) == sys.maxint is news to me. Could I ask you, or anybody with a 64-bit linux install, to try at an interactive Python prompt:

>>> import gmpy, sys, operator >>> sys.maxint ...whatever... >>> operator.index(sys.maxint) ...whatever... >>> gmpy.mpz(sys.maxint) ...whatever... >>> operator.index(gmpy.mpz(sys.maxint)) ...whatever...

and copy and paste that brief session here? Seeing the results should tell me enough to fix the test (or, less likely, to show me that the test is fine and there is some x86-64 specific issue to fix w/the gmpy code).

Again, thanks!

Alex

Comment #2

Posted on May 23, 2007 by Quick Dog

definitely look like problems specific to x86-64 and probably specific to the unit tests. Thanks for reporting them! Unfortunately I don't have a 64-bit Linux box to check them in more depth. The hash(z) problem appears to be fixed in the current svn HEAD, since that specific test has changed; that change was part of revision 14, i.e. brain:~/gmpy/test alex$ svn diff -r13 gmpy_test_mpz.py [snip] ->>> hash(z) --791330233 +>>> hash(z) == hash(long(z)) +True

The other issue, however -- the one with: ix(_g.mpz(sys.maxint)) == sys.maxint is news to me. Could I ask you, or anybody with a 64-bit linux install, to try at an interactive Python prompt:

>>> import gmpy, sys, operator >>> sys.maxint ...whatever... >>> operator.index(sys.maxint) ...whatever... >>> gmpy.mpz(sys.maxint) ...whatever... >>> operator.index(gmpy.mpz(sys.maxint)) ...whatever...

and copy and paste that brief session here? Seeing the results should tell me enough to fix the test (or, less likely, to show me that the test is fine and there is some x86-64 specific issue to fix w/the gmpy code).

Again, thanks!

Alex

Comment #3

Posted on May 23, 2007 by Quick Dog

(sorry for the repeated comment -- some issue w/code.google.com -- it gave me an error msg but it actually did accept my comment!)

Alex

Comment #4

Posted on May 23, 2007 by Massive Ox

Here is what you requested;

>>> import gmpy, sys, operator >>> sys.maxint 9223372036854775807 >>> operator.index(sys.maxint) 9223372036854775807 >>> gmpy.mpz(sys.maxint) mpz(-1) >>> operator.index(gmpy.mpz(sys.maxint)) -1

Note also: >>> gmpy.mpz(1 << 31) mpz(2147483648) >>> gmpy.mpz(1 << 32) mpz(0) . . . >>> gmpy.mpz(1 << 62) mpz(0) >>> gmpy.mpz(1 << 63) mpz(9223372036854775808L)

Gary Bunting

Comment #5

Posted on May 25, 2007 by Massive Ox

Changing the declaration of get_zconst (line 279 of gmpy.c) from

static PympzObject* get_zconst(int i)

to

static PympzObject* get_zconst(long i)

fixes the problem.

The call to get_zconst(i) from mpz_from_c_long(long i) was looking at only the low 32 bits of i.

Gary Bunting

Comment #6

Posted on May 30, 2007 by Quick Dog

Gary's fix looks good (and doesn't break tests on a 32-bit machine; unfortunately I don't have access to a 64-bit one to check!) so I uploaded it to subversion's HEAD (revision 17) -- thanks Gary!

Status: Fixed

Labels:
Type-Defect Priority-Medium 64-bit