Skip to content

Commit ff23511

Browse files
authored
fixed skimage import (#1832)
1 parent b7ad543 commit ff23511

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

packages/python/plotly/plotly/express/__init__.py

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
`plotly_express` is a terse, consistent, high-level wrapper around `plotly` for rapid \
33
data exploration and figure generation. See the gallery at https://plotly.github.io/plotly_express
44
"""
5+
from __future__ import absolute_import
6+
from plotly import optional_imports
7+
8+
pd = optional_imports.get_module("pandas")
9+
if pd is None:
10+
raise ImportError(
11+
"""\
12+
Plotly express requires pandas to be installed."""
13+
)
14+
515

616
from ._chart_types import ( # noqa: F401
717
scatter,

packages/python/plotly/plotly/figure_factory/__init__.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,31 @@
2424
from plotly.figure_factory._scatterplot import create_scatterplotmatrix
2525
from plotly.figure_factory._streamline import create_streamline
2626
from plotly.figure_factory._table import create_table
27-
from plotly.figure_factory._ternary_contour import create_ternary_contour
2827
from plotly.figure_factory._trisurf import create_trisurf
2928
from plotly.figure_factory._violin import create_violin
3029

3130
if optional_imports.get_module("pandas") is not None:
3231
from plotly.figure_factory._county_choropleth import create_choropleth
32+
else:
33+
34+
def create_choropleth(*args, **kwargs):
35+
raise ImportError("Please install pandas to use `create_choropleth`")
36+
37+
38+
if optional_imports.get_module("skimage") is not None:
39+
from plotly.figure_factory._ternary_contour import create_ternary_contour
40+
else:
41+
42+
def create_ternary_contour(*args, **kwargs):
43+
raise ImportError("Please install scikit-image to use `create_ternary_contour`")
44+
3345

3446
__all__ = [
3547
"create_2d_density",
3648
"create_annotated_heatmap",
3749
"create_bullet",
3850
"create_candlestick",
51+
"create_choropleth",
3952
"create_dendrogram",
4053
"create_distplot",
4154
"create_facet_grid",

packages/python/plotly/tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ deps=
7474
optional: pillow==5.2.0
7575
optional: matplotlib==2.2.3
7676
optional: xarray==0.10.9
77+
optional: pywavelets==1.0.3
7778
optional: scikit-image==0.14.4
7879

7980
; CORE ENVIRONMENTS

0 commit comments

Comments
 (0)