@@ -1660,24 +1660,29 @@ class AngleValidator(BaseValidator):
16601660 "description": "A number (in degree) between -180 and 180.",
16611661 "requiredOpts": [],
16621662 "otherOpts": [
1663- "dflt"
1663+ "dflt",
1664+ "arrayOk"
16641665 ]
16651666 },
16661667 """
16671668
1668- def __init__ (self , plotly_name , parent_name , ** kwargs ):
1669+ def __init__ (self , plotly_name , parent_name , array_ok = False , ** kwargs ):
16691670 super (AngleValidator , self ).__init__ (
16701671 plotly_name = plotly_name , parent_name = parent_name , ** kwargs
16711672 )
1673+ self .array_ok = array_ok
16721674
16731675 def description (self ):
16741676 desc = """\
16751677 The '{plotly_name}' property is a angle (in degrees) that may be
1676- specified as a number between -180 and 180. Numeric values outside this
1677- range are converted to the equivalent value
1678+ specified as a number between -180 and 180{array_ok}.
1679+ Numeric values outside this range are converted to the equivalent value
16781680 (e.g. 270 is converted to -90).
16791681 """ .format (
1680- plotly_name = self .plotly_name
1682+ plotly_name = self .plotly_name ,
1683+ array_ok = ", or a list, numpy array or other iterable thereof"
1684+ if self .array_ok
1685+ else "" ,
16811686 )
16821687
16831688 return desc
@@ -1686,6 +1691,22 @@ def validate_coerce(self, v):
16861691 if v is None :
16871692 # Pass None through
16881693 pass
1694+ elif self .array_ok and is_homogeneous_array (v ):
1695+ try :
1696+ v_array = copy_to_readonly_numpy_array (v , force_numeric = True )
1697+ except (ValueError , TypeError , OverflowError ):
1698+ self .raise_invalid_val (v )
1699+ v = v_array # Always numeric numpy array
1700+ # Normalize v onto the interval [-180, 180)
1701+ v = (v + 180 ) % 360 - 180
1702+ elif self .array_ok and is_simple_array (v ):
1703+ # Check numeric
1704+ invalid_els = [e for e in v if not isinstance (e , numbers .Number )]
1705+
1706+ if invalid_els :
1707+ self .raise_invalid_elements (invalid_els [:10 ])
1708+
1709+ v = [(x + 180 ) % 360 - 180 for x in to_scalar_or_list (v )]
16891710 elif not isinstance (v , numbers .Number ):
16901711 self .raise_invalid_val (v )
16911712 else :
0 commit comments