@@ -5,6 +5,20 @@ using ModelingToolkit.BipartiteGraphs: Label, BipartiteAdjacencyList, unassigned
5
5
using ModelingToolkit. SystemStructures: SystemStructure, MatchedSystemStructure,
6
6
SystemStructurePrintMatrix, HighlightInt
7
7
8
+ """
9
+ A utility struct for displaying the difference between two HighlightInts.
10
+
11
+ # Example
12
+ ```julia
13
+ using ModelingToolkit, DeepDiffs
14
+
15
+ old_i = HighlightInt(1, :default, true)
16
+ new_i = HighlightInt(2, :default, false)
17
+ diff = HighlightIntDiff(new_i, old_i)
18
+
19
+ show(diff)
20
+ ```
21
+ """
8
22
struct HighlightIntDiff
9
23
new:: HighlightInt
10
24
old:: HighlightInt
@@ -26,6 +40,21 @@ function Base.show(io::IO, d::HighlightIntDiff)
26
40
(d. new. match || d. old. match) && printstyled (io, " )" , color = p_color)
27
41
end
28
42
43
+ """
44
+ A utility struct for displaying the difference between two
45
+ BipartiteAdjacencyList's.
46
+
47
+ # Example
48
+ ```julia
49
+ using ModelingToolkit, DeepDiffs
50
+
51
+ old = BipartiteAdjacencyList(...)
52
+ new = BipartiteAdjacencyList(...)
53
+ diff = BipartiteAdjacencyListDiff(new, old)
54
+
55
+ show(diff)
56
+ ```
57
+ """
29
58
struct BipartiteAdjacencyListDiff
30
59
new:: BipartiteAdjacencyList
31
60
old:: BipartiteAdjacencyList
@@ -77,6 +106,21 @@ function Base.show(io::IO, l::BipartiteAdjacencyListDiff)
77
106
end
78
107
end
79
108
109
+ """
110
+ A utility struct for displaying the difference between two Labels
111
+ in git-style red/green highlighting.
112
+
113
+ # Example
114
+ ```julia
115
+ using ModelingToolkit, DeepDiffs
116
+
117
+ old = Label("before")
118
+ new = Label("after")
119
+ diff = LabelDiff(new, old)
120
+
121
+ show(diff)
122
+ ```
123
+ """
80
124
struct LabelDiff
81
125
new:: Label
82
126
old:: Label
@@ -91,19 +135,27 @@ function Base.show(io::IO, l::LabelDiff)
91
135
end
92
136
end
93
137
138
+ """
139
+ A utility struct for displaying the difference between two
140
+ (Matched)SystemStructure's in git-style red/green highlighting.
141
+
142
+ # Example
143
+ ```julia
144
+ using ModelingToolkit, DeepDiffs
145
+
146
+ old = SystemStructurePrintMatrix(...)
147
+ new = SystemStructurePrintMatrix(...)
148
+ diff = SystemStructureDiffPrintMatrix(new, old)
149
+
150
+ show(diff)
151
+ ```
152
+ """
94
153
struct SystemStructureDiffPrintMatrix < :
95
154
AbstractMatrix{Union{LabelDiff, BipartiteAdjacencyListDiff}}
96
155
new:: SystemStructurePrintMatrix
97
156
old:: SystemStructurePrintMatrix
98
157
end
99
158
100
- function DeepDiffs. deepdiff (old:: Union{MatchedSystemStructure, SystemStructure} ,
101
- new:: Union{MatchedSystemStructure, SystemStructure} )
102
- new_sspm = SystemStructurePrintMatrix (new)
103
- old_sspm = SystemStructurePrintMatrix (old)
104
- Base. print_matrix (stdout , SystemStructureDiffPrintMatrix (new_sspm, old_sspm))
105
- end
106
-
107
159
function Base. size (ssdpm:: SystemStructureDiffPrintMatrix )
108
160
max .(Base. size (ssdpm. new), Base. size (ssdpm. old))
109
161
end
@@ -123,4 +175,11 @@ function Base.getindex(ssdpm::SystemStructureDiffPrintMatrix, i::Integer, j::Int
123
175
end
124
176
end
125
177
178
+ function DeepDiffs. deepdiff (old:: Union{MatchedSystemStructure, SystemStructure} ,
179
+ new:: Union{MatchedSystemStructure, SystemStructure} )
180
+ new_sspm = SystemStructurePrintMatrix (new)
181
+ old_sspm = SystemStructurePrintMatrix (old)
182
+ Base. print_matrix (stdout , SystemStructureDiffPrintMatrix (new_sspm, old_sspm))
183
+ end
184
+
126
185
end # module
0 commit comments