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" 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..cefa73be8 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: | @@ -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: @@ -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 diff --git a/src/Symbolics.jl b/src/Symbolics.jl index d30cd5d6c..1b7e0c066 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, diff --git a/src/arrays.jl b/src/arrays.jl index 218545b97..3c8b7b84e 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 @@ -722,7 +722,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 diff --git a/src/build_function.jl b/src/build_function.jl index 7f117f51b..d97b1a36d 100644 --- a/src/build_function.jl +++ b/src/build_function.jl @@ -344,7 +344,7 @@ function make_array(s::ShardedForm, arr, similarto, cse) funcs = map(slices) do slice Func([], [], _make_array(slice, similarto, cse)) end - SpawnFetch{typeof(s)}(funcs, nothing, vcat) + SpawnFetch{typeof(s)}(funcs, vcat) end function toexpr(p::SpawnFetch{MultithreadedForm}, st) @@ -456,9 +456,7 @@ function recursive_split(leaf_f, s, out, args, outputidxs, xs) recursive_split(leaf_f, s, out, args, first.(slice), last.(slice)) end return Func(args, [], - SpawnFetch{typeof(s)}(fs, - (@inline noop(x...) = nothing)), - []) + SpawnFetch{typeof(s)}(fs, (@inline noop(x...) = nothing)), []) end end @@ -478,8 +476,7 @@ function set_array(s::ShardedForm, out, outputidxs, rhss, checkbounds, skipzeros if outputidxs === nothing outputidxs = collect(eachindex(rhss)) end - all_args = [outvar] - ex = recursive_split(s, outvar, all_args, outputidxs, rhss) do idxs, xs + ex = recursive_split(s, outvar, [], outputidxs, rhss) do idxs, xs Func([], [], _set_array(outvar, idxs, xs, checkbounds, skipzeros, cse), []) diff --git a/src/complex.jl b/src/complex.jl index e063f709f..832d2816a 100644 --- a/src/complex.jl +++ b/src/complex.jl @@ -21,6 +21,7 @@ symtype(a::ComplexTerm{T}) where T = Complex{T} istree(a::ComplexTerm) = true operation(a::ComplexTerm{T}) where T = Complex{T} arguments(a::ComplexTerm) = [a.re, a.im] +metadata(a::ComplexTerm) = a.re.metadata function similarterm(t::ComplexTerm, f, args, symtype; metadata=nothing) if f <: Complex 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) diff --git a/test/complex.jl b/test/complex.jl index 2a24d3304..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] @@ -26,3 +27,10 @@ end @test repr(z) == "z" @test repr(a + b*im) == "a + b*im" 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 +end