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

Remove H3IndexFat #13

Merged
merged 4 commits into from
Jan 23, 2018
Merged

Remove H3IndexFat #13

merged 4 commits into from
Jan 23, 2018

Conversation

dfellis
Copy link
Collaborator

@dfellis dfellis commented Jan 21, 2018

Made the change to remove H3IndexFat completely from the H3!

This change depends on the work in #12 so that has to be landed first, then I can rebase this on latest master (it should rebase perfectly). This also eliminates h3Api.c and appears to speed up H3 by 9% according to the benchmarks. (I haven't even gotten started on all of the perf stuff I want to do. I think the IJK rotation logic could be reduced from a loop to an O(1) algo and speed many things up.)

@coveralls
Copy link

coveralls commented Jan 21, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 3ee2307 on dfellis:slim-h3 into efacd9e on uber:master.

@@ -47,6 +47,20 @@ TEST(h3IsValidDigits) {
"h3IsValid failed on invalid unused digits");
}

TEST(h3IsValidBaseCell) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we're losing a test that an index with an invalid base cell (such as 127) is invalid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh? I'll look for it and include it in here. I satisfied myself with reaching 100% code coverage last night.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -43,6 +43,9 @@
/* For size_t */
#include <stdlib.h>

/* For constants used throughout H3 */
#include "constants.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this include added?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Many parts of the codebase depended on the constants being defined that they were getting indirectly through inclusion of H3IndexFat.h. It was easier to add it in here than in so many places across the codebase, and in some ways it makes sense -- if you can't #include "h3api.h" and have enough defined to be able to actually compile the requisite methods, then what kind of API is that?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think h3api.h exists for consumers of the library, not for the implementation, and consumers would not need these internal constants. I would prefer to replace #include "h3IndexFat.h" with #include "constants.h" if that's needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

"h3FatIsValid failed on large resolution");
}

TEST(h3FatUnusedDigitInvalid) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is covered by h3IsValidDigits although not as comprehensively

"h3FatIsValid failed on negative resolution");
}

TEST(h3FatLargeResolutionInvalid) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one can't be tested on H3Index because there's only 4 bits for the resolution.

}
}

TEST(h3FatNegativeResInvalid) {
Copy link
Collaborator

@isaacbrodsky isaacbrodsky Jan 22, 2018

Choose a reason for hiding this comment

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

This one can't be tested on H3Index because there's only 4 bits for the resolution.

edit: I added comments to each test, even if nothing needed to be done, just to track that I had looked at it.

}
}

TEST(h3FatIsValidBaseCellInvalid) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: h3Fat -> h3

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry I missed that.


BEGIN_TESTS(h3IndexFat);

TEST(h3FatIsValidWithMode) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we have a corresponding test for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding.

"h3FatIsValid failed on invalid index digit (1)");
}

TEST(h3FatBadDigitInvalid) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is tested (would look like res=1 but the digits are all 7)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Skipping the negative test (that can't exist, now) and porting the digit 7 test.

}
}

TEST(h3FatIsValidNegativeBaseCellInvalid) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can't be expressed in H3Index

t_assert(!h3FatIsValid(&hfLarge), "h3FatIsValid failed on too large digit");
}

TEST(h3FatIsValidBaseCell) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test is ported over.

"h3FatIsValid failed on negative base cell");
}

TEST(h3FatIsValidBaseCellInvalud) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test is ported over.

"h3FatIsValid failed on invalid base cell");
}

TEST(setH3IndexFat) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is already tested on H3Index (setH3Index)

H3Index h = H3_INIT;
H3_SET_MODE(h, i);
char failureMessage[BUFF_SIZE];
sprintf(failureMessage, "h3FatIsValid failed on mode %d", i);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: h3Fat -> h3

* and normalized base cell coordinates.
* @return Returns 1 if the possibility of overage exists, otherwise 0.
*/
int _h3ToFaceIjkWithInitializedFijk(H3Index h, FaceIJK* fijk) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/_h3ToFaceIjkWithInitializedFijk/_h3ToFaceIJKWithInitializedFIJK and same for others

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So that's how the original versions of these functions were named in H3IndexFat, and it makes a kind of sense to camelCase that way since it would be obvious to split as "h3 to face ijk with initialized fijk" whereas the other way would split as "h3 to face i j k with initialized f i j k".

Copy link
Contributor

Choose a reason for hiding this comment

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

If that’s how it was, no need to bunch unrelated changes into this. Comment rescinded!

I don’t buy the Ijk makes more sense than IJK argument, though :P

Copy link
Contributor

@jogly jogly left a comment

Choose a reason for hiding this comment

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

i think this definitely deserves a line item in the CHANGELOG under Unreleased.

@dfellis
Copy link
Collaborator Author

dfellis commented Jan 23, 2018

Wasn't sure if you guys wanted to manage the CHANGELOG yourselves or allow contributors to (since my other diffs didn't get entries). Since they're all focused on eliminating H3IndexFat, that should still be fine. :)

@jogly
Copy link
Contributor

jogly commented Jan 23, 2018

I guess we don’t have a policy for who adds to the changelog. My preference is commiter should add an entry under unreleased then We can groom the changelog on bump as needed. But I’ll raise this point up to others at our next meeting. No need to pollute your PR :)

Thanks @dfellis!!

@isaacbrodsky isaacbrodsky merged commit e9c765d into uber:master Jan 23, 2018
mrdvt92 pushed a commit to mrdvt92/h3 that referenced this pull request Jun 19, 2022
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.

None yet

4 participants