-
Notifications
You must be signed in to change notification settings - Fork 128
Closed
Labels
ITensorsIssues or pull requests related to the `ITensors` package.Issues or pull requests related to the `ITensors` package.bugSomething isn't workingSomething isn't working
Description
Description of bug
I believe that the nnz function for ITensors.jl should extend the one from SparseArrays. But this doesn't happen.
Minimal code demonstrating the bug or unexpected behavior
using ITensors, SparseArrays
A = sprand(10, 10, 0.5)
nnz(A)
This gives
julia> nnz(A)
ERROR: UndefVarError: `nnz` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Hint: a global variable of this name also exists in SparseArrays.
Hint: a global variable of this name also exists in NDTensors.
Hint: a global variable of this name also exists in ITensors.Looking at the methods, it seems like this is probably an oversight:
julia> methods(ITensors.nnz)
# 5 methods for generic function "nnz" from NDTensors:
[1] nnz(T::ITensor)
@ ITensors ~/.julia/packages/ITensors/GkEpm/src/itensor.jl:855
[2] nnz(::NDTensors.EmptyStorage)
@ ~/.julia/packages/NDTensors/OehsJ/src/empty/empty.jl:69
[3] nnz(bofs::Dictionaries.Dictionary{Block{N}, Int64} where N, inds)
@ ~/.julia/packages/NDTensors/OehsJ/src/blocksparse/blockoffsets.jl:60
[4] nnz(T::NDTensors.Tensor)
@ ~/.julia/packages/NDTensors/OehsJ/src/tensor/tensor.jl:310
[5] nnz(S::NDTensors.TensorStorage)
@ ~/.julia/packages/NDTensors/OehsJ/src/tensorstorage/tensorstorage.jl:101
julia> methods(SparseArrays.nnz)
# 15 methods for generic function "nnz" from SparseArrays:
[1] nnz(S::LinearAlgebra.LowerTriangular{<:Any, <:SparseArrays.AbstractSparseMatrixCSC})
@ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/sparsematrix.jl:222
[2] nnz(x::SubArray{Tv, 1, <:AbstractSparseVector{Tv, Ti}, Tuple{Base.Slice{Base.OneTo{Int64}}}, false} where {Tv, Ti})
@ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/sparsevector.jl:119
[3] nnz(x::SubArray{Tv, 1, <:AbstractSparseVector{Tv, Ti}, <:Tuple{AbstractUnitRange}, false} where {Tv, Ti})
@ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/sparsevector.jl:120
[4] nnz(x::SubArray{Tv, 1, <:SparseArrays.AbstractSparseMatrixCSC{Tv, Ti}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, false} where {Tv, Ti})
@ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/sparsevector.jl:115
[5] nnz(S::SubArray{Tv, 2, <:SparseArrays.AbstractSparseMatrixCSC{Tv, Ti}, Tuple{Base.Slice{Base.OneTo{Int64}}, I}} where {Tv, Ti, I<:(AbstractVector{<:Integer})})
@ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/sparsematrix.jl:223
[6] nnz(lu::SparseArrays.UMFPACK.UmfpackLU)
@ SparseArrays.UMFPACK /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/solvers/umfpack.jl:938
[7] nnz(A::SparseArrays.CHOLMOD.Sparse{<:Union{Float32, Float64, ComplexF64, ComplexF32}, Int64})
@ SparseArrays.CHOLMOD /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/solvers/cholmod.jl:601
[8] nnz(A::SparseArrays.CHOLMOD.Sparse{<:Union{Float32, Float64, ComplexF64, ComplexF32}, Int32})
@ SparseArrays.CHOLMOD /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/solvers/cholmod.jl:601
[9] nnz(x::SparseArrays.AbstractCompressedVector)
@ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/sparsevector.jl:114
[10] nnz(S::SparseArrays.AbstractSparseMatrixCSC)
@ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/sparsematrix.jl:218
[11] nnz(S::Base.ReshapedArray{<:Any, 1, <:SparseArrays.AbstractSparseMatrixCSC})
@ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/sparsematrix.jl:219
[12] nnz(S::LinearAlgebra.UpperTriangular{<:Any, <:SparseArrays.AbstractSparseMatrixCSC})
@ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/sparsematrix.jl:221
[13] nnz(F::SparseArrays.CHOLMOD.Factor)
@ SparseArrays.CHOLMOD /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/solvers/cholmod.jl:1268
[14] nnz(a::NDTensors.SparseArrayInterface.AbstractSparseArray)
@ NDTensors.SparseArrayInterface ~/.julia/packages/NDTensors/OehsJ/src/lib/SparseArrayInterface/src/abstractsparsearray/SparseArrayInterfaceSparseArraysExt.jl:6
[15] nnz(S::Union{LinearAlgebra.Adjoint{var"#s15", var"#s14"}, LinearAlgebra.Transpose{var"#s15", var"#s14"}} where {var"#s15", var"#s14"<:SparseArrays.AbstractSparseMatrixCSC})
@ /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/SparseArrays/src/sparsematrix.jl:220
Version information
- Output from
versioninfo():
julia> versioninfo()
Julia Version 1.11.0
Commit 501a4f25c2b (2024-10-07 11:40 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (x86_64-apple-darwin22.4.0)
CPU: 16 × Intel(R) Xeon(R) W-2140B CPU @ 3.20GHz
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, skylake-avx512)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)- Output from
using Pkg; Pkg.status("ITensors"):
julia> using Pkg; Pkg.status("ITensors")
⌅ [9136182c] ITensors v0.7.1Metadata
Metadata
Assignees
Labels
ITensorsIssues or pull requests related to the `ITensors` package.Issues or pull requests related to the `ITensors` package.bugSomething isn't workingSomething isn't working