- class perceval.utils.postselect.PostSelect(str_repr=None)
PostSelect is a callable post-selection intended to filter out unwanted output states. It is designed to be a user-friendly description of any post-selection logic.
str]) – string representation of the selection logic. The format is: “cond_1 & cond_2 & … & cond_n” where cond_i is “[mode list] <operator> <photon count>” (supported operators are ==, > and <)
>>> ps = PostSelect("[0,1] == 1 &  > 1") # Means "I want exactly one photon in mode 0 or 1, and at least one photon in mode 2" >>> ps = PostSelect().eq([0,1], 1).gt(2, 1) # Same as above >>> print(ps(BasicState([0, 1, 1]))) True >>> print(ps(BasicState([1, 1, 1]))) False
PostSelect is callable, with a post_select(BasicState) -> bool signature. Returns True if the input state validates all conditions, returns False otherwise.
- Return type:
- apply_permutation(perm_vector, first_mode=0)
Apply a given permutation on the conditions.
int]) – Permutation vector to apply (as returned by PERM.perm_vector)
int) – First mode of the permutation to apply (default 0)
A PostSelect with the permutation applied
Check if all conditions are compatible with a compisition on given modes
int]) – Modes used in the composition
- Return type:
True if the composition is allowed without mixing conditions, False otherwise
Clear all existing conditions
- eq(indexes, value)
Create a new “equals” condition for the current PostSelect instance
- gt(indexes, value)
Create a new “greater than” condition for the current PostSelect instance
- property has_condition: bool
Returns True if at least one condition is defined
- lt(indexes, value)
Create a new “lower than” condition for the current PostSelect instance