Example #1
0
 def test_reduce(self):
     # As this is not yet implemented, it should raise an error
     with self.assertRaises(NotImplementedError):
         correlate_maps_base(self.map1,
                             self.map2,
                             window_size=5,
                             reduce=True)
Example #2
0
 def test_correlation_value(self):
     # test the value of the correlation against scipys implementation
     np.random.seed(0)
     c1 = np.random.rand(5, 5)
     c2 = np.random.rand(5, 5)
     self.assertTrue(
         np.allclose(
             pearsonr(c1.flatten(), c2.flatten())[0],
             correlate_maps_base(c1, c2, window_size=5)[2, 2]))
Example #3
0
 def test_correlation_window_size_15(self):
     c1 = correlate_maps_base(self.map1, self.map2, window_size=15)
     c2 = correlate_maps_simple(self.map1, self.map2, window_size=15)
     self.assertTrue(np.allclose(c1, c2, equal_nan=True))
Example #4
0
 def test_correlation_fraction_accepted_1(self):
     c1 = correlate_maps_base(self.map1, self.map2, fraction_accepted=1)
     c2 = correlate_maps_simple(self.map1, self.map2, fraction_accepted=1)
     self.assertTrue(np.allclose(c1, c2, equal_nan=True))
Example #5
0
 def test_correlation(self):
     # fraction_accepted 0.7 and window_size 5
     c1 = correlate_maps_base(self.map1, self.map2)
     c2 = correlate_maps_simple(self.map1, self.map2)
     self.assertTrue(np.allclose(c1, c2, equal_nan=True))
Example #6
0
 def test_assumptions(self):
     with self.assertRaises((ValueError, IndexError)):
         # Only 2D is supported
         correlate_maps_base(np.random.rand(10, 10, 10),
                             np.random.rand(10, 10, 10))
     with self.assertRaises((ValueError, IndexError)):
         # Only 2D is supported
         correlate_maps_base(np.random.rand(10), np.random.rand(10))
     with self.assertRaises(ValueError):
         # fraction accepted needs to be in range 0-1
         correlate_maps_base(self.map1, self.map2, fraction_accepted=-0.1)
     with self.assertRaises(ValueError):
         # fraction accepted needs to be in range 0-1
         correlate_maps_base(self.map1, self.map2, fraction_accepted=1.1)
     with self.assertRaises(ValueError):
         # window_size should be bigger than 1
         correlate_maps_base(self.map1, self.map2, window_size=1)
     with self.assertRaises(ValueError):
         # window_size can't be even
         correlate_maps_base(self.map1, self.map2, window_size=4)