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

Sorting output from os.listdir when reading situation files #15

Merged
merged 1 commit into from
Jan 10, 2024

Conversation

freol35241
Copy link
Contributor

@freol35241 freol35241 commented Jan 4, 2024

As per the docs for os.listdir:

Return a list containing the names of the entries in the directory given by path. The list is in arbitrary order, and does not include the special entries '.' and '..' even if they are present in the directory. If a file is removed from or added to the directory during the call of this function, whether a name for that file be included is unspecified.

The output is in arbitrary order and actually depends on the filesystem. This makes it difficult to recreate the baseline encounter set from the input since the numbering of the generated files will not match the ordering of the input files.

Sorting the output from os.listdir fixes this issue.

Copy link
Collaborator

@tomarnepedersen tomarnepedersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change approved

@tomarnepedersen tomarnepedersen merged commit 62d2506 into dnv-opensource:main Jan 10, 2024
10 checks passed
@freol35241
Copy link
Contributor Author

Thanks, unfortunately I just realized that the same behavior is present for the code loading the target ship files, i.e. here: https://github.com/dnv-opensource/ship-traffic-generator/blob/main/src/trafficgen/read_files.py#L62

@tomarnepedersen
Copy link
Collaborator

Thanks, will be fixed👍

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

Successfully merging this pull request may close these issues.

2 participants