Skip to content

Commit e996883

Browse files
Jim Fultongcf-owl-bot[bot]tswast
authored
fix: support Pandas 0.24 (#8)
* 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 <[email protected]>
1 parent bc9f34d commit e996883

File tree

4 files changed

+11
-26
lines changed

4 files changed

+11
-26
lines changed

db_dtypes/core.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import numpy
1818
import pandas
1919
from pandas._libs import NaT
20-
from pandas._typing import Scalar
2120
import pandas.compat.numpy.function
2221
import pandas.core.algorithms
2322
import pandas.core.arrays
@@ -171,18 +170,14 @@ def all(
171170
result = pandas.core.nanops.nanall(self._ndarray, axis=axis, skipna=skipna)
172171
return result
173172

174-
def min(
175-
self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs
176-
) -> Scalar:
173+
def min(self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs):
177174
pandas.compat.numpy.function.validate_min((), kwargs)
178175
result = pandas.core.nanops.nanmin(
179176
values=self._ndarray, axis=axis, mask=self.isna(), skipna=skipna
180177
)
181178
return self._box_func(result)
182179

183-
def max(
184-
self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs
185-
) -> Scalar:
180+
def max(self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs):
186181
pandas.compat.numpy.function.validate_max((), kwargs)
187182
result = pandas.core.nanops.nanmax(
188183
values=self._ndarray, axis=axis, mask=self.isna(), skipna=skipna

noxfile.py

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
]
4545

4646
# Error if a python version is missing
47-
nox.options.stop_on_first_error = True
4847
nox.options.error_on_missing_interpreters = True
4948

5049

owlbot.py

-15
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,6 @@
5151
["noxfile.py"], "google/cloud", "db_dtypes",
5252
)
5353

54-
55-
def place_before(path, text, *before_text, escape=None):
56-
replacement = "\n".join(before_text) + "\n" + text
57-
if escape:
58-
for c in escape:
59-
text = text.replace(c, "\\" + c)
60-
s.replace([path], text, replacement)
61-
62-
63-
place_before(
64-
"noxfile.py",
65-
"nox.options.error_on_missing_interpreters = True",
66-
"nox.options.stop_on_first_error = True",
67-
)
68-
6954
# There are no system tests for this package.
7055
old_sessions = """
7156
"unit",

tests/unit/test_dtypes.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
for_date_and_time = pytest.mark.parametrize("dtype", ["date", "time"])
5959

6060

61+
def eq_na(a1, a2):
62+
nna1 = pd.notna(a1)
63+
nna2 = pd.notna(a2)
64+
return np.array_equal(nna1, nna2) and np.array_equal(a1[nna1], a2[nna2])
65+
66+
6167
@pytest.fixture(autouse=True)
6268
def register_dtype():
6369
import db_dtypes # noqa
@@ -575,8 +581,8 @@ def test_date_add():
575581
dates = pd.Series(dates)
576582
times = pd.Series(times)
577583
expect = dates.astype("datetime64") + times.astype("timedelta64")[:2]
578-
assert np.array_equal(dates + times[:2], expect, equal_nan=True)
579-
assert np.array_equal(times[:2] + dates, expect, equal_nan=True)
584+
assert eq_na(dates + times[:2], expect)
585+
assert eq_na(times[:2] + dates, expect)
580586

581587
do = pd.Series([pd.DateOffset(days=i) for i in range(4)])
582588
expect = dates.astype("object") + do
@@ -609,7 +615,7 @@ def test_date_sub():
609615
dates = pd.Series(dates)
610616
dates2 = pd.Series(dates2)
611617
expect = dates.astype("datetime64") - dates2.astype("datetime64")[:2]
612-
assert np.array_equal(dates - dates2[:2], expect, equal_nan=True)
618+
assert eq_na(dates - dates2[:2], expect)
613619

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

0 commit comments

Comments
 (0)