Skip to content

Commit f632703

Browse files
Merge branch 'main' into jp-4242
2 parents e717bec + b54adbf commit f632703

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ test = [
4242
"pytest>=9.0",
4343
"pytest-asdf-plugin",
4444
"pytest-doctestplus",
45-
"crds>=11.17.1",
45+
"crds>=11.17.1,<13.1.15",
4646
"requests",
47-
"scipy>=1.9.2", # same as astropy
47+
"scipy>=1.9.2", # same as astropy
4848
]
4949
docs = [
5050
"sphinx",

src/stdatamodels/util.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,13 @@ def gentle_asarray(a, dtype, allow_extra_columns=False):
6767
raise ValueError(msg)
6868

6969
# When a FITS file includes a pseudo-unsigned-int column, astropy will return
70-
# a FITS_rec with an incorrect table dtype. The following code rebuilds
71-
# in_dtype from the individual fields, which are correctly labeled with an
72-
# unsigned int dtype.
73-
# We can remove this once the issue is resolved in astropy:
70+
# a FITS_rec with an incorrect table dtype.
71+
# It's also unsafe to directly cast any FITS_rec with a
72+
# pseudo-unsigned column.
7473
# https://github.com/astropy/astropy/issues/8862
7574
if isinstance(a, fits.fitsrec.FITS_rec):
76-
a.dtype = _rebuild_fits_rec_dtype(a)
77-
in_dtype = a.dtype
75+
if any(c.bzero is not None for c in a.columns):
76+
return _safe_asanyarray(a, out_dtype)
7877

7978
if in_dtype == out_dtype:
8079
return a
@@ -161,7 +160,7 @@ def _safe_asanyarray(a, dtype):
161160
if any(c.bzero is not None for c in a.columns):
162161
# Due to an issue in astropy, it's not safe to directly cast
163162
# a FITS_rec with a pseudo-unsigned column.
164-
# See https://github.com/astropy/astropy/issues/12112
163+
# See https://github.com/astropy/astropy/issues/8862
165164
result = np.zeros(a.shape, dtype=dtype)
166165
for old_col, new_col in zip(a.dtype.names, result.dtype.names, strict=False):
167166
result[new_col] = a[old_col]

0 commit comments

Comments
 (0)