Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix convert label #38

Merged
merged 2 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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