-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Adding tests for AbstractArrayMath.jl #56773
base: master
Are you sure you want to change the base?
Conversation
added tests
Probably want a more descriptive PR title and commit message. |
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.
Thanks for contributing tests!
I can confirm that codecov reports both this isreal
method and all of insertdims
as untested. I don't see anywhere in test/
where this isreal
method is tested but I do see that insertdims
is tested here:
Lines 312 to 338 in 6cb9f04
a = rand(8, 7) | |
@test @inferred(insertdims(a, dims=1)) == @inferred(insertdims(a, dims=(1,))) == reshape(a, (1, 8, 7)) | |
@test @inferred(insertdims(a, dims=3)) == @inferred(insertdims(a, dims=(3,))) == reshape(a, (8, 7, 1)) | |
@test @inferred(insertdims(a, dims=(1, 3))) == reshape(a, (1, 8, 1, 7)) | |
@test @inferred(insertdims(a, dims=(1, 2, 3))) == reshape(a, (1, 1, 1, 8, 7)) | |
@test @inferred(insertdims(a, dims=(1, 4))) == reshape(a, (1, 8, 7, 1)) | |
@test @inferred(insertdims(a, dims=(1, 3, 5))) == reshape(a, (1, 8, 1, 7, 1)) | |
@test @inferred(insertdims(a, dims=(1, 2, 4, 6))) == reshape(a, (1, 1, 8, 1, 7, 1)) | |
@test @inferred(insertdims(a, dims=(1, 3, 4, 6))) == reshape(a, (1, 8, 1, 1, 7, 1)) | |
@test @inferred(insertdims(a, dims=(1, 4, 6, 3))) == reshape(a, (1, 8, 1, 1, 7, 1)) | |
@test @inferred(insertdims(a, dims=(1, 3, 5, 6))) == reshape(a, (1, 8, 1, 7, 1, 1)) | |
@test_throws ArgumentError insertdims(a, dims=(1, 1, 2, 3)) | |
@test_throws ArgumentError insertdims(a, dims=(1, 2, 2, 3)) | |
@test_throws ArgumentError insertdims(a, dims=(1, 2, 3, 3)) | |
@test_throws UndefKeywordError insertdims(a) | |
@test_throws ArgumentError insertdims(a, dims=0) | |
@test_throws ArgumentError insertdims(a, dims=(1, 2, 1)) | |
@test_throws ArgumentError insertdims(a, dims=4) | |
@test_throws ArgumentError insertdims(a, dims=6) | |
# insertdims and dropdims are inverses | |
b = rand(1,1,1,5,1,1,7) | |
for dims in [1, (1,), 2, (2,), 3, (3,), (1,3), (1,2,3), (1,2), (1,3,5), (1,2,5,6), (1,3,5,6), (1,3,5,6), (1,6,5,3)] | |
@test dropdims(insertdims(a; dims); dims) == a | |
@test insertdims(dropdims(b; dims); dims) == b | |
end |
Codecov does not currently display coverage results of this PR.
F = [MyReal(1.0), MyReal(2.0)] | ||
@test isreal(F) == true | ||
G = ["a", "b", "c"] | ||
@test_throws MethodError isreal(G) |
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.
I appreciate you testing this failure case as well.
make stricter test Co-authored-by: Lilith Orion Hafner <[email protected]>
Co-authored-by: Lilith Orion Hafner <[email protected]>
removing redundant tests already done before
thanks for such a detailed feedback! It really helps :) I had missed the insertdims test which were already present in the code, but they are not complete. So I have removed any redundancies for the same. Should i move all the insertdims test be together in arrayops? or is this okay? |
Yes, please. All the insertdims tests should be together. |
added insertdims tests
I have added my tests in the same place as well. making a test-set for the same :) |
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.
Thanks!
added tests for lines 7, 137-154 (insertdims function) from base/abstractarraymath.jl