Commit cd23003d authored by Theo Steininger's avatar Theo Steininger
Browse files

Pipeline can now fix seed for MagneticFieldFactory

parent 70da1a0f
...@@ -130,7 +130,7 @@ class MagneticFieldFactory(Loggable, object): ...@@ -130,7 +130,7 @@ class MagneticFieldFactory(Loggable, object):
parameter_dict[variable_name] = mapped_variable parameter_dict[variable_name] = mapped_variable
return parameter_dict return parameter_dict
def generate(self, variables={}, ensemble_size=1): def generate(self, variables={}, ensemble_size=1, random_seed=None):
mapped_variables = self._map_variables_to_parameters(variables) mapped_variables = self._map_variables_to_parameters(variables)
work_parameters = self.parameter_defaults.copy() work_parameters = self.parameter_defaults.copy()
work_parameters.update(mapped_variables) work_parameters.update(mapped_variables)
...@@ -142,7 +142,8 @@ class MagneticFieldFactory(Loggable, object): ...@@ -142,7 +142,8 @@ class MagneticFieldFactory(Loggable, object):
result_magnetic_field = self.magnetic_field_class( result_magnetic_field = self.magnetic_field_class(
domain=domain, domain=domain,
parameters=work_parameters, parameters=work_parameters,
distribution_strategy='equal') distribution_strategy='equal',
random_seed=random_seed)
self.logger.debug("Generated magnetic field with work-parameters %s" % self.logger.debug("Generated magnetic field with work-parameters %s" %
work_parameters) work_parameters)
return result_magnetic_field return result_magnetic_field
...@@ -56,6 +56,8 @@ class Pipeline(Loggable, object): ...@@ -56,6 +56,8 @@ class Pipeline(Loggable, object):
self.sample_callback = sample_callback self.sample_callback = sample_callback
self.fixed_random_seed = None
@property @property
def observer(self): def observer(self):
return self._observer return self._observer
...@@ -172,8 +174,9 @@ class Pipeline(Loggable, object): ...@@ -172,8 +174,9 @@ class Pipeline(Loggable, object):
# create magnetic field # create magnetic field
self.logger.debug("Creating magnetic field.") self.logger.debug("Creating magnetic field.")
b_field = self.magnetic_field_factory.generate( b_field = self.magnetic_field_factory.generate(
variables=variables, variables=variables,
ensemble_size=self.ensemble_size) ensemble_size=self.ensemble_size,
random_seed=self.fixed_random_seed)
# create observables # create observables
self.logger.debug("Creating observables.") self.logger.debug("Creating observables.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment