<commit_before># System Imports
import os

# Twised Imports
from twisted.internet import reactor, defer

# Sibling Imports
from sequence import Step
import data
import experiment
from machine import Machine, ui as machine_ui
import util

from sequence.shortcuts import *

_experiment = experiment.Experiment()

## inject machine registration
_old_machine_init = Machine.__init__

def _new_machine_init (self, *a, **k):
	_old_machine_init(self, *a, **k)
	_experiment.register_machine(self)

Machine.__init__ = _new_machine_init

def id (id):
	_experiment.id = id

def title (title):
	_experiment.title = title

def ui (**kwargs):
	_experiment.interface.clear()
	_experiment.interface["experiment"] = machine_ui(**kwargs)

def chdir (dir):
	return os.chdir(dir)

def variable (value, alias, title, unit = ""):
	v = experiment.Variable(title, type(value), unit = unit)
	v.alias = alias
	v.set(value)

	return v

def derived (expr, alias, title, unit = ""):
	expr.title = title
	expr.alias = alias

	return expr

def constant (value, alias, title, unit = ""):
	v = data.Constant(value)
	v.title = title
	v.alias = alias
	v.unit = unit

	return v

def log_variables (*variables):
	_experiment.log_variables(*variables)
<commit_msg>Add replace parameter to ui<commit_after># System Imports
import os

# Twised Imports
from twisted.internet import reactor, defer

# Sibling Imports
from sequence import Step
import data
import experiment
from machine import Machine, ui as machine_ui
import util

from sequence.shortcuts import *

_experiment = experiment.Experiment()

## inject machine registration
_old_machine_init = Machine.__init__

def _new_machine_init (self, *a, **k):
	_old_machine_init(self, *a, **k)
	_experiment.register_machine(self)

Machine.__init__ = _new_machine_init

def id (id):
	_experiment.id = id

def title (title):
	_experiment.title = title

def ui (replace = "experiment", **kwargs):
	if replace is True:
		_experiment.interface.clear()
		replace = "experiment"

	_experiment.interface[replace] = machine_ui(**kwargs)

def chdir (dir):
	return os.chdir(dir)

def variable (value, alias, title, unit = ""):
	v = experiment.Variable(title, type(value), unit = unit)
	v.alias = alias
	v.set(value)

	return v

def derived (expr, alias, title, unit = ""):
	expr.title = title
	expr.alias = alias

	return expr

def constant (value, alias, title, unit = ""):
	v = data.Constant(value)
	v.title = title
	v.alias = alias
	v.unit = unit

	return v

def log_variables (*variables):
	_experiment.log_variables(*variables)

{'fraction_non_alphanumeric': 0.11054086063955784, 'fraction_numerical': 0.0, 'mean_word_length': 4.8657407407407405, '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': '6467137', 'n_tokens_mistral': 851, 'n_tokens_neox': 835, 'n_words': 254}