本文整理汇总了Python中safe_extras.parameters.float_parameter.FloatParameter.value方法的典型用法代码示例。如果您正苦于以下问题:Python FloatParameter.value方法的具体用法?Python FloatParameter.value怎么用?Python FloatParameter.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe_extras.parameters.float_parameter.FloatParameter
的用法示例。
在下文中一共展示了FloatParameter.value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: age_postprocessor
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def age_postprocessor():
"""Get age postprocessor selectors.
:return: Selectors to activate age postprocessor.
:rtype: list
"""
age = BooleanParameter()
age.name = 'Age'
age.value = True
youth_ratio = FloatParameter()
youth_ratio.name = 'Youth ratio'
youth_ratio.value = get_defaults('YOUTH_RATIO')
youth_ratio.description = tr(
'Youth ratio defines what proportion of the population have not yet '
'achieved financial independence. The age threshold for youth can '
'vary by region - please consult with your local census bureau to find'
'out what the relevant threshold is in your region. InaSAFE does not '
'impose a particular age ratio scheme - it will break down the '
'population according to the thresholds you define for your locality.'
)
adult_ratio = FloatParameter()
adult_ratio.name = 'Adult ratio'
adult_ratio.value = get_defaults('ADULT_RATIO')
adult_ratio.description = tr(
'Adult ratio defines what proportion of the population have '
'passed into adulthood and are not yet aged. The age threshold for '
'adults can vary by region - please consult with your local census '
'bureau to find out what the relevant threshold is in your region. '
'InaSAFE does not impose a particular age ratio scheme - it will '
'break down the population according to the thresholds you define for '
'your locality.'
)
elderly_ratio = FloatParameter()
elderly_ratio.name = 'Elderly ratio'
elderly_ratio.value = get_defaults('ELDERLY_RATIO')
elderly_ratio.description = tr(
'Elderly ratio defines what proportion of the population have '
'passed from adulthood into their later life stage. The age '
'threshold for being considered elderly can vary by region - please '
'consult with your local census bureau to find out what the relevant '
'threshold is in your region. InaSAFE does not impose a particular '
'age ratio scheme - it will break down the population according to '
'the thresholds you define for your locality.'
)
return [age, youth_ratio, adult_ratio, elderly_ratio]
示例2: high_threshold
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def high_threshold():
"""Generate high hazard zone threshold parameter
:return: list of FloatParameter
:rtype: list[FloatParameter]
"""
field = FloatParameter()
field.is_required = True
field.name = 'High Hazard Zone Threshold'
field.precision = 2
field.value = 8
field.minimum_allowed_value = 0
field.maximum_allowed_value = 100
unit_metres = parameter_unit_metres()
field.unit = unit_metres
field.allowed_units = [unit_metres]
field.help_text = tr('High Hazard Zone threshold.')
field.description = tr(
'The threshold of hazard categorized as High Hazard Zone in '
'meter. A zone is categorized as High Hazard Zone if the depth of '
'tsunami inundation is more than Medium Hazard Zone Threshold and '
'less than High Hazard Zone Threshold.'
'A zone that has more than High Hazard Zone Threshold is categorized '
'as Very High Hazard Zone.')
return field
示例3: test_init
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def test_init(self):
"""Test initialize qt4 parameter factory."""
boolean_parameter = BooleanParameter('1231231')
boolean_parameter.name = 'Boolean'
boolean_parameter.help_text = 'A boolean parameter'
boolean_parameter.description = 'A test _description'
boolean_parameter.is_required = True
boolean_parameter.value = True
float_parameter = FloatParameter()
float_parameter.name = 'Float Parameter'
float_parameter.is_required = True
float_parameter.precision = 3
float_parameter.minimum_allowed_value = 1.0
float_parameter.maximum_allowed_value = 2.0
float_parameter.help_text = 'Short help.'
float_parameter.description = 'Long description for parameter.'
float_parameter.unit = 'metres'
float_parameter.value = 1.1
parameters = [boolean_parameter, float_parameter]
qt4_parameter_factory = Qt4ParameterFactory()
widgets = []
widget_classes = []
for parameter in parameters:
widget = qt4_parameter_factory.get_widget(parameter)
widgets.append(widget)
widget_classes.append(widget.__class__)
expected_classes = [BooleanParameterWidget, FloatParameterWidget]
message = 'Expected %s got %s' % (expected_classes, widget_classes)
self.assertListEqual(widget_classes, expected_classes, message)
示例4: test_all
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def test_all(self):
"""Basic test of all properties."""
parameter = FloatParameter()
parameter.is_required = True
parameter.minimum_allowed_value = 1.0
parameter.maximum_allowed_value = 2.0
parameter.value = 1.123
self.assertEqual(1.123, parameter.value)
with self.assertRaises(TypeError):
parameter.value = 'Test'
with self.assertRaises(ValueOutOfBounds):
parameter.value = 3.0
with self.assertRaises(ValueOutOfBounds):
parameter.value = 0.5
示例5: default_field_to_parameter
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def default_field_to_parameter(self, default_field):
"""Obtain parameter from default field.
:param default_field: A default field definition.
:type default_field: dict
:returns: A parameter object.
:rtype: FloatParameter, IntegerParameter
"""
if default_field.get('type') == QVariant.Double:
parameter = FloatParameter()
elif default_field.get('type') in qvariant_whole_numbers:
parameter = IntegerParameter()
else:
return
default_value = default_field.get('default_value')
if not default_value:
message = (
'InaSAFE default field %s does not have default value'
% default_field.get('name'))
LOGGER.exception(message)
return
parameter.guid = default_field.get('key')
parameter.name = default_value.get('name')
parameter.is_required = True
parameter.precision = default_field.get('precision')
parameter.minimum_allowed_value = default_value.get(
'min_value', 0)
parameter.maximum_allowed_value = default_value.get(
'max_value', 100000000)
parameter.help_text = default_value.get('help_text')
parameter.description = default_value.get('description')
# Check if user ask to restore to the most default value.
if self.is_restore_default:
parameter._value = default_value.get('default_value')
else:
# Current value
qsetting_default_value = get_inasafe_default_value_qsetting(
self.settings, GLOBAL, default_field['key'])
# To avoid python error
if qsetting_default_value > parameter.maximum_allowed_value:
qsetting_default_value = parameter.maximum_allowed_value
if qsetting_default_value < parameter.minimum_allowed_value:
qsetting_default_value = parameter.minimum_allowed_value
parameter.value = qsetting_default_value
return parameter
示例6: unaffected_threshold
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def unaffected_threshold():
"""Generate threshold for unaffected region
:returns: A FloatParameter.
:rtype: FloatParameter
"""
field = FloatParameter()
field.is_required = True
field.name = tr('Unaffected Threshold')
field.precision = 2
field.value = 1
field.minimum_allowed_value = 0
field.maximum_allowed_value = 100
field.value = 0.01
unit_centimetres = parameter_unit_centimetres()
field.unit = unit_centimetres
field.allowed_units = [unit_centimetres]
field.help_text = tr('Unaffected threshold.')
field.description = tr(
'The threshold of hazard categorized as Unaffected in '
'centimetres. A zone is categorized as Unaffected if the '
'thickness of ash is less than Unaffected Threshold.')
return field
示例7: low_hazard_class
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def low_hazard_class():
"""Parameter definition.
:returns: Low Hazard Class parameter
:rtype: FloatParameter
"""
field = FloatParameter()
field.name = 'Low Hazard Threshold'
field.element_type = float
field.value = 0.34
field.help_text = tr('Low Hazard class thresholds.')
field.description = tr(
'Threshold value of hazard categorized as Low Hazard class.')
return field
示例8: very_low_threshold
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def very_low_threshold():
"""Generate very low hazard zone threshold parameter
:returns: A FloatParameter.
:rtype: FloatParameter
"""
field = FloatParameter()
field.is_required = True
field.name = tr('Very Low Hazard Zone Threshold')
field.precision = 2
field.value = 1
field.minimum_allowed_value = 0
field.maximum_allowed_value = 100
field.value = 0.1
unit_centimetres = parameter_unit_centimetres()
field.unit = unit_centimetres
field.allowed_units = [unit_centimetres]
field.help_text = tr('Very Low Hazard Zone threshold.')
field.description = tr(
'The threshold of hazard categorized as Very Low Hazard Zone in '
'centimetres. A zone is categorized as Very Low Hazard Zone if the '
'thickness of ash is more than Unaffected threshold and less than '
'Very Low Hazard Zone Threshold.')
return field
示例9: high_hazard_class
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def high_hazard_class():
"""Parameter definition.
:returns: High Hazard Class parameter
:rtype: FloatParameter
"""
field = FloatParameter()
field.name = 'High Hazard Threshold'
field.element_type = float
field.value = 1.0
field.help_text = tr('High Hazard class threshold.')
field.description = tr(
'Threshold value of hazard categorized as High Hazard class. It '
'should be greater than Medium Hazard Thresholds')
return field
示例10: high_hazard_class
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def high_hazard_class():
"""Parameter definition.
:returns: High Hazard Class parameter
:rtype: FloatParameter
"""
field = FloatParameter()
field.name = 'High Hazard Class'
field.element_type = float
field.value = 3.0
unit_generic = parameter_unit_generic()
field.unit = unit_generic
field.allowed_units = [unit_generic]
field.help_text = tr('High Hazard class value.')
field.description = tr(
'The value of hazard categorized as High Hazard class')
return field
示例11: test_set_minimum_allowed_value
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def test_set_minimum_allowed_value(self):
"""Test setter for minimum allowed value."""
parameter = FloatParameter()
with self.assertRaises(TypeError):
parameter.maximum_allowed_value = 'One thousand'
parameter.minimum_allowed_value = 1
parameter.minimum_allowed_value = 1.0
# Also check that it raises an error if it exceeds max
parameter.maximum_allowed_value = 10.0
with self.assertRaises(InvalidMinimumError):
parameter.minimum_allowed_value = 11.0
# Also check that when we set a value it falls within [min, max]
parameter.value = 5
示例12: test_set_maximum_allowed_value
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def test_set_maximum_allowed_value(self):
"""Test setter for maximum allowed value."""
parameter = FloatParameter()
with self.assertRaises(TypeError):
parameter.maximum_allowed_value = 'One million'
parameter.maximum_allowed_value = 1000
parameter.maximum_allowed_value = 11.0
# Also check that it raises an error if it precedes min
parameter.minimum_allowed_value = 10.0
with self.assertRaises(InvalidMaximumError):
parameter.maximum_allowed_value = 1.0
# Also check that when we set a value it falls within [min, max]
parameter.value = 10.5
示例13: evacuation_percentage
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def evacuation_percentage():
"""Generator for the default evaluation percentage parameter.
:return: List of Float parameter
:rtype: list[FloatParameter]
"""
field = FloatParameter()
field.name = 'Evacuation Percentage'
field.is_required = True
field.maximum_allowed_value = 100
field.minimum_allowed_value = 0
field.value = 1
field.precision = 2
unit_percentage = parameter_unit_percentage()
field.unit = unit_percentage
field.allowed_units = [unit_percentage]
field.help_text = tr('Percentage value of affected population.')
field.description = tr(
'The value in percentage of the population that '
'represent the number of people needed to be evacuated.')
return field
示例14: threshold
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def threshold():
"""Generator for the default threshold parameter.
:return: List of FloatParameter
:rtype: list[FloatParameter]
"""
field = FloatParameter()
field.name = tr('Thresholds [m]')
field.is_required = True
field.precision = 2
field.value = 1.0 # default value
unit_metres = parameter_unit_metres()
field.unit = unit_metres
field.allowed_units = [unit_metres]
field.help_text = tr(
'Threshold value to categorize inundated area.')
field.description = tr(
'Hazard value above the threshold in meter will be considered '
'inundated.')
return field
示例15: low_threshold
# 需要导入模块: from safe_extras.parameters.float_parameter import FloatParameter [as 别名]
# 或者: from safe_extras.parameters.float_parameter.FloatParameter import value [as 别名]
def low_threshold():
"""Generate low hazard zone threshold parameter
:return: list of FloatParameter
:rtype: list[FloatParameter]
"""
field = FloatParameter()
field.is_required = True
field.name = 'Low Hazard Zone Threshold'
field.precision = 2
field.value = 1
field.minimum_allowed_value = 0
field.maximum_allowed_value = 100
unit_metres = parameter_unit_metres()
field.unit = unit_metres
field.allowed_units = [unit_metres]
field.help_text = tr('Low Hazard Zone threshold.')
field.description = tr(
'The threshold of hazard categorized as Low Hazard Zone in meter. A '
'zone is categorized as Low Hazard Zone if the depth of tsunami '
'inundation is less than Low Hazard Zone Threshold.')
return field