def create_pattern(n_dict_1, n_dict_2, save_as=None):
    """
    If `save_as` is not None, save the pattern in GEXF format as the specified file name.
    """

    lpu1_sel_in_gpot = plsel.Selector(LPU.extract_in_gpot(n_dict_1))
    lpu1_sel_out_gpot = plsel.Selector(LPU.extract_out_gpot(n_dict_1))
    lpu2_sel_in_gpot = plsel.Selector(LPU.extract_in_gpot(n_dict_2))
    lpu2_sel_out_gpot = plsel.Selector(LPU.extract_out_gpot(n_dict_2))

    lpu1_sel_in_spike = plsel.Selector(LPU.extract_in_spk(n_dict_1))
    lpu1_sel_out_spike = plsel.Selector(LPU.extract_out_spk(n_dict_1))
    lpu2_sel_in_spike = plsel.Selector(LPU.extract_in_spk(n_dict_2))
    lpu2_sel_out_spike = plsel.Selector(LPU.extract_out_spk(n_dict_2))

    lpu1_sel_out = plsel.Selector.union(lpu1_sel_out_gpot, lpu1_sel_out_spike)
    lpu2_sel_out = plsel.Selector.union(lpu2_sel_out_gpot, lpu2_sel_out_spike)
    lpu1_sel_in = plsel.Selector.union(lpu1_sel_in_gpot, lpu1_sel_in_spike)
    lpu2_sel_in = plsel.Selector.union(lpu2_sel_in_gpot, lpu2_sel_in_spike)

    lpu1_sel = plsel.Selector.union(lpu1_sel_out, lpu1_sel_in)
    lpu2_sel = plsel.Selector.union(lpu2_sel_out, lpu2_sel_in)

    Neuron_list_12 = ["L1", "L2", "L3", "L4", "L5", "T1"]
    Neuron_list_21 = ["C2", "C3"]

    gpot_sel = plsel.Selector.union(lpu1_sel_out_gpot, lpu1_sel_in_gpot, lpu2_sel_out_gpot, lpu2_sel_in_gpot)
    spike_sel = plsel.Selector.union(lpu1_sel_out_spike, lpu1_sel_in_spike, lpu2_sel_out_spike, lpu2_sel_in_spike)

    Neuron_str_12 = "[" + ",".join(Neuron_list_12) + "]"
    Neuron_str_21 = "[" + ",".join(Neuron_list_21) + "]"
    cart_str = "[" + ",".join(["cart%i" % i for i in range(768)]) + "]"

    from_sel_12 = "/lamina" + cart_str + Neuron_str_12
    to_sel_12 = "/medulla" + cart_str + Neuron_str_12
    from_sel_21 = "/medulla" + cart_str + Neuron_str_21
    to_sel_21 = "/lamina" + cart_str + Neuron_str_21

    from_sel = from_sel_12 + "," + from_sel_21
    to_sel = to_sel_12 + "," + to_sel_21

    pat = Pattern.from_concat(
        lpu1_sel, lpu2_sel, from_sel=from_sel, to_sel=to_sel, gpot_sel=gpot_sel, spike_sel=spike_sel, data=1
    )

    if save_as:
        nx.write_gexf(pat.to_graph(), save_as, prettyprint=True)
    return pat
def create_pattern(n_dict_1, n_dict_2, save_as=None):
    """
    If `save_as` is not None, save the pattern as the specified file name.
    """

    lpu1_sel_in_gpot = plsel.Selector(LPU.extract_in_gpot(n_dict_1))
    lpu1_sel_out_gpot = plsel.Selector(LPU.extract_out_gpot(n_dict_1))
    lpu2_sel_in_gpot = plsel.Selector(LPU.extract_in_gpot(n_dict_2))
    lpu2_sel_out_gpot = plsel.Selector(LPU.extract_out_gpot(n_dict_2))

    lpu1_sel_in_spike = plsel.Selector(LPU.extract_in_spk(n_dict_1))
    lpu1_sel_out_spike = plsel.Selector(LPU.extract_out_spk(n_dict_1))
    lpu2_sel_in_spike = plsel.Selector(LPU.extract_in_spk(n_dict_2))
    lpu2_sel_out_spike = plsel.Selector(LPU.extract_out_spk(n_dict_2))

    lpu1_sel_out = plsel.Selector.union(lpu1_sel_out_gpot, lpu1_sel_out_spike)
    lpu2_sel_out = plsel.Selector.union(lpu2_sel_out_gpot, lpu2_sel_out_spike)
    lpu1_sel_in = plsel.Selector.union(lpu1_sel_in_gpot, lpu1_sel_in_spike)
    lpu2_sel_in = plsel.Selector.union(lpu2_sel_in_gpot, lpu2_sel_in_spike)

    lpu1_sel = plsel.Selector.union(lpu1_sel_out, lpu1_sel_in)
    lpu2_sel = plsel.Selector.union(lpu2_sel_out, lpu2_sel_in)

    pat = Pattern(lpu1_sel, lpu2_sel)

    pat.interface[lpu1_sel_in_gpot, 'io', 'type'] = ['in', 'gpot']
    pat.interface[lpu1_sel_out_gpot, 'io', 'type'] = ['out', 'gpot']
    pat.interface[lpu2_sel_in_gpot, 'io', 'type'] = ['in', 'gpot']
    pat.interface[lpu2_sel_out_gpot, 'io', 'type'] = ['out', 'gpot']
    pat.interface[lpu1_sel_in_spike, 'io', 'type'] = ['in', 'spike']
    pat.interface[lpu1_sel_out_spike, 'io', 'type'] = ['out', 'spike']
    pat.interface[lpu2_sel_in_spike, 'io', 'type'] = ['in', 'spike']
    pat.interface[lpu2_sel_out_spike, 'io', 'type'] = ['out', 'spike']

    Neuron_list_12 = ['L1', 'L2', 'L3', 'L4', 'L5', 'T1']
    Neuron_list_21 = ['C2', 'C3']
    
    for i in range(768):
        for neuron in Neuron_list_12:
            pat['/lamina/cart'+str(i)+'/'+neuron, '/medulla/cart'+str(i)+'/'+neuron] = 1
        for neuron in Neuron_list_21:
            pat['/medulla/cart'+str(i)+'/'+neuron, '/lamina/cart'+str(i)+'/'+neuron] = 1
    if save_as:
        with open(save_as, 'wb') as pat_file:
            pickle.dump(pat, pat_file)
    return pat
Exemple #3
0
    def run(connected):
        """
        Set `connected` to True to connect the LPUs.
        """

        import neurokernel.mpi_relaunch

        out_name = 'un' if not connected else 'co'
        man = core.Manager()

        lpu_file_0 = './data/generic_lpu_0.gexf.gz'
        lpu_file_1 = './data/generic_lpu_1.gexf.gz'
        comp_dict_0, conns_0 = LPU.lpu_parser(lpu_file_0)
        comp_dict_1, conns_1 = LPU.lpu_parser(lpu_file_1)

        fl_input_processor_0 = FileInputProcessor(
            './data/generic_lpu_0_input.h5')
        fl_output_processor_0 = FileOutputProcessor(
            [('V', None), ('spike_state', None)],
            'generic_lpu_0_%s_output.h5' % out_name,
            sample_interval=1)

        lpu_0_id = 'lpu_0'
        man.add(LPU,
                lpu_0_id,
                dt,
                comp_dict_0,
                conns_0,
                input_processors=[fl_input_processor_0],
                output_processors=[fl_output_processor_0],
                device=args.gpu_dev[0],
                debug=args.debug,
                time_sync=args.time_sync)

        fl_input_processor_1 = FileInputProcessor(
            './data/generic_lpu_1_input.h5')
        fl_output_processor_1 = FileOutputProcessor(
            [('V', None), ('spike_state', None)],
            'generic_lpu_1_%s_output.h5' % out_name,
            sample_interval=1)

        lpu_1_id = 'lpu_1'
        man.add(LPU,
                lpu_1_id,
                dt,
                comp_dict_1,
                conns_1,
                input_processors=[fl_input_processor_1],
                output_processors=[fl_output_processor_1],
                device=args.gpu_dev[1],
                debug=args.debug,
                time_sync=args.time_sync)

        # Create random connections between the input and output ports if the LPUs
        # are to be connected:
        if connected:

            # Find all output and input port selectors in each LPU:
            out_ports_spk_0 = plsel.Selector(','.join(
                LPU.extract_out_spk(comp_dict_0, 'id')[0]))
            out_ports_gpot_0 = plsel.Selector(','.join(
                LPU.extract_out_gpot(comp_dict_0, 'id')[0]))

            out_ports_spk_1 = plsel.Selector(','.join(
                LPU.extract_out_spk(comp_dict_1, 'id')[0]))
            out_ports_gpot_1 = plsel.Selector(','.join(
                LPU.extract_out_gpot(comp_dict_1, 'id')[0]))

            in_ports_spk_0 = plsel.Selector(','.join(
                LPU.extract_in_spk(comp_dict_0, 'id')[0]))
            in_ports_gpot_0 = plsel.Selector(','.join(
                LPU.extract_in_gpot(comp_dict_0, 'id')[0]))

            in_ports_spk_1 = plsel.Selector(','.join(
                LPU.extract_in_spk(comp_dict_1, 'id')[0]))
            in_ports_gpot_1 = plsel.Selector(','.join(
                LPU.extract_in_gpot(comp_dict_1, 'id')[0]))

            out_ports_0 = plsel.Selector.union(out_ports_spk_0,
                                               out_ports_gpot_0)
            out_ports_1 = plsel.Selector.union(out_ports_spk_1,
                                               out_ports_gpot_1)

            in_ports_0 = plsel.Selector.union(in_ports_spk_0, in_ports_gpot_0)
            in_ports_1 = plsel.Selector.union(in_ports_spk_1, in_ports_gpot_1)

            # Initialize a connectivity pattern between the two sets of port
            # selectors:
            pat = pattern.Pattern(
                plsel.Selector.union(out_ports_0, in_ports_0),
                plsel.Selector.union(out_ports_1, in_ports_1))

            # Create connections from the ports with identifiers matching the output
            # ports of one LPU to the ports with identifiers matching the input
            # ports of the other LPU:
            N_conn_spk_0_1 = min(len(out_ports_spk_0), len(in_ports_spk_1))
            N_conn_gpot_0_1 = min(len(out_ports_gpot_0), len(in_ports_gpot_1))
            for src, dest in zip(
                    random.sample(out_ports_spk_0.identifiers, N_conn_spk_0_1),
                    random.sample(in_ports_spk_1.identifiers, N_conn_spk_0_1)):
                pat[src, dest] = 1
                pat.interface[src, 'type'] = 'spike'
                pat.interface[dest, 'type'] = 'spike'
            for src, dest in zip(
                    random.sample(out_ports_gpot_0.identifiers,
                                  N_conn_gpot_0_1),
                    random.sample(in_ports_gpot_1.identifiers,
                                  N_conn_gpot_0_1)):
                pat[src, dest] = 1
                pat.interface[src, 'type'] = 'gpot'
                pat.interface[dest, 'type'] = 'gpot'

            man.connect(lpu_0_id, lpu_1_id, pat, 0, 1)

        man.spawn()
        man.start(steps=args.steps)
        man.wait()
# Create connectivity patterns between antennal lobe, medulla, and
# integration LPUs:
sel_al = LPU.extract_all(n_dict_al)
sel_int = LPU.extract_all(n_dict_int)
sel_med = LPU.extract_all(n_dict_med)

pat_al_int = pattern.Pattern(sel_al, sel_int)
pat_med_int = pattern.Pattern(sel_med, sel_int)

# Define connections from antennal lobe to integration LPU:
for src, dest in zip(['/al[0]/pn%d' % i for i in xrange(3)],
                     plsel.Selector(LPU.extract_in_spk(n_dict_int))):
    pat_al_int[src, dest] = 1
    pat_al_int.interface[src, 'type'] = 'spike'
    pat_al_int.interface[dest, 'type'] = 'spike'

# Define connections from medulla to integration LPU:
for src, dest in zip(['/medulla/Mt3%c[%d]' % (c, i) \
                      for c in ('h','v') for i in xrange(4)],
                     plsel.Selector(LPU.extract_in_gpot(n_dict_int))):
    pat_med_int[src, dest] = 1
    pat_med_int.interface[src, 'type'] = 'gpot'
    pat_med_int.interface[dest, 'type'] = 'gpot'

man.connect(al_id, int_id, pat_al_int, 0, 1, compat_check=False)
man.connect(med_id, int_id, pat_med_int, 0, 1, compat_check=False)

man.spawn()
man.start(steps=Nt)
man.wait()
Exemple #5
0
# Create connectivity patterns between each combination of LPU pairs:
for id_0, id_1 in itertools.combinations(lpu_dict.keys(), 2):

    n_dict_0 = lpu_dict[id_0]['n_dict']
    n_dict_1 = lpu_dict[id_1]['n_dict']

    # Find all output and input port selectors in each LPU:
    out_ports_spk_0 = plsel.Selector(LPU.extract_out_spk(n_dict_0))
    out_ports_gpot_0 = plsel.Selector(LPU.extract_out_gpot(n_dict_0))

    out_ports_spk_1 = plsel.Selector(LPU.extract_out_spk(n_dict_1))
    out_ports_gpot_1 = plsel.Selector(LPU.extract_out_gpot(n_dict_1))

    in_ports_spk_0 = plsel.Selector(LPU.extract_in_spk(n_dict_0))
    in_ports_gpot_0 = plsel.Selector(LPU.extract_in_gpot(n_dict_0))

    in_ports_spk_1 = plsel.Selector(LPU.extract_in_spk(n_dict_1))
    in_ports_gpot_1 = plsel.Selector(LPU.extract_in_gpot(n_dict_1))

    out_ports_0 = plsel.Selector.union(out_ports_spk_0, out_ports_gpot_0)
    out_ports_1 = plsel.Selector.union(out_ports_spk_1, out_ports_gpot_1)

    in_ports_0 = plsel.Selector.union(in_ports_spk_0, in_ports_gpot_0)
    in_ports_1 = plsel.Selector.union(in_ports_spk_1, in_ports_gpot_1)

    # Initialize a connectivity pattern between the two sets of port
    # selectors:
    pat = pattern.Pattern(plsel.Selector.union(out_ports_0, in_ports_0),
                          plsel.Selector.union(out_ports_1, in_ports_1))
Exemple #6
0
    def run(connected):
        """
        Set `connected` to True to connect the LPUs.
        """

        import neurokernel.mpi_relaunch

        out_name = 'un' if not connected else 'co'
        man = core.Manager()

        lpu_file_0 = './data/generic_lpu_0.gexf.gz'
        lpu_file_1 = './data/generic_lpu_1.gexf.gz'
        comp_dict_0, conns_0 = LPU.lpu_parser(lpu_file_0)
        comp_dict_1, conns_1 = LPU.lpu_parser(lpu_file_1)
        
        fl_input_processor_0 = FileInputProcessor('./data/generic_lpu_0_input.h5')
        fl_output_processor_0 = FileOutputProcessor(
                    [('V',None),('spike_state',None)],
                    'generic_lpu_0_%s_output.h5' % out_name, sample_interval=1)

        lpu_0_id = 'lpu_0'
        man.add(LPU, lpu_0_id, dt, comp_dict_0, conns_0,
                    input_processors = [fl_input_processor_0],
                    output_processors = [fl_output_processor_0],
                    device=args.gpu_dev[0],
                    debug=args.debug, time_sync=args.time_sync)

        fl_input_processor_1 = FileInputProcessor('./data/generic_lpu_1_input.h5')
        fl_output_processor_1 = FileOutputProcessor(
                    [('V',None),('spike_state',None)],
                    'generic_lpu_1_%s_output.h5' % out_name, sample_interval=1)
                    
        lpu_1_id = 'lpu_1'
        man.add(LPU, lpu_1_id, dt, comp_dict_1, conns_1,
                    input_processors = [fl_input_processor_1],
                    output_processors = [fl_output_processor_1],
                    device=args.gpu_dev[1],
                    debug=args.debug, time_sync=args.time_sync)

        # Create random connections between the input and output ports if the LPUs
        # are to be connected:
        if connected:

            # Find all output and input port selectors in each LPU:
            out_ports_spk_0 = plsel.Selector(
                            ','.join(LPU.extract_out_spk(comp_dict_0, 'id')[0]))
            out_ports_gpot_0 = plsel.Selector(
                            ','.join(LPU.extract_out_gpot(comp_dict_0, 'id')[0]))

            out_ports_spk_1 = plsel.Selector(
                            ','.join(LPU.extract_out_spk(comp_dict_1, 'id')[0]))
            out_ports_gpot_1 = plsel.Selector(
                            ','.join(LPU.extract_out_gpot(comp_dict_1, 'id')[0]))

            in_ports_spk_0 = plsel.Selector(
                            ','.join(LPU.extract_in_spk(comp_dict_0, 'id')[0]))
            in_ports_gpot_0 = plsel.Selector(
                            ','.join(LPU.extract_in_gpot(comp_dict_0, 'id')[0]))

            in_ports_spk_1 = plsel.Selector(
                            ','.join(LPU.extract_in_spk(comp_dict_1, 'id')[0]))
            in_ports_gpot_1 = plsel.Selector(
                            ','.join(LPU.extract_in_gpot(comp_dict_1, 'id')[0]))

            out_ports_0 = plsel.Selector.union(out_ports_spk_0, out_ports_gpot_0)
            out_ports_1 = plsel.Selector.union(out_ports_spk_1, out_ports_gpot_1)

            in_ports_0 = plsel.Selector.union(in_ports_spk_0, in_ports_gpot_0)
            in_ports_1 = plsel.Selector.union(in_ports_spk_1, in_ports_gpot_1)

            # Initialize a connectivity pattern between the two sets of port
            # selectors:
            pat = pattern.Pattern(plsel.Selector.union(out_ports_0, in_ports_0),
                                  plsel.Selector.union(out_ports_1, in_ports_1))

            # Create connections from the ports with identifiers matching the output
            # ports of one LPU to the ports with identifiers matching the input
            # ports of the other LPU:
            N_conn_spk_0_1 = min(len(out_ports_spk_0), len(in_ports_spk_1))
            N_conn_gpot_0_1 = min(len(out_ports_gpot_0), len(in_ports_gpot_1))
            for src, dest in zip(random.sample(out_ports_spk_0.identifiers,
                                               N_conn_spk_0_1),
                                 random.sample(in_ports_spk_1.identifiers,
                                               N_conn_spk_0_1)):
                pat[src, dest] = 1
                pat.interface[src, 'type'] = 'spike'
                pat.interface[dest, 'type'] = 'spike'
            for src, dest in zip(random.sample(out_ports_gpot_0.identifiers,
                                               N_conn_gpot_0_1),
                                 random.sample(in_ports_gpot_1.identifiers,
                                               N_conn_gpot_0_1)):
                pat[src, dest] = 1
                pat.interface[src, 'type'] = 'gpot'
                pat.interface[dest, 'type'] = 'gpot'

            man.connect(lpu_0_id, lpu_1_id, pat, 0, 1)

        man.spawn()
        man.start(steps=args.steps)
        man.wait()
Exemple #7
0
check_compatibility = False
if check_compatibility:
    lpu_name_to_sel_in_gpot = {}
    lpu_name_to_sel_in_spike = {}
    lpu_name_to_sel_out_gpot = {}
    lpu_name_to_sel_out_spike = {}
    lpu_name_to_sel_in = {}
    lpu_name_to_sel_out = {}
    lpu_name_to_sel_gpot = {}
    lpu_name_to_sel_spike = {}
    lpu_name_to_sel = {}

    for name in lpu_name_list:
        n_dict = lpu_name_to_n_dict[name]
        lpu_name_to_sel_in_gpot[name] = \
            Selector(LPU.extract_in_gpot(n_dict))
        lpu_name_to_sel_in_spike[name] = \
            Selector(LPU.extract_in_spk(n_dict))
        lpu_name_to_sel_out_gpot[name] = \
            Selector(LPU.extract_out_gpot(n_dict))
        lpu_name_to_sel_out_spike[name] = \
            Selector(LPU.extract_out_spk(n_dict))
        lpu_name_to_sel_in[name] = \
            Selector.union(lpu_name_to_sel_in_gpot[name], lpu_name_to_sel_in_spike[name])
        lpu_name_to_sel_out[name] = \
            Selector.union(lpu_name_to_sel_out_gpot[name], lpu_name_to_sel_out_spike[name])
        lpu_name_to_sel_gpot[name] = \
            Selector.union(lpu_name_to_sel_in_gpot[name], lpu_name_to_sel_out_gpot[name])
        lpu_name_to_sel_spike[name] = \
            Selector.union(lpu_name_to_sel_in_spike[name], lpu_name_to_sel_out_spike[name])
        lpu_name_to_sel[name] = Selector.union(lpu_name_to_sel_in[name],
# Create connectivity patterns between each combination of LPU pairs:
for id_0, id_1 in itertools.combinations(lpu_dict.keys(), 2):

    n_dict_0 = lpu_dict[id_0]['n_dict']
    n_dict_1 = lpu_dict[id_1]['n_dict']

    # Find all output and input port selectors in each LPU:
    out_ports_spk_0 = plsel.Selector(LPU.extract_out_spk(n_dict_0))
    out_ports_gpot_0 = plsel.Selector(LPU.extract_out_gpot(n_dict_0))

    out_ports_spk_1 = plsel.Selector(LPU.extract_out_spk(n_dict_1))
    out_ports_gpot_1 = plsel.Selector(LPU.extract_out_gpot(n_dict_1))

    in_ports_spk_0 = plsel.Selector(LPU.extract_in_spk(n_dict_0))
    in_ports_gpot_0 = plsel.Selector(LPU.extract_in_gpot(n_dict_0))

    in_ports_spk_1 = plsel.Selector(LPU.extract_in_spk(n_dict_1))
    in_ports_gpot_1 = plsel.Selector(LPU.extract_in_gpot(n_dict_1)) 

    out_ports_0 = plsel.Selector.union(out_ports_spk_0, out_ports_gpot_0)
    out_ports_1 = plsel.Selector.union(out_ports_spk_1, out_ports_gpot_1)

    in_ports_0 = plsel.Selector.union(in_ports_spk_0, in_ports_gpot_0)
    in_ports_1 = plsel.Selector.union(in_ports_spk_1, in_ports_gpot_1)

    # Initialize a connectivity pattern between the two sets of port
    # selectors:
    pat = pattern.Pattern(plsel.Selector.union(out_ports_0, in_ports_0),
                          plsel.Selector.union(out_ports_1, in_ports_1))
# Create connectivity patterns between antennal lobe, medulla, and 
# integration LPUs:
sel_al = LPU.extract_all(n_dict_al)
sel_int = LPU.extract_all(n_dict_int)
sel_med = LPU.extract_all(n_dict_med)

pat_al_int = pattern.Pattern(sel_al, sel_int)
pat_med_int = pattern.Pattern(sel_med, sel_int)

# Define connections from antennal lobe to integration LPU:
for src, dest in zip(['/al[0]/pn%d' % i for i in xrange(3)],
                     plsel.Selector(LPU.extract_in_spk(n_dict_int))):
    pat_al_int[src, dest] = 1
    pat_al_int.interface[src, 'type'] = 'spike'
    pat_al_int.interface[dest, 'type'] = 'spike'

# Define connections from medulla to integration LPU:
for src, dest in zip(['/medulla/Mt3%c[%d]' % (c, i) \
                      for c in ('h','v') for i in xrange(4)],
                     plsel.Selector(LPU.extract_in_gpot(n_dict_int))):
    pat_med_int[src, dest] = 1
    pat_med_int.interface[src, 'type'] = 'gpot'
    pat_med_int.interface[dest, 'type'] = 'gpot'

man.connect(al_id, int_id, pat_al_int, 0, 1, compat_check=False)
man.connect(med_id, int_id, pat_med_int, 0, 1, compat_check=False)

man.spawn()
man.start(steps=Nt)
man.wait()
    # Find all output and input port selectors in each LPU:
    out_ports_spk_0 = plsel.Selector(','.join(
        LPU.extract_out_spk(comp_dict_0, 'id')[0]))
    out_ports_gpot_0 = plsel.Selector(','.join(
        LPU.extract_out_gpot(comp_dict_0, 'id')[0]))

    out_ports_spk_1 = plsel.Selector(','.join(
        LPU.extract_out_spk(comp_dict_1, 'id')[0]))
    out_ports_gpot_1 = plsel.Selector(','.join(
        LPU.extract_out_gpot(comp_dict_1, 'id')[0]))

    in_ports_spk_0 = plsel.Selector(','.join(
        LPU.extract_in_spk(comp_dict_0, 'id')[0]))
    in_ports_gpot_0 = plsel.Selector(','.join(
        LPU.extract_in_gpot(comp_dict_0, 'id')[0]))

    in_ports_spk_1 = plsel.Selector(','.join(
        LPU.extract_in_spk(comp_dict_1, 'id')[0]))
    in_ports_gpot_1 = plsel.Selector(','.join(
        LPU.extract_in_gpot(comp_dict_1, 'id')[0]))

    out_ports_0 = plsel.Selector.union(out_ports_spk_0, out_ports_gpot_0)
    out_ports_1 = plsel.Selector.union(out_ports_spk_1, out_ports_gpot_1)

    in_ports_0 = plsel.Selector.union(in_ports_spk_0, in_ports_gpot_0)
    in_ports_1 = plsel.Selector.union(in_ports_spk_1, in_ports_gpot_1)

    # Initialize a connectivity pattern between the two sets of port
    # selectors:
    pat = pattern.Pattern(plsel.Selector.union(out_ports_0, in_ports_0),