Skip to content

Commit

Permalink
⚰️ Remove unimplemented references to map and applymap (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange authored Apr 7, 2022
1 parent c879199 commit e9cc17d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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"],
Expand Down Expand Up @@ -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",
)
22 changes: 8 additions & 14 deletions src/mapply/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
4 changes: 2 additions & 2 deletions src/mapply/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e9cc17d

Please sign in to comment.