Skip to content
6 changes: 3 additions & 3 deletions src/earthkit/data/data/wrappers/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def _repr_html_(self):
return self.describe()._repr_html_()

def bounding_box(self):
if "/" in self.data:
return tuple(float(x) for x in self.data.split("/"))
if "/" in self._data:
return tuple(float(x) for x in self._data.split("/"))
else:
raise ValueError(f"Invalid bounding box '{self.data}'")
raise ValueError(f"Invalid bounding box '{self._data}'")

def _datetime(self):
return parse_date(self._data)
Expand Down
16 changes: 16 additions & 0 deletions tests/sources/test_mars.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,22 @@ def test_mars_grib_save():
assert len(ds1) == 1


# @pytest.mark.long_test
# @pytest.mark.download
@pytest.mark.skipif(NO_MARS, reason="No access to MARS")
def test_mars_grib_area_str():
s = from_source(
"mars",
param=["2t"],
levtype="sfc",
area="50/-50/20/50",
grid=[10, 10],
prompt=False,
date="2023-05-10",
).to_fieldlist()
assert len(s) == 1


if __name__ == "__main__":
from earthkit.data.utils.testing import main

Expand Down
9 changes: 9 additions & 0 deletions tests/wrappers/test_string_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,12 @@ def test_string_wrapper_datetime_list_by(date_format):
assert ds.to_value() == datetime_list_string + "/by/2"
assert ds.to_string() == datetime_list_string + "/by/2"
assert ds.to_datetime_list() == dt


def test_string_wrapper_bbox():
v = "89/0/-89/360"
ds = from_object(v)
assert ds._TYPE_NAME == "str"
assert "bounding_box" in ds.available_types

assert ds.bounding_box() == (89.0, 0.0, -89.0, 360.0)
Loading