(ans_p, ans_l, is_strict=False)
| 131 | |
| 132 | |
| 133 | def is_expr_equal(ans_p, ans_l, is_strict=False): |
| 134 | def is_equ_num_equal(equation, number): |
| 135 | if ( |
| 136 | isinstance(equation, sp.Eq) |
| 137 | # and isinstance(equation.lhs, sp.Symbol) |
| 138 | and equation.rhs.is_number |
| 139 | and number.is_number |
| 140 | ): |
| 141 | try: |
| 142 | ret = my_equals(equation.rhs, number) |
| 143 | return bool(ret) |
| 144 | except: |
| 145 | return equation.rhs == number |
| 146 | |
| 147 | if ans_p is None or ans_l is None: |
| 148 | return False |
| 149 | if isinstance(ans_l, str): |
| 150 | return ans_p == ans_l |
| 151 | |
| 152 | if ( |
| 153 | not is_strict |
| 154 | and is_equ_num_equal(ans_l, ans_p) |
| 155 | or is_equ_num_equal(ans_p, ans_l) |
| 156 | ): |
| 157 | return True |
| 158 | |
| 159 | if ans_p.free_symbols != ans_l.free_symbols: |
| 160 | return False |
| 161 | |
| 162 | if ans_p == ans_l: |
| 163 | return True |
| 164 | |
| 165 | if isinstance(ans_l, sp.core.relational.Relational): |
| 166 | try: |
| 167 | if ( |
| 168 | type(ans_l) == type(ans_p) |
| 169 | and my_equals(ans_p.lhs, ans_l.lhs) |
| 170 | and my_equals(ans_p.rhs, ans_l.rhs) |
| 171 | ): |
| 172 | return True |
| 173 | except Exception as e: |
| 174 | print(ans_p, ans_l, e) |
| 175 | try: |
| 176 | ret = my_equals(ans_p, ans_l) |
| 177 | return bool(ret) |
| 178 | except: |
| 179 | return False |
| 180 | |
| 181 | |
| 182 | # @timeout_decorator.timeout(5) |
no test coverage detected