(cls)
| 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(): |
nothing calls this directly
no test coverage detected