Skip to content

Commit

Permalink
Revert changes to validators
Browse files Browse the repository at this point in the history
  • Loading branch information
marthacryan committed Oct 17, 2024
1 parent 9d6b0c7 commit 960adb9
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions packages/python/plotly/_plotly_utils/basevalidators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import base64
import numbers
import textwrap
import traceback
import uuid
from importlib import import_module
import copy
Expand Down Expand Up @@ -208,17 +207,6 @@ def is_homogeneous_array(v):
return False


def is_typed_array_spec(v):
"""
Return whether a value is considered to be a typed array spec for plotly.js
"""
return isinstance(v, dict) and "bdata" in v and "dtype" in v


def is_none_or_typed_array_spec(v):
return v is None or is_typed_array_spec(v)


def is_simple_array(v):
"""
Return whether a value is considered to be an simple array
Expand Down Expand Up @@ -412,7 +400,9 @@ def description(self):
)

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):

if v is None:
# Pass None through
pass
elif is_homogeneous_array(v):
v = copy_to_readonly_numpy_array(v)
Expand Down Expand Up @@ -609,7 +599,8 @@ def in_values(self, e):
return False

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):
if v is None:
# Pass None through
pass
elif self.array_ok and is_array(v):
v_replaced = [self.perform_replacemenet(v_el) for v_el in v]
Expand Down Expand Up @@ -769,7 +760,8 @@ def description(self):
return desc

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):
if v is None:
# Pass None through
pass
elif self.array_ok and is_homogeneous_array(v):
np = get_module("numpy")
Expand Down Expand Up @@ -915,7 +907,8 @@ def description(self):
return desc

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):
if v is None:
# Pass None through
pass
elif v in self.extras:
return v
Expand Down Expand Up @@ -1078,7 +1071,8 @@ def description(self):
return desc

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):
if v is None:
# Pass None through
pass
elif self.array_ok and is_array(v):

Expand Down Expand Up @@ -1379,7 +1373,8 @@ def description(self):
return valid_color_description

def validate_coerce(self, v, should_raise=True):
if is_none_or_typed_array_spec(v):
if v is None:
# Pass None through
pass
elif self.array_ok and is_homogeneous_array(v):
v = copy_to_readonly_numpy_array(v)
Expand Down Expand Up @@ -1523,7 +1518,8 @@ def description(self):

def validate_coerce(self, v):

if is_none_or_typed_array_spec(v):
if v is None:
# Pass None through
pass
elif is_array(v):
validated_v = [
Expand Down Expand Up @@ -1728,7 +1724,8 @@ def description(self):
return desc

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):
if v is None:
# Pass None through
pass
elif self.array_ok and is_homogeneous_array(v):
try:
Expand Down Expand Up @@ -1916,9 +1913,6 @@ def validate_coerce(self, v):
if v is None:
# Pass None through
pass
if is_typed_array_spec(v):
# Pass typed array spec through
pass
elif self.array_ok and is_array(v):

# Coerce individual strings
Expand Down Expand Up @@ -1975,7 +1969,8 @@ def description(self):
return desc

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):
if v is None:
# Pass None through
pass
elif self.array_ok and is_homogeneous_array(v):
v = copy_to_readonly_numpy_array(v, kind="O")
Expand Down Expand Up @@ -2183,7 +2178,8 @@ def validate_element_with_indexed_name(self, val, validator, inds):
return val

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):
if v is None:
# Pass None through
return None
elif not is_array(v):
self.raise_invalid_val(v)
Expand Down Expand Up @@ -2246,7 +2242,7 @@ def validate_coerce(self, v):
return v

def present(self, v):
if is_none_or_typed_array_spec(v):
if v is None:
return None
else:
if (
Expand Down

0 comments on commit 960adb9

Please sign in to comment.