Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 4, 2023
1 parent 073613c commit 7179889
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/napari_matplotlib/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
8 changes: 3 additions & 5 deletions src/napari_matplotlib/tests/test_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

test_feature_histogram_points(napari.Viewer)

0 comments on commit 7179889

Please sign in to comment.