Skip to content

BUG: Fix repeatability issues in test suite #29380

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

Merged
merged 1 commit into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions numpy/_core/tests/test_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,13 @@ def test_deprecated(self):
class TestAddNewdocUFunc(_DeprecationTestCase):
# Deprecated in Numpy 2.2, 2024-11
def test_deprecated(self):
doc = struct_ufunc.add_triplet.__doc__
# gh-26718
# This test mutates the C-level docstring pointer for add_triplet,
# which is permanent once set. Skip when re-running tests.
if doc is not None and "new docs" in doc:
pytest.skip("Cannot retest deprecation, otherwise ValueError: "
"Cannot change docstring of ufunc with non-NULL docstring")
self.assert_deprecated(
lambda: np._core.umath._add_newdoc_ufunc(
struct_ufunc.add_triplet, "new docs"
Expand Down
2 changes: 2 additions & 0 deletions numpy/f2py/f2py2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ def callcrackfortran(files, options):
mod['gil_used'] = 'Py_MOD_GIL_USED'
else:
mod['gil_used'] = 'Py_MOD_GIL_NOT_USED'
# gh-26718 Reset global
crackfortran.f77modulename = ''
return postlist


Expand Down
2 changes: 2 additions & 0 deletions numpy/f2py/tests/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ def test_ftype(self):
ftype.data.x[1] = 45
assert_array_equal(ftype.data.x,
np.array([1, 45, 3], dtype=np.float32))
# gh-26718 Cleanup for repeated test runs
ftype.data.a = 0

# TODO: implement test methods for other example Fortran codes
8 changes: 6 additions & 2 deletions numpy/lib/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1276,12 +1276,16 @@ def test_max_rows_larger(self):
(1, ["ignored\n", "1,2\n", "\n", "3,4\n"]),
# "Bad" lines that do not end in newlines:
(1, ["ignored", "1,2", "", "3,4"]),
(1, StringIO("ignored\n1,2\n\n3,4")),
(1, lambda: StringIO("ignored\n1,2\n\n3,4")),
# Same as above, but do not skip any lines:
(0, ["-1,0\n", "1,2\n", "\n", "3,4\n"]),
(0, ["-1,0", "1,2", "", "3,4"]),
(0, StringIO("-1,0\n1,2\n\n3,4"))])
(0, lambda: StringIO("-1,0\n1,2\n\n3,4"))])
def test_max_rows_empty_lines(self, skip, data):
# gh-26718 re-instantiate StringIO objects each time
if callable(data):
data = data()

with pytest.warns(UserWarning,
match=f"Input line 3.*max_rows={3 - skip}"):
res = np.loadtxt(data, dtype=int, skiprows=skip, delimiter=",",
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy