Skip to content
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

MAINT: signal: force LTI state-space matrices to have inexact type #13235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

roryyorke
Copy link
Contributor

Reference issue

Closes gh-13125.

What does this implement/fix?

Forces LTI state space arrays A, B, C, and D to have inexact type.

Previously, when matrices were all of integer-type, step, lsim, etc. gave unexpected results.

This will restrict StateSpace to float32, float64, complex64, and complex128 types. So, a possible objection to the change is that it would previously have allowed more general types for ABCD, but I don't know if this is intended or required.

@e-q
Copy link
Contributor

e-q commented Dec 15, 2020

An alternate approach could be to use np.result_type to calculate the correct output dtype, instead of just inheriting A's, in places like this:

xout = zeros((n_steps, n_states), sys.A.dtype)

@roryyorke
Copy link
Contributor Author

An alternate approach could be to use np.result_type to calculate the correct output dtype, instead of just inheriting A's, in places like this:

xout = zeros((n_steps, n_states), sys.A.dtype)

That needs at least, and possibly only, changes in lsim (where you've indicated) and dlsim. lsim2 doesn't need this change. This would be less invasive than what I've proposed, in the sense that it only changes "simulation" (step, lsim, etc.) behaviour. On the other hand, I think the ABCD matrices are naturally real or complex, and making this change in only one place (ignoring the docstring changes) is reasonable.

I don't mind making the other change.

@tylerjereddy
Copy link
Contributor

The PR has been inactive for almost 4 years, I'll bump the milestone, just ping me if it is actually close to ready to merge for branching ~Sunday.

@tylerjereddy tylerjereddy modified the milestones: 1.13.0, 1.14.0 Mar 12, 2024
@lucascolley lucascolley changed the title Force LTI state-space matrices to have inexact type MAINT: signal: force LTI state-space matrices to have inexact type Mar 14, 2024
@tylerjereddy tylerjereddy modified the milestones: 1.14.0, 1.15.0 May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Items related to regular maintenance tasks scipy.signal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

signal.step function behaves differently when system parameters are integers/floats
5 participants