From ebe2fbdafad419c24f93506e31bf7913cedbee3f Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Thu, 2 Mar 2023 00:46:47 +0100 Subject: [PATCH] remove obsolete list and tuple call --- examples/add_labels_with_features.py | 2 +- napari/_qt/widgets/qt_color_swatch.py | 2 +- napari/_vispy/camera.py | 5 ++--- napari/layers/labels/_tests/test_labels.py | 2 +- napari/layers/points/_tests/test_points.py | 2 +- napari/layers/points/points.py | 4 ++-- napari/layers/shapes/_shape_list.py | 2 +- napari/layers/shapes/_tests/test_shapes.py | 2 +- napari/utils/theme.py | 6 +++--- 9 files changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/add_labels_with_features.py b/examples/add_labels_with_features.py index ee37a778377..1f45dbe989d 100644 --- a/examples/add_labels_with_features.py +++ b/examples/add_labels_with_features.py @@ -44,7 +44,7 @@ 'row': ['none'] + ['top'] * 4 + ['bottom'] * 4, # background is row: none - 'size': ["none", *list(coin_sizes)], # background is size: none + 'size': ["none", *coin_sizes], # background is size: none } color = {1: 'white', 2: 'blue', 3: 'green', 4: 'red', 5: 'yellow'} diff --git a/napari/_qt/widgets/qt_color_swatch.py b/napari/_qt/widgets/qt_color_swatch.py index 330b677c421..7f4fe2763f6 100644 --- a/napari/_qt/widgets/qt_color_swatch.py +++ b/napari/_qt/widgets/qt_color_swatch.py @@ -215,7 +215,7 @@ class QColorLineEdit(QLineEdit): def __init__(self, parent=None) -> None: super().__init__(parent) - self._compl = QCompleter([*list(get_color_dict()), "transparent"]) + self._compl = QCompleter([*get_color_dict(), "transparent"]) self._compl.setCompletionMode(QCompleter.InlineCompletion) self.setCompleter(self._compl) self.setTextMargins(2, 2, 2, 2) diff --git a/napari/_vispy/camera.py b/napari/_vispy/camera.py index 27dee4f2b7d..81a39f1235a 100644 --- a/napari/_vispy/camera.py +++ b/napari/_vispy/camera.py @@ -80,10 +80,9 @@ def center(self): center = tuple(self._view.camera.center) else: # in 2D, we arbitrarily choose 0.0 as the center in z - center = (*tuple(self._view.camera.center[:2]), 0.0) + center = (*self._view.camera.center[:2], 0.0) # switch from VisPy xyz ordering to NumPy prc ordering - center = center[::-1] - return center + return center[::-1] @center.setter def center(self, center): diff --git a/napari/layers/labels/_tests/test_labels.py b/napari/layers/labels/_tests/test_labels.py index 29299d90426..0d663019731 100644 --- a/napari/layers/labels/_tests/test_labels.py +++ b/napari/layers/labels/_tests/test_labels.py @@ -407,7 +407,7 @@ def test_custom_color_dict(): # Test to see if our label mapped control points map to those in the colormap # with an extra half step. local_controls = np.array( - sorted(np.unique([*list(layer._label_color_index.values()), 1.0])) + sorted(np.unique([*layer._label_color_index.values(), 1.0])) ) colormap_controls = np.array(layer._colormap.controls) assert np.max(np.abs(local_controls - colormap_controls)) == pytest.approx( diff --git a/napari/layers/points/_tests/test_points.py b/napari/layers/points/_tests/test_points.py index 2d7a533a501..fe1a24f7778 100644 --- a/napari/layers/points/_tests/test_points.py +++ b/napari/layers/points/_tests/test_points.py @@ -380,7 +380,7 @@ def test_removing_selected_points(): layer.remove_selected() assert len(layer.data) == shape[0] - 2 assert len(layer.selected_data) == 0 - keep = [1, 2, *list(range(4, 10))] + keep = [1, 2, *range(4, 10)] assert np.all(layer.data == data[keep]) assert layer._value is None diff --git a/napari/layers/points/points.py b/napari/layers/points/points.py index 8a948e8e430..df3182010f2 100644 --- a/napari/layers/points/points.py +++ b/napari/layers/points/points.py @@ -1807,7 +1807,7 @@ def _set_highlight(self, force=False): pos = _create_box_from_corners_3d( self._drag_box, self._drag_normal, self._drag_up ) - pos = pos[[*list(range(4)), 0]] + pos = pos[[*range(4), 0]] else: pos = None @@ -1852,7 +1852,7 @@ def _update_thumbnail(self): coords = np.clip(coords, 0, thumbnail_shape - 1) # Draw single pixel points in the colormapped thumbnail. - colormapped = np.zeros((*tuple(thumbnail_shape), 4)) + colormapped = np.zeros((*thumbnail_shape, 4)) colormapped[..., 3] = 1 colors = self._face.colors[thumbnail_indices] colormapped[coords[:, 0], coords[:, 1]] = colors diff --git a/napari/layers/shapes/_shape_list.py b/napari/layers/shapes/_shape_list.py index f8190437955..2ad1a8ecdbf 100644 --- a/napari/layers/shapes/_shape_list.py +++ b/napari/layers/shapes/_shape_list.py @@ -1228,7 +1228,7 @@ def to_colors( if colors_shape is None: colors_shape = self.displayed_vertices.max(axis=0).astype(int) - colors = np.zeros((*tuple(colors_shape), 4), dtype=float) + colors = np.zeros((*colors_shape, 4), dtype=float) colors[..., 3] = 1 z_order = self._z_order[::-1] diff --git a/napari/layers/shapes/_tests/test_shapes.py b/napari/layers/shapes/_tests/test_shapes.py index 44018aec566..da50141d108 100644 --- a/napari/layers/shapes/_tests/test_shapes.py +++ b/napari/layers/shapes/_tests/test_shapes.py @@ -1209,7 +1209,7 @@ def test_removing_selected_shapes(): # Select three shapes and remove them layer.selected_data = {1, 7, 8} layer.remove_selected() - keep = [0, *list(range(2, 7))] + [9] + keep = [0, *range(2, 7)] + [9] data_keep = [data[i] for i in keep] shape_type_keep = [shape_type[i] for i in keep] assert len(layer.data) == len(data_keep) diff --git a/napari/utils/theme.py b/napari/utils/theme.py index 48c7bcdaa6b..123fad2a510 100644 --- a/napari/utils/theme.py +++ b/napari/utils/theme.py @@ -4,7 +4,7 @@ import warnings from ast import literal_eval from contextlib import suppress -from typing import Union +from typing import List, Union import npe2 from pydantic import validator @@ -279,7 +279,7 @@ def unregister_theme(theme_id): _themes.pop(theme_id, None) -def available_themes(): +def available_themes() -> List[str]: """List available themes. Returns @@ -287,7 +287,7 @@ def available_themes(): list of str ids of available themes. """ - return (*tuple(_themes), 'system') + return [*_themes, 'system'] def is_theme_available(theme_id):