本文整理汇总了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