def put(self, options): """ Puts an options in queue. The options are converted using the converter of this runner's program. An :exc:`ValueError` is raised if an options with the same name was already added. This error is raised as options with the same name would lead to results been overwritten. :arg options: options to be added to the queue """ if not options.programs: raise ValueError("No program associated with options") base_options = options # copy.deepcopy(options) logging.debug("Putting %s options is queue" % base_options) list_options = [] for program in base_options.programs: converter = program.converter_class() for options in converter.convert(base_options): options.programs.clear() options.programs.add(program) options.name = options.name + "+" + program.alias freeze(options) self._queue_options.put((base_options, options)) list_options.append(options) self.options_added.fire(options) return list_options
def __init__(self, options, results): self._options = options freeze(self._options) self._list_results = [] for container in results: if not isinstance(container, ResultsContainer): container = ResultsContainer(*container) self._list_results.append(container)
def testfreeze2(self): subobj1 = MockParameterization('subobj1') subobj1.attr1 = [88, 108] self.obj.param1 = subobj1 freeze(self.obj.param1) self.obj.attr1 = 0.0 self.assertRaises(ValueError, setattr, self.obj.param1, 'param1', 0) self.assertRaises(ValueError, setattr, self.obj.param1, 'param2', 0) self.assertRaises(ValueError, setattr, self.obj.param1, 'param3', 0) self.assertRaises(ValueError, setattr, self.obj.param1, 'param4', 0)
def __init__(self, options, results={}): """ Internal container for the results. :arg options: options used to generate these results :type options: :class:`Options` :arg results: results to be part of this container. The results are specified by a key (key of the detector) and a :class:`Result <pymontecarlo.result.base.result.Result>` class. :type results: :class:`dict` """ self._options = options freeze(self._options) self._results = {} for key, result in results.items(): if key not in options.detectors: raise KeyError('No detector found for result %s' % key) self._results[key] = result