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