erlab.interactive.utilities¶
Various helper functions and extensions to pyqtgraph.
Functions
|
|
|
Copy content to the clipboard. |
|
Format a dictionary of keyword arguments for a function call. |
|
Copy the Python code for function calls to the clipboard. |
|
Generate the string for a Python function call. |
|
Classes
|
AnalysisWidgetBase. |
|
|
|
|
|
An improved spinbox. |
|
|
|
|
|
|
|
Easy creation of groupboxes with multiple varying parameters. |
|
|
|
|
- class erlab.interactive.utilities.AnalysisWidgetBase(orientation='vertical', num_ax=2, link='both', cut_to_data='none', **kwargs)[source]¶
Bases:
GraphicsLayoutWidget
AnalysisWidgetBase.
- Parameters:
orientation (Literal['vertical', 'horizontal']) – Sets the orientation of the plots, by default “vertical”
num_ax (int) – Sets the number of axes.
link (Literal['x', 'y', 'both', 'none']) – Link axes, by default “both”
cut_to_data (Literal['in', 'out', 'both', 'none']) – Whether to remove outliers by adjusting color levels, by default “none”
- class erlab.interactive.utilities.AnalysisWindow(data, title=None, layout='horizontal', data_is_input=True, analysisWidget=None, *args, **kwargs)[source]¶
Bases:
QMainWindow
- class erlab.interactive.utilities.BetterSpinBox(*args, integer=False, compact=True, discrete=False, decimals=3, significant=False, scientific=False, value=0.0, **kwargs)[source]¶
Bases:
QAbstractSpinBox
An improved spinbox.
- Signals:
valueChanged – Emitted when the value is changed.
textChanged – Emitted when the text is changed.
- Parameters:
integer (bool) – If
True
, the spinbox will only display integer values.compact (bool) – Whether to reduce the height of the spinbox.
discrete (bool) –
If
True
the spinbox will only step to pre-determined discrete values.If
False
, the spinbox will just add or subtract the predetermined increment when increasing or decreasing the step.decimals (int) – The precision of the spinbox. See the
significant
argument for the meaning. Wheninteger
isTrue
, this argument is ignored.significant (bool) –
If
True
,decimals
will specify the total number of significant digits, before or after the decimal point, ignoring leading zeros.If
False
,decimals
will specify the total number of digits after the decimal point, including leading zeros.When
integer
orscientific
isTrue
, this argument is ignored.scientific (bool) – Whether to print in scientific notation.
value (float) – Initial value of the spinbox.
- class erlab.interactive.utilities.ParameterGroup(widgets=None, ncols=1, groupbox_kw=None, **widgets_kwargs)[source]¶
Bases:
QGroupBox
Easy creation of groupboxes with multiple varying parameters.
Can be used in many different interactive tools for dynamic data analysis.
- Parameters:
ncols (int) – Number of columns in the layout.
groupbox_kw (dict | None) – Keyword arguments passed onto
PySide6.QtWidgets.QGroupBox
.params – See Examples.
- Signals:
sigParameterChanged(dict)
Examples
>>> ParameterGroup( **{ "a": QtWidgets.QDoubleSpinBox(range=(0, 1), singleStep=0.01, value=0.2), "b": dict(qwtype="dblspin", range=(0, 2), singleStep=0.04), "c": QtWidgets.QSlider(range=(0, 10000)) } )
- static getParameterWidget(qwtype=None, **kwargs)[source]¶
Initialize the
PySide6.QtWidgets.QWidget
corresponding toqwtype
.- Parameters:
qwtype (Literal['spin', 'dblspin', 'btspin', 'slider', 'chkbox', 'pushbtn', 'chkpushbtn', 'combobox', 'fitparam'] | None) – Type of the widget, must a key of
ParameterGroup.VALID_QWTYPE
.
- VALID_QWTYPE: Mapping[str, type[QWidget]] = mappingproxy({'spin': <class 'PyQt6.QtWidgets.QSpinBox'>, 'dblspin': <class 'PyQt6.QtWidgets.QDoubleSpinBox'>, 'btspin': <class 'erlab.interactive.utilities.BetterSpinBox'>, 'slider': <class 'PyQt6.QtWidgets.QSlider'>, 'chkbox': <class 'PyQt6.QtWidgets.QCheckBox'>, 'pushbtn': <class 'PyQt6.QtWidgets.QPushButton'>, 'chkpushbtn': <class 'PyQt6.QtWidgets.QPushButton'>, 'combobox': <class 'PyQt6.QtWidgets.QComboBox'>, 'fitparam': <class 'erlab.interactive.utilities.FittingParameterWidget'>})¶
- class erlab.interactive.utilities.xImageItem(image=None, **kwargs)[source]¶
Bases:
BetterImageItem
pyqtgraph.ImageItem
with additional functionality.This class provides
xarray.DataArray
support and auto limits based on histogram analysis.- Parameters:
image (npt.NDArray | None) – Image data.
**kwargs – Additional arguments to
pyqtgraph.ImageItem
.
- Signals:
sigToleranceChanged()
- erlab.interactive.utilities.gen_function_code(copy=True, **kwargs)[source]¶
Copy the Python code for function calls to the clipboard.
The result can be copied to your clipboard in a form that can be pasted into an interactive Python session or Jupyter notebook cell.
- erlab.interactive.utilities.gen_single_function_code(funcname, *args, **kwargs)[source]¶
Generate the string for a Python function call.
The first argument is the name of the function, and subsequent arguments are passed as positional arguments. Keyword arguments are also supported. For strings in arguments and keyword arguments, surrounding the string with vertical bars (
|
) will prevent the string from being quoted.