本文整理汇总了Python中numpy.longfloat方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.longfloat方法的具体用法?Python numpy.longfloat怎么用?Python numpy.longfloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy
的用法示例。
在下文中一共展示了numpy.longfloat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_unsigned_graph
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longfloat [as 别名]
def _setup_unsigned_graph():
edges, signed_edges, edge_beliefs, all_ns = _digraph_setup()
dg = nx.DiGraph()
dg.add_edges_from(edges)
# Add belief
for e in dg.edges:
dg.edges[e]['belief'] = edge_beliefs[e]
dg.edges[e]['weight'] = -np.log(edge_beliefs[e], dtype=np.longfloat)
# Add namespaces
nodes1, nodes2 = list(zip(*edges))
nodes = set(nodes1).union(nodes2)
for node in nodes:
ns = node[0]
_id = node[1]
dg.nodes[node]['ns'] = ns
dg.nodes[node]['id'] = _id
return dg, all_ns
示例2: test_to_digraph
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longfloat [as 别名]
def test_to_digraph():
ia = IndraNetAssembler([ab1, ab2, ab3, ab4, bc1, bc2, bc3, bc4])
df = ia.make_df()
net = IndraNet.from_df(df)
assert len(net.nodes) == 3
assert len(net.edges) == 8
digraph = net.to_digraph(weight_mapping=_weight_mapping)
assert len(digraph.nodes) == 3
assert len(digraph.edges) == 2
assert set([
stmt['stmt_type'] for stmt in digraph['a']['b']['statements']]) == {
'Activation', 'Phosphorylation', 'Inhibition', 'IncreaseAmount'}
assert all(digraph.edges[e].get('belief', False) for e in digraph.edges)
assert all(isinstance(digraph.edges[e]['belief'],
(float, np.longfloat)) for e in digraph.edges)
assert all(digraph.edges[e].get('weight', False) for e in digraph.edges)
assert all(isinstance(digraph.edges[e]['weight'],
(float, np.longfloat)) for e in digraph.edges)
digraph_from_df = IndraNet.digraph_from_df(df)
assert nx.is_isomorphic(digraph, digraph_from_df)
示例3: test_arange_endian
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longfloat [as 别名]
def test_arange_endian(self,level=rlevel):
"""Ticket #111"""
ref = np.arange(10)
x = np.arange(10, dtype='<f8')
assert_array_equal(ref, x)
x = np.arange(10, dtype='>f8')
assert_array_equal(ref, x)
# Longfloat support is not consistent enough across
# platforms for this test to be meaningful.
# def test_longfloat_repr(self,level=rlevel):
# """Ticket #112"""
# if np.longfloat(0).itemsize > 8:
# a = np.exp(np.array([1000],dtype=np.longfloat))
# assert_(str(a)[1:9] == str(a[0])[:8])
示例4: test_to_signed_graph
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longfloat [as 别名]
def test_to_signed_graph():
ia = IndraNetAssembler([ab1, ab2, ab3, ab4, bc1, bc2, bc3, bc4])
df = ia.make_df()
net = IndraNet.from_df(df)
signed_graph = net.to_signed_graph(
sign_dict=default_sign_dict,
weight_mapping=_weight_mapping)
assert len(signed_graph.nodes) == 3
assert len(signed_graph.edges) == 4
assert set([stmt['stmt_type'] for stmt in
signed_graph['a']['b'][0]['statements']]) == {
'Activation', 'IncreaseAmount'}
assert set([stmt['stmt_type'] for stmt in
signed_graph['a']['b'][1]['statements']]) == {'Inhibition'}
assert set([stmt['stmt_type'] for stmt in
signed_graph['b']['c'][0]['statements']]) == {
'Activation', 'IncreaseAmount'}
assert set([stmt['stmt_type'] for stmt in
signed_graph['b']['c'][1]['statements']]) == {
'Inhibition', 'DecreaseAmount'}
assert all(signed_graph.edges[e].get('belief', False) for e in
signed_graph.edges)
assert all(isinstance(signed_graph.edges[e]['belief'],
(float, np.longfloat)) for e in signed_graph.edges)
assert all(signed_graph.edges[e].get('weight', False) for e in
signed_graph.edges)
assert all(isinstance(signed_graph.edges[e]['weight'],
(float, np.longfloat)) for e in signed_graph.edges)
示例5: _complementary_belief
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longfloat [as 别名]
def _complementary_belief(G, edge):
# Aggregate belief score: 1-prod(1-belief_i)
np.seterr(all='raise')
NP_PRECISION = 10 ** -np.finfo(np.longfloat).precision # Numpy precision
belief_list = [s['belief'] for s in G.edges[edge]['statements']]
try:
ag_belief = np.longfloat(1.0) - np.prod(np.fromiter(
map(lambda belief: np.longfloat(1.0) - belief, belief_list),
dtype=np.longfloat))
except FloatingPointError as err:
logger.warning('%s: Resetting ag_belief to 10*np.longfloat precision '
'(%.0e)' % (err, Decimal(NP_PRECISION * 10)))
ag_belief = NP_PRECISION * 10
return ag_belief
示例6: forward
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import longfloat [as 别名]
def forward(self, weighted_input):
return np.longfloat(1.0 / (1.0 + np.exp(-weighted_input)))