From c49821c55b45574cd7d5300ddd4a83f12fcaa7e0 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Mon, 27 Jul 2015 21:49:30 +0200 Subject: BUG: fixed regression in np.histogram which caused input floating-point values to be modified --- numpy/lib/tests/test_function_base.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'numpy/lib/tests/test_function_base.py') diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index a82fab6a7..b29012bcb 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1221,6 +1221,13 @@ class TestHistogram(TestCase): wa, wb = histogram(values, bins=2, range=[1, 3], weights=weights) assert_array_almost_equal(wa, [Decimal(1), Decimal(5)]) + def test_no_side_effects(self): + # This is a regression test that ensures that values passed to + # ``histogram`` are unchanged. + values = np.array([1.3, 2.5, 2.3]) + np.histogram(values, range=[-10, 10], bins=100) + assert_array_almost_equal(values, [1.3, 2.5, 2.3]) + def test_empty(self): a, b = histogram([], bins=([0, 1])) assert_array_equal(a, np.array([0])) -- cgit v1.2.1