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

add macro to test all implementations #135

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft

Conversation

rafaqz
Copy link
Member

@rafaqz rafaqz commented May 6, 2024

WIP conversion of all tests to use our new @test_all_implementations macro to make sure all geometries work everywhere.

@asinghvi17 I added some helpers for nicer testset titles that combine the topic and the module name.

Closes #134

(probably doesn't work currently !)

  • TODO: There is no GI.convert for features and feature collections so we cant pass features into the macro. We should add it to GeoInterface with a fallback that just converts the geometries and rewraps them with GI Feature.

Copy link
Member

@asinghvi17 asinghvi17 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, but every test file will have to include("helper.jl") because they're wrapped inside SafeTestsets.

test/helpers.jl Outdated Show resolved Hide resolved
test/helpers.jl Outdated Show resolved Hide resolved
test/helpers.jl Outdated Show resolved Hide resolved
test/helpers.jl Outdated Show resolved Hide resolved
test/helpers.jl Outdated
end
end
quote
for mod in (GeoInterface, ArchGDAL, GeometryBasics, LibGEOS)
Copy link
Collaborator

@skygering skygering May 14, 2024

Choose a reason for hiding this comment

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

Might be nice to pull these out to the top of the file as a const list to make it clear which ones are tested without having to skim the whole file. Also, that way if other geometries make it into the scene we can easily add to the test.

Also, do we want the GeoInterface conversion to be tuples? Or do we not care about the point type here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll move it up. Hopefully the point type doesn't matter much...

Copy link
Collaborator

@skygering skygering left a comment

Choose a reason for hiding this comment

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

I am glad we have this. In a few places I was trying to make examples of different types of geometries to test this. It is nice that this is automated now.

@rafaqz
Copy link
Member Author

rafaqz commented May 15, 2024

@asinghvi17
Copy link
Member

I can deal with the GeometryBasics stuff today, will push a change to the CI to use that branch once I have.

@asinghvi17
Copy link
Member

Looks like the distance test failures are because GB and AG polygons hold LineStringTraits, whereas LG and GI polygons hold LinearRingTraits.

@rafaqz
Copy link
Member Author

rafaqz commented May 16, 2024

@asinghvi17 do you want to update the barycentric tests with @test_all_implementations? none of the geometries have variable names yet to pass to the macro, and you will probably do that naming in a more sensible way than me

@asinghvi17
Copy link
Member

Sure, will push it up in a bit.

@felixcremer
Copy link
Member

 we finally have a big test suite to throw at everything and a way to do it easily :D

Does this mean we should add GeometryOps as reverse dependency test to these other packages?

@rafaqz
Copy link
Member Author

rafaqz commented May 17, 2024

Maybe at some stage. We could add an env var to only test one package

Comment on lines 159 to 166
@test_all_implementations (g1, g2) begin
if swap_points
g1, g2 = g2, g1
sg1, sg2 = sg2, sg1
end
go_val = GO_f(g1, g2)
lg_val = LG_f(g1, g2)
@test go_val == lg_val
go_val != lg_val && println("\n↑ TEST INFO: $sg1 $f_name $sg2 - $sdesc \n\n")
end
Copy link
Member

Choose a reason for hiding this comment

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

This is killing test logs - it is literally impossible to read them because of the number of testsets. There must be a better way to handle this case - maybe using an external loop over the modules instead of an internal one over the geometries?

Copy link
Member Author

@rafaqz rafaqz Jun 10, 2024

Choose a reason for hiding this comment

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

Inverting the loop wont change the amount of printing as its in the middle already/either way.

I think we instead need to remove that line? Maybe we could make it a testset instead?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think the printing is an issue because as we fix the test cases, those will naturally fix themselves. I guess the problem is that each case has an individual testset - we should change that so that each module just runs all the test cases instead.

Maybe in this case we could use an explicit loop instead of the macro?

asinghvi17 added a commit that referenced this pull request Jun 11, 2024
rafaqz pushed a commit that referenced this pull request Jun 11, 2024
* Move types to a new `types.jl` file

so they are more accessible and general

* Add GEOSCorrection and LibGEOSExt

* Minor fixes

* Write out stubs for not-yet-implemented functions

* Implement `GEOS` algorithm

* Update ext/GeometryOpsLibGEOSExt/segmentize.jl

* switch from typed keys to no keys

* fix erroneous typing in buffer

* add test skeleton + move enforce to GO proper

* Switch to SafeTestsets for tests

This is meant to assure that conflicts in e.g. polygon definitions are avoided, and that tests are immediately runnable as files.

* Test segmentize properly

* Apply suggestions from code review

* Fix tests

* Allow LibGEOS to perform natural conversion on DE-9IM and poly set ops

* Describe exactly why the filter statement exists in the extension

* Remove GEOS correction (not working yet)

* Add TopologyPreserve simplification method

* Add a basic comment to not_implemented_yet.jl

* Add a "default" implementation for buffer that returns GO geoms

* Switch back to explicit conversion to LG in all simple overrides

* Fix incorrect references

* Add Downloads and NaturalEarth to the test env

* Fix primitive tests

* Add a hack for LibGEOS geometrycollection conversion

* Fix accidental swapping in x and y in test

* Add overlaps testing for GEOS

* Bump version to v0.1.7 (#150)

* Set compat for LibGEOS to be after the GeometryCollection patch

* Force `simplify` to always be called with GEOS() for GEOS functions

* Go back to regular testsets from SafeTestsets

* Revert the geom relations tests for #135

* Get simplify working as well

* Activate the LibGEOS listed tests

* Fix the segmentize test

* Fix buffer
Comment on lines +32 to +41
@eval LibGEOS begin
function GI.convert(
::Type{GeometryCollection},
::GeometryCollectionTrait,
geom;
context = get_global_context(),
)
return GeometryCollection(GI.convert.((LibGEOS,), GI.getgeom(geom)))
end
end
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@eval LibGEOS begin
function GI.convert(
::Type{GeometryCollection},
::GeometryCollectionTrait,
geom;
context = get_global_context(),
)
return GeometryCollection(GI.convert.((LibGEOS,), GI.getgeom(geom)))
end
end

This can be removed - the new LibGEOS compat should take care of it.

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.

Test all available geometry sources
4 participants