def testStimulatedOscillatorWithoutLateralPotential(self): params = legion_parameters(); params.teta = 0; # because no neighbors at all net = legion_network(1, type_conn = conn_type.NONE, parameters = params, ccore = False); dynamic = net.simulate(2000, 400, [1]); assert extract_number_oscillations(dynamic.output) > 1;
def testUstimulatedOscillatorWithoutLateralPotential(self): params = legion_parameters(); params.teta = 0; # because no neighbors at all net = legion_network(1, type_conn = conn_type.NONE, parameters = params, ccore = False); dynamic = net.simulate(1000, 200, [0]); assert extract_number_oscillations(dynamic.output, amplitude_threshold = 0.0) == 0;
def templateOscillationExistance(self, num_osc, own_weight, neigh_weight, steps, time, initial_states = None, initial_outputs = None, conn_repr = conn_represent.MATRIX): network = hysteresis_network(num_osc, own_weight, neigh_weight, type_conn_represent = conn_repr); if (initial_states is not None): network.states = initial_states; if (initial_outputs is not None): network.outputs = initial_outputs; (t, x) = network.simulate(steps, time); oscillations = []; for index in range(num_osc): number_oscillations = extract_number_oscillations(x, index, 0.9); oscillations.append(number_oscillations) assert number_oscillations > 1; return oscillations;
def testExtractNumberOscillationsMonotonicUpSlightlyDown(self): value = [ [1.0], [1.5], [2.0], [2.5], [3.0], [3.5], [4.0], [4.5], [5.0], [4.5], [4.0] ]; assert extract_number_oscillations(value, 0, 2.0) == 0;
def testExtractNumberOscillationsMonotonicDown(self): value = [[10.0], [9.5], [9.0], [8.5], [8.0], [7.5], [7.0], [6.5], [6.0], [5.5], [5.0]] assert extract_number_oscillations(value, 0, 8.0) == 0
def testMixStimulatedThreeOscillators(self): net = legion_network(3, type_conn = conn_type.LIST_BIDIR, ccore = False); dynamic = net.simulate(1000, 2000, [1, 0, 1]); assert extract_number_oscillations(dynamic.output, 0) > 1; assert extract_number_oscillations(dynamic.output, 2) > 1;
def templateOscillationsWithStructures(type_conn, ccore_flag): net = legion_network(4, type_conn = conn_type.LIST_BIDIR, ccore = ccore_flag); dynamic = net.simulate(500, 1000, [1, 1, 1, 1]); for i in range(len(net)): assert extract_number_oscillations(dynamic.output, i) > 1;
def testStimulatedOscillatorWithLateralPotential(self): net = legion_network(1, type_conn=conn_type.NONE, ccore=False) dynamic = net.simulate(2000, 400, [1]) assert extract_number_oscillations(dynamic.output, amplitude_threshold=0.0) >= 1
def testExtractNumberOscillationsDownUpDown(self): value = [[0.0], [1.0], [0.0]] assert extract_number_oscillations(value, 0, 0.5) == 1
def testExtractNumberOscillationsDownUpDown(self): value = [ [0.0], [1.0], [0.0] ]; assert extract_number_oscillations(value, 0, 0.5) == 1;
def testExtractNumberOscillationsFourPeriodsUnderThreshold(self): value = [ [0.0], [1.0], [0.0], [1.0], [0.0], [1.0], [0.0], [1.0], [0.0] ]; assert extract_number_oscillations(value, 0, 1.5) == 0;
def testExtractNumberOscillationsFourPeriods(self): value = [ [0.0], [1.0], [0.0], [1.0], [0.0], [1.0], [0.0], [1.0], [0.0] ]; assert extract_number_oscillations(value, 0, 0.5) == 4;
def testExtractNumberOscillationsOnePeriodWithHalf(self): value = [ [0.0], [1.0], [0.0], [1.0] ]; assert extract_number_oscillations(value, 0, 0.5) == 1;
def testExtractNumberOscillationsMonotonicDownSlightlyUp(self): value = [ [10.0], [9.5], [9.0], [8.5], [8.0], [7.5], [7.0], [6.5], [7.0], [7.1], [7.3] ]; assert extract_number_oscillations(value, 0, 7.5) == 0;
def testExtractNumberOscillationsFourPeriods(self): value = [[0.0], [1.0], [0.0], [1.0], [0.0], [1.0], [0.0], [1.0], [0.0]] assert extract_number_oscillations(value, 0, 0.5) == 4
def testExtractNumberOscillationsFourPeriodsUnderThreshold(self): value = [[0.0], [1.0], [0.0], [1.0], [0.0], [1.0], [0.0], [1.0], [0.0]] assert extract_number_oscillations(value, 0, 1.5) == 0
def testStimulatedOscillatorWithLateralPotential(self): net = legion_network(1, type_conn = conn_type.NONE); dynamic = net.simulate(1000, 200, [1]); assert extract_number_oscillations(dynamic.output) == 1;
def testStimulatedTwoOscillators(self): net = legion_network(2, type_conn=conn_type.LIST_BIDIR) dynamic = net.simulate(1000, 2000, [1, 1]) assert extract_number_oscillations(dynamic.output, 0) > 1 assert extract_number_oscillations(dynamic.output, 1) > 1
def testStimulatedTwoOscillators(self): net = legion_network(2, type_conn = conn_type.LIST_BIDIR); dynamic = net.simulate(1000, 2000, [1, 1]); assert extract_number_oscillations(dynamic.output, 0) > 1; assert extract_number_oscillations(dynamic.output, 1) > 1;
def testMixStimulatedThreeOscillators(self): net = legion_network(3, type_conn=conn_type.LIST_BIDIR, ccore=False) dynamic = net.simulate(1000, 2000, [1, 0, 1]) assert extract_number_oscillations(dynamic.output, 0) > 1 assert extract_number_oscillations(dynamic.output, 2) > 1
def templateOscillationsWithStructures(self, type_conn, ccore_flag = False): net = legion_network(4, type_conn = conn_type.LIST_BIDIR, ccore = ccore_flag); dynamic = net.simulate(500, 1000, [1, 1, 1, 1]); for i in range(len(net)): assert extract_number_oscillations(dynamic.output, i) > 1;
def testStimulatedOscillatorWithLateralPotential(self): net = legion_network(1, type_conn = conn_type.NONE); dynamic = net.simulate(1000, 200, [1]); assert extract_number_oscillations(dynamic.output) == 1;
def testListConnectionRepresentation(self): net = legion_network(3, type_conn = conn_type.LIST_BIDIR, type_conn_represent = conn_represent.LIST, ccore = False); dynamic = net.simulate(1000, 2000, [1, 0, 1]); assert extract_number_oscillations(dynamic.output, 0) > 1; assert extract_number_oscillations(dynamic.output, 2) > 1;
def testStimulatedOscillatorWithLateralPotential(self): net = legion_network(1, type_conn = conn_type.NONE, ccore = False); dynamic = net.simulate(2000, 400, [1]); assert extract_number_oscillations(dynamic.output, amplitude_threshold = 0.0) >= 1;
def testExtractNumberOscillationsMonotonicDownSlightlyUp(self): value = [[10.0], [9.5], [9.0], [8.5], [8.0], [7.5], [7.0], [6.5], [7.0], [7.1], [7.3]] assert extract_number_oscillations(value, 0, 7.5) == 0
def testListConnectionRepresentation(self): net = legion_network(3, type_conn = conn_type.LIST_BIDIR, type_conn_represent = conn_represent.LIST, ccore = False); dynamic = net.simulate(1000, 2000, [1, 0, 1]); assert extract_number_oscillations(dynamic.output, 0) > 1; assert extract_number_oscillations(dynamic.output, 2) > 1;
def testExtractNumberOscillationsOnePeriodWithHalf(self): value = [[0.0], [1.0], [0.0], [1.0]] assert extract_number_oscillations(value, 0, 0.5) == 1
def testExtractNumberOscillationsMonotonicUp(self): value = [[1.0], [1.5], [2.0], [2.5], [3.0], [3.5], [4.0], [4.5], [5.0], [5.5], [6.0]] assert extract_number_oscillations(value, 0, 4.0) == 0
def testExtractNumberOscillationsMonotonicDown(self): value = [ [10.0], [9.5], [9.0], [8.5], [8.0], [7.5], [7.0], [6.5], [6.0], [5.5], [5.0] ]; assert extract_number_oscillations(value, 0, 8.0) == 0;