本文整理汇总了Python中safe.impact_function.impact_function.ImpactFunction.post_process方法的典型用法代码示例。如果您正苦于以下问题:Python ImpactFunction.post_process方法的具体用法?Python ImpactFunction.post_process怎么用?Python ImpactFunction.post_process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe.impact_function.impact_function.ImpactFunction
的用法示例。
在下文中一共展示了ImpactFunction.post_process方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_post_processor
# 需要导入模块: from safe.impact_function.impact_function import ImpactFunction [as 别名]
# 或者: from safe.impact_function.impact_function.ImpactFunction import post_process [as 别名]
def test_post_processor(self):
"""Test for running post processor."""
impact_layer = load_test_vector_layer(
'impact',
'indivisible_polygon_impact.geojson',
clone_to_memory=True)
impact_layer.keywords['hazard_keywords'] = {
'classification': 'flood_hazard_classes'
}
impact_layer.keywords['exposure_keywords'] = {
'exposure': 'structure',
}
def debug_layer(layer, add_to_datastore):
"""Monkey patching because we can't check inasafe_fields.
:param layer: The layer.
:type layer: QgsVectorLayer
:param add_to_datastore: Flag
:type add_to_datastore: bool
"""
# We do nothing here.
return layer, add_to_datastore
impact_function = ImpactFunction()
impact_function.debug_layer = debug_layer
impact_function.post_process(impact_layer)
used_post_processors = [
post_processor_size,
post_processor_male,
post_processor_female,
post_processor_youth,
post_processor_adult,
post_processor_elderly,
]
# Check if new field is added
impact_fields = impact_layer.dataProvider().fieldNameMap().keys()
for post_processor in used_post_processors:
# noinspection PyTypeChecker
for output_value in post_processor['output'].values():
field_name = output_value['value']['field_name']
self.assertIn(field_name, impact_fields)
print_attribute_table(impact_layer, 1)