示例#1
0
    def test_04(self):
        # Actors with Bacon number of 2
        n = 2
        expected = {1640, 1811, 2115, 2283, 2561, 2878, 3085, 4025, 4252, 4765,
                    6541, 9827, 11317, 14104, 16927, 16935, 19225, 33668, 66785,
                    90659, 183201, 550521, 1059002, 1059003, 1059004, 1059005,
                    1059006, 1059007, 1232763}

        first_result = lab.get_actors_with_bacon_number(self.data, n)
        self.assertTrue(isinstance(first_result, set))
        self.assertEqual(first_result, expected)

        second_result = lab.get_actors_with_bacon_number(self.data, n)
        self.assertTrue(isinstance(second_result, set))
        self.assertEqual(second_result, expected)
 def test_02(self):
     # Actors with Bacon number of 2
     n = 2
     expected = {1640}
     result = lab.get_actors_with_bacon_number(self.tiny, n)
     self.assertTrue(isinstance(result, set))
     self.assertEqual(result, expected)
示例#3
0
def run_test(input_data):
    running_time = time.time()

    # Demux to the correct function
    try:
        if input_data["function"] == "pair":
            result = lab.did_x_and_y_act_together(small_data,
                                                  input_data["actor_1"],
                                                  input_data["actor_2"])

        # Actors with a given bacon number
        elif input_data["function"] == "set":
            result = lab.get_actors_with_bacon_number(small_data,
                                                      input_data["n"])

        # Paths in a small database
        elif input_data["function"] == "path_small":
            result = lab.get_bacon_path(small_data, input_data["actor_id"])

        # Paths in a large database
        elif input_data["function"] == "path":
            result = lab.get_bacon_path(large_data, input_data["actor_id"])

        running_time = time.time() - running_time

        return (running_time, result)
    except Exception:
        return ('error', traceback.format_exc())
 def test_03(self):
     # Actors with Bacon number of 3
     n = 3
     expected = set()
     result = lab.get_actors_with_bacon_number(self.tiny, n)
     self.assertTrue(isinstance(result, set))
     self.assertEqual(result, expected)
 def test_01(self):
     # Actors with Bacon number of 1
     n = 1
     expected = {2876, 1532}
     result = lab.get_actors_with_bacon_number(self.tiny, n)
     self.assertTrue(isinstance(result, set))
     self.assertEqual(result, expected)
示例#6
0
文件: wrapper.py 项目: lasernite/6fop
def run_test(input_data):
	running_time = time.time()

	# Demux to the correct function
	try:
		if input_data["function"] == "pair":
			result = lab.did_x_and_y_act_together(small_data, input_data["actor_1"], input_data["actor_2"])

		# Actors with a given bacon number
		elif input_data["function"] == "set":
			result = lab.get_actors_with_bacon_number(small_data, input_data["n"])

		# Paths in a small database
		elif input_data["function"] == "path_small":
			result = lab.get_bacon_path(small_data, input_data["actor_id"])

		# Paths in a large database
		elif input_data["function"] == "path":
			result = lab.get_bacon_path(large_data, input_data["actor_id"])

		running_time = time.time() - running_time

	except ValueError as e:
		return e.message

	except:
		return traceback.format_exc()

	return running_time, result
 def test_00(self):
     # Actors with Bacon number of 0
     n = 0
     expected = {4724}
     result = lab.get_actors_with_bacon_number(self.tiny, n)
     print(result)
     self.assertTrue(isinstance(result, set))
     self.assertEqual(result, expected)
示例#8
0
    def test_05(self):
        # Actors with Bacon number of 3
        n = 3
        expected = {52, 1004, 1248, 2231, 2884, 4887, 8979, 10500, 12521,
                    14792, 14886, 15412, 16937, 17488, 19119, 19207, 19363,
                    20853, 25972, 27440, 37252, 37612, 38351, 44712, 46866,
                    46867, 48576, 60062, 75429, 83390, 85096, 93138, 94976,
                    109625, 113777, 122599, 126471, 136921, 141458, 141459,
                    141460, 141461, 141495, 146634, 168638, 314092, 349956,
                    558335, 572598, 572599, 572600, 572601, 572602, 572603,
                    583590, 931399, 933600, 1086299, 1086300, 1168416, 1184797,
                    1190297, 1190298, 1190299, 1190300}
        first_result = lab.get_actors_with_bacon_number(self.data, n)
        self.assertTrue(isinstance(first_result, set))
        self.assertEqual(first_result, expected)

        second_result = lab.get_actors_with_bacon_number(self.data, n)
        self.assertTrue(isinstance(second_result, set))
        self.assertEqual(second_result, expected)
示例#9
0
文件: test.py 项目: suhridgit/6.009
    def test_00(self):
        for i in [0,1,2]:
            expected = set()
            if i == 0:
                expected = {4724}
            elif i == 1:
                expected = {1532, 2876}
            elif i == 2:
                expected = {1640}

            result = lab.get_actors_with_bacon_number(self.data, i)
            self.assertEqual(result, expected)
示例#10
0
 def test_bacon_2(self):
     result = lab.get_actors_with_bacon_number(self.data,2)
     expected = {1640}
     self.assertEqual(result,expected)
示例#11
0
 def test_bacon_1(self):
     result = lab.get_actors_with_bacon_number(self.data,1)
     expected = {1532,2876}
     self.assertEqual(result,expected)
示例#12
0
 def test_04(self):
     expected = [1532, 2876]
     result = lab.get_actors_with_bacon_number(self.data, 1)
     self.assertEqual(expected, result)
示例#13
0
 def test_Bacon_number_1(self):
     self.assertEqual(lab.get_actors_with_bacon_number(self.data, 1),
                      {1532, 2876})
示例#14
0
 def test_case_3(self):
     """Bacon number is 1"""
     result = lab.get_actors_with_bacon_number(self.data, 1)
     expected = {1532, 2876}
     self.assertEqual(result, expected)
示例#15
0
def bacon_number(d):
    return lab.get_actors_with_bacon_number(small_data, d["n"])
示例#16
0
文件: wrapper.py 项目: lasernite/6fop
def bacon_number(d):
	return lab.get_actors_with_bacon_number(small_data, d["n"])
示例#17
0
 def test_05(self):
     expected = [1640]
     result = lab.get_actors_with_bacon_number(self.data, 2)
     self.assertEqual(expected, result)
示例#18
0
 def test_case_4(self):
     """Bacon number is 2"""
     result = lab.get_actors_with_bacon_number(self.data, 2)
     expected = {1640}
     self.assertEqual(result, expected)
示例#19
0
 def test_bacon_number_01(self):
     # Actors with Bacon number of 0
     n = 0
     expected = {4724}
     result = set(lab.get_actors_with_bacon_number(self.data, n))
     self.assertEqual(result, expected)
 def test_18(self):
     n = 2
     expected = {1640}
     first_result = lab.get_actors_with_bacon_number(self.data, n)
     self.assertTrue(isinstance(first_result, set))
     self.assertEqual(first_result, expected)
示例#21
0
 def test_bacon_number_02(self):
     # Actors with Bacon number of 1
     n = 1
     expected = {1532, 2876}
     result = set(lab.get_actors_with_bacon_number(self.data, n))
     self.assertEqual(result, expected)
示例#22
0
 def test_bacon_number_03(self):
     # Actors with Bacon number of 2
     n = 2
     expected = {1640}
     result = set(lab.get_actors_with_bacon_number(self.data, n))
     self.assertEqual(result, expected)
示例#23
0
 def test_Bacon_number_0(self):
     self.assertEqual(lab.get_actors_with_bacon_number(self.data, 0),
                      {4724})
示例#24
0
 def test_bacon_0(self):
     result = lab.get_actors_with_bacon_number(self.data,0)
     expected = {4724}
     self.assertEqual(result,expected)
示例#25
0
 def test_Bacon_number_2(self):
     self.assertEqual(lab.get_actors_with_bacon_number(self.data, 2),
                      {1640})
示例#26
0
 def test_03(self):
     expected = [4724]
     result = lab.get_actors_with_bacon_number(self.data, 0)
     self.assertEqual(expected, result)