-
-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
When Parameters (params) or User Attributes (user_attrs) contain numeric values, they are serialized as strings by the backend. The frontend TrialTable currently relies on a default sorting mechanism (likely "natural" or alphanumeric sorting).
While this mechanism correctly handles positive integers (e.g., sorting 2 before 10), it fails for negative numbers. The sorting logic appears to treat the minus sign as a character and sorts based on the magnitude of the number following it.
Current Behavior:
- Positive numbers sort correctly:
2, 10, 100 - Negative numbers sort incorrectly (inverted order):
-1, -2, -10(instead of-10, -2, -1).
Expected Behavior:
The dashboard should detect if the column (Parameter or User Attribute) contains numeric values and apply a true numeric sort function that correctly accounts for negative signs.
How to Reproduce
- Create a Python script (
reproduce_issue.py) to generate a study with negative values in both parameters and user attributes:
import optuna
def objective(trial):
# 1. Create a parameter with a negative range
x = trial.suggest_int("x_param", -10, 10)
# 2. Set the same value as a user attribute
trial.set_user_attr("x_attr", x)
return x ** 2
if __name__ == "__main__":
study = optuna.create_study(storage="sqlite:///db.sqlite3", study_name="sort_bug_test")
study.optimize(objective, n_trials=20)- Run the script:
python reproduce_issue.py - Launch the dashboard:
optuna-dashboard sqlite:///db.sqlite3 - Open the Trials tab (Trial Table).
- Click the header for Param x_param and UserAttribute x_attr to sort them.
- Observe that for both columns, negative numbers are sorted by magnitude.
Python version
Python 3.12.12
Optuna version
4.4.0
optuna-dashboard version or git revision
0.20.0
Web browser
Microsoft Edge Beta
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working