@@ -56,8 +56,8 @@ def test_L1_norm(space, sigma):
56
56
x = noise_element (space )
57
57
58
58
# Test functional evaluation
59
- expected_result = func . domain . element ( np .abs (x ) ).inner (space .one ())
60
- assert pytest . approx ( func (x ), expected_result )
59
+ expected_result = np .abs (x ).inner (space .one ())
60
+ assert func (x ) == pytest . approx ( expected_result )
61
61
62
62
# Test gradient - expecting sign function
63
63
expected_result = func .domain .element (np .sign (x ))
@@ -125,7 +125,7 @@ def test_L2_norm(space, sigma):
125
125
126
126
# Test functional evaluation
127
127
expected_result = np .sqrt ((x ** 2 ).inner (space .one ()))
128
- assert pytest . approx ( func (x ), expected_result )
128
+ assert func (x ) == pytest . approx ( expected_result )
129
129
130
130
# Test gradient
131
131
if x_norm > 0 :
@@ -172,7 +172,7 @@ def test_L2_norm(space, sigma):
172
172
173
173
# Verify that the biconjugate is the functional itself
174
174
func_cc_cc = func_cc .convex_conj
175
- assert pytest . approx ( func_cc_cc (x ), func (x ))
175
+ assert func_cc_cc (x ) == pytest . approx ( func (x ))
176
176
177
177
178
178
def test_L2_norm_squared (space , sigma ):
@@ -183,7 +183,7 @@ def test_L2_norm_squared(space, sigma):
183
183
184
184
# Test functional evaluation
185
185
expected_result = x_norm ** 2
186
- assert pytest . approx ( func (x ), expected_result )
186
+ assert func (x ) == pytest . approx ( expected_result )
187
187
188
188
# Test gradient
189
189
expected_result = 2.0 * x
@@ -198,7 +198,7 @@ def test_L2_norm_squared(space, sigma):
198
198
199
199
# Test evaluation of the convex conjugate
200
200
expected_result = x_norm ** 2 / 4.0
201
- assert pytest . approx ( func_cc (x ), expected_result )
201
+ assert func_cc (x ) == pytest . approx ( expected_result )
202
202
203
203
# Test gradient of the convex conjugate
204
204
expected_result = x / 2.0
@@ -212,7 +212,7 @@ def test_L2_norm_squared(space, sigma):
212
212
func_cc_cc = func_cc .convex_conj
213
213
214
214
# Check that they evaluate to the same value
215
- assert pytest . approx ( func_cc_cc (x ), func (x ))
215
+ assert func_cc_cc (x ) == pytest . approx ( func (x ))
216
216
217
217
# Check that their gradients evaluate to the same value
218
218
assert all_almost_equal (func_cc_cc .gradient (x ), func .gradient (x ))
@@ -281,7 +281,7 @@ def test_kullback_leibler(space):
281
281
# Evaluation of the functional
282
282
expected_result = ((x - prior + prior * np .log (prior / x ))
283
283
.inner (one_elem ))
284
- assert pytest . approx ( func (x ), expected_result )
284
+ assert func (x ) == pytest . approx ( expected_result )
285
285
286
286
# Check property for prior
287
287
assert all_almost_equal (func .prior , prior )
@@ -317,7 +317,7 @@ def test_kullback_leibler(space):
317
317
# Evaluation of convex conjugate
318
318
with np .errstate (all = 'ignore' ):
319
319
expected_result = - (prior * np .log (1 - x )).inner (one_elem )
320
- assert pytest . approx ( cc_func (x ), expected_result )
320
+ assert cc_func (x ) == pytest . approx ( expected_result )
321
321
322
322
x_wrong = noise_element (space )
323
323
x_wrong = x_wrong - x_wrong .ufuncs .max () + 1.01
@@ -340,7 +340,7 @@ def test_kullback_leibler(space):
340
340
341
341
# Check that they evaluate the same
342
342
with np .errstate (all = 'ignore' ):
343
- assert pytest . approx ( cc_cc_func (x ), func (x ))
343
+ assert cc_cc_func (x ) == pytest . approx ( func (x ))
344
344
345
345
346
346
def test_kullback_leibler_cross_entorpy (space ):
@@ -359,7 +359,7 @@ def test_kullback_leibler_cross_entorpy(space):
359
359
# Evaluation of the functional
360
360
expected_result = ((prior - x + x * np .log (x / prior ))
361
361
.inner (one_elem ))
362
- assert pytest . approx ( func (x ), expected_result )
362
+ assert func (x ) == pytest . approx ( expected_result )
363
363
364
364
# Check property for prior
365
365
assert all_almost_equal (func .prior , prior )
@@ -390,7 +390,7 @@ def test_kullback_leibler_cross_entorpy(space):
390
390
391
391
# Evaluation of convex conjugate
392
392
expected_result = (prior * (np .exp (x ) - 1 )).inner (one_elem )
393
- assert pytest . approx ( cc_func (x ), expected_result )
393
+ assert cc_func (x ) == pytest . approx ( expected_result )
394
394
395
395
# The gradient of the convex conjugate
396
396
expected_result = prior * np .exp (x )
@@ -406,7 +406,7 @@ def test_kullback_leibler_cross_entorpy(space):
406
406
cc_cc_func = cc_func .convex_conj
407
407
408
408
# Check that they evaluate the same
409
- assert pytest . approx ( cc_cc_func (x ), func (x ))
409
+ assert cc_cc_func (x ) == pytest . approx ( func (x ))
410
410
411
411
412
412
def test_quadratic_form (space ):
@@ -425,7 +425,7 @@ def test_quadratic_form(space):
425
425
426
426
# Evaluation of the functional
427
427
expected_result = x .inner (operator (x )) + vector .inner (x ) + constant
428
- assert pytest . approx ( func (x ), expected_result )
428
+ assert func (x ) == pytest . approx ( expected_result )
429
429
430
430
# The gradient
431
431
expected_gradient = 2 * operator (x ) + vector
@@ -438,7 +438,7 @@ def test_quadratic_form(space):
438
438
func_no_operator = odl .solvers .QuadraticForm (vector = vector ,
439
439
constant = constant )
440
440
expected_result = vector .inner (x ) + constant
441
- assert pytest . approx ( func_no_operator (x ), expected_result )
441
+ assert func_no_operator (x ) == pytest . approx ( expected_result )
442
442
443
443
expected_gradient = vector
444
444
assert all_almost_equal (func_no_operator .gradient (x ), expected_gradient )
@@ -455,7 +455,7 @@ def test_quadratic_form(space):
455
455
# Test with no offset
456
456
func_no_offset = odl .solvers .QuadraticForm (operator , constant = constant )
457
457
expected_result = x .inner (operator (x )) + constant
458
- assert pytest . approx ( func_no_offset (x ), expected_result )
458
+ assert func_no_offset (x ) == pytest . approx ( expected_result )
459
459
460
460
461
461
def test_separable_sum (space ):
0 commit comments