Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated dataArray with toUnsafeView #547

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions src/arraymancer/tensor/algorithms.nim
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ proc sort*[T](t: var Tensor[T], order = SortOrder.Ascending) =
## Sorts the raw underlying data!
# TODO: if `t` is a view, this will sort everything
assert t.rank == 1, "Only 1D tensors can be sorted at the moment!"
var mt = t.dataArray # without this we get an error that the openArray is immutable?
var mt = t.toUnsafeView # without this we get an error that the openArray is immutable?
sort(toOpenArray(mt, 0, t.size - 1), order = order)

proc sorted*[T](t: Tensor[T], order = SortOrder.Ascending): Tensor[T] =
Expand All @@ -47,9 +47,9 @@ proc argsort*[T](t: Tensor[T], order = SortOrder.Ascending, toCopy = false): Ten
# make a tuple of input & indices
var mt: ptr UncheckedArray[T]
if toCopy:
mt = t.clone.dataArray # without this we get an error that the openArray is immutable?
mt = t.clone.toUnsafeView # without this we get an error that the openArray is immutable?
else:
mt = t.dataArray # without this we get an error that the openArray is immutable?
mt = t.toUnsafeView # without this we get an error that the openArray is immutable?
var tups = zip(toOpenArray(mt, 0, t.size - 1),
toSeq(0 ..< t.size))
# sort by custom sort proc
Expand Down