Пример #1
0
 def test_print_2(self):
     """ tests printing movie_id
     """
     rating = 2043
     writer = StringIO()
     netflix_print(writer, rating)
     self.assertEqual(writer.getvalue(), "2043:\n")
Пример #2
0
 def test_print_1(self):
     """
     Prints a movie id
     """
     temp1 = StringIO()
     netflix_print(1, 1, temp1)
     self.assertEqual(temp1.getvalue(), "1:\n")
Пример #3
0
 def test_print_1(self):
     """ tests printing rating
     """
     rating = 1.0
     writer = StringIO()
     netflix_print(writer, rating)
     self.assertEqual(writer.getvalue(), "1.0\n")
 def test_netflix_print_3(self):
     """ netflix_print_3 """
     input_dic = {1: {1001, 1002, 1003, 1004, 1005}}
     store_rating = {1: {3.5, 3.6}}
     writer = StringIO()
     netflix_print(writer, input_dic, store_rating)
     self.assertEqual(writer.getvalue(), "1:\n1001 3.5\n1002 3.6\n")
Пример #5
0
 def test_print_3(self):
     """
     Prints a customer rating
     """
     temp1 = StringIO()
     netflix_print(3.4, 0, temp1)
     self.assertEqual(temp1.getvalue(), "3.4\n")
Пример #6
0
 def test_print_1(self):
     """ tests printing rating
     """
     rating = 1.0
     writer = StringIO()
     netflix_print(writer, rating)
     self.assertEqual(writer.getvalue(), "1.0\n")
 def test_netflix_print_3(self):
     w = StringIO.StringIO()
     ans = {1: [1,2,3],
            2: [4,5],
            6: [2] }
     netflix_print(w, ans, [6,2,1])
     self.assert_(w.getvalue() == "6:\n2\n2:\n4\n5\n1:\n1\n2\n3\n")
Пример #8
0
 def test_print_3(self):
     """ tests printing RMSE
     """
     rating = "RMSE: 0.93"
     writer = StringIO()
     netflix_print(writer, rating)
     self.assertEqual(writer.getvalue(), "RMSE: 0.93\n")
Пример #9
0
 def test_print_2(self):
     """ tests printing movie_id
     """
     rating = 2043
     writer = StringIO()
     netflix_print(writer, rating)
     self.assertEqual(writer.getvalue(), "2043:\n")
 def test_print3(self):
     """
     Test printing RMSE format
     """
     writer = StringIO()
     netflix_print(writer, 0.9722263548654, "RMSE")
     self.assertEqual(writer.getvalue(), "RMSE: 0.97\n")
 def test_print2(self):
     """
     Test printing rating guess format
     """
     writer = StringIO()
     netflix_print(writer, 3.721318657451, "Rating Guess")
     self.assertEqual(writer.getvalue(), "3.7\n")
 def test_print_1(self):
     w = StringIO()
     i = {1: [1, 2, 3]}
     p = {(3, 1): 3, (1, 1): 2, (2, 1): 1}
     r = 0
     netflix_print(i, p, r, w)
     self.assertEqual(w.getvalue(), "1:\n2.0\n1.0\n3.0\nRMSE: 0.00\n")
Пример #13
0
 def test_print_1(self):
     """
         Tests print to see if prints a movie line correctly
     """
     writer = StringIO()
     netflix_print(writer, True, 2153330)
     self.assertEqual(writer.getvalue(), "2153330:\n")
Пример #14
0
 def test_print_3(self):
     """
         Tests print to see if prints a prediction line correctly
     """
     writer = StringIO()
     netflix_print(writer, False, 3.59648694869)
     self.assertEqual(writer.getvalue(), "3.6\n")
Пример #15
0
 def test_print_3(self):
     """ tests printing RMSE
     """
     rating = "RMSE: 0.93"
     writer = StringIO()
     netflix_print(writer, rating)
     self.assertEqual(writer.getvalue(), "RMSE: 0.93\n")
 def test_print1(self):
     """
     Test printing movie format
     """
     writer = StringIO()
     netflix_print(writer, "6478:\n", "Movie")
     self.assertEqual(writer.getvalue(), "6478:\n")
Пример #17
0
    def test_netflix_print_0(self):
        w = StringIO()
        movie_id = 1
        customer_ids = [1, 2, 3]
        ratings = [3, 3, 3]

        netflix_print(movie_id, customer_ids, ratings, w)
        self.assertEqual(w.getvalue(), "1:\n3.0\n3.0\n3.0\n")
 def test_print_2(self):
     w = StringIO()
     i = {1: [1, 2], 2: [1, 2]}
     p = {(1, 2): 4.1, (1, 1): 3, (2, 1): 1.89, (2, 2): 3}
     r = 0.63
     netflix_print(i, p, r, w)
     self.assertEqual(w.getvalue(),
                      "1:\n3.0\n1.9\n2:\n4.1\n3.0\nRMSE: 0.63\n")
 def test_netflix_print_5(self):
     """
     Test 5 netflix_print to see if the
     rmse is formatted correctly
     """
     write = StringIO()
     netflix_print(write, .9849846, 'rmse')
     self.assertEqual(write.getvalue(), 'RMSE: 0.98\n')
 def test_print_3(self):
     w = StringIO()
     i = {1: [1], 2: [1], 3: [1]}
     p = {(1, 2): 2, (1, 3): 2.25, (1, 1): 0.76}
     r = 0.93
     netflix_print(i, p, r, w)
     self.assertEqual(w.getvalue(),
                      "1:\n0.8\n2:\n2.0\n3:\n2.2\nRMSE: 0.93\n")
 def test_netflix_print_2(self):
     """
     Test 2 netflix_print to see if
     movies are formatted correctly
     """
     write = StringIO()
     netflix_print(write, '199999:', 'movie')
     self.assertEqual(write.getvalue(), '199999:\n')
Пример #22
0
 def test_print_4(self):
     '''
         Testing the netflix_print() function by passing a StringIO
         object to write to instead of standard out.
     '''
     write_io = StringIO()
     netflix_print(write_io, 21, [1, 5])
     self.assertEqual(write_io.getvalue(), "21:\n1\n5\n")
 def test_netflix_print_3(self):
     """
     Test 3 netflix_print to see if
     ratings are formatted correctly
     """
     write = StringIO()
     netflix_print(write, 3.5456465, 'rating')
     self.assertEqual(write.getvalue(), '3.5\n')
 def test_netflix_print_2(self):
     """ netflix_print_2 """
     input_dic = {1: {1000, 1001, 1002, 1003}}
     store_rating = {1: {3.4, 3.5, 3.6, 3.7}}
     writer = StringIO()
     netflix_print(writer, input_dic, store_rating)
     self.assertEqual(writer.getvalue(),
                      "1:\n1000 3.6\n1001 3.5\n1002 3.7\n1003 3.4\n")
 def test_netflix_print_1(self):
     """ netflix_print_1 """
     input_dic = {1: {2001}, 2: {2002}, 3: {2003}}
     store_rating = {1: {3.5}, 2: {3.6}, 3: {3.7}}
     writer = StringIO()
     netflix_print(writer, input_dic, store_rating)
     self.assertEqual(writer.getvalue(),
                      "1:\n2001 3.5\n2:\n2002 3.6\n3:\n2003 3.7\n")
Пример #26
0
    def test_netflix_print_1(self):
        w = StringIO()
        movie_id = 7
        customer_ids = [3, 2, 1]
        ratings = [5.1, 4.2, 3.3]

        netflix_print(movie_id, customer_ids, ratings, w)
        self.assertEqual(w.getvalue(), "7:\n5.1\n4.2\n3.3\n")
 def test_netflix_print_4(self):
     """
     Test 4 netflix_print to see if
     ratings are formatted correctly
     """
     write = StringIO()
     netflix_print(write, 1, 'rating')
     self.assertEqual(write.getvalue(), '1.0\n')
 def test_netflix_print_6(self):
     """
     Test 6 netflix_print to see if the
     rmse is formatted correctly
     """
     write = StringIO()
     # NOTE: We round instead of truncate. Is this permissable?
     netflix_print(write, .555555, 'rmse')
     self.assertEqual(write.getvalue(), 'RMSE: 0.56\n')
Пример #29
0
 def test_print_0(self):
     """ Test the printing functionallity in Netflix.py """
     writer = StringIO()
     netflix_print(writer, "1", {
         30878: 1,
         2647871: 2,
         123744: 3
     }, [30878, 2647871, 123744])
     self.assertEqual(writer.getvalue(), "1:\n1\n2\n3\n")
Пример #30
0
 def test_print_1(self):
     """ Test the printing functionallity in Netflix.py """
     writer = StringIO()
     netflix_print(writer, "150", {
         123: 5,
         456: 2,
         938: 1,
         9999: 0
     }, [9999, 938, 456, 123])
     self.assertEqual(writer.getvalue(), "150:\n0\n1\n2\n5\n")
Пример #31
0
 def test_print_4 (self) :
     w = StringIO()
     netflix_print(w, 1904905)
     self.assertEqual(w.getvalue(), "1904905 \n")
 def test_netflix_print_1 (self) :
     w = StringIO.StringIO()
     netflix_print(w, "1")
     self.assert_(w.getvalue() == "1\n")
Пример #33
0
 def test_print_3 (self) :
     w = StringIO()
     netflix_print(w, 3.7)
     self.assertEqual(w.getvalue(), "3.7\n")
Пример #34
0
 def test_print_3 (self): #no predictions
     w = StringIO()
     print_data = ["2043:"]
     rms_error = .8501
     netflix_print(w, print_data, rms_error)
     self.assertEqual(w.getvalue(), "2043:\nRMSE:0.8501\n")
Пример #35
0
 def test_print_1 (self) :
     w = StringIO()
     print_data = ["2043:", 1.5, "4014:", 2.5] #two sets
     rms_error = .9999
     netflix_print(w, print_data, rms_error)
     self.assertEqual(w.getvalue(), "2043:\n1.5\n4014:\n2.5\nRMSE:0.9999\n")
Пример #36
0
 def test_print_1 (self) :
     w = StringIO()
     predictions_dict = OrderedDict([(2043, [3.4, 4.1, 1.9])])
     netflix_print(w, predictions_dict)
     self.assertEqual(w.getvalue(), "2043:\n3.4\n4.1\n1.9\n")
 def test_print_2 (self) :
     output_stream = StringIO()
     output_dictionary = {1 : (1, 2, 3), 2 : (1, 2, 3)}
     rmse_value = 1
     netflix_print(output_stream, output_dictionary, rmse_value)
     self.assertEqual("1:\n1.0\n2.0\n3.0\n2:\n1.0\n2.0\n3.0\nRMSE: 1.00\n", output_stream.getvalue())
Пример #38
0
 def test_print_3(self):
     w = StringIO()
     netflix_print(w, 90, [])
     self.assertEqual(w.getvalue(), "90:\n")
 def test_print_3 (self) :
     output_stream = StringIO()
     output_dictionary = {}
     rmse_value = 1
     netflix_print(output_stream, output_dictionary, rmse_value)
     self.assertEqual("RMSE: 1.00\n", output_stream.getvalue())
Пример #40
0
 def test_print_1 (self) :
     w = StringIO()
     netflix_print(w, 1.9)
     self.assertEqual(w.getvalue(), "1.9 \n")
Пример #41
0
 def test_print_5 (self) :
     w = StringIO()
     netflix_print(w, 9293277)
     self.assertEqual(w.getvalue(), "9293277\n")
Пример #42
0
 def test_print_1 (self) :
     w = StringIO()
     netflix_print(w, 3423)
     self.assertEqual(w.getvalue(), "3423\n")
Пример #43
0
 def test_print_2 (self) :
     w = StringIO()
     netflix_print(w, 92838)
     self.assertEqual(w.getvalue(), "92838\n")
 def test_netflix_print_2 (self) :
     w = StringIO.StringIO()
     netflix_print(w, 4)
     self.assert_(w.getvalue() == "4\n")
Пример #45
0
 def test_print_2(self):
     """ Test the printing functionallity in Netflix.py """
     writer = StringIO()
     netflix_print(writer, "5", {53: 3, 827: 2, 128: 4}, [827, 128, 53])
     self.assertEqual(writer.getvalue(), "5:\n2\n4\n3\n")
Пример #46
0
 def test_print_1(self):
     w = StringIO()
     netflix_print(w, LineType.movie, 111)
     self.assertEqual(w.getvalue(), "111:\n")
Пример #47
0
 def test_print_3 (self) :
     w = StringIO()
     predictions_dict = OrderedDict([(2043, [3.4, 4.1, 1.9]), (10851, [4.3, 1.4, 2.8]), (3367, [3.2, 1.1, 4.5])])
     netflix_print(w, predictions_dict)
     self.assertEqual(w.getvalue(), "2043:\n3.4\n4.1\n1.9\n10851:\n4.3\n1.4\n2.8\n3367:\n3.2\n1.1\n4.5\n")
Пример #48
0
 def test_print_2(self):
     w = StringIO()
     netflix_print(w, LineType.user, 4.31)
     self.assertEqual(w.getvalue(), "4.3\n")
Пример #49
0
 def test_print_2 (self): #one set
     w = StringIO()
     print_data = ["2043:", 1.5, 4.5]
     rms_error = .8501
     netflix_print(w, print_data, rms_error)
     self.assertEqual(w.getvalue(), "2043:\n1.5\n4.5\nRMSE:0.8501\n")
 def test_print3 (self) :
     w = StringIO()
     netflix_print(w, ["1:","17770:",2])
     self.assertEqual(w.getvalue(), "1:\n17770:\n2\n")
Пример #51
0
 def test_print_4 (self) : #no movie number
     w = StringIO()
     print_data = [1.5, 4.5]
     rms_error = .8501
     netflix_print(w, print_data, rms_error)
     self.assertEqual(w.getvalue(), "1.5\n4.5\nRMSE:0.8501\n")
 def test_print2 (self) :
     w = StringIO()
     netflix_print(w, ["1:",3,4])
     self.assertEqual(w.getvalue(), "1:\n3\n4\n")
 def test_netflix_print_2(self):
     w = StringIO.StringIO()
     ans = {}
     netflix_print(w, ans, [])
     self.assert_(w.getvalue() == "")
Пример #54
0
 def test_print_2 (self) :
     w = StringIO()
     netflix_print(w, 2.79)
     self.assertEqual(w.getvalue(), "2.79 \n")
Пример #55
0
 def test_print_1 (self)	:
 	w = StringIO()
 	netflix_print(w, 4.279008432960954)
 	self.assertEqual(w.getvalue(), "4.279008432960954\n")
Пример #56
0
 def test_print_3 (self) :
     w = StringIO()
     netflix_print(w, 11134234)
     self.assertEqual(w.getvalue(), "11134234\n")
Пример #57
0
 def test_print_2 (self)	:
 	w = StringIO()
 	netflix_print(w, 3.4756)
 	self.assertEqual(w.getvalue(), "3.4756\n")
 def test_netflix_print_3 (self) :
     w = StringIO.StringIO()
     netflix_print(w, "123412:")
     self.assert_(w.getvalue() == "123412:\n")