sot / Quaternion

Quaternion manipulation
https://sot.github.io/Quaternion
BSD 3-Clause "New" or "Revised" License
3 stars 7 forks source link

Chandra.Maneuver tests fail #18

Closed jeanconn closed 4 years ago

javierggt commented 4 years ago

The problem is in the multiplication. All attributes ere being squeezed to the right shape, but when multiplying two quaternions the result is being inadvertently reshaped, because the result is created from the two input quaternions after applying np.atleast_2d.

One solution is to check the shape of the original quaternions and reshape after the multiplication operation.

While doing this, I realized that there is an implicit broadcasting. We did not think of a generic broadcasting, but the current behavior allows one to do this:

q2 = Quaternion.Quat(equatorial=[[10, 20, 30]])
q1 = Quaternion.Quat(equatorial=[1, 2, 3])
q3 = q1 * q2

This is because there is a check that both quaternions have the same shape, but again this is done after np.atleast_2d.

Options:

  1. Forbid the operation above (by requiring the same shape: q1.shape == q2.shape)
  2. Allow this limited broadcasting by setting the output's shape to the largest of the input shapes