Data sets¶
Defining data sets¶
- class guidata.dataset.DataSet(title: str | None = None, comment: str | None = None, icon: str = '', readonly: bool = False)¶
Construct a DataSet object is a set of DataItem objects
- Parameters:
- get_items(copy=False) list[DataItem] ¶
Returns all the DataItem objects from the DataSet instance. Ignore private items that have a name starting with an underscore (e.g. ‘_private_item = …’)
- Parameters:
copy – If True, deepcopy the DataItem list, else return the original.
False. (Defaults to)
- Returns:
_description_
- classmethod create(**kwargs) AutodocExampleParam1 ¶
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, wordwrap: bool = True, size: QSize | tuple[int, int] | None = None) DataSetEditDialog ¶
Open a dialog box to edit data set
- Parameters:
parent – parent widget (default is None, meaning no parent)
apply – apply callback (default is None)
wordwrap – if True, comment text is wordwrapped
size – dialog size (QSize object or integer tuple (width, height))
- view(parent: QWidget | None = None, wordwrap: bool = True, size: QSize | tuple[int, int] | None = None) None ¶
Open a dialog box to view data set
- Parameters:
parent – parent widget (default is None, meaning no parent)
wordwrap – if True, comment text is wordwrapped
size – dialog size (QSize object or integer tuple (width, height))
- 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.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
- edit(parent: QWidget | None = None, apply: Callable | None = None, wordwrap: bool = True, size: QSize | tuple[int, int] | None = None, mode: str | None = None) int ¶
Open a dialog box to edit data set
- Parameters:
parent – parent widget. Defaults to None.
apply – apply callback. Defaults to None.
wordwrap – if True, comment text is wordwrapped
size – dialog size (default: None)
mode – (str): dialog window style to use. Allowed values are “tabs”, “table” and None. Use “tabs” to navigate between datasets with tabs. Use “table” to create a table with one dataset by row (allows dataset editing by double clicking on a row). Defaults to None.
- Returns:
dialog box return code
- 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
- is_readonly() bool ¶
Return True if all datasets in the DataSetGroup are in readonly mode.
- Returns:
True if all datasets are in readonly, else False
- set_readonly(readonly=True)¶
Set all datasets of the dataset group to readonly mode
- Parameters:
readonly – Readonly flag. Defaults to True.
Grouping items¶
- class guidata.dataset.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.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.ItemProperty(callable: Callable)¶
Base class for item properties
- Parameters:
callable (Callable) – callable to use to evaluate the value of the property
- class guidata.dataset.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.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.ValueProp(value: Any)¶
A property that retrieves a value stored elsewhere
- Parameters:
value (Any) – value to store
- class guidata.dataset.NotProp(prop: ItemProperty)¶
Not property
- Parameters:
prop (ItemProperty) – property to negate
- class guidata.dataset.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)