You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Real of a weak complex scalar drops the weak flag (NEP 50 promotion) #126
Real of a weak complex scalar drops the weak flag, so the scalar no longer takes the other operand's dtype.
NumPy 2 (NEP 50): np.float32(1) + np.real(1+0j) stays float32, because the Python complex's real part is a weak float.
ndarray: float32Array.Add(Scalar(1+0i).Real()) gives Float64. Real on a complex array goes through AsType(complexPart(...)), which builds a new array without the weak field.
The real-scalar case is right: Scalar(1).Real() keeps weakInt, and int8 + Scalar(1).Real() stays int8. This was found while reviewing #125 and predates it.
Fix: in Real (and Imag, which has the same shape), carry weakComplex → weakFloat onto the result, with a test per dtype pair.
Prior art: priorart "weak scalar Real complex flag" at 2026-11-15 20:23 CET reported prior art; checked: priorart 'weak scalar Real complex flag': 64 entries, all single-word matches (weak/scalar/real); #42 introduced weak scalars and #125 touches Real for real dtypes only; none covers the complex-scalar weak flag
Activity