def test_custom_average(self):
    pc = [2, 3, 5, 7]


    # [START combine_custom_average]
    class AverageFn(df.CombineFn):
      def create_accumulator(self):
        return (0.0, 0)
      def add_input(self, (sum, count), input):
        return sum + input, count + 1
      def merge_accumulators(self, accumulators):
        sums, counts = zip(*accumulators)
        return sum(sums), sum(counts)
      def extract_output(self, (sum, count)):
        return count / sum if count else float('NaN')
    average = pc | df.CombineGlobally(AverageFn())
    # [END combine_custom_average]
    self.assertEqual([4.25], average)
dataset/ETHPy150Open GoogleCloudPlatform/DataflowPythonSDK/google/cloud/dataflow/examples/snippets/snippets_test.py/CombineTest.test_custom_average/swapped operands of `/`