I am having trouble trying to use multiple values to test since linspace and range in for loop is not accepting array as an input.
Here is an example of what I am trying to do:
gp_input = np.array([31,61])
def var_gp(gp):
for i in gp:
x_l = np.linspace(0,3,gp)
...
for i in range(gp):
...
What the error tells me:
Traceback (most recent call last):
File "variable gp.py", line 306, in var_gp(gp_input)
File "variable gp.py", line 18, in var_gp
x_l = np.linspace(0,3,gp)
File "<__array_function__ internals>", line 5, in linspace
File "/home/rjomega/anaconda3/lib/python3.8/site-packages/numpy/core/function_base.py", line 120, in linspace
num = operator.index(num)
TypeError: only integer scalar arrays can be converted to a scalar index
It feels like it would become a bad habit if I'll just manually change the value of gp and hoping I can just insert as much values to try. Thank you.
it works fine if I will just manually change the value of gp and not using def function
Solution I have found if you also experienced this kind of problem:
for i in gp:
gp = i
x_l = np.linspace(0,3,gp)
...
for i in range(gp):
...
adding gp = i seems to bypass the problem