@@ -81,6 +81,20 @@ class Box(BaseParam):
8181 shading_offset : Sequence [float | str ] | None = None
8282 shading_fill : str | None = None
8383
84+ def validate (self ):
85+ """
86+ Validate the parameters.
87+ """
88+ # shading_offset must be a sequence of two values or None.
89+ if (
90+ self .shading_offset and not isinstance (self .shading_offset , Sequence )
91+ ) or len (self .shading_offset ) != 2 :
92+ raise GMTValueError (
93+ self .shading_offset ,
94+ description = "value for parameter 'shading_offset'" ,
95+ reason = "Must be a sequence of two values (dx, dy) or None." ,
96+ )
97+
8498 @property
8599 def _innerborder (self ) -> list [str | float ] | None :
86100 """
@@ -93,16 +107,7 @@ def _shading(self) -> list[str | float] | None:
93107 """
94108 Shading for the box, formatted as a list of 1-3 values, or None.
95109 """
96- # Local variable to simplify the code.
97- _shading_offset = [] if self .shading_offset is None else self .shading_offset
98-
99- # shading_offset must be a sequence of two values (dx, dy) or None.
100- if len (_shading_offset ) not in {0 , 2 }:
101- raise GMTValueError (
102- self .shading_offset ,
103- description = "value for parameter 'shading_offset'" ,
104- reason = "Must be a sequence of two values (dx, dy) or None." ,
105- )
110+ _shading_offset = self .shading_offset or []
106111 return [
107112 v for v in (* _shading_offset , self .shading_fill ) if v is not None
108113 ] or None
0 commit comments