-
Notifications
You must be signed in to change notification settings - Fork 13
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
glob.glob() can return bizarre ordering #26
Comments
I always do the following flist=glob(pattern)
flist.sort() note sort is in place, so this will not work, since sort() returns None flist=glob(pattern).sort() |
Or
But the point remains that it would be helpful to have other ways to specify the list of image and catalog files to make sure they match up 1-1. |
FYI, sorted() returns an iterator, not a list. |
I don't think so...
or in Python 3.4 (where I thought maybe they changed the nature of this function)
|
I was clearly confused |
I did not know about the sorted() thingy. I always did it the way Erin did. In any event, as Mike has said, the original point still stands that we On Wed, Jun 22, 2016 at 10:25 AM, Erin Sheldon notifications@github.com
|
In my experience it is best to determine such things algorithmically. For example, if I'm processing an exposure I can generate the file names for the ccds in the exposure using a simple algorithm based on the DESDM run identifier. The base name is known and the suffix is based on ccd number. I recommend doing that by default. e.g. specify an exposure you want to process by name or id, and the code looks for it in the usual place This has the advantage that if a file is missing you will notice it; you generated the file list and you know what should be there, if the file is missing the code will crash. Also there are usually auxilliary files you will need to use that will be generated using the same algorithms, and don't need to be determined from the input file list. Then if you want to be able to do something different, perhaps for testing, that can be an alternative method, e.g. specifying an exact list of files, or a pattern as in the above config. |
This is now fixed on branch #20. There are a few ways allowed to specify the file lists. From the doc string:
|
Hey, stackexchange has the (unsatisfying) answer:
http://stackoverflow.com/questions/6773584/how-is-pythons-glob-glob-ordered
Apparently, it's order in the filesystem, whatever that may be; the order they were written to disk? But for two globs of files, they are by no means guaranteed to have the same matched ordering.
(I think sorting might fix this but would require some testing)
The text was updated successfully, but these errors were encountered: