Skip to content
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

fix to_scalar_or_list when v.ndim == 0 #1444

Merged
merged 2 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _plotly_utils/basevalidators.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def to_scalar_or_list(v):
if isinstance(v, (list, tuple)):
return [to_scalar_or_list(e) for e in v]
elif np and isinstance(v, np.ndarray):
if v.ndim == 0:
return v.item()
return [to_scalar_or_list(e) for e in v]
elif pd and isinstance(v, (pd.Series, pd.Index)):
return [to_scalar_or_list(e) for e in v]
Expand Down
2 changes: 1 addition & 1 deletion _plotly_utils/tests/validators/test_dataarray_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def validator():
# -----
# ### Acceptance ###
@pytest.mark.parametrize('val', [
[], [1], [''], (), ('Hello, ', 'world!'), ['A', 1, 'B', 0, 'C']
[], [1], [''], (), ('Hello, ', 'world!'), ['A', 1, 'B', 0, 'C'], [np.array(1), np.array(2)]
])
def test_validator_acceptance_simple(val, validator):
coerce_val = validator.validate_coerce(val)
Expand Down