Skip to content

Commit

Permalink
Merge pull request scipy#5377 from perimosocordiae/quad-bugfix
Browse files Browse the repository at this point in the history
BUG: integrate: builtin name no longer shadowed
  • Loading branch information
pv committed Oct 17, 2015
2 parents f861ec2 + 9728649 commit 8ae0dc2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions scipy/integrate/quadrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ def _basic_simps(y, start, stop, x, dx, axis):
# Account for possibly different spacings.
# Simpson's rule changes a bit.
h = np.diff(x, axis=axis)
sl0 = tupleset(all, axis, slice(start, stop, step))
sl1 = tupleset(all, axis, slice(start+1, stop+1, step))
sl0 = tupleset(slice_all, axis, slice(start, stop, step))
sl1 = tupleset(slice_all, axis, slice(start+1, stop+1, step))
h0 = h[sl0]
h1 = h[sl1]
hsum = h0 + h1
Expand Down
14 changes: 13 additions & 1 deletion scipy/integrate/tests/test_quadrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
assert_almost_equal, assert_allclose, assert_

from scipy.integrate import (quadrature, romberg, romb, newton_cotes,
cumtrapz, quad)
cumtrapz, quad, simps)
from scipy.integrate.quadrature import AccuracyWarning


Expand Down Expand Up @@ -127,6 +127,18 @@ def test_newton_cotes2(self):
numeric_integral = np.dot(wts, y)
assert_almost_equal(numeric_integral, exact_integral)

def test_simps(self):
y = np.arange(17)
assert_equal(simps(y), 128)
assert_equal(simps(y, dx=0.5), 64)
assert_equal(simps(y, x=np.linspace(0, 4, 17)), 32)

y = np.arange(4)
x = 2**y
assert_equal(simps(y, x=x, even='avg'), 13.875)
assert_equal(simps(y, x=x, even='first'), 13.75)
assert_equal(simps(y, x=x, even='last'), 14)


class TestCumtrapz(TestCase):
def test_1d(self):
Expand Down

0 comments on commit 8ae0dc2

Please sign in to comment.