-
Notifications
You must be signed in to change notification settings - Fork 29
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
Allow CartesianIndex
and CartesianIndices
with load!
#250
Comments
PS: To get around this, in my internals, I currently do variants of: inds = CartesianIndices((1:10,10:30))
NCDatasets.load!(variable(ds, "temperature"), v, inds.indices...)
ind = CartesianIndex(5,5)
NCDatasets.load!(variable(ds, "temperature"), vv, ind.I...) and I imagine a simple implementation of this could simply expand the indices in a similar fashion. |
I feel like a fix should be within reach by adding methods to Lines 455 to 465 in ce245f0
of the form _normalizeindex(n,ind::CartesianIndex) = ind
_normalizeindex(n,ind::CartesianIndices) = ind This doesn't immediately works, e.g. for Certainly, the Lines 95 to 108 in ce245f0
|
Thanks a lot for your detailed issue report. (it seems that we do not need |
Thanks a lot! This seems to work great. A small aside: In the future, I'd greatly appreciate if my contributions are explicitly acknowledged in the commit(s) (see how) with: Thanks again for the quick turnaround! Would you mind pushing a new release? |
Co-authored-by: Haakon Ludvig Langeland Ervik <[email protected]>
…on (#250) Co-authored-by: Haakon Ludvig Langeland Ervik <[email protected]>
Describe the bug
Reading a dataset normally, you can index it with
CartesianIndex
andCartesianIndices
, which is often very useful!For performance reasons it is sometimes useful to preallocate the output array, and therefore use
load!
. However, it appears this kind of indexing does not work withload!
.To Reproduce
stack traces
Cartesian indexing to work with
load!
Environment
OS info
The text was updated successfully, but these errors were encountered: