diff --git a/src/mlstatpy/graph/graph_distance.py b/src/mlstatpy/graph/graph_distance.py index 6076f8c..01defca 100644 --- a/src/mlstatpy/graph/graph_distance.py +++ b/src/mlstatpy/graph/graph_distance.py @@ -232,7 +232,7 @@ def load_from_file(filename, add_loop): def _private__init__(self, add_loop, weight_vertex, weight_edge): if add_loop: for k in self.vertices: - if k != self.labelBegin and k != self.labelEnd: + if k not in (self.labelBegin, self.labelEnd): self.edges[k, k] = Edge(k, k, "", weight_edge) self.connect_root_and_leave(weight_vertex, weight_edge) self.compute_predecessor() diff --git a/src/mlstatpy/image/detection_segment/detection_segment.py b/src/mlstatpy/image/detection_segment/detection_segment.py index a35ad6c..9e333da 100644 --- a/src/mlstatpy/image/detection_segment/detection_segment.py +++ b/src/mlstatpy/image/detection_segment/detection_segment.py @@ -285,7 +285,7 @@ def detect_segments(image, proba_bin=1.0 / 16, # on ajoute les resultats à la liste segment.extend(res) - if stop > 0 and len(segment) >= stop: + if len(segment) >= stop > 0: break else: not_aligned += 1 diff --git a/src/mlstatpy/ml/ml_grid_benchmark.py b/src/mlstatpy/ml/ml_grid_benchmark.py index 8a54e25..73f71b5 100644 --- a/src/mlstatpy/ml/ml_grid_benchmark.py +++ b/src/mlstatpy/ml/ml_grid_benchmark.py @@ -192,7 +192,7 @@ def graphs(self, path_to_images): @return list of tuple (image_name, function to create the graph) """ import matplotlib.pyplot as plt - import matplotlib.cm as cm + import matplotlib.cm as mcm df = self.to_df() def local_graph(vx, vy, ax=None, text=True, figsize=(5, 5)): @@ -200,7 +200,7 @@ def local_graph(vx, vy, ax=None, text=True, figsize=(5, 5)): ymin = df[vy].min() ymax = df[vy].max() decy = (ymax - ymin) / 50 - colors = cm.rainbow(numpy.linspace(0, 1, len(btrys))) + colors = mcm.rainbow(numpy.linspace(0, 1, len(btrys))) if len(btrys) == 0: raise ValueError("The benchmark is empty.") if ax is None: