Giter Club home page Giter Club logo

Comments (32)

vinc17fr avatar vinc17fr commented on July 29, 2024

I suppose that the bug is in gmpy2_format.c, function GMPy_MPC_Format, which currently has

    if (mpcstyle)
        strcat(tempbuf, " ");
    else {
        /* Need to insert + if imag is nan or +inf. */
        if (mpfr_nan_p(mpc_imagref(MPC(self))) ||
            (mpfr_inf_p(mpc_imagref(MPC(self))) &&
             mpfr_sgn(mpc_imagref(MPC(self))) > 0)) {
            strcat(tempbuf, "+");
        }

With the fix of the formatted output functions in GNU MPFR 4.2.1, the insertion of the + should no longer be needed.

Note also that the sign that appears before "nan" is indeterminate in general (just like in C), unless the sign bit is fixed by MPC.

from gmpy.

vinc17fr avatar vinc17fr commented on July 29, 2024

And to support both fixed and unfixed versions of MPFR, you could check whether the first character of imagbuf is a sign (+ or -).

But for the tests, note the indeterminate sign for "nan".

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

`dpkg-buildpackage: info: source package python-gmpy2
dpkg-buildpackage: info: source version 2.1.2-2ubuntu1
dpkg-buildpackage: info: source distribution mantic
dpkg-buildpackage: info: source changed by Matthias Klose [email protected]
dpkg-source --before-build .
dpkg-buildpackage: info: host architecture amd64
debian/rules clean
dh clean --buildsystem pybuild --with python3,sphinxdoc
dh_auto_clean -O--buildsystem=pybuild
I: pybuild base:291: python3.11 setup.py clean
running clean
removing '/home/packages/tmp/python-gmpy2-2.1.2/.pybuild/cpython3_3.11_gmpy2/build' (and everything under it)
'build/bdist.linux-x86_64' does not exist -- can't clean it
'build/scripts-3.11' does not exist -- can't clean it
dh_autoreconf_clean -O--buildsystem=pybuild
dh_clean -O--buildsystem=pybuild
debian/rules binary
dh binary --buildsystem pybuild --with python3,sphinxdoc
dh_update_autotools_config -O--buildsystem=pybuild
dh_autoreconf -O--buildsystem=pybuild
dh_auto_configure -O--buildsystem=pybuild
I: pybuild base:291: python3.11 setup.py config
running config
debian/rules override_dh_auto_build
make[1]: Entering directory '/home/packages/tmp/python-gmpy2-2.1.2'
dh_auto_build
I: pybuild base:291: /usr/bin/python3 setup.py build
running build
running build_py
creating /home/packages/tmp/python-gmpy2-2.1.2/.pybuild/cpython3_3.11_gmpy2/build/gmpy2
copying gmpy2/init.py -> /home/packages/tmp/python-gmpy2-2.1.2/.pybuild/cpython3_3.11_gmpy2/build/gmpy2
running egg_info
creating gmpy2.egg-info
writing gmpy2.egg-info/PKG-INFO
writing dependency_links to gmpy2.egg-info/dependency_links.txt
writing top-level names to gmpy2.egg-info/top_level.txt
writing manifest file 'gmpy2.egg-info/SOURCES.txt'
reading manifest file 'gmpy2.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'COPYING'
adding license file 'COPYING.LESSER'
writing manifest file 'gmpy2.egg-info/SOURCES.txt'
copying gmpy2/init.pxd -> /home/packages/tmp/python-gmpy2-2.1.2/.pybuild/cpython3_3.11_gmpy2/build/gmpy2
copying gmpy2/gmpy2.h -> /home/packages/tmp/python-gmpy2-2.1.2/.pybuild/cpython3_3.11_gmpy2/build/gmpy2
copying gmpy2/gmpy2.pxd -> /home/packages/tmp/python-gmpy2-2.1.2/.pybuild/cpython3_3.11_gmpy2/build/gmpy2
running build_ext
building 'gmpy2.gmpy2' extension
creating build
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/src
x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -O2 -ffile-prefix-map=/home/packages/tmp/python-gmpy2-2.1.2=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/home/packages/tmp/python-gmpy2-2.1.2=/usr/src/python-gmpy2-2.1.2-2ubuntu1 -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./src -I/usr/include/python3.11 -c src/gmpy2.c -o build/temp.linux-x86_64-cpython-311/src/gmpy2.o -DSHARED=1
x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -g -O2 -ffile-prefix-map=/home/packages/tmp/python-gmpy2-2.1.2=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/home/packages/tmp/python-gmpy2-2.1.2=/usr/src/python-gmpy2-2.1.2-2ubuntu1 -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-cpython-311/src/gmpy2.o -L/usr/lib/x86_64-linux-gnu -lmpc -lmpfr -lgmp -o /home/packages/tmp/python-gmpy2-2.1.2/.pybuild/cpython3_3.11_gmpy2/build/gmpy2/gmpy2.cpython-311-x86_64-linux-gnu.so
make man html -C /home/packages/tmp/python-gmpy2-2.1.2/docs SPHINXOPTS="-D today="1693742772""
make[2]: Entering directory '/home/packages/tmp/python-gmpy2-2.1.2/docs'
if [ ! -d _static ]; then mkdir _static; fi
sphinx-build -b man -d _build/doctrees -D today="1693742772" . _build/man
Running Sphinx v5.3.0
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [man]: all manpages
updating environment: [new config] 12 added, 0 changed, 0 removed
reading sources... [ 8%] advmpz
reading sources... [ 16%] conversion
reading sources... [ 25%] cython
reading sources... [ 33%] history
reading sources... [ 41%] index
reading sources... [ 50%] intro
reading sources... [ 58%] mpc
reading sources... [ 66%] mpfr
reading sources... [ 75%] mpq
reading sources... [ 83%] mpz
reading sources... [ 91%] overview
reading sources... [100%] win_build

looking for now-outdated files... none found
pickling environment... done
checking consistency... /home/packages/tmp/python-gmpy2-2.1.2/docs/win_build.rst: WARNING: document isn't included in any toctree
done
writing... gmpy2.3 { intro overview mpz advmpz mpq mpfr mpc cython conversion history } done
build succeeded, 1 warning.

The manual pages are in _build/man.

Build finished. The manual pages are in _build/man.
sphinx-build -b html -d _build/doctrees -D today="1693742772" . _build/html
Running Sphinx v5.3.0
making output directory... done
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 12 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
preparing documents... done
writing output... [ 8%] advmpz
writing output... [ 16%] conversion
writing output... [ 25%] cython
writing output... [ 33%] history
writing output... [ 41%] index
writing output... [ 50%] intro
writing output... [ 58%] mpc
writing output... [ 66%] mpfr
writing output... [ 75%] mpq
writing output... [ 83%] mpz
writing output... [ 91%] overview
writing output... [100%] win_build

generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.

The HTML pages are in _build/html.

Build finished. The HTML pages are in _build/html.
make[2]: Leaving directory '/home/packages/tmp/python-gmpy2-2.1.2/docs'
make[1]: Leaving directory '/home/packages/tmp/python-gmpy2-2.1.2'
debian/rules override_dh_auto_test
make[1]: Entering directory '/home/packages/tmp/python-gmpy2-2.1.2'
dh_auto_test -- --system=custom --test-args="{interpreter} {dir}/test/runtests.py"
I: pybuild base:291: python3.11 /home/packages/tmp/python-gmpy2-2.1.2/test/runtests.py

Unit tests for gmpy2 2.1.2 with Python 3.11.5
Mutliple-precision library: GMP 6.3.0
Floating-point library: MPFR 4.2.1
Complex library: MPC 1.3.1
Caching Values: (Cache size) 100
Caching Values: (Size in limbs) 128

Results for: test_context Attempted: 38 Failed: 0
Results for: test_gmpy2_abs Attempted: 83 Failed: 0
Results for: test_gmpy2_add Attempted: 82 Failed: 0
Results for: test_gmpy2_binary Attempted: 106 Failed: 0
Results for: test_gmpy2_cmp Attempted: 41 Failed: 0
Results for: test_gmpy2_comp Attempted: 89 Failed: 0
Results for: test_gmpy2_const Attempted: 33 Failed: 0
Results for: test_gmpy2_constructors Attempted: 34 Failed: 0
Results for: test_gmpy2_convert Attempted: 50 Failed: 0
Results for: test_gmpy2_divmod Attempted: 42 Failed: 0
Results for: test_gmpy2_floordiv Attempted: 72 Failed: 0
Results for: test_gmpy2_format Attempted: 102 Failed: 0
Results for: test_gmpy2_fused Attempted: 18 Failed: 0
Results for: test_gmpy2_lucas Attempted: 23 Failed: 0


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_gmpy2_math.txt", line 35, in test_gmpy2_math.txt
Failed example:
ctx.sqrt(mpfr(-380.25))
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


1 items had failures:
1 of 147 in test_gmpy2_math.txt
Test Failed 1 failures.
Results for: test_gmpy2_math Attempted: 147 Failed: 1
Results for: test_gmpy2_minus Attempted: 14 Failed: 0


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_gmpy2_mpfr_misc.txt", line 118, in test_gmpy2_mpfr_misc.txt
Failed example:
nan = gmpy2.nan(); nan
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


1 items had failures:
1 of 85 in test_gmpy2_mpfr_misc.txt
Test Failed 1 failures.
Results for: test_gmpy2_mpfr_misc Attempted: 85 Failed: 1
Results for: test_gmpy2_mpq_misc Attempted: 33 Failed: 0
Results for: test_gmpy2_mpq_misc_py3 Attempted: 3 Failed: 0
Results for: test_gmpy2_mpz_bitops Attempted: 106 Failed: 0
Results for: test_gmpy2_mpz_divmod Attempted: 67 Failed: 0
Results for: test_gmpy2_mpz_divmod2exp Attempted: 66 Failed: 0
Results for: test_gmpy2_mpz_inplace Attempted: 87 Failed: 0
Results for: test_gmpy2_mpz_misc Attempted: 231 Failed: 0
Results for: test_gmpy2_mpz_misc_py3 Attempted: 19 Failed: 0
Results for: test_gmpy2_mul Attempted: 68 Failed: 0
Results for: test_gmpy2_muldiv_2exp Attempted: 24 Failed: 0
Results for: test_gmpy2_plus Attempted: 16 Failed: 0
Results for: test_gmpy2_pow Attempted: 55 Failed: 0
Results for: test_gmpy2_predicate Attempted: 120 Failed: 0
Results for: test_gmpy2_prp Attempted: 57 Failed: 0
Results for: test_gmpy2_root Attempted: 23 Failed: 0
Results for: test_gmpy2_square Attempted: 19 Failed: 0
Results for: test_gmpy2_sub Attempted: 83 Failed: 0
Results for: test_gmpy2_xmpz_inplace Attempted: 79 Failed: 0
Results for: test_gmpy2_xmpz_limbs Attempted: 21 Failed: 0
Results for: test_gmpy2_xmpz_misc Attempted: 59 Failed: 0
Results for: test_misc Attempted: 27 Failed: 0


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpc.txt", line 151, in test_mpc.txt
Failed example:
aj - float('nan')
Differences (ndiff with -expected +actual):
- mpc('nan+2.0j')
+ mpc('-nan+2.0j')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpc.txt", line 159, in test_mpc.txt
Failed example:
mpc(0,0) * float('inf')
Differences (ndiff with -expected +actual):
- mpc('nan+nanj')
+ mpc('-nan+nanj')
? +


1 items had failures:
2 of 132 in test_mpc.txt
Test Failed 2 failures.
Results for: test_mpc Attempted: 132 Failed: 2
Results for: test_mpc_create Attempted: 7 Failed: 0
Results for: test_mpc_trig Attempted: 21 Failed: 0


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 293, in test_mpfr.txt
Failed example:
a + float('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 295, in test_mpfr.txt
Failed example:
float('nan') + a
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 307, in test_mpfr.txt
Failed example:
float('nan') - a
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 329, in test_mpfr.txt
Failed example:
mpfr(0) * float('Inf')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 353, in test_mpfr.txt
Failed example:
a / float('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 357, in test_mpfr.txt
Failed example:
float('nan') / mpfr(0)
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 370, in test_mpfr.txt
Failed example:
a + mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 382, in test_mpfr.txt
Failed example:
a - mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 402, in test_mpfr.txt
Failed example:
a * mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 430, in test_mpfr.txt
Failed example:
a / mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 434, in test_mpfr.txt
Failed example:
mpfr('nan') / mpfr(0)
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 447, in test_mpfr.txt
Failed example:
divmod(a, float('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 449, in test_mpfr.txt
Failed example:
divmod(-a, float('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 457, in test_mpfr.txt
Failed example:
divmod(float('Inf'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 461, in test_mpfr.txt
Failed example:
divmod(float('Inf'), -a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 463, in test_mpfr.txt
Failed example:
divmod(float('-Inf'), -a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 465, in test_mpfr.txt
Failed example:
divmod(float('nan'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 467, in test_mpfr.txt
Failed example:
divmod(float('nan'), -a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 469, in test_mpfr.txt
Failed example:
divmod(float('Inf'), mpfr(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 473, in test_mpfr.txt
Failed example:
divmod(float('nan'), mpfr(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 484, in test_mpfr.txt
Failed example:
divmod(a, mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 486, in test_mpfr.txt
Failed example:
divmod(-a, mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 492, in test_mpfr.txt
Failed example:
divmod(mpfr(0), mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 494, in test_mpfr.txt
Failed example:
divmod(mpfr('Inf'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 496, in test_mpfr.txt
Failed example:
divmod(mpfr('-Inf'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 498, in test_mpfr.txt
Failed example:
divmod(mpfr('Inf'), -a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 500, in test_mpfr.txt
Failed example:
divmod(mpfr('-Inf'), -a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 502, in test_mpfr.txt
Failed example:
divmod(mpfr('nan'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 504, in test_mpfr.txt
Failed example:
divmod(mpfr('nan'), -a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 506, in test_mpfr.txt
Failed example:
divmod(mpfr('Inf'), mpfr(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr.txt", line 510, in test_mpfr.txt
Failed example:
divmod(mpfr('nan'), mpfr(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


1 items had failures:
31 of 227 in test_mpfr.txt
Test Failed 31 failures.
Results for: test_mpfr Attempted: 227 Failed: 31
Results for: test_mpfr4_fused Attempted: 13 Failed: 0
Results for: test_mpfr4_random Attempted: 7 Failed: 0


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr_create.txt", line 47, in test_mpfr_create.txt
Failed example:
mpfr(float("nan"))
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


1 items had failures:
1 of 73 in test_mpfr_create.txt
Test Failed 1 failures.
Results for: test_mpfr_create Attempted: 73 Failed: 1


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpfr_min_max.txt", line 55, in test_mpfr_min_max.txt
Failed example:
minnum(nan, nan)
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


1 items had failures:
1 of 26 in test_mpfr_min_max.txt
Test Failed 1 failures.
Results for: test_mpfr_min_max Attempted: 26 Failed: 1
Results for: test_mpfr_subnormalize Attempted: 17 Failed: 0
Results for: test_mpfr_trig Attempted: 140 Failed: 0


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 218, in test_mpq.txt
Failed example:
a + float('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 220, in test_mpq.txt
Failed example:
float('nan') + a
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 232, in test_mpq.txt
Failed example:
float('nan') - a
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 278, in test_mpq.txt
Failed example:
a / float('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 282, in test_mpq.txt
Failed example:
float('nan') / G.mpz(0)
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 295, in test_mpq.txt
Failed example:
a + mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 307, in test_mpq.txt
Failed example:
a - mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 327, in test_mpq.txt
Failed example:
a * mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 335, in test_mpq.txt
Failed example:
mpfr('Inf') * G.mpz(0)
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 355, in test_mpq.txt
Failed example:
a / mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 372, in test_mpq.txt
Failed example:
divmod(a, float('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 374, in test_mpq.txt
Failed example:
divmod(-a, float('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 382, in test_mpq.txt
Failed example:
divmod(float('Inf'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 386, in test_mpq.txt
Failed example:
divmod(float('Inf'), -a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 390, in test_mpq.txt
Failed example:
divmod(float('nan'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 394, in test_mpq.txt
Failed example:
divmod(float('Inf'), G.mpz(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 398, in test_mpq.txt
Failed example:
divmod(float('nan'), G.mpz(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 409, in test_mpq.txt
Failed example:
divmod(a, mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 411, in test_mpq.txt
Failed example:
divmod(-a, mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 417, in test_mpq.txt
Failed example:
divmod(G.mpz(0), mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 419, in test_mpq.txt
Failed example:
divmod(mpfr('Inf'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 423, in test_mpq.txt
Failed example:
divmod(mpfr('Inf'), -a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 427, in test_mpq.txt
Failed example:
divmod(mpfr('nan'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 431, in test_mpq.txt
Failed example:
divmod(mpfr('Inf'), G.mpz(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpq.txt", line 435, in test_mpq.txt
Failed example:
divmod(mpfr('nan'), G.mpz(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


1 items had failures:
25 of 207 in test_mpq.txt
Test Failed 25 failures.
Results for: test_mpq Attempted: 207 Failed: 25


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 316, in test_mpz.txt
Failed example:
a + float('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 318, in test_mpz.txt
Failed example:
float('nan') + a
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 331, in test_mpz.txt
Failed example:
float('nan') - a
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 378, in test_mpz.txt
Failed example:
a / float('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 382, in test_mpz.txt
Failed example:
float('nan') / G.mpz(0)
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 395, in test_mpz.txt
Failed example:
a - mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 415, in test_mpz.txt
Failed example:
a * mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 423, in test_mpz.txt
Failed example:
mpfr('Inf') * G.mpz(0)
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 443, in test_mpz.txt
Failed example:
a / mpfr('nan')
Differences (ndiff with -expected +actual):
- mpfr('nan')
+ mpfr('-nan')
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 460, in test_mpz.txt
Failed example:
divmod(a, mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 462, in test_mpz.txt
Failed example:
divmod(-a, mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 468, in test_mpz.txt
Failed example:
divmod(G.mpz(0), mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 470, in test_mpz.txt
Failed example:
divmod(mpfr('Inf'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 474, in test_mpz.txt
Failed example:
divmod(mpfr('Inf'), -a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 478, in test_mpz.txt
Failed example:
divmod(mpfr('nan'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 482, in test_mpz.txt
Failed example:
divmod(mpfr('Inf'), G.mpz(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 486, in test_mpz.txt
Failed example:
divmod(mpfr('nan'), G.mpz(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 497, in test_mpz.txt
Failed example:
divmod(a, mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 499, in test_mpz.txt
Failed example:
divmod(-a, mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 505, in test_mpz.txt
Failed example:
divmod(G.mpz(0), mpfr('nan'))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 507, in test_mpz.txt
Failed example:
divmod(mpfr('Inf'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 511, in test_mpz.txt
Failed example:
divmod(mpfr('Inf'), -a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 515, in test_mpz.txt
Failed example:
divmod(mpfr('nan'), a)
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 519, in test_mpz.txt
Failed example:
divmod(mpfr('Inf'), G.mpz(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('nan'), mpfr('-nan'))
? +


File "/home/packages/tmp/python-gmpy2-2.1.2/test/test_mpz.txt", line 523, in test_mpz.txt
Failed example:
divmod(mpfr('nan'), G.mpz(0))
Differences (ndiff with -expected +actual):
- (mpfr('nan'), mpfr('nan'))
+ (mpfr('-nan'), mpfr('-nan'))
? + +


1 items had failures:
25 of 230 in test_mpz.txt
Test Failed 25 failures.
Results for: test_mpz Attempted: 230 Failed: 25
Results for: test_mpz_create Attempted: 58 Failed: 0
Results for: test_mpz_io Attempted: 60 Failed: 0
Results for: test_mpz_pack_unpack Attempted: 16 Failed: 0

                          Summary - Attempted: 3556   Failed:   87

Running external test programs.
Running test_pack.py successful
Running test_mpz_args.py successful
E: pybuild pybuild:395: test: plugin custom failed with: exit code=1: python3.11 /home/packages/tmp/python-gmpy2-2.1.2/test/runtests.py
dh_auto_test: error: pybuild --test -i python{version} -p 3.11 --system=custom "--test-args={interpreter} {dir}/test/runtests.py" returned exit code 13
make[1]: *** [debian/rules:19: override_dh_auto_test] Error 25
make[1]: Leaving directory '/home/packages/tmp/python-gmpy2-2.1.2'
make: *** [debian/rules:12: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2`

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

the proposed patch fixes the double '++', there are unexpected results regarding nan/-nan

from gmpy.

martingkelly avatar martingkelly commented on July 29, 2024

This was found recently in Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050797. Looks like the patch from @doko42 should address it.

If the patch looks good, please let me know if you plan to release a bugfix version soon; if not, we can include this in packaging to fix this up for Debian until the next gmpy release.

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

there is no patch from me, the nan/+nan issues are still present

from gmpy.

vinc17fr avatar vinc17fr commented on July 29, 2024

In addition to the correction I mentioned above, which fixes the double "+" sign, you should ignore the sign bit of nan since it is not used in these tests. I think that the easiest solution would be to check whether the real or imaginary part of the result is nan, and force the sign bit to positive before converting the value to a string. Perhaps I could provide a patch later.

from gmpy.

vinc17fr avatar vinc17fr commented on July 29, 2024

I think that the easiest solution would be to check whether the real or imaginary part of the result is nan, and force the sign bit to positive before converting the value to a string.

Actually this is not possible because the conversion to a string is the gmpy code, which is correct with #422. So, concerning the sign before nan differences, these are the only tests that should be modified. A solution could be to postprocess the result file to replace - by + before nanj (this is currently useless, but failures might occur in the future if this is not done) and remove the - before nan, then check the differences.

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

please reopen. the patch in #422 only fixes the issue with the double plus sign

from gmpy.

casevh avatar casevh commented on July 29, 2024

My apologies for the confusion. The test suite for the next version 2.2.0a1 passes on my machine. When I try one of the failures listed above, I believe I am getting the expected result.

gmpy2.mpfr_version()
'MPFR 4.2.1'
gmpy2.mpc_version()
'MPC 1.3.1'
nan = gmpy2.nan(); nan
mpfr('nan')

I will test with gmpy2 2.1.5 tomorrow and try to reproduce the issue.

I am trying to release gmpy2 2.2.0 as soon as I can since it required for Python 3.12. But it already doesn't work with 3.13(dev).

from gmpy.

vinc17fr avatar vinc17fr commented on July 29, 2024

MPFR sets a positive sign by default to initialized variables (mpfr_init2), but if a variable is reused, it is possible that gmpy2.nan() yields a NaN with a negative sign, which could explain the failure. I don't know what gmpy2 does, though. In any case, the sign of NaN should be ignored in the tests.

from gmpy.

skirpichev avatar skirpichev commented on July 29, 2024

the proposed patch fixes the double '++', there are unexpected results regarding nan/-nan

@doko42, your message shows test failures on the gmpy2 test suite. But it pass in #422.

Did you test the patched version?

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

no, just this patch on top of the 2.1.5 release. are there any patches in the trunk to get 2.1.5 working with mpfr 4.2.1?

from gmpy.

skirpichev avatar skirpichev commented on July 29, 2024

no, just this patch on top of the 2.1.5 release

From #422, correct? Then, there should be no test failures with our tests, e.g.:
https://github.com/aleaxit/gmpy/actions/runs/6061180143/job/16446076083
(The "Build Wheels" workflow uses MPFR 4.2.1)

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

yes, from #422

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

my build logs:
https://launchpad.net/ubuntu/+source/python-gmpy2/2.1.5-1ubuntu1

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

I see my builds use mpclib 1.3.1, your's are using 1.2.1

from gmpy.

skirpichev avatar skirpichev commented on July 29, 2024

Yeah, I'm trying to do an update:
https://github.com/skirpichev/gmpy/actions/runs/6083541455

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

also gmp 6.3.0 vs. 6.2.1

from gmpy.

skirpichev avatar skirpichev commented on July 29, 2024

No. MPC version is irrelevant:
https://github.com/skirpichev/gmpy/actions/runs/6083541455/job/16503615537 (test failure on macos-12 is not due to the test suite)

from gmpy.

skirpichev avatar skirpichev commented on July 29, 2024

@doko42, the problem is that you test not the latest version, but the stable gmpy2 release(s), which is(are) ~250+ commits behind the current master.

The MPC and GMP versions are irrelevant: #425

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

yes, that's what I said in #418 (comment)

also asking in #418 (comment)
for relevant patches

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

https://launchpad.net/~doko/+archive/ubuntu/ppa/+sourcepub/15141484/+listing-archive-extra
for a trunk build. already stops in the doctests

from gmpy.

skirpichev avatar skirpichev commented on July 29, 2024

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

https://launchpad.net/~doko/+archive/ubuntu/ppa/+sourcepub/15141533/+listing-archive-extra

that seems to work, although I patched out the call to pytest at the end of the script, which causes a failure code. just running the pytest on it's own

anyway, please could you point out the relevant change which could be used for backporting?

from gmpy.

skirpichev avatar skirpichev commented on July 29, 2024

from gmpy.

skirpichev avatar skirpichev commented on July 29, 2024

Ok, after some cleanup of the 7351e2e, I got this:
gmpy2_cache.c.diff.txt

With this additional patch - the test suite pass for gmpy2-2.1.5:
log.txt

from gmpy.

doko42 avatar doko42 commented on July 29, 2024

thanks, that looks good: https://launchpad.net/ubuntu/+source/python-gmpy2/2.1.5-1ubuntu2

What kind of failure?
the script doesn't show any error output ;)
the Debian packaging doesn't build in the srcdir, but in a separate dir. probably worth to set this or pass via an argument

from gmpy.

skirpichev avatar skirpichev commented on July 29, 2024

from gmpy.

casevh avatar casevh commented on July 29, 2024

I have published release 2.2.0a1 on PyPi. Unfortunately, I forgot to include the source distribution. For reference, the source code is available at:

https://github.com/aleaxit/gmpy/archive/refs/tags/gmpy2-2.2.0a1.tar.gz

I will publish a2 soon.

from gmpy.

casevh avatar casevh commented on July 29, 2024

Source for 2.2.0a1 has been uploaded.

from gmpy.

skirpichev avatar skirpichev commented on July 29, 2024

@casevh, probably this can be closed as v2.2 released.

from gmpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.