Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- run: uv sync
- uses: astral-sh/ruff-action@v3
Expand Down
6 changes: 3 additions & 3 deletions aoc2024/day12.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class Side(IntFlag):

m = len(lines)
n = max(map(len, lines))
regions: list[list[int | None]] = [[None] * len(line) for line in lines]
regions = [[-1] * len(line) for line in lines]

areas: list[int] = []

k = 0
for i, (line, region) in enumerate(zip(lines, regions)):
for j, (crop, cell) in enumerate(zip(line, region)):
if cell is None:
if cell < 0:
k = len(areas)
area = 0
q = [(i, j)]
Expand All @@ -31,7 +31,7 @@ class Side(IntFlag):
if (
0 <= s < m
and 0 <= t < n
and regions[s][t] is None
and regions[s][t] < 0
and lines[s][t] == crop
):
area += 1
Expand Down
16 changes: 5 additions & 11 deletions fourt2py/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,16 @@ fourt2py_source = custom_target('fourt2pymodule.c',
command: [py, '-m', 'numpy.f2py', '@INPUT@', '--build-dir', '@OUTDIR@'],
)

incdir_numpy = run_command(py,
['-c', 'import numpy.f2py; print(numpy.get_include())'],
include_directories = run_command(py,
['-c', 'import numpy.f2py; print(numpy.get_include(), numpy.f2py.get_include())'],
check : true
).stdout().strip()

incdir_f2py = run_command(py,
['-c', 'import numpy.f2py; print(numpy.f2py.get_include())'],
check : true
).stdout().strip()
).stdout().split()

py.extension_module('fourt2py',
'FOURT.F',
fourt2py_source,
incdir_f2py / 'fortranobject.c',
dependencies : [py.dependency(), dependency('numpy')],
include_directories : include_directories(incdir_numpy, incdir_f2py),
include_directories[1] / 'fortranobject.c',
include_directories : include_directories,
install : true,
link_language : 'fortran',
)
4 changes: 2 additions & 2 deletions fun/prechelt.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def aho_corasick(*words):
for digit in map(int, word.translate(MAP)):
next = node[digit]
if next is None:
node[digit] = next = [None] * WORD # pyright: ignore[reportArgumentType, reportCallIssue]
node[digit] = next = [None] * WORD # pyright: ignore[reportArgumentType, reportCallIssue] # ty: ignore[invalid-assignment]
node = next
node.append(word)

root[FAIL] = root # pyright: ignore[reportArgumentType, reportCallIssue]
root[FAIL] = root # pyright: ignore[reportArgumentType, reportCallIssue] # ty: ignore[invalid-assignment]
stack = []
append = stack.append
for node in root[:FAIL]:
Expand Down
2 changes: 1 addition & 1 deletion sudoku/bitsudoku.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def propagate(
while np.equal(count, 1, out=where).any(): # pyright: ignore[reportArgumentType, reportCallIssue] # ty: ignore[no-matching-overload]
k = np.invert(possible[where]) # pyright: ignore[reportArgumentType, reportCallIssue] # ty: ignore[invalid-argument-type]
# ufunc.at performs *unbuffered* in place operation
np.bitwise_and.at(possible, tuple(_neighbors[:, where, :]), # pyright: ignore[reportArgumentType, reportCallIssue]
np.bitwise_and.at(possible, tuple(_neighbors[:, where, :]), # pyright: ignore[reportArgumentType, reportCallIssue] # ty: ignore[invalid-argument-type]
k[:, np.newaxis])
if not _counts.take(possible, out=count).all(): # stay in sync
return -1
Expand Down