| 1760 | |
| 1761 | @pytest.mark.parametrize("join", ["inner", "outer", "left", "right"]) |
| 1762 | def test_align_axis(join): |
| 1763 | df1a = pd.DataFrame( |
| 1764 | {"A": np.random.randn(10), "B": np.random.randn(10), "C": np.random.randn(10)}, |
| 1765 | index=[1, 12, 5, 6, 3, 9, 10, 4, 13, 11], |
| 1766 | ) |
| 1767 | |
| 1768 | df1b = pd.DataFrame( |
| 1769 | {"B": np.random.randn(10), "C": np.random.randn(10), "D": np.random.randn(10)}, |
| 1770 | index=[0, 3, 2, 10, 5, 6, 7, 8, 12, 13], |
| 1771 | ) |
| 1772 | ddf1a = dd.from_pandas(df1a, 3) |
| 1773 | ddf1b = dd.from_pandas(df1b, 3) |
| 1774 | |
| 1775 | res1, res2 = ddf1a.align(ddf1b, join=join, axis=0) |
| 1776 | exp1, exp2 = df1a.align(df1b, join=join, axis=0) |
| 1777 | assert assert_eq(res1, exp1) |
| 1778 | assert assert_eq(res2, exp2) |
| 1779 | |
| 1780 | res1, res2 = ddf1a.align(ddf1b, join=join, axis=1) |
| 1781 | exp1, exp2 = df1a.align(df1b, join=join, axis=1) |
| 1782 | assert assert_eq(res1, exp1) |
| 1783 | assert assert_eq(res2, exp2) |
| 1784 | |
| 1785 | res1, res2 = ddf1a.align(ddf1b, join=join, axis="index") |
| 1786 | exp1, exp2 = df1a.align(df1b, join=join, axis="index") |
| 1787 | assert assert_eq(res1, exp1) |
| 1788 | assert assert_eq(res2, exp2) |
| 1789 | |
| 1790 | res1, res2 = ddf1a.align(ddf1b, join=join, axis="columns") |
| 1791 | exp1, exp2 = df1a.align(df1b, join=join, axis="columns") |
| 1792 | assert assert_eq(res1, exp1) |
| 1793 | assert assert_eq(res2, exp2) |
| 1794 | |
| 1795 | # invalid |
| 1796 | with pytest.raises(ValueError): |
| 1797 | ddf1a.align(ddf1b, join=join, axis="XXX") |
| 1798 | |
| 1799 | with pytest.raises(ValueError): |
| 1800 | ddf1a["A"].align(ddf1b["B"], join=join, axis=1) |
| 1801 | |
| 1802 | |
| 1803 | def test_combine(): |