def __init__(self, result, main_model): self._result = result self._ph = hierarchical.DictionaryModel( {r.key: r.prediction for r in self._result.results}) self._current_prediction = None self._plot_risk_level = -1 self._run_comparison_model = run_comparison.RunComparisonModel( main_model) self._adjust_tasks = self._build_adjust_tasks()
def dict_model_3(): return hier.DictionaryModel({ TaskKey(1, 2, 3): 5, TaskKey(1, 2, 4): 7, TaskKey(1, 3, 2): 8, TaskKey( 2, 1, 1, ): 9 })
def dict_model_2(): return hier.DictionaryModel({ (1, 2, 3): 5, (1, 2, 4): 7, (1, 3, 2): 8, ( 2, 1, 1, ): 9 })
import os, sys sys.path.insert(0, os.path.abspath(os.path.join("..", ".."))) import open_cp.gui.hierarchical as hierarchical model = hierarchical.DictionaryModel({ (1, 2, 3): "123", (1, 2, 4): "124", (1, 3, 1): "131", (1, 4, 2): "142", (1, 4, 4): "144" }) import tkinter as tk import tkinter.ttk as ttk root = tk.Tk() hier = hierarchical.Hierarchical(model, parent=root) for i in range(3): ttk.Label(root, text="Choice {}:".format(i + 1)).grid(row=i, column=0) hier.view.frames[i].grid(row=i, column=1) ttk.Label(root, text="Data:").grid(row=100, column=0) label = ttk.Label(root, ) label.grid(row=100, column=1) def update(): label["text"] = model.current_item
def test_dict_model_keys_different_lengths(): with pytest.raises(ValueError): hier.DictionaryModel({(1, 2): 5, (1, 2, 3): 7})
def test_dict_model_not_tuples(): with pytest.raises(ValueError): hier.DictionaryModel({5: 7})
def dict_model_1(): return hier.DictionaryModel({(1, 2, 3): 5, (1, 2, 4): 7})