Ejemplo n.º 1
0
 def test_basic(self):
     """Test that the plugin returns a Numpy array."""
     ranges = 2
     fullranges = (0, 2, 2)
     weighted_mode = False
     result = circular_kernel(fullranges, ranges, weighted_mode)
     self.assertIsInstance(result, np.ndarray)
Ejemplo n.º 2
0
 def test_single_point_weighted(self):
     """Test behaviour for a unitary range, with weighting."""
     ranges = 1
     fullranges = (1, 1)
     weighted_mode = True
     expected = [[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]]
     result = circular_kernel(fullranges, ranges, weighted_mode)
     self.assertArrayAlmostEqual(result, expected)
Ejemplo n.º 3
0
 def test_single_point_unweighted_extra_dims(self):
     """Test behaviour for a unitary range without weighting.
     And added dimensions."""
     ranges = 1
     fullranges = (0, 0, 1, 1)
     weighted_mode = False
     expected = [[[[0.0, 1.0, 0.0], [1.0, 1.0, 1.0], [0.0, 1.0, 0.0]]]]
     result = circular_kernel(fullranges, ranges, weighted_mode)
     self.assertArrayEqual(result, expected)
Ejemplo n.º 4
0
 def test_single_point_weighted_extra_dims(self):
     """Test behaviour for a unitary range, with weighting.
     And added dimensions."""
     ranges = (1, 1)
     fullranges = (0, 0, 1, 1)
     weighted_mode = True
     expected = [[[[0., 0., 0.], [0., 1., 0.], [0., 0., 0.]]]]
     result = (circular_kernel(fullranges, ranges, weighted_mode))
     self.assertArrayAlmostEqual(result, expected)
Ejemplo n.º 5
0
 def test_single_point_unweighted(self):
     """Test behaviour for a unitary range without weighting.
     Note that this gives one more grid cell range than weighted! As the
     affected area is one grid cell more in each direction, an equivalent
     range of 2 was chosen for this test."""
     ranges = 1
     fullranges = (1, 1)
     weighted_mode = False
     expected = [[0.0, 1.0, 0.0], [1.0, 1.0, 1.0], [0.0, 1.0, 0.0]]
     result = circular_kernel(fullranges, ranges, weighted_mode)
     self.assertArrayEqual(result, expected)
Ejemplo n.º 6
0
 def test_range5_unweighted(self):
     """Test behaviour for a range of 5 without weighting."""
     ranges = (5, 5)
     fullranges = (5, 5)
     weighted_mode = False
     expected = [[0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.],
                 [0., 0., 1., 1., 1., 1., 1., 1., 1., 0., 0.],
                 [0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0.],
                 [0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0.],
                 [0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0.],
                 [1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.],
                 [0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0.],
                 [0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0.],
                 [0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0.],
                 [0., 0., 1., 1., 1., 1., 1., 1., 1., 0., 0.],
                 [0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.]]
     result = (circular_kernel(fullranges, ranges, weighted_mode))
     self.assertArrayEqual(result, expected)
Ejemplo n.º 7
0
 def test_range5_weighted(self):
     """Test behaviour for a range of 5, with weighting."""
     ranges = 5
     fullranges = (5, 5)
     weighted_mode = True
     expected = [
         [0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00],
         [0.00, 0.00, 0.00, 0.20, 0.32, 0.36, 0.32, 0.20, 0.00, 0.00, 0.00],
         [0.00, 0.00, 0.28, 0.48, 0.60, 0.64, 0.60, 0.48, 0.28, 0.00, 0.00],
         [0.00, 0.20, 0.48, 0.68, 0.80, 0.84, 0.80, 0.68, 0.48, 0.20, 0.00],
         [0.00, 0.32, 0.60, 0.80, 0.92, 0.96, 0.92, 0.80, 0.60, 0.32, 0.00],
         [0.00, 0.36, 0.64, 0.84, 0.96, 1.00, 0.96, 0.84, 0.64, 0.36, 0.00],
         [0.00, 0.32, 0.60, 0.80, 0.92, 0.96, 0.92, 0.80, 0.60, 0.32, 0.00],
         [0.00, 0.20, 0.48, 0.68, 0.80, 0.84, 0.80, 0.68, 0.48, 0.20, 0.00],
         [0.00, 0.00, 0.28, 0.48, 0.60, 0.64, 0.60, 0.48, 0.28, 0.00, 0.00],
         [0.00, 0.00, 0.00, 0.20, 0.32, 0.36, 0.32, 0.20, 0.00, 0.00, 0.00],
         [0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00],
     ]
     result = circular_kernel(fullranges, ranges, weighted_mode)
     self.assertArrayAlmostEqual(result, expected)
Ejemplo n.º 8
0
 def test_range5_weighted_extra_dims(self):
     """Test behaviour for a range of 5, with weighting."""
     ranges = (5, 5)
     fullranges = (0, 0, 5, 5)
     weighted_mode = True
     expected = [
         [[[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0.2, 0.32, 0.36, 0.32, 0.2, 0., 0., 0.],
           [0., 0., 0.28, 0.48, 0.6, 0.64, 0.6, 0.48, 0.28, 0., 0.],
           [0., 0.2, 0.48, 0.68, 0.8, 0.84, 0.8, 0.68, 0.48, 0.2, 0.],
           [0., 0.32, 0.6, 0.8, 0.92, 0.96, 0.92, 0.8, 0.6, 0.32, 0.],
           [0., 0.36, 0.64, 0.84, 0.96, 1., 0.96, 0.84, 0.64, 0.36, 0.],
           [0., 0.32, 0.6, 0.8, 0.92, 0.96, 0.92, 0.8, 0.6, 0.32, 0.],
           [0., 0.2, 0.48, 0.68, 0.8, 0.84, 0.8, 0.68, 0.48, 0.2, 0.],
           [0., 0., 0.28, 0.48, 0.6, 0.64, 0.6, 0.48, 0.28, 0., 0.],
           [0., 0., 0., 0.2, 0.32, 0.36, 0.32, 0.2, 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]]
     ]
     result = (circular_kernel(fullranges, ranges, weighted_mode))
     self.assertArrayAlmostEqual(result, expected)
Ejemplo n.º 9
0
 def test_range5_unweighted_extra_dims(self):
     """Test behaviour for a range of 5 without weighting."""
     ranges = 5
     fullranges = (0, 0, 5, 5)
     weighted_mode = False
     expected = [
         [
             [
                 [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                 [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
                 [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
                 [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
                 [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
                 [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
                 [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
                 [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
                 [0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0],
                 [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
                 [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0],
             ]
         ]
     ]
     result = circular_kernel(fullranges, ranges, weighted_mode)
     self.assertArrayEqual(result, expected)