Skip to content

Commit 716820d

Browse files
committed
WIP - many questions; few answers
1 parent 6ff1608 commit 716820d

File tree

7 files changed

+28
-6
lines changed

7 files changed

+28
-6
lines changed

modin/core/storage_formats/pandas/query_compiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,6 +2717,8 @@ def fillna(self, **kwargs):
27172717
full_axis = method is not None or limit is not None
27182718
new_dtypes = None
27192719
if isinstance(value, BaseQueryCompiler):
2720+
# This code assumes that the operation occurs with the same query compiler
2721+
assert isinstance(value, PandasQueryCompiler)
27202722
if squeeze_self:
27212723
# Self is a Series type object
27222724
if full_axis:

modin/core/storage_formats/pandas/query_compiler_caster.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def _normalize_class_name(class_of_wrapped_fn: Optional[str]) -> str:
9898
"_query_compiler",
9999
"_get_query_compiler",
100100
"_copy_into",
101+
"_update_inplace",
101102
"is_backend_pinned",
102103
"_set_backend_pinned",
103104
"pin_backend",
@@ -121,6 +122,7 @@ def _normalize_class_name(class_of_wrapped_fn: Optional[str]) -> str:
121122
"_set_backend_pinned",
122123
"pin_backend",
123124
"unpin_backend",
125+
"_update_inplace",
124126
}
125127

126128

@@ -1126,11 +1128,13 @@ def cast_to_qc(arg):
11261128
switch_operation=f"{_normalize_class_name(class_of_wrapped_fn)}.{name}",
11271129
inplace=True,
11281130
)
1131+
assert arg.get_backend() == result_backend
11291132
cast = arg
11301133
else:
11311134
cast = arg.set_backend(
11321135
result_backend,
11331136
switch_operation=f"{_normalize_class_name(class_of_wrapped_fn)}.{name}",
1137+
inplace=False,
11341138
)
11351139
inplace_update_trackers.append(
11361140
InplaceUpdateTracker(

modin/pandas/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4585,9 +4585,12 @@ def set_backend(
45854585
# Last call to next informs tqdm that the operation is done
45864586
pass
45874587
if inplace:
4588+
assert query_compiler.get_backend() == backend
45884589
self._update_inplace(query_compiler)
45894590
# Always unpin after an explicit set_backend operation
45904591
self._pinned = False
4592+
assert self._query_compiler.get_backend() == backend
4593+
assert self.get_backend() == backend
45914594
return None
45924595
else:
45934596
return self.__constructor__(query_compiler=query_compiler)

modin/pandas/series.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,6 +2672,8 @@ def _update_inplace(self, new_query_compiler) -> None:
26722672
self._parent.loc[self.name] = self
26732673
else:
26742674
self._parent[self.name] = self
2675+
super(Series, self)._update_inplace(new_query_compiler=new_query_compiler)
2676+
assert self.get_backend() == new_query_compiler.get_backend()
26752677

26762678
def _create_or_update_from_compiler(
26772679
self, new_query_compiler, inplace=False

modin/tests/pandas/native_df_interoperability/test_binary.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def test_math_functions(other, axis, op, backend, df_mode_pair):
8686
backend,
8787
lambda df1, df2: getattr(df1, op)(other(df2, axis), axis=axis),
8888
df_mode_pair,
89+
pin_backend = True,
8990
)
9091

9192

modin/tests/pandas/native_df_interoperability/test_indexing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def _test_loc_rows(df1, df2):
182182
_test_loc_rows,
183183
expected_exception=expected_exception,
184184
df_mode_pair=df_mode_pair,
185+
pin_backend=True,
185186
)
186187

187188

modin/tests/pandas/native_df_interoperability/utils.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,35 @@ def switch_to_native_execution():
3737

3838

3939
def create_test_df_in_defined_mode(
40-
*args, post_fn=None, backend=None, native=None, **kwargs
40+
*args, post_fn=None, backend=None, native=None, pin_backend=False, **kwargs
4141
):
4242
assert not current_execution_is_native(), "already in native dataframe mode."
4343

4444
if not isinstance(native, bool):
4545
raise ValueError("`native` should be True or False.")
4646

4747
with switch_to_native_execution() if native else nullcontext():
48-
return create_test_dfs(*args, post_fn=post_fn, backend=backend, **kwargs)
48+
modin_df, pandas_df = create_test_dfs(*args, post_fn=post_fn, backend=backend, **kwargs)
49+
# pin the backend for interop tests explicitly
50+
if native and pin_backend:
51+
modin_df = modin_df.move_to("Pandas").pin_backend()
52+
return modin_df, pandas_df
4953

5054

5155
def create_test_series_in_defined_mode(
52-
vals, sort=False, backend=None, native=None, **kwargs
56+
vals, sort=False, backend=None, native=None, pin_backend=False, **kwargs
5357
):
5458
assert not current_execution_is_native(), "already in native dataframe mode."
5559

5660
if not isinstance(native, bool):
5761
raise ValueError("`native` should be True or False.")
5862

5963
with switch_to_native_execution() if native else nullcontext():
60-
return create_test_series(vals, sort=sort, backend=backend, **kwargs)
64+
modin_ser, pandas_ser = create_test_series(vals, sort=sort, backend=backend, **kwargs)
65+
# pin the backend for interop tests explicitly
66+
if native and pin_backend:
67+
modin_ser = modin_ser.move_to("Pandas").pin_backend()
68+
return modin_ser, pandas_ser
6169

6270

6371
def eval_general_interop(
@@ -71,14 +79,15 @@ def eval_general_interop(
7179
check_kwargs_callable=True,
7280
md_extra_kwargs=None,
7381
comparator_kwargs=None,
82+
pin_backend=False,
7483
**kwargs,
7584
):
7685
df1_native, df2_native = df_mode_pair
7786
modin_df1, pandas_df1 = create_test_df_in_defined_mode(
78-
data, backend=backend, native=df1_native
87+
data, backend=backend, native=df1_native, pin_backend=pin_backend
7988
)
8089
modin_df2, pandas_df2 = create_test_df_in_defined_mode(
81-
data, backend=backend, native=df2_native
90+
data, backend=backend, native=df2_native, pin_backend=pin_backend
8291
)
8392
md_kwargs, pd_kwargs = {}, {}
8493

0 commit comments

Comments
 (0)