Skip to content
Open
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
2 changes: 1 addition & 1 deletion tensor1d.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ float tensor_getitem(Tensor* t, int ix) {
// handle negative indices by wrapping around
if (ix < 0) { ix = t->size + ix; }
// oob indices raise IndexError (and we return NaN)
if (ix >= t->size) {
if (ix < 0 || ix >= t->size) {
fprintf(stderr, "IndexError: index %d is out of bounds of %d\n", ix, t->size);
return NAN;
}
Expand Down