Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def visitPipeline(self, op:Ops.PlannedPipeline)->Dict[str,Any]:
defaults_list:Iterable[Dict[str,Any]] = (
nest_HPparams(s.name(), accept(s, self)) for s in op.steps())
defaults:Dict[str,Any] = {}
for d in defaults_list:
defaults.update(d)
return defaults
def array_single_str_(self, space:SearchSpaceArray, path:str, num, useCounter=True)->str:
p = _mk_label(path, num, useCounter=useCounter) + "_"
ret = "(" if space.is_tuple else "["
items:Iterable[SearchSpace] = space.items()
ret += ",".join((accept(sub, self, p, counter=x, useCounter=useCounter) for x,sub in enumerate(items)))
ret += ")" if space.is_tuple else "]"
return ret
def visitSearchSpaceOperator(self, op:SearchSpaceOperator)->SearchSpaceGridInternalType:
return accept(op.sub_space, self)
def asexpr(key, e):
nonlocal child_counter
if e is None:
return None
else:
ee = accept(e, self, path + "_" + key, counter=child_counter)
if child_counter is None:
child_counter = 1
else:
child_counter = child_counter + 1
return ee
def visitSearchSpaceProduct(self, prod:SearchSpaceProduct, path:str, counter=None, useCounter=True):
search_spaces = (accept(space, self, self.get_unique_name(make_indexed_name(name, index))) for name, index, space in prod.get_indexed_spaces())
return "[" + ",".join(search_spaces) + "]"
def _searchSpaceList(self, space:SearchSpaceArray, *, size:int)->List[SearchSpaceGrid]:
sub_spaces = space.items(max=size)
param_grids:List[List[SearchSpaceGrid]] = \
[nest_all_HPparams(str(index), self.fixupDegenerateSearchSpaces(accept(sub,self))) for index,sub in enumerate(sub_spaces)]
param_grids_product:Iterable[Iterable[SearchSpaceGrid]] = itertools.product(*param_grids)
chained_grids:List[SearchSpaceGrid] = [
dict(ChainMap(*gridline,)) for gridline in param_grids_product]
if space.is_tuple:
st_val = structure_type_tuple
else:
st_val = structure_type_list
discriminated_grids:List[SearchSpaceGrid]=[{**d, structure_type_name:SearchSpaceConstant(st_val)} for d in chained_grids]
return discriminated_grids
def visitOperatorChoice(self, op:Ops.OperatorChoice)->Dict[str,Any]:
defaults_list:Iterable[Dict[str,Any]] = (
accept(s, self) for s in op.steps())
defaults : Dict[str,Any] = {}
for d in defaults_list:
defaults.update(d)
return defaults
def cstr(key, x):
nonlocal child_counter
if x is None:
return "None"
else:
s = accept(x, self, path + "_" + key, child_counter, useCounter=useCounter)
if child_counter is None:
child_counter = 1
else:
child_counter = child_counter + 1
return s
def visitSearchSpaceOperator(self, op:SearchSpaceOperator, path:str, counter=None):
return scope.make_nested_hyperopt(accept(op.sub_space, self, path))
def array_single_expr_(self, space:SearchSpaceArray, path:str, num):
p = _mk_label(path, num) + "_"
items:Iterable[SearchSpace] = space.items()
ret = [accept(sub, self, p, counter=x) for x,sub in enumerate(items)]
return tuple(ret) if space.is_tuple else ret