From 0a1c652fc84b4bf4755e4820932e8787c4709c8b Mon Sep 17 00:00:00 2001 From: davidschlegel Date: Mon, 14 Nov 2022 17:09:40 +0100 Subject: [PATCH 01/13] 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 02/13] 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 03/13] 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 04/13] 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 05/13] 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 06/13] 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] From d4d2c1023a67df866958e6929ee3d6829c52479d Mon Sep 17 00:00:00 2001 From: Whyborn Date: Fri, 7 Jul 2023 22:09:43 +1000 Subject: [PATCH 07/13] Calling coeff on an expression with symbolic division now throws a more informative DomainError instead of an unintentional StackOverflowError --- src/utils.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils.jl b/src/utils.jl index 29424c7d8..94b9433a7 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -323,6 +323,8 @@ function coeff(p, sym=nothing) else @views prod(Iterators.flatten((coeffs[findall(!iszero, coeffs)], args[findall(iszero, coeffs)]))) end + elseif isdiv(p) + throw(DomainError(p, "coeff on expressions with division is not yet implemented.")) else p isa Number && return sym === nothing ? p : 0 p isa Symbolic && return coeff(p, sym) From b668ceff6993ab8886a0128d5d527f89dd392f3f Mon Sep 17 00:00:00 2001 From: Raphael Chinchilla Date: Mon, 10 Jul 2023 16:46:16 -0700 Subject: [PATCH 08/13] Fixed minor bug in src/build_function where the keyword conv was not used --- src/build_function.jl | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/build_function.jl b/src/build_function.jl index 06a2c6e40..1c4606c55 100644 --- a/src/build_function.jl +++ b/src/build_function.jl @@ -113,11 +113,11 @@ function _build_function(target::JuliaTarget, op, args...; expr = if cse fun = Func(dargs, [], Code.cse(unwrap(op))) (wrap_code !== nothing) && (fun = wrap_code(fun)) - toexpr(fun, states) + conv(fun, states) else fun = Func(dargs, [], op) (wrap_code !== nothing) && (fun = wrap_code(fun)) - toexpr(fun, states) + conv(fun, states) end if expression == Val{true} @@ -142,14 +142,14 @@ function _build_function(target::JuliaTarget, op::Union{Arr, ArrayOp}, args...; Symbol("ˍ₋arg$(x[1])")), enumerate([args...])) expr = if cse - toexpr(Func(dargs, [], Code.cse(unwrap(op))), states) + conv(Func(dargs, [], Code.cse(unwrap(op))), states) else - toexpr(Func(dargs, [], op), states) + conv(Func(dargs, [], op), states) end outsym = Symbol("ˍ₋out") body = inplace_expr(unwrap(op), outsym) - oop_expr = toexpr(Func([outsym, dargs...], [], body), states) + oop_expr = conv(Func([outsym, dargs...], [], body), states) N = length(shape(op)) op = unwrap(op) @@ -161,7 +161,7 @@ function _build_function(target::JuliaTarget, op::Union{Arr, ArrayOp}, args...; $outsym end) |> LiteralExpr end - ip_expr = toexpr(Func(dargs, [], op_body), states) + ip_expr = conv(Func(dargs, [], op_body), states) if expression == Val{true} oop_expr, ip_expr else @@ -194,11 +194,28 @@ function fill_array_with_zero!(x::AbstractArray) end """ + _build_function(target::JuliaTarget, rhss::AbstractArray, args...; + conv=toexpr, + expression = Val{true}, + expression_module = @__MODULE__(), + checkbounds = false, + postprocess_fbody=ex -> ex, + linenumbers = false, + outputidxs=nothing, + skipzeros = false, + force_SA = false, + wrap_code = (nothing, nothing), + fillzeros = skipzeros && !(rhss isa SparseMatrixCSC), + states = LazyState(), + iip_config = (true, true), + parallel=nothing, cse = false, kwargs...) + Build function target: `JuliaTarget` ```julia function _build_function(target::JuliaTarget, rhss, args...; - conv = toexpr, expression = Val{true}, + conv = toexpr, + expression = Val{true}, checkbounds = false, linenumbers = false, headerfun = addheader, outputidxs=nothing, @@ -250,6 +267,7 @@ Special Keyword Arguments: safety with `skipzeros`. """ function _build_function(target::JuliaTarget, rhss::AbstractArray, args...; + conv=toexpr, expression = Val{true}, expression_module = @__MODULE__(), checkbounds = false, @@ -303,10 +321,10 @@ function _build_function(target::JuliaTarget, rhss::AbstractArray, args...; end if expression == Val{true} - return toexpr(oop_expr, states), toexpr(ip_expr, states) + return conv(oop_expr, states), conv(ip_expr, states) else - return _build_and_inject_function(expression_module, toexpr(oop_expr, states)), - _build_and_inject_function(expression_module, toexpr(ip_expr, states)) + return _build_and_inject_function(expression_module, conv(oop_expr, states)), + _build_and_inject_function(expression_module, conv(ip_expr, states)) end end From bdffaa0b6090ec4b12355af818697d0a4e630071 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 7 Aug 2023 08:40:44 +0200 Subject: [PATCH 09/13] Create dependabot.yml --- .github/dependabot.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..d60f0707f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "monthly" From 38846059f65267a7d12f05c082207c14a952e1a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 12:08:22 +0000 Subject: [PATCH 10/13] Bump codecov/codecov-action from 1 to 3 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 1 to 3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v1...v3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc1a6f479..401ec487a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,6 @@ jobs: env: GROUP: ${{ matrix.group }} - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v3 with: file: lcov.info From 63e416f55dd6206dcea73716316894c7fa366593 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 12:08:27 +0000 Subject: [PATCH 11/13] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/Documentation.yml | 2 +- .github/workflows/Downstream.yml | 4 ++-- .github/workflows/ci.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml index e47f93896..09a92853a 100644 --- a/.github/workflows/Documentation.yml +++ b/.github/workflows/Documentation.yml @@ -11,7 +11,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@latest with: version: '1' diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index 196ed216b..f09362284 100644 --- a/.github/workflows/Downstream.yml +++ b/.github/workflows/Downstream.yml @@ -25,14 +25,14 @@ jobs: - {user: SciML, repo: ModelOrderReduction.jl, group: All} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.julia-version }} arch: x64 - uses: julia-actions/julia-buildpkg@latest - name: Clone Downstream - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: ${{ matrix.package.user }}/${{ matrix.package.repo }} path: downstream diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc1a6f479..e894be1f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - '1' - '1.6' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - run: | From a8eaf33aaf0f5b2cf1c206a26aae78c983caf1d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 12:08:28 +0000 Subject: [PATCH 12/13] Bump actions/cache from 1 to 3 Bumps [actions/cache](https://github.com/actions/cache) from 1 to 3. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v1...v3) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc1a6f479..98acd8166 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - uses: julia-actions/setup-julia@v1 with: version: ${{ matrix.version }} - - uses: actions/cache@v1 + - uses: actions/cache@v3 env: cache-name: cache-artifacts with: From 60d26bb92565b9f54d5f95d261d2c38aedc9bccc Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Sun, 3 Sep 2023 13:24:37 -0400 Subject: [PATCH 13/13] fix ComplexTerm metadata test which was never tested --- test/complex.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/complex.jl b/test/complex.jl index 64696be5c..47a10b9c6 100644 --- a/test/complex.jl +++ b/test/complex.jl @@ -1,5 +1,6 @@ using Symbolics, Test using SymbolicUtils: metadata +using Symbolics: unwrap @variables a b::Real z::Complex (Z::Complex)[1:10] @@ -31,6 +32,6 @@ end @testset "metadata" begin z1 = z+1.0 @test_nowarn substitute(z1, z=>1.0im) - @test metadata(z1) == z1.im.metadata - @test metadata(z1) == z1.re.metadata + @test metadata(z1) == unwrap(z1.im).metadata + @test metadata(z1) == unwrap(z1.re).metadata end