adding clip tests · rs2/pandas@d9627fe (original) (raw)

`@@ -1931,22 +1931,30 @@ def test_clip_against_frame(self, axis):

`

1931

1931

`tm.assert_frame_equal(clipped_df[ub_mask], ub[ub_mask])

`

1932

1932

`tm.assert_frame_equal(clipped_df[mask], df[mask])

`

1933

1933

``

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)

`

1950

1958

``

1951

1959

`# Matrix-like

`

1952

1960

``