Commit ef6c404
authored
Adds tests (and fixes) for the dtype invariant. (#739)
That is, np.array(array).dtype == np.dtype(eltype(array)).
For this to hold, we needed to restrict to only creating dtypes for
primitives, tuples and named tuples. We removed support for arbitrary
structs (which are not supported by our implementation of the array
interface and buffer protocol).
We also worked around a feature/bug/quirk of numpy in that if you do
numpy.dtype(descr) where descr is a list of (name,type) field
descriptors of a struct, then the dtype you get is not the same as the
dtype of an array constructed from something whose array interface has
that same descr. In particular, if any item in descr is struct padding
like ("", "|V4"), then on conversion to a dtype the name is replaced
with e.g. "f2". Going the array route, the padding gets ignored and
does not feature in the resulting dtype. The fix here is to compute a
different representation of the same information for the dtype - namely
the dict of names, types and offsets way.
Co-authored-by: Christopher Rowley <github.com/cjdoris>1 parent f0365a9 commit ef6c404
File tree
4 files changed
+54
-20
lines changed- docs/src
- src/JlWrap
- test
4 files changed
+54
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
206 | | - | |
207 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
| 190 | + | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
| 237 | + | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
| 301 | + | |
301 | 302 | | |
302 | 303 | | |
303 | 304 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
19 | 50 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 51 | + | |
| 52 | + | |
25 | 53 | | |
| 54 | + | |
26 | 55 | | |
27 | 56 | | |
28 | | - | |
29 | | - | |
30 | 57 | | |
31 | 58 | | |
32 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
514 | 513 | | |
515 | 514 | | |
516 | | - | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
517 | 518 | | |
518 | 519 | | |
519 | 520 | | |
520 | 521 | | |
521 | | - | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
522 | 525 | | |
523 | 526 | | |
524 | 527 | | |
525 | 528 | | |
526 | 529 | | |
527 | 530 | | |
528 | 531 | | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
529 | 535 | | |
530 | 536 | | |
531 | 537 | | |
| |||
0 commit comments