Skip to content
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 = "NamedDimsArrays"
uuid = "60cbd0c0-df58-4cb7-918c-6f5607b73fde"
authors = ["ITensor developers <support@itensor.org> and contributors"]
version = "0.3.8"
version = "0.3.9"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
7 changes: 5 additions & 2 deletions src/abstractnameddimsarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@

# Generic constructor.
function nameddims(a::AbstractArray, nameddimsindices)
if iszero(ndims(a))
return constructorof_nameddims(typeof(a))(a, nameddimsindices)

Check warning on line 156 in src/abstractnameddimsarray.jl

View check run for this annotation

Codecov / codecov/patch

src/abstractnameddimsarray.jl#L156

Added line #L156 was not covered by tests
end
# TODO: Check the shape of `nameddimsindices` matches the shape of `a`.
arrtype = mapreduce(nameddimsarraytype, combine_nameddimsarraytype, nameddimsindices)
return arrtype(a, to_nameddimsindices(a, nameddimsindices))
Expand Down Expand Up @@ -781,7 +784,7 @@
ax1::Tuple{AbstractNamedUnitRange,Vararg{AbstractNamedUnitRange,N}},
ax2::Tuple{AbstractNamedUnitRange,Vararg{AbstractNamedUnitRange,N}},
) where {N}
perm = getperm(ax1, ax2)
perm = getperm(ax2, ax1)

Check warning on line 787 in src/abstractnameddimsarray.jl

View check run for this annotation

Codecov / codecov/patch

src/abstractnameddimsarray.jl#L787

Added line #L787 was not covered by tests
ax2_aligned = map(i -> ax2[i], perm)
ax_promoted = promote_shape(dename.(ax1), dename.(ax2_aligned))
return named.(ax_promoted, name.(ax1))
Expand Down Expand Up @@ -813,7 +816,7 @@
ax1::Tuple{AbstractNamedUnitRange,Vararg{AbstractNamedUnitRange,N}},
ax2::Tuple{AbstractNamedUnitRange,Vararg{AbstractNamedUnitRange,N}},
) where {N}
perm = getperm(ax1, ax2)
perm = getperm(ax2, ax1)
ax2_aligned = map(i -> ax2[i], perm)
check_broadcast_shape(dename.(ax1), dename.(ax2_aligned))
return nothing
Expand Down
5 changes: 4 additions & 1 deletion src/tensoralgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ function TensorAlgebra.contract(
a_dest, nameddimsindices_dest = contract(
dename(a1), nameddimsindices(a1), dename(a2), nameddimsindices(a2), α
)
return nameddims(a_dest, nameddimsindices_dest)
nameddimstype = combine_nameddimsarraytype(
constructorof(typeof(a1)), constructorof(typeof(a2))
)
return nameddimstype(a_dest, nameddimsindices_dest)
end

function Base.:*(a1::AbstractNamedDimsArray, a2::AbstractNamedDimsArray)
Expand Down
Loading