Skip to content

Commit

Permalink
fix deprecation warnings (#218)
Browse files Browse the repository at this point in the history
* fix deprecation warnings

* fix warning

* fix
  • Loading branch information
lkstrp authored Jan 30, 2025
1 parent e96bea5 commit 1bb7b7a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 30 deletions.
10 changes: 4 additions & 6 deletions powerplantmatching/cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def clean_name(df, config=None):
return df.assign(Name=name).sort_values("Name")


@deprecated(deprecated_in="5.0", removed_in="0.6", details="Use `clean_name` instead.")
@deprecated(deprecated_in="5.0", details="Use `clean_name` instead.")
def clean_powerplantname(df, config=None):
return clean_name(df, config=config)

Expand Down Expand Up @@ -243,7 +243,6 @@ def gather_fueltype_info(

@deprecated(
deprecated_in="0.5",
removed_in="0.6",
details="Use `gather_specifications` instead.",
)
def gather_technology_info(
Expand Down Expand Up @@ -302,10 +301,9 @@ def gather_set_info(df, search_col=["Name", "Fueltype", "Technology"], config=No
return df.assign(Set=Set)


@deprecated(
deprecated_in="0.5",
removed_in="0.6",
)
# @deprecated(
# deprecated_in="0.5",
# )
def clean_technology(df, generalize_hydros=False):
"""
Clean the 'Technology' by condensing down the value into one claim. This
Expand Down
2 changes: 1 addition & 1 deletion powerplantmatching/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def powerplants(
return matched.pipe(set_column_name, "Matched Data")


@deprecated(deprecated_in="5.5", removed_in="0.6", details="Use `powerplants` instead.")
@deprecated(deprecated_in="5.5", details="Use `powerplants` instead.")
def matched_data(
config=None,
update=False,
Expand Down
11 changes: 2 additions & 9 deletions powerplantmatching/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
gather_fueltype_info,
gather_set_info,
gather_specifications,
gather_technology_info,
)
from .core import _package_data, get_config
from .heuristics import scale_to_net_capacities
Expand Down Expand Up @@ -311,7 +310,6 @@ def to_year(ds):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="Removed since data is not publicly available anymore",
)
def CARMA(raw=False, update=False, config=None):
Expand Down Expand Up @@ -458,7 +456,6 @@ def set_large_spanish_stores_to_reservoirs(df):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="Use the JRC data instead",
)
def IWPDCY(config=None):
Expand Down Expand Up @@ -595,7 +592,7 @@ def GPD(raw=False, update=False, config=None, filter_other_dbs=True):
.pipe(clean_name)
.pipe(set_column_name, "GPD")
.pipe(config_filter, config)
.pipe(gather_technology_info, config=config)
.pipe(gather_specifications, config=config)
)


Expand Down Expand Up @@ -859,7 +856,6 @@ def ENTSOE_EIC(raw=False, update=False, config=None, entsoe_token=None):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function is not maintained anymore.",
)
def WEPP(raw=False, config=None):
Expand Down Expand Up @@ -1129,7 +1125,6 @@ def WEPP(raw=False, config=None):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function is not maintained anymore.",
)
def UBA(
Expand Down Expand Up @@ -1253,7 +1248,6 @@ def UBA(

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function is not maintained anymore.",
)
def BNETZA(
Expand Down Expand Up @@ -1350,7 +1344,7 @@ def BNETZA(
lambda df: df.projectID.notna()
& df.Status.str.contains(pattern, regex=True, case=False)
].pipe(
gather_technology_info,
gather_specifications,
search_col=["Name", "Fueltype", "Blockname"],
config=config,
)
Expand Down Expand Up @@ -2280,7 +2274,6 @@ def MASTR(
# deprecated alias for GGPT
@deprecated(
deprecated_in="0.5.5",
removed_in="0.6",
details="Use `GGPT` instead.",
)
def GEM_GGPT(*args, **kwargs):
Expand Down
7 changes: 3 additions & 4 deletions powerplantmatching/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def to_pypsa_network(df, network, buslist=None):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function is not maintained anymore and will be removed in the future.",
)
def to_TIMES(df=None, use_scaled_capacity=False, baseyear=2015):
Expand Down Expand Up @@ -318,7 +317,7 @@ def to_TIMES(df=None, use_scaled_capacity=False, baseyear=2015):
return df_exp


@deprecated(deprecated_in="0.5.0", removed_in="0.6.0")
@deprecated(deprecated_in="0.5.0")
def store_open_dataset():
from .collection import matched_data, reduce_matched_dataframe

Expand All @@ -331,7 +330,7 @@ def store_open_dataset():
return m


@deprecated(deprecated_in="0.5.0", removed_in="0.6.0")
@deprecated(deprecated_in="0.5.0")
def fueltype_to_abbrev():
"""
Return the fueltype-specific abbreviation.
Expand All @@ -354,7 +353,7 @@ def fueltype_to_abbrev():
return data


@deprecated(deprecated_in="0.5.0", removed_in="0.6.0")
@deprecated(deprecated_in="0.5.0")
def timestype_to_life():
"""
Returns the timestype-specific technical lifetime.
Expand Down
14 changes: 5 additions & 9 deletions powerplantmatching/heuristics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
from deprecation import deprecated
from six import iteritems

from powerplantmatching.cleaning import gather_specifications

from .core import _package_data, get_config, get_obj_if_Acc
from .utils import lookup

Expand Down Expand Up @@ -327,7 +329,6 @@ def wm(x):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function was renamed to `fill_missing_commissioning_years`",
)
def fill_missing_commyears(df):
Expand All @@ -336,7 +337,6 @@ def fill_missing_commyears(df):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function was renamed to `fill_missing_decommissioning_years`",
)
def fill_missing_decommyears(df, config=None):
Expand All @@ -345,7 +345,6 @@ def fill_missing_decommyears(df, config=None):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function was renamed to `aggregate_VRE_by_commissioning_year`",
)
def aggregate_VRE_by_commyear(df, config=None):
Expand All @@ -354,7 +353,6 @@ def aggregate_VRE_by_commyear(df, config=None):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function is not maintained anymore and will be removed in the future.",
)
def derive_vintage_cohorts_from_statistics(df, base_year=2015, config=None):
Expand Down Expand Up @@ -455,7 +453,6 @@ def reduceVintages(addition, mat, life, y_pres):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function is not maintained anymore and will be removed in the future.",
)
def set_denmark_region_id(df):
Expand Down Expand Up @@ -501,7 +498,6 @@ def set_denmark_region_id(df):

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function is not maintained anymore and will be removed in the future.",
)
def remove_oversea_areas(df, lat=[36, 72], lon=[-10.6, 31]):
Expand All @@ -522,7 +518,6 @@ def remove_oversea_areas(df, lat=[36, 72], lon=[-10.6, 31]):

def gross_to_net_factors(reference="opsd", aggfunc="median", return_entire_data=False):
""" """
from .cleaning import gather_technology_info

if reference == "opsd":
from .data import OPSD
Expand Down Expand Up @@ -555,7 +550,9 @@ def gross_to_net_factors(reference="opsd", aggfunc="median", return_entire_data=
inplace=True,
)
df.rename(columns={"technology": "Technology"}, inplace=True)
df = gather_technology_info(df, ["Technology", "energy_source_level_2"])
df = gather_specifications(
df, parse_columns=["Technology", "energy_source_level_2"]
)
df = df.assign(
energy_source_level_2=lambda df: df.energy_source_level_2.str.title()
)
Expand Down Expand Up @@ -588,7 +585,6 @@ def PLZ_to_LatLon_map():

@deprecated(
deprecated_in="0.5.0",
removed_in="0.6.0",
details="This function is not maintained anymore and will be removed in the future.",
)
def set_known_retire_years(df):
Expand Down
3 changes: 2 additions & 1 deletion powerplantmatching/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def cross_matches(sets_of_pairs, labels=None):
matches = pd.concat(
[
matches.groupby(label, as_index=False, sort=False).apply(
lambda x: x.loc[x.isnull().sum(axis=1).idxmin()]
lambda x: x.loc[x.isnull().sum(axis=1).idxmin()],
include_groups=False,
),
matches[matches[label].isnull()],
]
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ include = ["powerplantmatching"]

[tool.pytest.ini_options]
filterwarnings = [
"error::DeprecationWarning", # Raise all DeprecationWarnings as errors
"error::FutureWarning", # Raise all FutureWarnings as errors
]

Expand Down

0 comments on commit 1bb7b7a

Please sign in to comment.