Skip to content

Commit

Permalink
fixup! fix: fix hashconsing not comparing metadata of symbolics insid…
Browse files Browse the repository at this point in the history
…e metadata
  • Loading branch information
AayushSabharwal committed Jan 10, 2025
1 parent d2285a0 commit 5c688eb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ Compare the metadata of two `BasicSymbolic`s to ensure it is equal, recursively
`isequal_with_metadata` to ensure symbolic variables in the metadata also have equal
metadata.
"""
function isequal_with_metadata(a::Union{AbstractDict, Tuple, NamedTuple}, b::Union{AbstractDict, Tuple, NamedTuple})
function isequal_with_metadata(a::Union{AbstractDict, NamedTuple}, b::Union{AbstractDict, NamedTuple})
typeof(a) == typeof(b) || return false
length(a) == length(b) || return false

Expand Down Expand Up @@ -337,12 +337,14 @@ isequal_with_metadata(a::AbstractRange, b::AbstractRange) = isequal(a, b)
"""
$(TYPEDSIGNATURES)
Check if two arrays are equal by calling `isequal_with_metadata` on each element. This
is to ensure true equality of any symbolic elements, if present.
Check if two arrays/tuples are equal by calling `isequal_with_metadata` on each element.
This is to ensure true equality of any symbolic elements, if present.
"""
function isequal_with_metadata(a::AbstractArray, b::AbstractArray)
function isequal_with_metadata(a::Union{AbstractArray, Tuple}, b::Union{AbstractArray, Tuple})
typeof(a) == typeof(b) || return false
size(a) == size(b) || return false
if a isa AbstractArray
size(a) == size(b) || return false
end # otherwise they're tuples and type equality also checks length equality
for (x, y) in zip(a, b)
isequal_with_metadata(x, y) || return false
end
Expand Down

0 comments on commit 5c688eb

Please sign in to comment.