<commit_before># -*- coding: utf-8 -*-
"""
Created on Tue Nov  3 21:14:25 2015

@author: <NAME>, <NAME>
"""

from __future__ import division, print_function, absolute_import, unicode_literals
import os
from multiprocessing import cpu_count
from time import strftime
from psutil import virtual_memory as vm
from warnings import warn
import h5py
import numpy as np

__all__ = ['getAvailableMem', 'getTimeStamp', 'transformToTargetType', 'transformToReal',
           'complex_to_float', 'compound_to_scalar', 'realToComplex', 'realToCompound', 'check_dtype',
           'recommendCores', 'uiGetFile']


def check_ssh():
    return 'SSH_CLIENT' in os.environ or 'SSH_TTY' in os.environ


def uiGetFile(filter='H5 file (*.h5)', caption='Select File'):
    """
    Presents a File dialog used for selecting the .mat file
    and returns the absolute filepath of the selecte file\n

    Parameters
    ----------
    extension : String or list of strings
        file extensions to look for
    caption : (Optional) String
        Title for the file browser window

    Returns
    -------
    file_path : String
        Absolute path of the chosen file
    """
    # Only try to use the GUI options if not over an SSH connection.
    if not check_ssh():
        try:
            from PyQt5 import QtWidgets
        except ImportError:
            warn('The required package PyQt5 could not be imported.\n',
                 'The code will check for PyQt4.')
        except:
            raise
        else:
            app = QtWidgets.QApplication([])
            path = QtWidgets.QFileDialog.getOpenFileName(caption=caption, filter=filter)[0]
            app.exit()
            del app
<commit_msg>uiGetFile update<commit_after># -*- coding: utf-8 -*-
"""
Created on Tue Nov  3 21:14:25 2015

@author: <NAME>, <NAME>
"""

from __future__ import division, print_function, absolute_import, unicode_literals
import os
from multiprocessing import cpu_count
from time import strftime
from psutil import virtual_memory as vm
from warnings import warn
import h5py
import numpy as np

__all__ = ['getAvailableMem', 'getTimeStamp', 'transformToTargetType', 'transformToReal',
           'complex_to_float', 'compound_to_scalar', 'realToComplex', 'realToCompound', 'check_dtype',
           'recommendCores', 'uiGetFile']


def check_ssh():
    return 'SSH_CLIENT' in os.environ or 'SSH_TTY' in os.environ


def uiGetFile(filter='H5 file (*.h5)', caption='Select File'):
    """
    Presents a File dialog used for selecting the .mat file
    and returns the absolute filepath of the selecte file\n

    Parameters
    ----------
    extension : String or list of strings
        file extensions to look for
    caption : (Optional) String
        Title for the file browser window

    Returns
    -------
    file_path : String
        Absolute path of the chosen file
    """
    # Only try to use the GUI options if not over an SSH connection.
    if not check_ssh():
        try:
            from PyQt5 import QtWidgets
        except ImportError:
            warn('The required package PyQt5 could not be imported.\n',
                 'The code will check for PyQt4.')
        except:
            raise
        else:
            app = QtWidgets.QApplication([])
            path = QtWidgets.QFileDialog.getOpenFileName(caption=caption, filter=filter)[0]
            app.closeAllWindows()
            app.exit()
            del app

{'fraction_non_alphanumeric': 0.09202453987730061, 'fraction_numerical': 0.011101373064563248, 'mean_word_length': 2.611814345991561, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '631345', 'n_tokens_mistral': 990, 'n_tokens_neox': 949, 'n_words': 344}