本文整理匯總了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)