1
I have this function in Matlab
cn = reshape(repmat(sn, n_rep, 1), 1,[]);
in Python I have the following code:
import numpy as np
from numpy.random import randint
M=2
N=2*10**8 ### valor de Dados
n_rep = 3 ## numero de repetições
sn = randint(0,M,size = N)### Inteiros 0 e 1
print("sn=", sn)
cn_repmat=np.tile(sn,n_rep)
print("cn_repmat=", cn_repmat)
cn=np.reshape(cn_repmat,1,[])
print(cn)
I’m not sure if the square parentheses in python are like this because it gives me the following error
File "C:/Users/Sergio Malhao/.spyder-py3/Desktop/untitled6.py", line 17, in <module>
cn=np.reshape(cn_repmat,1,[])
File "E:\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 232, in reshape
return _wrapfunc(a, 'reshape', newshape, order=order)
File "E:\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py", line 57, in _wrapfunc
return getattr(obj, method)(*args, **kwds)
ValueError: cannot reshape array of size 600000000 into shape (1,)
That mistake is not about
Parênteses
, error of Parentheses that’s how it isSyntaxError: Missing parentheses
– NoobSaibot
@Wéllingthonm.Download the rectal parenthesis is what we call a square bracket. Possibly the author is from another country. I believe the question is whether it is right to use
[]
in functionreshape
.– Woss
yes the doubt is if it is right to use brackets (parentheses) and how I can make the correct syntax, in cn
– Sergio Nunes