Пример #1
0
    def test_alg_with_overridden_attrs(self):
        self.raisesNothing(algorithm_mgr.create_unmanaged, "CoolAlgorithm")
        alg = algorithm_mgr.create_unmanaged("CoolAlgorithm")
        self.assertEquals(alg.name(), "CoolAlgorithm")
        self.assertEquals(alg.version(), 2)
        self.assertEquals(alg.category(), "BestAlgorithms")

        
Пример #2
0
    def test_execute_succeeds_with_valid_props(self):
        alg = algorithm_mgr.create_unmanaged('Load')
        alg.initialize()
        alg.set_property('Filename', 'LOQ48127.raw')
        nspec = 1
        alg.set_property('SpectrumMax', nspec)
        wsname = 'LOQ48127' 
        alg.set_property('OutputWorkspace', wsname)
        alg.set_child(True) # Just to keep the output from the data service
        alg.execute()

        self.assertEquals(alg.get_property('SpectrumMax').value, nspec)
        self.assertEquals(type(alg.get_property('SpectrumMax').value), int)
        self.assertEquals(alg.get_property('SpectrumMax').name, 'SpectrumMax')
                
        ws = alg.get_property('OutputWorkspace').value
        self.assertTrue(ws.get_memory_size() > 0.0 )
Пример #3
0
def run_algorithm(name, **kwargs):
    """Run a named algorithm and return the
    algorithm handle
    
    Parameters: 
        name - The name of the algorithm
        kwargs - A dictionary of property name:value pairs    
    """
    alg = algorithm_mgr.create_unmanaged(name)
    alg.initialize()
    # Avoid problem that Load needs to set Filename first if it exists
    if name == 'Load' and 'Filename' in kwargs:
        alg.set_property('Filename', kwargs['Filename'])
        del kwargs['Filename']
    if 'child'in kwargs:
        alg.set_child(True)
        del kwargs['child']
    for key, value in kwargs.iteritems():
        alg.set_property(key, value)
    alg.execute()
    return alg 
Пример #4
0
 def test_unmanaged_cppalg_isinstance_of_Algorithm(self):
     alg = algorithm_mgr.create_unmanaged("ConvertUnits")
     self.assertTrue(isinstance(alg, Algorithm))
Пример #5
0
 def test_alg_with_default_attrs(self):
     self.raisesNothing(algorithm_mgr.create_unmanaged, "TestPyAlgDefaultAttrs")
     alg = algorithm_mgr.create_unmanaged("TestPyAlgDefaultAttrs")
     self.assertEquals(alg.name(), "TestPyAlgDefaultAttrs")
     self.assertEquals(alg.version(), 1)
     self.assertEquals(alg.category(), "PythonAlgorithms")
Пример #6
0
 def test_alg_attrs_are_correct(self):
     alg = algorithm_mgr.create_unmanaged('Load')
     self.assertTrue(alg.name(), 'Load')
     self.assertTrue(alg.version(), 1)
     self.assertTrue(alg.category(), 'DataHandling')
Пример #7
0
 def test_cannot_execute_with_invalid_properties(self):
     alg = algorithm_mgr.create_unmanaged('Load')
     alg.initialize()
     self.assertRaises(RuntimeError, alg.execute)
Пример #8
0
 def test_alg_set_invalid_prop_raises_error(self):
     alg = algorithm_mgr.create_unmanaged('Load')
     alg.initialize()
     args = ('Filename', 'nonexistent.txt')
     self.assertRaises(ValueError, alg.set_property, *args)
Пример #9
0
 def test_alg_set_valid_prop_succeeds(self):
     alg = algorithm_mgr.create_unmanaged('Load')
     alg.initialize()
     alg.set_property('Filename', 'LOQ48127.raw')