本文整理汇总了Python中scipy.sparse.sputils.isintlike方法的典型用法代码示例。如果您正苦于以下问题:Python sputils.isintlike方法的具体用法?Python sputils.isintlike怎么用?Python sputils.isintlike使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.sparse.sputils
的用法示例。
在下文中一共展示了sputils.isintlike方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isintlike [as 别名]
def __init__(self, A, p):
if not isinstance(A, LinearOperator):
raise ValueError('LinearOperator expected as A')
if A.shape[0] != A.shape[1]:
raise ValueError('square LinearOperator expected, got %r' % A)
if not isintlike(p) or p < 0:
raise ValueError('non-negative integer expected as p')
super(_PowerLinearOperator, self).__init__(_get_dtype([A]), A.shape)
self.args = (A, p)
示例2: test_isintlike
# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isintlike [as 别名]
def test_isintlike(self):
assert_equal(sputils.isintlike(3.0),True)
assert_equal(sputils.isintlike(-4),True)
assert_equal(sputils.isintlike(np.array(3)),True)
assert_equal(sputils.isintlike(np.array([3])), False)
assert_equal(sputils.isintlike(2.5),False)
assert_equal(sputils.isintlike(1 + 3j),False)
assert_equal(sputils.isintlike((1,)), False)
assert_equal(sputils.isintlike((1,2)), False)
示例3: __init__
# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isintlike [as 别名]
def __init__(self, A, p):
if not isinstance(A, LinearOperator):
raise ValueError('LinearOperator expected as A')
if A.shape[0] != A.shape[1]:
raise ValueError('square LinearOperator expected as A')
if not isintlike(p):
raise ValueError('integer expected as p')
super(_PowerLinearOperator, self).__init__(A.shape,
self.matvec, self.rmatvec, self.matmat,
_get_dtype([A]))
self.args = (A, p)
示例4: test_isintlike
# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isintlike [as 别名]
def test_isintlike(self):
assert_equal(sputils.isintlike(-4), True)
assert_equal(sputils.isintlike(np.array(3)), True)
assert_equal(sputils.isintlike(np.array([3])), False)
with suppress_warnings() as sup:
sup.filter(DeprecationWarning,
"Inexact indices into sparse matrices are deprecated")
assert_equal(sputils.isintlike(3.0), True)
assert_equal(sputils.isintlike(2.5), False)
assert_equal(sputils.isintlike(1 + 3j), False)
assert_equal(sputils.isintlike((1,)), False)
assert_equal(sputils.isintlike((1, 2)), False)
示例5: __getitem__
# 需要导入模块: from scipy.sparse import sputils [as 别名]
# 或者: from scipy.sparse.sputils import isintlike [as 别名]
def __getitem__(self, index):
assert sputils.issequence(index) or sputils.isintlike(index)
users = np.array(index).reshape(-1,)
extracted_sparse_matrix = self._extract(self.interactions_matrix, index)
if self.target_interactions_matrix is None:
return UsersInteractions(users=users, interactions_matrix=extracted_sparse_matrix), None
else:
extracted_target_sparse_matrix = self._extract(self.target_interactions_matrix, index)
return UsersInteractions(users=users, interactions_matrix=extracted_sparse_matrix), \
UsersInteractions(users=users, interactions_matrix=extracted_target_sparse_matrix)