<commit_before>def _createDefaultMantidUserConfig(facility='SNS'):
    # create default Mantid user configuration for DEMO purpose.
    import os
    mantid_config_path = os.path.expanduser('~/.mantid/Mantid.user.properties')
    mantid_user_dir = os.path.dirname(mantid_config_path)
    if not os.path.exists(mantid_config_path):
        if not os.path.exists(mantid_user_dir):
            os.makedirs(mantid_user_dir)
        with open(mantid_config_path, 'wt') as of:
            of.write('default.facility=%s' % facility)
    return
# this should be done before mantid is imported
_createDefaultMantidUserConfig()


mantid_checked = False
def _checkMantid():
    print "* Checking Mantid ..."
    import subprocess as sp, shlex
    sp.call(shlex.split("python -c 'import mantid'"), stdout=sp.PIPE, stderr=sp.PIPE) # sometimes mantid import for the first time may fail
    if sp.call(shlex.split("python -c 'import mantid'")):
        raise RuntimeError("Please install mantid")
    global mantid_checked
    mantid_checked = True
    print "  - Done."
    return
if not mantid_checked:
    _checkMantid()


def reduce(nxsfile, qaxis, outfile, use_ei_guess=False, ei_guess=None, eaxis=None, tof2E=True, ibnorm='ByCurrent'):
    """reduce a NeXus file to a I(Q,E) histogram using Mantid

    This is a wrapper of Mantid algorithms to reduce a NeXus file to IQE histogram.

    Parameters
    ----------

    nxsfile: str
        path to nxs file

    qaxis: 3-tuple of floats
        Momentum transfer axis. (Qmin, dQ, Qmax). unit: inverse angstrom<commit_msg>Refs#116. workaround in _checkMantid<commit_after>def _createDefaultMantidUserConfig(facility='SNS'):
    # create default Mantid user configuration for DEMO purpose.
    import os
    mantid_config_path = os.path.expanduser('~/.mantid/Mantid.user.properties')
    mantid_user_dir = os.path.dirname(mantid_config_path)
    if not os.path.exists(mantid_config_path):
        if not os.path.exists(mantid_user_dir):
            os.makedirs(mantid_user_dir)
        with open(mantid_config_path, 'wt') as of:
            of.write('default.facility=%s' % facility)
    return
# this should be done before mantid is imported
_createDefaultMantidUserConfig()


mantid_checked = False
def _checkMantid():
    print "* Checking Mantid ..."
    import subprocess as sp, shlex
    sp.call(shlex.split("python -c 'import matplotlib, mantid'"), stdout=sp.PIPE, stderr=sp.PIPE) # sometimes mantid import for the first time may fail
    if sp.call(shlex.split("python -c 'import matplotlib, mantid'")):
        raise RuntimeError("Please install mantid")
    global mantid_checked
    mantid_checked = True
    print "  - Done."
    return
if not mantid_checked:
    _checkMantid()


def reduce(nxsfile, qaxis, outfile, use_ei_guess=False, ei_guess=None, eaxis=None, tof2E=True, ibnorm='ByCurrent'):
    """reduce a NeXus file to a I(Q,E) histogram using Mantid

    This is a wrapper of Mantid algorithms to reduce a NeXus file to IQE histogram.

    Parameters
    ----------

    nxsfile: str
        path to nxs file

    qaxis: 3-tuple of floats
        Momentum transfer axis. (Qmin, dQ, Qmax). unit: inverse angstrom
{'fraction_non_alphanumeric': 0.10028382213812677, 'fraction_numerical': 0.002207505518763797, 'mean_word_length': 3.4363636363636365, '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': '1967568', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1023, 'n_words': 286}