class_docstr: Canonical constraint to use with trust-constr algorithm.
  
  It represents the set of constraints of the form::
  
      f_eq(x) = 0
      f_ineq(x) <= 0
  
  where ``f_eq`` and ``f_ineq`` are evaluated by a single function, see
  below.
  
  The class is supposed to be instantiated by factory methods, which
  should prepare the parameters listed below.
  
  Parameters
  ----------
  n_eq, n_ineq : int
      Number of equality and inequality constraints respectively.
  fun : callable
      Function defining the constraints. The signature is
      ``fun(x) -> c_eq, c_ineq``, where ``c_eq`` is ndarray with `n_eq`
      components and ``c_ineq`` is ndarray with `n_ineq` components.
  jac : callable
      Function to evaluate the Jacobian of the constraint. The signature
      is ``jac(x) -> J_eq, J_ineq``, where ``J_eq`` and ``J_ineq`` are
      either ndarray of csr_matrix of shapes (n_eq, n) and (n_ineq, n),
      respectively.
  hess : callable
      Function to evaluate the Hessian of the constraints multiplied
      by Lagrange multipliers, that is
      ``dot(f_eq, v_eq) + dot(f_ineq, v_ineq)``. The signature is
      ``hess(x, v_eq, v_ineq) -> H``, where ``H`` has an implied
      shape (n, n) and provide a matrix-vector product operation
      ``H.dot(p)``.
  keep_feasible : ndarray, shape (n_ineq,)
      Mask indicating which inequality constraints should be kept feasible.
class_docstr_tok: ["Canonical","constraint","to","use","with","trust-constr","algorithm",".","It","represents","the","set","of","constraints","of","the","form",":",":","f_eq","(","x",")","=","0","f_ineq","(","x",")","<","=","0","where","``","f_eq","``","and","``","f_ineq","``","are","evaluated","by","a","single","function",",","see","below",".","The","class","is","supposed","to","be","instantiated","by","factory","methods",",","which","should","prepare","the","parameters","listed","below",".","Parameters","--","--","--","--","--","n_eq",",","n_ineq",":","int","Number","of","equality","and","inequality","constraints","respectively",".","fun",":","callable","Function","defining","the","constraints",".","The","signature","is","``","fun","(","x",")","-",">","c_eq",",","c_ineq","``",",","where","``","c_eq","``","is","ndarray","with","`","n_eq","`","components","and","``","c_ineq","``","is","ndarray","with","`","n_ineq","`","components",".","jac",":","callable","Function","to","evaluate","the","Jacobian","of","the","constraint",".","The","signature","is","``","jac","(","x",")","-",">","J_eq",",","J_ineq","``",",","where","``","J_eq","``","and","``","J_ineq","``","are","either","ndarray","of","csr_matrix","of","shapes","(","n_eq",",","n",")","and","(","n_ineq",",","n",")",",","respectively",".","hess",":","callable","Function","to","evaluate","the","Hessian","of","the","constraints","multiplied","by","Lagrange","multipliers",",","that","is","``","dot","(","f_eq",",","v_eq",")","+","dot","(","f_ineq",",","v_ineq",")","``",".","The","signature","is","``","hess","(","x",",","v_eq",",","v_ineq",")","-",">","H","``",",","where","``","H","``","has","an","implied","shape","(","n",",","n",")","and","provide","a","matrix-vector","product","operation","``","H.dot","(","p",")","``",".","keep_feasible",":","ndarray",",","shape","(","n_ineq",",",")","Mask","indicating","which","inequality","constraints","should","be","kept","feasible","."]
docstr: Create an "empty" instance.
  
  This "empty" instance is required to allow working with unconstrained
  problems as if they have some constraints.
docstr_tok: ["Create","an","``","empty","''","instance",".","This","``","empty","''","instance","is","required","to","allow","working","with","unconstrained","problems","as","if","they","have","some","constraints","."]
code: def empty(cls, n):
      """Create an "empty" instance.
  
      This "empty" instance is required to allow working with unconstrained
      problems as if they have some constraints.
      """
      empty_fun = np.empty(0)
      empty_jac = np.empty((0, n))
      empty_hess = sps.csr_matrix((n, n))
  
      def fun(x):
          return empty_fun, empty_fun
  
      def jac(x):
          return empty_jac, empty_jac
  
      def hess(x, v_eq, v_ineq):
          return empty_hess
  
      return cls(0, 0, fun, jac, hess, np.empty(0, dtype=np.bool_))
  
file_path: scipy/scipy/optimize/_trustregion_constr/canonical_constraint.py
imports: import numpy
  import scipy.sparse
label_desc: Use image node_id 3 for calling the CanonicalConstraint obj's underlying member method code with example usage: obj.empty(cls, n) and returns: cls, empty_fun,  empty_fun, empty_jac,  empty_jac, empty_hess