Skip to content

Commit 70877b4

Browse files
authored
Require python 3.6 and CI maintenance (#3160)
* Update setup.py to require Python>=3.6 * Add an f-string (compatible with python>=3.6) for good measure * Remove tox * Rename plot_ly in chart_studio in ci tests * Move tests with pandas/numpy dependencies to test_optional, remove these from core requirements * Move dependency check tests to optional * Don't open browser window in matplotlylib test * Add Python 3.8 and 3.9 tests
1 parent 6bf5849 commit 70877b4

36 files changed

+363
-528
lines changed

Diff for: .circleci/config.yml

+108-172
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
decorator==4.0.9
2+
nose==1.3.7
3+
requests==2.12.4
4+
six==1.10.0
5+
pytz==2016.10
6+
retrying==1.3.3
7+
pytest==3.5.1
8+
pandas==0.23.2
9+
numpy==1.14.3
10+
ipywidgets==7.2.0
11+
matplotlib==2.2.3
12+
--editable=./plotly

Diff for: packages/python/chart-studio/tox.ini

-86
This file was deleted.

Diff for: packages/python/plotly/_plotly_utils/optional_imports.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ def get_module(name, should_load=True):
3232
_not_importable.add(name)
3333
except Exception as e:
3434
_not_importable.add(name)
35-
msg = "Error importing optional module {}".format(name)
35+
msg = f"Error importing optional module {name}"
3636
logger.exception(msg)

Diff for: packages/python/plotly/plotly/tests/test_core/test_figure_messages/test_add_traces.py

-30
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,6 @@ def test_add_traces(self):
6666
)
6767

6868

69-
class TestAddTracesRowsColsDataTypes(TestCase):
70-
def test_add_traces_with_iterable(self):
71-
import plotly.express as px
72-
73-
df = px.data.tips()
74-
fig = px.scatter(df, x="total_bill", y="tip", color="day")
75-
from plotly.subplots import make_subplots
76-
77-
fig2 = make_subplots(1, 2)
78-
fig2.add_traces(fig.data, rows=[1,] * len(fig.data), cols=[1,] * len(fig.data))
79-
80-
expected_data_length = 4
81-
82-
self.assertEqual(expected_data_length, len(fig2.data))
83-
84-
def test_add_traces_with_integers(self):
85-
import plotly.express as px
86-
87-
df = px.data.tips()
88-
fig = px.scatter(df, x="total_bill", y="tip", color="day")
89-
from plotly.subplots import make_subplots
90-
91-
fig2 = make_subplots(1, 2)
92-
fig2.add_traces(fig.data, rows=1, cols=2)
93-
94-
expected_data_length = 4
95-
96-
self.assertEqual(expected_data_length, len(fig2.data))
97-
98-
9969
def test_add_trace_exclude_empty_subplots():
10070
# Add traces
10171
fig = make_subplots(2, 2)

Diff for: packages/python/plotly/plotly/tests/test_core/test_utils/test_utils.py

+1-80
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
from unittest import TestCase
44

5-
import json as _json
6-
75
from plotly.utils import PlotlyJSONEncoder, get_by_path, node_generator
8-
from time import time
9-
import numpy as np
10-
import plotly.graph_objects as go
6+
import json as _json
117

128

139
class TestJSONEncoder(TestCase):
@@ -21,38 +17,6 @@ def test_invalid_encode_exception(self):
2117
with self.assertRaises(TypeError):
2218
_json.dumps({"a": {1}}, cls=PlotlyJSONEncoder)
2319

24-
def test_fast_track_finite_arrays(self):
25-
# if NaN or Infinity is found in the json dump
26-
# of a figure, it is decoded and re-encoded to replace these values
27-
# with null. This test checks that NaN and Infinity values are
28-
# indeed converted to null, and that the encoding of figures
29-
# without inf or nan is faster (because we can avoid decoding
30-
# and reencoding).
31-
z = np.random.randn(100, 100)
32-
x = np.arange(100.0)
33-
fig_1 = go.Figure(go.Heatmap(z=z, x=x))
34-
t1 = time()
35-
json_str_1 = _json.dumps(fig_1, cls=PlotlyJSONEncoder)
36-
t2 = time()
37-
x[0] = np.nan
38-
x[1] = np.inf
39-
fig_2 = go.Figure(go.Heatmap(z=z, x=x))
40-
t3 = time()
41-
json_str_2 = _json.dumps(fig_2, cls=PlotlyJSONEncoder)
42-
t4 = time()
43-
assert t2 - t1 < t4 - t3
44-
assert "null" in json_str_2
45-
assert "NaN" not in json_str_2
46-
assert "Infinity" not in json_str_2
47-
x = np.arange(100.0)
48-
fig_3 = go.Figure(go.Heatmap(z=z, x=x))
49-
fig_3.update_layout(title_text="Infinity")
50-
t5 = time()
51-
json_str_3 = _json.dumps(fig_3, cls=PlotlyJSONEncoder)
52-
t6 = time()
53-
assert t2 - t1 < t6 - t5
54-
assert "Infinity" in json_str_3
55-
5620

5721
class TestGetByPath(TestCase):
5822
def test_get_by_path(self):
@@ -86,46 +50,3 @@ def test_node_generator(self):
8650
]
8751
for i, item in enumerate(node_generator(node0)):
8852
self.assertEqual(item, expected_node_path_tuples[i])
89-
90-
91-
class TestNumpyIntegerBaseType(TestCase):
92-
def test_numpy_integer_import(self):
93-
# should generate a figure with subplots of array and not throw a ValueError
94-
import numpy as np
95-
import plotly.graph_objects as go
96-
from plotly.subplots import make_subplots
97-
98-
indices_rows = np.array([1], dtype=np.int)
99-
indices_cols = np.array([1], dtype=np.int)
100-
fig = make_subplots(rows=1, cols=1)
101-
fig.add_trace(go.Scatter(y=[1]), row=indices_rows[0], col=indices_cols[0])
102-
103-
data_path = ("data", 0, "y")
104-
value = get_by_path(fig, data_path)
105-
expected_value = (1,)
106-
self.assertEqual(value, expected_value)
107-
108-
def test_get_numpy_int_type(self):
109-
import numpy as np
110-
from _plotly_utils.utils import _get_int_type
111-
112-
int_type_tuple = _get_int_type()
113-
expected_tuple = (int, np.integer)
114-
115-
self.assertEqual(int_type_tuple, expected_tuple)
116-
117-
118-
class TestNoNumpyIntegerBaseType(TestCase):
119-
def test_no_numpy_int_type(self):
120-
import sys
121-
from _plotly_utils.utils import _get_int_type
122-
from _plotly_utils.optional_imports import get_module
123-
124-
np = get_module("numpy", should_load=False)
125-
if np:
126-
sys.modules.pop("numpy")
127-
128-
int_type_tuple = _get_int_type()
129-
expected_tuple = (int,)
130-
131-
self.assertEqual(int_type_tuple, expected_tuple)

Diff for: packages/python/plotly/plotly/tests/test_core/test_autoshapes/test_annotated_shapes.py renamed to packages/python/plotly/plotly/tests/test_optional/test_autoshapes/test_annotated_shapes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import sys
2929
import pytest
3030
import json
31-
from common import _cmp_partial_dict, _check_figure_layout_objects
31+
from .common import _cmp_partial_dict, _check_figure_layout_objects
3232

3333

3434
@pytest.fixture

Diff for: packages/python/plotly/plotly/tests/test_core/test_autoshapes/test_axis_span_shapes.py renamed to packages/python/plotly/plotly/tests/test_optional/test_autoshapes/test_axis_span_shapes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from plotly.basedatatypes import _indexing_combinations
44
import plotly.express as px
55
import pytest
6-
from common import _cmp_partial_dict, _check_figure_layout_objects
6+
from .common import _cmp_partial_dict, _check_figure_layout_objects
77

88

99
@pytest.fixture

Diff for: packages/python/plotly/plotly/tests/test_optional/test_offline/test_offline.py

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def test_iplot_works_after_you_call_init_notebook_mode(self):
4040

4141
@pytest.mark.matplotlib
4242
def test_iplot_mpl_works(self):
43+
plotly.offline.init_notebook_mode()
4344
# Generate matplotlib plot for tests
4445
fig = plt.figure()
4546

Diff for: packages/python/plotly/plotly/tests/test_optional/test_px/__init__.py

Whitespace-only changes.

Diff for: packages/python/plotly/plotly/tests/test_optional/test_subplots/test_make_subplots.py

+30
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,33 @@ def test_subplot_titles_numpy_array(self):
1616
subplot_titles=np.array(["", "Inset"]),
1717
)
1818
self.assertEqual(fig, expected)
19+
20+
21+
class TestAddTracesRowsColsDataTypes(TestCase):
22+
def test_add_traces_with_iterable(self):
23+
import plotly.express as px
24+
25+
df = px.data.tips()
26+
fig = px.scatter(df, x="total_bill", y="tip", color="day")
27+
from plotly.subplots import make_subplots
28+
29+
fig2 = make_subplots(1, 2)
30+
fig2.add_traces(fig.data, rows=[1,] * len(fig.data), cols=[1,] * len(fig.data))
31+
32+
expected_data_length = 4
33+
34+
self.assertEqual(expected_data_length, len(fig2.data))
35+
36+
def test_add_traces_with_integers(self):
37+
import plotly.express as px
38+
39+
df = px.data.tips()
40+
fig = px.scatter(df, x="total_bill", y="tip", color="day")
41+
from plotly.subplots import make_subplots
42+
43+
fig2 = make_subplots(1, 2)
44+
fig2.add_traces(fig.data, rows=1, cols=2)
45+
46+
expected_data_length = 4
47+
48+
self.assertEqual(expected_data_length, len(fig2.data))

0 commit comments

Comments
 (0)