Scenario: Add HS to memory clean and minor comment change.

This commit is contained in:
parouby committed 2026-05-21 15:07:18 +02:00
1 parent f9d83ac68c
commit 363b9c7132
2 files changed
+26 -9

No files matched your search

+2 -2
View File
@@ -208,7 +208,7 @@ class Reach(SQLSubModel):
self.modified()
def delete(self, indexes):
"""Delete some elements in profile list
"""Set some elements as deleted in profile list
Args:
indexes: The list of index to delete
@@ -250,7 +250,7 @@ class Reach(SQLSubModel):
self.modified()
def delete_profiles(self, profiles):
"""Delete some elements in profile list
"""Set profiles list as deleted
Args:
profiles: The list of profile to delete
+24 -7
View File
@@ -33,6 +33,12 @@ from Model.Status import StudyStatus
from Model.Except import NotImplementedMethodeError
from Model.River import River
from Model.Geometry.Reach import Reach
from Model.HydraulicStructures.HydraulicStructures import (
HydraulicStructure
)
from Model.HydraulicStructures.Basic.HydraulicStructures import (
BasicHS
)
from Checker.Study import *
@@ -463,18 +469,29 @@ class Study(SQLModel):
@timer
def memory_clean(self, ids):
if len(ids) == 0:
return
reach_class = Reach
hs_classes = [HydraulicStructure, BasicHS]
list_classes = set(PamhyrModelList.__subclasses__())
dict_classes = set(PamhyrModelDict.__subclasses__())
reach_class = Reach
def modifier(obj, data):
t = type(obj)
if t in list_classes:
obj._lst = list(
if t is reach_class:
obj._profiles = list(
filter(
lambda el: el.id not in ids,
obj._lst
obj._profiles
)
)
elif t in hs_classes:
obj._data = list(
filter(
lambda el: el.id not in ids,
obj._data
)
)
elif t in dict_classes:
@@ -483,11 +500,11 @@ class Study(SQLModel):
if obj._dict[key].id not in ids:
new[key] = obj._dict[key]
obj._dict = new
elif t is reach_class:
obj._profiles = list(
elif t in list_classes:
obj._lst = list(
filter(
lambda el: el.id not in ids,
obj._profiles
obj._lst
)
)