|
5 | 5 |
|
6 | 6 | import numpy as np |
7 | 7 | import pytest |
| 8 | +import operator |
8 | 9 |
|
| 10 | +import control as ct |
9 | 11 | from control.statesp import StateSpace, _convertToStateSpace, rss |
10 | 12 | from control.xferfcn import TransferFunction, _convert_to_transfer_function, \ |
11 | 13 | ss2tf |
@@ -1022,3 +1024,20 @@ def test_returnScipySignalLTI_error(self, mimotf): |
1022 | 1024 | mimotf.returnScipySignalLTI() |
1023 | 1025 | with pytest.raises(ValueError): |
1024 | 1026 | mimotf.returnScipySignalLTI(strict=True) |
| 1027 | + |
| 1028 | +@pytest.mark.parametrize( |
| 1029 | + "op", |
| 1030 | + [pytest.param(getattr(operator, s), id=s) for s in ('add', 'sub', 'mul')]) |
| 1031 | +@pytest.mark.parametrize( |
| 1032 | + "tf, arr", |
| 1033 | + [# pytest.param(ct.tf([1], [0.5, 1]), np.array(2.), id="0D scalar"), |
| 1034 | + # pytest.param(ct.tf([1], [0.5, 1]), np.array([2.]), id="1D scalar"), |
| 1035 | + pytest.param(ct.tf([1], [0.5, 1]), np.array([[2.]]), id="2D scalar")]) |
| 1036 | +def test_xferfcn_ndarray_precedence(op, tf, arr): |
| 1037 | + # Apply the operator to the transfer function and array |
| 1038 | + result = op(tf, arr) |
| 1039 | + assert isinstance(result, ct.TransferFunction) |
| 1040 | + |
| 1041 | + # Apply the operator to the array and transfer function |
| 1042 | + result = op(arr, tf) |
| 1043 | + assert isinstance(result, ct.TransferFunction) |
0 commit comments