Skip to content

Commit

Permalink
Merge pull request #911 from eslavich/PR-901-2.7.x
Browse files Browse the repository at this point in the history
PR 901 2.7.x
  • Loading branch information
eslavich authored Jan 15, 2021
2 parents efcd637 + e08378c commit 5030d5a
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

- Fix bug causing test collection failures in some environments. [#889]

- Fix bug when decompressing arrays with numpy 1.20. [#901]

2.7.1 (2020-08-18)
------------------

Expand Down
2 changes: 1 addition & 1 deletion asdf/commands/tests/test_defragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def _test_defragment(tmpdir, codec):
x = np.arange(0, 1000, dtype=np.float)
x = np.arange(0, 1000, dtype=float)

tree = {
'science_data': x,
Expand Down
2 changes: 1 addition & 1 deletion asdf/commands/tests/test_exploded.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def test_explode_then_implode(tmpdir):
x = np.arange(0, 10, dtype=np.float)
x = np.arange(0, 10, dtype=float)

tree = {
'science_data': x,
Expand Down
2 changes: 1 addition & 1 deletion asdf/commands/tests/test_to_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def test_to_yaml(tmpdir):
x = np.arange(0, 10, dtype=np.float)
x = np.arange(0, 10, dtype=float)

tree = {
'science_data': x,
Expand Down
6 changes: 5 additions & 1 deletion asdf/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,11 @@ def decompress(fd, used_size, data_size, compression):
raise ValueError("Decompressed data too long")
elif i + len(decoded) < data_size:
raise ValueError("Decompressed data too short")
buffer[i:i+len(decoded)] = decoded
# Previous versions of numpy permitted assignment of an
# empty bytes object to an empty array range, but starting
# with numpy 1.20 this raises an error.
elif len(decoded) > 0:
buffer[i:i+len(decoded)] = decoded

return buffer

Expand Down
4 changes: 2 additions & 2 deletions asdf/fits_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class AsdfInFits(asdf.AsdfFile):
from astropy.io import fits
hdulist = fits.HDUList()
hdulist.append(fits.ImageHDU(np.arange(512, dtype=np.float), name='SCI'))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=np.float), name='DQ'))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=float), name='SCI'))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=float), name='DQ'))
tree = {
'model': {
Expand Down
10 changes: 5 additions & 5 deletions asdf/tags/core/tests/test_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def url_mapping(self):


def test_sharing(tmpdir):
x = np.arange(0, 10, dtype=np.float)
x = np.arange(0, 10, dtype=float)
tree = {
'science_data': x,
'subset': x[3:-3],
Expand Down Expand Up @@ -136,7 +136,7 @@ def test_all_dtypes(tmpdir):


def test_dont_load_data():
x = np.arange(0, 10, dtype=np.float)
x = np.arange(0, 10, dtype=float)
tree = {
'science_data': x,
'subset': x[3:-3],
Expand Down Expand Up @@ -269,7 +269,7 @@ def check_raw_yaml(content):


def test_inline():
x = np.arange(0, 10, dtype=np.float)
x = np.arange(0, 10, dtype=float)
tree = {
'science_data': x,
'subset': x[3:-3],
Expand Down Expand Up @@ -301,7 +301,7 @@ def test_inline_bare():


def test_mask_roundtrip(tmpdir):
x = np.arange(0, 10, dtype=np.float)
x = np.arange(0, 10, dtype=float)
m = ma.array(x, mask=x > 5)
tree = {
'masked_array': m,
Expand All @@ -321,7 +321,7 @@ def check_asdf(asdf):
helpers.assert_roundtrip_tree(tree, tmpdir, asdf_check_func=check_asdf)

def test_len_roundtrip(tmpdir):
sequence = np.arange(0, 10, dtype=np.int)
sequence = np.arange(0, 10, dtype=int)
tree = {
'sequence': sequence
}
Expand Down
2 changes: 1 addition & 1 deletion asdf/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def from_tree(cls, tree, ctx):


def create_small_tree():
x = np.arange(0, 10, dtype=np.float)
x = np.arange(0, 10, dtype=float)
tree = {
'science_data': x,
'subset': x[3:-3],
Expand Down
6 changes: 3 additions & 3 deletions asdf/tests/test_fits_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ def test_dangling_file_handle(tmpdir):

# Create FITS file to use for test
hdulist = fits.HDUList()
hdulist.append(fits.ImageHDU(np.arange(512, dtype=np.float)))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=np.float)))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=np.float)))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=float)))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=float)))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=float)))
hdulist.writeto(fits_filename)
hdulist.close()

Expand Down
12 changes: 6 additions & 6 deletions asdf/tests/test_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
def test_external_reference(tmpdir):
exttree = {
'cool_stuff': {
'a': np.array([0, 1, 2], np.float),
'b': np.array([3, 4, 5], np.float)
'a': np.array([0, 1, 2], float),
'b': np.array([3, 4, 5], float)
},
'list_of_stuff': [
'foobar',
42,
np.array([7, 8, 9], np.float)
np.array([7, 8, 9], float)
]
}
external_path = os.path.join(str(tmpdir), 'external.asdf')
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_external_reference_invalid_fragment(tmpdir):
'list_of_stuff': [
'foobar',
42,
np.array([7, 8, 9], np.float)
np.array([7, 8, 9], float)
]
}
external_path = os.path.join(str(tmpdir), 'external.asdf')
Expand Down Expand Up @@ -207,8 +207,8 @@ def test_make_reference(tmpdir):
# Include some ~ and / in the name to make sure that escaping
# is working correctly
'f~o~o/': {
'a': np.array([0, 1, 2], np.float),
'b': np.array([3, 4, 5], np.float)
'a': np.array([0, 1, 2], float),
'b': np.array([3, 4, 5], float)
}
}
external_path = os.path.join(str(tmpdir), 'external.asdf')
Expand Down
4 changes: 2 additions & 2 deletions docs/asdf/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ respectively.
from astropy.io import fits

hdulist = fits.HDUList()
hdulist.append(fits.ImageHDU(np.arange(512, dtype=np.float), name='SCI'))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=np.float), name='DQ'))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=float), name='SCI'))
hdulist.append(fits.ImageHDU(np.arange(512, dtype=float), name='DQ'))

Next we make a tree structure out of the data in the FITS file. Importantly,
we use the *same* array references in the FITS `~astropy.io.fits.HDUList` and
Expand Down

0 comments on commit 5030d5a

Please sign in to comment.