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

Show of Vector{Particles} #92

Open
mauro3 opened this issue Sep 29, 2020 · 5 comments
Open

Show of Vector{Particles} #92

mauro3 opened this issue Sep 29, 2020 · 5 comments

Comments

@mauro3
Copy link

mauro3 commented Sep 29, 2020

The show method seems to to some rounding with particles in an array:

julia> [10000+i ± 0.5 for i=1:10:50]
5-element Array{Particles{Float64,2000},1}:
 10000.0 ± 0.5
 10000.0 ± 0.5
 10000.0 ± 0.5
 10000.0 ± 0.5
 10000.0 ± 0.5

julia> ans[1]
Particles{Float64,2000}
 10001.0 ± 0.5

Is this intentional? If so, then it should take into account the significant digits according to the uncertainty.

@baggepinnen
Copy link
Owner

It's intentional, but poorly implemented at the moment

# TODO: be smart and select sig digits based on s

Should probably use printf instead of the round function with sigdigits keyword?

@mauro3
Copy link
Author

mauro3 commented Sep 30, 2020

Should it be different between arrays and scalars?

@baggepinnen
Copy link
Owner

The idea is to not overwhelm the user with too many digits, similar to the difference

julia> rand()
0.22107097572682943

julia> rand(3,3)
3×3 Array{Float64,2}:
 0.831273  0.407677   0.509738
 0.924296  0.0520808  0.925542
 0.17117   0.44741    0.224877

But I think sigdigits does not do what I wanted, I wanted something similar to

julia> @printf("%4.3g", 10001.0)
1e+04

Ideally, the number of digits to show should depend on the standard deviation of the sample. There is no point in showing many digits of the mean if they are not significant.

@mauro3
Copy link
Author

mauro3 commented Sep 30, 2020

deally, the number of digits to show should depend on the standard deviation of the sample. There is no point in showing many digits of the mean if they are not significant.

Sounds good. So, for instance:

julia> 10001.0578 ± 0.01
Particles{Float64,2000}
 10001.0 ± 0.01

should print as 10001.05 ± 0.01.

@baggepinnen
Copy link
Owner

Something like that, yes :)
With a upper bound on the number of digits to show in the array case.

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

No branches or pull requests

2 participants