File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515import contextlib
16+ import importlib .metadata
1617import importlib .util
1718import inspect
1819import logging
8788
8889NUTPIE_INSTALLED = importlib .util .find_spec ("nutpie" ) is not None
8990
91+ # Bump when PyMC starts using a feature that requires a newer nutpie release.
92+ # Installed versions below this still work via fallback paths but get a FutureWarning
93+ # the first time they are used in a `pm.sample` call.
94+ _NUTPIE_MIN_SUPPORTED = (0 , 16 , 8 )
95+ _NUTPIE_VERSION : tuple [int , ...] | None = (
96+ tuple (int (p ) for p in importlib .metadata .version ("nutpie" ).split ("." )[:3 ])
97+ if NUTPIE_INSTALLED
98+ else None
99+ )
100+
90101
91102sys .setrecursionlimit (10000 )
92103
@@ -365,6 +376,14 @@ def _sample_external_nuts(
365376 raise ImportError (
366377 "nutpie not found. Install it with conda install -c conda-forge nutpie"
367378 )
379+ if _NUTPIE_VERSION is not None and _NUTPIE_VERSION < _NUTPIE_MIN_SUPPORTED :
380+ warnings .warn (
381+ f"nutpie { '.' .join (map (str , _NUTPIE_VERSION ))} is installed; "
382+ f"support for nutpie < { '.' .join (map (str , _NUTPIE_MIN_SUPPORTED ))} "
383+ "is deprecated and will be removed in a future PyMC release." ,
384+ FutureWarning ,
385+ stacklevel = 3 ,
386+ )
368387 import nutpie
369388
370389 if initvals is not None :
You can’t perform that action at this time.
0 commit comments