Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for active with no DropoutMask defined #57

Open
eileen-kuehn opened this issue Sep 19, 2021 · 0 comments
Open

Add test for active with no DropoutMask defined #57

eileen-kuehn opened this issue Sep 19, 2021 · 0 comments
Labels
good first issue Good for newcomers

Comments

@eileen-kuehn
Copy link
Member

eileen-kuehn commented Sep 19, 2021

Currently the function active statically builds on the existence of DropoutMask to return the number of active gates in a circuit.

def active(self) -> int:
"""
Number of active gates in the circuit based on layer, wire, and parameter mask.
Entangling gates are not included.
"""
mask = self.full_mask(mask_type=DropoutMask)
return mask.size - np.sum(mask)

During handling of edge cases in full_mask this issue is properly fixed, but might not be guaranteed in the future.

def full_mask(self, mask_type: Type[Mask]) -> np.ndarray:
"""
Accumulated mask of layer, wire, and parameter masks for a given type of Mask.
Note that this mask is readonly.
"""
if Axis.PARAMETERS in self.masks and mask_type in self.masks[Axis.PARAMETERS]:
result = self.masks[Axis.PARAMETERS][mask_type].mask.copy()
else:
result = np.zeros(
self.parameters.shape,
dtype=mask_type.elemental_type,
requires_grad=False,
)

To properly handle this, we should implement a proper unit test.

@eileen-kuehn eileen-kuehn added bug Something isn't working good first issue Good for newcomers and removed bug Something isn't working labels Sep 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant