From 57923b1a67f8afed313b4ba52b123bda1d36a1f1 Mon Sep 17 00:00:00 2001 From: Jinguo Liu Date: Mon, 31 Jul 2023 01:10:20 +0800 Subject: [PATCH] fix convert label (#38) * fix label type * update version --- Project.toml | 2 +- src/json.jl | 4 ++-- src/treesa.jl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index c7504a4..c7cecd0 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "OMEinsumContractionOrders" uuid = "6f22d1fd-8eed-4bb7-9776-e7d684900715" authors = ["Jin-Guo Liu", "Pan Zhang"] -version = "0.8.1" +version = "0.8.2" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" diff --git a/src/json.jl b/src/json.jl index f32d7b9..8014887 100644 --- a/src/json.jl +++ b/src/json.jl @@ -31,7 +31,7 @@ function _fromdict(dict) end ne = fromdict(LT, dict["tree"]) if haskey(dict, "slices") - return SlicedEinsum(_convert.(LT, dict["slices"]), ne) + return SlicedEinsum(LT[_convert(LT, l) for l in dict["slices"]], ne) else return ne end @@ -68,4 +68,4 @@ function einsfromdict(::Type{LT}, dict::Dict) where LT end _convert(::Type{LT}, x) where LT = convert(LT, x) -_convert(::Type{Char}, x::String) where LT = (@assert length(x)==1; x[1]) +_convert(::Type{Char}, x::String) = (@assert length(x)==1; x[1]) diff --git a/src/treesa.jl b/src/treesa.jl index c63f27e..fb31557 100644 --- a/src/treesa.jl +++ b/src/treesa.jl @@ -454,7 +454,7 @@ function ExprTree(code::NestedEinsum) _exprtree(code, _label_dict(code)) end function _exprtree(code::NestedEinsum, labels) - @assert length(code.args) == 2 + @assert length(code.args) == 2 "einsum contraction not in the binary form, got number of arguments: $(length(code.args))" ExprTree(map(enumerate(code.args)) do (i,arg) if isleaf(arg) # leaf nodes ExprTree(ExprInfo(getindex.(Ref(labels), getixsv(code.eins)[i]), arg.tensorindex))