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
Typecheck conditions p3 #17
Conversation
…ypecheck_conditions_p3 # Conflicts: # ConfigSpace/conditions.py # ConfigSpace/hyperparameters.py
|
Is this PR ready for a review? |
yes its ready:) |
@@ -64,19 +65,19 @@ def evaluate(self, instantiated_parent_hyperparameter): | |||
pass | |||
|
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.
Please annotate all abstract methods as well.
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.
done
ConfigSpace/conditions.py
Outdated
@@ -134,27 +136,28 @@ def __init__(self, *args): | |||
raise ValueError("All Conjunctions and Conditions must have " | |||
"the same child.") | |||
|
|||
def get_descendant_literal_conditions(self): | |||
children = [] | |||
def get_descendant_literal_conditions(self) -> List[ConditionComponent]: |
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.
Wouldn't this only return AbstractCondition? If it is a conjunction, it is replaced by all conditions which make up the conjunction.
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.
first line of this function initializes a list which is filled and returned. that list might only have one item but it will make the return type list
ConfigSpace/conditions.py
Outdated
def get_descendant_literal_conditions(self): | ||
children = [] | ||
def get_descendant_literal_conditions(self) -> List[ConditionComponent]: | ||
children = [] # type: List[ConditionComponent] |
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.
AbstractCondition as well?
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.
same as above
ConfigSpace/conditions.py
Outdated
for component in self.components: | ||
parents.extend(component.get_parents()) | ||
return parents | ||
|
||
# TODO: find typeof _evaluate? |
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.
bool
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.
fixed
ConfigSpace/conditions.py
Outdated
@@ -180,7 +183,8 @@ def _evaluate(self, evaluations): | |||
|
|||
|
|||
class EqualsCondition(AbstractCondition): | |||
def __init__(self, child, parent, value): | |||
# ToDo: typeof value? |
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.
Since all hyperparameter values so far are Union[str, float, int]
, this can be the same.
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.
done
ConfigSpace/conditions.py
Outdated
@@ -301,18 +309,19 @@ def __repr__(self): | |||
retval.write(")") | |||
return retval.getvalue() | |||
|
|||
def _evaluate(self, evaluations): | |||
# TODO: type of evaluations? |
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.
Please remove this todo.
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.
removed
ConfigSpace/hyperparameters.py
Outdated
return 0 | ||
|
||
def get_neighbors(self, value, rs, number, transform=False): | ||
def get_neighbors(self, value: Any, rs: Any, number: int, transform: bool = False) -> List: |
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.
rs should not be of type Any, but np.random.RandomState
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.
fixed
ConfigSpace/hyperparameters.py
Outdated
return True | ||
|
||
def get_num_neighbors(self): | ||
def get_num_neighbors(self, value=None) -> np.inf: |
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.
np.inf is of type np.float, right?
ConfigSpace/hyperparameters.py
Outdated
return True | ||
|
||
def get_order(self, value: Union[int, float]) -> Union[int, float]: | ||
return value |
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.
What is this supposed to do?
ConfigSpace/hyperparameters.py
Outdated
|
||
def get_order(self, value: Union[None, int, str, float]) -> Union[None, int, str, float]: | ||
""" | ||
returns the seuence position/order of a certain value from the sequence |
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.
This is not what the function does.
This review submission did not work as expected. Please fix the mentioned issues. We should then discuss the how the approach of condition can be generalized in person. |
@smohsinali this PR has a conflict now. Please resolve. |
No description provided.