Skip to content

Commit 32cc70d

Browse files
refactor: remove old == and hash implementation for System
1 parent 9201dbf commit 32cc70d

File tree

1 file changed

+0
-91
lines changed

1 file changed

+0
-91
lines changed

src/systems/system.jl

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -785,97 +785,6 @@ function ignored_connections_equal(sys1::System, sys2::System)
785785
return _eq_unordered(ic1[1], ic2[1]) && _eq_unordered(ic1[2], ic2[2])
786786
end
787787

788-
function Base.:(==)(sys1::System, sys2::System)
789-
sys1 === sys2 && return true
790-
iv1 = get_iv(sys1)
791-
iv2 = get_iv(sys2)
792-
isequal(iv1, iv2) &&
793-
isequal(nameof(sys1), nameof(sys2)) &&
794-
_eq_unordered(get_eqs(sys1), get_eqs(sys2)) &&
795-
noise_equations_equal(sys1, sys2) &&
796-
_eq_unordered(get_jumps(sys1), get_jumps(sys2)) &&
797-
_eq_unordered(get_constraints(sys1), get_constraints(sys2)) &&
798-
_eq_unordered(get_costs(sys1), get_costs(sys2)) &&
799-
isequal(get_consolidate(sys1), get_consolidate(sys2)) &&
800-
_eq_unordered(get_unknowns(sys1), get_unknowns(sys2)) &&
801-
_eq_unordered(get_ps(sys1), get_ps(sys2)) &&
802-
_eq_unordered(get_brownians(sys1), get_brownians(sys2)) &&
803-
_eq_unordered(get_observed(sys1), get_observed(sys2)) &&
804-
_eq_unordered(get_parameter_dependencies(sys1), get_parameter_dependencies(sys2)) &&
805-
isequal(get_description(sys1), get_description(sys2)) &&
806-
isequal(get_defaults(sys1), get_defaults(sys2)) &&
807-
isequal(get_guesses(sys1), get_guesses(sys2)) &&
808-
_eq_unordered(get_initialization_eqs(sys1), get_initialization_eqs(sys2)) &&
809-
_eq_unordered(get_continuous_events(sys1), get_continuous_events(sys2)) &&
810-
_eq_unordered(get_discrete_events(sys1), get_discrete_events(sys2)) &&
811-
isequal(get_connector_type(sys1), get_connector_type(sys2)) &&
812-
isequal(get_assertions(sys1), get_assertions(sys2)) &&
813-
isequal(get_metadata(sys1), get_metadata(sys2)) &&
814-
isequal(get_gui_metadata(sys1), get_gui_metadata(sys2)) &&
815-
get_is_dde(sys1) == get_is_dde(sys2) &&
816-
_eq_unordered(get_tstops(sys1), get_tstops(sys2)) &&
817-
# not comparing tearing states because checking if they're equal up to ordering
818-
# is difficult
819-
getfield(sys1, :namespacing) == getfield(sys2, :namespacing) &&
820-
getfield(sys1, :complete) == getfield(sys2, :complete) &&
821-
ignored_connections_equal(sys1, sys2) &&
822-
get_parent(sys1) == get_parent(sys2) &&
823-
get_isscheduled(sys1) == get_isscheduled(sys2) &&
824-
all(s1 == s2 for (s1, s2) in zip(get_systems(sys1), get_systems(sys2)))
825-
end
826-
827-
function Base.hash(sys::System, h::UInt)
828-
h = hash(nameof(sys), h)
829-
h = hash(get_iv(sys), h)
830-
# be considerate of things compared using `_eq_unordered` in `==`
831-
eqs = get_eqs(sys)
832-
eq_sortperm = sortperm(eqs; by = string)
833-
h = hash(@view(eqs[eq_sortperm]), h)
834-
neqs = get_noise_eqs(sys)
835-
if neqs === nothing
836-
h = hash(nothing, h)
837-
elseif neqs isa Vector
838-
h = hash(@view(neqs[eq_sortperm]), h)
839-
else
840-
h = hash(@view(neqs[eq_sortperm, :]), h)
841-
end
842-
h = hash(Set(get_jumps(sys)), h)
843-
h = hash(Set(get_constraints(sys)), h)
844-
h = hash(Set(get_costs(sys)), h)
845-
h = hash(get_consolidate(sys), h)
846-
h = hash(Set(get_unknowns(sys)), h)
847-
h = hash(Set(get_ps(sys)), h)
848-
h = hash(Set(get_brownians(sys)), h)
849-
h = hash(Set(get_observed(sys)), h)
850-
h = hash(Set(get_parameter_dependencies(sys)), h)
851-
h = hash(get_description(sys), h)
852-
h = hash(get_defaults(sys), h)
853-
h = hash(get_guesses(sys), h)
854-
h = hash(Set(get_initialization_eqs(sys)), h)
855-
h = hash(Set(get_continuous_events(sys)), h)
856-
h = hash(Set(get_discrete_events(sys)), h)
857-
h = hash(get_connector_type(sys), h)
858-
h = hash(get_assertions(sys), h)
859-
h = hash(get_metadata(sys), h)
860-
h = hash(get_gui_metadata(sys), h)
861-
h = hash(get_is_dde(sys), h)
862-
h = hash(Set(get_tstops(sys)), h)
863-
h = hash(Set(getfield(sys, :namespacing)), h)
864-
h = hash(Set(getfield(sys, :complete)), h)
865-
ics = get_ignored_connections(sys)
866-
if ics === nothing
867-
h = hash(ics, h)
868-
else
869-
h = hash(Set(ics[1]), hash(Set(ics[2]), h), h)
870-
end
871-
h = hash(get_parent(sys), h)
872-
h = hash(get_isscheduled(sys), h)
873-
for s in get_systems(sys)
874-
h = hash(s, h)
875-
end
876-
return h
877-
end
878-
879788
"""
880789
$(TYPEDSIGNATURES)
881790

0 commit comments

Comments
 (0)