Skip to content

Conversation

@smohsinali
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Jan 20, 2017

Coverage Status

Coverage increased (+1.8%) to 69.09% when pulling 69ca427 on smohsinali:typecheck_configuration_p3 into a7f2c84 on automl:master.

# no guarantee that the parent of a condition was evaluated before
self._conditionsals = OrderedDict()
self.forbidden_clauses = []
self._conditionsals = OrderedDict() # type: OrderedDict[str, str]
Copy link
Contributor

Choose a reason for hiding this comment

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

Line 169 suggests that this maps for str to Condition or 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.

line 169 is
self._conditionsals[child_node] = child_node
from here it appears that key and value are equal. debugger also says the same

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, let's discuss this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make it a set

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 still open, right?

return hyperparameter

def add_condition(self, condition):
def add_condition(self, condition: ConditionComponent) -> ConditionComponent:
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this accept and return an abstract condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the first line of this function raises error if input is not of type conditioncomponent
if not isinstance(condition, ConditionComponent):
raise TypeError("The method add_condition must be called "
"with an instance of "
"HPOlibConfigSpace.condition.ConditionComponent.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return type changed to abstractcondition

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right, ConditionComponent is a parent class of AbstractCondition; accepting and returning a ConditionComponent is totally correct.

to_visit.appendleft(current)

by_level = defaultdict(list)
by_level = defaultdict(list) # type: Dict['int', List[str]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not #type: defaultdict[int, List[str]]?

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


def add_configuration_space(self, prefix, configuration_space,
delimiter=":", parent_hyperparameter=None):
def add_configuration_space(self, prefix: str, configuration_space: ConfigSpace,
Copy link
Contributor

Choose a reason for hiding this comment

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

It should accept and return ConfigurationSpace, right?

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

def get_child_conditions_of(self, name: Union[str, Hyperparameter]) -> List[AbstractCondition]:
if isinstance(name, Hyperparameter):
name = name.name
name = name.name # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

What about # type: str?

Copy link
Contributor Author

@smohsinali smohsinali Jan 20, 2017

Choose a reason for hiding this comment

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

i thought so too but mypy gives following error which doesnt make any sense
configuration_space.py:413: error: Some element of union has no attribute "name"

self._num_hyperparameters = len(self.configuration_space._hyperparameters)
self.origin = origin
self._keys = None
self._keys = None # type: ignore
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

@smohsinali smohsinali Jan 20, 2017

Choose a reason for hiding this comment

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

changed to Union[None, List[str]]

# hyperparameters in the configuration are sorted in the same way as
# they are sorted in the configuration space
self._values = dict()
self._values = dict() # type: ignore
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.

changed

return self._values[item]

def get(self, item, default=None):
# todo: find return type of get
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is correct.

return default

def __contains__(self, item):
# todo: recheck
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be bool I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return type changed to bool


def get_dictionary(self):
# todo: recheck
def get_dictionary(self) -> Any:
Copy link
Contributor

Choose a reason for hiding this comment

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

This returns a dictionary ;)

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 to Dict[str, Union[str, float, int]]

@mfeurer
Copy link
Contributor

mfeurer commented Jan 20, 2017

Could you please also make the sorting in line 648 deterministic to prevent stochastic failure of unit tests?

@coveralls
Copy link

coveralls commented Jan 20, 2017

Coverage Status

Coverage increased (+0.01%) to 67.349% when pulling b234a5a on smohsinali:typecheck_configuration_p3 into a7f2c84 on automl:master.

@coveralls
Copy link

coveralls commented Jan 25, 2017

Coverage Status

Coverage increased (+0.01%) to 67.349% when pulling d18d240 on smohsinali:typecheck_configuration_p3 into a7f2c84 on automl:master.

return hyperparameter

def add_condition(self, condition: ConditionComponent) -> ConditionComponent:
def add_condition(self, condition: ConditionComponent) -> AbstractCondition:
Copy link
Contributor

Choose a reason for hiding this comment

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

This was correct before, please revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted

@mfeurer
Copy link
Contributor

mfeurer commented Jan 25, 2017

Please also remove all TODOs that you added regarding types; together with the two changes to go, this will be ready to merge.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 67.328% when pulling a40973a on smohsinali:typecheck_configuration_p3 into a7f2c84 on automl:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 67.328% when pulling a40973a on smohsinali:typecheck_configuration_p3 into a7f2c84 on automl:master.

@mfeurer mfeurer merged commit ea2a3cf into automl:master Jan 25, 2017
@smohsinali smohsinali deleted the typecheck_configuration_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