@@ -81,6 +81,20 @@ class Box(BaseParam):
81
81
shading_offset : Sequence [float | str ] | None = None
82
82
shading_fill : str | None = None
83
83
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
+
84
98
@property
85
99
def _innerborder (self ) -> list [str | float ] | None :
86
100
"""
@@ -93,16 +107,7 @@ def _shading(self) -> list[str | float] | None:
93
107
"""
94
108
Shading for the box, formatted as a list of 1-3 values, or None.
95
109
"""
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 []
106
111
return [
107
112
v for v in (* _shading_offset , self .shading_fill ) if v is not None
108
113
] or None
0 commit comments