本文整理汇总了Python中qgis.core.QgsStringStatisticalSummary.setStatistics方法的典型用法代码示例。如果您正苦于以下问题:Python QgsStringStatisticalSummary.setStatistics方法的具体用法?Python QgsStringStatisticalSummary.setStatistics怎么用?Python QgsStringStatisticalSummary.setStatistics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsStringStatisticalSummary
的用法示例。
在下文中一共展示了QgsStringStatisticalSummary.setStatistics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testIndividualStats
# 需要导入模块: from qgis.core import QgsStringStatisticalSummary [as 别名]
# 或者: from qgis.core.QgsStringStatisticalSummary import setStatistics [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)
示例2: testIndividualStats
# 需要导入模块: from qgis.core import QgsStringStatisticalSummary [as 别名]
# 或者: from qgis.core.QgsStringStatisticalSummary import setStatistics [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)