Skip to content

Use the time axis of transposed inputs in discrete-time forced_response - #1255

Closed
raashish1601 wants to merge 1 commit into
python-control:mainfrom
raashish1601:fix/931-forced-response-transpose
Closed

raashish1601 wants to merge 1 commit into
python-control:mainfrom
raashish1601:fix/931-forced-response-transpose

Conversation

@raashish1601

Copy link
Copy Markdown

Fixes #931.

In discrete time, forced_response() builds the time vector from U when T is not given, but it took the number of steps from U.shape[1] even with transpose=True, where time is along the first axis:

sys = ct.rss(3, 2, 2, dt=0.1)
U = np.random.randn(2, 10)
ct.forced_response(sys, U=U.T, transpose=True)
# ValueError: Parameter `U`: Wrong shape (rows, columns): (2, 10). Expected: (2, 2).

For a single input, U of shape (10, 1) gave a one-step time vector, a "divide by zero" warning in the time step check, and then a shape error. The number of steps now comes from U.shape[0] when transpose=True.

The same branch also expands a scalar U to (ninputs, len(T)) when T is given. With transpose=True that array is transposed again when its shape is checked, so ct.forced_response(sys, T=T, U=1.0, transpose=True) failed with a shape error for discrete-time systems (it works in continuous time). The expanded array is now transposed first in that case.

Added test_forced_response_transpose_discrete in control/tests/timeresp_test.py (one and two inputs, comparing against the non-transposed call). It fails on main and passes here. timeresp_test.py, discrete_test.py, matlab_test.py, trdata_test.py and docstrings_test.py pass locally (486 passed, 52 skipped), and ruff check is clean.

@slivingston

Copy link
Copy Markdown
Member

@raashish1601 Can you disclose if and how you used AI tools to do this work? (Please read the README section about contributing and in particular https://numpy.org/doc/stable/dev/ai_policy.html.)

@slivingston

Copy link
Copy Markdown
Member

@raashish1601 I'm asking because I see that you opened a very large number of PRs today across many different repositories, so I guess that the PRs were created automatically via a tool like Codex or Claude? Can you confirm?

@raashish1601

Copy link
Copy Markdown
Author

Yes. This PR and #1254 were prepared with an AI coding agent (Claude Code, Anthropic): it reproduced the issues, wrote the fixes, tests and PR text, ran the tests locally, and opened the PRs. That does not meet the NumPy AI policy your README points to (no autonomous agent PRs, no AI-written descriptions), so I am closing both. Sorry for the noise, and thanks for asking.

@slivingston

Copy link
Copy Markdown
Member

@raashish1601 Please check for these policies and contributing guidelines in other repositories where you are slinging stuff... at the very least, disclose your use of a tool. It wastes real humans' time (like mine) because we assume we are interacting with a human that cares, not a chat bot.

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.

forced_response transpose bug

2 participants