diff --git a/tests/netedit/viewPositions.py b/tests/netedit/viewPositions.py index c7cc985e9a05..9f48511323dc 100644 --- a/tests/netedit/viewPositions.py +++ b/tests/netedit/viewPositions.py @@ -45,6 +45,7 @@ class externLaneTop: x = 42 y = 136 + class overlappedTest: x = 500 y = 218 diff --git a/tools/assign/duaIterate_routeCosts.py b/tools/assign/duaIterate_routeCosts.py index 35bb0c577ba1..85a10b56b05c 100755 --- a/tools/assign/duaIterate_routeCosts.py +++ b/tools/assign/duaIterate_routeCosts.py @@ -34,9 +34,9 @@ >>> import duaIterate_routeCosts as rc >>> r = rc.load('.', range(47, 50)) # load iteration numbers 47,48,49 >>> f = rc.filter(r, via=['531478184','25483415']) # filter routes that pass both edges -47 Costs: count 1124, min 896.14 (126868_8), max 1960.17 (225725_1), mean 1355.41, Q1 1257.53, median 1325.86, Q3 1434.97 -48 Costs: count 1124, min 896.47 (126868_8.1), max 1993.74 (225725_1), mean 1355.02, Q1 1257.32, median 1323.68, Q3 1434.09 -49 Costs: count 1124, min 898.51 (126868_8.1), max 1958.68 (225725_1), mean 1355.00, Q1 1257.93, median 1323.39, Q3 1434.92 +47 Costs: count 1124, min 896.14 (veh0), max 1960.17 (veh1), mean 1355.41, Q1 1257.53, median 1325.86, Q3 1434.97 +48 Costs: count 1124, min 896.47 (veh0), max 1993.74 (veh2), mean 1355.02, Q1 1257.32, median 1323.68, Q3 1434.09 +49 Costs: count 1124, min 898.51 (veh3), max 1958.68 (veh1), mean 1355.00, Q1 1257.93, median 1323.39, Q3 1434.92 Implementation Note: edgeIDs are mapped to numbers in a numpy array to conserve memory @@ -72,7 +72,7 @@ def hasSequence(array, via): i = npindex(array, via[0]) for edge in via[1:]: i = npindex(array, edge) - if i == None: + if i is None: return False return True @@ -92,7 +92,6 @@ def numberToString(n): def load(baseDir, iterations, suffix="gz"): """iterations is an iterable that gives the iteration numberes to load """ - iteration = set(iterations) result = [] files = glob.glob(os.path.join(baseDir, "**/*.rou.alt.%s" % suffix)) files = [(int(os.path.basename(os.path.dirname(f))), f) for f in files] @@ -152,7 +151,7 @@ def filter(stepRoutes, origin=None, dest=None, via=None, forbidden=None, cutVia= iStart = 0 iEnd = iStart elif dest: - iEnd = edges.size - 1 + iEnd = r.edges.size - 1 else: iEnd = iStart else: diff --git a/tools/build_config/schemaCheck.py b/tools/build_config/schemaCheck.py index aef9207ae5b8..52a7448f9397 100755 --- a/tools/build_config/schemaCheck.py +++ b/tools/build_config/schemaCheck.py @@ -68,7 +68,7 @@ def validate(root, f): print(normalized + s, file=sys.stderr) except Exception as e: print("Error on parsing '%s'!" % normalized, file=sys.stderr) - if haveLxml and type(e) == etree.XMLSyntaxError: + if haveLxml and type(e) is etree.XMLSyntaxError: # we expect to encounter such errors and don't need a full strack trace print(e, file=sys.stderr) else: diff --git a/tools/randomTrips.py b/tools/randomTrips.py index 0763c38a9b88..7c93c0bb51b2 100755 --- a/tools/randomTrips.py +++ b/tools/randomTrips.py @@ -756,7 +756,8 @@ def generate_one_flow(label, combined_attrs, departureTime, arrivalTime, period, fouttrips.write((' \n') % ( label, departureTime, arrivalTime, intIfPossible(period * options.flows), combined_attrs)) - def generate_one_personflow(label, combined_attrs, attrFrom, attrTo, arrivalPos, departureTime, arrivalTime, period, options, timeIdx): + def generate_one_personflow(label, combined_attrs, attrFrom, attrTo, arrivalPos, + departureTime, arrivalTime, period, options, timeIdx): if len(options.period) > 1: label = label + "#%s" % timeIdx if options.binomial: diff --git a/tools/routeSampler.py b/tools/routeSampler.py index db6c51deb44c..3a244e8c73b4 100755 --- a/tools/routeSampler.py +++ b/tools/routeSampler.py @@ -248,13 +248,6 @@ def sample(self, rng, n, begin, end): scale = right - left r = [left + v * scale for v in rng.random(n)] - #print("cdf_x", self.cdf_x) - #print("cdf_y", self.cdf_y) - #print("begin", begin, "end", end) - #print("icdf_x", icdf_x) - #print("icdf_y", icdf_y) - #print("scale", scale, "left", left, "right", right) - # evaluate icdf return np.interp(r, icdf_x, icdf_y) @@ -803,6 +796,7 @@ def initTotalCounts(options, routes, intervals, b, e): " or match the number of data intervals (%s)" % len(intervals)) sys.exit() + def main(options): rng = np.random.RandomState(options.seed) diff --git a/tools/sumolib/miscutils.py b/tools/sumolib/miscutils.py index 2256dd14d00d..77de0bc3420b 100644 --- a/tools/sumolib/miscutils.py +++ b/tools/sumolib/miscutils.py @@ -40,19 +40,21 @@ _BLACKLIST = type, ModuleType, FunctionType + + def get_size(obj): """sum size of object & members. lifted from https://stackoverflow.com/a/30316760 """ if isinstance(obj, (_BLACKLIST)): - raise TypeError('getsize() does not take argument of type: '+ str(type(obj))) + raise TypeError('getsize() does not take argument of type: ' + str(type(obj))) seen_ids = set() size = 0 objects = [obj] while objects: need_referents = [] for obj in objects: - if not isinstance(obj, BLACKLIST) and id(obj) not in seen_ids: + if not isinstance(obj, _BLACKLIST) and id(obj) not in seen_ids: seen_ids.add(id(obj)) size += sys.getsizeof(obj) need_referents.append(obj) @@ -76,6 +78,7 @@ def benchmark_wrapper(*args, **kwargs): return result return benchmark_wrapper + class Benchmarker: """ class for benchmarking a function using a "with"-statement. @@ -95,6 +98,7 @@ def __exit__(self, *args): duration = time.time() - self.started print("%s finished after %s" % (self.description, humanReadableTime(duration))) + class working_dir: """ temporarily change working directory using 'with' statement @@ -384,5 +388,3 @@ def short_names(filenames, noEmpty): base = os.path.basename(prefix) shortened = [base + f for f in shortened] return shortened - - diff --git a/tools/visualization/plotXMLAttributes.py b/tools/visualization/plotXMLAttributes.py index ea81ea980f3e..ab8e130d36db 100755 --- a/tools/visualization/plotXMLAttributes.py +++ b/tools/visualization/plotXMLAttributes.py @@ -25,9 +25,11 @@ @INDEX: the index of the other value within the input file is used. @RANK: the index of the other value within the sorted (descending) list of values is used @COUNT: the number of occurrences of the other value is used. - Together with option --barplot or -hbarplot this gives a histogram. Binning size can be set via options --xbin and --ybin. + Together with option --barplot or -hbarplot this gives a histogram. + Binning size can be set via options --xbin and --ybin. @DENSITY: the number of occurrences of the other value is used, normalized by the total number of values. - @BOX: one or more box plots of the other value are drawn. The --idattr is used for grouping and there will be one box plot per id + @BOX: one or more box plots of the other value are drawn. + The --idattr is used for grouping and there will be one box plot per id @FILE: the (shortened) input file name is used (useful when plotting one value per file) Individual trajectories can be clicked in interactive mode to print the data Id on the console. @@ -220,6 +222,7 @@ def onpick(event): mevent = event.mouseevent print("dataID=%s x=%d y=%d" % (event.artist.get_label(), mevent.xdata, mevent.ydata)) + def makeSplitter(splitx, otherIsIndex, ds_fun): def splitter(file): for dataID, x, y in ds_fun(file): @@ -235,9 +238,9 @@ def splitter(file): yield dataID, i, y2 else: yield dataID, x, y2 - return splitter + def getDataStream(options): # determine elements and nesting for the given attributes # by reading from the first file diff --git a/tools/xml/xml2csv.py b/tools/xml/xml2csv.py index 5711d9371703..a358c316e091 100755 --- a/tools/xml/xml2csv.py +++ b/tools/xml/xml2csv.py @@ -129,7 +129,7 @@ def startElement(self, name, attrs): return # collect attributes for a in sorted(list(attrs.keys())): - if self.keepAttrs is not None and not a in self.keepAttrs: + if self.keepAttrs is not None and a not in self.keepAttrs: continue if a not in self.tagAttrs[name] and ":" not in a: self.tagAttrs[name][a] = xsd.XmlAttribute(a)