# Error when running with synapse of 0-connections loaded from a file

**URL:** <https://brian.discourse.group/t/error-when-running-with-synapse-of-0-connections-loaded-from-a-file/781>\
**Category:** Support\
**Created:** [9 September 2022 21:29 UTC](https://brian.discourse.group/t/error-when-running-with-synapse-of-0-connections-loaded-from-a-file/781 "2022-09-09T21:29:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidKing2020](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DavidKing2020](https://brian.discourse.group/u/DavidKing2020)\
**Post date:** [9 September 2022 21:29 UTC](https://brian.discourse.group/t/error-when-running-with-synapse-of-0-connections-loaded-from-a-file/781/1 "2022-09-09T21:29:20Z")

</div>

When running with synapse of 0-connections loaded from a file, I encounter the error the following error in runtime mode:

```
"synapses' does not do anything ...."

```

This error, however, doesn’t show up in cpp\_standalone mode. Is it possible to avoid this error in runtime mode?

Here is the code to demonstrate the issue:

```
    from brian2 import *
    import numpy as np

    #set_device('cpp_standalone')

    eqs = '''
    dv/dt = (I-v)/tau : 1
    I : 1
    tau : second
    '''
    G = NeuronGroup(3, eqs, threshold='v>1', reset='v = 0', method='exact')
    G.I = [2, 0, 0]
    G.tau = [10, 100, 100]*ms

    t = np.load('test.npz')
    S = Synapses(G, G, 'w : 1', on_pre='v_post += w')
    if len(t['i'])>0:
        S.connect(i=t['i'], j=t['j'])
        S.w = t['w']
        S.delay = t['delay']*ms

    net = Network()
    net.add(G)
    net.add(S)

    run(50*ms)

```

After removing the comment on “set\_device(‘cpp\_standalone’)”, the run will be successful. I also noticed that without “Network()”, the code can run in both mode, but I will need the Network() in the actual application.

The code to produce the input file “test.npz” is the following:

```
    from brian2 import *
    import numpy as np

    eqs = '''
    dv/dt = (I-v)/tau : 1
    I : 1
    tau : second
    '''
    G = NeuronGroup(3, eqs, threshold='v>1', reset='v = 0', method='exact')
    G.I = [2, 0, 0]
    G.tau = [10, 100, 100]*ms

    S = Synapses(G, G, 'w : 1', on_pre='v_post += w')
    S.connect(p=0.0)
    S.w = 'j*0.2'
    S.delay = 'j*2*ms'

    # save the file, load it and run
    np.savez('test', i=S.i[:], j=S.j[:], w=S.w[:], delay=S.delay[:])

    run(50*ms)

```

Thanks

---

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [13 September 2022 09:34 UTC](https://brian.discourse.group/t/error-when-running-with-synapse-of-0-connections-loaded-from-a-file/781/2 "2022-09-13T09:34:26Z")

</div>

Hi @DavidKing2020 , thanks for the report. This is a bit of a bug: the error message is correct (you shouldn’t be able to use `Synapses` where `connect` has never been called), but calling `S.connect(i=..., j=...)` with empty arrays should work (so there should be no need for the `if len(...)` statement). As a workaround, you can add an explicit empty connect after the block, i.e.:

```auto
if len(t['i'])>0:
    ...
else:
    S.connect(False)

```

It should then work in either mode.

> [@DavidKing2020](#):
>
> I also noticed that without “Network()”, the code can run in both mode, but I will need the Network() in the actual application.

Using a `Network` or not shouldn’t make a difference with respect to the two modes, but note that here:

> [@DavidKing2020](#):
>
> ```auto
> net = Network()
> net.add(G)
> net.add(S)
> 
> run(50*ms)
> 
> ```

You are creating a network `net` but you are not using it – instead you run the default “magic network” composed of all objects visible at the location of the `run` call. You probably want to use `net.run(50*ms)` instead.
