Skip to content

Commit

Permalink
Merge pull request #643 from Smit-create/pytest_warn
Browse files Browse the repository at this point in the history
MAINT: Fix pytest warnings
  • Loading branch information
Smit-create authored Oct 29, 2022
2 parents 060f3e6 + a1b2286 commit 89a7012
Show file tree
Hide file tree
Showing 31 changed files with 71 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class TestBlottoGame:
def setup(self):
def setup_method(self):
self.h, self.t = 4, 3
rho = 0.5
self.g = blotto_game(self.h, self.t, rho)
Expand All @@ -38,7 +38,7 @@ def test_seed(self):


class TestRankingGame:
def setup(self):
def setup_method(self):
self.n = 100
self.g = ranking_game(self.n)

Expand Down Expand Up @@ -85,7 +85,7 @@ def test_sgc_game():


class TestTournamentGame:
def setup(self):
def setup_method(self):
self.n = 5
self.k = 3
self.m = comb(self.n, self.k, exact=True)
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_raises_value_error_too_large_inputs(self):


class TestUnitVectorGame:
def setup(self):
def setup_method(self):
self.n = 100
self.g = unit_vector_game(self.n)

Expand Down
4 changes: 2 additions & 2 deletions quantecon/game_theory/tests/test_lemke_howson.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class TestLemkeHowson():
def setup(self):
def setup_method(self):
self.game_dicts = []

# From von Stengel 2007 in Algorithmic Game Theory
Expand All @@ -30,7 +30,7 @@ def test_lemke_howson(self):


class TestLemkeHowsonDegenerate():
def setup(self):
def setup_method(self):
self.game_dicts = []

# From von Stengel 2007 in Algorithmic Game Theory
Expand Down
6 changes: 3 additions & 3 deletions quantecon/game_theory/tests/test_mclennan_tourky.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class TestMclennanTourky():
def setup(self):
def setup_method(self):
def anti_coordination(N, v):
payoff_array = np.empty((2,)*N)
payoff_array[0, :] = 1
Expand Down Expand Up @@ -56,7 +56,7 @@ def test_pure_nash(self):


class TestMclennanTourkyInvalidInputs():
def setup(self):
def setup_method(self):
self.bimatrix = [[(3, 3), (3, 2)],
[(2, 2), (5, 6)],
[(0, 3), (6, 1)]]
Expand All @@ -73,7 +73,7 @@ def test_mclennan_tourky_invalid_init_length(self):


class TestEpsilonNash():
def setup(self):
def setup_method(self):
def anti_coordination(N, v):
payoff_array = np.empty((2,)*N)
payoff_array[0, :] = 1
Expand Down
16 changes: 8 additions & 8 deletions quantecon/game_theory/tests/test_normal_form_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class TestPlayer_1opponent:
"""Test the methods of Player with one opponent player"""

def setup(self):
def setup_method(self):
"""Setup a Player instance"""
coordination_game_matrix = [[4, 0], [3, 2]]
self.player = Player(coordination_game_matrix)
Expand Down Expand Up @@ -89,7 +89,7 @@ def test_dominated_actions(self):
class TestPlayer_2opponents:
"""Test the methods of Player with two opponent players"""

def setup(self):
def setup_method(self):
"""Setup a Player instance"""
payoffs_2opponents = [[[3, 6],
[4, 2]],
Expand Down Expand Up @@ -176,7 +176,7 @@ def test_player_corner_cases():
class TestNormalFormGame_Sym2p:
"""Test the methods of NormalFormGame with symmetric two players"""

def setup(self):
def setup_method(self):
"""Setup a NormalFormGame instance"""
coordination_game_matrix = [[4, 0], [3, 2]]
self.g = NormalFormGame(coordination_game_matrix)
Expand All @@ -194,7 +194,7 @@ def test_is_nash_mixed(self):
class TestNormalFormGame_Asym2p:
"""Test the methods of NormalFormGame with asymmetric two players"""

def setup(self):
def setup_method(self):
"""Setup a NormalFormGame instance"""
self.BoS_bimatrix = np.array([[(3, 2), (1, 1)],
[(0, 0), (2, 3)]])
Expand Down Expand Up @@ -234,7 +234,7 @@ def test_payoff_arrays(self):
class TestNormalFormGame_3p:
"""Test the methods of NormalFormGame with three players"""

def setup(self):
def setup_method(self):
"""Setup a NormalFormGame instance"""
payoffs_2opponents = [[[3, 6],
[4, 2]],
Expand Down Expand Up @@ -341,7 +341,7 @@ def test_normalformgame_payoff_profile_array_c_contiguous():
class TestPlayer_0opponents:
"""Test for trivial Player with no opponent player"""

def setup(self):
def setup_method(self):
"""Setup a Player instance"""
self.payoffs = [0, 1, -1]
self.player = Player(self.payoffs)
Expand Down Expand Up @@ -386,7 +386,7 @@ def test_dominated_actions(self):
class TestNormalFormGame_1p:
"""Test for trivial NormalFormGame with a single player"""

def setup(self):
def setup_method(self):
"""Setup a NormalFormGame instance"""
data = [[0], [1], [1]]
self.g = NormalFormGame(data)
Expand Down Expand Up @@ -444,7 +444,7 @@ def test_normalformgame_setitem_1p():
# Trivial cases with one action #

class TestPlayer_1action:
def setup(self):
def setup_method(self):
"""Setup a Player instance"""
self.payoffs = [[0, 1]]
self.player = Player(self.payoffs)
Expand Down
2 changes: 1 addition & 1 deletion quantecon/game_theory/tests/test_pure_nash.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class TestPureNashBruteForce():
def setup(self):
def setup_method(self):
self.game_dicts = []

# Matching Pennies game with no pure nash equilibrium
Expand Down
2 changes: 1 addition & 1 deletion quantecon/game_theory/tests/test_repeated_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class TestAS():
def setup(self):
def setup_method(self):
self.game_dicts = []

# Example from Abreu and Sannikov (2014)
Expand Down
2 changes: 1 addition & 1 deletion quantecon/game_theory/tests/test_support_enumeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def random_skew_sym(n, m=None, random_state=None):


class TestSupportEnumeration():
def setup(self):
def setup_method(self):
self.game_dicts = []

# From von Stengel 2007 in Algorithmic Game Theory
Expand Down
4 changes: 2 additions & 2 deletions quantecon/game_theory/tests/test_vertex_enumeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class TestVertexEnumeration:
def setup(self):
def setup_method(self):
self.game_dicts = []

# From von Stengel 2007 in Algorithmic Game Theory
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_vertex_enumeration_invalid_g():


class TestBestResponsePolytope:
def setup(self):
def setup_method(self):
# From von Stengel 2007 in Algorithmic Game Theory
bimatrix = [[(3, 3), (3, 2)],
[(2, 2), (5, 6)],
Expand Down
4 changes: 2 additions & 2 deletions quantecon/markov/tests/test_approximation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class TestTauchen:

def setup(self):
def setup_method(self):
self.rho, self.sigma_u = np.random.rand(2)
self.n = np.random.randint(3, 25)
self.m = np.random.randint(5)
Expand Down Expand Up @@ -54,7 +54,7 @@ def test_states_sum_0(self):

class TestRouwenhorst:

def setup(self):
def setup_method(self):
self.rho, self.sigma = np.random.uniform(0, 1, size=2)
self.n = np.random.randint(3, 26)
self.ybar = np.random.randint(0, 11)
Expand Down
4 changes: 2 additions & 2 deletions quantecon/markov/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class Test_markovchain_stationary_distributions_KMRMarkovMatrix2():
p = 1/3
TOL = 1e-2

def setup(self):
def setup_method(self):
""" Setup a KMRMarkovMatrix and Compute Stationary Values """
self.P = KMR_Markov_matrix_sequential(self.N, self.p, self.epsilon)
self.mc = MarkovChain(self.P)
Expand Down Expand Up @@ -409,7 +409,7 @@ def test_mc_sample_path_lln():


class TestMCStateValues:
def setup(self):
def setup_method(self):
state_values = [[0, 1], [2, 3], [4, 5]] # Pass python list
self.state_values = np.array(state_values)

Expand Down
4 changes: 2 additions & 2 deletions quantecon/markov/tests/test_ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class TestDiscreteDP:
def setup(self):
def setup_method(self):
# From Puterman 2005, Section 3.1
beta = 0.95

Expand Down Expand Up @@ -194,7 +194,7 @@ def test_ddp_sorting():


class TestFiniteHorizon:
def setup(self):
def setup_method(self):
# From Puterman 2005, Section 3.2, Section 4.6.1
# "single-product stochastic inventory control"
s_indices = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3]
Expand Down
2 changes: 1 addition & 1 deletion quantecon/markov/tests/test_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_random_stochastic_matrix_k_1():


class TestRandomDiscreteDP:
def setup(self):
def setup_method(self):
self.num_states, self.num_actions = 5, 4
self.num_sa = self.num_states * self.num_actions
self.k = 3
Expand Down
4 changes: 2 additions & 2 deletions quantecon/random/tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# probvec #

class TestProbvec:
def setup(self):
def setup_method(self):
self.m, self.k = 2, 3 # m vectors of dimension k
seed = 1234

Expand Down Expand Up @@ -68,7 +68,7 @@ def test_sample_without_replacement_value_error():
# draw #

class TestDraw:
def setup(self):
def setup_method(self):
self.pmf = np.array([0.4, 0.1, 0.5])
self.cdf = np.cumsum(self.pmf)
self.n = len(self.pmf)
Expand Down
2 changes: 1 addition & 1 deletion quantecon/tests/test_arma.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class TestARMA():
def setup(self):
def setup_method(self):
# Initial Values
phi = np.array([.95, -.4, -.4])
theta = np.zeros(3)
Expand Down
4 changes: 2 additions & 2 deletions quantecon/tests/test_compute_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class TestFPLogisticEquation():

@classmethod
def setup(cls):
def setup_method(cls):
cls.mu_1 = 0.2 # 0 is unique fixed point forall x_0 \in [0, 1]

# (4mu - 1)/(4mu) is a fixed point forall x_0 \in [0, 1]
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_imitation_game_method(self):


class TestComputeFPContraction():
def setup(self):
def setup_method(self):
self.coeff = 0.5
self.methods = ['iteration', 'imitation_game']

Expand Down
2 changes: 1 addition & 1 deletion quantecon/tests/test_discrete_rv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class TestDiscreteRV:

@classmethod
def setup(cls):
def setup_method(cls):
x = np.random.rand(10)
x /= x.sum()
# make sure it sums to 1
Expand Down
2 changes: 1 addition & 1 deletion quantecon/tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class TestBetaBinomial:
def setup(self):
def setup_method(self):
self.n = 100
self.a = 5
self.b = 5
Expand Down
2 changes: 1 addition & 1 deletion quantecon/tests/test_dle.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class TestDLE:

def setup(self):
def setup_method(self):
"""
Given LQ control is tested we will test the transformation
to alter the problem into a form suitable to solve using LQ
Expand Down
2 changes: 1 addition & 1 deletion quantecon/tests/test_ecdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class TestECDF:

@classmethod
def setup(cls):
def setup_method(cls):
cls.obs = np.random.rand(40) # observations defining dist
cls.ecdf = ECDF(cls.obs)

Expand Down
12 changes: 6 additions & 6 deletions quantecon/tests/test_estspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class PeriodogramBase:

@classmethod
def setup(cls):
def setup_method(cls):
if cls is PeriodogramBase:
raise pytest.skip("Skip PeriodogramBase tests" +
" it's a base class")
Expand Down Expand Up @@ -47,10 +47,10 @@ def test_func_I(self):
class TestPeriodogram(PeriodogramBase):

@classmethod
def setup(cls):
def setup_method(cls):
if cls is PeriodogramBase:
raise pytest.skip("Skip BaseTest tests, it's a base class")
super(TestPeriodogram, cls).setup()
super(TestPeriodogram, cls).setup_method()
cls.window_length = 7
cls.w_20, cls.Iw_20 = periodogram(x_20)
cls.w_21, cls.Iw_21 = periodogram(x_21)
Expand All @@ -60,10 +60,10 @@ def setup(cls):
class TestArPeriodogram(PeriodogramBase):

@classmethod
def setup(cls):
def setup_method(cls):
if cls is PeriodogramBase:
raise pytest.skip("Skip BaseTest tests, it's a base class")
super(TestArPeriodogram, cls).setup()
super(TestArPeriodogram, cls).setup_method()
cls.window_length = 7
cls.w_20, cls.Iw_20 = ar_periodogram(x_20)
cls.w_21, cls.Iw_21 = ar_periodogram(x_21)
Expand All @@ -81,7 +81,7 @@ def test_func_Iw_shape_even_x(self):
class TestSmooth:

@classmethod
def setup(cls):
def setup_method(cls):
cls.x_20 = np.random.rand(20)
cls.x_21 = np.random.rand(21)
cls.window_length = 7
Expand Down
Loading

0 comments on commit 89a7012

Please sign in to comment.