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

Typecheck conditions p3 #17

Merged
merged 16 commits into from Feb 23, 2017
Merged

Conversation

smohsinali
Copy link
Contributor

No description provided.

…ypecheck_conditions_p3

# Conflicts:
#	ConfigSpace/conditions.py
#	ConfigSpace/hyperparameters.py
@smohsinali
Copy link
Contributor Author

smohsinali commented Jan 20, 2017

ERROR: test_greater_and_less_condition (test.test_conditions.TestConditions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/smohsinali/ConfigSpace/test/test_conditions.py", line 131, in test_greater_and_less_condition
    self.assertFalse(gt.evaluate({hp.name: None}))
  File "/home/travis/build/smohsinali/ConfigSpace/ConfigSpace/conditions.py", line 114, in evaluate
    return self._evaluate(instantiated_parent_hyperparameter[hp_name])
  File "/home/travis/build/smohsinali/ConfigSpace/ConfigSpace/conditions.py", line 253, in _evaluate
    return value > self.value
TypeError: unorderable types: NoneType() > int()

@coveralls
Copy link

coveralls commented Jan 27, 2017

Coverage Status

Coverage increased (+0.05%) to 67.39% when pulling a2279ff on smohsinali:typecheck_conditions_p3 into a7f2c84 on automl:master.

@coveralls
Copy link

coveralls commented Feb 3, 2017

Coverage Status

Coverage increased (+0.09%) to 67.414% when pulling 3b3d4f5 on smohsinali:typecheck_conditions_p3 into 4aa95af on automl:master.

@mfeurer
Copy link
Contributor

mfeurer commented Feb 3, 2017

Is this PR ready for a review?

@smohsinali
Copy link
Contributor Author

yes its ready:)

@@ -64,19 +65,19 @@ def evaluate(self, instantiated_parent_hyperparameter):
pass

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -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]:
Copy link
Contributor

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.

Copy link
Contributor Author

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

def get_descendant_literal_conditions(self):
children = []
def get_descendant_literal_conditions(self) -> List[ConditionComponent]:
children = [] # type: List[ConditionComponent]
Copy link
Contributor

Choose a reason for hiding this comment

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

AbstractCondition as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above

for component in self.components:
parents.extend(component.get_parents())
return parents

# TODO: find typeof _evaluate?
Copy link
Contributor

Choose a reason for hiding this comment

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

bool

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -180,7 +183,8 @@ def _evaluate(self, evaluations):


class EqualsCondition(AbstractCondition):
def __init__(self, child, parent, value):
# ToDo: typeof value?
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -301,18 +309,19 @@ def __repr__(self):
retval.write(")")
return retval.getvalue()

def _evaluate(self, evaluations):
# TODO: type of evaluations?
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this todo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

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:
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

return True

def get_num_neighbors(self):
def get_num_neighbors(self, value=None) -> np.inf:
Copy link
Contributor

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?

return True

def get_order(self, value: Union[int, float]) -> Union[int, float]:
return value
Copy link
Contributor

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?


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
Copy link
Contributor

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.

@mfeurer
Copy link
Contributor

mfeurer commented Feb 3, 2017

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.

@coveralls
Copy link

coveralls commented Feb 9, 2017

Coverage Status

Coverage increased (+0.7%) to 68.05% when pulling a472ba0 on smohsinali:typecheck_conditions_p3 into 4aa95af on automl:master.

@coveralls
Copy link

coveralls commented Feb 9, 2017

Coverage Status

Coverage increased (+0.8%) to 68.08% when pulling b75bf78 on smohsinali:typecheck_conditions_p3 into 4aa95af on automl:master.

@coveralls
Copy link

coveralls commented Feb 9, 2017

Coverage Status

Coverage increased (+0.8%) to 68.08% when pulling b75bf78 on smohsinali:typecheck_conditions_p3 into 4aa95af on automl:master.

@mfeurer
Copy link
Contributor

mfeurer commented Feb 10, 2017

@smohsinali this PR has a conflict now. Please resolve.

@coveralls
Copy link

coveralls commented Feb 23, 2017

Coverage Status

Coverage increased (+1.0%) to 68.861% when pulling b46ae45 on smohsinali:typecheck_conditions_p3 into be0ef51 on automl:master.

@mfeurer mfeurer merged commit 9cea3b4 into automl:master Feb 23, 2017
@smohsinali smohsinali deleted the typecheck_conditions_p3 branch June 8, 2017 02:12
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.

None yet

3 participants