Skip to content

Commit

Permalink
disable sliderule tests by default
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyhq committed Dec 16, 2024
1 parent e37ad45 commit e803b94
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 65 deletions.
4 changes: 2 additions & 2 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ precommit = "pre-commit run --all"
# NOTE: consider --output-format=github for github actions
lint = "pylint src"
test = "pytest -o markers=network -m 'not network' --cov --cov-report=xml --cov-report=term"
networktest = "pytest --cov --cov-report=xml --cov-report=term"
networktest = "pytest --cov --cov-report=xml --cov-report=term --durations=0"

[tool.pixi.feature.docs.pypi-dependencies]
coincident = { path = ".", editable = true }
Expand Down
1 change: 0 additions & 1 deletion tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test_download_maxar_browse():
gf = coincident.search.search(dataset="maxar", ids=["102001008EC5AC00"])
item = coincident.search.stac.to_pystac_items(gf)[0]
asyncio.run(coincident.io.download.download_item(item, config="maxar"))

assert Path("/tmp/102001008EC5AC00.browse.tif").exists()
assert Path("/tmp/102001008EC5AC00.json").exists()

Expand Down
110 changes: 53 additions & 57 deletions tests/test_sliderule.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,65 +25,61 @@ def test_gdf_to_sliderule_polygon():


@network
def test_subset_gedi02a(tinyaoi):
gf_gedi = coincident.search.search(
dataset="gedi", intersects=tinyaoi, datetime="2022"
)
data = coincident.io.sliderule.subset_gedi02a(
gf_gedi, aoi=tinyaoi, include_worldcover=True
)
assert isinstance(data, gpd.GeoDataFrame)
assert "elevation_lm" in data.columns
assert "elevation_hr" in data.columns
assert data.iloc[0].name.toordinal() == 738192
assert data.iloc[0]["worldcover.value"] == "Tree cover"
assert data.shape == (262, 11)

@pytest.mark.skip(reason="https://github.com/uw-cryo/coincident/issues/35")
class TestSlideRule:
def test_subset_gedi02a(self, tinyaoi):
gf_gedi = coincident.search.search(
dataset="gedi", intersects=tinyaoi, datetime="2022"
)
data = coincident.io.sliderule.subset_gedi02a(
gf_gedi, aoi=tinyaoi, include_worldcover=True
)
assert isinstance(data, gpd.GeoDataFrame)
assert "elevation_lm" in data.columns
assert "elevation_hr" in data.columns
assert data.iloc[0].name.toordinal() == 738192
assert data.iloc[0]["worldcover.value"] == "Tree cover"
assert data.shape == (262, 11)

@network
def test_subset_atl06(tinyaoi):
gf_is2 = coincident.search.search(
dataset="icesat-2", intersects=tinyaoi, datetime="2022"
)
data = coincident.io.sliderule.subset_atl06(gf_is2, aoi=tinyaoi)
assert isinstance(data, gpd.GeoDataFrame)
assert "h_li" in data.columns
assert 1034 in data.rgt.unique()
assert data.iloc[0].name.toordinal() == 738304
assert data.shape == (413, 21)
def test_subset_atl06(self, tinyaoi):
gf_is2 = coincident.search.search(
dataset="icesat-2", intersects=tinyaoi, datetime="2022"
)
data = coincident.io.sliderule.subset_atl06(gf_is2, aoi=tinyaoi)
assert isinstance(data, gpd.GeoDataFrame)
assert "h_li" in data.columns
assert 1034 in data.rgt.unique()
assert data.iloc[0].name.toordinal() == 738304
assert data.shape == (413, 21)

def test_process_atl06sr(self, tinyaoi):
gf_is2 = coincident.search.search(
dataset="icesat-2", intersects=tinyaoi, datetime="2022"
)
data = coincident.io.sliderule.process_atl06sr(
gf_is2, aoi=tinyaoi, include_3dep=True
)
assert isinstance(data, gpd.GeoDataFrame)
assert "n_fit_photons" in data.columns
assert "3dep.value" in data.columns
assert data.shape == (367, 20)
assert data.iloc[0].name.toordinal() == 738304
assert int(data.iloc[0].h_mean) == 3178

@network
def test_process_atl06sr(tinyaoi):
gf_is2 = coincident.search.search(
dataset="icesat-2", intersects=tinyaoi, datetime="2022"
@pytest.mark.filterwarnings(
"ignore:Geometry is in a geographic CRS:UserWarning:geopandas"
)
data = coincident.io.sliderule.process_atl06sr(
gf_is2, aoi=tinyaoi, include_3dep=True
)
assert isinstance(data, gpd.GeoDataFrame)
assert "n_fit_photons" in data.columns
assert "3dep.value" in data.columns
assert data.shape == (367, 20)
assert data.iloc[0].name.toordinal() == 738304
assert int(data.iloc[0].h_mean) == 3178


@network
@pytest.mark.filterwarnings(
"ignore:Geometry is in a geographic CRS:UserWarning:geopandas"
)
def test_sample_3dep():
gf = gpd.GeoDataFrame(
geometry=gpd.points_from_xy(
[-106.46953038438801, -106.47209604357627],
[38.781089777057986, 38.78292421778072],
crs="EPSG:4326",
def test_sample_3dep(self):
gf = gpd.GeoDataFrame(
geometry=gpd.points_from_xy(
[-106.46953038438801, -106.47209604357627],
[38.781089777057986, 38.78292421778072],
crs="EPSG:4326",
)
)
)
samples = coincident.io.sliderule.sample_3dep(gf)
assert {"file", "geometry", "time", "value"} == set(samples.columns)
assert samples.time.dtype == "<M8[ns]"
assert str(samples.time.dt.date.iloc[0]) == "2019-09-04"
# NOTE: is this on edge of 2 tiles?! sometimes comes back as {3110, 3178}...
# assert set(samples.value.astype('i2')) == {3111, 3178}
samples = coincident.io.sliderule.sample_3dep(gf)
assert {"file", "geometry", "time", "value"} == set(samples.columns)
assert samples.time.dtype == "<M8[ns]"
assert str(samples.time.dt.date.iloc[0]) == "2019-09-04"
# NOTE: is this on edge of 2 tiles?! sometimes comes back as {3110, 3178}...
# assert set(samples.value.astype('i2')) == {3111, 3178}
8 changes: 4 additions & 4 deletions tests/test_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@network
def test_to_dataset_with_cop30(aoi):
def test_to_dataset_with_cop30_lazy(aoi):
"""Test `to_dataset` functionality with COP30 dataset."""
gf_cop30 = coincident.search.search(
dataset="cop30",
Expand All @@ -20,13 +20,13 @@ def test_to_dataset_with_cop30(aoi):
gf_cop30,
aoi=aoi,
resolution=0.1, # ~1km
).compute()
)
assert isinstance(ds, xr.Dataset), "Expected output to be an xarray Dataset."
assert "data" in ds.data_vars, "Expected 'data' variable in the Dataset."


@network
def test_to_dataset_with_worldcover(aoi):
def test_to_dataset_with_worldcover_lazy(aoi):
"""Test `to_dataset` functionality with WorldCover dataset."""
gf_wc = coincident.search.search(
dataset="worldcover",
Expand All @@ -38,6 +38,6 @@ def test_to_dataset_with_worldcover(aoi):
bands=["map"],
aoi=aoi,
resolution=0.1, # ~1km
).compute()
)
assert isinstance(ds, xr.Dataset), "Expected output to be an xarray Dataset."
assert "map" in ds.data_vars, "Expected 'map' variable in the Dataset."

0 comments on commit e803b94

Please sign in to comment.