@plac.annotations(n="Length of array to test sort with, defaults to 277")
def main(n=277):
    """Tests Copperhead radix sort in Python interpreter and on GPU."""
    def random_numbers(n, bits=8):
        import random
        return [np.int32(random.getrandbits(bits)) for i in xrange(n)]

    def test_sort(S, n=277, trials=50, bits=8):
        npass, nfail = 0,0
        name = S.__name__

        for i in xrange(trials):
            data_in  = random_numbers(n, bits)
            gold     = sorted(data_in)
            data_out = S(data_in)
            if list(gold) == list(data_out):
                npass = npass+1
            else:
                nfail = nfail+1

            print ((name, npass,nfail) % "%-20s passed [%2d]\tfailed [%2d]\r"),
        print

    print
    
    print "---- Checking Python implementations (n=277) ----"
    with places.here:
        test_sort(radix_sort8,    n=277)
   

    print "---- Checking GPU results (n=277) ----"
    with places.gpu0:
        test_sort(radix_sort8,    n=277)
dataset/ETHPy150Open bryancatanzaro/copperhead/samples/radix_sort.py/main/swapped operands of `%`