6     Convert the integer value to a tuple of the next power of two,      7     and number of bits required to represent it.    10     bits = (bin_val).bit_length()
    19     l_ns = 
pow2bits( int(np.max( list(encoding_dict[
'ns'].values()))) )
    20     l_v  = 
pow2bits( int(np.max( list(encoding_dict[
'v'].values()))) )
    21     l_no = 
pow2bits( int(np.max( list(encoding_dict[
'no'].values()))) )
    22     return l_ns, l_v, l_no
    26     if type_offsets == 
None:
    29         l_ns, l_v, l_no = type_offsets
    31     bitmask_ns = (l_ns[0]-1) << (l_v[1] + l_no[1])
    32     bitmask_v = (l_v[0]-1) << l_no[1]
    33     bitmask_no = (l_no[0]-1) 
    35     return bitmask_ns, bitmask_v, bitmask_no
    40     Map the integer binary value to the result from the encoded basis mappings.    42     if type_offsets == 
None:
    45         l_ns, l_v, l_no = type_offsets
    47     bitmask_ns, bitmask_v, bitmask_no = 
get_type_masks(encoding_dict, type_offsets=(l_ns, l_v, l_no) )
    49     ns_val = (bin_val & bitmask_ns) >> (l_v[1] + l_no[1])
    50     v_val  = (bin_val & bitmask_v) >> l_no[1]
    51     no_val = (bin_val & bitmask_no)
    53     return decoding_dict[
"ns"][ns_val], decoding_dict[
"v"][v_val], decoding_dict[
"no"][no_val]
    57     """Given a list of strings, generate the latex '\\vert {} \\rangle' representation of this in superposition."""    59     str_template = 
r"\vert {} \rangle"    60     for idx,i 
in enumerate(l):
    61         result += 
r"b_{{{}}}\vert \textrm{{{}}} \rangle ".format(idx, i[0])
    67     """Simple integer based hamming distance for bits"""    68     return bin(i1 ^ i2).
count(
"1")
    72     Assuming simple.py encoding and give qubits as num_tokens/2 per meaning space    75     num_ns = len(enc_dict[
'ns'])//2
    76     num_v = len(enc_dict[
'v'])//2
    77     num_no = len(enc_dict[
'no'])//2
    78     return num_ns, num_v, num_no
    82     Pass in the pattern given by the basis token values as (ns,v,no)    83     The pattern will be constructed into the appropriate binary string    84     and output for encoding.    87     result = enc_dict[
"ns"][pattern[0]] | \
    88                 enc_dict[
"v"][pattern[1]] << num_ns | \
    89                 enc_dict[
"no"][pattern[2]] << (num_ns + num_v)
    95     Pass in the pattern given by the basis token values as (ns,v,no)    96     The pattern will be constructed into the appropriate binary string    97     and output for encoding.   100     result = pattern[0] | pattern[1] << num_ns | pattern[2] << (num_ns + num_v)
   107     Pass in the pattern given as the encoded integer.   108     The pattern will be deconstructed into the appropriate token tuple   109     and output for plotting/printing. Inverse of encode_binary_pattern.   113     t_ns =   pattern & (2**num_ns -1)
   114     t_v  = ( pattern >> num_ns ) & (2**num_v -1)
   115     t_no = ( pattern >> (num_ns + num_v) ) & (2**num_no -1)
   117     return (dec_dict[
"ns"][t_ns], dec_dict[
"v"][t_v], dec_dict[
"no"][t_no])
 
def get_type_masks(encoding_dict, type_offsets=None)
 
def HammingInt(int i1, int i2)
 
def num_qubits(dict enc_dict)
 
def encode_binary_pattern((str, str, str) pattern, dict enc_dict)
 
def decode_binary_pattern(int pattern, dict dec_dict)
 
def encode_binary_pattern_direct([int, int, int] pattern, dict enc_dict)
 
def bin_to_sentence(bin_val, encoding_dict, decoding_dict, type_offsets=None)
 
def get_type_offsets(encoding_dict)