From 6e281feeab8f6e6d1f90e380e57bbfd9f210ab6f Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 18 Oct 2019 12:51:40 -0400 Subject: [PATCH 1/6] fixed skimage import --- packages/python/plotly/plotly/figure_factory/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/python/plotly/plotly/figure_factory/__init__.py b/packages/python/plotly/plotly/figure_factory/__init__.py index 2b686c8ce3e..1881d5707bd 100644 --- a/packages/python/plotly/plotly/figure_factory/__init__.py +++ b/packages/python/plotly/plotly/figure_factory/__init__.py @@ -24,18 +24,21 @@ from plotly.figure_factory._scatterplot import create_scatterplotmatrix from plotly.figure_factory._streamline import create_streamline from plotly.figure_factory._table import create_table -from plotly.figure_factory._ternary_contour import create_ternary_contour from plotly.figure_factory._trisurf import create_trisurf from plotly.figure_factory._violin import create_violin if optional_imports.get_module("pandas") is not None: from plotly.figure_factory._county_choropleth import create_choropleth +if optional_imports.get_module("skimage") is not None: + from plotly.figure_factory._ternary_contour import create_ternary_contour + __all__ = [ "create_2d_density", "create_annotated_heatmap", "create_bullet", "create_candlestick", + "create_choropleth", "create_dendrogram", "create_distplot", "create_facet_grid", From 570aff1f5d44f1390d4079d2d667f1ea19b77bb3 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 18 Oct 2019 15:38:01 -0400 Subject: [PATCH 2/6] message for pandas --- packages/python/plotly/plotly/express/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/python/plotly/plotly/express/__init__.py b/packages/python/plotly/plotly/express/__init__.py index 19aa4bb3e51..b0a13812ae0 100644 --- a/packages/python/plotly/plotly/express/__init__.py +++ b/packages/python/plotly/plotly/express/__init__.py @@ -2,6 +2,15 @@ `plotly_express` is a terse, consistent, high-level wrapper around `plotly` for rapid \ data exploration and figure generation. See the gallery at https://plotly.github.io/plotly_express """ +from __future__ import absolute_import +from plotly import optional_imports +pd = optional_imports.get_module("pandas") +if pd is None: + raise ImportError( + """\ +Plotly express requires pandas to be installed.""" + ) + from ._chart_types import ( # noqa: F401 scatter, From 4cd117d7ac8365d28feaf726118899c22f72478a Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 18 Oct 2019 15:44:06 -0400 Subject: [PATCH 3/6] black --- packages/python/plotly/plotly/express/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/python/plotly/plotly/express/__init__.py b/packages/python/plotly/plotly/express/__init__.py index b0a13812ae0..4ff085156ce 100644 --- a/packages/python/plotly/plotly/express/__init__.py +++ b/packages/python/plotly/plotly/express/__init__.py @@ -4,6 +4,7 @@ """ from __future__ import absolute_import from plotly import optional_imports + pd = optional_imports.get_module("pandas") if pd is None: raise ImportError( From 4b77cb3fb1160724c66ed7d129a7176c8861e7cd Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 18 Oct 2019 16:10:25 -0400 Subject: [PATCH 4/6] temp fix in CI --- packages/python/plotly/tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/python/plotly/tox.ini b/packages/python/plotly/tox.ini index df41b7e1df1..ad22acbea13 100644 --- a/packages/python/plotly/tox.ini +++ b/packages/python/plotly/tox.ini @@ -75,6 +75,7 @@ deps= optional: matplotlib==2.2.3 optional: xarray==0.10.9 optional: scikit-image==0.14.4 + optional: pywavelets==1.0.3 ; CORE ENVIRONMENTS [testenv:py27-core] From f0fd5f42905bd2afbc9d6dcd81ef28ae15a2caee Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 18 Oct 2019 16:11:02 -0400 Subject: [PATCH 5/6] fix CI --- packages/python/plotly/tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/python/plotly/tox.ini b/packages/python/plotly/tox.ini index ad22acbea13..d98beda6272 100644 --- a/packages/python/plotly/tox.ini +++ b/packages/python/plotly/tox.ini @@ -74,8 +74,8 @@ deps= optional: pillow==5.2.0 optional: matplotlib==2.2.3 optional: xarray==0.10.9 - optional: scikit-image==0.14.4 optional: pywavelets==1.0.3 + optional: scikit-image==0.14.4 ; CORE ENVIRONMENTS [testenv:py27-core] From acc2c11fc94a28ac0844b92d1b0d1fba5a02ee1c Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Fri, 18 Oct 2019 16:32:01 -0400 Subject: [PATCH 6/6] still expose factories when deps not installed --- .../python/plotly/plotly/figure_factory/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/python/plotly/plotly/figure_factory/__init__.py b/packages/python/plotly/plotly/figure_factory/__init__.py index 1881d5707bd..3829ca2fb67 100644 --- a/packages/python/plotly/plotly/figure_factory/__init__.py +++ b/packages/python/plotly/plotly/figure_factory/__init__.py @@ -29,9 +29,19 @@ if optional_imports.get_module("pandas") is not None: from plotly.figure_factory._county_choropleth import create_choropleth +else: + + def create_choropleth(*args, **kwargs): + raise ImportError("Please install pandas to use `create_choropleth`") + if optional_imports.get_module("skimage") is not None: from plotly.figure_factory._ternary_contour import create_ternary_contour +else: + + def create_ternary_contour(*args, **kwargs): + raise ImportError("Please install scikit-image to use `create_ternary_contour`") + __all__ = [ "create_2d_density",