@@ -27,15 +27,17 @@ def gen_bounds(self, start, stop, step):
2727
2828 def test_target_half_resolution (self ):
2929 target_bounds = self .gen_bounds (0 , 7 , 2 )
30- res = bounded_vinterp .interpolate (target_bounds , self .bounds ,
31- self .data , axis = 1 )
30+ res = bounded_vinterp .interpolate_conservative (target_bounds ,
31+ self .bounds , self .data ,
32+ axis = 1 )
3233 target_data = np .ones ((4 , 3 ))* 2
3334 assert_array_equal (res , target_data )
3435
3536 def test_target_double_resolution (self ):
3637 target_bounds = self .gen_bounds (0 , 6.5 , 0.5 )
37- res = bounded_vinterp .interpolate (target_bounds , self .bounds ,
38- self .data , axis = 1 )
38+ res = bounded_vinterp .interpolate_conservative (target_bounds ,
39+ self .bounds , self .data ,
40+ axis = 1 )
3941 target_data = np .ones ((4 , 12 ))* .5
4042 assert_array_equal (res , target_data )
4143
@@ -45,8 +47,9 @@ def test_no_broadcasting(self):
4547 # [1, axis_interpolation, 1].
4648 data = self .data [0 ]
4749 target_bounds = self .gen_bounds (0 , 7 , 2 )
48- res = bounded_vinterp .interpolate (target_bounds , self .bounds , data ,
49- axis = 0 )
50+ res = bounded_vinterp .interpolate_conservative (target_bounds ,
51+ self .bounds , data ,
52+ axis = 0 )
5053 target_data = np .ones ((3 ))* 2
5154 assert_array_equal (res , target_data )
5255
@@ -55,8 +58,9 @@ def test_target_extends_above_source(self):
5558 # |-|-|-|-|-|-|-|-| - Target
5659 source_bounds = self .gen_bounds (0 , 7 , 1 )
5760 target_bounds = self .gen_bounds (0 , 8 , 1 )
58- res = bounded_vinterp .interpolate (target_bounds , source_bounds ,
59- self .data , axis = 1 )
61+ res = bounded_vinterp .interpolate_conservative (target_bounds ,
62+ source_bounds ,
63+ self .data , axis = 1 )
6064 target_data = np .ones ((4 , 7 ))
6165 target_data [:, - 1 ] = 0
6266 assert_array_equal (res , target_data )
@@ -66,8 +70,9 @@ def test_target_extends_below_source(self):
6670 # |-|-|-|-|-|-|-|-| - Target
6771 source_bounds = self .gen_bounds (0 , 7 , 1 )
6872 target_bounds = self .gen_bounds (- 1 , 7 , 1 )
69- res = bounded_vinterp .interpolate (target_bounds , source_bounds ,
70- self .data , axis = 1 )
73+ res = bounded_vinterp .interpolate_conservative (target_bounds ,
74+ source_bounds ,
75+ self .data , axis = 1 )
7176 target_data = np .ones ((4 , 7 ))
7277 target_data [:, 0 ] = 0
7378 assert_array_equal (res , target_data )
@@ -90,8 +95,9 @@ def gen_bounds(self, start, stop, step):
9095
9196 def test_target_half_resolution (self ):
9297 target_bounds = self .gen_bounds (0 , 7 , 2 )
93- res = bounded_vinterp .interpolate (target_bounds , self .bounds ,
94- self .data , axis = 1 )
98+ res = bounded_vinterp .interpolate_conservative (target_bounds ,
99+ self .bounds , self .data ,
100+ axis = 1 )
95101
96102 target_data = np .ones ((2 , 3 , 4 , 3 ))* 2
97103 assert_array_equal (res , target_data )
@@ -103,14 +109,16 @@ def test_target_half_resolution_alt_axis(self):
103109 target_bounds = self .gen_bounds (0 , 7 , 2 )
104110 target_bounds = target_bounds .transpose ((1 , 0 , 2 , 3 ))
105111
106- res = bounded_vinterp .interpolate (target_bounds , bounds , data , axis = 2 )
112+ res = bounded_vinterp .interpolate_conservative (target_bounds , bounds ,
113+ data , axis = 2 )
107114 target_data = np .ones ((2 , 4 , 3 , 3 ))* 2
108115 assert_array_equal (res , target_data )
109116
110117 def test_target_double_resolution (self ):
111118 target_bounds = self .gen_bounds (0 , 6.5 , 0.5 )
112- res = bounded_vinterp .interpolate (target_bounds , self .bounds ,
113- self .data , axis = 1 )
119+ res = bounded_vinterp .interpolate_conservative (target_bounds ,
120+ self .bounds ,
121+ self .data , axis = 1 )
114122 target_data = np .ones ((2 , 12 , 4 , 3 ))* .5
115123 assert_array_equal (res , target_data )
116124
@@ -123,7 +131,8 @@ def test_mismatch_source_target_level_dimensionality(self):
123131
124132 msg = 'Expecting source and target levels dimensionality'
125133 with self .assertRaisesRegexp (ValueError , msg ):
126- bounded_vinterp .interpolate (target_bounds , source_bounds , data )
134+ bounded_vinterp .interpolate_conservative (target_bounds ,
135+ source_bounds , data )
127136
128137 def test_mismatch_source_target_level_shape (self ):
129138 # The source and target levels should have identical shape, other than
@@ -134,8 +143,9 @@ def test_mismatch_source_target_level_shape(self):
134143
135144 msg = 'Expecting the shape of the source and target levels'
136145 with self .assertRaisesRegexp (ValueError , msg ):
137- bounded_vinterp .interpolate (target_bounds , source_bounds , data ,
138- axis = 0 )
146+ bounded_vinterp .interpolate_conservative (target_bounds ,
147+ source_bounds , data ,
148+ axis = 0 )
139149
140150 def test_mismatch_between_source_levels_source_data (self ):
141151 # The source levels should reflect the shape of the data.
@@ -145,8 +155,9 @@ def test_mismatch_between_source_levels_source_data(self):
145155
146156 msg = 'The provided data is not of compatible shape'
147157 with self .assertRaisesRegexp (ValueError , msg ):
148- bounded_vinterp .interpolate (target_bounds , source_bounds , data ,
149- axis = 0 )
158+ bounded_vinterp .interpolate_conservative (target_bounds ,
159+ source_bounds , data ,
160+ axis = 0 )
150161
151162 def test_unexpected_bounds_shape (self ):
152163 # Expecting bounds of size 2 (that is the upper and lower).
@@ -157,8 +168,9 @@ def test_unexpected_bounds_shape(self):
157168
158169 msg = 'Unexpected source and target bounds shape. shape\[-1\] != 2'
159170 with self .assertRaisesRegexp (ValueError , msg ):
160- bounded_vinterp .interpolate (target_bounds , source_bounds , data ,
161- axis = 0 )
171+ bounded_vinterp .interpolate_conservative (target_bounds ,
172+ source_bounds , data ,
173+ axis = 0 )
162174
163175 def test_not_conservative (self ):
164176 # Where the target does not cover the full extent of the source.
@@ -175,8 +187,9 @@ def gen_bounds(start, stop, step):
175187
176188 msg = 'Weights calculation yields a less than conservative result.'
177189 with self .assertRaisesRegexp (ValueError , msg ):
178- bounded_vinterp .interpolate (target_bounds , source_bounds , data ,
179- axis = 1 )
190+ bounded_vinterp .interpolate_conservative (target_bounds ,
191+ source_bounds , data ,
192+ axis = 1 )
180193
181194
182195if __name__ == '__main__' :
0 commit comments