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 1717
1818import numpy as np
1919import pymc as pm
20- import xhistogram .core
2120from numpy .typing import ArrayLike
2221
2322try :
2625except ImportError :
2726 dask = None
2827
28+ try :
29+ import xhistogram .core
30+ except ImportError :
31+ xhistogram = None
32+
2933
3034__all__ = ["quantile_histogram" , "discrete_histogram" , "histogram_approximation" ]
3135
3236
3337def quantile_histogram (
3438 data : ArrayLike , n_quantiles = 1000 , zero_inflation = False
3539) -> Dict [str , ArrayLike ]:
40+ if xhistogram is None :
41+ raise RuntimeError ("quantile_histogram requires xhistogram package" )
42+
3643 if dask and isinstance (data , (dask .dataframe .Series , dask .dataframe .DataFrame )):
3744 data = data .to_dask_array (lengths = True )
3845 if zero_inflation :
@@ -67,6 +74,9 @@ def quantile_histogram(
6774
6875
6976def discrete_histogram (data : ArrayLike , min_count = None ) -> Dict [str , ArrayLike ]:
77+ if xhistogram is None :
78+ raise RuntimeError ("discrete_histogram requires xhistogram package" )
79+
7080 if dask and isinstance (data , (dask .dataframe .Series , dask .dataframe .DataFrame )):
7181 data = data .to_dask_array (lengths = True )
7282 mid , count_uniq = np .unique (data , return_counts = True )
Original file line number Diff line number Diff line change 11pymc >= 4.3.0
2- xhistogram
You can’t perform that action at this time.
0 commit comments