Fix linspace retstep dtype handling - #2304
Conversation
Cast only the generated samples when retstep is enabled, preserving the step value returned by the core implementation. Add regression coverage across inferred, integer, and floatX dtypes.
| dtype = pytensor.config.floatX | ||
| start, stop = broadcast_arrays(start, stop) | ||
|
|
||
| ls = _linspace_core( |
There was a problem hiding this comment.
the other places that make use of this helper don't share the same problem?
|
Good question — I checked, and no, the other callers are unaffected.
Since Confirmed on the branch: One thing worth flagging from that last line: I left |
Description
linspace(..., retstep=True)now casts only the generated samples instead of callingastypeon the returned tuple. The step keeps NumPy-compatible floating-point precision.Related Issue
linspaceandretstep=Truefails #1297Checklist
Type of change