Apply suggestions from code review

This commit is contained in:
Adriane Boyd 2023-04-27 09:13:45 +02:00 committed by GitHub
parent 31c7ce5072
commit eb8d45291c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,9 +57,9 @@ def _get_span_indices(ops, spans: Ragged, lengths: Ints1d) -> Ints1d:
for i, length in enumerate(lengths): for i, length in enumerate(lengths):
spans_i = spans[i].dataXd + offset spans_i = spans[i].dataXd + offset
for j in range(spans_i.shape[0]): for j in range(spans_i.shape[0]):
indices += list(range(spans_i[j, 0], spans_i[j, 1])) # type: ignore indices.extend(range(spans_i[j, 0], spans_i[j, 1]))
offset += length offset += length
return ops.xp.asarray(indices, dtype="int") return ops.asarray1i(indices)
def _ensure_cpu(spans: Ragged, lengths: Ints1d) -> Tuple[Ragged, Ints1d]: def _ensure_cpu(spans: Ragged, lengths: Ints1d) -> Tuple[Ragged, Ints1d]: