mirror of https://gitlab.com/pamhyr/pamhyr2
Ensemble: Function: Rename get_sample to random and use np.random.
parent
f5a7cd5984
commit
6e029beafc
|
|
@ -130,7 +130,7 @@ class Ensemble(SQLSubModel):
|
||||||
None
|
None
|
||||||
)
|
)
|
||||||
|
|
||||||
rdata = cls._decode_params(params, params_len)
|
rdata = list(cls._decode_params(params, params_len))
|
||||||
|
|
||||||
new_ensemble = cls(
|
new_ensemble = cls(
|
||||||
id, name=name,
|
id, name=name,
|
||||||
|
|
@ -201,9 +201,9 @@ class Ensemble(SQLSubModel):
|
||||||
|
|
||||||
return struct.unpack(data_format, bparams)
|
return struct.unpack(data_format, bparams)
|
||||||
|
|
||||||
def get_sample(self, nb):
|
def random(self, nb):
|
||||||
return np.nditer(
|
return np.nditer(
|
||||||
self._function.get_sample(
|
self._function.random(
|
||||||
self._params, nb
|
self._params, nb
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ class Function(SQLSubModel):
|
||||||
if predicate(self, data):
|
if predicate(self, data):
|
||||||
modifier(self, data)
|
modifier(self, data)
|
||||||
|
|
||||||
def get_sample(self, r):
|
def random(self, r):
|
||||||
raise NotImplementedMethodeError(cls, cls._load)
|
raise NotImplementedMethodeError(cls, cls._load)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -154,16 +154,11 @@ class Uniform(Function):
|
||||||
name=name, script=script
|
name=name, script=script
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_sample(self, ens_range, nb):
|
def random(self, ens_range, nb):
|
||||||
b = ens_range[0]
|
lst = ens_range.copy()
|
||||||
t = ens_range[1]
|
lst.append(nb)
|
||||||
|
|
||||||
step = (t - b) / nb
|
return np.random.uniform(*lst)
|
||||||
|
|
||||||
r = np.arange(b, t, step)
|
|
||||||
np.random.shuffle(r)
|
|
||||||
|
|
||||||
return r
|
|
||||||
|
|
||||||
|
|
||||||
class Custom(Function):
|
class Custom(Function):
|
||||||
|
|
@ -179,7 +174,7 @@ class Custom(Function):
|
||||||
|
|
||||||
self._type = "custom"
|
self._type = "custom"
|
||||||
|
|
||||||
def get_sample(self, ens_range, nb):
|
def random(self, ens_range, nb):
|
||||||
try:
|
try:
|
||||||
# Run script to (re)define the sample function
|
# Run script to (re)define the sample function
|
||||||
f = eval(self._script)
|
f = eval(self._script)
|
||||||
|
|
|
||||||
|
|
@ -277,9 +277,9 @@ class TableData(SQLSubModel):
|
||||||
|
|
||||||
if len(shape) == 2:
|
if len(shape) == 2:
|
||||||
shape_x, shape_y = shape
|
shape_x, shape_y = shape
|
||||||
elif len(shape == 1):
|
elif len(shape) == 1:
|
||||||
shape_x, = shape
|
shape_x, = shape
|
||||||
elif len(shape == 3):
|
elif len(shape) == 3:
|
||||||
shape_x, shape_y, shape_z = shape
|
shape_x, shape_y, shape_z = shape
|
||||||
else:
|
else:
|
||||||
logger.error(
|
logger.error(
|
||||||
|
|
|
||||||
|
|
@ -474,7 +474,7 @@ class SolverLogEnsWindow(SolverLogWindow):
|
||||||
if ens.function is None:
|
if ens.function is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self._samples[ens] = ens.get_sample(self._run_number)
|
self._samples[ens] = ens.random(self._run_number)
|
||||||
|
|
||||||
self._results = None
|
self._results = None
|
||||||
self._run_samples = []
|
self._run_samples = []
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Min:</string>
|
<string>Low:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Max:</string>
|
<string>High:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue