Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion statsmodels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
if PY3:
# ResourceWarning doesn't exist in python 2
# we have currently many ResourceWarnings in the datasets on python 3.4
warnings.simplefilter("ignore", ResourceWarning)
warnings.simplefilter("ignore", ResourceWarning) # noqa:F821

test = PytestTester()

Expand Down
21 changes: 12 additions & 9 deletions statsmodels/distributions/empirical_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,18 @@ class ECDF(StepFunction):
array([ 0.75, 1. , 0. , 0.25])
"""
def __init__(self, x, side='right'):
step = True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lossy change since it loses what to do it step is added as an option. Could leave as a well-formatted comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other branch hides a NameError since ival isn't defined (besides which it has a return in it). So the alternative is to replace line 143 with raising NotImplementedError. I prefer this route because it isn't hard-coding a branching.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m open to ideas if there’s a third option

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like

# TODO: make step an arg and have a linear interpolation option?
# This is the path for step is True
# If step is False, interp1d(x,y,drop_errors=False,fill_values=ival)
# which currently raises a NameError, and so would need to be fixed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the suggested change.

This is one of the occasions where I'd be on board with the "thats what git history is for" approach to keeping the old version accessible (or just a reference back to this thread).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De facto green

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. These types of comments would help should someone every try and rescue this code. They make it much easier to merge changes like this.

if step: #TODO: make this an arg and have a linear interpolation option?
x = np.array(x, copy=True)
x.sort()
nobs = len(x)
y = np.linspace(1./nobs,1,nobs)
super(ECDF, self).__init__(x, y, side=side, sorted=True)
else:
return interp1d(x,y,drop_errors=False,fill_values=ival)
x = np.array(x, copy=True)
x.sort()
nobs = len(x)
y = np.linspace(1./nobs,1,nobs)
super(ECDF, self).__init__(x, y, side=side, sorted=True)
# TODO: make `step` an arg and have a linear interpolation option?
# This is the path with `step` is True
# If `step` is False, a previous version of the code read
# `return interp1d(x,y,drop_errors=False,fill_values=ival)`
# which would have raised a NameError if hit, so would need to be
# fixed. See GH#5701.


def monotone_fn_inverter(fn, x, vectorized=True, **keywords):
"""
Expand Down
2 changes: 1 addition & 1 deletion statsmodels/sandbox/bspline.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,4 +663,4 @@ def _gcv(pen, y, x):
a = self.gcv()
return a

a = golden(_gcv, args=(y,x), brack=bracket, tol=tol)
a = golden(_gcv, args=(y,x), brack=brack, tol=tol)
2 changes: 1 addition & 1 deletion statsmodels/sandbox/regression/runmnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def loglike_branch(self, params, tau):
#not yet sure how to keep track of branches during walking of tree
ivs = []
for b in branches:
probs, iv = loglike_leafbranch(self, params, tau)
probs, iv = self.loglike_leafbranch(params, tau)
ivs.append(iv)

#ivs = np.array(ivs) #note ivs is (nobs,nbranchchoices)
Expand Down
2 changes: 1 addition & 1 deletion statsmodels/sandbox/stats/stats_mstats_short.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def edf_normal_inverse_transformed(x, alpha=3./8, beta=3./8, axis=0):
'''rank based normal inverse transformed cdf
'''
from scipy import stats
ranks = plotting_positions(data, alpha=alpha, beta=alpha, axis=0, masknan=False)
ranks = plotting_positions(x, alpha=alpha, beta=alpha, axis=0, masknan=False)
ranks_transf = stats.norm.ppf(ranks)
return ranks_transf

Expand Down
2 changes: 1 addition & 1 deletion statsmodels/sandbox/tests/maketests_mlabwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def generate_armarep(filen='testsave.py'):



def exampletest():
def exampletest(res_armarep):
from statsmodels.sandbox import tsa
arrep = tsa.arma_impulse_response(res_armarep.ma, res_armarep.ar, nobs=21)[1:]
marep = tsa.arma_impulse_response(res_armarep.ar, res_armarep.ma, nobs=21)[1:]
Expand Down
2 changes: 1 addition & 1 deletion statsmodels/sandbox/tools/mctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def run(self, nrepl, statindices=None, dgpargs=[], statsargs=[]):
#self.nreturn = nreturns = 1
mcres = np.zeros(nrepl)
mcres[0] = mcres0
for ii in range(1, repl-1, nreturns):
for ii in range(1, nrepl-1, nreturns):
x = dgp(*dgpargs) #(1e-4+np.random.randn(nobs)).cumsum()
#should I ravel?
mcres[ii] = statfun(x, *statsargs) #unitroot_adf(x, 2,trendorder=0, autolag=None)
Expand Down
1 change: 1 addition & 0 deletions statsmodels/sandbox/tsa/example_arma.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#from movstat import acf, acovf
#from statsmodels.sandbox.tsa import acf, acovf, pacf
from statsmodels.tsa.stattools import acf, acovf, pacf
from statsmodels.graphics.tsaplots import plotacf

ar = [1., -0.6]
#ar = [1., 0.]
Expand Down