Skip to content

Possible fix for #914 compactCells failing when passed all res 1 cells#919

Merged
isaacbrodsky merged 20 commits intouber:masterfrom
isaacbrodsky:compact_all_res1_tes-proposed-fix
Oct 1, 2024
Merged

Possible fix for #914 compactCells failing when passed all res 1 cells#919
isaacbrodsky merged 20 commits intouber:masterfrom
isaacbrodsky:compact_all_res1_tes-proposed-fix

Conversation

@isaacbrodsky
Copy link
Collaborator

Incorporates #914

@isaacbrodsky isaacbrodsky marked this pull request as draft September 29, 2024 17:37
@coveralls
Copy link

coveralls commented Sep 29, 2024

Coverage Status

coverage: 98.824% (-0.001%) from 98.825%
when pulling 25eecc5 on isaacbrodsky:compact_all_res1_tes-proposed-fix
into b355c9d on uber:master.

Copy link
Collaborator

@nrabinowitz nrabinowitz left a comment

Choose a reason for hiding this comment

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

Fix looks correct to me

Copy link
Collaborator

@ajfriend ajfriend left a comment

Choose a reason for hiding this comment

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

Looks good!

int64_t numUncompacted = numRes1;
t_assertSuccess(H3_EXPORT(compactCells)(cells1, out, numUncompacted));

// TODO: check that output matches cells0
Copy link
Collaborator

Choose a reason for hiding this comment

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

If everything else is passing, shall we add this check that we recover the res 0 cells?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I'll add that too

@isaacbrodsky isaacbrodsky marked this pull request as ready for review September 30, 2024 22:23
@isaacbrodsky isaacbrodsky mentioned this pull request Sep 30, 2024
Comment on lines +143 to +172
TEST(allRes1_variousRanges) {
const int64_t numRes0 = 122;
const int64_t numRes1 = 842;
H3Index *cells0 = calloc(numRes0, sizeof(H3Index));
H3Index *cells1 = calloc(numRes1, sizeof(H3Index));
H3Index *out = calloc(numRes1, sizeof(H3Index));

H3_EXPORT(getRes0Cells)(cells0);
t_assert(cells0[0] == 0x8001fffffffffff,
"got expected first res0 cell");

t_assertSuccess(
H3_EXPORT(uncompactCells)(cells0, numRes0, cells1, numRes1, 1));

// Test various (but not all possible combinations) ranges of res 1
// cells
for (int64_t offset = 0; offset < numRes1; offset++) {
for (int64_t numUncompacted = numRes1 - offset; numUncompacted >= 0;
numUncompacted--) {
memset(out, 0, sizeof(H3Index) * numRes1);

t_assertSuccess(H3_EXPORT(compactCells)(&cells1[offset], out,
numUncompacted));
}
}

free(cells0);
free(cells1);
free(out);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, I'm not positive that we need this test. I had code like this previously just to try to generate a minimal example of a failure. I don't think it hurts to add this test, but I don't think there's any reason to think this provides much additional value beyond compacting all the res 1 cells. Happy to go either way with it, based on your judgement @isaacbrodsky .

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not that strong a test. More convincing might be enumerating all possible sets of res 1 cells, but it might be useful for just ensuring all of these cases are not inadvertently failing.

@isaacbrodsky isaacbrodsky merged commit d6f2701 into uber:master Oct 1, 2024
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.

5 participants