Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Housekeeping PR focused on reducing noisy/deprecated warnings across the codebase (tests, docs, and a couple of runtime utilities), mainly around pandas and torch behaviors.
Changes:
- Suppress or avoid warnings in tests (e.g.,
UnusedObjectWarning, pandas dtype FutureWarnings, SHAP runtime warnings). - Adjust dataframe dtype normalization to avoid warning on integer-to-float conversions while still converting internally.
- Avoid pandas FutureWarnings in constraint logic and docs examples (copying slices; avoiding concat with empty frames).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/validation/test_campaign_validation.py | Suppresses UnusedObjectWarning during overlapping-name validation for non-predictive recommenders. |
| tests/utils/test_sampling_algorithms.py | Conditionally suppresses the “All points are identical” warning in FPS property-based tests. |
| tests/utils/test_dataframe.py | Adds an integer-valued “valid” case for dtype normalization tests. |
| tests/test_simulation.py | Adds include_groups=False to silence pandas groupby/apply warnings. |
| tests/test_settings.py | Suppresses UnusedObjectWarning during caching tests for non-predictive recommenders. |
| tests/test_kernels.py | Replaces torch.tensor(...) with torch.as_tensor(...) to reduce tensor-construction warnings. |
| tests/test_input_output.py | Uses .loc assignment and suppresses pandas FutureWarning for deliberate bad-dtype injections. |
| tests/serialization/test_json_serialization.py | Ensures opened file handles are closed even when JSON decoding raises. |
| tests/insights/test_shap.py | Suppresses SHAP-internal RuntimeWarning noise while still asserting expected UserWarnings. |
| docs/userguide/async.md | Uses .copy() when slicing to avoid pandas chained-assignment/view warnings. |
| baybe/utils/dataframe.py | Refines dtype normalization warning logic (don’t warn for integer columns, still convert). |
| baybe/constraints/discrete.py | Avoids pandas FutureWarning by skipping concat with empty DataFrame parts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f018573 to
582e01f
Compare
AdrianSosic
requested changes
Mar 27, 2026
42a0a09 to
178066b
Compare
Integer columns for numerical parameters/targets are losslessly convertible to float and do not warrant a warning. Only truly problematic types (bool, object, string) now trigger InputDataTypeWarning.
Pandas deprecated concatenation behavior when empty DataFrames affect result dtype inference. Skip the empty DataFrame from concat when other_params is empty.
Copy the DataFrame slice before in-place modification to avoid pandas SettingWithCopyWarning.
…output Replace df[col].iloc[0] with df.iloc[0, ...] to avoid pandas SettingWithCopyWarning and ChainedAssignmentError FutureWarning. Suppress the remaining incompatible dtype FutureWarning since it is an inherent side effect of deliberately assigning invalid values.
Add include_groups=False to groupby().apply() to avoid pandas FutureWarning about deprecated behavior of operating on grouping columns.
Avoid UserWarning about copying from an existing tensor when the value is already a torch.Tensor.
Close the file handle opened for the filelike channel to avoid ResourceWarning about unclosed files.
Use pytest.warns for expected UserWarnings about missing explanation_index (force/waterfall plots) and excluded non-numeric features (scatter plots). Suppress shap's own RuntimeWarnings.
The degenerate point cloud edge case is already explicitly tested in test_farthest_point_sampling_pathological_case. Suppress the warning in the general hypothesis-based test to avoid noise from randomly generated identical points.
Non-predictive recommenders warn when called with an objective. Suppress this expected side effect in tests that validate unrelated behavior (overlapping names, caching).
Using `apply` is suboptimal since it underwent various arg and default changes in different pandas versions. By avoiding `apply` and calling the validation explicitly it works in all pandas versions. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: AdrianSosic <adrian.sosic@merckgroup.com>
4550856 to
6e14288
Compare
AdrianSosic
approved these changes
Mar 30, 2026
AVHopp
approved these changes
Mar 30, 2026
Instead of silencing the warning, this fixes the cause of the issue
This section used deprecated functions and is obsolete as the random seeding is explained now in the settings user guide
bf5f5aa to
23aa86f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is mostly a housekeeping PR aimed at reducing unnecessary warnings. Examples are for instance unnecessary tensor or integer conversion, pandas behavior that is deprecated etc.
Two sources of warnings have not been touched:
Dummyin discrete constraints:FutureWarningfrom pandas but likely more complex to fixtest_deprecationsuses construction of objects in parameterization that is deprecated. Since this happens before code execution warnings filters did not have any effect on this (including a file widepytestmark)A full run of all tests with
pytest -vvleads to 246 warnings on a fairly up to date dev environment versus 722 warnings previously.