Esempio n. 1
0
    def property_setup(self, properties):
        properties = super(EarlyVisionModel, self).property_setup(properties)
        sheet.SettlingCFSheet.joint_norm_fn = sheet.optimized.compute_joint_norm_totals_opt
        center_polarities = ['On', 'Off']

        # Useful for setting up sheets
        properties['polarities'] = lancet.List('polarity', center_polarities)
        properties['eyes'] = (lancet.List('eye', ['Left', 'Right']) if
                              properties['binocular'] else lancet.Identity())
        properties['SFs'] = (lancet.List('SF', properties['SF']) if
                             max(properties['SF']) > 1 else lancet.Identity())
        return properties
Esempio n. 2
0
    def property_setup(self, properties):
        properties = super(ColorEarlyVisionModel, self).property_setup(properties)

        properties['SF']=range(1,self.sf_channels+1) if 'sf' in self.dims and 'cr' not in self.dims else \
                         range(2,self.sf_channels+1) if 'sf' in self.dims and 'cr' in self.dims else [1]
        properties['SFs'] = (lancet.List('SF', properties['SF'])
                             if max(properties['SF'])>1 else lancet.Identity())

        cr = 'cr' in self.dims
        #TFALERT: Dichromatic simulations have not been tested!
        opponent_types_center =   ['Red','Green','Blue','RedGreenBlue'] if cr \
                                    and self.color_sim_type=='Trichromatic' else \
                                  ['Green','Blue','GreenBlue'] if cr \
                                    and self.color_sim_type=='Dichromatic' else []
        opponent_types_surround = ['Green','Red','RedGreen','RedGreenBlue'] if cr \
                                    and self.color_sim_type=='Trichromatic' else \
                                  ['Green','Green','GreenBlue'] if cr \
                                    and self.color_sim_type=='Dichromatic' else []
        self.ColorToChannel = {'Red':0, 'Green':1, 'Blue':2} if cr else {}

        # Definitions useful for setting up sheets
        opponent_specs =[dict(opponent=el1, surround=el2) for el1, el2
                         in zip(opponent_types_center,
                                opponent_types_surround)]
        properties['opponents'] = (lancet.Args(specs=opponent_specs)
                                   if opponent_types_center else lancet.Identity())
        return properties
Esempio n. 3
0
    def test_outputs_captured_correctly(self):
        # Given
        nargs = 2
        args = lancet.List('c', ["print(%d)" % i for i in range(nargs)])
        cmd = lancet.ShellCommand(executable=sys.executable)
        lancet.Launcher('test', args, cmd, output_directory=self.output_dir)()

        # When
        o = lancet.Output(self.output_dir)
        latest = o[-1]

        # Then
        self.assertEqual(len(o), 1)
        expected = ('timestamp', 'path', 'tids', 'specs', 'stdout', 'stderr',
                    'log', 'info')
        self.assertEqual(latest._fields, expected)
        self.assertEqual(latest.tids, list(range(nargs)))
        self.assertEqual(len(latest.stdout), nargs)
        self.assertEqual(len(latest.stderr), nargs)
        expected = [{'c': 'print(%d)' % i} for i in range(nargs)]
        self.assertEqual(latest.specs, expected)

        # Gather the stdout data.
        result = [int(open(x).read().strip()) for x in latest.stdout]
        expected = list(range(nargs))
        self.assertEqual(result, expected)

        # We should be able to iterate over the output.
        paths = [x.path for x in o]
        expected = [latest.path]
        self.assertEqual(paths, expected)
Esempio n. 4
0
    def setup_attributes(self, attrs):
        attrs = super(EarlyVisionModel, self).setup_attributes(attrs)
        sheet.SettlingCFSheet.joint_norm_fn = sheet.optimized.compute_joint_norm_totals_opt
        center_polarities = ['On', 'Off']

        # Useful for setting up sheets
        attrs.Args = {
            'eyes':
            lancet.List('eye', attrs.Eyes)
            if len(attrs.Eyes) > 1 else lancet.Identity(),
            'polarities':
            lancet.List('polarity', center_polarities),
            'SFs':
            lancet.List('SF', attrs.SF)
            if max(attrs.SF) > 1 else lancet.Identity()
        }
        return attrs
Esempio n. 5
0
    def setup_attributes(self, attrs):
        attrs = super(ColorEarlyVisionModel, self).setup_attributes(attrs)

        cr = 'cr' in self.dims
        opponent_types_center = ['Red', 'Green', 'Blue', 'RedGreenBlue'
                                 ] if cr else []
        opponent_types_surround = ['Green', 'Red', 'RedGreen', 'RedGreenBlue'
                                   ] if cr else []
        cone_types = ['Red', 'Green', 'Blue'] if cr else []

        # Definitions useful for setting up sheets
        opponent_specs = [
            dict(opponent=el1, surround=el2)
            for el1, el2 in zip(opponent_types_center, opponent_types_surround)
        ]

        attrs.Args['opponents'] = (lancet.Args(
            specs=opponent_specs) if opponent_types_center else
                                   lancet.Identity())
        attrs.Args['cones'] = (lancet.List('cone', cone_types)
                               if cone_types else lancet.Identity())
        return attrs
Esempio n. 6
0
    def test_output_supports_expansions(self):
        # Given
        nargs = 2
        args = lancet.List('c', ["print(%d)" % i for i in range(nargs)])
        cmd = lancet.ShellCommand(executable=sys.executable)
        lancet.Launcher('test', args, cmd, output_directory=self.output_dir)()

        # This is useful if one needs to generate a separate file for each
        # invocation.  Here a filename is generated for each case run.
        expansions = {'filename': lancet.ShellCommand.LongFilename('.png')}

        # When
        o = lancet.Output(self.output_dir, expansions=expansions)
        latest = o[-1]

        # Then.
        self.assertEqual(len(o), 1)
        expected = ('timestamp', 'path', 'tids', 'specs', 'stdout', 'stderr',
                    'log', 'info', 'filename')
        self.assertEqual(latest._fields, expected)
        self.assertEqual(len(latest.filename), 2)
        self.assertTrue(all([x.endswith('.png') for x in latest.filename]))