DataSet class conversion/creation functions

Update and restore datasets

guidata.dataset.update_dataset(dest: DataSet, source: Any | dict[str, Any], visible_only: bool = False) None

Update dest dataset items from source dataset.

Parameters:
  • dest (DataSet) – The destination dataset object to update.

  • source (Union[Any, Dict[str, Any]]) – The source object or dictionary containing matching attribute names.

  • visible_only (bool) – If True, update only visible items. Defaults to False.

For each DataSet item, the function will try to get the attribute of the same name from the source.

If the attribute exists in the source object or the key exists in the dictionary, it will be set as the corresponding attribute in the destination dataset.

Returns:

None

guidata.dataset.restore_dataset(source: DataSet, dest: Any | dict[str, Any]) None

Restore dest dataset items from source dataset.

Parameters:
  • source (DataSet) – The source dataset object to restore from.

  • dest (Union[Any, Dict[str, Any]]) – The destination object or dictionary.

This function is almost the same as update_dataset but requires the source to be a DataSet instead of the destination.

Symmetrically from update_dataset, dest may also be a dictionary.

Returns:

None

Create dataset classes

guidata.dataset.create_dataset_from_func(func) DataSet

Creates a DataSet class from a function signature.

Parameters:

func – The function to create the DataSet from.

Returns:

The DataSet class.

Note: Supported data types are: int, float, bool, str, dict, np.ndarray.

guidata.dataset.create_dataset_from_dict(dictionary: dict[str, Any], klassname: str | None = None) DataSet

Creates a DataSet class from a dictionary.

Parameters:
  • dictionary – The dictionary to create the DataSet class from.

  • klassname – The name of the DataSet class. If None, the name is ‘DictDataSet’.

Returns:

The DataSet class.

Note: Supported data types are: int, float, bool, str, dict, np.ndarray.