On 10/06/2012 10:16 AM Julien Rioux wrote:
Hi,

Running sympy's test suite would be a good test for pypy. Sympy is a
python module for symbolic mathematics (www.sympy.org). The release
0.7.2 is being prepared and there is a single test failure remaining
when running under pypy nightly (from a couple days ago). It boils
down to this small example:

dirac:~/git/sympy  $ cat test_arnault.py
from sympy.ntheory import isprime
# Arnault's number
a = int('''
803837457453639491257079614341942108138837688287558145837488917522297\
427376533365218650233616396004545791504202360320876656996676098728404\
396540823292873879185086916685732826776177102938969773947016708230428\
687109997439976544144845341155872450633409279022275296229414984230688\
1685404326457534018329786111298960644845216191652872597534901''')
print type(a)
print a
print isprime(a)
dirac:~/git/sympy  $ python test_arnault.py
<type 'long'>
8038374574536394912570796143419421081388376882875581458374889175222974273765333652186502336163960045457915042023603208766569966760987284043965408232928738791850869166857328267761771029389697739470167082304286871099974399765441448453411558724506334092790222752962294149842306881685404326457534018329786111298960644845216191652872597534901
True
dirac:~/git/sympy  $ python -V
Python 2.7.2
dirac:~/git/sympy  $ pypy test_arnault.py
<type 'long'>
8038374574536394912570796143419421081388376882875581458374889175222974273765333652186502336163960045457915042023603208766569966760987284043965408232928738791850869166857328267761771029389697739470167082304286871099974399765441448453411558724506334092790222752962294149842306881685404326457534018329786111298960644845216191652872597534901
RPython traceback:
   File "objspace_std_longobject.c", line 4316, in pow__Long_Long_Long
   File "rlib_rbigint.c", line 23606, in rbigint_pow
Fatal RPython error: AssertionError
Aborted
dirac:~/git/sympy  $ pypy --version
Python 2.7.3 (7f6d5c878b908afec8a643b6d6166dfbd0af2bdf, Oct 03 2012, 11:42:40)
[PyPy 1.9.1-dev0 with GCC 4.6.2]


This code (isprime) is part of previous sympy releases, and this
failure did not happen with pypy 1.9 but happens with the nightly from
Oct 3 (self built with translate.py -Ojit). Can anyone reproduce?

Thanks,
Cheers,
Julien

Hi Julien,
I installed an unshared copy of sympy and changed your test_arnault.py
to an equivalent ta2.py, to make it importable, with the code in main,
so I could try an old trace routine I wrote long ago, which surprisingly
still seems to sort of work:
______________________________________________________________________
[10:10 ~/wk/sympy]$ cat ta2.py
from sympy.ntheory import isprime
# Arnault's number
def main():
    a = int('''
803837457453639491257079614341942108138837688287558145837488917522297\
427376533365218650233616396004545791504202360320876656996676098728404\
396540823292873879185086916685732826776177102938969773947016708230428\
687109997439976544144845341155872450633409279022275296229414984230688\
1685404326457534018329786111298960644845216191652872597534901''')
    print type(a)
    print a
    print isprime(a)

if __name__ == '__main__':
    main()
[10:10 ~/wk/sympy]$
______________________________________________________________________

Here's the run, diffing the results of _test calls grepped out of a traces
for pypy and python:

[10:23 ~/wk/sympy]$ diff -u <(pypy $(which tw) ta2 main _test |grep 'R: _test\|^File') <(python $(which tw) ta2 main _test|grep 'R: _test\|^File')
pypy: /usr/lib/libcrypto.so.0.9.8: no version information available (required 
by pypy)
pypy: /usr/lib/libssl.so.0.9.8: no version information available (required by 
pypy)
--- /dev/fd/63  2012-10-07 10:24:30.108533498 +0200
+++ /dev/fd/62  2012-10-07 10:24:30.108533498 +0200
@@ -1,2 +1,47 @@
 File: "/home/bokr/lib/python2.7/site-packages/sympy/ntheory/primetest.py"
-  72 [_test]:           R: _test(...) => False
+  71 [_test]:           R: _test(...) => True
+  66 [_test]:           R: _test(...) => True
+  66 [_test]:           R: _test(...) => True
+  71 [_test]:           R: _test(...) => True
                   ... 41 repeats of same as above and below ...
+  71 [_test]:           R: _test(...) => True
[10:24 ~/wk/sympy]$

The 72, 71, 66 represent the line numbers of the returns from _test
I didn't grep out the calls, as the args are such long wrapping long integers.

I wrote out some failing args to pow (which I can't trace into as it's builtin)
and made a tpow.py, seen below.

HTH,
Regards,
Bengt Richter
______________________________________________________________________

[09:56 ~/wk/sympy]$ python --version
Python 2.7.2
[09:56 ~/wk/sympy]$ pypy --version
pypy: /usr/lib/libcrypto.so.0.9.8: no version information available (required 
by pypy)
pypy: /usr/lib/libssl.so.0.9.8: no version information available (required by 
pypy)
Python 2.7.1 (b590cf6de419, Apr 30 2011, 02:00:38)
[PyPy 1.5.0-alpha0 with GCC 4.4.3]
[09:56 ~/wk/sympy]$ cat tpow.py
#!/usr/bin/python
#
def main(opts):
    expected = int('205308233964764741474065440722548147152837487'
            '8436244152161245680082478906739003837537707602796'
            '2523882678514957414514288325968530357544873923327'
            '2560600119280228812360239622859389835106130303819'
            '8812608395321192472488554180795988393259013286827'
            '6127496893617704776708371167151813294028632749297'
            '63810769866878488336371858543186166507924901737')

    actual = pow(2, int('200959364363409872814269903585485527034709'
        '4220718895364593722293805743568441333413046625584040990011'
        '3644787605059008021916424916902468210109913520582321846979'
        '6271729171433206694044275734742443486754177057607171777499'
        '3599941360362113352889681126583523197555688240573537460576'
        '720421351081614383504582446527824740161211304047913218149383725'),
        int('803837457453639491257079614341942108138837688287558145'
            '837488917522297427376533365218650233616396004545791504'
            '202360320876656996676098728404396540823292873879185086'
            '916685732826776177102938969773947016708230428687109997'
            '439976544144845341155872450633409279022275296229414984'
            '230688168540432645753401832978611129896064484521619165'
            '2872597534901'))

    text =  'expected:\n    %s\nactual:\n    %s'%(
            tuple('\n    '.join(s[i:i+50] for i in range(0,len(s),50))
               for s in [repr(v) for v in (expected, actual)]))

    assert actual==expected, text

    if opts and opts[0]=='-print': print text
    if actual == expected:
        print '... as expected ;-)'

if __name__ == '__main__':
    import sys
    try: main(sys.argv[1:])
    except Exception,e: print '%s:\n%s'%(e.__class__.__name__, e)

Bear in mind my python and pypy versions are out of date,
but you can easily try tpow.py as follows and see what
happens for you...

[09:56 ~/wk/sympy]$ python tpow.py
... as expected ;-)
[09:57 ~/wk/sympy]$ pypy tpow.py
pypy: /usr/lib/libcrypto.so.0.9.8: no version information available (required 
by pypy)
pypy: /usr/lib/libssl.so.0.9.8: no version information available (required by 
pypy)
AssertionError:
expected:
    20530823396476474147406544072254814715283748784362
    44152161245680082478906739003837537707602796252388
    26785149574145142883259685303575448739233272560600
    11928022881236023962285938983510613030381988126083
    95321192472488554180795988393259013286827612749689
    36177047767083711671518132940286327492976381076986
    6878488336371858543186166507924901737L
actual:
    54907080201776472107337034411173408169461451059492
    19340520622621434519462362497005098074867506892669
    64669150197877920364556131878818528130569072864509
    78537992136333962220382281410469047624566423572707
    23947703936700498584279881397667810995651289825448
    34510224055185249725794168117352710937820049011975
    6120237666889918094387505100251368387L
[09:57 ~/wk/sympy]$ python tpow.py -print
expected:
    20530823396476474147406544072254814715283748784362
    44152161245680082478906739003837537707602796252388
    26785149574145142883259685303575448739233272560600
    11928022881236023962285938983510613030381988126083
    95321192472488554180795988393259013286827612749689
    36177047767083711671518132940286327492976381076986
    6878488336371858543186166507924901737L
actual:
    20530823396476474147406544072254814715283748784362
    44152161245680082478906739003837537707602796252388
    26785149574145142883259685303575448739233272560600
    11928022881236023962285938983510613030381988126083
    95321192472488554180795988393259013286827612749689
    36177047767083711671518132940286327492976381076986
    6878488336371858543186166507924901737L
... as expected ;-)
[09:57 ~/wk/sympy]$

_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to