def setUp(self): FrameworkManagerImpl.Instance() self._alg_factory = AlgorithmFactory.Instance() self._alg_factory.subscribe(_ParamTester) if self._load is None: self.__class__._load = AlgorithmManager.createUnmanaged('Load') self._load.initialize()
def get_algorithm_data(self): """ Prepare the algorithm description data for displaying in the view. :return: A tuple of two elements. The first is a list of all algorithm names. This always contains all known algorithms regardless of their hidden state The second is a tree of nested dicts where keys either category names or self.algorithm_key. Values of the category names are sub-trees and those of self.algorithm_key have dicts mapping algorithm names to lists of their versions. For example (as yaml): Arithmetic: Errors: _: PoissonErrors: [1] SetUncertainties: [1] SignalOverError: [1] FFT: _: ExtractFFTSpectrum: [1] FFT: [1] FFTDerivative: [1] FFTSmooth: [1, 2] _: CrossCorrelate: [1] Divide: [1] Exponential: [1] GeneralisedSecondDifference: [1] Here self.algorithm_key == '_' """ include_alias = True algm_factory = AlgorithmFactory.Instance() descriptors = algm_factory.getDescriptors(self.include_hidden, include_alias) data = {} for descriptor in descriptors: categories = descriptor.category.split(CATEGORY_SEP) # Create nested dictionaries in which the key is a category and the value # is a similar dictionary with sub-categories as keys d = data for cat in categories: if cat not in d: d[cat] = {} d = d[cat] # Entry with key == '' contains a dict with algorithm names as keys # The values are lists of version numbers if self.algorithm_key not in d: d[self.algorithm_key] = {} d = d[self.algorithm_key] if descriptor.name not in d: d[descriptor.name] = [] d[descriptor.name].append(descriptor.version) # Add hidden algs to search box (hidden on tree) include_hidden = True unique_alg_names = set(descr.name for descr in algm_factory.getDescriptors(include_hidden, include_alias)) return sorted(unique_alg_names), data
def post_mantid_init(self): """Run any setup that requires mantid to have been initialized """ self.populate_menus() self.algorithm_selector.refresh() # turn on algorithm factory notifications from mantid.api import AlgorithmFactory algorithm_factory = AlgorithmFactory.Instance() algorithm_factory.enableNotifications()
def create_mantid_algorithm(self, algorithm_name, version=-1): """ Create and initializes a Mantid algorithm. Args: algorithm_name (str): The name of the algorithm to use for the title. version (int): Version of the algorithm to create Returns: algorithm: An instance of a Mantid algorithm. """ if version == -1: version = AlgorithmFactory.Instance().highestVersion( algorithm_name) alg = AlgorithmManager.Instance().createUnmanaged( algorithm_name, version) alg.initialize() return alg
def set_algorithm_tree_categories(self): widget = self.view.algorithm_tree_widget widget.setHeaderLabel("Show/Hide Algorithm Categories") category_map = AlgorithmFactory.Instance().getCategoriesandState() self._set_tree_categories(widget, category_map)
def setUp(self): self._alg_factory = AlgorithmFactory.Instance() self._alg_factory.enableNotifications()
def setUp(self): self.fake_class = FakeAlgorithmFactoryObserver() self.fake_class.updateHandle = mock.MagicMock() self._alg_factory = AlgorithmFactory.Instance() self._alg_factory.disableNotifications()
def set_algorithm_tree_categories(self): widget = self.view.algorithm_tree_widget category_map = AlgorithmFactory.Instance().getCategoriesandState() self._set_tree_categories(widget, category_map)