result.volume = self.volume + other.volume mass1 = self.concentration * self.volume mass2 = other.concentration * other.volume result.concentration = (mass1 + mass2) / result.volume return result def split(self): d1, d2 = super().split() d1.volume = self.volume / 2 d2.volume = self.volume / 2 d1.concentration = self.concentration d2.concentration = self.concentration return d1, d2 arch_path = project_path('tests/arches/arch-big.json') with mk_session(arch_path) as session: # FIXME this needs arch big for now because place and route is bad # also, you just can't do that many iterations c_low = 0 c_high = 1 c_target = .37 eps = 0.1 def d_low_factory(): return session.create( location=None, volume=1, dimensions=None,
# no test from puddle import mk_session, project_path # def thermocycle(droplet, temps_and_times): arch_path = project_path('tests/arches/purpledrop-thermocycle.yaml') with mk_session(arch_path) as session: # a = session.input('water', volume=15.0, dimensions=(1,1)) # a.move((2,2)) # session._flush() a = session.create(location=(14, 5), volume=1.0, dimensions=(1, 1)) for i in range(10): print('python loop ', i) if i > 0: a = session.heat(a, temp=98, seconds=200) print('post 98 volume: ', a.volume()) if a.volume() < 1.0: r = session.input('water', volume=15, dimensions=(1, 1)) session._flush() a = session.combine_into(a, r) a = session.heat(a, temp=62, seconds=30) print('post 62 volume: ', a.volume()) a = session.heat(a, temp=72, seconds=20) print('post 72 volume: ', a.volume()) # initial_volume = c.volume()
# from https://docs.python.org/3.6/library/readline.html#example class HistoryConsole(code.InteractiveConsole): def __init__(self, locals=None, filename="<console>", histfile=os.path.expanduser("~/.console-history")): code.InteractiveConsole.__init__(self, locals, filename) self.init_history(histfile) def init_history(self, histfile): readline.parse_and_bind("tab: complete") if hasattr(readline, "read_history_file"): try: readline.read_history_file(histfile) except IOError: pass atexit.register(self.save_history, histfile) def save_history(self, histfile): readline.set_history_length(1000) readline.write_history_file(histfile) arch_path = project_path('tests/arches/purpledrop.yaml') with mk_session(arch_path) as session: HistoryConsole(locals=session.prelude()).interact() print(session.droplets())
result.volume = self.volume + other.volume mass1 = self.concentration * self.volume mass2 = other.concentration * other.volume result.concentration = (mass1 + mass2) / result.volume return result def split(self): d1, d2 = super().split() d1.volume = self.volume / 2 d2.volume = self.volume / 2 d1.concentration = self.concentration d2.concentration = self.concentration return d1, d2 arch_path = project_path('tests/arches/arch-big.yaml') with mk_session(arch_path) as session: # FIXME this needs arch big for now because place and route is bad # also, you just can't do that many iterations c_low = 0 c_high = 1 c_target = .25 eps = 0.1 def d_low_factory(): return session.create( location=None, volume=1, dimensions=None,
def session(): arch_path = puddle.project_path('tests/arches/arch01.json') with puddle.mk_session(arch_path) as sess: yield sess
corners = [corner1, corner2, corner3, corner4] def try_move(d, corner): try: old_id = d._id d.move(corner[0]) session._flush() except puddle.SessionError: corner.pop(0) d._id = old_id d.valid = True print("python: ERROR") arch_path = puddle.project_path('tests/arches/purpledrop.json') def endurance(session): globals().update(session.prelude()) d = create((6, 6)) for i in range(100): for j, c in enumerate(corners): if not c: print("python: corners{} is empty!".format(j)) return try_move(d, corner1) try_move(d, corner2)
# no test from puddle import mk_session, project_path arch_path = project_path('tests/arches/purpledrop-nanopore.yaml') with mk_session(arch_path) as session: dna = session.create(location=(1, 0), volume=10.0, dimensions=(1, 1)) session._flush() buf = session.input('buffer', volume=350.0, dimensions=(2, 2)) session._flush() mixture = session.mix(dna, buf) session._flush() session.output('minion', mixture) session._flush()
def setUp(self): arch_path = puddle.project_path('tests/arches/arch01.yaml') session = puddle.mk_session(arch_path) self.session = session.__enter__() self.addCleanup(session.__exit__, None, None, None)