Skip to content
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

checks for sum_constraint leads to errors in utils.py #307

Closed
sqbl opened this issue Dec 17, 2024 · 2 comments
Closed

checks for sum_constraint leads to errors in utils.py #307

sqbl opened this issue Dec 17, 2024 · 2 comments

Comments

@sqbl
Copy link
Collaborator

sqbl commented Dec 17, 2024

As title says.

During instantiation of a constraint-class, all types of constraints are added (e.g. constraints.py l. 30). This means that when utils.py (e.g. l 296) checks for hasattr(constraint, "sum_equals") it will always get a "True".

Solutions (?): Make a factory-class for constraints that only add attributes based on input from user or change the checks for sum_constraint in utils.py (?)

Finally, we should likely add some tests to ensure that "old" constraints are still working

@SRFU-NN
Copy link
Collaborator

SRFU-NN commented Jan 8, 2025

If there are no sum constraints, constraint.sum_equal is an empty list, right? So could we "just" change if hasattr(res.constraints, "sum_equals"): to if len(res.constraints)>0: in the lines 276 and 296? They are the only places in the repo where "sum_equals" is used.

But we absolutely need tests. It seems like the problem is localized to expected_minimum(), which might explain why tests didn't catch it.

@sqbl
Copy link
Collaborator Author

sqbl commented Jan 16, 2025

Fixed with PR #308

@sqbl sqbl closed this as completed Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants