Skip to content

Commit

Permalink
FIX-#6984: Ensure the results of inplace operations materialize (for …
Browse files Browse the repository at this point in the history
…tests) (#6985)

Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev authored Mar 1, 2024
1 parent cee9b98 commit 2e5aba1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
16 changes: 4 additions & 12 deletions modin/pandas/test/dataframe/test_map_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,28 +1590,20 @@ def test_transpose(data):
({"A": [1, 2, 3], "B": [400, 500, 600]}, {"B": [4, np.nan, 6]}),
],
)
@pytest.mark.parametrize(
"raise_errors", bool_arg_values, ids=arg_keys("raise_errors", bool_arg_keys)
)
def test_update(data, other_data, raise_errors):
@pytest.mark.parametrize("errors", ["raise", "ignore"])
def test_update(data, other_data, errors):
modin_df, pandas_df = create_test_dfs(data)
other_modin_df, other_pandas_df = create_test_dfs(other_data)

if raise_errors:
kwargs = {"errors": "raise"}
else:
kwargs = {}

eval_general(
modin_df,
pandas_df,
lambda df: (
df.update(other_modin_df)
df.update(other_modin_df, errors=errors)
if isinstance(df, pd.DataFrame)
else df.update(other_pandas_df)
else df.update(other_pandas_df, errors=errors)
),
__inplace__=True,
**kwargs,
)


Expand Down
8 changes: 7 additions & 1 deletion modin/pandas/test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,13 @@ def execute_callable(fn, inplace=False, md_kwargs={}, pd_kwargs={}):
if check_exception_type is None:
return None
with pytest.raises(Exception) as md_e:
try_cast_to_pandas(fn(modin_df, **md_kwargs)) # force materialization
if inplace:
_ = fn(modin_df, **md_kwargs)
try_cast_to_pandas(modin_df) # force materialization
else:
try_cast_to_pandas(
fn(modin_df, **md_kwargs)
) # force materialization
if check_exception_type:
assert isinstance(
md_e.value, type(pd_e)
Expand Down

0 comments on commit 2e5aba1

Please sign in to comment.