Skip to content

Commit

Permalink
filter counts, updated sparse computation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeisel committed Sep 22, 2022
1 parent a33e8cf commit 4d389ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/database/minio_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from config import Config
import os
from datetime import datetime

from scipy.sparse import *

client = Minio(
Config.MINIO_ENDPOINT,
Expand Down
2 changes: 1 addition & 1 deletion app/services/rem_services/mitigation_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def appyl_mitigation(self, mitigator, **kwargs):
counts = kwargs["counts"]
array_counts = dict_to_array(counts, n_qubits)
if issparse(mitigator):
res = list(np.matmul(mitigator.toarray(), array_counts))
res = mitigator.dot(array_counts)
else:
res = list(np.matmul(mitigator, array_counts))
return array_to_dict(res, n_qubits)
Expand Down
4 changes: 3 additions & 1 deletion app/utils/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def dict_to_array(counts_dict: dict, n_qubits: int):
def array_to_dict(counts_array: list, n_qubits: int):
dict = {}
for i, e in enumerate(counts_array):
dict["{:0{}b}".format(i, n_qubits)] = e
# Remove all counts da occur less than once -> this drastically decreases the number of total counts
if (e >= 1):
dict["{:0{}b}".format(i, n_qubits)] = e
return dict


Expand Down

0 comments on commit 4d389ea

Please sign in to comment.