def test_synthesizer_synthesize_parameter_sequence_bad_inputs(): """ Check that synthesize_sequence() correctly raises an error if you give it bad input types """ try: synth = sy.Synthesizer() results = synth.synthesize_sequence(1) raise Exception('This should have failed!') except TypeError: return
def test_synthesizer_synthesize_parameter_sequence_array_nested(): """ Check that synthesize_sequence() correctly accepts an array of a list of dicts and returns a corresponding number of stimuli """ synth = sy.Synthesizer() params = np.array([{'a': 1}]) params = increment_parameters(params, {'a': 0.01}) results = synth.synthesize_sequence(params) assert results.shape == (1, ) and type(results[0]) == list
def test_synthesizer_synthesize_parameter_sequence(): """ Check that synthesize_sequence() correctly accepts a list of dicts and returns a corresponding number of stimuli""" synth = sy.Synthesizer() results = synth.synthesize_sequence([{ 'foo': 1, 'bar': 2 }, { 'foo': 3, 'bar': 4 }]) assert len(results) == 2
def test_synthesizer_synthesize_parameter_sequence_array_with_kwarg(): """ Check that synthesize_sequence() correctly accepts an array of dicts and returns a corresponding number of stimuli and if we pass an extra kwarg that it gets passed correctly """ synth = sy.Synthesizer() results = synth.synthesize_sequence(np.array([{ 'foo': 1, 'bar': 2 }, { 'foo': 3, 'bar': 4 }]), qux='hello world') assert len(results) == 2 and results[0]['qux'] == 'hello world'
def test_synthesizer_synthesize_parameter_sequence_with_kwarg(): """ Check that synthesize_sequence() correctly accepts a list of dicts and returns a corresponding number of stimuli while also allowing the user to pass additional keyword arguments""" synth = sy.Synthesizer() results = synth.synthesize_sequence([{ 'foo': 1, 'bar': 2 }, { 'foo': 3, 'bar': 4 }], qux='hello world') assert len(results) == 2 and results[0]['qux'] == 'hello world'
def test_synthesizer_synthesize_parameter_sequence_with_duplicated_kwarg(): """ Check that synthesize_sequence() correctly accepts a list of dicts and returns a corresponding number of stimuli, but if the user passes a kwarg that is already passed once by the parameter sequence then an error is re turned""" synth = sy.Synthesizer() try: synth.synthesize_sequence([{ 'foo': 1, 'bar': 2 }, { 'foo': 3, 'bar': 4 }], foo='hello world') raise Exception except TypeError: return
def test_synthesizer_synthesize_parameter_sequence_array_2d(): """ Check that synthesize_sequence() correctly accepts a 2d array of dicts and returns a corresponding number of stimuli """ synth = sy.Synthesizer() results = synth.synthesize_sequence( np.array([[{ 'foo': 1, 'bar': 2 }, { 'foo': 3, 'bar': 4 }], [{ 'foo': 10, 'bar': 20 }, { 'foo': 30, 'bar': 40 }]])) assert results.shape == (2, 2)
def test_synthesizer_synthesize_parameter_sequence_nested(): """ Check that synthesize_sequence() correctly accepts a lists of lists and returns a properly nested list of lists """ synth = sy.Synthesizer() results = synth.synthesize_sequence([[{ 'foo': 1, 'bar': 2 }, { 'foo': 3, 'bar': 4 }], [{ 'foo': 1, 'bar': 2 }, { 'foo': -3, 'bar': -4 }, { 'foo': 0, 'bar': 0 }]]) assert len(results) == 2 and len(results[0]) == 2 and len(results[1]) == 3
def test_synthesizer_synthesize_parameter_sequence_parameters(): """ Check that synthesize_sequence() correctly accepts a Parametrs object and returns a corresponding number of stimuli """ synth = sy.Synthesizer() results = synth.synthesize_sequence(Parameters()) assert len(results) == 1
def test_synthesizer_synthesize(): """ Check that Synthesizer object can successfully synthesize""" synth = sy.Synthesizer() synth.synthesize()