Skip to content

added minimal test for px #1754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 12, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from plotly.graph_objs import graph_objs as go

np = optional_imports.get_module("numpy")
sk_measure = optional_imports.get_module("skimage.measure")
scipy_interp = optional_imports.get_module("scipy.interpolate")

from skimage import measure

# -------------------------- Layout ------------------------------

Expand Down Expand Up @@ -305,8 +305,8 @@ def _extract_contours(im, values, colors):
all_contours1, all_values1, all_areas1, all_colors1 = [], [], [], []
all_contours2, all_values2, all_areas2, all_colors2 = [], [], [], []
for i, val in enumerate(values):
contour_level1 = sk_measure.find_contours(zz_min, val)
contour_level2 = sk_measure.find_contours(zz_max, val)
contour_level1 = measure.find_contours(zz_min, val)
contour_level2 = measure.find_contours(zz_max, val)
all_contours1.extend(contour_level1)
all_contours2.extend(contour_level2)
all_values1.extend([val] * len(contour_level1))
Expand Down Expand Up @@ -614,6 +614,7 @@ def create_ternary_contour(
"""\
The create_ternary_contour figure factory requires the scipy package"""
)
sk_measure = optional_imports.get_module("skimage")
if sk_measure is None:
raise ImportError(
"""\
Expand Down
12 changes: 12 additions & 0 deletions packages/python/plotly/plotly/tests/test_core/test_px/test_px.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import plotly.express as px
import numpy as np


def test_scatter():
iris = px.data.iris()
fig = px.scatter(iris, x="sepal_width", y="sepal_length")
assert fig.data[0].type == "scatter"
assert np.all(fig.data[0].x == iris.sepal_width)
assert np.all(fig.data[0].y == iris.sepal_length)
# test defaults
assert fig.data[0].mode == "markers"
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
shapely = optional_imports.get_module("shapely")
shapefile = optional_imports.get_module("shapefile")
gp = optional_imports.get_module("geopandas")
sk_measure = optional_imports.get_module("skimage.measure")
sk_measure = optional_imports.get_module("skimage")


class TestDistplot(NumpyTestUtilsMixin, TestCaseNoTemplate):
Expand Down
6 changes: 3 additions & 3 deletions packages/python/plotly/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ deps=
pytz==2016.10
retrying==1.3.3
pytest==3.5.1
pandas==0.24.2
backports.tempfile==1.0
optional: --editable=file:///{toxinidir}/../plotly-geo
optional: numpy==1.11.3
optional: numpy==1.16.5
optional: ipython[all]==5.1.0
optional: ipywidgets==7.2.0
optional: ipykernel==4.8.2
optional: jupyter==1.0.0
optional: pandas==0.19.2
optional: scipy==0.18.1
optional: shapely==1.6.4
optional: geopandas==0.3.0
optional: pyshp==1.2.10
optional: pillow==5.2.0
optional: matplotlib==2.2.3
optional: xarray==0.10.9
optional: scikit-image==0.13.1
optional: scikit-image==0.14.4

; CORE ENVIRONMENTS
[testenv:py27-core]
Expand Down