python - Stacking Arrays in pylab using vstack -


i have following code stack arrays , solve system of equations:

 1     import numpy np  2     numpy.linalg import solve   3     xi = np.array([-1., 1., -2])  4     yi = np.array([0., 4., 3.])  5     = np.vstack([np.ones(3), xi, xi**2]).t  6     b = yi   7     c = solve(a,b) 

then after have code execute graph, error on line 5. says:

  typeerror: 'function' object has no attribute '__getitem__' 

how can fix this?

it looks you've got brackets confused. code printed above has mismatched brackets @ line 5: ([...)] gives syntaxerror. i'd guess version used [(...)] gives error report. problem you're trying call function using square brackets, when python syntax requires round ones. try putting brackets other way round: ([...]) code runs fine on system.

edit: question edited while typed this, ignore first 2 sentences. still suspect ordering of brackets wrong in code run.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -