<commit_before>"""Methods for reading files.
"""

import numpy as np

def read_timeseries(inputfns, importer, **kwargs):
    """Read a list of input files using io tools and stack them into a 3d array.
  
    Parameters
    ----------
    inputfns : list
        List of input files returned by any function implemented in archive.
    importer : function
        Any function implemented in importers.
    kwargs : dict
        Optional keyword arguments for the importer.
    
    Returns
    -------
    out : tuple
        A three-element tuple containing the precipitation fields read, the quality field,
        and associated metadata.
    """
    R = []
    Q = []
    for ifn in inputfns[0]:
        R_, Q_, metadata = importer(ifn, **kwargs)
        R.append(R_)
        Q.append(Q_)
        
    R = np.concatenate([R_[None, :, :] for R_ in R])    
    Q = np.concatenate([Q_[None, :, :] for Q_ in Q])    

    return R, Q, metadata<commit_msg>Q passed as list<commit_after>"""Methods for reading files.
"""

import numpy as np

def read_timeseries(inputfns, importer, **kwargs):
    """Read a list of input files using io tools and stack them into a 3d array.
  
    Parameters
    ----------
    inputfns : list
        List of input files returned by any function implemented in archive.
    importer : function
        Any function implemented in importers.
    kwargs : dict
        Optional keyword arguments for the importer.
    
    Returns
    -------
    out : tuple
        A three-element tuple containing the precipitation fields read, the quality field,
        and associated metadata.
    """
    R = []
    Q = []
    for ifn in inputfns[0]:
        R_, Q_, metadata = importer(ifn, **kwargs)
        R.append(R_)
        Q.append(Q_)
        
    R = np.concatenate([R_[None, :, :] for R_ in R])      
    #TODO: Q should be organized as R, but this is not trivial as Q_ can be also None or a scalar

    return R, Q, metadata
{'fraction_non_alphanumeric': 0.09867075664621677, 'fraction_numerical': 0.002044989775051125, 'mean_word_length': 2.1412520064205456, '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': '620961', 'n_tokens_mistral': 563, 'n_tokens_neox': 554, 'n_words': 223}