44 TYPE_CHECKING ,
55 Literal ,
66 NamedTuple ,
7+ Optional ,
8+ Union ,
79)
810import warnings
911
@@ -98,7 +100,8 @@ def __init__(self, data, return_type: str = "axes", **kwargs) -> None:
98100 # error: Signature of "_plot" incompatible with supertype "MPLPlot"
99101 @classmethod
100102 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+
102105 ):
103106 ys : np .ndarray | list [np .ndarray ]
104107 if y .ndim == 2 :
@@ -107,6 +110,9 @@ def _plot( # type: ignore[override]
107110 # if any cols are empty
108111 # GH 8181
109112 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 ())
110116 else :
111117 ys = remove_na_arraylike (y )
112118 bp = ax .boxplot (ys , ** kwds )
@@ -166,10 +172,7 @@ def _caps_c(self):
166172 def _get_colors (
167173 self ,
168174 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" ,
173176 ) -> None :
174177 pass
175178
@@ -391,8 +394,7 @@ def _get_colors():
391394 result [key_to_index [key ]] = value
392395 else :
393396 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." )
396398 )
397399 else :
398400 result .fill (colors )
0 commit comments