Skip to content

Commit

Permalink
set array storage during IntegerType serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Sep 8, 2023
1 parent 66d3a51 commit c86c640
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
20 changes: 0 additions & 20 deletions asdf/_tests/tags/core/tests/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,6 @@ def test_integer_storage(tmpdir, inline):
assert rf.tree["integer"]["string"] == str(value)


def test_integer_storage_duplication(tmpdir):
tmpfile = str(tmpdir.join("integer.asdf"))

random.seed(0)
value = random.getrandbits(1000)
tree = {"integer1": IntegerType(value), "integer2": IntegerType(value)}

with asdf.AsdfFile(tree) as af:
af.write_to(tmpfile)

with asdf.open(tmpfile, _force_raw_types=True) as rf:
assert len(rf._blocks.blocks) == 1
assert rf.tree["integer1"]["words"]["source"] == 0
assert rf.tree["integer2"]["words"]["source"] == 0

with asdf.open(tmpfile) as aa:
assert aa.tree["integer1"] == value
assert aa.tree["integer2"] == value


def test_integer_conversion():
random.seed(0)
value = random.getrandbits(1000)
Expand Down
3 changes: 1 addition & 2 deletions asdf/core/_converters/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def to_yaml_tree(self, obj, tag, ctx):
array = np.array(words, dtype=np.uint32)

tree = {}
# TODO: No support for this yet in SerializationContext
# ctx.set_array_storage(array, node._storage)
ctx._blocks._set_array_storage(array, obj._storage)
tree["words"] = array
tree["sign"] = obj._sign
tree["string"] = str(int(obj._value))
Expand Down

0 comments on commit c86c640

Please sign in to comment.