Skip to content

Commit

Permalink
Merge pull request #216 from ecmwf/feature/throw_error_unsliceable_ax…
Browse files Browse the repository at this point in the history
…is_many_vals

throw error when the unsliceable axis tries to slice a shape with mor…
  • Loading branch information
mathleur authored Nov 8, 2024
2 parents bb4e17e + d5fd27a commit 7c82ca0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions polytope_feature/datacube/backends/fdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def __init__(
for axis_config in alternative_axes:
self.fdb_coordinates[axis_config.axis_name] = axis_config.values

fdb_coordinates_copy = deepcopy(self.fdb_coordinates)
for axis, vals in fdb_coordinates_copy.items():
if len(vals) == 1:
if vals[0] == "":
self.fdb_coordinates.pop(axis)

logging.info("Axes returned from GribJump are: " + str(self.fdb_coordinates))

self.fdb_coordinates["values"] = []
Expand Down
2 changes: 1 addition & 1 deletion polytope_feature/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ConvexPolytope(Shape):
def __init__(self, axes, points, method=None, is_orthogonal=False):
self._axes = list(axes)
self.is_flat = False
if len(self._axes) == 1:
if len(self._axes) == 1 and len(points) == 1:
self.is_flat = True
self.points = points
self.method = method
Expand Down
1 change: 0 additions & 1 deletion tests/requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ cffi
eccodes
h5netcdf
h5py
earthkit
earthkit-data
2 changes: 1 addition & 1 deletion tests/test_datacube_axes_init.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import earthkit.data as data
import pytest
from earthkit import data
from helper_functions import download_test_data

from polytope_feature.datacube.datacube_axis import FloatDatacubeAxis
Expand Down

0 comments on commit 7c82ca0

Please sign in to comment.