Skip to content

Commit

Permalink
Add docstrings
Browse files Browse the repository at this point in the history
Signed-off-by: Igoshev, Iaroslav <[email protected]>
  • Loading branch information
YarShev committed Apr 24, 2024
1 parent 1955c72 commit 139d3b5
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,25 @@ def from_map(cls, func, iterable, *args, **kwargs):
return cls.query_compiler_cls(cls.frame_cls(partitions))


def deploy_map_func(func, obj, *args, **kwargs):
def deploy_map_func(func, obj, *args, **kwargs): # pragma: no cover
"""
Deploy a func to apply to an object.
Parameters
----------
func : callable
Function to map across the iterable object.
obj : object
An object to apply a function to.
*args : tuple
Positional arguments to pass in `func`.
**kwargs : dict
Keyword arguments to pass in `func`.
Returns
-------
pandas.DataFrame
"""
result = func(obj, *args, **kwargs)
if not isinstance(result, pandas.DataFrame):
result = pandas.DataFrame(result)
Expand Down
23 changes: 15 additions & 8 deletions modin/core/execution/dispatching/factories/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,15 @@ def _from_dask(cls, dask_obj):
return cls.io_cls.from_dask(dask_obj)

@classmethod
@doc(
_doc_io_method_template,
source="a map function",
params="""
def _from_map(cls, func, iterable, *args, **kwargs):
"""
Create a Modin `query_compiler` from a map function.
This method will construct a Modin `query_compiler` split by row partitions.
The number of row partitions matches the number of elements in the iterable object.
Parameters
----------
func : callable
Function to map across the iterable object.
iterable : Iterable
Expand All @@ -234,10 +239,12 @@ def _from_dask(cls, dask_obj):
Positional arguments to pass in `func`.
**kwargs : dict
Keyword arguments to pass in `func`.
""",
method="from_map",
)
def _from_map(cls, func, iterable, *args, **kwargs):
Returns
-------
BaseQueryCompiler
QueryCompiler containing data returned by map function.
"""
return cls.io_cls.from_map(func, iterable, *args, **kwargs)

@classmethod
Expand Down
20 changes: 19 additions & 1 deletion modin/core/execution/ray/implementations/pandas_on_ray/io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,25 @@ def from_map(cls, func, iterable, *args, **kwargs):


@ray.remote
def deploy_map_func(func, obj, *args, **kwargs):
def deploy_map_func(func, obj, *args, **kwargs): # pragma: no cover
"""
Deploy a func to apply to an object.
Parameters
----------
func : callable
Function to map across the iterable object.
obj : object
An object to apply a function to.
*args : tuple
Positional arguments to pass in `func`.
**kwargs : dict
Keyword arguments to pass in `func`.
Returns
-------
pandas.DataFrame
"""
result = func(obj, *args, **kwargs)
if not isinstance(result, pandas.DataFrame):
result = pandas.DataFrame(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,25 @@ def from_map(cls, func, iterable, *args, **kwargs):


@unidist.remote
def deploy_map_func(func, obj, *args, **kwargs):
def deploy_map_func(func, obj, *args, **kwargs): # pragma: no cover
"""
Deploy a func to apply to an object.
Parameters
----------
func : callable
Function to map across the iterable object.
obj : object
An object to apply a function to.
*args : tuple
Positional arguments to pass in `func`.
**kwargs : dict
Keyword arguments to pass in `func`.
Returns
-------
pandas.DataFrame
"""
result = func(obj, *args, **kwargs)
if not isinstance(result, pandas.DataFrame):
result = pandas.DataFrame(result)
Expand Down

0 comments on commit 139d3b5

Please sign in to comment.