Skip to content

Commit 3f1929e

Browse files
committed
more development notes, add xproj to tests
1 parent fe7dae0 commit 3f1929e

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,15 @@ pip install rasterix
4141
hatch env run --env test.py3.13 run-pytest # Run the tests without coverage reports
4242
hatch env run --env test.py3.13 run-coverage-html # Run the tests with an html coverage report
4343
```
44+
45+
#### Using hatch
46+
47+
Start a shell
48+
```
49+
hatch env run --env test.py3.13 ipython
50+
```
51+
52+
Expose kernel for notebooks in JupyterLab
53+
```
54+
hatch env run --env test.py3.13 "python -m ipykernel install --user --name=rasterix"
55+
```

pyproject.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies = [
3131
"pandas>=2",
3232
"numpy>=2",
3333
"xarray>=2025",
34+
"xproj",
3435
]
3536
dynamic=["version"]
3637
[project.optional-dependencies]
@@ -42,13 +43,16 @@ rasterize = [
4243
]
4344
exactextract = ["exactextract"]
4445
test = [
45-
"geodatasets",
4646
"dask-geopandas",
47+
"geodatasets",
48+
"exactextract",
49+
"ipykernel",
50+
"ipython",
51+
"netCDF4",
4752
"odc-geo",
4853
"rasterio",
4954
"rioxarray",
50-
"exactextract",
51-
"netCDF4"
55+
"ruff",
5256
]
5357

5458
[tool.hatch]
@@ -82,8 +86,9 @@ run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --
8286
run-coverage-html = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report html --cov=src"
8387
run-pytest = "run-coverage --no-cov"
8488
run-verbose = "run-coverage --verbose"
85-
run-mypy = "mypy src"
8689
list-env = "pip list"
90+
install-kernel = "python -m ipykernel install --user --name=rasterix"
91+
lint = "ruff check"
8792

8893
[tool.ruff.lint]
8994
# E402: module level import not at top of file

tests/test_raster_index.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,36 @@
22
import rioxarray # noqa
33
import xarray as xr
44
from affine import Affine
5+
import pytest
6+
7+
from xarray.structure.merge import MergeError
58

69
from rasterix import RasterIndex, assign_index
10+
# TODO: hook up xproj to remove need for import?
11+
import xproj
12+
13+
def _open_test_raster():
14+
source = "/vsicurl/https://noaadata.apps.nsidc.org/NOAA/G02135/south/daily/geotiff/2024/01_Jan/S_20240101_concentration_v3.0.tif"
15+
return xr.open_dataarray(source, engine="rasterio")
716

817

918
def test_rectilinear():
10-
source = "/vsicurl/https://noaadata.apps.nsidc.org/NOAA/G02135/south/daily/geotiff/2024/01_Jan/S_20240101_concentration_v3.0.tif"
11-
da_no_raster_index = xr.open_dataarray(source, engine="rasterio")
19+
da_no_raster_index = _open_test_raster()
1220
da_raster_index = assign_index(da_no_raster_index)
1321
assert da_raster_index.equals(da_no_raster_index)
1422

1523

24+
def test_different_crs_same_geotransform():
25+
da = _open_test_raster()
26+
da1 = assign_index(da)
27+
da2 = da1.copy()
28+
da1 = da1.proj.assign_crs(spatial_ref='EPSG:32610')
29+
da2 = da2.proj.assign_crs(spatial_ref='EPSG:32611')
30+
with pytest.raises(
31+
MergeError, match="conflicting values/indexes on objects to be combined for coordinate"
32+
):
33+
da1 + da2
34+
1635
# TODO: parameterize over
1736
# 1. y points up;
1837
# 2. y points down

0 commit comments

Comments
 (0)