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:
  • {object} -- object where to load the data (obj) –
  • {str} -- name pf the hdf5 file (fname) –
  • {str} -- name of the root group in the hdf5 (obj_name) –
qmctorch.utils.hdf5_utils.load_object(grp, parent_obj, grp_name)[source]

Load object attribute from the hdf5 group/data

Parameters:
  • {hdf5 group} -- the current group in the hdf5 architecture (grp) –
  • {object} -- parent object (parent_obj) –
  • {str} -- name of the group (grp_name) –
qmctorch.utils.hdf5_utils.load_group(grp, parent_obj, grp_name)[source]

Load object attribute from the hdf5 group

Parameters:
  • {hdf5 group} -- the current group in the hdf5 architecture (grp) –
  • {object} -- parent object (parent_obj) –
  • {str} -- name of the group (grp_name) –
qmctorch.utils.hdf5_utils.load_data(grp, parent_obj, grp_name)[source]

Load data from the hdf5 data

Parameters:
  • {hdf5 group} -- the current group in the hdf5 architecture (grp) –
  • {object} -- parent object (parent_obj) –
  • {str} -- name of the group (grp_name) –
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:{hdf5 group} -- hdf5 group or dataset (grp) –
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:
  • {object} -- object to dump (obj) –
  • {str} -- name of the hdf5 (fname) –
Keyword Arguments:
 

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

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

Insert the content of the object in the hdf5 file

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.insert_group(obj, parent_grp, obj_name)[source]

Insert the content of the object in a hdf5 group

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.insert_data(obj, parent_grp, obj_name)[source]

Insert the content of the object in a hdf5 dataset

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.insert_type(obj, parent_grp, obj_name)[source]

Insert the content of the type object in an attribute

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.insert_default(obj, parent_grp, obj_name)[source]

Default funtion to insert a dataset

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.insert_list(obj, parent_grp, obj_name)[source]

funtion to insert a list as a dataset

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.insert_tuple(obj, parent_grp, obj_name)[source]

funtion to insert a tuple as a dataset

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.insert_numpy(obj, parent_grp, obj_name)[source]

funtion to insert a numpy array as a dataset

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.insert_torch_tensor(obj, parent_grp, obj_name)[source]

funtion to insert a torch tensor as a dataset

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.insert_torch_parameter(obj, parent_grp, obj_name)[source]

funtion to insert a torch parameter as a dataset

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.insert_none(obj, parent_grp, obj_name)[source]

funtion to insert a None Type as a dataset

Parameters:
  • {object} -- object to save (obj) –
  • {hdf5 group} -- group where to dump (parent_grp) –
  • {str} -- name of the object (obj_name) –
qmctorch.utils.hdf5_utils.haschildren(obj)[source]

Check if the object has children

Parameters:{object} -- the object to check (obj) –
Returns:bool – True if the object has children
qmctorch.utils.hdf5_utils.children(obj)[source]

Returns the children of the object as items

Parameters:{object} -- the object to check (obj) –
Returns:dict – items
qmctorch.utils.hdf5_utils.get_children_names(obj)[source]

Returns the children names of the object as items

Parameters:{object} -- the object to check (obj) –
Returns:dict – items
qmctorch.utils.hdf5_utils.get_child_object(obj, child_name)[source]

Return the child object

Parameters:
  • {object} -- parent object (obj) –
  • {str} -- cild name (child_name) –
Returns:

object – child object

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

Add attribute to a given group

Parameters:
  • {str} -- name of the file (filename) –
  • {str} -- name of the group (grp_name) –
  • {dict} -- attrivutes to add (attr) –
qmctorch.utils.hdf5_utils.register_extra_attributes(obj, attr_names)[source]

Register extra attribute to be able to dump them

Parameters:
  • {object} -- the object where we want to add attr (obj) –
  • {list} -- a list of attr names (attr_names) –