Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Structural equality tests. #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

[WIP] Structural equality tests. #45

wants to merge 3 commits into from

Conversation

pearu
Copy link
Member

@pearu pearu commented Apr 28, 2019

This PR introduces identity function for structural equality tests.

  • C function xnd_identity
  • C function xnd_bitmap_identity
  • Python function identity(x, y)
  • extend to identity(x, y, elementwise=True)
  • Add unittests for identity
  • Update documentation

@skrah
Copy link
Member

skrah commented Apr 30, 2019

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.

@skrah
Copy link
Member

skrah commented Apr 30, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants