Alexander-Barth / NCDatasets.jl

Load and create NetCDF files in Julia
MIT License
146 stars 31 forks source link

Add support for `_normalizeindex` with `Base.OneTo` #195

Closed charleskawczynski closed 1 year ago

charleskawczynski commented 1 year ago

This PR adds support for _normalizeindex with Base.OneTo for the second argument. In ClimaCoreTempestRemap.jl, we use axes on a struct which returns a Base.OneTo type, and it's failing with unsupported index.

charleskawczynski commented 1 year ago

Hmm, I'm actually not sure whether this should be

_normalizeindex(n, ind::Base.OneTo) = 1:1:ind.stop

or

_normalizeindex(n, ind::Base.OneTo) = 1:1:n
Alexander-Barth commented 1 year ago

To me ind.stop seems correct, as n is the upper bound for the colon type.

(Thanks for the pr!)

Charles Kawczynski @.***> schrieb am Fr., 9. Dez. 2022, 19:30:

Hmm, I'm actually not sure whether this should be

_normalizeindex(n, ind::Base.OneTo) = 1:1:ind.stop

or

_normalizeindex(n, ind::Base.OneTo) = 1:1:n

— Reply to this email directly, view it on GitHub https://github.com/Alexander-Barth/NCDatasets.jl/pull/195#issuecomment-1344628607, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACLMPA74P2GWZSZWCPVJTGTWMN3FLANCNFSM6AAAAAASZS33IU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Alexander-Barth commented 1 year ago

Thanks again!