From 5c688eb8189ef0d4828620ce4165fa85e007a418 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Fri, 10 Jan 2025 23:13:56 +0530 Subject: [PATCH] fixup! fix: fix hashconsing not comparing metadata of symbolics inside metadata --- src/types.jl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/types.jl b/src/types.jl index aec52fb1..a71fefa8 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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 @@ -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