code: def test_with_penalty():
      from mystic.math.measures import mean, spread
  
      @with_penalty(quadratic_equality, kwds={"target": 5.0})
      def penalty(x, target):
          return mean(x) - target
  
      def cost(x):
          return abs(sum(x) - 5.0)
  
      from mystic.solvers import fmin
      from numpy import array
  
      x = array([1, 2, 3, 4, 5])
      y = fmin(cost, x, penalty=penalty, disp=False)
  
      assert round(mean(y)) == 5.0
      assert round(cost(y)) == 4 * (5.0)
  
file_path: mystic/mystic/tests/test_constraints.py
imports: from mystic.constraints import *
  from mystic.penalty import quadratic_equality
  from mystic.coupler import inner
  from mystic.math import almostEqual
  from mystic.tools import random_seed
label_desc: Use image node_id 6 for calling a global function with example usage: test_with_penalty() and returns: unknown, abs