Skip to content

Commit 1828c9c

Browse files
committed
Update docstrings
1 parent a8f419a commit 1828c9c

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

src/analysis/lattice.jl

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,22 @@ Compiler.has_extended_unionsplit(::EqStructureLattice) = true
4141

4242
############################## Linearity #######################################
4343

44-
# XXX: update docstring
4544
"""
46-
struct Linearity
45+
Base.@kwdef struct Linearity
46+
time_dependent::Bool = true
47+
state_dependent::Bool = true
4748
nonlinear::Bool = true
4849
end
4950
50-
This struct expresses linearity information: linear or nonlinear.
51+
Together with `Float64` values in `Incidence`, this struct expresses linearity information:
52+
- Linear, coefficient is a known constant (a `Float64` value).
53+
- Linear, coefficient is an unknown constant (`linear`).
54+
- Linear, coefficient is unknown with a known state or time dependence (`linear_state_dependent`, `linear_time_dependent`).
55+
- Linear, coefficient is unknown with both state and time dependence (`linear_time_and_state_dependent`).
56+
- Nonlinear (`nonlinear` - always taints state and time dependence currently).
5157
52-
Nonlinearity is similar to `missing` in that arithmetic with it is
53-
saturating. When used as a coefficient in the Incidence lattice, it indicates
54-
that the corresponding variable does not have a (constant) linear coefficient.
55-
This may either mean that the variable in question has a non-constant linear
56-
coefficient or that the variable is used non-linearly. We do not currently
57-
distinguish the two situations.
58+
A known constant-coefficient contains the highest level of information. `nonlinear` contains the lowest
59+
(and most conservative) level of information, and should be assumed used by default or if uncertain.
5860
"""
5961
Base.@kwdef struct Linearity
6062
time_dependent::Bool = true
@@ -68,10 +70,15 @@ Base.@kwdef struct Linearity
6870
end
6971
end
7072

73+
"The variable is used linearly, with an unknown constant."
7174
const linear = Linearity(time_dependent = false, state_dependent = false, nonlinear = false)
75+
"The variable is used linearly, with an unknown constant that may depend on time."
7276
const linear_time_dependent = Linearity(state_dependent = false, nonlinear = false)
77+
"The variable is used linearly, with an unknown constant that may depend on time and on other states."
7378
const linear_state_dependent = Linearity(time_dependent = false, nonlinear = false)
79+
"The variable is used linearly, with an unknown constant that may depend on time and on other states."
7480
const linear_time_and_state_dependent = Linearity(nonlinear = false)
81+
"The variable is used nonlinearly, with a possible dependence on time and other states."
7582
const nonlinear = Linearity()
7683

7784
join_linearity(a::Linearity, b::Real) = a
@@ -128,6 +135,9 @@ elements are defined by subset inclusion. Note that in particular this implies
128135
that plain `T` lattice elements have unknown incidence and `Const` lattice elements
129136
have no incidence. A lattice element of type `T` that is known to be state-independent
130137
would have lattice element `Incidence(T, {})`.
138+
139+
For convenience, you may want to use the `incidence"..."` string macro to construct an
140+
[`Incidence`](@ref) from its printed representation.
131141
"""
132142
struct Incidence
133143
# Considered additive to `row`. In particular, if the `typ` is Float64,
@@ -253,6 +263,11 @@ function Base.show(io::IO, inc::Incidence)
253263
print(io, ")")
254264
end
255265

266+
"""
267+
incidence"a + f(∝ₛt, u₁)"
268+
269+
Construct an [`Incidence`](@ref) from its printed representation.
270+
"""
256271
macro incidence_str(str) generate_incidence(str) end
257272

258273
function generate_incidence(str::String)

src/analysis/structural.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ function process_ipo_return!(𝕃, ultimate_rt::Incidence, eqclassification, eqk
390390
if v != 0 && varclassification[v] != External && coeff === nonlinear
391391
# nonlinear state variable created within this call tree
392392
get_nonlinrepl()
393-
new_eq_row[v_offset] = nonlinear # XXX: should we refine this to something linear?
393+
new_eq_row[v_offset] = nonlinear # we might want to refine this to something linear
394394
else
395395
new_row[v_offset] = coeff
396396
while v != 0 && v !== nothing

src/transform/tearing/schedule.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ function schedule_incidence!(compact, curval, incT::Incidence, var, line; vars=n
8080
continue
8181
end
8282

83-
# XXX: what to do with the linear parts that have an unknown coefficient?
8483
isa(coeff, Float64) || continue
8584

8685
if lin_var == 0

0 commit comments

Comments
 (0)