ENH: Allows Float64Adjustments to act on a range of columns

This commit is contained in:
llllllllll
2015-10-19 16:35:03 -04:00
parent c7ca0166cc
commit 0183d0a914
5 changed files with 115 additions and 55 deletions
+12 -12
View File
@@ -95,7 +95,7 @@ def _gen_multiplicative_adjustment_cases(dtype):
# Note that row indices are inclusive!
adjustments[1] = [
adjustment_type(0, 0, 0, dtype(2)),
adjustment_type(0, 0, 0, 0, dtype(2)),
]
buffer_as_of[1] = array([[2, 1, 1],
[1, 1, 1],
@@ -108,8 +108,8 @@ def _gen_multiplicative_adjustment_cases(dtype):
buffer_as_of[2] = buffer_as_of[1]
adjustments[3] = [
adjustment_type(1, 2, 1, dtype(3)),
adjustment_type(0, 1, 0, dtype(4)),
adjustment_type(1, 2, 1, 1, dtype(3)),
adjustment_type(0, 1, 0, 0, dtype(4)),
]
buffer_as_of[3] = array([[8, 1, 1],
[4, 3, 1],
@@ -119,7 +119,7 @@ def _gen_multiplicative_adjustment_cases(dtype):
[1, 1, 1]], dtype=dtype)
adjustments[4] = [
adjustment_type(0, 3, 2, dtype(5))
adjustment_type(0, 3, 2, 2, dtype(5))
]
buffer_as_of[4] = array([[8, 1, 5],
[4, 3, 5],
@@ -129,8 +129,8 @@ def _gen_multiplicative_adjustment_cases(dtype):
[1, 1, 1]], dtype=dtype)
adjustments[5] = [
adjustment_type(0, 4, 1, dtype(6)),
adjustment_type(2, 2, 2, dtype(7)),
adjustment_type(0, 4, 1, 1, dtype(6)),
adjustment_type(2, 2, 2, 2, dtype(7)),
]
buffer_as_of[5] = array([[8, 6, 5],
[4, 18, 5],
@@ -162,7 +162,7 @@ def _gen_overwrite_adjustment_cases(dtype):
# Note that row indices are inclusive!
adjustments[1] = [
adjustment_type(0, 0, 0, dtype(1)),
adjustment_type(0, 0, 0, 0, dtype(1)),
]
buffer_as_of[1] = array([[1, 2, 2],
[2, 2, 2],
@@ -175,8 +175,8 @@ def _gen_overwrite_adjustment_cases(dtype):
buffer_as_of[2] = buffer_as_of[1]
adjustments[3] = [
adjustment_type(1, 2, 1, dtype(3)),
adjustment_type(0, 1, 0, dtype(4)),
adjustment_type(1, 2, 1, 1, dtype(3)),
adjustment_type(0, 1, 0, 0, dtype(4)),
]
buffer_as_of[3] = array([[4, 2, 2],
[4, 3, 2],
@@ -186,7 +186,7 @@ def _gen_overwrite_adjustment_cases(dtype):
[2, 2, 2]], dtype=dtype)
adjustments[4] = [
adjustment_type(0, 3, 2, dtype(5))
adjustment_type(0, 3, 2, 2, dtype(5))
]
buffer_as_of[4] = array([[4, 2, 5],
[4, 3, 5],
@@ -196,8 +196,8 @@ def _gen_overwrite_adjustment_cases(dtype):
[2, 2, 2]], dtype=dtype)
adjustments[5] = [
adjustment_type(0, 4, 1, dtype(6)),
adjustment_type(2, 2, 2, dtype(7)),
adjustment_type(0, 4, 1, 1, dtype(6)),
adjustment_type(2, 2, 2, 2, dtype(7)),
]
buffer_as_of[5] = array([[4, 6, 5],
[4, 6, 5],
+28 -4
View File
@@ -189,14 +189,38 @@ class DataFrameLoaderTestCase(TestCase):
)
expected_formatted_adjustments = {
6: [
Float64Multiply(first_row=0, last_row=5, col=0, value=0.5),
Float64Add(first_row=0, last_row=5, col=1, value=1.0),
Float64Multiply(
first_row=0,
last_row=5,
first_col=0,
last_col=0,
value=0.5,
),
Float64Add(
first_row=0,
last_row=5,
first_col=1,
last_col=1,
value=1.0,
),
],
7: [
Float64Add(first_row=5, last_row=6, col=1, value=1.0),
Float64Add(
first_row=5,
last_row=6,
first_col=1,
last_col=1,
value=1.0,
),
],
8: [
Float64Overwrite(first_row=6, last_row=7, col=2, value=99.0)
Float64Overwrite(
first_row=6,
last_row=7,
first_col=2,
last_col=2,
value=99.0,
)
],
}
self.assertEqual(formatted_adjustments, expected_formatted_adjustments)
@@ -337,7 +337,8 @@ class USEquityPricingLoaderTestCase(TestCase):
Float64Multiply(
first_row=0,
last_row=delta,
col=sid - 1,
first_col=sid - 1,
last_col=sid - 1,
value=ratio,
)
)
@@ -347,7 +348,8 @@ class USEquityPricingLoaderTestCase(TestCase):
Float64Multiply(
first_row=0,
last_row=delta,
col=sid - 1,
first_col=sid - 1,
last_col=sid - 1,
value=1.0 / ratio,
)
)