<commit_before>from PyQt4 import QtCore

def subscribe(event, callback):
  if event not in _events_map:
    _events_map[event] = []
  _events_map[event].append(callback)

def inform(event, *args, **kwargs):
  _marshall.informsignal.emit(event, args, kwargs)

def _inform_UIT(event, args, kwargs):
  if event in _events_map:
    for callback in _events_map[event]:
      callback(*args, **kwargs)

def run_on_ui_thread(action, *, delay_ms=0):
  _marshall.runuithreadsignal.emit(action, delay_ms)

def _run_on_ui_thread_UIT(action, delay_ms):
  # NB: QTimer cannot be used on non-Qt threads.
  QtCore.QTimer.singleShot(delay_ms, action)

class ThreadMarshaller(QtCore.QObject):
  informsignal = QtCore.pyqtSignal(object, tuple, dict)
  runuithreadsignal = QtCore.pyqtSignal(object, int)

_marshall = ThreadMarshaller()
_marshall.informsignal.connect(_inform_UIT, QtCore.Qt.QueuedConnection)
_marshall.runuithreadsignal.connect(_run_on_ui_thread_UIT, QtCore.Qt.QueuedConnection)

_events_map = {}
<commit_msg>getting rid of the separate Qt signal for event.inform<commit_after>from PyQt4 import QtCore

def subscribe(event, callback):
  if event not in _events_map:
    _events_map[event] = []
  _events_map[event].append(callback)

def inform(event, *args, **kwargs):
  def _inform_UIT():
    if event in _events_map:
      for callback in _events_map[event]:
        callback(*args, **kwargs)
  run_on_ui_thread(_inform_UIT)

def run_on_ui_thread(action, *, delay_ms=0):
  _marshall.runuithreadsignal.emit(action, delay_ms)

def _run_on_ui_thread_UIT(action, delay_ms):
  # NB: QTimer cannot be used on non-Qt threads.
  QtCore.QTimer.singleShot(delay_ms, action)

class ThreadMarshaller(QtCore.QObject):
  runuithreadsignal = QtCore.pyqtSignal(object, int)

_marshall = ThreadMarshaller()
_marshall.runuithreadsignal.connect(_run_on_ui_thread_UIT, QtCore.Qt.QueuedConnection)

_events_map = {}

{'fraction_non_alphanumeric': 0.10348468848996832, 'fraction_numerical': 0.0021119324181626186, 'mean_word_length': 5.941391941391942, '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': '5114191', 'n_tokens_mistral': 685, 'n_tokens_neox': 670, 'n_words': 138}