示例#1
0
    def describe(self, template='population_default.txt', engine='default'):
        """ Returns a human-readable description of the population.

        The output may be customised by specifying a different template
        together with an associated template engine (see ``pyNN.descriptions``)

        If template is None, then a dictionary containing the template context
        will be returned.
        """

        vertex_context = self._vertex.describe()

        context = {
            "label": self.label,
            "celltype": descriptions.render(
                engine, 'modeltype_default.txt', vertex_context),
            "structure": None,
            "size": self.size,
            "size_local": self.size,
            "first_id": None,
            "last_id": None,
        }
        if self.size > 0:
            context.update({
                "local_first_id": None,
                "cell_parameters": {}})

        if self._structure:
            context["structure"] = self._structure.describe(template=None)
        return descriptions.render(engine, template, context)
示例#2
0
 def test_render_with_template(self):
     engine = MockTemplateEngine
     context = {'a':2, 'b':3}
     template = "abcdefg"
     result = descriptions.render(engine, template, context)
     engine.render.assert_called_with(template, context)
     self.assertEqual(result, "african swallow")
 def test_render_with_template(self):
     engine = MockTemplateEngine
     context = {'a': 2, 'b': 3}
     template = "abcdefg"
     result = descriptions.render(engine, template, context)
     engine.render.assert_called_with(template, context)
     self.assertEqual(result, "african swallow")
示例#4
0
    def describe(self, template='projection_default.txt', engine='default'):
        """
        Returns a human-readable description of the projection.

        The output may be customized by specifying a different template
        togther with an associated template engine (see ``pyNN.descriptions``).

        If template is None, then a dictionary containing the template context
        will be returned.
        """
        context = {
            "label": self.label,
            "pre": self.pre.describe(template=None),
            "post": self.post.describe(template=None),
            "source": self.source,
            "receptor_type": self.receptor_type,
            "size_local": len(self),
            "size": self.size(gather=True),
            "connector": self._connector.describe(template=None),
            "plasticity": None,
        }
        if self.synapse_type:
            context.update(plasticity=self.synapse_type.describe(
                template=None))
        return descriptions.render(engine, template, context)
示例#5
0
    def describe(self, template='connector_default.txt', engine='default'):
        """
        Returns a human-readable description of the connection method.

        The output may be customized by specifying a different template
        togther with an associated template engine (see ``pyNN.descriptions``).

        If template is None, then a dictionary containing the template context
        will be returned.
        """
        context = {'name': self.__class__.__name__,
                   'parameters': self.get_parameters()}
        return descriptions.render(engine, template, context)
示例#6
0
    def describe(self, template='connector_default.txt', engine='default'):
        """
        Returns a human-readable description of the connection method.

        The output may be customized by specifying a different template
        togther with an associated template engine (see ``pyNN.descriptions``).

        If template is None, then a dictionary containing the template context
        will be returned.
        """
        context = {'name': self.__class__.__name__,
                   'parameters': self.get_parameters()}
        return descriptions.render(engine, template, context)
示例#7
0
 def describe(self, template='synapsedynamics_default.txt', engine='default'):
     """
     Returns a human-readable description of the synapse dynamics.
     
     The output may be customized by specifying a different template
     togther with an associated template engine (see ``pyNN.descriptions``).
     
     If template is None, then a dictionary containing the template context
     will be returned.
     """
     context = {'fast': self.fast and self.fast.describe(template=None) or None,
                'slow': self.slow and self.slow.describe(template=None) or None}
     return descriptions.render(engine, template, context)
示例#8
0
文件: synapses.py 项目: lbbaker/PyNN
    def describe(self, template='stdpmechanism_default.txt', engine='default'):
        """
        Returns a human-readable description of the STDP mechanism.

        The output may be customized by specifying a different template
        togther with an associated template engine (see ``pyNN.descriptions``).

        If template is None, then a dictionary containing the template context
        will be returned.
        """
        context = {'weight_dependence': self.weight_dependence.describe(template=None),
                   'timing_dependence': self.timing_dependence.describe(template=None),
                   'voltage_dependence': self.voltage_dependence and self.voltage_dependence.describe(template=None) or None,
                   'dendritic_delay_fraction': self.dendritic_delay_fraction}
        return descriptions.render(engine, template, context)
示例#9
0
文件: models.py 项目: agravier/pynn
 def describe(self, template='modeltype_default.txt', engine='default'):
     """
     Returns a human-readable description of the cll or synapse type.
     
     The output may be customized by specifying a different template
     togther with an associated template engine (see ``pyNN.descriptions``).
     
     If template is None, then a dictionary containing the template context
     will be returned.
     """
     context = {
         "name": self.__class__.__name__,
         "parameters": self.parameters,
     }
     return descriptions.render(engine, template, context)
示例#10
0
文件: models.py 项目: agravier/pynn
 def describe(self, template='modeltype_default.txt', engine='default'):
     """
     Returns a human-readable description of the cll or synapse type.
     
     The output may be customized by specifying a different template
     togther with an associated template engine (see ``pyNN.descriptions``).
     
     If template is None, then a dictionary containing the template context
     will be returned.
     """
     context = {
         "name": self.__class__.__name__,
         "parameters": self.parameters,
     }
     return descriptions.render(engine, template, context)
示例#11
0
    def describe(self, template='populationview_default.txt',
                 engine='default'):
        """ Returns a human-readable description of the population view.

        The output may be customized by specifying a different template\
        together with an associated template engine (see pyNN.descriptions).

        If template is None, then a dictionary containing the template\
        context will be returned.
        """
        context = {"label": self.label,
                   "parent": self.parent.label,
                   "mask": self.mask,
                   "size": self.size}
        context.update(self._annotations)
        return descriptions.render(engine, template, context)
示例#12
0
    def describe(self, template='projection_default.txt', engine='default'):
        """
        Returns a human-readable description of the projection.

        The output may be customized by specifying a different template
        togther with an associated template engine (see ``pyNN.descriptions``).

        If template is None, then a dictionary containing the template context
        will be returned.
        """
        context = {
            "label": self.label,
            "pre": self.pre.describe(template=None),
            "post": self.post.describe(template=None),
            "source": self.source,
            "receptor_type": self.receptor_type,
            "size_local": len(self),
            "size": self.size(gather=True),
            "connector": self._connector.describe(template=None),
            "plasticity": None,
        }
        if self.synapse_type:
            context.update(plasticity=self.synapse_type.describe(template=None))
        return descriptions.render(engine, template, context)
示例#13
0
    def describe(self,
                 template='populationview_default.txt',
                 engine='default'):
        """ Returns a human-readable description of the population view.

        The output may be customized by specifying a different template
        together with an associated template engine (see pyNN.descriptions).

        If template is ``None``, then a dictionary containing the template
        context will be returned.

        :param str template: Template filename
        :param engine: Template substitution engine
        :type engine: str or ~pyNN.descriptions.TemplateEngine or None
        :rtype: str or dict
        """
        context = {
            "label": self.label,
            "parent": self.parent.label,
            "mask": self.mask,
            "size": self.size
        }
        context.update(self.__annotations)
        return descriptions.render(engine, template, context)
示例#14
0
 def test_render_with_no_template(self):
     context = {'a':2, 'b':3}
     result = descriptions.render(Mock(), None, context)
     self.assertEqual(result, context)
 def test_render_with_no_template(self):
     context = {'a': 2, 'b': 3}
     result = descriptions.render(Mock(), None, context)
     self.assertEqual(result, context)