def find_discrete_line_points2(self, matching_image, p1, p2, show):
     if show:
         print("finding discrete line point between ", p1, p2)
     mp = MatchingProblem(p1, p2, matching_image)
     sol = astar_search(mp)
     path = self.path_states(sol)
     return path
 def test_get_recom_info_matrix(self):
     my_problem = MatchingProblem(users, items, trans)
     result = my_problem.get_recom_info(3)['recom_dok_matrix'].toarray()
     
     expected = np.array([ [0, 0, 0, 0, 0, 1, 0, 0],
                           [0, 0, 0, 0, 0, 0, 0, 1],
                           [0, 0, 0, 0, 0, 0, 1, 0],
                           [0, 0, 0, 0, 0, 1, 0, 0],
                           [0, 0, 0, 0, 0, 0, 0, 1],
                           [0, 0, 0, 0, 0, 1, 0, 0],
                           [0, 0, 0, 0, 0, 1, 0, 0],
                           [0, 0, 0, 0, 0, 1, 0, 0],
                           [0, 0, 1, 0, 0, 0, 0, 0],
                           [0, 0, 0, 0, 0, 1, 0, 0]]).astype('int8')
                           
     self.assertTrue(np.array_equal(result, expected))
 def test_get_recom_info_summary(self):
     my_problem = MatchingProblem(users, items, trans)
     result = my_problem.get_recom_info(3)['recom_summary']
     expected = Counter({5: 6, 7: 2, 2: 1, 6: 1})
     self.assertDictEqual(result, expected)
 def test_get_recom(self):
     my_problem = MatchingProblem(users, items, trans)
     result = my_problem.get_recom(2, 3)
     expected = 6
     self.assertEqual(result, expected)
 def test_best_item(self):
     my_problem = MatchingProblem(users, items, trans)
     result = my_problem.best_item(np.array([7,9,4]))
     expected = 6
     self.assertEqual(result, expected)
 def test_get_nearest_neighbors(self):
     my_problem = MatchingProblem(users, items, trans)
     result = my_problem.get_nearest_neighbors(2, 3)
     expected = np.array([7, 9, 4])
     self.assertTrue(np.array_equal(result, expected))
 def test_most_popular_item(self):
     my_problem = MatchingProblem(users, items, trans)
     result = my_problem.most_popular_item()
     expected = 2
     self.assertEquals(result, expected)