Skip to content

Commit

Permalink
fix convert label (#38)
Browse files Browse the repository at this point in the history
* fix label type

* update version
  • Loading branch information
GiggleLiu authored Jul 30, 2023
1 parent 27a358c commit 57923b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/json.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
2 changes: 1 addition & 1 deletion src/treesa.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 57923b1

Please sign in to comment.