-
Notifications
You must be signed in to change notification settings - Fork 13
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
Implementing repeat for PooledArray #67
Changes from 4 commits
f913260
3391ecd
5ad8abf
901c26b
8cc60f6
f8818d9
6f6610e
d8acef4
5600e9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -461,3 +461,45 @@ end | |||||||||
pa[:] = [1 2; 3 4] | ||||||||||
@test pa == [1 2; 3 4] | ||||||||||
end | ||||||||||
|
||||||||||
@testset "repeat" begin | ||||||||||
pa1 = PooledArray([1, 2, 3]) | ||||||||||
pa2 = repeat(pa1) | ||||||||||
pa3 = repeat(pa1, 2) | ||||||||||
pa4 = repeat(pa1, inner = 2) | ||||||||||
@test pa2 == pa1 | ||||||||||
@test pa3 == [1, 2, 3, 1, 2, 3] | ||||||||||
@test pa4 == [1, 1, 2, 2, 3, 3] | ||||||||||
@test refpool(pa1) === refpool(pa2) === refpool(pa3) === refpool(pa4) | ||||||||||
@test invrefpool(pa1) === invrefpool(pa2) === invrefpool(pa3) === invrefpool(pa4) | ||||||||||
@test refcount(pa1) === refcount(pa2) === refcount(pa3) === refcount(pa4) | ||||||||||
@test refcount(pa1)[] == 4 | ||||||||||
|
||||||||||
pa1 = PooledArray(["one", "two"]) | ||||||||||
# check it didn't mess the other pa | ||||||||||
@test pa3 == [1, 2, 3, 1, 2, 3] | ||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't check much AFAICT: no significant operation has been performed since the last check.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I remove it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's what the suggestion does? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I am lost. What is your suggestion on lines 478-480? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why GitHub is confused about it, but I just suggested dropping lines 479-481. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||||||||||
pa2 = repeat(pa1, outer = 3) | ||||||||||
pa3 = repeat(pa1, inner = 3, outer = 2) | ||||||||||
@test pa2 == ["one", "two", "one", "two", "one", "two"] | ||||||||||
@test pa3 == ["one", "one", "one", "two", "two", "two", "one", "one", "one", "two", "two", "two"] | ||||||||||
|
||||||||||
# missing shouldn't be a problem | ||||||||||
|
||||||||||
pa1 = PooledArray(["one", missing, "two"]) | ||||||||||
pa2 = repeat(pa1, 2) | ||||||||||
pa3 = repeat(pa1, 0) | ||||||||||
@test isequal(pa2, ["one", missing, "two", "one", missing, "two"]) | ||||||||||
@test isequal(pa2.pool, ["one", missing, "two"]) | ||||||||||
@test size(pa3) == (0,) | ||||||||||
@test pa3.refs == UInt32[] | ||||||||||
sl-solution marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
# two dimensional | ||||||||||
pa1 = PooledArray([true false; false true; true true]) | ||||||||||
pa2 = repeat(pa1, 2) | ||||||||||
@test pa2 == Bool[1 0; 0 1; 1 1; 1 0; 0 1; 1 1] | ||||||||||
|
||||||||||
pa1 = PooledArray([1 2; 3 4]) | ||||||||||
pa2 = repeat(pa1, inner = (2, 1)) | ||||||||||
@test pa2 == [1 2; 1 2; 3 4; 3 4] | ||||||||||
end |
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 would assume that the
{T, R, N, RA}
part is not needed. Why have you added it?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.
based on CI output, it seems it is needed for
Julia 1.0.5
?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.
It seems the problem should be solved in another way. I updated it.