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

Method __new__

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

Source from the content-addressed store, hash-verified

6548 return cls.__singleton is not None and type(cls.__singleton) is cls
6549
6550 def __new__(cls):
6551 if not cls.__has_singleton():
6552 # We define the masked singleton as a float for higher precedence.
6553 # Note that it can be tricky sometimes w/ type comparison
6554 data = np.array(0.)
6555 mask = np.array(True)
6556
6557 # prevent any modifications
6558 data.flags.writeable = False
6559 mask.flags.writeable = False
6560
6561 # don't fall back on MaskedArray.__new__(MaskedConstant), since
6562 # that might confuse it - this way, the construction is entirely
6563 # within our control
6564 cls.__singleton = MaskedArray(data, mask=mask).view(cls)
6565
6566 return cls.__singleton
6567
6568 def __array_finalize__(self, obj):
6569 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