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


Python QgsStringStatisticalSummary.displayName方法代码示例

本文整理汇总了Python中qgis.core.QgsStringStatisticalSummary.displayName方法的典型用法代码示例。如果您正苦于以下问题:Python QgsStringStatisticalSummary.displayName方法的具体用法?Python QgsStringStatisticalSummary.displayName怎么用?Python QgsStringStatisticalSummary.displayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.core.QgsStringStatisticalSummary的用法示例。


在下文中一共展示了QgsStringStatisticalSummary.displayName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testIndividualStats

# 需要导入模块: from qgis.core import QgsStringStatisticalSummary [as 别名]
# 或者: from qgis.core.QgsStringStatisticalSummary import displayName [as 别名]
    def testIndividualStats(self):
        # tests calculation of statistics one at a time, to make sure statistic calculations are not
        # dependent on each other
        tests = [{'stat': QgsStringStatisticalSummary.Count, 'expected': 9},
                 {'stat': QgsStringStatisticalSummary.CountDistinct, 'expected': 6},
                 {'stat': QgsStringStatisticalSummary.CountMissing, 'expected': 2},
                 {'stat': QgsStringStatisticalSummary.Min, 'expected': 'aaaa'},
                 {'stat': QgsStringStatisticalSummary.Max, 'expected': 'eeee'},
                 {'stat': QgsStringStatisticalSummary.MinimumLength, 'expected': 0},
                 {'stat': QgsStringStatisticalSummary.MaximumLength, 'expected': 8},
                 ]

        s = QgsStringStatisticalSummary()
        s3 = QgsStringStatisticalSummary()
        for t in tests:
            # test constructor
            s2 = QgsStringStatisticalSummary(t['stat'])
            self.assertEqual(s2.statistics(), t['stat'])

            s.setStatistics(t['stat'])
            s3.setStatistics(t['stat'])
            self.assertEqual(s.statistics(), t['stat'])

            strings = ['cc', 'aaaa', 'bbbbbbbb', 'aaaa', 'eeee', '', 'eeee', '', 'dddd']
            s.calculate(strings)
            s3.reset()
            for string in strings:
                s3.addString(string)
            s3.finalize()

            self.assertEqual(s.statistic(t['stat']), t['expected'])
            self.assertEqual(s3.statistic(t['stat']), t['expected'])

            # display name
            self.assertTrue(len(QgsStringStatisticalSummary.displayName(t['stat'])) > 0)
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:37,代码来源:test_qgsstringstatisticalsummary.py

示例2: testIndividualStats

# 需要导入模块: from qgis.core import QgsStringStatisticalSummary [as 别名]
# 或者: from qgis.core.QgsStringStatisticalSummary import displayName [as 别名]
    def testIndividualStats(self):
        # tests calculation of statistics one at a time, to make sure statistic calculations are not
        # dependent on each other
        tests = [
            {"stat": QgsStringStatisticalSummary.Count, "expected": 9},
            {"stat": QgsStringStatisticalSummary.CountDistinct, "expected": 6},
            {"stat": QgsStringStatisticalSummary.CountMissing, "expected": 2},
            {"stat": QgsStringStatisticalSummary.Min, "expected": "aaaa"},
            {"stat": QgsStringStatisticalSummary.Max, "expected": "eeee"},
            {"stat": QgsStringStatisticalSummary.MinimumLength, "expected": 0},
            {"stat": QgsStringStatisticalSummary.MaximumLength, "expected": 8},
            {"stat": QgsStringStatisticalSummary.MeanLength, "expected": 3.3333333333333335},
        ]

        s = QgsStringStatisticalSummary()
        s3 = QgsStringStatisticalSummary()
        for t in tests:
            # test constructor
            s2 = QgsStringStatisticalSummary(t["stat"])
            self.assertEqual(s2.statistics(), t["stat"])

            s.setStatistics(t["stat"])
            s3.setStatistics(t["stat"])
            self.assertEqual(s.statistics(), t["stat"])

            strings = ["cc", "aaaa", "bbbbbbbb", "aaaa", "eeee", "", "eeee", "", "dddd"]
            s.calculate(strings)
            s3.reset()
            for string in strings:
                s3.addString(string)
            s3.finalize()

            self.assertEqual(s.statistic(t["stat"]), t["expected"])
            self.assertEqual(s3.statistic(t["stat"]), t["expected"])

            # display name
            self.assertTrue(len(QgsStringStatisticalSummary.displayName(t["stat"])) > 0)
开发者ID:spono,项目名称:QGIS,代码行数:39,代码来源:test_qgsstringstatisticalsummary.py


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