diff --git a/src/napari_matplotlib/histogram.py b/src/napari_matplotlib/histogram.py index cf677bea..0a49dc41 100644 --- a/src/napari_matplotlib/histogram.py +++ b/src/napari_matplotlib/histogram.py @@ -162,7 +162,6 @@ def on_update_layers(self) -> None: def draw(self) -> None: """Clear the axes and histogram the currently selected layer/slice.""" - # get the colormap from the layer depending on its type if isinstance(self.layers[0], napari.layers.Points): colormap = self.layers[0].face_colormap @@ -183,16 +182,18 @@ def draw(self) -> None: if data is None: return - _, bins, patches = self.axes.hist(data, bins=50, edgecolor="white", linewidth=0.3) + _, bins, patches = self.axes.hist( + data, bins=50, edgecolor="white", linewidth=0.3 + ) # recolor the histogram plot if colormap is not None: - self.bins_norm = (bins - bins.min())/(bins.max() - bins.min()) + self.bins_norm = (bins - bins.min()) / (bins.max() - bins.min()) colors = colormap.map(self.bins_norm) # Set histogram style: for idx, patch in enumerate(patches): - patch.set_facecolor(colors[idx]) + patch.set_facecolor(colors[idx]) # set ax labels self.axes.set_xlabel(x_axis_name) diff --git a/src/napari_matplotlib/tests/test_histogram.py b/src/napari_matplotlib/tests/test_histogram.py index 534d7952..e71fea2a 100644 --- a/src/napari_matplotlib/tests/test_histogram.py +++ b/src/napari_matplotlib/tests/test_histogram.py @@ -36,7 +36,6 @@ def test_histogram_3D(make_napari_viewer, brain_data): def test_feature_histogram(make_napari_viewer): - n_points = 1000 random_points = np.random.random((n_points, 3)) * 10 random_directions = np.random.random((n_points, 3)) * 10 @@ -74,7 +73,6 @@ def test_feature_histogram(make_napari_viewer): @pytest.mark.mpl_image_compare def test_feature_histogram_vectors(make_napari_viewer): - n_points = 1000 np.random.seed(42) random_points = np.random.random((n_points, 3)) * 10 @@ -99,7 +97,6 @@ def test_feature_histogram_vectors(make_napari_viewer): @pytest.mark.mpl_image_compare def test_feature_histogram_points(make_napari_viewer): - np.random.seed(0) n_points = 1000 random_points = np.random.random((n_points, 3)) * 10 @@ -143,6 +140,7 @@ def test_change_layer(make_napari_viewer, brain_data, astronaut_data): assert_figures_not_equal(widget.figure, fig1) -if __name__ == '__main__': +if __name__ == "__main__": import napari - test_feature_histogram_points(napari.Viewer) \ No newline at end of file + + test_feature_histogram_points(napari.Viewer)