diff --git a/energypylinear/assets/site.py b/energypylinear/assets/site.py index 0c19edf..a578c2f 100644 --- a/energypylinear/assets/site.py +++ b/energypylinear/assets/site.py @@ -27,7 +27,7 @@ def get_custom_interval_data(kwargs: dict | None) -> list | None: Returns: A list of custom interval data, or `None` if no kwargs. """ - if kwargs is None: + if (kwargs is None) or (kwargs == {}): return None custom_interval_data = [] diff --git a/tests/assets/test_battery.py b/tests/assets/test_battery.py index 9ec0683..2274d8c 100644 --- a/tests/assets/test_battery.py +++ b/tests/assets/test_battery.py @@ -48,6 +48,20 @@ def test_price_optimization( dispatch = charge - discharge np.testing.assert_almost_equal(dispatch, expected_dispatch) + # now try the same with a spill asset + # this is just for test coverage really... + asset = epl.Battery( + power_mw=power_mw, + capacity_mwh=capacity_mwh, + efficiency_pct=efficiency, + electricity_prices=np.array(electricity_prices), + freq_mins=freq_mins, + initial_charge_mwh=initial_charge_mwh, + final_charge_mwh=0, + include_spill=True, + ) + simulation = asset.optimize(verbose=False) + @pytest.mark.parametrize( "carbon_intensities, initial_charge_mwh, expected_dispatch", @@ -322,7 +336,6 @@ def test_no_simultaneous_import_export() -> None: ) simulation = asset.optimize() results = simulation.results - check_no_simultaneous(results, "site-import_power_mwh", "site-export_power_mwh") diff --git a/tests/assets/test_renewable_generator.py b/tests/assets/test_renewable_generator.py index 0cbd49e..568a7d9 100644 --- a/tests/assets/test_renewable_generator.py +++ b/tests/assets/test_renewable_generator.py @@ -123,6 +123,7 @@ def test_interval_data() -> None: electric_generation_lower_bound_pct=hypothesis.strategies.floats( min_value=0, max_value=1.0 ), + include_spill=hypothesis.strategies.booleans(), ) def test_hypothesis( idx_length: int, @@ -130,6 +131,7 @@ def test_hypothesis( prices_std: float, prices_offset: float, electric_generation_lower_bound_pct: float, + include_spill: bool, ) -> None: """Test optimization with hypothesis.""" electricity_prices = ( @@ -144,5 +146,6 @@ def test_hypothesis( electricity_prices=electricity_prices, electric_generation_mwh=electric_generation_mwh, electric_generation_lower_bound_pct=electric_generation_lower_bound_pct, + include_spill=include_spill, ) asset.optimize(verbose=False)