Commit 9071af48 authored by Ole Streicher's avatar Ole Streicher

New upstream version 2.0.3

parent d94f4f6b
2.0.3 (2018-09-06)
------------------
- Update asdf-standard to reflect more stringent (and, consequently, more
correct) requirements on the formatting of complex numbers. [#526]
- Fix bug with dangling file handle when using ASDF-in-FITS. [#533]
- Fix bug that prevented fortran-order arrays from being serialized properly.
[#539]
2.0.2 (2018-07-27)
------------------
......
Metadata-Version: 1.2
Name: asdf
Version: 2.0.2
Version: 2.0.3
Summary: Python tools to handle ASDF files
Home-page: http://github.com/spacetelescope/asdf
Author: Erik Bray, Dan D'Avella, Michael Droettboom
......
......@@ -36,7 +36,7 @@ allOf:
can be cast to the given datatype without data loss. For
exact datatype matching, set `exact_datatype` to `true`.
allOf:
- $ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0#definitions/datatype-1.0.0"
- $ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0#/definitions/datatype-1.0.0"
exact_datatype:
description: |
......
......@@ -7,17 +7,27 @@ description: |
Represents a complex number matching the following EBNF grammar
```
dot = "."
plus-or-minus = "+" | "-"
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
sign = "" | plus-or-minus
suffix = "J" | "j" | "I" | "i"
complex = [ieee754] [plus-or-minus ieee754 suffix]
inf = "inf" | "INF"
nan = "nan" | "NAN"
number = digits | dot digits | digits dot digits
sci-suffix = "e" | "E"
scientific = number sci-suffix sign digits
real = sign number | sign scientific
imag = number suffix | scientific suffix
complex = real | sign imag | real plus-or-minus imag
```
Where `ieee754` is a floating point number in IEEE 754 decimal
format.
Though `J`, `j`, `I` and `i` must be supported on reading, it is
recommended to use `i` on writing.
For historical reasons, it is necessary to accept as valid complex numbers
that are surrounded by parenthesis.
examples:
-
- 1 real, -1 imaginary
......@@ -31,4 +41,5 @@ examples:
tag: "tag:stsci.edu:asdf/core/complex-1.0.0"
type: string
pattern: "([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)?([-+][0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?[JjIi])?"
# This regex was automatically generated from a description of a grammar
pattern: "^(((((([+-]?(([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN)))))|([+-]?(([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[eE][+-]?[0-9]+)))|([+-]?(((([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[iIjJ])|((([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[eE][+-]?[0-9]+[iIjJ])))|((([+-]?(([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN)))))|([+-]?(([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[eE][+-]?[0-9]+))[+-](((([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[iIjJ])|((([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[eE][+-]?[0-9]+[iIjJ])))))|(\\((((([+-]?(([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN)))))|([+-]?(([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[eE][+-]?[0-9]+)))|([+-]?(((([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[iIjJ])|((([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[eE][+-]?[0-9]+[iIjJ])))|((([+-]?(([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN)))))|([+-]?(([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[eE][+-]?[0-9]+))[+-](((([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[iIjJ])|((([0-9]+)|(\\.[0-9]+)|([0-9]+\\.[0-9]+)|(((inf)|(INF)))|(((nan)|(NAN))))[eE][+-]?[0-9]+[iIjJ]))))\\)))$"
......@@ -122,7 +122,7 @@ allOf:
- type: object
properties:
$ref: "../core/ndarray-1.0.0#anyOf/1/properties"
$ref: "../core/ndarray-1.0.0#/anyOf/1/properties"
- type: object
properties:
......
......@@ -122,7 +122,7 @@ allOf:
- type: object
properties:
$ref: "../core/ndarray-1.0.0#anyOf/1/properties"
$ref: "../core/ndarray-1.0.0#/anyOf/1/properties"
- type: object
properties:
......
......@@ -42,10 +42,6 @@ from .tags.core.external_reference import ExternalArrayReference
from jsonschema import ValidationError
# TODO: there doesn't seem to be any reason to redefine this here
class ValidationError(ValidationError):
pass
try:
from astropy.io import fits
except ImportError:
......
......@@ -1213,7 +1213,7 @@ class AsdfFile(versioning.VersionedMixin):
try:
self.validate()
except:
except Exception:
self.tree['history']['entries'].pop()
raise
......
......@@ -148,7 +148,7 @@ class _AsdfWriteTypeIndex(object):
self._type_by_name[name] = asdftype
add_all_types(asdftype)
# Process all types defined in the ASDF version map
# Process all types defined in the ASDF version map
for name, _version in version_map.items():
add_by_tag(name, AsdfVersion(_version))
......
......@@ -764,7 +764,10 @@ class Block(object):
def __init__(self, data=None, uri=None, array_storage='internal', memmap=True):
if isinstance(data, np.ndarray) and not data.flags.c_contiguous:
self._data = np.ascontiguousarray(data)
if data.flags.f_contiguous:
self._data = np.asfortranarray(data)
else:
self._data = np.ascontiguousarray(data)
else:
self._data = data
self._uri = uri
......@@ -867,7 +870,7 @@ class Block(object):
def _calculate_checksum(self, data):
m = hashlib.new('md5')
m.update(self.data)
m.update(self.data.flatten())
return m.digest()
def validate_checksum(self):
......@@ -1126,7 +1129,7 @@ class Block(object):
self._data.flush()
if self._data._mmap is not None:
self._data._mmap.close()
self._data = None
self._data = None
class UnloadedBlock(object):
......
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
......@@ -376,7 +376,7 @@ class GenericFile(object):
"""
def write_array(self, array):
_array_tofile(None, self.write, np.ascontiguousarray(array))
_array_tofile(None, self.write, array.ravel(order='A'))
def seek(self, offset, whence=0):
"""
......@@ -755,7 +755,7 @@ class RealFile(RandomAccessFile):
arr.flush()
self.fast_forward(len(arr.data))
else:
_array_tofile(self._fd, self._fd.write, np.ascontiguousarray(arr))
_array_tofile(self._fd, self._fd.write, arr.ravel(order='A'))
def can_memmap(self):
return True
......
......@@ -97,7 +97,7 @@ class Reference(AsdfType):
return None
try:
return getattr(self._get_target(), attr)
except:
except Exception:
raise AttributeError("No attribute '{0}'".format(attr))
def __getitem__(self, item):
......
......@@ -114,7 +114,7 @@ def tag_object(tag, instance, ctx=None):
try:
instance = yamlutil.custom_tree_to_tagged_tree(instance, ctx)
except TypeError:
raise TypeError("Don't know how to tag a {0}".format(type(instance)))
raise TypeError("Don't know how to tag a {0}".format(type(instance)))
instance._tag = tag
return instance
......
......@@ -370,7 +370,7 @@ class NDArrayType(AsdfType):
strides = node.get('strides', None)
mask = node.get('mask', None)
return cls(source, shape, dtype, offset, strides, 'C', mask, ctx)
return cls(source, shape, dtype, offset, strides, 'A', mask, ctx)
raise TypeError("Invalid ndarray description.")
......
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
import re
import pytest
import asdf
from asdf.tests import helpers
def test_invalid_complex():
def make_complex_asdf(string):
yaml = """
a: !core/complex-1.0.0
3 + 4i
"""
{}
""".format(string)
return helpers.yaml_to_asdf(yaml)
buff = helpers.yaml_to_asdf(yaml)
with pytest.raises(ValueError):
with asdf.AsdfFile.open(buff):
@pytest.mark.parametrize('invalid', [
'3 + 4i', '3+-4i', '3-+4i', '3i+4i', 'X3+4iX', '3+X4i', '3+4', '3i+4'
'3+4z', '3.+4i', '3+4.i', '3e-4.0+4i', '3+4e4.0i', ''
])
def test_invalid_complex(invalid):
with pytest.raises(asdf.ValidationError):
with asdf.AsdfFile.open(make_complex_asdf(invalid)):
pass
@pytest.mark.parametrize('valid', [
'3+4j', '(3+4j)', '.3+4j', '3+.4j', '3e10+4j', '3e-10+4j', '3+4e10j',
'3.0+4j', '3+4.0j', '3.0+4.0j', '3+4e-10j', '3+4J', '3+4i', '3+4I', 'inf',
'inf+infj', 'inf+infi', 'infj', 'infi', 'INFi', 'INFI', '3+infj', 'inf+4j',
])
def test_valid_complex(valid):
with asdf.AsdfFile.open(make_complex_asdf(valid)) as af:
assert af.tree['a'] == complex(re.sub(r'[iI]$', r'j', valid))
@pytest.mark.parametrize('valid', [
'nan', 'nan+nanj', 'nan+nani', 'nanj', 'nani', 'NANi', 'NANI', '3+nanj',
'nan+4j'
])
def test_valid_nan_complex(valid):
with asdf.AsdfFile.open(make_complex_asdf(valid)) as af:
# Don't compare values since NANs are never equal
pass
def test_roundtrip(tmpdir):
tree = {
'a': 0+0j,
......
......@@ -88,7 +88,7 @@ def test_old_history(tmpdir):
"""Make sure that old versions of the history format are still accepted"""
yaml = """
history:
history:
- !core/history_entry-1.0.0
description: "Here's a test of old history entries"
software: !core/software-1.0.0
......
......@@ -809,3 +809,9 @@ def test_broadcasted_array(tmpdir):
attrs = np.broadcast_arrays(np.array([10,20]), np.array(10), np.array(10))
tree = {'one': attrs[1] }#, 'two': attrs[1], 'three': attrs[2]}
helpers.assert_roundtrip_tree(tree, tmpdir)
def test_fortran_order(tmpdir):
array = np.array([[11,12,13], [21,22,23]], order='F')
tree = dict(data=array)
helpers.assert_roundtrip_tree(tree, tmpdir)
......@@ -168,7 +168,7 @@ class AsdfSchemaExampleItem(pytest.Item):
ff._open_impl(ff, buff)
# Do not tolerate any warnings that occur during schema validation
assert len(w) == 0, helpers.display_warnings(w)
except:
except Exception:
print("From file:", self.filename)
raise
......
......@@ -115,7 +115,7 @@ def test_bzp2(tmpdir):
_roundtrip(tmpdir, tree, 'bzp2')
def test_lz4(tmpdir):
pytest.importorskip('lz4')
tree = _get_large_tree()
......
......@@ -377,3 +377,37 @@ def test_extension_check():
with pytest.raises(RuntimeError):
with asdf.AsdfFile.open(testfile, strict_extension_check=True) as ff:
pass
def test_dangling_file_handle(tmpdir):
"""
This tests the bug fix introduced in #533. Without the bug fix, this test
will fail when running the test suite with pytest-openfiles.
"""
import gc
fits_filename = str(tmpdir.join('dangling.fits'))
# 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.writeto(fits_filename)
hdulist.close()
hdul = fits.open(fits_filename)
gc.collect()
ctx = asdf.AsdfFile()
gc.collect()
ctx.blocks.find_or_create_block_for_array(hdul[0].data, ctx)
gc.collect()
hdul.close()
gc.collect()
ctx.close()
gc.collect()
del ctx
......@@ -66,7 +66,7 @@ def test_reference_file(reference_file):
try:
_compare_trees(name_without_ext, expect_warnings=expect_warnings)
except:
except Exception:
if known_fail:
pytest.xfail()
else:
......
# Autogenerated by Astropy-affiliated package asdf's setup.py on 2018-07-30 12:30:24
# Autogenerated by Astropy-affiliated package asdf's setup.py on 2018-09-06 18:26:21
from __future__ import unicode_literals
import datetime
......@@ -187,8 +187,8 @@ def _get_repo_path(pathname, levels=None): # pragma: no cover
_packagename = "asdf"
_last_generated_version = "2.0.2"
_last_githash = "9b856b85cb57f6bbb26f810ed2eae8b01bc29788"
_last_generated_version = "2.0.3"
_last_githash = "89f8a7c5f1484ca662a216c644ed59237c4b8bb2"
# Determine where the source code for this module
# lives. If __file__ is not a filesystem path then
......@@ -206,10 +206,10 @@ else:
major = 2
minor = 0
bugfix = 2
bugfix = 3
release = True
timestamp = datetime.datetime(2018, 7, 30, 12, 30, 24)
timestamp = datetime.datetime(2018, 9, 6, 18, 26, 21)
debug = False
try:
......
......@@ -19,6 +19,7 @@ from semantic_version import Version, SpecItem, Spec
from . import generic_io
from . import resolver
from . import util
from .version import version as asdf_version
__all__ = ['AsdfVersion', 'AsdfSpec']
......@@ -35,7 +36,7 @@ def get_version_map(version):
with generic_io.get_file(version_map_path, 'r') as fd:
version_map = yaml.load(
fd, Loader=_yaml_base_loader)
except:
except Exception:
raise ValueError(
"Could not load version map for version {0}".format(version))
_version_map[version] = version_map
......@@ -154,8 +155,9 @@ class VersionedMixin(object):
human_versions = util.human_list(
[str(x) for x in supported_versions])
raise ValueError(
"asdf only understands how to handle ASDF versions {0}. "
"Got '{1}'".format(human_versions, version))
"This version of the asdf package ({0}) only understands how "
"to handle versions {1} of the ASDF Standard. Got "
"'{2}'".format(asdf_version, human_versions, version))
self._version = version
......
Metadata-Version: 1.1
Name: astropy-helpers
Version: 2.0.4
Version: 2.0.1
Summary: Utilities for building and installing Astropy, Astropy affiliated packages, and their respective documentation.
Home-page: https://github.com/astropy/astropy-helpers
Author: The Astropy Developers
Author-email: astropy.team@gmail.com
License: BSD
Description-Content-Type: UNKNOWN
Description: astropy-helpers
===============
......@@ -29,8 +28,8 @@ Description: astropy-helpers
in Numpy format
* `sphinx-automodapi <https://github.com/astropy/sphinx-automodapi>`_, a Sphinx
extension developed as part of the Astropy project. This used to be developed
directly in ``astropy-helpers`` but is now a standalone package.
developed as part of the Astropy project. This used to be developed directly
in ``astropy-helpers`` but is now a standalone package.
Issues with these sub-modules should be reported in their respective repositories,
and we will regularly update the bundled versions to reflect the latest released
......
......@@ -9,7 +9,6 @@ setup.py
astropy_helpers/__init__.py
astropy_helpers/distutils_helpers.py
astropy_helpers/git_helpers.py
astropy_helpers/openmp_helpers.py
astropy_helpers/setup_helpers.py
astropy_helpers/test_helpers.py
astropy_helpers/utils.py
......@@ -47,8 +46,8 @@ astropy_helpers/extern/automodapi/templates/autosummary_core/module.rst
astropy_helpers/extern/numpydoc/__init__.py
astropy_helpers/extern/numpydoc/docscrape.py
astropy_helpers/extern/numpydoc/docscrape_sphinx.py
astropy_helpers/extern/numpydoc/linkcode.py
astropy_helpers/extern/numpydoc/numpydoc.py
astropy_helpers/extern/numpydoc/templates/numpydoc_docstring.rst
astropy_helpers/sphinx/__init__.py
astropy_helpers/sphinx/conf.py
astropy_helpers/sphinx/setup_package.py
......@@ -73,6 +72,5 @@ astropy_helpers/sphinx/themes/bootstrap-astropy/static/astropy_logo_32.png
astropy_helpers/sphinx/themes/bootstrap-astropy/static/bootstrap-astropy.css
astropy_helpers/sphinx/themes/bootstrap-astropy/static/copybutton.js
astropy_helpers/sphinx/themes/bootstrap-astropy/static/sidebar.js
licenses/LICENSE_ASTROSCRAPPY.rst
licenses/LICENSE_COPYBUTTON.rst
licenses/LICENSE_NUMPYDOC.rst
\ No newline at end of file
# Autogenerated by Astropy-affiliated package astropy_helpers's setup.py on 2018-02-22 15:58:01
# Autogenerated by Astropy-affiliated package astropy_helpers's setup.py on 2017-08-31 10:04:54.962827
from __future__ import unicode_literals
import datetime
version = "2.0.4"
githash = "41a607235bdc335c9c125f828bdd35502a09aff9"
version = "2.0.1"
githash = "14ca346b0da3e92e65bdc398cc8f726cbd7be57d"
major = 2
minor = 0
bugfix = 4
bugfix = 1
release = True
timestamp = datetime.datetime(2018, 2, 22, 15, 58, 1)
timestamp = datetime.datetime(2017, 8, 31, 10, 4, 54, 962827)
debug = False
try:
......
......@@ -32,3 +32,7 @@ license = BSD
url = http://github.com/spacetelescope/asdf
edit_on_github = False
github_project = spacetelescope/asdf
[flake8]
exclude = extern
select = E101 W191 W291 W292 W293 W391 E11 E502 E722 E901 E902
......@@ -31,7 +31,7 @@ URL = metadata.get('url', '')
builtins._PACKAGE_NAME_ = PACKAGE_NAME
# VERSION should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386)
VERSION = '2.0.2'
VERSION = '2.0.3'
# Indicates if this version is a release version
RELEASE = 'dev' not in VERSION
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment