diff --git a/REUSE.toml b/REUSE.toml index 592bb73..0e77ec3 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -46,3 +46,15 @@ path = [".github/ISSUE_TEMPLATE/*.md"] precedence = "override" SPDX-FileCopyrightText = ["Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.", "Copyright (c) 2025 Timor Knudsen (AMD)"] SPDX-License-Identifier = "MIT" + +[[annotations]] +path = [".github/instructions/**"] +precedence = "override" +SPDX-FileCopyrightText = ["Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.", "Copyright (c) 2025 Timor Knudsen (AMD)"] +SPDX-License-Identifier = "MIT" + +[[annotations]] +path = [".agents/skills/**"] +precedence = "override" +SPDX-FileCopyrightText = ["Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.", "Copyright (c) 2025 Timor Knudsen (AMD)"] +SPDX-License-Identifier = "MIT" diff --git a/python/tb/test_blc.py b/python/tb/test_blc.py index e9cf1cc..54d8cba 100644 --- a/python/tb/test_blc.py +++ b/python/tb/test_blc.py @@ -124,7 +124,7 @@ async def test_blc_basic(dut): cv2.imwrite("blc_ref.png", ((ref * 256) / np.max(ref)).astype(np.uint8)) cv2.imwrite("blc.png", ((result * 256) / np.max(result)).astype(np.uint8)) - assert np.allclose(result.astype(np.uint32), ref.astype(np.uint32), atol=0) + np.testing.assert_allclose(result.astype(np.uint32), ref.astype(np.uint32), atol=0) await Timer(20 * 10, unit="ns") diff --git a/python/tb/test_colorgain.py b/python/tb/test_colorgain.py index 86e0784..743a9f5 100644 --- a/python/tb/test_colorgain.py +++ b/python/tb/test_colorgain.py @@ -147,7 +147,7 @@ async def test_colorgain_basic(dut): cv2.imwrite("colorgain_ref.png", ((ref * 256) / np.max(ref)).astype(np.uint8)) cv2.imwrite("colorgain.png", ((result * 256) / np.max(result)).astype(np.uint8)) - assert np.allclose(result.astype(np.uint32), ref.astype(np.uint32), atol=0) + np.testing.assert_allclose(result.astype(np.uint32), ref.astype(np.uint32), atol=0) await Timer(20 * 10, unit="ns") diff --git a/python/tb/test_demosaic.py b/python/tb/test_demosaic.py index 8903f27..04c6f6f 100644 --- a/python/tb/test_demosaic.py +++ b/python/tb/test_demosaic.py @@ -112,7 +112,7 @@ async def test_demosaic_basic(dut): # tuser should only be set for first line (signals start of frame) tuser = 0 - result = np.zeros((h - 4, 3 * (w - 4)), dtype=np.uint16) + result = np.zeros((h - 4, 3 * (w - 4)), dtype=np.uint32) for y in range(0, h - 4): frame = await tb.axis_sink.recv() result[y, :] = unpack_buffer( @@ -153,7 +153,9 @@ async def test_demosaic_basic(dut): cv2.imwrite("demosaic.png", (rgb2 / np.max(rgb2)) * 256) cv2.imwrite("demosaic_ref.png", (ref_rgb / np.max(ref_rgb)) * 256) - assert np.allclose(rgb3.astype(np.uint32), ref_rgb.astype(np.uint32), atol=0) + np.testing.assert_allclose( + rgb3.astype(np.uint32), ref_rgb.astype(np.uint32), atol=0 + ) await Timer(20 * 10, unit="ns") diff --git a/python/tb/test_linebuffer.py b/python/tb/test_linebuffer.py index 2964e9c..827db22 100644 --- a/python/tb/test_linebuffer.py +++ b/python/tb/test_linebuffer.py @@ -75,7 +75,7 @@ async def reset(self): @cocotb.test() @pytest.mark.sim -async def test_colorgain_basic(dut): +async def test_linebuffer_basic(dut): """Try accessing the design.""" tb = TB(dut) @@ -104,7 +104,7 @@ async def test_colorgain_basic(dut): for y in range(0, h): frame = AxiStreamFrame( pack_buffer( - cfa[y, :].astype(np.uint16), + cfa[y, :].astype(np.uint32), int(dut.PIXEL_PER_CYCLE.value), int(dut.PIXEL_BIT_WIDTH.value), ), @@ -114,7 +114,7 @@ async def test_colorgain_basic(dut): # tuser should only be set for first line (signals start of frame) tuser = 0 - result = np.zeros((h - conv_loss, w * conv_size), dtype=np.uint16) + result = np.zeros((h - conv_loss, w * conv_size), dtype=np.uint32) for y in range(0, h - conv_loss): frame = await tb.axis_sink.recv() result[y, :] = unpack_buffer( diff --git a/python/tb/test_minmaxmean.py b/python/tb/test_minmaxmean.py index 3429430..84088eb 100644 --- a/python/tb/test_minmaxmean.py +++ b/python/tb/test_minmaxmean.py @@ -88,7 +88,7 @@ async def test_minmaxmean_basic(dut): for y in range(0, h): frame = AxiStreamFrame( pack_buffer( - cfa[y, :].astype(np.uint16), + cfa[y, :].astype(np.uint32), int(dut.PIXEL_PER_CYCLE.value), int(dut.PIXEL_BIT_WIDTH.value), ), diff --git a/python/test/test_gamma.py b/python/test/test_gamma.py index c0019d5..b132b30 100644 --- a/python/test/test_gamma.py +++ b/python/test/test_gamma.py @@ -40,7 +40,7 @@ def test_gamma(): diff_pwl = np.abs(output_pwl - reference) print("max absolute error pwl: ", np.max(diff_pwl)) - assert np.allclose(output_pwl, reference, atol=1e-2) + np.testing.assert_allclose(output_pwl, reference, atol=1e-2) # plt.plot(reference) # plt.plot(output) diff --git a/python/test/test_utils.py b/python/test/test_utils.py index a915251..d10575b 100644 --- a/python/test/test_utils.py +++ b/python/test/test_utils.py @@ -38,15 +38,12 @@ def test_bitsqrt(): Test bitsqrt """ export_lut(bitsqrt_lut, "bitsqrt.mem") - # rand = (np.random.rand(100, 100) * np.iinfo(np.uint32).max).astype(np.uint32) rand = np.linspace(1, np.iinfo(np.uint32).max - 1, 10000000).astype(np.uint32) - # rand = np.linspace(1, 1024, 1024).astype(np.uint32) rand[rand == 0] = 1 # exclude zero - # output = bitlog2(rand).astype(np.float32) / 2**24 output = bitsqrt(rand).astype(np.float32) / 2**16 reference = np.sqrt(rand) print("max error: ", np.max(np.abs(output - reference))) - assert np.allclose(output, reference, rtol=1e-2) + np.testing.assert_allclose(output, reference, rtol=1e-2) mask = np.abs(output - reference) > 60 masked = output.copy() masked[mask] = 0