Commit 1a49ff0
committed
Fix 2 problems in
The `dual_basis` parameter to the `MultiTensor` class constructor was
defaulted to `DualBasis()`. In Python, default arguments are evaluated
only once at definition time, meaning every `MultiTensor` instance
created without an explicit basis shared the same global `DualBasis`
object. When tests were run in parallel or repeated, data from one test
would leak into others, leading to errors.
In addition, `MultiTensor.add_dual_elements` used `list.extend()`
instead of `list.append()` when adding `DualBasisElement` objects. Since
`DualBasisElement` is iterable (yielding its internal terms), using
`extend()` incorrectly decomposed the object into its constituent tuples
instead of adding the object as a single unit. This caused
`MultiTensor.synthesize_dual_basis()` to fail in some cases._multitensor.py
1 parent cf66a25 commit 1a49ff0
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
82 | 84 | | |
83 | 85 | | |
84 | 86 | | |
85 | | - | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| |||
0 commit comments