From 02fab6eee219d4d04d2847379343af29cb4c3c3f Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 6 Feb 2026 16:35:04 +1100 Subject: [PATCH] Fix #7634. Support formatting signed numbers. --- src/ifcopenshell-python/ifcopenshell/util/selector.py | 2 +- src/ifcopenshell-python/test/util/test_selector.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index abcba23a0f..17051d6917 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -144,7 +144,7 @@ format_grammar = lark.Lark( | mul_div "*" function -> multiply | mul_div "/" function -> divide - function: round | number | int | format_length | lower | upper | title | concat | substr | variable | ESCAPED_STRING | NUMBER | "(" expression ")" + function: round | number | int | format_length | lower | upper | title | concat | substr | variable | ESCAPED_STRING | SIGNED_NUMBER | "(" expression ")" variable: "{{" query_path "}}" query_path: /[^}]+/ diff --git a/src/ifcopenshell-python/test/util/test_selector.py b/src/ifcopenshell-python/test/util/test_selector.py index 0b90f3b278..959cacd02d 100644 --- a/src/ifcopenshell-python/test/util/test_selector.py +++ b/src/ifcopenshell-python/test/util/test_selector.py @@ -54,6 +54,7 @@ class TestFormat: def test_number_formatting(self): assert subject.format("round(123, 5)") == "125" assert subject.format('round("123", 5)') == "125" + assert subject.format('round(-123, 5)') == "-125" assert subject.format("int(123.123)") == "123" assert subject.format("int(123)") == "123" assert subject.format("number(123)") == "123"