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 2
2
3
3
import numpy as np
4
4
import pymc as pm
5
- import xhistogram .core
6
5
from numpy .typing import ArrayLike
7
6
8
7
try :
11
10
except ImportError :
12
11
dask = None
13
12
13
+ try :
14
+ import xhistogram .core
15
+ except ImportError :
16
+ xhistogram = None
17
+
14
18
15
19
__all__ = ["quantile_histogram" , "discrete_histogram" , "histogram_approximation" ]
16
20
17
21
18
22
def quantile_histogram (
19
23
data : ArrayLike , n_quantiles = 1000 , zero_inflation = False
20
24
) -> Dict [str , ArrayLike ]:
25
+ if xhistogram is None :
26
+ raise RuntimeError ("quantile_histogram requires xhistogram package" )
27
+
21
28
if dask and isinstance (data , (dask .dataframe .Series , dask .dataframe .DataFrame )):
22
29
data = data .to_dask_array (lengths = True )
23
30
if zero_inflation :
@@ -52,6 +59,9 @@ def quantile_histogram(
52
59
53
60
54
61
def discrete_histogram (data : ArrayLike , min_count = None ) -> Dict [str , ArrayLike ]:
62
+ if xhistogram is None :
63
+ raise RuntimeError ("discrete_histogram requires xhistogram package" )
64
+
55
65
if dask and isinstance (data , (dask .dataframe .Series , dask .dataframe .DataFrame )):
56
66
data = data .to_dask_array (lengths = True )
57
67
mid , count_uniq = np .unique (data , return_counts = True )
Original file line number Diff line number Diff line change 1
1
pymc >= 4.0.1
2
- xhistogram
You can’t perform that action at this time.
0 commit comments