本文整理匯總了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)))