Skip to content

Commit

Permalink
Apply @vnlitvinov's suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
  • Loading branch information
dchigarev committed Jul 14, 2023
1 parent d65387e commit 3f3cc5b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
8 changes: 3 additions & 5 deletions modin/core/dataframe/algebra/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,12 @@ def apply(
"""
operator = cls.register(func, **kwargs)

func_args = tuple() if func_args is None else func_args
func_kwargs = dict() if func_kwargs is None else func_kwargs
qc_result = operator(
left._query_compiler,
right._query_compiler,
broadcast=right.ndim == 1,
*func_args,
*(func_args or ()),
axis=axis,
**func_kwargs,
**(func_kwargs or {}),
)
return type(left)(query_compiler=qc_result)
return left.__constructor__(query_compiler=qc_result)
7 changes: 2 additions & 5 deletions modin/core/dataframe/algebra/fold.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,5 @@ def apply(cls, df, func, fold_axis=0, func_args=None, func_kwargs=None):
-------
the same type as `df`
"""
func_args = tuple() if func_args is None else func_args
func_kwargs = dict() if func_kwargs is None else func_kwargs
func_args = (fold_axis,) + func_args

return super().apply(df, func, func_args, func_kwargs)
func_args = (fold_axis,) + (func_args or ())
return super().apply(df, func, func_args, func_kwargs or {})
12 changes: 4 additions & 8 deletions modin/core/dataframe/algebra/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,19 +772,15 @@ def apply(
-------
The same type as `df`.
"""
agg_args = tuple() if agg_args is None else agg_args
agg_kwargs = dict() if agg_kwargs is None else agg_kwargs
groupby_kwargs = dict() if groupby_kwargs is None else groupby_kwargs

operator = cls.register(map_func, reduce_func)
qc_result = operator(
df._query_compiler,
df[by]._query_compiler,
axis=0,
groupby_kwargs=groupby_kwargs,
agg_args=agg_args,
agg_kwargs=agg_kwargs,
groupby_kwargs=groupby_kwargs or {},
agg_args=agg_args or (),
agg_kwargs=agg_kwargs or {},
drop=True,
)

return type(df)(query_compiler=qc_result)
return df.__constructor__(query_compiler=qc_result)
10 changes: 4 additions & 6 deletions modin/core/dataframe/algebra/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ def apply(cls, df, func, func_args=None, func_kwargs=None, **kwargs):
return_type
"""
operator = cls.register(func, **kwargs)

func_args = tuple() if func_args is None else func_args
func_kwargs = dict() if func_kwargs is None else func_kwargs

qc_result = operator(df._query_compiler, *func_args, **func_kwargs)
return type(df)(query_compiler=qc_result)
qc_result = operator(
df._query_compiler, *(func_args or ()), **(func_kwargs or {})
)
return df.__constructor__(query_compiler=qc_result)

0 comments on commit 3f3cc5b

Please sign in to comment.