fix: handle linspace function when num is 1 (#602)

* fix: handle linspace function when num is 1

* add comment

* fix test case

* remove breakpoint
This commit is contained in:
Avikant Srivastava
2024-02-05 00:33:49 +05:30
committed by GitHub
parent 4fd2fb84a6
commit 11a9fd40f0
2 changed files with 8 additions and 0 deletions

View File

@@ -148,6 +148,9 @@ array linspace(
msg << "[linspace] number of samples, " << num << ", must be non-negative.";
throw std::invalid_argument(msg.str());
}
if (num == 1) {
return astype(array({start}), dtype, to_stream(s));
}
array sequence = arange(0, num, float32, to_stream(s));
float step = (stop - start) / (num - 1);
return astype(