You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running the latest seaborn (0.13.2) on Mac OS 14.2.1 (x86_64), Python 3.12.4.
The issue
When a user attempts to use widgets from widgets.py module without having ipywidgets installed, the intended ImportError is not raised because of a NameError raised moments before that.
$ python -c "import seaborn; seaborn.choose_colorbrewer_palette('quatlitative')" (test-seaborn-fresh)
Traceback (most recent call last):
File "<string>", line 1, in<module>
File "<redacted>/anaconda3/envs/test-seaborn-setup/lib/python3.12/site-packages/seaborn/widgets.py", line 134, in choose_colorbrewer_palette
desat=FloatSlider(min=0, max=1, value=1)):
^^^^^^^^^^^
NameError: name 'FloatSlider' is not defined
Root cause
The widgets.py module wraps imports from ipywidgets with a try/except clause (link). When the user doesn't have ipywidgets installed, the interact function is patched to raise an ImportError and notify the user on the missing module upon invocation.
The local functions defined later in the module are guarded using the wrapper:
Unfortunately, such function definitions already attempt to use the members of the ipywidgets module to define the default values for parameters (in this case the FloatSlider is used to define a default for desat). This prevents the user from seeing the intended ImportError and presents them with a NameError instead like the one reproduced above.
The text was updated successfully, but these errors were encountered:
I'm running the latest seaborn (0.13.2) on Mac OS 14.2.1 (x86_64), Python 3.12.4.
The issue
When a user attempts to use widgets from widgets.py module without having ipywidgets installed, the intended ImportError is not raised because of a NameError raised moments before that.
Steps to reproduce:
1. Set up a fresh virtualenv.
2. Install seaborn (skip ipywidgets).
Root cause
The widgets.py module wraps imports from
ipywidgets
with a try/except clause (link). When the user doesn't have ipywidgets installed, theinteract
function is patched to raise anImportError
and notify the user on the missing module upon invocation.The local functions defined later in the module are guarded using the wrapper:
Unfortunately, such function definitions already attempt to use the members of the ipywidgets module to define the default values for parameters (in this case the
FloatSlider
is used to define a default fordesat
). This prevents the user from seeing the intendedImportError
and presents them with aNameError
instead like the one reproduced above.The text was updated successfully, but these errors were encountered: