Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Fix printing values with too few decimals #4575

Merged
merged 2 commits into from
Apr 2, 2020

Conversation

janezd
Copy link
Contributor

@janezd janezd commented Mar 26, 2020

Issue

Fixes #4555.

Description of changes

Print two more decimals when the format is not %g and the difference from the rounded values is outside numeric error.

Includes
  • Code changes
  • Tests

@codecov
Copy link

codecov bot commented Mar 26, 2020

Codecov Report

Merging #4575 into master will decrease coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4575      +/-   ##
==========================================
- Coverage   83.59%   83.56%   -0.03%     
==========================================
  Files         281      276       -5     
  Lines       56131    55331     -800     
==========================================
- Hits        46921    46236     -685     
+ Misses       9210     9095     -115     

@markotoplak
Copy link
Member

This PR makes printing tables slower, but this operation does not need to be fast. It does not influence saving data, because the writer has its own formatter. Here are the differences between master and this branch:

[str_val_decimals] with 10 loops, best of 3:
	min 797 usec per loop
	avg 824 usec per loop
[str_val_g] with 10 loops, best of 3:
	min 681 usec per loop
	avg 728 usec per loop
[print_dense] with 10 loops, best of 3:
	min 1.98 msec per loop
	avg 2.02 msec per loop
[print_dense_decimals] with 10 loops, best of 3:
	min 2.1 msec per loop
	avg 2.16 msec per loop


[str_val_decimals] with 10 loops, best of 3:
	min 2.51 msec per loop
	avg 2.7 msec per loop
[str_val_g] with 10 loops, best of 3:
	min 1.01 msec per loop
	avg 1.04 msec per loop
[print_dense] with 10 loops, best of 3:
	min 2.45 msec per loop
	avg 2.47 msec per loop
[print_dense_decimals] with 10 loops, best of 3:
	min 11.7 msec per loop
	avg 11.9 msec per loop

@markotoplak markotoplak merged commit bd2f7ec into biolab:master Apr 2, 2020
@janezd janezd deleted the str-val-more-decimals branch April 2, 2020 09:55
@janezd
Copy link
Contributor Author

janezd commented Apr 2, 2020

Excellent, thanks!

And even these differences are not too large.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Values of numeric variables should sometimes show more decimals
2 participants