Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to v1 #819

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading