From 00ddfc564b7e76da653bdac7e12a72dc20d483fd Mon Sep 17 00:00:00 2001 From: moririn2528 Date: Tue, 29 Aug 2023 17:54:50 +0900 Subject: [PATCH] fix by lint --- optuna_dashboard/preferential/_history.py | 2 ++ python_tests/preferential/test_history.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/optuna_dashboard/preferential/_history.py b/optuna_dashboard/preferential/_history.py index 4170ee21..fba0c69d 100644 --- a/optuna_dashboard/preferential/_history.py +++ b/optuna_dashboard/preferential/_history.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dataclasses import asdict from dataclasses import dataclass from datetime import datetime diff --git a/python_tests/preferential/test_history.py b/python_tests/preferential/test_history.py index e8563b25..bf80d058 100644 --- a/python_tests/preferential/test_history.py +++ b/python_tests/preferential/test_history.py @@ -42,10 +42,18 @@ def test_report_and_get_choices(storage_supplier: Callable[[], StorageSupplier]) history = serialize_preference_history(storage.get_study_system_attrs(study_id)) assert len(history) == 2 assert history[0]["candidate_trials"] == [0, 1, 2] - assert history[0]["preferences"] == [[0, 1], [2, 1]] + assert len(history[0]["preferences"]) == 2 + for i, (best, worst) in enumerate([(0, 1), (2, 1)]): + assert len(history[0]["preferences"][i]) == 2 + assert history[0]["preferences"][i][0] == best + assert history[0]["preferences"][i][1] == worst assert history[0]["feedback_mode"] == FeedbackMode.CHOOSE_WORST.name assert history[0]["timestamp"] == "2020-01-01T10:00:00" assert history[1]["candidate_trials"] == [0, 2, 3, 4] - assert history[1]["preferences"] == [[2, 0], [3, 0], [4, 0]] + assert len(history[1]["preferences"]) == 3 + for i, (best, worst) in enumerate([(2, 0), (3, 0), (4, 0)]): + assert len(history[1]["preferences"][i]) == 2 + assert history[1]["preferences"][i][0] == best + assert history[1]["preferences"][i][1] == worst assert history[1]["feedback_mode"] == FeedbackMode.CHOOSE_WORST.name assert history[1]["timestamp"] == "2020-01-01T10:00:01"