(x, copy=False)
| 710 | |
| 711 | |
| 712 | def safe_masked_invalid(x, copy=False): |
| 713 | x = np.array(x, subok=True, copy=copy) |
| 714 | if not x.dtype.isnative: |
| 715 | # If we have already made a copy, do the byteswap in place, else make a |
| 716 | # copy with the byte order swapped. |
| 717 | # Swap to native order. |
| 718 | x = x.byteswap(inplace=copy).view(x.dtype.newbyteorder('N')) |
| 719 | try: |
| 720 | xm = np.ma.masked_where(~(np.isfinite(x)), x, copy=False) |
| 721 | except TypeError: |
| 722 | if len(x.dtype.descr) == 1: |
| 723 | # Arrays with dtype 'object' get returned here. |
| 724 | # For example the 'c' kwarg of scatter, which supports multiple types. |
| 725 | # `plt.scatter([3, 4], [2, 5], c=[(1, 0, 0), 'y'])` |
| 726 | return x |
| 727 | else: |
| 728 | # In case of a dtype with multiple fields |
| 729 | # for example image data using a MultiNorm |
| 730 | try: |
| 731 | mask = np.empty(x.shape, dtype=np.dtype('bool, '*len(x.dtype.descr))) |
| 732 | for dd, dm in zip(x.dtype.descr, mask.dtype.descr): |
| 733 | mask[dm[0]] = ~np.isfinite(x[dd[0]]) |
| 734 | xm = np.ma.array(x, mask=mask, copy=False) |
| 735 | except TypeError: |
| 736 | return x |
| 737 | return xm |
| 738 | |
| 739 | |
| 740 | def print_cycles(objects, outstream=sys.stdout, show_progress=False): |
no outgoing calls
no test coverage detected
searching dependent graphs…