2323 categorical_order ,
2424)
2525from seaborn .utils import desaturate
26-
2726from seaborn .palettes import color_palette
2827
2928
30- try :
31- from pandas import NA as PD_NA
32- except ImportError :
33- PD_NA = None
34-
35-
3629@pytest .fixture (params = [
3730 dict (x = "x" , y = "y" ),
3831 dict (x = "t" , y = "y" ),
@@ -1302,28 +1295,23 @@ def test_comp_data_category_order(self):
13021295
13031296 @pytest .fixture (
13041297 params = itertools .product (
1305- [None , np .nan , PD_NA ],
1306- ["numeric" , "category" , "datetime" ]
1298+ [None , np .nan , pd . NA ],
1299+ ["numeric" , "category" , "datetime" ],
13071300 )
13081301 )
1309- @pytest .mark .parametrize (
1310- "NA,var_type" ,
1311- )
1302+ @pytest .mark .parametrize ("NA,var_type" )
13121303 def comp_data_missing_fixture (self , request ):
13131304
13141305 # This fixture holds the logic for parameterizing
13151306 # the following test (test_comp_data_missing)
13161307
13171308 NA , var_type = request .param
13181309
1319- if NA is None :
1320- pytest .skip ("No pandas.NA available" )
1321-
13221310 comp_data = [0 , 1 , np .nan , 2 , np .nan , 1 ]
13231311 if var_type == "numeric" :
13241312 orig_data = [0 , 1 , NA , 2 , np .inf , 1 ]
13251313 elif var_type == "category" :
1326- orig_data = ["a" , "b" , NA , "c" , NA , "b" ]
1314+ orig_data = ["a" , "b" , NA , "c" , pd . NA , "b" ]
13271315 elif var_type == "datetime" :
13281316 # Use 1-based numbers to avoid issue on matplotlib<3.2
13291317 # Could simplify the test a bit when we roll off that version
@@ -1343,6 +1331,7 @@ def test_comp_data_missing(self, comp_data_missing_fixture):
13431331 ax = plt .figure ().subplots ()
13441332 p ._attach (ax )
13451333 assert_array_equal (p .comp_data ["x" ], comp_data )
1334+ assert p .comp_data ["x" ].dtype == "float"
13461335
13471336 def test_comp_data_duplicate_index (self ):
13481337
@@ -1352,6 +1341,15 @@ def test_comp_data_duplicate_index(self):
13521341 p ._attach (ax )
13531342 assert_array_equal (p .comp_data ["x" ], x )
13541343
1344+ def test_comp_data_nullable_dtype (self ):
1345+
1346+ x = pd .Series ([1 , 2 , 3 , 4 ], dtype = "Int64" )
1347+ p = VectorPlotter (variables = {"x" : x })
1348+ ax = plt .figure ().subplots ()
1349+ p ._attach (ax )
1350+ assert_array_equal (p .comp_data ["x" ], x )
1351+ assert p .comp_data ["x" ].dtype == "float"
1352+
13551353 def test_var_order (self , long_df ):
13561354
13571355 order = ["c" , "b" , "a" ]
@@ -1456,7 +1454,12 @@ def test_variable_type(self):
14561454 assert variable_type (s ) == "numeric"
14571455
14581456 s = pd .Series ([np .nan , np .nan ])
1459- # s = pd.Series([pd.NA, pd.NA])
1457+ assert variable_type (s ) == "numeric"
1458+
1459+ s = pd .Series ([pd .NA , pd .NA ])
1460+ assert variable_type (s ) == "numeric"
1461+
1462+ s = pd .Series ([1 , 2 , pd .NA ], dtype = "Int64" )
14601463 assert variable_type (s ) == "numeric"
14611464
14621465 s = pd .Series (["1" , "2" , "3" ])
0 commit comments