MCPcopy Create free account
hub / github.com/numpy/numpy / __array_finalize__

Method __array_finalize__

numpy/ma/core.py:6568–6580  ·  view source on GitHub ↗
(self, obj)

Source from the content-addressed store, hash-verified

6566 return cls.__singleton
6567
6568 def __array_finalize__(self, obj):
6569 if not self.__has_singleton():
6570 # this handles the `.view` in __new__, which we want to copy across
6571 # properties normally
6572 return super().__array_finalize__(obj)
6573 elif self is self.__singleton:
6574 # not clear how this can happen, play it safe
6575 pass
6576 else:
6577 # everywhere else, we want to downcast to MaskedArray, to prevent a
6578 # duplicate maskedconstant.
6579 self.__class__ = MaskedArray
6580 MaskedArray.__array_finalize__(self, obj)
6581
6582 def __array_prepare__(self, obj, context=None):
6583 return self.view(MaskedArray).__array_prepare__(obj, context)

Callers

nothing calls this directly

Calls 2

__has_singletonMethod · 0.95
__array_finalize__Method · 0.45

Tested by

no test coverage detected