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