def __init__(self,
to_nearest = 1,
rounding = ROUND_HALF_UP,
result_type = DecimalType,
):
# type: (Union[int, Text, DecimalType], Text, type) -> None
"""
:param to_nearest:
The value that the filter should round to.
E.g., ``Round(1)`` rounds to the nearest whole number.
If you want to round to a float value, it is recommended
that you provide it as a string or Decimal, to avoid
floating point problems.
:param rounding:
Controls how to round values.
:param result_type:
The type of result to return.
"""
super(Round, self).__init__()
self.to_nearest = DecimalType(to_nearest)
# Rounding to negative values isn't supported.
# I'm not even sure if that concept is valid.
Min(DecimalType('0')).apply(self.to_nearest)
self.result_type = result_type
self.rounding = rounding
评论列表
文章目录