MCPcopy Index your code
hub / github.com/numpy/numpy / __new__

Method __new__

numpy/ma/core.py:6751–6767  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

6749 return cls.__singleton is not None and type(cls.__singleton) is cls
6750
6751 def __new__(cls):
6752 if not cls.__has_singleton():
6753 # We define the masked singleton as a float for higher precedence.
6754 # Note that it can be tricky sometimes w/ type comparison
6755 data = np.array(0.)
6756 mask = np.array(True)
6757
6758 # prevent any modifications
6759 data.flags.writeable = False
6760 mask.flags.writeable = False
6761
6762 # don't fall back on MaskedArray.__new__(MaskedConstant), since
6763 # that might confuse it - this way, the construction is entirely
6764 # within our control
6765 cls.__singleton = MaskedArray(data, mask=mask).view(cls)
6766
6767 return cls.__singleton
6768
6769 def __array_finalize__(self, obj):
6770 if not self.__has_singleton():

Callers

nothing calls this directly

Calls 3

MaskedArrayClass · 0.85
__has_singletonMethod · 0.80
viewMethod · 0.45

Tested by

no test coverage detected