DESC icon indicating copy to clipboard operation
DESC copied to clipboard

Add easier to read print option

Open YigitElma opened this issue 1 year ago • 7 comments

Add an option to print start and end errors next to each other for easier comparison. Resolves #1112

Start of solver   -->   End of solver
Total (sum of squares):  6.409e+01  -->   1.523e-03, 
Maximum absolute Quasi-symmetry error:  4.730e+02   -->   2.086e+00( T^4/m^2)
Minimum absolute Quasi-symmetry error:  4.422e-04   -->   2.614e-05 (T^4/m^2)
Average absolute Quasi-symmetry error:  1.117e+01   -->   1.081e-01 (T^4/m^2)
Maximum absolute Quasi-symmetry error:  4.183e+00   -->   1.845e-02 (normalized)
Minimum absolute Quasi-symmetry error:  3.910e-06   -->   2.312e-07 (normalized)
Average absolute Quasi-symmetry error:  9.879e-02   -->   9.560e-04 (normalized)
Maximum absolute Force error:  1.516e+05   -->   1.611e+04 (N)
Minimum absolute Force error:  2.431e+00   -->   2.379e-01 (N)
Average absolute Force error:  5.922e+03   -->   7.447e+02 (N)
Maximum absolute Force error:  8.198e-03   -->   8.715e-04 (normalized)
Minimum absolute Force error:  1.315e-07   -->   1.287e-08 (normalized)
Average absolute Force error:  3.203e-04   -->   4.028e-05 (normalized)
R boundary error:  0.000e+00   -->   0.000e+00 (m)
Z boundary error:  0.000e+00   -->   0.000e+00 (m)
Fixed pressure profile error:  0.000e+00   -->   1.608e-13 (Pa)
Fixed iota profile error:  0.000e+00   -->   0.000e+00 (dimensionless)
Fixed Psi error:  0.000e+00   -->   0.000e+00 (Wb)

YigitElma avatar Aug 13 '24 21:08 YigitElma

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -0.94 +/- 11.25    | -4.93e-03 +/- 5.91e-02 |  5.20e-01 +/- 3.7e-02  |  5.25e-01 +/- 4.6e-02  |
 test_build_transform_fft_midres         |     -2.28 +/- 7.86     | -1.41e-02 +/- 4.86e-02 |  6.04e-01 +/- 2.2e-02  |  6.18e-01 +/- 4.3e-02  |
 test_build_transform_fft_highres        |     -2.44 +/- 6.55     | -2.54e-02 +/- 6.81e-02 |  1.01e+00 +/- 2.8e-02  |  1.04e+00 +/- 6.2e-02  |
 test_equilibrium_init_lowres            |     +2.10 +/- 7.64     | +8.11e-02 +/- 2.95e-01 |  3.94e+00 +/- 2.3e-01  |  3.86e+00 +/- 1.9e-01  |
 test_equilibrium_init_medres            |     -5.90 +/- 5.72     | -2.71e-01 +/- 2.63e-01 |  4.32e+00 +/- 1.3e-01  |  4.59e+00 +/- 2.3e-01  |
 test_equilibrium_init_highres           |     -4.92 +/- 3.25     | -2.96e-01 +/- 1.95e-01 |  5.71e+00 +/- 1.5e-01  |  6.01e+00 +/- 1.2e-01  |
 test_objective_compile_dshape_current   |     -1.41 +/- 1.66     | -5.70e-02 +/- 6.71e-02 |  3.98e+00 +/- 5.6e-02  |  4.04e+00 +/- 3.7e-02  |
-test_objective_compile_atf              |     +8.41 +/- 2.55     | +6.57e-01 +/- 1.99e-01 |  8.47e+00 +/- 1.9e-01  |  7.81e+00 +/- 5.7e-02  |
 test_objective_compute_dshape_current   |    +11.41 +/- 6.10     | +3.95e-04 +/- 2.11e-04 |  3.86e-03 +/- 2.0e-04  |  3.46e-03 +/- 6.7e-05  |
-test_objective_compute_atf              |    +14.87 +/- 2.44     | +1.52e-03 +/- 2.50e-04 |  1.17e-02 +/- 2.2e-04  |  1.02e-02 +/- 1.3e-04  |
 test_objective_jac_dshape_current       |     +8.63 +/- 7.15     | +3.48e-03 +/- 2.88e-03 |  4.38e-02 +/- 2.7e-03  |  4.03e-02 +/- 1.0e-03  |
 test_objective_jac_atf                  |     +4.34 +/- 3.23     | +8.32e-02 +/- 6.18e-02 |  2.00e+00 +/- 3.5e-02  |  1.91e+00 +/- 5.1e-02  |
-test_perturb_1                          |    +13.67 +/- 1.85     | +1.66e+00 +/- 2.25e-01 |  1.38e+01 +/- 2.1e-01  |  1.22e+01 +/- 7.8e-02  |
 test_perturb_2                          |     +5.27 +/- 4.82     | +9.13e-01 +/- 8.36e-01 |  1.82e+01 +/- 8.2e-01  |  1.73e+01 +/- 1.8e-01  |
 test_proximal_jac_atf                   |     +1.14 +/- 1.46     | +9.24e-02 +/- 1.19e-01 |  8.23e+00 +/- 1.1e-01  |  8.13e+00 +/- 4.8e-02  |
 test_proximal_freeb_compute             |     +2.02 +/- 1.94     | +3.68e-03 +/- 3.53e-03 |  1.85e-01 +/- 2.9e-03  |  1.82e-01 +/- 2.0e-03  |
 test_proximal_freeb_jac                 |     +1.22 +/- 2.17     | +9.02e-02 +/- 1.60e-01 |  7.47e+00 +/- 1.3e-01  |  7.38e+00 +/- 9.6e-02  |
 test_solve_fixed_iter                   |     +0.21 +/- 58.95    | +1.04e-02 +/- 2.91e+00 |  4.94e+00 +/- 2.0e+00  |  4.93e+00 +/- 2.1e+00  |

github-actions[bot] avatar Aug 13 '24 23:08 github-actions[bot]

Codecov Report

Attention: Patch coverage is 98.80952% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.42%. Comparing base (69ef318) to head (4e4627e). Report is 56 commits behind head on master.

Files Patch % Lines
desc/objectives/objective_funs.py 95.55% 2 Missing :warning:
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1189   +/-   ##
=======================================
  Coverage   95.42%   95.42%           
=======================================
  Files          89       89           
  Lines       22434    22493   +59     
=======================================
+ Hits        21407    21465   +58     
- Misses       1027     1028    +1     
Files Coverage Δ
desc/objectives/_bootstrap.py 97.14% <100.00%> (ø)
desc/objectives/_coils.py 99.14% <100.00%> (ø)
desc/objectives/_equilibrium.py 94.95% <100.00%> (ø)
desc/objectives/_free_boundary.py 97.02% <100.00%> (+0.16%) :arrow_up:
desc/objectives/_generic.py 97.52% <100.00%> (ø)
desc/objectives/_geometry.py 96.94% <100.00%> (ø)
desc/objectives/_omnigenity.py 96.30% <100.00%> (ø)
desc/objectives/_profiles.py 97.36% <100.00%> (ø)
desc/objectives/_stability.py 98.76% <100.00%> (ø)
desc/objectives/linear_objectives.py 97.05% <100.00%> (+<0.01%) :arrow_up:
... and 3 more

... and 1 file with indirect coverage changes

codecov[bot] avatar Aug 14 '24 06:08 codecov[bot]

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Are black and linting tests failing due to the high number of lines changed or some server error? I have tried to re-run them several times, but they fail anyway.

YigitElma avatar Aug 15 '24 05:08 YigitElma

Are black and linting tests failing due to the high number of lines changed or some server error? I have tried to re-run them several times, but they fail anyway.

There was an outage earlier that killed a bunch of CI jobs, might still be kind of buggy. Usually just wait a few hours and retry

f0uriest avatar Aug 15 '24 05:08 f0uriest

Black and linting tests give a timeout type error. I assume that is because of the high number of lines changed (I decreased the resolution of 3D plot while I was re-running the notebooks, it still looks good, but it decreased the file size 30Mb!). Actual code changes are around 200 lines at most. The recommit passed everything locally

YigitElma avatar Aug 15 '24 17:08 YigitElma

I'd like all the -> to align with each other, so that printing looks like:

So, I thought about it after @ddudt suggested yesterday, but I have couple concern. Let's say we specify a max length according to the longest objective print name, then even if we don't have that objective, we will have a spacing. For example in the text you sent

Maximum absolute Force error:           1.516e+05   -->   1.611e+04(N)
Minimum absolute Force error:           2.431e+00   -->   2.379e-01(N)
Average absolute Force error:           5.922e+03   -->   7.447e+02(N)
Maximum absolute Force error:           8.198e-03   -->   8.715e-04(normalized)
Minimum absolute Force error:           1.315e-07   -->   1.287e-08(normalized)
Average absolute Force error:           3.203e-04   -->   4.028e-05(normalized)
R boundary error:                       0.000e+00   -->   0.000e+00(m)
Z boundary error:                       0.000e+00   -->   0.000e+00(m)
Fixed pressure profile error:           0.000e+00   -->   1.608e-13(Pa)
Fixed iota profile error:               0.000e+00   -->   0.000e+00(dimensionless)
Fixed Psi error:                        0.000e+00   -->   0.000e+00(Wb)

I can add a for loop before the main print for loop to get the longest name and decide the padding according to that. But I would rather do that if everybody wants this.

YigitElma avatar Aug 15 '24 18:08 YigitElma

The _print_value_fmt of Bootstrap self consistency objective is the longest, I chose the width for that

Maximum absolute Bootstrap current self-consistency error:   1.013e-01  -->   1.013e-01 (T A m^-2)

That is why other objectives will have some extra spacing. Having a for loop to determine the width seems a bit too much effort and edit for the source code (and the test that have manual prints)

YigitElma avatar Aug 18 '24 17:08 YigitElma

if you want a nitpick, my personal preference is one line of dashes "-" to a line of "= and/or +". either way thanks for doing this

unalmis avatar Aug 19 '24 16:08 unalmis

if you want a nitpick, my personal preference is one line of dashes "-" to a line of "= and/or +". either way thanks for doing this

I tried - first, it looked a bit weak. At least for me, = acts better up to its name as divider :smile:

YigitElma avatar Aug 19 '24 18:08 YigitElma

This looks so much better!

I think the line breaks \n are excessive since we already separate the sections with the diving line ====, but I'm fine with it if everyone else prefers having the line breaks

It is again up to the general vote, but I feel like, especially when you run something like solve_continuation_automatic, our stdouts get too long and I would like to make them modularized.

YigitElma avatar Aug 19 '24 18:08 YigitElma

run black and flake8 on repo then we will commit

dpanici avatar Aug 21 '24 19:08 dpanici