From 91385163d1fcd715e0ac7b510493195b962dcb29 Mon Sep 17 00:00:00 2001 From: Andrew Seier Date: Tue, 17 Jan 2017 16:46:49 -0800 Subject: [PATCH 1/2] Fail if user tries to import FF without `numpy`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that we don’t necessarily *require* `numpy` for in all the FF methods. We’re just looking to make the compatibility-breaking change so that we can depend on it in `2.0.0`. Also note that I’d forgotten to include `figure_factory` in setup.py before ;__;. --- CHANGELOG.md | 2 ++ circle.yml | 6 +++++- plotly/figure_factory/__init__.py | 3 +++ setup.py | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8c5843c68c..15f153afcd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ which depend on `try-except` blocks containing network requests should be revisited. - `plotly.py:sign_in` now validates to the plotly server specified in your config. If it cannot make a successful request, it raises a `PlotlyError`. +- `plotly.figure_factory` will raise an `ImportError` if `numpy` is not + installed. ### Deprecated - `plotly.tools.FigureFactory`. Use `plotly.figure_factory.*`. diff --git a/circle.yml b/circle.yml index 62a7bdb505a..29fb8d4fa11 100644 --- a/circle.yml +++ b/circle.yml @@ -52,5 +52,9 @@ test: - sudo chmod -R 444 ${PLOTLY_CONFIG_DIR} && python -c "import plotly" # test that giving back write permissions works again - # this also has to pass the test suite that follows - sudo chmod -R 777 ${PLOTLY_CONFIG_DIR} && python -c "import plotly" + + # test that figure_factory cannot be imported with only core requirements. + # since optional requirements is part of the test suite, we don't need to + # worry about testing that it *can* be imported in this case. + - $(! python -c "import plotly.figure_factory") diff --git a/plotly/figure_factory/__init__.py b/plotly/figure_factory/__init__.py index 11547989cf6..153ac6d657b 100644 --- a/plotly/figure_factory/__init__.py +++ b/plotly/figure_factory/__init__.py @@ -1,5 +1,8 @@ from __future__ import absolute_import +# Require that numpy exists for figure_factory +import numpy + from plotly.figure_factory._2d_density import create_2d_density from plotly.figure_factory._annotated_heatmap import create_annotated_heatmap from plotly.figure_factory._candlestick import create_candlestick diff --git a/setup.py b/setup.py index 0e87794e7bb..1e66057b516 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,7 @@ def readme(): 'plotly/api/v2', 'plotly/plotly', 'plotly/plotly/chunked_requests', + 'plotly/figure_factory', 'plotly/graph_objs', 'plotly/grid_objs', 'plotly/widgets', From 7e3b3581f0aa36afcca4749d30cd977ba4e37b2f Mon Sep 17 00:00:00 2001 From: Andrew Seier Date: Tue, 17 Jan 2017 23:05:32 -0800 Subject: [PATCH 2/2] Move all FF tests into `test_optional`. --- plotly/tests/test_optional/test_tools/__init__.py | 0 .../test_tools/test_figure_factory.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 plotly/tests/test_optional/test_tools/__init__.py rename plotly/tests/{test_core => test_optional}/test_tools/test_figure_factory.py (100%) diff --git a/plotly/tests/test_optional/test_tools/__init__.py b/plotly/tests/test_optional/test_tools/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plotly/tests/test_core/test_tools/test_figure_factory.py b/plotly/tests/test_optional/test_tools/test_figure_factory.py similarity index 100% rename from plotly/tests/test_core/test_tools/test_figure_factory.py rename to plotly/tests/test_optional/test_tools/test_figure_factory.py