Skip to content

Commit

Permalink
fix modin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicBboy committed Oct 6, 2022
1 parent b24f08d commit 4e9c997
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pandera/engines/pandas_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def _check_decimal(

is_decimal = pandas_obj.apply(
lambda x: isinstance(x, decimal.Decimal)
).astype("boolean") | pd.isnull(pandas_obj)
).astype("bool") | pd.isnull(pandas_obj)

decimals = pandas_obj[is_decimal]
# fix for modin unamed series raises KeyError
Expand Down
8 changes: 8 additions & 0 deletions pandera/typing/modin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@

from typing import TYPE_CHECKING, Generic, TypeVar

from packaging import version

from .common import DataFrameBase, IndexBase, SeriesBase
from .pandas import GenericDtype, Schema

try:
import modin
import modin.pandas as mpd

MODIN_INSTALLED = True
except ImportError:
MODIN_INSTALLED = False


def modin_version():
"""Return the modin version."""
return version.parse(modin.__version__)


# pylint:disable=invalid-name
if TYPE_CHECKING:
T = TypeVar("T") # pragma: no cover
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[tool.pyright]
include = [ "pandera", "tests" ]
exclude = [".nox/**", ".nox-*/**"]

[tool.pytest.ini_options]
log_cli = true
log_cli_level = 20
1 change: 0 additions & 1 deletion tests/core/test_logical_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def test_logical_datatype_check(
assert not any(
cast(Iterable[bool], expected_datatype.check(SimpleDtype(), data))
)
print(expected_datatype.check(SimpleDtype(), None))
assert expected_datatype.check(SimpleDtype(), None) is False

# No data container
Expand Down
4 changes: 2 additions & 2 deletions tests/modin/test_schemas_on_modin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pandera as pa
from pandera import extensions
from pandera.engines import numpy_engine, pandas_engine
from pandera.typing.modin import DataFrame, Index, Series
from pandera.typing.modin import DataFrame, Index, Series, modin_version
from tests.strategies.test_strategies import NULLABLE_DTYPES
from tests.strategies.test_strategies import (
SUPPORTED_DTYPES as SUPPORTED_STRATEGY_DTYPES,
Expand Down Expand Up @@ -151,7 +151,7 @@ def test_index_dtypes(
schema.coerce = coerce
sample = data.draw(schema.strategy(size=3))
# pandas (and modin) use object arrays to store boolean data
if dtype is bool:
if modin_version().release < (0, 16, 0) and dtype is bool:
assert sample.dtype == "object"
return
assert isinstance(
Expand Down

0 comments on commit 4e9c997

Please sign in to comment.