Skip to content

Commit

Permalink
no need to close outvar
Browse files Browse the repository at this point in the history
  • Loading branch information
shashi committed Aug 18, 2023
2 parents 2cded7f + d70b4ef commit b4fa967
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
- '1'
- '1.6'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: |
if [ "`git rev-parse --abbrev-ref HEAD`" != master ]; then git fetch origin master:master; fi
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
- uses: actions/cache@v1
- uses: actions/cache@v3
env:
cache-name: cache-artifacts
with:
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/Symbolics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions src/build_function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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),
[])
Expand Down
1 change: 1 addition & 0 deletions src/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions test/complex.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Symbolics, Test
using SymbolicUtils: metadata

@variables a b::Real z::Complex (Z::Complex)[1:10]

Expand Down Expand Up @@ -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

0 comments on commit b4fa967

Please sign in to comment.