debug save BoundaryConditionsAdisTS

This commit is contained in:
Dylan Jeannin committed 2026-04-22 12:05:28 +02:00
1 parent b58d3e005d
commit d6f7755d12
6 files changed
+63 -28

No files matched your search

@@ -312,19 +312,21 @@ class BoundaryConditionAdisTS(SQLSubModel):
status = data['status']
nodes = data['nodes']
scenario = data["scenario"]
pollutant = data["pollutant"]
pollutant = data.get("pollutant")
loaded = data['loaded_pid']
if scenario is None:
return new
table = execute(
"SELECT pamhyr_id, deleted, pollutant, type, node, scenario " +
sql = (
"SELECT pamhyr_id, deleted, pollutant, type, node, scenario "
"FROM boundary_condition_adists " +
f"WHERE scenario = {scenario.id} " +
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) " +
f"AND pollutant = {pollutant.id} "
f"WHERE scenario = {scenario.id} "
)
if pollutant is not None:
sql += f"AND pollutant = {pollutant.id} "
table = execute(sql)
if table is not None:
for row in table:
@@ -349,7 +351,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
bc.type = bc_type
bc.node = None
if row[3] != -1:
if node != -1:
tmp = next(
filter(
lambda n: n.id == node, nodes
@@ -513,7 +515,10 @@ class BoundaryConditionAdisTS(SQLSubModel):
return (new_0, new_1)
def add(self, index: int):
value = (self._default_0, self._default_1)
value = Data(
self._default_0, self._default_1,
status=self._status
)
self._data.insert(index, value)
self._status.modified()
return value
@@ -554,9 +559,9 @@ class BoundaryConditionAdisTS(SQLSubModel):
return lst
def _set_i_c_v(self, index, column, value):
v = list(self._data[index])
v = self._data[index]
v[column] = self._types[column](value)
self._data[index] = tuple(v)
self._data[index] = v
self._status.modified()
def set_i_0(self, index: int, value):
@@ -38,9 +38,13 @@ class BoundaryConditionsAdisTSList(PamhyrModelList):
if data is None:
data = {}
new._lst = BoundaryConditionAdisTS._db_load(
execute, data
)
previous_pollutant = data.get("pollutant")
data.pop("pollutant", None)
new._lst = BoundaryConditionAdisTS._db_load(execute, data)
if previous_pollutant is not None:
data["pollutant"] = previous_pollutant
return new