# Syntax error: Value is not constant

**URL:** <https://brian.discourse.group/t/syntax-error-value-is-not-constant/1078>\
**Category:** Support\
**Tags:** synapses\
**Created:** [13 November 2023 07:31 UTC](https://brian.discourse.group/t/syntax-error-value-is-not-constant/1078 "2023-11-13T07:31:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliasmateo95](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/eliasmateo95/32/384_2.png) [@eliasmateo95](https://brian.discourse.group/u/eliasmateo95)\
**Post date:** [13 November 2023 07:31 UTC](https://brian.discourse.group/t/syntax-error-value-is-not-constant/1078/1 "2023-11-13T07:31:20Z")

</div>

Description of problem  
Hello, I am trying a new plasticity mechanism that depends on the activity of the presynaptic neuron (rho\_PF) and postsynaptic neuron (rho\_PC). The change in weights depends on a sliding threshold based on the postsynaptic neuron’s activity. However, the equation I’m trying to use to keep my weight changes bounded does not work. I get an error that says Syntax error: Value thresh\_M is not constant.

Minimal code to reproduce problem

```auto
eqs_Copy = '''
                I : amp # copy of the noise current
                rho_PF : Hz 
                rho_PC : Hz
                weight : 1 (constant)
                new_weight = weight + delta_weight_CS: 1 
                ddelta_weight_BCM/dt = ((rho_PC*(rho_PC-thresh_M)*e**(-((thresh_M-500*Hz)/(250*(thresh_M-250*Hz)))*rho_PC))/thresh_M)*rho_PF*msecond : 1 
                phi = (rho_PC*(rho_PC-thresh_M)*e**(-((thresh_M-500*Hz)/(250*(thresh_M-250*Hz)))*rho_PC))/thresh_M : Hz    
                dthresh_M/dt = rho_PC**2 - thresh_M/tau_thresh_M : Hz 
        '''
        conn_N_PC = NeuronGroup(N_Copy, eqs_Copy, method='euler',dt=dt)
        conn_N_PC.weight = Noise_PC_Synapse_Weights
        mon_N_PC = StateMonitor(conn_N_PC , ['rho_PF','rho_PC','phi','thresh_M','delta_weight_CS','new_weight','delta_weight_BCM'], record=conn_N_PC_record, dt=dt_rec) 

```

What you have aready tried  
I understand the problem comes from the (250-theta) part as theta could reach 250 and make it go to zero. However, I don’t understand what the error truly means.

# Expected output (if relevant)

# Actual output (if relevant)

# Full traceback of error (if relevant)

---

<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 November 2023 10:11 UTC](https://brian.discourse.group/t/syntax-error-value-is-not-constant/1078/2 "2023-11-13T10:11:18Z")

</div>

Hi @eliasmateo95. This is less obvious than what it should be, but first the reason for the error: in this equation

```auto
e**(-((thresh_M-500*Hz)/(250*(thresh_M-250*Hz)))*rho_PC)

```

the exponent of e is wrong, you probably wanted to close the parentheses before multiplying it with `rho_PC` (or divide `rho_PC` by `thresh_M` as part of the argument)? As it is written now, the exponent has dimensions of 1/time, and you cannot take e to the power of a value that is not dimensionless.

You’d actually get a better error message if you used `exp(...)` instead of `e**(...)`:

```verbatim
Argument number 1 for function exp does not have the correct units. Expression '(- ((thresh_M - (500 * Hz)) / (250 * (thresh_M - (250 * Hz))))) * rho_PC' has units (s^-1), but should be (1).

```

The reason you are getting this “value is not constant” error is that the code is going through the general pathway for x^y, trying to figure out the value of y (since e.g. something like `v**c` would have a different dimensionality depending on the value of the constant `c`). In your case, y is not a fixed value, since it refers to the variables `thresh_M` and `rho_PC`. This is why it complains about a value that isn’t constant. If y is dimensionless (as it should be), then it shouldn’t matter – we should change the error handling here so that it doesn’t hide the real issue.

Hope that makes things clear!
