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

Allow lazy loading of Quantity instances created during deserialization #190

Open
braingram opened this issue Jul 20, 2023 · 1 comment
Open

Comments

@braingram
Copy link
Contributor

Currently the Quantity converter calls _make_array before creating the Quantity:

value = value._make_array()

When the array is stored as an internal ASDF block this will force the block to be loaded at the time of deserialization.

Initial attempts to enable lazy loading by removing the above mentioned line do not prevent the ASDF block from being loaded possibly because NDArrayType is not a subclass of ndarray and astropy will attempt to iterate through the array during loading:
https://github.com/astropy/astropy/blob/79dd50f61ef5e0a568dd42549319db38fefd0bc7/astropy/units/quantity.py#L495
triggering loading of the ASDF block.

@WilliamJamieson
Copy link
Contributor

Whenever Quantity is updated to support the Python array API standard, then this will become trivial because Quantity will no longer subclass ndarray, instead it will satisfy the API's protocol.

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

No branches or pull requests

2 participants