test failure on macos: test_kdot2
risicle opened this issue · 4 comments
risicle commented
On macos 10.14, having built accupy
0.3.2 using clang 7.1.0, I get a precision error in the test test/test_dot.py::test_kdot2[1000000000000000.0]
. Output:
============================= test session starts ==============================
platform darwin -- Python 3.7.9, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: /private/tmp/nix-build-python3.7-accupy-0.3.2.drv-0/accupy-0.3.2
collected 28 items / 4 deselected / 24 selected
test/test_dot.py .F......... [ 45%]
test/test_sums.py ............. [100%]
=================================== FAILURES ===================================
________________________ test_kdot2[1000000000000000.0] ________________________
cond = 1000000000000000.0
@pytest.mark.parametrize("cond", [1.0, 1.0e15])
def test_kdot2(cond):
x, y, ref, _ = accupy.generate_ill_conditioned_dot_product(100, cond)
> assert abs(accupy.kdot(x, y, K=2) - ref) < 1.0e-15 * abs(ref)
E AssertionError: assert mpf('0.000000000000000114084570757375210839671410496456786853711854747527032483134235008037649095058441162109375') < (1e-15 * mpf('0.03302009849489094927194480185983845556774002768261744316314525247296751686576499196235090494155883789063'))
E + where mpf('0.000000000000000114084570757375210839671410496456786853711854747527032483134235008037649095058441162109375') = abs((0.03302009849489106 - mpf('0.03302009849489094927194480185983845556774002768261744316314525247296751686576499196235090494155883789063')))
E + where 0.03302009849489106 = <function kdot at 0x11eede8c0>(array([ 5.10653219e+07, -1.35558140e+04, 1.16214778e+03, -7.64036713e+05,\n -4.15362782e+02, -5.10518025e+03, -7...8710e+01, -4.28172558e+00, 1.95177498e+00,\n 3.74687011e-01, -2.86712378e+00, 1.99264877e-02, 1.83323108e+00]), array([ 2.28091352e+07, -1.13769239e+04, 9.42159060e+02, 3.52913613e+05,\n 7.06341353e+01, -4.42719693e+03, 2...7027e-01, 2.37823667e+00, 3.99193374e+00,\n -3.83499060e+00, 1.10856098e+00, -1.75602080e+00, 7.20764693e-01]), K=2)
E + where <function kdot at 0x11eede8c0> = accupy.kdot
E + and mpf('0.03302009849489094927194480185983845556774002768261744316314525247296751686576499196235090494155883789063') = abs(mpf('0.03302009849489094927194480185983845556774002768261744316314525247296751686576499196235090494155883789063'))
test/test_dot.py:12: AssertionError
=========================== short test summary info ============================
FAILED test/test_dot.py::test_kdot2[1000000000000000.0] - AssertionError: ass...
================= 1 failed, 23 passed, 4 deselected in 14.64s ==================
A similar build with the same dependencies passes this test on x86_64 linux. I'm currently working on the Nix package for accupy
and obviously don't want to ship a broken package. Is this a showstopper?
Relevant dependencies:
/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh
/nix/store/x8sbijw81kcc2dcfycy2nm9yxnl5wrma-bash-4.4-p23.drv
/nix/store/87n9yqbs28rr1js0yxfwszdp8ldn0r2j-stdenv-darwin.drv
/nix/store/0nn6gan1407fc1mkh17zcpl1zn6rdxp9-python3-3.7.9.drv
/nix/store/13bk41y1aagcifilqwnr6x6rz0w0b2rf-python-recompile-bytecode-hook.drv
/nix/store/1l0n6pmfgfna1ffgk3g9w0v0shkzzqwv-accupy-0.3.2.tar.gz.drv
/nix/store/6qx7xgsyi25fwyxjcj2dz90k3xxcfs1b-python-imports-check-hook.sh.drv
/nix/store/8bzixyfrrdd3fni0dmh4nw5kknbi5xng-python-remove-bin-bytecode-hook.drv
/nix/store/bk2p76spz2ba25m3iw978m1zpwb6wgmx-hook.drv
/nix/store/g03kwd95zf3wrdp94a1nlvkbav9nlg4j-python-namespaces-hook.sh.drv
/nix/store/k4a197bybzv6jgkk7gjp59fgg64yv1gn-hook.drv
/nix/store/yrkgh4waq5pnv8gpsscfba3r1q0nhl6l-python-remove-tests-dir-hook.drv
/nix/store/bpyv1qgi6k3fjzq7ay4b8n5fp49bfp0h-python3.7-setuptools-47.3.1.drv
/nix/store/32ymxb64r5d31jijzq8h078zgw8pbfag-setuptools-check-hook.drv
/nix/store/4b61dddsswbmzr8xl1qvn4pk2zfmi2g5-python-catch-conflicts-hook.drv
/nix/store/ffx3x2c6chq7164bxsa3p0119mx0mxam-pip-install-hook.drv
/nix/store/mdr3rdy79bj3zvmnrz4k0mm7ipk4skzq-setuptools-setup-hook.drv
/nix/store/ahgmj7j0d95rjbgaq9wrgnv41dxcgb5p-python3.7-numpy-1.19.1.drv
/nix/store/m53dbcxp4mh1jla9q5ymdsvp70zfj8il-eigen-3.3.7.drv
/nix/store/kmx7gnv8nwzpf5wrr730m2jlr4qxvsnj-python3.7-pybind11-2.5.0.drv
/nix/store/4yy64nasiak07w39ghm0scp2x1qyxz7j-python3.7-pyfma-0.1.1.drv
/nix/store/7fpcagcz29gvsi2k4j6dqac6251gxhla-python3.7-matplotlib-3.3.1.drv
/nix/store/jzq99nkn3msjxb30lp1li6dn4wsrahvc-python3.7-mpmath-1.1.0.drv
/nix/store/pcn6qi5z4mhi2sc3mpzk9mlinn927svp-pytest-check-hook.drv
/nix/store/vj9md5s8d8h9w445qgf0syaljkir8rna-python3.7-pipdate-0.5.2.drv
nschloe commented
Can you check how far you'd have to relax the tolerance? 1.0e-15
is pretty strict, perhaps we should put 1.0e-13
there.
risicle commented
Well, from the output, the left hand side was ~1.14e-16
and the right hand side was ~ 3.3e-17
, so it was a pretty close thing.
nschloe commented
Just submit a PR then relaxing the tolerance to your needs, I'll merge and release it.