Skip to content

Commit

Permalink
[Python] Add utility to query HDF support
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Jan 12, 2023
1 parent 0d79adb commit 240f9bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions interfaces/cython/cantera/_utils.pxd
Expand Up @@ -72,6 +72,7 @@ cdef extern from "cantera/base/global.h" namespace "Cantera":
cdef void Cxx_suppress_thermo_warnings "Cantera::suppress_thermo_warnings" (cbool)
cdef void Cxx_use_legacy_rate_constants "Cantera::use_legacy_rate_constants" (cbool)
cdef string CxxGitCommit "Cantera::gitCommit" ()
cdef cbool CxxUsesHighFive "Cantera::usesHighFive" ()
cdef cbool CxxDebugModeEnabled "Cantera::debugModeEnabled" ()


Expand Down
17 changes: 17 additions & 0 deletions interfaces/cython/cantera/_utils.pyx
Expand Up @@ -93,6 +93,23 @@ def use_legacy_rate_constants(pybool legacy):
"""
Cxx_use_legacy_rate_constants(legacy)

def hdf_support():
"""
Returns list of libraries that include HDF support:
- 'h5py': HDF support by Python package 'h5py'.
- 'HighFive': if Cantera was compiled with C++ HighFive HDF support.
"""
out = []
try:
pkg_resources.get_distribution("h5py")
except pkg_resources.DistributionNotFound:
pass
else:
out.append("h5py")
if CxxUsesHighFive():
out.append("HighFive")
return set(out)

cdef Composition comp_map(X) except *:
if isinstance(X, (str, bytes)):
return parseCompString(stringify(X))
Expand Down

0 comments on commit 240f9bb

Please sign in to comment.