diff --git a/Project.toml b/Project.toml index 3f2206f..6b3c6f1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QuantumOperatorDefinitions" uuid = "826dd319-6fd5-459a-a990-3a4f214664bf" authors = ["ITensor developers and contributors"] -version = "0.2.0" +version = "0.2.1" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -19,9 +19,9 @@ QuantumOperatorDefinitionsGradedArraysExt = ["BlockArrays", "GradedArrays"] [compat] BlockArrays = "1.3.0" -GradedArrays = "0.2.1" -ITensorBase = "0.2.0" +GradedArrays = "0.3" +ITensorBase = "0.2" LinearAlgebra = "1.10" -NamedDimsArrays = "0.6" +NamedDimsArrays = "0.7" Random = "1.10" julia = "1.10" diff --git a/src/op.jl b/src/op.jl index 7aee6a0..ea0257d 100644 --- a/src/op.jl +++ b/src/op.jl @@ -174,7 +174,7 @@ for nametype in (:StateName, :OpName) :(Base.:-), ) @eval begin - $f(n::$(nametype)) = $(applied)(; f=$f, arg=n) + $f(n::$(nametype)) = $(applied)(; f=($f), arg=n) end end end @@ -191,8 +191,9 @@ for nametype in (:StateName, :OpName) domains = map((start, stop) -> domain[start:stop], starts, stops) return kron(map((arg, domain) -> arg(domain...), n.args, domains)...) end - Base.kron(n1::$(nametype), n2::$(nametype), n_rest::$(nametype)...) = - $(kronned)(; args=(n1, n2, n_rest...)) + Base.kron(n1::$(nametype), n2::$(nametype), n_rest::$(nametype)...) = $(kronned)(; + args=(n1, n2, n_rest...) + ) ⊗(n1::$(nametype), n2::$(nametype)) = kron(n1, n2) ⊗(n1::$(kronned), n2::$(kronned)) = kron(n1.args..., n2.args...) ⊗(n1::$(nametype), n2::$(kronned)) = kron(n1, n2.args...) @@ -211,8 +212,9 @@ for nametype in (:StateName, :OpName) function (n::$(summed))(domain...) return mapreduce(a -> a(domain...), +, n.args) end - Base.:+(n1::$(nametype), n2::$(nametype), n_rest::$(nametype)...) = - $(summed)(; args=(n1, n2, n_rest...)) + Base.:+(n1::$(nametype), n2::$(nametype), n_rest::$(nametype)...) = $(summed)(; + args=(n1, n2, n_rest...) + ) Base.:+(n1::$(summed), n2::$(summed)) = +(n1.args..., n2.args...) Base.:+(n1::$(summed), n2::$(nametype)) = +(n1.args..., n2) Base.:+(n1::$(nametype), n2::$(summed)) = +(n1, n2.args...) @@ -252,7 +254,7 @@ end # Unary operations unique to operators. for f in (:(Base.sqrt), :(Base.exp), :(Base.cis), :(Base.cos), :(Base.sin), :(Base.adjoint)) @eval begin - $f(n::OpName) = OpName"applied"(; f=$f, arg=n) + $f(n::OpName) = OpName"applied"(; f=($f), arg=n) end end diff --git a/test/Project.toml b/test/Project.toml index 158444d..f0e7ff3 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -16,9 +16,9 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Aqua = "0.8.9" BlockArrays = "1" BlockSparseArrays = "0.4" -GradedArrays = "0.2" +GradedArrays = "0.3" ITensorBase = "0.2" -NamedDimsArrays = "0.6" +NamedDimsArrays = "0.7" QuantumOperatorDefinitions = "0.2" SafeTestsets = "0.1" Suppressor = "0.2" diff --git a/test/runtests.jl b/test/runtests.jl index 1c52c3e..98b2d2b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -14,11 +14,13 @@ const GROUP = uppercase( ) "match files of the form `test_*.jl`, but exclude `*setup*.jl`" -istestfile(fn) = - endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup") +function istestfile(fn) + return endswith(fn, ".jl") && startswith(basename(fn), "test_") && !contains(fn, "setup") +end "match files of the form `*.jl`, but exclude `*_notest.jl` and `*setup*.jl`" -isexamplefile(fn) = - endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup") +function isexamplefile(fn) + return endswith(fn, ".jl") && !endswith(fn, "_notest.jl") && !contains(fn, "setup") +end @time begin # tests in groups based on folder structure