Merge pull request #2456 from JuliaPlots/as/remove-tryrange

move tryrange to PlotUtils
This commit is contained in:
Daniel Schwabeneder 2020-04-01 23:08:28 +02:00 committed by GitHub
commit 6e3c218d89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 22 deletions

View File

@ -41,7 +41,7 @@ Measures = "0.3"
NaNMath = "0.3"
PGFPlotsX = "1.2.0"
PlotThemes = "1"
PlotUtils = "0.6.1"
PlotUtils = "0.6.5"
RecipesBase = "0.8"
Reexport = "0.2"
Requires = "0.5, 1.0"

View File

@ -464,33 +464,14 @@ end
axis_limits(plt[1], :x)
catch
xinv = invscalefunc(get(plotattributes, :xscale, :identity))
xm = tryrange(f, xinv.([-5,-1,0,0.01]))
xm, tryrange(f, filter(x->x>xm, xinv.([5,1,0.99, 0, -0.01])))
xm = PlotUtils.tryrange(f, xinv.([-5,-1,0,0.01]))
xm, PlotUtils.tryrange(f, filter(x->x>xm, xinv.([5,1,0.99, 0, -0.01])))
end
end
f, xmin, xmax
end
# try some intervals over which the function may be defined
function tryrange(F::AbstractArray, vec)
rets = [tryrange(f, vec) for f in F] # get the preferred for each
maxind = maximum(indexin(rets, vec)) # get the last attempt that succeeded (most likely to fit all)
rets .= [tryrange(f, vec[maxind:maxind]) for f in F] # ensure that all functions compute there
rets[1]
end
function tryrange(F, vec)
for v in vec
try
tmp = F(v)
return v
catch
end
end
error("$F is not a Function, or is not defined at any of the values $vec")
end
# --------------------------------------------------------------------
# 2 arguments