1

# efficiency must satisfy 0.0 < efficiency < 1.0

Package:
scipy
8546
Exception Class:
ValueError

## Raise code

if not (isspmatrix_csr(A) or isspmatrix_csc(A)):
A = csr_matrix(A)

if A.nnz == 0:
return (1,1)

if not 0 < efficiency < 1.0:
raise ValueError('efficiency must satisfy 0.0 < efficiency < 1.0')

high_efficiency = (1.0 + efficiency) / 2.0
nnz = float(A.nnz)
M,N = A.shape

if M % 2 == 0 and N % 2 == 0:
e22 = nnz / (4 * count_blocks(A,(2,2)))
😲 Agile task management is now easier than calling a taxi. #Tracklify
🙏 Scream for help to Ukraine
Today, 14th August 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

## Ways to fix

2

The value of the efficiency parameter is expected to be between 0 and 1.

## Steps to reproduce the error:

\$ pipenv install scipy

\$ pipenv shell

from scipy.sparse import spfuncs
import scipy
matrix = scipy.sparse.csr_matrix([[0,1],[2,0]])
r,c = spfuncs.estimate_blocksize(matrix,efficiency=1.2)
print(r,c)

## Result(Error):

---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

<ipython-input-11-89b42a8dd3e6> in <module>()
2 import scipy
3 matrix = scipy.sparse.csr_matrix([[0,1],[2,0]])
----> 4 r,c = spfuncs.estimate_blocksize(matrix,efficiency=1.2)
5 print(r,c)

/usr/local/lib/python3.7/dist-packages/scipy/sparse/spfuncs.py in estimate_blocksize(A, efficiency)
46
47     if not 0 < efficiency < 1.0:
---> 48         raise ValueError('efficiency must satisfy 0.0 < efficiency < 1.0')
49
50     high_efficiency = (1.0 + efficiency) / 2.0

ValueError: efficiency must satisfy 0.0 < efficiency < 1.0

## Fixed:

from scipy.sparse import spfuncs
import scipy
matrix = scipy.sparse.csr_matrix([[0,1],[2,0]])
r,c = spfuncs.estimate_blocksize(matrix,efficiency=0.7)
print(r,c)

1 1

Sep 21, 2021
kellemnegasi 30.6k