@@ -162,12 +162,15 @@ def test_correct_data_single_fit(self):
162
162
Tests that correct data gives the expected result
163
163
"""
164
164
fitting_problem = FittingProblem (self .options )
165
- fitting_problem .data_x = np .array ([- 0.5 , 0.0 , 1.0 , 0.5 , 1.5 ,
166
- 2.0 , 2.5 , 3.0 , 4.0 ])
167
- fitting_problem .data_y = np .array ([0.0 , 1.0 , 2.0 , 3.0 , 4.0 ,
168
- 5.0 , 6.0 , 7.0 , 8.0 ])
169
- fitting_problem .data_e = np .array ([1.0 , 20.0 , 30.0 , 40.0 , 50.0 ,
170
- 60.0 , 70.0 , 80.0 , 9.0 ])
165
+ fitting_problem .data_x = np .array (
166
+ [- 0.5 , 0.0 , 1.0 , 0.5 , 1.5 , 2.0 , 2.5 , 3.0 , 4.0 ]
167
+ )
168
+ fitting_problem .data_y = np .array (
169
+ [0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ]
170
+ )
171
+ fitting_problem .data_e = np .array (
172
+ [1.0 , 20.0 , 30.0 , 40.0 , 50.0 , 60.0 , 70.0 , 80.0 , 9.0 ]
173
+ )
171
174
fitting_problem .start_x = 0.5
172
175
fitting_problem .end_x = 2.5
173
176
@@ -178,19 +181,24 @@ def test_correct_data_single_fit(self):
178
181
fitting_problem .correct_data ()
179
182
180
183
sort = fitting_problem .sorted_index
181
- self .assertTrue ((fitting_problem .data_x [sort ]
182
- == expected_x_data ).all ())
183
- self .assertTrue ((fitting_problem .data_y [sort ]
184
- == expected_y_data ).all ())
185
- self .assertTrue ((fitting_problem .data_e [sort ]
186
- == expected_e_data ).all ())
184
+ self .assertTrue (
185
+ (fitting_problem .data_x [sort ] == expected_x_data ).all ()
186
+ )
187
+ self .assertTrue (
188
+ (fitting_problem .data_y [sort ] == expected_y_data ).all ()
189
+ )
190
+ self .assertTrue (
191
+ (fitting_problem .data_e [sort ] == expected_e_data ).all ()
192
+ )
187
193
188
194
self .options .cost_func_type = ["nlls" ]
189
195
fitting_problem .correct_data ()
190
- self .assertTrue ((fitting_problem .data_x [sort ]
191
- == expected_x_data ).all ())
192
- self .assertTrue ((fitting_problem .data_y [sort ]
193
- == expected_y_data ).all ())
196
+ self .assertTrue (
197
+ (fitting_problem .data_x [sort ] == expected_x_data ).all ()
198
+ )
199
+ self .assertTrue (
200
+ (fitting_problem .data_y [sort ] == expected_y_data ).all ()
201
+ )
194
202
self .assertIs (fitting_problem .data_e , None )
195
203
196
204
def test_correct_data_multi_fit (self ):
@@ -199,59 +207,70 @@ def test_correct_data_multi_fit(self):
199
207
"""
200
208
fitting_problem = FittingProblem (self .options )
201
209
fitting_problem .multifit = True
202
- fitting_problem .data_x = [np .array ([- 0.5 , 0.0 , 1.0 , 0.5 , 1.5 ,
203
- 2.0 , 2.5 , 3.0 , 4.0 ]),
204
- np .array ([- 0.5 , 0.0 , 1.0 , 0.5 , 1.4 ,
205
- 2.0 , 2.5 , 3.0 , 4.0 ]),
206
- np .array ([- 0.5 , 0.0 , 1.0 , 0.5 , 1.7 ,
207
- 2.0 , 2.5 , 3.0 , 4.0 ])]
208
- fitting_problem .data_y = [np .array ([0.0 , 1.0 , 2.0 , 3.0 , 4.0 ,
209
- 5.0 , 6.0 , 7.0 , 8.0 ]),
210
- np .array ([0.0 , 1.0 , 2.0 , 3.0 , 24.0 ,
211
- 5.0 , 6.0 , 7.0 , 8.0 ]),
212
- np .array ([0.0 , 1.0 , 2.8 , 3.0 , 4.0 ,
213
- 5.0 , 6.0 , 7.0 , 8.0 ])]
214
- fitting_problem .data_e = [np .array ([1.0 , 20.0 , 30.0 , 40.0 , 50.0 ,
215
- 60.0 , 1.0 , 6.0 , 9.0 ]),
216
- np .array ([1.0 , 20.0 , 30.0 , 40.0 , 50.0 ,
217
- 60.0 , 1.0 , 6.0 , 9.0 ]),
218
- np .array ([1.0 , 20.0 , 30.0 , 40.0 , 50.0 ,
219
- 60.0 , 1.0 , 6.0 , 9.0 ])]
210
+ fitting_problem .data_x = [
211
+ np .array ([- 0.5 , 0.0 , 1.0 , 0.5 , 1.5 , 2.0 , 2.5 , 3.0 , 4.0 ]),
212
+ np .array ([- 0.5 , 0.0 , 1.0 , 0.5 , 1.4 , 2.0 , 2.5 , 3.0 , 4.0 ]),
213
+ np .array ([- 0.5 , 0.0 , 1.0 , 0.5 , 1.7 , 2.0 , 2.5 , 3.0 , 4.0 ]),
214
+ ]
215
+ fitting_problem .data_y = [
216
+ np .array ([0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ]),
217
+ np .array ([0.0 , 1.0 , 2.0 , 3.0 , 24.0 , 5.0 , 6.0 , 7.0 , 8.0 ]),
218
+ np .array ([0.0 , 1.0 , 2.8 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ]),
219
+ ]
220
+ fitting_problem .data_e = [
221
+ np .array ([1.0 , 20.0 , 30.0 , 40.0 , 50.0 , 60.0 , 1.0 , 6.0 , 9.0 ]),
222
+ np .array ([1.0 , 20.0 , 30.0 , 40.0 , 50.0 , 60.0 , 1.0 , 6.0 , 9.0 ]),
223
+ np .array ([1.0 , 20.0 , 30.0 , 40.0 , 50.0 , 60.0 , 1.0 , 6.0 , 9.0 ]),
224
+ ]
220
225
fitting_problem .start_x = [0.5 , 1.1 , 0.0 ]
221
226
fitting_problem .end_x = [2.5 , 2.6 , 1.0 ]
222
227
223
- expected_x_data = [np .array ([0.5 , 1.0 , 1.5 , 2.0 , 2.5 ]),
224
- np .array ([1.4 , 2.0 , 2.5 ]),
225
- np .array ([0.0 , 0.5 , 1.0 ])]
226
- expected_y_data = [np .array ([3.0 , 2.0 , 4.0 , 5.0 , 6.0 ]),
227
- np .array ([24.0 , 5.0 , 6.0 ]),
228
- np .array ([1.0 , 3.0 , 2.8 ])]
229
- expected_e_data = [np .array ([40.0 , 30.0 , 50.0 , 60.0 , 1.0 ]),
230
- np .array ([50.0 , 60.0 , 1.0 ]),
231
- np .array ([20.0 , 40.0 , 30.0 ])]
228
+ expected_x_data = [
229
+ np .array ([0.5 , 1.0 , 1.5 , 2.0 , 2.5 ]),
230
+ np .array ([1.4 , 2.0 , 2.5 ]),
231
+ np .array ([0.0 , 0.5 , 1.0 ]),
232
+ ]
233
+ expected_y_data = [
234
+ np .array ([3.0 , 2.0 , 4.0 , 5.0 , 6.0 ]),
235
+ np .array ([24.0 , 5.0 , 6.0 ]),
236
+ np .array ([1.0 , 3.0 , 2.8 ]),
237
+ ]
238
+ expected_e_data = [
239
+ np .array ([40.0 , 30.0 , 50.0 , 60.0 , 1.0 ]),
240
+ np .array ([50.0 , 60.0 , 1.0 ]),
241
+ np .array ([20.0 , 40.0 , 30.0 ]),
242
+ ]
232
243
233
244
fitting_problem .correct_data ()
234
245
235
246
for ix , sort in enumerate (fitting_problem .sorted_index ):
236
- self .assertTrue ((fitting_problem .data_x [ix ][sort ]
237
- == expected_x_data [ix ]).all ())
238
- self .assertTrue ((fitting_problem .data_y [ix ][sort ]
239
- == expected_y_data [ix ]).all ())
240
- self .assertTrue ((fitting_problem .data_e [ix ][sort ]
241
- == expected_e_data [ix ]).all ())
247
+ self .assertTrue (
248
+ (fitting_problem .data_x [ix ][sort ] == expected_x_data [ix ]).all ()
249
+ )
250
+ self .assertTrue (
251
+ (fitting_problem .data_y [ix ][sort ] == expected_y_data [ix ]).all ()
252
+ )
253
+ self .assertTrue (
254
+ (fitting_problem .data_e [ix ][sort ] == expected_e_data [ix ]).all ()
255
+ )
242
256
243
257
self .options .cost_func_type = ["nlls" ]
244
258
fitting_problem .correct_data ()
245
259
for ix , sort in enumerate (fitting_problem .sorted_index ):
246
- self .assertTrue ((fitting_problem .data_x [ix ][sort ]
247
- == expected_x_data [ix ]).all ())
248
- self .assertTrue ((fitting_problem .data_y [ix ][sort ]
249
- == expected_y_data [ix ]).all ())
260
+ self .assertTrue (
261
+ (fitting_problem .data_x [ix ][sort ] == expected_x_data [ix ]).all ()
262
+ )
263
+ self .assertTrue (
264
+ (fitting_problem .data_y [ix ][sort ] == expected_y_data [ix ]).all ()
265
+ )
250
266
self .assertIs (fitting_problem .data_e [ix ], None )
251
267
252
- @parameterized .expand ([(True , [np .array ([1 , 2 ]), np .array ([3 , 4 ])],
253
- ['params' , 'x' ]),
254
- (False , np .array ([1 , 2 ]), ['params' ])])
268
+ @parameterized .expand (
269
+ [
270
+ (True , [np .array ([1 , 2 ]), np .array ([3 , 4 ])], ["params" , "x" ]),
271
+ (False , np .array ([1 , 2 ]), ["params" ]),
272
+ ]
273
+ )
255
274
@patch ("fitbenchmarking.parsing.fitting_problem.FittingProblem.eval_model" )
256
275
def test_ini_y_args (self , multifit , data_x , args , mock ):
257
276
"""
@@ -260,7 +279,7 @@ def test_ini_y_args(self, multifit, data_x, args, mock):
260
279
fitting_problem = FittingProblem (self .options )
261
280
fitting_problem .multifit = multifit
262
281
fitting_problem .data_x = data_x
263
- fitting_problem .starting_values = [{0 : '0' }]
282
+ fitting_problem .starting_values = [{0 : "0" }]
264
283
265
284
fitting_problem .ini_y ()
266
285
self .assertEqual (mock .call_count , 1 )
0 commit comments