Subject: bug#40406: python-matplotlib fails to build on i686-linux

From: Diego Nicola Barbato <[email-masked]>
Date: Tue, 02 Jun 2020 18:18:28 +0200

Hi,

Leo Famulari <[email-masked]> writes:

> On Fri, Apr 03, 2020 at 05:20:08PM +0200, Diego Nicola Barbato wrote:
>> The package python-matplotlib fails to build during the check phase on
>> i686-linux.  The test failure appears to be deterministic:

I've taken a closer look at the failing test (on x86_64-linux, commit:
ebbf915) by keeping the build tree ...

--8<---------------cut here---------------start------------->8---
guix build --no-grafts -s i686-linux --keep-failed python-matplotlib
--8<---------------cut here---------------end--------------->8---

... and running python inside of it.

--8<---------------cut here---------------start------------->8---
cd /tmp/guix-build-python-matplotlib-3.1.2.drv-0/matplotlib-3.1.2/
. ../environment-variables
export PYTHONPATH="${PYTHONPATH}:build/lib.linux-i686-3.8"
python3
--8<---------------cut here---------------end--------------->8---

I retraced the steps of the failing test ...

--8<---------------cut here---------------start------------->8---
import matplotlib.pyplot as plt
import matplotlib.widgets as widgets
from numpy.testing import assert_allclose
fig, ax = plt.subplots()
slider = widgets.Slider(ax=ax, label='', valmin=0, valmax=24, valinit=12, orientation='horizontal')
slider.set_val(10)
box = slider.poly.get_extents().transformed(ax.transAxes.inverted())
assert_allclose(box.bounds, [0, 0, 10/24, 1])
--8<---------------cut here---------------end--------------->8---

... and was able to reproduce the failing assertion ...

--8<---------------cut here---------------start------------->8---
AssertionError:
Not equal to tolerance rtol=1e-07, atol=0

Mismatch: 25%
Max absolute difference: 1.11022302e-16
Max relative difference: 2.66453526e-16
 x: array([ 0.000000e+00, -1.046255e-17,  4.166667e-01,  1.000000e+00])
 y: array([0.      , 0.      , 0.416667, 1.      ])
--8<---------------cut here---------------end--------------->8---

... , although the differing value wasn't exactly the same as the one
reported by the test.  As expected, the assertion did not fail when I
followed the same steps on x86_64.

--8<---------------cut here---------------start------------->8---
guix environment --ad-hoc python python-matplotlib -- python3
--8<---------------cut here---------------end--------------->8---

A closer look at the intermediate results ...

--8<---------------cut here---------------start------------->8---
print(slider.poly.get_extents().bounds,
      ax.transAxes.get_matrix(),
      ax.transAxes.inverted().get_matrix(),
      box.bounds,
      sep='\n')
--8<---------------cut here---------------end--------------->8---

... revealed that only the values of box.bounds differ.  The dimensions
of the slider are the same (as are the values of the transformation
matrices) on i686-linux ...

--8<---------------cut here---------------start------------->8---
(80.0, 52.8, 206.66666666666663, 369.59999999999997)
[[496.    0.   80. ]
 [  0.  369.6  52.8]
 [  0.    0.    1. ]]
[[ 0.00201613  0.         -0.16129032]
 [ 0.          0.00270563 -0.14285714]
 [ 0.          0.          1.        ]]
(0.0, -1.0462550964485118e-17, 0.4166666666666666, 1.0)
--8<---------------cut here---------------end--------------->8---

... and on x86_64-linux.

--8<---------------cut here---------------start------------->8---
(80.0, 52.8, 206.66666666666663, 369.59999999999997)
[[496.    0.   80. ]
 [  0.  369.6  52.8]
 [  0.    0.    1. ]]
[[ 0.00201613  0.         -0.16129032]
 [ 0.          0.00270563 -0.14285714]
 [ 0.          0.          1.        ]]
(0.0, 0.0, 0.41666666666666663, 1.0000000000000002)
--8<---------------cut here---------------end--------------->8---

Apparently there is nothing wrong with the slider.  Instead matrix
multiplication, which is used under the hood for transformations, seems
to sometimes produce incorrect results on i686-linux.  I have reported
this as a separate bug (https://debbugs.gnu.org/41665).

> I wonder if this scientific computing stuff should be tried on i686 at
> all. Should we limit it to contemporary architectures?

I was opposed to this at first (after all, if upstream supports Numpy on
i686, why shouldn't we?), but after seeing that even simple things like
matrix multiplication can produce incorrect results I'm in favour of
limiting it to contemporary architectures.  What do others think?

Regards,

Diego