
    bi                     ^    d Z ddlmZ ddlZddlZddlmZ ddl	m
Z
 ddlmZ  G d de      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.
    )IterableN)maximum_canon)minimum_canon)BaseTestc                       e Zd Zedeej                     fd       Zdej                  dej                  ddfdZd Z	d Z
y)	TestCanonSignreturnc                      t        j                  d      } t        j                  d      }t        j                  d      }| ||gS )zList of test expressionsT)pos)negr   )cpVariableConstant)expr_nonnegexpr_nonpos	expr_zeros      V/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/tests/test_canon_sign.pyexprszTestCanonSign.exprs   s:     kkd+kkd+KKN	[)44    abNc                     | j                  |j                         |j                                | j                  |j                         |j                                y)zCAsserting sign methods are preserved across a & b (a function of a)N)assertEqual	is_nonpos	is_nonneg)selfr   r   s      r   expr_sign_assertionsz"TestCanonSign.expr_sign_assertions%   s:    66r   c                     | j                         D ]R  }t        j                  |t        j                         }t        ||j                        \  }}| j                  ||       T y)zmIterate over test expressions,
        check that sign is preserved for composition of all with maximum_canonN)r   r   maximumnpinfr   argsr   r   exprtmp
canon_expr
canon_conss        r   test_maximum_signzTestCanonSign.test_maximum_sign*   sT     JJL 	7D**TBFF7+C%23%A"J
%%c:6	7r   c                     | j                         D ]Q  }t        j                  |t        j                        }t        ||j                        \  }}| j                  ||       S y)zcf. test_maximum_signN)r   r   minimumr    r!   r   r"   r   r#   s        r   test_minimum_signzTestCanonSign.test_minimum_sign2   sP    JJL 	7D**T266*C%23%A"J
%%c:6	7r   )__name__
__module____qualname__staticmethodr   r   
Expressionr   r   r(   r+    r   r   r   r      sP    58BMM* 5 57bmm 7 7$ 7
77r   r   )__doc__typingr   numpyr    cvxpyr   ;cvxpy.reductions.eliminate_pwl.canonicalizers.maximum_canonr   ;cvxpy.reductions.eliminate_pwl.canonicalizers.minimum_canonr   cvxpy.tests.base_testr   r   r1   r   r   <module>r9      s*        U U *7H 7r   