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)
| 502 | |
| 503 | |
| 504 | def fromarrays(arraylist, dtype=None, shape=None, formats=None, |
| 505 | names=None, titles=None, aligned=False, byteorder=None, |
| 506 | fill_value=None): |
| 507 | """ |
| 508 | Creates a mrecarray from a (flat) list of masked arrays. |
| 509 | |
| 510 | Parameters |
| 511 | ---------- |
| 512 | arraylist : sequence |
| 513 | A list of (masked) arrays. Each element of the sequence is first converted |
| 514 | to a masked array if needed. If a 2D array is passed as argument, it is |
| 515 | processed line by line |
| 516 | dtype : {None, dtype}, optional |
| 517 | Data type descriptor. |
| 518 | shape : {None, integer}, optional |
| 519 | Number of records. If None, shape is defined from the shape of the |
| 520 | first array in the list. |
| 521 | formats : {None, sequence}, optional |
| 522 | Sequence of formats for each individual field. If None, the formats will |
| 523 | be autodetected by inspecting the fields and selecting the highest dtype |
| 524 | possible. |
| 525 | names : {None, sequence}, optional |
| 526 | Sequence of the names of each field. |
| 527 | fill_value : {None, sequence}, optional |
| 528 | Sequence of data to be used as filling values. |
| 529 | |
| 530 | Notes |
| 531 | ----- |
| 532 | Lists of tuples should be preferred over lists of lists for faster processing. |
| 533 | |
| 534 | """ |
| 535 | datalist = [getdata(x) for x in arraylist] |
| 536 | masklist = [np.atleast_1d(getmaskarray(x)) for x in arraylist] |
| 537 | _array = recfromarrays(datalist, |
| 538 | dtype=dtype, shape=shape, formats=formats, |
| 539 | names=names, titles=titles, aligned=aligned, |
| 540 | byteorder=byteorder).view(mrecarray) |
| 541 | _array._mask.flat = list(zip(*masklist)) |
| 542 | if fill_value is not None: |
| 543 | _array.fill_value = fill_value |
| 544 | return _array |
| 545 | |
| 546 | |
| 547 | def fromrecords(reclist, dtype=None, shape=None, formats=None, names=None, |