Skip to content

Commit

Permalink
Fix cross2d
Browse files Browse the repository at this point in the history
There were two issues:

- The overload decorator didn't overload `cross2d`
- The tests called the overload directly, rather than calling `cross2d`
  in a jitted function.
  • Loading branch information
gmarkall committed Sep 27, 2022
1 parent 327d8a1 commit e101b48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion numba/np/arraymath.py
Original file line number Diff line number Diff line change
Expand Up @@ -4620,7 +4620,7 @@ def cross2d(a, b):
pass


@overload
@overload(cross2d)
def cross2d_impl(a, b):
if not type_can_asarray(a) or not type_can_asarray(b):
raise TypingError("Inputs must be array-like.")
Expand Down
8 changes: 6 additions & 2 deletions numba/tests/test_np_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ def np_cross(a, b):
return np.cross(a, b)


def nb_cross2d(a, b):
return cross2d(a, b)


def flip_lr(a):
return np.fliplr(a)

Expand Down Expand Up @@ -4432,7 +4436,7 @@ def test_cross_exceptions(self):

def test_cross2d(self):
pyfunc = np_cross
cfunc = cross2d
cfunc = njit(nb_cross2d)
pairs = [
# 2x2 (n-dims)
(
Expand Down Expand Up @@ -4477,7 +4481,7 @@ def test_cross2d(self):
self.assertPreciseEqual(expected, got)

def test_cross2d_exceptions(self):
cfunc = cross2d
cfunc = njit(nb_cross2d)
self.disable_leak_check()

# test incompatible dimensions for ndim == 1
Expand Down

0 comments on commit e101b48

Please sign in to comment.