1from dipy.reconst.cache import Cache 2from dipy.core.sphere import Sphere 3 4from numpy.testing import assert_, assert_equal, run_module_suite 5 6 7class DummyModel(Cache): 8 def __init__(self): 9 pass 10 11 12def test_basic_cache(): 13 t = DummyModel() 14 s = Sphere(theta=[0], phi=[0]) 15 16 assert_(t.cache_get("design_matrix", s) is None) 17 18 m = [[1, 0], [0, 1]] 19 20 t.cache_set("design_matrix", key=s, value=m) 21 assert_equal(t.cache_get("design_matrix", s), m) 22 23 t.cache_clear() 24 assert_(t.cache_get("design_matrix", s) is None) 25 26 27if __name__ == "__main__": 28 run_module_suite() 29