Skip to content

Commit 0d0dad2

Browse files
committed
Revert changes to validator tests
1 parent de2bcb5 commit 0d0dad2

14 files changed

+12
-169
lines changed

packages/python/plotly/_plotly_utils/tests/validators/test_angle_validator.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# from ..basevalidators import AngleValidator
44
from _plotly_utils.basevalidators import AngleValidator
55
import numpy as np
6-
from plotly.tests.b64 import b64
76

87

98
# Fixtures
@@ -52,14 +51,6 @@ def test_aok_acceptance(val, validator_aok):
5251
assert np.array_equal(validator_aok.validate_coerce(np.array(val)), np.array(val))
5352

5453

55-
# Test base64 array
56-
def test_aok_base64_array(validator_aok):
57-
val = b64(np.array([1, 2, 3], dtype="int64"))
58-
coerce_val = validator_aok.validate_coerce(val)
59-
assert coerce_val["bdata"] == "AQID"
60-
assert coerce_val["dtype"] == "i1"
61-
62-
6354
# ### Test coercion above 180 ###
6455
@pytest.mark.parametrize(
6556
"val,expected",

packages/python/plotly/_plotly_utils/tests/validators/test_any_validator.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
from _plotly_utils.basevalidators import AnyValidator
33
import numpy as np
4-
from plotly.tests.b64 import b64
54

65

76
# Fixtures
@@ -50,10 +49,3 @@ def test_acceptance_array(val, validator_aok):
5049
else:
5150
assert coerce_val == val
5251
assert validator_aok.present(coerce_val) == val
53-
54-
55-
def test_base64_array(validator_aok):
56-
val = b64(np.array([1, 2, 3], dtype="int64"))
57-
coerce_val = validator_aok.validate_coerce(val)
58-
assert coerce_val["bdata"] == "AQID"
59-
assert coerce_val["dtype"] == "i1"

packages/python/plotly/_plotly_utils/tests/validators/test_basetraces_validator.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from _plotly_utils.basevalidators import BaseDataValidator
33
from plotly.graph_objs import Scatter, Bar, Box
4-
import numpy as np
4+
55

66
# Fixtures
77
# --------
@@ -118,19 +118,6 @@ def test_rejection_element_tracetype(validator):
118118
assert "Invalid element(s)" in str(validation_failure.value)
119119

120120

121-
def test_b64(validator):
122-
val = [dict(type="scatter", x=np.array([1, 2, 3]))]
123-
res = validator.validate_coerce(val)
124-
res_present = validator.present(res)
125-
126-
assert isinstance(res, list)
127-
assert isinstance(res_present, tuple)
128-
129-
assert isinstance(res_present[0], Scatter)
130-
assert res_present[0].type == "scatter"
131-
assert res_present[0].x == {"bdata": "AQID", "dtype": "i1"}
132-
133-
134121
def test_skip_invalid(validator_nouid):
135122
val = (
136123
dict(

packages/python/plotly/_plotly_utils/tests/validators/test_color_validator.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import pytest
22
from _plotly_utils.basevalidators import ColorValidator
33
import numpy as np
4-
from plotly.tests.b64 import b64
54

65

76
# Fixtures
@@ -132,19 +131,6 @@ def test_acceptance_aok(val, validator_aok):
132131
assert coerce_val == val
133132

134133

135-
# Test that it doesn't use a base64 array
136-
# Numpy v2 has a StrDType but we don't want to convert it yet.
137-
# Change this test if you add support for it.
138-
def test_acceptance_aok_base64_array(validator_aok):
139-
val = b64(np.array(["aliceblue", "antiquewhite", "aqua", "aquamarine", "azure"]))
140-
coerce_val = validator_aok.validate_coerce(val)
141-
assert coerce_val[0] == "aliceblue"
142-
assert coerce_val[1] == "antiquewhite"
143-
assert coerce_val[2] == "aqua"
144-
assert coerce_val[3] == "aquamarine"
145-
assert coerce_val[4] == "azure"
146-
147-
148134
@pytest.mark.parametrize(
149135
"val",
150136
[

packages/python/plotly/_plotly_utils/tests/validators/test_colorlist_validator.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33

44
from _plotly_utils.basevalidators import ColorlistValidator
5-
from plotly.tests.b64 import b64
5+
66

77
# Fixtures
88
# --------
@@ -48,13 +48,3 @@ def test_acceptance_aok(val, validator):
4848
coerce_val = validator.validate_coerce(val)
4949
assert isinstance(coerce_val, list)
5050
assert validator.present(coerce_val) == tuple(val)
51-
52-
53-
# Test that it doesn't use a base64 array
54-
# Numpy v2 has a StrDType but we don't want to convert it yet.
55-
# Change this test if you add support for it.
56-
def test_acceptance_b64_aok(validator):
57-
val = b64(np.array(["red", "rgb(255, 0, 0)"]))
58-
coerce_val = validator.validate_coerce(val)
59-
assert coerce_val[0] == "red"
60-
assert coerce_val[1] == "rgb(255, 0, 0)"

packages/python/plotly/_plotly_utils/tests/validators/test_compoundarray_validator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from _plotly_utils.basevalidators import CompoundArrayValidator
33
from plotly.graph_objs.layout import Image
44

5+
56
# Fixtures
67
# --------
78
@pytest.fixture()

packages/python/plotly/_plotly_utils/tests/validators/test_dataarray_validator.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from _plotly_utils.basevalidators import DataArrayValidator
33
import numpy as np
44
import pandas as pd
5-
from plotly.tests.b64 import b64
65

76
# Fixtures
87
# --------
@@ -34,22 +33,12 @@ def test_validator_acceptance_simple(val, validator):
3433

3534
@pytest.mark.parametrize(
3635
"val",
37-
[pd.Series(["a", "b", "c"])],
36+
[np.array([2, 3, 4]), pd.Series(["a", "b", "c"]), np.array([[1, 2, 3], [4, 5, 6]])],
3837
)
3938
def test_validator_acceptance_homogeneous(val, validator):
4039
coerce_val = validator.validate_coerce(val)
4140
assert isinstance(coerce_val, np.ndarray)
42-
assert np.array_equal(validator.present(coerce_val), b64(val))
43-
44-
45-
@pytest.mark.parametrize(
46-
"val",
47-
[np.array([2, 3, 4]), np.array([[1, 2, 3], [4, 5, 6]])],
48-
)
49-
def test_validator_acceptance_homogeneous(val, validator):
50-
coerce_val = validator.validate_coerce(val)
51-
assert isinstance(coerce_val, object)
52-
assert np.array_equal(validator.present(coerce_val), b64(val))
41+
assert np.array_equal(validator.present(coerce_val), val)
5342

5443

5544
# ### Rejection ###

packages/python/plotly/_plotly_utils/tests/validators/test_enumerated_validator.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import numpy as np
33
import pandas as pd
44
from _plotly_utils.basevalidators import EnumeratedValidator
5-
from plotly.tests.b64 import b64
65

76

87
# Fixtures
@@ -95,14 +94,6 @@ def test_acceptance_aok(val, validator_aok):
9594
assert coerce_val == val
9695

9796

98-
# Test base64 array
99-
def test_aok_base64_array(validator_aok):
100-
val = b64(np.array([1, 2, 3], dtype="int64"))
101-
coerce_val = validator_aok.validate_coerce(val)
102-
assert coerce_val["bdata"] == "AQID"
103-
assert coerce_val["dtype"] == "i1"
104-
105-
10697
# ### Rejection by value ###
10798
@pytest.mark.parametrize("val", [True, 0, 1, 23, np.inf, set()])
10899
def test_rejection_by_value_aok(val, validator_aok):

packages/python/plotly/_plotly_utils/tests/validators/test_flaglist_validator.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
from _plotly_utils.basevalidators import FlaglistValidator
44
import numpy as np
5-
from plotly.tests.b64 import b64
5+
66

77
EXTRAS = ["none", "all", True, False, 3]
88
FLAGS = ["lines", "markers", "text"]
@@ -130,14 +130,6 @@ def test_acceptance_aok_scalar_extra(extra, validator_extra_aok):
130130
assert validator_extra_aok.validate_coerce(extra) == extra
131131

132132

133-
# Test base64 array
134-
def test_acceptance_aok_scalar_base64(validator_extra_aok):
135-
val = b64(np.array([1, 2, 3], dtype="int64"))
136-
coerce_val = validator_extra_aok.validate_coerce(val)
137-
assert coerce_val["bdata"] == "AQID"
138-
assert coerce_val["dtype"] == "i1"
139-
140-
141133
# ### Acceptance (lists) ###
142134
def test_acceptance_aok_scalarlist_flaglist(flaglist, validator_extra_aok):
143135
assert np.array_equal(

packages/python/plotly/_plotly_utils/tests/validators/test_integer_validator.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import pytest
44
from pytest import approx
55
from _plotly_utils.basevalidators import IntegerValidator
6-
from plotly.tests.b64 import b64
76
import numpy as np
87
import pandas as pd
98

@@ -145,51 +144,6 @@ def test_acceptance_aok_list(val, validator_aok):
145144
assert np.array_equal(validator_aok.validate_coerce(val), val)
146145

147146

148-
# Test base64 encoded arrays with array_ok=True
149-
INT_BASE64_TEST_CASES = [
150-
# Note: we decided not to support int64 in plotly.js,
151-
# so the the max / min value are limited to int32 and the
152-
# dtype is cast to int32 in the output
153-
(
154-
b64(np.array([-900000000, 900000000, 3], dtype="int64")),
155-
{"bdata": "ABdbygDppDUDAAAA", "dtype": "i4"},
156-
),
157-
(
158-
b64(np.array([-900000000, 900000000, 3], dtype="int32")),
159-
{"bdata": "ABdbygDppDUDAAAA", "dtype": "i4"},
160-
),
161-
(
162-
b64(np.array([32767, -32767, 3], dtype="int16")),
163-
{"bdata": "/38BgAMA", "dtype": "i2"},
164-
),
165-
(
166-
b64(np.array([127, -127, 3], dtype="int8")),
167-
{"bdata": "f4ED", "dtype": "i1"},
168-
),
169-
(
170-
b64(np.array([900000000, 2, 3], dtype="uint64")),
171-
{"bdata": "AOmkNQIAAAADAAAA", "dtype": "u4"},
172-
),
173-
(
174-
b64(np.array([900000000, 2, 3], dtype="uint32")),
175-
{"bdata": "AOmkNQIAAAADAAAA", "dtype": "u4"},
176-
),
177-
(
178-
b64(np.array([32767, 0, 3], dtype="uint16")),
179-
{"bdata": "/38AAAMA", "dtype": "u2"},
180-
),
181-
(
182-
b64(np.array([127, 2, 3], dtype="uint8")),
183-
{"bdata": "fwID", "dtype": "u1"},
184-
),
185-
]
186-
187-
188-
@pytest.mark.parametrize("val, expected", INT_BASE64_TEST_CASES)
189-
def test_acceptance_aok_base64(val, expected, validator_aok):
190-
assert np.array_equal(validator_aok.validate_coerce(val), expected)
191-
192-
193147
# ### Coerce ###
194148
# Coerced to general consistent numeric type
195149
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)