blegat / HybridSystems.jl

Compare 138dec4 ... +12 ... 795aee1

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 1 of 13 files from the diff.

@@ -1,12 +1,12 @@
Loading
1 1
import MappedArrays
2 -
import LightGraphs
2 +
import Graphs
3 3
4 4
using MappedArrays: ReadonlyMappedArray
5 5
6 6
"""
7 7
    LightAutomaton{GT, ET} <: AbstractAutomaton
8 8
9 -
A hybrid automaton that uses the `LightGraphs` backend. See the constructor
9 +
A hybrid automaton that uses the `Graphs` backend. See the constructor
10 10
[`LightAutomaton(::Int)`](@ref).
11 11
12 12
###  Fields
@@ -37,21 +37,21 @@
Loading
37 37
julia> a = LightAutomaton(2);
38 38
39 39
julia> add_transition!(a, 1, 1, 1) # Add a self-loop of label 1 for state 1
40 -
HybridSystems.LightTransition{LightGraphs.SimpleGraphs.SimpleEdge{Int64}}(Edge 1 => 1, 1)
40 +
HybridSystems.LightTransition{Graphs.SimpleGraphs.SimpleEdge{Int64}}(Edge 1 => 1, 1)
41 41
42 42
julia> add_transition!(a, 2, 2, 1) # Add a self-loop of label 1 for state 2
43 -
HybridSystems.LightTransition{LightGraphs.SimpleGraphs.SimpleEdge{Int64}}(Edge 2 => 2, 2)
43 +
HybridSystems.LightTransition{Graphs.SimpleGraphs.SimpleEdge{Int64}}(Edge 2 => 2, 2)
44 44
45 45
julia> add_transition!(a, 1, 2, 2) # Add a transition from state 1 to state 2 with label 2
46 -
HybridSystems.LightTransition{LightGraphs.SimpleGraphs.SimpleEdge{Int64}}(Edge 1 => 2, 3)
46 +
HybridSystems.LightTransition{Graphs.SimpleGraphs.SimpleEdge{Int64}}(Edge 1 => 2, 3)
47 47
48 48
julia> add_transition!(a, 2, 1, 3) # Add a transition from state 2 to state 1 with label 3
49 -
HybridSystems.LightTransition{LightGraphs.SimpleGraphs.SimpleEdge{Int64}}(Edge 2 => 1, 4)
49 +
HybridSystems.LightTransition{Graphs.SimpleGraphs.SimpleEdge{Int64}}(Edge 2 => 1, 4)
50 50
```
51 51
"""
52 52
function LightAutomaton(n::Int)
53 -
    G = LightGraphs.DiGraph(n)
54 -
    Σ = Dict{LightGraphs.edgetype(G), Dict{Int, Int}}()
53 +
    G = Graphs.DiGraph(n)
54 +
    Σ = Dict{Graphs.edgetype(G), Dict{Int, Int}}()
55 55
    LightAutomaton(G, Σ, 0, 0)
56 56
end
57 57
@@ -101,25 +101,25 @@
Loading
101 101
    return new_id_iterate(tit, edge, edge_state, ids, iterate(ids, id_state))
102 102
end
103 103
104 -
states(A::LightAutomaton) = LightGraphs.vertices(A.G)
105 -
nstates(A::LightAutomaton) = LightGraphs.nv(A.G)
104 +
states(A::LightAutomaton) = Graphs.vertices(A.G)
105 +
nstates(A::LightAutomaton) = Graphs.nv(A.G)
106 106
107 -
transitiontype(A::LightAutomaton) = LightTransition{LightGraphs.edgetype(A.G)}
107 +
transitiontype(A::LightAutomaton) = LightTransition{Graphs.edgetype(A.G)}
108 108
function transitions(A::LightAutomaton)
109 -
    return LightTransitionIterator(A, LightGraphs.edges(A.G))
109 +
    return LightTransitionIterator(A, Graphs.edges(A.G))
110 110
end
111 111
ntransitions(A::LightAutomaton) = A.nt
112 112
113 113
function edge_object(A::LightAutomaton, q, r)
114 114
    @assert 1 <= q <= nstates(A)
115 115
    @assert 1 <= r <= nstates(A)
116 -
    return LightGraphs.Edge(q, r)
116 +
    return Graphs.Edge(q, r)
117 117
end
118 118
119 119
# return transitions with source `q` and target `r`
120 120
function transitions(A::LightAutomaton{GT, ET}, q, r) where {GT, ET}
121 121
    e = edge_object(A, q, r)
122 -
    LightTransitionIterator(A, Fill(e, LightGraphs.has_edge(A.G, e) ? 1 : 0))
122 +
    LightTransitionIterator(A, Fill(e, Graphs.has_edge(A.G, e) ? 1 : 0))
123 123
end
124 124
125 125
function add_transition!(A::LightAutomaton, q, r, σ)
@@ -134,23 +134,23 @@
Loading
134 134
    end
135 135
    ids[id] = σ
136 136
    if new_ids
137 -
        LightGraphs.add_edge!(A.G, edge)
137 +
        Graphs.add_edge!(A.G, edge)
138 138
        A.Σ[edge] = ids
139 139
    end
140 140
    return LightTransition(edge, id)
141 141
end
142 142
function has_transition(A::LightAutomaton, q, r)
143 -
    return LightGraphs.has_edge(A.G, edge_object(A, q, r))
143 +
    return Graphs.has_edge(A.G, edge_object(A, q, r))
144 144
end
145 145
function has_transition(A::LightAutomaton, t::LightTransition)
146 -
    return LightGraphs.has_edge(A.G, t.edge) && haskey(A.Σ[t.edge], t.id)
146 +
    return Graphs.has_edge(A.G, t.edge) && haskey(A.Σ[t.edge], t.id)
147 147
end
148 148
function rem_transition!(A::LightAutomaton, t::LightTransition)
149 149
    ids = A.Σ[t.edge]
150 150
    delete!(ids, t.id)
151 151
    A.nt -= 1
152 152
    if isempty(ids)
153 -
        LightGraphs.rem_edge!(A.G, t.edge)
153 +
        Graphs.rem_edge!(A.G, t.edge)
154 154
        delete!(A.Σ, t.edge)
155 155
    end
156 156
end
@@ -163,11 +163,11 @@
Loading
163 163
    for t in collect(out_transitions(A, st))
164 164
        rem_transition!(A, t)
165 165
    end
166 -
    return LightGraphs.rem_vertex!(A.G, st)
166 +
    return Graphs.rem_vertex!(A.G, st)
167 167
end
168 168
169 169
function add_state!(A::LightAutomaton)
170 -
    return LightGraphs.add_vertex!(A.G)
170 +
    return Graphs.add_vertex!(A.G)
171 171
end
172 172
173 173
source(::LightAutomaton, t::LightTransition) = t.edge.src
@@ -176,13 +176,13 @@
Loading
176 176
177 177
function in_transitions(A::LightAutomaton{GT, ET}, s) where {GT, ET}
178 178
    f(src) = edge_object(A, src, s)
179 -
    inneigh = LightGraphs.inneighbors(A.G, s)
179 +
    inneigh = Graphs.inneighbors(A.G, s)
180 180
    edges = ReadonlyMappedArray{ET, 1, typeof(inneigh), typeof(f)}(f, inneigh)
181 181
    LightTransitionIterator(A, edges)
182 182
end
183 183
function out_transitions(A::LightAutomaton{GT, ET}, s) where {GT, ET}
184 184
    f(dst) = edge_object(A, s, dst)
185 -
    outneigh = LightGraphs.outneighbors(A.G, s)
185 +
    outneigh = Graphs.outneighbors(A.G, s)
186 186
    edges = ReadonlyMappedArray{ET, 1, typeof(outneigh), typeof(f)}(f, outneigh)
187 187
    LightTransitionIterator(A, edges)
188 188
end

Learn more Showing 6 files with coverage changes found.

Changes in src/light.jl
+15
Loading file...
Changes in src/onestate.jl
+9
Loading file...
Changes in src/switchedsystems.jl
+5
Loading file...
Changes in src/automata.jl
+2
Loading file...
Changes in src/paths.jl
-2
+17
Loading file...
Changes in src/HybridSystems.jl
-1
+1
Loading file...
Files Coverage
src +2.27% 94.94%
Project Totals (7 files) 94.94%
Loading