<commit_before>###############################################################################
# apogee.spec.stack: stack APOGEE spectra in various ways
###############################################################################
import numpy
def median(spec,mask=None):
    """
    NAME:
       median
    PURPOSE:
       median stack a set of spectra
    INPUT:
       spec - array of spectra (nspec,nwave)
       mask= (None) if set, use this mask (1/True for inclusion)
    OUTPUT:
       median spectrum
    HISTORY:
       2015-01-26 - Written - Bovy (IAS@KITP)
    """
    mask= mask.astype('bool')
    if mask is None:
        mask= True-numpy.isnan(spec)
    else:
        mask*= True-numpy.isnan(spec)
    
    out= numpy.zeros(spec.shape[1])+numpy.nan
    for ii in range(spec.shape[1]):
        out[ii]= numpy.median(spec[mask[:,ii],ii])
    return out<commit_msg>fix boolean casting<commit_after>###############################################################################
# apogee.spec.stack: stack APOGEE spectra in various ways
###############################################################################
import numpy
def median(spec,mask=None):
    """
    NAME:
       median
    PURPOSE:
       median stack a set of spectra
    INPUT:
       spec - array of spectra (nspec,nwave)
       mask= (None) if set, use this mask (1/True for inclusion)
    OUTPUT:
       median spectrum
    HISTORY:
       2015-01-26 - Written - Bovy (IAS@KITP)
    """
    if mask is None:
        mask= True-numpy.isnan(spec)
    else:
        mask= mask.astype('bool')
        mask*= True-numpy.isnan(spec)
    out= numpy.zeros(spec.shape[1])+numpy.nan
    for ii in range(spec.shape[1]):
        out[ii]= numpy.median(spec[mask[:,ii],ii])
    return out
{'fraction_non_alphanumeric': 0.27906976744186046, 'fraction_numerical': 0.012478729438457176, 'mean_word_length': 3.121495327102804, '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': '1959597', 'n_tokens_mistral': 545, 'n_tokens_neox': 514, 'n_words': 133}