Skip to content

Commit

Permalink
Fixed some pre-commit hook issues
Browse files Browse the repository at this point in the history
  • Loading branch information
KrissiHub committed Feb 9, 2024
1 parent c7640ba commit 4fd326b
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 31 deletions.
6 changes: 4 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ extend-exclude =
.venv
build
extend-ignore =
E203 # No whitespace before ':' in [x : y]
E731 # No lambdas — too strict
# No whitespace before ':' in [x : y]
E203,
# No lambdas — too strict
E731,
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Version 1.1.4

## Bug-Fixes
-

# Version 1.1.3

## Bug-Fixes
Expand Down
3 changes: 1 addition & 2 deletions deepcave/evaluators/epm/random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,9 @@ def predict_marginalized(self, X: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
# marginalized predictions for each tree
dat_ = np.zeros((X.shape[0], self._model_options.num_trees))
for i, x in enumerate(X):

# marginalize over instances
# 1. get all leaf values for each tree
# type: list[list[float]]
# type= list[list[float]]
preds_trees = [[] for i in range(self._model_options.num_trees)]

for feat in self.instance_features:
Expand Down
3 changes: 1 addition & 2 deletions deepcave/layouts/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def update_navigation_items(pathname): # type: ignore
]

point_layouts = []
for (id, name, icon) in points:
for id, name, icon in points:
href = f"/plugins/{id}"
point_layouts += [
html.Li(
Expand Down Expand Up @@ -106,7 +106,6 @@ def update_queue_info() -> List[Component]:

collect = []
for jobs, status in zip(all_jobs, job_stati):

for job in jobs:
name = job.meta["display_name"]
job_id = job.id
Expand Down
20 changes: 9 additions & 11 deletions deepcave/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def plugin_input_update(pathname: str, *inputs_list: str) -> List[str]:
update_dict(inputs, new_inputs)

# Set not used inputs
for (id, attribute, _, _) in self.inputs:
for id, attribute, _, _ in self.inputs:
if id not in inputs:
inputs[id] = {}

Expand Down Expand Up @@ -421,7 +421,7 @@ def toggle_help_modal(n: Optional[int], is_open: bool) -> Tuple[bool, str]:
return is_open

# Register callback to click on configurations
for (id, *_) in self.outputs:
for id, *_ in self.outputs:
internal_id = self.get_internal_output_id(id)

@app.callback(
Expand Down Expand Up @@ -470,8 +470,7 @@ def _inputs_changed(
# If only filters changed, then we don't need to
# calculate the results again.
if last_inputs is not None:
for (id, attribute, filter, _) in self.inputs:

for id, attribute, filter, _ in self.inputs:
if self.activate_run_selection:
if id == "run":
continue
Expand Down Expand Up @@ -524,7 +523,7 @@ def _process_raw_outputs(
# We have to add no_updates here for the mode we don't want
count_outputs = 0
count_mpl_outputs = 0
for (_, _, mpl_mode) in self.outputs:
for _, _, mpl_mode in self.outputs:
if mpl_mode:
count_mpl_outputs += 1
else:
Expand Down Expand Up @@ -600,7 +599,7 @@ def _dict_to_list(
order = self.outputs # type: ignore

result: List[Optional[str]] = []
for (id, attribute, instance, *_) in order:
for id, attribute, instance, *_ in order:
if not input:
# Instance is mlp_mode in case of outputs
# Simply ignore other outputs.
Expand Down Expand Up @@ -637,7 +636,7 @@ def _dict_as_key(self, d: Dict[str, Any], remove_filters: bool = False) -> Optio

new_d = copy.deepcopy(d)
if remove_filters:
for (id, _, filter, _) in self.inputs:
for id, _, filter, _ in self.inputs:
if filter:
if id in new_d:
del new_d[id]
Expand All @@ -662,10 +661,9 @@ def _cast_inputs(self, inputs: Dict[str, Dict[str, str]]) -> Dict[str, Dict[str,
casted_inputs: Dict[str, Dict[str, str]] = defaultdict(dict)
for id, attributes in inputs.items():
for attribute in attributes:

# Find corresponding input
type = None
for (id_, attribute_, _, type_) in self.inputs:
for id_, attribute_, _, type_ in self.inputs:
if id == id_ and attribute == attribute_:
type = type_
break
Expand Down Expand Up @@ -702,7 +700,7 @@ def _clean_inputs(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
"""
used_ids = []
cleaned_inputs = {}
for (id, attribute, *_) in self.inputs:
for id, attribute, *_ in self.inputs:
# Since self.inputs is ordered, we use the first occuring attribute and add
# the id so it is not used again.
if id not in used_ids:
Expand Down Expand Up @@ -1332,7 +1330,7 @@ def generate_inputs(self, **kwargs: Any) -> Dict[str, Any]:
The inputs for the run.
"""
mapping = {}
for (id, attribute, *_) in self.inputs:
for id, attribute, *_ in self.inputs:
# Since `self.inputs` is ordered, we use the first occuring attribute and add
# the id so it is not used again.
if id not in mapping:
Expand Down
6 changes: 4 additions & 2 deletions deepcave/plugins/objective/cost_over_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ def check_runs_compatibility(self, runs: List[AbstractRun]) -> None:
if run_inequality == RunInequality.INEQ_BUDGET:
notification.update("The budgets of the runs are not equal.", color="warning")
elif run_inequality == RunInequality.INEQ_CONFIGSPACE:
notification.update("The configuration spaces of the runs are not equal.", color="warning")
notification.update(
"The configuration spaces of the runs are not equal.", color="warning"
)
elif run_inequality == RunInequality.INEQ_META:
notification.update("The meta data of the runs is not equal.", color="warning")
elif run_inequality == RunInequality.INEQ_OBJECTIVE:
notification.update("The objectives of the runs are not equal.", color="warning")

# Set some attributes here
run = runs[0]

Expand Down
5 changes: 3 additions & 2 deletions deepcave/plugins/objective/pareto_front.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def check_runs_compatibility(self, runs):
if run_inequality == RunInequality.INEQ_BUDGET:
notification.update("The budgets of the runs are not equal.", color="warning")
elif run_inequality == RunInequality.INEQ_CONFIGSPACE:
notification.update("The configuration spaces of the runs are not equal.", color="warning")
notification.update(
"The configuration spaces of the runs are not equal.", color="warning"
)
elif run_inequality == RunInequality.INEQ_META:
notification.update("The meta data of the runs is not equal.", color="warning")
elif run_inequality == RunInequality.INEQ_OBJECTIVE:
Expand Down Expand Up @@ -186,7 +188,6 @@ def process(run, inputs):

is_front: Union[List, np.ndarray] = np.ones(points.shape[0], dtype=bool)
for point_idx, costs in enumerate(points):

if is_front[point_idx]:
# Keep any point with a lower/upper cost
# This loop is a little bit complicated than
Expand Down
1 change: 0 additions & 1 deletion deepcave/plugins/summary/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ def load_outputs(run, *_):
}

for hp_name, hp in run.configspace.get_hyperparameters_dict().items():

log = False
value = None
if (
Expand Down
14 changes: 10 additions & 4 deletions deepcave/runs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,9 @@ def check_equality(
continue

if k not in m2 or m2[k] != v:
raise NotMergeableError("Meta data of runs are not equal.", RunInequality.INEQ_META)
raise NotMergeableError(
"Meta data of runs are not equal.", RunInequality.INEQ_META
)

result["meta"] = m1

Expand All @@ -951,7 +953,9 @@ def check_equality(
for run in runs:
cs2 = run.configspace
if cs1 != cs2:
raise NotMergeableError("Configspace of runs are not equal.", RunInequality.INEQ_CONFIGSPACE)
raise NotMergeableError(
"Configspace of runs are not equal.", RunInequality.INEQ_CONFIGSPACE
)

result["configspace"] = cs1

Expand All @@ -978,7 +982,9 @@ def check_equality(
continue

if len(o1) != len(o2):
raise NotMergeableError("Objectives of runs are not equal.", RunInequality.INEQ_OBJECTIVE)
raise NotMergeableError(
"Objectives of runs are not equal.", RunInequality.INEQ_OBJECTIVE
)

for o1_, o2_ in zip(o1, o2):
o1_.merge(o2_)
Expand All @@ -988,4 +994,4 @@ def check_equality(
if meta:
result["meta"]["objectives"] = serialized_objectives

return result
return result
1 change: 0 additions & 1 deletion deepcave/runs/converters/bohb.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def from_path(cls, path):

first_starttime = None
for bohb_run in bohb.get_all_runs():

times = bohb_run.time_stamps
starttime = times["started"]
endtime = times["finished"]
Expand Down
7 changes: 4 additions & 3 deletions deepcave/runs/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from enum import Enum


class NotValidRunError(Exception):
"""Raised if directory is not a valid run."""

Expand All @@ -10,12 +12,11 @@ class NotMergeableError(Exception):

pass


class RunInequality(Enum):
"""Check why runs were not compatible."""

INEQ_META = 1
INEQ_OBJECTIVE = 2
INEQ_BUDGET = 3
INEQ_CONFIGSPACE = 4



1 change: 0 additions & 1 deletion examples/record/mnist_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def prepare_data(self):
MNIST(self.data_dir, train=False, download=True)

def setup(self, stage=None):

# Assign train/val datasets for use in dataloaders
if stage == "fit" or stage is None:
mnist_full = MNIST(self.data_dir, train=True, transform=self.transform)
Expand Down

0 comments on commit 4fd326b

Please sign in to comment.