Changeset 6229 for anuga_core/source/anuga/caching/test_caching.py
- Timestamp:
- Jan 22, 2009, 11:45:27 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/caching/test_caching.py
r6148 r6229 366 366 367 367 368 def Xtest_caching_of_complex_circular_structure(self): 369 """test_caching_of_complex_circular_structure 370 371 Test that Caching can handle a realistic 372 complex structure. This one is inspired by 373 ANUGA's Okushiri example, although reduced in size. 374 """ 375 376 pass 377 368 def Xtest_caching_of_callable_objects(self): 369 """test_caching_of_callable_objects(self) 370 371 Test that caching will discern between calls of 372 two different instances of a callable object with the same input. 373 374 This cause problems with add_quantity in ANUGA in changeset:6225 375 where a previous instance of Polygon_function was picked up. 376 """ 377 378 class call: 379 380 def __init__(self, a, b): 381 self.a = a 382 self.b = b 383 384 def __call__(self, x): 385 return self.a*x + self.b 386 387 388 389 f1 = call(2, 3) 390 f2 = call(5, 7) 391 392 x = num.arange(10).astype(num.Float) 393 394 ref1 = f1(x) 395 ref2 = f2(x) 396 397 # Clear cache for f1(x) and f2(x) and verify that all is clear 398 cache(f1, x, clear=True, verbose=False) 399 flag = cache(f1, x, test=True, verbose=False) 400 assert flag is None 401 402 cache(f2, x, clear=True, verbose=False) 403 flag = cache(f2, x, test=True, verbose=False) 404 assert flag is None 405 406 # Run f1(x) and cache 407 res1 = cache(f1, x, verbose=False) 408 assert num.allclose(res1, ref1) 409 410 # Test that f1(x) has been cached correctly 411 res1 = cache(f1, x, test=True, verbose=False) 412 assert num.allclose(res1, ref1) 413 414 # Test that f2(x) is still clear 415 flag = cache(f2, x, test=True, verbose=False) 416 msg = 'Function f2(x) should not be cached here' 417 assert flag is None, msg 418 419 # Run f2(x) and test result 420 res2 = cache(f2, x, verbose=False) 421 msg = 'Wrong result for f2(x)' 422 assert num.allclose(res2, ref2), msg 423 424 425 378 426 379 427 def test_uniqueness_of_hash_values(self):
Note: See TracChangeset
for help on using the changeset viewer.