Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASDF unable to read empty inline array. #1538

Closed
braingram opened this issue May 4, 2023 · 0 comments · Fixed by #1537
Closed

ASDF unable to read empty inline array. #1538

braingram opened this issue May 4, 2023 · 0 comments · Fixed by #1537

Comments

@braingram
Copy link
Contributor

braingram commented May 4, 2023

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).

@braingram braingram changed the title ASDF unable to read or write empty inline array. ASDF unable to read empty inline array. May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant