1515from pandas .core .dtypes .common import is_scalar
1616from pandas .core .dtypes .dtypes import DatetimeTZDtype
1717from pandas .core .dtypes .missing import (
18- array_equivalent , isna , notna ,
18+ array_equivalent , isna , notna , isnull , notnull ,
1919 na_value_for_dtype )
2020
2121
22- def test_notna ():
23- assert notna (1. )
24- assert not notna (None )
25- assert not notna (np .NaN )
22+ @pytest .mark .parametrize ('notna_f' , [notna , notnull ])
23+ def test_notna_notnull (notna_f ):
24+ assert notna_f (1. )
25+ assert not notna_f (None )
26+ assert not notna_f (np .NaN )
2627
2728 with cf .option_context ("mode.use_inf_as_na" , False ):
28- assert notna (np .inf )
29- assert notna (- np .inf )
29+ assert notna_f (np .inf )
30+ assert notna_f (- np .inf )
3031
3132 arr = np .array ([1.5 , np .inf , 3.5 , - np .inf ])
32- result = notna (arr )
33+ result = notna_f (arr )
3334 assert result .all ()
3435
3536 with cf .option_context ("mode.use_inf_as_na" , True ):
36- assert not notna (np .inf )
37- assert not notna (- np .inf )
37+ assert not notna_f (np .inf )
38+ assert not notna_f (- np .inf )
3839
3940 arr = np .array ([1.5 , np .inf , 3.5 , - np .inf ])
40- result = notna (arr )
41+ result = notna_f (arr )
4142 assert result .sum () == 2
4243
4344 with cf .option_context ("mode.use_inf_as_na" , False ):
4445 for s in [tm .makeFloatSeries (), tm .makeStringSeries (),
4546 tm .makeObjectSeries (), tm .makeTimeSeries (),
4647 tm .makePeriodSeries ()]:
47- assert (isinstance (isna (s ), Series ))
48+ assert (isinstance (notna_f (s ), Series ))
4849
4950
5051class TestIsNA (object ):
@@ -66,40 +67,41 @@ def test_empty_object(self):
6667 expected = np .ones (shape = shape , dtype = bool )
6768 tm .assert_numpy_array_equal (result , expected )
6869
69- def test_isna (self ):
70- assert not isna (1. )
71- assert isna (None )
72- assert isna (np .NaN )
70+ @pytest .mark .parametrize ('isna_f' , [isna , isnull ])
71+ def test_isna_isnull (self , isna_f ):
72+ assert not isna_f (1. )
73+ assert isna_f (None )
74+ assert isna_f (np .NaN )
7375 assert float ('nan' )
74- assert not isna (np .inf )
75- assert not isna (- np .inf )
76+ assert not isna_f (np .inf )
77+ assert not isna_f (- np .inf )
7678
7779 # series
7880 for s in [tm .makeFloatSeries (), tm .makeStringSeries (),
7981 tm .makeObjectSeries (), tm .makeTimeSeries (),
8082 tm .makePeriodSeries ()]:
81- assert isinstance (isna (s ), Series )
83+ assert isinstance (isna_f (s ), Series )
8284
8385 # frame
8486 for df in [tm .makeTimeDataFrame (), tm .makePeriodFrame (),
8587 tm .makeMixedDataFrame ()]:
86- result = isna (df )
87- expected = df .apply (isna )
88+ result = isna_f (df )
89+ expected = df .apply (isna_f )
8890 tm .assert_frame_equal (result , expected )
8991
9092 # panel
9193 with catch_warnings (record = True ):
9294 for p in [tm .makePanel (), tm .makePeriodPanel (),
9395 tm .add_nans (tm .makePanel ())]:
94- result = isna (p )
95- expected = p .apply (isna )
96+ result = isna_f (p )
97+ expected = p .apply (isna_f )
9698 tm .assert_panel_equal (result , expected )
9799
98100 # panel 4d
99101 with catch_warnings (record = True ):
100102 for p in [tm .makePanel4D (), tm .add_nans_panel4d (tm .makePanel4D ())]:
101- result = isna (p )
102- expected = p .apply (isna )
103+ result = isna_f (p )
104+ expected = p .apply (isna_f )
103105 tm .assert_panel4d_equal (result , expected )
104106
105107 def test_isna_lists (self ):
@@ -331,13 +333,3 @@ def test_na_value_for_dtype():
331333
332334 for dtype in ['O' ]:
333335 assert np .isnan (na_value_for_dtype (np .dtype (dtype )))
334-
335-
336- @pytest .mark .parametrize ("func" , [pd .notnull , pd .isnull ])
337- def test_deprecation_deprecations (func ):
338-
339- # top level deprecations
340- # 15001
341- with tm .assert_produces_warning (DeprecationWarning ,
342- check_stacklevel = False ):
343- func ('foo' )
0 commit comments