def SPLAY_FORMAT_ADAPTERS__(stdout, stderr): """if the user passes the string "help" for the argument, display help for that format and terminate early. otherwise, do nothing. """ o = stderr.write o('the filename extension can imply a format adapter.\n') o('(or you can specify an adapter explicitly by name.)\n') o('known format adapters (and associated extensions):\n') out = stdout.write # imagine piping output (! errput) (Case3459DP) count = 0 from kiss_rdb import collectionerer _ = collectionerer().SPLAY_STORAGE_ADAPTERS() for (k, ref) in _: _storage_adapter = ref() mod = _storage_adapter.module if mod.STORAGE_ADAPTER_CAN_LOAD_SCHEMALESS_SINGLE_FILES: _these = mod.STORAGE_ADAPTER_ASSOCIATED_FILENAME_EXTENSIONS _these = ', '.join(_these) _surface = f'({_these})' else: _surface = '(schema-based)' _name = k.replace('_', '-') out(f' {_name} {_surface}\n') count += 1 o(f'({count} total.)\n') return 0 # _exitstatus_for_success
def __repr__(i): return '%s=%s' % (i.name, o(name=i.name, lo=i.lo, hi=i.hi, init=i.init, goal=i.goal, touch=i.touch))
def options(prog, before, after, **d): """Convert dictionary 'd' to command line options divided into comand-line groups (one for every key in 'd'.""" parser = argparse.ArgumentParser( prog=prog, description=before, epilog=after, formatter_class=argparse.RawTextHelpFormatter) inside, out = {}, o() for context in sorted(d.keys()): out[context] = o() description = d[context][0] group = parser.add_argument_group(context, description) for key, rest in d[context][1:]: group.add_argument("--" + key, **rest) assert key not in inside, 'keys cannot repeat' inside[key] = context parsed = vars(parser.parse_args()) for key, val in parsed.items(): out[inside[key]][key] = val return out
def mutate1(self, old, c, east, west, gamma=1.5, delta=0.5): if c == 0: return old new = o(decs=old.decs[:],scores=[]) #copy the decisions and omit the score index = 0 for n,e,w,H in zip(new.decs, east.decs, west.decs, self.model.dec): d = sign(e - n) #n = delta * n * (1 +abs(c)*d) n = n + d * (abs(e-n) * delta) new.decs[index] = H.restrain(n) # avoid running out of the range index += 1 newDist = self.project(west, east, c, new) - \ self.project(west, east, c, west) if abs(newDist) < gamma * abs(c) and self.model.ok(new): return new return old
import sys sys.dont_write_bytecode = True from o import * The = o(cache = o(keep=256, update=1.1), cluster=o(using= lambda tbl: tbl.cols.indep), misc= o(missing='?', nervous= True, _logo= """ _.._.-..-._ .-' .' /\ \`._ / / .' `-.\ `. :_.' .. : _.../\ | ;___ .-' //\\. \ _..._ / `/\ // \\\ `-.___.-' /\ //\\ \\: | //\V/ :\\ \\ \ \\/ \\ /\\ `.____.\\ \\ .' \\ // /\\---\\-' \\ fsc // // \\ \\ \\ DeadAnt (c) 2014, Tim Menzies Tabu-based ant colony optimizer. """))
def candidate(decs = [], scores =[]): return o(decs=decs, scores=scores)
def __repr__(i): return '%s=%s' % (i.name, o(name=i.name,lo=i.lo,hi=i.hi,init=i.init,goal=i.goal,touch=i.touch))
def candidate(decs=[], scores=[]): return o(decs=decs, scores=scores)
def candidate(decs = [], scores =[], energy = None): return o(decs=decs, scores=scores, energy = energy)
def candidate(decs=[], scores=[], energy=None): return o(decs=decs, scores=scores, energy=energy)