Apply black formatting

This commit is contained in:
Ghesselink
2026-05-06 11:04:02 +00:00
committed by Thomas Krijnen
parent ab73550059
commit c197a45247
2 changed files with 11 additions and 13 deletions
@@ -420,6 +420,7 @@ class SchemaClass(codegen.Base):
if isinstance(type, nodes.AggregationType): if isinstance(type, nodes.AggregationType):
aggr_type = type.aggregate_type aggr_type = type.aggregate_type
def make_bound(b): def make_bound(b):
# `?` and non-literal bounds (attribute references, arithmetic expressions) collapse to -1. # `?` and non-literal bounds (attribute references, arithmetic expressions) collapse to -1.
# #
@@ -427,6 +428,7 @@ class SchemaClass(codegen.Base):
return int(b) return int(b)
except (TypeError, ValueError): except (TypeError, ValueError):
return -1 return -1
bound1, bound2 = map(make_bound, (type.bounds.lower, type.bounds.upper)) bound1, bound2 = map(make_bound, (type.bounds.lower, type.bounds.upper))
decl_type = get_declared_type(type.type, emitted_names) decl_type = get_declared_type(type.type, emitted_names)
return x.aggregation_type(aggr_type, bound1, bound2, decl_type) return x.aggregation_type(aggr_type, bound1, bound2, decl_type)
@@ -553,6 +555,7 @@ class SchemaClass(codegen.Base):
inv_attrs = [] inv_attrs = []
for attr in type.inverse: for attr in type.inverse:
if attr.bounds: if attr.bounds:
def make_bound(b): def make_bound(b):
# `?` and non-literal bounds (attribute references, arithmetic # `?` and non-literal bounds (attribute references, arithmetic
# expressions) collapse to -1 (unbounded) — the C++ runtime has # expressions) collapse to -1 (unbounded) — the C++ runtime has
@@ -561,6 +564,7 @@ class SchemaClass(codegen.Base):
return int(b) return int(b)
except (TypeError, ValueError): except (TypeError, ValueError):
return -1 return -1
bound1, bound2 = map(make_bound, (attr.bounds.lower, attr.bounds.upper)) bound1, bound2 = map(make_bound, (attr.bounds.lower, attr.bounds.upper))
else: else:
bound1, bound2 = -1, -1 bound1, bound2 = -1, -1
@@ -24,9 +24,7 @@ def _parse(schema_text):
class TestAggregateBounds(unittest.TestCase): class TestAggregateBounds(unittest.TestCase):
def test_literal_bounds_preserved(self): def test_literal_bounds_preserved(self):
"""After loading [1;3] -> (1, 3)?""" """After loading [1;3] -> (1, 3)?"""
s = _parse( s = _parse("SCHEMA t; ENTITY E; v : ARRAY [1:3] OF REAL; END_ENTITY; END_SCHEMA;")
"SCHEMA t; ENTITY E; v : ARRAY [1:3] OF REAL; END_ENTITY; END_SCHEMA;"
)
agg = ( agg = (
next(d for d in s.schema.declarations() if d.name() == "E") next(d for d in s.schema.declarations() if d.name() == "E")
.attributes()[0] .attributes()[0]
@@ -37,10 +35,8 @@ class TestAggregateBounds(unittest.TestCase):
s.disown() s.disown()
def test_unbounded_marker(self): def test_unbounded_marker(self):
""" [0:?] -> (0, -1)?""" """[0:?] -> (0, -1)?"""
s = _parse( s = _parse("SCHEMA t; ENTITY E; v : LIST [0:?] OF REAL; END_ENTITY; END_SCHEMA;")
"SCHEMA t; ENTITY E; v : LIST [0:?] OF REAL; END_ENTITY; END_SCHEMA;"
)
agg = ( agg = (
next(d for d in s.schema.declarations() if d.name() == "E") next(d for d in s.schema.declarations() if d.name() == "E")
.attributes()[0] .attributes()[0]
@@ -56,8 +52,7 @@ class TestAggregateBounds(unittest.TestCase):
Array that is an expression : [1:dim_x*dim_y*dim_z] Array that is an expression : [1:dim_x*dim_y*dim_z]
Parsing must not crash, Bbund must be (1, -1) Parsing must not crash, Bbund must be (1, -1)
""" """
s = _parse( s = _parse("""
"""
SCHEMA t; SCHEMA t;
TYPE IfcBoolean = BOOLEAN; END_TYPE; TYPE IfcBoolean = BOOLEAN; END_TYPE;
@@ -68,8 +63,7 @@ class TestAggregateBounds(unittest.TestCase):
Voxels : ARRAY [1:NumberOfVoxelsX*NumberOfVoxelsY*NumberOfVoxelsZ] OF IfcBoolean; Voxels : ARRAY [1:NumberOfVoxelsX*NumberOfVoxelsY*NumberOfVoxelsZ] OF IfcBoolean;
END_ENTITY; END_ENTITY;
END_SCHEMA; END_SCHEMA;
""" """)
)
holder = next(d for d in s.schema.declarations() if d.name() == "IfcVoxelHolder") holder = next(d for d in s.schema.declarations() if d.name() == "IfcVoxelHolder")
voxels = holder.attributes()[-1].type_of_attribute().as_aggregation_type() voxels = holder.attributes()[-1].type_of_attribute().as_aggregation_type()
self.assertEqual((voxels.bound1(), voxels.bound2()), (1, -1)) self.assertEqual((voxels.bound1(), voxels.bound2()), (1, -1))