Skip to content

Commit

Permalink
nicer fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mathleur committed Jan 19, 2024
1 parent e2161ca commit 721c53a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions polytope/datacube/index_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from sortedcontainers import SortedList

from .datacube_axis import IntDatacubeAxis
from .datacube_axis import IntDatacubeAxis, UnsliceableDatacubeAxis


class DatacubePath(OrderedDict):
Expand Down Expand Up @@ -85,7 +85,7 @@ def __eq__(self, other):
if other.value == self.value:
return True
else:
if isinstance(self.value, str):
if isinstance(self.axis, UnsliceableDatacubeAxis):
return False
else:
if other.value - 2 * other.axis.tol <= self.value <= other.value + 2 * other.axis.tol:
Expand Down
41 changes: 41 additions & 0 deletions tests/test_multiple_param_fdb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import pandas as pd
import pytest

from polytope.engine.hullslicer import HullSlicer
from polytope.polytope import Polytope, Request
from polytope.shapes import Box, Select


class TestSlicingFDBDatacube:
def setup_method(self, method):
from polytope.datacube.backends.fdb import FDBDatacube

# Create a dataarray with 3 labelled axes using different index types
self.options = {
"values": {"mapper": {"type": "octahedral", "resolution": 1280, "axes": ["latitude", "longitude"]}},
"date": {"merge": {"with": "time", "linkers": ["T", "00"]}},
"step": {"type_change": "int"},
}
self.config = {"class": "od", "expver": "0001", "levtype": "sfc", "stream": "oper", "type": "fc"}
self.fdbdatacube = FDBDatacube(self.config, axis_options=self.options)
self.slicer = HullSlicer()
self.API = Polytope(datacube=self.fdbdatacube, engine=self.slicer, axis_options=self.options)

# Testing different shapes
@pytest.mark.fdb
def test_fdb_datacube(self):
request = Request(
Select("step", [0]),
Select("levtype", ["sfc"]),
Select("date", [pd.Timestamp("20240118T000000")]),
Select("domain", ["g"]),
Select("expver", ["0001"]),
Select("param", ["49", "167"]),
Select("class", ["od"]),
Select("stream", ["oper"]),
Select("type", ["fc"]),
Box(["latitude", "longitude"], [0, 0], [0.2, 0.2]),
)
result = self.API.retrieve(request)
result.pprint()
assert len(result.leaves) == 18

0 comments on commit 721c53a

Please sign in to comment.