andyvand / gmpy

Automatically exported from code.google.com/p/gmpy
GNU Lesser General Public License v3.0
0 stars 0 forks source link

unit test failure #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

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.

Original issue reported on code.google.com by bunting....@gmail.com on 22 May 2007 at 11:15

GoogleCodeExporter commented 9 years ago
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

Original comment by alea...@gmail.com on 23 May 2007 at 4:21

GoogleCodeExporter commented 9 years ago
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

Original comment by alea...@gmail.com on 23 May 2007 at 4:21

GoogleCodeExporter commented 9 years ago
(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

Original comment by alea...@gmail.com on 23 May 2007 at 4:23

GoogleCodeExporter commented 9 years ago
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

Original comment by bunting....@gmail.com on 23 May 2007 at 5:44

GoogleCodeExporter commented 9 years ago
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

Original comment by bunting....@gmail.com on 25 May 2007 at 3:34

GoogleCodeExporter commented 9 years ago
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!

Original comment by alea...@gmail.com on 30 May 2007 at 6:06