Changeset 13483
- Timestamp:
- Sep 16, 2019 8:04:48 AM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/dev-5819/Python/src/tests_jmodelica/initialization/test_KINsolver_options.py
r13461 r13483 129 129 log = parse_jmi_log(self.log_file_name) 130 130 solves = gather_solves(log) 131 nose.tools.assert_equals(solves, [])131 assert not solves, "Failed in assert (1/6) because list is not empty, got solves={}".format(solves) 132 132 133 133 self.setUp() … … 137 137 log = parse_jmi_log(self.log_file_name) 138 138 solves = gather_solves(log) 139 nose.tools.assert_equals(solves, [])139 assert not solves, "Failed in assert (2/6) because list is not empty, got solves={}".format(solves) 140 140 141 141 self.setUp() … … 145 145 log = parse_jmi_log(self.log_file_name) 146 146 solves = gather_solves(log) 147 nose.tools.assert_equals(solves, [])147 assert not solves, "Failed in assert (3/6) because list is not empty, got solves={}".format(solves) 148 148 149 149 self.setUp() … … 153 153 log = parse_jmi_log(self.log_file_name) 154 154 solves = gather_solves(log) 155 nose.tools.assert_equals(solves, [])155 assert not solves, "Failed in assert (4/6) because list is not empty, got solves={}".format(solves) 156 156 157 157 self.setUp() … … 161 161 log = parse_jmi_log(self.log_file_name) 162 162 solves = gather_solves(log) 163 nose.tools.assert_equals(len(solves), 4)163 assert len(solves) == 4, "Failed in assert (5/6) because result is not of length 4, got solves={}, with length {}".format(solves, len(solves)) 164 164 165 165 self.setUp() … … 169 169 log = parse_jmi_log(self.log_file_name) 170 170 solves = gather_solves(log) 171 nose.tools.assert_equals(len(solves), 4)171 assert len(solves) == 4, "Failed in assert (6/6) because result is not of length 4, got solves={}, with length {}".format(solves, len(solves)) 172 172 173 173 @testattr(stddist_full = True) … … 181 181 log = parse_jmi_log(self.log_file_name) 182 182 solves = gather_solves(log) 183 N.testing.assert_array_almost_equal(solves[0].block_solves[0].iterations[-1].ivs, N.array([N.sqrt(11), 5. ])) 183 result = solves[0].block_solves[0].iterations[-1].ivs 184 expected = N.array([N.sqrt(11), 5. ]) 185 err_msg = "Arrays not equal, expected {} but got {}".format(expected, result) 186 assert N.allclose(result, expected), err_msg 184 187 185 188 … … 227 230 log = parse_jmi_log(self.log_file_name) 228 231 solves = gather_solves(log) 229 nose.tools.assert_true(N.array_equal(solves[0].block_solves[0].nominal, 230 N.array([1.,1.]))) 232 result = solves[0].block_solves[0].nominal 233 expected = N.array([1.,1.]) 234 err_msg = "Arrays not equal, expected {} but got {}".format(expected, result) 235 assert N.allclose(result, expected), err_msg 231 236 232 237 @testattr(stddist_full = True) … … 239 244 log = parse_jmi_log(self.log_file_name) 240 245 solves = gather_solves(log) 241 nose.tools.assert_false(N.array_equal(solves[0].block_solves[0].iterations[0].residual_scaling, 242 N.array([1., 1.]))) 246 result = solves[0].block_solves[0].iterations[0].residual_scaling 247 expected = N.array([1., 1.]) 248 err_msg = "Arrays are supposed to be different but are actually equal. Result={}\nExpected={}".format(result, expected) 249 assert not N.allclose(result, expected), err_msg 243 250 244 251 # self.setUp() … … 257 264 solves = gather_solves(log) 258 265 #residual scaling is not logged when turned off. 259 nose.tools.assert_false('residual_scaling' in solves[0].block_solves[0].iterations[0]) 266 condition = 'residual_scaling' in solves[0].block_solves[0].iterations[0] 267 assert not condition, "Test failed because string residual_scaling was found in {}".format(solves[0].block_solves[0].iterations[0]) 260 268 261 269 @testattr(stddist_full = True) … … 283 291 log = parse_jmi_log(self.log_file_name) 284 292 solves = gather_solves(log) 285 nose.tools.assert_equals(solves, [])293 assert not solves, "Failed in assert (1/6) because list is not empty, got solves={}".format(solves) 286 294 287 295 self.setUp('test_KINsolver_options_log_ll2.txt') … … 290 298 log = parse_jmi_log(self.log_file_name) 291 299 solves = gather_solves(log) 292 nose.tools.assert_equals(solves, [])300 assert not solves, "Failed in assert (2/6) because list is not empty, got solves={}".format(solves) 293 301 294 302 self.setUp('test_KINsolver_options_log_ll3.txt') … … 297 305 log = parse_jmi_log(self.log_file_name) 298 306 solves = gather_solves(log) 299 nose.tools.assert_equals(solves, [])307 assert not solves, "Failed in assert (3/6) because list is not empty, got solves={}".format(solves) 300 308 301 309 self.setUp('test_KINsolver_options_log_ll4.txt') … … 304 312 log = parse_jmi_log(self.log_file_name) 305 313 solves = gather_solves(log) 306 nose.tools.assert_equals(solves, [])314 assert not solves, "Failed in assert (4/6) because list is not empty, got solves={}".format(solves) 307 315 308 316 self.setUp('test_KINsolver_options_log_ll5.txt') … … 311 319 log = parse_jmi_log(self.log_file_name) 312 320 solves = gather_solves(log) 313 nose.tools.assert_equals(len(solves), 2)321 assert len(solves) == 2, "Failed in assert (5/6) because result is not of length 2, got solves={}, with length {}".format(solves, len(solves)) 314 322 315 323 self.setUp('test_KINsolver_options_log_ll6.txt') … … 318 326 log = parse_jmi_log(self.log_file_name) 319 327 solves = gather_solves(log) 320 print(solves) 321 nose.tools.assert_equals(len(solves), 2) 328 assert len(solves) == 2, "Failed in assert (6/6) because result is not of length 2, got solves={}, with length {}".format(solves, len(solves)) 322 329 323 330 @testattr(stddist_full = True) … … 331 338 log = parse_jmi_log(self.log_file_name) 332 339 solves = gather_solves(log) 333 N.testing.assert_array_almost_equal(solves[0].block_solves[0].iterations[-1].ivs, N.array([N.sqrt(11), 5. ])) 334 335 336 337 338 339 340 341 342 343 340 result = solves[0].block_solves[0].iterations[-1].ivs 341 expected = N.array([N.sqrt(11), 5. ]) 342 err_msg = "Arrays are not almost equal:\nEXPECTED: {}\nACTUAL: {}".format(expected, result) 343 N.testing.assert_array_almost_equal(result, expected, err_msg=err_msg) 344 345 346 347 348 349 350 351 352 353
Note: See TracChangeset
for help on using the changeset viewer.