diff --git a/README.md b/README.md index 66907c7..b63383a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![downloads](https://pepy.tech/badge/mapply)](https://pypistats.org/packages/mapply) [![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) -[`mapply`](https://github.com/ddelange/mapply) provides sensible multi-core apply/map/applymap functions for Pandas. +[`mapply`](https://github.com/ddelange/mapply) provides sensible multi-core apply function for Pandas. ### mapply vs. pandarallel vs. swifter diff --git a/setup.py b/setup.py index 2b68076..357d4dc 100644 --- a/setup.py +++ b/setup.py @@ -12,9 +12,7 @@ def read_requirements(path): try: with open(path, mode="rt", encoding="utf-8") as fp: - return list( - filter(None, [line.split("#")[0].strip() for line in fp]) # noqa:C407 - ) + return list(filter(None, (line.split("#")[0].strip() for line in fp))) except IndexError: raise RuntimeError("{} is broken".format(path)) @@ -26,7 +24,7 @@ def read_readme(path): setup( name="mapply", - description="Sensible multi-core apply/map/applymap functions for Pandas", + description="Sensible multi-core apply function for Pandas", long_description=read_readme(readme_path), long_description_content_type="text/markdown", setup_requires=["setuptools_scm"], @@ -56,6 +54,6 @@ def read_readme(path): "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities", ], - keywords="pandas parallel apply map applymap multicore multiprocessing", + keywords="pandas parallel apply multicore multiprocessing multiprocess dill", license="MIT", ) diff --git a/src/mapply/__init__.py b/src/mapply/__init__.py index 8257f88..7aca1c2 100644 --- a/src/mapply/__init__.py +++ b/src/mapply/__init__.py @@ -31,8 +31,6 @@ def init( max_chunks_per_worker: int = DEFAULT_MAX_CHUNKS_PER_WORKER, progressbar: bool = True, apply_name: str = "mapply", - map_name: str = "mmap", - applymap_name: str = "mapplymap", ): """Patch Pandas, adding multi-core methods to PandasObject. @@ -48,19 +46,15 @@ def init( n_chunks determined by chunk_size if necessary. Set to 0 to skip this check. progressbar: Whether to wrap the chunks in a :meth:`tqdm.auto.tqdm`. apply_name: Method name for the patched apply function. - map_name: Method name for the patched map function. - applymap_name: Method name for the patched applymap function. """ from pandas.core.base import PandasObject - setattr( - PandasObject, - apply_name, - partialmethod( - _mapply, - n_workers=n_workers, - chunk_size=chunk_size, - max_chunks_per_worker=max_chunks_per_worker, - progressbar=progressbar, - ), + apply = partialmethod( + _mapply, + n_workers=n_workers, + chunk_size=chunk_size, + max_chunks_per_worker=max_chunks_per_worker, + progressbar=progressbar, ) + + setattr(PandasObject, apply_name, apply) diff --git a/src/mapply/parallel.py b/src/mapply/parallel.py index c8457fd..b92b6c5 100644 --- a/src/mapply/parallel.py +++ b/src/mapply/parallel.py @@ -20,7 +20,7 @@ def some_heavy_computation(x, power): """ import logging from functools import partial -from typing import Any, Callable, Iterable, Optional +from typing import Any, Callable, Iterable, Iterator, Optional import psutil from pathos.multiprocessing import ProcessPool @@ -65,7 +65,7 @@ def multiprocessing_imap( progressbar: bool = True, args=(), **kwargs -) -> Iterable[Any]: +) -> Iterator[Any]: """Execute func on each element in iterable on n_workers, ensuring order. Args: