asdf-format/asdf

ASDF unable to read empty inline array.

Closed this issue · 0 comments

The following example:

import asdf
import numpy

a = numpy.array([])
af = asdf.AsdfFile({'a': a})
af.set_array_storage(a, 'inline')
af.write_to('test.asdf')

print(asdf.open('test.asdf')['a'][:])

fails when the read array is accessed.

TypeError: Unknown source 'None'

The produced file contains what looks like a valid empty array

#ASDF 1.0.0
#ASDF_STANDARD 1.5.0
%YAML 1.1
%TAG ! tag:stsci.edu:asdf/
--- !core/asdf-1.1.0
asdf_library: !core/software-1.0.0 {author: The ASDF Developers, homepage: 'http://github.com/asdf-format/asdf',
  name: asdf, version: 3.0.0.dev265+g0c44742c}
history:
  extensions:
  - !core/extension_metadata-1.0.0
    extension_class: asdf.extension._manifest.ManifestExtension
    extension_uri: asdf://asdf-format.org/core/extensions/core-1.5.0
    software: !core/software-1.0.0 {name: asdf, version: 3.0.0.dev265+g0c44742c}
  - !core/extension_metadata-1.0.0
    extension_class: asdf.extension.BuiltinExtension
    software: !core/software-1.0.0 {name: asdf, version: 3.0.0.dev265+g0c44742c}
a: !core/ndarray-1.0.0
  data: []
  datatype: float64
  shape: [0]
...

This issue if affecting weldx tests (and perhaps more than just the tests) as:
BAMWelDX/weldx#469
introduced a function that produces files like the example above (that contains data: []) which open, but throw an error when the array is accessed (due to lazy loading).