<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
generic utilities for daily work

TODO
====
- collect here daily work utilities

"""

__author__ = "<NAME>"
__email__ = "<EMAIL>"
__license__ = "BSD license <http://opensource.org/licenses/BSD-3-Clause>"
__organization__ = "European Synchrotron Radiation Facility"
__year__ = "2014"
__version__ = "0.0.1"
__status__ = "in progress"
__date__ = "Aug 2014"

### IPython ###
def ipythonAutoreload():
    """ force ipython to autoreload imported modules """
    from IPython import get_ipython
    mgc = get_ipython().magic
    mgc(u'%load_ext autoreload')
    mgc(u'%autoreload 2')

### PyMca ###
def getPyMcaMain():
    """ show PyMcaMain from a shell (e.g. IPython) and return its obj """<commit_msg>imin/imax utils<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
generic utilities for daily work

TODO
====
- collect here daily work utilities

"""

import numpy as np

__author__ = "<NAME>"
__email__ = "<EMAIL>"
__license__ = "BSD license <http://opensource.org/licenses/BSD-3-Clause>"
__organization__ = "European Synchrotron Radiation Facility"
__year__ = "2014"
__version__ = "0.0.1"
__status__ = "in progress"
__date__ = "Aug 2014"

### Numpy ###
def imin(arr, check=False):
    """ index of minimum value """
    _im = np.argmin(arr)
    if check:
        print('Check: {0} = {1}'.format(np.min(arr), arr[_im]))
    return _im
        
def imax(arr, check=False):
    """ index of maximum value """
    _im = np.argmax(arr)
    if check:
        print('Check: {0} = {1}'.format(np.max(arr), arr[_im]))
    return _im
        
### IPython ###
def ipythonAutoreload():
    """ force ipython to autoreload imported modules """
    from IPython import get_ipython
    mgc = get_ipython().magic
    mgc(u'%load_ext autoreload')
    mgc(u'%autoreload 2')

### PyMca ###
def getPyMcaMain():
    """ show PyMcaMain from a shell (e.g. IPython) and return its obj """
{'fraction_non_alphanumeric': 0.15895061728395063, 'fraction_numerical': 0.01646090534979424, 'mean_word_length': 3.6867469879518073, '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': '7620856', 'n_tokens_mistral': 725, 'n_tokens_neox': 688, 'n_words': 182}