|
1 | 1 | # --------------------------------------------------------------- |
2 | | -bool_env(x, default)::Bool = |
3 | | -try |
4 | | - return parse(Bool, get(ENV, x, default)) |
5 | | -catch e |
6 | | - @warn e |
7 | | - return false |
| 2 | +function bool_env(x, default)::Bool |
| 3 | + try |
| 4 | + return parse(Bool, get(ENV, x, default)) |
| 5 | + catch e |
| 6 | + @warn e |
| 7 | + return false |
| 8 | + end |
8 | 9 | end |
9 | 10 |
|
10 | 11 | treats_y_as_x(seriestype) = |
@@ -36,10 +37,8 @@ to_nan(::Type{NTuple{2, Float64}}) = (NaN, NaN) |
36 | 37 | to_nan(::Type{NTuple{3, Float64}}) = (NaN, NaN, NaN) |
37 | 38 |
|
38 | 39 | coords(segs::Segments{Float64}) = segs.pts |
39 | | -coords(segs::Segments{NTuple{2, Float64}}) = |
40 | | - (map(p -> p[1], segs.pts), map(p -> p[2], segs.pts)) |
41 | | -coords(segs::Segments{NTuple{3, Float64}}) = |
42 | | - (map(p -> p[1], segs.pts), map(p -> p[2], segs.pts), map(p -> p[3], segs.pts)) |
| 40 | +coords(segs::Segments{NTuple{2, Float64}}) = (map(p -> p[1], segs.pts), map(p -> p[2], segs.pts)) |
| 41 | +coords(segs::Segments{NTuple{3, Float64}}) = (map(p -> p[1], segs.pts), map(p -> p[2], segs.pts), map(p -> p[3], segs.pts)) |
43 | 42 |
|
44 | 43 | function Base.push!(segments::Segments{T}, vs...) where {T} |
45 | 44 | isempty(segments.pts) || push!(segments.pts, to_nan(T)) |
@@ -112,21 +111,21 @@ function series_segments(series::Series, seriestype::Symbol = :path; check = fal |
112 | 111 | end |
113 | 112 |
|
114 | 113 | segments = if has_attribute_segments(series) |
115 | | - map(nan_segments) do r |
| 114 | + ( |
116 | 115 | if seriestype === :shape |
117 | | - warn_on_inconsistent_shape_attr(series, x, y, z, r) |
118 | | - (SeriesSegment(r, first(r)),) |
| 116 | + # warn_on_inconsistent_shape_attr(series, x, y, z, r) |
| 117 | + (SeriesSegment(segment, j),) |
119 | 118 | elseif seriestype in (:scatter, :scatter3d) |
120 | | - (SeriesSegment(i:i, i) for i in r) |
| 119 | + (SeriesSegment(i:i, i) for i in segment) |
121 | 120 | else |
122 | | - (SeriesSegment(i:(i + 1), i) for i in first(r):(last(r) - 1)) |
123 | | - end |
124 | | - end |> Iterators.flatten |
| 121 | + (SeriesSegment(i:(i + 1), i) for i in first(segment):(last(segment) - 1)) |
| 122 | + end for (j, segment) in enumerate(nan_segments) |
| 123 | + ) |> Iterators.flatten |
125 | 124 | else |
126 | 125 | (SeriesSegment(r, 1) for r in nan_segments) |
127 | 126 | end |
128 | 127 |
|
129 | | - warn_on_attr_dim_mismatch(series, x, y, z, segments) |
| 128 | + # warn_on_attr_dim_mismatch(series, x, y, z, segments) |
130 | 129 | return segments |
131 | 130 | end |
132 | 131 |
|
@@ -198,7 +197,8 @@ _cycle(wrapper::InputWrapper, idx::Int) = wrapper.obj |
198 | 197 | _cycle(wrapper::InputWrapper, idx::AVec{Int}) = wrapper.obj |
199 | 198 |
|
200 | 199 | _cycle(v::AVec, idx::Int) = v[mod(idx, axes(v, 1))] |
201 | | -_cycle(v::AMat, idx::Int) = size(v, 1) == 1 ? v[end, mod(idx, axes(v, 2))] : v[:, mod(idx, axes(v, 2))] |
| 200 | +_cycle(v::AMat, idx::Int) = |
| 201 | + size(v, 1) == 1 ? v[end, mod(idx, axes(v, 2))] : v[:, mod(idx, axes(v, 2))] |
202 | 202 | _cycle(v, idx::Int) = v |
203 | 203 |
|
204 | 204 | _cycle(v::AVec, indices::AVec{Int}) = map(i -> _cycle(v, i), indices) |
@@ -376,20 +376,22 @@ function nanvcat(vs::AVec) |
376 | 376 | return v_out |
377 | 377 | end |
378 | 378 |
|
379 | | -sort_3d_axes(x, y, z, letter) = |
380 | | -if letter === :x |
381 | | - x, y, z |
382 | | -elseif letter === :y |
383 | | - y, x, z |
384 | | -else |
385 | | - z, y, x |
| 379 | +function sort_3d_axes(x, y, z, letter) |
| 380 | + return if letter === :x |
| 381 | + x, y, z |
| 382 | + elseif letter === :y |
| 383 | + y, x, z |
| 384 | + else |
| 385 | + z, y, x |
| 386 | + end |
386 | 387 | end |
387 | 388 |
|
388 | | -axes_letters(sp, letter) = |
389 | | -if RecipesPipeline.is3d(sp) |
390 | | - sort_3d_axes(:x, :y, :z, letter) |
391 | | -else |
392 | | - letter === :x ? (:x, :y) : (:y, :x) |
| 389 | +function axes_letters(sp, letter) |
| 390 | + return if RecipesPipeline.is3d(sp) |
| 391 | + sort_3d_axes(:x, :y, :z, letter) |
| 392 | + else |
| 393 | + letter === :x ? (:x, :y) : (:y, :x) |
| 394 | + end |
393 | 395 | end |
394 | 396 |
|
395 | 397 | handle_surface(z) = z |
@@ -1009,19 +1011,20 @@ function ___straightline_data(xl, yl, x, y, exp_fact) |
1009 | 1011 | ) |
1010 | 1012 | end |
1011 | 1013 |
|
1012 | | -__straightline_data(xl, yl, x, y, exp_fact) = |
1013 | | -if (n = length(x)) == 2 |
1014 | | - ___straightline_data(xl, yl, x, y, exp_fact) |
1015 | | -else |
1016 | | - k, r = divrem(n, 3) |
1017 | | - @assert r == 0 "Misformed data. `straightline_data` either accepts vectors of length 2 or 3k. The provided series has length $n" |
1018 | | - xdata, ydata = fill(NaN, n), fill(NaN, n) |
1019 | | - for i in 1:k |
1020 | | - inds = (3i - 2):(3i - 1) |
1021 | | - xdata[inds], ydata[inds] = |
1022 | | - ___straightline_data(xl, yl, x[inds], y[inds], exp_fact) |
| 1014 | +function __straightline_data(xl, yl, x, y, exp_fact) |
| 1015 | + return if (n = length(x)) == 2 |
| 1016 | + ___straightline_data(xl, yl, x, y, exp_fact) |
| 1017 | + else |
| 1018 | + k, r = divrem(n, 3) |
| 1019 | + @assert r == 0 "Misformed data. `straightline_data` either accepts vectors of length 2 or 3k. The provided series has length $n" |
| 1020 | + xdata, ydata = fill(NaN, n), fill(NaN, n) |
| 1021 | + for i in 1:k |
| 1022 | + inds = (3i - 2):(3i - 1) |
| 1023 | + xdata[inds], ydata[inds] = |
| 1024 | + ___straightline_data(xl, yl, x[inds], y[inds], exp_fact) |
| 1025 | + end |
| 1026 | + xdata, ydata |
1023 | 1027 | end |
1024 | | - xdata, ydata |
1025 | 1028 | end |
1026 | 1029 |
|
1027 | 1030 | _straightline_data(::Val{true}, ::Function, ::Function, ::Function, ::Function, args...) = |
@@ -1282,12 +1285,13 @@ function protectedstring(s) |
1282 | 1285 | To suppress all axis labels, pass an empty string to `xlabel`, etc. |
1283 | 1286 | To suppress units in axis labels pass `unitformat = :nounit` or `unitformat=(l,u)->l` |
1284 | 1287 | (equivalently for `xunitformat`, `yunitformat`, etc.). |
1285 | | - """, :protectedstring, force = true |
| 1288 | + """, |
| 1289 | + :protectedstring, |
| 1290 | + force = true, |
1286 | 1291 | ) |
1287 | 1292 | return ProtectedString(s) |
1288 | 1293 | end |
1289 | 1294 |
|
1290 | | - |
1291 | 1295 | """ |
1292 | 1296 | P_str(s) |
1293 | 1297 |
|
|
0 commit comments