neurokernel.pattern.Pattern

class neurokernel.pattern.Pattern(*selectors, **kwargs)[source]

Connectivity pattern linking sets of interface ports.

This class represents connection mappings between interfaces comprising sets of ports. Ports are represented using path-like identifiers; the presence of a row linking the two identifiers in the class’ internal index indicates the presence of a connection. A single data attribute (‘conn’) associated with defined connections is created by default. Specific attributes may be accessed by specifying their names after the port identifiers; if a nonexistent attribute is specified when a sequential value is assigned, a new column for that attribute is automatically created:

p['/x[0]', '/y[0]', 'conn', 'x'] = [1, 'foo']

The direction of connections between ports in a class instance determines whether they are input or output ports. Ports may not both receive input or emit output. Patterns may contain fan-out connections, i.e., one source port connected to multiple destination ports, but not fan-in connections, i.e., multiple source ports connected to a single destination port.

Examples

>>> p = Pattern('/x[0:3]','/y[0:4]')
>>> p['/x[0]', '/y[0:2]'] = 1
>>> p['/y[2]', '/x[1]'] = 1
>>> p['/y[3]', '/x[2]'] = 1
data

pandas.DataFrame – Connection attribute data.

index

pandas.MultiIndex – Index of connections.

interface

Interface – Interfaces containing port identifiers and attributes.

Parameters:
  • sel1, .. (sel0,) – Selectors defining the sets of ports potentially connected by the pattern. These selectors must be disjoint, i.e., no identifier comprised by one selector may be in any other selector.
  • columns (sequence of str) – Data column names.

See also

plsel.SelectorMethods

__init__(*selectors, **kwargs)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

Methods

__init__(*selectors, **kwargs) x.__init__(…) initializes x; see help(type(x)) for signature
clear() Clear all connections in class instance.
connected_port_pairs([as_str]) Return connections as pairs of port identifiers.
connected_ports([i, tuples]) Return ports that are connected by the pattern.
dest_idx(src_int, dest_int[, src_type, …]) Retrieve destination ports connected to the specified source ports.
from_concat(*selectors, **kwargs) Create pattern from the concatenation of identifers in two selectors.
from_csv(file_name, **kwargs) Read connectivity data from CSV file.
from_df(df_int, df_pat) Create a Pattern from properly formatted DataFrames.
from_graph(g) Convert a NetworkX directed graph into a Pattern instance.
from_product(*selectors, **kwargs) Create pattern from the product of identifiers comprised by two selectors.
gpot_ports([i, tuples]) Restrict Interface ports to graded potential ports.
in_ports([i, tuples]) Restrict Interface ports to input ports.
interface_ports([i, tuples]) Restrict Interface ports to specific interface.
is_connected(from_int, to_int) Check whether the specified interfaces are connected.
is_in_interfaces(selector) Check whether a selector is supported by any stored interface.
out_ports([i, tuples]) Restrict Interface ports to output ports.
spike_ports([i, tuples]) Restrict Interface ports to spiking ports.
split_multiindex(idx, a, b) Split a single MultiIndex into two instances.
src_idx(src_int, dest_int[, src_type, …]) Retrieve source ports connected to the specified destination ports.
to_graph() Convert the pattern to a networkx directed graph.
which_int(s) Return the interface containing the identifiers comprised by a selector.

Attributes

from_slice Slice of pattern index row corresponding to source port(s).
index Pattern index.
interface_ids Interface identifiers.
to_slice Slice of pattern index row corresponding to destination port(s).