From d49269c6bb9845c449dd55de04f05e4e02ad2f81 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Tue, 29 Jun 2021 11:55:37 -0700 Subject: [PATCH] refactor: update references to postreise.analyze.check --- postreise/analyze/generation/binding.py | 3 ++- postreise/analyze/generation/capacity.py | 5 ++--- postreise/analyze/generation/curtailment.py | 12 ++++++------ postreise/analyze/generation/emissions.py | 9 +++------ postreise/analyze/generation/summarize.py | 13 +++++-------- postreise/analyze/generation/tests/test_binding.py | 3 ++- postreise/analyze/time.py | 6 ++++-- postreise/plot/plot_shadowprice_map.py | 2 +- 8 files changed, 25 insertions(+), 28 deletions(-) diff --git a/postreise/analyze/generation/binding.py b/postreise/analyze/generation/binding.py index 89b8b467..081db045 100644 --- a/postreise/analyze/generation/binding.py +++ b/postreise/analyze/generation/binding.py @@ -1,4 +1,5 @@ -from postreise.analyze.check import _check_epsilon, _check_scenario_is_in_analyze_state +from powersimdata.input.check import _check_epsilon +from powersimdata.scenario.check import _check_scenario_is_in_analyze_state def pmin_constraints(scenario, epsilon=1e-3): diff --git a/postreise/analyze/generation/capacity.py b/postreise/analyze/generation/capacity.py index 6024dfaf..6e7b3a6d 100644 --- a/postreise/analyze/generation/capacity.py +++ b/postreise/analyze/generation/capacity.py @@ -1,14 +1,13 @@ import numpy as np - -from postreise.analyze.check import ( +from powersimdata.input.check import ( _check_number_hours_to_analyze, _check_resources_are_in_grid_and_format, - _check_scenario_is_in_analyze_state, ) from powersimdata.input.helpers import ( get_plant_id_for_resources_in_area, get_storage_id_in_area, ) +from powersimdata.scenario.check import _check_scenario_is_in_analyze_state def calculate_NLDC(scenario, resources, hours=100): # noqa: N802 diff --git a/postreise/analyze/generation/curtailment.py b/postreise/analyze/generation/curtailment.py index d582b844..76eb86b9 100644 --- a/postreise/analyze/generation/curtailment.py +++ b/postreise/analyze/generation/curtailment.py @@ -1,12 +1,7 @@ import pandas as pd - -from postreise.analyze.check import ( +from powersimdata.input.check import ( _check_areas_are_in_grid_and_format, _check_resources_are_renewable_and_format, - _check_scenario_is_in_analyze_state, -) -from postreise.analyze.generation.summarize import ( - get_generation_time_series_by_resources, ) from powersimdata.input.helpers import ( decompose_plant_data_frame_into_areas, @@ -18,6 +13,11 @@ summarize_plant_to_bus, summarize_plant_to_location, ) +from powersimdata.scenario.check import _check_scenario_is_in_analyze_state + +from postreise.analyze.generation.summarize import ( + get_generation_time_series_by_resources, +) def calculate_curtailment_time_series(scenario): diff --git a/postreise/analyze/generation/emissions.py b/postreise/analyze/generation/emissions.py index 604b4f6d..172d80d3 100644 --- a/postreise/analyze/generation/emissions.py +++ b/postreise/analyze/generation/emissions.py @@ -1,12 +1,9 @@ import numpy as np import pandas as pd +from powersimdata.input.check import _check_grid_type, _check_time_series from powersimdata.network.model import ModelImmutables +from powersimdata.scenario.check import _check_scenario_is_in_analyze_state -from postreise.analyze.check import ( - _check_grid, - _check_scenario_is_in_analyze_state, - _check_time_series, -) from postreise.analyze.generation.costs import calculate_costs @@ -88,7 +85,7 @@ def summarize_emissions_by_bus(emissions, grid): if (emissions < -1e-3).any(axis=None): raise ValueError("emissions must be non-negative") - _check_grid(grid) + _check_grid_type(grid) plant = grid.plant # sum by generator diff --git a/postreise/analyze/generation/summarize.py b/postreise/analyze/generation/summarize.py index 272e8556..29bcf9ca 100644 --- a/postreise/analyze/generation/summarize.py +++ b/postreise/analyze/generation/summarize.py @@ -1,17 +1,14 @@ import numpy as np import pandas as pd -from powersimdata.network.model import ModelImmutables -from powersimdata.scenario.scenario import Scenario - -from postreise.analyze.check import ( - _check_data_frame, - _check_resources_and_format, - _check_scenario_is_in_analyze_state, -) +from powersimdata.input.check import _check_data_frame, _check_resources_and_format from powersimdata.input.helpers import ( get_plant_id_for_resources_in_area, get_storage_id_in_area, ) +from powersimdata.network.model import ModelImmutables +from powersimdata.scenario.check import _check_scenario_is_in_analyze_state +from powersimdata.scenario.scenario import Scenario + from postreise.analyze.time import change_time_zone, slice_time_series diff --git a/postreise/analyze/generation/tests/test_binding.py b/postreise/analyze/generation/tests/test_binding.py index 09c60737..50e3c831 100644 --- a/postreise/analyze/generation/tests/test_binding.py +++ b/postreise/analyze/generation/tests/test_binding.py @@ -1,9 +1,10 @@ import unittest import pandas as pd +from powersimdata.input.check import _check_epsilon +from powersimdata.scenario.check import _check_scenario_is_in_analyze_state from powersimdata.tests.mock_scenario import MockScenario -from postreise.analyze.check import _check_epsilon, _check_scenario_is_in_analyze_state from postreise.analyze.generation.binding import ( pmax_constraints, pmin_constraints, diff --git a/postreise/analyze/time.py b/postreise/analyze/time.py index 64b3e3d3..b113bca3 100644 --- a/postreise/analyze/time.py +++ b/postreise/analyze/time.py @@ -2,8 +2,10 @@ import pandas as pd import pytz - -from postreise.analyze.check import _check_date_range_in_time_series, _check_time_series +from powersimdata.input.check import ( + _check_date_range_in_time_series, + _check_time_series, +) def is_24_hour_format(time): diff --git a/postreise/plot/plot_shadowprice_map.py b/postreise/plot/plot_shadowprice_map.py index e892810e..da2504a9 100644 --- a/postreise/plot/plot_shadowprice_map.py +++ b/postreise/plot/plot_shadowprice_map.py @@ -5,9 +5,9 @@ from bokeh.plotting import figure from bokeh.tile_providers import Vendors, get_provider from bokeh.transform import linear_cmap +from powersimdata.input.check import _check_date from powersimdata.scenario.scenario import Scenario -from postreise.analyze.check import _check_date from postreise.plot.colors import shadow_price_pallette from postreise.plot.projection_helpers import project_branch, project_bus