diff --git a/control-pr994-numpy2.patch b/control-pr994-numpy2.patch new file mode 100644 index 0000000..4f8ee64 --- /dev/null +++ b/control-pr994-numpy2.patch @@ -0,0 +1,205 @@ +From 03df7185bc8a44a345fb926effb38ed6aeb817cc Mon Sep 17 00:00:00 2001 +From: Ben Greiner +Date: Sat, 20 Apr 2024 16:25:33 +0200 +Subject: [PATCH 1/4] Replace np.NaN removed in numpy 2 + +--- + control/tests/timeresp_test.py | 14 +++++++------- + control/timeresp.py | 14 +++++++------- + 2 files changed, 14 insertions(+), 14 deletions(-) + +diff --git a/control/tests/timeresp_test.py b/control/tests/timeresp_test.py +index fb21180b..441f4a7b 100644 +--- a/control/tests/timeresp_test.py ++++ b/control/tests/timeresp_test.py +@@ -173,15 +173,15 @@ def tsystem(self, request): + # System Type 1 - Step response not stationary: G(s)=1/s(s+1) + siso_tf_type1 = TSys(TransferFunction(1, [1, 1, 0])) + siso_tf_type1.step_info = { +- 'RiseTime': np.NaN, +- 'SettlingTime': np.NaN, +- 'SettlingMin': np.NaN, +- 'SettlingMax': np.NaN, +- 'Overshoot': np.NaN, +- 'Undershoot': np.NaN, ++ 'RiseTime': np.nan, ++ 'SettlingTime': np.nan, ++ 'SettlingMin': np.nan, ++ 'SettlingMax': np.nan, ++ 'Overshoot': np.nan, ++ 'Undershoot': np.nan, + 'Peak': np.Inf, + 'PeakTime': np.Inf, +- 'SteadyStateValue': np.NaN} ++ 'SteadyStateValue': np.nan} + + # SISO under shoot response and positive final value + # G(s)=(-s+1)/(s²+s+1) +diff --git a/control/timeresp.py b/control/timeresp.py +index 58207e88..843ae3a8 100644 +--- a/control/timeresp.py ++++ b/control/timeresp.py +@@ -1590,15 +1590,15 @@ def step_info(sysdata, T=None, T_num=None, yfinal=None, params=None, + InfValue = InfValues[i, j] + sgnInf = np.sign(InfValue.real) + +- rise_time: float = np.NaN +- settling_time: float = np.NaN +- settling_min: float = np.NaN +- settling_max: float = np.NaN ++ rise_time: float = np.nan ++ settling_time: float = np.nan ++ settling_min: float = np.nan ++ settling_max: float = np.nan + peak_value: float = np.Inf + peak_time: float = np.Inf +- undershoot: float = np.NaN +- overshoot: float = np.NaN +- steady_state_value: complex = np.NaN ++ undershoot: float = np.nan ++ overshoot: float = np.nan ++ steady_state_value: complex = np.nan + + if not np.isnan(InfValue) and not np.isinf(InfValue): + # RiseTime + +From 38188fbd6d8b95ef0ed5d76e396db43f95bbf488 Mon Sep 17 00:00:00 2001 +From: Ben Greiner +Date: Sat, 20 Apr 2024 16:35:21 +0200 +Subject: [PATCH 2/4] Replace np.Inf removed in numpy 2 + +--- + control/tests/timeresp_test.py | 4 ++-- + control/timeresp.py | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/control/tests/timeresp_test.py b/control/tests/timeresp_test.py +index 441f4a7b..bdbbb3e8 100644 +--- a/control/tests/timeresp_test.py ++++ b/control/tests/timeresp_test.py +@@ -179,8 +179,8 @@ def tsystem(self, request): + 'SettlingMax': np.nan, + 'Overshoot': np.nan, + 'Undershoot': np.nan, +- 'Peak': np.Inf, +- 'PeakTime': np.Inf, ++ 'Peak': np.inf, ++ 'PeakTime': np.inf, + 'SteadyStateValue': np.nan} + + # SISO under shoot response and positive final value +diff --git a/control/timeresp.py b/control/timeresp.py +index 843ae3a8..428baf23 100644 +--- a/control/timeresp.py ++++ b/control/timeresp.py +@@ -1594,8 +1594,8 @@ def step_info(sysdata, T=None, T_num=None, yfinal=None, params=None, + settling_time: float = np.nan + settling_min: float = np.nan + settling_max: float = np.nan +- peak_value: float = np.Inf +- peak_time: float = np.Inf ++ peak_value: float = np.inf ++ peak_time: float = np.inf + undershoot: float = np.nan + overshoot: float = np.nan + steady_state_value: complex = np.nan + +From 0b5332bfa9580df81ba2ebc6f9d8f54975fa9cd6 Mon Sep 17 00:00:00 2001 +From: Ben Greiner +Date: Sat, 20 Apr 2024 16:44:45 +0200 +Subject: [PATCH 3/4] replace deprecated numpy.linalg.linalg.LinAlgError with + numpy.linalg.LinAlgError and isort + +--- + control/statesp.py | 30 ++++++++++++++++-------------- + 1 file changed, 16 insertions(+), 14 deletions(-) + +diff --git a/control/statesp.py b/control/statesp.py +index e14a8358..0c2856b1 100644 +--- a/control/statesp.py ++++ b/control/statesp.py +@@ -48,26 +48,27 @@ + """ + + import math ++from copy import deepcopy ++from warnings import warn ++ + import numpy as np +-from numpy import any, asarray, concatenate, cos, delete, \ +- empty, exp, eye, isinf, ones, pad, sin, zeros, squeeze +-from numpy.random import rand, randn +-from numpy.linalg import solve, eigvals, matrix_rank +-from numpy.linalg.linalg import LinAlgError + import scipy as sp + import scipy.linalg +-from scipy.signal import cont2discrete ++from numpy import (any, asarray, concatenate, cos, delete, empty, exp, eye, ++ isinf, ones, pad, sin, squeeze, zeros) ++from numpy.linalg import LinAlgError, eigvals, matrix_rank, solve ++from numpy.random import rand, randn + from scipy.signal import StateSpace as signalStateSpace +-from warnings import warn ++from scipy.signal import cont2discrete + +-from .exception import ControlSlycot, slycot_check, ControlMIMONotImplemented ++from . import config ++from .exception import ControlMIMONotImplemented, ControlSlycot, slycot_check + from .frdata import FrequencyResponseData ++from .iosys import (InputOutputSystem, _process_dt_keyword, ++ _process_iosys_keywords, _process_signal_list, ++ common_timebase, isdtime, issiso) + from .lti import LTI, _process_frequency_response +-from .iosys import InputOutputSystem, common_timebase, isdtime, issiso, \ +- _process_iosys_keywords, _process_dt_keyword, _process_signal_list +-from .nlsys import NonlinearIOSystem, InterconnectedSystem +-from . import config +-from copy import deepcopy ++from .nlsys import InterconnectedSystem, NonlinearIOSystem + + try: + from slycot import ab13dd +@@ -2221,9 +2222,10 @@ def _convert_to_statespace(sys, use_prefix_suffix=False, method=None): + by the calling function. + + """ +- from .xferfcn import TransferFunction + import itertools + ++ from .xferfcn import TransferFunction ++ + if isinstance(sys, StateSpace): + return sys + + +From ebb8a5284c8c4e58ef8efdae656f1e4748b3ba68 Mon Sep 17 00:00:00 2001 +From: Ben Greiner +Date: Sat, 20 Apr 2024 16:49:11 +0200 +Subject: [PATCH 4/4] Replace deprecated numpy row_stack with vstack + +--- + control/rlocus.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/control/rlocus.py b/control/rlocus.py +index 631185cc..281fed08 100644 +--- a/control/rlocus.py ++++ b/control/rlocus.py +@@ -21,7 +21,7 @@ + import matplotlib.pyplot as plt + import numpy as np + import scipy.signal # signal processing toolbox +-from numpy import array, imag, poly1d, real, row_stack, zeros_like ++from numpy import array, imag, poly1d, real, vstack, zeros_like + + from . import config + from .exception import ControlMIMONotImplemented +@@ -421,7 +421,7 @@ def _RLFindRoots(nump, denp, kvect): + curroots.sort() + roots.append(curroots) + +- return row_stack(roots) ++ return vstack(roots) + + + def _RLSortRoots(roots): diff --git a/python-control.changes b/python-control.changes index b43fcec..2cca0f8 100644 --- a/python-control.changes +++ b/python-control.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Sat Apr 20 15:20:30 UTC 2024 - Ben Greiner + +- Add control-pr994-numpy2.patch + gh#python-control/python-control#994 + ------------------------------------------------------------------- Fri Apr 5 14:22:32 UTC 2024 - Ben Greiner diff --git a/python-control.spec b/python-control.spec index 83d3185..7d4f8bc 100644 --- a/python-control.spec +++ b/python-control.spec @@ -24,6 +24,8 @@ License: BSD-3-Clause URL: https://python-control.org Source: https://files.pythonhosted.org/packages/source/c/control/control-%{version}.tar.gz Source1: %{name}-rpmlintrc +# PATCH-FIX-UPSTREAM control-pr994-numpy2.patch gh#python-control/python-control#994 +Patch1: control-pr994-numpy2.patch BuildRequires: %{python_module base >= 3.8} BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools_scm}