I'm kinda new to python, currently working on a project and getting this error with this lines of code.
g1_coll[obstacle==0]=tau*(g1+g2-g3+g4)
g2_coll[obstacle==0]=tau*(g1+g2+g3-g4)
g3_coll[obstacle==0]=tau*(-g1+g2+g3+g4)
g4_coll[obstacle==0]=tau*(g1-g2+g3+g4)
can anyone help me understand this?
I Assume the error you are getting is because all of your arrays are 2-dimensional. I suggest you try using numpy.putmask(matrix, mask, new_matrix_values)
For instance
mask = (obstacle == 0)
numpy.putmask(g1_coll, mask, tau*(g1+g2-g3+g4))
numpy.putmask(g2_coll, mask, tau*(g1+g2+g3-g4))
numpy.putmask(g3_coll, mask, tau*(-g1+g2+g3+g4))
numpy.putmask(g4_coll, mask, tau*(g1-g2+g3+g4))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With