Exemple #1
0
 def __init__(self, pypinm, deps=None, import_nm=None, path=None):
     store_attr('pypinm,deps')
     self.import_nm = ifnone(import_nm, pypinm)
     try:
         self.ver = str(latest_pypi(pypinm))
     except:
         raise ValueError(f'package name: {pypinm} not found on pypi.')
     self.info = pypi_json(f'{pypinm}/{self.ver}')['info']
     self.path = _mkdir(ifnone(path, self.pypinm))
     self.meta = {
         'package': {
             'name': self.pypinm,
             'version': self.ver
         },
         'build': {
             'number': 0,
             'binary_relocation': False,
             'detect_binary_files_with_prefix': False
         },
         'requirements': {
             'host': ['pip', 'python'],
             'run': ['python'] + list(L(self.deps))
         },
         'test': {
             'imports': [self.import_nm],
             'requires': ['pip']
         },
         'about': {
             'home': self.info['home_page'],
             'summary': self.info['summary'],
             'license': self.info['license']
         },
         'extra': {
             'recipe-maintainers': ['jph00']
         }
     }
Exemple #2
0
def tx(xs):
    return L(xs).map(list).map(set).reduce(lambda a, b: a | b)
def fit(self: Learner, epochs, lr, cbs, reset_opt=False, wd=None):
    """Default Fit 'self.model' for 'n_cycles' with 'lr' using 'cbs'. Optionally 'reset_opt'.
    For run from script with hydra config"""
    self.fit(epochs, lr, cbs=L(cbs), reset_opt=reset_opt, wd=wd)
Exemple #4
0
 def all_params(self, n=slice(None), with_grad=False):
     "List of `param_groups` upto n"
     res = L(p for p in self.param_lists[n])
     return (L(o for o in res if hasattr(o, "grad") and o.grad is not None)
             if with_grad else res)
Exemple #5
0
def xform(xs):
    l = L(xs).map(xform_item).filter(lambda x: x and x != "no other")
    return (l[0], l[1:])
Exemple #6
0
 def __init__(self, x, raw=False):
     if raw:
         self.t = x
     else:
         self.t = L(map(tuplify, x))
Exemple #7
0
def part1(xs):
    xs = L(xs)
    row = walk(list(xs[0]), 0, 127)
    seat = walk(list(xs[1]), 0, 7)
    return row * 8 + seat
Exemple #8
0
def logic(x, n):
    return L(combinations(x.col(),
                          n)).filter(lambda x: sum(x) == 2020).map(prod)[0]
Exemple #9
0
 def _(self, other):
     self.logs.append(L(operator, other))
     return self
Exemple #10
0
 def __init__(self, message):
     store_attr()
     self.logs = L()
Exemple #11
0
 def exec(itr):
     return L(f(e) for e in itr)
Exemple #12
0
 def __init__(self, default = _NoMatchError,): 
     store_attr()
     self.cases = L()
     self.preprocesses = L()