Parameter¶
-
class
qef.widgets.parameter.
ParameterCallbacksMixin
[source]¶ Bases:
object
Implement relationships between the different components of an ipywidget exposing all or some of the parameter attributes
The methods in this Mixin expects attribute
facade
, a dictionary whose keys coincide with tuplewidget_names
and whose values are eitherNone
or references to ipywidgets. Attributefacade
can be created with functionadd_widget_facade()
.-
inf
= inf¶ Representation of infinity value
-
max_value_change
(change)[source]¶ Notify other widgets if
min
changes.- Reject change if
max
becomes smaller thanmin
- Uncheck
nomax
if new value is entered inmax
2. Update
value.value
if it becomes bigger thanmax.value
- Reject change if
-
min_value_change
(change)[source]¶ Notify other widgets if
min
changes.- Reject change if
min
becomes bigger thanmax
- Uncheck
nomin
if new value is entered inmin
- Update
value.value
if it becomes smaller thanmin.value
- Reject change if
-
validate_facade
()[source]¶ Ascertain that keys of
facade
attribute are contained inwidget_names
-
value_value_change
(change)[source]¶ Validate
value
is within bounds. Otherwise setvalue
as the closest bound value
-
widget_names
= ('nomin', 'min', 'value', 'nomax', 'max', 'vary', 'expr')¶
-
-
class
qef.widgets.parameter.
ParameterWidget
(show_header=True)[source]¶ Bases:
ipywidgets.widgets.widget_box.Box
One possible representation of a fitting parameter. Inherits from ipywidgets.widgets.widget_box.Box
Parameters: show_header (Bool) – Hide or show names of the widget components min, value,…
-
class
qef.widgets.parameter.
ParameterWithTraits
(name=None, value=None, vary=True, min=-inf, max=inf, expr=None, brute_step=None, user_data=None)[source]¶ Bases:
lmfit.parameter.Parameter
,traitlets.traitlets.HasTraits
Wrapper of
Parameter
withTraitType
allows synchronization with ipywidgetsSame signature for initialization as that of
Parameter
.Parameters: - name (str, optional) – Name of the Parameter.
- value (float, optional) – Numerical Parameter value.
- vary (bool, optional) – Whether the Parameter is varied during a fit (default is True).
- min (float, optional) – Lower bound for value (default is -numpy.inf, no lower bound).
- max (float, optional) – Upper bound for value (default is numpy.inf, no upper bound).
- expr (str, optional) – Mathematical expression used to constrain the value during the fit.
- brute_step (float, optional) – Step size for grid points in the brute method.
- user_data (optional) – User-definable extra attribute used for a Parameter.
-
link_widget
(widget, mapping=None)[source]¶ Link the value of a single ipywidget to one trait, or the values of the element widgets of a composite ipywidget to different traits. The specific traits can be specified with the
mapping
argument.Parameters: - widget (ipywidgets.widgets.widget.Widget)
- mapping (str, dict, or None) – if str,
mapping
denotes the widget name to be associated with the widget. If dict, thenmapping
values are attribute names of widget, referencing the simple ipywidgets to be associated to standardwidget_names
. The widget names are the keys ofmapping
. IfNone
, an inspection of widget attributes will be performed, looking for names that coincide with standardwidget_names
. If the inspection is unsuccessful, the widget will be associated with the standard widget name ‘value’ to represent the values taken by the fitting parameter.
-
trait_names
= ('tvalue', 'tmin', 'tmax', 'tvary', 'texpr')¶
-
qef.widgets.parameter.
add_widget_callbacks
(widget, mapping=None)[source]¶ Extend the widget’s type with
ParameterCallbacksMixin
Parameters: - widget (ipywidgets.widgets.widget.Widget)
- mapping (str, dict, or None) – if str,
mapping
denotes the widget name to be associated with the widget. If dict, thenmapping
values are attribute names of widget, referencing the simple ipywidgets to be associated to standardwidget_names
. The widget names are the keys ofmapping
. IfNone
, an inspection of widget attributes will be performed, looking for names that coincide with standardwidget_names
. If the inspection is unsuccessful, the widget will be associated with the standard widget name ‘value’ to represent the values taken by the fitting parameter.
-
qef.widgets.parameter.
add_widget_facade
(widget, mapping=None)[source]¶ Create
facade
dictionary where keys are standardwidget_names
and whose values are simple ipywidgets that control the fitting parameter attributes denoted by the standardwidget_names
. This dictionary is added to the input widget as an attribute.Parameters: - widget (ipywidgets.widgets.widget.Widget)
- mapping (str, dict, or None) – if str, mapping denotes the widget name to be associated with
the widget. If dict, then mapping values are attribute names
of widget, referencing the simple ipywidgets to be associated
to standard widget names. The widget names are the keys of mapping.
If
None
, an inspection of widget attributes will be performed, looking for names that coincide with standard widget names. If the inspection is unsuccessful, the widget will be associated with the standard widget name ‘value’ to represent the values taken by the fitting parameter.
Returns: widget – Reference to input widget
Return type: Widget
-
qef.widgets.parameter.
create_facade
(widget, mapping=None)[source]¶ Create
facade
dictionary where keys are standardwidget_names
and whose values are simple ipywidgets that control the fitting parameter attributes denoted by the standardwidget_names
.Parameters: - widget (ipywidgets.widgets.widget.Widget)
- mapping (str, dict, or None) – if str, mapping denotes the widget name to be associated with
the widget. If dict, then mapping values are attribute names
of widget, referencing the simple ipywidgets to be associated
to standard widget names. The widget names are the keys of mapping.
If
None
, an inspection of widget attributes will be performed, looking for names that coincide with standard widget names. If the inspection is unsuccessful, the widget will be associated with the standard widget name ‘value’ to represent the values taken by the fitting parameter.
Returns: facade
Return type: