Skip to content

Commit ff9176e

Browse files
committed
Use sources arg in Projects for test and doc
1 parent d8f13e5 commit ff9176e

3 files changed

Lines changed: 52 additions & 44 deletions

File tree

docs/Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
MultiScaleTreeGraph = "dd4a991b-8a45-4075-bede-262ee62d5583"
4+
5+
[sources]
6+
MultiScaleTreeGraph = { path = ".." }

src/compute_MTG/ancestors.jl

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
@inline function _ancestors_values_no_filter_ignore!(node, key::Symbol, val, recursivity_level, ignore_nothing::Bool)
2+
current = node
3+
remaining = recursivity_level
4+
5+
while !isroot(current) && remaining != 0
6+
parent_ = parent(current)
7+
v = unsafe_getindex(parent_, key)
8+
ignore_nothing && v === nothing || push!(val, v)
9+
remaining -= 1
10+
current = parent_
11+
end
12+
return val
13+
end
14+
15+
@inline function _ancestors_values_no_filter_collect(node, key::Symbol, recursivity_level, ignore_nothing::Bool)
16+
vals = Any[]
17+
current = node
18+
remaining = recursivity_level
19+
20+
while !isroot(current) && remaining != 0
21+
parent_ = parent(current)
22+
v = unsafe_getindex(parent_, key)
23+
ignore_nothing && v === nothing || push!(vals, v)
24+
remaining -= 1
25+
current = parent_
26+
end
27+
return vals
28+
end
29+
30+
@inline function _typed_from_any(vals::Vector{Any}, fallback_type=Any)
31+
if isempty(vals)
32+
return Array{fallback_type,1}()
33+
end
34+
T = typeof(vals[1])
35+
@inbounds for i in 2:length(vals)
36+
T = Union{T,typeof(vals[i])}
37+
end
38+
out = Vector{T}(undef, length(vals))
39+
@inbounds for i in eachindex(vals)
40+
out[i] = vals[i]
41+
end
42+
return out
43+
end
44+
45+
146
"""
247
ancestors(node::Node,key,<keyword arguments>)
348
ancestors(node::Node,<keyword arguments>)
@@ -49,50 +94,6 @@ ancestors(leaf_node, :Length, symbol = :Internode)
4994
ancestors(leaf_node, :Length, symbol = (:Axis,:Internode))
5095
```
5196
"""
52-
@inline function _ancestors_values_no_filter_ignore!(node, key::Symbol, val, recursivity_level, ignore_nothing::Bool)
53-
current = node
54-
remaining = recursivity_level
55-
56-
while !isroot(current) && remaining != 0
57-
parent_ = parent(current)
58-
v = unsafe_getindex(parent_, key)
59-
ignore_nothing && v === nothing || push!(val, v)
60-
remaining -= 1
61-
current = parent_
62-
end
63-
return val
64-
end
65-
66-
@inline function _ancestors_values_no_filter_collect(node, key::Symbol, recursivity_level, ignore_nothing::Bool)
67-
vals = Any[]
68-
current = node
69-
remaining = recursivity_level
70-
71-
while !isroot(current) && remaining != 0
72-
parent_ = parent(current)
73-
v = unsafe_getindex(parent_, key)
74-
ignore_nothing && v === nothing || push!(vals, v)
75-
remaining -= 1
76-
current = parent_
77-
end
78-
return vals
79-
end
80-
81-
@inline function _typed_from_any(vals::Vector{Any}, fallback_type=Any)
82-
if isempty(vals)
83-
return Array{fallback_type,1}()
84-
end
85-
T = typeof(vals[1])
86-
@inbounds for i in 2:length(vals)
87-
T = Union{T,typeof(vals[i])}
88-
end
89-
out = Vector{T}(undef, length(vals))
90-
@inbounds for i in eachindex(vals)
91-
out[i] = vals[i]
92-
end
93-
return out
94-
end
95-
9697
function ancestors(
9798
node, key;
9899
scale=nothing,

test/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
33
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
44
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
55
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
6+
MultiScaleTreeGraph = "dd4a991b-8a45-4075-bede-262ee62d5583"
67
MutableNamedTuples = "af6c499f-54b4-48cc-bbd2-094bba7533c7"
78
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
89
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
10+
11+
[sources]
12+
MultiScaleTreeGraph = { path = ".." }

0 commit comments

Comments
 (0)