Created
December 2, 2012 17:54
-
-
Save ethanrublee/4190153 to your computer and use it in GitHub Desktop.
test dynamic output declaration in python ecto cells.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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