Skip to content

Fix impuse response, input data only contains one input[0]==1 in each trace #1023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 7, 2024

Conversation

KybernetikJo
Copy link
Contributor

Computation of impulse response was correct, but input in impulse response was not.

@coveralls
Copy link

Coverage Status

coverage: 94.533%. remained the same
when pulling a03ed38 on KybernetikJo:fix_impulse_response
into 4acc78b on python-control:main.

@KybernetikJo KybernetikJo changed the title Fix impuse response, input data only contains one inpute[0]==1 in each trace Fix impuse response, input data only contains one input[0]==1 in each trace Jul 3, 2024
@slivingston
Copy link
Member

@KybernetikJo Can you add a regression test that demonstrates the error you are fixing?

@KybernetikJo
Copy link
Contributor Author

import numpy as np
import control as ct
print(ct.__version__)

A = [[.5, 0.25],[.0, .5]]
B = [[1., 0,],[0., 1.]]
C = [[1., 0.],[0., 1.]]
D = [[0., 0.],[0., 0.]]
dt = True
sysd = ct.ss(A,B,C,D, dt=dt)
response = ct.impulse_response(sysd,T=dt*3)

U = np.zeros((2,2,4), dtype=float).astype(object)
U[0,0,0] = 1./dt
U[1,1,0] = 1./dt

print(np.array_equal(response.inputs,U))
display(U)
display(response.inputs)

Expected / New behavior

0.10.1.dev76+g4acc78b.d20240703
True
array([[[1.0, 0.0, 0.0, 0.0],
        [0.0, 0.0, 0.0, 0.0]],

       [[0.0, 0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0, 0.0]]], dtype=object)

array([[[1.0, 0.0, 0.0, 0.0],
        [0.0, 0.0, 0.0, 0.0]],

       [[0.0, 0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0, 0.0]]], dtype=object)

Old behavior

0.10.0
False
array([[[1.0, 0.0, 0.0, 0.0],
        [0.0, 0.0, 0.0, 0.0]],

       [[0.0, 0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0, 0.0]]], dtype=object)

array([[[1.0, 0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0, 0.0]],

       [[1.0, 0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0, 0.0]]], dtype=object)

@coveralls
Copy link

Coverage Status

coverage: 94.533%. remained the same
when pulling 7624aeb on KybernetikJo:fix_impulse_response
into 4acc78b on python-control:main.

@murrayrm murrayrm merged commit 7a135d1 into python-control:main Jul 7, 2024
23 checks passed
@murrayrm murrayrm added this to the 0.10.1 milestone Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants