diff --git a/docs/usage.rst b/docs/usage.rst index 4e39cbee4..cb25937d9 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -75,7 +75,7 @@ Both code blocks will create an hourly datetime index for 2011: .. code-block:: python import pandas as pd - my_index = pd.date_range('1/1/2011', periods=8761, freq='H') + my_index = pd.date_range('1/1/2011', periods=8761, freq='h') This index can be used to define the EnergySystem: @@ -816,7 +816,7 @@ This small example of PV, grid and SinkDSM shows how to use the component data = pd.DataFrame.from_dict(data_dict) # Do timestamp stuff - datetimeindex = pd.date_range(start='1/1/2013', periods=len(data.index), freq='H') + datetimeindex = pd.date_range(start='1/1/2013', periods=len(data.index), freq='h') data['timestamp'] = datetimeindex data.set_index('timestamp', inplace=True) @@ -1030,10 +1030,10 @@ First, you start by defining your energy system as you might have done before, b import pandas as pd import oemof.solph as solph - my_index = pd.date_range('1/1/2013', periods=17520, freq='H') + my_index = pd.date_range('1/1/2013', periods=17520, freq='h') periods = [ - pd.date_range('1/1/2013', periods=8760, freq='H'), - pd.date_range('1/1/2014', periods=8760, freq='H'), + pd.date_range('1/1/2013', periods=8760, freq='h'), + pd.date_range('1/1/2014', periods=8760, freq='h'), ] my_energysystem = solph.EnergySystem(timeindex=my_index, periods=periods) @@ -1084,7 +1084,7 @@ So if you want to use this, the above would simplify to: def determine_periods(datetimeindex): ... - my_index = pd.date_range('1/1/2013', periods=17520, freq='H') + my_index = pd.date_range('1/1/2013', periods=17520, freq='h') periods = determine_periods(my_index) # Make use of method my_energysystem = solph.EnergySystem(timeindex=my_index, periods=periods) diff --git a/examples/activity_costs/activity_costs.py b/examples/activity_costs/activity_costs.py index 950304d21..9f129c015 100644 --- a/examples/activity_costs/activity_costs.py +++ b/examples/activity_costs/activity_costs.py @@ -52,7 +52,7 @@ def main(): # Calculate parameters and initialize the energy system and ########################################################################## periods = 24 - time = pd.date_range("1/1/2018", periods=periods, freq="H") + time = pd.date_range("1/1/2018", periods=periods, freq="h") demand_heat = np.full(periods, 5) demand_heat[:4] = 0 diff --git a/examples/electrical/transshipment.py b/examples/electrical/transshipment.py index 8f6349c72..d5e0e53ef 100644 --- a/examples/electrical/transshipment.py +++ b/examples/electrical/transshipment.py @@ -129,7 +129,7 @@ def draw_graph( def main(): - datetimeindex = pd.date_range("1/1/2017", periods=3, freq="H") + datetimeindex = pd.date_range("1/1/2017", periods=3, freq="h") es = EnergySystem(timeindex=datetimeindex, infer_last_interval=False) diff --git a/examples/emission_constraint/emission_constraint.py b/examples/emission_constraint/emission_constraint.py index 4945eaa28..73537ead4 100644 --- a/examples/emission_constraint/emission_constraint.py +++ b/examples/emission_constraint/emission_constraint.py @@ -39,7 +39,7 @@ def main(): # create energy system energysystem = solph.EnergySystem( - timeindex=pd.date_range("1/1/2012", periods=3, freq="H") + timeindex=pd.date_range("1/1/2012", periods=3, freq="h") ) # create gas bus diff --git a/examples/flexible_modelling/add_constraints.py b/examples/flexible_modelling/add_constraints.py index 824da815a..dda9e3639 100644 --- a/examples/flexible_modelling/add_constraints.py +++ b/examples/flexible_modelling/add_constraints.py @@ -56,7 +56,7 @@ def run_add_constraints_example(solver="cbc", nologg=False): # ##### creating an oemof solph optimization model, nothing special here ## # create an energy system object for the oemof solph nodes es = EnergySystem( - timeindex=pd.date_range("1/1/2017", periods=5, freq="H"), + timeindex=pd.date_range("1/1/2017", periods=5, freq="h"), infer_last_interval=False, ) # add some nodes diff --git a/examples/flexible_modelling/saturating_storage.py b/examples/flexible_modelling/saturating_storage.py index 08efa43ab..46f9d7730 100644 --- a/examples/flexible_modelling/saturating_storage.py +++ b/examples/flexible_modelling/saturating_storage.py @@ -40,7 +40,7 @@ def saturating_storage_example(): # create an energy system - idx = pd.date_range("1/1/2023", periods=100, freq="H") + idx = pd.date_range("1/1/2023", periods=100, freq="h") es = solph.EnergySystem(timeindex=idx, infer_last_interval=False) # power bus diff --git a/examples/flow_count_limit/flow_count_limit.py b/examples/flow_count_limit/flow_count_limit.py index 0ba707e74..210d85052 100644 --- a/examples/flow_count_limit/flow_count_limit.py +++ b/examples/flow_count_limit/flow_count_limit.py @@ -50,7 +50,7 @@ def main(): energy_system = solph.EnergySystem( - timeindex=pd.date_range("1/1/2012", periods=4, freq="H") + timeindex=pd.date_range("1/1/2012", periods=4, freq="h") ) bel = solph.Bus(label="bel") diff --git a/examples/gradient_example/gradient_example.py b/examples/gradient_example/gradient_example.py index c1e153668..c1f7f58cb 100644 --- a/examples/gradient_example/gradient_example.py +++ b/examples/gradient_example/gradient_example.py @@ -50,7 +50,7 @@ def main(): # used. gradient = 0.01 - date_time_index = pd.date_range("1/1/2012", periods=48, freq="H") + date_time_index = pd.date_range("1/1/2012", periods=48, freq="h") print(date_time_index) energysystem = EnergySystem( timeindex=date_time_index, infer_last_interval=True diff --git a/examples/invest_nonconvex_flow_examples/diesel_genset_nonconvex_investment.py b/examples/invest_nonconvex_flow_examples/diesel_genset_nonconvex_investment.py index 8ecaa15af..9ea6dfa30 100644 --- a/examples/invest_nonconvex_flow_examples/diesel_genset_nonconvex_investment.py +++ b/examples/invest_nonconvex_flow_examples/diesel_genset_nonconvex_investment.py @@ -89,7 +89,7 @@ def main(): # Change the index of data to be able to select data based on the time # range. - data.index = pd.date_range(start="2022-01-01", periods=len(data), freq="H") + data.index = pd.date_range(start="2022-01-01", periods=len(data), freq="h") # Choose the range of the solar potential and demand # based on the selected simulation period. diff --git a/examples/offset_converter_example/offset_diesel_genset_nonconvex_investment.py b/examples/offset_converter_example/offset_diesel_genset_nonconvex_investment.py index e56a013e5..061c77c78 100644 --- a/examples/offset_converter_example/offset_diesel_genset_nonconvex_investment.py +++ b/examples/offset_converter_example/offset_diesel_genset_nonconvex_investment.py @@ -89,7 +89,7 @@ def offset_converter_example(): data = pd.read_csv(filepath_or_buffer=filename) # Change the index of data to be able to select data based on the time range. - data.index = pd.date_range(start="2022-01-01", periods=len(data), freq="H") + data.index = pd.date_range(start="2022-01-01", periods=len(data), freq="h") # Choose the range of the solar potential and demand # based on the selected simulation period. @@ -100,7 +100,7 @@ def offset_converter_example(): # Create the energy system. date_time_index = pd.date_range( - start=start_date, periods=n_days * 24, freq="H" + start=start_date, periods=n_days * 24, freq="h" ) energy_system = solph.EnergySystem(timeindex=date_time_index) diff --git a/examples/storage_balanced_unbalanced/storage.py b/examples/storage_balanced_unbalanced/storage.py index 396e96bb1..29c8069c6 100644 --- a/examples/storage_balanced_unbalanced/storage.py +++ b/examples/storage_balanced_unbalanced/storage.py @@ -66,7 +66,7 @@ def storage_example(): ) # create an energy system - idx = pd.date_range("1/1/2017", periods=len(timeseries), freq="H") + idx = pd.date_range("1/1/2017", periods=len(timeseries), freq="h") es = solph.EnergySystem(timeindex=idx) for data_set in DATA: diff --git a/examples/storage_costs/storage_costs.py b/examples/storage_costs/storage_costs.py index d82068860..312c5ab49 100644 --- a/examples/storage_costs/storage_costs.py +++ b/examples/storage_costs/storage_costs.py @@ -42,7 +42,7 @@ def storage_costs_example(): # create an energy system - idx = pd.date_range("1/1/2023", periods=13, freq="H") + idx = pd.date_range("1/1/2023", periods=13, freq="h") es = solph.EnergySystem(timeindex=idx, infer_last_interval=False) # power bus diff --git a/pyproject.toml b/pyproject.toml index d2bd463d8..059f2ba56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ dependencies = [ "blinker", "dill", "numpy", - "pandas >= 1.5.3", + "pandas >= 2.0.0", "pyomo >= 6.6.0, < 7.0", "networkx", "oemof.tools >= 0.4.3", diff --git a/src/oemof/solph/_energy_system.py b/src/oemof/solph/_energy_system.py index c089b0ef6..79681ad04 100644 --- a/src/oemof/solph/_energy_system.py +++ b/src/oemof/solph/_energy_system.py @@ -302,4 +302,13 @@ def create_time_index( number = round(hoy / interval) if start is None: start = f"1/1/{year}" - return pd.date_range(start, periods=number + 1, freq=f"{interval}h") + try: + time_index = pd.date_range( + start, periods=number + 1, freq=f"{interval}h" + ) + except ValueError: + # Pandas <2.2 compatibility + time_index = pd.date_range( + start, periods=number + 1, freq=f"{interval}H" + ) + return time_index diff --git a/src/oemof/solph/components/_sink.py b/src/oemof/solph/components/_sink.py index a48c6c188..7b5c4f829 100644 --- a/src/oemof/solph/components/_sink.py +++ b/src/oemof/solph/components/_sink.py @@ -64,9 +64,7 @@ def __init__(self, label=None, inputs=None, custom_attributes=None): ) super().__init__( - label=label, - inputs=inputs, - custom_properties=custom_attributes + label=label, inputs=inputs, custom_properties=custom_attributes ) def constraint_group(self): diff --git a/src/oemof/solph/components/_source.py b/src/oemof/solph/components/_source.py index beb9b4f72..13af1576f 100644 --- a/src/oemof/solph/components/_source.py +++ b/src/oemof/solph/components/_source.py @@ -74,9 +74,7 @@ def __init__(self, label=None, outputs=None, custom_attributes=None): ) super().__init__( - label=label, - outputs=outputs, - custom_properties=custom_attributes + label=label, outputs=outputs, custom_properties=custom_attributes ) def constraint_group(self): diff --git a/tests/constraint_tests.py b/tests/constraint_tests.py index 3b759d627..80bfdcaa1 100644 --- a/tests/constraint_tests.py +++ b/tests/constraint_tests.py @@ -29,7 +29,7 @@ def setup_class(cls): r"^objective.*(?=s\.t\.)", re.DOTALL | re.MULTILINE ) - cls.date_time_index = pd.date_range("1/1/2012", periods=3, freq="H") + cls.date_time_index = pd.date_range("1/1/2012", periods=3, freq="h") cls.tmppath = solph.helpers.extend_basic_path("tmp") logging.info(cls.tmppath) @@ -1903,7 +1903,7 @@ def test_nonequidistant_storage(self): """Constraint test of an energy system with non-equidistant time index """ - idxh = pd.date_range("1/1/2017", periods=3, freq="H") + idxh = pd.date_range("1/1/2017", periods=3, freq="h") idx2h = pd.date_range("1/1/2017 03:00:00", periods=2, freq="2H") idx30m = pd.date_range("1/1/2017 07:00:00", periods=4, freq="30min") timeindex = idxh.append([idx2h, idx30m]) diff --git a/tests/multi_period_constraint_tests.py b/tests/multi_period_constraint_tests.py index 991efeb86..ca2053202 100644 --- a/tests/multi_period_constraint_tests.py +++ b/tests/multi_period_constraint_tests.py @@ -45,9 +45,9 @@ def setup_class(cls): r"^objective.*(?=s\.t\.)", re.DOTALL | re.MULTILINE ) - timeindex1 = pd.date_range("1/1/2012", periods=2, freq="H") - timeindex2 = pd.date_range("1/1/2013", periods=2, freq="H") - timeindex3 = pd.date_range("1/1/2014", periods=2, freq="H") + timeindex1 = pd.date_range("1/1/2012", periods=2, freq="h") + timeindex2 = pd.date_range("1/1/2013", periods=2, freq="h") + timeindex3 = pd.date_range("1/1/2014", periods=2, freq="h") cls.date_time_index = timeindex1.append(timeindex2).append(timeindex3) cls.periods = [timeindex1, timeindex2, timeindex3] @@ -2316,7 +2316,7 @@ def test_multi_period_varying_period_length(self): # Create a list of timeindex for each period periods = [ - pd.date_range(f"1/1/{i}", periods=3, freq="H") for i in years + pd.date_range(f"1/1/{i}", periods=3, freq="h") for i in years ] # Create an overall timeindex diff --git a/tests/regression_tests.py b/tests/regression_tests.py index 8ec62c759..f233d8fbf 100644 --- a/tests/regression_tests.py +++ b/tests/regression_tests.py @@ -24,7 +24,7 @@ def test_version_metadata(): def test_wrong_logging_level(): - datetimeindex = pd.date_range("1/1/2012", periods=12, freq="H") + datetimeindex = pd.date_range("1/1/2012", periods=12, freq="h") es = solph.EnergySystem(timeindex=datetimeindex, infer_last_interval=True) tools.logger.define_logging() my_logger = logging.getLogger() diff --git a/tests/test_constraints_module.py b/tests/test_constraints_module.py index e28889a55..fbf4fc15b 100644 --- a/tests/test_constraints_module.py +++ b/tests/test_constraints_module.py @@ -4,7 +4,7 @@ def test_special(): - date_time_index = pd.date_range("1/1/2012", periods=5, freq="H") + date_time_index = pd.date_range("1/1/2012", periods=5, freq="h") energysystem = solph.EnergySystem( timeindex=date_time_index, infer_last_interval=True, @@ -28,7 +28,7 @@ def test_special(): def test_something_else(): - date_time_index = pd.date_range("1/1/2012", periods=5, freq="H") + date_time_index = pd.date_range("1/1/2012", periods=5, freq="h") energysystem = solph.EnergySystem( timeindex=date_time_index, infer_last_interval=True ) diff --git a/tests/test_energy_system.py b/tests/test_energy_system.py index d4a9b0cf4..77833087b 100644 --- a/tests/test_energy_system.py +++ b/tests/test_energy_system.py @@ -22,20 +22,20 @@ ) def test_add_periods(): """test method _add_periods of energy system""" - timeindex = pd.date_range(start="2012-01-01", periods=10000, freq="H") + timeindex = pd.date_range(start="2012-01-01", periods=10000, freq="h") periods = [ - pd.date_range(start="2012-01-01", periods=8784, freq="H"), - pd.date_range(start="2013-01-01", periods=1217, freq="H"), + pd.date_range(start="2012-01-01", periods=8784, freq="h"), + pd.date_range(start="2013-01-01", periods=1217, freq="h"), ] es = EnergySystem( timeindex=timeindex, periods=periods, infer_last_interval=True ) assert len(es.periods) == 2 assert es.periods[0].equals( - pd.date_range(start="2012-01-01", periods=8784, freq="H") + pd.date_range(start="2012-01-01", periods=8784, freq="h") ) assert es.periods[1].equals( - pd.date_range(start="2013-01-01", periods=1217, freq="H") + pd.date_range(start="2013-01-01", periods=1217, freq="h") ) @@ -48,9 +48,9 @@ def test_add_periods(): ) def test_extract_periods_years(): """test method _extract_periods_years of energy system""" - t_idx_1 = pd.date_range("1/1/2020", periods=3, freq="H").to_series() - t_idx_2 = pd.date_range("1/1/2041", periods=3, freq="H").to_series() - t_idx_3 = pd.date_range("1/1/2050", periods=3, freq="H").to_series() + t_idx_1 = pd.date_range("1/1/2020", periods=3, freq="h").to_series() + t_idx_2 = pd.date_range("1/1/2041", periods=3, freq="h").to_series() + t_idx_3 = pd.date_range("1/1/2050", periods=3, freq="h").to_series() timeindex = pd.concat([t_idx_1, t_idx_2, t_idx_3]).index periods = [t_idx_1, t_idx_2, t_idx_3] es = EnergySystem( diff --git a/tests/test_models.py b/tests/test_models.py index d450d887a..95086ba5c 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -112,7 +112,7 @@ def test_multi_period_default_discount_rate(): def test_cellular_structure_detection(): """Test flag creation if list is passed as energysystem to model""" - timeindex = pd.date_range(start="2020-01-01", periods=1, freq="H") + timeindex = pd.date_range(start="2020-01-01", periods=1, freq="h") es = solph.EnergySystem(timeindex=timeindex, infer_last_interval=True) ec_1 = solph.EnergySystem(timeindex=timeindex, infer_last_interval=True) ec_2 = solph.EnergySystem(timeindex=timeindex, infer_last_interval=True) @@ -125,7 +125,7 @@ def test_sub_cell_node_consideration(): Test if the nodes of sub-cells are considered for cellular energysystems. """ - timeindex = pd.date_range(start="2020-01-01", periods=1, freq="H") + timeindex = pd.date_range(start="2020-01-01", periods=1, freq="h") es = solph.EnergySystem(timeindex=timeindex, infer_last_interval=True) ec_1 = solph.EnergySystem(timeindex=timeindex, infer_last_interval=True) bus_es = solph.buses.Bus(label="bus_es") @@ -141,7 +141,7 @@ def test_sub_cell_flow_consideration(): Test if the flows of sub-cells are considered for cellular energysystems. """ - timeindex = pd.date_range(start="2020-01-01", periods=1, freq="H") + timeindex = pd.date_range(start="2020-01-01", periods=1, freq="h") es = solph.EnergySystem(timeindex=timeindex, infer_last_interval=True) ec_1 = solph.EnergySystem(timeindex=timeindex, infer_last_interval=True) bus_es = solph.buses.Bus(label="bus_es") diff --git a/tests/test_non_equidistant_time_index.py b/tests/test_non_equidistant_time_index.py index d4f3592f3..1b68df738 100644 --- a/tests/test_non_equidistant_time_index.py +++ b/tests/test_non_equidistant_time_index.py @@ -24,7 +24,7 @@ class TestParameterResult: @classmethod def setup_class(cls): - dtindex1 = pd.date_range("1/1/2012", periods=24, freq="H") + dtindex1 = pd.date_range("1/1/2012", periods=24, freq="h") dtindex2 = pd.date_range("1/2/2012", periods=49, freq="30min") dtindex = dtindex1.union(dtindex2) es = EnergySystem(timeindex=dtindex, infer_last_interval=False) diff --git a/tests/test_outputlib/__init__.py b/tests/test_outputlib/__init__.py index 752119194..5e86927e3 100644 --- a/tests/test_outputlib/__init__.py +++ b/tests/test_outputlib/__init__.py @@ -122,7 +122,7 @@ conversion_factors={bel: 1 / 3, b_heat_source: (cop - 1) / cop}, ) -datetimeindex = pd.date_range("1/1/2012", periods=24, freq="H") +datetimeindex = pd.date_range("1/1/2012", periods=24, freq="h") energysystem = EnergySystem(timeindex=datetimeindex, infer_last_interval=True) energysystem.add( bcoal, diff --git a/tests/test_processing.py b/tests/test_processing.py index c7d9d5842..b35c0e9e3 100644 --- a/tests/test_processing.py +++ b/tests/test_processing.py @@ -34,7 +34,7 @@ def setup_class(cls): timeindex=pandas.date_range( "2016-01-01", periods=cls.period, - freq="H", + freq="h", ), infer_last_interval=True, ) diff --git a/tests/test_scripts/test_solph/test_connect_invest/test_connect_invest.py b/tests/test_scripts/test_solph/test_connect_invest/test_connect_invest.py index 498261204..a409177fb 100644 --- a/tests/test_scripts/test_solph/test_connect_invest/test_connect_invest.py +++ b/tests/test_scripts/test_solph/test_connect_invest/test_connect_invest.py @@ -28,7 +28,7 @@ def test_connect_invest(): - date_time_index = pd.date_range("1/1/2012", periods=24 * 7, freq="H") + date_time_index = pd.date_range("1/1/2012", periods=24 * 7, freq="h") es = EnergySystem(timeindex=date_time_index, infer_last_interval=True) diff --git a/tests/test_scripts/test_solph/test_flexible_modelling/test_add_constraints.py b/tests/test_scripts/test_solph/test_flexible_modelling/test_add_constraints.py index 7851f9d52..9919eb735 100644 --- a/tests/test_scripts/test_solph/test_flexible_modelling/test_add_constraints.py +++ b/tests/test_scripts/test_solph/test_flexible_modelling/test_add_constraints.py @@ -32,7 +32,7 @@ def test_add_constraints_example(solver="cbc", nologg=False): # ##### creating an oemof solph optimization model, nothing special here ## # create an energy system object for the oemof solph nodes es = EnergySystem( - timeindex=pd.date_range("1/1/2012", periods=4, freq="H"), + timeindex=pd.date_range("1/1/2012", periods=4, freq="h"), infer_last_interval=True, ) diff --git a/tests/test_scripts/test_solph/test_generic_caes/test_generic_caes.py b/tests/test_scripts/test_solph/test_generic_caes/test_generic_caes.py index 335e30964..dc40286cb 100644 --- a/tests/test_scripts/test_solph/test_generic_caes/test_generic_caes.py +++ b/tests/test_scripts/test_solph/test_generic_caes/test_generic_caes.py @@ -37,7 +37,7 @@ def test_gen_caes(): periods = len(data) - 1 # create an energy system - idx = pd.date_range("1/1/2017", periods=periods, freq="H") + idx = pd.date_range("1/1/2017", periods=periods, freq="h") es = EnergySystem(timeindex=idx, infer_last_interval=True) # resources diff --git a/tests/test_scripts/test_solph/test_generic_chp/test_generic_chp.py b/tests/test_scripts/test_solph/test_generic_chp/test_generic_chp.py index 910c83532..6c9f8c423 100644 --- a/tests/test_scripts/test_solph/test_generic_chp/test_generic_chp.py +++ b/tests/test_scripts/test_solph/test_generic_chp/test_generic_chp.py @@ -31,7 +31,7 @@ def test_gen_chp(): periods = len(data) - 1 # create an energy system - idx = pd.date_range("1/1/2017", periods=periods, freq="H") + idx = pd.date_range("1/1/2017", periods=periods, freq="h") es = solph.EnergySystem(timeindex=idx, infer_last_interval=True) # resources diff --git a/tests/test_scripts/test_solph/test_invest_fix_flow/test_simple_invest_fixed.py b/tests/test_scripts/test_solph/test_invest_fix_flow/test_simple_invest_fixed.py index 8f2eb1d71..1a025b9a6 100644 --- a/tests/test_scripts/test_solph/test_invest_fix_flow/test_simple_invest_fixed.py +++ b/tests/test_scripts/test_solph/test_invest_fix_flow/test_simple_invest_fixed.py @@ -60,7 +60,7 @@ def test_dispatch_fix_example(solver="cbc", periods=10): inputs={bel: Flow(nominal_value=85, fix=data["demand_el"])}, ) - datetimeindex = pd.date_range("1/1/2012", periods=periods, freq="H") + datetimeindex = pd.date_range("1/1/2012", periods=periods, freq="h") energysystem = EnergySystem( timeindex=datetimeindex, infer_last_interval=True diff --git a/tests/test_scripts/test_solph/test_lopf/test_lopf.py b/tests/test_scripts/test_solph/test_lopf/test_lopf.py index 26b2a1fa6..e831734a4 100644 --- a/tests/test_scripts/test_solph/test_lopf/test_lopf.py +++ b/tests/test_scripts/test_solph/test_lopf/test_lopf.py @@ -34,7 +34,7 @@ def test_lopf(solver="cbc"): logging.info("Initialize the energy system") # create time index for 192 hours in May. - date_time_index = pd.date_range("5/5/2012", periods=1, freq="H") + date_time_index = pd.date_range("5/5/2012", periods=1, freq="h") es = EnergySystem(timeindex=date_time_index, infer_last_interval=True) ########################################################################## diff --git a/tests/test_scripts/test_solph/test_multi_period_model/test_multi_period_dispatch_model.py b/tests/test_scripts/test_solph/test_multi_period_model/test_multi_period_dispatch_model.py index 9b1ceef27..c61952720 100644 --- a/tests/test_scripts/test_solph/test_multi_period_model/test_multi_period_dispatch_model.py +++ b/tests/test_scripts/test_solph/test_multi_period_model/test_multi_period_dispatch_model.py @@ -36,9 +36,9 @@ def test_multi_period_dispatch_model(solver="cbc"): """Test a simple multi_period dispatch model""" - t_idx_1 = pd.date_range("1/1/2020", periods=3, freq="H") - t_idx_2 = pd.date_range("1/1/2030", periods=3, freq="H") - t_idx_3 = pd.date_range("1/1/2040", periods=3, freq="H") + t_idx_1 = pd.date_range("1/1/2020", periods=3, freq="h") + t_idx_2 = pd.date_range("1/1/2030", periods=3, freq="h") + t_idx_3 = pd.date_range("1/1/2040", periods=3, freq="h") # Create an overall timeindex t_idx_1_series = pd.Series(index=t_idx_1, dtype="float64") diff --git a/tests/test_scripts/test_solph/test_multi_period_model/test_multi_period_investment_model.py b/tests/test_scripts/test_solph/test_multi_period_model/test_multi_period_investment_model.py index e8d36f7ce..43c45834b 100644 --- a/tests/test_scripts/test_solph/test_multi_period_model/test_multi_period_investment_model.py +++ b/tests/test_scripts/test_solph/test_multi_period_model/test_multi_period_investment_model.py @@ -39,9 +39,9 @@ def test_multi_period_investment_model(solver="cbc"): for multiple SinkDSM approaches""" for approach in ["oemof", "DLR", "DIW"]: - t_idx_1 = pd.date_range("1/1/2020", periods=3, freq="H") - t_idx_2 = pd.date_range("1/1/2030", periods=3, freq="H") - t_idx_3 = pd.date_range("1/1/2040", periods=3, freq="H") + t_idx_1 = pd.date_range("1/1/2020", periods=3, freq="h") + t_idx_2 = pd.date_range("1/1/2030", periods=3, freq="h") + t_idx_3 = pd.date_range("1/1/2040", periods=3, freq="h") # Create an overall timeindex t_idx_1_series = pd.Series(index=t_idx_1, dtype="float64") diff --git a/tests/test_scripts/test_solph/test_piecewiselineartransformer/test_piecewiselineartransformer.py b/tests/test_scripts/test_solph/test_piecewiselineartransformer/test_piecewiselineartransformer.py index 41b7a60b1..64823a6b9 100644 --- a/tests/test_scripts/test_solph/test_piecewiselineartransformer/test_piecewiselineartransformer.py +++ b/tests/test_scripts/test_solph/test_piecewiselineartransformer/test_piecewiselineartransformer.py @@ -26,7 +26,7 @@ def test_pwltf(): # Set timeindex and create data periods = 20 - datetimeindex = pd.date_range("1/1/2019", periods=periods, freq="H") + datetimeindex = pd.date_range("1/1/2019", periods=periods, freq="h") step = 5 demand = np.arange(0, step * periods, step) diff --git a/tests/test_scripts/test_solph/test_simple_model/test_simple_dispatch.py b/tests/test_scripts/test_solph/test_simple_model/test_simple_dispatch.py index d7fc978ec..e8d12b264 100644 --- a/tests/test_scripts/test_solph/test_simple_model/test_simple_dispatch.py +++ b/tests/test_scripts/test_solph/test_simple_model/test_simple_dispatch.py @@ -125,7 +125,7 @@ def test_dispatch_example(solver="cbc", periods=24 * 5): conversion_factors={bel: 1 / 3, b_heat_source: (cop - 1) / cop}, ) - datetimeindex = pd.date_range("1/1/2012", periods=periods, freq="H") + datetimeindex = pd.date_range("1/1/2012", periods=periods, freq="h") energysystem = EnergySystem( timeindex=datetimeindex, infer_last_interval=True ) diff --git a/tests/test_scripts/test_solph/test_simple_model/test_simple_invest.py b/tests/test_scripts/test_solph/test_simple_model/test_simple_invest.py index dcefb11e8..3634406f3 100644 --- a/tests/test_scripts/test_solph/test_simple_model/test_simple_invest.py +++ b/tests/test_scripts/test_solph/test_simple_model/test_simple_invest.py @@ -141,7 +141,7 @@ def test_dispatch_example(solver="cbc", periods=24 * 5): conversion_factors={bel: 1 / 3, b_heat_source: (cop - 1) / cop}, ) - datetimeindex = pd.date_range("1/1/2012", periods=periods, freq="H") + datetimeindex = pd.date_range("1/1/2012", periods=periods, freq="h") energysystem = EnergySystem( timeindex=datetimeindex, infer_last_interval=True ) diff --git a/tests/test_scripts/test_solph/test_storage_investment/test_invest_storage_regression.py b/tests/test_scripts/test_solph/test_storage_investment/test_invest_storage_regression.py index 1faa13677..b33f915e5 100644 --- a/tests/test_scripts/test_solph/test_storage_investment/test_invest_storage_regression.py +++ b/tests/test_scripts/test_solph/test_storage_investment/test_invest_storage_regression.py @@ -23,7 +23,7 @@ def test_regression_investment_storage(solver="cbc"): """ logging.info("Initialize the energy system") - date_time_index = pd.date_range("1/1/2012", periods=4, freq="H") + date_time_index = pd.date_range("1/1/2012", periods=4, freq="h") energysystem = solph.EnergySystem( timeindex=date_time_index, infer_last_interval=True diff --git a/tests/test_scripts/test_solph/test_storage_investment/test_storage_investment.py b/tests/test_scripts/test_solph/test_storage_investment/test_storage_investment.py index 3d89bde91..e67bec253 100644 --- a/tests/test_scripts/test_solph/test_storage_investment/test_storage_investment.py +++ b/tests/test_scripts/test_solph/test_storage_investment/test_storage_investment.py @@ -54,7 +54,7 @@ def test_optimise_storage_size( global PP_GAS logging.info("Initialize the energy system") - date_time_index = pd.date_range("1/1/2012", periods=400, freq="H") + date_time_index = pd.date_range("1/1/2012", periods=400, freq="h") es = solph.EnergySystem( timeindex=date_time_index, diff --git a/tests/test_scripts/test_solph/test_storage_investment/test_storage_with_tuple_label.py b/tests/test_scripts/test_solph/test_storage_investment/test_storage_with_tuple_label.py index 998373fac..2b9654fd1 100644 --- a/tests/test_scripts/test_solph/test_storage_investment/test_storage_with_tuple_label.py +++ b/tests/test_scripts/test_solph/test_storage_investment/test_storage_with_tuple_label.py @@ -63,7 +63,7 @@ def test_tuples_as_labels_example( filename="storage_investment.csv", solver="cbc" ): logging.info("Initialize the energy system") - date_time_index = pd.date_range("1/1/2012", periods=40, freq="H") + date_time_index = pd.date_range("1/1/2012", periods=40, freq="h") energysystem = solph.EnergySystem( timeindex=date_time_index, diff --git a/tests/test_scripts/test_solph/test_variable_chp/test_variable_chp.py b/tests/test_scripts/test_solph/test_variable_chp/test_variable_chp.py index 9753e3684..eec3f7267 100644 --- a/tests/test_scripts/test_solph/test_variable_chp/test_variable_chp.py +++ b/tests/test_scripts/test_solph/test_variable_chp/test_variable_chp.py @@ -26,7 +26,7 @@ def test_variable_chp(filename="variable_chp.csv", solver="cbc"): logging.info("Initialize the energy system") # create time index for 192 hours in May. - date_time_index = pd.date_range("5/5/2012", periods=5, freq="H") + date_time_index = pd.date_range("5/5/2012", periods=5, freq="h") energysystem = solph.EnergySystem( timeindex=date_time_index, infer_last_interval=True ) diff --git a/tests/test_time_index.py b/tests/test_time_index.py index f5a7aaf03..08d2b56cb 100644 --- a/tests/test_time_index.py +++ b/tests/test_time_index.py @@ -16,28 +16,28 @@ def test_energysystem_with_datetimeindex_infer_last_interval(): """Test EnergySystem with DatetimeIndex (equidistant)""" - datetimeindex = pd.date_range("1/1/2012", periods=24, freq="H") + datetimeindex = pd.date_range("1/1/2012", periods=24, freq="h") es = solph.EnergySystem(timeindex=datetimeindex, infer_last_interval=True) assert es.timeincrement[1] == 1.0 assert es.timeincrement.sum() == 24 def test_energysystem_with_datetimeindex(): - datetimeindex = pd.date_range("1/1/2012", periods=24, freq="H") + datetimeindex = pd.date_range("1/1/2012", periods=24, freq="h") es = solph.EnergySystem(timeindex=datetimeindex, infer_last_interval=False) assert es.timeincrement[1] == 1.0 assert es.timeincrement.sum() == 23 def test_energysystem_interval_inference_warning(): - datetimeindex = pd.date_range("1/1/2012", periods=24, freq="H") + datetimeindex = pd.date_range("1/1/2012", periods=24, freq="h") with pytest.warns(FutureWarning): _ = solph.EnergySystem(timeindex=datetimeindex) def test_energysystem_with_datetimeindex_non_equidistant_infer_last_interval(): """Test EnergySystem with DatetimeIndex (non-equidistant)""" - dtindex1 = pd.date_range("1/1/2012", periods=24, freq="H") + dtindex1 = pd.date_range("1/1/2012", periods=24, freq="h") dtindex2 = pd.date_range("1/2/2012", periods=49, freq="30min") dtindex = dtindex1.union(dtindex2) msg = ( @@ -50,7 +50,7 @@ def test_energysystem_with_datetimeindex_non_equidistant_infer_last_interval(): def test_energysystem_with_datetimeindex_non_equidistant(): """Test EnergySystem with DatetimeIndex (non-equidistant)""" - dtindex1 = pd.date_range("1/1/2012", periods=24, freq="H") + dtindex1 = pd.date_range("1/1/2012", periods=24, freq="h") dtindex2 = pd.date_range("1/2/2012", periods=49, freq="30min") dtindex = dtindex1.union(dtindex2) es = solph.EnergySystem(timeindex=dtindex, infer_last_interval=False) @@ -107,7 +107,7 @@ def test_energysystem_with_numeric_index_non_equidistant(): def test_model_timeincrement_with_valid_timeindex(): - datetimeindex = pd.date_range("1/1/2012", periods=5, freq="H") + datetimeindex = pd.date_range("1/1/2012", periods=5, freq="h") es = solph.EnergySystem(timeindex=datetimeindex, infer_last_interval=True) m = solph._models.BaseModel(es) assert es.timeincrement.sum() == 5 @@ -129,7 +129,7 @@ def test_conflicting_time_index(): ) with pytest.raises(AttributeError, match=msg): solph.EnergySystem( - timeindex=pd.date_range("1/1/2012", periods=2, freq="H"), + timeindex=pd.date_range("1/1/2012", periods=2, freq="h"), timeincrement=[1, 2, 3, 4], infer_last_interval=False, ) @@ -147,7 +147,7 @@ def test_missing_timeincrement(): def test_overwrite_timeincrement(): es = solph.EnergySystem( - timeindex=pd.date_range("1/1/2012", periods=2, freq="H"), + timeindex=pd.date_range("1/1/2012", periods=2, freq="h"), infer_last_interval=True, ) assert es.timeincrement[0] == 1 @@ -163,8 +163,8 @@ def test_model_timeincrement_list(): def test_nonequ_inconsistent_timeindex(): # with pytest.raises(IndexError): - timeindex_one = pd.date_range("1/1/2019", periods=1, freq="H") - timeindex_hourly = pd.date_range("1/1/2019", periods=3, freq="H") + timeindex_one = pd.date_range("1/1/2019", periods=1, freq="h") + timeindex_hourly = pd.date_range("1/1/2019", periods=3, freq="h") timeindex_45mins = pd.date_range("1/1/2019", periods=2, freq="45min") timeindex1 = timeindex_one.append(timeindex_hourly) timeindex2 = timeindex_hourly.append([timeindex_45mins]) diff --git a/tests/test_warnings.py b/tests/test_warnings.py index 446739277..7619aaf79 100644 --- a/tests/test_warnings.py +++ b/tests/test_warnings.py @@ -173,7 +173,7 @@ def test_link_raise_key_error_in_Linkblock(warning_fixture): """Link raises KeyError if conversion factors don't match the connected busses.""" - date_time_index = pd.date_range("1/1/2012", periods=3, freq="H") + date_time_index = pd.date_range("1/1/2012", periods=3, freq="h") energysystem = solph.EnergySystem( timeindex=date_time_index, infer_last_interval=True, diff --git a/tox.ini b/tox.ini index eb75a35a0..bbbaac9c0 100644 --- a/tox.ini +++ b/tox.ini @@ -113,6 +113,7 @@ deps = {[testenv]deps} pytest-cov + [testenv:py39] basepython = {env:TOXPYTHON:python3.9} setenv = @@ -124,5 +125,16 @@ deps = {[testenv]deps} pytest-cov +[testenv:py38] +basepython = {env:TOXPYTHON:python3.8} +setenv = + {[testenv]setenv} +usedevelop = true +commands = + {posargs:pytest --cov --cov-report=term-missing -vv} +deps = + {[testenv]deps} + pytest-cov + [testenv:py3-nocov] basepython = {env:TOXPYTHON:python3}