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 17
17
18
18
import numpy as np
19
19
import pymc as pm
20
- import xhistogram .core
21
20
from numpy .typing import ArrayLike
22
21
23
22
try :
26
25
except ImportError :
27
26
dask = None
28
27
28
+ try :
29
+ import xhistogram .core
30
+ except ImportError :
31
+ xhistogram = None
32
+
29
33
30
34
__all__ = ["quantile_histogram" , "discrete_histogram" , "histogram_approximation" ]
31
35
32
36
33
37
def quantile_histogram (
34
38
data : ArrayLike , n_quantiles = 1000 , zero_inflation = False
35
39
) -> Dict [str , ArrayLike ]:
40
+ if xhistogram is None :
41
+ raise RuntimeError ("quantile_histogram requires xhistogram package" )
42
+
36
43
if dask and isinstance (data , (dask .dataframe .Series , dask .dataframe .DataFrame )):
37
44
data = data .to_dask_array (lengths = True )
38
45
if zero_inflation :
@@ -67,6 +74,9 @@ def quantile_histogram(
67
74
68
75
69
76
def discrete_histogram (data : ArrayLike , min_count = None ) -> Dict [str , ArrayLike ]:
77
+ if xhistogram is None :
78
+ raise RuntimeError ("discrete_histogram requires xhistogram package" )
79
+
70
80
if dask and isinstance (data , (dask .dataframe .Series , dask .dataframe .DataFrame )):
71
81
data = data .to_dask_array (lengths = True )
72
82
mid , count_uniq = np .unique (data , return_counts = True )
Original file line number Diff line number Diff line change 1
1
pymc >= 4.3.0
2
- xhistogram
You can’t perform that action at this time.
0 commit comments