qmctorch.utils.hdf5_utils module

qmctorch.utils.hdf5_utils.print_insert_error(obj, obj_name)[source]
qmctorch.utils.hdf5_utils.print_insert_type_error(obj, obj_name)[source]
qmctorch.utils.hdf5_utils.print_load_error(grp)[source]
qmctorch.utils.hdf5_utils.load_from_hdf5(obj, fname, obj_name)[source]

Load the content of an hdf5 file in an object.

Parameters:
  • data (obj {object} -- object where to load the) –

  • file (fname {str} -- name pf the hdf5) –

  • hdf5 (obj_name {str} -- name of the root group in the) –

qmctorch.utils.hdf5_utils.load_object(grp, parent_obj, grp_name)[source]

Load object attribute from the hdf5 group/data

Parameters:
  • architecture (grp {hdf5 group} -- the current group in the hdf5) –

  • object (parent_obj {object} -- parent) –

  • group (grp_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.load_group(grp, parent_obj, grp_name)[source]

Load object attribute from the hdf5 group

Parameters:
  • architecture (grp {hdf5 group} -- the current group in the hdf5) –

  • object (parent_obj {object} -- parent) –

  • group (grp_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.load_data(grp, parent_obj, grp_name)[source]

Load data from the hdf5 data

Parameters:
  • architecture (grp {hdf5 group} -- the current group in the hdf5) –

  • object (parent_obj {object} -- parent) –

  • group (grp_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.cast_loaded_data(data)[source]

cast the data before loading.

qmctorch.utils.hdf5_utils.bytes2str(bstr)[source]

Convert a bytes into string.

qmctorch.utils.hdf5_utils.lookup_cast(ori_type, current_type)[source]
qmctorch.utils.hdf5_utils.isgroup(grp)[source]

Check if current hdf5 group is a group

Parameters:

dataset (grp {hdf5 group} -- hdf5 group or) –

Returns:

bool – True if the group is a group

qmctorch.utils.hdf5_utils.dump_to_hdf5(obj, fname, root_name=None)[source]

Dump the content of an object in a hdf5 file.

Parameters:
  • dump (obj {object} -- object to) –

  • hdf5 (fname {str} -- name of the) –

Keyword Arguments:

(default (root_name {str} -- root group in the hdf5 file) – {None})

qmctorch.utils.hdf5_utils.insert_object(obj, parent_grp, obj_name)[source]

Insert the content of the object in the hdf5 file

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.insert_group(obj, parent_grp, obj_name)[source]

Insert the content of the object in a hdf5 group

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.insert_data(obj, parent_grp, obj_name)[source]

Insert the content of the object in a hdf5 dataset

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.insert_type(obj, parent_grp, obj_name)[source]

Insert the content of the type object in an attribute

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.insert_default(obj, parent_grp, obj_name)[source]

Default funtion to insert a dataset

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.insert_list(obj, parent_grp, obj_name)[source]

funtion to insert a list as a dataset

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.insert_tuple(obj, parent_grp, obj_name)[source]

funtion to insert a tuple as a dataset

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.insert_numpy(obj, parent_grp, obj_name)[source]

funtion to insert a numpy array as a dataset

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.insert_torch_tensor(obj, parent_grp, obj_name)[source]

funtion to insert a torch tensor as a dataset

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.insert_torch_parameter(obj, parent_grp, obj_name)[source]

funtion to insert a torch parameter as a dataset

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.insert_none(obj, parent_grp, obj_name)[source]

funtion to insert a None Type as a dataset

Parameters:
  • save (obj {object} -- object to) –

  • dump (parent_grp {hdf5 group} -- group where to) –

  • object (obj_name {str} -- name of the) –

qmctorch.utils.hdf5_utils.haschildren(obj)[source]

Check if the object has children

Parameters:

check (obj {object} -- the object to) –

Returns:

bool – True if the object has children

qmctorch.utils.hdf5_utils.children(obj)[source]

Returns the children of the object as items

Parameters:

check (obj {object} -- the object to) –

Returns:

dict – items

qmctorch.utils.hdf5_utils.get_children_names(obj)[source]

Returns the children names of the object as items

Parameters:

check (obj {object} -- the object to) –

Returns:

dict – items

qmctorch.utils.hdf5_utils.get_child_object(obj, child_name)[source]

Return the child object

Parameters:
  • object (obj {object} -- parent) –

  • name (child_name {str} -- cild) –

Returns:

object – child object

qmctorch.utils.hdf5_utils.add_group_attr(filename, grp_name, attr)[source]

Add attribute to a given group

Parameters:
  • file (filename {str} -- name of the) –

  • group (grp_name {str} -- name of the) –

  • add (attr {dict} -- attrivutes to) –

qmctorch.utils.hdf5_utils.register_extra_attributes(obj, attr_names)[source]

Register extra attribute to be able to dump them

Parameters:
  • attr (obj {object} -- the object where we want to add) –

  • names (attr_names {list} -- a list of attr) –