Skip to content

Conversation

boombard
Copy link

Issue #665

mypy now passes when run on core.algorithm. I tried to avoid changing anything substantial. The tests are passing to the same extent as in main.

Because I was avoiding changing anything too much, there are a lot of ignore statements (there's only so much one can do with annotations).


# filter the index to have individual where not all attributes have been evaluated
if skip_already_evaluated:
I = [i for i, ind in enumerate(pop) if not all([e in ind.evaluated for e in evaluate_values_of])]
Copy link
Author

Choose a reason for hiding this comment

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

Consistent with I below


class Population(np.ndarray):

def __new__(cls, individuals=[]):
Copy link
Author

Choose a reason for hiding this comment

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

Mutable defaults are generally bad, so thought it would be okay to change this

def merge(a: Population | np.ndarray | Individual | None, b: Population | np.ndarray | Individual | None) -> Population:
if a is None:
return b
assert b is not None, "Merge requires at least on non-empty Individual"
Copy link
Author

Choose a reason for hiding this comment

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

Does this follow the intention here?

if problem is None:
from pymoo.core.problem import Problem
problem = Problem()
# TODO: this line is probably never evaluated. It would raise as Problem is ABC
Copy link
Author

Choose a reason for hiding this comment

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

FYI

"""
# set decision variable vector to None
self._X = None
self._X: np.ndarray | None = None
Copy link
Author

Choose a reason for hiding this comment

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

Is it necessary to assign None to these, or could they be empty as in reset below?

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

Successfully merging this pull request may close these issues.

1 participant