@@ -50,7 +50,7 @@ def get_njit_funcs():
5050 func_name = node .name
5151 for decorator in node .decorator_list :
5252 decorator_name = None
53- if isinstance (decorator , ast .Name ):
53+ if isinstance (decorator , ast .Name ): # pragma: no cover
5454 # Bare decorator
5555 decorator_name = decorator .id
5656 if isinstance (decorator , ast .Call ) and isinstance (
@@ -79,7 +79,7 @@ def _enable():
7979 """
8080 frame = inspect .currentframe ()
8181 caller_name = inspect .getouterframes (frame )[1 ].function
82- if caller_name != "_save" :
82+ if caller_name != "_save" : # pragma: no cover
8383 msg = (
8484 "The 'cache._enable()' function is deprecated and no longer supported. "
8585 + "Please use 'cache.save()' instead"
@@ -90,7 +90,16 @@ def _enable():
9090 for module_name , func_name in njit_funcs :
9191 module = importlib .import_module (f".{ module_name } " , package = "stumpy" )
9292 func = getattr (module , func_name )
93- func .enable_caching ()
93+ try :
94+ func .enable_caching ()
95+ except AttributeError as e :
96+ if (
97+ numba .config .DISABLE_JIT
98+ and str (e ) == "'function' object has no attribute 'enable_caching'"
99+ ):
100+ pass
101+ else : # pragma: no cover
102+ raise
94103
95104
96105def _clear ():
@@ -167,7 +176,16 @@ def _recompile():
167176 for module_name , func_name in get_njit_funcs ():
168177 module = importlib .import_module (f".{ module_name } " , package = "stumpy" )
169178 func = getattr (module , func_name )
170- func .recompile ()
179+ try :
180+ func .recompile ()
181+ except AttributeError as e :
182+ if (
183+ numba .config .DISABLE_JIT
184+ and str (e ) == "'function' object has no attribute 'recompile'"
185+ ):
186+ pass
187+ else : # pragma: no cover
188+ raise
171189
172190 return
173191
@@ -206,8 +224,9 @@ def save():
206224 if numba .config .DISABLE_JIT :
207225 msg = "Could not save/cache function because NUMBA JIT is disabled"
208226 warnings .warn (msg )
209- else :
227+ else : # pragma: no cover
210228 warnings .warn (CACHE_WARNING )
211- _save ()
229+
230+ _save ()
212231
213232 return
0 commit comments