From e8977979558cfca4e5f13832fa1730d71abfac97 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 8 Sep 2023 11:15:01 +1000 Subject: [PATCH] For convenience, rounding to an integer value now also casts to integer. --- src/ifcopenshell-python/ifcopenshell/util/selector.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index 7216eb5e67..502fe8333b 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -189,7 +189,11 @@ class FormatTransformer(lark.Transformer): def round(self, args): value = args[0] or 0.0 - return str(round(float(value) / float(args[1])) * float(args[1])) + nearest = float(args[1]) + result = round(float(value) / nearest) * nearest + if nearest % 1 == 0: + return str(int(result)) + return str(result) def format_length(self, args): return args[0]