This file is indexed.

/usr/lib/python2.7/dist-packages/Globs/statistics.py is in globs 0.2.0~svn50-4ubuntu1.

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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
## statistics.py
##
## GL O.B.S.: GL Open Benchmark Suite
## Copyright (C) 2006-2007 Angelo Theodorou <encelo@users.sourceforge.net>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
##

import array as a

try:
	import numpy as n
except ImportError:
	with_numpy = False # NumPy is not installed!
else:
	with_numpy = True


class Statistics_Numpy:
	"""Statistics class, Numpy version"""
	def __init__(self, names):
		self.chunk = 100 # Preallocation chunk size
		self.__arrays = {}
		self.__sizes = {}
		self.__max = {}
		self.__min = {}
		for name in names:
			self.__arrays[name] = n.array(n.zeros(self.chunk))
			self.__sizes[name] = 0
			self.__max[name] = None
			self.__min[name] = None


	def __getitem__(self, key):
		"""Return the results array of the selected benchmark"""
		try:
			size = self.__sizes[key]
			array = self.__arrays[key][:size]
			return array
		except KeyError:
			return None


	def __len__(self):
		"""Return the number of available benchmarks arrays"""
		return len(self.__arrays)


	def append(self, value, name):
		"""Append a value in the selected array"""
		if name not in self.__arrays:
			print(name + " " + _("doesn't exist!"))
			return None

		size = self.__sizes[name]
		array = self.__arrays[name]
		if size == len(array):
			self.__arrays[name] = n.concatenate([array, n.zeros(self.chunk)])
		self.__arrays[name][size] = value
		self.__sizes[name] += 1

		if value > self.__max[name] or self.__max[name] == None:
			self.__max[name] = value
		if value < self.__min[name] or self.__min[name] == None:
			self.__min[name] = value


	def clear(self, name):
		"""Erase the selected array"""
		try:
			self.__arrays[name] = n.array(n.zeros(self.chunk))
			self.__sizes[name] = 0
			self.__max[name] = None
			self.__min[name] = None
		except KeyError:
			print(name + " " + _("doesn't exist!"))


	def get_array(self, name, tail=0):
		"""Return the selected array, optionally just a tail of it"""
		if name not in self.__arrays:
			return None

		size = self.__sizes[name]
		array = self.__arrays[name][:size]
		if slice == 0:
			return array
		else:
			return array[-tail:]


	def get_last(self, name):
		"""Return the last value in the selected array
		   It is similar (but not the same!) to get_array(name, slice=1)"""
		if name not in self.__arrays:
			return None

		size = self.__sizes[name]
		array = self.__arrays[name][:size]
		if size == 0: # Empty array
			return None
		else:
			return array[len(array)-1]


	def get_min(self, name):
		"""Return the minimum value in the selected array"""
		try:
			return self.__min[name]
		except KeyError:
			return None


	def get_max(self, name):
		"""Return the maximum value in the selected array"""
		try:
			return self.__max[name]
		except KeyError:
			return None


	def get_avg(self, name):
		"""Return the average value in the selected array"""
		try:
			size = self.__sizes[name]
			array = self.__arrays[name][:size]
			return n.sum(array)/size
		except ZeroDivisionError:
			return 0
		except KeyError:
			return None


class Statistics_Array:
	"""Statistics class, built-in array module version"""
	def __init__(self, names):
		self.__arrays = {}
		self.__min = {}
		self.__max = {}
		for name in names:
			self.__arrays[name] = a.array('f')
			self.__max[name] = None
			self.__min[name] = None


	def __getitem__(self, key):
		"""Return the results array of the selected benchmark"""
		try:
			return self.__arrays[key].tolist()
		except KeyError:
			return None


	def __len__(self):
		"""Return the number of available benchmarks arrays"""
		return len(self.__arrays)


	def append(self, value, name):
		"""Append a value in the selected array"""
		try:
			self.__arrays[name].append(value)
			if value > self.__max[name] or self.__max[name] == None:
				self.__max[name] = value
			if value < self.__min[name] or self.__min[name] == None:
				self.__min[name] = value
		except KeyError:
			print(name + " " + _("doesn't exist!"))
			return None


	def clear(self, name):
		"""Erase the selected array"""
		try:
			del self.__arrays[name][:]
			self.__max[name] = None
			self.__min[name] = None
		except KeyError:
			print(name + " " + _("doesn't exist!"))


	def get_array(self, name, tail=0):
		"""Return the selected array, optionally just a tail of it"""
		if name not in self.__arrays:
			return None

		array = self.__arrays[name]
		if tail == 0:
			return array.tolist()
		else:
			return array[-tail:].tolist()


	def get_last(self, name):
		"""Return the last value in the selected array
		   It is similar (but not the same!) to get_array(name, slice=1)"""
		if name not in self.__arrays:
			return None

		array = self.__arrays[name]
		try:
			return array[len(array)-1]
		except IndexError: # Empty array
			return None


	def get_min(self, name):
		"""Return the minimum value in the selected array"""
		try:
			return self.__min[name]
		except KeyError:
			return None


	def get_max(self, name):
		"""Return the maximum value in the selected array"""
		try:
			return self.__max[name]
		except KeyError:
			return None


	def get_avg(self, name):
		"""Return the average value in the selected array"""
		if name not in self.__arrays:
			return None

		array = self.__arrays[name]
		try:
			avg = sum(array) / len(array)
		except ZeroDivisionError:
			avg = 0

		return avg


if with_numpy == True:
	Statistics = Statistics_Numpy
else:
	Statistics = Statistics_Array