Repository navigation
Removed OrderedDict from io.ascii - #15496
alexandrecesarba wants to merge 10 commits into
Conversation
This pull request removes OrderedDict from files in io.ascii. The files are: core.py , daophot.py , ecsv.py , fastbasic.py , ipac.py and test_read.py. The OrderedDicts are normal dictionaries now.
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
There was a problem hiding this comment.
Welcome to Astropy 👋 and congratulations on your first pull request! 🎉
A project member will respond to you as soon as possible; in the meantime, please have a look over the Checklist for Contributed Code and make sure you've addressed as many of the questions there as possible.
If you feel that this pull request has not been responded to in a timely manner, please send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail [email protected].
|
Error is real, please fix. Thanks! |
|
How was this not caught by codestyle checks? |
|
I think this might be a tricky one. It causes real failures in cosmology tests. I am turning this into draft for now. |
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
Pinging @nstarman – for some reason this is causing the |
|
Note: any time things are writting to yaml, dict ordering is lost. This is why we are still using an More generally: we did have a round of removing |
|
So yaml is reordering a And I have been wondering as well if e.g. #10888 (comment) might be relevant – sounds like something like this could be happening within |
|
Yes, |
|
But Lines 387 to 389 in bbdf2ce would fix this problem (unless there are any header structures where sorting is explicitly desired and expected, but I doubt that). At least testing with plain AstropyDumper indicates so (yaml.load seems to preserve order already by default).
However that would link this PR to a Remove OrderedDict from Pinging @taldcroft as well as |
|
@dhomeier @alexandrecesarba - if we make the suggested change in |
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
OK, looks like astropy/astropy/cosmology/_io/yaml.py Line 203 in bbdf2ce is directly calling io.misc.yaml's own version of the dumper. Would need @nstarman's input whether it makes sense to set sort_keys=False there as well.We could also add it more widely as kwargs.setdefault("sort_keys", False)to astropy/astropy/io/misc/yaml.py Lines 379 to 381 in bbdf2ce Could you try the latter change to see if that lets the tests pass? |
Applying @dhomeier suggested changes defining sort_keys as False instead of default_flow_style
…andrecesarba/astropy into remove-ordereddict-io.ascii
|
There are some additional failures in the doctests now, but those actually show that the However the real issue in So I think this will still have to be synchronised with removing |
|
LMK what I can do to help on the cosmology side. Though if this is a Table issue, then perhaps the cosmology tests will "just work" when Table is addressed? |
Key order is important in cosmology ONLY for doctests. Some logic like |
In general this only seems to be an issue with some doctests. So if we preserve order in the YAML output of Cosmology tests like
Thought for a moment I misunderstood #15496 (comment), but that is already the default for But it looks like all of this really depends on getting |
|
@alexandrecesarba I started looking into this while going through #10888, do you still have the bandwidth to finish this up? I can cherry pick the commits and start a new PR if you aren't available right now :) |
|
I started looking a bit more into this and we just need to do change the default factory in --- a/astropy/utils/metadata/core.py
+++ b/astropy/utils/metadata/core.py
@@ -79,7 +79,7 @@ class MetaData:
None
"""
- def __init__(self, doc="", copy=True, *, default_factory=OrderedDict):
+ def __init__(self, doc="", copy=True, *, default_factory=dict): |
|
Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then. In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary. If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock. If you believe I commented on this pull request incorrectly, please report this here. |
|
@MridulS, @taldcroft, is #16250 superseding this PR as well? |
|
I'm going to close this pull request as per my previous message. If you think what is being added/fixed here is still important, please remember to open an issue to keep track of it. Thanks! If this is the first time I am commenting on this issue, or if you believe I closed this issue incorrectly, please report this here. |
Description
This pull request removes OrderedDict from files in io.ascii.
The files are: core.py , daophot.py , ecsv.py , fastbasic.py , ipac.py and test_read.py. The OrderedDicts are normal dictionaries now.
Fixes part of #10888