-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add support for masked quantities, angles, and coordinates #253
base: main
Are you sure you want to change the base?
Conversation
24f6e11
to
3397b36
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #253 +/- ##
==========================================
+ Coverage 99.40% 99.42% +0.01%
==========================================
Files 62 64 +2
Lines 2200 2254 +54
==========================================
+ Hits 2187 2241 +54
Misses 13 13 ☔ View full report in Codecov by Sentry. |
434b4c0
to
e4751e5
Compare
Thanks for opening this PR. The unit tests are failing because this introduces an import of astropy at "integration" (when the extension/entry point is loaded). The asdf docs have more details on how this can lead to performance issues:
This makes supporting >> import astropy.utils.masked as masked
>> import astropy.units as u
>> MQ = masked.Masked(u.Quantity)
>> MQ
astropy.utils.masked.core.MaskedQuantity
>> masked.core.MaskedQuantity
AttributeError: module 'astropy.utils.masked.core' has no attribute 'MaskedQuantity' I read this as masked stating that the |
That's right. The fully qualified name Is there a way to configure a converter to decide whether it is capable of handling instances of a class by calling a function? |
Not that I'm aware of. The matching of converter to object uses the object type:
(see this comment for more details). I suspect that more extensive changes to asdf will be needed to support |
What do you have in mind? It is turning out to be surprisingly simple to implement |
One option could be to have Astropy add those dynamically-created subclasses to the module dictionary, so that (for example) |
I will try to carve out some time to look into this soon. At the moment I don't have a clear solution to propose. |
Registered types associated with ASDF converters must be importable by their fully qualified name. Masked classes are dynamically created and have apparent names like ``astropy.utils.masked.core.MaskedQuantity`` although they aren't actually attributes of this module. Customize module attribute lookup so that certain commonly used Masked classes are importable. See: - https://asdf.readthedocs.io/en/latest/asdf/extending/converters.html#entry-point-performance-considerations - astropy/asdf-astropy#253
For a possible workaround, see astropy/astropy#17685. |
Are you able to run a job here using your branch at astropy/astropy#17685 and see if it is actually green? Thanks! (devdeps is usually the easiest to hack for such things) |
Registered types associated with ASDF converters must be importable by their fully qualified name. Masked classes are dynamically created and have apparent names like ``astropy.utils.masked.core.MaskedQuantity`` although they aren't actually attributes of this module. Customize module attribute lookup so that certain commonly used Masked classes are importable. See: - https://asdf.readthedocs.io/en/latest/asdf/extending/converters.html#entry-point-performance-considerations - astropy/asdf-astropy#253
e4751e5
to
76bfe81
Compare
... maybe? See latest commit 🤞 |
Registered types associated with ASDF converters must be importable by their fully qualified name. Masked classes are dynamically created and have apparent names like ``astropy.utils.masked.core.MaskedQuantity`` although they aren't actually attributes of this module. Customize module attribute lookup so that certain commonly used Masked classes are importable. See: - https://asdf.readthedocs.io/en/latest/asdf/extending/converters.html#entry-point-performance-considerations - astropy/asdf-astropy#253
I'm not really sure how to make this work in the CI against a branch of astropy. But the tests I added are passing on my computer. |
Try grab v7.1.dev tag from astropy proper and push that tag to your fork. Then rerun the jobs. |
dfee919 |
423a109
to
c07b3df
Compare
Tests are passing now, except for Python 3.10 which is EOL as far as Astropy is concerned. |
Overall this looks good to me. Once the astropy PR is merged we can:
Thanks again for the PR and adding support for |
Fixes #202.