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

I1906 solution json #1909

Merged
merged 8 commits into from Jan 21, 2022
Merged

I1906 solution json #1909

merged 8 commits into from Jan 21, 2022

Conversation

martinjrobins
Copy link
Contributor

@martinjrobins martinjrobins commented Jan 21, 2022

Description

  • Allow Solution.save_data() to return a string if filename is None
  • add extra to_format of json

Fixes #1906

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov
Copy link

codecov bot commented Jan 21, 2022

Codecov Report

Merging #1909 (fb7f727) into develop (8384226) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1909   +/-   ##
========================================
  Coverage    99.32%   99.32%           
========================================
  Files          346      346           
  Lines        19121    19135   +14     
========================================
+ Hits         18992    19006   +14     
  Misses         129      129           
Impacted Files Coverage Δ
pybamm/solvers/solution.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8384226...fb7f727. Read the comment docs.

Copy link
Member

@valentinsulzer valentinsulzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me!


# check if string has the right values
json_data = json.loads(json_str)
np.testing.assert_array_almost_equal(json_data["c"], solution.data["c"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it only almost equal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was only copying the other lines of this test. But it would need to be almost equal, as the numbers (e.g. 1/3) will be rounded off when they are written to json

@martinjrobins martinjrobins merged commit 0393111 into develop Jan 21, 2022
@martinjrobins martinjrobins deleted the i1906-solution-json branch January 21, 2022 15:39
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.

save a pybamm solution object as json
2 participants