本文整理汇总了Python中sys.float_info方法的典型用法代码示例。如果您正苦于以下问题:Python sys.float_info方法的具体用法?Python sys.float_info怎么用?Python sys.float_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sys
的用法示例。
在下文中一共展示了sys.float_info方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_float
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def get_float(min_size=None, max_size=None):
"""
return a random float
sames as the random method but automatically sets min and max
:param min_size: float, the minimum float size you want
:param max_size: float, the maximum float size you want
:returns: float, a random value between min_size and max_size
"""
float_info = sys.float_info
if min_size is None:
min_size = float_info.min
if max_size is None:
max_size = float_info.max
return random.uniform(min_size, max_size)
开发者ID:SeldomQA,项目名称:seldom,代码行数:17,代码来源:__init__.py示例2: rank
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def rank(self):
ws = defaultdict(float)
outSum = defaultdict(float)
wsdef = 1.0 / (len(self.graph) or 1.0)
for n, out in self.graph.items():
ws[n] = wsdef
outSum[n] = sum((e[2] for e in out), 0.0)
# this line for build stable iteration
sorted_keys = sorted(self.graph.keys())
for x in xrange(10): # 10 iters
for n in sorted_keys:
s = 0
for e in self.graph[n]:
s += e[2] / outSum[e[1]] * ws[e[1]]
ws[n] = (1 - self.d) + self.d * s
(min_rank, max_rank) = (sys.float_info[0], sys.float_info[3])
for w in itervalues(ws):
if w < min_rank:
min_rank = w
if w > max_rank:
max_rank = w
for n, w in ws.items():
# to unify the weights, don't *100.
ws[n] = (w - min_rank / 10.0) / (max_rank - min_rank / 10.0)
return ws
开发者ID:deepcs233,项目名称:jieba_fast,代码行数:33,代码来源:textrank.py示例3: test_float_roundtrip
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def test_float_roundtrip(self):
info = sys.float_info
inf = float("inf")
nan = float("nan")
self.assertEqual(1.0, serialize.load(serialize.dump(1.0)))
self.assertEqual(-1.0, serialize.load(serialize.dump(-1.0)))
self.assertEqual(info.min, serialize.load(serialize.dump(info.min)))
self.assertEqual(info.max, serialize.load(serialize.dump(info.max)))
self.assertEqual(inf, serialize.load(serialize.dump(inf)))
self.assertEqual(-inf, serialize.load(serialize.dump(-inf)))
self.assertTrue(math.isnan(serialize.load(serialize.dump(nan))))
开发者ID:abusesa,项目名称:abusehelper,代码行数:14,代码来源:test_serialize.py示例4: sysmis
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def sysmis(self):
"""This function returns the IBM SPSS Statistics system-missing
value ($SYSMIS) for the host system (also called 'NA' in other
systems)."""
try:
sysmis = -1 * sys.float_info[0] # Python 2.6 and higher.
except AttributeError:
self.spssio.spssSysmisVal.restype = c_float
sysmis = self.spssio.spssSysmisVal()
return sysmis
开发者ID:Quantipy,项目名称:quantipy,代码行数:12,代码来源:generic.py示例5: test_float_info_tuple
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def test_float_info_tuple(self):
self.assertEqual(tuple(sys.float_info), sys.float_info)
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:4,代码来源:test_sys_jy.py示例6: rank
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def rank(self):
ws = defaultdict(float)
outSum = defaultdict(float)
wsdef = 1.0 / (len(self.graph) or 1.0)
for n, out in self.graph.items():
ws[n] = wsdef
outSum[n] = sum((e[2] for e in out), 0.0)
# this line for build stable iteration
sorted_keys = sorted(self.graph.keys())
for x in xrange(10): # 10 iters
for n in sorted_keys:
s = 0
for e in self.graph[n]:
s += e[2] / outSum[e[1]] * ws[e[1]]
ws[n] = (1 - self.d) + self.d * s
(min_rank, max_rank) = (sys.float_info[0], sys.float_info[3])
for w in itervalues(ws):
if w < min_rank:
min_rank = w
elif w > max_rank:
max_rank = w
for n, w in ws.items():
# to unify the weights, don't *100.
ws[n] = (w - min_rank / 10.0) / (max_rank - min_rank / 10.0)
return ws
开发者ID:ustcdane,项目名称:annotated_jieba,代码行数:33,代码来源:textrank.py示例7: test_indexer_records_import_of_variable
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def test_indexer_records_import_of_variable(self):
client = self.indexSourceCode(
'from sys import float_info\n'
)
self.assertTrue('USAGE: virtual_file -> sys at [1:6|1:8]' in client.references)
self.assertTrue('IMPORT: virtual_file -> sys.float_info at [1:17|1:26]' in client.references)
开发者ID:CoatiSoftware,项目名称:SourcetrailPythonIndexer,代码行数:8,代码来源:test.py示例8: test_indexer_records_import_of_aliased_variable
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def test_indexer_records_import_of_aliased_variable(self):
client = self.indexSourceCode(
'from sys import float_info as FI\n'
)
self.assertTrue('USAGE: virtual_file -> sys at [1:6|1:8]' in client.references)
self.assertTrue('IMPORT: virtual_file -> sys.float_info at [1:17|1:26]' in client.references)
self.assertTrue('IMPORT: virtual_file -> sys.float_info at [1:31|1:32]' in client.references)
开发者ID:CoatiSoftware,项目名称:SourcetrailPythonIndexer,代码行数:9,代码来源:test.py示例9: test_indexer_records_import_of_multiple_aliased_variables_with_single_import_statement
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def test_indexer_records_import_of_multiple_aliased_variables_with_single_import_statement(self):
client = self.indexSourceCode(
'from sys import float_info as FI, api_version as AI\n'
)
self.assertTrue('USAGE: virtual_file -> sys at [1:6|1:8]' in client.references)
self.assertTrue('IMPORT: virtual_file -> sys.float_info at [1:17|1:26]' in client.references)
self.assertTrue('IMPORT: virtual_file -> sys.float_info at [1:31|1:32]' in client.references)
self.assertTrue('IMPORT: virtual_file -> sys.api_version at [1:35|1:45]' in client.references)
self.assertTrue('IMPORT: virtual_file -> sys.api_version at [1:50|1:51]' in client.references)
开发者ID:CoatiSoftware,项目名称:SourcetrailPythonIndexer,代码行数:11,代码来源:test.py示例10: gaussPDF
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def gaussPDF(Data, Mu, Sigma):
realmin = sys.float_info[3]
nbVar, nbData = np.shape(Data)
Data = np.transpose(Data) - np.tile(np.transpose(Mu), (nbData, 1))
prob = np.sum(np.dot(Data, np.linalg.inv(Sigma))*Data, 1)
prob = np.exp(-0.5*prob)/np.sqrt((np.power((2*math.pi), nbVar))*np.absolute(np.linalg.det(Sigma))+realmin)
return prob
开发者ID:BatyaGG,项目名称:Gaussian-Mixture-Models,代码行数:9,代码来源:gaussPDF.py示例11: test_attributes
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def test_attributes(self):
self.assertIsInstance(sys.api_version, int)
self.assertIsInstance(sys.argv, list)
self.assertIn(sys.byteorder, ("little", "big"))
self.assertIsInstance(sys.builtin_module_names, tuple)
self.assertIsInstance(sys.copyright, basestring)
self.assertIsInstance(sys.exec_prefix, basestring)
self.assertIsInstance(sys.executable, basestring)
self.assertEqual(len(sys.float_info), 11)
self.assertEqual(sys.float_info.radix, 2)
self.assertEqual(len(sys.long_info), 2)
if sys.platform != 'cli':
self.assertTrue(sys.long_info.bits_per_digit % 5 == 0)
else:
self.assertTrue(sys.long_info.bits_per_digit % 8 == 0)
self.assertTrue(sys.long_info.sizeof_digit >= 1)
self.assertEqual(type(sys.long_info.bits_per_digit), int)
self.assertEqual(type(sys.long_info.sizeof_digit), int)
self.assertIsInstance(sys.hexversion, int)
self.assertIsInstance(sys.maxint, int)
if test.test_support.have_unicode:
self.assertIsInstance(sys.maxunicode, int)
self.assertIsInstance(sys.platform, basestring)
self.assertIsInstance(sys.prefix, basestring)
self.assertIsInstance(sys.version, basestring)
vi = sys.version_info
self.assertIsInstance(vi[:], tuple)
self.assertEqual(len(vi), 5)
self.assertIsInstance(vi[0], int)
self.assertIsInstance(vi[1], int)
self.assertIsInstance(vi[2], int)
self.assertIn(vi[3], ("alpha", "beta", "candidate", "final"))
self.assertIsInstance(vi[4], int)
self.assertIsInstance(vi.major, int)
self.assertIsInstance(vi.minor, int)
self.assertIsInstance(vi.micro, int)
self.assertIn(vi.releaselevel, ("alpha", "beta", "candidate", "final"))
self.assertIsInstance(vi.serial, int)
self.assertEqual(vi[0], vi.major)
self.assertEqual(vi[1], vi.minor)
self.assertEqual(vi[2], vi.micro)
self.assertEqual(vi[3], vi.releaselevel)
self.assertEqual(vi[4], vi.serial)
self.assertTrue(vi > (1,0,0))
self.assertIsInstance(sys.float_repr_style, str)
self.assertIn(sys.float_repr_style, ('short', 'legacy'))
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:48,代码来源:test_sys.py示例12: test_attributes
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def test_attributes(self):
self.assertIsInstance(sys.api_version, int)
self.assertIsInstance(sys.argv, list)
self.assertIn(sys.byteorder, ("little", "big"))
self.assertIsInstance(sys.builtin_module_names, tuple)
self.assertIsInstance(sys.copyright, basestring)
self.assertIsInstance(sys.exec_prefix, basestring)
self.assertIsInstance(sys.executable, basestring)
self.assertEqual(len(sys.float_info), 11)
self.assertEqual(sys.float_info.radix, 2)
self.assertEqual(len(sys.long_info), 2)
self.assertTrue(sys.long_info.bits_per_digit % 5 == 0)
self.assertTrue(sys.long_info.sizeof_digit >= 1)
self.assertEqual(type(sys.long_info.bits_per_digit), int)
self.assertEqual(type(sys.long_info.sizeof_digit), int)
self.assertIsInstance(sys.hexversion, int)
self.assertIsInstance(sys.maxint, int)
if test.test_support.have_unicode:
self.assertIsInstance(sys.maxunicode, int)
self.assertIsInstance(sys.platform, basestring)
self.assertIsInstance(sys.prefix, basestring)
self.assertIsInstance(sys.version, basestring)
vi = sys.version_info
self.assertIsInstance(vi[:], tuple)
self.assertEqual(len(vi), 5)
self.assertIsInstance(vi[0], int)
self.assertIsInstance(vi[1], int)
self.assertIsInstance(vi[2], int)
self.assertIn(vi[3], ("alpha", "beta", "candidate", "final"))
self.assertIsInstance(vi[4], int)
self.assertIsInstance(vi.major, int)
self.assertIsInstance(vi.minor, int)
self.assertIsInstance(vi.micro, int)
self.assertIn(vi.releaselevel, ("alpha", "beta", "candidate", "final"))
self.assertIsInstance(vi.serial, int)
self.assertEqual(vi[0], vi.major)
self.assertEqual(vi[1], vi.minor)
self.assertEqual(vi[2], vi.micro)
self.assertEqual(vi[3], vi.releaselevel)
self.assertEqual(vi[4], vi.serial)
self.assertTrue(vi > (1,0,0))
self.assertIsInstance(sys.float_repr_style, str)
self.assertIn(sys.float_repr_style, ('short', 'legacy'))
开发者ID:dxwu,项目名称:BinderFilter,代码行数:45,代码来源:test_sys.py示例13: EM
# 需要导入模块: import sys [as 别名]
# 或者: from sys import float_info [as 别名]
def EM(Data, Priors0, Mu0, Sigma0):
realmax = sys.float_info[0]
realmin = sys.float_info[3]
loglik_threshold = 1e-10
nbVar, nbData = np.shape(Data)
nbStates = np.size(Priors0)
loglik_old = -realmax
nbStep = 0
Mu = Mu0
Sigma = Sigma0
Priors = Priors0
Pix = np.ndarray(shape = (nbStates, nbData))
Pxi = np.ndarray(shape = (nbData, nbStates))
while 1:
for i in range (0,nbStates):
Pxi[:,i] = gaussPDF(Data,Mu[:,i],Sigma[:,:,i])
Pix_tmp = np.multiply(np.tile(Priors, (nbData, 1)),Pxi)
Pix = np.divide(Pix_tmp,np.tile(np.reshape(np.sum(Pix_tmp,1), (nbData, 1)), (1, nbStates)))
E = np.sum(Pix, 0)
Priors = np.reshape(Priors, (nbStates))
for i in range (0,nbStates):
Priors[i] = E[i]/nbData
Mu[:,i] = np.dot(Data,Pix[:,i])/E[i]
Data_tmp1 = Data - np.tile(np.reshape(Mu[:,i], (nbVar, 1)), (1,nbData))
a = np.transpose(Pix[:, i])
b = np.reshape(a, (1, nbData))
c = np.tile(b, (nbVar, 1))
d = c*Data_tmp1
e = np.transpose(Data_tmp1)
f = np.dot(d,e)
Sigma[:,:,i] = f/E[i]
Sigma[:,:,i] = Sigma[:,:,i] + 0.00001 * np.diag(np.diag(np.ones((nbVar,nbVar))))
for i in range (0,nbStates):
Pxi[:,i] = gaussPDF(Data,Mu[:,i],Sigma[:,:,i])
F = np.dot(Pxi,np.transpose(Priors))
indexes = np.nonzero(F<realmin)
indexes = list(indexes)
indexes = np.reshape(indexes,np.size(indexes))
F[indexes] = realmin
F = np.reshape(F, (nbData, 1))
loglik = np.mean(np.log10(F), 0)
if np.absolute((loglik/loglik_old)-1)<loglik_threshold:
break
loglik_old = loglik
nbStep = nbStep+1
return(Priors,Mu,Sigma, Pix)
开发者ID:BatyaGG,项目名称:Gaussian-Mixture-Models,代码行数:51,代码来源:EM.py本文标签属性:
示例:示例图
代码:代码零九
Python:Python