WidgetFunctions

class WidgetFunctions.OptimizationWidget(widget_name, widget_options, controlvalue=False)

Bases: object

A wrapper around ipywidgets with options for optimization problems.

This custom widget wraps around a specified ipywidget and includes checkboxes to specify whether or not this widget should be used as a control value or an objective value.

Initialize an optimization widget.

This creates an optimization widget of type widget_name which must be a valid ipywidget type. widget_options determines the set up and properties of this widget.

Parameters:
  • widget_name (string) – The name of the ipywidget to create, e.g., BoundedFloatText

  • widget_options (dict) –

    A dictionary containing all the setup values for a widget of type widget_name. For example:

    widget_options = {'value': 0.25,
                      'min': -1.0,
                      'max': 1.0,
                      'description': Short Description
                      'description_tooltip': A long description...}
    

Returns:

None

custom_display()

Displays an optimization widget.

This displays an optimization widget including the formatting of the boxes used to toggle control/objective specification.

Parameters:

None

Returns:

None

class WidgetFunctions.ValueRangeWidget(description, tooltip, bounds, init_vals, step_size)

Bases: object

A pair of linked BoundedFloatText widgets for value ranges.

This is a custom widget composed of two linked BoundedFloatText widgets intended to enable the easy solicitation of a range of values from the user.

Initialize the linked input fields.

These linked widgets will be displayed side-by-side for intuitive entry of [lower_bound, upper_bound] information, the behavior of the individual fields and their labeling/description is provided by the user.

Parameters:
  • description (string) – A short name or label for the the widget, e.g., Porosity Range

  • tooltip (string) – A longer, potentially multi-line explanation describing the values that are intended to be entered, background information, units, suggested values, etc., should all be communicated here.

  • bounds (list(float)) – A two-element list where bounds[0] is the lower bound to enforce on both fields and bounds[1] is the upper bound to enforce on both fields.

  • init_vals (list(float)) – A two-element list where init_vals[0] is the initial value of the lower bound and init_vals[1] is the initial value of the upper bound.

  • step_size (float) – The change in value produced by clicking the increment or decrement buttons in the BoundedFloatText field.

Returns:

None

custom_display()

Displays a value range widget.

This displays a value range widget including the formatting of the two fields side by side with a single label.

Parameters:

None

Returns:

None

class WidgetFunctions.WidgetCollection

Bases: object

A WidgetCollection object collects any number of different iPyWidgets.

This object can be used to organize all the widgets pertaining to a single unit model or step of the overall conversion process. New widgets should be accumulated after initialization using an approach like:

fs_options = wf.WidgetCollection()
fs_options.xylan_solid_fraction = widgets.BoundedFloatText(...)
fs_options.glucan_solid_fraction = widgets.BoundedFloatText(...)
fs_options.initial_porosity = widgets.Checkbox(...)

where widget options and values can be accessed using, for example, fs_options.initial_porosity.value

display_all_widgets()

Displays all the collected widgets in the Notebook.

This method displays all the widgets collected in the object to the Jupyter Notebook interface.

Parameters:

None

Returns:

None

export_widgets_to_dict(parent_name=None)

Store all widget values in dictionary.

This method allows the values of each widget to be saved in a dictionary with the pattern {"widget_1_name": widget_1_value, ...}. If the widget was created with a scaling function, the scaled version of the value is calculated and stored in the dictionary. This scaled value is the one that will be referenced by subsequent operations accessing the VE parameter file.

Parameters:

parent_name (str, optional) –

At the end of the dictionary creation, all the name: value entries can be nested under a single “parent” keyword. For example:

{parent_name: {"widget_1_name": widget_1_value,
               "widget_2_name": widget_2_value}}

Defaults to None, i.e., do not nest under a parent name.

Returns:

The name and value of each widget collected in a Python dictionary.

Return type:

dict

WidgetFunctions.csv2widget_collection(filename)