Return the youngest subclass of MaskedArray from a list of (masked) arrays. In case of siblings, the first listed takes over.
(*arrays)
| 691 | |
| 692 | |
| 693 | def get_masked_subclass(*arrays): |
| 694 | """ |
| 695 | Return the youngest subclass of MaskedArray from a list of (masked) arrays. |
| 696 | |
| 697 | In case of siblings, the first listed takes over. |
| 698 | |
| 699 | """ |
| 700 | if len(arrays) == 1: |
| 701 | arr = arrays[0] |
| 702 | if isinstance(arr, MaskedArray): |
| 703 | rcls = type(arr) |
| 704 | else: |
| 705 | rcls = MaskedArray |
| 706 | else: |
| 707 | arrcls = [type(a) for a in arrays] |
| 708 | rcls = arrcls[0] |
| 709 | if not issubclass(rcls, MaskedArray): |
| 710 | rcls = MaskedArray |
| 711 | for cls in arrcls[1:]: |
| 712 | if issubclass(cls, rcls): |
| 713 | rcls = cls |
| 714 | # Don't return MaskedConstant as result: revert to MaskedArray |
| 715 | if rcls.__name__ == 'MaskedConstant': |
| 716 | return MaskedArray |
| 717 | return rcls |
| 718 | |
| 719 | |
| 720 | def getdata(a, subok=True): |
no outgoing calls
no test coverage detected
searching dependent graphs…