Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 10, 2024
1 parent a5ced30 commit e7e1e04
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 20 deletions.
1 change: 1 addition & 0 deletions hyperopt/algobase.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" Support code for new-style search algorithms.
"""

import copy
from collections import deque

Expand Down
26 changes: 13 additions & 13 deletions hyperopt/atpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ def createHyperparameterConfigForHyperoptDomain(domain):
data = {"type": "object", "properties": {}}

for key in domain.params:
data["properties"][
key
] = Hyperparameter.createHyperparameterConfigForHyperoptDomain(
domain.params[key]
data["properties"][key] = (
Hyperparameter.createHyperparameterConfigForHyperoptDomain(
domain.params[key]
)
)

if "name" not in data["properties"][key]:
Expand All @@ -394,9 +394,9 @@ def createHyperparameterConfigForHyperoptDomain(domain):
data = {"type": "object", "properties": {}}

for item in domain.named_args:
data["properties"][
item[0]
] = Hyperparameter.createHyperparameterConfigForHyperoptDomain(item[1])
data["properties"][item[0]] = (
Hyperparameter.createHyperparameterConfigForHyperoptDomain(item[1])
)

return data
elif domain.name == "switch":
Expand Down Expand Up @@ -1133,9 +1133,9 @@ def computePrimarySecondary():
secondary.name
]
elif atpeParams["secondaryLockingMode"] == "random":
lockedValues[
secondary.name
] = self.chooseRandomValueForParameter(secondary)
lockedValues[secondary.name] = (
self.chooseRandomValueForParameter(secondary)
)

elif atpeParams["secondaryProbabilityMode"] == "correlation":
probability = max(
Expand All @@ -1158,9 +1158,9 @@ def computePrimarySecondary():
secondary.name
]
elif atpeParams["secondaryLockingMode"] == "random":
lockedValues[
secondary.name
] = self.chooseRandomValueForParameter(secondary)
lockedValues[secondary.name] = (
self.chooseRandomValueForParameter(secondary)
)

# Now last step, we filter results prior to sending them into ATPE
for resultIndex, result in enumerate(results):
Expand Down
1 change: 1 addition & 0 deletions hyperopt/criteria.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Criteria for Bayesian optimization
"""

import numpy as np
import scipy.stats

Expand Down
1 change: 1 addition & 0 deletions hyperopt/graph_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
in a search space.
"""

import io
from .pyll_utils import expr_to_config

Expand Down
1 change: 1 addition & 0 deletions hyperopt/hp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from hyperopt import hp
hp.uniform('x', 0, 1)
"""

from .pyll_utils import hp_choice as choice
from .pyll_utils import hp_randint as randint
from .pyll_utils import hp_pchoice as pchoice
Expand Down
1 change: 1 addition & 0 deletions hyperopt/ipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Author: James Bergstra <james.bergstra@gmail.com>
Licensed: MIT
"""

from time import sleep, time

import numpy as np
Expand Down
7 changes: 4 additions & 3 deletions hyperopt/mongoexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
finalize the job in the database.
"""

import copy

# import hashlib
Expand Down Expand Up @@ -497,9 +498,9 @@ def reserve(self, host_id, cond=None, exp_key=None):
raise ValueError("refusing to reserve owned job")
else:
cond["owner"] = None
cond[
"state"
] = JOB_STATE_NEW # theoretically this is redundant, theoretically
cond["state"] = (
JOB_STATE_NEW # theoretically this is redundant, theoretically
)

try:
rval = self.jobs.find_and_modify(
Expand Down
1 change: 1 addition & 0 deletions hyperopt/pyll/stochastic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Constructs for annotating base graphs.
"""

import sys
import numpy as np
from .base import scope, as_apply, dfs, rec_eval, clone
Expand Down
1 change: 1 addition & 0 deletions hyperopt/rand.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Random search - presented as hyperopt.fmin_random
"""

import logging
import numpy as np

Expand Down
1 change: 1 addition & 0 deletions hyperopt/rdists.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Extra distributions to complement scipy.stats
"""

import numpy as np
import numpy.random as mtrand
import scipy.stats
Expand Down
6 changes: 3 additions & 3 deletions hyperopt/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def ok_trial(tid, *args, **kwargs):
def create_fake_trial(tid, loss=None, status=STATUS_OK, state=JOB_STATE_DONE):
return dict(
tid=tid,
result={"status": status, "loss": loss}
if loss is not None
else {"status": status},
result=(
{"status": status, "loss": loss} if loss is not None else {"status": status}
),
spec={"a": 1},
misc={
"tid": tid,
Expand Down
1 change: 1 addition & 0 deletions hyperopt/tests/unit/test_ipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

import sys
from nose import SkipTest

Expand Down
1 change: 1 addition & 0 deletions hyperopt/tests/unit/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
then the plots actually appear.
"""

import unittest
import os

Expand Down
2 changes: 1 addition & 1 deletion hyperopt/tests/unit/test_rdists.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_distribution_rvs(self):


def check_d_samples(dfn, n, rtol=1e-2, atol=1e-2):
counts = defaultdict(lambda: 0)
counts = defaultdict(int)
# print 'sample', dfn.rvs(size=n)
inc = 1 / n
for s in dfn.rvs(size=n):
Expand Down
1 change: 1 addition & 0 deletions hyperopt/tpe.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Graphical model (GM)-based optimization algorithm using Theano
"""

import logging
import time

Expand Down

0 comments on commit e7e1e04

Please sign in to comment.