From aa50d3206d169ffa9f673ce7b8096d2ac2c77cda Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Tue, 21 Nov 2023 11:09:39 +0530 Subject: [PATCH] refactor: implement new `hasname` function from SII --- src/variable.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/variable.jl b/src/variable.jl index 4d09212ab..b2b3d3880 100644 --- a/src/variable.jl +++ b/src/variable.jl @@ -409,6 +409,12 @@ getsource(x, val=_fail) = getmetadata(unwrap(x), VariableSource, val) SymbolicIndexingInterface.symbolic_type(::Type{<:Symbolics.Num}) = ScalarSymbolic() SymbolicIndexingInterface.symbolic_type(::Type{<:Symbolics.Arr}) = ArraySymbolic() +SymbolicIndexingInterface.hasname(x::Union{Num,Arr}) = hasname(unwrap(x)) + +function SymbolicIndexingInterface.hasname(x::Symbolic) + issym(x) || !istree(x) || istree(x) && (issym(operation(x)) || operation(x) == getindex) +end + SymbolicIndexingInterface.getname(x, val=_fail) = _getname(unwrap(x), val) function getparent(x, val=_fail)