|
10 | 10 |
|
11 | 11 | def test_cache_save():
|
12 | 12 | def get_cache_fnames_ref():
|
13 |
| - cache._clear() |
| 13 | + cache.clear() |
14 | 14 | cache._enable()
|
15 | 15 | stump(np.random.rand(10), 3)
|
16 |
| - cache_data_fnames = [ |
17 |
| - fname for fname in cache._get_cache() if fname.endswith(".nbc") |
18 |
| - ] |
19 |
| - cache_index_fnames = [ |
20 |
| - fname for fname in cache._get_cache() if fname.endswith(".nbi") |
21 |
| - ] |
22 |
| - cache._clear() |
23 |
| - return cache_data_fnames, cache_index_fnames |
| 16 | + cache_files = cache._get_cache() |
| 17 | + cache.clear() |
| 18 | + return cache_files |
24 | 19 |
|
25 | 20 | def get_cache_fnames_comp():
|
26 |
| - cache._clear() |
27 |
| - cache._save() |
| 21 | + cache.clear() |
| 22 | + cache.save() |
28 | 23 | stump(np.random.rand(10), 3)
|
29 |
| - cache_data_fnames = [ |
30 |
| - fname for fname in cache._get_cache() if fname.endswith(".nbc") |
31 |
| - ] |
32 |
| - cache_index_fnames = [ |
33 |
| - fname for fname in cache._get_cache() if fname.endswith(".nbi") |
34 |
| - ] |
35 |
| - cache._clear() |
36 |
| - return cache_data_fnames, cache_index_fnames |
| 24 | + cache_files = cache._get_cache() |
| 25 | + cache.clear() |
| 26 | + return cache_files |
37 | 27 |
|
38 |
| - ref_data, ref_index = get_cache_fnames_ref() |
39 |
| - comp_data, comp_index = get_cache_fnames_comp() |
| 28 | + ref_cache_files = get_cache_fnames_ref() |
| 29 | + comp_cache_files = get_cache_fnames_comp() |
40 | 30 |
|
41 |
| - assert sorted(ref_data) == sorted(comp_data) |
42 |
| - assert set(ref_index).issubset(comp_index) |
| 31 | + # check nbc files |
| 32 | + ref_nbc = [fname for fname in ref_cache_files if fname.endswith(".nbc")] |
| 33 | + comp_nbc = [fname for fname in comp_cache_files if fname.endswith(".nbc")] |
| 34 | + assert sorted(ref_nbc) == sorted(comp_nbc) |
| 35 | + |
| 36 | + # check nbi files |
| 37 | + ref_nbi = [fname for fname in ref_cache_files if fname.endswith(".nbi")] |
| 38 | + comp_nbi = [fname for fname in comp_cache_files if fname.endswith(".nbi")] |
| 39 | + assert set(ref_nbi).issubset(comp_nbi) |
43 | 40 |
|
44 | 41 |
|
45 | 42 | def test_cache_save_after_clear():
|
46 | 43 | T = np.random.rand(10)
|
47 | 44 | m = 3
|
48 | 45 | stump(T, m)
|
49 | 46 |
|
50 |
| - cache._save() |
| 47 | + cache.save() |
51 | 48 | ref_cache = cache._get_cache()
|
52 | 49 |
|
53 |
| - cache._clear() |
| 50 | + cache.clear() |
54 | 51 | # testing cache._clear()
|
55 | 52 | assert len(cache._get_cache()) == 0
|
56 | 53 |
|
57 |
| - cache._save() |
| 54 | + cache.save() |
58 | 55 | comp_cache = cache._get_cache()
|
59 | 56 |
|
60 | 57 | # testing cache._save() after cache._clear()
|
|
0 commit comments