Skip to content

Fix failing XArray tests#97

Merged
glennmoy merged 5 commits intomainfrom
gm/nightly
Jul 1, 2021
Merged

Fix failing XArray tests#97
glennmoy merged 5 commits intomainfrom
gm/nightly

Conversation

@glennmoy
Copy link
Copy Markdown
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
Copy Markdown

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.

Comment thread src/apply.jl Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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