<commit_before>#!/usr/bin/env python

""" A quick and extremely dirty hack to wrap matlabpipe/matlabcom as if they
were mlabraw.

Author: <NAME> <<EMAIL>>
License: MIT
"""
import sys

is_win = sys.platform == 'win32'
if is_win:
  from matlabcom import MatlabCom as MatlabConnection
  from matlabcom import MatlabError as error
else:
  from matlabpipe import MatlabPipe as MatlabConnection
  from matlabpipe import MatlabError as error

try:
  import settings
except:
  class settings:
    MATLAB_PATH = 'guess'

def open(arg):
  if is_win:
    ret = MatlabConnection()
    ret.open()
  else:
    if settings.MATLAB_PATH != 'guess':
      matlab_path = settings.MATLAB_PATH + '/bin/matlab'
    else:
      matlab_path = 'guess'
    try:
      ret = MatlabConnection(matlab_path)
      ret.open()
    except:
      print 'Could not open matlab, is it in %s?' % matlab_path
  return ret

def close(matlab):
  matlab.close()

def eval(matlab, exp, log=False):
  if log or is_win:
    matlab.eval(exp)
  else:
    matlab.eval(exp, print_expression=False, on_new_output=None)
  return ''

def get(matlab, var_name):
  return matlab.get(var_name)

def put(matlab, var_name, val):
  matlab.put({var_name : val})
<commit_msg>Minor pep8 fixes.<commit_after>#!/usr/bin/env python

""" A quick and extremely dirty hack to wrap matlabpipe/matlabcom as if they
were mlabraw.

Author: <NAME> <<EMAIL>>
License: MIT
"""
import sys

is_win = sys.platform == 'win32'
if is_win:
    from matlabcom import MatlabCom as MatlabConnection
    #from matlabcom import MatlabError as error
else:
    from matlabpipe import MatlabPipe as MatlabConnection
    #from matlabpipe import MatlabError as error

try:
    import settings
except:
    class settings:
        MATLAB_PATH = 'guess'


def open(arg):
    if is_win:
        ret = MatlabConnection()
        ret.open()
    else:
        if settings.MATLAB_PATH != 'guess':
            matlab_path = settings.MATLAB_PATH + '/bin/matlab'
        else:
            matlab_path = 'guess'
        try:
            ret = MatlabConnection(matlab_path)
            ret.open()
        except:
            print('Could not open matlab, is it in %s?' % matlab_path)
    return ret


def close(matlab):
    matlab.close()


def eval(matlab, exp, log=False):
    if log or is_win:
        matlab.eval(exp)
    else:
        matlab.eval(exp, print_expression=False, on_new_output=None)
    return ''


def get(matlab, var_name):
    return matlab.get(var_name)


def put(matlab, var_name, val):
    matlab.put({var_name: val})

{'fraction_non_alphanumeric': 0.09964552973611658, 'fraction_numerical': 0.0019692792437967705, 'mean_word_length': 3.0901771336553945, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1522498', 'n_tokens_mistral': 879, 'n_tokens_neox': 866, 'n_words': 247}