apache / apache/arrow

[Python] mix of np.float16/np.float128 and integers converts to Int64Array, not DoubleArray

Open
#40,910 1 comment 0 reactions 0 assignees View on GitHub
Component: Python Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

When you mix `np.float32` or `np.float64` scalars and integers, the result is `DoubleArray`:

```python
>>> pa.array([np.float32(0.5), 1])

[
0.5,
1
]
>>> pa.array([np.float64(0.5), 1])

[
0.5,
1
]
```

But when you mix `np.float16` or `np.float128` scalars and integers, the result is `Int64Array`, and the floats are truncated to integers:

```python
>>> pa.array([np.float16(0.5), 1])

[
0,
1
]
>>> pa.array([np.float128(0.5), 1])

[
0,
1
]
```

### Component(s)

Python

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.