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

Add write_hdf to SolutionArray objects #680

Merged
merged 1 commit into from
Aug 13, 2019

Conversation

ischoegl
Copy link
Member

@ischoegl ischoegl commented Aug 6, 2019

Please fill in the issue number this pull request is fixing:

Fixes #679

Changes proposed in this pull request:

  • The commit implements saving of data extracted from SolutionArrays to HDF containers using pandas infrastructure.
  • The method only works if the pandas module can be imported; an exception is only raised if the method is called without a working pandas installation.

A simple example for the intended use would be:

# create SolutionArray and/or run some manipulations
states = ct.SolutionArray(gas, 10)
...

states.write_hdf('some_file.h5')

@ischoegl ischoegl force-pushed the add-write-hdf-to-solution-array branch 3 times, most recently from dec7fa2 to f39e122 Compare August 6, 2019 18:00
@codecov
Copy link

codecov bot commented Aug 6, 2019

Codecov Report

Merging #680 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #680      +/-   ##
==========================================
+ Coverage   70.62%   70.62%   +<.01%     
==========================================
  Files         372      372              
  Lines       43565    43565              
==========================================
+ Hits        30768    30769       +1     
+ Misses      12797    12796       -1
Impacted Files Coverage Δ
src/transport/GasTransport.cpp 90.58% <0%> (+0.2%) ⬆️

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 bbdc790...f39e122. Read the comment docs.

@bryanwweber
Copy link
Member

Does pandas require a particular HDF5 package? I don't think that's a default dependency of Pandas, but I could be wrong

@ischoegl
Copy link
Member Author

ischoegl commented Aug 6, 2019

@bryanwweber ... it uses PyTables as backend. I keep a pretty sparse build tool chain, and apt-get install python3-pandas took care of everything. Haven't checked pip yet, but can look into this.

@ischoegl
Copy link
Member Author

ischoegl commented Aug 6, 2019

PS: if this has legs, I am still planning on implementing unit tests, but wanted to get some feedback before getting into the CI settings.

Copy link
Member

@bryanwweber bryanwweber left a comment

Choose a reason for hiding this comment

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

I'm definitely in favor of this change, just some minor comments. I also don't think there's much to test here, since all of the functionality is either tested elsewhere (collect_states()) or part of the Pandas package, which we don't really need to test.

I'm also interested in how a pip-installed or conda-installed Pandas manages the HDF5 dependency.

interfaces/cython/cantera/composite.py Outdated Show resolved Hide resolved
interfaces/cython/cantera/composite.py Outdated Show resolved Hide resolved
@bryanwweber
Copy link
Member

I forgot to mention in the review, there's a few places where pandas should be uppercase Pandas in the docstring.

@ischoegl ischoegl force-pushed the add-write-hdf-to-solution-array branch from f39e122 to 99f3540 Compare August 7, 2019 17:05
@ischoegl
Copy link
Member Author

ischoegl commented Aug 7, 2019

Alright. pip dependencies require pandas and tables (i.e. Pandas and PyTables). Docstring is updated accordingly.

@ischoegl ischoegl force-pushed the add-write-hdf-to-solution-array branch from 99f3540 to 5c9e348 Compare August 7, 2019 17:09
@codecov
Copy link

codecov bot commented Aug 7, 2019

Codecov Report

Merging #680 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #680      +/-   ##
==========================================
+ Coverage   70.62%   70.62%   +<.01%     
==========================================
  Files         372      372              
  Lines       43565    43565              
==========================================
+ Hits        30768    30769       +1     
+ Misses      12797    12796       -1
Impacted Files Coverage Δ
src/transport/GasTransport.cpp 90.58% <0%> (+0.2%) ⬆️

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 bbdc790...5c9e348. Read the comment docs.

@ischoegl
Copy link
Member Author

ischoegl commented Aug 7, 2019

Ugh. Last push was autopep'd. Can revert if so desired.

@speth
Copy link
Member

speth commented Aug 7, 2019

Please do. It makes the intentional changes hard to see in the diff.

@ischoegl ischoegl force-pushed the add-write-hdf-to-solution-array branch from 5c9e348 to ffa4d3d Compare August 7, 2019 17:23
@ischoegl
Copy link
Member Author

ischoegl commented Aug 7, 2019

Please do. It makes the intentional changes hard to see in the diff.

done. thankfully the file was mostly compliant with autopep8's choices ;) ... unintentionally opened emacs from within a conda environment with an autopep8-on-save hook enabled.

@ischoegl ischoegl force-pushed the add-write-hdf-to-solution-array branch 2 times, most recently from fb802e2 to d4f4eeb Compare August 7, 2019 20:07
Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

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

I'm in favor of this addition. My only suggested changes relate to the docstrings for the new methods.

interfaces/cython/cantera/composite.py Outdated Show resolved Hide resolved
interfaces/cython/cantera/composite.py Outdated Show resolved Hide resolved
interfaces/cython/cantera/composite.py Outdated Show resolved Hide resolved
@ischoegl ischoegl force-pushed the add-write-hdf-to-solution-array branch from d4f4eeb to 99eb201 Compare August 7, 2019 22:33
@ischoegl ischoegl force-pushed the add-write-hdf-to-solution-array branch 2 times, most recently from 3eb9e28 to 7378cbc Compare August 9, 2019 20:57
@ischoegl
Copy link
Member Author

ischoegl commented Aug 9, 2019

@speth ... I just noticed that two issues you wanted to have addressed didn't make it into the last commit (I had taken care of it but the commit was lost). It is now fixed.

@ischoegl
Copy link
Member Author

ischoegl commented Aug 9, 2019

@bryanwweber ... if this looks good to you, could you approve so I can add HDF support to #687?

@ischoegl ischoegl force-pushed the add-write-hdf-to-solution-array branch from 7378cbc to d1f1f80 Compare August 9, 2019 21:55
 * The commit implements saving of data extracted from SolutionArrays
 to HDF containers using pandas infrastructure.
 * Two methods are introduced: `write_hdf` and `to_pandas`.
 * Both methods only work if the pandas module can be imported; an
 exception is raised only if the method is called without a working
 pandas installation.
@ischoegl ischoegl force-pushed the add-write-hdf-to-solution-array branch from d1f1f80 to 9f76dec Compare August 9, 2019 21:57
@codecov
Copy link

codecov bot commented Aug 9, 2019

Codecov Report

Merging #680 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #680      +/-   ##
==========================================
+ Coverage   70.62%   70.63%   +<.01%     
==========================================
  Files         372      372              
  Lines       43575    43575              
==========================================
+ Hits        30777    30778       +1     
+ Misses      12798    12797       -1
Impacted Files Coverage Δ
src/transport/GasTransport.cpp 90.58% <0%> (+0.2%) ⬆️

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 97356a4...9f76dec. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Aug 9, 2019

Codecov Report

Merging #680 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #680      +/-   ##
==========================================
+ Coverage   70.62%   70.63%   +<.01%     
==========================================
  Files         372      372              
  Lines       43575    43575              
==========================================
+ Hits        30777    30778       +1     
+ Misses      12798    12797       -1
Impacted Files Coverage Δ
src/transport/GasTransport.cpp 90.58% <0%> (+0.2%) ⬆️

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 97356a4...9f76dec. Read the comment docs.

@speth speth merged commit eea0425 into Cantera:master Aug 13, 2019
@ischoegl ischoegl deleted the add-write-hdf-to-solution-array branch October 5, 2019 00:11
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.

[Enhancement] Add HDF output for SolutionArray objects
3 participants