From 147b2e34a30dfe4ee51b58c5c494bb6a057c117c Mon Sep 17 00:00:00 2001 From: Sam Nicholls Date: Tue, 26 Aug 2014 18:27:34 +0100 Subject: [PATCH] CHANGELOG --- CHANGELOG.rst | 5 +++++ tests/test_frame.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 02f15e1..be0f115 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,11 @@ History * Introduced :class:`frontier.frame.DataFrame` which extends numpy's `ndarray`, that will now be returned from :class:`frontier.frontier.Statplexer`'s API functions that return read in data. + * :func:`frontier.frame.DataFrame.transform` takes a dictionary mapping + labels to a lambda function that will be applied to the corresponding + column of values in the DataFrame. + * :func:`frontier.frame.DataFrame.add_observation` stacks a new observation + array to the DataFrame. * `_test_variance` function of the `Statplexer` will now test the range of variance magnitudes across each parameter of read in data, issuing a warning and producing a table if a magnitude difference greater than ±1 is discovered. diff --git a/tests/test_frame.py b/tests/test_frame.py index cf6c55b..5cf1ceb 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -119,7 +119,15 @@ def test_transform(self): # Check nothing was transformed self.assertEquals(frame[i, j], transformed_frame[i, j]) + def test_bad_transform(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) + self.assertRaises(Exception, frame.transform, { TEST_PARAMETERS[0]: "hoot" }) if __name__ == '__main__': unittest.main()