Skip to content

Commit

Permalink
merge with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mathleur committed Aug 30, 2023
1 parent 5f86a2c commit f29d9e8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/test_mappers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from polytope.datacube.mappers import OctahedralGridMap
from polytope.datacube.datacube_mappers import OctahedralGridMapper


class TestMapper:
def test_octahedral_mapper_init(self):
mapped_axes = ["lat", "lon"]
base_axis = "base"
resolution = 1280
octahedral_mapper = OctahedralGridMap(base_axis, mapped_axes, resolution)
octahedral_mapper = OctahedralGridMapper(base_axis, mapped_axes, resolution)
assert octahedral_mapper._base_axis == base_axis
assert octahedral_mapper._mapped_axes == mapped_axes
assert octahedral_mapper._resolution == resolution
Expand All @@ -15,7 +15,7 @@ def test_first_axis_vals_01280_grid(self):
mapped_axes = ["lat", "lon"]
base_axis = "base"
resolution = 1280
octahedral_mapper = OctahedralGridMap(base_axis, mapped_axes, resolution)
octahedral_mapper = OctahedralGridMapper(base_axis, mapped_axes, resolution)
assert octahedral_mapper.first_axis_vals()[:5] == [
89.94618771566562,
89.87647835333229,
Expand All @@ -29,7 +29,7 @@ def test_first_axis_vals_other_grid(self):
mapped_axes = ["lat", "lon"]
base_axis = "base"
resolution = 640
octahedral_mapper = OctahedralGridMap(base_axis, mapped_axes, resolution)
octahedral_mapper = OctahedralGridMapper(base_axis, mapped_axes, resolution)
assert octahedral_mapper.first_axis_vals()[:5] == [
89.89239644559007,
89.75300494317403,
Expand All @@ -43,7 +43,7 @@ def test_map_first_axis(self):
mapped_axes = ["lat", "lon"]
base_axis = "base"
resolution = 1280
octahedral_mapper = OctahedralGridMap(base_axis, mapped_axes, resolution)
octahedral_mapper = OctahedralGridMapper(base_axis, mapped_axes, resolution)
assert octahedral_mapper.map_first_axis(89.7, 89.96) == [
89.94618771566562,
89.87647835333229,
Expand All @@ -55,7 +55,7 @@ def test_second_axis_vals(self):
mapped_axes = ["lat", "lon"]
base_axis = "base"
resolution = 1280
octahedral_mapper = OctahedralGridMap(base_axis, mapped_axes, resolution)
octahedral_mapper = OctahedralGridMapper(base_axis, mapped_axes, resolution)
assert octahedral_mapper.second_axis_vals(0.035149384215604956)[0] == 0
assert octahedral_mapper.second_axis_vals(10.017574499477174)[0] == 0
assert octahedral_mapper.second_axis_vals(89.94618771566562)[10] == 180
Expand All @@ -67,14 +67,14 @@ def test_map_second_axis(self):
mapped_axes = ["lat", "lon"]
base_axis = "base"
resolution = 1280
octahedral_mapper = OctahedralGridMap(base_axis, mapped_axes, resolution)
octahedral_mapper = OctahedralGridMapper(base_axis, mapped_axes, resolution)
assert octahedral_mapper.map_second_axis(89.94618771566562, 0, 90) == [0, 18, 36, 54, 72, 90]

def test_axes_idx_to_octahedral_idx(self):
mapped_axes = ["lat", "lon"]
base_axis = "base"
resolution = 1280
octahedral_mapper = OctahedralGridMap(base_axis, mapped_axes, resolution)
octahedral_mapper = OctahedralGridMapper(base_axis, mapped_axes, resolution)
assert octahedral_mapper.axes_idx_to_octahedral_idx(1, 0) == 0
assert octahedral_mapper.axes_idx_to_octahedral_idx(1, 1) == 1
assert octahedral_mapper.axes_idx_to_octahedral_idx(1, 16) == 16
Expand All @@ -99,7 +99,7 @@ def test_unmap(self):
mapped_axes = ["lat", "lon"]
base_axis = "base"
resolution = 1280
octahedral_mapper = OctahedralGridMap(base_axis, mapped_axes, resolution)
octahedral_mapper = OctahedralGridMapper(base_axis, mapped_axes, resolution)
assert octahedral_mapper.unmap(89.94618771566562, 0) == 0
assert octahedral_mapper.unmap(0.035149384215604956, 0) == 3299840 - 5136
assert octahedral_mapper.unmap(-0.035149384215604956, 0) == 3299840

0 comments on commit f29d9e8

Please sign in to comment.