Removing hyperparameter(s) from ConfigurationSpace#411
Conversation
thijssnelleman
commented
Aug 6, 2025
- Removed Hyperparameter from all clauses regarding forbidden / conditions, leaving all else intact
- Recalculated the node depth for only the affected nodes in the tree
|
I updated the structure to now rebuild the DAG: "Now the ConfigurationSpace.remove does all the work, at the end it reset dag by self._dag = Dag() and adds all parameters/conditions/forbiddens as done in ConfigurationSpace.init" I think after review, with a few minor changes, this can be merged |
…ove_hyperparameter
|
@mfeurer Reminder for this PR |
Co-authored-by: Matthias Feurer <feurerm@informatik.uni-freiburg.de>
Co-authored-by: Matthias Feurer <feurerm@informatik.uni-freiburg.de>
Co-authored-by: Matthias Feurer <feurerm@informatik.uni-freiburg.de>
Co-authored-by: Matthias Feurer <feurerm@informatik.uni-freiburg.de>
There was a problem hiding this comment.
Pull request overview
This pull request adds a remove() method to ConfigurationSpace that allows hyperparameters to be removed along with their associated conditions and forbidden clauses. The implementation properly handles nested conjunctions by recursively removing hyperparameters and simplifying the condition/forbidden structures as needed.
Changes:
- Added
ConfigurationSpace.remove()method to remove hyperparameters and update conditions/forbiddens accordingly - Fixed a bug in
test_util.pywhere the test was not correctly validating generated grid values - Various code quality improvements including alphabetical sorting of imports/exports, clearer parenthesization, and more concise boundary checks
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ConfigSpace/configuration_space.py | Added new remove() method with recursive logic to handle hyperparameter removal from conditions and forbiddens |
| test/test_configuration_space.py | Comprehensive test coverage for the new remove() method including complex nested conjunctions |
| test/test_util.py | Fixed bug where test was comparing value to itself instead of checking generated vs expected |
| src/ConfigSpace/util.py | Refactored boundary checks to use max/min; incorrectly changed cast() calls to use string literals |
| src/ConfigSpace/forbidden.py | Added trailing commas for consistency; contains debug print statement |
| src/ConfigSpace/configuration.py | Improved readability by adding explicit parentheses around boolean conditions |
| src/ConfigSpace/_condition_tree.py | Moved ConditionLike import from TYPE_CHECKING to runtime imports |
| src/ConfigSpace/init.py | Alphabetically sorted imports |
| src/ConfigSpace/api/init.py | Alphabetically sorted all exports |
| src/ConfigSpace/hyperparameters/init.py | Alphabetically sorted all exports |
| src/ConfigSpace/c_util.py | Alphabetically sorted all exports |
| src/ConfigSpace/read_and_write/dictionary.py | Alphabetically sorted imports and added trailing commas |
| changelog.md | Added entry for the new feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>