Skip to content

Commit

Permalink
Address failing IFC102 and SPS007
Browse files Browse the repository at this point in the history
  • Loading branch information
aothms committed Dec 28, 2024
1 parent ee42006 commit 6854cb0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions features/IFC102_Absence-of-deprecated-entities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ IFC4: https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2_TC1/HTML/
Given A model with Schema "IFC4.3"
Given an <Entity>

Then its type is not <Entity> excluding subtypes
Then its type is not "<Entity>" excluding subtypes

Examples:
| Entity |
Expand All @@ -270,7 +270,7 @@ IFC4: https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2_TC1/HTML/
Given A model with Schema "IFC4"
Given an <Entity>

Then its type is not <Entity> excluding subtypes
Then its type is not "<Entity>" excluding subtypes

Examples:
| Entity |
Expand All @@ -289,7 +289,7 @@ IFC4: https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2_TC1/HTML/
Given A model with Schema "IFC2X3"
Given an <Entity>

Then its type is not <Entity> excluding subtypes
Then its type is not "<Entity>" excluding subtypes

Examples:
| Entity |
Expand Down
32 changes: 16 additions & 16 deletions features/steps/givens/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,39 +75,39 @@ def step_impl(context, inst, comparison_op, attribute, value, tail=SubTypeHandli
"""
start_value = value
pred = operator.eq

def negate(fn):
def inner(*args):
return not fn(*args)
return inner

if value == 'empty':
value = ()
elif value == 'not empty':
value = ()
pred = operator.ne
elif comparison_op == ComparisonOperator.NOT_EQUAL: # avoid using != together with (not)empty stmt
pred = operator.ne
try:
value = set(map(ast.literal_eval, map(str.strip, value.split(' or '))))
except ValueError:
print('ValueError: entity must be typed in quotes')
else:
try:
value = ast.literal_eval(value)
except ValueError:
# Check for multiple values, for example `PredefinedType = 'POSITION' or 'STATION'`.
value = set(map(ast.literal_eval, map(str.strip, value.split(' or '))))
pred = misc.reverse_operands(operator.contains)
pred = operator.contains

if comparison_op == ComparisonOperator.NOT_EQUAL: # avoid using != together with (not)empty stmt
pred = negate(pred)

entity_is_applicable = False
observed_v = ()
if attribute.lower() in ['its type', 'its entity type']: # it's entity type is a special case using ifcopenshell 'is_a()' func
observed_v = misc.do_try(lambda : inst.is_a(), ())
values = {value} if isinstance(value, str) else value
if any(check_entity_type(inst, v, tail) for v in values):
entity_is_applicable = True
if isinstance(value, set):
values = [check_entity_type(inst, v, tail) for v in value]
else:
values = check_entity_type(inst, value, tail)
entity_is_applicable = pred(values, True)
else:
observed_v = getattr(inst, attribute, ()) or ()
if comparison_op.name == 'NOT_EQUAL':
if all(pred(observed_v, v) for v in value):
entity_is_applicable = True
elif pred(observed_v, value):
entity_is_applicable = True
entity_is_applicable = pred(value, observed_v)

if entity_is_applicable:
yield ValidationOutcome(instance_id=inst, severity = OutcomeSeverity.PASSED)
Expand Down

0 comments on commit 6854cb0

Please sign in to comment.