Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
meandmytram committed Apr 18, 2024
1 parent 6a5afde commit 066543d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
27 changes: 18 additions & 9 deletions examples/decoding/classical.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
from scipy.stats import unitary_group

# Setup logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)

# Append paths using environment variables or hardcoded fallbacks
project_root = os.getenv(
'MDOPT_PATH', '/home/bereza/projects/def-ko1/bereza/project-mdopt/mdopt'
)
"MDOPT_PATH", "/home/bereza/projects/def-ko1/bereza/project-mdopt/mdopt"
)
examples_path = os.getenv(
'MDOPT_EXAMPLES_PATH', '/home/bereza/projects/def-ko1/bereza/project-mdopt/mdopt/examples'
)
"MDOPT_EXAMPLES_PATH",
"/home/bereza/projects/def-ko1/bereza/project-mdopt/mdopt/examples",
)

sys.path.append(project_root)
sys.path.append(examples_path)
Expand All @@ -40,7 +43,9 @@
decode_linear,
)
except ImportError as e:
logging.error("Failed to import required modules. Ensure paths are correct.", exc_info=True)
logging.error(
"Failed to import required modules. Ensure paths are correct.", exc_info=True
)
sys.exit(1)

NUM_EXPERIMENTS = 100
Expand All @@ -61,7 +66,7 @@
for PROB_ERROR in tqdm(error_rates):
logging.info(
f"Starting experiments for NUM_BITS={NUM_BITS}, CHI_MAX={CHI_MAX_CONTRACTOR}, PROB_ERROR={PROB_ERROR}"
)
)
failures = []

for l in range(NUM_EXPERIMENTS):
Expand Down Expand Up @@ -129,6 +134,10 @@
failures.append(1 - success)

failures_statistics[(NUM_BITS, CHI_MAX_CONTRACTOR, PROB_ERROR)] = failures
failures_key = f"numbits{NUM_BITS}_bonddim{CHI_MAX_CONTRACTOR}_errorprob{PROB_ERROR}"
failures_key = (
f"numbits{NUM_BITS}_bonddim{CHI_MAX_CONTRACTOR}_errorprob{PROB_ERROR}"
)
np.save(f"data/{failures_key}.npy", failures)
logging.info(f"Completed experiments for {failures_key} with {np.mean(failures)*100:.2f}% failure rate.")
logging.info(
f"Completed experiments for {failures_key} with {np.mean(failures)*100:.2f}% failure rate."
)
4 changes: 3 additions & 1 deletion examples/decoding/classical_ldpc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,9 @@
" failures.append(1 - success)\n",
"\n",
" failures_statistics[NUM_BITS, CHI_MAX_CONTRACTOR, PROB_ERROR] = failures\n",
" failures_key = f\"numbits{NUM_BITS}_bonddim{CHI_MAX_CONTRACTOR}_errorprob{PROB_ERROR}\"\n",
" failures_key = (\n",
" f\"numbits{NUM_BITS}_bonddim{CHI_MAX_CONTRACTOR}_errorprob{PROB_ERROR}\"\n",
" )\n",
" np.save(f\"data/{failures_key}.npy\", failures)"
]
}
Expand Down
4 changes: 3 additions & 1 deletion examples/random_circuit/mps-rand-circ.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
fidels = [1 - error for error in errors]
tails_iter.append(np.prod(fidels))

tails_key = f"numqubits{NUM_QUBITS}_bonddim{BOND_DIM}_circlayers{NUM_LAYERS_CIRC}"
tails_key = (
f"numqubits{NUM_QUBITS}_bonddim{BOND_DIM}_circlayers{NUM_LAYERS_CIRC}"
)
tails[tails_key] = tails_iter

np.save(f"data/{tails_key}.npy", tails)
Expand Down

0 comments on commit 066543d

Please sign in to comment.