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

Make flat accept AbstractArray #31

Merged
merged 3 commits into from
May 8, 2021
Merged

Conversation

schneiderfelipe
Copy link
Contributor

Fix #30.

@yurivish I could add a test for this if you like, but that would probably add an extra test dependency.

@yurivish
Copy link
Collaborator

yurivish commented May 6, 2021

Thanks @schneiderfelipe!

I think you should be able to test this by choosing an AbstractArray from Base that is other than the concrete type Array. A BitVector, for example:

julia> BitArray([0, 0, 1, 1, 0])
5-element BitVector:
 0
 0
 1
 1
 0

julia> BitArray([0, 0, 1, 1, 0]) isa Array
false

@schneiderfelipe
Copy link
Contributor Author

@yurivish Nice! I added a test with BitVector.

I had to add an extra case for AbstractRanges, as they are AbstractArrays as well, in order to avoid flattening:

julia> using Hyperscript

julia> const p = m("p")
<p></p>

julia> p([1, 2, 3])
<p>123</p>

julia> p(BitVector([0, 1, 0]))
<p>falsetruefalse</p>

julia> p(1:3)
<p>1:3</p>

@yurivish
Copy link
Collaborator

yurivish commented May 8, 2021

That's a good thought. Thanks for working on this!

@yurivish yurivish merged commit a0afe27 into JuliaWeb:master May 8, 2021
@schneiderfelipe schneiderfelipe deleted the patch-1 branch May 8, 2021 15:01
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.

flat should accept AbstractArray
2 participants