class_docstr: A ConstrainedFunction class used to hold constrained single-objective functions.
class_docstr_tok: ["A","ConstrainedFunction","class","used","to","hold","constrained","single-objective","functions","."]
code: def penalty(self, penalty: float) -> None:
      if not isinstance(penalty, (float, int)):
          raise e.TypeError("`penalty` should be a float or integer")
      if penalty < 0:
          raise e.ValueError("`penalty` should be >= 0")
  
      self._penalty = penalty
  
file_path: opytimizer/opytimizer/functions/constrained.py
imports: from typing import List
  import numpy
  import opytimizer.utils.exception
  from opytimizer.core import Function
  from opytimizer.utils import logging
label_desc: Use image node_id 5 for calling the ConstrainedFunction obj's underlying member method code with example usage: obj.penalty(penalty) without return types