Skip to content

Commit

Permalink
Fix ribbon slicing (#4068)
Browse files Browse the repository at this point in the history
* move ribbon handling after slicing

* format file
  • Loading branch information
BeastyBlacksmith authored Jan 25, 2022
1 parent 2eaf9f3 commit 915df5d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
28 changes: 15 additions & 13 deletions src/pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,6 @@ function _preprocess_userrecipe(kw::AKW)
map(kw[:line_z], kw[:x], kw[:y], kw[:z])
end

rib = get(kw, :ribbon, default(:ribbon))
fr = get(kw, :fillrange, default(:fillrange))
# map ribbon if it's a Function
if rib isa Function
kw[:ribbon] = map(rib, kw[:x])
end
# convert a ribbon into a fillrange
if rib !== nothing
make_fillrange_from_ribbon(kw)
# map fillrange if it's a Function
elseif fr !== nothing && fr isa Function
kw[:fillrange] = map(fr, kw[:x])
end
return
end

Expand Down Expand Up @@ -164,6 +151,21 @@ function RecipesPipeline.process_sliced_series_attributes!(plt::Plots.Plot, kw_l
end
end

for kw in kw_list
rib = get(kw, :ribbon, default(:ribbon))
fr = get(kw, :fillrange, default(:fillrange))
# map ribbon if it's a Function
if rib isa Function
kw[:ribbon] = map(rib, kw[:x])
end
# convert a ribbon into a fillrange
if rib !== nothing
make_fillrange_from_ribbon(kw)
# map fillrange if it's a Function
elseif fr !== nothing && fr isa Function
kw[:fillrange] = map(fr, kw[:x])
end
end
return nothing
end

Expand Down
13 changes: 10 additions & 3 deletions test/test_pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ end
@testset "Slicing" begin
@test plot(1:5, fillrange = 0)[1][1][:fillrange] == 0
data4 = rand(4, 4)
mat = reshape(1:8, 2, 4)
for i in axes(data4, 1)
@test plot(data4, fillrange = 0)[1][i][:fillrange] == 0
@test plot(data4, fillrange = [1, 2])[1][i][:fillrange] == [1.0, 2.0]
@test plot(data4, fillrange = [1 2])[1][i][:fillrange] == (iseven(i) ? 2 : 1)
for attribute in (:fillrange, :ribbon)
@test plot(data4; NamedTuple{tuple(attribute)}(0)...)[1][i][attribute] == 0
@test plot(data4; NamedTuple{tuple(attribute)}(Ref([1, 2]))...)[1][i][attribute] ==
[1.0, 2.0]
@test plot(data4; NamedTuple{tuple(attribute)}(Ref([1 2]))...)[1][i][attribute] ==
(iseven(i) ? 2 : 1)
@test plot(data4; NamedTuple{tuple(attribute)}(Ref(mat))...)[1][i][attribute] ==
[2(i - 1) + 1, 2i]
end
end
end

0 comments on commit 915df5d

Please sign in to comment.