Closed
Description
@brokkoli71 could you explain the logic of NDBuffer.as_scalar
?
I noticed that it's doing some data type-specific stuff (there's a special path for np.datetime64
). Why was this necessary?
I'm asking because this function is erroring over in #2874 when I add timedelta data types, because timedeltas are not caught in the datetime special case. But I find the need for dtype-specific special cases here suspicious.
For reference, if I replace that function with something much simpler:
def as_scalar(self) -> ScalarType:
"""Returns the buffer as a scalar value"""
if self._data.size != 1:
raise ValueError("Buffer does not contain a single scalar value")
return self.as_numpy_array().item()
I get errors in a different place, but it looks like those errors are revealing real indexing bugs.
Metadata
Metadata
Assignees
Labels
No labels