Creates a mrecarray from a (flat) list of masked arrays. Parameters ---------- arraylist : sequence A list of (masked) arrays. Each element of the sequence is first converted to a masked array if needed. If a 2D array is passed as argument, it is processed l
(arraylist, dtype=None, shape=None, formats=None,
names=None, titles=None, aligned=False, byteorder=None,
fill_value=None)
| 469 | |
| 470 | |
| 471 | def fromarrays(arraylist, dtype=None, shape=None, formats=None, |
| 472 | names=None, titles=None, aligned=False, byteorder=None, |
| 473 | fill_value=None): |
| 474 | """ |
| 475 | Creates a mrecarray from a (flat) list of masked arrays. |
| 476 | |
| 477 | Parameters |
| 478 | ---------- |
| 479 | arraylist : sequence |
| 480 | A list of (masked) arrays. Each element of the sequence is first converted |
| 481 | to a masked array if needed. If a 2D array is passed as argument, it is |
| 482 | processed line by line |
| 483 | dtype : {None, dtype}, optional |
| 484 | Data type descriptor. |
| 485 | shape : {None, integer}, optional |
| 486 | Number of records. If None, shape is defined from the shape of the |
| 487 | first array in the list. |
| 488 | formats : {None, sequence}, optional |
| 489 | Sequence of formats for each individual field. If None, the formats will |
| 490 | be autodetected by inspecting the fields and selecting the highest dtype |
| 491 | possible. |
| 492 | names : {None, sequence}, optional |
| 493 | Sequence of the names of each field. |
| 494 | fill_value : {None, sequence}, optional |
| 495 | Sequence of data to be used as filling values. |
| 496 | |
| 497 | Notes |
| 498 | ----- |
| 499 | Lists of tuples should be preferred over lists of lists for faster processing. |
| 500 | |
| 501 | """ |
| 502 | datalist = [ma.getdata(x) for x in arraylist] |
| 503 | masklist = [np.atleast_1d(ma.getmaskarray(x)) for x in arraylist] |
| 504 | _array = np.rec.fromarrays(datalist, |
| 505 | dtype=dtype, shape=shape, formats=formats, |
| 506 | names=names, titles=titles, aligned=aligned, |
| 507 | byteorder=byteorder).view(mrecarray) |
| 508 | _array._mask.flat = list(zip(*masklist)) |
| 509 | if fill_value is not None: |
| 510 | _array.fill_value = fill_value |
| 511 | return _array |
| 512 | |
| 513 | |
| 514 | def fromrecords(reclist, dtype=None, shape=None, formats=None, names=None, |
searching dependent graphs…