Skip to content

Commit bfef378

Browse files
changed deprecation warning to decorators
1 parent 685b6c8 commit bfef378

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

climada/engine/impact.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import numpy as np
4141
import pandas as pd
4242
import xlsxwriter
43+
from deprecation import deprecated
4344
from pyproj import CRS as pyprojCRS
4445
from rasterio.crs import CRS as rasterioCRS # pylint: disable=no-name-in-module
4546
from scipy import sparse
@@ -595,14 +596,14 @@ def local_exceedance_impact(
595596

596597
return gdf, label, column_label
597598

599+
@deprecated(
600+
details="The use of Impact.local_exceedance_imp is deprecated. Use "
601+
"Impact.local_exceedance_impact instead. Some errors in the previous calculation "
602+
"in Impact.local_exceedance_imp have been corrected. To reproduce data with the "
603+
"previous calculation, use CLIMADA v5.0.0 or less."
604+
)
598605
def local_exceedance_imp(self, return_periods=(25, 50, 100, 250)):
599606
"""This function is deprecated, use Impact.local_exceedance_impact instead."""
600-
LOGGER.warning(
601-
"The use of Impact.local_exceedance_imp is deprecated. Use "
602-
"Impact.local_exceedance_impact instead. Some errors in the previous calculation "
603-
"in Impact.local_exceedance_imp have been corrected. To reproduce data with the "
604-
"previous calculation, use CLIMADA v5.0.0 or less."
605-
)
606607

607608
return (
608609
self.local_exceedance_impact(return_periods)[0]
@@ -1001,7 +1002,10 @@ def plot_basemap_impact_exposure(
10011002

10021003
return axis
10031004

1004-
# TODO: replace with plot_from_gdf()
1005+
@deprecated(
1006+
details="The use of Impact.plot_rp_imp is deprecated."
1007+
"Use Impact.local_exceedance_impact and util.plot.plot_from_gdf instead."
1008+
)
10051009
def plot_rp_imp(
10061010
self,
10071011
return_periods=(25, 50, 100, 250),
@@ -1013,13 +1017,8 @@ def plot_rp_imp(
10131017
"""
10141018
This function is deprecated, use Impact.local_exceedance_impact and
10151019
util.plot.plot_from_gdf instead.
1016-
"""
1017-
LOGGER.warning(
1018-
"The use of Impact.plot_rp_imp is deprecated."
1019-
"Use Impact.local_exceedance_impact and util.plot.plot_from_gdf instead."
1020-
)
10211020
1022-
"""Compute and plot exceedance impact maps for different return periods.
1021+
Compute and plot exceedance impact maps for different return periods.
10231022
Calls local_exceedance_imp.
10241023
10251024
Parameters

climada/hazard/base.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import geopandas as gpd
3131
import numpy as np
32+
from deprecation import deprecated
3233
from pathos.pools import ProcessPool as Pool
3334
from scipy import sparse
3435

@@ -584,14 +585,14 @@ def local_exceedance_intensity(
584585

585586
return gdf, label, column_label
586587

588+
@deprecated(
589+
details="The use of Hazard.local_exceedance_inten is deprecated. Use "
590+
"Hazard.local_exceedance_intensity instead. Some errors in the previous calculation "
591+
"in Hazard.local_exceedance_inten have been corrected. To reproduce data with the "
592+
"previous calculation, use CLIMADA v5.0.0 or less."
593+
)
587594
def local_exceedance_inten(self, return_period=(25, 50, 100, 250)):
588595
"""This function is deprecated, use Hazard.local_exceedance_intensity instead."""
589-
LOGGER.warning(
590-
"The use of Hazard.local_exceedance_inten is deprecated. Use "
591-
"Hazard.local_exceedance_intensity instead. Some errors in the previous calculation "
592-
"in Hazard.local_exceedance_inten have been corrected. To reproduce data with the "
593-
"previous calculation, use CLIMADA v5.0.0 or less."
594-
)
595596
return (
596597
self.local_exceedance_intensity(return_period)[0]
597598
.values[:, 1:]

climada/hazard/plot.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import matplotlib.pyplot as plt
2525
import numpy as np
26+
from deprecation import deprecated
2627

2728
import climada.util.plot as u_plot
2829

@@ -36,7 +37,10 @@ class HazardPlot:
3637
Contains all plotting methods of the Hazard class
3738
"""
3839

39-
# TODO depreciating warning, to be replaced with plot_from_gdf
40+
@deprecated(
41+
details="The use of Hazard.plot_rp_intensity is deprecated."
42+
"Use Hazard.local_exceedance_intensity and util.plot.plot_from_gdf instead."
43+
)
4044
def plot_rp_intensity(
4145
self,
4246
return_periods=(25, 50, 100, 250),
@@ -49,13 +53,8 @@ def plot_rp_intensity(
4953
"""
5054
This function is deprecated,
5155
use Impact.local_exceedance_impact and util.plot.plot_from_gdf instead.
52-
"""
53-
LOGGER.warning(
54-
"The use of Hazard.plot_rp_intensity is deprecated."
55-
"Use Hazard.local_exceedance_intensity and util.plot.plot_from_gdf instead."
56-
)
5756
58-
"""Compute and plot hazard exceedance intensity maps for different
57+
Compute and plot hazard exceedance intensity maps for different
5958
return periods. Calls local_exceedance_inten.
6059
6160
Parameters

0 commit comments

Comments
 (0)