Skip to content

Commit 8a3a4b3

Browse files
committed
blacken
1 parent 242d1fa commit 8a3a4b3

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

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

+13-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ def copy_to_readonly_numpy_array_or_list(v, kind=None, force_numeric=False):
8989

9090
# u: unsigned int, i: signed int, f: float
9191
numeric_kinds = {"u", "i", "f"}
92-
kind_default_dtypes = {"u": "uint32", "i": "int32", "f": "float64", "O": "object", "U": "U"}
92+
kind_default_dtypes = {
93+
"u": "uint32",
94+
"i": "int32",
95+
"f": "float64",
96+
"O": "object",
97+
"U": "U",
98+
}
9399

94100
# Handle pandas Series and Index objects
95101
if pd and isinstance(v, (pd.Series, pd.Index)):
@@ -191,7 +197,7 @@ def is_homogeneous_array(v):
191197
if v_numpy.shape == ():
192198
return False
193199
else:
194-
return True # v_numpy.dtype.kind in ["u", "i", "f", "M", "U"]
200+
return True # v_numpy.dtype.kind in ["u", "i", "f", "M", "U"]
195201
return False
196202

197203

@@ -1320,7 +1326,11 @@ def validate_coerce(self, v, should_raise=True):
13201326
pass
13211327
elif self.array_ok and is_homogeneous_array(v):
13221328
v = copy_to_readonly_numpy_array_or_list(v)
1323-
if not isinstance(v, list) and self.numbers_allowed() and v.dtype.kind in ["u", "i", "f"]:
1329+
if (
1330+
not isinstance(v, list)
1331+
and self.numbers_allowed()
1332+
and v.dtype.kind in ["u", "i", "f"]
1333+
):
13241334
# Numbers are allowed and we have an array of numbers.
13251335
# All good
13261336
pass

Diff for: packages/python/plotly/_plotly_utils/tests/validators/test_dataarray_validator.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ def test_validator_acceptance_simple(val, validator):
3232

3333

3434
@pytest.mark.parametrize(
35-
"val",
36-
[np.array([2, 3, 4]), np.array([[1, 2, 3], [4, 5, 6]])],
35+
"val", [np.array([2, 3, 4]), np.array([[1, 2, 3], [4, 5, 6]])],
3736
)
3837
def test_validator_acceptance_homogeneous(val, validator):
3938
coerce_val = validator.validate_coerce(val)
@@ -44,7 +43,11 @@ def test_validator_acceptance_homogeneous(val, validator):
4443
# Accept object array as list
4544
@pytest.mark.parametrize(
4645
"val",
47-
[["A", "B", "C"], np.array(["A", "B", "C"], dtype="object"), pd.Series(["a", "b", "c"])]
46+
[
47+
["A", "B", "C"],
48+
np.array(["A", "B", "C"], dtype="object"),
49+
pd.Series(["a", "b", "c"]),
50+
],
4851
)
4952
def test_validator_accept_object_array_as_list(val, validator):
5053
coerce_val = validator.validate_coerce(val)

0 commit comments

Comments
 (0)