Skip to content
Merged
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
15 changes: 8 additions & 7 deletions examples/attribute_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from echo.configuration import Units
from echo.models.agnostic import FlexPort, Sink, TellegenNode
from echo.models.base import Node, OptimisationGraph
from echo.models.scenario import (ScenarioSettings,
engine_settings_from_environment)
from echo.models.scenario import ScenarioSettings, engine_settings_from_environment
from echo.models.thermal import ThermalStorage
from echo.objectives.base import ObjectiveSet
from echo.objectives.power import PeakPositivePower
Expand All @@ -33,7 +32,7 @@
NUM_EXPANSION_PERIODS = 1


def default_surface_area_of_cylinder(volume: float, include_bottom: bool = True):
def default_surface_area_of_cylinder(volume: float, include_bottom: bool = True) -> float:
"""Given volume of the cylinder in cubic meters, calculate surface area. Assuming height to diameter ration H/D=3.

If include_bottom is False, do not include bottom surface.
Expand Down Expand Up @@ -150,7 +149,7 @@ def default_surface_area_of_cylinder(volume: float, include_bottom: bool = True)
print(tracker)


def to_html_string(attrs: dict[str, list[Any]]):
def to_html_string(attrs: dict[str, list[Any]]) -> str:
attr_text = ""
for attr_class in sorted(attrs.keys()):
attr_text += "<br>"
Expand All @@ -160,7 +159,7 @@ def to_html_string(attrs: dict[str, list[Any]]):
return attr_text


def node_hover_text(node: Any, *_) -> str:
def node_hover_text(node: Node, *_: object) -> str:
node_object = optimise_results.graph.node_obj[node]
node_type = type(node_object).__name__

Expand All @@ -173,7 +172,7 @@ def node_hover_text(node: Any, *_) -> str:
return ""


def edge_hover_text(edge: Any, *_) -> str:
def edge_hover_text(edge: Node, *_: object) -> str:
edge_reversed = edge[::-1] # reverse the edge tuple (not sure why edges are defined in the opposite sense)
edge_object = optimise_results.graph.edge_obj[edge_reversed]

Expand All @@ -185,9 +184,11 @@ def edge_hover_text(edge: Any, *_) -> str:
return title + to_html_string(attrs)
return ""

def node_size(*_) -> int:

def node_size(*_: object) -> int:
return 40


# Use the new visualization function to plot the network/graph
# This function takes callbacks for setting the node (colors, text/labels, hover text etc).
fig = viz.PlotlyGraph.plot(
Expand Down
3 changes: 1 addition & 2 deletions examples/behind_the_meter_with_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
from echo.configuration import Units
from echo.models.agnostic import FlexPort, TellegenNode
from echo.models.base import Node, OptimisationGraph
from echo.models.electrical import (ElectricalDemand, ElectricalGeneration,
ElectricalStorage, Inverter)
from echo.models.electrical import ElectricalDemand, ElectricalGeneration, ElectricalStorage, Inverter
from echo.models.scenario import EngineSettings, ScenarioSettings
from echo.objectives.base import ObjectiveSet
from echo.objectives.power import PeakNegativePower
Expand Down
6 changes: 2 additions & 4 deletions examples/demand_tariff.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
from echo.models.agnostic import FlexPort, TellegenNode
from echo.models.base import OptimisationGraph
from echo.models.prebuilt import Battery, FlexNode, Load
from echo.models.scenario import (ScenarioSettings,
engine_settings_from_environment)
from echo.models.scenario import ScenarioSettings, engine_settings_from_environment
from echo.objectives.base import ObjectiveSet
from echo.objectives.tariff import (DemandTariffObjective, ImportDemandCharge,
ThroughputCost)
from echo.objectives.tariff import DemandTariffObjective, ImportDemandCharge, ThroughputCost
from echo.optimiser import optimise

SOLVER = os.environ.get("OPTIMISER_ENGINE", "cplex")
Expand Down
15 changes: 10 additions & 5 deletions examples/demand_tariff_with_time_periods.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
from echo.models.agnostic import FlexPort, TellegenNode
from echo.models.base import Node, OptimisationGraph
from echo.models.electrical import ElectricalDemand, ElectricalStorage
from echo.models.scenario import (ScenarioSettings,
engine_settings_from_environment)
from echo.models.scenario import ScenarioSettings, engine_settings_from_environment
from echo.objectives.base import ObjectiveSet
from echo.objectives.tariff import (Day, DemandTariffObjective,
ImportDemandCharge, ResetPeriod,
ThroughputCost, TimePeriod, Window)
from echo.objectives.tariff import (
Day,
DemandTariffObjective,
ImportDemandCharge,
ResetPeriod,
ThroughputCost,
TimePeriod,
Window,
)
from echo.optimiser import optimise

expansion_periods = 1
Expand Down
3 changes: 1 addition & 2 deletions examples/electric_vehicles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
from echo.models.base import OptimisationGraph
from echo.models.electrical import EVV0G, EVV1G, EVV2G, EVWithProfile
from echo.models.prebuilt import FlexElectricalNode
from echo.models.scenario import (ScenarioSettings,
engine_settings_from_environment)
from echo.models.scenario import ScenarioSettings, engine_settings_from_environment
from echo.objectives.base import ObjectiveSet
from echo.objectives.tariff import ImportTariff, ThroughputCost
from echo.optimiser import optimise
Expand Down
5 changes: 3 additions & 2 deletions examples/jupyter_examples/electric_vehicles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,9 @@
"plt.xlim([0, 47])\n",
"plt.show()\n",
"\n",
"# Plot ev_with_profile input demand, output demand (which should be the same as input demand) and import tariff. There is no state\n",
"# of charge value for ev_with_profile\n",
"# Plot ev_with_profile input demand, output demand (which should\n",
"# be the same as input demand) and import tariff.\n",
"# There is no state of charge value for ev_with_profile\n",
"plt.plot(ev_with_profile_demand)\n",
"plt.plot(optimise_results.node_values(ev_with_profile, 0)[\"cp\"])\n",
"plt.plot(import_tariff)\n",
Expand Down
6 changes: 2 additions & 4 deletions examples/neighbourhood_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from echo.configuration import Units
from echo.models.agnostic import FlexPort, TellegenNode
from echo.models.base import Node, OptimisationGraph
from echo.models.electrical import (ElectricalDemand, ElectricalGeneration,
ElectricalStorage)
from echo.models.scenario import (ScenarioSettings,
engine_settings_from_environment)
from echo.models.electrical import ElectricalDemand, ElectricalGeneration, ElectricalStorage
from echo.models.scenario import ScenarioSettings, engine_settings_from_environment
from echo.objectives.base import ObjectiveSet
from echo.objectives.tariff import PathTariff, ThroughputCost
from echo.optimiser import optimise
Expand Down
3 changes: 1 addition & 2 deletions examples/neighbourhood_battery_with_aggregate_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from echo.models.agnostic import FlexPort, TellegenNode
from echo.models.base import Node, OptimisationGraph
from echo.models.electrical import ElectricalStorage, FixedElectricalPort
from echo.models.scenario import (ScenarioSettings,
engine_settings_from_environment)
from echo.models.scenario import ScenarioSettings, engine_settings_from_environment
from echo.objectives.base import ObjectiveSet
from echo.objectives.tariff import PathTariff, ThroughputCost
from echo.optimiser import optimise
Expand Down
3 changes: 1 addition & 2 deletions examples/serialisable_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from echo.models.agnostic import FlexPort, TellegenNode
from echo.models.base import Node, OptimisationGraph
from echo.models.electrical import ElectricalStorage, FixedElectricalPort
from echo.models.scenario import (ScenarioSettings,
engine_settings_from_environment)
from echo.models.scenario import ScenarioSettings, engine_settings_from_environment
from echo.objectives.base import ObjectiveSet
from echo.objectives.tariff import ThroughputCost
from echo.optimiser import optimise
Expand Down
3 changes: 1 addition & 2 deletions examples/simple_behind_the_meter_network.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from echo.configuration import Units
from echo.models.agnostic import FlexPort, TellegenNode
from echo.models.base import Node, OptimisationGraph
from echo.models.electrical import (ElectricalDemand, ElectricalGeneration,
ElectricalStorage, Inverter)
from echo.models.electrical import ElectricalDemand, ElectricalGeneration, ElectricalStorage, Inverter

""" A behind-the-meter battery network

Expand Down
3 changes: 1 addition & 2 deletions examples/simple_thermal_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from echo.configuration import Units
from echo.models.agnostic import FlexPort, Sink, TellegenNode
from echo.models.base import Node, OptimisationGraph
from echo.models.scenario import (ScenarioSettings,
engine_settings_from_environment)
from echo.models.scenario import ScenarioSettings, engine_settings_from_environment
from echo.models.thermal import ThermalStorage
from echo.objectives.base import ObjectiveSet
from echo.objectives.power import PeakPositivePower
Expand Down
6 changes: 2 additions & 4 deletions examples/stand_alone_power_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
from echo.configuration import Units
from echo.models.agnostic import FlexPort, TellegenNode
from echo.models.base import Node, OptimisationGraph
from echo.models.electrical import (ElectricalDemand, ElectricalGeneration,
ElectricalStorage, Inverter)
from echo.models.electrical import ElectricalDemand, ElectricalGeneration, ElectricalStorage, Inverter
from echo.models.prebuilt import DieselGenerator
from echo.models.scenario import (ScenarioSettings,
engine_settings_from_environment)
from echo.models.scenario import ScenarioSettings, engine_settings_from_environment
from echo.objectives.base import ObjectiveSet
from echo.objectives.tariff import ImportTariff
from echo.optimiser import optimise
Expand Down
3 changes: 1 addition & 2 deletions examples/using_dataframes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from echo.models.agnostic import FlexPort, TellegenNode
from echo.models.base import Node, OptimisationGraph
from echo.models.electrical import ElectricalGeneration, FixedElectricalPort
from echo.models.scenario import (ScenarioSettings,
engine_settings_from_environment)
from echo.models.scenario import ScenarioSettings, engine_settings_from_environment
from echo.optimiser import optimise

time_periods = 48
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ exclude_dirs = ["tests"]

[tool.ruff]
line-length = 120
extend-exclude = ["examples"]

[tool.ruff.lint]
select = ["E", "W", "F", "I", "S", "C90", "B", "UP", "ANN", "N"]
Expand All @@ -93,7 +92,7 @@ select = ["E", "W", "F", "I", "S", "C90", "B", "UP", "ANN", "N"]
max-complexity = 15

[tool.ruff.lint.pep8-naming]
# Allow pydantic's @validator and @root_validator decorators to trigger class method treatment.
# Allow pydantic's @validator and @root_validator decorators to trigger class method treatment.
classmethod-decorators = [
"classmethod",
"pydantic.validator",
Expand Down
Loading