Skip to content

Commit

Permalink
Test that bilinear interpolation is called
Browse files Browse the repository at this point in the history
  • Loading branch information
pnuu committed Feb 14, 2017
1 parent 15a0f83 commit 9c9e345
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions mpop/tests/test_projector.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ class TestProjector(unittest.TestCase):

proj = None

@patch('mpop.projector.get_bil_info')
@patch.object(utils, 'generate_quick_linesample_arrays')
@patch.object(mpop.projector.kd_tree, 'get_neighbour_info')
@patch.object(mpop.projector, '_get_area_hash')
def test_init(self, gah, gni, gqla):
def test_init(self, gah, gni, gqla, bil_info):
"""Creation of coverage.
"""

Expand Down Expand Up @@ -147,13 +148,26 @@ def test_init(self, gah, gni, gqla):
self.assertTrue(cache['col_idx'] is not None)

# nearest mode cache

self.proj = Projector(in_area_id, out_area_id, mode="nearest")
cache = getattr(self.proj, "_cache")
self.assertTrue(cache['valid_index'] is not None)
self.assertTrue(cache['valid_output_index'] is not None)
self.assertTrue(cache['index_array'] is not None)

# bilinear mode cache
bil_info.return_value = (1, 2, 3, 4)

def spam(val):
return 'adef'

with patch.object(mpop.projector, 'get_area_def', spam):
self.proj = Projector(in_area_id, out_area_id, mode="bilinear")
cache = getattr(self.proj, "_cache")
self.assertTrue(cache['bilinear_t'] is not None)
self.assertTrue(cache['bilinear_s'] is not None)
self.assertTrue(cache['input_idxs'] is not None)
self.assertTrue(cache['idx_arr'] is not None)

@patch.object(np.ma, "array")
@patch.object(mpop.projector.kd_tree, 'get_sample_from_neighbour_info')
@patch.object(np, "load")
Expand Down Expand Up @@ -182,8 +196,8 @@ def test_project_array(self, npload, gsfni, marray):
# test nearest
in_area = MagicMock()
out_area = MagicMock()
utils.parse_area_file.return_value.__getitem__.side_effect = \
[in_area, out_area]
utils.parse_area_file.return_value.__getitem__.side_effect = [
in_area, out_area]
self.proj = Projector(in_area_id, out_area_id, mode="nearest")
self.proj.project_array(data)
mpop.projector.kd_tree.get_sample_from_neighbour_info.\
Expand Down

0 comments on commit 9c9e345

Please sign in to comment.