Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <[email protected]>
  • Loading branch information
anmyachev committed May 12, 2024
1 parent ae861e3 commit 32baa1d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 21 deletions.
1 change: 0 additions & 1 deletion modin/core/storage_formats/pandas/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3088,7 +3088,6 @@ def mapper(df: pandas.DataFrame):
)
# we have to keep other columns so setting their mask
# values with `False`
# TODO: pyarrow backend?
mask = pandas.Series(
np.zeros(df.shape[1], dtype=bool), index=df.columns
)
Expand Down
4 changes: 2 additions & 2 deletions modin/distributed/dataframe/pandas/partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def unwrap_partitions(
f"Only API Layer objects may be passed in here, got {type(api_layer_object)} instead."
)

modin_frame = api_layer_object._query_compiler._modin_frame
modin_frame = api_layer_object._query_compiler._modin_frame # type: ignore[attr-defined]
modin_frame._propagate_index_objs(None)
if axis is None:

Expand Down Expand Up @@ -122,7 +122,7 @@ def get_block(partition: PartitionUnionType) -> np.ndarray:
]

actual_engine = type(
api_layer_object._query_compiler._modin_frame._partitions[0][0]
api_layer_object._query_compiler._modin_frame._partitions[0][0] # type: ignore[attr-defined]
).__name__
if actual_engine in (
"PandasOnRayDataframePartition",
Expand Down
17 changes: 4 additions & 13 deletions modin/logging/logger_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from functools import wraps
from types import FunctionType, MethodType
from typing import Any, Callable, Dict, Optional, Tuple, Type, TypeVar, Union, overload
from typing import Any, Callable, Dict, Optional, Tuple, Type, Union

from modin.config import LogMode

Expand All @@ -28,9 +28,6 @@
_MODIN_LOGGER_NOWRAP = "__modin_logging_nowrap__"


Fn = TypeVar("Fn", bound=Callable)


def disable_logging(func: Callable) -> Callable:
"""
Disable logging of one particular function. Useful for decorated classes.
Expand All @@ -49,17 +46,11 @@ def disable_logging(func: Callable) -> Callable:
return func


@overload
def enable_logging(modin_layer: Fn) -> Fn:
# This helps preserve typings when the decorator is used without parentheses
...


def enable_logging(
modin_layer: Union[str, Fn, Type] = "PANDAS-API",
modin_layer: Union[str, Callable, Type] = "PANDAS-API",
name: Optional[str] = None,
log_level: LogLevel = LogLevel.INFO,
) -> Callable[[Fn], Fn]:
) -> Callable:
"""
Log Decorator used on specific Modin functions or classes.
Expand All @@ -85,7 +76,7 @@ def enable_logging(
# def func()
return enable_logging()(modin_layer)

def decorator(obj: Fn) -> Fn:
def decorator(obj: Any) -> Any:
"""Decorate function or class to add logs to Modin API function(s)."""
if isinstance(obj, type):
seen: Dict[Any, Any] = {}
Expand Down
4 changes: 2 additions & 2 deletions modin/numpy/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def boolean_mask_to_numeric(indexer):
# `itertools.compress` masks `data` with the `selectors` mask,
# works about ~10% faster than a pure list comprehension
itertools.compress(data=range(len(indexer)), selectors=indexer),
dtype="int64",
dtype=np.int64,
)


Expand Down Expand Up @@ -585,7 +585,7 @@ def _compute_lookup(self, row_loc, col_loc):
# `Index.__getitem__` works much faster with numpy arrays than with python lists,
# so although we lose some time here on converting to numpy, `Index.__getitem__`
# speedup covers the loss that we gain here.
axis_loc = np.array(axis_loc, dtype="int64")
axis_loc = np.array(axis_loc, dtype=np.int64)
# Relatively fast check allows us to not trigger `self.qc.get_axis()` computation
# if there're no negative indices and so they don't not depend on the axis length.
if isinstance(axis_loc, np.ndarray) and not (axis_loc < 0).any():
Expand Down
3 changes: 0 additions & 3 deletions modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3067,7 +3067,6 @@ def _validate_dtypes_min_max(self, axis, numeric_only) -> DataFrame:
):
# check if there are columns with dtypes datetime or timedelta
if all(
# TODO: pyarrow backend?
dtype != pandas.api.types.pandas_dtype("datetime64[ns]")
and dtype != pandas.api.types.pandas_dtype("timedelta64[ns]")
for dtype in self.dtypes
Expand Down Expand Up @@ -3104,7 +3103,6 @@ def _validate_dtypes_sum_prod_mean(
not axis
and numeric_only is False
and any(
# TODO: pyarrow backend?
dtype == pandas.api.types.pandas_dtype("datetime64[ns]")
for dtype in self.dtypes
)
Expand All @@ -3125,7 +3123,6 @@ def _validate_dtypes_sum_prod_mean(
):
# check if there are columns with dtypes datetime or timedelta
if all(
# TODO: pyarrow backend?
dtype != pandas.api.types.pandas_dtype("datetime64[ns]")
and dtype != pandas.api.types.pandas_dtype("timedelta64[ns]")
for dtype in self.dtypes
Expand Down

0 comments on commit 32baa1d

Please sign in to comment.