| 741 | |
| 742 | |
| 743 | def test_clip_axis_0(): |
| 744 | df = pd.DataFrame( |
| 745 | { |
| 746 | "a": [1, 2, 3, 4, 5, 6, 7, 8, 9], |
| 747 | "b": [3, 5, 2, 5, 7, 2, 4, 2, 4], |
| 748 | } |
| 749 | ) |
| 750 | s = pd.Series([1, 2, 3, 4, 5, 6, 7, 8, 9]) |
| 751 | l = pd.Series([3] * len(df)) |
| 752 | u = pd.Series([7] * len(df)) |
| 753 | |
| 754 | ddf = dd.from_pandas(df, 3) |
| 755 | ds = dd.from_pandas(s, 3) |
| 756 | dl = dd.from_pandas(l, 3) |
| 757 | du = dd.from_pandas(u, 3) |
| 758 | |
| 759 | assert_eq(ddf.clip(lower=dl, upper=du, axis=0), df.clip(lower=l, upper=u, axis=0)) |
| 760 | assert_eq(ddf.clip(lower=dl, axis=0), df.clip(lower=l, axis=0)) |
| 761 | assert_eq(ddf.clip(upper=du, axis=0), df.clip(upper=u, axis=0)) |
| 762 | |
| 763 | assert_eq(ds.clip(lower=dl, upper=du, axis=0), s.clip(lower=l, upper=u, axis=0)) |
| 764 | assert_eq(ds.clip(lower=dl, axis=0), s.clip(lower=l, axis=0)) |
| 765 | assert_eq(ds.clip(upper=du, axis=0), s.clip(upper=u, axis=0)) |
| 766 | |
| 767 | |
| 768 | def test_clip_axis_1(): |