mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Ensemble: Distribution: Add default values for each distribution.
This commit is contained in:
1 parent
86d93fd702
commit
2818644b7f
2 files changed
+12
No files matched your search
@@ -45,6 +45,7 @@ class Distribution(SQLSubModel):
|
|||||||
self._type = "generic"
|
self._type = "generic"
|
||||||
self._script = script
|
self._script = script
|
||||||
self._labels = []
|
self._labels = []
|
||||||
|
self._default_values = []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@@ -54,6 +55,10 @@ class Distribution(SQLSubModel):
|
|||||||
def labels(self):
|
def labels(self):
|
||||||
return self._labels
|
return self._labels
|
||||||
|
|
||||||
|
@property
|
||||||
|
def default_values(self):
|
||||||
|
return self._default_values
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_create(cls, execute, ext=""):
|
def _db_create(cls, execute, ext=""):
|
||||||
execute(f"""
|
execute(f"""
|
||||||
@@ -160,6 +165,7 @@ class Uniform(Distribution):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._labels = ["low", "high"]
|
self._labels = ["low", "high"]
|
||||||
|
self._default_values = [20.0, 40.0]
|
||||||
|
|
||||||
def random(self, params, nb):
|
def random(self, params, nb):
|
||||||
lst = params.copy()
|
lst = params.copy()
|
||||||
@@ -180,6 +186,7 @@ class Normal(Distribution):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._labels = ["loc", "scale"]
|
self._labels = ["loc", "scale"]
|
||||||
|
self._default_values = [30.0, 5.0]
|
||||||
|
|
||||||
def random(self, params, nb):
|
def random(self, params, nb):
|
||||||
lst = params.copy()
|
lst = params.copy()
|
||||||
@@ -200,6 +207,7 @@ class Poisson(Distribution):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._labels = ["lam"]
|
self._labels = ["lam"]
|
||||||
|
self._default_values = [5.0]
|
||||||
|
|
||||||
def random(self, params, nb):
|
def random(self, params, nb):
|
||||||
lst = params.copy()
|
lst = params.copy()
|
||||||
@@ -221,6 +229,7 @@ class Custom(Distribution):
|
|||||||
|
|
||||||
self._labels = ["custom"]
|
self._labels = ["custom"]
|
||||||
self._type = "custom"
|
self._type = "custom"
|
||||||
|
self._default_values = ""
|
||||||
|
|
||||||
def random(self, params, nb):
|
def random(self, params, nb):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -84,13 +84,16 @@ class SetDistributionCommand(QUndoCommand):
|
|||||||
self._ensembles = ensembles
|
self._ensembles = ensembles
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._ensembles.get(self._index).distribution
|
self._old = self._ensembles.get(self._index).distribution
|
||||||
|
self._old_params = self._ensembles.get(self._index).params
|
||||||
self._new = distribution
|
self._new = distribution
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._ensembles.get(self._index).distribution = self._old
|
self._ensembles.get(self._index).distribution = self._old
|
||||||
|
self._ensembles.get(self._index).params = self._old_params
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
self._ensembles.get(self._index).distribution = self._new
|
self._ensembles.get(self._index).distribution = self._new
|
||||||
|
self._ensembles.get(self._index).params = self._new.default_values
|
||||||
|
|
||||||
|
|
||||||
class AddCommand(QUndoCommand):
|
class AddCommand(QUndoCommand):
|
||||||
|
|||||||
Reference in new issue
Block a user