astropy / astropy/astropy

Saving HDUList corrupts array data assigned to `BinTableHDU.data`

Open
#15,366 6 comments 0 reactions 0 assignees View on GitHub
Bug io.fits
Dominant language
Python
Stars
5.3k
Forks
2.2k
Avg merge
1d 18h
Merged PRs (30d)
74

Description

### Description

If a record array with an unsigned dtype is assigned to the `data` attribute of a `BinTableHDU` the data in the original array is modified when the `BinTableHDU` is saved (as seen in the example below).

Tested with `5.3` and a recently build 'nightly' `6.0.dev697+gb9b552a68` in python 3.10 on mac os (M1).

### Expected behavior

_No response_

### How to Reproduce

Running the following:

```python
from astropy.io import fits
import numpy as np

tbl = np.array([1, 2, 3], dtype=[('a', '

Contributor guide

Open the contributing guide

Research direction

Run the provided NumPy reproduction through astropy.io.fits.HDUList, BinTableHDU.data, and writeto, then trace where saving changes the assigned record array. Done means the original unsigned array remains unchanged after writing the FITS file, with regression coverage for the shown case.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.