Index: lnt/trunk/lnt/external/stats/pstat.py =================================================================== --- lnt/trunk/lnt/external/stats/pstat.py +++ lnt/trunk/lnt/external/stats/pstat.py @@ -281,8 +281,7 @@ return means else: values = colex(listoflists,keepcols) - uniques = unique(values) - uniques.sort() + uniques = sorted(unique(values)) newlist = [] if not isinstance(keepcols, (list, tuple)): keepcols = [keepcols] for item in uniques: @@ -646,8 +645,7 @@ Usage: sortby(listoflists,sortcols) Returns: sorted list, unchanged column ordering """ - newlist = abut(colex(listoflists,sortcols),listoflists) - newlist.sort() + newlist = sorted(abut(colex(listoflists, sortcols), listoflists)) try: numcols = len(sortcols) except TypeError: @@ -807,8 +805,7 @@ if not isinstance(keepcols, (list, tuple, N.ndarray)): keepcols = [keepcols] values = colex(a,keepcols) # so that "item" can be appended (below) - uniques = unique(values) # get a LIST, so .sort keeps rows intact - uniques.sort() + uniques = sorted(unique(values)) # get a LIST, so .sort keeps rows intact newlist = [] for item in uniques: if not isinstance(item, (list, tuple, N.ndarray)): Index: lnt/trunk/lnt/external/stats/stats.py =================================================================== --- lnt/trunk/lnt/external/stats/stats.py +++ lnt/trunk/lnt/external/stats/stats.py @@ -337,8 +337,7 @@ Usage: lmedianscore(inlist) """ - newlist = copy.deepcopy(inlist) - newlist.sort() + newlist = sorted(copy.deepcopy(inlist)) if len(newlist) % 2 == 0: # if even number of scores, average middle 2 index = len(newlist)/2 # integer division correct median = float(newlist[index] + newlist[index-1]) /2 @@ -358,8 +357,7 @@ Returns: bin-count for mode(s), a list of modal value(s) """ - scores = pstat.unique(inlist) - scores.sort() + scores = sorted(pstat.unique(inlist)) freq = [] for item in scores: freq.append(inlist.count(item)) @@ -458,8 +456,7 @@ Usage: litemfreq(inlist) Returns: a 2D frequency table (col [0:n-1]=scores, col n=frequencies) """ - scores = pstat.unique(inlist) - scores.sort() + scores = sorted(pstat.unique(inlist)) freq = [] for item in scores: freq.append(inlist.count(item)) @@ -2028,9 +2025,7 @@ shp[dimension] = 1 sum = N.reshape(sum,shp) else: # must be a SEQUENCE of dims to average over - dims = list(dimension) - dims.sort() - dims.reverse() + dims = sorted(dimension, reverse=True) size = N.array(N.multiply.reduce(N.take(inarray.shape,dims)),N.float_) mult = N.power(inarray,1.0/size) for dim in dims: @@ -2069,8 +2064,7 @@ shp[dimension] = 1 s = N.reshape(s,shp) else: # must be a SEQUENCE of dims to average over - dims = list(dimension) - dims.sort() + dims = sorted(dimension) nondims = [] for i in range(len(inarray.shape)): if i not in dims: @@ -2124,9 +2118,7 @@ shp[dimension] = 1 sum = N.reshape(sum,shp) else: # must be a TUPLE of dims to average over - dims = list(dimension) - dims.sort() - dims.reverse() + dims = sorted(dimension, reverse=True) sum = inarray *1.0 for dim in dims: sum = N.add.reduce(sum,dim) @@ -4165,9 +4157,7 @@ shp[dimension] = 1 s = N.reshape(s,shp) else: # must be a SEQUENCE of dims to sum over - dims = list(dimension) - dims.sort() - dims.reverse() + dims = sorted(dimension, reverse=True) s = a *1.0 for dim in dims: s = N.add.reduce(s,dim) @@ -4192,9 +4182,7 @@ a = N.ravel(a) dimension = 0 if isinstance(dimension, (list, tuple, N.ndarray)): - dimension = list(dimension) - dimension.sort() - dimension.reverse() + dimension = sorted(dimension, reverse=True) for d in dimension: a = N.add.accumulate(a,d) return a Index: lnt/trunk/lnt/server/db/testsuitedb.py =================================================================== --- lnt/trunk/lnt/server/db/testsuitedb.py +++ lnt/trunk/lnt/server/db/testsuitedb.py @@ -904,11 +904,8 @@ session.add(order) session.commit() - # Load all the orders. - orders = list(session.query(self.Order)) - - # Sort the objects to form the total ordering. - orders.sort() + # Load all the orders and sort them to form the total ordering. + orders = sorted(session.query(self.Order)) # Find the order we just added. index = orders.index(order) @@ -1128,10 +1125,13 @@ # # FIXME: Scalability! However, pretty fast in practice, see elaborate # explanation above. - all_machine_orders = session.query(self.Order).\ - join(self.Run).\ - filter(self.Run.machine == run.machine).distinct().all() - all_machine_orders.sort() + all_machine_orders = sorted( + session.query(self.Order) + .join(self.Run) + .filter(self.Run.machine == run.machine) + .distinct() + .all() + ) # Find the index of the current run. index = all_machine_orders.index(run.order) Index: lnt/trunk/lnt/server/ui/util.py =================================================================== --- lnt/trunk/lnt/server/ui/util.py +++ lnt/trunk/lnt/server/ui/util.py @@ -74,8 +74,7 @@ def median(values): - values = list(values) - values.sort() + values = sorted(values) N = len(values) return (values[(N - 1) // 2] + values[(N + 0) // 2]) * .5 Index: lnt/trunk/lnt/server/ui/views.py =================================================================== --- lnt/trunk/lnt/server/ui/views.py +++ lnt/trunk/lnt/server/ui/views.py @@ -305,8 +305,7 @@ .join(ts.Order) .filter(ts.Run.machine_id == id) .order_by(ts.Run.start_time.desc()))) - associated_runs = associated_runs.items() - associated_runs.sort() + associated_runs = sorted(associated_runs.items()) try: machine = session.query(ts.Machine).filter(ts.Machine.id == id).one() @@ -658,11 +657,8 @@ session = request.session ts = request.get_testsuite() - # Get the orders. - orders = session.query(ts.Order).all() - - # Order the runs totally. - orders.sort() + # Get the orders and sort them totally. + orders = sorted(session.query(ts.Order).all()) return render_template("v4_all_orders.html", orders=orders, **ts_data(ts)) Index: lnt/trunk/lnt/util/stats.py =================================================================== --- lnt/trunk/lnt/util/stats.py +++ lnt/trunk/lnt/util/stats.py @@ -54,8 +54,7 @@ def median(values): if not values: return None - values = list(values) - values.sort() + values = sorted(values) N = len(values) return (values[(N - 1) // 2] + values[N // 2]) * .5 Index: lnt/trunk/lnt/util/wsgi_restart.py =================================================================== --- lnt/trunk/lnt/util/wsgi_restart.py +++ lnt/trunk/lnt/util/wsgi_restart.py @@ -58,7 +58,7 @@ def _monitor(): - while 1: + while True: # Check modification times on all files in sys.modules. for module in sys.modules.values():