Skip to content

Commit be7eb0f

Browse files
Removed _unzip_pairs in favour of zip(*...)
1 parent 6a86381 commit be7eb0f

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

packages/python/plotly/plotly/basedatatypes.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
Undefined = object()
2222

2323

24-
def _unzip_pairs(pairs):
25-
pairs = list(pairs)
26-
return ([t[0] for t in pairs], [t[1] for t in pairs])
27-
28-
2924
def _combine_dicts(dicts):
3025
all_args = dict()
3126
for d in dicts:

packages/python/plotly/plotly/tests/test_core/test_autoshapes/test_axis_span_shapes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import plotly.graph_objs as go
22
from plotly.subplots import make_subplots
3-
from plotly.basedatatypes import _indexing_combinations, _unzip_pairs
3+
from plotly.basedatatypes import _indexing_combinations
44
import plotly.express as px
55
import pytest
66
from common import _cmp_partial_dict, _check_figure_layout_objects

packages/python/plotly/plotly/tests/test_core/test_update_objects/test_select_subplots.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import plotly.graph_objs as go
22
from plotly.subplots import make_subplots
3-
from plotly.basedatatypes import _indexing_combinations, _unzip_pairs
3+
from plotly.basedatatypes import _indexing_combinations
44
import pytest
5+
from itertools import product
56

67
NROWS = 4
78
NCOLS = 5
@@ -154,29 +155,17 @@ def _sort_row_col_lists(rows, cols):
154155
@pytest.mark.parametrize(
155156
"test_input,expected",
156157
[
157-
(
158-
("all", [2, 4, 5], False),
159-
_unzip_pairs([(r, c) for r in range(1, NROWS + 1) for c in [2, 4, 5]]),
160-
),
161-
(
162-
([1, 3], "all", False),
163-
_unzip_pairs([(r, c) for r in [1, 3] for c in range(1, NCOLS + 1)]),
164-
),
165-
(
166-
([1, 3], "all", True),
167-
_unzip_pairs([(r, c) for r in [1, 3] for c in range(1, NCOLS + 1)]),
168-
),
169-
(([1, 3], [2, 4, 5], False), _unzip_pairs([(1, 2), (3, 4)])),
170-
(
171-
([1, 3], [2, 4, 5], True),
172-
_unzip_pairs([(r, c) for r in [1, 3] for c in [2, 4, 5]]),
173-
),
158+
(("all", [2, 4, 5], False), zip(*product(range(1, NROWS + 1), [2, 4, 5])),),
159+
(([1, 3], "all", False), zip(*product([1, 3], range(1, NCOLS + 1))),),
160+
(([1, 3], "all", True), zip(*product([1, 3], range(1, NCOLS + 1))),),
161+
(([1, 3], [2, 4, 5], False), [(1, 3), (2, 4)]),
162+
(([1, 3], [2, 4, 5], True), zip(*product([1, 3], [2, 4, 5])),),
174163
],
175164
)
176165
def test_select_subplot_coordinates(subplot_fig_fixture, test_input, expected):
177166
rows, cols, product = test_input
178167
er, ec = _sort_row_col_lists(*expected)
179168
t = subplot_fig_fixture._select_subplot_coordinates(rows, cols, product=product)
180-
r, c = _unzip_pairs(t)
169+
r, c = zip(*t)
181170
r, c = _sort_row_col_lists(r, c)
182171
assert (r == er) and (c == ec)

0 commit comments

Comments
 (0)