@@ -249,11 +249,13 @@ def test_update_plot(self, plotter):
249
249
failing_test_cases = [("mixed" , ['A' , 3.14 ]),
250
250
("number integer" , ['1' , 1 ]),
251
251
("string integer" , ['42' , 42 ]),
252
+ ("nested categorical" , [["a" , "b" ], ["c" , "d" ]]),
252
253
("missing" , ['12' , np .nan ])]
253
254
254
255
fids , fvalues = zip (* failing_test_cases )
255
256
256
- plotters = [Axes .scatter , Axes .bar ,
257
+ plotters = [pytest .param (Axes .scatter , marks = pytest .mark .xfail ),
258
+ Axes .bar ,
257
259
pytest .param (Axes .plot , marks = pytest .mark .xfail )]
258
260
259
261
@pytest .mark .parametrize ("plotter" , plotters )
@@ -321,3 +323,33 @@ def test_set_lim():
321
323
ax .plot (["a" , "b" , "c" , "d" ], [1 , 2 , 3 , 4 ])
322
324
with warnings .catch_warnings ():
323
325
ax .set_xlim ("b" , "c" )
326
+
327
+
328
+ categorical_examples = [("nested categorical" , [["a" , "b" ], ["c" , "d" ]]),
329
+ ("nested with nan" , [['0' , np .nan ], ["aa" , "bb" ]]),
330
+ ("nested mixed" , [[1 , 'a' ], ['b' , np .nan ]])]
331
+ cids , cvalues = zip (* categorical_examples )
332
+
333
+
334
+ @pytest .mark .parametrize ("xdata" , cvalues , ids = cids )
335
+ @pytest .mark .parametrize ("ydata" , cvalues , ids = cids )
336
+ def test_nested_categorical (xdata , ydata ):
337
+ ax = plt .figure ().subplots ()
338
+ ax .scatter (xdata , ydata )
339
+
340
+ xtexts = [xelement ._text for xelement in ax .get_xticklabels ()]
341
+
342
+ assert np .all (xtexts == np .ma .ravel (xdata ))
343
+
344
+
345
+ @pytest .mark .parametrize ("xdata" , cvalues , ids = cids )
346
+ def test_nested_categorical_and_numerical (xdata ):
347
+ ydata = [[0 , 1 ], [2 , 3 ]]
348
+ ax = plt .figure ().subplots ()
349
+ splot = ax .scatter (xdata , ydata )
350
+
351
+ xtexts = [xelement ._text for xelement in ax .get_xticklabels ()]
352
+ y_offset_processed = list (zip (* splot .get_offsets ()))[1 ]
353
+
354
+ assert np .all (xtexts == np .ma .ravel (xdata ))
355
+ assert np .all (np .ma .ravel (ydata ) == y_offset_processed )
0 commit comments