Skip to content

quaternions do not respect numpy.set_printoptions #254

Description

@tapple

quaternions print their components in a fixed format. by contrast, number printing in numpy is quite configurable via numpy.set_printoptions. quaternions should print their components the same format numpy prints other floating point numbers

To Reproduce

In [1]: import numpy as np, quaternion

In [2]: q = quaternion.from_rotation_vector([1, 2, 3])

In [3]: q
Out[3]: quaternion(-0.295551127492978, 0.255321860045264, 0.510643720090529, 0.765965580135793)

In [4]: quaternion.as_float_array(q)
Out[4]: array([-0.29555113,  0.25532186,  0.51064372,  0.76596558])

In [5]: np.set_printoptions(precision=5, suppress=True, sign='+', floatmode='fixed')

In [6]: quaternion.as_float_array(q)
Out[6]: array([-0.29555, +0.25532, +0.51064, +0.76597])

In [7]: q
Out[7]: quaternion(-0.295551127492978, 0.255321860045264, 0.510643720090529, 0.765965580135793)

Expected behavior

Out[3]: quaternion(-0.29555113,  0.25532186,  0.51064372,  0.76596558)
Out[7]: quaternion(-0.29555, +0.25532, +0.51064, +0.76597)

Environment (please complete the following information):

  • OS: Fedora 42
  • Installation method: pip
  • Numpy version: 2.3.2
  • Quaternion version: 2024.0.10

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions