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

Fix failing XArray tests #97

Merged
merged 5 commits into from
Jul 1, 2021
Merged

Fix failing XArray tests #97

merged 5 commits into from
Jul 1, 2021

Conversation

glennmoy
Copy link
Member

@glennmoy glennmoy commented Jun 30, 2021

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 calling cat, which removes the axis info and forces to use the default in both cases.

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
Copy link

codecov bot commented Jun 30, 2021

Codecov Report

Merging #97 (cdb209a) into main (135e533) will decrease coverage by 0.72%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/apply.jl 100.00% <100.00%> (ø)
src/test_utils.jl 100.00% <100.00%> (ø)
src/scaling.jl 94.11% <0.00%> (-5.89%) ⬇️
src/one_hot_encoding.jl 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1b023b1...cdb209a. Read the comment docs.

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)
Copy link
Member

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?

Copy link
Member Author

@glennmoy glennmoy Jun 30, 2021

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 reshaped 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.

Copy link
Member

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?

Copy link
Member Author

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:

@glennmoy glennmoy enabled auto-merge July 1, 2021 13:20
@glennmoy glennmoy merged commit f929182 into main Jul 1, 2021
@glennmoy glennmoy deleted the gm/nightly branch July 1, 2021 13:21
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 this pull request may close these issues.

AxisArray and KeyedArray Nightly failures
2 participants