class_docstr: Penalty applied to linear transformation of parameters
  
  Parameters
  ----------
  penalty: instance of penalty function
      currently this requires an instance of a univariate, vectorized
      penalty class
  weights : None or ndarray
      weights for adding penalties of transformed params
  restriction : None or ndarray
      If it is not None, then restriction defines a linear transformation
      of the parameters. The penalty function is applied to each transformed
      parameter independently.
  
  Notes
  -----
  `restrictions` allows us to impose penalization on contrasts or stochastic
  constraints of the original parameters.
  Examples for these contrast are difference penalities or all pairs
  penalties.
class_docstr_tok: ["Penalty","applied","to","linear","transformation","of","parameters","Parameters","--","--","--","--","--","penalty",":","instance","of","penalty","function","currently","this","requires","an","instance","of","a","univariate",",","vectorized","penalty","class","weights",":","None","or","ndarray","weights","for","adding","penalties","of","transformed","params","restriction",":","None","or","ndarray","If","it","is","not","None",",","then","restriction","defines","a","linear","transformation","of","the","parameters",".","The","penalty","function","is","applied","to","each","transformed","parameter","independently",".","Notes","--","--","-","`","restrictions","`","allows","us","to","impose","penalization","on","contrasts","or","stochastic","constraints","of","the","original","parameters",".","Examples","for","these","contrast","are","difference","penalities","or","all","pairs","penalties","."]
docstr: second derivative of penalty function w.r.t. params
  
  Parameter
  ---------
  params : ndarray
      array of parameters at which derivative is evaluated
  
  Returns
  -------
  deriv2 : ndarray, 2-D
      second derivative matrix
docstr_tok: ["second","derivative","of","penalty","function","w.r.t",".","params","Parameter","--","--","--","--","-","params",":","ndarray","array","of","parameters","at","which","derivative","is","evaluated","Returns","--","--","--","-","deriv2",":","ndarray",",","2-D","second","derivative","matrix"]
code: def deriv2(self, params):
      """second derivative of penalty function w.r.t. params
  
      Parameter
      ---------
      params : ndarray
          array of parameters at which derivative is evaluated
  
      Returns
      -------
      deriv2 : ndarray, 2-D
          second derivative matrix
      """
  
      if self.restriction is not None:
          params = self.restriction.dot(params)
  
      value = self.penalty.deriv2(params)
  
      if self.restriction is not None:
          # note: univariate penalty returns 1d array for diag,
          # i.e. hessian_diag
          v = self.restriction.T * value * self.weights
          value = v.dot(self.restriction)
      else:
          value = np.diag(self.weights * value)
  
      return value
  
imports: import numpy
label_desc: Use image node_id 4 for calling the ConstraintsPenalty obj's underlying member method code with example usage: obj.deriv2(params) and returns: value