From 0a1c652fc84b4bf4755e4820932e8787c4709c8b Mon Sep 17 00:00:00 2001 From: davidschlegel Date: Mon, 14 Nov 2022 17:09:40 +0100 Subject: [PATCH 1/6] change calls of metadata field to metadata method --- src/arrays.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arrays.jl b/src/arrays.jl index 4fe8fa50d..19d9afb9d 100644 --- a/src/arrays.jl +++ b/src/arrays.jl @@ -88,7 +88,7 @@ function operation(a::ArrayOp) end function arguments(a::ArrayOp) isnothing(a.term) ? [a.output_idx, a.expr, a.reduce, - a.term, a.shape, a.ranges, a.metadata] : + a.term, a.shape, a.ranges, metadata(a)] : arguments(a.term) end @@ -717,7 +717,7 @@ function scalarize(arr) elseif arr isa Num wrap(scalarize(unwrap(arr))) elseif istree(arr) && symtype(arr) <: Number - t = similarterm(arr, operation(arr), map(scalarize, arguments(arr)), symtype(arr), metadata=arr.metadata) + t = similarterm(arr, operation(arr), map(scalarize, arguments(arr)), symtype(arr), metadata=metadata(arr)) istree(t) ? scalarize_op(operation(t), t) : t else arr From 13a139358d7e2b9956d88d5fca3701c194551f86 Mon Sep 17 00:00:00 2001 From: davidschlegel Date: Mon, 14 Nov 2022 17:11:25 +0100 Subject: [PATCH 2/6] Add function metadata for type ComplexTerm --- src/complex.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/complex.jl b/src/complex.jl index f7b86a829..7aeccbe79 100644 --- a/src/complex.jl +++ b/src/complex.jl @@ -21,6 +21,7 @@ TermInterface.symtype(a::ComplexTerm{T}) where T = Complex{T} TermInterface.istree(a::ComplexTerm) = true TermInterface.operation(a::ComplexTerm{T}) where T = Complex{T} TermInterface.arguments(a::ComplexTerm) = [a.re, a.im] +TermInterface.metadata(a::ComplexTerm) = a.re.metadata function TermInterface.similarterm(t::ComplexTerm, f, args, symtype; metadata=nothing, exprhead=exprhead(t)) if f <: Complex From 65853e614ad40753d17069cc2c4ed85e0aa847a7 Mon Sep 17 00:00:00 2001 From: davidschlegel Date: Wed, 11 Jan 2023 16:08:48 +0100 Subject: [PATCH 3/6] add tests --- test/complex.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/complex.jl b/test/complex.jl index 2a24d3304..8ef2b88a0 100644 --- a/test/complex.jl +++ b/test/complex.jl @@ -26,3 +26,9 @@ end @test repr(z) == "z" @test repr(a + b*im) == "a + b*im" end + +@testset "metadata" begin + @test_nowarn substitute(z+1.0im, z=>1.0im) + @test metadata(z) == z.im.metadata + @test metadata(z) == z.re.metadata +end From 98cf526f4871f3f9cd920481cba0cffa7c7b04b8 Mon Sep 17 00:00:00 2001 From: davidschlegel Date: Wed, 11 Jan 2023 16:10:22 +0100 Subject: [PATCH 4/6] fix tests --- test/complex.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/complex.jl b/test/complex.jl index 8ef2b88a0..e367dd52f 100644 --- a/test/complex.jl +++ b/test/complex.jl @@ -28,7 +28,8 @@ end end @testset "metadata" begin - @test_nowarn substitute(z+1.0im, z=>1.0im) - @test metadata(z) == z.im.metadata - @test metadata(z) == z.re.metadata + z1 = z+1.0 + @test_nowarn substitute(z1, z=>1.0im) + @test metadata(z1) == z1.im.metadata + @test metadata(z1) == z1.re.metadata end From f9d2260bcc6a056b8aa4924cd9717b51de6b6c9a Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Mon, 20 Mar 2023 14:48:54 -0400 Subject: [PATCH 5/6] import metadata from SU --- src/Symbolics.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symbolics.jl b/src/Symbolics.jl index 78242bcbd..78b1c72dc 100644 --- a/src/Symbolics.jl +++ b/src/Symbolics.jl @@ -16,7 +16,7 @@ using Setfield import DomainSets: Domain @reexport using SymbolicUtils -import SymbolicUtils: similarterm, istree, operation, arguments, symtype +import SymbolicUtils: similarterm, istree, operation, arguments, symtype, metadata import SymbolicUtils: Term, Add, Mul, Pow, Sym, Div, BasicSymbolic, FnType, @rule, Rewriters, substitute, From a5944db671727f51f56fa84b5cf7234956140f50 Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Mon, 24 Apr 2023 11:23:05 -0400 Subject: [PATCH 6/6] import metadata --- test/complex.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/complex.jl b/test/complex.jl index e367dd52f..64696be5c 100644 --- a/test/complex.jl +++ b/test/complex.jl @@ -1,4 +1,5 @@ using Symbolics, Test +using SymbolicUtils: metadata @variables a b::Real z::Complex (Z::Complex)[1:10]