Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Code freeze date: YYYY-MM-DD
- `Hazard.from_raster_xarray` now returns a sparse matrix instead of a sparse array [#1261](https://github.com/CLIMADA-project/climada_python/pull/1261).
- `ImpactCalc.impact` now raises a clear `ValueError` when the supplied `Hazard` contains no events, instead of failing later inside `np.array_split` with an obscure message [#814](https://github.com/CLIMADA-project/climada_python/issues/814).
- Fix TCTracks.from_FAST duplicate loading from year loop [#1269](github.com/CLIMADA-project/climada_python/pull/1269)
- `TropCyclone.apply_climate_scenario_knu` now raises its `ValueError` for negative frequencies (the check `any(x) < 0` never triggered) [#1338](https://github.com/CLIMADA-project/climada_python/pull/1338).
- Fix missing spaces and `f` prefixes in warning and error messages [#1338](https://github.com/CLIMADA-project/climada_python/pull/1338).
- Remove debug `print` calls [#1338](https://github.com/CLIMADA-project/climada_python/pull/1338).

### Deprecated
- `Impact.calc_freq_curve()` should not be given the parameter `return_per`. Use the parameter `return_periods` in `Impact.calc_freq_curve().interpolate()` instead.
Expand Down
6 changes: 2 additions & 4 deletions climada/engine/calibration_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def change_impf(impf_instance, param_dict):
)
else:
raise AttributeError(
"keys in param_dict not recognized. Use only:"
"keys in param_dict not recognized. Use only: "
"paa_shift, paa_scale, mdd_shift, mdd_scale"
)

Expand Down Expand Up @@ -394,7 +394,6 @@ def calib_all(
for x in itertools.product(*param_full_dict.values())
)
for param_dict in params_generator:
print(param_dict)
df_out = copy.deepcopy(df_impact_data)
impact_func_final, df_out = init_impf(impf_name_or_instance, param_dict, df_out)
df_out = calib_instance(
Expand Down Expand Up @@ -475,7 +474,6 @@ def calib_optimize(
# definie specific function to
def specific_calib(values):
param_dict_temp = dict(zip(param_dict.keys(), values))
print(param_dict_temp)
return calib_instance(
hazard,
exposure,
Expand Down Expand Up @@ -519,7 +517,7 @@ def specific_calib(values):
else:
LOGGER.info(
"Opimization did not finish successfully. Check you input"
" or consult the detailed returns (with argument"
" or consult the detailed returns (with argument "
"show_details=True) for further information."
)

Expand Down
14 changes: 7 additions & 7 deletions climada/engine/impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def tot_value(self):
instead.
"""
LOGGER.warning(
"The Impact.tot_value attribute is deprecated."
"The Impact.tot_value attribute is deprecated. "
"Use Exposures.affected_total_value to calculate the affected "
"total exposure value based on a specific hazard intensity "
"threshold"
Expand All @@ -294,7 +294,7 @@ def tot_value(self):
def tot_value(self, value):
"""Set the total exposure value close to a hazard"""
LOGGER.warning(
"The Impact.tot_value attribute is deprecated."
"The Impact.tot_value attribute is deprecated. "
"Use Exposures.affected_total_value to calculate the affected "
"total exposure value based on a specific hazard intensity "
"threshold"
Expand Down Expand Up @@ -485,7 +485,7 @@ def impact_at_reg(self, agg_regions=None):
def calc_impact_year_set(self, all_years=True, year_range=None):
"""This function is deprecated, use Impact.impact_per_year instead."""
LOGGER.warning(
"The use of Impact.calc_impact_year_set is deprecated."
"The use of Impact.calc_impact_year_set is deprecated. "
"Use Impact.impact_per_year instead."
)
return self.impact_per_year(all_years=all_years, year_range=year_range)
Expand Down Expand Up @@ -566,7 +566,7 @@ def local_exceedance_impact(
)
if self.imp_mat.size == 0:
raise ValueError(
"Attribute imp_mat is empty. Recalculate Impact"
"Attribute imp_mat is empty. Recalculate Impact "
"instance with parameter save_mat=True"
)

Expand Down Expand Up @@ -713,7 +713,7 @@ def local_return_period(
LOGGER.info("Computing return period map for impacts: %s", threshold_impact)
if self.imp_mat.size == 0:
raise ValueError(
"Attribute imp_mat is empty. Recalculate Impact"
"Attribute imp_mat is empty. Recalculate Impact "
"instance with parameter save_mat=True"
)

Expand Down Expand Up @@ -1077,7 +1077,7 @@ def plot_hexbin_impact_exposure(
"""
if self.imp_mat.size == 0:
raise ValueError(
"Attribute imp_mat is empty. Recalculate Impact"
"Attribute imp_mat is empty. Recalculate Impact "
"instance with parameter save_mat=True"
)
if "cmap" not in kwargs:
Expand Down Expand Up @@ -1145,7 +1145,7 @@ def plot_basemap_impact_exposure(
"""
if self.imp_mat.size == 0:
raise ValueError(
"Attribute imp_mat is empty. Recalculate Impact"
"Attribute imp_mat is empty. Recalculate Impact "
"instance with parameter save_mat=True"
)

Expand Down
2 changes: 1 addition & 1 deletion climada/engine/impact_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def _return_impact(self, imp_mat_gen, save_mat):
else:
if isinstance(self.hazard, HazardForecast):
raise ValueError(
"Saving impact matrix is required when using HazardForecast."
"Saving impact matrix is required when using HazardForecast. "
"Please set save_mat=True."
)
imp_mat = None
Expand Down
1 change: 0 additions & 1 deletion climada/engine/impact_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,6 @@ def scale_impact2refyear(impact_values, year_values, iso3a_values, reference_yea
# get GDP value for each country and year:
gdp_years[country] = dict()
years_country = np.unique(year_values[iso3a_values == country])
print(years_country)
for year in years_country:
gdp_years[country][year] = gdp(country, year)[1]
# loop through each value and apply scaling:
Expand Down
4 changes: 2 additions & 2 deletions climada/engine/unsequa/calc_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def est_comp_time(self, n_samples, time_one_run, processes=None):
if time_one_run > 5:
LOGGER.warning(
"Computation time for one set of parameters is "
"%.2fs. This is rather long."
"%.2fs. This is rather long. "
"Potential reasons: InputVars are loading data, centroids have "
"been assigned to exp before defining input_var, ..."
"\n If computation cannot be reduced, consider using"
Expand Down Expand Up @@ -249,7 +249,7 @@ def make_sample(self, N, sampling_method="saltelli", sampling_kwargs=None):
if sampling_method == "ff":
LOGGER.warning(
"You are using the 'ff' sampler which does not require "
"a value for N. The entered N value will be ignored"
"a value for N. The entered N value will be ignored "
"in the sampling process."
)
uniform_base_sample = self._make_uniform_base_sample(
Expand Down
2 changes: 1 addition & 1 deletion climada/engine/unsequa/calc_delta_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def uncertainty(

if unc_sample.samples_df.empty:
raise ValueError(
"No sample was found. Please create one first"
"No sample was found. Please create one first "
"using UncImpact.make_sample(N)"
)

Expand Down
2 changes: 1 addition & 1 deletion climada/engine/unsequa/calc_impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def uncertainty(

if unc_sample.samples_df.empty:
raise ValueError(
"No sample was found. Please create one first"
"No sample was found. Please create one first "
"using UncImpact.make_sample(N)"
)

Expand Down
4 changes: 2 additions & 2 deletions climada/entity/_legacy_measures/measure_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def read_att_mat(measures, data, file_name, var_names):
def read_mat(self, *args, **kwargs):
"""This function is deprecated, use MeasureSet.from_mat instead."""
LOGGER.warning(
"The use of MeasureSet.read_mat is deprecated."
"The use of MeasureSet.read_mat is deprecated. "
"Use MeasureSet.from_mat instead."
)
self.__dict__ = MeasureSet.from_mat(*args, **kwargs).__dict__
Expand Down Expand Up @@ -557,7 +557,7 @@ def read_att_excel(measures, dfr, var_names):
def read_excel(self, *args, **kwargs):
"""This function is deprecated, use MeasureSet.from_excel instead."""
LOGGER.warning(
"The use ofMeasureSet.read_excel is deprecated."
"The use of MeasureSet.read_excel is deprecated. "
"Use MeasureSet.from_excel instead."
)
self.__dict__ = MeasureSet.from_excel(*args, **kwargs).__dict__
Expand Down
4 changes: 2 additions & 2 deletions climada/entity/disc_rates/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def from_mat(cls, file_name, var_names=None):
def read_mat(self, *args, **kwargs):
"""This function is deprecated, use ``DiscRates.from_mat`` instead."""
LOGGER.warning(
"The use of DiscRates.read_mat is deprecated."
"The use of DiscRates.read_mat is deprecated. "
"Use DiscRates.from_mat instead."
)
self.__dict__ = DiscRates.from_mat(*args, **kwargs).__dict__
Expand Down Expand Up @@ -305,7 +305,7 @@ def from_excel(cls, file_name, var_names=None):
def read_excel(self, *args, **kwargs):
"""This function is deprecated, use DiscRates.from_excel instead."""
LOGGER.warning(
"The use of DiscRates.read_excel is deprecated."
"The use of DiscRates.read_excel is deprecated. "
"Use DiscRates.from_excel instead."
)
self.__dict__ = DiscRates.from_excel(*args, **kwargs).__dict__
Expand Down
2 changes: 1 addition & 1 deletion climada/entity/entity_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def from_mat(cls, file_name):
def read_mat(self, *args, **kwargs):
"""This function is deprecated, use Entity.from_mat instead."""
LOGGER.warning(
"The use of Entity.read_mat is deprecated." "Use Entity.from_mat instead."
"The use of Entity.read_mat is deprecated. Use Entity.from_mat instead."
)
self.__dict__ = Entity.from_mat(*args, **kwargs).__dict__

Expand Down
4 changes: 2 additions & 2 deletions climada/entity/exposures/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ def write_hdf5(self, file_name):
def read_hdf5(self, *args, **kwargs):
"""This function is deprecated, use Exposures.from_hdf5 instead."""
LOGGER.warning(
"The use of Exposures.read_hdf5 is deprecated."
"The use of Exposures.read_hdf5 is deprecated. "
"Use Exposures.from_hdf5 instead."
)
self.__dict__ = Exposures.from_hdf5(*args, **kwargs).__dict__
Expand Down Expand Up @@ -1233,7 +1233,7 @@ def from_hdf5(cls, file_name):
def read_mat(self, *args, **kwargs):
"""This function is deprecated, use Exposures.from_mat instead."""
LOGGER.warning(
"The use of Exposures.read_mat is deprecated."
"The use of Exposures.read_mat is deprecated. "
"Use Exposures.from_mat instead."
)
self.__dict__ = Exposures.from_mat(*args, **kwargs).__dict__
Expand Down
12 changes: 6 additions & 6 deletions climada/entity/exposures/litpop/litpop.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(
def set_countries(self, *args, **kwargs):
"""This function is deprecated, use LitPop.from_countries instead."""
LOGGER.warning(
"The use of LitPop.set_countries is deprecated."
"The use of LitPop.set_countries is deprecated. "
"Use LitPop.from_countries instead."
)
self.__dict__ = LitPop.from_countries(*args, **kwargs).__dict__
Expand Down Expand Up @@ -307,7 +307,7 @@ def from_countries(
def set_nightlight_intensity(self, *args, **kwargs):
"""This function is deprecated, use LitPop.from_nightlight_intensity instead."""
LOGGER.warning(
"The use of LitPop.set_nightlight_intensity is deprecated."
"The use of LitPop.set_nightlight_intensity is deprecated. "
"Use LitPop.from_nightlight_intensity instead."
)
self.__dict__ = LitPop.from_nightlight_intensity(*args, **kwargs).__dict__
Expand Down Expand Up @@ -409,7 +409,7 @@ def from_nightlight_intensity(
def set_population(self, *args, **kwargs):
"""This function is deprecated, use LitPop.from_population instead."""
LOGGER.warning(
"The use of LitPop.set_population is deprecated."
"The use of LitPop.set_population is deprecated. "
"Use LitPop.from_population instead."
)
self.__dict__ = LitPop.from_population(*args, **kwargs).__dict__
Expand Down Expand Up @@ -510,7 +510,7 @@ def from_population(
def set_custom_shape_from_countries(self, *args, **kwargs):
"""This function is deprecated, use LitPop.from_shape_and_countries instead."""
LOGGER.warning(
"The use of LitPop.set_custom_shape_from_countries is deprecated."
"The use of LitPop.set_custom_shape_from_countries is deprecated. "
"Use LitPop.from_shape_and_countries instead."
)
self.__dict__ = LitPop.from_shape_and_countries(*args, **kwargs).__dict__
Expand Down Expand Up @@ -646,7 +646,7 @@ def from_shape_and_countries(
gdf = exp.gdf.loc[idx]
else:
raise NotImplementedError(
"Not implemented for `shape` of type {type(shape)}"
f"Not implemented for `shape` of type {type(shape)}"
)

exp.description = (
Expand Down Expand Up @@ -681,7 +681,7 @@ def from_shape_and_countries(
def set_custom_shape(self, *args, **kwargs):
"""This function is deprecated, use LitPop.from_shape instead."""
LOGGER.warning(
"The use of LitPop.set_custom_shape is deprecated."
"The use of LitPop.set_custom_shape is deprecated. "
"Use LitPop.from_shape instead."
)
self.__dict__ = LitPop.from_shape(*args, **kwargs).__dict__
Expand Down
2 changes: 1 addition & 1 deletion climada/entity/impact_funcs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def from_sigmoid_impf(
def set_sigmoid_impf(self, *args, **kwargs):
"""This function is deprecated, use LitPop.from_countries instead."""
LOGGER.warning(
"The use of ImpactFunc.set_sigmoid_impf is deprecated."
"The use of ImpactFunc.set_sigmoid_impf is deprecated. "
"Use ImpactFunc.from_sigmoid_impf instead."
)
self.__dict__ = ImpactFunc.from_sigmoid_impf(*args, **kwargs).__dict__
Expand Down
2 changes: 1 addition & 1 deletion climada/entity/impact_funcs/impact_func_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def _get_hdf5_str(imp, idxs, file_name, var_name):
def read_mat(self, *args, **kwargs):
"""This function is deprecated, use ImpactFuncSet.from_mat instead."""
LOGGER.warning(
"The use of ImpactFuncSet.read_mat is deprecated."
"The use of ImpactFuncSet.read_mat is deprecated. "
"Use ImpactFuncSet.from_mat instead."
)
self.__dict__ = ImpactFuncSet.from_mat(*args, **kwargs).__dict__
Expand Down
4 changes: 2 additions & 2 deletions climada/entity/impact_funcs/storm_europe.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def set_schwierz(self, impf_id=1):
instead.
"""
LOGGER.warning(
"The use of ImpfStormEurope.set_schwierz is deprecated."
"The use of ImpfStormEurope.set_schwierz is deprecated. "
"Use ImpfStormEurope.from_schwierz instead."
)
self.__dict__ = ImpfStormEurope.from_schwierz(impf_id=impf_id).__dict__
Expand All @@ -129,7 +129,7 @@ def set_welker(self, impf_id=1):
instead.
"""
LOGGER.warning(
"The use of ImpfStormEurope.set_welker is deprecated."
"The use of ImpfStormEurope.set_welker is deprecated. "
"Use ImpfStormEurope.from_welker instead."
)
self.__dict__ = ImpfStormEurope.from_welker(impf_id=impf_id).__dict__
Expand Down
4 changes: 2 additions & 2 deletions climada/entity/impact_funcs/trop_cyclone.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self):
def set_emanuel_usa(self, *args, **kwargs):
"""This function is deprecated, use from_emanuel_usa() instead."""
LOGGER.warning(
"The use of ImpfTropCyclone.set_emanuel_usa is deprecated."
"The use of ImpfTropCyclone.set_emanuel_usa is deprecated. "
"Use ImpfTropCyclone.from_emanuel_usa instead."
)
self.__dict__ = ImpfTropCyclone.from_emanuel_usa(*args, **kwargs).__dict__
Expand Down Expand Up @@ -210,7 +210,7 @@ def __init__(self):
def set_calibrated_regional_ImpfSet(self, *args, **kwargs):
"""This function is deprecated, use from_calibrated_regional_ImpfSet() instead."""
LOGGER.warning(
"ImpfSetTropCyclone.set_calibrated_regional_ImpfSet is deprecated."
"ImpfSetTropCyclone.set_calibrated_regional_ImpfSet is deprecated. "
"Use ImpfSetTropCyclone.from_calibrated_regional_ImpfSet instead."
)
self.__dict__ = ImpfSetTropCyclone.from_calibrated_regional_ImpfSet(
Expand Down
6 changes: 3 additions & 3 deletions climada/hazard/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ def set_frequency(self, yearrange=None):
"""
if self.frequency_unit not in ["1/year", "annual", "1/y", "1/a"]:
LOGGER.warning(
"setting the frequency on a hazard object who's frequency unit"
"setting the frequency on a hazard object who's frequency unit "
"is %s and not %s will most likely lead to unexpected results",
self.frequency_unit,
u_const.DEF_FREQ_UNIT,
Expand Down Expand Up @@ -1208,8 +1208,8 @@ def get_mdr(self, cent_idx, impf):
mdr.data = impf.calc_mdr(mdr.data)
else:
LOGGER.warning(
"Impact function id=%d has mdr(0) != 0."
"The mean damage ratio must thus be computed for all values of"
"Impact function id=%d has mdr(0) != 0. "
"The mean damage ratio must thus be computed for all values of "
"hazard intensity including 0 which can be very time consuming.",
impf.id,
)
Expand Down
2 changes: 1 addition & 1 deletion climada/hazard/centroids/centr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ def _ne_crs_geom(self):

@classmethod
@deprecated(
details="Reading Centroids data from matlab files is not supported anymore."
details="Reading Centroids data from matlab files is not supported anymore. "
"This method has been removed with climada 5.0"
)
def from_mat(cls, file_name, var_names=None):
Expand Down
7 changes: 4 additions & 3 deletions climada/hazard/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class HazardIO:
def set_raster(self, *args, **kwargs):
"""This function is deprecated, use Hazard.from_raster."""
LOGGER.warning(
"The use of Hazard.set_raster is deprecated."
"The use of Hazard.set_raster is deprecated. "
"Use Hazard.from_raster instead."
)
self.__dict__ = self.__class__.from_raster(*args, **kwargs).__dict__
Expand Down Expand Up @@ -783,7 +783,7 @@ def _attrs_to_kwargs(attrs: Dict[str, Any], num_events: int) -> Dict[str, Any]:
def read_excel(self, *args, **kwargs):
"""This function is deprecated, use Hazard.from_excel."""
LOGGER.warning(
"The use of Hazard.read_excel is deprecated."
"The use of Hazard.read_excel is deprecated. "
"Use Hazard.from_excel instead."
)
self.__dict__ = self.__class__.from_excel(*args, **kwargs).__dict__
Expand Down Expand Up @@ -961,7 +961,8 @@ def write_hdf5(self, file_name, todense=False):
def read_hdf5(self, *args, **kwargs):
"""This function is deprecated, use Hazard.from_hdf5."""
LOGGER.warning(
"The use of Hazard.read_hdf5 is deprecated." "Use Hazard.from_hdf5 instead."
"The use of Hazard.read_hdf5 is deprecated. "
"Use Hazard.from_hdf5 instead."
)
self.__dict__ = self.__class__.from_hdf5(*args, **kwargs).__dict__

Expand Down
Loading