From 9fabf8e01bf45399b7ab70a6418e06a83dbcd1ef Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Mon, 26 Jan 2015 14:07:37 -0500 Subject: [PATCH] Added map snippet. --- core/functions.ipynb | 10 ++++++++-- core/tests/test_transform_util.py | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/functions.ipynb b/core/functions.ipynb index 8165934..39e14da 100644 --- a/core/functions.ipynb +++ b/core/functions.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:8c91cadf8bbcbcdd5a60fc0a89e964b846a6f5328eaa57d57afbaedda06ad3ca" + "signature": "sha256:93f08d982c73b7b50d2c679984dc25a00cc198f32a1a82269c2c119da5d0e26e" }, "nbformat": 3, "nbformat_minor": 0, @@ -108,6 +108,11 @@ " \n", " def test_remove_punctuation(self):\n", " assert_equal(TransformUtil.remove_punctuation('!#?'), '')\n", + " \n", + " def test_map_remove_punctuation(self):\n", + " # Map applies a function to a collection\n", + " output = map(TransformUtil.remove_punctuation, self.states)\n", + " assert_equal('!#?' not in output, True)\n", "\n", " def test_clean_strings(self):\n", " clean_ops = [str.strip, TransformUtil.remove_punctuation, str.title] \n", @@ -141,10 +146,11 @@ "stream": "stdout", "text": [ "core.tests.test_transform_util.TestTransformUtil.test_clean_strings ... ok\r\n", + "core.tests.test_transform_util.TestTransformUtil.test_map_remove_punctuation ... ok\r\n", "core.tests.test_transform_util.TestTransformUtil.test_remove_punctuation ... ok\r\n", "\r\n", "----------------------------------------------------------------------\r\n", - "Ran 2 tests in 0.001s\r\n", + "Ran 3 tests in 0.002s\r\n", "\r\n", "OK\r\n" ] diff --git a/core/tests/test_transform_util.py b/core/tests/test_transform_util.py index b21bd2d..312afb9 100644 --- a/core/tests/test_transform_util.py +++ b/core/tests/test_transform_util.py @@ -17,6 +17,10 @@ class TestTransformUtil(): def test_remove_punctuation(self): assert_equal(TransformUtil.remove_punctuation('!#?'), '') + + def test_map_remove_punctuation(self): + output = map(TransformUtil.remove_punctuation, self.states) + assert_equal('!#?' not in output, True) def test_clean_strings(self): clean_ops = [str.strip, TransformUtil.remove_punctuation, str.title]