Skip to content

Commit 9bc80fd

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 7afdefd commit 9bc80fd

11 files changed

Lines changed: 30 additions & 22 deletions

File tree

temoa/extensions/discrete_capacity/core/model.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from temoa.core.model import TemoaModel
1111

1212
class DiscreteCapacityModel(TemoaModel):
13-
1413
limit_discrete_new_capacity: Param
1514
limit_discrete_new_capacity_constraint_rtv: Set
1615
limit_discrete_new_capacity_constraint: Constraint
@@ -39,7 +38,6 @@ def register_model_components(model: TemoaModel) -> None:
3938
rule=discrete_capacity.limit_discrete_new_capacity_constraint_rule,
4039
)
4140

42-
4341
m.limit_discrete_capacity = Param(
4442
m.regional_global_indices, m.tech_or_group, within=NonNegativeReals
4543
)

temoa/extensions/get_comm_tech.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ def get_tperiods(inp_f: str) -> dict[str, list[int]]:
3131
for row in cur:
3232
x.append(row[0])
3333
for y in x:
34-
cur.execute(
35-
'SELECT DISTINCT period FROM output_flow_out WHERE scenario = ?', (y,)
36-
)
34+
cur.execute('SELECT DISTINCT period FROM output_flow_out WHERE scenario = ?', (y,))
3735
periods_list[y] = []
3836
for per in cur:
3937
z = per[0]

temoa/extensions/method_of_morris/morris_evaluate.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
This module contains the core "evaluation" function for Method Of Morris. It needs to be isolated
33
(outside of class) to enable parallelization.
44
"""
5+
56
from __future__ import annotations
67

78
import logging
@@ -19,7 +20,6 @@
1920
from temoa.core.config import TemoaConfig
2021

2122

22-
2323
def configure_worker_logger(log_queue: Any, log_level: int) -> logging.Logger:
2424
"""configure the logger"""
2525
worker_logger = logging.getLogger('MM evaluate')
@@ -35,8 +35,15 @@ def configure_worker_logger(log_queue: Any, log_level: int) -> logging.Logger:
3535
return worker_logger
3636

3737

38-
def evaluate(param_info: dict[int, list[Any]], mm_sample: Any, data: dict[str, Any],
39-
i: int, config: TemoaConfig, log_queue: Any, log_level: int) -> list[float]:
38+
def evaluate(
39+
param_info: dict[int, list[Any]],
40+
mm_sample: Any,
41+
data: dict[str, Any],
42+
i: int,
43+
config: TemoaConfig,
44+
log_queue: Any,
45+
log_level: int,
46+
) -> list[float]:
4047
"""
4148
Run model for params provided and return objective value and emission value
4249
Note: This function needs to be a static instance to enable the parallel
@@ -81,6 +88,7 @@ def evaluate(param_info: dict[int, list[Any]], mm_sample: Any, data: dict[str, A
8188
with TableWriter(config) as table_writer:
8289
table_writer.write_mm_results(model=mdl, iteration=i)
8390
import contextlib
91+
8492
with contextlib.closing(sqlite3.connect(config.input_database)) as con:
8593
cur = con.cursor()
8694
scenario_name = config.scenario + f'-{i}'

temoa/extensions/modeling_to_generate_alternatives/manager_factory.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
from temoa.extensions.modeling_to_generate_alternatives.vector_manager import VectorManager
1515

1616

17-
18-
1917
def get_manager(
2018
axis: MgaAxis,
2119
weighting: MgaWeighting,

temoa/extensions/modeling_to_generate_alternatives/tech_activity_vector_manager.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ def initialize(self) -> None:
137137
for idx_annual in self.base_model.active_flow_rpitvo or set():
138138
tech = idx_annual[3]
139139
self.technology_size[tech] += 1
140-
self.variable_index_mapping[tech][self.base_model.v_flow_out_annual.name].append(idx_annual)
140+
self.variable_index_mapping[tech][self.base_model.v_flow_out_annual.name].append(
141+
idx_annual
142+
)
141143
logger.debug('Catalogued %d Technology Variables', sum(self.technology_size.values()))
142144

143145
@property
@@ -364,8 +366,9 @@ def tracker(self) -> None:
364366
A little function to track the size of the hull, after it is built initially
365367
Note: This hull is a "throw away" and only used for volume calc, but it is pretty quick
366368
"""
367-
if self.hull is not None and \
368-
self.hull_points is not None: # don't try until after first hull is built
369+
if (
370+
self.hull is not None and self.hull_points is not None
371+
): # don't try until after first hull is built
369372
hull = Hull(self.hull_points)
370373
volume = hull.volume
371374
logger.info('Tracking hull at %0.2f', volume)

temoa/extensions/modeling_to_generate_alternatives/vector_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
An ABC to serve as a framework for future Vector Managers
33
"""
4+
45
from __future__ import annotations
56

67
from abc import ABC, abstractmethod

temoa/extensions/modeling_to_generate_alternatives/worker.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Class to contain Workers that execute solves in separate processes
33
"""
4+
45
from __future__ import annotations
56

67
import logging.handlers
@@ -52,15 +53,16 @@ def __init__(
5253
self.solver_name = solver_name
5354
self.solver_options = solver_options or {}
5455
self.solver_log_path = solver_log_path
55-
self.opt = None # Initialize in run()
56+
self.opt = None # Initialize in run()
5657

5758
self.log_root_name = log_root_name
5859
self.log_level = log_level
5960
self.solve_count = 0
6061

6162
def run(self) -> None:
62-
logger: logging.Logger = getLogger('.'.join(
63-
(self.log_root_name, 'worker', str(self.worker_number))))
63+
logger: logging.Logger = getLogger(
64+
'.'.join((self.log_root_name, 'worker', str(self.worker_number)))
65+
)
6466
logger.propagate = False # prevent duplicate logs
6567
# add a handler that pushes to the queue
6668
handler = logging.handlers.QueueHandler(self.log_queue)
@@ -133,7 +135,8 @@ def run(self) -> None:
133135
status = solve_res['Solver'].termination_condition
134136
logger.info(
135137
'Worker %d did not solve. Results status: %s',
136-
self.worker_number, status
138+
self.worker_number,
139+
status,
137140
)
138141
except AttributeError:
139142
pass

temoa/extensions/monte_carlo/mc_worker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
new obj functions
1010
1111
"""
12+
1213
from __future__ import annotations
1314

1415
import logging.handlers
@@ -60,7 +61,7 @@ def __init__(
6061
self.results_queue = results_queue
6162
self.solver_name = solver_name
6263
self.solver_options = solver_options
63-
self.opt = None # Initialize in run()
64+
self.opt = None # Initialize in run()
6465
self.log_queue = log_queue
6566
self.log_level = log_level
6667
self.root_logger_name = log_root_name

temoa/extensions/single_vector_mga/output_summary.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
A tabular summation of the results from an SVMGA run
33
"""
4+
45
from __future__ import annotations
56

67
import sqlite3

temoa/extensions/stochastics/stochastic_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class StochasticConfig:
3333
perturbations: list[Perturbation] = field(default_factory=list)
3434
solver_options: dict[str, Any] = field(default_factory=dict)
3535

36-
3736
@classmethod
3837
def from_toml(cls, path: Path) -> Self:
3938
with open(path, 'rb') as f:

0 commit comments

Comments
 (0)