Skip to content

Commit

Permalink
creating function for create_test_df_in_defined_mode
Browse files Browse the repository at this point in the history
Signed-off-by: arunjose696 <arunjose696@gmail.com>
  • Loading branch information
arunjose696 committed Sep 2, 2024
1 parent c1b0942 commit 58dbd30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
4 changes: 2 additions & 2 deletions modin/tests/pandas/native_df_mode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def create_test_df_in_defined_mode(
):
with context(NativeDataframeMode=df_mode):
return create_test_dfs(
*args, post_fn=None, backend=None, df_mode=None, **kwargs
*args, post_fn=post_fn, backend=backend, **kwargs
)


def create_test_series_in_defined_mode(
vals, sort=False, backend=None, df_mode=None, **kwargs
):
with context(NativeDataframeMode=df_mode):
return create_test_series(vals, sort=False, backend=None, **kwargs)
return create_test_series(vals, sort=sort, backend=backend, **kwargs)


def eval_general_interop(
Expand Down
23 changes: 3 additions & 20 deletions modin/tests/pandas/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
Engine,
MinColumnPartitionSize,
MinRowPartitionSize,
NativeDataframeMode,
NPartitions,
RangePartitioning,
TestDatasetSize,
Expand Down Expand Up @@ -1088,11 +1087,7 @@ def eval_io_from_str(csv_str: str, unique_filename: str, **kwargs):


def create_test_dfs(
*args,
post_fn=None,
backend=None,
df_mode=None,
**kwargs,
*args, post_fn=None, backend=None, **kwargs
) -> tuple[pd.DataFrame, pandas.DataFrame]:
if post_fn is None:
post_fn = lambda df: ( # noqa: E731
Expand All @@ -1102,24 +1097,14 @@ def create_test_dfs(
post_fn = lambda df: post_fn(df).convert_dtypes( # noqa: E731
dtype_backend=backend
)
if df_mode:
actual_df_mode = NativeDataframeMode().get()
NativeDataframeMode().put(df_mode)
test_dfs = tuple(
return tuple(
map(post_fn, [pd.DataFrame(*args, **kwargs), pandas.DataFrame(*args, **kwargs)])
)
if df_mode:
NativeDataframeMode().put(actual_df_mode)

return test_dfs


def create_test_series(
vals, sort=False, backend=None, df_mode=None, **kwargs
vals, sort=False, backend=None, **kwargs
) -> tuple[pd.Series, pandas.Series]:
if df_mode:
actual_df_mode = NativeDataframeMode().get()
NativeDataframeMode().put(df_mode)
if isinstance(vals, dict):
modin_series = pd.Series(vals[next(iter(vals.keys()))], **kwargs)
pandas_series = pandas.Series(vals[next(iter(vals.keys()))], **kwargs)
Expand All @@ -1133,8 +1118,6 @@ def create_test_series(
if backend is not None:
modin_series = modin_series.convert_dtypes(dtype_backend=backend)
pandas_series = pandas_series.convert_dtypes(dtype_backend=backend)
if df_mode:
NativeDataframeMode().put(actual_df_mode)
return modin_series, pandas_series


Expand Down

0 comments on commit 58dbd30

Please sign in to comment.