Return a new array keeping only the fields in `keep_names`, and preserving the order of those fields. Parameters ---------- base : array Input array keep_names : string or sequence String or sequence of strings corresponding to the names of the field
(base, keep_names, usemask=True, asrecarray=False)
| 564 | |
| 565 | |
| 566 | def _keep_fields(base, keep_names, usemask=True, asrecarray=False): |
| 567 | """ |
| 568 | Return a new array keeping only the fields in `keep_names`, |
| 569 | and preserving the order of those fields. |
| 570 | |
| 571 | Parameters |
| 572 | ---------- |
| 573 | base : array |
| 574 | Input array |
| 575 | keep_names : string or sequence |
| 576 | String or sequence of strings corresponding to the names of the |
| 577 | fields to keep. Order of the names will be preserved. |
| 578 | usemask : {False, True}, optional |
| 579 | Whether to return a masked array or not. |
| 580 | asrecarray : string or sequence, optional |
| 581 | Whether to return a recarray or a mrecarray (`asrecarray=True`) or |
| 582 | a plain ndarray or masked array with flexible dtype. The default |
| 583 | is False. |
| 584 | """ |
| 585 | newdtype = [(n, base.dtype[n]) for n in keep_names] |
| 586 | output = np.empty(base.shape, dtype=newdtype) |
| 587 | output = recursive_fill_fields(base, output) |
| 588 | return _fix_output(output, usemask=usemask, asrecarray=asrecarray) |
| 589 | |
| 590 | |
| 591 | def _rec_drop_fields_dispatcher(base, drop_names): |
no test coverage detected
searching dependent graphs…