Skip to content

Commit

Permalink
improved inference of physical spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Nov 7, 2023
1 parent d874817 commit deb1e76
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/operators/sparsempo/sparsempo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ end

#default constructor
function SparseMPO(x::AbstractArray{Union{E,M},3}) where {M<:MPOTensor,E<:Number}
(period, numrows, numcols) = size(x)
period, numrows, numcols = size(x)

Sp = spacetype(M)
E == scalartype(M) || throw(
Expand Down Expand Up @@ -175,8 +175,15 @@ function SparseMPO(x::AbstractArray{Union{E,M},3}) where {M<:MPOTensor,E<:Number
end
end

sum(ismissing.(pspaces)) == 0 ||
throw(ArgumentError("Not all physical spaces were assigned"))
if sum(ismissing.(pspaces)) != 0
if allequal(Iterators.filter(!ismissing, pspaces))
V = pspaces[findfirst(!ismissing, pspaces)]
@warn "Not all physical spaces were assigned, assumed $V everywhere"
pspaces .= Ref(V)
else
throw(ArgumentError("Not all physical spaces were assigned"))
end
end
# sum(ismissing.(domspaces)) == 0 || @warn "failed to deduce all domspaces"

for loc in 1:period, j in 1:numrows
Expand Down

0 comments on commit deb1e76

Please sign in to comment.