From 58ae986a19e8f1a64bef42bd80e03a61b54a44d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Fri, 1 Nov 2024 12:17:45 +0100 Subject: [PATCH] Remove extra *tuple and *list --- holoviews/element/graphs.py | 4 ++-- holoviews/element/raster.py | 2 +- holoviews/element/sankey.py | 2 +- holoviews/tests/core/data/test_imageinterface.py | 4 ++-- holoviews/tests/core/test_utils.py | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/holoviews/element/graphs.py b/holoviews/element/graphs.py index 4489a936ba..6d939b7834 100644 --- a/holoviews/element/graphs.py +++ b/holoviews/element/graphs.py @@ -63,7 +63,7 @@ def _process(self, element, key=None): for (s, t), w in zip(edges, element[weight]): graph.edges[s, t][weight] = w positions = self.p.layout(graph, **self.p.kwargs) - nodes = [(*tuple(pos), idx) for idx, pos in sorted(positions.items())] + nodes = [(*pos, idx) for idx, pos in sorted(positions.items())] else: source = element.dimension_values(0, expanded=False) target = element.dimension_values(1, expanded=False) @@ -455,7 +455,7 @@ def from_networkx(cls, G, positions, nodes=None, **kwargs): node_columns[idim.name].append(idx) node_cols = sorted([k for k in node_columns if k not in cls.node_type.kdims and len(node_columns[k]) == len(node_columns[xdim.name])]) - columns = [xdim.name, ydim.name, idim.name, *node_cols, *list(info_cols)] + columns = [xdim.name, ydim.name, idim.name, *node_cols, *info_cols] node_data = tuple(node_columns[col] for col in columns) # Construct nodes diff --git a/holoviews/element/raster.py b/holoviews/element/raster.py index e12d17b61d..9de00dce7b 100644 --- a/holoviews/element/raster.py +++ b/holoviews/element/raster.py @@ -333,7 +333,7 @@ def _validate(self, data_bounds, supplied_bounds): if yvals.ndim > 1: invalid.append(ydim) if invalid: - dims = '{} and {}'.format(*tuple(invalid)) if len(invalid) > 1 else f'{invalid[0]}' + dims = '{} and {}'.format(*invalid) if len(invalid) > 1 else f'{invalid[0]}' raise ValueError(f'{clsname} coordinates must be 1D arrays, ' f'{dims} dimension(s) were found to have ' 'multiple dimensions. Either supply 1D ' diff --git a/holoviews/element/sankey.py b/holoviews/element/sankey.py index 9b376dd7df..f98e2e543b 100644 --- a/holoviews/element/sankey.py +++ b/holoviews/element/sankey.py @@ -62,7 +62,7 @@ def layout(self, element, **params): np.mean([node['x0'], node['x1']]), np.mean([node['y0'], node['y1']]), node['index'], - *tuple(node['values']) + *node['values'] )) if element.nodes.ndims == 3: kdims = element.nodes.kdims diff --git a/holoviews/tests/core/data/test_imageinterface.py b/holoviews/tests/core/data/test_imageinterface.py index 17d3f8a21c..b9d81025c1 100644 --- a/holoviews/tests/core/data/test_imageinterface.py +++ b/holoviews/tests/core/data/test_imageinterface.py @@ -429,7 +429,7 @@ def test_reduce_to_single_values(self): def test_sample_xcoord(self): ys = np.linspace(0.5, 9.5, 10) - data = (ys, *tuple(self.rgb_array[:, 7, i] for i in range(3))) + data = (ys, *(self.rgb_array[:, 7, i] for i in range(3))) with DatatypeContext([self.datatype, 'dictionary' , 'dataframe'], self.rgb): self.assertEqual(self.rgb.sample(x=5), self.rgb.clone(data, kdims=['y'], @@ -437,7 +437,7 @@ def test_sample_xcoord(self): def test_sample_ycoord(self): xs = np.linspace(-9, 9, 10) - data = (xs, *tuple(self.rgb_array[4, :, i] for i in range(3))) + data = (xs, *(self.rgb_array[4, :, i] for i in range(3))) with DatatypeContext([self.datatype, 'dictionary' , 'dataframe'], self.rgb): self.assertEqual(self.rgb.sample(y=5), self.rgb.clone(data, kdims=['x'], diff --git a/holoviews/tests/core/test_utils.py b/holoviews/tests/core/test_utils.py index 2051a04168..47bc751d8c 100644 --- a/holoviews/tests/core/test_utils.py +++ b/holoviews/tests/core/test_utils.py @@ -639,12 +639,12 @@ def test_isfinite_pandas_period_series(self): def test_isfinite_pandas_period_index_nat(self): daily = pd.date_range('2017-1-1', '2017-1-3', freq='D').to_period('D') - daily = pd.PeriodIndex([*list(daily), pd.NaT]) + daily = pd.PeriodIndex([*daily, pd.NaT]) self.assertEqual(isfinite(daily), np.array([True, True, True, False])) def test_isfinite_pandas_period_series_nat(self): daily = pd.date_range('2017-1-1', '2017-1-3', freq='D').to_period('D') - daily = pd.Series([*list(daily), pd.NaT]) + daily = pd.Series([*daily, pd.NaT]) self.assertEqual(isfinite(daily), np.array([True, True, True, False])) def test_isfinite_pandas_timestamp_index(self): @@ -657,12 +657,12 @@ def test_isfinite_pandas_timestamp_series(self): def test_isfinite_pandas_timestamp_index_nat(self): daily = pd.date_range('2017-1-1', '2017-1-3', freq='D') - daily = pd.DatetimeIndex([*list(daily), pd.NaT]) + daily = pd.DatetimeIndex([*daily, pd.NaT]) self.assertEqual(isfinite(daily), np.array([True, True, True, False])) def test_isfinite_pandas_timestamp_series_nat(self): daily = pd.date_range('2017-1-1', '2017-1-3', freq='D') - daily = pd.Series([*list(daily), pd.NaT]) + daily = pd.Series([*daily, pd.NaT]) self.assertEqual(isfinite(daily), np.array([True, True, True, False])) def test_isfinite_datetime64_array(self):