Skip to content

Commit

Permalink
Merge branch 'master' into 317-allow-setting-tiff-scale-+-offset-+-cu…
Browse files Browse the repository at this point in the history
…stom-metadata
  • Loading branch information
bossie committed Sep 26, 2024
2 parents 81614a5 + 33ac29b commit 5cbb5e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
tests_require=tests_require,
install_requires=[
"openeo>=0.30.0.a2.dev",
"openeo_driver>=0.107.7.dev",
"openeo_driver>=0.107.8.dev",
'pyspark==3.4.2; python_version>="3.8"',
'pyspark>=2.3.1,<2.4.0; python_version<"3.8"',
'geopyspark==0.4.7+openeo',
Expand Down
4 changes: 4 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import attrs
import pytest

from openeo_driver.config.config import check_config_definition
from openeogeotrellis.config import (
GpsBackendConfig,
get_backend_config,
Expand Down Expand Up @@ -35,6 +36,9 @@ def get_config_file(


class TestGpsBackendConfig:
def test_check_config_definition(self):
check_config_definition(GpsBackendConfig)

def test_all_defaults(self):
"""Test that config can be created without arguments: everything has default value"""
config = GpsBackendConfig()
Expand Down
16 changes: 8 additions & 8 deletions tests/test_reduce_dimension.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import datetime
import datetime as dt
from typing import Dict

import numpy as np
Expand Down Expand Up @@ -29,7 +29,7 @@ def _stitch(cube: GeopysparkDataCube) -> Tile:
return cube.pyramid.levels[0].stitch()


def _timeseries_stitch(cube: GeopysparkDataCube) -> Dict[datetime.datetime, Tile]:
def _timeseries_stitch(cube: GeopysparkDataCube) -> Dict[dt.datetime, Tile]:
"""Stitch each instant of the SPACETIME TiledRasterLayer of given cube."""
layer: TiledRasterLayer = cube.pyramid.levels[0]
keys = layer.collect_keys()
Expand All @@ -47,10 +47,10 @@ def test_reduce_bands(imagecollection_with_two_bands_and_three_dates):
env = EvalEnv()
cube = cube.reduce_dimension(dimension="bands", reducer=reducer, env=env)
ts = _timeseries_stitch(cube)
assert len(ts) == 2
expected = np.full((1, 8, 8), 3.0)
for t, tile in ts.items():
assert_array_almost_equal(tile.cells, expected)
assert len(ts) == 3
assert_array_almost_equal(ts[dt.datetime(2017, 9, 25, 11, 37, 0)].cells, np.full((1, 8, 8), 3.0))
assert_array_almost_equal(ts[dt.datetime(2017, 9, 30, 0, 37, 0)].cells, np.full((1, 8, 8), np.nan))
assert_array_almost_equal(ts[dt.datetime(2017, 9, 25, 11, 37, 0)].cells, np.full((1, 8, 8), 3.0))


@pytest.mark.parametrize("udf", [("udf_noop"), ("udf_noop_jep")])
Expand All @@ -65,7 +65,7 @@ def test_reduce_bands_reduce_time(imagecollection_with_two_bands_and_three_dates
env = EvalEnv()
cube = cube.reduce_dimension(dimension="bands", reducer=reducer, env=env)
ts = _timeseries_stitch(cube)
assert len(ts) == 2
assert len(ts) == 3
assert set(t.cells.shape for t in ts.values()) == {(1, 8, 8)}

cube = cube.reduce_dimension(dimension='t', reducer=udf, env=env)
Expand All @@ -78,7 +78,7 @@ def test_reduce_bands_reduce_time(imagecollection_with_two_bands_and_three_dates
@pytest.mark.parametrize("udf", [("udf_noop"), ("udf_noop_jep")])
def test_reduce_bands_udf(imagecollection_with_two_bands_and_three_dates, udf, request):
udf = request.getfixturevalue(udf)
the_date = datetime.datetime(2017, 9, 25, 11, 37)
the_date = dt.datetime(2017, 9, 25, 11, 37)
cube = imagecollection_with_two_bands_and_three_dates
input = imagecollection_with_two_bands_and_three_dates.pyramid.levels[0].to_spatial_layer(the_date).stitch().cells
result = imagecollection_with_two_bands_and_three_dates.reduce_dimension(
Expand Down

0 comments on commit 5cbb5e4

Please sign in to comment.