0

I have the following code:

l = -r_dot_k - sq_rt + 2*sq_rt*(npl.norm(r_rel,axis=1)<np.abs(self._radius))
l.reshape(N,1)
intercept_pt = ray_direction*l + ray_point

#r_dot_k: (25L,)
#sq_rt: (25L,)
#r_rel: (25L,3L)
#l: (25L,) #after first line
#ray_direction: (25L,3L)
#ray_point: (25L,3L)

There is an error for the third line saying that 'operands could not be broadcast together with shapes (25,3) (25,)'. Since the shape of l is not correct, I add the second line to try to change the shape of l from (25L,) to (25L,1L), but it doesn't work. The shape of l before and after the second line is still (25L,). Why? How should I reshape l so that the third line can run?

1
  • 1
    I think ray_direction*l[:,None], which might be same as ray_direction*l.reshape(N,1) if you want to use the second line, where N = 25. Commented Jan 29, 2016 at 21:23

1 Answer 1

2

array.reshape doesn't modify array it returns a new array with the new shape. I think you want:

l = l.reashape(N, 1)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.