MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / safe_masked_invalid

Function safe_masked_invalid

lib/matplotlib/cbook.py:712–737  ·  view source on GitHub ↗
(x, copy=False)

Source from the content-addressed store, hash-verified

710
711
712def 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
740def print_cycles(objects, outstream=sys.stdout, show_progress=False):

Callers 1

_combine_masksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…