-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix failing XArray tests #97
Conversation
The issue was in calling `cat` on AxisArrays and KeyedArrays. For AxisArrays the issue was it wouldn't allow two arrays to have the same axis values. KeyedArrays allows cat-ing two arrays with the same values but the default axis keys generated in the tests did not match those from the code.
Codecov Report
@@ Coverage Diff @@
## main #97 +/- ##
==========================================
- Coverage 99.25% 98.52% -0.73%
==========================================
Files 12 12
Lines 134 136 +2
==========================================
+ Hits 133 134 +1
- Misses 1 2 +1
Continue to review full report at Codecov.
|
src/apply.jl
Outdated
@@ -118,7 +118,8 @@ the usual [`Transform`](@ref) being invoked. | |||
function apply_append(A::AbstractArray, t; append_dim, kwargs...)::AbstractArray | |||
result = apply(A, t; kwargs...) | |||
result = _postformat(cardinality(t), result, A, append_dim) | |||
return cat(A, result; dims=append_dim) | |||
# Call parent to avoid clashing axis/key names in concatenated result | |||
return cat(A, parent(result); dims=append_dim) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this is OK for if the arrays are some kind of SubArray
or ReshapedArray
or Symmetric
etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first result
should be a new instance of the array A
- at least this is guaranteed for the FakeTransforms since those use replace
to generate a result.
It can potentially get reshape
d when calling _postformat
but I added a call to copy
to also return a new instance there.
I tried Symmetric
, NameDimsArray
on a few transforms and they worked so I think it's safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add them to tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added tests for NamedDimsArrays, SubArrays, and ReshapedArrays.
Symmetric
is a bit odd because you can't call replace
on it so it's not compatible with the test suite.
ERROR: ArgumentError: Cannot set a non-diagonal index in a symmetric matrix
Stacktrace:
Fixes #96
The issue was in calling
cat
on AxisArrays and KeyedArrays.For AxisArrays the issue was it wouldn't allow two arrays to have the same axis values.
KeyedArrays allows cat-ing two arrays with the same values but the default axis keys generated in the tests did not match those from the code.
Solution is to call
parent
on either before callingcat
, which removes the axis info and forces to use the default in both cases.