<commit_before>#!/usr/bin/python
import adddeps #fix sys.path
import argparse
import base64
import pickle
import tempfile
import shutil
import subprocess
import re

import opentuner
from opentuner.search.manipulator import ConfigurationManipulator, IntegerParameter, EnumParameter, BooleanParameter
from opentuner.measurement import MeasurementInterface
from opentuner.measurement.inputmanager import FixedInputManager
from opentuner.tuningrunmain import TuningRunMain
from opentuner.search.objective import MinimizeTime

def fm2_line(up, down, left, right, a, b, start, select, reset=False):
  return ''.join(('|1|' if reset else '|0|') +
    ('R' if right else '.') +
    ('L' if left else '.') +
    ('D' if down else '.') +
    ('U' if up else '.') +
    ('T' if start else '.') +
    ('D' if select else '.') +
    ('B' if b else '.') +
    ('A' if a else '.') +
    '|........||')

def maxd(iterable, default):
  try:
    return max(iterable)
  except ValueError:
    return default

def fm2_lines(up, down, left, right, a, b, start, select, reset=set(), minFrame=None, maxFrame=None):
  if minFrame is None:
    minFrame = 0
  if maxFrame is None:
    maxFrame = max(maxd(up, 0), maxd(down, 0), maxd(left, 0), maxd(right, 0), maxd(a, 0), maxd(b, 0), maxd(start, 0), maxd(select, 0), maxd(reset, 0)) + 1
  lines = list()
  for i in xrange(minFrame, maxFrame):
    lines.append(fm2_line(i in up, i in down, i in left, i in right, i in a, i in b, i in start, i in select, i in reset))
  return lines

def fm2_smb_header():
  return ["version 3",
    "emuVersion 9828",<commit_msg>fm2-related docstrings<commit_after>#!/usr/bin/python
import adddeps #fix sys.path
import argparse
import base64
import pickle
import tempfile
import shutil
import subprocess
import re

import opentuner
from opentuner.search.manipulator import ConfigurationManipulator, IntegerParameter, EnumParameter, BooleanParameter
from opentuner.measurement import MeasurementInterface
from opentuner.measurement.inputmanager import FixedInputManager
from opentuner.tuningrunmain import TuningRunMain
from opentuner.search.objective import MinimizeTime

# Functions for building FCEUX movie files (.fm2 files)

def fm2_line(up, down, left, right, a, b, start, select, reset=False):
  """formats one frame of input with the given button presses"""
  return ''.join(('|1|' if reset else '|0|') +
    ('R' if right else '.') +
    ('L' if left else '.') +
    ('D' if down else '.') +
    ('U' if up else '.') +
    ('T' if start else '.') +
    ('D' if select else '.') +
    ('B' if b else '.') +
    ('A' if a else '.') +
    '|........||')

def maxd(iterable, default):
  try:
    return max(iterable)
  except ValueError:
    return default

def fm2_lines(up, down, left, right, a, b, start, select, reset=set(), minFrame=None, maxFrame=None):
  """formats many frames using the given button-press sets"""
  if minFrame is None:
    minFrame = 0
  if maxFrame is None:
    maxFrame = max(maxd(up, 0), maxd(down, 0), maxd(left, 0), maxd(right, 0), maxd(a, 0), maxd(b, 0), maxd(start, 0), maxd(select, 0), maxd(reset, 0)) + 1
  lines = list()
  for i in xrange(minFrame, maxFrame):
    lines.append(fm2_line(i in up, i in down, i in left, i in right, i in a, i in b, i in start, i in select, i in reset))
  return lines

def fm2_smb_header():
  return ["version 3",
    "emuVersion 9828",
{'fraction_non_alphanumeric': 0.13864921154418328, 'fraction_numerical': 0.01487652484379649, 'mean_word_length': 3.95139911634757, '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': '3055586', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1167, 'n_words': 400}