def merge(ops): if all(o.A.shape == (1,) for o in ops): assert all(o.A.initial_value == ops[0].A.initial_value for o in ops) A, A_sigr = ops[0].A, {} else: A, A_sigr = SigMerger.merge([o.A for o in ops], axis=ops[0].A.ndim - 1) X, X_sigr = SigMerger.merge([o.X for o in ops], axis=ops[0].X.ndim - 1) Y, Y_sigr = SigMerger.merge([o.Y for o in ops], axis=ops[0].Y.ndim - 1) return (op.ElementwiseInc(A, X, Y), Merger.merge_dicts(A_sigr, X_sigr, Y_sigr))
def test_elementwise_inc(Simulator): # note: normally the op_builders are just tested as part of the nengo # tests. but in this particular case, there are no nengo tests that # have a scalar, non-1 transform. those all get optimized out during # the graph optimization, so we don't end up with any tests of # elementwiseinc where A is a scalar. so that's what this is for. model = builder.Model() a = signal.Signal([2.0]) x = signal.Signal([[3.0]]) y = signal.Signal([[1.0]]) op = operator.ElementwiseInc(a, x, y) model.add_op(op) with Simulator(None, model=model) as sim: sim.run_steps(5)