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

refactor: add array comparison test helper #2024

Merged
merged 9 commits into from
Dec 22, 2022

Conversation

agoose77
Copy link
Collaborator

@agoose77 agoose77 commented Dec 20, 2022

Add a helper function to ak._util that makes approximate comparisons of ragged arrays.

Some of the branches in this helper may not have been tested; my view is that we'll discover any bugs when we use it in a test. I've checked all of the primitive cases, though.

@agoose77 agoose77 requested a review from jpivarski December 20, 2022 12:02
@agoose77 agoose77 temporarily deployed to docs-preview December 20, 2022 12:09 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Dec 20, 2022

Codecov Report

Merging #2024 (7ede827) into main (b83d9dc) will decrease coverage by 0.00%.
The diff coverage is 74.35%.

Additional details and impacted files
Impacted Files Coverage Δ
src/awkward/_util.py 80.79% <74.35%> (-0.51%) ⬇️

@agoose77 agoose77 temporarily deployed to docs-preview December 20, 2022 12:48 — with GitHub Actions Inactive
Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for posterity: we talked about this on Slack. But there are a few (good) additions since then, too.

You extract the two behaviors, but do you check them for equality? If so, I don't see it.

The "approximate dtype" is interesting: normally, we want types to be exact, but we do have an issue in which NumPy on Windows initializes integers as 32-bit. In our tests so far, we try to be diligent about explicitly setting the integer dtype to int64 when using NumPy, but this function would accept 32-bit integers and 64-bit integers as the same.

Overall, I approve! We'll probably be tweaking it as we use it, to more clearly define what we want to call equal same what we want to call not-equal.

@agoose77
Copy link
Collaborator Author

agoose77 commented Dec 20, 2022

You extract the two behaviors, but do you check them for equality? If so, I don't see it.

No, I only check that they map to the same behaviour class for the array / record parameters. This might not be sufficient; we obviously also permit overloads of ufuncs, which wouldn't be caught this way. Equally, I wouldn't want to ban cases where additional behaviour classes were added to the behaviour dictionary that aren't used. Unless we consider that an desirable outcome?

The "approximate dtype" is interesting: normally, we want types to be exact, but we do have an issue in which NumPy on Windows initializes integers as 32-bit. In our tests so far, we try to be diligent about explicitly setting the integer dtype to int64 when using NumPy, but this function would accept 32-bit integers and 64-bit integers as the same.

Right, I'm worried about

arrays_approx_equal(array, [1, 2, ...]) 

failing due to the default types for ArrayBuilder, Perhaps that should be opt-in, though, not opt-out.

@pre-commit-ci pre-commit-ci bot temporarily deployed to docs-preview December 21, 2022 16:53 Inactive
@agoose77 agoose77 temporarily deployed to docs-preview December 21, 2022 18:17 — with GitHub Actions Inactive
@agoose77 agoose77 merged commit a242c6e into main Dec 22, 2022
@agoose77 agoose77 deleted the agoose77/refactor-add-test-helper branch December 22, 2022 10:29
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