pyquibbler.initialize_quibbler

pyquibbler.initialize_quibbler(draggable_plots: bool = True, show_quibs_as_widgets: bool = True, jupyterlab_extension: bool = True)

Initialize Quibbler to allow functions to work on quibs

Initiate quibbler and override all relevant functions and operators in NumPy, Matplotlib, and ipywidgets to support Quibs.

Parameters:
  • draggable_plots (bool, default True) –

    Indicates whether plots created by matplotlib plot and scatter are mouse draggable by default (namely, allowing graphics-based assignments).

    When set to True, plots are automatically draggable. Indicate picker=False in a plot or scatter function call to prevent dragging for a specific plot.

    When set to False, plots are not draggable, unless picker=True is specified in the plot or scatter function calls.

  • show_quibs_as_widgets (bool, default True) – Indicates whether to display quibs as interactive widgets within Jupyter Lab. When set to False, quibs can still be displayed as widgets using the quib’s display() method. (Note that show_quibs_as_widgets is only applicable within Jupyter Lab).

  • jupyterlab_extension (bool, default True) – Indicates whether to connect with the pyquibbler_labextension to allow save/load of quibs to the Jupyter notebook.

Examples

>>> import numpy as np
>>> from pyquibbler import initialize_quibbler, is_quiby
>>> is_quiby(np.sin)
False
>>> initialize_quibbler()
>>> is_quiby(np.sin)
True

initialize_quibbler must be called before importing from NumPy or Matplotlib. It will not work on functions already imported from these packages:

>>> from numpy import sin
>>> from pyquibbler import initialize_quibbler, is_quiby
>>> is_quiby(sin)
False
>>> initialize_quibbler()
>>> is_quiby(sin)
False

Note

initialize_quibbler need only be called once at the beginning of the script, after pyquibbler is imported. Additional calls, though, are harmless and can even be useful as a means to re-specify draggable_plots and show_quibs_as_widgets.

If Quibbler is not initaited, the iquib, quiby and q will not modify their arguments. Therefore, not initiating Quibbler allows testing your code as a normal code without any quibs.