Skip to content

BUG: Quad ufunc promoters override valid object common-dtype promotion #114

Description

@SwayamInSync

The generic Quad promoters force every operand to QuadPrecDType whenever one input is Quad. This conflicts with NumPy's normal common-dtype result for object arrays.

Reproducer:

import numpy as np
from numpy_quaddtype import QuadPrecDType

q = np.array([1, 2], dtype=QuadPrecDType())
obj = np.array([3, 4], dtype=object)

assert np.result_type(q, obj) == np.dtype(object)
np.add(q, obj)  # TypeError: cannot cast dtype object to QuadPrecDType

The same issue affects operations including multiply, comparisons, and matmul. Explicitly converting the Quad array to object allows NumPy's object loop to produce the expected result.

This is related to #76, but different: #76 fixed promoters matching calls with no Quad operand. Here a Quad operand is present, but the promoter chooses the wrong common dtype.

Acceptance criteria:

  • Quad/object operations select the existing object loop where applicable.
  • Both operand orders behave consistently.
  • Unsupported complex/string combinations continue to raise promotion errors.
  • Importing quaddtype does not alter built-in-only NumPy dispatch.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions