Skip to content

Commit

Permalink
CLN: Remove small bug bears
Browse files Browse the repository at this point in the history
Remove unused iteration variables and related bug bears
  • Loading branch information
bashtage committed Oct 1, 2018
1 parent f8ab244 commit 301db6b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
26 changes: 13 additions & 13 deletions arch/tests/bootstrap/test_bootstrap.py
Expand Up @@ -147,25 +147,25 @@ def test_state(self):
bs = IIDBootstrap(np.arange(100))
bs.seed(23456)
state = bs.get_state()
for data, kwdata in bs.bootstrap(10):
for data, _ in bs.bootstrap(10):
final = data[0]
bs.seed(23456)
for data, kwdata in bs.bootstrap(10):
for data, _ in bs.bootstrap(10):
final_seed = data[0]
bs.set_state(state)
for data, kwdata in bs.bootstrap(10):
for data, _ in bs.bootstrap(10):
final_state = data[0]
assert_equal(final, final_seed)
assert_equal(final, final_state)

def test_reset(self):
bs = IIDBootstrap(np.arange(100))
state = bs.get_state()
for data, kwdata in bs.bootstrap(10):
for data, _ in bs.bootstrap(10):
final = data[0]
bs.reset()
state_reset = bs.get_state()
for data, kwdata in bs.bootstrap(10):
for data, _ in bs.bootstrap(10):
final_reset = data[0]
assert_equal(final, final_reset)
assert_equal(state, state_reset)
Expand Down Expand Up @@ -248,7 +248,7 @@ def func(y):
bs.reset()
results = np.zeros((num_bootstrap, 2))
count = 0
for pos, kw in bs.bootstrap(num_bootstrap):
for pos, _ in bs.bootstrap(num_bootstrap):
results[count] = func(*pos)
count += 1
mu = func(self.x)
Expand Down Expand Up @@ -283,7 +283,7 @@ def func(y):
bs.reset()
results = np.zeros((num_bootstrap, 2))
count = 0
for pos, kw in bs.bootstrap(num_bootstrap):
for pos, _ in bs.bootstrap(num_bootstrap):
results[count] = func(*pos)
count += 1

Expand Down Expand Up @@ -371,7 +371,7 @@ def std_err_func(mu, y):
results = np.zeros((num_bootstrap, 2))
stud_results = np.zeros((num_bootstrap, 2))
count = 0
for pos, kwdata in bs.bootstrap(reps=num_bootstrap):
for pos, _ in bs.bootstrap(reps=num_bootstrap):
results[count] = func(*pos)
std_err = std_err_func(results[count], *pos)
stud_results[count] = (results[count] - base) / std_err
Expand All @@ -398,7 +398,7 @@ def std_err_func(mu, y):
results = np.zeros((num_bootstrap, 2))
stud_results = np.zeros((num_bootstrap, 2))
count = 0
for pos, kwdata in bs.bootstrap(reps=num_bootstrap):
for pos, _ in bs.bootstrap(reps=num_bootstrap):
results[count] = func(*pos)
inner_bs = IIDBootstrap(*pos)
seed = bs.random_state.randint(2 ** 31 - 1)
Expand Down Expand Up @@ -495,7 +495,7 @@ def semi_func(x, params=None):
results = np.zeros((reps, 2))
count = 0
mu = self.x.mean(0)
for pos, kw in bs.bootstrap(100):
for pos, _ in bs.bootstrap(100):
results[count] = param_func(*pos, params=mu,
state=bs.random_state)
count += 1
Expand All @@ -508,7 +508,7 @@ def semi_func(x, params=None):
bs.reset()
results = np.zeros((reps, 2))
count = 0
for pos, kw in bs.bootstrap(100):
for pos, _ in bs.bootstrap(100):
results[count] = semi_func(*pos, params=mu)
count += 1
assert_allclose(bs._results, results)
Expand Down Expand Up @@ -626,7 +626,7 @@ def func(y):
results = bs.apply(func, 1000)
bs.reset(23456)
direct_results = []
for pos, kw in bs.bootstrap(1000):
for pos, _ in bs.bootstrap(1000):
direct_results.append(func(*pos))
direct_results = np.array(direct_results)
assert_equal(results, direct_results)
Expand All @@ -641,7 +641,7 @@ def func(y):
results = bs.apply(func, 1000)
bs.reset(23456)
direct_results = []
for pos, kw in bs.bootstrap(1000):
for pos, _ in bs.bootstrap(1000):
direct_results.append(func(*pos))
direct_results = np.array(direct_results)
direct_results = direct_results[:, None]
Expand Down
2 changes: 1 addition & 1 deletion arch/tests/univariate/test_variance_forecasting.py
Expand Up @@ -1467,7 +1467,7 @@ def test_bs_rng_errors(self):
bs_rng = BootstrapRng(y, 100)
rng = bs_rng.rng()
with pytest.raises(IndexError):
for i in range(100, 1001):
for _ in range(100, 1001):
rng(1)

y = self.rng.rand(1000)
Expand Down
4 changes: 1 addition & 3 deletions arch/unitroot/critical_values/dickey_fuller.py
Expand Up @@ -6,8 +6,6 @@
did not appear in the original paper and have been computed using an identical
simulation.
"""
from arch.compat.python import iteritems

from numpy import asarray, inf

small_scaling = asarray([1, 1, 1e-2])
Expand Down Expand Up @@ -247,7 +245,7 @@
'ctt': [3.4216, 0.4170, 1.6939, 0.4203, 0.4153]}

adf_z_large_p_scale = asarray([1.0, 1.0, 1e-2, 1e-3, 1e-5])
for k, v in iteritems(adf_z_large_p):
for k in adf_z_large_p.keys():
adf_z_large_p[k] = asarray(adf_z_large_p[k]) * adf_z_large_p_scale

adf_z_cv_approx = {
Expand Down
12 changes: 6 additions & 6 deletions arch/univariate/volatility.py
Expand Up @@ -125,7 +125,7 @@ class VolatilityProcess(object):
separately from the conditional variance, even though parameters are estimated jointly.
"""

__metaclass__ = DocStringInheritor
__metaclass__ = DocStringInheritor # noqa

def __init__(self):
self.num_params = 0
Expand Down Expand Up @@ -1451,13 +1451,13 @@ class RiskMetrics2006(VolatilityProcess):
Parameters
----------
tau0 : int, optional
Length of long cycle
Length of long cycle. Default is 1560.
tau1 : int, optional
Length of short cycle
Length of short cycle. Default is 4.
kmax : int, optional
Number of components
Number of components. Default is 14.
rho : float, optional
Relative scale of adjacent cycles
Relative scale of adjacent cycles. Default is sqrt(2)
Attributes
----------
Expand All @@ -1479,7 +1479,7 @@ class RiskMetrics2006(VolatilityProcess):
This model has no parameters since the smoothing parameter is fixed.
"""

def __init__(self, tau0=1560, tau1=4, kmax=14, rho=sqrt(2)):
def __init__(self, tau0=1560, tau1=4, kmax=14, rho=1.4142135623730951):
super(RiskMetrics2006, self).__init__()
self.tau0 = tau0
self.tau1 = tau1
Expand Down

0 comments on commit 301db6b

Please sign in to comment.