Index: lnt/external/stats/pstat.py =================================================================== --- lnt/external/stats/pstat.py +++ 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/external/stats/stats.py =================================================================== --- lnt/external/stats/stats.py +++ lnt/external/stats/stats.py @@ -336,8 +336,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 @@ -357,8 +356,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)) @@ -457,8 +455,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)) @@ -2027,8 +2024,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 = sorted(dimension) dims.reverse() size = N.array(N.multiply.reduce(N.take(inarray.shape,dims)),N.float_) mult = N.power(inarray,1.0/size) @@ -2068,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: @@ -2123,8 +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 = sorted(dimension) dims.reverse() sum = inarray *1.0 for dim in dims: @@ -4164,8 +4158,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 = sorted(dimension) dims.reverse() s = a *1.0 for dim in dims: @@ -4191,8 +4184,7 @@ a = N.ravel(a) dimension = 0 if isinstance(dimension, (list, tuple, N.ndarray)): - dimension = list(dimension) - dimension.sort() + dimension = sorted(dimension) dimension.reverse() for d in dimension: a = N.add.accumulate(a,d) Index: lnt/server/db/testsuitedb.py =================================================================== --- lnt/server/db/testsuitedb.py +++ lnt/server/db/testsuitedb.py @@ -903,11 +903,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) @@ -1127,10 +1124,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/server/ui/util.py =================================================================== --- lnt/server/ui/util.py +++ 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/server/ui/views.py =================================================================== --- lnt/server/ui/views.py +++ 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/util/stats.py =================================================================== --- lnt/util/stats.py +++ 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/util/wsgi_restart.py =================================================================== --- lnt/util/wsgi_restart.py +++ 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():