You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ro...@apache.org on 2017/10/12 22:54:47 UTC

[11/18] beam git commit: Change the xxx_todo_changeme[x]s to reasonable values

Change the xxx_todo_changeme[x]s to reasonable values


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/a795e545
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/a795e545
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/a795e545

Branch: refs/heads/master
Commit: a795e545157d20099c82970e4e2c302aa151413b
Parents: fe0dc2e
Author: Holden Karau <ho...@us.ibm.com>
Authored: Wed Sep 6 16:15:10 2017 -0700
Committer: Robert Bradshaw <ro...@gmail.com>
Committed: Thu Oct 12 15:50:09 2017 -0700

----------------------------------------------------------------------
 sdks/python/apache_beam/examples/complete/tfidf.py      | 12 ++++++------
 sdks/python/apache_beam/examples/snippets/snippets.py   |  4 ++--
 .../apache_beam/examples/snippets/snippets_test.py      |  8 ++++----
 sdks/python/apache_beam/transforms/combiners.py         |  8 ++++----
 sdks/python/apache_beam/transforms/ptransform_test.py   |  8 ++++----
 sdks/python/apache_beam/transforms/util.py              |  8 ++++----
 .../apache_beam/typehints/trivial_inference_test.py     |  4 ++--
 .../python/apache_beam/typehints/typed_pipeline_test.py | 12 ++++++------
 8 files changed, 32 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/a795e545/sdks/python/apache_beam/examples/complete/tfidf.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/examples/complete/tfidf.py b/sdks/python/apache_beam/examples/complete/tfidf.py
index 55404df..065e4b3 100644
--- a/sdks/python/apache_beam/examples/complete/tfidf.py
+++ b/sdks/python/apache_beam/examples/complete/tfidf.py
@@ -68,8 +68,8 @@ class TfIdf(beam.PTransform):
     # Create a collection of pairs mapping a URI to each of the words
     # in the document associated with that that URI.
 
-    def split_into_words(xxx_todo_changeme):
-      (uri, line) = xxx_todo_changeme
+    def split_into_words(uri_line):
+      (uri, line) = uri_line
       return [(uri, w.lower()) for w in re.findall(r'[A-Za-z\']+', line)]
 
     uri_to_words = (
@@ -128,8 +128,8 @@ class TfIdf(beam.PTransform):
     # that word occurs in the document divided by the total number of words in
     # the document.
 
-    def compute_term_frequency(xxx_todo_changeme1):
-      (uri, count_and_total) = xxx_todo_changeme1
+    def compute_term_frequency(uri_count_and_total):
+      (uri, count_and_total) = uri_count_and_total
       word_and_count = count_and_total['word counts']
       # We have an iterable for one element that we want extracted.
       [word_total] = count_and_total['word totals']
@@ -169,8 +169,8 @@ class TfIdf(beam.PTransform):
     # basic version that is the term frequency divided by the log of the
     # document frequency.
 
-    def compute_tf_idf(xxx_todo_changeme2):
-      (word, tf_and_df) = xxx_todo_changeme2
+    def compute_tf_idf(word_tf_and_df):
+      (word, tf_and_df) = word_tf_and_df
       [docf] = tf_and_df['df']
       for uri, tf in tf_and_df['tf']:
         yield word, (uri, tf * math.log(1 / docf))

http://git-wip-us.apache.org/repos/asf/beam/blob/a795e545/sdks/python/apache_beam/examples/snippets/snippets.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/examples/snippets/snippets.py b/sdks/python/apache_beam/examples/snippets/snippets.py
index 10080c9..01118b3 100644
--- a/sdks/python/apache_beam/examples/snippets/snippets.py
+++ b/sdks/python/apache_beam/examples/snippets/snippets.py
@@ -1171,8 +1171,8 @@ def model_co_group_by_key_tuple(email_list, phone_list, output_path):
     results = ({'emails': emails_pcoll, 'phones': phones_pcoll}
                | beam.CoGroupByKey())
 
-    def join_info(xxx_todo_changeme):
-      (name, info) = xxx_todo_changeme
+    def join_info(name_info):
+      (name, info) = name_info
       return '%s; %s; %s' %\
         (name, sorted(info['emails']), sorted(info['phones']))
 

http://git-wip-us.apache.org/repos/asf/beam/blob/a795e545/sdks/python/apache_beam/examples/snippets/snippets_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/examples/snippets/snippets_test.py b/sdks/python/apache_beam/examples/snippets/snippets_test.py
index 8a9695d..8f88ab9 100644
--- a/sdks/python/apache_beam/examples/snippets/snippets_test.py
+++ b/sdks/python/apache_beam/examples/snippets/snippets_test.py
@@ -882,16 +882,16 @@ class CombineTest(unittest.TestCase):
       def create_accumulator(self):
         return (0.0, 0)
 
-      def add_input(self, xxx_todo_changeme, input):
-        (sum, count) = xxx_todo_changeme
+      def add_input(self, sum_count, input):
+        (sum, count) = sum_count
         return sum + input, count + 1
 
       def merge_accumulators(self, accumulators):
         sums, counts = zip(*accumulators)
         return sum(sums), sum(counts)
 
-      def extract_output(self, xxx_todo_changeme1):
-        (sum, count) = xxx_todo_changeme1
+      def extract_output(self, sum_count):
+        (sum, count) = sum_count
         return sum / count if count else float('NaN')
     # [END combine_custom_average_define]
     # [START combine_custom_average_execute]

http://git-wip-us.apache.org/repos/asf/beam/blob/a795e545/sdks/python/apache_beam/transforms/combiners.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/combiners.py b/sdks/python/apache_beam/transforms/combiners.py
index 3348790..ce5e942 100644
--- a/sdks/python/apache_beam/transforms/combiners.py
+++ b/sdks/python/apache_beam/transforms/combiners.py
@@ -77,16 +77,16 @@ class MeanCombineFn(core.CombineFn):
   def create_accumulator(self):
     return (0, 0)
 
-  def add_input(self, xxx_todo_changeme, element):
-    (sum_, count) = xxx_todo_changeme
+  def add_input(self, sum_count, element):
+    (sum_, count) = sum_count
     return sum_ + element, count + 1
 
   def merge_accumulators(self, accumulators):
     sums, counts = zip(*accumulators)
     return sum(sums), sum(counts)
 
-  def extract_output(self, xxx_todo_changeme1):
-    (sum_, count) = xxx_todo_changeme1
+  def extract_output(self, sum_count):
+    (sum_, count) = sum_count
     if count == 0:
       return float('NaN')
     return sum_ / float(count)

http://git-wip-us.apache.org/repos/asf/beam/blob/a795e545/sdks/python/apache_beam/transforms/ptransform_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/ptransform_test.py b/sdks/python/apache_beam/transforms/ptransform_test.py
index 2f2734d..0d2bb7a 100644
--- a/sdks/python/apache_beam/transforms/ptransform_test.py
+++ b/sdks/python/apache_beam/transforms/ptransform_test.py
@@ -355,16 +355,16 @@ class PTransformTest(unittest.TestCase):
     def create_accumulator(self):
       return (0, 0)
 
-    def add_input(self, xxx_todo_changeme, element):
-      (sum_, count) = xxx_todo_changeme
+    def add_input(self, sum_count, element):
+      (sum_, count) = sum_count
       return sum_ + element, count + 1
 
     def merge_accumulators(self, accumulators):
       sums, counts = zip(*accumulators)
       return sum(sums), sum(counts)
 
-    def extract_output(self, xxx_todo_changeme3):
-      (sum_, count) = xxx_todo_changeme3
+    def extract_output(self, sum_count):
+      (sum_, count) = sum_count
       if not count:
         return float('nan')
       return sum_ / float(count)

http://git-wip-us.apache.org/repos/asf/beam/blob/a795e545/sdks/python/apache_beam/transforms/util.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/util.py b/sdks/python/apache_beam/transforms/util.py
index 4509ed4..6a7e269 100644
--- a/sdks/python/apache_beam/transforms/util.py
+++ b/sdks/python/apache_beam/transforms/util.py
@@ -98,16 +98,16 @@ class CoGroupByKey(PTransform):
   def expand(self, pcolls):
     """Performs CoGroupByKey on argument pcolls; see class docstring."""
     # For associating values in K-V pairs with the PCollections they came from.
-    def _pair_tag_with_value(xxx_todo_changeme, tag):
-      (key, value) = xxx_todo_changeme
+    def _pair_tag_with_value(k_v, tag):
+      (key, value) = k_v
       return (key, (tag, value))
 
     # Creates the key, value pairs for the output PCollection. Values are either
     # lists or dicts (per the class docstring), initialized by the result of
     # result_ctor(result_ctor_arg).
-    def _merge_tagged_vals_under_key(xxx_todo_changeme3, result_ctor,
+    def _merge_tagged_vals_under_key(k_grouped, result_ctor,
                                      result_ctor_arg):
-      (key, grouped) = xxx_todo_changeme3
+      (key, grouped) = k_grouped
       result_value = result_ctor(result_ctor_arg)
       for tag, value in grouped:
         result_value[tag].append(value)

http://git-wip-us.apache.org/repos/asf/beam/blob/a795e545/sdks/python/apache_beam/typehints/trivial_inference_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/typehints/trivial_inference_test.py b/sdks/python/apache_beam/typehints/trivial_inference_test.py
index 7b7b6a8..37b2258 100644
--- a/sdks/python/apache_beam/typehints/trivial_inference_test.py
+++ b/sdks/python/apache_beam/typehints/trivial_inference_test.py
@@ -44,8 +44,8 @@ class TrivialInferenceTest(unittest.TestCase):
         typehints.Tuple[str, int, float], lambda x: (x, 0, 1.0), [str])
 
   def testUnpack(self):
-    def reverse(xxx_todo_changeme):
-      (a, b) = xxx_todo_changeme
+    def reverse(a_b):
+      (a, b) = a_b
       return b, a
     any_tuple = typehints.Tuple[typehints.Any, typehints.Any]
     self.assertReturnType(

http://git-wip-us.apache.org/repos/asf/beam/blob/a795e545/sdks/python/apache_beam/typehints/typed_pipeline_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/typehints/typed_pipeline_test.py b/sdks/python/apache_beam/typehints/typed_pipeline_test.py
index 501715b..2581457 100644
--- a/sdks/python/apache_beam/typehints/typed_pipeline_test.py
+++ b/sdks/python/apache_beam/typehints/typed_pipeline_test.py
@@ -103,16 +103,16 @@ class NativeTypesTest(unittest.TestCase):
 
   def test_good_main_input(self):
     @typehints.with_input_types(typing.Tuple[str, int])
-    def munge(xxx_todo_changeme):
-      (s, i) = xxx_todo_changeme
+    def munge(s_i):
+      (s, i) = s_i
       return (s + 's', i * 2)
     result = [('apple', 5), ('pear', 3)] | beam.Map(munge)
     self.assertEqual([('apples', 10), ('pears', 6)], sorted(result))
 
   def test_bad_main_input(self):
     @typehints.with_input_types(typing.Tuple[str, str])
-    def munge(xxx_todo_changeme1):
-      (s, i) = xxx_todo_changeme1
+    def munge(s_i):
+      (s, i) = s_i
       return (s + 's', i * 2)
     with self.assertRaises(typehints.TypeCheckError):
       [('apple', 5), ('pear', 3)] | beam.Map(munge)
@@ -120,8 +120,8 @@ class NativeTypesTest(unittest.TestCase):
   def test_bad_main_output(self):
     @typehints.with_input_types(typing.Tuple[int, int])
     @typehints.with_output_types(typing.Tuple[str, str])
-    def munge(xxx_todo_changeme2):
-      (a, b) = xxx_todo_changeme2
+    def munge(a_b):
+      (a, b) = a_b
       return (str(a), str(b))
     with self.assertRaises(typehints.TypeCheckError):
       [(5, 4), (3, 2)] | beam.Map(munge) | 'Again' >> beam.Map(munge)