-
Hi, I am very intrigued by vectorized approach. I found numpy has useful function for that and it looks helpful for vectorized modeling. For example, I can use the code below which is easy to understand def NO_SURRS(t):
but when I tried this function, the error message pops up and it said np is not defined even if I wrote Import Numpy as np at the top of the code. Instead of previous code, the code below works well. def NO_SURRS(t):
The problem is that the models will have many cells use that method and each of cells need to call import numpy as np. Is there any way to call numpy once? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes. If import numpy as np
Projection.np = np After this, Insted, if you assign the numpy module to the |
Beta Was this translation helpful? Give feedback.
Yes. If
NO_SURRS
is defined in theProjection
space, then you can assign the numpy module to thenp
attribute ofProjection
like this:After this,
np
becomes referable in any formulas inProjection
, includingNO_SURRS
.Insted, if you assign the numpy module to the
np
attribute of the model instead, thennp
becomes referable from any formulas in all spaces in the model.