From 80eacd150015ed23ff2b159090b758c969eed4b7 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Mon, 22 May 2023 20:16:46 +0530 Subject: [PATCH 1/5] chore: replce custom definition of np.isclose with numba's np.isclose --- src/vector/backends/_numba_object.py | 33 ---------------------------- 1 file changed, 33 deletions(-) diff --git a/src/vector/backends/_numba_object.py b/src/vector/backends/_numba_object.py index 705c34bf..358b0543 100644 --- a/src/vector/backends/_numba_object.py +++ b/src/vector/backends/_numba_object.py @@ -94,39 +94,6 @@ def nan_to_num_impl(x, copy=True, nan=0.0, posinf=None, neginf=None): return nan_to_num_impl -@numba.extending.overload(numpy.isclose) # FIXME: This needs to go into Numba! -def isclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False): - if isinstance(a, numba.types.Array) and isinstance(b, numba.types.Array): - - def isclose_impl(a, b, rtol=1e-05, atol=1e-08, equal_nan=False): - a, b = numpy.broadcast_arrays(a, b) - x = a.reshape(-1) - y = b.astype(numpy.float64).reshape(-1) - out = numpy.zeros(len(x), numpy.bool_) - for i in range(len(out)): - if numpy.isnan(x[i]) and numpy.isnan(y[i]): - out[i] = equal_nan - elif numpy.isinf(x[i]) and numpy.isinf(y[i]): - out[i] = (x[i] > 0) == (y[i] > 0) - else: - out[i] = abs(x[i] - y[i]) <= atol + rtol * abs(y[i]) - return out.reshape(a.shape) - - else: - - def isclose_impl(a, b, rtol=1e-05, atol=1e-08, equal_nan=False): - x = a - y = numpy.float64(b) - if numpy.isnan(x) and numpy.isnan(y): - return equal_nan - elif numpy.isinf(x) and numpy.isinf(y): - return (x > 0) == (y > 0) - else: - return abs(x - y) <= atol + rtol * abs(y) - - return isclose_impl - - # Since CoordinateObjects are NamedTuples, we get their types wrapped for free. From 68826df8a1788832791580988f5e087b3ca2bc61 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Mon, 22 May 2023 20:18:58 +0530 Subject: [PATCH 2/5] docs: update changelog --- docs/changelog.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 45bc66d1..1c2d63c7 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,14 @@ ## Version 1.0 +### Unreleased + +#### Maintenance + +- chore: replace custom definition of np.isclose with numba's np.isclose [#348][] + +[#348]: https://github.com/scikit-hep/vector/pull/2348 + ### Version 1.0.0 #### Features From fd7ffa9711fb86a697a663a1283d80a621ae68a0 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Mon, 22 May 2023 20:24:04 +0530 Subject: [PATCH 3/5] chore(deps): bump numba version to 0.57 + remove Python 3.11 restriction --- environment.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 3a5a3a0c..894540b2 100644 --- a/environment.yml +++ b/environment.yml @@ -6,7 +6,7 @@ dependencies: - nb_conda_kernels - pip >=18 - pytest >=6 - - numba >=0.50 + - numba >=0.57 - numpy >=1.13.3 - root >=6.18.04 - pip: diff --git a/pyproject.toml b/pyproject.toml index 72281013..f55fafda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ awkward = [ ] dev = [ "awkward>=1.2", - 'numba>=0.50; python_version < "3.11"', + "numba>=0.57", "papermill>=2.4", "pytest>=6", "pytest-cov>=3", From 108ba1381790aee6145043e3b8f57cc2be0655ca Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Mon, 22 May 2023 20:29:09 +0530 Subject: [PATCH 4/5] Numba 0.57 dropped Python 3.7 support --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f55fafda..bf20a338 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ awkward = [ ] dev = [ "awkward>=1.2", - "numba>=0.57", + 'numba>=0.57; python_version > "3.7"', "papermill>=2.4", "pytest>=6", "pytest-cov>=3", From 3865c8dd6b5413cbb19dff5ed148c0241f2fe8e8 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Mon, 22 May 2023 23:14:34 +0530 Subject: [PATCH 5/5] python_version>3.7 -> python_version>=3.8 Co-authored-by: Henry Schreiner --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bf20a338..88025680 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ awkward = [ ] dev = [ "awkward>=1.2", - 'numba>=0.57; python_version > "3.7"', + 'numba>=0.57; python_version >= "3.8"', "papermill>=2.4", "pytest>=6", "pytest-cov>=3",