Skip to content

Commit

Permalink
Implement hash for AnalysisPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Feb 21, 2024
1 parent 9a47c71 commit 78d4200
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/src/tutorials/custom_component.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ function NonlinearResistor(; name, Ga, Gb, Ve)
pars = @parameters Ga=Ga Gb=Gb Ve=Ve
eqs = [
i ~ ifelse(v < -Ve,
Gb * (v + Ve) - Ga * Ve,
ifelse(v > Ve,
Gb * (v - Ve) + Ga * Ve,
Ga * v))
Gb * (v + Ve) - Ga * Ve,
ifelse(v > Ve,
Gb * (v - Ve) + Ga * Ve,
Ga * v))
]
extend(ODESystem(eqs, t, [], pars; name = name), oneport)
end
Expand Down
6 changes: 6 additions & 0 deletions src/Blocks/analysis_points.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ if Base.isdefined(ModelingToolkit, :isconnection)
end

Base.nameof(ap::AnalysisPoint) = ap.name
function Base.hash(ap::AnalysisPoint, seed::UInt)
h1 = hash(ap.in, seed)
h2 = hash(ap.out, h1)
h3 = hash(ap.name, h2)
h3 (0xd29cdc51aa6562d4 % UInt)

Check warning on line 17 in src/Blocks/analysis_points.jl

View check run for this annotation

Codecov / codecov/patch

src/Blocks/analysis_points.jl#L13-L17

Added lines #L13 - L17 were not covered by tests
end

function ap_var(sys)
if hasproperty(sys, :u)
Expand Down

0 comments on commit 78d4200

Please sign in to comment.