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

typing: core algorithm and its imports #666

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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).

@@ -56,7 +58,7 @@ def eval(self,

# 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

import numpy as np

from pymoo.core.individual import Individual


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

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?

@@ -25,7 +25,8 @@ def __init__(self, survival, problem=None) -> None:

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

@@ -63,36 +65,36 @@ def __init__(
in the ``Individual``.
"""
# 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