@@ -1660,15 +1660,17 @@ class AngleValidator(BaseValidator):
1660
1660
"description": "A number (in degree) between -180 and 180.",
1661
1661
"requiredOpts": [],
1662
1662
"otherOpts": [
1663
- "dflt"
1663
+ "dflt",
1664
+ "arrayOk"
1664
1665
]
1665
1666
},
1666
1667
"""
1667
1668
1668
- def __init__ (self , plotly_name , parent_name , ** kwargs ):
1669
+ def __init__ (self , plotly_name , parent_name , array_ok = False , ** kwargs ):
1669
1670
super (AngleValidator , self ).__init__ (
1670
1671
plotly_name = plotly_name , parent_name = parent_name , ** kwargs
1671
1672
)
1673
+ self .array_ok = array_ok
1672
1674
1673
1675
def description (self ):
1674
1676
desc = """\
@@ -1686,6 +1688,20 @@ def validate_coerce(self, v):
1686
1688
if v is None :
1687
1689
# Pass None through
1688
1690
pass
1691
+ elif self .array_ok and is_homogeneous_array (v ):
1692
+ try :
1693
+ v_array = copy_to_readonly_numpy_array (v , force_numeric = True )
1694
+ except (ValueError , TypeError , OverflowError ):
1695
+ self .raise_invalid_val (v )
1696
+ v = v_array # Always numeric numpy array
1697
+ elif self .array_ok and is_simple_array (v ):
1698
+ # Check numeric
1699
+ invalid_els = [e for e in v if not isinstance (e , numbers .Number )]
1700
+
1701
+ if invalid_els :
1702
+ self .raise_invalid_elements (invalid_els [:10 ])
1703
+
1704
+ v = to_scalar_or_list (v )
1689
1705
elif not isinstance (v , numbers .Number ):
1690
1706
self .raise_invalid_val (v )
1691
1707
else :
0 commit comments