rashdf 0.8.1__tar.gz → 0.8.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rashdf
3
- Version: 0.8.1
3
+ Version: 0.8.2
4
4
  Summary: Read data from HEC-RAS HDF files.
5
5
  Project-URL: repository, https://github.com/fema-ffrd/rashdf
6
6
  Classifier: Development Status :: 4 - Beta
@@ -12,7 +12,7 @@ classifiers = [
12
12
  "Programming Language :: Python :: 3.11",
13
13
  "Programming Language :: Python :: 3.12",
14
14
  ]
15
- version = "0.8.1"
15
+ version = "0.8.2"
16
16
  dependencies = ["h5py", "geopandas>=1.0,<2.0", "pyarrow", "xarray<=2025.4.0"]
17
17
 
18
18
  [project.optional-dependencies]
@@ -106,10 +106,15 @@ class RasGeomHdf(RasHdf):
106
106
  mesh_area_names = self.mesh_area_names()
107
107
  if not mesh_area_names:
108
108
  return GeoDataFrame()
109
- mesh_area_polygons = [
110
- Polygon(self[f"{self.FLOW_AREA_2D_PATH}/{n}/Perimeter"][()])
111
- for n in mesh_area_names
112
- ]
109
+
110
+ mesh_area_polygons = []
111
+ for n in mesh_area_names:
112
+ try:
113
+ mesh_area_polygons.append(
114
+ Polygon(self[f"{self.FLOW_AREA_2D_PATH}/{n}/Perimeter"][()])
115
+ )
116
+ except KeyError as e:
117
+ raise RasGeomHdfError(f"Data for mesh '{n}' not found.") from e
113
118
  return GeoDataFrame(
114
119
  {"mesh_name": mesh_area_names, "geometry": mesh_area_polygons},
115
120
  geometry="geometry",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rashdf
3
- Version: 0.8.1
3
+ Version: 0.8.2
4
4
  Summary: Read data from HEC-RAS HDF files.
5
5
  Project-URL: repository, https://github.com/fema-ffrd/rashdf
6
6
  Classifier: Development Status :: 4 - Beta
@@ -2,9 +2,10 @@ import geopandas as gpd
2
2
  from pathlib import Path
3
3
  import h5py
4
4
  from pyproj import CRS
5
- from src.rashdf import RasGeomHdf
5
+ from src.rashdf.geom import RasGeomHdf, RasGeomHdfError
6
6
  from pandas.testing import assert_frame_equal
7
7
  import pytest
8
+ import numpy as np
8
9
 
9
10
  from . import _create_hdf_with_group_attrs, _gdf_matches_json, _gdf_matches_json_alt
10
11
 
@@ -44,6 +45,20 @@ def test_invalid_mesh_area_names(tmp_path):
44
45
  assert ghdf.mesh_area_names() == []
45
46
 
46
47
 
48
+ def test_missing_mesh_in_mesh_area(tmp_path):
49
+ test_hdf = tmp_path / "test.hdf"
50
+ mesh_name = "blw-west-fork"
51
+ with h5py.File(test_hdf, "w") as f:
52
+ dtype = np.dtype([("Name", h5py.string_dtype("utf-8"))])
53
+ data = np.array([(mesh_name,)], dtype=dtype)
54
+ f.create_dataset(f"{RasGeomHdf.FLOW_AREA_2D_PATH}/Attributes", data=data)
55
+
56
+ ras_hdf = RasGeomHdf(test_hdf)
57
+ expected_error_message = f"Data for mesh '{mesh_name}' not found."
58
+ with pytest.raises(RasGeomHdfError, match=expected_error_message):
59
+ ras_hdf.mesh_areas()
60
+
61
+
47
62
  def test_mesh_areas():
48
63
  mesh_areas_json = TEST_JSON / "mesh_areas.json"
49
64
  with RasGeomHdf(MUNCIE_G05) as ghdf:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes