Commit b9704f3
Fix an issue with empty preallocation (#113)
* Fix issue with NumPy chain and preallocation=0
Original logic in `grow_append` was to extend data by 10% of its length.
This is a problem with the original data length is 0, since it then
never extends.
This commit amends `grow_append` to always extend by at least 10 elements.
* [NumPyBackend] Prevent ``preallocate=0`` from creating object arrays.
`grow_append` cannot know if ``preallocate = 0`` was used: it only
looks at the `rigid` value to determine how to append.
Because of this, will always fail when we use `preallocate = 0` with
tensor variables, since then the shapes of `target` and `extension`
don’t match.
A simple fix is to simply deactivate the special behavior for
`preallocate = 0`.
- This commit extends `test_growing` with a `preallocate` parameter,
so that we test both cases where it is 0 and positive.
- We also fix `test_growing` to match the new behavior of `grow_append`
introduced in #ea812b0, where data arrays always grow by at least 10.
* Remove trailing whitespace
---------
Co-authored-by: Alexandre René <[email protected]>
Co-authored-by: Michael Osthege <[email protected]>1 parent b35be42 commit b9704f3
2 files changed
+24
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
78 | 88 | | |
79 | 89 | | |
80 | 90 | | |
| |||
0 commit comments