本文整理匯總了Python中numba.boolean方法的典型用法代碼示例。如果您正苦於以下問題:Python numba.boolean方法的具體用法?Python numba.boolean怎麽用?Python numba.boolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numba
的用法示例。
在下文中一共展示了numba.boolean方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _jit_give_bond_array
# 需要導入模塊: import numba [as 別名]
# 或者: from numba import boolean [as 別名]
def _jit_give_bond_array(pos, bond_radii, self_bonding_allowed=False):
"""Calculate a boolean array where ``A[i,j] is True`` indicates a
bond between the i-th and j-th atom.
"""
n = pos.shape[0]
bond_array = np.empty((n, n), dtype=nb.boolean)
for i in range(n):
for j in range(i, n):
D = 0
for h in range(3):
D += (pos[i, h] - pos[j, h])**2
B = (bond_radii[i] + bond_radii[j])**2
bond_array[i, j] = (B - D) >= 0
bond_array[j, i] = bond_array[i, j]
if not self_bonding_allowed:
for i in range(n):
bond_array[i, i] = False
return bond_array
示例2: transform_lists_to_arrays
# 需要導入模塊: import numba [as 別名]
# 或者: from numba import boolean [as 別名]
def transform_lists_to_arrays(module, to_change, __funcs, vec=False, cache_blacklist=set([])):
if vec:
conv_fun = numba.vectorize
extra_args = extra_args_vec
else:
conv_fun = numba.njit
extra_args = extra_args_std
for s in to_change:
func = s.split('.')[-1]
mod = '.'.join(s.split('.')[:-1])
fake_mod = __funcs[mod]
try:
real_mod = getattr(module, mod)
except:
real_mod = module
for s in mod.split('.'):
real_mod = getattr(real_mod, s)
orig_func = getattr(real_mod, func)
source = inspect.getsource(orig_func)
source = remove_for_numba(source) # do before anything else
source = return_value_numpy(source)
source = re.sub(list_mult_expr, numpy_not_list_expr, source)
# if 'longitude_obliquity_nutation' in s:
# print(source)
numba_exec_cacheable(source, fake_mod.__dict__, fake_mod.__dict__)
new_func = fake_mod.__dict__[func]
do_cache = caching and func not in cache_blacklist
obj = conv_fun(cache=do_cache, **extra_args)(new_func)
__funcs[func] = obj
fake_mod.__dict__[func] = obj
obj.__doc__ = ''
#set_signatures = {'Clamond': [numba.float64(numba.float64, numba.float64, numba.boolean),
# numba.float64(numba.float64, numba.float64, numba.optional(numba.boolean))
# ]
# }