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

BUG: Unusual test failures (whitespace-related?) on ppc32 with numpy-1.25.1 #24239

Closed
thesamesam opened this issue Jul 23, 2023 · 7 comments · Fixed by #24240
Closed

BUG: Unusual test failures (whitespace-related?) on ppc32 with numpy-1.25.1 #24239

thesamesam opened this issue Jul 23, 2023 · 7 comments · Fixed by #24240

Comments

@thesamesam
Copy link
Contributor

Describe the issue:

I get several more test failures with numpy-1.25.1 than I do with numpy-1.24.4 on ppc32:

  • numpy-1.24.4: 15 failed, 25832 passed, 883 skipped, 31 xfailed, 7 xpassed, 387 warnings
  • numpy-1.25.1: 71 failed, 34200 passed, 931 skipped, 31 xfailed, 6 xpassed, 709 warnings

It's worth noting that we've switched prematurely to building with Meson in Gentoo for 1.25.x, although I hope that's not relevant for this bug.

What's especially interesting is that a bunch of the failures seem to be whitespace related in TestArray2String.

There are some other errors in the log as well which look endianness related. Some of these aren't new to us (see https://bugs.gentoo.org/707116, #11831, #12638).

Reproduce the code example:

I've only reproduced this via the numpy test suite.

Error message:

I get the following test failures with numpy-1.25.1:

FAILED core/tests/test_defchararray.py::TestOperations::test_mod - AssertionError: 
FAILED core/tests/test_api.py::test_array_array - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestArrayRepr::test_subclass - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestArrayRepr::test_0d_object_subclass - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestArray2String::test_basic - AssertionError
FAILED core/tests/test_arrayprint.py::TestArray2String::test_structure_format_int - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestArray2String::test_edgeitems_kwarg - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestArray2String::test_summarize_2d - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestArray2String::test_linewidth - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestPrintOptions::test_precision_zero - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestPrintOptions::test_formatter - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestPrintOptions::test_formatter_reset - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestPrintOptions::test_0d_arrays - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestPrintOptions::test_legacy_stray_comma - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestPrintOptions::test_dtype_linewidth_wrapping - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestPrintOptions::test_linewidth_repr - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestPrintOptions::test_linewidth_str - AssertionError: 
FAILED core/tests/test_arrayprint.py::TestPrintOptions::test_edgeitems - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[B-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[H-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[H-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[I-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[I-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[L-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[L-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[Q-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[Q-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[P-S] - AssertionError: 
FAILED core/tests/test_overrides.py::TestNDArrayMethods::test_repr - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[P-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[e-S] - AssertionError: 
FAILED core/tests/test_records.py::TestFromrecords::test_recarray_repr - AssertionError: 
FAILED core/tests/test_records.py::TestFromrecords::test_0d_recarray_repr - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[e-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[f-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[f-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[d-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[d-U] - AssertionError: 
FAILED core/tests/test_shape_base.py::TestConcatenate::test_concatenate_axis_None - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[g-S] - AssertionError: 
FAILED core/tests/test_numeric.py::TestCreationFuncs::test_full - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[g-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[F-S] - AssertionError: 
FAILED core/tests/test_numeric.py::TestStringFunction::test_set_string_function - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[F-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[D-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[D-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[G-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[G-U] - AssertionError: 
FAILED ma/tests/test_core.py::TestMaskedArray::test_basic0d - AssertionError: 
FAILED ma/tests/test_core.py::TestMaskedArray::test_str_repr - AssertionError: 
FAILED ma/tests/test_core.py::TestMaskedArray::test_str_repr_legacy - AssertionError: 
FAILED matrixlib/tests/test_defmatrix.py::TestProperties::test_repr - AssertionError
FAILED matrixlib/tests/test_interaction.py::test_array_equal_error_message_matrix - AssertionError: 
FAILED polynomial/tests/test_printing.py::TestRepr::test_polynomial_str - AssertionError: 
FAILED polynomial/tests/test_printing.py::TestRepr::test_chebyshev_str - AssertionError: 
FAILED polynomial/tests/test_printing.py::TestRepr::test_legendre_repr - AssertionError: 
FAILED polynomial/tests/test_printing.py::TestRepr::test_hermite_repr - AssertionError: 
FAILED polynomial/tests/test_printing.py::TestRepr::test_hermiteE_repr - AssertionError: 
FAILED testing/tests/test_utils.py::TestAlmostEqual::test_error_message - AssertionError: 
FAILED f2py/tests/test_kind.py::TestKind::test_int - AssertionError: selectedintkind(19): expected 16 but got -1
FAILED core/tests/test_multiarray.py::TestDtypedescr::test_structured_non_void - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[b-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[h-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[i-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[i-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[l-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[q-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[p-S] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[p-U] - AssertionError: 
FAILED core/tests/test_nditer.py::test_iter_copy_casts[B-S] - AssertionError: 
======================================================== 71 failed, 34200 passed, 931 skipped, 31 xfailed, 6 xpassed, 709 warnings in 470.58s (0:07:50) ========================================================
 * ERROR: dev-python/numpy-1.25.1-r1::gentoo failed (test phase):
 *   pytest failed with python3.11

Full log (xz-compressed): https://bugs.gentoo.org/attachment.cgi?id=866019.



### Runtime information:

1.25.1
3.11.4 (main, Jul  5 2023, 00:34:18) [GCC 13.1.1 20230527]

### Context for the issue:

- Downstream Gentoo bug: https://bugs.gentoo.org/910739
- This affects us deploying newer versions of Numpy. Dropping Numpy on an architecture means dropping a very large number of packages, as it's often needed as a direct dependency if not as a test dependency.
@seberg
Copy link
Member

seberg commented Jul 23, 2023

Using meson does very much not seem advisable at all, assuming it works, you still should get a slower than wanted build.

The main failure I see seem to me thing like:

a = np.zeros(5, dtype="S5)
a[0] = 3  # even this probably fails
print(a.tobytes())  # lets see what got stored (side-step oppisite direction)

# if that works, try:
np.copyto(a, 3)
print(a.tobytes()) 

Can you check if the first and/or second fail?

I suppose it would have to be related with the PPC32 platform somehow, but not sure where to look.

@thesamesam
Copy link
Contributor Author

thesamesam commented Jul 23, 2023

wrt meson: yeah, that's fine, we've already filed a bunch of bugs for things. Having Meson makes life a lot easier for us because of the hacks needed for distutils to get cross working. We've already discussed it w/ Ralf (not saying he loves it, but he's aware).

The main failure I see seem to me thing like:

a = np.zeros(5, dtype="S5)
a[0] = 3  # even this probably fails
print(a.tobytes())  # lets see what got stored (side-step oppisite direction)

b'3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

if that works, try:

np.copyto(a, 3)
print(a.tobytes())

b'1\x00\x00\x00\x001\x00\x00\x00\x001\x00\x00\x00\x001\x00\x00\x00\x001\x00\x00\x00\x00'

@seberg
Copy link
Member

seberg commented Jul 23, 2023

Hummm, well, the second is nonense, its filling in 1 not 3. Although it should end up doing much the same code path internally, unless string to string copies are broken 🤔.

But first let's see, does this part work? (i.e. the first step, converting the NumPy 3 to the right string). That seems more likely to be wrong then:

s = np.int_(3)
print(repr(s))
print(s)
a = np.array(3)[()]
print(s)

@thesamesam
Copy link
Contributor Author

ppc32-testing ~ # cat /tmp/foo2.py
import numpy as np

s = np.int_(3)
print(repr(s))
print(s)
a = np.array(3)[()]
print(s)

ppc32-testing ~ # python /tmp/foo2.py
1
1
1

Huh!

@seberg
Copy link
Member

seberg commented Jul 23, 2023

OK. that was helpful, thanks.

@mattip another oversight in gh-23746 from everyone glancing at the code, although I am very surprised that this could fly under the radar long enough?!

I suppose it hits seriously only on a big-endian machine that also has a "weird" size for C long...

@thesamesam if you want to look at that, the casts in that PR are clearly wrong mixing bit-sized names with C names.

@seberg seberg added this to the 1.25.2 release milestone Jul 23, 2023
@thesamesam
Copy link
Contributor Author

Many thanks for your help! Let me give that a whack.

thesamesam added a commit to thesamesam/numpy that referenced this issue Jul 23, 2023
numpy#23746 introduced a fast path for scalar
int conversions, but the map between Python types and C types was subtly
wrong.

This fixes tests on at least ppc32 (big-endian).

Many thanks to Sebastian Berg for debugging this with me and pointing out
what needed to be fixed.

Bug: numpy#24239
Fixes: 81caed6
thesamesam added a commit to thesamesam/numpy that referenced this issue Jul 23, 2023
numpy#23746 introduced a fast path for scalar
int conversions, but the map between Python types and C types was subtly
wrong.

This fixes tests on at least ppc32 (big-endian).

Many thanks to Sebastian Berg for debugging this with me and pointing out
what needed to be fixed.

Closes numpy#24239.

Fixes: 81caed6
@seberg
Copy link
Member

seberg commented Jul 24, 2023

@thesamesam could you also post the last remaining (clear) error you are seeing, or maybe just create a new issue?

seberg pushed a commit to thesamesam/numpy that referenced this issue Jul 25, 2023
numpy#23746 introduced a fast path for scalar
int conversions, but the map between Python types and C types was subtly
wrong.

This fixes tests on at least ppc32 (big-endian).

Many thanks to Sebastian Berg for debugging this with me and pointing out
what needed to be fixed.

Closes numpy#24239.

Fixes: 81caed6
charris pushed a commit to charris/numpy that referenced this issue Jul 30, 2023
numpy#23746 introduced a fast path for scalar
int conversions, but the map between Python types and C types was subtly
wrong.

This fixes tests on at least ppc32 (big-endian).

Many thanks to Sebastian Berg for debugging this with me and pointing out
what needed to be fixed.

Closes numpy#24239.

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

Successfully merging a pull request may close this issue.

3 participants
@seberg @thesamesam and others