4
4
TYPE_CHECKING ,
5
5
Literal ,
6
6
NamedTuple ,
7
+ Optional ,
8
+ Union ,
7
9
)
8
10
import warnings
9
11
@@ -98,7 +100,8 @@ def __init__(self, data, return_type: str = "axes", **kwargs) -> None:
98
100
# error: Signature of "_plot" incompatible with supertype "MPLPlot"
99
101
@classmethod
100
102
def _plot ( # type: ignore[override]
101
- cls , ax : Axes , y : np .ndarray , column_num = None , return_type : str = "axes" , ** kwds
103
+ cls , ax : Axes , y : np .ndarray , column_num : Optional [int ] = None , return_type : str = "axes" , ** kwds
104
+
102
105
):
103
106
ys : np .ndarray | list [np .ndarray ]
104
107
if y .ndim == 2 :
@@ -107,6 +110,9 @@ def _plot( # type: ignore[override]
107
110
# if any cols are empty
108
111
# GH 8181
109
112
ys = [v if v .size > 0 else np .array ([np .nan ]) for v in ys ]
113
+ for v in ys :
114
+ if v .size == 0 :
115
+ warnings .warn ("Empty array detected, replacing with NaN" , stacklevel = find_stack_level ())
110
116
else :
111
117
ys = remove_na_arraylike (y )
112
118
bp = ax .boxplot (ys , ** kwds )
@@ -166,10 +172,7 @@ def _caps_c(self):
166
172
def _get_colors (
167
173
self ,
168
174
num_colors = None ,
169
- color_kwds : dict [str , MatplotlibColor ]
170
- | MatplotlibColor
171
- | Collection [MatplotlibColor ]
172
- | None = "color" ,
175
+ color_kwds : Optional [Union [dict [str , MatplotlibColor ], MatplotlibColor , Collection [MatplotlibColor ]]] = "color" ,
173
176
) -> None :
174
177
pass
175
178
@@ -391,8 +394,7 @@ def _get_colors():
391
394
result [key_to_index [key ]] = value
392
395
else :
393
396
raise ValueError (
394
- f"color dict contains invalid key '{ key } '. "
395
- f"The key must be either { valid_keys } "
397
+ f"Invalid key '{ key } ' in color dictionary. Expected one of { valid_keys } . Please refer to documentation." )
396
398
)
397
399
else :
398
400
result .fill (colors )
0 commit comments