GeezerVison is showing github.com — update use/computation of sys._isstatic() by murrayrm · Pull Request #1117 · python-control/python-control
Conversation
murrayrm
commented
Feb 2, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
This small PR addresses #1090, where there was a redundant calculation for whether a transfer function is static (constant) or not. This fixes that by saving the computation done in init and using it later if sys._isstatic() is called. I also found a spot in nlsys where there was a (simple) redundant computation, so converted that to a call to sys._isstatic().
Following the discussion below, the current PR does the following:
- Moves the
_isstatic() method from InputOutputSystem to NonlinearIOSystem and TransferFunction. This is because the way in which the checks are done is different for systems with a state versus transfer functions.
- For
NonlinearIOSystem (including StateSpace, which is a subclass), a system sys is static if sys.nstates is zero, so this is what _isstatic() checks.
- For
TransferFunction, a system sys is static if the numerator and denominator polynomials are all zero order. This is computed when the system is constructed and store in the private instance variable _static.
- For
FrequencyResponseData, the _isstatic() method is not defined (mainly because it isn't used anywhere).
- Updated the User Guide documentation for nonlinear systems to reflect the updated usage of "static" (= no internal state, but time-varying is allowed).
- Updated the documentation and docstrings for describing functions to reflect that fact that non-static functions are allowed (eg, backlash and hysteresis).
The main uses of the static property for a system are described in more detail in the comments below.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coveralls
commented
Feb 2, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

coverage: 94.751% (-0.001%) from 94.752%
when pulling ce77e6b on murrayrm:update_isstatic-01Feb2025
into f73e893 on python-control:main.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. But a question that comes to mind is should tf’s new _isstatic method get put in iosys.py instead (and the explanatory comment moved to its init)? If so, I think NonlinearIOSystem should also get a _static field. Statesp.py also suffers from multiple implementations of isstatic (the first when the dt field is processed in process_io_keywords) but this may just be unavoidable complexity.
One thing to consider is terminology : is a time-varying stateless system considered to be static?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
I asked ChatGPT how we should think about "static". I thought the answer was pretty good:
Prompt: Consider a nonlinear input/output system with input $u$ and output $y$. What does it mean for this input/output system to be a "static" system? Is there a common definition of "static"? Also, if the system is time-dependent, is the system still considered to be static? If so, what is the logic behind that terminology?
Response: A static system in the context of input/output systems refers to a system in which the output $y(t)$ at any given time $t$ depends only on the input $u(t)$ at that same time $t$, and not on past or future values of $u$. Mathematically, this can be expressed as:
$$
y(t) = f(u(t))
$$
for some function $f$, which can be nonlinear. This means that there is no memory or dynamics involved in the system—there is no dependency on past inputs, derivatives of the input, or any internal state that evolves over time.
Common Definition of "Static"
Yes, the term "static" is commonly used in this way to distinguish such systems from dynamic systems, where the output depends on past (or future) inputs, typically via differential or difference equations.
Time-Dependent Static Systems
If the system is explicitly time-dependent, meaning that the function ($f$) varies with time, i.e.,
$$
y(t) = f(t, u(t)),
$$
then the system is still often considered static because at each time $t$, the output still depends only on the instantaneous input $u(t)$. The presence of explicit time dependence does not introduce memory or dynamics into the system—it only means that the input/output relationship is changing with time.
Logic Behind the Terminology
The key idea behind calling such systems "static" is that there is no dependence on past or future inputs—no accumulation of past states, no integration, no internal state evolution. Even if the system itself changes with time, as long as the output at each moment is determined purely by the input at that moment, the system remains static in this sense.
Thus, even with explicit time dependence, a system is still called "static" if it lacks memory or dynamic behavior.
Based on that, I think we should adopt the following definition: A static I/O system model is a model in which the output $y(t)$ at any given time $t$ depends only on the input $u(t)$ at that same time $t$, and not on past or future values of $u$. Thus a static system has no internal state, but may depend on time (not an issue now, but will be if/when we add in time dependence.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Also, I've looked into where this concept is used. There are a couple of instances:
- In the describing function module, the notion of static is used in some of the initialization of the numerical computation of a describing function. There is an interesting inconsistency in the wording in this module: the docstrings say that nonlinearities have to be static, but the computations allow for non-static models (eg, hysteresis).
- When computing out the timebase
dt, if a system is static then not specifying a timebase allows the timebase to default to None, which means it can be combined with either a continuous or discrete time system. This only occurs when a system is created.
- In various places we need to handle the case with
nstates == 0 separately, since it means that things like eigenvalues of the A matrix don't exist. Those might be as easily handled by a direct check on what we care about (A.size == 0).
I'll think through these and update the PR to provide a more uniform way of representing static I/O systems (including describing functions).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Looks good, with just a couple of clarifying questions.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
I asked ChatGPT how we should think about "static". I thought the answer was pretty good:
Nice. and pretty good answer.
It looks like Matlab has an isstatic function, perhaps a future PR could turn _isstatic into a public method.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I thought about making isstatic public, but I couldn't think if where you might want to actually use it in "user" code. Easy enough to change. Is there a use case that could motivate making it public?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|