Files
app-store-optimization/skills/loki-mode/benchmarks/results/2026-01-05-01-24-17/swebench-patches/sympy__sympy-21171.patch

36 lines
1.5 KiB
Diff

Based on my understanding of the issue from the error traceback and hints provided, I can construct the fix. The problem is:
1. In `_print_Pow`, when the base is a Function, it calls `self._print(expr.base, exp=self._print(expr.exp))`
2. `_print_SingularityFunction` doesn't accept the `exp` keyword argument
3. The fix is to add support for the `exp` keyword argument in `_print_SingularityFunction`
Looking at the traceback, specifically line 651:
```python
return self._print(expr.base, exp=self._print(expr.exp))
```
This passes an `exp` argument to print functions for Function bases. Other function printers that handle this pattern typically have signatures like:
```python
def _print_SomeFunction(self, expr, exp=None):
```
And then wrap the result with the exponent if `exp` is provided.
Here's the patch:
--- a/sympy/printing/latex.py
+++ b/sympy/printing/latex.py
@@ -1962,7 +1962,7 @@ class LatexPrinter(Printer):
return r"\delta^{%s}\left(%s\right)" % (tex1, diff)
return r"\delta\left(%s\right)" % diff
- def _print_SingularityFunction(self, expr):
+ def _print_SingularityFunction(self, expr, exp=None):
shift = self._print(expr.args[0] - expr.args[1])
power = self._print(expr.args[2])
tex = r"{\left\langle %s \right\rangle}^{%s}" % (shift, power)
+ if exp is not None:
+ tex = r"{\left(%s\right)}^{%s}" % (tex, exp)
return tex
def _print_Heaviside(self, expr, exp=None):