Skip to content

Commit d9627fe

Browse files
committed
adding clip tests
1 parent 9aa0159 commit d9627fe

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

pandas/tests/frame/test_analytics.py

+24-16
Original file line numberDiff line numberDiff line change
@@ -1931,22 +1931,30 @@ def test_clip_against_frame(self, axis):
19311931
tm.assert_frame_equal(clipped_df[ub_mask], ub[ub_mask])
19321932
tm.assert_frame_equal(clipped_df[mask], df[mask])
19331933

1934-
def test_clip_na(self):
1935-
msg = "Cannot use an NA"
1936-
with tm.assert_raises_regex(ValueError, msg):
1937-
self.frame.clip(lower=np.nan)
1938-
1939-
with tm.assert_raises_regex(ValueError, msg):
1940-
self.frame.clip(lower=[np.nan])
1941-
1942-
with tm.assert_raises_regex(ValueError, msg):
1943-
self.frame.clip(upper=np.nan)
1944-
1945-
with tm.assert_raises_regex(ValueError, msg):
1946-
self.frame.clip(upper=[np.nan])
1947-
1948-
with tm.assert_raises_regex(ValueError, msg):
1949-
self.frame.clip(lower=np.nan, upper=np.nan)
1934+
# def test_clip_na(self):
1935+
# msg = "Cannot use an NA"
1936+
# with tm.assert_raises_regex(ValueError, msg):
1937+
# self.frame.clip(lower=np.nan)
1938+
1939+
# with tm.assert_raises_regex(ValueError, msg):
1940+
# self.frame.clip(lower=[np.nan])
1941+
1942+
# with tm.assert_raises_regex(ValueError, msg):
1943+
# self.frame.clip(upper=np.nan)
1944+
1945+
# with tm.assert_raises_regex(ValueError, msg):
1946+
# self.frame.clip(upper=[np.nan])
1947+
1948+
# with tm.assert_raises_regex(ValueError, msg):
1949+
# self.frame.clip(lower=np.nan, upper=np.nan)
1950+
1951+
def test_clip_with_na_args(self):
1952+
"""Should process np.nan argument as None """
1953+
# GH # 17276
1954+
self.frame.clip(np.nan)
1955+
self.frame.clip(upper=[1,2,np.nan])
1956+
self.frame.clip(lower=[1,np.nan,3])
1957+
self.frame.clip(upper=np.nan, lower=np.nan)
19501958

19511959
# Matrix-like
19521960

pandas/tests/series/test_analytics.py

+9
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,15 @@ def test_clip_types_and_nulls(self):
10001000
assert list(isna(s)) == list(isna(l))
10011001
assert list(isna(s)) == list(isna(u))
10021002

1003+
def test_clip_with_na_args(self):
1004+
"""Should process np.nan argument as None """
1005+
# GH # 17276
1006+
s = Series([1,2,3])
1007+
s.clip(np.nan)
1008+
s.clip(upper=[1,2,np.nan])
1009+
s.clip(lower=[1,np.nan,3])
1010+
s.clip(upper=np.nan, lower=np.nan)
1011+
10031012
def test_clip_against_series(self):
10041013
# GH #6966
10051014

0 commit comments

Comments
 (0)