Skip to content

Commit

Permalink
Basten propagate time resolution fix (#94)
Browse files Browse the repository at this point in the history
* Fixed proper propagation of time resolution through AggregateRaster

* Initial attempt to test proper propagation of request

* Added another trivial test

* Added a note regarding WSL in the installation docs

* Updated note

* Added a link to VSCode manual

* AggregateRaster: time_resolution request only propageted when provided

* Removed irrelevant test

* minor style change (index-operator instead of get())

* fixed rst format issue
  • Loading branch information
benvanbasten-ns committed Feb 18, 2022
1 parent 3f5fd72 commit 90e2c30
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog of dask-geomodeling
2.3.8 (unreleased)
------------------

- Nothing changed yet.
- Fixed proper propagation of time resolution through AggregateRaster


2.3.7 (2022-02-08)
Expand Down
6 changes: 5 additions & 1 deletion dask_geomodeling/geometry/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,13 @@ def get_sources_and_requests(self, **request):
"aggregation": None, # TODO
"bbox": (x1, y1, x2, y2),
"width": width,
"height": height,
"height": height
}

# only propagate if provided
if "time_resolution" in request:
raster_request["time_resolution"] = request["time_resolution"]

process_kwargs = {
"mode": request.get("mode", "intersects"),
"pixel_size": self.pixel_size,
Expand Down
29 changes: 29 additions & 0 deletions dask_geomodeling/tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,35 @@ def test_raster_request(self):
self.assertEqual(6, request["width"])
self.assertEqual(6, request["height"])

def test_raster_time_resolution(self):
req = self.request
req["time_resolution"] = 3600000
req["geometry"] = box(0, 0, 10, 10)

# temp_group = GroupTemporal([
# MockRaster(timedelta=Timedelta(hours=1)),
# MockRaster(timedelta=Timedelta(minutes=1)),
# MockRaster(timedelta=Timedelta(seconds=1))
# ])

temp_raster = MockRaster(
origin=Datetime(2018, 1, 1),
timedelta=Timedelta(hours=1),
bands=1
)

geom_source = MockGeometry(
polygons=[((2.0, 2.0), (8.0, 2.0), (8.0, 8.0), (2.0, 8.0))],
properties=[{"id": 1}],
)
view = geometry.AggregateRaster(
source=geom_source, raster=temp_raster, statistic="sum"
)

_, (source, request), _ = view.get_sources_and_requests(**req)

self.assertEqual(3600000, request["time_resolution"])

def test_pixel_size(self):
# larger
self.view = geometry.AggregateRaster(
Expand Down
18 changes: 18 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,21 @@ Install dask-geomodeling::
Run the tests::

(.venv) $ pytest

Advanced: Running tests in VSCode for WSL2 (Ubuntu)
-------------------------------------------------------

It is possible to run the tests (that reside in WSL2) but perform debugging in VSCode (Windows)

1 Install the Python extension in VSCode.

2 Open the ``Test Explorer View`` (beaker icon)

3 Press the ``Configure Tests`` button. Select ``pytest`` as test framework, and base the configuration on the existing ``setup.cfg``

4 The tests should now be discovered, and by pressing the ``Debug Tests`` button, it is now possible to place breakpoints and step through the tests.

See the `VSCode manual for python testing <https://code.visualstudio.com/docs/python/testing>`_ for explanation regarding running the tests.

A known `issue <https://stackoverflow.com/questions/58799879/vscode-on-discover-tests-error-spawn-python-enoent>`_ can be found on StackOverflow.

0 comments on commit 90e2c30

Please sign in to comment.