Consolidate most 32- and 64-bit special cases in the doctests#41468
Merged
vbraun merged 8 commits intosagemath:developfrom Jan 25, 2026
Merged
Consolidate most 32- and 64-bit special cases in the doctests#41468vbraun merged 8 commits intosagemath:developfrom
vbraun merged 8 commits intosagemath:developfrom
Conversation
Pytest doesn't support the 32- and 64-bit comment tags that we use to distinguish the hash() output on machines of differing bitness. In this case there are however only two expected integer answers, so it is easy to check for them both without the conditional tags.
In many cases, we have 32- and 64-bit comment tags to differentiate between output that merely carries more precision in the 64-bit case. Pytest does not support such tags on the output, so to minimize the barrier to switching in the future, we use ellipses to indicate that more digits may appear.
We don't really need to verify the upper limit that was exceeded. Replacing it with ellipses allows us to combine the 32- and 64-bit cases.
When there are two possible answers and they are easy to compare with equality (e.g. integers), we can put them both in a list and use list membership instead of separate 32- and 64-bit outputs.
Printing the _info() for one of these lists always includes the sys.maxsize, and its value depends on whether the machine is 32- or 64-bit. To handle both cases with one test, we omit that part of the output with ellipses.
Rather than list two separate outputs for 32- and 64-bit systems that differ by 1e-13, we can increase the tolerance a bit and support both.
Printing a numpy array is platform-dependent, because the default dtype (which is platform-dependent) will not be shown: numpy/numpy#25787 We have two instances in our test suite where special comment tags are used to work around this. This commit passes in dtype="int8" instead, because int8 is not default on any platform, and therefore makes the output consistent.
|
Documentation preview for this PR (built with commit 5f238bb; changes) is ready! 🎉 |
Contributor
Author
|
This fixes most of the easy cases that #40238 wants to remove. The others can surely be worked around too, but I grouped together the ones that are trivial to review. Note: I don't have a 32-bit machine to run the tests on, so they haven't been run. |
tobiasdiez
approved these changes
Jan 18, 2026
Contributor
tobiasdiez
left a comment
There was a problem hiding this comment.
Thanks, that's a good solution as well.
dcoudert
reviewed
Jan 18, 2026
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Jan 19, 2026
sagemathgh-41468: Consolidate most 32- and 64-bit special cases in the doctests Pytest does not support the `# 32-bit` and `# 64-bit` tags that we apply to platform-dependent output, so in the long run it is desirable to eliminate them. Fortunately most instances are easy to handle simultaneously; this PR begins by tacking the easy ones. URL: sagemath#41468 Reported by: Michael Orlitzky Reviewer(s): David Coudert, Michael Orlitzky, Tobias Diez
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Feb 5, 2026
sagemathgh-41540: Eliminate remaining 32- and 64-bit doctest output tags Our `# 32-bit` and `# 64bit` tags, namely that they must annotate the output lines and not the input line, are non-standard. We have replacements that work on the input lines in `# needs 32_bit` or `# needs !32_bit`, but in some cases we can handle both cases simultaneously (which is preferable, in my opinion). This PR replaces all uses of the old tags, updates the documentation to suggest `# needs 32_bit`, and removes support for the old tags from the doctest runner. The latter is a backwards-incompatible change, but it cannot break user code, only custom tests. If we were to make the old- style tags raise deprecation warnings, exactly the same tests would break, so it does not seem worthwhile to deprecate and remove later. This is a follow-up to sagemath#41468, and supersedes sagemath#40238. The tests pass for me on a 64-bit system, but I don't have a 32-bit one to try with. URL: sagemath#41540 Reported by: Michael Orlitzky Reviewer(s): Chenxin Zhong, Tobias Diez
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Feb 7, 2026
sagemathgh-41540: Eliminate remaining 32- and 64-bit doctest output tags Our `# 32-bit` and `# 64bit` tags, namely that they must annotate the output lines and not the input line, are non-standard. We have replacements that work on the input lines in `# needs 32_bit` or `# needs !32_bit`, but in some cases we can handle both cases simultaneously (which is preferable, in my opinion). This PR replaces all uses of the old tags, updates the documentation to suggest `# needs 32_bit`, and removes support for the old tags from the doctest runner. The latter is a backwards-incompatible change, but it cannot break user code, only custom tests. If we were to make the old- style tags raise deprecation warnings, exactly the same tests would break, so it does not seem worthwhile to deprecate and remove later. This is a follow-up to sagemath#41468, and supersedes sagemath#40238. The tests pass for me on a 64-bit system, but I don't have a 32-bit one to try with. URL: sagemath#41540 Reported by: Michael Orlitzky Reviewer(s): Chenxin Zhong, Tobias Diez
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Feb 10, 2026
sagemathgh-41540: Eliminate remaining 32- and 64-bit doctest output tags Our `# 32-bit` and `# 64bit` tags, namely that they must annotate the output lines and not the input line, are non-standard. We have replacements that work on the input lines in `# needs 32_bit` or `# needs !32_bit`, but in some cases we can handle both cases simultaneously (which is preferable, in my opinion). This PR replaces all uses of the old tags, updates the documentation to suggest `# needs 32_bit`, and removes support for the old tags from the doctest runner. The latter is a backwards-incompatible change, but it cannot break user code, only custom tests. If we were to make the old- style tags raise deprecation warnings, exactly the same tests would break, so it does not seem worthwhile to deprecate and remove later. This is a follow-up to sagemath#41468, and supersedes sagemath#40238. The tests pass for me on a 64-bit system, but I don't have a 32-bit one to try with. URL: sagemath#41540 Reported by: Michael Orlitzky Reviewer(s): Chenxin Zhong, Tobias Diez
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pytest does not support the
# 32-bitand# 64-bittags that we apply to platform-dependent output, so in the long run it is desirable to eliminate them. Fortunately most instances are easy to handle simultaneously; this PR begins by tacking the easy ones.