-
Notifications
You must be signed in to change notification settings - Fork 398
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
base: main
Are you sure you want to change the base?
Conversation
@@ -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])] |
There was a problem hiding this comment.
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=[]): |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
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 inmain
.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).