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 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..88025680 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; python_version >= "3.8"', "papermill>=2.4", "pytest>=6", "pytest-cov>=3", 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.