dict_to_h5py Module

digraph inheritancece297bf13c { bgcolor=transparent; rankdir=LR; size=""; "pyNastran.utils.dict_to_h5py.HDF5Exporter" [URL="#pyNastran.utils.dict_to_h5py.HDF5Exporter",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "pyNastran.utils.dict_to_h5py.HDF5Importer" [URL="#pyNastran.utils.dict_to_h5py.HDF5Importer",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; }
defines:
  • mydict = load_obj_from_hdf5(hdf5_filename, log=None, debug=False)

  • mydict = load_obj_from_hdf5_file(mydict, h5_file, log=None, debug=False)

  • export_obj_to_hdf5(hdf5_filename, mydict)

  • export_obj_to_hdf5_file(hdf5_file, mydict)

Supports: - integers, floats, None, strings, unicode, lists, tuple, - numpy arrays (including NaN), - objects (including custom objects), - scikit-learn StandardScalar - minimal dependencies (e.g., no scikit-learn)

Limitations: - Dictionary keys must be strings/unicode - May run into problems if you have two classes with the same name,

but point to different locations. There is some support for this, but hopefully you aren’t using it.

class pyNastran.utils.dict_to_h5py.HDF5Exporter(hdf5_file, user_custom_types=None, log=None, debug=False)[source]

Bases: object

class pyNastran.utils.dict_to_h5py.HDF5Importer(h5_file, custom_types_dict=None, log=None, debug=False, encoding='utf8')[source]

Bases: object

load(model, h5_file, self_obj=None)[source]
pyNastran.utils.dict_to_h5py.add_list_tuple(hdf5_file, key, value, Type: str, log)[source]

tuples are indistinguishable from lists as a dataset, so we’ll store it as a numpy array, list it, and then tuple it back

lists/tuples with numpy unicode are special

pyNastran.utils.dict_to_h5py.cast(h5_file: Dataset, key: str, value, nlevels: int)[source]

casts a value

pyNastran.utils.dict_to_h5py.cast_string(h5_result_attr, encoding: str) str | None[source]

converts the h5py type back into the actual type

pyNastran.utils.dict_to_h5py.cast_strings(group, encoding: str) list[str][source]
pyNastran.utils.dict_to_h5py.export_obj_to_hdf5(hdf5_filename, obj, user_custom_types=None, log=None, debug=False)[source]

exports an object to an HDF5 file

pyNastran.utils.dict_to_h5py.export_obj_to_hdf5_file(hdf5_file, obj, user_custom_types=None, log=None, debug=False)[source]

exports an object to an HDF5 file object

pyNastran.utils.dict_to_h5py.load_obj_from_hdf5(hdf5_filename: str, custom_types_dict=None, log=None, debug=False)[source]

loads an hdf5 file into an object

Parameters:
hdf5_filenamestr

the h5 filename to load

custom_types_dictdict[key]function()

the custom mapper

pyNastran.utils.dict_to_h5py.load_obj_from_hdf5_file(model, h5_file, log=None, custom_types_dict=None, debug=False)[source]

loads an h5 file object into an dict object