Skip to content

Commit

Permalink
fix(model): Include room names in model adjacency checks where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Jul 30, 2024
1 parent e8e4d70 commit 115079f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions honeybee/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ def _validation_message(
error_dict['parents'] = [parents]
return [error_dict]

def _top_parent(self):
"""Get the highest parent object that this object is a part of."""
if getattr(self, '_parent', None) is not None:
rel_obj = self
while getattr(rel_obj, '_parent', None) is not None:
rel_obj = getattr(rel_obj, '_parent')
return rel_obj

@staticmethod
def _validation_message_child(
message, child_obj, detailed=False, code='000000', extension='Core',
Expand Down
13 changes: 9 additions & 4 deletions honeybee/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3282,8 +3282,10 @@ def _self_adj_check(self, obj_type, hb_obj, bc_ids, room_ids, bc_set, detailed):
msgs = []
# first ensure that the object is not referencing itself
if hb_obj.identifier == bc_obj:
msg = '{} "{}" cannot reference itself in its Surface boundary ' \
'condition.'.format(obj_type, hb_obj.full_id)
parent_msg = 'with parent "{}" '.format(hb_obj._top_parent().full_id) \
if hb_obj.has_parent else ''
msg = '{} "{}" {}cannot reference itself in its Surface boundary ' \
'condition.'.format(obj_type, hb_obj.full_id, parent_msg)
msg = self._validation_message_child(
msg, hb_obj, detailed, '000201',
error_type='Self-Referential Adjacency')
Expand All @@ -3299,8 +3301,11 @@ def _self_adj_check(self, obj_type, hb_obj, bc_ids, room_ids, bc_set, detailed):
msgs.append(msg)
# lastly make sure the adjacent object doesn't already have an adjacency
if bc_obj in bc_set:
msg = '{} "{}" is adjacent to object "{}", which has another adjacent ' \
'object in the Model.'.format(obj_type, hb_obj.full_id, bc_obj)
parent_msg = 'with parent "{}" '.format(hb_obj._top_parent().full_id) \
if hb_obj.has_parent else ''
msg = '{} "{}" {}is adjacent to object "{}", which has another adjacent ' \
'object in the Model.'.format(
obj_type, hb_obj.full_id, parent_msg, bc_obj)
msg = self._validation_message_child(
msg, hb_obj, detailed, '000203',
error_type='Object with Multiple Adjacencies')
Expand Down

0 comments on commit 115079f

Please sign in to comment.