def test_delta_update_limits(self):
     hb = ParamHintBox()
     hb.vary_e.setCurrentText('delta')
     self.assertEqual((-1, 1), (hb.min_e.value(), hb.max_e.value()))
     hb.setValues(value=10)
     self.assertEqual((9, 11), (hb.min_e.value(), hb.max_e.value()))
     hb.vary_e.setCurrentText('limits')
     self.assertEqual((9, 11), (hb.min_e.value(), hb.max_e.value()))
 def test_expr_change_to_vary(self):
     init = OrderedDict([('expr', "test")])
     hb = ParamHintBox(init_hints=init)
     self.assertEqual(init, hb.param_hints())
     hb.vary_e.setCurrentText('delta')
     self.assertEqual('delta', hb.vary_e.currentText())
     self.assertEqual("", hb.param_hints()['expr'])
     hb.vary_e.setCurrentText('expr')
     self.assertEqual('expr', hb.vary_e.currentText())
     self.assertEqual(init, hb.param_hints())
 def test_delta_update_limits(self):
     h = {'vary': 'limits'}
     hb = ParamHintBox(h)
     hb.vary_e.setCurrentText('delta')
     hb.setValues()  # an Editor should run this
     self.assertEqual((-1, 1), (hb.min_e.value(), hb.max_e.value()))
     hb.val_e.setValue(10)
     hb.setValues()
     self.assertEqual((9, 11), (hb.min_e.value(), hb.max_e.value()))
     hb.vary_e.setCurrentText('limits')
     hb.setValues()
     self.assertEqual((9, 11), (hb.min_e.value(), hb.max_e.value()))
     hb.vary_e.setCurrentText('delta')
     h['value'] = 20
     hb.update_min_max_for_delta()  # should be called after line move
     self.assertEqual((19, 21), (hb.min_e.value(), hb.max_e.value()))
 def test_keep_delta(self):
     hb = ParamHintBox()
     hb.vary_e.setCurrentText('delta')
     self.assertEqual('delta', hb.vary_e.currentText())
     self.assertEqual((-1, 1), (hb.min_e.value(), hb.max_e.value()))
     hb.vary_e.setCurrentText('limits')
     self.assertEqual((-1, 1), (hb.min_e.value(), hb.max_e.value()))
     hb.vary_e.setCurrentText('delta')
     self.assertEqual((-1, 1), (hb.min_e.value(), hb.max_e.value()))
 def test_defaults(self):
     hb = ParamHintBox()
     defaults = {
         'value': 0,
         'vary': 'limits',
         'min': float('-inf'),
         'max': float('-inf'),
         'delta': 1,
         'expr': "",
     }
     e_vals = {
         'value': hb.val_e.value(),
         'vary': hb.vary_e.currentText(),
         'min': hb.min_e.value(),
         'max': hb.max_e.value(),
         'delta': hb.delta_e.value(),
         'expr': hb.expr_e.text(),
     }
     self.assertEqual(defaults, e_vals)
     self.assertEqual(OrderedDict([('value', 0.0)]), hb.param_hints())
 def test_expr_change_to_vary(self):
     h = {'expr': 'test', 'vary': 'expr'}
     hb = ParamHintBox(h)
     self.assertEqual({}, VoigtModelEditor.translate("gamma",
                                                     hb.hints))  # default
     hb.vary_e.setCurrentText('delta')
     self.assertEqual('delta', hb.vary_e.currentText())
     self.assertEqual("",
                      VoigtModelEditor.translate("gamma", hb.hints)["expr"])
     hb.vary_e.setCurrentText('expr')
     self.assertEqual('expr', hb.vary_e.currentText())
     self.assertEqual({}, VoigtModelEditor.translate("gamma",
                                                     hb.hints))  # default
 def test_keep_delta(self):
     h = {'vary': 'limits'}
     hb = ParamHintBox(h)
     hb.vary_e.setCurrentText('delta')
     hb.setValues()  # an Editor should run this
     self.assertEqual('delta', h['vary'])
     self.assertEqual((-1, 1), (h['min'], h['max']))
     self.assertEqual((-1, 1), (hb.min_e.value(), hb.max_e.value()))
     hb.vary_e.setCurrentText('limits')
     hb.setValues()  # an Editor should run this
     self.assertEqual('limits', h['vary'])
     self.assertEqual((-1, 1), (h['min'], h['max']))
     self.assertEqual((-1, 1), (hb.min_e.value(), hb.max_e.value()))
     hb.vary_e.setCurrentText('delta')
     hb.setValues()  # an Editor should run this
     self.assertEqual((-1, 1), (h['min'], h['max']))
     self.assertEqual((-1, 1), (hb.min_e.value(), hb.max_e.value()))
 def test_defaults(self):
     defaults = {
         'value': 0,
         'vary': 'limits',
         'min': float('-inf'),
         'max': float('-inf'),
         'delta': 1,
         'expr': "",
     }
     hb = ParamHintBox(defaults)
     e_vals = {
         'value': hb.val_e.value(),
         'vary': hb.vary_e.currentText(),
         'min': hb.min_e.value(),
         'max': hb.max_e.value(),
         'delta': hb.delta_e.value(),
         'expr': hb.expr_e.text(),
     }
     self.assertEqual(defaults, e_vals)
     self.assertEqual({'value': 0.0},
                      VoigtModelEditor.translate("center", hb.hints))
 def test_expr_set_hint(self):
     hb = ParamHintBox(init_hints=OrderedDict([('expr', "test")]))
     hb.setValues(expr="")
     self.assertEqual('limits', hb.vary_e.currentText())
     self.assertEqual("", hb.param_hints()['expr'])
 def test_delta_restore_from_saved_hints(self):
     hb = ParamHintBox()
     hb.setValues(value=15.3, min=10.3, max=20.3)
     self.assertEqual('delta', hb.vary_e.currentText())
     self.assertEqual(5.0, hb.delta_e.value())
 def test_expr_set_hint(self):
     h = {'expr': 'test', 'vary': 'expr'}
     hb = ParamHintBox(h)
     self.assertEqual('expr', hb.vary_e.currentText())
     self.assertEqual({}, VoigtModelEditor.translate("gamma",
                                                     hb.hints))  # default