Skip to content

Commit 5ac8308

Browse files
authored
Merge pull request #239 from MakieOrg/hw/pointf
rename Pointf -> to_pointf32
2 parents 78d6f05 + d89187e commit 5ac8308

4 files changed

Lines changed: 35 additions & 32 deletions

File tree

src/beziercurves.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ function Path(P::Vararg{PT, N}; tangents=nothing, tfactor=.5) where {PT<:Abstrac
272272
# first command, recalculate WP if tangent is given
273273
first_wp = WP[1]
274274
if tangents !== nothing
275-
p1, p2, t = P[1], P[2], normalize(Pointf(tangents[1]))
275+
p1, p2, t = P[1], P[2], normalize(to_pointf32(tangents[1]))
276276
dir = p2 - p1
277277
d = tfactor * norm(dir t)
278278
first_wp = PT(p1+d*t)
@@ -289,7 +289,7 @@ function Path(P::Vararg{PT, N}; tangents=nothing, tfactor=.5) where {PT<:Abstrac
289289
# last command, recalculate last WP if tangent is given
290290
last_wp = (P[N] + WP[N-1])/2
291291
if tangents !== nothing
292-
p1, p2, t = P[N-1], P[N], normalize(Pointf(tangents[2]))
292+
p1, p2, t = P[N-1], P[N], normalize(to_pointf32(tangents[2]))
293293
dir = p2 - p1
294294
d = tfactor * norm(dir t)
295295
last_wp = PT(p2-d*t)
@@ -313,8 +313,8 @@ function Path(P::Vararg{PT, 2}; tangents=nothing, tfactor=.5) where {PT<:Abstrac
313313
if tangents === nothing
314314
return Line(p1, p2)
315315
else
316-
t1 = normalize(Pointf(tangents[1]))
317-
t2 = normalize(Pointf(tangents[2]))
316+
t1 = normalize(to_pointf32(tangents[1]))
317+
t2 = normalize(to_pointf32(tangents[2]))
318318
len = norm(p2 - p1)
319319
return BezierPath([MoveTo(p1),
320320
CurveTo(PT(p1+len*tf1*t1),

src/recipes.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ function Makie.plot!(gp::GraphPlot)
216216
if length(layout) != nv(graph)
217217
throw(ArgumentError("The length of the layout vector does not match the number of nodes in the graph!"))
218218
else
219-
Pointf.(layout)
219+
to_pointf32.(layout)
220220
end
221221
else
222-
[Pointf(p) for p in layout(graph)]
222+
[to_pointf32(p) for p in layout(graph)]
223223
end
224224
end
225225

@@ -783,7 +783,7 @@ end
783783

784784
function _expand_args(args::Union{AbstractVector, AbstractDict}, ranges)
785785
N_paths = length(ranges)
786-
N_points = ranges[end][end]
786+
N_points = N_paths > 0 ? ranges[end][end] : 0
787787
allstraight = N_paths*3 == N_points
788788
if args isa AbstractVector && length(args) != N_paths
789789
throw(ArgumentError("The length of the args vector $args does not match the number of edges!"))

src/utils.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ Return `true` if `x` represents a single attribute value
112112
issingleattribute(x) = isa(x, Point) || (!isa(x, AbstractVector) && !isa(x, AbstractDict))
113113

114114
"""
115-
Pointf(p::Point{N, T})
115+
to_pointf32(p::Point{N, T})
116116
117117
Convert Point{N, T} or NTuple{N, T} to Point{N, Float32}.
118118
"""
119-
Pointf(p::Union{Point{N,T}, NTuple{N,T}}) where {N,T} = Point{N, Float32}(p)
120-
Pointf(p::StaticVector{N, T}) where {N,T} = Point{N, Float32}(p)
121-
Pointf(p::Vararg{T,N}) where {N,T} = Point{N, Float32}(p)
122-
Pointf(p::Vector{T}) where {T} = Point{length(p), Float32}(p)
119+
to_pointf32(p::Union{Point{N,T}, NTuple{N,T}}) where {N,T} = Point{N, Float32}(p)
120+
to_pointf32(p::StaticVector{N, T}) where {N,T} = Point{N, Float32}(p)
121+
to_pointf32(p::Vararg{T,N}) where {N,T} = Point{N, Float32}(p)
122+
to_pointf32(p::Vector{T}) where {T} = Point{length(p), Float32}(p)
123123

124124
"""
125125
align_to_dir(align::Tuple{Symbol, Symbol})

test/runtests.jl

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -189,32 +189,32 @@ end
189189
@test get_elabel_plot(p)[:text][] == elabels
190190
end
191191

192-
@testset "test Pointf" begin
193-
using GraphMakie: Pointf
192+
@testset "test to_pointf32" begin
193+
using GraphMakie: to_pointf32
194194

195195
p = Point(0.0, 0.0)
196-
@test typeof(Pointf(p)) == Point2f
197-
@test Pointf(p) == Point2f(p)
196+
@test typeof(to_pointf32(p)) == Point2f
197+
@test to_pointf32(p) == Point2f(p)
198198

199199
p = Point(1, 0)
200-
@test typeof(Pointf(p)) == Point2f
201-
@test Pointf(p) == Point2f(p)
200+
@test typeof(to_pointf32(p)) == Point2f
201+
@test to_pointf32(p) == Point2f(p)
202202

203203
p = Point(0.0, 1.0, 2.0)
204-
@test typeof(Pointf(p)) == Point3f
205-
@test Pointf(p) == Point3f(p)
204+
@test typeof(to_pointf32(p)) == Point3f
205+
@test to_pointf32(p) == Point3f(p)
206206

207-
@test Pointf(0.0, 0.0, 0.0) isa Point3f
208-
@test Pointf(1.0, 1.0) isa Point2f
207+
@test to_pointf32(0.0, 0.0, 0.0) isa Point3f
208+
@test to_pointf32(1.0, 1.0) isa Point2f
209209

210-
@test Pointf((0.0, 0.0, 0.0 )) isa Point3f
211-
@test Pointf((1.0, 1.0)) isa Point2f
210+
@test to_pointf32((0.0, 0.0, 0.0 )) isa Point3f
211+
@test to_pointf32((1.0, 1.0)) isa Point2f
212212

213-
@test Pointf([0.0, 0.0, 0.0]) isa Point3f
214-
@test Pointf([1.0, 1.0]) isa Point2f
213+
@test to_pointf32([0.0, 0.0, 0.0]) isa Point3f
214+
@test to_pointf32([1.0, 1.0]) isa Point2f
215215

216-
@test Pointf(SA[0.0, 0.0, 0.0]) isa Point3f
217-
@test Pointf(SA[1.0, 1.0]) isa Point2f
216+
@test to_pointf32(SA[0.0, 0.0, 0.0]) isa Point3f
217+
@test to_pointf32(SA[1.0, 1.0]) isa Point2f
218218

219219
g = complete_graph(3)
220220
pos1 = [(0,0),
@@ -226,9 +226,9 @@ end
226226
pos3 = [SA[0,0],
227227
SA[1,1],
228228
SA[0,1]]
229-
@test isconcretetype(typeof(Pointf.(pos1)))
230-
@test isconcretetype(typeof(Pointf.(pos2)))
231-
@test isconcretetype(typeof(Pointf.(pos3)))
229+
@test isconcretetype(typeof(to_pointf32.(pos1)))
230+
@test isconcretetype(typeof(to_pointf32.(pos2)))
231+
@test isconcretetype(typeof(to_pointf32.(pos3)))
232232
graphplot(g; layout=(x)->pos1)
233233
graphplot(g; layout=(x)->pos2)
234234
graphplot(g; layout=(x)->pos3)
@@ -278,9 +278,12 @@ end
278278
@test ax isa LScene
279279
end
280280

281-
@testset "test empty endge Blot" begin
281+
@testset "test empty edge plot" begin
282282
GraphMakie.edgeplot(GraphMakie.Line{Point{2, Float32}}[])
283283
GraphMakie.edgeplot(GraphMakie.AbstractPath{Point{2, Float32}}[])
284+
285+
# test empty edge color
286+
graphplot(SimpleGraph(2); edge_color=Symbol[])
284287
end
285288

286289
include("referencetests.jl")

0 commit comments

Comments
 (0)