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

[BUG] json (pas-file) float precision #353

Closed
dbrakenhoff opened this issue Dec 6, 2021 · 1 comment
Closed

[BUG] json (pas-file) float precision #353

dbrakenhoff opened this issue Dec 6, 2021 · 1 comment
Assignees
Labels
bug Indicates an unintended behavior or coding error
Milestone

Comments

@dbrakenhoff
Copy link
Member

Describe the bug
The float precision when calling DataFrame.to_json() is 10 by default (max 15) and stores numbers in decimal format when it would be much more logical to store most values in scientific format. This means that after loading a model from a pas-file, the float precision is affected which can lead to unexpected results.

To Reproduce
Get some model with a very small parameter value somewhere in ml.parameters or ml.fit.pcov and then store model as pas file:

ml.to_file(f"{ml.name}.pas")
ml2 = ps.io.load(f"{ml.name}.pas")
# try one of these, depending on which DataFrame contains the small float value
ml.fit.pcov.equals(ml2.fit.pcov)
ml.parameters.equals(ml2.parameters)

Expected behavior
Store values with higher precision and scientific notation in pas files.

@dbrakenhoff dbrakenhoff added the bug Indicates an unintended behavior or coding error label Dec 6, 2021
@dbrakenhoff dbrakenhoff self-assigned this Dec 6, 2021
@dbrakenhoff dbrakenhoff added this to the 0.19.0 milestone Dec 6, 2021
dbrakenhoff added a commit that referenced this issue Dec 6, 2021
- ensure float precision is maintained when writing model to pas file
- modify load test to check for this
@dbrakenhoff
Copy link
Member Author

Closed by #354

dbrakenhoff added a commit that referenced this issue Dec 7, 2021
Fix #353, precision of floats in JSON files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unintended behavior or coding error
Projects
None yet
Development

No branches or pull requests

1 participant