Opened 5 years ago

Closed 5 years ago

#16858 closed defect (fixed)

Print RDF and CDF elements with more digits

Reported by: jdemeyer Owned by:
Priority: blocker Milestone: sage-6.4
Component: basic arithmetic Keywords:
Cc: vbraun, zimmerma, tdumont, dimpase Merged in:
Authors: Jeroen Demeyer Reviewers: Volker Braun
Report Upstream: N/A Work issues:
Branch: 641e553 (Commits) Commit: 641e553ba86daad46813778c55e9073baf617a5f
Dependencies: #16889 Stopgaps:

Description (last modified by jdemeyer)

With the optional package cbc installed:

sage -t --long src/sage/numerical/mip.pyx
**********************************************************************
File "src/sage/numerical/mip.pyx", line 1470, in sage.numerical.mip.MixedIntegerLinearProgram.number_of_variables.add_constraint
Failed example:
    p.solve()     # rel tol 1e-15
Expected:
    6.666666666666666
Got:
    6.66666666667
Tolerance exceeded: 5e-13 > 1e-15
**********************************************************************
[...several similar failures not shown...]

The underlying reason is that the coin solver returns an RDF element, while the glpk solver returns a Python float. These are printed differently, even though they have the same value.

The branch here changes __repr__ for RDF and CDF elements and fixes tons of doctests. Other small fixes are switching __str__ and __repr__ for some classes in real_roots.pyx and some doctest reformatting.

Change History (44)

comment:1 Changed 5 years ago by jdemeyer

I'm working on a patch to change _repr_ for RDF and CDF. There are a lot of doctest failures, but I think it makes sense.

comment:2 Changed 5 years ago by dimpase

same happens when GUROBI is the default LP solver. In addition, GUROBI automatically gives constraints names, and this screws up even more doctests in this case.

comment:3 Changed 5 years ago by jdemeyer

  • Branch set to u/jdemeyer/ticket/16858
  • Created changed from 08/20/14 13:59:23 to 08/20/14 13:59:23
  • Modified changed from 08/21/14 13:00:39 to 08/21/14 13:00:39

comment:4 Changed 5 years ago by jdemeyer

  • Commit set to 4957ed4306eaa69b0b20a14b056c1ff3f6a6c19c
  • Component changed from linear programming to basic arithmetic
  • Description modified (diff)
  • Summary changed from Doctest failures when cbc is installed to Print RDF and CDF elements with more digits

New commits:

4957ed4Print RDF and CDF elements like Python floats

comment:5 Changed 5 years ago by git

  • Commit changed from 4957ed4306eaa69b0b20a14b056c1ff3f6a6c19c to 9293ea3a5e8f5ef215159ee5e46cc36e754cc52d

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

9293ea3Print RDF and CDF elements like Python floats

comment:6 Changed 5 years ago by git

  • Commit changed from 9293ea3a5e8f5ef215159ee5e46cc36e754cc52d to e1a218252aa87ecec15e4ba3e2dcd5f9532b3b06

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

e1a2182Print RDF and CDF elements like Python floats

comment:7 Changed 5 years ago by git

  • Commit changed from e1a218252aa87ecec15e4ba3e2dcd5f9532b3b06 to e1bc1645ab4edae4f0d41eb608c600d01a903847

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

e1bc164Print RDF and CDF elements like Python floats

comment:8 Changed 5 years ago by jdemeyer

  • Dependencies set to #16889

comment:9 follow-up: Changed 5 years ago by dimpase

Should we test this on ARM? There might be quite a bit of extra numerical noise...

comment:10 in reply to: ↑ 9 Changed 5 years ago by jdemeyer

Replying to dimpase:

Should we test this on ARM?

When this ticket has been set to needs_review, yes please.

There might be quite a bit of extra numerical noise...

I am also afraid of that.

comment:11 Changed 5 years ago by git

  • Commit changed from e1bc1645ab4edae4f0d41eb608c600d01a903847 to b95a636f5983dd1092423bad64a9201decc77013

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

291a442Doctest tolerance: allow spaces
b95a636Print RDF and CDF elements like Python floats

comment:12 Changed 5 years ago by jdemeyer

  • Authors set to Jeroen Demeyer

comment:13 Changed 5 years ago by git

  • Commit changed from b95a636f5983dd1092423bad64a9201decc77013 to 2421bfa9233bf9b49bd347b22e4ac08cfad9d645

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

2421bfaPrint RDF and CDF elements like Python floats

comment:14 Changed 5 years ago by git

  • Commit changed from 2421bfa9233bf9b49bd347b22e4ac08cfad9d645 to ca60d8a3b0c600b7048967b42446fb232436d7d6

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

dde3a3aUse intervals for doctest tolerances
ca60d8aPrint RDF and CDF elements like Python floats

comment:15 Changed 5 years ago by git

  • Commit changed from ca60d8a3b0c600b7048967b42446fb232436d7d6 to e595a20bfe084744e281a78792b737105f2c7d96

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

e595a20Print RDF and CDF elements like Python floats

comment:16 Changed 5 years ago by vbraun

Conflicts with 6.4.beta2. Let me know if I should wait for this ticket...

comment:17 Changed 5 years ago by git

  • Commit changed from e595a20bfe084744e281a78792b737105f2c7d96 to 1fe0898c5249af0b9377cff728c9fe56426fe3a5

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

3ede5ecMerge branch 'ticket/16889' into HEAD
1fe0898Print RDF and CDF elements like Python floats

comment:18 Changed 5 years ago by git

  • Commit changed from 1fe0898c5249af0b9377cff728c9fe56426fe3a5 to 7b858a2c569fb5f973fb49007d38064d5df1978f

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

59b511eAdd tolerance test file
2938a29Merge remote-tracking branch 'origin/develop' into HEAD
7b858a2Print RDF and CDF elements like Python floats

comment:19 Changed 5 years ago by git

  • Commit changed from 7b858a2c569fb5f973fb49007d38064d5df1978f to 1c5cd881d6c039e7d154020d36af524240fe3b37

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

1c5cd88Print RDF and CDF elements like Python floats

comment:20 Changed 5 years ago by jdemeyer

  • Status changed from new to needs_review

This is now ready for testing. Volker, could you run this on the buildbots please and report back? It's not yet tested on OS X, so I expect some doctest failures.

comment:21 Changed 5 years ago by jdemeyer

  • Cc zimmerma added

This also needs some changes to the French book...

comment:22 follow-up: Changed 5 years ago by vbraun

I a couple of failures like this on my laptop:

sage -t src/sage/matrix/matrix_double_dense.pyx
**********************************************************************
File "src/sage/matrix/matrix_double_dense.pyx", line 3842, in sage.matrix.matrix_double_dense.Matrix_double_dense.exp
Failed example:
    A.exp(algorithm='eig')  # tol 1e-14
Expected:
    [-19.614602953804923 + 12.51774384676257*I 3.7949636449582016 + 28.883799306580997*I]
    [-32.38358098092227 + 21.884235957898433*I  2.2696330040935084 + 44.90132482768484*I]
Got:
    [-19.614602953804923 + 12.517743846762574*I   3.794963644958207 + 28.883799306580997*I]
    [ -32.38358098092226 + 21.884235957898447*I  2.2696330040935333 + 44.901324827684824*I]
Tolerance exceeded in 1 of 8:
    2.2696330040935084 vs 2.2696330040935333, tolerance 1e-14 > 1e-14

At least the 1e-14 > 1e-14 is wrong ;-)

comment:23 Changed 5 years ago by vbraun

I just started to run this ticket on the buildbot (http://build.sagemath.org/sage/waterfall?category=incremental)

comment:24 in reply to: ↑ 22 Changed 5 years ago by jdemeyer

Replying to vbraun:

At least the 1e-14 > 1e-14 is wrong ;-)

I don't know if you're joking or not, but the left 1e-14 is actually 1.097e-14 printed with 1 significant digit. I didn't change that, but if you think that tolerances should be printed with more precision, that can easily be done on #16889.

comment:25 Changed 5 years ago by zimmerma

  • Cc tdumont added

Thierry Dumont will have a look at the changes implied for the french book, but not before Wednesday.

Paul

comment:26 Changed 5 years ago by git

  • Commit changed from 1c5cd881d6c039e7d154020d36af524240fe3b37 to 40dbfc4c4b0ac47d24a8d9c97824f6f7b542d5a7

Branch pushed to git repo; I updated commit sha1. New commits:

40dbfc4Fix numerical noise on various systems

comment:27 Changed 5 years ago by vbraun

Still getting two failures on my laptop:

sage -t src/sage/matrix/matrix2.pyx
**********************************************************************
File "src/sage/matrix/matrix2.pyx", line 12209, in sage.matrix.matrix2.Matrix.diagonal.norm
Failed example:
    A.norm(2)
Expected:
    5.470684443210384
Got:
    5.470684443210385
**********************************************************************

and

sage -t src/sage/modular/modform/numerical.py
**********************************************************************
File "src/sage/modular/modform/numerical.py", line 463, in sage.modular.modform.numerical.NumericalEigenforms.systems_of_eigenvalues
Failed example:
    numerical_eigenforms(61).systems_of_eigenvalues(10)  # rel tol 1e-14
Expected:
    [
    [-1.4811943040920152, 0.8060634335253695, 3.1563251746586642, 0.6751308705666477],
    [-1.0, -2.0000000000000027, -3.000000000000003, 1.0000000000000044],
    [0.3111078174659775, 2.903211925911551, -2.525427560843529, -3.214319743377552],
    [2.170086486626034, -1.7092753594369208, -1.63089761381512, -0.46081112718908984],
    [3.0, 4.0, 6.0, 8.0]
    ]
Got:
    [
    [-1.4811943040920152, 0.8060634335253695, 3.1563251746586642, 0.6751308705666477],
    [-1.0000000000000007, -2.000000000000002, -3.000000000000004, 1.0000000000000024],
    [0.3111078174659775, 2.903211925911551, -2.525427560843529, -3.214319743377552],
    [2.1700864866260345, -1.7092753594369194, -1.6308976138151292, -0.46081112718909495],
    [3.0, 4.0, 6.0, 8.0]
    ]
Tolerance exceeded in 1 of 20:
    -0.46081112718908984 vs -0.46081112718909495, tolerance 1e-14 > 1e-14
**********************************************************************
File "src/sage/modular/modform/numerical.py", line 490, in sage.modular.modform.numerical.NumericalEigenforms.systems_of_abs
Failed example:
    numerical_eigenforms(61).systems_of_abs(10)  # rel tol 1e-14
Expected:
    [
    [0.3111078174659775, 2.903211925911551, 2.525427560843529, 3.214319743377552],
    [1.0, 2.0000000000000027, 3.000000000000003, 1.0000000000000044],
    [1.4811943040920152, 0.8060634335253695, 3.1563251746586642, 0.6751308705666477],
    [2.170086486626034, 1.7092753594369208, 1.63089761381512, 0.46081112718908984],
    [3.0, 4.0, 6.0, 8.0]
    ]
Got:
    [
    [0.3111078174659775, 2.903211925911551, 2.525427560843529, 3.214319743377552],
    [1.0000000000000007, 2.000000000000002, 3.000000000000004, 1.0000000000000024],
    [1.4811943040920152, 0.8060634335253695, 3.1563251746586642, 0.6751308705666477],
    [2.1700864866260345, 1.7092753594369194, 1.6308976138151292, 0.46081112718909495],
    [3.0, 4.0, 6.0, 8.0]
    ]
Tolerance exceeded in 1 of 20:
    0.46081112718908984 vs 0.46081112718909495, tolerance 1e-14 > 1e-14
**********************************************************************
2 items had failures:
   1 of   2 in sage.modular.modform.numerical.NumericalEigenforms.systems_of_abs
   1 of   2 in sage.modular.modform.numerical.NumericalEigenforms.systems_of_eigenvalues

Re-running on the buildbot right now.

comment:28 Changed 5 years ago by vbraun

Passed on the buildbot.

comment:29 Changed 5 years ago by git

  • Commit changed from 40dbfc4c4b0ac47d24a8d9c97824f6f7b542d5a7 to b86821f5c785e49b7bc8ba3b2542163d3f1648d4

Branch pushed to git repo; I updated commit sha1. New commits:

b86821fFix numerical noise on one more system

comment:30 Changed 5 years ago by vbraun

  • Cc dimpase added

ARM tests: http://boxen.math.washington.edu/home/vbraun/logs/arm-ptestlong.log

Dima: what is the status with ARM float precision (before this ticket)?

comment:31 Changed 5 years ago by dimpase

IIRC, #15921 fixed all precision things. As the precision has increased, no wonder that few tests now fail.

comment:32 Changed 5 years ago by vbraun

Indeed, all tests pass on ARM without this ticket.

comment:33 Changed 5 years ago by git

  • Commit changed from b86821f5c785e49b7bc8ba3b2542163d3f1648d4 to d3b1d0b4839997338b847a4741c69ad95896d358

Branch pushed to git repo; I updated commit sha1. New commits:

d3b1d0bFix doctests on ARM

comment:34 Changed 5 years ago by vbraun

  • Reviewers set to Volker Braun

comment:35 Changed 5 years ago by vbraun

You missed one failing doctest:

sage -t --long src/sage/modular/modform/numerical.py
**********************************************************************
File "src/sage/modular/modform/numerical.py", line 463, in sage.modular.modform.numerical.NumericalEigenforms.systems_of_eigenvalues
Failed example:
    numerical_eigenforms(61).systems_of_eigenvalues(10)  # rel tol 2e-14
Expected:
    [
    [-1.4811943040920152, 0.8060634335253695, 3.1563251746586642, 0.6751308705666477],
    [-1.0, -2.0000000000000027, -3.000000000000003, 1.0000000000000044],
    [0.3111078174659775, 2.903211925911551, -2.525427560843529, -3.214319743377552],
    [2.170086486626034, -1.7092753594369208, -1.63089761381512, -0.46081112718908984],
    [3.0, 4.0, 6.0, 8.0]
    ]
Got:
    [
    [-1.4811943040920152, 0.806063433525369, 3.156325174658668, 0.675130870566654],
    [-1.0000000000000024, -1.9999999999999993, -2.999999999999994, 1.0000000000000067],
    [0.3111078174659905, 2.9032119259115587, -2.525427560843502, -3.214319743377512],
    [2.170086486626031, -1.7092753594369192, -1.6308976138151232, -0.46081112718909467],
    [3.0, 4.0, 6.0, 8.0]
    ]
Tolerance exceeded in 1 of 20:
    0.3111078174659775 vs 0.3111078174659905, tolerance 4e-14 > 2e-14
**********************************************************************
File "src/sage/modular/modform/numerical.py", line 490, in sage.modular.modform.numerical.NumericalEigenforms.systems_of_abs
Failed example:
    numerical_eigenforms(61).systems_of_abs(10)  # rel tol 2e-14
Expected:
    [
    [0.3111078174659775, 2.903211925911551, 2.525427560843529, 3.214319743377552],
    [1.0, 2.0000000000000027, 3.000000000000003, 1.0000000000000044],
    [1.4811943040920152, 0.8060634335253695, 3.1563251746586642, 0.6751308705666477],
    [2.170086486626034, 1.7092753594369208, 1.63089761381512, 0.46081112718908984],
    [3.0, 4.0, 6.0, 8.0]
    ]
Got:
    [
    [0.3111078174659905, 2.9032119259115587, 2.525427560843502, 3.214319743377512],
    [1.0000000000000024, 1.9999999999999993, 2.999999999999994, 1.0000000000000067],
    [1.4811943040920152, 0.806063433525369, 3.156325174658668, 0.675130870566654],
    [2.170086486626031, 1.7092753594369192, 1.6308976138151232, 0.46081112718909467],
    [3.0, 4.0, 6.0, 8.0]
    ]
Tolerance exceeded in 1 of 20:
    0.3111078174659775 vs 0.3111078174659905, tolerance 4e-14 > 2e-14
**********************************************************************
2 items had failures:
   1 of   2 in sage.modular.modform.numerical.NumericalEigenforms.systems_of_abs
   1 of   2 in sage.modular.modform.numerical.NumericalEigenforms.systems_of_eigenvalues
    [46 tests, 2 failures, 1.53 s]

comment:36 Changed 5 years ago by jdemeyer

  • Status changed from needs_review to needs_work

comment:37 Changed 5 years ago by git

  • Commit changed from d3b1d0b4839997338b847a4741c69ad95896d358 to 641e553ba86daad46813778c55e9073baf617a5f

Branch pushed to git repo; I updated commit sha1. New commits:

641e553Fix more doctests on ARM

comment:38 Changed 5 years ago by jdemeyer

  • Status changed from needs_work to needs_review

New commits:

641e553Fix more doctests on ARM

comment:39 Changed 5 years ago by vbraun

  • Status changed from needs_review to positive_review

comment:40 Changed 5 years ago by zimmerma

if there are any changes in tests/french_book, I'd like we check them first (see comment 25), otherwise this might invalidate some examples we give in our book.

Paul

comment:41 Changed 5 years ago by vbraun

Per your comment, you have time until tomorrow ;-)

comment:42 Changed 5 years ago by vbraun

  • Status changed from positive_review to needs_review

comment:43 Changed 5 years ago by vbraun

  • Status changed from needs_review to positive_review

Its only adding precision to the output, I think this should be uncontroversial.

comment:44 Changed 5 years ago by vbraun

  • Branch changed from u/jdemeyer/ticket/16858 to 641e553ba86daad46813778c55e9073baf617a5f
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.