
    bi                     8    d Z ddlmZ dZdZdZdefdZdefdZ	y	)
a(  
Copyright, the CVXPY authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
    )VariableDCPDGPi'  returnc           	      B    dt        d t        | dg       D              z   S )z0Return node count for the expression/constraint.   c              3   2   K   | ]  }t        |        y wN)
node_count).0args     V/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/utilities/debug_tools.py	<genexpr>znode_count.<locals>.<genexpr>   s     Hs:c?Hs   args)sumgetattr)exprs    r   r   r      s!    sHgdFB.GHHHH    c                 <   d d}t         k(  rdnt        k(  rdd}nt        d      dfd	 t        | j                               s | j                  j
                        }t        |      dkD  rdj                        }nd	j                  |d
      }d	j                  |d      } t        | j                  j                  d   dj                  |                   }dj                  | j                  j                  |r|n|      }|D ]  }|dt        |      z  z  } |S | j                  D cg c]  }|j                         r| }	}dj                        }|	D ]+  }|d|dz  } |      }|D ]  }
|dt        |
      z  z  } - |S c c}w )N is_dcpis_dgplog_log_zUnknown discipline typec                 l   |g }t        | j                        dk(  r t        |              r|S  t        |              sXt        fd| j                  D              r:t	        |       }t
        k(  rt        | t              r|dz  }|j                  |       | j                  D ]  } ||      } |S )Nr   c              3   @   K   | ]  } t        |               y wr
   )r   )r   child	prop_names     r   r   zPbuild_non_disciplined_error_msg.<locals>.find_non_prop_leaves.<locals>.<genexpr>,   s     GE-GE9-/Gs   z" <-- needs to be declared positive)	lenr   r   allstrr   
isinstancer   append)r   resstr_exprr   discipline_typefind_non_prop_leavesr   s       r   r&   z=build_non_disciplined_error_msg.<locals>.find_non_prop_leaves&   s    ;C		Na$<GD)$<$>J)y)+GTYYGG4yH#%*T8*D@@JJx YY 	3E&uc2C	3
r   r   z>The objective is not {}. Its following subexpressions are not:z{}{}convexconcavezis_{}zhThe objective is not {}, even though each sub-expression is.
You are trying to {} a function that is {}.z
%sz%The following constraints are not {}:
z0 , because the following subexpressions are not:z
|--  %sr
   )r   r   
ValueErrorr   	objectiver   r   formatr   NAMEr    constraintsr   )problemr%   prefix_convnon_disciplined_leavesmsg
convex_strconcave_strfun_attr_checkr   not_disciplined_constraintssubexprr&   r   s    `         @@r   build_non_disciplined_error_msgr8      s   IK#		C		 233 177$$i02!5g6G6G6L6L!M%&*RYYC  {H=J --Y?K[WW%6%6%;%;A%>z@Z[]NABH&'))..&4
+C  + 	)D6SZ((C	)
4;4G4G"]Dt{{}4"]"]
1
8
8
IC+ 1OO!5d!;- 	1G;#g-00C	11
 J #^s   :FFN)
__doc__cvxpy.expressions.variabler   r   r   	MAX_NODESintr   r    r8    r   r   <module>r>      s8    0	I I
4 4r   