Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUG: fix distributions.fit() with 2 frozen parameters. Closes #1551.

  • Loading branch information...
commit a70f7db391b71581e5da9d353ebecacfb80af27c 1 parent f43dff7
@rgommers rgommers authored
View
5 scipy/stats/distributions.py
@@ -1792,12 +1792,13 @@ def _reduce_func(self, args, kwds):
fixedn = []
index = range(Nargs)
names = ['f%d' % n for n in range(Nargs - 2)] + ['floc', 'fscale']
- x0 = args[:]
+ x0 = []
for n, key in zip(index, names):
if kwds.has_key(key):
fixedn.append(n)
args[n] = kwds[key]
- del x0[n]
+ else:
+ x0.append(args[n])
if len(fixedn) == 0:
func = self.nnlf
View
8 scipy/stats/tests/test_distributions.py
@@ -488,6 +488,14 @@ def test_fix_fit(self):
assert_(len(vals5) == 2+len(args))
assert_(vals5[2] == args[2])
+ def test_fix_fit_2args_lognorm(self):
+ """Regression test for #1551."""
+ np.random.seed(12345)
+ x = stats.lognorm.rvs(0.25, 0., 20.0, size=20)
+ assert_allclose(np.array(stats.lognorm.fit(x, floc=0, fscale=20)),
+ [0.25888672, 0, 20], atol=1e-5)
+
+
class TestFrozen(TestCase):
"""Test that a frozen distribution gives the same results as the original object.
Please sign in to comment.
Something went wrong with that request. Please try again.