本文整理匯總了Python中numpy.issctype方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.issctype方法的具體用法?Python numpy.issctype怎麽用?Python numpy.issctype使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.issctype方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_issctype
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import issctype [as 別名]
def test_issctype(rep, expected):
# ensure proper identification of scalar
# data-types by issctype()
actual = np.issctype(rep)
assert_equal(actual, expected)
示例2: num_symbolic
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import issctype [as 別名]
def num_symbolic(val):
"""
Return the number of symbols in val
"""
if is_symbolic(val):
return 1
elif isinstance(val, np.ndarray) and np.issctype(val.dtype):
return 0
elif hasattr(val, "__iter__"):
return sum(any_symbolic(i) for i in val)
return 0
示例3: any_symbolic
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import issctype [as 別名]
def any_symbolic(val):
if is_symbolic(val):
return True
if isinstance(val, np.ndarray) and val.ndim == 0:
return is_symbolic(val[()])
elif isinstance(val, np.ndarray) and np.issctype(val.dtype):
return False
elif isinstance(val, six.string_types): # string is iterable
return False
elif hasattr(val, "__iter__"):
return any(any_symbolic(i) for i in val)
return False
示例4: any_variadic
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import issctype [as 別名]
def any_variadic(val):
if is_variadic(val):
return True
elif isinstance(val, np.ndarray) and np.issctype(val.dtype):
return False
elif isinstance(val, six.string_types): # string is iterable
return False
elif hasattr(val, "__iter__"):
return any(any_variadic(i) for i in val)
return False