Skip to content

Commit

Permalink
updated code for new flake8 version (#548)
Browse files Browse the repository at this point in the history
* fixed errors thrown by new flake8 version

* fixed all version numbers in requirements.txt

* fixed tensorboardX version number
  • Loading branch information
jonasrauber committed May 24, 2020
1 parent 0d37a83 commit 86c36e3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 24 deletions.
34 changes: 29 additions & 5 deletions foolbox/attacks/brendel_bethge.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ def solve(

return qk

def _cauchy_point(self, x, l, u, g, B):
def _cauchy_point(self, x, l, u, g, B): # noqa: E741
# finds the cauchy point for q(x)=x'Gx+x'd s$t. l<=x<=u
# g=G*x+d #gradient of q(x)
# converted from r-code: https://github.com/andrewhooker/PopED/blob/master/R/cauchy_point.R
Expand Down Expand Up @@ -949,7 +949,7 @@ def _cauchy_point(self, x, l, u, g, B):

return x_cp

def _subspace_min(self, x, l, u, x_cp, d, G):
def _subspace_min(self, x, l, u, x_cp, d, G): # noqa: E741
# converted from r-code: https://github.com/andrewhooker/PopED/blob/master/R/subspace_min.R
n = x.shape[0]
Z = np.eye(n)
Expand Down Expand Up @@ -990,7 +990,7 @@ def _subspace_min(self, x, l, u, x_cp, d, G):

return x_cp + alpha * Z.dot(d[~fixed])

def _project(self, q, l, u):
def _project(self, q, l, u): # noqa: E741
N = q.shape[0]
for k in range(N):
if q[k] < l[k]:
Expand All @@ -1001,7 +1001,22 @@ def _project(self, q, l, u):
return q

def _line_search_armijo(
self, fun_and_jac, pt, dpt, func_calls, m, gk, l, u, x0, x, b, min_, max_, c, r
self,
fun_and_jac,
pt,
dpt,
func_calls,
m,
gk,
l, # noqa: E741
u,
x0,
x,
b,
min_,
max_,
c,
r,
):
ls_rho = 0.6
ls_c = 1e-4
Expand All @@ -1023,7 +1038,16 @@ def _line_search_armijo(
return ls_alpha, ls_pt, gkp1, dgkp1, func_calls

def _line_search_wolfe( # noqa: C901
self, fun_and_jac, xk, pk, gfk, old_fval, old_old_fval, l, u, args
self,
fun_and_jac,
xk,
pk,
gfk,
old_fval,
old_old_fval,
l, # noqa: #E741
u,
args,
):
"""Find alpha that satisfies strong Wolfe conditions.
Uses the line search algorithm to enforce strong Wolfe conditions
Expand Down
2 changes: 1 addition & 1 deletion foolbox/attacks/deepfool.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def run(

# we don't need the logits
diffs_ = [(losses, grad) for _, (losses, _), grad in diffs]
losses = ep.stack([l for l, _ in diffs_], axis=1)
losses = ep.stack([lo for lo, _ in diffs_], axis=1)
grads = ep.stack([g for _, g in diffs_], axis=1)
assert losses.shape == (N, candidates - 1)
assert grads.shape == (N, candidates - 1) + x0.shape[1:]
Expand Down
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
flake8>=3.7.9
black>=19.10b0
pytest>=5.3.2
pytest-cov>=2.8.1
coverage>=5.0.3
codecov>=2.0.15
coveralls>=1.10.0
mypy>=0.761
pre-commit>=1.21.0
flake8==3.8.2
black==19.10b0
pytest==5.4.1
pytest-cov==2.8.1
coverage==5.1
codecov==2.0.15
coveralls==1.10.0
mypy==0.770
pre-commit==2.3.0
responses==0.10.9
18 changes: 9 additions & 9 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
torch>=1.4.0
torchvision>=0.5.0
jaxlib>=0.1.37
jax>=0.1.57
tensorflow>=2.0.0
numba>=0.47.0
matplotlib>=3.1.2
pillow>=7.0.0
tensorboardX>=2.0
torch==1.4.0
torchvision==0.5.0
jaxlib==0.1.46
jax==0.1.66
tensorflow==2.0.0
numba==0.47.0
matplotlib==3.2.1
pillow==7.1.2
tensorboardX==2.0

0 comments on commit 86c36e3

Please sign in to comment.