Esempio n. 1
0
    def test_output_multiple(self):
        outputs = [["key1", "value1"], ["key2", "value"], ["key3", "value3"]]
        
        for o in outputs:
            output(o[0], o[1], output_io=self.out)

        actual_output = self.get_value().split("\n")
        self.assertListEqual(["\t".join(expect) for expect in outputs], actual_output)
Esempio n. 2
0
#!/usr/bin/env python3
# encoding: utf-8
from __future__ import division
from util.stream_input import input_tab_key_json
from util.stream_output import output

summation = 0
count = 0
for key, count_dict in input_tab_key_json():
    summation += count_dict["summation"]
    count += count_dict["count"]

average = summation / count if not count == 0 else 0

output("result", str(average))
Esempio n. 3
0
#!/usr/bin/env python3
import json
import sys
from util.stream_output import output

# This file comes from GridSearch#CACHE_FILE_NAME
# It will no need to identify filename for future
f = open("cache/condition.txt")
condition = json.loads((list(f))[0])

for value in sys.stdin:
    for i in range(len(condition)):
        # distribute all data to all reducer
        output(str(i), value.replace("\r", "").replace("\n", ""))
Esempio n. 4
0
    def test_output_tab_no_output(self):
        output("", "", output_io=self.out)

        actual_output = self.get_value()
        self.assertEqual("\t", actual_output)
Esempio n. 5
0
    def test_output_tab_include_value(self):
        output("a", "b\tc", output_io=self.out)

        actual_output = self.get_value()
        self.assertEqual("a\tb\tc", actual_output)
Esempio n. 6
0
 def test_output(self):
     output("a", "b", output_io=self.out)
     
     actual_output = self.get_value()
     self.assertEqual("a\tb", actual_output)