Hello community, here is the log from the commit of package python-nilearn for openSUSE:Factory checked in at 2020-10-15 13:50:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-nilearn (Old) and /work/SRC/openSUSE:Factory/.python-nilearn.new.3486 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-nilearn" Thu Oct 15 13:50:45 2020 rev:5 rq:841775 version:0.6.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-nilearn/python-nilearn.changes 2020-04-29 20:54:48.353330960 +0200 +++ /work/SRC/openSUSE:Factory/.python-nilearn.new.3486/python-nilearn.changes 2020-10-15 13:51:00.869314782 +0200 @@ -1,0 +2,7 @@ +Wed Oct 14 11:42:18 UTC 2020 - Guillaume GARDET <guillaume.gar...@opensuse.org> + +- Backport patches to fix some tests: + * update-numpy-warning.patch - https://github.com/nilearn/nilearn/pull/2530 + * fix-test_save_cmap.patch - https://github.com/nilearn/nilearn/pull/2543 + +------------------------------------------------------------------- New: ---- fix-test_save_cmap.patch update-numpy-warning.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-nilearn.spec ++++++ --- /var/tmp/diff_new_pack.u6C7ki/_old 2020-10-15 13:51:01.705315132 +0200 +++ /var/tmp/diff_new_pack.u6C7ki/_new 2020-10-15 13:51:01.709315133 +0200 @@ -26,6 +26,10 @@ Group: Development/Languages/Python URL: https://github.com/nilearn/nilearn Source: https://files.pythonhosted.org/packages/source/n/nilearn/nilearn-%{version}.tar.gz +# PATCH-FIX-UPSTREAM - https://github.com/nilearn/nilearn/pull/2530 +Patch1: update-numpy-warning.patch +# PATCH-FIX-UPSTREAM - https://github.com/nilearn/nilearn/pull/2543 +Patch2: fix-test_save_cmap.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros @@ -54,6 +58,7 @@ %prep %setup -q -n nilearn-%{version} +%autopatch -p1 %build %python_build ++++++ fix-test_save_cmap.patch ++++++ --- nilearn-0.6.2.orig/nilearn/plotting/tests/test_html_stat_map.py 2020-10-14 10:27:20.286975259 +0200 +++ nilearn-0.6.2/nilearn/plotting/tests/test_html_stat_map.py 2020-10-14 11:02:45.979137810 +0200 @@ -1,7 +1,9 @@ import warnings from io import BytesIO +import base64 import numpy as np +from matplotlib import pyplot as plt import pytest from nibabel import Nifti1Image @@ -105,9 +107,10 @@ def test_save_sprite(): """ # Generate a simulated volume with a square inside - data = np.zeros([2, 1, 1]) - data[0, 0, 0] = 1 - mask = data > 0 + data = np.random.RandomState(0).uniform(size=140).reshape(7, 5, 4) + mask = np.zeros((7, 5, 4), dtype=int) + mask[1:-1, 1:-1, 1:-1] = 1 + # data *= mask # Save the sprite using BytesIO sprite_io = BytesIO() @@ -117,25 +120,36 @@ def test_save_sprite(): # Load the sprite back in base64 sprite_base64 = html_stat_map._bytesIO_to_base64(sprite_io) - # Check the sprite is correct - assert sprite_base64.startswith('iVBORw0KG') - assert sprite_base64.endswith('ABJRU5ErkJggg==') + decoded_io = BytesIO() + decoded_io.write(base64.b64decode(sprite_base64)) + decoded_io.seek(0) + img = plt.imread(decoded_io, format="png") + correct_img = np.ma.array(html_stat_map._data_to_sprite(data), + mask=html_stat_map._data_to_sprite(mask)) + correct_img = plt.Normalize(0, 1)(correct_img) + cmapped = plt.get_cmap("Greys")(correct_img) + assert np.allclose(img, cmapped, atol=.1) -def test_save_cmap(): +@pytest.mark.parametrize("cmap", ["tab10", "cold_hot"]) +@pytest.mark.parametrize("n_colors", [7, 20]) +def test_save_cmap(cmap, n_colors): """This test covers _save_cmap as well as _bytesIO_to_base64 """ # Save the cmap using BytesIO cmap_io = BytesIO() - html_stat_map._save_cm(cmap_io, 'cold_hot', format='png', n_colors=2) + html_stat_map._save_cm(cmap_io, cmap, format='png', n_colors=n_colors) # Load the colormap back in base64 cmap_base64 = html_stat_map._bytesIO_to_base64(cmap_io) - # Check the colormap is correct - assert cmap_base64.startswith('iVBORw0KG') - assert cmap_base64.endswith('ElFTkSuQmCC') + decoded_io = BytesIO() + decoded_io.write(base64.b64decode(cmap_base64)) + decoded_io.seek(0) + img = plt.imread(decoded_io, format="png") + expected = plt.get_cmap(cmap)(np.linspace(0, 1, n_colors)) + assert np.allclose(img, expected, atol=.1) def test_mask_stat_map(): ++++++ update-numpy-warning.patch ++++++ --- nilearn-0.6.2.orig/nilearn/image/tests/test_resampling.py 2020-10-14 10:27:20.294973452 +0200 +++ nilearn-0.6.2/nilearn/image/tests/test_resampling.py 2020-10-14 10:29:29.025968587 +0200 @@ -479,7 +479,7 @@ def test_resampling_nan(): # check 3x3 transformation matrix target_affine = np.eye(3)[axis_permutation] - with pytest.warns(RuntimeWarning): + with pytest.warns(Warning, match=r"(\bnan\b|invalid value)"): resampled_img = resample_img(source_img, target_affine=target_affine)