23 lines
1.1 KiB
Diff
23 lines
1.1 KiB
Diff
# sympy__sympy-24152
|
|
# Loki Mode Multi-Agent Patch
|
|
# Attempts: 1
|
|
|
|
Based on the issue description and the architect's analysis, I have enough information to generate the patch. The issue clearly describes the problem and provides the fix code. Let me generate the unified diff patch:
|
|
|
|
--- a/sympy/physics/quantum/tensorproduct.py
|
|
+++ b/sympy/physics/quantum/tensorproduct.py
|
|
@@ -246,9 +246,12 @@ class TensorProduct(Expr):
|
|
for i in range(len(args)):
|
|
if isinstance(args[i], Add):
|
|
for aa in args[i].args:
|
|
tp = TensorProduct(*args[:i] + (aa,) + args[i + 1:])
|
|
- if isinstance(tp, TensorProduct):
|
|
- tp = tp._eval_expand_tensorproduct()
|
|
- add_args.append(tp)
|
|
+ c_part, nc_part = tp.args_cnc()
|
|
+ if len(nc_part)==1 and isinstance(nc_part[0], TensorProduct):
|
|
+ nc_part = (nc_part[0]._eval_expand_tensorproduct(), )
|
|
+ add_args.append(Mul(*c_part)*Mul(*nc_part))
|
|
break
|
|
if add_args:
|
|
return Add(*add_args)
|