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,6 +1,6 @@
name = "ITensorBase"
uuid = "4795dd04-0d67-49bb-8f44-b89c448a1dc7"
version = "0.13.0"
version = "0.13.1"
authors = ["ITensor developers <support@itensor.org> and contributors"]

[workspace]
Expand Down
3 changes: 2 additions & 1 deletion src/abstractnamedtensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ Symbol
"""
function dimnametype end
dimnametype(a::AbstractNamedTensor) = dimnametype(typeof(a))
dimnametype(type::Type{<:AbstractNamedTensor}) = Any
dimnametype(::Type{<:AbstractNamedTensor{DimName}}) where {DimName} = DimName
dimnametype(::Type{<:AbstractNamedTensor}) = Any

# Unwrapping the names (named-array interface).
# TODO: Use `IsNamed` trait?
Expand Down
1 change: 0 additions & 1 deletion src/lazyitensors/symbolicitensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ dimnames(a::SymbolicNamedTensor) = getfield(a, :dimnames)
function Base.axes(a::SymbolicNamedTensor)
return named.(Tuple(Base.OneTo.(getfield(a, :size))), Tuple(getfield(a, :dimnames)))
end
dimnametype(::Type{<:SymbolicNamedTensor{DimName}}) where {DimName} = DimName
Base.ndims(a::SymbolicNamedTensor) = length(getfield(a, :dimnames))

function Base.:(==)(a::SymbolicNamedTensor, b::SymbolicNamedTensor)
Expand Down
2 changes: 0 additions & 2 deletions src/namedtensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ dimnames(a::NamedTensor) = a.dimnames
unnamed(a::NamedTensor) = a.unnamed
Base.parent(a::NamedTensor) = unnamed(a)

dimnametype(::Type{<:NamedTensor{DimName}}) where {DimName} = DimName

# The parent array is erased at the field level, so its concrete type is not part
# of `NamedTensor`'s signature. An instance still carries the parent, so the instance
# methods recover the concrete type while the type methods report `AbstractArray`.
Expand Down
10 changes: 7 additions & 3 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using ITensorBase: ITensorBase, AbstractNamedTensor, ITensor, Index, IndexName, NamedTensor,
commonind, commoninds, dimnametype, gettag, hascommoninds, hastag, id, inds, mapinds,
name, named, noncommonind, noncommoninds, noprime, plev, prime, replaceinds, setplev,
settag, sim, tags, trycommonind, trynoncommonind, tryuniqueind, unioninds, uniqueind,
uniqueinds, uniquename, unname, unnamed, unsettag, uuid
name, named, noncommonind, noncommoninds, noprime, operator, plev, prime, replaceinds,
setplev, settag, sim, tags, trycommonind, trynoncommonind, tryuniqueind, unioninds,
uniqueind, uniqueinds, uniquename, unname, unnamed, unsettag, uuid
using Test: @test, @test_broken, @test_throws, @testset
using UUIDs: UUID

Expand Down Expand Up @@ -172,6 +172,10 @@ using UUIDs: UUID
@test dimnametype(a) === IndexName
@test dimnametype(typeof(a)) === IndexName
@test dimnametype(NamedTensor{IndexName}) === IndexName
# An operator reports the dimname flavor of its underlying tensor.
op = operator(a, (name(i),), (name(j),))
@test dimnametype(op) === IndexName
@test dimnametype(typeof(op)) === IndexName
# Unparameterized `NamedTensor` does not fix its dimname flavor, like `eltype(Array)`.
@test dimnametype(NamedTensor) === Any
end
Expand Down