예제 #1
0
 def test_non_contiguous_memory_blocks(self):
     s = Sparse(shape=(3, 3, 3), chunks=(2, 2, 2))
     s[1, 1, 1] = 1.0
     s[2, 2, 2] = 1.0
     # Exception: Memory blocks have wrong len: 2, use make_dense_data() to fix.
     with self.assertRaises(Exception):
         point_probe(np.zeros((1, 3)), s)
예제 #2
0
 def test_shape_corner_probe(self):
     self.assertEqual(point_probe(np.full(3, 2), self.s), 2.0)
예제 #3
0
 def test_unequal_spacing(self):
     s = Sparse(shape=(2, 2, 2), chunks=(2, 2, 2), spacing=(1, 2, 4))
     s[:2, :2, :2] = np.arange(8).reshape((2, 2, 2))
     s.update_grid_mask()
     self.assertEqual(point_probe([0.5, 0.5, 0.5], s), 1.5)
예제 #4
0
 def test_list_xyz(self):
     self.assertEqual(point_probe([0.5, 0.5, 0.5], self.s), 0.125)
예제 #5
0
 def test_middle_of_voxel(self):
     self.assertEqual(point_probe(np.ones((1, 3)) * 0.5, self.s), 0.125)
예제 #6
0
 def test_flat_xyz(self):
     self.assertEqual(point_probe(np.ones(3), self.s), 1.0)
예제 #7
0
 def test_empty_zeros(self):
     self.assertEqual(point_probe(np.zeros((1, 3)), self.s), 0.0)
예제 #8
0
 def test_grid_mask_exception(self):
     s = Sparse(shape=(2, 2, 2), chunks=(2, 2, 2))
     s[1, 1, 1] = 1.0
     # RuntimeError: Missing grid_mask in sparse array. Use update_grid_mask() before point_probe().
     with self.assertRaises(RuntimeError):
         point_probe(np.zeros((1, 3)), s)