Closed astrofrog closed 10 years ago
One way to achieve this is to use ordered dictionaries - unfortunately, these were not available in Python 2.6.
The attached code does the trick.
@ChrisBeaumont - what do you think?
Maybe make sorted_by_idx
_sorted_by_idx
? Otherwise, good to me
Done - I need to try and figure out if and how to add a test for this.
I think a test is going to be hard, precisely because it's non-deterministic, so let's forget about a test for now.
As an aside - ordered dictionaries are included in astropy.extern
. Since astrodendro requires astropy anyway, you could use their ordereddict structure.
I tried that and there was a reason why it didn't work but I can't remember...
@ChrisBeaumont - fixed the unnecessary list()
Ready to merge
Here's the output of a simple script:
The output is not always the same which is going to cause issues if users try and reproduce bugs. Also, structure IDs may not always refer to the same structures, which would be an issue. There are several places where dictionaries are used, so this must be what is causing the differences: