diff --git a/quantecon/__init__.py b/quantecon/__init__.py index b88d762fb..fabf9ab27 100644 --- a/quantecon/__init__.py +++ b/quantecon/__init__.py @@ -7,10 +7,10 @@ try: import numba -except: +except ImportError as e: raise ImportError( - "Cannot import numba from current anaconda distribution. \ - Please run `conda install numba` to install the latest version.") + "Cannot import numba, which QuantEcon.py requires. Install it with " + "`pip install numba` or `conda install numba`.") from e #-Modules-# from . import distributions diff --git a/quantecon/_dle.py b/quantecon/_dle.py index ceeaee7f1..7bafed20d 100644 --- a/quantecon/_dle.py +++ b/quantecon/_dle.py @@ -243,7 +243,7 @@ def compute_sequence(self, x0, ts_length=None, Pay=None): # === Value of asset whose payout vector is Pay*xt === # # See p.145: Equation (7.11.1) - if isinstance(Pay, np.ndarray) == True: + if isinstance(Pay, np.ndarray): self.Za = Pay.T @ self.Mc self.Q = solve_discrete_lyapunov( self.A0.T * self.beta**0.5, self.Za) @@ -277,7 +277,7 @@ def irf(self, ts_length=100, shock=None): """ - if type(shock) != np.ndarray: + if not isinstance(shock, np.ndarray): # Default is to select first element of w shock = np.vstack((np.ones((1, 1)), np.zeros((self.nw - 1, 1)))) diff --git a/quantecon/game_theory/game_generators/__init__.py b/quantecon/game_theory/game_generators/__init__.py index fa20a29ea..1b51543b5 100644 --- a/quantecon/game_theory/game_generators/__init__.py +++ b/quantecon/game_theory/game_generators/__init__.py @@ -1,6 +1,11 @@ -# flake8: noqa """ game_theory.game_generators """ -from .bimatrix_generators import * +from .bimatrix_generators import (blotto_game, ranking_game, sgc_game, + tournament_game, unit_vector_game) + +__all__ = [ + 'blotto_game', 'ranking_game', 'sgc_game', 'tournament_game', + 'unit_vector_game' +] diff --git a/quantecon/tests/test_graph_tools.py b/quantecon/tests/test_graph_tools.py index 00e20b526..222c27ef9 100644 --- a/quantecon/tests/test_graph_tools.py +++ b/quantecon/tests/test_graph_tools.py @@ -134,7 +134,7 @@ def setup_method(self): for graph_dict in self.graphs.graph_dicts: try: weighted = graph_dict['weighted'] - except: + except KeyError: weighted = False graph_dict['g'] = DiGraph(graph_dict['A'], weighted=weighted) diff --git a/quantecon/tests/test_quadsum.py b/quantecon/tests/test_quadsum.py index 60011b6c6..2843144bd 100644 --- a/quantecon/tests/test_quadsum.py +++ b/quantecon/tests/test_quadsum.py @@ -53,11 +53,3 @@ def test_m_matsum(): summedval = summedval + a**i * b * a.T**i assert_allclose(retval, summedval, atol=1e-5, rtol=0) - - - -if __name__ == '__main__': - test_simplesum() - test_identitysum() - test_m_simplesum() - test_m_identitysum diff --git a/quantecon/util/notebooks.py b/quantecon/util/notebooks.py index 37b0f1bf4..5dc60e51d 100644 --- a/quantecon/util/notebooks.py +++ b/quantecon/util/notebooks.py @@ -86,7 +86,7 @@ def fetch_nb_dependencies(files, repo=REPO, raw=RAW, branch=BRANCH, folder=FOLDE import requests #-Generate Common Data Structure-# - if type(files) == list: + if isinstance(files, list): files = {"" : files} status = [] diff --git a/quantecon/util/timing.py b/quantecon/util/timing.py index f415e23c8..83c125051 100644 --- a/quantecon/util/timing.py +++ b/quantecon/util/timing.py @@ -247,7 +247,7 @@ def __enter__(self): self._start_time = time.time() return self - def __exit__(self, exc_type, exc_val, exc_tb): + def __exit__(self, *exc_info): end_time = time.time() self.elapsed = end_time - self._start_time