Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 10 additions & 0 deletions numba/np/arrayobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -2555,6 +2555,16 @@ def impl(a):
return np.asarray(a).shape
return impl


@overload(np.size)
def np_size(a):
if not type_can_asarray(a):
raise errors.TypingError("The argument to np.size must be array-like")

def impl(a):
return np.asarray(a).size
return impl

# ------------------------------------------------------------------------------


Expand Down
3 changes: 3 additions & 0 deletions numba/tests/test_array_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def numpy_fill_diagonal(arr, val, wrap=False):
def numpy_shape(arr):
return np.shape(arr)

def numpy_size(arr):
Comment thread
shourya5 marked this conversation as resolved.
Resolved
return np.size(arr)


def numpy_flatnonzero(a):
return np.flatnonzero(a)
Expand Down
4 changes: 4 additions & 0 deletions numba/tests/test_record_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ def get_shape(rec):
return np.shape(rec.j)


def get_size(rec):
return np.size(rec.j)
Comment thread
shourya5 marked this conversation as resolved.
Resolved


def get_charseq(ary, i):
return ary[i].n

Expand Down