예제 #1
0
 def test_fromarray(self):
   data = sparse.fromarray(self.full)
   self.assertEqual(data.tolist(),
     [((0,0),0),((0,1),40),((0,2),0),((0,3),0),((0,4),0),
      ((1,0),0),((1,1),0),((1,2),80),((1,3),0),((1,4),0),
      ((2,0),60),((2,1),0),((2,2),0),((2,3),0),((2,4),10),
      ((3,0),0),((3,1),0),((3,2),0),((3,3),0),((3,4),20)])
예제 #2
0
 def setUpContext(self, stack):
     super().setUpContext(stack)
     if self.backend:
         stack.enter_context(self.backend)
         self.exact = 2 * numpy.eye(self.n) - numpy.eye(
             self.n, self.n, -1) - numpy.eye(self.n, self.n, +1)
         data = sparse.prune(sparse.fromarray(self.exact), inplace=True)
         assert len(data) == self.n * 3 - 2
         self.matrix = matrix.fromsparse(data, inplace=True)
예제 #3
0
 def setUp(self):
   super().setUp()
   try:
     self.enter_context(matrix.backend(self.backend))
   except matrix.BackendNotAvailable:
     self.skipTest('backend is unavailable')
   self.exact = 2 * numpy.eye(self.n) - numpy.eye(self.n, self.n, -1) - numpy.eye(self.n, self.n, +1)
   data = sparse.prune(sparse.fromarray(self.exact), inplace=True)
   assert len(data) == self.n*3-2
   self.matrix = matrix.fromsparse(data, inplace=True)
예제 #4
0
 def test_fromarray(self):
     data = sparse.fromarray(self.full)
     self.assertEqual(data.tolist(), [((0, ), 60), ((1, ), 40), ((2, ), 80),
                                      ((3, ), 0), ((4, ), 30)])