Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix tf2sos failing for constant transfer function.#9395

Merged
asi1024 merged 9 commits into
cupy:mainfrom
steppi:gh-9376
Nov 7, 2025
Merged

Fix tf2sos failing for constant transfer function.#9395
asi1024 merged 9 commits into
cupy:mainfrom
steppi:gh-9376

Conversation

@steppi

@steppi steppi commented Sep 16, 2025

Copy link
Copy Markdown
Contributor

Closes #9376

This PR makes tf2sos work when a constant transfer function is passed. The problem occurred due to array construction in zpk2sos which assumes that the system gain k is a float and fails when k is a 0d CuPy array. To fix this, I added a check for if k is a 0d CuPy array, and call k.get() to convert to a 0d NumPy array, which does work for such array construction. I made it check specifically for a 0d CuPy array to try to make the error message less confusing if a higher dimensional CuPy array is passed for k, e.g. to avoid an error message referring to NumPy arrays.

I've also copied the tests for tf2sos over from SciPy, including the ones that failed due to #9376.

@steppi steppi requested a review from a team as a code owner September 16, 2025 14:17
@leofang

leofang commented Oct 29, 2025

Copy link
Copy Markdown
Member

/test mini

leofang
leofang previously approved these changes Oct 29, 2025

@leofang leofang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delay. LGTM but I'd like to have @asi1024's blessing, since this corner case causes a host-device synchronization.

Comment thread cupyx/scipy/signal/_iir_filter_conversions.py Outdated
@leofang

leofang commented Oct 31, 2025

Copy link
Copy Markdown
Member

/test mini

@leofang

leofang commented Oct 31, 2025

Copy link
Copy Markdown
Member

/test mini

@asi1024 asi1024 enabled auto-merge November 6, 2025 01:13
@asi1024 asi1024 merged commit 03b45e5 into cupy:main Nov 7, 2025
48 checks passed
@asi1024

asi1024 commented Nov 7, 2025

Copy link
Copy Markdown
Member

LGTM! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tf2sos fails when given constant transfer function.

4 participants