-
Notifications
You must be signed in to change notification settings - Fork 328
[BUG] Fix Catch22 TypingError on float32 input with outlier features #3747
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
64469d5
bdfe777
db44123
7a5a783
cba0e33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1521,3 +1521,24 @@ def track_n(s): | |
| assert abs(np.std(passed_series["p"]) - 1.0) < 1e-10 | ||
| assert abs(np.mean(passed_series["n"])) < 1e-10 | ||
| assert abs(np.std(passed_series["n"]) - 1.0) < 1e-10 | ||
|
|
||
|
|
||
| def test_catch22_float32_output_dtype(): | ||
| """Test Catch22 does not raise on float32 input with outlier features. | ||
|
|
||
| Regression test: the outlier_series placeholder in _transform_case_numba was | ||
| hardcoded to float64, which numba's nopython mode could not unify with a | ||
| float32 z-normalised series produced for features 13/14 (outlier_include / | ||
| outlier_include_n), raising a TypingError for float32 input. | ||
| """ | ||
| X = np.random.default_rng(0).standard_normal((6, 1, 40)).astype(np.float32) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be replaced with the existing testing utils (make_example_3d_numpy) to generate 3D data. You need to keep the float32 cast
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to use make_example_3d_numpy with the float32 cast kept — see db44123. |
||
|
|
||
| # outlier_norm=True exercises the fixed code path (features 13/14) | ||
| c22 = Catch22(outlier_norm=True, replace_nans=True) | ||
| result = c22.fit_transform(X) | ||
| assert result.shape == (6, 22) | ||
|
|
||
| # outlier_norm=False takes the other branch -- should still work | ||
| c22_no_norm = Catch22(outlier_norm=False, replace_nans=True) | ||
| result_no_norm = c22_no_norm.fit_transform(X) | ||
| assert result_no_norm.shape == (6, 22) | ||
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.
Even if we override the value afterward, I'd rather want a helper function to init an empty array to the correct type/shape.
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.
Added the _zeros_promoted helper as requested in 7a5a783 — it's used both here and for the c22 buffer above.