<commit_before>class SorterArray(object):
    """
    Base class for storing data to be sorted.  
    """
    def __init__(self, data):
        pass
    def set_data(self, data):
        pass
    def append_data(self, data):
        pass
    def get_data(self):
        pass
    def get_range(self, beginIdx, endIdx):
        pass
    def del_data(self):
        pass
    def del_range(self, beginIndex, endIndex):
        pass
    def del_indexed(self, index)
        pass


class Sorter(SorterArray): 
    """ 
    Class that defines the basic functionality of SorterDist for
    serial sorting.
    """
    def __init__(self, data=None, comp=None):
        pass
    def set_comp(self, comp):
        pass
    def get_sorted(self):
        pass
    def get_sequence(self, beginEl, endEl):
        pass
    def get_sequence_fixed(self, beginEl, numEl):
        pass
    def get_sequence_multi(self, rangeList):
        pass
    def return_permutation(self, doIt=True):
        pass
    def store_permuation(self, doIt=True):
        pass
    def sort_in_place(self, doIt=True):
        pass

class Compare(object):
    """
    Abstract base class for determining how to compare two objects.
    This object will facilitate the use of native comparisons in C++
    for Python objects.  The implementation of this class depends on
    how BOOST integrates C++ and Python

    NumPy's array sorter gives a working model for complex objects.
    """
    pass

class SorterThread(Sorter):
    """
    Shared memory sorting for Python users through binding to C++
    library.  
    """
    def __init__(self, data=None, comp=None, numThr=1):
        pass
    def set_num_threads(self):
        pass
    def get_sorted(self):
        pass
    def get_sequence(self, beginEl, endEl):
        pass
    def get_sequence_multi(self, rangeList):
        pass
    def get_sequence_fixed(self, beginEl, numEl):
        pass


class SorterDist(Sorter):
    """
    Abstract base class for distributed memory sorting
    """
    def init_session(self, comm, sessionID):
        pass
    def kill_session(self, comm, sessionID):
        pass
    def get_sorted(self):
        pass
    def get_sequence(self, beginEl, endEl)
        pass
    def get_sequence_multi(self, rangeList):
        pass
    def get_sequence_fixed(self, beginEl, numEl):
        pass

class SorterDistMPI(SorterDist):
    """
    MPI parallel sorter will be implemented in C++ for tightly coupled
    applications.
    """
    pass

class SorterDistAMQP(SorterDist):
    """
    Python class for loosely coupled distributed computing with AMQP
    library.
    """
    pass

class SorterDistCURL(SorterDist):
    """
    Python class for loosely coupled distributed computing with cURL
    """
    pass

class SorterDistNice(SorterDist):
    """
    Python class for doing sort in background in anticipation of
    needing the result in the future.  The class will stage result on
    local disk and use network only as it becomes available.
    """<commit_msg>Sorter is now derived from list and the interface is cleaned up<commit_after>class Sorter(list): 
    """ 
    Class that defines the basic functionality of SorterDist for
    serial sorting.  We are deriving from list so sort() is built
    in.  
    """
    def __init__(self, data=None, comp=None):
        list.__init__(self, data)
        self._comp = comp
    def sorted(self):
        return sorted(self)
    def sorted_permutation(self):
        return sorted(range(len(self)), key = self.__getitem__)
    def sorted_sequence(self, bounds):
        ss = self.sorted()
        if type(bounds[0]) == list:
            result = [ss[ss.index(bb[0]) : ss.index(bb[1]) + 1] for bb in bounds]
            return result
        return ss[ss.index(range[0]):ss.index(range[1])]
    def sorted_sequence_permutation(self, range):
        raise NotImplementedError()
    def set_comp(self, comp):
        raise NotImplementedError()


class Compare(object):
    """
    Abstract base class for determining how to compare two objects.
    This object will facilitate the use of native comparisons in C++
    for Python objects.  The implementation of this class depends on
    how BOOST integrates C++ and Python

    NumPy's array sorter gives a working model for complex objects.
    """
    pass

class SorterThread(Sorter):
    """
    Shared memory sorting for Python users through binding to C++
    library.  
    """
    def __init__(self, data=None, comp=None, numThr=1):
        pass
    def sort(self):
        pass
    def sorted(self):
        pass
    def sorted_permutation(self):
        pass
    def sorted_sequence(self, range):
        pass
    def sorted_sequence_permutation(self, rangeList):
        pass

class SorterDistSession(object):
    """
    Distributed sort will require setting up a communicator
    of some kind.  
    """
    def init_session(self, comm, sessionID):
        pass
    def kill_session(self, comm, sessionID):
        pass
    def attach_sorter(self, sorter):
        pass

class SorterDistMPI(Sorter):
    """
    MPI parallel sorter will be implemented in C++ for tightly coupled
    applications.
    """
    pass

class SorterDistAMQP(Sorter):
    """
    Python class for loosely coupled distributed computing with AMQP
    library.
    """
    pass

class SorterDistCURL(Sorter):
    """
    Python class for loosely coupled distributed computing with cURL
    """
    pass

class SorterDistNice(Sorter):
    """
    Python class for doing sort in background in anticipation of
    needing the result in the future.  The class will stage result on
    local disk and use network only as it becomes available.
    """
    pass

if __name__ == '__main__':
    import random
    dd = range(10)
    random.shuffle(dd)
    dd = Sorter(dd)
    print dd
    ss = dd.sorted()
    print ss
    ii = dd.sorted_permutation()
    print ii
    print [dd[i] for i in ii]
    bounds = [[0,3],[7,9]]
    print bounds
    ii = dd.sorted_sequence(bounds)
    print ii
{'fraction_non_alphanumeric': 0.0823920265780731, 'fraction_numerical': 0.002325581395348837, 'mean_word_length': 2.5924821002386635, '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': '1652706', 'n_tokens_mistral': 1782, 'n_tokens_neox': 1730, 'n_words': 596}