15
15
from pandas .core .dtypes .common import is_scalar
16
16
from pandas .core .dtypes .dtypes import DatetimeTZDtype
17
17
from pandas .core .dtypes .missing import (
18
- array_equivalent , isna , notna ,
18
+ array_equivalent , isna , notna , isnull , notnull ,
19
19
na_value_for_dtype )
20
20
21
21
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 )
26
27
27
28
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 )
30
31
31
32
arr = np .array ([1.5 , np .inf , 3.5 , - np .inf ])
32
- result = notna (arr )
33
+ result = notna_f (arr )
33
34
assert result .all ()
34
35
35
36
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 )
38
39
39
40
arr = np .array ([1.5 , np .inf , 3.5 , - np .inf ])
40
- result = notna (arr )
41
+ result = notna_f (arr )
41
42
assert result .sum () == 2
42
43
43
44
with cf .option_context ("mode.use_inf_as_na" , False ):
44
45
for s in [tm .makeFloatSeries (), tm .makeStringSeries (),
45
46
tm .makeObjectSeries (), tm .makeTimeSeries (),
46
47
tm .makePeriodSeries ()]:
47
- assert (isinstance (isna (s ), Series ))
48
+ assert (isinstance (notna_f (s ), Series ))
48
49
49
50
50
51
class TestIsNA (object ):
@@ -66,40 +67,41 @@ def test_empty_object(self):
66
67
expected = np .ones (shape = shape , dtype = bool )
67
68
tm .assert_numpy_array_equal (result , expected )
68
69
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 )
73
75
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 )
76
78
77
79
# series
78
80
for s in [tm .makeFloatSeries (), tm .makeStringSeries (),
79
81
tm .makeObjectSeries (), tm .makeTimeSeries (),
80
82
tm .makePeriodSeries ()]:
81
- assert isinstance (isna (s ), Series )
83
+ assert isinstance (isna_f (s ), Series )
82
84
83
85
# frame
84
86
for df in [tm .makeTimeDataFrame (), tm .makePeriodFrame (),
85
87
tm .makeMixedDataFrame ()]:
86
- result = isna (df )
87
- expected = df .apply (isna )
88
+ result = isna_f (df )
89
+ expected = df .apply (isna_f )
88
90
tm .assert_frame_equal (result , expected )
89
91
90
92
# panel
91
93
with catch_warnings (record = True ):
92
94
for p in [tm .makePanel (), tm .makePeriodPanel (),
93
95
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 )
96
98
tm .assert_panel_equal (result , expected )
97
99
98
100
# panel 4d
99
101
with catch_warnings (record = True ):
100
102
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 )
103
105
tm .assert_panel4d_equal (result , expected )
104
106
105
107
def test_isna_lists (self ):
@@ -331,13 +333,3 @@ def test_na_value_for_dtype():
331
333
332
334
for dtype in ['O' ]:
333
335
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