Skip to content

Commit

Permalink
ruff: fix C409 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed Aug 11, 2024
1 parent 4bf3f35 commit a2465a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions pytools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,11 +1054,11 @@ def monkeypatch_class(_name, bases, namespace):
# {{{ generic utilities

def add_tuples(t1, t2):
return tuple([t1v + t2v for t1v, t2v in zip(t1, t2)])
return tuple(t1v + t2v for t1v, t2v in zip(t1, t2))


def negate_tuple(t1):
return tuple([-t1v for t1v in t1])
return tuple(-t1v for t1v in t1)


def shift(vec, dist):
Expand Down Expand Up @@ -1609,7 +1609,7 @@ def add_row(self, row: Tuple[Any, ...]) -> None:
f"tried to add a row with {len(row)} columns to "
f"a table with {self.ncolumns} columns")

self.rows.append(tuple([str(i) for i in row]))
self.rows.append(tuple(str(i) for i in row))

def _get_alignments(self) -> Tuple[str, ...]:
# NOTE: If not all alignments were specified, extend alignments with the
Expand All @@ -1619,9 +1619,9 @@ def _get_alignments(self) -> Tuple[str, ...]:
)

def _get_column_widths(self, rows) -> Tuple[int, ...]:
return tuple([
return tuple(
max(len(row[i]) for row in rows) for i in range(self.ncolumns)
])
)

def __str__(self) -> str:
"""
Expand Down Expand Up @@ -1678,7 +1678,7 @@ def escape(cell: str) -> str:
# Pipe symbols ('|') must be replaced
return cell.replace("|", "\\|")

rows = [tuple([escape(cell) for cell in row]) for row in self.rows]
rows = [tuple(escape(cell) for cell in row) for row in self.rows]
alignments = self._get_alignments()
col_widths = self._get_column_widths(rows)

Expand Down Expand Up @@ -1788,9 +1788,9 @@ def remove_columns(i, row):
if i == 0 or skip_columns is None:
return row
else:
return tuple([
return tuple(
entry for i, entry in enumerate(row) if i not in skip_columns
])
)

alignments = sum((
remove_columns(i, tbl._get_alignments())
Expand Down
2 changes: 1 addition & 1 deletion pytools/convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def stringify_eocs(*eocs: EOCRecorder,
f"{len(eocs)} EOCRecorder instances")

if names is None:
names = tuple([f"{error_label} {i}" for i in range(len(eocs))])
names = tuple(f"{error_label} {i}" for i in range(len(eocs)))

from pytools import merge_tables
tbl = merge_tables(*[eoc._to_table(
Expand Down

0 comments on commit a2465a7

Please sign in to comment.