当前位置: 首页>>代码示例>>Python>>正文


Python NumericUtils.sqrtSumOfSquares方法代码示例

本文整理汇总了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)) )
开发者ID:sernst,项目名称:Cadence,代码行数:40,代码来源:CurveSparsenessStage.py

示例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))
开发者ID:sernst,项目名称:PyAid,代码行数:7,代码来源:Test_NumericUtils.py


注:本文中的pyaid.number.NumericUtils.NumericUtils.sqrtSumOfSquares方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。