Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 320135
Collapse All | Expand All

(-)scipy/optimize/optimize.py.orig (-6 / +11 lines)
Lines 41-46 Link Here
41
    m = asarray(m)
41
    m = asarray(m)
42
    return numpy.minimum.reduce(m,axis)
42
    return numpy.minimum.reduce(m,axis)
43
43
44
def is_array_scalar(x):
45
    """Test whether `x` is either a scalar or an array scalar.
46
47
    """
48
    return len(atleast_1d(x) == 1)
49
44
abs = absolute
50
abs = absolute
45
import __builtin__
51
import __builtin__
46
pymin = __builtin__.min
52
pymin = __builtin__.min
Lines 1177-1189 Link Here
1177
1183
1178
    """
1184
    """
1179
    # Test bounds are of correct form
1185
    # Test bounds are of correct form
1180
    x1 = atleast_1d(x1)
1186
1181
    x2 = atleast_1d(x2)
1187
    if not (is_array_scalar(x1) and is_array_scalar(x2)):
1182
    if len(x1) != 1 or len(x2) != 1:
1188
        raise ValueError("Optimisation bounds must be scalars"
1183
        raise ValueError, "Optimisation bounds must be scalars" \
1189
                         " or array scalars.")
1184
                " or length 1 arrays"
1185
    if x1 > x2:
1190
    if x1 > x2:
1186
        raise ValueError, "The lower bound exceeds the upper bound."
1191
        raise ValueError("The lower bound exceeds the upper bound.")
1187
1192
1188
    flag = 0
1193
    flag = 0
1189
    header = ' Func-count     x          f(x)          Procedure'
1194
    header = ' Func-count     x          f(x)          Procedure'
(-)scipy/optimize/tests/test_optimize.py.orig (-1 / +8 lines)
Lines 159-168 Link Here
159
        assert abs(x - 1.5) < 1e-6
160
        assert abs(x - 1.5) < 1e-6
160
        assert_raises(ValueError,
161
        assert_raises(ValueError,
161
                optimize.fminbound, lambda x: (x - 1.5)**2 - 0.8, 5, 1)
162
                optimize.fminbound, lambda x: (x - 1.5)**2 - 0.8, 5, 1)
163
164
    def test_fminbound_scalar(self):
162
        assert_raises(ValueError,
165
        assert_raises(ValueError,
163
                optimize.fminbound, lambda x: (x - 1.5)**2 - 0.8,
166
                      optimize.fminbound, lambda x: (x - 1.5)**2 - 0.8,
164
                      np.zeros(2), 1)
167
                      np.zeros(2), 1)
165
168
169
        assert_almost_equal(
170
            optimize.fminbound(lambda x: (x - 1.5)**2 - 0.8, 1, np.array(5)),
171
            1.5)
172
173
166
class TestTnc(TestCase):
174
class TestTnc(TestCase):
167
    """TNC non-linear optimization.
175
    """TNC non-linear optimization.

Return to bug 320135