Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
fb51cc2
Bump pypa/gh-action-pypi-publish from 1.12.3 to 1.12.4
dependabot[bot] Jan 27, 2025
3e1466a
update s3 stubs for integrity checks introduced in boto3==1.36.0
asjohnston-asf Feb 1, 2025
e6c9418
Merge pull request #263 from ASFHyP3/s3-crc
asjohnston-asf Feb 3, 2025
324a1b2
Update CODEOWNERS
jhkennedy Feb 5, 2025
a8e9b41
Merge pull request #264 from ASFHyP3/jhkennedy-patch-1
jhkennedy Feb 6, 2025
9f75e49
delete repo CoC in favor of organization default
jtherrmann Feb 7, 2025
dcfa229
Merge pull request #265 from ASFHyP3/delete-coc
jtherrmann Feb 8, 2025
e7e7735
update dependabot config
jtherrmann Feb 9, 2025
647b2a6
add requirements-static.txt
jtherrmann Feb 9, 2025
9cb982b
install requirements-static.txt from environment.yml
jtherrmann Feb 9, 2025
bd74cd9
bump version for ruff and mypy actions
jtherrmann Feb 9, 2025
8dcacf0
update ruff config
jtherrmann Feb 9, 2025
2d44369
Bump ASFHyP3/actions from 0.15.0 to 0.17.1
dependabot[bot] Feb 10, 2025
bcd2188
Merge branch 'pin-ruff-and-mypy' into dependabot/github_actions/ASFHy…
jtherrmann Feb 10, 2025
94abeb7
Merge pull request #266 from ASFHyP3/dependabot/github_actions/ASFHyP…
jtherrmann Feb 10, 2025
663f9b4
Bump ruff from 0.9.5 to 0.9.6
dependabot[bot] Feb 10, 2025
1845795
Merge pull request #267 from ASFHyP3/dependabot/pip/ruff-0.9.6
jtherrmann Feb 11, 2025
e79661a
Bump mypy from 1.14.1 to 1.15.0
dependabot[bot] Feb 11, 2025
202778e
Merge pull request #268 from ASFHyP3/dependabot/pip/mypy-1.15.0
jtherrmann Feb 11, 2025
e719691
Merge pull request #262 from ASFHyP3/dependabot/github_actions/pypa/g…
jtherrmann Feb 12, 2025
1bc66b8
Bump ruff from 0.9.6 to 0.9.7
dependabot[bot] Feb 24, 2025
59beafd
Merge pull request #269 from ASFHyP3/dependabot/pip/ruff-0.9.7
jtherrmann Feb 25, 2025
d0fa324
Bump ruff from 0.9.7 to 0.9.9
dependabot[bot] Mar 3, 2025
ab3b68b
Merge pull request #271 from ASFHyP3/dependabot/pip/ruff-0.9.9
jtherrmann Mar 5, 2025
11521f8
Bump ruff from 0.9.9 to 0.9.10
dependabot[bot] Mar 10, 2025
1847a55
update read_as_masked_array to handle nan nodata values
Alex-Lewandowski Mar 11, 2025
be02a8c
update CHANGELOG
Alex-Lewandowski Mar 11, 2025
1a41273
Merge pull request #272 from ASFHyP3/dependabot/pip/ruff-0.9.10
jtherrmann Mar 12, 2025
6046068
Bump ruff from 0.9.10 to 0.11.0
dependabot[bot] Mar 17, 2025
41a3502
Merge pull request #274 from ASFHyP3/dependabot/pip/ruff-0.11.0
jtherrmann Mar 17, 2025
c2e6442
mask invalid values on all dastasets in read_as_masked_array
Alex-Lewandowski Mar 19, 2025
d7dfada
Bump ruff from 0.11.0 to 0.11.2
dependabot[bot] Mar 24, 2025
0e1ff7b
Merge pull request #275 from ASFHyP3/dependabot/pip/ruff-0.11.2
jtherrmann Mar 25, 2025
abeb3d6
Update test-and-build.yml
jhkennedy Mar 25, 2025
648a71d
update ruff config for Actions v0.18.0
jtherrmann Mar 26, 2025
36daa2f
Bump ASFHyP3/actions from 0.17.1 to 0.18.0
dependabot[bot] Mar 31, 2025
636913c
Merge branch 'apply-actions-v0.18.0' into dependabot/github_actions/A…
jtherrmann Apr 1, 2025
c0cfbad
Merge pull request #277 from ASFHyP3/dependabot/github_actions/ASFHyP…
jtherrmann Apr 1, 2025
594ed36
Bump ruff from 0.11.2 to 0.11.4
dependabot[bot] Apr 7, 2025
59c6f1f
Merge pull request #279 from ASFHyP3/dependabot/pip/ruff-0.11.4
jtherrmann Apr 8, 2025
a714c0c
Bump ruff from 0.11.4 to 0.11.5
dependabot[bot] Apr 14, 2025
061159f
type annotation
jtherrmann Apr 15, 2025
0d4a0ce
Merge pull request #280 from ASFHyP3/dependabot/pip/ruff-0.11.5
jtherrmann Apr 15, 2025
ef086f0
Bump ruff from 0.11.5 to 0.11.6
dependabot[bot] Apr 21, 2025
9ca6cee
Bump ASFHyP3/actions from 0.18.0 to 0.18.1
dependabot[bot] Apr 21, 2025
0f18cd2
Merge pull request #282 from ASFHyP3/dependabot/github_actions/ASFHyP…
jtherrmann Apr 21, 2025
0407c6d
Merge pull request #281 from ASFHyP3/dependabot/pip/ruff-0.11.6
jtherrmann Apr 21, 2025
171a63e
remove extraneous nan check in read_as_masked_array
Alex-Lewandowski Apr 25, 2025
d3a8131
remove print, correct var name in doc strings
Alex-Lewandowski Apr 25, 2025
386be72
Merge pull request #273 from Alex-Lewandowski/develop
Alex-Lewandowski Apr 25, 2025
c374816
Bump ruff from 0.11.6 to 0.11.8
dependabot[bot] May 5, 2025
3ac2292
ruff format
jtherrmann May 6, 2025
3ab88bf
Merge pull request #284 from ASFHyP3/dependabot/pip/ruff-0.11.8
jtherrmann May 6, 2025
32b7d93
Bump ruff from 0.11.8 to 0.11.9
dependabot[bot] May 12, 2025
de9c4d4
Merge pull request #285 from ASFHyP3/dependabot/pip/ruff-0.11.9
jtherrmann May 13, 2025
680a707
Bump ruff from 0.11.9 to 0.11.10
dependabot[bot] May 19, 2025
fd52836
Bump ASFHyP3/actions from 0.18.1 to 0.19.0
dependabot[bot] May 19, 2025
67845fc
Merge pull request #287 from ASFHyP3/dependabot/github_actions/ASFHyP…
jtherrmann May 20, 2025
c5ef421
Merge pull request #286 from ASFHyP3/dependabot/pip/ruff-0.11.10
jtherrmann May 20, 2025
2ad717d
Bump ruff from 0.11.10 to 0.11.11
dependabot[bot] May 26, 2025
9be849c
Merge pull request #289 from ASFHyP3/dependabot/pip/ruff-0.11.11
jtherrmann May 28, 2025
a69ded7
Bump ruff from 0.11.11 to 0.11.12
dependabot[bot] Jun 2, 2025
7a5909a
Merge pull request #292 from ASFHyP3/dependabot/pip/ruff-0.11.12
jtherrmann Jun 3, 2025
7b91945
Bump ruff from 0.11.12 to 0.12.0
dependabot[bot] Jun 23, 2025
874ad76
Merge pull request #295 from ASFHyP3/dependabot/pip/ruff-0.12.0
jtherrmann Jun 24, 2025
a68efb4
dependabot groups
jtherrmann Jun 26, 2025
8515d1b
Merge pull request #296 from ASFHyP3/dependabot-groups
jhkennedy Jun 27, 2025
b386b0a
Bump the pip-deps group with 2 updates
dependabot[bot] Jun 27, 2025
f0080f1
Update requirements-static.txt
jtherrmann Jul 1, 2025
8561a9f
Merge pull request #297 from ASFHyP3/dependabot/pip/pip-deps-c0f196afc9
jtherrmann Jul 1, 2025
8ce4922
Bump the pip-deps group with 2 updates
dependabot[bot] Jul 14, 2025
47defef
fix mypy warnings
jtherrmann Jul 23, 2025
3ad4ae3
add test-and-build perms
jtherrmann Jul 23, 2025
b2f90db
fix import order
jtherrmann Jul 23, 2025
28c8684
Merge pull request #298 from ASFHyP3/dependabot/pip/pip-deps-3d7d6b5a95
jtherrmann Jul 23, 2025
c849077
Bump the github-actions-deps group across 1 directory with 3 updates
dependabot[bot] Sep 8, 2025
e3ccc42
add type ignore
jtherrmann Nov 4, 2025
511adb7
changes for Actions v0.20.0
jtherrmann Nov 4, 2025
abfc6c3
Merge pull request #301 from ASFHyP3/dependabot/github_actions/github…
jtherrmann Nov 4, 2025
9c27969
changelog
jtherrmann Nov 4, 2025
d51057b
Merge pull request #302 from ASFHyP3/changelog
jtherrmann Nov 4, 2025
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: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# These owners will be requested for review when someone opens a pull request.
* @ASFHyP3/plugins
* @ASFHyP3/Tools @ASFHyP3/SciDev
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,23 @@

version: 2
updates:
- package-ecosystem: pip
directory: /
schedule:
interval: weekly
labels:
- bumpless
groups:
pip-deps:
patterns:
- "*"
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
labels:
- bumpless
groups:
github-actions-deps:
patterns:
- "*"
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
- develop
jobs:
call-changelog-check-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-changelog-check.yml@v0.20.0

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 4 months ago

To fix the problem, add a permissions block at the root level of the workflow or within the specific job that calls the reusable workflow. Since the job only invokes a reusable workflow, and to follow the principle of least privilege, start with the minimal permissions block, such as contents: read. This limits the permissions granted to the GITHUB_TOKEN for this workflow and any jobs (unless individually overridden). Edit .github/workflows/changelog.yml and insert the permissions block immediately after the workflow's name and before on: so it applies to all jobs by default. No additional imports or definitions are required for this YAML file change.

Suggested changeset 1
.github/workflows/changelog.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml
--- a/.github/workflows/changelog.yml
+++ b/.github/workflows/changelog.yml
@@ -1,4 +1,6 @@
 name: Changelog updated?
+permissions:
+  contents: read
 on:
   pull_request:
     types:
EOF
@@ -1,4 +1,6 @@
name: Changelog updated?
permissions:
contents: read
on:
pull_request:
types:
Copilot is powered by AI and may make mistakes. Always verify output.
2 changes: 1 addition & 1 deletion .github/workflows/create-jira-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

jobs:
call-create-jira-issue-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-create-jira-issue.yml@v0.20.0
secrets:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }}
JIRA_FIELDS: ${{ secrets.JIRA_FIELDS }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
6 changes: 3 additions & 3 deletions .github/workflows/distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

jobs:
call-version-info-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.20.0
with:
python_version: "3.11"

distribute:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

Expand All @@ -31,7 +31,7 @@
python -m build

- name: upload to PyPI.org
uses: pypa/gh-action-pypi-publish@v1.12.3
uses: pypa/gh-action-pypi-publish@v1.13.0
with:
user: __token__
password: ${{ secrets.TOOLS_PYPI_PAK }}
2 changes: 1 addition & 1 deletion .github/workflows/labeled-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

jobs:
call-labeled-pr-check-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-labeled-pr-check.yml@v0.20.0

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 4 months ago

To fix the problem, an explicit permissions: block should be added, either at the root of the workflow or within the job definition. For a workflow calling a reusable workflow, in nearly all cases contents: read is sufficient unless the reusable workflow requires more.

The single best fix is to add

permissions:
  contents: read

directly below the name: line at the top of .github/workflows/labeled-pr.yml. This applies the minimal permissions to all jobs in this workflow.

No imports, new methods, or further changes are needed.


Suggested changeset 1
.github/workflows/labeled-pr.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/labeled-pr.yml b/.github/workflows/labeled-pr.yml
--- a/.github/workflows/labeled-pr.yml
+++ b/.github/workflows/labeled-pr.yml
@@ -1,4 +1,6 @@
 name: Is PR labeled?
+permissions:
+  contents: read
 
 on:
   pull_request:
EOF
@@ -1,4 +1,6 @@
name: Is PR labeled?
permissions:
contents: read

on:
pull_request:
Copilot is powered by AI and may make mistakes. Always verify output.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
finish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.TOOLS_BOT_PAK }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
jobs:
# Docs: https://github.com/ASFHyP3/actions
call-secrets-analysis-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-secrets-analysis.yml@v0.20.0

call-ruff-workflow:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-ruff.yml@v0.20.0

call-mypy-workflow:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
uses: ASFHyP3/actions/.github/workflows/reusable-mypy.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-mypy.yml@v0.20.0

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 4 months ago

The best way to fix this problem is to add a permissions block at the root of .github/workflows/static-analysis.yml, with the least privilege needed for static analysis jobs. Since typical static analysis workflows only require read access to repository contents (and no write access to issues, pull requests, etc.), you can use contents: read as a starting point. This block should be inserted immediately under the workflow name, before the on: key. If specific jobs later need additional permissions, such as writing PR comments or updating statuses, those jobs can define their own permissions. For now, set the most restrictive permissions globally.

Suggested changeset 1
.github/workflows/static-analysis.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml
--- a/.github/workflows/static-analysis.yml
+++ b/.github/workflows/static-analysis.yml
@@ -1,4 +1,6 @@
 name: Static analysis
+permissions:
+  contents: read
 
 on: push
 
EOF
@@ -1,4 +1,6 @@
name: Static analysis
permissions:
contents: read

on: push

Copilot is powered by AI and may make mistakes. Always verify output.
2 changes: 1 addition & 1 deletion .github/workflows/tag-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

jobs:
call-bump-version-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-bump-version.yml@v0.20.0
secrets:
USER_TOKEN: ${{ secrets.TOOLS_BOT_PAK }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
18 changes: 13 additions & 5 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,38 @@ name: Test and build
on:
push:
branches:
- main
- develop
tags:
- 'v*'
pull_request:
branches:
- main
- develop

jobs:
call-pytest-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-pytest.yml@v0.20.0
permissions:
contents: read
with:
local_package_name: asf_tools
python_versions: >- # Optional; default shown
["3.10", "3.11"]

call-version-info-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.20.0
permissions:
contents: read
with:
python_version: "3.10"

call-docker-ghcr-workflow:
needs: call-version-info-workflow
uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.15.0
uses: ASFHyP3/actions/.github/workflows/reusable-docker-ghcr.yml@v0.20.0
permissions:
contents: read
packages: write
with:
version_tag: ${{ needs.call-version-info-workflow.outputs.version_tag }}
secrets:
USER_TOKEN: ${{ secrets.TOOLS_BOT_PAK }}
USER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.4]

### Changed
- Various dependencies have been upgraded.

### Fixed
- Support rasters with `nan` nodata values in `read_as_masked_array`
- Upgraded to [Actions v0.20.0](https://github.com/ASFHyP3/actions/releases/tag/v0.20.0) so that Docker image `latest` tag will correspond to the actual version tag. See https://github.com/ASFHyP3/actions/issues/278

## [0.8.3]

### Changed
Expand Down
125 changes: 0 additions & 125 deletions CODE_OF_CONDUCT.md

This file was deleted.

5 changes: 2 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ dependencies:
# For packaging, and testing
# - arcpy # windows only
- python-build
- ruff
- mypy
- setuptools>=61
- setuptools_scm>=6.2
- pytest
- pytest-console-scripts
- pytest-cov
# For running
- astropy
- boto3<1.36.0 # FIXME: remove top pin when tests no longer fail
- boto3>=1.36.0
- fiona
- gdal>=3.7
- geopandas
Expand All @@ -33,5 +31,6 @@ dependencies:
- shapely
- tqdm
- pip:
- -r requirements-static.txt
# for testing
- gdal-utils
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ classifiers=[
]
dependencies = [
"astropy",
"boto3>=1.36.0",
"fiona",
"gdal>=3.3",
"geopandas",
Expand Down Expand Up @@ -105,6 +106,12 @@ convention = "google"
case-sensitive = true
lines-after-imports = 2

[tool.ruff.lint.flake8-annotations]
suppress-dummy-args = true

[tool.ruff.lint.extend-per-file-ignores]
"tests/*" = ["D1", "ANN"]

[tool.mypy]
python_version = "3.10"
warn_redundant_casts = true
Expand Down
2 changes: 2 additions & 0 deletions requirements-static.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ruff==0.12.3
mypy==1.16.1
1 change: 1 addition & 0 deletions src/asf_tools/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def prepare_dem_vrt(vrt: str | Path, geometry: ogr.Geometry | BaseGeometry):
if isinstance(geometry, BaseGeometry):
geometry = ogr.CreateGeometryFromWkb(geometry.wkb)

assert isinstance(geometry, ogr.Geometry)
min_lon, max_lon, _, _ = geometry.GetEnvelope()
if min_lon < -160.0 and max_lon > 160.0:
raise ValueError(f'asf_tools does not currently support geometries that cross the antimeridian: {geometry}')
Expand Down
8 changes: 5 additions & 3 deletions src/asf_tools/hydrosar/flood_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections.abc import Callable
from pathlib import Path
from shutil import make_archive
from typing import Literal
from typing import Any, Literal

import numpy as np
from osgeo import gdal
Expand Down Expand Up @@ -164,7 +164,7 @@ def estimate_flood_depth(

if estimator.lower() == 'nmad':
hand_mean = np.nanmean(hand[flood_labels == label])
hand_std = stats.median_abs_deviation(hand[flood_labels == label], scale='normal', nan_policy='omit')
hand_std: Any = stats.median_abs_deviation(hand[flood_labels == label], scale='normal', nan_policy='omit')

if estimator.lower() == 'numpy':
hand_mean = np.nanmean(hand[flood_labels == label])
Expand Down Expand Up @@ -260,7 +260,9 @@ def make_flood_map(
padding_mask = vv_array.mask
del vv_array

labeled_flood_mask, num_labels = ndimage.label(flood_mask)
# The return type annotation for ndimage.label is int, which seems incorrect,
# since the documentation shows an example of unpacking the return value, like we do here.
labeled_flood_mask, num_labels = ndimage.label(flood_mask) # type: ignore[misc]
object_slices = ndimage.find_objects(labeled_flood_mask)
log.info(f'Detected {num_labels} waterbodies...')
if estimator.lower() == 'iterative':
Expand Down
1 change: 1 addition & 0 deletions src/asf_tools/hydrosar/hand/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def prepare_hand_vrt(vrt: str | Path, geometry: ogr.Geometry | BaseGeometry):
if isinstance(geometry, BaseGeometry):
geometry = ogr.CreateGeometryFromWkb(geometry.wkb)

assert isinstance(geometry, ogr.Geometry)
min_lon, max_lon, _, _ = geometry.GetEnvelope()
if min_lon < -160.0 and max_lon > 160.0:
raise ValueError(f'asf_tools does not currently support geometries that cross the antimeridian: {geometry}')
Expand Down
2 changes: 1 addition & 1 deletion src/asf_tools/hydrosar/threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def _make_histogram(image):
del indices
size = image.size
maximum = int(np.ceil(np.amax(image)) + 1)
histogram = np.zeros((1, maximum))
histogram: np.ndarray = np.zeros((1, maximum))
for i in range(0, size):
floor_value = np.floor(image[i]).astype(np.uint8)
if 0 < floor_value < maximum - 1:
Expand Down
Loading