Skip to content

BUG: Using the latex presentation of a Polynomial with coefficients of object dtype raises an error #24576

@eendebakpt

Description

@eendebakpt

Describe the issue:

The latex presentation is automatically used in environments like Jupyter notebook and Spyder. For coefficients of object dtype an exception is generated since np.signbit is not available.

Reproduce the code example:

import fractions
from numpy.polynomial import Polynomial

f=fractions.Fraction(2,3)
p=Polynomial([f, f])
p._repr_latex_()

Error message:

Traceback (most recent call last):

  Cell In[2], line 6
    p._repr_latex_()

  File C:\develop\env311\Lib\site-packages\numpy\polynomial\_polybase.py:468 in _repr_latex_
    elif not np.signbit(c):

TypeError: ufunc 'signbit' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Runtime information:

1.25.1
3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions