From 2ca325e08fcc67b099200bf40d5e355874e7e17b Mon Sep 17 00:00:00 2001 From: Jim Fulton Date: Sun, 26 Sep 2021 10:11:12 -0600 Subject: [PATCH 1/8] test: Don't use the equal_nan option of array_equal. It requires new versions of numpy --- tests/unit/test_dtypes.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_dtypes.py b/tests/unit/test_dtypes.py index 572915e..325343f 100644 --- a/tests/unit/test_dtypes.py +++ b/tests/unit/test_dtypes.py @@ -58,6 +58,11 @@ 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 @@ -575,8 +580,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 @@ -609,7 +614,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 From fec2a2da5e64eb5e0847ece1b106823e0469f18a Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Sun, 26 Sep 2021 16:16:06 +0000 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- tests/unit/test_dtypes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/test_dtypes.py b/tests/unit/test_dtypes.py index 325343f..4991639 100644 --- a/tests/unit/test_dtypes.py +++ b/tests/unit/test_dtypes.py @@ -63,6 +63,7 @@ def eq_na(a1, a2): 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 From 0258316705f46fc2a41c075a97bd26d9aee553fa Mon Sep 17 00:00:00 2001 From: Jim Fulton Date: Sun, 26 Sep 2021 10:19:55 -0600 Subject: [PATCH 3/8] blacken --- tests/unit/test_dtypes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/test_dtypes.py b/tests/unit/test_dtypes.py index 325343f..4991639 100644 --- a/tests/unit/test_dtypes.py +++ b/tests/unit/test_dtypes.py @@ -63,6 +63,7 @@ def eq_na(a1, a2): 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 From e787a4e209e77235056f8814c506fe0d011d81d0 Mon Sep 17 00:00:00 2001 From: Jim Fulton Date: Sun, 26 Sep 2021 10:26:37 -0600 Subject: [PATCH 4/8] fix: support pandas 0.24 --- db_dtypes/core.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db_dtypes/core.py b/db_dtypes/core.py index dd1d23a..65539a6 100644 --- a/db_dtypes/core.py +++ b/db_dtypes/core.py @@ -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 @@ -173,7 +172,7 @@ def all( def min( self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs - ) -> Scalar: + ): pandas.compat.numpy.function.validate_min((), kwargs) result = pandas.core.nanops.nanmin( values=self._ndarray, axis=axis, mask=self.isna(), skipna=skipna @@ -182,7 +181,7 @@ def min( def max( self, *, axis: Optional[int] = None, skipna: bool = True, **kwargs - ) -> Scalar: + ): pandas.compat.numpy.function.validate_max((), kwargs) result = pandas.core.nanops.nanmax( values=self._ndarray, axis=axis, mask=self.isna(), skipna=skipna From 742b2dfd21e2202f61b67841af8775469bb00a0a Mon Sep 17 00:00:00 2001 From: Jim Fulton Date: Sun, 26 Sep 2021 10:29:15 -0600 Subject: [PATCH 5/8] blacken --- db_dtypes/core.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/db_dtypes/core.py b/db_dtypes/core.py index 65539a6..3b05ad6 100644 --- a/db_dtypes/core.py +++ b/db_dtypes/core.py @@ -170,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 - ): + 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 - ): + 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 From aa4fd71af27a7c027dd375f16e976c0bc78e12c7 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Mon, 27 Sep 2021 10:06:14 -0500 Subject: [PATCH 6/8] remove 'stop on first error' --- owlbot.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/owlbot.py b/owlbot.py index dd1ed69..176e179 100644 --- a/owlbot.py +++ b/owlbot.py @@ -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", From d75710e42fbd0c83f8daccfe664830b628e930ab Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 27 Sep 2021 15:08:10 +0000 Subject: [PATCH 7/8] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- noxfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 63ac434..f2a2bed 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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 From 834f11630642a1df3e88cdf5d0780026872d274c Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 27 Sep 2021 15:09:13 +0000 Subject: [PATCH 8/8] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- noxfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 63ac434..f2a2bed 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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