| 11 | |
| 12 | |
| 13 | def test_cache_save_after_clear(): |
| 14 | T = np.random.rand(10) |
| 15 | m = 3 |
| 16 | |
| 17 | cache_dir = "stumpy/__pycache__" |
| 18 | |
| 19 | cache.clear(cache_dir) |
| 20 | stump(T, m) |
| 21 | cache.save() # Enable and save both `.nbi` and `.nbc` cache files |
| 22 | |
| 23 | ref_cache = cache._get_cache(cache_dir) |
| 24 | |
| 25 | if numba.config.DISABLE_JIT: |
| 26 | assert len(ref_cache) == 0 |
| 27 | else: # pragma: no cover |
| 28 | assert len(ref_cache) > 0 |
| 29 | |
| 30 | cache.clear(cache_dir) |
| 31 | assert len(cache._get_cache(cache_dir)) == 0 |
| 32 | # Note that `stump(T, m)` has already been called once above and any subsequent |
| 33 | # calls to `cache.save()` will automatically save both `.nbi` and `.nbc` cache files |
| 34 | cache.save() # Save both `.nbi` and `.nbc` cache files |
| 35 | |
| 36 | comp_cache = cache._get_cache(cache_dir) |
| 37 | |
| 38 | assert sorted(ref_cache) == sorted(comp_cache) |
| 39 | |
| 40 | cache.clear(cache_dir) |