Skip to content

Commit

Permalink
Merge branch 'master' into reduced-constant
Browse files Browse the repository at this point in the history
  • Loading branch information
mvashishtha authored Aug 9, 2022
2 parents 34fa004 + 3e981ba commit 2cb8bea
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 17 deletions.
3 changes: 2 additions & 1 deletion docs/release_notes/release_notes-0.16.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ Key Features and Updates
* REFACTOR-#4717: Improve PartitionMgr.get_indices() usage (#4718)
* REFACTOR-#4774: remove `_build_treereduce_func` call from `_compute_dtypes` (#4775)
* REFACTOR-#4750: Delete BaseDataframeAxisPartition.shuffle (#4751)
* REFACTOR-#4796: Introduce constant for __reduced__ column name (#4799)
* REFACTOR-#4722: Stop suppressing undefined name lint (#4723)
* REFACTOR-#4796: Introduce constant for __reduced__ column name (#4799)
* Pandas API implementations and improvements
* FEAT-#4670: Implement convert_dtypes by mapping across partitions (#4671)
* OmniSci enhancements
Expand Down
23 changes: 19 additions & 4 deletions modin/_compat/pandas_api/latest/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,32 @@

import pandas
from pandas.core.dtypes.common import is_datetime_or_timedelta_dtype
from pandas.core.window.ewm import ExponentialMovingWindow
from pandas.util._validators import validate_bool_kwarg, validate_ascending
from pandas._libs.lib import no_default
from pandas._typing import StorageOptions, CompressionOptions, IndexLabel
from pandas._libs.lib import no_default, NoDefault
from pandas._typing import (
StorageOptions,
CompressionOptions,
IndexLabel,
TimedeltaConvertibleTypes,
Axis,
)
import pickle as pkl
from numpy import nan
from typing import Sequence, Hashable, Optional
import numpy as np
from typing import Sequence, Hashable, Optional, TYPE_CHECKING

from ..abc import BaseCompatibleBasePandasDataset
from .utils import create_stat_method
from modin.utils import _inherit_docstrings

if TYPE_CHECKING:
from modin.pandas.base import BasePandasDataset

nan = np.nan

# See https://github.com/pandas-dev/pandas/blob/v1.4.3/pandas/core/generic.py#L195
bool_t = bool


class LatestCompatibleBasePandasDataset(BaseCompatibleBasePandasDataset):
"""Compatibility layer for 'latest pandas' for Dataset."""
Expand Down
18 changes: 15 additions & 3 deletions modin/_compat/pandas_api/latest/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,23 @@

"""Module for 'latest pandas' compatibility layer for DataFrame."""

from typing import Optional, Union, IO
from datetime import datetime
from typing import (
Optional,
Union,
IO,
Hashable,
Sequence,
)
import pandas
from pandas.util._validators import validate_bool_kwarg
from pandas._libs.lib import no_default
from pandas._typing import StorageOptions
from pandas._libs.lib import no_default, NoDefault
from pandas._typing import (
CompressionOptions,
FilePath,
StorageOptions,
WriteBuffer,
)
from numpy import nan

from ..abc import BaseCompatibleDataFrame
Expand Down
22 changes: 21 additions & 1 deletion modin/_compat/pandas_api/latest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,28 @@
import inspect
import pandas
from pandas._libs.lib import no_default
from pandas._typing import (
CompressionOptions,
CSVEngine,
DtypeArg,
ReadCsvBuffer,
FilePath,
StorageOptions,
IntStrT,
)
import pickle
from typing import Optional, Dict, Any, OrderedDict, List
from typing import (
Optional,
Dict,
Any,
OrderedDict,
List,
Sequence,
Literal,
Hashable,
Callable,
Iterable,
)

from modin.utils import _inherit_docstrings, Engine
from modin.error_message import ErrorMessage
Expand Down
8 changes: 7 additions & 1 deletion modin/_compat/pandas_api/latest/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@

"""Module for 'latest pandas' compatibility layer for Series."""

from typing import IO, Hashable, TYPE_CHECKING

import numpy as np
import pandas
from pandas.util._validators import validate_bool_kwarg
from pandas._libs.lib import no_default
from pandas._libs.lib import no_default, NoDefault
from pandas._typing import Axis

from ..abc.series import BaseCompatibleSeries

if TYPE_CHECKING:
from modin.pandas.dataframe import DataFrame


class LatestCompatibleSeries(BaseCompatibleSeries):
"""Compatibility layer for 'latest pandas' for Series."""
Expand Down
2 changes: 1 addition & 1 deletion modin/_compat/pandas_api/latest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

"""Module for utility functions used by 'latest pandas' compatibility layer."""

from pandas._libs.lib import no_default
from pandas._libs.lib import no_default, NoDefault


def create_stat_method(name):
Expand Down
3 changes: 2 additions & 1 deletion modin/_compat/pandas_api/py36/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ def read_stata(
@_inherit_docstrings(pandas.read_pickle)
@enable_logging
def read_pickle(
filepath_or_buffer: "FilePathOrBuffer", compression: Optional[str] = "infer"
filepath_or_buffer: Union[str, pathlib.Path, IO[AnyStr]],
compression: Optional[str] = "infer",
):
_, _, _, kwargs = inspect.getargvalues(inspect.currentframe())

Expand Down
5 changes: 5 additions & 0 deletions modin/_compat/pandas_api/py36/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@

"""Module for 'Python 3.6 pandas' compatibility layer for Series."""

from typing import TYPE_CHECKING

import numpy as np
import pandas

from ..abc.series import BaseCompatibleSeries
from modin.utils import _inherit_docstrings

if TYPE_CHECKING:
from modin.pandas import DataFrame


@_inherit_docstrings(pandas.Series)
class Python36CompatibleSeries(BaseCompatibleSeries):
Expand Down
3 changes: 3 additions & 0 deletions modin/core/dataframe/pandas/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
Axis,
JoinType,
)
from modin.core.dataframe.base.exchange.dataframe_protocol.dataframe import (
ProtocolDataframe,
)
from modin.pandas.indexing import is_range_like
from modin.pandas.utils import is_full_grab_slice, check_both_not_none
from modin.logging import ClassLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

from modin.core.dataframe.pandas.dataframe.dataframe import PandasDataframe
from modin.core.dataframe.base.dataframe.utils import Axis, JoinType
from modin.core.dataframe.base.exchange.dataframe_protocol.dataframe import (
ProtocolDataframe,
)
from modin.experimental.core.storage_formats.omnisci.query_compiler import (
DFAlgQueryCompiler,
)
Expand Down Expand Up @@ -2078,7 +2081,7 @@ def __dataframe__(self, nan_as_null: bool = False, allow_copy: bool = True):
)

@classmethod
def from_dataframe(cls, df: "ProtocolDataframe") -> "OmnisciOnNativeDataframe":
def from_dataframe(cls, df: ProtocolDataframe) -> "OmnisciOnNativeDataframe":
"""
Convert a DataFrame implementing the dataframe exchange protocol to a Core Modin Dataframe.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import pyarrow as pa
import pandas
import numpy as np
from typing import Any, Optional, Tuple, Dict, Iterable
from typing import Any, Optional, Tuple, Dict, Iterable, TYPE_CHECKING
from math import ceil

from modin.core.dataframe.base.exchange.dataframe_protocol.utils import (
Expand All @@ -34,6 +34,9 @@
from .buffer import OmnisciProtocolBuffer
from .utils import arrow_dtype_to_arrow_c, arrow_types_map

if TYPE_CHECKING:
from .dataframe import OmnisciProtocolDataframe


@_inherit_docstrings(ProtocolColumn)
class OmnisciProtocolColumn(ProtocolColumn):
Expand Down Expand Up @@ -254,7 +257,7 @@ def _pyarrow_table(self) -> pa.Table:
def num_chunks(self) -> int:
return self._col.num_chunks()

def get_chunks(self, n_chunks: Optional[int] = None) -> Iterable["Column"]:
def get_chunks(self, n_chunks: Optional[int] = None) -> Iterable[ProtocolColumn]:
for chunk in self._col.get_chunks(n_chunks):
yield OmnisciProtocolColumn(chunk)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from modin.core.dataframe.base.exchange.dataframe_protocol.dataframe import (
ProtocolDataframe,
)
from modin.pandas.indexing import is_range_like
from modin.utils import _inherit_docstrings
from modin.error_message import ErrorMessage
from modin.experimental.core.execution.native.implementations.omnisci_on_native.df_algebra import (
Expand Down
6 changes: 5 additions & 1 deletion modin/pandas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
from pandas._libs.lib import no_default
from pandas._typing import IndexKeyFunc
from typing import Union, Optional
from typing import Union, Optional, Hashable, TYPE_CHECKING
import warnings

from modin.utils import (
Expand All @@ -41,6 +41,10 @@
from modin._compat.pandas_api.classes import SeriesCompat


if TYPE_CHECKING:
from .dataframe import DataFrame


@_inherit_docstrings(
pandas.Series, excluded=[pandas.Series.__init__], apilink="pandas.Series"
)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ filterwarnings =

[flake8]
max-line-length = 88
ignore = E203, E266, E501, W503, F821
ignore = E203, E266, E501, W503
select = B,C,E,F,W,T,B9,NIC
per-file-ignores =
modin/pandas/__init__.py:E402,F401
Expand Down

0 comments on commit 2cb8bea

Please sign in to comment.