Skip to content

Commit

Permalink
fix: support Pandas 0.24 (#8)
Browse files Browse the repository at this point in the history
* test: Don't use the equal_nan option of array_equal. It requires new versions of numpy

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* blacken

* fix: support pandas 0.24

* blacken

* remove 'stop on first error'

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Tim Swast <swast@google.com>
  • Loading branch information
3 people committed Sep 27, 2021
1 parent bc9f34d commit e996883
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 26 deletions.
9 changes: 2 additions & 7 deletions db_dtypes/core.py
Expand Up @@ -17,7 +17,6 @@
import numpy
import pandas
from pandas._libs import NaT
from pandas._typing import Scalar
import pandas.compat.numpy.function
import pandas.core.algorithms
import pandas.core.arrays
Expand Down Expand Up @@ -171,18 +170,14 @@ def all(
result = pandas.core.nanops.nanall(self._ndarray, axis=axis, skipna=skipna)
return result

def min(
self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs
) -> Scalar:
def min(self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs):
pandas.compat.numpy.function.validate_min((), kwargs)
result = pandas.core.nanops.nanmin(
values=self._ndarray, axis=axis, mask=self.isna(), skipna=skipna
)
return self._box_func(result)

def max(
self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs
) -> Scalar:
def max(self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs):
pandas.compat.numpy.function.validate_max((), kwargs)
result = pandas.core.nanops.nanmax(
values=self._ndarray, axis=axis, mask=self.isna(), skipna=skipna
Expand Down
1 change: 0 additions & 1 deletion noxfile.py
Expand Up @@ -44,7 +44,6 @@
]

# Error if a python version is missing
nox.options.stop_on_first_error = True
nox.options.error_on_missing_interpreters = True


Expand Down
15 changes: 0 additions & 15 deletions owlbot.py
Expand Up @@ -51,21 +51,6 @@
["noxfile.py"], "google/cloud", "db_dtypes",
)


def place_before(path, text, *before_text, escape=None):
replacement = "\n".join(before_text) + "\n" + text
if escape:
for c in escape:
text = text.replace(c, "\\" + c)
s.replace([path], text, replacement)


place_before(
"noxfile.py",
"nox.options.error_on_missing_interpreters = True",
"nox.options.stop_on_first_error = True",
)

# There are no system tests for this package.
old_sessions = """
"unit",
Expand Down
12 changes: 9 additions & 3 deletions tests/unit/test_dtypes.py
Expand Up @@ -58,6 +58,12 @@
for_date_and_time = pytest.mark.parametrize("dtype", ["date", "time"])


def eq_na(a1, a2):
nna1 = pd.notna(a1)
nna2 = pd.notna(a2)
return np.array_equal(nna1, nna2) and np.array_equal(a1[nna1], a2[nna2])


@pytest.fixture(autouse=True)
def register_dtype():
import db_dtypes # noqa
Expand Down Expand Up @@ -575,8 +581,8 @@ def test_date_add():
dates = pd.Series(dates)
times = pd.Series(times)
expect = dates.astype("datetime64") + times.astype("timedelta64")[:2]
assert np.array_equal(dates + times[:2], expect, equal_nan=True)
assert np.array_equal(times[:2] + dates, expect, equal_nan=True)
assert eq_na(dates + times[:2], expect)
assert eq_na(times[:2] + dates, expect)

do = pd.Series([pd.DateOffset(days=i) for i in range(4)])
expect = dates.astype("object") + do
Expand Down Expand Up @@ -609,7 +615,7 @@ def test_date_sub():
dates = pd.Series(dates)
dates2 = pd.Series(dates2)
expect = dates.astype("datetime64") - dates2.astype("datetime64")[:2]
assert np.array_equal(dates - dates2[:2], expect, equal_nan=True)
assert eq_na(dates - dates2[:2], expect)

do = pd.Series([pd.DateOffset(days=i) for i in range(4)])
expect = dates.astype("object") - do
Expand Down

0 comments on commit e996883

Please sign in to comment.