Data sets¶
Defining data sets¶
- class guidata.dataset.datatypes.DataSet(title: str | None = None, comment: str | None = None, icon: str = '')¶
Construct a DataSet object is a set of DataItem objects
- Parameters:
- classmethod create(**kwargs) DataSet ¶
Create a new instance of the DataSet class
- Parameters:
**kwargs – keyword arguments to set the DataItem values
- Returns:
DataSet instance
- edit(parent: QWidget | None = None, apply: Callable | None = None, size: Any | None = None) DataSetEditDialog ¶
Open a dialog box to edit data set
- view(parent: QWidget | None = None, size: Any | None = None) None ¶
Open a dialog box to view data set
- to_string(debug: bool | None = False, indent: str | None = None, align: bool | None = False, show_hidden: bool | None = True) str ¶
Return readable string representation of the data set If debug is True, add more details on data items
- Parameters:
- Returns:
string representation of the data set
- Return type:
- accept(vis: object) None ¶
Helper function that passes the visitor to the accept methods of all the items in this dataset
- Parameters:
vis (object) – visitor object
- serialize(writer: HDF5Writer | JSONWriter | INIWriter) None ¶
Serialize the dataset
- Parameters:
writer (HDF5Writer | JSONWriter | INIWriter) – writer object
- deserialize(reader: HDF5Reader | JSONReader | INIReader) None ¶
Deserialize the dataset
- Parameters:
reader (HDF5Reader | JSONReader | INIReader) – reader object
- read_config(conf: UserConfig, section: str, option: str) None ¶
Read configuration from a UserConfig instance
- Parameters:
conf (UserConfig) – UserConfig instance
section (str) – section name
option (str) – option name
- write_config(conf: UserConfig, section: str, option: str) None ¶
Write configuration to a UserConfig instance
- Parameters:
conf (UserConfig) – UserConfig instance
section (str) – section name
option (str) – option name
- class guidata.dataset.datatypes.DataSetGroup(datasets: list[DataSet], title: str | None = None, icon: str = '')¶
Construct a DataSetGroup object, used to group several datasets together
- Parameters:
This class tries to mimics the DataSet interface.
The GUI should represent it as a notebook with one page for each contained dataset.
- get_comment() None ¶
Return data set group comment –> not implemented (will return None)
- Returns:
data set group comment
- Return type:
None
- class guidata.dataset.datatypes.ActivableDataSet(title: str | None = None, comment: str | None = None, icon: str = '')¶
An ActivableDataSet instance must have an “enable” class attribute which will set the active state of the dataset instance (see example in: tests/activable_dataset.py)
- Parameters:
Grouping items¶
- class guidata.dataset.datatypes.BeginGroup(label: str)¶
Data item which does not represent anything but a begin flag to define a data set group
- Parameters:
label (str) – group label
- serialize(instance, writer) None ¶
Serialize this item using the writer object
This is a default implementation that should work for everything but new datatypes
- Parameters:
instance (DataSet) – instance of the DataSet
writer (HDF5Writer | JSONWriter | INIWriter) – writer object
- deserialize(instance, reader) None ¶
Deserialize this item using the reader object
Default base implementation supposes the reader can detect expected datatype from the stream
- Parameters:
instance (Any) – instance of the DataSet
reader (HDF5Reader | JSONReader | INIReader) – reader object
- class guidata.dataset.datatypes.EndGroup(label: str)¶
Data item which does not represent anything but an end flag to define a data set group
- Parameters:
label (str) – group label
- serialize(instance, writer) None ¶
Serialize this item using the writer object
This is a default implementation that should work for everything but new datatypes
- Parameters:
instance (DataSet) – instance of the DataSet
writer (HDF5Writer | JSONWriter | INIWriter) – writer object
- deserialize(instance, reader) None ¶
Deserialize this item using the reader object
Default base implementation supposes the reader can detect expected datatype from the stream
- Parameters:
instance (Any) – instance of the DataSet
reader (HDF5Reader | JSONReader | INIReader) – reader object
Handling item properties¶
- class guidata.dataset.datatypes.ItemProperty(callable: Callable)¶
Base class for item properties
- Parameters:
callable (Callable) – callable to use to evaluate the value of the property
- class guidata.dataset.datatypes.FormatProp(fmt: str, ignore_error: bool | None = True)¶
A Property that returns a string to help custom read-only representation of items
- class guidata.dataset.datatypes.GetAttrProp(attr: str)¶
A property that matches the value of an instance’s attribute
- Parameters:
attr (str) – attribute to match
- set(instance: DataSet, item: DataItem, value: Any) None ¶
Sets the value of the property given an instance, item and value Depending on implementation the value will be stored either on the instance, item or self
- Parameters:
instance (DataSet) – instance of the DataSet
item (Any) – item to set the value of
value (Any) – value to set
- class guidata.dataset.datatypes.ValueProp(value: Any)¶
A property that retrieves a value stored elsewhere
- Parameters:
value (Any) – value to store
- class guidata.dataset.datatypes.NotProp(prop: ItemProperty)¶
Not property
- Parameters:
prop (ItemProperty) – property to negate
- class guidata.dataset.datatypes.FuncProp(prop: ItemProperty, func: Callable, invfunc: Callable | None = None)¶
An ‘operator property’
- Parameters:
prop (ItemProperty) – property to apply function to
func (function) – function to apply
invfunc (function) – inverse function (default: func)