Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
address reviewer comments
  • Loading branch information
guilhermeleobas committed Sep 12, 2022
commit 3f0a1586221153e9d7764d8680464995b4dafde9
19 changes: 6 additions & 13 deletions numba/np/arrayobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -4532,28 +4532,21 @@ def impl(start, stop=None, step=None, dtype=None):


@overload(np.linspace)
def numpy_linspace_2(start, stop):
if isinstance(start, types.Number) and isinstance(stop, types.Number):
def impl(start, stop):
return np.linspace(start, stop, 50)
return impl


@overload(np.linspace)
def numpy_linspace_3(start, stop, num):
def numpy_linspace(start, stop, num=50):
if not all(isinstance(arg, types.Number) for arg in [start, stop]):
return

if not isinstance(num, types.Integer):
return
if not isinstance(num, (int, types.Integer)):
msg = 'The argument "num" must be an integer'
raise errors.TypingError(msg)

if any(isinstance(arg, types.Complex) for arg in [start, stop]):
dtype = types.complex128
else:
dtype = types.float64
dtype = as_dtype(dtype)

def linspace(start, stop, num):
# Implementation based on https://github.com/numpy/numpy/blob/v1.20.0/numpy/core/function_base.py#L24 # noqa: E501
def linspace(start, stop, num=50):
arr = np.empty(num, dtype)
# The multiply by 1.0 mirrors
# https://github.com/numpy/numpy/blob/v1.20.0/numpy/core/function_base.py#L125-L128 # noqa: E501
Expand Down