<commit_before>from PyQt5.QtGui import QDoubleValidator
from PyQt5.QtWidgets import QGridLayout, QWidget, \
  QLabel, QSpinBox, QLineEdit

class ParamBase:
  def __init__(self, name, label, default):
    self.name = name
    self.label = label
    self.default = default
    self.widget = None

  def value(self):
    if hasattr(self, 'value_'):
      return self.value_
    return self.default

  def setValue(self, value):
    if value == self.value():
      return
    self.value_ = value
    if self.widget and not self.widget.hasFocus():
      self.updateWidgetValue(self.widget, value)

  def getWidget(self):
    if self.widget is None:
      self.widget = self.createWidget()
    return self.widget



class ParamInt(ParamBase):
  def __init__(self, name, label, min_, max_, default):
    super().__init__(name, label, default)
    self.min = min_
    self.max = max_

  def updateWidgetValue(self, widget, value):
    self.widget.setValue(value)

  def createWidget(self):
    spin = QSpinBox()
    spin.setMinimum(self.min)
    spin.setMaximum(self.max)
    spin.setValue(self.value())
    spin.valueChanged.connect(self.setValue)
    return spin



class ParamDouble(ParamBase):
  def updateWidgetValue(self, widget, value):
    self.widget.setText(str(value))

  def createWidget(self):
    edit = QLineEdit()
    edit.setValidator(QDoubleValidator())
    edit.textChanged.connect(lambda t: self.setValue(float(t)))
    return edit



class MethodBase:
  def __init__(self):<commit_msg>ParamDouble widget never shows its default value<commit_after>from PyQt5.QtGui import QDoubleValidator
from PyQt5.QtWidgets import QGridLayout, QWidget, \
  QLabel, QSpinBox, QLineEdit


class ParamBase:
  def __init__(self, name, label, default):
    self.name = name
    self.label = label
    self.default = default
    self.widget = None

  def value(self):
    if hasattr(self, 'value_'):
      return self.value_
    return self.default

  def setValue(self, value):
    if value == self.value():
      return
    self.value_ = value
    if self.widget and not self.widget.hasFocus():
      self.updateWidgetValue(self.widget, value)

  def getWidget(self):
    if self.widget is None:
      self.widget = self.createWidget()
    return self.widget



class ParamInt(ParamBase):
  def __init__(self, name, label, min_, max_, default):
    super().__init__(name, label, default)
    self.min = min_
    self.max = max_

  def updateWidgetValue(self, widget, value):
    self.widget.setValue(value)

  def createWidget(self):
    spin = QSpinBox()
    spin.setMinimum(self.min)
    spin.setMaximum(self.max)
    spin.setValue(self.value())
    spin.valueChanged.connect(self.setValue)
    return spin



class ParamDouble(ParamBase):
  def updateWidgetValue(self, widget, value):
    self.widget.setText(str(value))

  def createWidget(self):
    edit = QLineEdit()
    edit.setValidator(QDoubleValidator())
    edit.setText(str(self.value()))
    edit.textChanged.connect(lambda t: self.setValue(float(t)))
    return edit



class MethodBase:
  def __init__(self):
{'fraction_non_alphanumeric': 0.11016949152542373, 'fraction_numerical': 0.001303780964797914, 'mean_word_length': 3.533234859675037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3346861', 'n_tokens_mistral': 983, 'n_tokens_neox': 963, 'n_words': 234}