Skip to content

Commit

Permalink
Merge pull request #6985 from bashtage/remove-print
Browse files Browse the repository at this point in the history
MAINT: Remove print statements
  • Loading branch information
bashtage committed Aug 24, 2020
2 parents 1659994 + 98dfc00 commit 26d901a
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 90 deletions.
1 change: 0 additions & 1 deletion statsmodels/base/model.py
Expand Up @@ -2383,7 +2383,6 @@ def bootstrap(self, nrep=100, method='nm', disp=0, store=1):
distributed observations.
"""
results = []
print(self.model.__class__)
hascloneattr = True if hasattr(self.model, 'cloneattr') else False
for i in range(nrep):
rvsind = np.random.randint(self.nobs, size=self.nobs)
Expand Down
7 changes: 2 additions & 5 deletions statsmodels/discrete/tests/test_constrained.py
Expand Up @@ -553,12 +553,9 @@ def junk(): # FIXME: make this into a test, or move/remove
# example without offset
formula1a = 'deaths ~ logpyears + smokes + C(agecat)'
mod1a = Poisson.from_formula(formula1a, data=data)
print(mod1a.exog.shape)

mod1a.fit()
lc_1a = patsy.DesignInfo(mod1a.exog_names).linear_constraint(
'C(agecat)[T.4] = C(agecat)[T.5]')
resc1a = mod1a.fit_constrained(lc_1a.coefs, lc_1a.constants,
fit_kwds={'method': 'newton'})
print(resc1a[0])
print(resc1a[1])
mod1a.fit_constrained(lc_1a.coefs, lc_1a.constants,
fit_kwds={'method': 'newton'})
46 changes: 0 additions & 46 deletions statsmodels/nonparametric/kde.py
Expand Up @@ -498,49 +498,3 @@ def kdensityfft(X, kernel="gau", bw="normal_reference", weights=None, gridsize=N
return f, grid, bw
else:
return f, bw

if __name__ == "__main__":
import numpy as np
np.random.seed(12345)
xi = np.random.randn(100)
f,grid, bw1 = kdensity(xi, kernel="gau", bw=.372735, retgrid=True)
f2, bw2 = kdensityfft(xi, kernel="gau", bw="silverman",retgrid=False)

# do some checking vs. silverman algo.
# you need denes.f, http://lib.stat.cmu.edu/apstat/176
#NOTE: I (SS) made some changes to the Fortran
# and the FFT stuff from Munro http://lib.stat.cmu.edu/apstat/97o
# then compile everything and link to denest with f2py
#Make pyf file as usual, then compile shared object
#f2py denest.f -m denest2 -h denest.pyf
#edit pyf
#-c flag makes it available to other programs, fPIC builds a shared library
#/usr/bin/gfortran -Wall -c -fPIC fft.f
#f2py -c denest.pyf ./fft.o denest.f

try:
from denest2 import denest # @UnresolvedImport
a = -3.4884382032045504
b = 4.3671504686785605
RANGE = b - a
bw = bandwidths.bw_silverman(xi)

ft,smooth,ifault,weights,smooth1 = denest(xi,a,b,bw,np.zeros(512),np.zeros(512),0,
np.zeros(512), np.zeros(512))
# We use a different binning algo, so only accurate up to 3 decimal places
np.testing.assert_almost_equal(f2, smooth, 3)
#NOTE: for debugging
# y2 = forrt(weights)
# RJ = np.arange(512/2+1)
# FAC1 = 2*(np.pi*bw/RANGE)**2
# RJFAC = RJ**2*FAC1
# BC = 1 - RJFAC/(6*(bw/((b-a)/M))**2)
# FAC = np.exp(-RJFAC)/BC
# SMOOTH = np.r_[FAC,FAC[1:-1]] * y2

# dens = revrt(SMOOTH)

except:
# ft = np.loadtxt('./ft_silver.csv')
# smooth = np.loadtxt('./smooth_silver.csv')
print("Did not get the estimates from the Silverman algorithm")
3 changes: 0 additions & 3 deletions statsmodels/nonparametric/smoothers_lowess.py
Expand Up @@ -211,22 +211,19 @@ def lowess(endog, exog, frac=2.0/3.0, it=3, delta=0.0, xvals=None, is_sorted=Fal

if not given_xvals:
# Run LOWESS on the data points
print("Not giving xvalues")
res, _ = _lowess(y, x, x, np.ones_like(x),
frac=frac, it=it, delta=delta, given_xvals=False)
else:
# First run LOWESS on the data points to get the weights of the data points
# using it-1 iterations, last iter done next
if it > 0:
print("Not giving xvalues")
_, weights = _lowess(y, x, x, np.ones_like(x),
frac=frac, it=it-1, delta=delta, given_xvals=False)
else:
weights = np.ones_like(x)

# Then run once more using those supplied weights at the points provided by xvals
# No extra iterations are performed here since weights are fixed
print("giving xvalues")
res, _ = _lowess(y, x, xvalues, weights,
frac=frac, it=0, delta=delta, given_xvals=True)

Expand Down
11 changes: 0 additions & 11 deletions statsmodels/nonparametric/tests/test_kernels.py
Expand Up @@ -85,19 +85,10 @@ def test_smoothconf(self):
se_n_diff = self.se_n_diff
assert_array_less(mask.sum(), se_n_diff + 1) # at most 5 large diffs

if DEBUG:
# raises: RuntimeWarning: invalid value encountered in divide
print(fitted / res_fitted - 1)
print(se / res_se - 1)
# Stata only displays ci, does not save it
res_upp = res_fitted + crit * res_se
res_low = res_fitted - crit * res_se
self.res_fittedg = np.column_stack((res_low, res_fitted, res_upp))
if DEBUG:
print(fittedg[:, 2] / res_upp - 1)
print(fittedg[:, 2] - res_upp)
print(fittedg[:, 0] - res_low)
print(np.max(np.abs(fittedg[:, 2] / res_upp - 1)))
assert_allclose(fittedg[se_valid, 2], res_upp[se_valid],
rtol=self.upp_rtol, atol=0.2)
assert_allclose(fittedg[se_valid, 0], res_low[se_valid],
Expand All @@ -112,8 +103,6 @@ def test_smoothconf_data(self):
crit = 1.9599639845400545 # norm.isf(0.05 / 2)
# no reference results saved to csv yet
fitted_x = np.array([kern.smoothconf(x, y, xi) for xi in x])
if DEBUG:
print(fitted_x[:, 2] - fitted_x[:, 1]) / crit


class TestEpan(CheckKernelMixin):
Expand Down
15 changes: 0 additions & 15 deletions statsmodels/stats/_adnorm.py
Expand Up @@ -137,18 +137,3 @@ def normal_ad(x, axis=0):
pval[mask] = pvalli[i](ad2a[mask])

return ad2, pval


if __name__ == '__main__':
x = np.array([-0.1184, -1.3403, 0.0063, -0.612, -0.3869, -0.2313,
-2.8485, -0.2167, 0.4153, 1.8492, -0.3706, 0.9726,
-0.1501, -0.0337, -1.4423, 1.2489, 0.9182, -0.2331,
-0.6182, 0.1830])
r_res = np.array([0.58672353588821502, 0.1115380760041617])
ad2, pval = normal_ad(x)
print(ad2, pval)
print(r_res - [ad2, pval])

print(anderson_statistic((x - x.mean()) / x.std(), dist=stats.norm,
fit=False))
print(anderson_statistic(x, dist=stats.norm, fit=True))
1 change: 0 additions & 1 deletion statsmodels/stats/descriptivestats.py
Expand Up @@ -499,7 +499,6 @@ def _mode(ser):
while dupe:
scale *= 10
idx = np.floor(scale * perc.index)
print(np.diff(idx))
if np.all(np.diff(idx) > 0):
dupe = False
index = np.floor(scale * index) / (scale / 100)
Expand Down
1 change: 0 additions & 1 deletion statsmodels/stats/multivariate.py
Expand Up @@ -579,7 +579,6 @@ def test_cov_oneway(cov_list, nobs_list):
else:
tmp = b2 * stat0
statistic_f = a2 / a1 * tmp / (1 + tmp)
print("in branch 2")
df_f = (a1, a2)
pvalue_f = stats.f.sf(statistic_f, *df_f)
return HolderTuple(statistic=statistic_f, # name convention, using F here
Expand Down
7 changes: 0 additions & 7 deletions statsmodels/tools/rootfinding.py
Expand Up @@ -130,8 +130,6 @@ def brentq_expanding(func, low=None, upp=None, args=(), xtol=1e-5,
sl = 1e-8
f_low = func(sl, *args)
increasing = (f_low < f_upp)
if DEBUG:
print('symm', sl, su, f_low, f_upp)

# possibly func returns nan
delta = su - sl
Expand Down Expand Up @@ -162,11 +160,6 @@ def brentq_expanding(func, low=None, upp=None, args=(), xtol=1e-5,

increasing = (f_low < f_upp)

if DEBUG:
print('low, upp', low, upp, func(sl, *args), func(su, *args))
print('increasing', increasing)
print('sl, su', sl, su)

if not increasing:
sl, su = su, sl
left, right = right, left
Expand Down

0 comments on commit 26d901a

Please sign in to comment.