Return the youngest subclass of MaskedArray from a list of (masked) arrays. In case of siblings, the first listed takes over.
(*arrays)
| 642 | |
| 643 | |
| 644 | def get_masked_subclass(*arrays): |
| 645 | """ |
| 646 | Return the youngest subclass of MaskedArray from a list of (masked) arrays. |
| 647 | |
| 648 | In case of siblings, the first listed takes over. |
| 649 | |
| 650 | """ |
| 651 | if len(arrays) == 1: |
| 652 | arr = arrays[0] |
| 653 | if isinstance(arr, MaskedArray): |
| 654 | rcls = type(arr) |
| 655 | else: |
| 656 | rcls = MaskedArray |
| 657 | else: |
| 658 | arrcls = [type(a) for a in arrays] |
| 659 | rcls = arrcls[0] |
| 660 | if not issubclass(rcls, MaskedArray): |
| 661 | rcls = MaskedArray |
| 662 | for cls in arrcls[1:]: |
| 663 | if issubclass(cls, rcls): |
| 664 | rcls = cls |
| 665 | # Don't return MaskedConstant as result: revert to MaskedArray |
| 666 | if rcls.__name__ == 'MaskedConstant': |
| 667 | return MaskedArray |
| 668 | return rcls |
| 669 | |
| 670 | |
| 671 | def getdata(a, subok=True): |
no outgoing calls
no test coverage detected