本文整理匯總了Python中pyaid.number.NumericUtils.NumericUtils.sqrtSumOfSquares方法的典型用法代碼示例。如果您正苦於以下問題:Python NumericUtils.sqrtSumOfSquares方法的具體用法?Python NumericUtils.sqrtSumOfSquares怎麽用?Python NumericUtils.sqrtSumOfSquares使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyaid.number.NumericUtils.NumericUtils
的用法示例。
在下文中一共展示了NumericUtils.sqrtSumOfSquares方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _calculateAverageSpacing
# 需要導入模塊: from pyaid.number.NumericUtils import NumericUtils [as 別名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import sqrtSumOfSquares [as 別名]
def _calculateAverageSpacing(cls, series):
""" Determines the average spacing of the tracks in the track series for use as a
comparative measure of sparseness to the other track series in the trackway. If the
series is not ready or does not have a sufficient number of tracks, this method will
return None.
:param: series | TrackSeries
The series on which to determine the average spacing.
:return: ValueUncertainty
A value uncertainty instance that represents the average spacing of the series,
or None if it's the calculation is aborted. """
if not series.isReady:
# Skip trackways with invalid series
return None
tracks = series.tracks
if not tracks or len(tracks) < 2:
# Ignore series with less than two tracks
return None
length = 0.0
uncs = []
for i in ListUtils.range(len(tracks) - 1):
line = LineSegment2D(
start=tracks[i].positionValue,
end=tracks[i + 1].positionValue)
spacing = line.length
length += spacing.value
uncs.append(spacing.uncertainty)
unc = NumericUtils.sqrtSumOfSquares(*uncs)
return NumericUtils.toValueUncertainty(
value=length/float(len(tracks)),
uncertainty=unc/float(len(tracks)) )
示例2: test_sqrtSumOfSquares
# 需要導入模塊: from pyaid.number.NumericUtils import NumericUtils [as 別名]
# 或者: from pyaid.number.NumericUtils.NumericUtils import sqrtSumOfSquares [as 別名]
def test_sqrtSumOfSquares(self):
"""test_sqrtSumOfSquares doc..."""
self.assertEqual(1.0, NumericUtils.sqrtSumOfSquares(-1.0))
self.assertEqual(math.sqrt(2), NumericUtils.sqrtSumOfSquares(1.0, 1.0))
self.assertEqual(math.sqrt(4.25), NumericUtils.sqrtSumOfSquares(2.0, 0.5))