def test_operators(): sig = Signal(np.array([0.0]), name="sig") assert fnmatch(repr(TimeUpdate(sig, sig)), "<TimeUpdate at 0x*>") assert fnmatch(repr(TimeUpdate(sig, sig, tag="tag")), "<TimeUpdate 'tag' at 0x*>") assert fnmatch(repr(Reset(sig)), "<Reset at 0x*>") assert fnmatch(repr(Reset(sig, tag="tag")), "<Reset 'tag' at 0x*>") assert fnmatch(repr(Copy(sig, sig)), "<Copy at 0x*>") assert fnmatch(repr(Copy(sig, sig, tag="tag")), "<Copy 'tag' at 0x*>") assert fnmatch(repr(ElementwiseInc(sig, sig, sig)), "<ElementwiseInc at 0x*>") assert fnmatch(repr(ElementwiseInc(sig, sig, sig, tag="tag")), "<ElementwiseInc 'tag' at 0x*>") assert fnmatch(repr(DotInc(sig, sig, sig)), "<DotInc at 0x*>") assert fnmatch(repr(DotInc(sig, sig, sig, tag="tag")), "<DotInc 'tag' at 0x*>") assert fnmatch(repr(SimPyFunc(sig, lambda x: 0.0, True, sig)), "<SimPyFunc at 0x*>") assert fnmatch( repr(SimPyFunc(sig, lambda x: 0.0, True, sig, tag="tag")), "<SimPyFunc 'tag' at 0x*>", ) assert fnmatch(repr(SimPES(sig, sig, sig, 0.1)), "<SimPES at 0x*>") assert fnmatch(repr(SimPES(sig, sig, sig, 0.1, tag="tag")), "<SimPES 'tag' at 0x*>") assert fnmatch(repr(SimBCM(sig, sig, sig, sig, 0.1)), "<SimBCM at 0x*>") assert fnmatch(repr(SimBCM(sig, sig, sig, sig, 0.1, tag="tag")), "<SimBCM 'tag' at 0x*>") assert fnmatch(repr(SimOja(sig, sig, sig, sig, 0.1, 1.0)), "<SimOja at 0x*>") assert fnmatch(repr(SimOja(sig, sig, sig, sig, 0.1, 1.0, tag="tag")), "<SimOja 'tag' at 0x*>") assert fnmatch(repr(SimVoja(sig, sig, sig, sig, 1.0, sig, 1.0)), "<SimVoja at 0x*>") assert fnmatch( repr(SimVoja(sig, sig, sig, sig, 0.1, sig, 1.0, tag="tag")), "<SimVoja 'tag' at 0x*>", ) assert fnmatch(repr(SimRLS(sig, sig, sig, sig)), "<SimRLS at 0x*>") assert fnmatch( repr(SimRLS(sig, sig, sig, sig, tag="tag")), "<SimRLS 'tag' at 0x*>", ) assert fnmatch(repr(SimNeurons(LIF(), sig, {"sig": sig})), "<SimNeurons at 0x*>") assert fnmatch( repr(SimNeurons(LIF(), sig, {"sig": sig}, tag="tag")), "<SimNeurons 'tag' at 0x*>", ) assert fnmatch(repr(SimProcess(WhiteNoise(), sig, sig, sig)), "<SimProcess at 0x*>") assert fnmatch( repr(SimProcess(WhiteNoise(), sig, sig, sig, tag="tag")), "<SimProcess 'tag' at 0x*>", )
def __init__(self, dt=0.001, label=None, decoder_cache=NoDecoderCache()): self.dt = dt self.label = label self.decoder_cache = decoder_cache # Will be filled in by the network builder self.toplevel = None self.config = None # Resources used by the build process self.operators = [] self.params = {} self.probes = [] self.seeds = {} self.seeded = {} self.sig = collections.defaultdict(dict) self.sig['common'][0] = Signal(0., readonly=True, name='ZERO') self.sig['common'][1] = Signal(1., readonly=True, name='ONE') self.step = Signal(np.array(0, dtype=np.int64), name='step') self.time = Signal(np.array(0, dtype=np.float64), name='time') self.add_op(TimeUpdate(self.step, self.time)) self.build_callback = None
def __init__(self, dt=0.001, label=None, decoder_cache=None, builder=None): self.dt = dt self.label = label self.decoder_cache = (NoDecoderCache() if decoder_cache is None else decoder_cache) # Will be filled in by the network builder self.toplevel = None self.config = None # Resources used by the build process self.operators = [] self.params = {} self.probes = [] self.seeds = {} self.seeded = {} self.sig = collections.defaultdict(dict) self.sig["common"][0] = Signal(np.array(0.0, dtype=rc.float_dtype), readonly=True, name="ZERO") self.sig["common"][1] = Signal(np.array(1.0, dtype=rc.float_dtype), readonly=True, name="ONE") self.step = Signal(np.array(0, dtype=rc.int_dtype), name="step") self.time = Signal(np.array(0, dtype=rc.float_dtype), name="time") self.add_op(TimeUpdate(self.step, self.time)) self.builder = Builder() if builder is None else builder self.build_callback = None
def __init__(self, dt=0.001, label=None, decoder_cache=NoDecoderCache()): self.dt = dt self.label = label self.decoder_cache = decoder_cache # We want to keep track of the toplevel network self.toplevel = None # Builders can set a config object to affect sub-builders self.config = None # Resources used by the build process. self.operators = [] self.params = {} self.seeds = {} self.probes = [] self.sig = collections.defaultdict(dict) self.sig['common'][0] = Signal(0., readonly=True, name='ZERO') self.sig['common'][1] = Signal(1., readonly=True, name='ONE') self.step = Signal(np.array(0, dtype=np.int64), name='step') self.time = Signal(np.array(0, dtype=np.float64), name='time') self.add_op(TimeUpdate(self.step, self.time))