Skip to content

Fix Incorrect EntityList equality evaluation #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aidanc-ansys
Copy link
Collaborator

EntityList equality evaluation was previously evaluating whether the first list was a subset of the second. The new behaviour is as expected.

@aidanc-ansys aidanc-ansys self-assigned this Jun 19, 2025
@aidanc-ansys aidanc-ansys added the bug Something isn't working label Jun 19, 2025
Copy link

codecov bot commented Jun 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.67%. Comparing base (d9471c8) to head (a18fc30).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #537      +/-   ##
==========================================
+ Coverage   88.66%   88.67%   +0.01%     
==========================================
  Files          21       21              
  Lines        2487     2491       +4     
==========================================
+ Hits         2205     2209       +4     
  Misses        282      282              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -2139,6 +2139,9 @@ def _entities_same_with_direction(entities_1, entities_2):
else:
return False

if len(self) != len(entities_to_compare):
return False
Copy link
Contributor

@james-packer james-packer Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code coverage warning is flagging up that there's a subtle problem here. Because our EntityList inherits from list, which defines an empty __ne__(self, other), unless our EntityList re-defines __ne__, != is not the opposite of ==, and checking ent1 != ent2 if ent1 and ent2 are lists, isn't actually calling our comparison code at all!

To resolve this, I think we just need to add a new method in EntityList that is just

def __ne__(self, other):
    """Compare difference of 2 EntityList objects."""
    return not self == other

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks! I believe with that, it's now working as it should

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants