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

wc.run(continue_run=True) breaks #163

Open
ronja-roevardotter opened this issue Jun 14, 2021 · 4 comments
Open

wc.run(continue_run=True) breaks #163

ronja-roevardotter opened this issue Jun 14, 2021 · 4 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ronja-roevardotter
Copy link

by calling

for i, val in enumerate(inputs):
  if i==0:
    wc.run()
  else:
    wc.run(continue_run=True)

the following error is returned as i=2:

Traceback (most recent call last):
  File "/mnt/antares_raid/home/ronjastroms/anaconda3/envs/trial/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/mnt/antares_raid/home/ronjastroms/anaconda3/envs/trial/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/mnt/antares_raid/home/ronjastroms/Bifurcation.py", line 139, in continuedRun_wc
    self.model.run(continue_run=True)
  File "/mnt/antares_raid/home/ronjastroms/anaconda3/envs/trial/lib/python3.7/site-packages/neurolib/models/model.py", line 227, in run
    self.integrate(append_outputs=append, simulate_bold=bold)
  File "/mnt/antares_raid/home/ronjastroms/anaconda3/envs/trial/lib/python3.7/site-packages/neurolib/models/model.py", line 267, in integrate
    t, *variables = self.integration(self.params)
  File "/mnt/antares_raid/home/ronjastroms/anaconda3/envs/trial/lib/python3.7/site-packages/neurolib/models/wc/timeIntegration.py", line 164, in timeIntegration
    tau_adap,
  File "/mnt/antares_raid/home/ronjastroms/anaconda3/envs/trial/lib/python3.7/site-packages/numba/dispatcher.py", line 401, in _compile_for_args
    error_rewrite(e, 'typing')
  File "/mnt/antares_raid/home/ronjastroms/anaconda3/envs/trial/lib/python3.7/site-packages/numba/dispatcher.py", line 344, in error_rewrite
    reraise(type(e), e, None)
  File "/mnt/antares_raid/home/ronjastroms/anaconda3/envs/trial/lib/python3.7/site-packages/numba/six.py", line 668, in reraise
    raise value.with_traceback(tb)
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<built-in function setitem>) with argument(s) of type(s): (array(float64, 2d, C), UniTuple(int64 x 2), array(float64, 1d, C))
 * parameterized
In definition 0:
    All templates rejected with literals.
In definition 1:
    All templates rejected without literals.
In definition 2:
    All templates rejected with literals.
In definition 3:
    All templates rejected without literals.
In definition 4:
    All templates rejected with literals.
In definition 5:
    All templates rejected without literals.
In definition 6:
    All templates rejected with literals.
In definition 7:
    All templates rejected without literals.
In definition 8:
    All templates rejected with literals.
In definition 9:
    All templates rejected without literals.
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: typing of setitem at /mnt/antares_raid/home/ronjastroms/anaconda3/envs/trial/lib/python3.7/site-packages/neurolib/models/wc/timeIntegration.py (270)

File "anaconda3/envs/trial/lib/python3.7/site-packages/neurolib/models/wc/timeIntegration.py", line 270:
    def S_I(x):
        <source elided>
            # Euler integration
            excs[no, i] = excs[no, i - 1] + dt * exc_rhs
            ^
@jajcayn
Copy link
Collaborator

jajcayn commented Jun 14, 2021

hey @Ronjaa95,

it seems that inputs have weird shape and neurolib is not happy about that:)
can you please do something like:

for i, val in enumerate(inputs):
    print(inputs.shape)
    if i==0:
        wc.run()
    else:
        wc.run(continue_run=True)

now I see you do not pass the inputs to the run, is that intended?
when I simply do:

wc.run()
# any number of times
wc.run(continue_run=True)
wc.run(continue_run=True)
wc.run(continue_run=True)

it works for me...

@caglorithm caglorithm added the help wanted Extra attention is needed label Jun 14, 2021
@ronja-roevardotter
Copy link
Author

I'm sorry, I forgot to insert that into the code, the loop does change the input:


for i, val in enumerate(inputs):
  if i==0:
    wc.params['exc_ext']=val
    wc.run()
  else:
    wc.params['exc_ext']=val
    wc.run(continue_run=True)

I'll check for the shape.

@caglorithm
Copy link
Member

Mhh it's a weird error, it looks like the arguments of the functions are changing. For sure, will need to use python mode to debug this, but I can look into this! Could you please post the entire code that reproduces the error? It would make it a lot easier to find the bug.

Thanks for creating the Issue!

@caglorithm caglorithm self-assigned this Jun 14, 2021
@caglorithm caglorithm added the bug Something isn't working label Jun 14, 2021
@ronja-roevardotter
Copy link
Author

Sure, the inputs are initialized by

inputs = np.arange(bound_low, bound_up, stepsize)

The function is called via

modelUp = copy.deepcopy(wc) # deepcopy model to avoid interference
p1 = multiprocessing.Process(target=self.continuedRun_wc, 
                                         args=(modelUp, 'up', inputs, return_dict, wiggle))
p1.start()

into the function

 def continuedRun_wc(self, model, typ, steps, returndict):
        
        numSteps = len(steps)
        max_exc = np.ndarray( numSteps )
        min_exc = np.ndarray( numSteps )
        max_inh = np.ndarray( numSteps )
        min_inh = np.ndarray( numSteps )

            
        for i, cvalue in tqdm(enumerate(steps), total=numSteps):
            wc.params[self.continueParam] = cvalue
            if i == 0:
                self.model.run()
            else:                
                self.model.run(continue_run=True)

           # get max and min of last n seconds (defined by self.analysisDur)
            end = snalysisDur*1000 /mwcparams.dt

            max_exc[i] = np.max(wc['exc'][0, -int(end):])
            min_exc[i] = np.min(wc['exc'][0, -int(end):])
            max_inh[i] = np.max(wc['inh'][0, -int(end):])
            min_inh[i] = np.min(wc['inh'][0, -int(end):])

    
        returndict[typ] = [max_exc, min_exc, max_inh, min_inh]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants