From f6921517ab205741fc859f6646fc71c2880292de282472e304bf4bbb264c6887 Mon Sep 17 00:00:00 2001 From: Daniel Garcia Date: Mon, 6 Mar 2023 11:19:44 +0000 Subject: [PATCH] - Add numpy120.patch to support numpy 1.20 gh#jterrace/pyssim#44 - Update to 0.5 * No release notes found OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pyssim?expand=0&rev=9 --- numpy120.patch | 69 +++++++++++++++++++++++++++++++++++++++++++ pyssim-0.5.tar.gz | 3 ++ python-pyssim.changes | 7 +++++ python-pyssim.spec | 17 ++++++----- v0.4.tar.gz | 3 -- 5 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 numpy120.patch create mode 100644 pyssim-0.5.tar.gz delete mode 100644 v0.4.tar.gz diff --git a/numpy120.patch b/numpy120.patch new file mode 100644 index 0000000..6b90d6a --- /dev/null +++ b/numpy120.patch @@ -0,0 +1,69 @@ +From fa854ac6b4c2a691a418cfac0eb5a2305731576c Mon Sep 17 00:00:00 2001 +From: "adria.labay" +Date: Wed, 8 Feb 2023 15:40:36 +0100 +Subject: [PATCH] support numpy 1.20 + +--- + ssim/utils.py | 26 ++++++++++++-------------- + 1 file changed, 12 insertions(+), 14 deletions(-) + +Index: pyssim-0.5/ssim/utils.py +=================================================================== +--- pyssim-0.5.orig/ssim/utils.py ++++ pyssim-0.5/ssim/utils.py +@@ -2,31 +2,29 @@ + + from __future__ import absolute_import + +-import numpy +-from numpy.ma.core import exp ++import numpy as np + import scipy.ndimage + + from ssim.compat import ImageOps + ++ + def convolve_gaussian_2d(image, gaussian_kernel_1d): + """Convolve 2d gaussian.""" +- result = scipy.ndimage.filters.correlate1d( ++ result = scipy.ndimage.correlate1d( + image, gaussian_kernel_1d, axis=0) +- result = scipy.ndimage.filters.correlate1d( ++ return scipy.ndimage.correlate1d( + result, gaussian_kernel_1d, axis=1) +- return result ++ + + def get_gaussian_kernel(gaussian_kernel_width=11, gaussian_kernel_sigma=1.5): + """Generate a gaussian kernel.""" + # 1D Gaussian kernel definition +- gaussian_kernel_1d = numpy.ndarray((gaussian_kernel_width)) +- norm_mu = int(gaussian_kernel_width / 2) ++ gaussian_kernel_1d = np.arange(0, gaussian_kernel_width, 1.) ++ gaussian_kernel_1d -= gaussian_kernel_width / 2 ++ gaussian_kernel_1d = np.exp(-0.5 * gaussian_kernel_1d**2 / ++ gaussian_kernel_sigma**2) ++ return gaussian_kernel_1d / np.sum(gaussian_kernel_1d) + +- # Fill Gaussian kernel +- for i in range(gaussian_kernel_width): +- gaussian_kernel_1d[i] = (exp(-(((i - norm_mu) ** 2)) / +- (2 * (gaussian_kernel_sigma ** 2)))) +- return gaussian_kernel_1d / numpy.sum(gaussian_kernel_1d) + + def to_grayscale(img): + """Convert PIL image to numpy grayscale array and numpy alpha array. +@@ -37,11 +35,11 @@ def to_grayscale(img): + Returns: + (gray, alpha): both numpy arrays. + """ +- gray = numpy.asarray(ImageOps.grayscale(img)).astype(numpy.float) ++ gray = np.asarray(ImageOps.grayscale(img)).astype(float) + + imbands = img.getbands() + alpha = None + if 'A' in imbands: +- alpha = numpy.asarray(img.split()[-1]).astype(numpy.float) ++ alpha = np.asarray(img.split()[-1]).astype(float) + + return gray, alpha diff --git a/pyssim-0.5.tar.gz b/pyssim-0.5.tar.gz new file mode 100644 index 0000000..c5b314a --- /dev/null +++ b/pyssim-0.5.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:438ff84a371f05e443f136ed6cba0afad4dd486038da39b6d0d9d189a80973a4 +size 2263693 diff --git a/python-pyssim.changes b/python-pyssim.changes index 03cb613..aafe6d5 100644 --- a/python-pyssim.changes +++ b/python-pyssim.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Mar 6 11:17:51 UTC 2023 - Daniel Garcia + +- Add numpy120.patch to support numpy 1.20 gh#jterrace/pyssim#44 +- Update to 0.5 + * No release notes found + ------------------------------------------------------------------- Sat Feb 13 07:49:33 UTC 2021 - Dirk Müller diff --git a/python-pyssim.spec b/python-pyssim.spec index ef4f8cd..57761bf 100644 --- a/python-pyssim.spec +++ b/python-pyssim.spec @@ -1,7 +1,7 @@ # # spec file for package python-pyssim # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,17 +16,18 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} %global skip_python36 1 Name: python-pyssim -Version: 0.4 +Version: 0.5 Release: 0 Summary: Structured Similarity Image Metric (SSIM) License: MIT Group: Development/Languages/Python URL: https://github.com/jterrace/pyssim -Source: https://github.com/jterrace/pyssim/archive/v%{version}.tar.gz +Source: https://files.pythonhosted.org/packages/source/p/pyssim/pyssim-%{version}.tar.gz Patch0: Pillow-imports.patch +# PATCH-FIX-UPSTREAM numpy120.patch gh#jterrace/pyssim#44 +Patch1: numpy120.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros @@ -34,7 +35,7 @@ Requires: python-Pillow Requires: python-numpy Requires: python-scipy Requires(post): update-alternatives -Requires(postun): update-alternatives +Requires(postun):update-alternatives BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module Pillow} @@ -47,8 +48,7 @@ BuildRequires: %{python_module scipy} Module for computing Structured Similarity Image Metric (SSIM) in Python. %prep -%setup -q -n pyssim-%{version} -%patch0 -p1 +%autosetup -p1 -n pyssim-%{version} %build %python_build @@ -77,6 +77,7 @@ $python -m ssim --cw --width 128 --height 128 test-images/test3-orig.jpg test-im %license LICENSE.md %doc README.md %python_alternative %{_bindir}/pyssim -%{python_sitelib}/* +%{python_sitelib}/ssim +%{python_sitelib}/pyssim-%{version}*-info %changelog diff --git a/v0.4.tar.gz b/v0.4.tar.gz deleted file mode 100644 index 37064c8..0000000 --- a/v0.4.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c7b0842f46dd002b27d76e4ccfb30d29bb853f415990ef95710f725debbfc532 -size 2661739