Skip to content

Commit

Permalink
Test mixing array and scalar operations
Browse files Browse the repository at this point in the history
  • Loading branch information
SamStudio8 committed Aug 26, 2014
1 parent bbaa035 commit 6bb84e2
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions tests/test_frame.py
Expand Up @@ -138,8 +138,34 @@ def test_transform_with_other_labels(self):
data[i, j] = (i+1)*(j+1)

transform_map = {
0: lambda x, f, i: x + f.get("owl-ratio", i), # Increase owl capacity
8: lambda x, f, i: np.mean(f.get("owl-ratio", None)) - x # Normalise the splines
0: lambda x, f, i: x + f.get(TEST_PARAMETERS[0], i), # Increase owl capacity
8: lambda x, f, i: np.mean(f.get(TEST_PARAMETERS[8], None)) - x # Normalise the splines
}
test_transformations = {}
for label_index in transform_map:
test_transformations[TEST_PARAMETERS[label_index]] = transform_map[label_index]

transformed_frame = frame.transform(test_transformations)
for transform in test_transformations:
for i, row in enumerate(frame):
for j, col in enumerate(frame[i]):
if j in transform_map:
self.assertEquals(transform_map[j](frame[i, j], frame, i),
transformed_frame[i, j])
else:
# Check nothing was transformed if it shouldn't have been
self.assertEquals(frame[i, j], transformed_frame[i, j])

def test_transform_mix_array_and_scalar_functionality(self):
# Initialise data frame with trivial data
data = np.zeros([ARBITRARY_ROWS, len(TEST_PARAMETERS)])
frame = DataFrame(data, TEST_PARAMETERS)
for i in range(0, ARBITRARY_ROWS):
for j in range(0, len(TEST_PARAMETERS)):
data[i, j] = (i+1)*(j+1)

transform_map = {
0: lambda x, f, i: f.get(TEST_PARAMETERS[0], i) + math.factorial(math.ceil(x/2)), # Factorialising owl capacity
}
test_transformations = {}
for label_index in transform_map:
Expand Down

0 comments on commit 6bb84e2

Please sign in to comment.