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

Request for clarification: rebuilding/copying YAXArray structure? #413

Closed
ConnectedSystems opened this issue Jul 11, 2024 · 1 comment · Fixed by #436
Closed

Request for clarification: rebuilding/copying YAXArray structure? #413

ConnectedSystems opened this issue Jul 11, 2024 · 1 comment · Fixed by #436

Comments

@ConnectedSystems
Copy link
Contributor

In this section of the docs on handling axes names it is stated:

WARNING
To get the axes of a YAXArray use the dims function instead of the caxes function

and

INFO
Also, use DD.rebuild(ax, values) instead of axcopy(ax, values) to copy an axes with the same name but different values.

There are two issues.

First, the indicated functions either do not exist or are not exported:

using YAXArrays

yax = YAXArray(ones(10,10))

dims(yax)
# ERROR: UndefVarError: `dims` not defined
# Stacktrace:
# [1] top-level scope
#   @ REPL[26]:1

# This works
YAXArrays.DD.dims(yax)
# ↓ Dim_1 Sampled{Int64} Base.OneTo(10) ForwardOrdered Regular Points,
# → Dim_2 Sampled{Int64} Base.OneTo(10) ForwardOrdered Regular Points

Second, it is not clear what is expected in place of ax.
At first glance, it appears it should be the output from YAXArrays.DD.dims(), but that doesn't seem to be the case:

YAXArrays.DD.rebuild(YAXArrays.DD.dims(yax), rand(10,10))
# ERROR: MethodError: no method matching rebuild(::Tuple{Dim{…}, Dim{…}}, ::Matrix{Float64})
# Closest candidates are:
#   rebuild(::DimensionalData.AbstractDimStack, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any)
#    @ DimensionalData C:\Users\tiwanaga\.julia\packages\DimensionalData\BoJag\src\stack\stack.jl:61
#   rebuild(::DimensionalData.AbstractDimStack, ::Any, ::Any, ::Any, ::Any, ::Any)
#    @ DimensionalData C:\Users\tiwanaga\.julia\packages\DimensionalData\BoJag\src\stack\stack.jl:61
#   rebuild(::DimensionalData.AbstractDimStack, ::Any, ::Any, ::Any, ::Any)
#    @ DimensionalData C:\Users\tiwanaga\.julia\packages\DimensionalData\BoJag\src\stack\stack.jl:61

What I'm actually trying to do is create a copy of the YAXArray structure, holding Int64 instead of Floats.
i.e., same dims/axes, but the values are different and of a different type.

yax = YAXArray(ones(10,10))
# How do I convert to YAXArray{Int64, 2, Matrix{Int64}, ...} ?
@lazarusA
Copy link
Collaborator

close by #436

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

Successfully merging a pull request may close this issue.

2 participants