本文整理匯總了Python中pyaid.number.NumericUtils.NumericUtils.linearSpace方法的典型用法代碼示例。如果您正苦於以下問題:Python NumericUtils.linearSpace方法的具體用法?Python NumericUtils.linearSpace怎麽用?Python NumericUtils.linearSpace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyaid.number.NumericUtils.NumericUtils
的用法示例。
在下文中一共展示了NumericUtils.linearSpace方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_linearSpace
# 需要導入模塊: from pyaid.number.NumericUtils import NumericUtils [as 別名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import linearSpace [as 別名]
def test_linearSpace(self):
"""test_linearSpace doc..."""
result = NumericUtils.linearSpace(0.0, 1.0, 10)
self.assertTrue(len(result) == 10)
self.assertAlmostEqual(0, result[0])
self.assertAlmostEqual(1.0, result[-1])
result = NumericUtils.linearSpace(-25.0, 25.0, 51)
self.assertTrue(len(result) == 51)
self.assertAlmostEqual(-25.0, result[0])
self.assertAlmostEqual(25.0, result[-1])
try:
self.assertTrue(result.index(0.0))
except Exception:
self.fail('Unexpected linear spacing')
示例2: process
# 需要導入模塊: from pyaid.number.NumericUtils import NumericUtils [as 別名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import linearSpace [as 別名]
def process(self, session, difference =True):
"""Doc..."""
if self.results is not None:
return True
results = []
model = Tracks_Track.MASTER
if session is None:
session = model.createSession()
trackStores = session.query(model).all()
index = 0
indices = NumericUtils.linearSpace(0, len(trackStores), roundToIntegers=True)[1:]
for trackStore in trackStores:
track = trackStore.getMatchingTrack(session)
if track is None:
self.modifications += 1
results.append({'uid':trackStore.uid, 'action':self.DELETED_IDENTIFIER})
self.logger.write(
u'<div>DELETED: %s</div>' % DictUtils.prettyPrint(
trackStore.toDict(uniqueOnly=True)))
else:
if difference:
diff = trackStore.toDiffDict(track.toDict())
if diff is not None:
self.modifications += 1
results.append(diff)
self.logger.write(
u'<div>MODIFIED: %s</div>' % trackStore.fingerprint)
else:
results.append(track.toDict())
index += 1
if index in indices:
self.logger.write(
u'<div style="color:#33CC33">%s%% Complete</div>' % StringUtils.toUnicode(
10*(indices.index(index) + 1)))
self.logger.write(u'<div style="color:#33CC33">100% Complete</div>')
self.results = results
return True