File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
pymc_experimental/distributions Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 22
33import numpy as np
44import pymc as pm
5- import xhistogram .core
65from numpy .typing import ArrayLike
76
87try :
1110except ImportError :
1211 dask = None
1312
13+ try :
14+ import xhistogram .core
15+ except ImportError :
16+ xhistogram = None
17+
1418
1519__all__ = ["quantile_histogram" , "discrete_histogram" , "histogram_approximation" ]
1620
1721
1822def quantile_histogram (
1923 data : ArrayLike , n_quantiles = 1000 , zero_inflation = False
2024) -> Dict [str , ArrayLike ]:
25+ if xhistogram is None :
26+ raise RuntimeError ("quantile_histogram requires xhistogram package" )
27+
2128 if dask and isinstance (data , (dask .dataframe .Series , dask .dataframe .DataFrame )):
2229 data = data .to_dask_array (lengths = True )
2330 if zero_inflation :
@@ -52,6 +59,9 @@ def quantile_histogram(
5259
5360
5461def discrete_histogram (data : ArrayLike , min_count = None ) -> Dict [str , ArrayLike ]:
62+ if xhistogram is None :
63+ raise RuntimeError ("discrete_histogram requires xhistogram package" )
64+
5565 if dask and isinstance (data , (dask .dataframe .Series , dask .dataframe .DataFrame )):
5666 data = data .to_dask_array (lengths = True )
5767 mid , count_uniq = np .unique (data , return_counts = True )
Original file line number Diff line number Diff line change 11pymc >= 4.0.1
2- xhistogram
You can’t perform that action at this time.
0 commit comments