Skip to content

QKD-5: Correct usage of numpy.where in error_estimation.py #14

@gnypit

Description

@gnypit

Current code:

alice_key = []
    bob_key = []

    """Vectorize generation of random publication decision"""
    random_vals = np.random.uniform(0, 1, len(alice_bits))

    """Separate indices by basis"""
    rect_indices = np.where(basis == 0)[0]
    diag_indices = np.where(basis == 1)[0]

    """Determine which rectilinear and diagonal bits are published"""
    rect_published = rect_indices[random_vals[rect_indices] < rect_pub_prob]
    diag_published = diag_indices[random_vals[diag_indices] < diag_pub_prob]

    """Count errors and published bits for rectilinear and diagonal bases"""
    rect_error = np.sum(alice_bits[rect_published] != bob_bits[rect_published])
    diag_error = np.sum(alice_bits[diag_published] != bob_bits[diag_published])

This usage of numpy.where is deppreciated, update it. For more info look here: https://numpy.org/doc/stable/reference/generated/numpy.where.html

This should resolve the following error:
Zrzut ekranu 2024-11-23 212852

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions