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

.var[:] always returns a vector #233

Closed
mwlidar opened this issue Oct 11, 2023 · 7 comments
Closed

.var[:] always returns a vector #233

mwlidar opened this issue Oct 11, 2023 · 7 comments

Comments

@mwlidar
Copy link

mwlidar commented Oct 11, 2023

.var[:] in the latest version now always makes a vector, even if the source is a higher dim array. This is a change of behaviour and contradicts the docs. Array() still works as expected.

  • operating system: Windows 10
  • Julia version: 1.9.3
  • NCDatasets version: NCDatasets v0.13.1
@visr
Copy link
Contributor

visr commented Oct 11, 2023

NCDatasets 0.13 is a breaking release, where this behavior was changed intentionally. This is written in the release notes here: https://github.com/Alexander-Barth/NCDatasets.jl/releases/tag/v0.13.0

Which are the docs that you say this contradicts? Perhaps some still need updating.

@mwlidar
Copy link
Author

mwlidar commented Oct 11, 2023

vairiable.md on master still says:

To load the variable v_cf in memory as numeric data you can convert it into an array (preserving its dimensionality structure) with

Array(v_cf)

The syntax v_cf[:] is equivalent with the above, it doesn't make a Vector (like it does on normal Julia arrays).

Anyway this quite beraking for me, als there are over 200 places to review and correct manually. At least my regex skills are not enough to come up with an automated conversion...

Alexander-Barth added a commit that referenced this issue Oct 11, 2023
@Alexander-Barth
Copy link
Owner

Alexander-Barth commented Oct 11, 2023

Thanks for pointing out where the documentation needs to updated. This commit fixed this part of the docs:
981729f

@lupemba
Copy link

lupemba commented Oct 12, 2023

Just a note. This does not only affect multi dimensional arrays.
I have experienced that scalar variables are returned as an vectors now.
I have instrument_parameters["fsamp"][:] which previously returned a float but now returns a vector with one element.

I like change for the multi dimensional case.

@Alexander-Barth
Copy link
Owner

Scalar variable can also be loaded using [], I clarified that in the docs here:
d22fff6

Also for julia this indexing works for scalars '42[] == 42`.

I like change for the multi dimensional case.

Thank you for noting that 😀 I typically get mostly negative feedback over-here 😅

@mwlidar
Copy link
Author

mwlidar commented Oct 13, 2023

While fixing up my code I noticed that Array(v_cf) is not equivalent to v_cf.var[:] even in the vector case, because Array(v_cf) does Missing and DateTime conversion etc. The equivalent would be Array(v_cf.var). Maybe this could be added in some way to the docs.

@Alexander-Barth
Copy link
Owner

Alexander-Barth commented Oct 13, 2023

OK I added this here to include also an example of v_cf.var:

148e086#diff-048ca2e4745de3ff36dc57555fe64b07a4b761109d9c4caafe45df1f1d8e35ffR45

Is there something in the docs that made you think that Array(v_cf) was equivalent to v_cf.var[:] ?

bors bot added a commit to CliMA/ClimaAtmos.jl that referenced this issue Nov 2, 2023
2303: Update to the new CloudMicrophysics interface r=szy21 a=trontrytel

This PR:
- updates the 0-moment microphysics to the new parameters interface in CloudMicrophysics v0.15
- deletes unused old EDMF + microphysics code

2318: Update dependencies r=szy21 a=charleskawczynski

This PR updates the dependencies.

2319: Pin NCDatasets to < 0.13 r=szy21 a=Sbozzolo

Alexander-Barth/NCDatasets.jl#233

Co-authored-by: Anna Jaruga <[email protected]>
Co-authored-by: Charles Kawczynski <[email protected]>
Co-authored-by: Gabriele Bozzola <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants