qubiter.utilities_gen module

qubiter.utilities_gen.all_floats(li)[source]

Returns True iff all items in list are floats.

Parameters:li (list) –
Returns:
Return type:bool
qubiter.utilities_gen.all_strings(li)[source]

Returns True iff all items in list are strings.

Parameters:li (list) –
Returns:
Return type:bool
qubiter.utilities_gen.find_path_to_qubiter()[source]

Returns absolute path to this file.

Returns:
Return type:str
qubiter.utilities_gen.get_eng_file_rel_path(file_prefix, num_qbits)[source]

Returns path to English file.

Returns:
Return type:str
qubiter.utilities_gen.get_pic_file_rel_path(file_prefix, num_qbits, ZL=True)[source]

Returns path to Picture file.

Returns:
Return type:str
qubiter.utilities_gen.get_value(kwargs, key_str, default_val=None)[source]

Returns kwargs[key_str] if there is one. Else it returns default_val if there is one. Else aborts.

Parameters:
  • kwargs (dict[str, float]) –
  • key_str (str) –
  • default_val (float) –
Returns:

Return type:

float

qubiter.utilities_gen.increment_dict(di, key, inc, initial=0)[source]

Increments dictionary entry at position key by inc. If item at position key does not exist coming in, first creates one with value initial, then increments it by inc.

Parameters:
  • di (dict[]) –
  • key
  • inc – increment
  • initial
qubiter.utilities_gen.is_arr(x)[source]

Returns True iff x is a numpy array.

Parameters:x
Returns:
Return type:bool
qubiter.utilities_gen.is_const_mat(arr)[source]

Returns True iff arr is numpy array for constant square matrix.

Parameters:arr (np.ndarray) –
Returns:
Return type:bool
qubiter.utilities_gen.is_diag_mat(arr)[source]

Returns True iff arr is numpy array for diagonal square matrix.

Parameters:arr (np.ndarray) –
Returns:
Return type:bool
qubiter.utilities_gen.is_non_neg_int(s)[source]

Returns True iff string s is a non-negative number.

Parameters:s (str) –
Returns:
Return type:bool
qubiter.utilities_gen.is_prob_dist(pd)[source]

Returns True iff pd is a probability distribution.

Parameters:pd (np.ndarray) –
Returns:
Return type:bool
qubiter.utilities_gen.kron_prod(mat_list)[source]

This method returns the Kronecker product of the list of matrices which it has as input.

Parameters:mat_list (list[np.ndarray]) –
Returns:
Return type:np.ndarray
qubiter.utilities_gen.log_print(x)[source]

Prints file name of log_print() call, then file line of log_print() call, then x.

Parameters:x (object) –
Returns:
Return type:None
qubiter.utilities_gen.preface(a_str)[source]

Throughout Qubiter, the term file_prefix is used for files. If the file_prefix string starts with _, then the file is created with relative path equal to (hence, it shows up in the current working directory)

./file_prefix + ending

If file_prefix doesn’t start with _, then the file is created with absolute path equal to (hence, it shows up in qubiter’s io_folder)

absolute_path_to_io_folder/file_prefix + ending.

Given a_str, if it doesn’t start with _, this method returns absolute_path_to_io_folder/a_str. Otherwise, this method just returns a_str.

Parameters:a_str (str) –
Returns:
Return type:str
qubiter.utilities_gen.scalar_prod(scalars_list)[source]

This method returns the product of the list of scalars which it has as input.

Parameters:scalars_list (list[int|float|complex] | tuple[int|float|complex]) –
Returns:
Return type:complex|float|int