Open pearu opened 5 years ago
There is a problem with non-contiguous buffer imports, where the actual start of the buffer cannot be known:
>>> a = np.arange(10000000)[::-1]
>>> x = xnd.from_buffer(a)
>>> y = xnd.from_buffer(a)
>>> x.strict_equal(y)
True
>>> x.identical(y)
Segmentation fault (core dumped)
I think we may have to abandon the idea of complete buffer equality (which is less interesting anyway) and do a version of strict equal
that compares NaN
and NA
as equal.
FWIW, R
's identical
also compares the results of slicing and not the whole data structure:
> df1 <- data.frame(a = c(1, 2, 3, 4), b = c(1, 2, 3, 4))
> df2 <- data.frame(a = c(1, 2), b = c(1, 2))
> df1 %>% slice(1)
a b
1 1 1
> df2 %>% slice(1)
a b
1 1 1
> identical(df1, df2)
[1] FALSE
> identical(df1 %>% slice(1), df2 %>% slice(1))
[1] TRUE
This PR introduces
identity
function for structural equality tests.xnd_identity
xnd_bitmap_identity
identity(x, y)
identity(x, y, elementwise=True)
identity