Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
33 changes: 0 additions & 33 deletions src/vector/backends/_numba_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down