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
11 changes: 11 additions & 0 deletions arkouda/numpy/pdarraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,17 @@ def linspace(
start_ = start
stop_ = stop

# Handle the special cases of num

if num == 0:
return array([], dtype=float64)

if num == 1:
if isinstance(start_, pdarray):
return start_.reshape((1,) + start_.shape)
else:
return array([start_], dtype=float64)

if isinstance(start_, pdarray):
start_ = start_.astype(float64)
elif isinstance(start_, int):
Expand Down
8 changes: 8 additions & 0 deletions tests/numpy/pdarray_creation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,14 @@ def test_full_like_multi_dim(self, size, dtype):
assert (full_like_arr == 1).all()
assert full_like_arr.size == ran_arr.size

def test_linspace_special_cases(self):
pda = ak.linspace(0, 1, 0, endpoint=True)
nda = np.linspace(0, 1, 0, endpoint=True)
assert_almost_equivalent(pda, nda)
pda = ak.linspace(0, 1, 1, endpoint=True)
nda = np.linspace(0, 1, 1, endpoint=True)
assert_almost_equivalent(pda, nda)

@pytest.mark.parametrize("size", pytest.prob_size)
def test_linspace_1D(self, size):
pda = ak.linspace(0, 100, size)
Expand Down