<commit_before>####################################################################################################
# neuropythy/util/core.py
# This file implements the command-line tools that are available as part of neuropythy as well as
# a number of other random utilities.

import types, inspect, atexit, shutil, tempfile, importlib, pimms, os, six
import collections                       as colls
import numpy                             as np
import scipy.sparse                      as sps
import pyrsistent                        as pyr
import nibabel                           as nib
import nibabel.freesurfer.mghformat      as fsmgh
from   functools                    import reduce

if six.PY2: (_tuple_type, _list_type) = (types.TupleType, types.ListType)
else:       (_tuple_type, _list_type) = (tuple, list)

# Used by functions that pass arguments on to the isclose and related functions
default_rtol = inspect.getargspec(np.isclose)[3][0]
default_atol = inspect.getargspec(np.isclose)[3][1]

# A few functions were moved into pimms; they still appear here for compatibility
from pimms import (is_tuple, is_list, is_set, curry)

def to_hemi_str(s):
    '''
    to_hemi_str(s) yields either 'lh', 'rh', or 'lr' depending on the input s.

    The match rules for s are as follows:
      * if s is None or Ellipsis, returns 'lr'
      * if s is not a string, error; otherwise s becomes s.lower()
      * if s is in ('lh','rh','lr'), returns s
      * if s is in ('left', 'l', 'sh'), returns 'lh'
      * if s is in ('right', 'r', 'dh'), returns 'rh'
      * if s in in ('both', 'all', 'xh'), returns 'lr'<commit_msg>bug fixe for newer versions of numpy<commit_after>####################################################################################################
# neuropythy/util/core.py
# This file implements the command-line tools that are available as part of neuropythy as well as
# a number of other random utilities.

import types, inspect, atexit, shutil, tempfile, importlib, pimms, os, six
import collections                       as colls
import numpy                             as np
import scipy.sparse                      as sps
import pyrsistent                        as pyr
import nibabel                           as nib
import nibabel.freesurfer.mghformat      as fsmgh
from   functools                    import reduce

if six.PY2: (_tuple_type, _list_type) = (types.TupleType, types.ListType)
else:       (_tuple_type, _list_type) = (tuple, list)

# Used by functions that pass arguments on to the isclose and related functions
try:              default_rtol = inspect.getargspec(np.isclose)[3][0]
except Exception: default_rtol = 1e-5
try:              default_atol = inspect.getargspec(np.isclose)[3][1]
except Exception: default_atol = 1e-8

# A few functions were moved into pimms; they still appear here for compatibility
from pimms import (is_tuple, is_list, is_set, curry)

def to_hemi_str(s):
    '''
    to_hemi_str(s) yields either 'lh', 'rh', or 'lr' depending on the input s.

    The match rules for s are as follows:
      * if s is None or Ellipsis, returns 'lr'
      * if s is not a string, error; otherwise s becomes s.lower()
      * if s is in ('lh','rh','lr'), returns s
      * if s is in ('left', 'l', 'sh'), returns 'lh'
      * if s is in ('right', 'r', 'dh'), returns 'rh'
      * if s in in ('both', 'all', 'xh'), returns 'lr'
{'fraction_non_alphanumeric': 0.14904270986745213, 'fraction_numerical': 0.004123711340206186, 'mean_word_length': 2.802911534154535, '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': '1645612', 'n_tokens_mistral': 1014, 'n_tokens_neox': 975, 'n_words': 385}