code style fixed

This commit is contained in:
Nicolas Kruse 2026-03-29 14:56:05 +02:00
parent 09d7d01eee
commit cb633bd827
10 changed files with 19 additions and 21 deletions

View File

@ -79,7 +79,7 @@ def get_all_dag_edges_between(roots: Iterable[Node], leaves: Iterable[Node]) ->
# Walk the DAG in reverse direction starting from given leaves to given roots
emitted_edges: set[tuple[Node, Node]] = set()
node_list = [n for n in leaves]
node_list = list(leaves)
while(node_list):
child_node = node_list.pop()
if child_node in parent_lookup:
@ -104,13 +104,13 @@ def get_all_dag_edges(nodes: Iterable[Node]) -> Generator[tuple[Node, Node], Non
"""
emitted_edges: set[tuple[Node, Node]] = set()
used_nets: dict[Net, Net] = {}
node_list: list[Node] = [n for n in nodes]
node_list: list[Node] = list(nodes)
while(node_list):
node = node_list.pop()
for net in node.args:
# In case there is already net with equivalent value use this
# In case there is already net with equivalent value use this
if net in used_nets:
net = used_nets[net]
else:

View File

@ -362,7 +362,7 @@ class stencil_database():
patch_value = symbol_address + pr.fields['r_addend']
symbol_type = symbol_type + 0x06 # PATCH_OBJECT_ARM32_ABS_THM
#print(f" *> {pr.type} {patch_value=} {symbol_address=}, {function_offset=}, {pr.fields['r_addend']=}")
elif pr.type == 'R_ARM_THM_MOVT_ABS':
# (S + A) & 0xFFFF0000
mask = 0xFFFF0000

View File

@ -1,4 +1,4 @@
def coparun(context: int, data: bytes) -> int: ...
def read_data_mem(context: int, rel_addr: int, length: int) -> bytes: ...
def create_target() -> int: ...
def clear_target(context: int) -> None: ...
def clear_target(context: int) -> None: ...

View File

@ -303,7 +303,7 @@ if __name__ == "__main__":
code += get_custom_stencil('abs_int(int arg1)', 'result_int(__builtin_abs(arg1));')
for t in types:
code += get_custom_stencil(f"sign_{t}({t} arg1)", f"result_int((arg1 > 0) - (arg1 < 0));")
code += get_custom_stencil(f"sign_{t}({t} arg1)", "result_int((arg1 > 0) - (arg1 < 0));")
fnames = ['atan2', 'pow']
for fn, t1, t2 in permutate(fnames, types, types):

View File

@ -7,8 +7,6 @@ import sys
import numpy as np
from numpy.core._multiarray_umath import __cpu_features__
from copapy._matrices import diagonal
CPU_SIMD_FEATURES = "SSE SSE2 SSE3 SSSE3 SSE41 SSE42 AVX AVX2 AVX512F FMA3"
@ -217,7 +215,7 @@ def save_svg_with_theme_styles(pyplot_obj, path):
# --- Step 1: Capture SVG to memory ---
buf = io.StringIO()
# pyplot_obj can be a module (plt) or a Figure instance
if hasattr(pyplot_obj, "gcf"):
fig = pyplot_obj.gcf()

View File

@ -70,4 +70,4 @@ def test_dag_reduction():
if __name__ == "__main__":
test_get_dag_stats()
test_dag_reduction()
test_dag_reduction()

View File

@ -181,4 +181,4 @@ qemu-arm -d in_asm,exec -D qemu_trace.log \
-global driver=pl011.audiomaddr,property=addr,value=0xff7ec000 \
-global driver=pl011.audiomaddr,property=size,value=0x100000 \
your_binary
"""
"""

View File

@ -18,7 +18,7 @@ def forward_kinematics(theta1: cp.value[float] | float, theta2: cp.value[float]
return joint, end_effector
def test_two_arms():
def test_two_arms():
target_vec = cp.vector(target)
theta = cp.vector([cp.value(0.0), cp.value(0.0)])
@ -47,4 +47,4 @@ def test_two_arms():
if __name__ == '__main__':
test_two_arms()
test_two_arms()

View File

@ -68,7 +68,7 @@ def test_tensor_basic():
assert result_2d_1d.shape == (2, 3)
assert result_2d_1d[0, 0] == 11.0
assert result_2d_1d[1, 2] == 36.0
# 3D tensor + 2D tensor
t3d = cp.tensor([[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0], [7.0, 8.0]]])
t2d_broadcast = cp.tensor([[100.0, 200.0], [300.0, 400.0]])
@ -77,7 +77,7 @@ def test_tensor_basic():
assert result_3d_2d.shape == (2, 2, 2)
assert result_3d_2d[0, 0, 0] == 101.0
assert result_3d_2d[1, 1, 1] == 408.0
# 3D tensor + 1D tensor
t1d_broadcast = cp.tensor([1.0, 2.0])
result_3d_1d = t3d + t1d_broadcast
@ -106,7 +106,7 @@ def test_tensor_basic():
assert c2d.shape == (2, 2)
assert c2d[0, 0] == 2.0
assert c2d[1, 1] == 20.0
# 3D - 2D
t3d_sub = cp.tensor([[[10.0, 20.0], [30.0, 40.0]], [[50.0, 60.0], [70.0, 80.0]]])
t2d_sub = cp.tensor([[1.0, 2.0], [3.0, 4.0]])
@ -173,7 +173,7 @@ def test_tensor_basic():
print("Test 10b: Sum with multiple axes and keepdims")
t3d = cp.tensor([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
print(f"Original 3D tensor: shape={t3d.shape}")
# Sum along multiple axes
sum_axes_0_2 = t3d.sum(axis=(0, 2))
print(f"Sum along axes (0, 2): shape={sum_axes_0_2.shape}")
@ -181,17 +181,17 @@ def test_tensor_basic():
assert sum_axes_0_2[0] == 1 + 2 + 5 + 6 # Elements from [0,:,*] and [1,:,*]
assert sum_axes_0_2[1] == 3 + 4 + 7 + 8
print(f"Values: {[sum_axes_0_2[i] for i in range(len(sum_axes_0_2))]}")
# Sum with keepdims
sum_keepdims = t3d.sum(axis=1, keepdims=True)
print(f"Sum along axis 1 with keepdims: shape={sum_keepdims.shape}")
assert sum_keepdims.shape == (2, 1, 2), f"Expected (2, 1, 2), got {sum_keepdims.shape}"
# Sum multiple axes with keepdims
sum_multi_keepdims = t3d.sum(axis=(0, 2), keepdims=True)
print(f"Sum along axes (0, 2) with keepdims: shape={sum_multi_keepdims.shape}")
assert sum_multi_keepdims.shape == (1, 2, 1), f"Expected (1, 2, 1), got {sum_multi_keepdims.shape}"
# Sum all axes with keepdims
sum_all_keepdims = t3d.sum(keepdims=True)
print(f"Sum all with keepdims: shape={sum_all_keepdims.shape}")

View File

@ -13,4 +13,4 @@ dw, _ = compile_to_dag([Store(result)], sdb)
# Instruct runner to dump patched code to a file:
dw.write_com(Command.DUMP_CODE)
dw.to_file('build/runner/test.copapy')
dw.to_file('build/runner/test.copapy')