evals / sympy-sqrtdenest

inline-positive-check

Expected

Hidden from the reviewer, like the grading note below.

helper-inputs
holds

The same positive-rational check is written inline without the sqargs list. Behavior is unchanged. Failing the contract is an invented failure.

Change

Contracts

helper-inputs
---
name: helper-inputs
message: Fix invalid helper inputs where they are chosen, not by catching every error at the entry point.
---

## Rules

Do not wrap `sqrtdenest` or another public function in a bare `except` or `except Exception` that returns the input
unchanged. Such a handler also hides unrelated bugs.
`_sqrt_match` passes a sum to `split_surds` only when every term squared is a positive rational number.
A term such as `I` squares to `-1`, which `split_surds` cannot handle.
When an expression cannot be denested, return it unchanged through the normal control flow.

## Checks

From the SymPy root, run `pytest sympy/simplify/tests/test_sqrtdenest.py`. `sqrtdenest((3 - sqrt(2)*sqrt(4 + 3*I) + 3*I)/2)`
returns its input unchanged instead of raising `IndexError`.