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

Standardise printing of significant digits in results #170

Closed
smishr opened this issue Jan 9, 2023 · 3 comments · Fixed by #172
Closed

Standardise printing of significant digits in results #170

smishr opened this issue Jan 9, 2023 · 3 comments · Fixed by #172
Labels
food for thought High level ideas/links or thoughts for long run dev of project
Milestone

Comments

@smishr
Copy link
Contributor

smishr commented Jan 9, 2023

There should be logical consistency in how many significant digits are printed or shown as the result. This maybe different to the actual evaluated result (which may have floating point issues).

Eg.

julia> apisrs = load_data("apisrs");

julia> srs = SurveyDesign(apisrs; weights = :pw) |> bootweights

julia> tot = total(:api00, srs)
1×2 DataFrame
 Row │ total      SE
     │ Float64    Float64
─────┼────────────────────
   14.06689e6  57644.8

julia> mn = mean(:api00, srs)
1×2 DataFrame
 Row │ mean     SE
     │ Float64  Float64
─────┼──────────────────
   1656.585  9.30656

Above, 656.585 is printed answer, but the actual evaluated value is 656.5849999999991.

In R

> srs <- svydesign(data=apisrs, weights=~pw,fpc=~fpc)
> svytotal(~api00, srs)
        total    SE
api00 4066888 58241

What can be suitable strategy for consistent printing?

@smishr smishr added the food for thought High level ideas/links or thoughts for long run dev of project label Jan 9, 2023
@smishr smishr added this to the 0.3.0 release milestone Jan 9, 2023
@iuliadmtru
Copy link
Contributor

There is a way to configure your REPL using IOContext. The relevant option in our case is probably :compact, but that is already set to true by default. There is no option to choose whether to suppress scientific notation of not (at least I couldn't find one). See also this discussion or the Julia documentation for prompt modes. Maybe printf can also be used for this purpose, although I don't really see how. This is not exactly what you're saying, since this is something that the user must configure, not a standard that we can give.

However, I don't think we need this standard. Maybe there's a way to suppress scientific notation, but I don't think we should enforce this in our package. The user can configure this on their own, the way they prefer it. This is more a matter of taste.

@smishr
Copy link
Contributor Author

smishr commented Jan 9, 2023

okay. lets not worry too much about it for now.

@smishr
Copy link
Contributor Author

smishr commented Jan 15, 2023

I think by changing from sigdigits to digits in #172 it achieves the above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
food for thought High level ideas/links or thoughts for long run dev of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants