Skip to content

Conversation

@smohsinali
Copy link
Contributor

No description provided.

Copy link
Contributor

@mfeurer mfeurer left a comment

Choose a reason for hiding this comment

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

I added some minor comments. Could you please work on them and also fix the conflict to the master branch?

class AbstractForbiddenComponent(object):
__metaclass__ = ABCMeta

# todo : should absract methods be annotated with types?
Copy link
Contributor

Choose a reason for hiding this comment

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

From my point of view, this is not necessary here. Did mypy complain? If yes, we have to do something about it. Else, please remove the comment. The other abstract methods which should return something should be annotated though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no mypy didnt complain...removed this todo


class AbstractForbiddenClause(AbstractForbiddenComponent):
def get_descendant_literal_clauses(self):
def get_descendant_literal_clauses(self) -> List['AbstractForbiddenClause']:
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 AbstractForbiddenComponent be more appropriate her? Also, why is this a string? Moreover, the definition further below suggests that this function return List[Hyperparameter].

Copy link
Contributor Author

Choose a reason for hiding this comment

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


class SingleValueForbiddenClause(AbstractForbiddenClause):
def __init__(self, hyperparameter, value):
# todo: possible types of hyperparameter valuees?
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid we need to accept Any here. Please remove the comment.

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

self.value = value

def is_forbidden(self, instantiated_hyperparameters, strict=True):
def is_forbidden(self, instantiated_hyperparameters: Hyperparameter, strict: bool=True) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check the code by running it, but I think that instantiated_hyperparameters is a dict. Please also annotate _is_forbidden.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed the type of instantiated_hyperparameters to Dict[str, Union[None, str, float, int]] .
all versions of _is_forbidden are annotated except abstract methods


class MultipleValueForbiddenClause(AbstractForbiddenClause):
def __init__(self, hyperparameter, values):
# todo: type of vals of hp
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

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

class MultipleValueForbiddenClause(AbstractForbiddenClause):
def __init__(self, hyperparameter, values):
# todo: type of vals of hp
def __init__(self, hyperparameter: Hyperparameter, values: Any) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

pass

def get_descendant_literal_clauses(self):
def get_descendant_literal_clauses(self) -> List[Hyperparameter]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update this based on the comment above.

Copy link
Contributor Author

@smohsinali smohsinali Jan 19, 2017

Choose a reason for hiding this comment

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

mypy fails if set to AbstractForbiddenComponent or AbstractForbiddenConjunction at following lines:
dlcs = self.get_descendant_literal_clauses()
for dlc in dlcs:
if dlc.hyperparameter.name not in ihp_names:

return children

def is_forbidden(self, instantiated_hyperparameters, strict=True):
def is_forbidden(self, instantiated_hyperparameters: Hyperparameter, strict: bool=True) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

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

for component in self.components:
e = component.is_forbidden(instantiated_hyperparameters,
strict=strict)
e = component.is_forbidden(instantiated_hyperparameters)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

type of strict is bool so its value should be 'true' or 'false' and not 'strict'

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but strict is a boolean variable that is passed to is_forbidden in line 195; so it won't change till down here.

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

Copy link
Contributor

@mfeurer mfeurer left a comment

Choose a reason for hiding this comment

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

Two more things to do, then we can merge this.

pass

def get_descendant_literal_clauses(self):
# todo: recheck is return type should be AbstractForbiddenComponent or AbstractForbiddenConjunction or Hyperparameter
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please check this with the debugger?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mypy accepts only List[hyperparameter] but according to debugger AbstractForbiddenComponent should also work

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by also? Can both happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from output of debugger it seems that the object of type forbidden has hyperparameter as its keys

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 by adding hyperparameter attribute to AbstractForbiddenComponent

for component in self.components:
e = component.is_forbidden(instantiated_hyperparameters,
strict=strict)
e = component.is_forbidden(instantiated_hyperparameters)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but strict is a boolean variable that is passed to is_forbidden in line 195; so it won't change till down here.

…ypecheck_hyperparameter_p3

# Conflicts:
#	ConfigSpace/hyperparameters.py
@coveralls
Copy link

coveralls commented Jan 20, 2017

Coverage Status

Coverage increased (+0.02%) to 67.359% when pulling 18ea83f on smohsinali:typecheck_forbidden_p3 into a7f2c84 on automl:master.

@coveralls
Copy link

coveralls commented Jan 25, 2017

Coverage Status

Coverage increased (+0.03%) to 67.369% when pulling 2a4c1db on smohsinali:typecheck_forbidden_p3 into a7f2c84 on automl:master.

@mfeurer mfeurer merged commit 89cd0cd into automl:master Jan 25, 2017
@smohsinali smohsinali deleted the typecheck_forbidden_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.

3 participants