Skip to content

Commit

Permalink
Fix Place block. (#116)
Browse files Browse the repository at this point in the history
* Fix Place block.

* Fix read the docs.

* Fix read the docs more.

* Fix read the docs once more.
  • Loading branch information
arjanverkerk authored Jan 12, 2024
1 parent 6cb7332 commit 94a8303
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
10 changes: 7 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ sphinx:
formats:
- pdf

build:
os: "ubuntu-22.04"
tools:
python: "3.8"

python:
version: 3.7
# use system_packages for numpy; the rest is mocked by autodoc_mock_imports
system_packages: true
# only numpy is in the requirements file; the rest is mocked by autodoc_mock_imports
install:
- requirements: docs/requirements.txt
- method: setuptools
path: . # setup.py includes a hack that emulates --no-deps for RTD
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.4.4 (unreleased)
------------------

- Nothing changed yet.
- Fix Place block.


2.4.3 (2023-06-01)
Expand Down
2 changes: 1 addition & 1 deletion dask_geomodeling/geometry/field_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def choices(self):

@staticmethod
def process(source, *choices):
result = pd.Series(np.nan, index=source.index)
result = pd.Series(np.nan, dtype=object, index=source.index)
for i, choice in enumerate(choices):
mask = source == i
result[mask] = choice[source.index[mask]]
Expand Down
2 changes: 1 addition & 1 deletion dask_geomodeling/raster/spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def get_sources_and_requests(self, **request):
if extent_geometry is None:
# no geometry means: no data
return (({"mode": "null"}, None),)
xmin, xmax, ymin, ymax = Extent.from_geometry(extent_geometry).transformed(request["projection"]).bbox
xmin, ymin, xmax, ymax = Extent.from_geometry(extent_geometry).transformed(request["projection"]).bbox

# compute the requested cellsize
x1, y1, x2, y2 = request["bbox"]
Expand Down
7 changes: 7 additions & 0 deletions dask_geomodeling/tests/test_raster_spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ def test_place_exact(source, center, vals_request):
assert (values[:, :10, :10] == 7).all()


def test_place_exact_source_requests(source, center, vals_request):
place = raster.Place(source, "EPSG:28992", center, [(50, 50)])
source_request = place.get_sources_and_requests(**vals_request)[1][1]
# next assert assumes native resolution requests and source of 10 x 10 pixels
assert source_request['height'] * source_request['width'] <= 100


def test_place_reproject(source, center_epsg3857):
target = 572050, 6812050 # EPSG3857 coords somewhere inside RD validity
place = raster.Place(source, "EPSG:3857", center_epsg3857, [target])
Expand Down
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx-rtd-theme
numpy

0 comments on commit 94a8303

Please sign in to comment.