Skip to content

Commit 2c90439

Browse files
committed
Revert extraneous change, improve tests
1 parent 5507cc5 commit 2c90439

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

RecipesPipeline/src/type_recipe.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function _apply_type_recipe(plotattributes, v, letter)
2121
rdvec = RecipesBase.apply_recipe(plotattributes, typeof(v), v)
2222
warn_on_recipe_aliases!(plotattributes[:plot_object], plotattributes, :type, v)
2323
postprocess_axis_args!(plt, plotattributes, letter)
24-
isnothing(rdvec) && return nothing
2524
return rdvec[1].args[1]
2625
end
2726

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Unitful: m, s, cm, DimensionError
2+
import Plots.UnitfulRecipes: getaxisunit
23
import Plots: PLOTS_SEED, Plot, with
34
import GeometryBasics
45
import ImageMagick

test/test_unitful.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ xseries(pl, idx = length(pl.series_list)) = pl.series_list[idx].plotattributes[:
77
yseries(pl, idx = length(pl.series_list)) = pl.series_list[idx].plotattributes[:y]
88
zseries(pl, idx = length(pl.series_list)) = pl.series_list[idx].plotattributes[:z]
99

10-
testfile = tempname() * ".png"
10+
forcedraw(pl) = savefig(pl, tempname() * ".png")
1111

1212
macro isplot(ex) # @isplot macro to streamline tests
1313
:(@test $(esc(ex)) isa Plot)
@@ -41,6 +41,7 @@ end
4141
@testset "yunit" begin
4242
@test yguide(plot(y, yunit = cm)) == "cm"
4343
@test yseries(plot(y, yunit = cm)) ustrip.(cm, y)
44+
@test getaxisunit(plot(y, yunit = cm).subplots[1][:yaxis]) == cm
4445
end
4546

4647
@testset "ylims" begin # Using all(lims .≈ lims) because of uncontrolled type conversions?
@@ -52,7 +53,7 @@ end
5253
@test_throws DimensionError begin
5354
pl = plot(y)
5455
plot!(pl; ylims = (-1s, 5s))
55-
savefig(pl, testfile)
56+
forcedraw(pl)
5657
end
5758
end
5859

@@ -62,15 +63,15 @@ end
6263
pl = plot(y; ylims = encompassing_ylims, yticks = (1:5)m)
6364
@test compare_yticks(pl, 1:5)
6465
pl = plot(y; ylims = encompassing_ylims, yticks = [1cm, 3cm])
65-
savefig(pl, testfile)
66+
forcedraw(pl)
6667
@test compare_yticks(pl, [0.01, 0.03])
6768
pl = plot!(; ylims = encompassing_ylims, yticks = [-1cm, 4cm])
68-
savefig(pl, testfile)
69+
forcedraw(pl)
6970
@test compare_yticks(pl, [-0.01, 0.04])
7071
@test_throws DimensionError begin
7172
pl = plot(y)
7273
plot!(pl; yticks = (1:5)s)
73-
savefig(pl, testfile)
74+
forcedraw(pl)
7475
end
7576
end
7677

@@ -337,19 +338,18 @@ end
337338

338339
@testset "Aspect ratio" begin
339340
pl = plot((1:10)u"m", (1:10)u"dm"; aspect_ratio = :equal)
340-
savefig(pl, testfile) # Force a render, to make it evaluate aspect ratio
341+
forcedraw(pl)
341342
@test abs(-(ylims(pl)...)) > 50
342343
plot!(pl, (3:4)u"m", (4:5)u"m")
343344
@test first(pl.subplots)[:aspect_ratio] == 1 // 10 # This is what "equal" means when yunit==xunit/10
344345
pl = plot((1:10)u"m", (1:10)u"dm"; aspect_ratio = 2)
345-
savefig(pl, testfile)
346+
forcedraw(pl)
346347
@test 25 < abs(-(ylims(pl)...)) < 50
347348
pl = plot((1:10)u"m", (1:10)u"s"; aspect_ratio = 1u"m/s")
348-
savefig(pl, testfile)
349+
forcedraw(pl)
349350
@test 7.5 < abs(-(ylims(pl)...)) < 12.5
350-
@test_throws DimensionError savefig(
351+
@test_throws DimensionError forcedraw(
351352
plot((1:10)u"m", (1:10)u"s"; aspect_ratio = :equal),
352-
testfile,
353353
)
354354
end
355355

0 commit comments

Comments
 (0)