From 908fdfdc10bdd274789d197562359166b12ee960 Mon Sep 17 00:00:00 2001 From: Joschka Roffe Date: Thu, 23 Nov 2023 10:55:44 +0100 Subject: [PATCH] without custom MACOS repair command --- .github/workflows/build.yml | 2 +- python_test/test_scratch.py | 80 +++++++++++-------------------------- 2 files changed, 25 insertions(+), 57 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8ce2b44..2762b9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: CIBW_BUILD: "${{ matrix.os_dist.dist }}" MACOSX_DEPLOYMENT_TARGET: "10.15" CIBW_ARCHS_MACOS: "arm64 x86_64" - CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-wheel -w {dest_dir} -v {wheel} + # CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-wheel -w {dest_dir} -v {wheel} strategy: fail-fast: false matrix: diff --git a/python_test/test_scratch.py b/python_test/test_scratch.py index 3e4569e..0272313 100644 --- a/python_test/test_scratch.py +++ b/python_test/test_scratch.py @@ -3,6 +3,8 @@ import ldpc.codes import ldpc.code_util +import scipy.sparse + import numpy as np import ldpc.codes from ldpc import BpDecoder @@ -11,79 +13,45 @@ from ldpc.monte_carlo_simulation import MonteCarloBscSimulation import ldpc.mod2 -if __name__ == "__main__": - - H = ldpc.codes.rep_code(5) - error_rate = 0.001 - dec = BpOsdDecoder(H, error_rate=error_rate, max_iter = 0, bp_method="product_sum", input_vector_type = "syndrome", osd_method="osd_e", osd_order = 1) - assert dec.osd_order == 1 +from qec.codes import ToricCode - span = ldpc.mod2.row_span(ldpc.codes.rep_code(5)) - print(span.toarray()) - H = ldpc.codes.hamming_code(3) - d = ldpc.mod2.compute_exact_code_distance(H) - - print(d) - - import numpy as np - import ldpc.codes - from ldpc import BeliefFindDecoder +if __name__ == "__main__": - H = ldpc.codes.ring_code(3) - ## The - bf = BeliefFindDecoder( - H, - error_rate = 0.1, - bp_method = 'product_sum', - max_iter = 1, - schedule = 'serial', - uf_method = True, # If uf_method is set to False, union-find clusters are solved using a peeling decoder - bits_per_step = 1 ## this is the number of bits by which clusters are expanded in each growth step - ) - - error = np.random.randint(size=H.shape[0], low=0, high=2).astype(np.uint8) - syndrome = H@error % 2 - - print(f"Syndrome: {syndrome.__repr__()}") + H1 = ldpc.codes.hamming_code(3) + H2 = ldpc.codes.hamming_code(3) - decoding = bf.decode(syndrome) - print(f"Decoding: {decoding}") - decoding_syndrome = H@decoding % 2 - print(f"Decoding syndrome: {decoding_syndrome}") + H3 = scipy.sparse.hstack([H1, scipy.sparse.csr_matrix((H1.shape[0], H2.shape[1]))]) + H4 = scipy.sparse.hstack([scipy.sparse.csr_matrix((H2.shape[0], H1.shape[1])), H2]) + H = scipy.sparse.vstack([H3, H4]).astype(np.uint8) + H5 = scipy.sparse.csr_matrix((H.shape[0], H.shape[1])) + vec= np.zeros(H.shape[1]).astype(np.uint8) + vec[[6,7]] = 1 + vec = scipy.sparse.csr_matrix(vec) - # syndrome + H = scipy.sparse.vstack([H, vec]) + print(H.toarray()) - # H = np.array([[0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0], - # [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0], - # [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1], - # [1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0], - # [0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0], - # [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0], - # [1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0], - # [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0], - # [0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0]]) - + c1 = H[:,:7] + c2 = H[:,7:] - # n,k,d = ldpc.code_util.compute_code_parameters(H,timeout_seconds=0.1) - # print(f"n = {n}, k = {k}, d = {d}") + # print(c1.toarray()) + # print(c2.toarray()) - # # exit(22) + # print(vec.toarray()) - # for _ in range(10000): - # H = ldpc.codes.random_binary_code(8,15,4, variance=1) - # n,k,d = ldpc.code_util.compute_code_parameters(H,timeout_seconds=0.001) + plu1 = ldpc.mod2.PluDecomposition(c1) + plu2 = ldpc.mod2.PluDecomposition(c2) - # if d > 4: - # print(f"n = {n}, k = {k}, d = {d}") - # print(H.toarray().__repr__()) \ No newline at end of file + print(plu1.U.toarray()) + print(plu2.L.toarray()) \ No newline at end of file