8000 TST: Verify determinism of `savez` and `savez_compressed` by mdsmarte · Pull Request #21994 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

TST: Verify determinism of savez and savez_compressed #21994

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

Closed
wants to merge 1 commit into from

Conversation

mdsmarte
Copy link

Closes #9439

The savez and savez_compressed functions were incidentally made deterministic by PR #9863. As suggested in #9439 (comment), this PR adds a test to ensure that these functions remain deterministic by comparing their results to existing reference files that contain the same data.

This PR was created as part of the SciPy 2022 sprints.

@mdsmarte
Copy link
Author

The npz files added by this PR were created on Mac. The test added by this PR is failing on the Windows checks. From some investigation, zipfile includes the system used to create the archive as metadata for each "file" (i.e. array) in the archive: https://docs.python.org/3/library/zipfile.html#zipfile.ZipInfo.create_system

For identical arrays, npz files created on Mac will differ from npz files created on Windows by N bytes, where N is the number of arrays in the archive. So it appears the savez and savez_compressed functions are deterministic for the same platform, but not different platforms.

Copy link
Contributor
@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

Instead of adding reference .npz files, could the tests instead be structured to generate the .npz files at test time? That should guarantee that the files are deterministic on the same platform at least. Whether or not the inter-platform component is critical to #9439, I'm not really sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: savez() is not deterministic
2 participants
0