Skip to content

Conversation

braingram
Copy link
Contributor

Description

The goal here is to read in bytes from a file into an existing array. Something like the following:

import asdf
import numpy as np

arr = np.ones(1000, dtype='i4')

af = asdf.AsdfFile({"arr": arr})
af.set_array_compression(arr, 'bzp2')
af.write_to("arr.asdf")

dst = np.zeros(2000, dtype='i4')
with asdf.open("arr.asdf") as af:
    breakpoint()
    af._blocks.blocks[0].load(out=dst[1000:].view(dtype='uint8'))

assert np.all(dst[:1000] == 0)
assert np.all(dst[1000:] == 1)

This works with the current commit but there are a bunch of loose ends.

Checklist:

  • pre-commit checks ran successfully

  • tests ran successfully

  • for a public change, added a towncrier news fragment

    changes/<PR#>.<changetype>.rst

    • changes/<PR#>.feature.rst: new feature
    • changes/<PR#>.bugfix.rst: bug fix
    • changes/<PR#>.doc.rst: documentation change
    • changes/<PR#>.removal.rst: deprecation or removal of public API
    • changes/<PR#>.general.rst: infrastructure or miscellaneous change
  • for a public change, updated documentation

  • for any new features, unit tests were added

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 this pull request may close these issues.

1 participant