Skip to content

Commit

Permalink
Merge pull request #738 from apdavison/issue692
Browse files Browse the repository at this point in the history
Check the type of the connector argument to Projection, and provide a user-friendly error message
  • Loading branch information
apdavison authored Nov 9, 2021
2 parents f4f3e6c + e1756f1 commit fbc6349
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pyNN/common/projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pyNN.parameters import ParameterSpace, LazyArray
from pyNN.space import Space
from pyNN.standardmodels import StandardSynapseType
from pyNN.connectors import Connector
from .populations import BasePopulation, Assembly

logger = logging.getLogger("PyNN")
Expand Down Expand Up @@ -88,12 +89,19 @@ def __init__(self, presynaptic_neurons, postsynaptic_neurons, connector,
self.post = postsynaptic_neurons # } read-only
self.label = label
self.space = space
if not isinstance(connector, Connector):
raise TypeError(
"The connector argument should be an instance of a subclass of Connector. "
f"The argument provided was of type '{type(connector).__name__}'."
)
self._connector = connector

self.synapse_type = synapse_type or self._static_synapse_class()
assert isinstance(self.synapse_type, models.BaseSynapseType), \
"The synapse_type argument must be a models.BaseSynapseType object, not a %s" % type(
synapse_type)
if not isinstance(self.synapse_type, models.BaseSynapseType):
raise TypeError(
"The synapse_type argument should be an instance of a subclass of BaseSynapseType. "
f"The argument provided was of type '{type(synapse_type).__name__}'"
)

self.receptor_type = receptor_type
if self.receptor_type in ("default", None):
Expand Down

0 comments on commit fbc6349

Please sign in to comment.