File tree Expand file tree Collapse file tree 3 files changed +42
-6
lines changed Expand file tree Collapse file tree 3 files changed +42
-6
lines changed Original file line number Diff line number Diff line change @@ -41,3 +41,15 @@ pip install rasterix
41
41
hatch env run --env test.py3.13 run-pytest # Run the tests without coverage reports
42
42
hatch env run --env test.py3.13 run-coverage-html # Run the tests with an html coverage report
43
43
```
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
+ ```
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ dependencies = [
31
31
" pandas>=2" ,
32
32
" numpy>=2" ,
33
33
" xarray>=2025" ,
34
+ " xproj" ,
34
35
]
35
36
dynamic =[" version" ]
36
37
[project .optional-dependencies ]
@@ -42,13 +43,16 @@ rasterize = [
42
43
]
43
44
exactextract = [" exactextract" ]
44
45
test = [
45
- " geodatasets" ,
46
46
" dask-geopandas" ,
47
+ " geodatasets" ,
48
+ " exactextract" ,
49
+ " ipykernel" ,
50
+ " ipython" ,
51
+ " netCDF4" ,
47
52
" odc-geo" ,
48
53
" rasterio" ,
49
54
" rioxarray" ,
50
- " exactextract" ,
51
- " netCDF4"
55
+ " ruff" ,
52
56
]
53
57
54
58
[tool .hatch ]
@@ -82,8 +86,9 @@ run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --
82
86
run-coverage-html = " pytest --cov-config=pyproject.toml --cov=pkg --cov-report html --cov=src"
83
87
run-pytest = " run-coverage --no-cov"
84
88
run-verbose = " run-coverage --verbose"
85
- run-mypy = " mypy src"
86
89
list-env = " pip list"
90
+ install-kernel = " python -m ipykernel install --user --name=rasterix"
91
+ lint = " ruff check"
87
92
88
93
[tool .ruff .lint ]
89
94
# E402: module level import not at top of file
Original file line number Diff line number Diff line change 2
2
import rioxarray # noqa
3
3
import xarray as xr
4
4
from affine import Affine
5
+ import pytest
6
+
7
+ from xarray .structure .merge import MergeError
5
8
6
9
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" )
7
16
8
17
9
18
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 ()
12
20
da_raster_index = assign_index (da_no_raster_index )
13
21
assert da_raster_index .equals (da_no_raster_index )
14
22
15
23
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
+
16
35
# TODO: parameterize over
17
36
# 1. y points up;
18
37
# 2. y points down
You can’t perform that action at this time.
0 commit comments