Skip to content

Commit

Permalink
more refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
christinafan committed Jul 13, 2023
1 parent c06e2d9 commit a5df69e
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions modin/core/storage_formats/pandas/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ def expanding_corr(

old_window_mean = Fold.register(
lambda df, rolling_kwargs, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).mean(*args, **kwargs)
df.rolling(**rolling_kwargs).mean(*args, **kwargs)
)
)

Expand All @@ -1425,15 +1425,15 @@ def window_mean(self, axis, window_kwargs, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*window_kwargs).mean(*args, **kwargs),
lambda df: df.rolling(**window_kwargs).mean(*args, **kwargs),
)
)
else:
return self.old_window_mean(axis, window_kwargs, *args, **kwargs)

old_window_sum = Fold.register(
lambda df, rolling_kwargs, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).sum(*args, **kwargs)
df.rolling(**rolling_kwargs).sum(*args, **kwargs)
)
)

Expand All @@ -1446,15 +1446,15 @@ def window_sum(self, axis, window_kwargs, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*window_kwargs).sum(*args, **kwargs),
lambda df: df.rolling(**window_kwargs).sum(*args, **kwargs),
)
)
else:
return self.old_window_sum(axis, window_kwargs, *args, **kwargs)

old_window_var = Fold.register(
lambda df, rolling_kwargs, ddof, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).var(ddof=ddof, *args, **kwargs)
df.rolling(**rolling_kwargs).var(ddof=ddof, *args, **kwargs)
)
)

Expand All @@ -1467,15 +1467,15 @@ def window_var(self, axis, window_kwargs, ddof, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*window_kwargs).var(ddof, *args, **kwargs),
lambda df: df.rolling(**window_kwargs).var(ddof, *args, **kwargs),
)
)
else:
return self.old_window_var(axis, window_kwargs, ddof, *args, **kwargs)

old_window_std = Fold.register(
lambda df, rolling_kwargs, ddof, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).std(ddof=ddof, *args, **kwargs)
df.rolling(**rolling_kwargs).std(ddof=ddof, *args, **kwargs)
)
)

Expand All @@ -1488,14 +1488,14 @@ def window_std(self, axis, window_kwargs, ddof, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*window_kwargs).std(ddof=ddof, *args, **kwargs),
lambda df: df.rolling(**window_kwargs).std(ddof=ddof, *args, **kwargs),
)
)
else:
return self.old_window_std(axis, window_kwargs, ddof, *args, **kwargs)

old_rolling_count = Fold.register(
lambda df, rolling_kwargs: pandas.DataFrame(df.rolling(*rolling_kwargs).count())
lambda df, rolling_kwargs: pandas.DataFrame(df.rolling(**rolling_kwargs).count())
)

def rolling_count(self, axis, rolling_kwargs):
Expand All @@ -1505,15 +1505,15 @@ def rolling_count(self, axis, rolling_kwargs):
if _can_use_cell_wise_window(center, window, win_type):
return self.__constructor__(
self._modin_frame.window(
axis, window, lambda df: df.rolling(*rolling_kwargs).count()
axis, window, lambda df: df.rolling(**rolling_kwargs).count()
)
)
else:
return self.old_rolling_count(axis, rolling_kwargs)

old_rolling_sum = Fold.register(
lambda df, rolling_kwargs, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).sum(*args, **kwargs)
df.rolling(**rolling_kwargs).sum(*args, **kwargs)
)
)

Expand All @@ -1526,15 +1526,15 @@ def rolling_sum(self, axis, rolling_kwargs, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).sum(*args, **kwargs),
lambda df: df.rolling(**rolling_kwargs).sum(*args, **kwargs),
)
)
else:
return self.old_rolling_sum(axis, rolling_kwargs, *args, **kwargs)

old_rolling_sem = Fold.register(
lambda df, rolling_kwargs, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).sem(*args, **kwargs)
df.rolling(**rolling_kwargs).sem(*args, **kwargs)
)
)

Expand All @@ -1547,15 +1547,15 @@ def rolling_sem(self, axis, rolling_kwargs, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).sem(*args, **kwargs),
lambda df: df.rolling(**rolling_kwargs).sem(*args, **kwargs),
)
)
else:
return self.old_rolling_sem(axis, rolling_kwargs, *args, **kwargs)

old_rolling_mean = Fold.register(
lambda df, rolling_kwargs, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).mean(*args, **kwargs)
df.rolling(**rolling_kwargs).mean(*args, **kwargs)
)
)

Expand All @@ -1568,15 +1568,15 @@ def rolling_mean(self, axis, rolling_kwargs, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).mean(*args, **kwargs),
lambda df: df.rolling(**rolling_kwargs).mean(*args, **kwargs),
)
)
else:
return self.old_rolling_mean(axis, rolling_kwargs, *args, **kwargs)

old_rolling_median = Fold.register(
lambda df, rolling_kwargs, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).median(**kwargs)
df.rolling(**rolling_kwargs).median(**kwargs)
)
)

Expand All @@ -1587,15 +1587,15 @@ def rolling_median(self, axis, rolling_kwargs, **kwargs):
if _can_use_cell_wise_window(center, window, win_type):
return self.__constructor__(
self._modin_frame.window(
axis, window, lambda df: df.rolling(*rolling_kwargs).median(**kwargs)
axis, window, lambda df: df.rolling(**rolling_kwargs).median(**kwargs)
)
)
else:
return self.old_rolling_median(axis, rolling_kwargs, **kwargs)

old_rolling_var = Fold.register(
lambda df, rolling_kwargs, ddof, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).var(ddof=ddof, *args, **kwargs)
df.rolling(**rolling_kwargs).var(ddof=ddof, *args, **kwargs)
)
)

Expand All @@ -1608,7 +1608,7 @@ def rolling_var(self, axis, rolling_kwargs, ddof, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).var(
lambda df: df.rolling(**rolling_kwargs).var(
ddof=ddof, *args, **kwargs
),
)
Expand All @@ -1618,7 +1618,7 @@ def rolling_var(self, axis, rolling_kwargs, ddof, *args, **kwargs):

old_rolling_std = Fold.register(
lambda df, rolling_kwargs, ddof, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).std(ddof=ddof, *args, **kwargs)
df.rolling(**rolling_kwargs).std(ddof=ddof, *args, **kwargs)
)
)

Expand All @@ -1631,7 +1631,7 @@ def rolling_std(self, axis, rolling_kwargs, ddof, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).std(
lambda df: df.rolling(**rolling_kwargs).std(
ddof=ddof, *args, **kwargs
),
)
Expand All @@ -1641,7 +1641,7 @@ def rolling_std(self, axis, rolling_kwargs, ddof, *args, **kwargs):

old_rolling_min = Fold.register(
lambda df, rolling_kwargs, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).min(*args, **kwargs)
df.rolling(**rolling_kwargs).min(*args, **kwargs)
)
)

Expand All @@ -1654,15 +1654,15 @@ def rolling_min(self, axis, rolling_kwargs, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).min(*args, **kwargs),
lambda df: df.rolling(**rolling_kwargs).min(*args, **kwargs),
)
)
else:
return self.old_rolling_min(axis, rolling_kwargs, *args, **kwargs)

old_rolling_max = Fold.register(
lambda df, rolling_kwargs, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).max(*args, **kwargs)
df.rolling(**rolling_kwargs).max(*args, **kwargs)
)
)

Expand All @@ -1675,15 +1675,15 @@ def rolling_max(self, axis, rolling_kwargs, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).max(*args, **kwargs),
lambda df: df.rolling(**rolling_kwargs).max(*args, **kwargs),
)
)
else:
return self.old_rolling_max(axis, rolling_kwargs, *args, **kwargs)

old_rolling_skew = Fold.register(
lambda df, rolling_kwargs, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).skew(**kwargs)
df.rolling(**rolling_kwargs).skew(**kwargs)
)
)

Expand All @@ -1694,15 +1694,15 @@ def rolling_skew(self, axis, rolling_kwargs, **kwargs):
if _can_use_cell_wise_window(center, window, win_type):
return self.__constructor__(
self._modin_frame.window(
axis, window, lambda df: df.rolling(*rolling_kwargs).skew(**kwargs)
axis, window, lambda df: df.rolling(**rolling_kwargs).skew(**kwargs)
)
)
else:
return self.old_rolling_skew(axis, rolling_kwargs, **kwargs)

old_rolling_kurt = Fold.register(
lambda df, rolling_kwargs, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).kurt(**kwargs)
df.rolling(**rolling_kwargs).kurt(**kwargs)
)
)

Expand All @@ -1713,15 +1713,15 @@ def rolling_kurt(self, axis, rolling_kwargs, **kwargs):
if _can_use_cell_wise_window(center, window, win_type):
return self.__constructor__(
self._modin_frame.window(
axis, window, lambda df: df.rolling(*rolling_kwargs).kurt(**kwargs)
axis, window, lambda df: df.rolling(**rolling_kwargs).kurt(**kwargs)
)
)
else:
return self.old_rolling_kurt(axis, rolling_kwargs, **kwargs)

old_rolling_apply = Fold.register(
lambda df, rolling_kwargs, func, raw, engine, engine_kwargs, args, kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).apply(
df.rolling(**rolling_kwargs).apply(
func=func,
raw=raw,
engine=engine,
Expand All @@ -1743,7 +1743,7 @@ def rolling_apply(
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).apply(
lambda df: df.rolling(**rolling_kwargs).apply(
func=func,
raw=raw,
engine=engine,
Expand All @@ -1767,7 +1767,7 @@ def rolling_apply(

old_rolling_rank = Fold.register(
lambda df, rolling_kwargs, method, ascending, pct, numeric_only, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).rank(
df.rolling(**rolling_kwargs).rank(
method=method,
ascending=ascending,
pct=pct,
Expand All @@ -1788,7 +1788,7 @@ def rolling_rank(
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).rank(
lambda df: df.rolling(**rolling_kwargs).rank(
method=method,
ascending=ascending,
pct=pct,
Expand All @@ -1804,7 +1804,7 @@ def rolling_rank(

old_rolling_quantile = Fold.register(
lambda df, rolling_kwargs, quantile, interpolation, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).quantile(
df.rolling(**rolling_kwargs).quantile(
quantile=quantile, interpolation=interpolation, **kwargs
)
)
Expand All @@ -1819,7 +1819,7 @@ def rolling_quantile(self, axis, rolling_kwargs, quantile, interpolation, **kwar
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).quantile(
lambda df: df.rolling(**rolling_kwargs).quantile(
quantile=quantile, interpolation=interpolation, **kwargs
),
)
Expand All @@ -1831,7 +1831,7 @@ def rolling_quantile(self, axis, rolling_kwargs, quantile, interpolation, **kwar

old_rolling_corr = Fold.register(
lambda df, rolling_kwargs, other, pairwise, *args, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).corr(
df.rolling(**rolling_kwargs).corr(
other=other, pairwise=pairwise, *args, **kwargs
)
)
Expand All @@ -1853,7 +1853,7 @@ def rolling_corr(self, axis, rolling_kwargs, other, pairwise, *args, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).corr(
lambda df: df.rolling(**rolling_kwargs).corr(
other=other, pairwise=pairwise, *args, **kwargs
),
)
Expand All @@ -1865,7 +1865,7 @@ def rolling_corr(self, axis, rolling_kwargs, other, pairwise, *args, **kwargs):

old_rolling_cov = Fold.register(
lambda df, rolling_kwargs, other, pairwise, ddof, **kwargs: pandas.DataFrame(
df.rolling(*rolling_kwargs).cov(
df.rolling(**rolling_kwargs).cov(
other=other, pairwise=pairwise, ddof=ddof, **kwargs
)
)
Expand All @@ -1891,7 +1891,7 @@ def rolling_cov(self, axis, rolling_kwargs, other, pairwise, ddof, **kwargs):
self._modin_frame.window(
axis,
window,
lambda df: df.rolling(*rolling_kwargs).cov(
lambda df: df.rolling(**rolling_kwargs).cov(
other=other, pairwise=pairwise, **kwargs
),
)
Expand All @@ -1907,7 +1907,7 @@ def rolling_aggregate(self, axis, rolling_kwargs, func, *args, **kwargs):
new_modin_frame = self._modin_frame.apply_full_axis(
axis,
lambda df: pandas.DataFrame(
df.rolling(*rolling_kwargs).aggregate(func=func, *args, **kwargs)
df.rolling(**rolling_kwargs).aggregate(func=func, *args, **kwargs)
),
new_index=self.index,
)
Expand Down

0 comments on commit a5df69e

Please sign in to comment.