Ejemplo n.º 1
0
def test_add_function_to_composite(self):
    assert (isinstance(self, TestFunctionBrowser))
    browser = self.widget
    browser.setFunction(
        'name=FlatBackground;(name=FlatBackground,A0=1;name=FlatBackground,A0=2)'
    )
    view = browser.view()
    user = BrowserUser(browser)
    pos = view.getVisualRectFunctionProperty('f1.').center()
    tree = view.treeWidget().viewport()
    yield self.show_context_menu(tree, pos, pause=0)
    yield self.mouse_trigger_action('add_function', pause=0)
    yield self.wait_for_modal()
    dlg = self.get_active_modal_widget()
    tree = get_child(dlg, 'fitTree')
    item = tree.findItems('Background', Qt.MatchExactly)[0]
    item.setExpanded(True)
    item = tree.findItems('LinearBackground', Qt.MatchRecursive)[0]
    pos = tree.visualItemRect(item).center()
    yield click_on(tree.viewport(), pos)
    dlg.accept()
    fun = self.get_fit_function()
    self.assertEqual(fun.name, 'CompositeFunction')
    self.assertEqual(fun[0].name, 'FlatBackground')
    self.assertEqual(fun[1].name, 'CompositeFunction')
    self.assertEqual(fun[1][0].name, 'FlatBackground')
    self.assertEqual(fun[1][1].name, 'FlatBackground')
    self.assertEqual(fun[1][2].name, 'LinearBackground')
    self.assertEqual(fun[1][0].A0, 1.0)
    self.assertEqual(fun[1][1].A0, 2.0)
    self.assertEqual(fun[1][2].A0, 0.0)
    self.assertEqual(user.structure_changed.call_count, 2)
Ejemplo n.º 2
0
def test_add_function_to_composite(self):
    assert (isinstance(self, TestFunctionBrowser))
    browser = self.widget
    browser.setFunction('name=FlatBackground;(name=FlatBackground,A0=1;name=FlatBackground,A0=2)')
    view = browser.view()
    user = BrowserUser(browser)
    pos = view.getVisualRectFunctionProperty('f1.').center()
    tree = view.treeWidget().viewport()
    yield self.show_context_menu(tree, pos, pause=0)
    yield self.mouse_trigger_action('add_function', pause=0)
    yield self.wait_for_modal()
    dlg = self.get_active_modal_widget()
    tree = get_child(dlg, 'fitTree')
    item = tree.findItems('Background', Qt.MatchExactly)[0]
    item.setExpanded(True)
    item = tree.findItems('LinearBackground', Qt.MatchRecursive)[0]
    pos = tree.visualItemRect(item).center()
    yield click_on(tree.viewport(), pos)
    dlg.accept()
    fun = self.get_fit_function()
    self.assertEqual(fun.name, 'CompositeFunction')
    self.assertEqual(fun[0].name, 'FlatBackground')
    self.assertEqual(fun[1].name, 'CompositeFunction')
    self.assertEqual(fun[1][0].name, 'FlatBackground')
    self.assertEqual(fun[1][1].name, 'FlatBackground')
    self.assertEqual(fun[1][2].name, 'LinearBackground')
    self.assertEqual(fun[1][0].A0, 1.0)
    self.assertEqual(fun[1][1].A0, 2.0)
    self.assertEqual(fun[1][2].A0, 0.0)
    self.assertEqual(user.structure_changed.call_count, 1)
Ejemplo n.º 3
0
def test_converting_to_composite_retains_globals(self):
    assert (isinstance(self, TestFunctionBrowser))
    browser = self.widget
    browser.setFunction('name=FlatBackground')
    browser.setGlobalParameters(['A0'])
    view = browser.view()
    pos = view.getVisualRectFunctionProperty('').center()
    tree = view.treeWidget().viewport()
    yield self.show_context_menu(tree, pos, pause=0)
    yield self.mouse_trigger_action('add_function', pause=0)
    yield self.wait_for_modal()
    dlg = self.get_active_modal_widget()
    tree = get_child(dlg, 'fitTree')
    item = tree.findItems('Background', Qt.MatchExactly)[0]
    item.setExpanded(True)
    item = tree.findItems('BSpline', Qt.MatchRecursive)[0]
    pos = tree.visualItemRect(item).center()
    yield click_on(tree.viewport(), pos, pause=10)
    dlg.accept()
    self.assertEqual(browser.getGlobalParameters(), ['f0.A0'])