Skip to content

Instantly share code, notes, and snippets.

@ethanrublee
Created December 2, 2012 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethanrublee/4190153 to your computer and use it in GitHub Desktop.
Save ethanrublee/4190153 to your computer and use it in GitHub Desktop.
test dynamic output declaration in python ecto cells.
import ecto
class FanCell(ecto.Cell):
def declare_params(self, p):
p.declare("N", "number of outputs", 3)
def declare_io(self, p, i, o):
for i in range(p.N):
o.declare("out%d"%i, "output %d"%i, None)
class FanCellStatic(ecto.Cell):
@staticmethod
def declare_params(p):
p.declare("N", "number of outputs", 3)
@staticmethod
def declare_io(p, i, o):
for i in range(p.N):
o.declare("out%d"%i, "output %d"%i, None)
c1 = FanCell(N=2)
print c1.outputs
c2 = FanCellStatic(N=7)
print c2.outputs
assert len(c1.outputs) == 2
assert len(c2.outputs) == 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment