Skip to content

Commit

Permalink
Fix unzip for empty vectors (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg authored Mar 23, 2022
1 parent 34cb065 commit 2d78415
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
9 changes: 7 additions & 2 deletions RecipesPipeline/.github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ jobs:

# Run tests
- name: Run tests
run: |
$TESTCMD --project -e 'using Pkg; Pkg.test(coverage=true);'
run: $TESTCMD --project -e 'using Pkg; Pkg.test(coverage=true)'

# Codecov
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v2
with:
file: lcov.info

Skip:
if: "contains(github.event.head_commit.message, '[skip ci]')"
Expand Down
2 changes: 1 addition & 1 deletion RecipesPipeline/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ inverse_scale_func(scale::Symbol) =
# ## Unzip
# --------------------------------

unzip(v::AVec{<:Tuple}) = tuple((([t[j] for t in v]) for j in 1:length(v[1]))...)
unzip(v::AVec{<:Tuple}) = map(x->getfield.(v, x), fieldnames(eltype(v)))

# --------------------------------
# ## Map functions on vectors
Expand Down
37 changes: 24 additions & 13 deletions RecipesPipeline/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,32 @@ using StatsPlots
using Test
using TestImages

# makie_test_dir = joinpath(@__DIR__, "test_makie")
# mkpath(makie_test_dir)
@testset "unzip" begin
x, y, z = unzip([(1., 2., 3.), (1., 2., 3.)])
@test all(x .== 1.) && all(y .== 2.) && all(z .== 3.)
x, y, z = unzip(Tuple{Float64, Float64, Float64}[])
@test isempty(x) && isempty(y) && isempty(z)
end

@testset "group" begin
include("test_group.jl")
end

@testset "RecipesPipeline.jl" begin
# @testset "Makie integration" begin cd(makie_test_dir) do
# include("makie.jl")
# end end
@testset "Plots" begin
for i in eachindex(Plots._examples)
if i Plots._backend_skips[:gr]
@test Plots.test_examples(:gr, i, disp=false) isa Plots.Plot
end
@testset "plots" begin
for i in eachindex(Plots._examples)
if i Plots._backend_skips[:gr]
@test Plots.test_examples(:gr, i, disp=false) isa Plots.Plot
end
end
@testset "Group" begin
include("test_group.jl")
end

#=
makie_test_dir = joinpath(@__DIR__, "test_makie")
mkpath(makie_test_dir)
@testset "Makie integration" begin
cd(makie_test_dir) do
include("makie.jl")
end
end
=#

0 comments on commit 2d78415

Please sign in to comment.