From 01438075154fe2637731831fed2c803f984323c7 Mon Sep 17 00:00:00 2001 From: Michael Krabbe Borregaard Date: Thu, 9 Aug 2018 15:15:53 +0100 Subject: [PATCH 1/6] Remove deprecated endof --- src/types.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types.jl b/src/types.jl index fde75008..c9ae2f24 100644 --- a/src/types.jl +++ b/src/types.jl @@ -88,7 +88,7 @@ end Base.getindex(plt::Plot, i::Integer) = plt.subplots[i] Base.length(plt::Plot) = length(plt.subplots) -Base.endof(plt::Plot) = length(plt) +Base.lastindex(plt::Plot) = length(plt) Base.getindex(plt::Plot, r::Integer, c::Integer) = plt.layout[r,c] Base.size(plt::Plot) = size(plt.layout) @@ -99,6 +99,6 @@ Base.ndims(plt::Plot) = 2 # attr!(plt::Plot, v, k::Symbol) = (plt.attr[k] = v) Base.getindex(sp::Subplot, i::Integer) = series_list(sp)[i] -Base.endof(sp::Subplot) = length(series_list(sp)) +Base.lastindex(sp::Subplot) = length(series_list(sp)) # ----------------------------------------------------------------------- From 5205ac38ad6338baff2916971a497307887192b5 Mon Sep 17 00:00:00 2001 From: Michael Krabbe Borregaard Date: Thu, 9 Aug 2018 16:37:32 +0100 Subject: [PATCH 2/6] Implement new iterator protocol --- src/components.jl | 9 ++++++--- src/utils.jl | 14 ++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/components.jl b/src/components.jl index 8635c71b..c9b03d41 100644 --- a/src/components.jl +++ b/src/components.jl @@ -523,9 +523,12 @@ mutable struct EachAnn x y end -Base.start(ea::EachAnn) = 1 -Base.done(ea::EachAnn, i) = ea.anns == nothing || isempty(ea.anns.strs) || i > length(ea.y) -function Base.next(ea::EachAnn, i) + +function Base.iterate(ea::EachAnn, i = 1) + if ea.anns == nothing || isempty(ea.anns.strs) || i > length(ea.y) + return nothing + end + tmp = _cycle(ea.anns.strs,i) str,fnt = if isa(tmp, PlotText) tmp.str, tmp.font diff --git a/src/utils.jl b/src/utils.jl index 591b0e8e..e20f9453 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -215,15 +215,13 @@ anynan(i::Int, args::Tuple) = any(a -> try isnan(_cycle(a,i)) catch MethodError anynan(istart::Int, iend::Int, args::Tuple) = any(i -> anynan(i, args), istart:iend) allnan(istart::Int, iend::Int, args::Tuple) = all(i -> anynan(i, args), istart:iend) -function Base.start(itr::SegmentsIterator) - nextidx = 1 - if !any(isempty,itr.args) && anynan(1, itr.args) - _, nextidx = next(itr, 1) +Base.iterate(itr::SegmentsIterator, nextidx::Int) = +function Base.next(itr::SegmentsIterator, nextidx::Int = 1) + nextidx > itr.n && return nothing + if nextidx == 1 && !any(isempty,itr.args) && anynan(1, itr.args) + nextidx = 2 end - nextidx -end -Base.done(itr::SegmentsIterator, nextidx::Int) = nextidx > itr.n -function Base.next(itr::SegmentsIterator, nextidx::Int) + i = istart = iend = nextidx # find the next NaN, and iend is the one before From c544dbbbb7a04f71cd8cbc77571f686c3f45c349 Mon Sep 17 00:00:00 2001 From: Michael Krabbe Borregaard Date: Thu, 9 Aug 2018 16:49:03 +0100 Subject: [PATCH 3/6] rename mimewritable --- src/output.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output.jl b/src/output.jl index 085876fb..7c762d6b 100644 --- a/src/output.jl +++ b/src/output.jl @@ -185,8 +185,8 @@ function _show(io::IO, ::MIME"text/html", plt::Plot) end end -# delegate mimewritable (showable on julia 0.7) to _show instead -function Base.mimewritable(m::M, plt::P) where {M<:MIME, P<:Plot} +# delegate showable to _show instead +function Base.showable(m::M, plt::P) where {M<:MIME, P<:Plot} return hasmethod(_show, Tuple{IO, M, P}) end From 8e6ccf1b207b6671c0ab894d91c11c2f7e732d88 Mon Sep 17 00:00:00 2001 From: Michael Krabbe Borregaard Date: Thu, 9 Aug 2018 16:55:30 +0100 Subject: [PATCH 4/6] typo fix --- src/utils.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index e20f9453..e816dd51 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -215,8 +215,7 @@ anynan(i::Int, args::Tuple) = any(a -> try isnan(_cycle(a,i)) catch MethodError anynan(istart::Int, iend::Int, args::Tuple) = any(i -> anynan(i, args), istart:iend) allnan(istart::Int, iend::Int, args::Tuple) = all(i -> anynan(i, args), istart:iend) -Base.iterate(itr::SegmentsIterator, nextidx::Int) = -function Base.next(itr::SegmentsIterator, nextidx::Int = 1) +function Base.iterate(itr::SegmentsIterator, nextidx::Int = 1) nextidx > itr.n && return nothing if nextidx == 1 && !any(isempty,itr.args) && anynan(1, itr.args) nextidx = 2 From 3dd0049973a1487bc8ece3f55e50e77a695d38e3 Mon Sep 17 00:00:00 2001 From: Michael Krabbe Borregaard Date: Thu, 9 Aug 2018 17:00:17 +0100 Subject: [PATCH 5/6] No longer overload broadcast --- src/layouts.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layouts.jl b/src/layouts.jl index 8999cf62..924f571d 100644 --- a/src/layouts.jl +++ b/src/layouts.jl @@ -5,8 +5,8 @@ to_pixels(m::AbsoluteLength) = m.value / 0.254 const _cbar_width = 5mm -Base.broadcast(::typeof(Base.:.*), m::Measure, n::Number) = m * n -Base.broadcast(::typeof(Base.:.*), m::Number, n::Measure) = m * n +#Base.broadcast(::typeof(Base.:.*), m::Measure, n::Number) = m * n +#Base.broadcast(::typeof(Base.:.*), m::Number, n::Measure) = m * n Base.:-(m::Measure, a::AbstractArray) = map(ai -> m - ai, a) Base.:-(a::AbstractArray, m::Measure) = map(ai -> ai - m, a) Base.zero(::Type{typeof(mm)}) = 0mm From 3849700a280a40813a841e3d82331be5aaf6f06a Mon Sep 17 00:00:00 2001 From: Michael Krabbe Borregaard Date: Thu, 9 Aug 2018 17:03:44 +0100 Subject: [PATCH 6/6] readstring -> read --- src/backends/plotly.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index a3bcec14..9c1841ee 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -76,7 +76,7 @@ end const _plotly_js_path = joinpath(dirname(@__FILE__), "..", "..", "deps", "plotly-latest.min.js") const _plotly_js_path_remote = "https://cdn.plot.ly/plotly-latest.min.js" -_js_code = open(readstring, _plotly_js_path, "r") +_js_code = open(read, _plotly_js_path, "r") # borrowed from https://github.com/plotly/plotly.py/blob/2594076e29584ede2d09f2aa40a8a195b3f3fc66/plotly/offline/offline.py#L64-L71 c/o @spencerlyon2 _js_script = """