Skip to content

QuadPrec scalar repr isn't ideal for display in arrays #131

@ngoldbaum

Description

@ngoldbaum

I think it'd be a lot nicer if we used the string form instead of the repr form when formatting arrays:

>>> np.array([str(pi), str(pi+1)], dtype=npq.QuadPrecDType())
array([QuadPrecision('3.1415926535897932384626433832795e+000', backend='sleef'),
       QuadPrecision('4.1415926535897932384626433832795e+000', backend='sleef')],
      dtype=QuadPrecDType(backend='sleef'))

The current output repeats backend='sleef' three times and uses the unnecessarily verbose format with QuadPrecision showing up explicitly.

This is happening because of this choice:

>>> str(npq.QuadPrecision(str(pi)))
'3.1415926535897932384626433832795  '
>>> repr(npq.QuadPrecision(str(pi)))
"QuadPrecision('3.1415926535897932384626433832795e+000', backend='sleef')"

IMO it would be better if the array repr used the string form instead of the repr format.

Although that said, I'm not totally sure why there's trailing whitespace in the string format. That might be another bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions