Skip to content

Commit

Permalink
fix issue with numpy 2.0 in BRL
Browse files Browse the repository at this point in the history
  • Loading branch information
csinva committed Oct 15, 2024
1 parent 7581f43 commit e4436bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions imodels/rule_list/bayesian_rule_list/brl_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from collections import defaultdict

from numpy import *
import numpy
import numpy as np
from scipy.special import gammaln
from scipy.stats import poisson, beta

Expand Down Expand Up @@ -357,7 +357,10 @@ def bayesdl_mcmc(numiters, thinning, alpha, lbda, eta, X, Y, nruleslen, lhs_len,
def initialize_d(X, Y, lbda, eta, lhs_len, maxlhs, nruleslen):
'''Samples a list from the prior
'''
m = numpy.Inf
try:
m = np.inf
except:
m = np.Inf
while m >= len(X):
# sample the length of the list from Poisson(lbda), truncated at len(X)
m = poisson.rvs(lbda)
Expand Down Expand Up @@ -493,7 +496,7 @@ def prior_calculations(lbda, maxlen, eta, maxlhs):
try:
logalpha_pmf[i] = poisson.logpmf(i, lbda)
except RuntimeWarning:
logalpha_pmf[i] = -inf
logalpha_pmf[i] = -np.inf
logbeta_pmf = {}
for i in range(1, maxlhs + 1):
logbeta_pmf[i] = poisson.logpmf(i, eta)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
required_pypi = [
'matplotlib',
'mlxtend>=0.18.0', # some lower versions are missing fpgrowth
'numpy<2.0.0',
'numpy',
# tested with pandas 2.2.2 (but installing this pandas version will try to use newer np versions)
'pandas<2.2.2',
'pandas',
'requests', # used in c4.5
'scipy',
'scikit-learn>=1.2.0', # recently updated this
Expand Down

0 comments on commit e4436bf

Please sign in to comment.