@@ -201,37 +201,23 @@ def test_DgsmGpSampling(self) -> None:
201201 def _test_sobol_gp_mean (
202202 self ,
203203 sensitivity : SobolSensitivityGPMean ,
204- expected_first_order : Tensor ,
205- expected_total_order : Tensor ,
206- expected_second_order : Tensor | None = None ,
204+ expected_first_order_shape : torch . Size ,
205+ expected_total_order_shape : torch . Size ,
206+ expected_second_order_shape : torch . Size | None = None ,
207207 ) -> None :
208- """
209- Check that outputs are as expected. The `assertAllClose` checks are
210- characterization tests rather than correctness tests; they check that
211- behavior is the same as it was in the past, not that it is
212- quantitatively correct. Innocuous changes such as changing a random seed
213- could potentially break these tests, and it may become necessary to
214- delete them.
215- """
216- atol = 4e-3
217- rtol = 2e-3
208+ """Check that outputs have the correct type and shape."""
218209 first_order = sensitivity .first_order_indices ()
219210 self .assertIsInstance (first_order , Tensor )
220- self .assertAllClose (first_order , expected_first_order , atol = atol , rtol = rtol )
221- self .assertEqual (first_order .shape , expected_first_order .shape )
211+ self .assertEqual (first_order .shape , expected_first_order_shape )
222212
223213 total_order = sensitivity .total_order_indices ()
224214 self .assertIsInstance (total_order , Tensor )
225- self .assertAllClose (total_order , expected_total_order , atol = atol , rtol = rtol )
226- self .assertEqual (total_order .shape , expected_total_order .shape )
215+ self .assertEqual (total_order .shape , expected_total_order_shape )
227216
228- if expected_second_order is not None :
217+ if expected_second_order_shape is not None :
229218 second_order = sensitivity .second_order_indices ()
230219 self .assertIsInstance (second_order , Tensor )
231- self .assertAllClose (
232- second_order , expected_second_order , atol = atol , rtol = rtol
233- )
234- self .assertEqual (second_order .shape , expected_second_order .shape )
220+ self .assertEqual (second_order .shape , expected_second_order_shape )
235221
236222 def test_SobolGPMean (self ) -> None :
237223 bounds = torch .tensor ([(0.0 , 1.0 ) for _ in range (2 )]).t ()
@@ -240,9 +226,9 @@ def test_SobolGPMean(self) -> None:
240226 )
241227 self ._test_sobol_gp_mean (
242228 sensitivity = sensitivity_mean ,
243- expected_first_order = torch .tensor ([ 1.1547 , - 0.4024 ], dtype = torch . float64 ),
244- expected_total_order = torch .tensor ([ 0.4299 , 0.4894 ], dtype = torch . float64 ),
245- expected_second_order = torch .tensor ([ - 1.4845 ], dtype = torch . float64 ),
229+ expected_first_order_shape = torch .Size ([ 2 ] ),
230+ expected_total_order_shape = torch .Size ([ 2 ] ),
231+ expected_second_order_shape = torch .Size ([ 1 ] ),
246232 )
247233
248234 def test_SobolGPMean_SAASBO (self ) -> None :
@@ -252,9 +238,9 @@ def test_SobolGPMean_SAASBO(self) -> None:
252238 )
253239 self ._test_sobol_gp_mean (
254240 sensitivity = sensitivity_mean_saas ,
255- expected_first_order = torch .tensor ([ 0.5752 , 0.5143 ], dtype = torch . double ),
256- expected_total_order = torch .tensor ([ 0.9897 , 0.0979 ], dtype = torch . float64 ),
257- expected_second_order = torch .tensor ([ 0.8332 ], dtype = torch . double ),
241+ expected_first_order_shape = torch .Size ([ 2 ] ),
242+ expected_total_order_shape = torch .Size ([ 2 ] ),
243+ expected_second_order_shape = torch .Size ([ 1 ] ),
258244 )
259245
260246 sensitivity_mean_bootstrap = SobolSensitivityGPMean (
@@ -267,17 +253,9 @@ def test_SobolGPMean_SAASBO(self) -> None:
267253 )
268254 self ._test_sobol_gp_mean (
269255 sensitivity = sensitivity_mean_bootstrap ,
270- expected_first_order = torch .tensor (
271- [[0.6327 , 10.0889 , 1.0044 ], [0.2089 , 0.7322 , 0.2706 ]],
272- dtype = torch .float64 ,
273- ),
274- expected_total_order = torch .tensor (
275- [[0.8013 , 0.1824 , 0.1351 ], [0.2203 , 0.0304 , 0.0551 ]],
276- dtype = torch .float64 ,
277- ),
278- expected_second_order = torch .tensor (
279- [[0.7978 , 22.6598 , 1.5053 ]], dtype = torch .float64
280- ),
256+ expected_first_order_shape = torch .Size ([2 , 3 ]),
257+ expected_total_order_shape = torch .Size ([2 , 3 ]),
258+ expected_second_order_shape = torch .Size ([1 , 3 ]),
281259 )
282260
283261 sensitivity_mean_bootstrap = SobolSensitivityGPMean (
@@ -290,26 +268,18 @@ def test_SobolGPMean_SAASBO(self) -> None:
290268 )
291269 self ._test_sobol_gp_mean (
292270 sensitivity = sensitivity_mean_bootstrap ,
293- expected_first_order = torch .tensor (
294- [[3.4512 , 32.4428 , 1.8012 ], [0.2069 , 121.8610 , 3.4909 ]],
295- dtype = torch .float64 ,
296- ),
297- expected_total_order = torch .tensor (
298- [[0.4288 , 0.0903 , 0.0950 ], [0.7923 , 0.2218 , 0.1489 ]],
299- dtype = torch .float64 ,
300- ),
301- expected_second_order = torch .tensor (
302- [[- 6.3790 , 397.4363 , 6.3043 ]], dtype = torch .float64
303- ),
271+ expected_first_order_shape = torch .Size ([2 , 3 ]),
272+ expected_total_order_shape = torch .Size ([2 , 3 ]),
273+ expected_second_order_shape = torch .Size ([1 , 3 ]),
304274 )
305275
306276 sensitivity_mean = SobolSensitivityGPMean (
307277 self .model , num_mc_samples = 10 , bounds = bounds , second_order = False
308278 )
309279 self ._test_sobol_gp_mean (
310280 sensitivity = sensitivity_mean ,
311- expected_first_order = torch .tensor ([ 0.9566 , - 0.4183 ], dtype = torch . float64 ),
312- expected_total_order = torch .tensor ([ 0.3440 , 0.3685 ], dtype = torch . float64 ),
281+ expected_first_order_shape = torch .Size ([ 2 ] ),
282+ expected_total_order_shape = torch .Size ([ 2 ] ),
313283 )
314284
315285 with self .assertRaisesRegex (ValueError , "Second order indices" ):
0 commit comments