Skip to content

Commit 2725215

Browse files
committed
Reformat all files with black
1 parent a7daa42 commit 2725215

10 files changed

Lines changed: 98 additions & 70 deletions

File tree

app/dashboard/helpers.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,21 +172,25 @@ def fetch_user_projects(user):
172172

173173
def kpi_scalars_list(kpi_scalar_values_dict, KPI_SCALAR_UNITS, KPI_SCALAR_TOOLTIPS):
174174
return [
175-
{
176-
"kpi": key.replace("_", " "),
177-
"value": round(val, 3)
178-
if "currency/kWh" in KPI_SCALAR_UNITS[key]
179-
else round(val, 2),
180-
"unit": KPI_SCALAR_UNITS[key],
181-
"tooltip": KPI_SCALAR_TOOLTIPS[key],
182-
}
183-
if key in KPI_SCALAR_UNITS.keys()
184-
else {
185-
"kpi": key.replace("_", " "),
186-
"value": round(val, 3),
187-
"unit": "N/A",
188-
"tooltip": "",
189-
}
175+
(
176+
{
177+
"kpi": key.replace("_", " "),
178+
"value": (
179+
round(val, 3)
180+
if "currency/kWh" in KPI_SCALAR_UNITS[key]
181+
else round(val, 2)
182+
),
183+
"unit": KPI_SCALAR_UNITS[key],
184+
"tooltip": KPI_SCALAR_TOOLTIPS[key],
185+
}
186+
if key in KPI_SCALAR_UNITS.keys()
187+
else {
188+
"kpi": key.replace("_", " "),
189+
"value": round(val, 3),
190+
"unit": "N/A",
191+
"tooltip": "",
192+
}
193+
)
190194
for key, val in kpi_scalar_values_dict.items()
191195
]
192196

app/dashboard/models.py

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -691,9 +691,9 @@ def available_timeseries(self):
691691
MAP_EPA_MVS.get(sub_cat, sub_cat)
692692
)
693693
if storage_subasset is not None:
694-
storage_subasset[
695-
"category"
696-
] = format_storage_subasset_name(category, sub_cat)
694+
storage_subasset["category"] = (
695+
format_storage_subasset_name(category, sub_cat)
696+
)
697697
storage_subasset["type_oemof"] = asset["type_oemof"]
698698
storage_subasset["energy_vector"] = asset[
699699
"energy_vector"
@@ -755,10 +755,10 @@ def single_asset_results(self, asset_name, asset_category=None):
755755
if storage_subasset is not None:
756756
if answer is None:
757757
answer = storage_subasset
758-
answer[
759-
"category"
760-
] = format_storage_subasset_name(
761-
category, sub_cat
758+
answer["category"] = (
759+
format_storage_subasset_name(
760+
category, sub_cat
761+
)
762762
)
763763
answer["energy_vector"] = asset["energy_vector"]
764764
break
@@ -1045,15 +1045,19 @@ def graph_capacities(simulations, y_variables):
10451045

10461046
installed_capacity_dict = {
10471047
"capacity": [],
1048-
"name": _("Installed Capacity")
1049-
if multi_scenario is False
1050-
else _("Inst. Cap.") + f"{simulation.scenario.name}",
1048+
"name": (
1049+
_("Installed Capacity")
1050+
if multi_scenario is False
1051+
else _("Inst. Cap.") + f"{simulation.scenario.name}"
1052+
),
10511053
}
10521054
optimized_capacity_dict = {
10531055
"capacity": [],
1054-
"name": _("Optimized Capacity")
1055-
if multi_scenario is False
1056-
else _("Opt. Cap.") + f"{simulation.scenario.name}",
1056+
"name": (
1057+
_("Optimized Capacity")
1058+
if multi_scenario is False
1059+
else _("Opt. Cap.") + f"{simulation.scenario.name}"
1060+
),
10571061
}
10581062

10591063
# read information about the installed capacity
@@ -1304,16 +1308,20 @@ def graph_costs(
13041308
y = df.iloc[:, i].values.tolist()
13051309
y_values.append(
13061310
{
1307-
"base": df.iloc[:, :i].sum(axis=1).values.tolist()
1308-
if i > 0
1309-
else None,
1311+
"base": (
1312+
df.iloc[:, :i].sum(axis=1).values.tolist()
1313+
if i > 0
1314+
else None
1315+
),
13101316
"value": y,
13111317
"text": [name for j in range(len(x_values))],
1312-
"name": name
1313-
if multi_scenario is False
1314-
else name + f" {simulation.scenario.name}",
1318+
"name": (
1319+
name
1320+
if multi_scenario is False
1321+
else name + f" {simulation.scenario.name}"
1322+
),
13151323
"hover": "<b>%{text}, </b><br><br>Block value: %{customdata:.2f}$<br>Stacked value: %{y:.2f}$<extra> %{x}</extra>",
1316-
"customdata": y
1324+
"customdata": y,
13171325
# https://stackoverflow.com/questions/59057881/python-plotly-how-to-customize-hover-template-on-with-what-information-to-show
13181326
}
13191327
)
@@ -1326,14 +1334,18 @@ def graph_costs(
13261334
y = df.iloc[i, :].values.tolist()
13271335
y_values.append(
13281336
{
1329-
"base": df.iloc[:i, :].sum(axis=0).values.tolist()
1330-
if i > 0
1331-
else None,
1337+
"base": (
1338+
df.iloc[:i, :].sum(axis=0).values.tolist()
1339+
if i > 0
1340+
else None
1341+
),
13321342
"value": y,
13331343
"text": [name for j in range(len(x_values))],
1334-
"name": name
1335-
if multi_scenario is False
1336-
else name + f" {simulation.scenario.name}",
1344+
"name": (
1345+
name
1346+
if multi_scenario is False
1347+
else name + f" {simulation.scenario.name}"
1348+
),
13371349
"hover": "<b>%{text}</b><br><br>Block value: %{customdata:.2f}$<br>Stacked value: %{y:.2f}$",
13381350
"customdata": y,
13391351
}
@@ -1495,6 +1507,7 @@ def graph_sankey(simulation, energy_vector, timestep=None):
14951507
GRAPH_SANKEY: graph_sankey,
14961508
}
14971509

1510+
14981511
# # TODO change the form from this model to adapt the choices depending on single scenario/compare scenario or sensitivity
14991512
class ReportItem(models.Model):
15001513
title = models.CharField(max_length=120, default="", blank=True)

app/epa/settings.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
For the full list of settings and their values, see
1010
https://docs.djangoproject.com/en/3.0/ref/settings/
1111
"""
12+
1213
import ast
1314
import os
1415

@@ -110,19 +111,23 @@
110111
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
111112
# SQLite is used if no other database system is set via environment variables.
112113
DATABASES = {
113-
"default": {
114-
"ENGINE": os.environ.get("SQL_ENGINE"),
115-
"NAME": os.environ.get("SQL_DATABASE"),
116-
"USER": os.environ.get("SQL_USER"),
117-
"PASSWORD": os.environ.get("SQL_PASSWORD"),
118-
"HOST": os.environ.get("SQL_HOST"),
119-
"PORT": os.environ.get("SQL_PORT"),
120-
}
121-
if os.environ.get("SQL_ENGINE")
122-
else {
123-
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
124-
"NAME": os.environ.get("SQL_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")),
125-
}
114+
"default": (
115+
{
116+
"ENGINE": os.environ.get("SQL_ENGINE"),
117+
"NAME": os.environ.get("SQL_DATABASE"),
118+
"USER": os.environ.get("SQL_USER"),
119+
"PASSWORD": os.environ.get("SQL_PASSWORD"),
120+
"HOST": os.environ.get("SQL_HOST"),
121+
"PORT": os.environ.get("SQL_PORT"),
122+
}
123+
if os.environ.get("SQL_ENGINE")
124+
else {
125+
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
126+
"NAME": os.environ.get(
127+
"SQL_DATABASE", os.path.join(BASE_DIR, "db.sqlite3")
128+
),
129+
}
130+
)
126131
}
127132

128133
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

app/epa/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
1. Import the include() function: from django.urls import include, path
1414
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
16+
1617
from django.contrib import admin
1718
from django.conf.urls.i18n import i18n_patterns
1819
from django.urls import path, re_path, include

app/projects/forms.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,9 @@ def __init__(self, *args, **kwargs):
709709
"Electrical efficiency with no heat extraction"
710710
)
711711

712-
self.fields[
713-
"efficiency"
714-
].help_text = "This is the custom help text for chp efficiency"
712+
self.fields["efficiency"].help_text = (
713+
"This is the custom help text for chp efficiency"
714+
)
715715

716716
self.fields["efficiency_multiple"] = DualNumberField(
717717
default=1, min=0, max=1, param_name="efficiency_multiple"
@@ -727,9 +727,9 @@ def __init__(self, *args, **kwargs):
727727
self.fields["efficiency"].label = _("Efficiency gaz to electricity")
728728

729729
# TODO
730-
self.fields[
731-
"efficiency"
732-
].help_text = "This is the custom help text for chp efficiency"
730+
self.fields["efficiency"].help_text = (
731+
"This is the custom help text for chp efficiency"
732+
)
733733

734734
self.fields["efficiency_multiple"].widget = forms.NumberInput(
735735
attrs={

app/projects/scenario_topology_helpers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ def db_bus_nodes_to_list(scen_id):
388388
"name": db_bus.name,
389389
"bustype": db_bus.type,
390390
"databaseId": db_bus.id,
391-
"parent_asset_id": db_bus.parent_asset_id
392-
if db_bus.parent_asset_id
393-
else "",
391+
"parent_asset_id": (
392+
db_bus.parent_asset_id if db_bus.parent_asset_id else ""
393+
),
394394
},
395395
}
396396
bus_nodes_list.append(db_bus_dict)
@@ -411,9 +411,9 @@ def db_asset_nodes_to_list(scen_id):
411411
"data": {
412412
"name": db_asset.name,
413413
"unique_id": db_asset.unique_id,
414-
"parent_asset_id": db_asset.parent_asset_id
415-
if db_asset.parent_asset_id
416-
else "",
414+
"parent_asset_id": (
415+
db_asset.parent_asset_id if db_asset.parent_asset_id else ""
416+
),
417417
},
418418
}
419419
asset_nodes_list.append(db_asset_dict)

app/projects/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def create_or_delete_simulation_scheduler(**kwargs):
8282
func="projects.services.check_simulation_objects",
8383
# args='5',
8484
schedule_type=Schedule.MINUTES,
85-
minutes=1
85+
minutes=1,
8686
# kwargs={'test_arg': 1, 'test_arg2': "test"}
8787
)
8888
if schedule.id:

app/projects/views.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ def project_duplicate(request, proj_id):
567567

568568
# endregion Project
569569

570+
570571
# region Usecase
571572
@login_required
572573
@require_http_methods(["GET"])
@@ -1130,9 +1131,11 @@ def scenario_review(request, proj_id, scen_id, step_id=4, max_step=5):
11301131
"secondsElapsed": simulation.elapsed_seconds,
11311132
"rating": simulation.user_rating,
11321133
"mvs_token": simulation.mvs_token,
1133-
"mvs_version": simulation.mvs_version
1134-
if simulation.mvs_version
1135-
else "undefined",
1134+
"mvs_version": (
1135+
simulation.mvs_version
1136+
if simulation.mvs_version
1137+
else "undefined"
1138+
),
11361139
}
11371140
)
11381141
if simulation.status == DONE:

app/translation_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
the procedure is executed below when this file is executed as main
3131
3232
"""
33+
3334
import os
3435

3536
LANG = "de"

app/users/tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def test_user_change_form(self):
7070
"""
7171
Views Tests
7272
"""
73+
7374
# Signup
7475
def test_view_url_exists_at_desired_location(self):
7576
response = self.client.get("/en/users/signup/")

0 commit comments

Comments
 (0)