This file is indexed.

/usr/share/doc/python-tables-doc/bench/recarray2-test.py is in python-tables-doc 3.2.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
from __future__ import print_function
import os
import sys
import time
import numpy as np
import chararray
import recarray
import recarray2  # This is my modified version

usage = """usage: %s recordlength
     Set recordlength to 1000 at least to obtain decent figures!
""" % sys.argv[0]

try:
    reclen = int(sys.argv[1])
except:
    print(usage)
    sys.exit()

delta = 0.000001

# Creation of recarrays objects for test
x1 = np.array(np.arange(reclen))
x2 = chararray.array(None, itemsize=7, shape=reclen)
x3 = np.array(np.arange(reclen, reclen * 3, 2), np.Float64)
r1 = recarray.fromarrays([x1, x2, x3], names='a,b,c')
r2 = recarray2.fromarrays([x1, x2, x3], names='a,b,c')

print("recarray shape in test ==>", r2.shape)

print("Assignment in recarray original")
print("-------------------------------")
t1 = time.clock()
for row in range(reclen):
    #r1.field("b")[row] = "changed"
    r1.field("c")[row] = float(row ** 2)
t2 = time.clock()
origtime = round(t2 - t1, 3)
print("Assign time:", origtime, " Rows/s:", int(reclen / (origtime + delta)))
# print "Field b on row 2 after re-assign:", r1.field("c")[2]
print()

print("Assignment in recarray modified")
print("-------------------------------")
t1 = time.clock()
for row in range(reclen):
    rec = r2._row(row)  # select the row to be changed
    # rec.b = "changed"      # change the "b" field
    rec.c = float(row ** 2)  # Change the "c" field
t2 = time.clock()
ttime = round(t2 - t1, 3)
print("Assign time:", ttime, " Rows/s:", int(reclen / (ttime + delta)),
      end=' ')
print(" Speed-up:", round(origtime / ttime, 3))
# print "Field b on row 2 after re-assign:", r2.field("c")[2]
print()

print("Selection in recarray original")
print("------------------------------")
t1 = time.clock()
for row in range(reclen):
    rec = r1[row]
    if rec.field("a") < 3:
        print("This record pass the cut ==>", rec.field("c"), "(row", row, ")")
t2 = time.clock()
origtime = round(t2 - t1, 3)
print("Select time:", origtime, " Rows/s:", int(reclen / (origtime + delta)))
print()

print("Selection in recarray modified")
print("------------------------------")
t1 = time.clock()
for row in range(reclen):
    rec = r2._row(row)
    if rec.a < 3:
        print("This record pass the cut ==>", rec.c, "(row", row, ")")
t2 = time.clock()
ttime = round(t2 - t1, 3)
print("Select time:", ttime, " Rows/s:", int(reclen / (ttime + delta)),
      end=' ')
print(" Speed-up:", round(origtime / ttime, 3))
print()

print("Printing in recarray original")
print("------------------------------")
f = open("test.out", "w")
t1 = time.clock()
f.write(str(r1))
t2 = time.clock()
origtime = round(t2 - t1, 3)
f.close()
os.unlink("test.out")
print("Print time:", origtime, " Rows/s:", int(reclen / (origtime + delta)))
print()
print("Printing in recarray modified")
print("------------------------------")
f = open("test2.out", "w")
t1 = time.clock()
f.write(str(r2))
t2 = time.clock()
ttime = round(t2 - t1, 3)
f.close()
os.unlink("test2.out")
print("Print time:", ttime, " Rows/s:", int(reclen / (ttime + delta)), end=' ')
print(" Speed-up:", round(origtime / ttime, 3))
print()