Skip to content

Commit f5719c3

Browse files
committed
Added example
1 parent 707f4c1 commit f5719c3

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

stumpy/cache.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,24 @@ def save():
253253
Notes
254254
-----
255255
The cache is never cleared before saving/overwriting and may be explicitly cleared
256-
by calling `cache.clear()` before saving. If `cache.save()` is called for the first
257-
time (before any `njit` function is called) then only the `.nbi` files (i.e., the
258-
"cache index") for all `njit` functions are saved. As each `njit` function (and
256+
by calling `cache.clear()` before saving. It is best practice to call `cache.save()`
257+
only after calling all of your `njit` functions. If `cache.save()` is called for the
258+
first time (before any `njit` function is called) then only the `.nbi` files (i.e.,
259+
the "cache index") for all `njit` functions are saved. As each `njit` function (and
259260
sub-functions) is called then their corresponding `.nbc` file (i.e., "object code")
260261
is saved. Each `.nbc` file will only be saved after its `njit` function is called
261-
once. However, subsequent calls to `cache.save()` (after clearing the cache via
262-
`cache.clear()`) will automatically save BOTH the `.nbi` files as well as the `.nbc`
263-
files as long as their `njit` function has been called at least once.
262+
at least once. However, subsequent calls to `cache.save()` (after clearing the cache
263+
via `cache.clear()`) will automatically save BOTH the `.nbi` files as well as the
264+
`.nbc` files as long as their `njit` function has been called at least once.
265+
266+
Examples
267+
--------
268+
>>> import stumpy
269+
>>> from stumpy import cache
270+
>>> import numpy as np
271+
>>> cache.clear()
272+
>>> mp = stumpy.stump(np.array([584., -11., 23., 79., 1001., 0., -19.]), m=3)
273+
>>> cache.save()
264274
"""
265275
if numba.config.DISABLE_JIT:
266276
msg = "Could not save/cache function because NUMBA JIT is disabled"

0 commit comments

Comments
 (0)