Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check the type of the connector argument to Projection, and provide a user-friendly error message #738

Merged
merged 1 commit into from
Nov 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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