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

Fix bug when duplicating inline arrays #370

Merged
merged 2 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

- Fix bug when retrieving file format version from new ASDF file. [#365]

- Fix bug when duplicating inline arrays. [#370]

1.3.0 (2017-10-24)
------------------

Expand Down
4 changes: 4 additions & 0 deletions asdf/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,10 @@ def get_block(self, source):
block = asdffile.blocks._internal_blocks[0]
self.set_array_storage(block, 'external')

# Handle the case of inline data
elif isinstance(source, list):
block = Block(data=np.array(source), array_storage='inline')

else:
raise TypeError("Unknown source '{0}'".format(source))

Expand Down
15 changes: 15 additions & 0 deletions asdf/tags/core/tests/test_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ def check_asdf(asdf):
tree, tmpdir, check_asdf, None, {'auto_inline': 64})


def test_copy_inline():
yaml = """
x0: !core/ndarray-1.0.0
data: [-1.0, 1.0]
"""

buff = helpers.yaml_to_asdf(yaml)

with asdf.AsdfFile.open(buff) as infile:
with asdf.AsdfFile() as f:
f.tree['a'] = infile.tree['x0']
f.tree['b'] = f.tree['a']
f.write_to(io.BytesIO())


def test_table(tmpdir):
table = np.array(
[(0, 1, (2, 3)), (4, 5, (6, 7))],
Expand Down