CartesianIndex hard to use #56738
trafficfan
started this conversation in
RFC: features for discussion
Replies: 1 comment
-
Thanks for raising this — many users transitioning from older Julia versions hit the same friction. In newer Julia versions (≥ 0.7), findmax(..., dims=...) returns a tuple:
So the modern equivalent of: (Tv[i,:], dr[i,:]) = findmax(u_temp + beta * Ev, 1) would be something like: vals, inds = findmax(u_temp + beta * Ev, dims=1)
Tv[i, :] = vals
dr[i, :] = getindex.(inds, 1) # Get row indices from CartesianIndex This change supports N-dimensional arrays more robustly, but yes, it's more verbose for simple 2D use-cases.
plain_indices(inds::Array{CartesianIndex}) = getindex.(inds, 1) Or improved documentation/examples for common 2D array use. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
using CartesianIndex makes such work hard to understand
Beta Was this translation helpful? Give feedback.
All reactions