bramtayl / unzip.jl Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I couldn't reproduce this in my global environment, and need to run it in a test harness. Here is a MWE:
]add https://github.com/LilithHafner/UnzipUser.jl
test UnzipUser
And the results from a CI run of same:
https://github.com/LilithHafner/UnzipUser.jl/runs/4084456970?check_suite_focus=true
Can we have a new release that includes the fix for #3?
Thanks for making Unzip
. I appreciate it.
My main use-case for unzip
, though, is returning a tuple of vectors from map
rather than a vector of tuples. Would this be possible to add to Unzip
?
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
using GeometryBasics
using Unzip
const P2 = GeometryBasics.Point2
unzip([P2((0.2,0.3)), P2((0.1,2.0))])
Results in
ERROR: MethodError: Cannot `convert` an object of type Float64 to an object of type Tuple{Float64, Float64}
Closest candidates are:
convert(::Type{T}, ::T) where T<:Tuple at ~/.asdf/installs/julia/1.7.2/share/julia/base/essentials.jl:336
convert(::Type{T}, ::Tuple{Vararg{Any, N}}) where {N, T<:Tuple} at ~/.asdf/installs/julia/1.7.2/share/julia/base/essentials.jl:337
convert(::Type{T}, ::CartesianIndex) where T<:Tuple at ~/.asdf/installs/julia/1.7.2/share/julia/base/multidimensional.jl:137
...
Stacktrace:
[1] setindex!(A::Vector{Tuple{Float64, Float64}}, x::Float64, i1::Int64)
@ Base ./array.jl:903
[2] #5
@ ~/.julia/packages/Unzip/Yiepw/src/Unzip.jl:82 [inlined]
[3] (::Base.var"#4#5"{Unzip.var"#5#6"{Tuple{Int64}}})(a::Tuple{Vector{Tuple{Float64, Float64}}, Float64})
@ Base ./generator.jl:36
[4] iterate
@ ./generator.jl:47 [inlined]
[5] collect(itr::Base.Generator{Base.Iterators.Zip{Tuple{Tuple{Vector{Tuple{Float64, Float64}}}, GeometryBasics.Point2{Float64}}}, Base.var"#4#5"{Unzip.var"#5#6"{Tuple{Int64}}}})
@ Base ./array.jl:724
[6] map(::Function, ::Tuple{Vector{Tuple{Float64, Float64}}}, ::GeometryBasics.Point2{Float64})
@ Base ./abstractarray.jl:2948
[7] setindex!
@ ~/.julia/packages/Unzip/Yiepw/src/Unzip.jl:81 [inlined]
[8] copyto_unaliased!(deststyle::IndexCartesian, dest::Unzip.Rows{Tuple{Tuple{Float64, Float64}}, 1, Tuple{Vector{Tuple{Float64, Float64}}}}, srcstyle::IndexLinear, src::Vector{GeometryBasics.Point2{Float64}})
@ Base ./abstractarray.jl:1032
[9] copyto!
@ ./abstractarray.jl:998 [inlined]
[10] _collect(cont::Unzip.Rows{Tuple{}, 1, Tuple{}}, itr::Vector{GeometryBasics.Point2{Float64}}, #unused#::Base.HasEltype, isz::Base.HasShape{1})
@ Base ./array.jl:655
[11] unzip(rows::Vector{GeometryBasics.Point2{Float64}})
@ Unzip ~/.julia/packages/Unzip/Yiepw/src/Unzip.jl:264
[12] top-level scope
@ REPL[46]:1
Not sure if this is a bug in Unzip
or BlockArrays
julia> using Unzip, BlockArrays
julia> m = mortar([Matrix(rand(i,j)) for i=1:2, j=1:3]);
julia> cblocks = [(rand(),rand()) for c in eachcol(m)];
julia> cblocks isa AbstractVector{<:Tuple}
true
julia> unzip(cblocks)
ERROR: type BlockArray has no field columns
Stacktrace:
[1] getproperty(x::BlockVector{Tuple{Float64, Float64}, Vector{Vector{Tuple{Float64, Float64}}}, Tuple{BlockedUnitRange{Vector{Int64}}}}, f::Symbol)
@ Base .\Base.jl:33
[2] unzip(rows::PseudoBlockVector{Tuple{Float64, Float64}, Vector{Tuple{Float64, Float64}}, Tuple{BlockedUnitRange{Vector{Int64}}}})
@ Unzip C:\Users\sternlab\.julia\packages\Unzip\x2oA5\src\Unzip.jl:249
[3] top-level scope
@ REPL[60]:1
unzip( [(1, 2), (3, 4)] ) # OK
unzip( x for x in [(1, 2), (3, 4)] ) # OK
unzip( [(1, 2), ("a", "b")] ) # OK
unzip( x for x in [(1, 2), ("a", "b")] ) # MethodError: no method matching widen_column(::Base.HasLength, ::Int64, ::Int64, ::Vector{Int64}, ::String)
unzip( [(a=1, b=2), (a=3, b=4)] ) # OK
unzip( x for x in [(a=1, b=2), (a=3, b=4)] ) # OK
unzip( [(a=1, b=2), (a="a", b="b")] ) # BoundError: attempt to access 0-element Unzip.Rows{Tuple{}, 1, Tuple{}} at index [1, 2]
unzip( x for x in [(a=1, b=2), (a="a", b="b")] ) # MethodError: no method matching widen_column(::Base.HasLength, ::Int64, ::Int64, ::Vector{Int64}, ::String)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.