mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Ensemble: Fix some view/model interations.
This commit is contained in:
1 parent
b203e8e062
commit
8b36905842
5 files changed
+59
-22
No files matched your search
@@ -22,6 +22,7 @@ import itertools
|
||||
|
||||
from Model.Tools.PamhyrDB import SQLSubModel
|
||||
from Model.Scenario import Scenario
|
||||
from Model.Ensembles.Function import Uniform
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
@@ -30,7 +31,8 @@ class Ensemble(SQLSubModel):
|
||||
_sub_classes = []
|
||||
|
||||
def __init__(self, id: int = -1, name: str = "",
|
||||
function=None, range=[], target_data=None,
|
||||
function=None, range=[],
|
||||
data_type=None, target_data=None,
|
||||
status=None, owner_scenario=-1):
|
||||
super(Ensemble, self).__init__(
|
||||
id=id, status=status,
|
||||
@@ -38,7 +40,7 @@ class Ensemble(SQLSubModel):
|
||||
)
|
||||
|
||||
self._name = name
|
||||
self._data_type = "generic"
|
||||
self._data_type = data_type
|
||||
self._function = function
|
||||
self._range = range
|
||||
self._target_data = target_data
|
||||
@@ -132,6 +134,7 @@ class Ensemble(SQLSubModel):
|
||||
id, name=name,
|
||||
function=function,
|
||||
range=rdata,
|
||||
data_type=data_type,
|
||||
target_data=target_data,
|
||||
status=data["status"],
|
||||
owner_scenario=owner_scenario
|
||||
@@ -158,9 +161,12 @@ class Ensemble(SQLSubModel):
|
||||
|
||||
if self._function is None:
|
||||
fid = -1
|
||||
fname = "NULL"
|
||||
else:
|
||||
fid = self._function._pamhyr_id
|
||||
if self._function._data_type == "generic":
|
||||
fname = self._function._name
|
||||
|
||||
if self._function._type == "generic":
|
||||
fid = -1
|
||||
|
||||
data_pid = -1
|
||||
@@ -175,7 +181,7 @@ class Ensemble(SQLSubModel):
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
self.pamhyr_id, self.is_deleted(),
|
||||
self._name, self._data_type,
|
||||
fid, self._function._name, brange, length,
|
||||
fid, fname, brange, length,
|
||||
data_pid, self._status.scenario_id
|
||||
)
|
||||
|
||||
|
||||
@@ -45,6 +45,10 @@ class Function(SQLSubModel):
|
||||
self._type = "generic"
|
||||
self._script = script
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name
|
||||
|
||||
@classmethod
|
||||
def _db_create(cls, execute, ext=""):
|
||||
execute(f"""
|
||||
|
||||
Reference in new issue
Block a user