Skip to content

Commit 4518f66

Browse files
authored
Merge pull request #470 from rht/F401
Fix flake8 errors
2 parents a72b98a + a50612c commit 4518f66

28 files changed

+101
-86
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ install:
4646
- python setup.py install
4747

4848
script:
49-
- flake8 --select F401 quantecon
49+
- flake8 --select F401, F405,E231 quantecon
5050
- nosetests --with-coverage -a "!slow" --cover-package=quantecon
5151

5252
after_success:

quantecon/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
try:
77
import numba
88
except:
9-
raise ImportError("Cannot import numba from current anaconda distribution. Please run `conda install numba` to install the latest version.")
9+
raise ImportError(
10+
"Cannot import numba from current anaconda distribution. Please run `conda install numba` to install the latest version.")
1011

1112
#-Modules-#
1213
from . import distributions
@@ -35,8 +36,10 @@
3536
from .matrix_eqn import solve_discrete_lyapunov, solve_discrete_riccati
3637
from .quadsums import var_quadratic_sum, m_quadratic_sum
3738
#->Propose Delete From Top Level
38-
from .markov import MarkovChain, random_markov_chain, random_stochastic_matrix, gth_solve, tauchen, rouwenhorst #Promote to keep current examples working
39-
from .markov import mc_compute_stationary, mc_sample_path #Imports that Should be Deprecated with markov package
39+
#Promote to keep current examples working
40+
from .markov import MarkovChain, random_markov_chain, random_stochastic_matrix, gth_solve, tauchen, rouwenhorst
41+
#Imports that Should be Deprecated with markov package
42+
from .markov import mc_compute_stationary, mc_sample_path
4043
#<-
4144
from .rank_nullspace import rank_est, nullspace
4245
from .robustlq import RBLQ

quantecon/game_theory/game_generators/tests/test_bimatrix_generators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def test_seed(self):
112112
@raises(ValueError)
113113
def test_raises_value_error_too_large_inputs(self):
114114
n, k = 100, 50
115-
g = tournament_game(n, k)
115+
tournament_game(n, k)
116116

117117

118118
class TestUnitVectorGame:
@@ -149,7 +149,7 @@ def test_redraw(self):
149149
@raises(ValueError)
150150
def test_raises_value_error_avoid_pure_nash_n_1(self):
151151
n = 1
152-
g = unit_vector_game(n, avoid_pure_nash=True)
152+
unit_vector_game(n, avoid_pure_nash=True)
153153

154154

155155
def test_payoff_range():

quantecon/game_theory/tests/test_mclennan_tourky.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_best_response_selection_no_indptr():
147147
[(0, 3), (6, 1)]]
148148
g = NormalFormGame(bimatrix)
149149

150-
test_obj = _best_response_selection([1/3, 1/3, 1/3, 1/2,1/2], g)
150+
test_obj = _best_response_selection([1/3, 1/3, 1/3, 1/2, 1/2], g)
151151
expected_output = np.array([0., 1., 0., 0., 1.])
152152

153153
assert_array_equal(test_obj, expected_output)

quantecon/game_theory/tests/test_normal_form_game.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,43 +482,43 @@ def test_player_repr():
482482

483483
@raises(ValueError)
484484
def test_player_zero_actions():
485-
p = Player([[]])
485+
Player([[]])
486486

487487

488488
@raises(ValueError)
489489
def test_normalformgame_invalid_input_players_shape_inconsistent():
490490
p0 = Player(np.zeros((2, 3)))
491491
p1 = Player(np.zeros((2, 3)))
492-
g = NormalFormGame([p0, p1])
492+
NormalFormGame([p0, p1])
493493

494494

495495
@raises(ValueError)
496496
def test_normalformgame_invalid_input_players_num_inconsistent():
497497
p0 = Player(np.zeros((2, 2, 2)))
498498
p1 = Player(np.zeros((2, 2, 2)))
499-
g = NormalFormGame([p0, p1])
499+
NormalFormGame([p0, p1])
500500

501501

502502
@raises(ValueError)
503503
def test_normalformgame_invalid_input_players_dtype_inconsistent():
504504
p0 = Player(np.zeros((2, 2), dtype=int))
505505
p1 = Player(np.zeros((2, 2), dtype=float))
506-
g = NormalFormGame([p0, p1])
506+
NormalFormGame([p0, p1])
507507

508508

509509
@raises(ValueError)
510510
def test_normalformgame_invalid_input_nosquare_matrix():
511-
g = NormalFormGame(np.zeros((2, 3)))
511+
NormalFormGame(np.zeros((2, 3)))
512512

513513

514514
@raises(ValueError)
515515
def test_normalformgame_invalid_input_payoff_profiles():
516-
g = NormalFormGame(np.zeros((2, 2, 1)))
516+
NormalFormGame(np.zeros((2, 2, 1)))
517517

518518

519519
@raises(ValueError)
520520
def test_normalformgame_zero_actions():
521-
g = NormalFormGame((2, 0))
521+
NormalFormGame((2, 0))
522522

523523

524524
# Utility functions #

quantecon/game_theory/tests/test_support_enumeration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_no_error_skew_sym(self):
6666
n, m = 3, 2
6767
seed = 7028
6868
g = random_skew_sym(n, m, random_state=seed)
69-
NEs = support_enumeration(g)
69+
support_enumeration(g)
7070

7171

7272
@raises(TypeError)

quantecon/game_theory/vertex_enumeration.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def __init__(self, opponent_player, idx=0, qhull_options=None):
225225
# Shift the payoffs to be nonnegative and have no zero column
226226
col_mins = B.min(axis=0)
227227
col_maxs = B.max(axis=0)
228-
neg_cols = (col_mins < 0)
229228
nonpos_const_cols = (col_maxs == col_mins) * (col_mins <= 0)
230229
shifts = np.zeros(m)
231230
shifts[col_mins < 0] = -col_mins[col_mins < 0]

quantecon/lss.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,17 @@ def __init__(self, A, C, G, H=None, mu_0=None, Sigma_0=None):
109109
# = Check Input Shapes = #
110110
ni, nj = self.A.shape
111111
if ni != nj:
112-
raise ValueError("Matrix A (shape: %s) needs to be square" % (self.A.shape))
112+
raise ValueError(
113+
"Matrix A (shape: %s) needs to be square" % (self.A.shape))
113114
if ni != self.C.shape[0]:
114-
raise ValueError("Matrix C (shape: %s) does not have compatible dimensions with A. It should be shape: %s" % (self.C.shape, (ni,1)))
115+
raise ValueError(
116+
"Matrix C (shape: %s) does not have compatible dimensions with A. "
117+
"It should be shape: %s" % (self.C.shape, (ni, 1)))
115118
self.m = self.C.shape[1]
116119
self.k, self.n = self.G.shape
117120
if self.n != ni:
118-
raise ValueError("Matrix G (shape: %s) does not have compatible dimensions with A (%s)"%(self.G.shape, self.A.shape))
121+
raise ValueError("Matrix G (shape: %s) does not have compatible dimensions with A (%s)"%(
122+
self.G.shape, self.A.shape))
119123
if H is None:
120124
self.H = None
121125
self.l = None

quantecon/markov/core.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ def cdfs(self):
429429
def cdfs1d(self):
430430
if (self._cdfs1d is None) and self.is_sparse:
431431
data = self.P.data
432-
indices = self.P.indices
433432
indptr = self.P.indptr
434433

435434
cdfs1d = np.empty(self.P.nnz, order='C')

quantecon/markov/ddp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ def to_product_form(self):
511511
R[self.s_indices, self.a_indices] = self.R
512512
Q = np.zeros((ns, na, ns))
513513
if self._sparse:
514-
_fill_dense_Q(self.s_indices, self.a_indices, self.Q.toarray(), Q)
514+
_fill_dense_Q(self.s_indices, self.a_indices,
515+
self.Q.toarray(), Q)
515516
else:
516517
_fill_dense_Q(self.s_indices, self.a_indices, self.Q, Q)
517518
return DiscreteDP(R, Q, self.beta)

0 commit comments

Comments
 (0)