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

Temporarily modify spatial.py tests to work around odc-geo Geobox comparison precision issue #1235

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

robbibt
Copy link
Member

@robbibt robbibt commented Jul 1, 2024

Proposed changes

A recent change in odc-geo (link here) is causing our tests to fail against odc-geo version 0.4.7, due to tiny differences in coordinate certainty causing comparisons like this to fail:

ds.odc.geobox == ds2.odc.geobox

This PR implements a temporary workaround using a new geobox_test testing function that compares GeoBoxes using np.allclose to account for tiny differences in coordinate precision. This should be reverted if an odc-geo fix/workaround becomes available.

def geobox_test(gbox1, gbox2):
    """
    Tests equivalency between two GeoBoxes, allowing for floating
    point precision differences between coordinates
    TODO: Remove once `odc-geo` bug is resolved
    """
    y_dim, x_dim = gbox1.dims
    assert np.allclose(gbox1.coords[x_dim].values, gbox2.coords[x_dim].values)
    assert np.allclose(gbox1.coords[y_dim].values, gbox2.coords[y_dim].values)
    assert np.allclose(gbox1.resolution.xy, gbox2.resolution.xy)
    assert gbox1.crs == gbox2.crs
    assert gbox1.shape == gbox2.shape
    ```

@robbibt robbibt changed the title Temporarily modify spatial.py tests to work around odc-geo bug Temporarily modify spatial.py tests to work around odc-geo bug Jul 1, 2024
@robbibt robbibt changed the title Temporarily modify spatial.py tests to work around odc-geo bug Temporarily modify spatial.py tests to work around odc-geo Geobox comparison precision issue Jul 1, 2024
@robbibt robbibt marked this pull request as ready for review July 1, 2024 06:55
@robbibt robbibt merged commit 2f82af5 into develop Jul 1, 2024
1 check passed
@robbibt robbibt deleted the geobox_comparison branch July 1, 2024 06:59
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