Minor updates to address a few issues (#537)

* docs on arg indices return type

* arange with nan

* undo isort
This commit is contained in:
Awni Hannun
2024-01-23 22:24:41 -08:00
committed by GitHub
parent 4fe2fa2a64
commit f30e63353a
3 changed files with 23 additions and 5 deletions

View File

@@ -79,7 +79,14 @@ array arange(
msg << bool_ << " not supported for arange.";
throw std::invalid_argument(msg.str());
}
int size = std::max(static_cast<int>(std::ceil((stop - start) / step)), 0);
if (std::isnan(start) || std::isnan(step) || std::isnan(stop)) {
throw std::invalid_argument("[arange] Cannot compute length.");
}
double real_size = std::ceil((stop - start) / step);
if (std::isnan(real_size)) {
throw std::invalid_argument("[arange] Cannot compute length.");
}
int size = std::max(static_cast<int>(real_size), 0);
return array(
{size},
dtype,