numpy / numpy/numpy-quaddtype

casting to `quaddtype` emits uneccesary warnings

Open
#25 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
24
Forks
6
Avg merge
5d 41m
Merged PRs (30d)
3

Description

When using np.astype and the array has inf or nan, I see a RuntimeWarning: invalid value encountered in cast. On internal numpy float dtypes these are not emitted.

Run with python -Walways

import numpy as np
import numpy_quaddtype
a = np.arange(30, dtype=np.float32); 
a[-1] = np.inf
q = numpy_quaddtype.QuadPrecision
d = np.float64
warns = a.astype(q)
# <stdin>:1: RuntimeWarning: invalid value encountered in cast
nowarns = a.astype(d)
# This does not warn
warns.astype(d)

I think this is coming from sleef?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Python reproducer with python -Walways and compare astype behavior for numpy_quaddtype.QuadPrecision and np.float64. Trace the cast path and investigate the suspected sleef involvement; done means converting arrays containing inf or nan no longer emits the unnecessary warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.