Skip to content

Commit 24de29a

Browse files
committed
implementation and tests added
1 parent ce89576 commit 24de29a

44 files changed

Lines changed: 10894 additions & 17 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
## Changes in 0.1.0 (under development)
2+
3+
- Added algorithm for **affine transformation**.
4+
- Added algorithm for **rectification of non-regular grids**.
5+
- Added algorithm for **reprojection to a different coordinate reference system (CRS)**.
6+
- Introduced main function `resample_in_space`, which dynamically selects the
7+
appropriate resampling algorithm based on the input dataset.

environment.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,28 @@ channels:
44
dependencies:
55
# Python
66
- python >=3.10
7+
# Required
8+
- affine >=2.2
9+
- dask >=2021.6
10+
- dask-image >=0.6
11+
- numba >=0.52
12+
- numpy >=1.16
13+
- pyproj >=3.0
14+
- xarray >=2024.7
15+
- zarr >=2.11,<3 # until we can ensure zarr 3 compatibility
16+
# Development Dependencies - Tools
17+
- black
18+
- isort
19+
- mkdocs
20+
- mkdocs-autorefs
21+
- mkdocs-material
22+
- mkdocs-jupyter
23+
- mkdocstrings
24+
- mkdocstrings-python
25+
- pytest
26+
- pytest-cov
27+
- ruff
28+
# Development Dependencies - Demos
29+
- jupyterlab
30+
- matplotlib
731

pyproject.toml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,34 @@ classifiers = [
4040

4141
requires-python = ">=3.10"
4242

43-
dependencies = []
43+
dependencies = [
44+
"affine>=2.2",
45+
"dask>=2021.6",
46+
"dask-image>=0.6",
47+
"numba>=0.52",
48+
"numpy>=1.16",
49+
"pyproj>=3.0",
50+
"xarray>=2024.7",
51+
"zarr>=2.11,<3"
52+
]
4453

4554
[project.optional-dependencies]
46-
dev = []
55+
dev = [
56+
# Build tools
57+
"build",
58+
"hatch",
59+
"twine",
60+
# Code Style / QA
61+
"black",
62+
"isort",
63+
"ruff",
64+
# Testing
65+
"pytest",
66+
"pytest-cov",
67+
# Notebooks / Visualisation
68+
"jupyterlab",
69+
"matplotlib",
70+
]
4771
doc = [
4872
"mkdocs",
4973
"mkdocs-autorefs",

tests/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# The MIT License (MIT)
2+
# Copyright (c) 2025 by the xcube development team and contributors
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a
5+
# copy of this software and associated documentation files (the "Software"),
6+
# to deal in the Software without restriction, including without limitation
7+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
# and/or sell copies of the Software, and to permit persons to whom the
9+
# Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
# DEALINGS IN THE SOFTWARE.

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import numba as nb
2+
3+
nb.config.DISABLE_JIT = True

tests/gridmapping/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# The MIT License (MIT)
2+
# Copyright (c) 2025 by the xcube development team and contributors
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a
5+
# copy of this software and associated documentation files (the "Software"),
6+
# to deal in the Software without restriction, including without limitation
7+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
# and/or sell copies of the Software, and to permit persons to whom the
9+
# Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
# DEALINGS IN THE SOFTWARE.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# The MIT License (MIT)
2+
# Copyright (c) 2025 by the xcube development team and contributors
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a
5+
# copy of this software and associated documentation files (the "Software"),
6+
# to deal in the Software without restriction, including without limitation
7+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
# and/or sell copies of the Software, and to permit persons to whom the
9+
# Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
# DEALINGS IN THE SOFTWARE.
21+
22+
import unittest
23+
24+
from xcube_resampling.gridmapping import assertions
25+
26+
27+
class Testassertions(unittest.TestCase):
28+
# --- assert_given ---
29+
def test_assert_given_ok(self):
30+
assertions.assert_given("hello")
31+
32+
def test_assert_given_fail(self):
33+
with self.assertRaises(ValueError) as cm:
34+
assertions.assert_given("", name="arg")
35+
self.assertIn("arg must be given", str(cm.exception))
36+
37+
# --- assert_instance ---
38+
def test_assert_instance_ok(self):
39+
assertions.assert_instance(5, int)
40+
41+
def test_assert_instance_fail(self):
42+
with self.assertRaises(TypeError) as cm:
43+
assertions.assert_instance("s", int, name="val")
44+
self.assertIn("val must be an instance of", str(cm.exception))
45+
46+
def test_assert_instance_tuple_dtype(self):
47+
assertions.assert_instance(5, (int, float)) # should pass
48+
49+
# --- assert_in ---
50+
def test_assert_in_ok(self):
51+
assertions.assert_in(1, [1, 2, 3])
52+
53+
def test_assert_in_fail(self):
54+
with self.assertRaises(ValueError) as cm:
55+
assertions.assert_in("z", ["a", "b"], name="char")
56+
self.assertIn("char must be one of", str(cm.exception))
57+
58+
# --- assert_true ---
59+
def test_assert_true_ok(self):
60+
assertions.assert_true(True, "must be true")
61+
62+
def test_assert_true_fail(self):
63+
with self.assertRaises(ValueError) as cm:
64+
assertions.assert_true(False, "bad value")
65+
self.assertEqual(str(cm.exception), "bad value")

0 commit comments

Comments
 (0)