File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1140,20 +1140,24 @@ def __init__(self, *args):
11401140 and isinstance (arg [0 ], str )
11411141 and
11421142 # TODO: this should be extended to a slice.
1143- isinstance (arg [1 ], (int , np .integer ))
1143+ isinstance (arg [1 ], (int , np .integer , Projection ))
11441144 ), (
1145- "Each wire needs to be a tuple: (name, length). "
1145+ "Each wire needs to be a tuple: (name, length) or (name, Projection) . "
11461146 "You provided: {}" .format (arg )
11471147 )
11481148
1149- self ._nP = int (np .sum ([w [1 ] for w in args ]))
11501149 start = 0
11511150 maps = []
11521151 for arg in args :
1153- wire = Projection (self .nP , slice (start , start + arg [1 ]))
1152+
1153+ if isinstance (arg [1 ], (int , np .integer )):
1154+ wire = Projection (self .nP , slice (start , start + arg [1 ]))
1155+ start += arg [1 ]
1156+ else :
1157+ wire = arg [1 ]
1158+
11541159 setattr (self , arg [0 ], wire )
11551160 maps += [(arg [0 ], wire )]
1156- start += arg [1 ]
11571161 self .maps = maps
11581162
11591163 self ._tuple = namedtuple ("Model" , [w [0 ] for w in args ])
You can’t perform that action at this time.
0 commit comments