Updates flake8 to latest.

The latest flake8 release in now 1.5, which pulls in pep8: 1.3.4a0

The upgrade pep8 has changes to what it picks up as lint.
Making code base compatible, so that new devs can install pep8
from PyPI and not have friction over the version difference.

Currently using these ignores in the config file:

```
[pep8]
ignore = E124,E125,E126
```

Ignoring these since they are difficult to squash while maintaining
an 80 char line length, and appear spurious.
Should address later.

Updates Travis config, README, and pip requirements to reflect change.
This commit is contained in:
Eddie Hebert
2012-10-22 11:57:16 -04:00
parent ddb007a6f9
commit 7904773d00
21 changed files with 310 additions and 101 deletions
+2 -3
View File
@@ -55,8 +55,7 @@ class SlippageTestCase(TestCase):
{'dt': datetime.datetime(2006, 1, 5, 14, 30, tzinfo=pytz.utc),
'amount': 100,
'filled': 0, 'sid': 133})
]
}
]}
txn = slippage_model.simulate(
event,
@@ -69,7 +68,7 @@ class SlippageTestCase(TestCase):
2006, 1, 5, 14, 31, tzinfo=pytz.utc),
'amount': int(50),
'sid': int(133)
}
}
self.assertIsNotNone(txn)
+7 -7
View File
@@ -83,10 +83,10 @@ class ExceptionTestCase(TestCase):
# Simulation
# ----------
self.zipline_test_config['algorithm'] = \
ExceptionAlgorithm(
'handle_data',
self.zipline_test_config['sid']
)
ExceptionAlgorithm(
'handle_data',
self.zipline_test_config['sid']
)
zipline = simfactory.create_test_zipline(
**self.zipline_test_config
@@ -103,9 +103,9 @@ class ExceptionTestCase(TestCase):
# Simulation
# ----------
self.zipline_test_config['algorithm'] = \
DivByZeroAlgorithm(
self.zipline_test_config['sid']
)
DivByZeroAlgorithm(
self.zipline_test_config['sid']
)
zipline = simfactory.create_test_zipline(
**self.zipline_test_config
+2 -3
View File
@@ -72,7 +72,7 @@ class FinanceTestCase(TestCase):
@timed(DEFAULT_TIMEOUT)
def test_trading_environment(self):
benchmark_returns, treasury_curves = \
factory.load_market_data()
factory.load_market_data()
env = TradingEnvironment(
benchmark_returns,
@@ -270,8 +270,7 @@ class FinanceTestCase(TestCase):
order_date = start_date
for i in xrange(order_count):
order = ndict(
{
order = ndict({
'sid': sid,
'amount': order_amount * alternator ** i,
'dt': order_date
+3 -5
View File
@@ -30,7 +30,7 @@ class PerformanceTestCase(unittest.TestCase):
def setUp(self):
self.benchmark_returns, self.treasury_curves = \
factory.load_market_data()
factory.load_market_data()
for n in range(100):
@@ -127,8 +127,7 @@ check treasury and benchmark data in findb, and re-run the test."""
"last sale should be same as last trade. \
expected {exp} actual {act}".format(
exp=trades[-1]['price'],
act=pp.positions[1].last_sale_price
)
act=pp.positions[1].last_sale_price)
)
self.assertEqual(
@@ -446,8 +445,7 @@ shares in position"
pp.positions[1].last_sale_price,
trades[-1].price,
"should have a last sale of 12, got {val}".format(
val=pp.positions[1].last_sale_price
)
val=pp.positions[1].last_sale_price)
)
self.assertEqual(
+254 -40
View File
@@ -38,7 +38,7 @@ class Risk(unittest.TestCase):
year=2006, month=12, day=31, tzinfo=pytz.utc)
self.benchmark_returns, self.treasury_curves = \
factory.load_market_data()
factory.load_market_data()
self.trading_env = TradingEnvironment(
self.benchmark_returns,
@@ -768,46 +768,260 @@ class Risk(unittest.TestCase):
period_length=period_length,
start_date=start_date,
end=col[-1].end_date,
actual=len(col)
))
actual=len(col))
)
self.assert_month(start_date.month, col[-1].end_date.month)
self.assert_last_day(col[-1].end_date)
RETURNS = [
0.0093, -0.0193, 0.0351, 0.0396, 0.0338, -0.0211, 0.0389,
0.0326, -0.0137, -0.0411, -0.0032, 0.0149, 0.0133, 0.0348,
0.042, -0.0455, 0.0262, -0.0461, 0.0021, -0.0273, -0.0429,
0.0427, -0.0104, 0.0346, -0.0311, 0.0003, 0.0211, 0.0248,
-0.0215, 0.004, 0.0267, 0.0029, -0.0369, 0.0057, 0.0298,
-0.0179, -0.0361, -0.0401, -0.0123, -0.005, 0.0203, -0.041,
0.0011, 0.0118, 0.0103, -0.0184, -0.0437, 0.0411, -0.0242,
-0.0054, -0.0039, -0.0273, -0.0075, 0.0064, -0.0376, 0.0424,
0.0399, 0.019, 0.0236, -0.0284, -0.0341, 0.0266, 0.05,
0.0069, -0.0442, -0.016, 0.0173, 0.0348, -0.0404, -0.0068,
-0.0376, 0.0356, 0.0043, -0.0481, -0.0134, 0.0257, 0.0442,
0.0234, 0.0394, 0.0376, -0.0147, -0.0098, 0.0474, -0.0102,
0.0138, 0.0286, 0.0347, 0.0279, -0.0067, 0.0462, -0.0432,
0.0247, 0.0174, -0.0305, -0.0317, -0.0068, 0.0264, -0.0257,
-0.0328, 0.0092, 0.0288, -0.002, 0.0288, 0.028, -0.0093,
0.0178, -0.0365, -0.0086, -0.0133, -0.0309, 0.0473, -0.0149,
0.0378, -0.0316, -0.0292, -0.0453, -0.0451, 0.0093, 0.0397,
-0.0361, -0.0168, -0.0494, -0.0143, -0.0405, -0.0349, 0.0069,
0.0378, -0.0233, -0.0492, 0.018, -0.0386, 0.0339, 0.0119,
0.0454, 0.0118, -0.011, -0.0254, 0.0266, -0.0366, -0.0211,
0.0399, 0.0307, 0.035, -0.0402, 0.0304, -0.0031, 0.0256,
0.0134, -0.0019, -0.0235, -0.0058, -0.0117, 0.0051, -0.0451,
-0.0466, -0.0124, 0.0283, -0.0499, 0.0318, -0.0028, 0.0203,
0.005, 0.0085, 0.0048, 0.0277, 0.0159, -0.0149, 0.035,
0.0404, -0.01, 0.0377, 0.0302, 0.0046, -0.0328, -0.0469,
0.0071, -0.0382, -0.0214, 0.0429, 0.0145, -0.0279, -0.0172,
0.0423, 0.041, -0.0183, 0.0137, -0.0412, -0.0348, 0.0302,
0.0248, 0.0051, -0.0298, -0.0103, -0.0333, -0.0399, 0.0485,
-0.0166, 0.0384, 0.0259, -0.0163, 0.0357, 0.0308, -0.0386,
0.0481, -0.0446, -0.0282, -0.0037, 0.0202, 0.0216, 0.0113,
0.0194, 0.0392, 0.0016, 0.0268, -0.0155, -0.027, 0.02,
0.0216, -0.0009, 0.022, 0., 0.041, 0.0133, -0.0382,
0.0495, -0.0221, -0.0329, -0.0033, -0.0089, -0.0129, -0.0252,
0.048, -0.0307, -0.0357, 0.0033, -0.0412, -0.0407, 0.0455,
0.0159, -0.0051, -0.0274, -0.0213, 0.0361, 0.0051, -0.0378,
0.0084, 0.0066, -0.0103, -0.0037, 0.0478, -0.0278
]
0.0093,
-0.0193,
0.0351,
0.0396,
0.0338,
-0.0211,
0.0389,
0.0326,
-0.0137,
-0.0411,
-0.0032,
0.0149,
0.0133,
0.0348,
0.042,
-0.0455,
0.0262,
-0.0461,
0.0021,
-0.0273,
-0.0429,
0.0427,
-0.0104,
0.0346,
-0.0311,
0.0003,
0.0211,
0.0248,
-0.0215,
0.004,
0.0267,
0.0029,
-0.0369,
0.0057,
0.0298,
-0.0179,
-0.0361,
-0.0401,
-0.0123,
-0.005,
0.0203,
-0.041,
0.0011,
0.0118,
0.0103,
-0.0184,
-0.0437,
0.0411,
-0.0242,
-0.0054,
-0.0039,
-0.0273,
-0.0075,
0.0064,
-0.0376,
0.0424,
0.0399,
0.019,
0.0236,
-0.0284,
-0.0341,
0.0266,
0.05,
0.0069,
-0.0442,
-0.016,
0.0173,
0.0348,
-0.0404,
-0.0068,
-0.0376,
0.0356,
0.0043,
-0.0481,
-0.0134,
0.0257,
0.0442,
0.0234,
0.0394,
0.0376,
-0.0147,
-0.0098,
0.0474,
-0.0102,
0.0138,
0.0286,
0.0347,
0.0279,
-0.0067,
0.0462,
-0.0432,
0.0247,
0.0174,
-0.0305,
-0.0317,
-0.0068,
0.0264,
-0.0257,
-0.0328,
0.0092,
0.0288,
-0.002,
0.0288,
0.028,
-0.0093,
0.0178,
-0.0365,
-0.0086,
-0.0133,
-0.0309,
0.0473,
-0.0149,
0.0378,
-0.0316,
-0.0292,
-0.0453,
-0.0451,
0.0093,
0.0397,
-0.0361,
-0.0168,
-0.0494,
-0.0143,
-0.0405,
-0.0349,
0.0069,
0.0378,
-0.0233,
-0.0492,
0.018,
-0.0386,
0.0339,
0.0119,
0.0454,
0.0118,
-0.011,
-0.0254,
0.0266,
-0.0366,
-0.0211,
0.0399,
0.0307,
0.035,
-0.0402,
0.0304,
-0.0031,
0.0256,
0.0134,
-0.0019,
-0.0235,
-0.0058,
-0.0117,
0.0051,
-0.0451,
-0.0466,
-0.0124,
0.0283,
-0.0499,
0.0318,
-0.0028,
0.0203,
0.005,
0.0085,
0.0048,
0.0277,
0.0159,
-0.0149,
0.035,
0.0404,
-0.01,
0.0377,
0.0302,
0.0046,
-0.0328,
-0.0469,
0.0071,
-0.0382,
-0.0214,
0.0429,
0.0145,
-0.0279,
-0.0172,
0.0423,
0.041,
-0.0183,
0.0137,
-0.0412,
-0.0348,
0.0302,
0.0248,
0.0051,
-0.0298,
-0.0103,
-0.0333,
-0.0399,
0.0485,
-0.0166,
0.0384,
0.0259,
-0.0163,
0.0357,
0.0308,
-0.0386,
0.0481,
-0.0446,
-0.0282,
-0.0037,
0.0202,
0.0216,
0.0113,
0.0194,
0.0392,
0.0016,
0.0268,
-0.0155,
-0.027,
0.02,
0.0216,
-0.0009,
0.022,
0.0,
0.041,
0.0133,
-0.0382,
0.0495,
-0.0221,
-0.0329,
-0.0033,
-0.0089,
-0.0129,
-0.0252,
0.048,
-0.0307,
-0.0357,
0.0033,
-0.0412,
-0.0407,
0.0455,
0.0159,
-0.0051,
-0.0274,
-0.0213,
0.0361,
0.0051,
-0.0378,
0.0084,
0.0066,
-0.0103,
-0.0037,
0.0478,
-0.0278]
+3 -3
View File
@@ -44,7 +44,7 @@ class RiskCompareIterativeToBatch(unittest.TestCase):
self.end_date = datetime.datetime(
year=2006, month=12, day=31, tzinfo=pytz.utc)
self.benchmark_returns, self.treasury_curves = \
factory.load_market_data()
factory.load_market_data()
self.trading_env = TradingEnvironment(
self.benchmark_returns,
@@ -115,8 +115,8 @@ class RiskCompareIterativeToBatch(unittest.TestCase):
self.assertEqual(set(risk_original_dict.keys()),
set(risk_refactor_dict.keys()))
err_msg_format = \
"In update step {iter}: {measure} should be {truth} but is {returned}!"
err_msg_format = """\
"In update step {iter}: {measure} should be {truth} but is {returned}!"""
for measure in risk_original_dict.iterkeys():
if measure == 'max_drawdown':
+1 -1
View File
@@ -35,4 +35,4 @@ class TestDataFrameSource(TestCase):
_, df = factory.create_test_df_source()
source = DataFrameSource(df, sids=[0])
assert 1 not in [event.sid for event in source], \
"DataFrameSource should only stream selected sid 0, not sid 1."
"DataFrameSource should only stream selected sid 0, not sid 1."
+1 -1
View File
@@ -294,7 +294,7 @@ class FinanceTransformsTestCase(TestCase):
np.std([10.0, 15.0], ddof=1),
np.std([10.0, 15.0, 13.0], ddof=1),
np.std([15.0, 13.0, 12.0], ddof=1),
]
]
# np has odd rounding behavior, cf.
# http://docs.scipy.org/doc/np/reference/generated/np.std.html