Skip to content

Commit

Permalink
Merge pull request #370 from drdavella/fix-inline-array-bug
Browse files Browse the repository at this point in the history
Fix bug when duplicating inline arrays
  • Loading branch information
drdavella authored Oct 31, 2017
2 parents f29a792 + 30d9322 commit 6127e78
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
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

0 comments on commit 6127e78

Please sign in to comment.