| 4803 | @pytest.mark.parametrize("sorted_index", [False, True]) |
| 4804 | @pytest.mark.parametrize("sorted_map_index", [False, True]) |
| 4805 | def test_series_map(base_npart, map_npart, sorted_index, sorted_map_index): |
| 4806 | if map_npart != base_npart: |
| 4807 | pytest.xfail(reason="not yet implemented") |
| 4808 | base = pd.Series( |
| 4809 | ["".join(np.random.choice(["a", "b", "c"], size=3)) for x in range(100)] |
| 4810 | ) |
| 4811 | if not sorted_index: |
| 4812 | index = np.arange(100) |
| 4813 | np.random.shuffle(index) |
| 4814 | base.index = index |
| 4815 | map_index = ["".join(x) for x in product("abc", repeat=3)] |
| 4816 | mapper = pd.Series(np.random.randint(50, size=len(map_index)), index=map_index) |
| 4817 | if not sorted_map_index: |
| 4818 | map_index = np.array(map_index) |
| 4819 | np.random.shuffle(map_index) |
| 4820 | mapper.index = map_index |
| 4821 | expected = base.map(mapper) |
| 4822 | dask_base = dd.from_pandas(base, npartitions=base_npart, sort=False) |
| 4823 | dask_map = dd.from_pandas(mapper, npartitions=map_npart, sort=False) |
| 4824 | with pytest.warns(UserWarning, match="meta"): |
| 4825 | result = dask_base.map(dask_map) |
| 4826 | assert_eq(expected, result) |
| 4827 | |
| 4828 | |
| 4829 | @pytest.mark.skip_with_pyarrow_strings # has to be array to explode |