From 6c9702ec241b871d7369cd3249490f7946b3e51b Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:54:31 -0400 Subject: [PATCH] address warnings --- ravenpy/extractors/routing_product.py | 6 +++++- ravenpy/utilities/geo.py | 13 +++++++++---- tests/test_nb_graphs.py | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ravenpy/extractors/routing_product.py b/ravenpy/extractors/routing_product.py index 20507a81..c066e633 100644 --- a/ravenpy/extractors/routing_product.py +++ b/ravenpy/extractors/routing_product.py @@ -420,7 +420,11 @@ def keep_only_valid_downsubid_and_obs_nm(g): return row - # Remove duplicate HRU_IDs while making sure that we keed relevant DowSubId and Obs_NM values + # Remove duplicate HRU_IDs while making sure that we keep relevant DowSubId and Obs_NM values + # FIXME: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. + # This behavior is deprecated, and in a future version of pandas the grouping columns will be + # excluded from the operation. Either pass `include_groups=False` to exclude the groupings or + # explicitly select the grouping columns after groupby to silence this warning. self._routing_data = self._routing_data.groupby( self._routing_id_field, group_keys=False ).apply(keep_only_valid_downsubid_and_obs_nm) diff --git a/ravenpy/utilities/geo.py b/ravenpy/utilities/geo.py index d7d1a4cb..6c6c8946 100644 --- a/ravenpy/utilities/geo.py +++ b/ravenpy/utilities/geo.py @@ -234,10 +234,15 @@ def generic_vector_reproject( try: geom = shape(feature["geometry"]) transformed = geom_transform(geom, source_crs, target_crs) - feature["geometry"] = fiona.Geometry().from_dict( - mapping(transformed) - ) - sink.write(feature) + transformed_feature = { + "geometry": fiona.Geometry().from_dict( + mapping(transformed) + ), + "properties": feature.__geo_interface__["properties"], + "id": feature.__geo_interface__["id"], + "type": feature.__geo_interface__["type"], + } + sink.write(transformed_feature) except Exception as err: LOGGER.exception( f"{err}: Unable to reproject feature {feature}" diff --git a/tests/test_nb_graphs.py b/tests/test_nb_graphs.py index 83a52562..2cf697f0 100644 --- a/tests/test_nb_graphs.py +++ b/tests/test_nb_graphs.py @@ -24,7 +24,7 @@ def test_ts_fit_graph(self, get_local_testdata): from xclim.indicators.generic import fit, stats with xr.open_dataset(get_local_testdata(self.hydrographs)) as ds: - ts = stats(ds.q_sim.load(), op="max", freq="M") + ts = stats(ds.q_sim.load(), op="max", freq="ME") with set_options(check_missing="skip"): params = fit(ts, dist="gamma") self.nbg.ts_fit_graph(ts, params)