Skip to content

Commit

Permalink
Merge main to v1 (#819)
Browse files Browse the repository at this point in the history
Co-authored-by: roeldegoede <83765910+roeldegoede@users.noreply.github.com>
Co-authored-by: Dirk Eilander <dirk.eilander@gmail.com>
Co-authored-by: DirkEilander <15379728+DirkEilander@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub <noreply@github.com>
Co-authored-by: Sam Vente <savente93@proton.me>
  • Loading branch information
7 people authored Mar 4, 2024
1 parent 4738216 commit f8c642f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- hydromt/*
- data/*
- pyproject.toml
- pixi.lock
pull_request:
branches:
- main
Expand All @@ -20,6 +21,7 @@ on:
- hydromt/*
- data/*
- pyproject.toml
- pixi.lock


jobs:
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ venv.bak/
.spyderproject
.spyproject

# VScode
.vscode

# PyCharm
.idea

Expand Down
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"ms-python.python",
"ms-python.debugpy",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"njpwerner.autodocstring"
]
}
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"purpose": ["debug-test"]
}
]
}
14 changes: 14 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
}
},
"editor.formatOnSave": true
}
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Changed
-------
- Development environment is now set up via pixi instead of mamba / conda. See the documentation for more information on how to install.

Fixed
-----
- Bug in `raster.transform` with lazy coordinates. (#801)


v0.9.4 (2024-02-26)
Expand Down
12 changes: 8 additions & 4 deletions hydromt/gis/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ def res(self) -> tuple[float, float]:
)
):
dy = -1 * dy
if isinstance(dx, dask.array.Array):
dx, dy = dx.compute(), dy.compute()
self._res = dx, dy
return dx, dy

Expand Down Expand Up @@ -649,6 +651,8 @@ def origin(self) -> tuple[float, float]:
b = c * math.cos(beta - alpha)
x0 = xs[0, 0] - np.sign(dy) * a
y0 = ys[0, 0] - np.sign(dy) * b
if isinstance(x0, dask.array.Array): # compute if lazy
x0, y0 = x0.compute(), y0.compute()
self._origin = x0, y0
return x0, y0

Expand Down Expand Up @@ -1244,10 +1248,10 @@ def clip_bbox(self, bbox, align=None, buffer=0, crs=None):
xs, ys = zip(*gdf_bbox.dissolve().boundary[0].coords[:])
cs, rs = ~self.transform * (np.array(xs), np.array(ys))
# use round to get integer slices
c0 = max(int(round(cs.min() - buffer)), 0)
r0 = max(int(round(rs.min() - buffer)), 0)
c1 = int(round(cs.max() + buffer))
r1 = int(round(rs.max() + buffer))
c0 = max(int(np.round(cs.min() - buffer)), 0)
r0 = max(int(np.round(rs.min() - buffer)), 0)
c1 = int(np.round(cs.max() + buffer))
r1 = int(np.round(rs.max() + buffer))
return self.clip(slice(c0, c1), slice(r0, r1))

def clip_mask(self, da_mask: xr.DataArray, mask: bool = False):
Expand Down

0 comments on commit f8c642f

Please sign in to comment.