id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
12,100
nschloe/optimesh
optimesh/cvt/lloyd.py
quasi_newton_uniform_lloyd
def quasi_newton_uniform_lloyd(points, cells, *args, omega=1.0, **kwargs): """Relaxed Lloyd's algorithm. omega=1 leads to Lloyd's algorithm, overrelaxation omega=2 gives good results. Check out Xiao Xiao, Over-Relaxation Lloyd Method For Computing Centroidal Voronoi Tessellations, Master's thesis, ...
python
def quasi_newton_uniform_lloyd(points, cells, *args, omega=1.0, **kwargs): """Relaxed Lloyd's algorithm. omega=1 leads to Lloyd's algorithm, overrelaxation omega=2 gives good results. Check out Xiao Xiao, Over-Relaxation Lloyd Method For Computing Centroidal Voronoi Tessellations, Master's thesis, ...
[ "def", "quasi_newton_uniform_lloyd", "(", "points", ",", "cells", ",", "*", "args", ",", "omega", "=", "1.0", ",", "*", "*", "kwargs", ")", ":", "def", "get_new_points", "(", "mesh", ")", ":", "x", "=", "(", "mesh", ".", "node_coords", "-", "omega", ...
Relaxed Lloyd's algorithm. omega=1 leads to Lloyd's algorithm, overrelaxation omega=2 gives good results. Check out Xiao Xiao, Over-Relaxation Lloyd Method For Computing Centroidal Voronoi Tessellations, Master's thesis, <https://scholarcommons.sc.edu/etd/295/>. Everything above omega=2 can le...
[ "Relaxed", "Lloyd", "s", "algorithm", ".", "omega", "=", "1", "leads", "to", "Lloyd", "s", "algorithm", "overrelaxation", "omega", "=", "2", "gives", "good", "results", ".", "Check", "out" ]
b85f48d1559a51a01cc3df6214c61ca8ad5ed786
https://github.com/nschloe/optimesh/blob/b85f48d1559a51a01cc3df6214c61ca8ad5ed786/optimesh/cvt/lloyd.py#L8-L46
12,101
nschloe/optimesh
optimesh/cpt.py
_energy_uniform_per_node
def _energy_uniform_per_node(X, cells): """The CPT mesh energy is defined as sum_i E_i, E_i = 1/(d+1) * sum int_{omega_i} ||x - x_i||^2 rho(x) dx, see Chen-Holst. This method gives the E_i and assumes uniform density, rho(x) = 1. """ dim = 2 mesh = MeshTri(X, cells) star_inte...
python
def _energy_uniform_per_node(X, cells): """The CPT mesh energy is defined as sum_i E_i, E_i = 1/(d+1) * sum int_{omega_i} ||x - x_i||^2 rho(x) dx, see Chen-Holst. This method gives the E_i and assumes uniform density, rho(x) = 1. """ dim = 2 mesh = MeshTri(X, cells) star_inte...
[ "def", "_energy_uniform_per_node", "(", "X", ",", "cells", ")", ":", "dim", "=", "2", "mesh", "=", "MeshTri", "(", "X", ",", "cells", ")", "star_integrals", "=", "numpy", ".", "zeros", "(", "mesh", ".", "node_coords", ".", "shape", "[", "0", "]", ")"...
The CPT mesh energy is defined as sum_i E_i, E_i = 1/(d+1) * sum int_{omega_i} ||x - x_i||^2 rho(x) dx, see Chen-Holst. This method gives the E_i and assumes uniform density, rho(x) = 1.
[ "The", "CPT", "mesh", "energy", "is", "defined", "as" ]
b85f48d1559a51a01cc3df6214c61ca8ad5ed786
https://github.com/nschloe/optimesh/blob/b85f48d1559a51a01cc3df6214c61ca8ad5ed786/optimesh/cpt.py#L91-L116
12,102
nschloe/optimesh
optimesh/cpt.py
jac_uniform
def jac_uniform(X, cells): """The approximated Jacobian is partial_i E = 2/(d+1) (x_i int_{omega_i} rho(x) dx - int_{omega_i} x rho(x) dx) = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_{j, rho}) int_{tau_j} rho, see Chen-Holst. This method here assumes uniform density, rho(x) = 1, such tha...
python
def jac_uniform(X, cells): """The approximated Jacobian is partial_i E = 2/(d+1) (x_i int_{omega_i} rho(x) dx - int_{omega_i} x rho(x) dx) = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_{j, rho}) int_{tau_j} rho, see Chen-Holst. This method here assumes uniform density, rho(x) = 1, such tha...
[ "def", "jac_uniform", "(", "X", ",", "cells", ")", ":", "dim", "=", "2", "mesh", "=", "MeshTri", "(", "X", ",", "cells", ")", "jac", "=", "numpy", ".", "zeros", "(", "X", ".", "shape", ")", "for", "k", "in", "range", "(", "mesh", ".", "cells", ...
The approximated Jacobian is partial_i E = 2/(d+1) (x_i int_{omega_i} rho(x) dx - int_{omega_i} x rho(x) dx) = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_{j, rho}) int_{tau_j} rho, see Chen-Holst. This method here assumes uniform density, rho(x) = 1, such that partial_i E = 2/(d+1) sum...
[ "The", "approximated", "Jacobian", "is" ]
b85f48d1559a51a01cc3df6214c61ca8ad5ed786
https://github.com/nschloe/optimesh/blob/b85f48d1559a51a01cc3df6214c61ca8ad5ed786/optimesh/cpt.py#L123-L147
12,103
nschloe/optimesh
optimesh/cpt.py
solve_hessian_approx_uniform
def solve_hessian_approx_uniform(X, cells, rhs): """As discussed above, the approximated Jacobian is partial_i E = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_j) |tau_j|. To get the Hessian, we have to form its derivative. As a simplifications, let us assume again that |tau_j| is independent of the node...
python
def solve_hessian_approx_uniform(X, cells, rhs): """As discussed above, the approximated Jacobian is partial_i E = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_j) |tau_j|. To get the Hessian, we have to form its derivative. As a simplifications, let us assume again that |tau_j| is independent of the node...
[ "def", "solve_hessian_approx_uniform", "(", "X", ",", "cells", ",", "rhs", ")", ":", "dim", "=", "2", "mesh", "=", "MeshTri", "(", "X", ",", "cells", ")", "# Create matrix in IJV format", "row_idx", "=", "[", "]", "col_idx", "=", "[", "]", "val", "=", ...
As discussed above, the approximated Jacobian is partial_i E = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_j) |tau_j|. To get the Hessian, we have to form its derivative. As a simplifications, let us assume again that |tau_j| is independent of the node positions. Then we get partial_ii E = 2/(d+1) |...
[ "As", "discussed", "above", "the", "approximated", "Jacobian", "is" ]
b85f48d1559a51a01cc3df6214c61ca8ad5ed786
https://github.com/nschloe/optimesh/blob/b85f48d1559a51a01cc3df6214c61ca8ad5ed786/optimesh/cpt.py#L150-L227
12,104
nschloe/optimesh
optimesh/cpt.py
quasi_newton_uniform
def quasi_newton_uniform(points, cells, *args, **kwargs): """Like linear_solve above, but assuming rho==1. Note that the energy gradient \\partial E_i = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_j) \\int_{tau_j} rho becomes \\partial E_i = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_j) |tau_j|. ...
python
def quasi_newton_uniform(points, cells, *args, **kwargs): """Like linear_solve above, but assuming rho==1. Note that the energy gradient \\partial E_i = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_j) \\int_{tau_j} rho becomes \\partial E_i = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_j) |tau_j|. ...
[ "def", "quasi_newton_uniform", "(", "points", ",", "cells", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "get_new_points", "(", "mesh", ")", ":", "# do one Newton step", "# TODO need copy?", "x", "=", "mesh", ".", "node_coords", ".", "copy", ...
Like linear_solve above, but assuming rho==1. Note that the energy gradient \\partial E_i = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_j) \\int_{tau_j} rho becomes \\partial E_i = 2/(d+1) sum_{tau_j in omega_i} (x_i - b_j) |tau_j|. Because of the dependence of |tau_j| on the point coordinates, ...
[ "Like", "linear_solve", "above", "but", "assuming", "rho", "==", "1", ".", "Note", "that", "the", "energy", "gradient" ]
b85f48d1559a51a01cc3df6214c61ca8ad5ed786
https://github.com/nschloe/optimesh/blob/b85f48d1559a51a01cc3df6214c61ca8ad5ed786/optimesh/cpt.py#L230-L257
12,105
nschloe/optimesh
optimesh/laplace.py
fixed_point
def fixed_point(points, cells, *args, **kwargs): """Perform k steps of Laplacian smoothing to the mesh, i.e., moving each interior vertex to the arithmetic average of its neighboring points. """ def get_new_points(mesh): # move interior points into average of their neighbors num_neighbo...
python
def fixed_point(points, cells, *args, **kwargs): """Perform k steps of Laplacian smoothing to the mesh, i.e., moving each interior vertex to the arithmetic average of its neighboring points. """ def get_new_points(mesh): # move interior points into average of their neighbors num_neighbo...
[ "def", "fixed_point", "(", "points", ",", "cells", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "get_new_points", "(", "mesh", ")", ":", "# move interior points into average of their neighbors", "num_neighbors", "=", "numpy", ".", "zeros", "(", ...
Perform k steps of Laplacian smoothing to the mesh, i.e., moving each interior vertex to the arithmetic average of its neighboring points.
[ "Perform", "k", "steps", "of", "Laplacian", "smoothing", "to", "the", "mesh", "i", ".", "e", ".", "moving", "each", "interior", "vertex", "to", "the", "arithmetic", "average", "of", "its", "neighboring", "points", "." ]
b85f48d1559a51a01cc3df6214c61ca8ad5ed786
https://github.com/nschloe/optimesh/blob/b85f48d1559a51a01cc3df6214c61ca8ad5ed786/optimesh/laplace.py#L12-L34
12,106
nschloe/optimesh
optimesh/odt.py
energy
def energy(mesh, uniform_density=False): """The mesh energy is defined as E = int_Omega |u_l(x) - u(x)| rho(x) dx where u(x) = ||x||^2 and u_l is its piecewise linearization on the mesh. """ # E = 1/(d+1) sum_i ||x_i||^2 |omega_i| - int_Omega_i ||x||^2 dim = mesh.cells["nodes"].shape[1] - 1 ...
python
def energy(mesh, uniform_density=False): """The mesh energy is defined as E = int_Omega |u_l(x) - u(x)| rho(x) dx where u(x) = ||x||^2 and u_l is its piecewise linearization on the mesh. """ # E = 1/(d+1) sum_i ||x_i||^2 |omega_i| - int_Omega_i ||x||^2 dim = mesh.cells["nodes"].shape[1] - 1 ...
[ "def", "energy", "(", "mesh", ",", "uniform_density", "=", "False", ")", ":", "# E = 1/(d+1) sum_i ||x_i||^2 |omega_i| - int_Omega_i ||x||^2", "dim", "=", "mesh", ".", "cells", "[", "\"nodes\"", "]", ".", "shape", "[", "1", "]", "-", "1", "star_volume", "=", "...
The mesh energy is defined as E = int_Omega |u_l(x) - u(x)| rho(x) dx where u(x) = ||x||^2 and u_l is its piecewise linearization on the mesh.
[ "The", "mesh", "energy", "is", "defined", "as" ]
b85f48d1559a51a01cc3df6214c61ca8ad5ed786
https://github.com/nschloe/optimesh/blob/b85f48d1559a51a01cc3df6214c61ca8ad5ed786/optimesh/odt.py#L28-L70
12,107
nschloe/optimesh
optimesh/cvt/block_diagonal.py
quasi_newton_uniform_blocks
def quasi_newton_uniform_blocks(points, cells, *args, **kwargs): """Lloyd's algorithm can be though of a diagonal-only Hessian; this method incorporates the diagonal blocks, too. """ def get_new_points(mesh): # TODO need copy? x = mesh.node_coords.copy() x += update(mesh) ...
python
def quasi_newton_uniform_blocks(points, cells, *args, **kwargs): """Lloyd's algorithm can be though of a diagonal-only Hessian; this method incorporates the diagonal blocks, too. """ def get_new_points(mesh): # TODO need copy? x = mesh.node_coords.copy() x += update(mesh) ...
[ "def", "quasi_newton_uniform_blocks", "(", "points", ",", "cells", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "get_new_points", "(", "mesh", ")", ":", "# TODO need copy?", "x", "=", "mesh", ".", "node_coords", ".", "copy", "(", ")", "x",...
Lloyd's algorithm can be though of a diagonal-only Hessian; this method incorporates the diagonal blocks, too.
[ "Lloyd", "s", "algorithm", "can", "be", "though", "of", "a", "diagonal", "-", "only", "Hessian", ";", "this", "method", "incorporates", "the", "diagonal", "blocks", "too", "." ]
b85f48d1559a51a01cc3df6214c61ca8ad5ed786
https://github.com/nschloe/optimesh/blob/b85f48d1559a51a01cc3df6214c61ca8ad5ed786/optimesh/cvt/block_diagonal.py#L12-L39
12,108
linnarsson-lab/loompy
loompy/loompy.py
new
def new(filename: str, *, file_attrs: Optional[Dict[str, str]] = None) -> LoomConnection: """ Create an empty Loom file, and return it as a context manager. """ if filename.startswith("~/"): filename = os.path.expanduser(filename) if file_attrs is None: file_attrs = {} # Create the file (empty). # Yes, this...
python
def new(filename: str, *, file_attrs: Optional[Dict[str, str]] = None) -> LoomConnection: """ Create an empty Loom file, and return it as a context manager. """ if filename.startswith("~/"): filename = os.path.expanduser(filename) if file_attrs is None: file_attrs = {} # Create the file (empty). # Yes, this...
[ "def", "new", "(", "filename", ":", "str", ",", "*", ",", "file_attrs", ":", "Optional", "[", "Dict", "[", "str", ",", "str", "]", "]", "=", "None", ")", "->", "LoomConnection", ":", "if", "filename", ".", "startswith", "(", "\"~/\"", ")", ":", "fi...
Create an empty Loom file, and return it as a context manager.
[ "Create", "an", "empty", "Loom", "file", "and", "return", "it", "as", "a", "context", "manager", "." ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L993-L1020
12,109
linnarsson-lab/loompy
loompy/loompy.py
create
def create(filename: str, layers: Union[np.ndarray, Dict[str, np.ndarray], loompy.LayerManager], row_attrs: Union[loompy.AttributeManager, Dict[str, np.ndarray]], col_attrs: Union[loompy.AttributeManager, Dict[str, np.ndarray]], *, file_attrs: Dict[str, str] = None) -> None: """ Create a new Loom file from the given ...
python
def create(filename: str, layers: Union[np.ndarray, Dict[str, np.ndarray], loompy.LayerManager], row_attrs: Union[loompy.AttributeManager, Dict[str, np.ndarray]], col_attrs: Union[loompy.AttributeManager, Dict[str, np.ndarray]], *, file_attrs: Dict[str, str] = None) -> None: """ Create a new Loom file from the given ...
[ "def", "create", "(", "filename", ":", "str", ",", "layers", ":", "Union", "[", "np", ".", "ndarray", ",", "Dict", "[", "str", ",", "np", ".", "ndarray", "]", ",", "loompy", ".", "LayerManager", "]", ",", "row_attrs", ":", "Union", "[", "loompy", "...
Create a new Loom file from the given data. Args: filename (str): The filename (typically using a ``.loom`` file extension) layers: One of the following: * Two-dimensional (N-by-M) numpy ndarray of float values * Sparse matrix (e.g. :class:`scipy.sparse.csr_matrix`) * Dictiona...
[ "Create", "a", "new", "Loom", "file", "from", "the", "given", "data", "." ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L1023-L1089
12,110
linnarsson-lab/loompy
loompy/loompy.py
connect
def connect(filename: str, mode: str = 'r+', *, validate: bool = True, spec_version: str = "2.0.1") -> LoomConnection: """ Establish a connection to a .loom file. Args: filename: Path to the Loom file to open mode: Read/write mode, 'r+' (read/write) or 'r' (read-only), defaults to 'r+' validate: Validate ...
python
def connect(filename: str, mode: str = 'r+', *, validate: bool = True, spec_version: str = "2.0.1") -> LoomConnection: """ Establish a connection to a .loom file. Args: filename: Path to the Loom file to open mode: Read/write mode, 'r+' (read/write) or 'r' (read-only), defaults to 'r+' validate: Validate ...
[ "def", "connect", "(", "filename", ":", "str", ",", "mode", ":", "str", "=", "'r+'", ",", "*", ",", "validate", ":", "bool", "=", "True", ",", "spec_version", ":", "str", "=", "\"2.0.1\"", ")", "->", "LoomConnection", ":", "return", "LoomConnection", "...
Establish a connection to a .loom file. Args: filename: Path to the Loom file to open mode: Read/write mode, 'r+' (read/write) or 'r' (read-only), defaults to 'r+' validate: Validate the file structure against the Loom file format specification spec_version: The loom file spec version to validate against ...
[ "Establish", "a", "connection", "to", "a", ".", "loom", "file", "." ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L1290-L1316
12,111
linnarsson-lab/loompy
loompy/loompy.py
LoomConnection.last_modified
def last_modified(self) -> str: """ Return an ISO8601 timestamp indicating when the file was last modified Returns: An ISO8601 timestamp indicating when the file was last modified Remarks: If the file has no timestamp, and mode is 'r+', a new timestamp is created and returned. Otherwise, the current ...
python
def last_modified(self) -> str: """ Return an ISO8601 timestamp indicating when the file was last modified Returns: An ISO8601 timestamp indicating when the file was last modified Remarks: If the file has no timestamp, and mode is 'r+', a new timestamp is created and returned. Otherwise, the current ...
[ "def", "last_modified", "(", "self", ")", "->", "str", ":", "if", "\"last_modified\"", "in", "self", ".", "attrs", ":", "return", "self", ".", "attrs", "[", "\"last_modified\"", "]", "elif", "self", ".", "mode", "==", "\"r+\"", ":", "# Make sure the file has...
Return an ISO8601 timestamp indicating when the file was last modified Returns: An ISO8601 timestamp indicating when the file was last modified Remarks: If the file has no timestamp, and mode is 'r+', a new timestamp is created and returned. Otherwise, the current time in UTC is returned
[ "Return", "an", "ISO8601", "timestamp", "indicating", "when", "the", "file", "was", "last", "modified" ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L115-L132
12,112
linnarsson-lab/loompy
loompy/loompy.py
LoomConnection.get_changes_since
def get_changes_since(self, timestamp: str) -> Dict[str, List]: """ Get a summary of the parts of the file that changed since the given time Args: timestamp: ISO8601 timestamp Return: dict: Dictionary like ``{"row_graphs": rg, "col_graphs": cg, "row_attrs": ra, "col_attrs": ca, "layers": layers}`` listi...
python
def get_changes_since(self, timestamp: str) -> Dict[str, List]: """ Get a summary of the parts of the file that changed since the given time Args: timestamp: ISO8601 timestamp Return: dict: Dictionary like ``{"row_graphs": rg, "col_graphs": cg, "row_attrs": ra, "col_attrs": ca, "layers": layers}`` listi...
[ "def", "get_changes_since", "(", "self", ",", "timestamp", ":", "str", ")", "->", "Dict", "[", "str", ",", "List", "]", ":", "rg", "=", "[", "]", "cg", "=", "[", "]", "ra", "=", "[", "]", "ca", "=", "[", "]", "layers", "=", "[", "]", "if", ...
Get a summary of the parts of the file that changed since the given time Args: timestamp: ISO8601 timestamp Return: dict: Dictionary like ``{"row_graphs": rg, "col_graphs": cg, "row_attrs": ra, "col_attrs": ca, "layers": layers}`` listing the names of objects that were modified since the given time
[ "Get", "a", "summary", "of", "the", "parts", "of", "the", "file", "that", "changed", "since", "the", "given", "time" ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L134-L171
12,113
linnarsson-lab/loompy
loompy/loompy.py
LoomConnection.sparse
def sparse(self, rows: np.ndarray = None, cols: np.ndarray = None, layer: str = None) -> scipy.sparse.coo_matrix: """ Return the main matrix or specified layer as a scipy.sparse.coo_matrix, without loading dense matrix in RAM Args: rows: Rows to include, or None to include all cols: Columns to include, o...
python
def sparse(self, rows: np.ndarray = None, cols: np.ndarray = None, layer: str = None) -> scipy.sparse.coo_matrix: """ Return the main matrix or specified layer as a scipy.sparse.coo_matrix, without loading dense matrix in RAM Args: rows: Rows to include, or None to include all cols: Columns to include, o...
[ "def", "sparse", "(", "self", ",", "rows", ":", "np", ".", "ndarray", "=", "None", ",", "cols", ":", "np", ".", "ndarray", "=", "None", ",", "layer", ":", "str", "=", "None", ")", "->", "scipy", ".", "sparse", ".", "coo_matrix", ":", "if", "layer...
Return the main matrix or specified layer as a scipy.sparse.coo_matrix, without loading dense matrix in RAM Args: rows: Rows to include, or None to include all cols: Columns to include, or None to include all layer: Layer to return, or None to return the default layer Returns: Sparse matrix (:class...
[ "Return", "the", "main", "matrix", "or", "specified", "layer", "as", "a", "scipy", ".", "sparse", ".", "coo_matrix", "without", "loading", "dense", "matrix", "in", "RAM" ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L229-L244
12,114
linnarsson-lab/loompy
loompy/loompy.py
LoomConnection.close
def close(self, suppress_warning: bool = False) -> None: """ Close the connection. After this, the connection object becomes invalid. Warns user if called after closing. Args: suppress_warning: Suppresses warning message if True (defaults to false) """ if self._file is None: if not suppress_warning: ...
python
def close(self, suppress_warning: bool = False) -> None: """ Close the connection. After this, the connection object becomes invalid. Warns user if called after closing. Args: suppress_warning: Suppresses warning message if True (defaults to false) """ if self._file is None: if not suppress_warning: ...
[ "def", "close", "(", "self", ",", "suppress_warning", ":", "bool", "=", "False", ")", "->", "None", ":", "if", "self", ".", "_file", "is", "None", ":", "if", "not", "suppress_warning", ":", "# Warn user that they're being paranoid", "# and should clean up their co...
Close the connection. After this, the connection object becomes invalid. Warns user if called after closing. Args: suppress_warning: Suppresses warning message if True (defaults to false)
[ "Close", "the", "connection", ".", "After", "this", "the", "connection", "object", "becomes", "invalid", ".", "Warns", "user", "if", "called", "after", "closing", "." ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L246-L269
12,115
linnarsson-lab/loompy
loompy/loompy.py
LoomConnection.permute
def permute(self, ordering: np.ndarray, axis: int) -> None: """ Permute the dataset along the indicated axis. Args: ordering (list of int): The desired order along the axis axis (int): The axis along which to permute Returns: Nothing. """ if self._file.__contains__("tiles"): del self._fi...
python
def permute(self, ordering: np.ndarray, axis: int) -> None: """ Permute the dataset along the indicated axis. Args: ordering (list of int): The desired order along the axis axis (int): The axis along which to permute Returns: Nothing. """ if self._file.__contains__("tiles"): del self._fi...
[ "def", "permute", "(", "self", ",", "ordering", ":", "np", ".", "ndarray", ",", "axis", ":", "int", ")", "->", "None", ":", "if", "self", ".", "_file", ".", "__contains__", "(", "\"tiles\"", ")", ":", "del", "self", ".", "_file", "[", "'tiles'", "]...
Permute the dataset along the indicated axis. Args: ordering (list of int): The desired order along the axis axis (int): The axis along which to permute Returns: Nothing.
[ "Permute", "the", "dataset", "along", "the", "indicated", "axis", "." ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L784-L806
12,116
linnarsson-lab/loompy
loompy/loompy.py
LoomConnection.aggregate
def aggregate(self, out_file: str = None, select: np.ndarray = None, group_by: Union[str, np.ndarray] = "Clusters", aggr_by: str = "mean", aggr_ca_by: Dict[str, str] = None) -> np.ndarray: """ Aggregate the Loom file by applying aggregation functions to the main matrix as well as to the column attributes Args: ...
python
def aggregate(self, out_file: str = None, select: np.ndarray = None, group_by: Union[str, np.ndarray] = "Clusters", aggr_by: str = "mean", aggr_ca_by: Dict[str, str] = None) -> np.ndarray: """ Aggregate the Loom file by applying aggregation functions to the main matrix as well as to the column attributes Args: ...
[ "def", "aggregate", "(", "self", ",", "out_file", ":", "str", "=", "None", ",", "select", ":", "np", ".", "ndarray", "=", "None", ",", "group_by", ":", "Union", "[", "str", ",", "np", ".", "ndarray", "]", "=", "\"Clusters\"", ",", "aggr_by", ":", "...
Aggregate the Loom file by applying aggregation functions to the main matrix as well as to the column attributes Args: out_file The name of the output Loom file (will be appended to if it exists) select Bool array giving the columns to include (or None, to include all) group_by The column attribute to grou...
[ "Aggregate", "the", "Loom", "file", "by", "applying", "aggregation", "functions", "to", "the", "main", "matrix", "as", "well", "as", "to", "the", "column", "attributes" ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loompy.py#L873-L934
12,117
linnarsson-lab/loompy
loompy/file_attribute_manager.py
FileAttributeManager.get
def get(self, name: str, default: Any = None) -> np.ndarray: """ Return the value for a named attribute if it exists, else default. If default is not given, it defaults to None, so that this method never raises a KeyError. """ if name in self: return self[name] else: return default
python
def get(self, name: str, default: Any = None) -> np.ndarray: """ Return the value for a named attribute if it exists, else default. If default is not given, it defaults to None, so that this method never raises a KeyError. """ if name in self: return self[name] else: return default
[ "def", "get", "(", "self", ",", "name", ":", "str", ",", "default", ":", "Any", "=", "None", ")", "->", "np", ".", "ndarray", ":", "if", "name", "in", "self", ":", "return", "self", "[", "name", "]", "else", ":", "return", "default" ]
Return the value for a named attribute if it exists, else default. If default is not given, it defaults to None, so that this method never raises a KeyError.
[ "Return", "the", "value", "for", "a", "named", "attribute", "if", "it", "exists", "else", "default", ".", "If", "default", "is", "not", "given", "it", "defaults", "to", "None", "so", "that", "this", "method", "never", "raises", "a", "KeyError", "." ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/file_attribute_manager.py#L78-L86
12,118
linnarsson-lab/loompy
loompy/color.py
cat_colors
def cat_colors(N: int = 1, *, hue: str = None, luminosity: str = None, bgvalue: int = None, loop: bool = False, seed: str = "cat") -> Union[List[Any], colors.LinearSegmentedColormap]: """ Return a colormap suitable for N categorical values, optimized to be both aesthetically pleasing and perceptually distinct. Args...
python
def cat_colors(N: int = 1, *, hue: str = None, luminosity: str = None, bgvalue: int = None, loop: bool = False, seed: str = "cat") -> Union[List[Any], colors.LinearSegmentedColormap]: """ Return a colormap suitable for N categorical values, optimized to be both aesthetically pleasing and perceptually distinct. Args...
[ "def", "cat_colors", "(", "N", ":", "int", "=", "1", ",", "*", ",", "hue", ":", "str", "=", "None", ",", "luminosity", ":", "str", "=", "None", ",", "bgvalue", ":", "int", "=", "None", ",", "loop", ":", "bool", "=", "False", ",", "seed", ":", ...
Return a colormap suitable for N categorical values, optimized to be both aesthetically pleasing and perceptually distinct. Args: N The number of colors requested. hue Controls the hue of the generated color. You can pass a string representing a color name: "red", "orange", "yellow", "green", "blue", "purple"...
[ "Return", "a", "colormap", "suitable", "for", "N", "categorical", "values", "optimized", "to", "be", "both", "aesthetically", "pleasing", "and", "perceptually", "distinct", "." ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/color.py#L336-L367
12,119
linnarsson-lab/loompy
loompy/graph_manager.py
_renumber
def _renumber(a: np.ndarray, keys: np.ndarray, values: np.ndarray) -> np.ndarray: """ Renumber 'a' by replacing any occurrence of 'keys' by the corresponding 'values' """ ordering = np.argsort(keys) keys = keys[ordering] values = keys[ordering] index = np.digitize(a.ravel(), keys, right=True) return(values[inde...
python
def _renumber(a: np.ndarray, keys: np.ndarray, values: np.ndarray) -> np.ndarray: """ Renumber 'a' by replacing any occurrence of 'keys' by the corresponding 'values' """ ordering = np.argsort(keys) keys = keys[ordering] values = keys[ordering] index = np.digitize(a.ravel(), keys, right=True) return(values[inde...
[ "def", "_renumber", "(", "a", ":", "np", ".", "ndarray", ",", "keys", ":", "np", ".", "ndarray", ",", "values", ":", "np", ".", "ndarray", ")", "->", "np", ".", "ndarray", ":", "ordering", "=", "np", ".", "argsort", "(", "keys", ")", "keys", "=",...
Renumber 'a' by replacing any occurrence of 'keys' by the corresponding 'values'
[ "Renumber", "a", "by", "replacing", "any", "occurrence", "of", "keys", "by", "the", "corresponding", "values" ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/graph_manager.py#L7-L15
12,120
linnarsson-lab/loompy
loompy/loom_validator.py
LoomValidator.validate
def validate(self, path: str, strictness: str = "speconly") -> bool: """ Validate a file for conformance to the Loom specification Args: path: Full path to the file to be validated strictness: "speconly" or "conventions" Remarks: In "speconly" mode, conformance is assessed relative to the file fo...
python
def validate(self, path: str, strictness: str = "speconly") -> bool: """ Validate a file for conformance to the Loom specification Args: path: Full path to the file to be validated strictness: "speconly" or "conventions" Remarks: In "speconly" mode, conformance is assessed relative to the file fo...
[ "def", "validate", "(", "self", ",", "path", ":", "str", ",", "strictness", ":", "str", "=", "\"speconly\"", ")", "->", "bool", ":", "valid1", "=", "True", "with", "h5py", ".", "File", "(", "path", ",", "mode", "=", "\"r\"", ")", "as", "f", ":", ...
Validate a file for conformance to the Loom specification Args: path: Full path to the file to be validated strictness: "speconly" or "conventions" Remarks: In "speconly" mode, conformance is assessed relative to the file format specification at http://linnarssonlab.org/loompy/format/. In "convent...
[ "Validate", "a", "file", "for", "conformance", "to", "the", "Loom", "specification" ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loom_validator.py#L34-L60
12,121
linnarsson-lab/loompy
loompy/attribute_manager.py
AttributeManager._permute
def _permute(self, ordering: np.ndarray) -> None: """ Permute all the attributes in the collection Remarks: This permutes the order of the values for each attribute in the file """ for key in self.keys(): self[key] = self[key][ordering]
python
def _permute(self, ordering: np.ndarray) -> None: """ Permute all the attributes in the collection Remarks: This permutes the order of the values for each attribute in the file """ for key in self.keys(): self[key] = self[key][ordering]
[ "def", "_permute", "(", "self", ",", "ordering", ":", "np", ".", "ndarray", ")", "->", "None", ":", "for", "key", "in", "self", ".", "keys", "(", ")", ":", "self", "[", "key", "]", "=", "self", "[", "key", "]", "[", "ordering", "]" ]
Permute all the attributes in the collection Remarks: This permutes the order of the values for each attribute in the file
[ "Permute", "all", "the", "attributes", "in", "the", "collection" ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/attribute_manager.py#L180-L188
12,122
linnarsson-lab/loompy
loompy/attribute_manager.py
AttributeManager.get
def get(self, name: str, default: np.ndarray) -> np.ndarray: """ Return the value for a named attribute if it exists, else default. Default has to be a numpy array of correct size. """ if name in self: return self[name] else: if not isinstance(default, np.ndarray): raise ValueError(f"Default must...
python
def get(self, name: str, default: np.ndarray) -> np.ndarray: """ Return the value for a named attribute if it exists, else default. Default has to be a numpy array of correct size. """ if name in self: return self[name] else: if not isinstance(default, np.ndarray): raise ValueError(f"Default must...
[ "def", "get", "(", "self", ",", "name", ":", "str", ",", "default", ":", "np", ".", "ndarray", ")", "->", "np", ".", "ndarray", ":", "if", "name", "in", "self", ":", "return", "self", "[", "name", "]", "else", ":", "if", "not", "isinstance", "(",...
Return the value for a named attribute if it exists, else default. Default has to be a numpy array of correct size.
[ "Return", "the", "value", "for", "a", "named", "attribute", "if", "it", "exists", "else", "default", ".", "Default", "has", "to", "be", "a", "numpy", "array", "of", "correct", "size", "." ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/attribute_manager.py#L190-L205
12,123
linnarsson-lab/loompy
loompy/normalize.py
normalize_attr_array
def normalize_attr_array(a: Any) -> np.ndarray: """ Take all kinds of array-like inputs and normalize to a one-dimensional np.ndarray """ if type(a) is np.ndarray: return a elif type(a) is np.matrix: if a.shape[0] == 1: return np.array(a)[0, :] elif a.shape[1] == 1: return np.array(a)[:, 0] else: ...
python
def normalize_attr_array(a: Any) -> np.ndarray: """ Take all kinds of array-like inputs and normalize to a one-dimensional np.ndarray """ if type(a) is np.ndarray: return a elif type(a) is np.matrix: if a.shape[0] == 1: return np.array(a)[0, :] elif a.shape[1] == 1: return np.array(a)[:, 0] else: ...
[ "def", "normalize_attr_array", "(", "a", ":", "Any", ")", "->", "np", ".", "ndarray", ":", "if", "type", "(", "a", ")", "is", "np", ".", "ndarray", ":", "return", "a", "elif", "type", "(", "a", ")", "is", "np", ".", "matrix", ":", "if", "a", "....
Take all kinds of array-like inputs and normalize to a one-dimensional np.ndarray
[ "Take", "all", "kinds", "of", "array", "-", "like", "inputs", "and", "normalize", "to", "a", "one", "-", "dimensional", "np", ".", "ndarray" ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/normalize.py#L29-L47
12,124
linnarsson-lab/loompy
loompy/to_html.py
to_html
def to_html(ds: Any) -> str: """ Return an HTML representation of the loom file or view, showing the upper-left 10x10 corner. """ rm = min(10, ds.shape[0]) cm = min(10, ds.shape[1]) html = "<p>" if ds.attrs.__contains__("title"): html += "<strong>" + ds.attrs["title"] + "</strong> " html += f"{ds.shape[0]} ro...
python
def to_html(ds: Any) -> str: """ Return an HTML representation of the loom file or view, showing the upper-left 10x10 corner. """ rm = min(10, ds.shape[0]) cm = min(10, ds.shape[1]) html = "<p>" if ds.attrs.__contains__("title"): html += "<strong>" + ds.attrs["title"] + "</strong> " html += f"{ds.shape[0]} ro...
[ "def", "to_html", "(", "ds", ":", "Any", ")", "->", "str", ":", "rm", "=", "min", "(", "10", ",", "ds", ".", "shape", "[", "0", "]", ")", "cm", "=", "min", "(", "10", ",", "ds", ".", "shape", "[", "1", "]", ")", "html", "=", "\"<p>\"", "i...
Return an HTML representation of the loom file or view, showing the upper-left 10x10 corner.
[ "Return", "an", "HTML", "representation", "of", "the", "loom", "file", "or", "view", "showing", "the", "upper", "-", "left", "10x10", "corner", "." ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/to_html.py#L4-L62
12,125
linnarsson-lab/loompy
loompy/loom_view.py
LoomView.permute
def permute(self, ordering: np.ndarray, *, axis: int) -> None: """ Permute the view, by permuting its layers, attributes and graphs Args: ordering (np.ndarray): The desired ordering along the axis axis (int): 0, permute rows; 1, permute columns """ if axis not in (0, 1): raise ValueError("Axis mu...
python
def permute(self, ordering: np.ndarray, *, axis: int) -> None: """ Permute the view, by permuting its layers, attributes and graphs Args: ordering (np.ndarray): The desired ordering along the axis axis (int): 0, permute rows; 1, permute columns """ if axis not in (0, 1): raise ValueError("Axis mu...
[ "def", "permute", "(", "self", ",", "ordering", ":", "np", ".", "ndarray", ",", "*", ",", "axis", ":", "int", ")", "->", "None", ":", "if", "axis", "not", "in", "(", "0", ",", "1", ")", ":", "raise", "ValueError", "(", "\"Axis must be 0 (rows) or 1 (...
Permute the view, by permuting its layers, attributes and graphs Args: ordering (np.ndarray): The desired ordering along the axis axis (int): 0, permute rows; 1, permute columns
[ "Permute", "the", "view", "by", "permuting", "its", "layers", "attributes", "and", "graphs" ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loom_view.py#L45-L68
12,126
linnarsson-lab/loompy
loompy/loom_layer.py
MemoryLoomLayer.permute
def permute(self, ordering: np.ndarray, *, axis: int) -> None: """ Permute the layer along an axis Args: axis: The axis to permute (0, permute the rows; 1, permute the columns) ordering: The permutation vector """ if axis == 0: self.values = self.values[ordering, :] elif axis == 1: self.values ...
python
def permute(self, ordering: np.ndarray, *, axis: int) -> None: """ Permute the layer along an axis Args: axis: The axis to permute (0, permute the rows; 1, permute the columns) ordering: The permutation vector """ if axis == 0: self.values = self.values[ordering, :] elif axis == 1: self.values ...
[ "def", "permute", "(", "self", ",", "ordering", ":", "np", ".", "ndarray", ",", "*", ",", "axis", ":", "int", ")", "->", "None", ":", "if", "axis", "==", "0", ":", "self", ".", "values", "=", "self", ".", "values", "[", "ordering", ",", ":", "]...
Permute the layer along an axis Args: axis: The axis to permute (0, permute the rows; 1, permute the columns) ordering: The permutation vector
[ "Permute", "the", "layer", "along", "an", "axis" ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loom_layer.py#L30-L43
12,127
linnarsson-lab/loompy
loompy/loom_layer.py
LoomLayer._resize
def _resize(self, size: Tuple[int, int], axis: int = None) -> None: """Resize the dataset, or the specified axis. The dataset must be stored in chunked format; it can be resized up to the "maximum shape" (keyword maxshape) specified at creation time. The rank of the dataset cannot be changed. "Size" should be ...
python
def _resize(self, size: Tuple[int, int], axis: int = None) -> None: """Resize the dataset, or the specified axis. The dataset must be stored in chunked format; it can be resized up to the "maximum shape" (keyword maxshape) specified at creation time. The rank of the dataset cannot be changed. "Size" should be ...
[ "def", "_resize", "(", "self", ",", "size", ":", "Tuple", "[", "int", ",", "int", "]", ",", "axis", ":", "int", "=", "None", ")", "->", "None", ":", "if", "self", ".", "name", "==", "\"\"", ":", "self", ".", "ds", ".", "_file", "[", "'/matrix'"...
Resize the dataset, or the specified axis. The dataset must be stored in chunked format; it can be resized up to the "maximum shape" (keyword maxshape) specified at creation time. The rank of the dataset cannot be changed. "Size" should be a shape tuple, or if an axis is specified, an integer. BEWARE: This fu...
[ "Resize", "the", "dataset", "or", "the", "specified", "axis", "." ]
62c8373a92b058753baa3a95331fb541f560f599
https://github.com/linnarsson-lab/loompy/blob/62c8373a92b058753baa3a95331fb541f560f599/loompy/loom_layer.py#L130-L144
12,128
optimizely/python-sdk
optimizely/helpers/validator.py
is_datafile_valid
def is_datafile_valid(datafile): """ Given a datafile determine if it is valid or not. Args: datafile: JSON string representing the project. Returns: Boolean depending upon whether datafile is valid or not. """ try: datafile_json = json.loads(datafile) except: return False try: jso...
python
def is_datafile_valid(datafile): """ Given a datafile determine if it is valid or not. Args: datafile: JSON string representing the project. Returns: Boolean depending upon whether datafile is valid or not. """ try: datafile_json = json.loads(datafile) except: return False try: jso...
[ "def", "is_datafile_valid", "(", "datafile", ")", ":", "try", ":", "datafile_json", "=", "json", ".", "loads", "(", "datafile", ")", "except", ":", "return", "False", "try", ":", "jsonschema", ".", "Draft4Validator", "(", "constants", ".", "JSON_SCHEMA", ")"...
Given a datafile determine if it is valid or not. Args: datafile: JSON string representing the project. Returns: Boolean depending upon whether datafile is valid or not.
[ "Given", "a", "datafile", "determine", "if", "it", "is", "valid", "or", "not", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/validator.py#L24-L44
12,129
optimizely/python-sdk
optimizely/helpers/validator.py
is_user_profile_valid
def is_user_profile_valid(user_profile): """ Determine if provided user profile is valid or not. Args: user_profile: User's profile which needs to be validated. Returns: Boolean depending upon whether profile is valid or not. """ if not user_profile: return False if not type(user_profile) is...
python
def is_user_profile_valid(user_profile): """ Determine if provided user profile is valid or not. Args: user_profile: User's profile which needs to be validated. Returns: Boolean depending upon whether profile is valid or not. """ if not user_profile: return False if not type(user_profile) is...
[ "def", "is_user_profile_valid", "(", "user_profile", ")", ":", "if", "not", "user_profile", ":", "return", "False", "if", "not", "type", "(", "user_profile", ")", "is", "dict", ":", "return", "False", "if", "UserProfile", ".", "USER_ID_KEY", "not", "in", "us...
Determine if provided user profile is valid or not. Args: user_profile: User's profile which needs to be validated. Returns: Boolean depending upon whether profile is valid or not.
[ "Determine", "if", "provided", "user", "profile", "is", "valid", "or", "not", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/validator.py#L126-L156
12,130
optimizely/python-sdk
optimizely/helpers/validator.py
is_attribute_valid
def is_attribute_valid(attribute_key, attribute_value): """ Determine if given attribute is valid. Args: attribute_key: Variable which needs to be validated attribute_value: Variable which needs to be validated Returns: False if attribute_key is not a string False if attribute_value is not one o...
python
def is_attribute_valid(attribute_key, attribute_value): """ Determine if given attribute is valid. Args: attribute_key: Variable which needs to be validated attribute_value: Variable which needs to be validated Returns: False if attribute_key is not a string False if attribute_value is not one o...
[ "def", "is_attribute_valid", "(", "attribute_key", ",", "attribute_value", ")", ":", "if", "not", "isinstance", "(", "attribute_key", ",", "string_types", ")", ":", "return", "False", "if", "isinstance", "(", "attribute_value", ",", "(", "string_types", ",", "bo...
Determine if given attribute is valid. Args: attribute_key: Variable which needs to be validated attribute_value: Variable which needs to be validated Returns: False if attribute_key is not a string False if attribute_value is not one of the supported attribute types True otherwise
[ "Determine", "if", "given", "attribute", "is", "valid", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/validator.py#L174-L196
12,131
optimizely/python-sdk
optimizely/helpers/validator.py
is_finite_number
def is_finite_number(value): """ Validates if the given value is a number, enforces absolute limit of 2^53 and restricts NAN, INF, -INF. Args: value: Value to be validated. Returns: Boolean: True if value is a number and not NAN, INF, -INF or greater than absolute limit of 2^53 else Fals...
python
def is_finite_number(value): """ Validates if the given value is a number, enforces absolute limit of 2^53 and restricts NAN, INF, -INF. Args: value: Value to be validated. Returns: Boolean: True if value is a number and not NAN, INF, -INF or greater than absolute limit of 2^53 else Fals...
[ "def", "is_finite_number", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "numbers", ".", "Integral", ",", "float", ")", ")", ":", "# numbers.Integral instead of int to accomodate long integer in python 2", "return", "False", "if", "isins...
Validates if the given value is a number, enforces absolute limit of 2^53 and restricts NAN, INF, -INF. Args: value: Value to be validated. Returns: Boolean: True if value is a number and not NAN, INF, -INF or greater than absolute limit of 2^53 else False.
[ "Validates", "if", "the", "given", "value", "is", "a", "number", "enforces", "absolute", "limit", "of", "2^53", "and", "restricts", "NAN", "INF", "-", "INF", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/validator.py#L199-L225
12,132
optimizely/python-sdk
optimizely/helpers/validator.py
are_values_same_type
def are_values_same_type(first_val, second_val): """ Method to verify that both values belong to same type. Float and integer are considered as same type. Args: first_val: Value to validate. second_Val: Value to validate. Returns: Boolean: True if both values belong to same type. Otherwise False. ...
python
def are_values_same_type(first_val, second_val): """ Method to verify that both values belong to same type. Float and integer are considered as same type. Args: first_val: Value to validate. second_Val: Value to validate. Returns: Boolean: True if both values belong to same type. Otherwise False. ...
[ "def", "are_values_same_type", "(", "first_val", ",", "second_val", ")", ":", "first_val_type", "=", "type", "(", "first_val", ")", "second_val_type", "=", "type", "(", "second_val", ")", "# use isinstance to accomodate Python 2 unicode and str types.", "if", "isinstance"...
Method to verify that both values belong to same type. Float and integer are considered as same type. Args: first_val: Value to validate. second_Val: Value to validate. Returns: Boolean: True if both values belong to same type. Otherwise False.
[ "Method", "to", "verify", "that", "both", "values", "belong", "to", "same", "type", ".", "Float", "and", "integer", "are", "considered", "as", "same", "type", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/validator.py#L228-L255
12,133
optimizely/python-sdk
optimizely/logger.py
reset_logger
def reset_logger(name, level=None, handler=None): """ Make a standard python logger object with default formatter, handler, etc. Defaults are: - level == logging.INFO - handler == logging.StreamHandler() Args: name: a logger name. level: an optional initial log level for this logger. handl...
python
def reset_logger(name, level=None, handler=None): """ Make a standard python logger object with default formatter, handler, etc. Defaults are: - level == logging.INFO - handler == logging.StreamHandler() Args: name: a logger name. level: an optional initial log level for this logger. handl...
[ "def", "reset_logger", "(", "name", ",", "level", "=", "None", ",", "handler", "=", "None", ")", ":", "# Make the logger and set its level.", "if", "level", "is", "None", ":", "level", "=", "logging", ".", "INFO", "logger", "=", "logging", ".", "getLogger", ...
Make a standard python logger object with default formatter, handler, etc. Defaults are: - level == logging.INFO - handler == logging.StreamHandler() Args: name: a logger name. level: an optional initial log level for this logger. handler: an optional initial handler for this logger. Return...
[ "Make", "a", "standard", "python", "logger", "object", "with", "default", "formatter", "handler", "etc", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/logger.py#L22-L52
12,134
optimizely/python-sdk
optimizely/logger.py
adapt_logger
def adapt_logger(logger): """ Adapt our custom logger.BaseLogger object into a standard logging.Logger object. Adaptations are: - NoOpLogger turns into a logger with a single NullHandler. - SimpleLogger turns into a logger with a StreamHandler and level. Args: logger: Possibly a logger.BaseLogger,...
python
def adapt_logger(logger): """ Adapt our custom logger.BaseLogger object into a standard logging.Logger object. Adaptations are: - NoOpLogger turns into a logger with a single NullHandler. - SimpleLogger turns into a logger with a StreamHandler and level. Args: logger: Possibly a logger.BaseLogger,...
[ "def", "adapt_logger", "(", "logger", ")", ":", "if", "isinstance", "(", "logger", ",", "logging", ".", "Logger", ")", ":", "return", "logger", "# Use the standard python logger created by these classes.", "if", "isinstance", "(", "logger", ",", "(", "SimpleLogger",...
Adapt our custom logger.BaseLogger object into a standard logging.Logger object. Adaptations are: - NoOpLogger turns into a logger with a single NullHandler. - SimpleLogger turns into a logger with a StreamHandler and level. Args: logger: Possibly a logger.BaseLogger, or a standard python logging.Logg...
[ "Adapt", "our", "custom", "logger", ".", "BaseLogger", "object", "into", "a", "standard", "logging", ".", "Logger", "object", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/logger.py#L95-L117
12,135
optimizely/python-sdk
optimizely/user_profile.py
UserProfile.get_variation_for_experiment
def get_variation_for_experiment(self, experiment_id): """ Helper method to retrieve variation ID for given experiment. Args: experiment_id: ID for experiment for which variation needs to be looked up for. Returns: Variation ID corresponding to the experiment. None if no decision available. ...
python
def get_variation_for_experiment(self, experiment_id): """ Helper method to retrieve variation ID for given experiment. Args: experiment_id: ID for experiment for which variation needs to be looked up for. Returns: Variation ID corresponding to the experiment. None if no decision available. ...
[ "def", "get_variation_for_experiment", "(", "self", ",", "experiment_id", ")", ":", "return", "self", ".", "experiment_bucket_map", ".", "get", "(", "experiment_id", ",", "{", "self", ".", "VARIATION_ID_KEY", ":", "None", "}", ")", ".", "get", "(", "self", "...
Helper method to retrieve variation ID for given experiment. Args: experiment_id: ID for experiment for which variation needs to be looked up for. Returns: Variation ID corresponding to the experiment. None if no decision available.
[ "Helper", "method", "to", "retrieve", "variation", "ID", "for", "given", "experiment", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/user_profile.py#L34-L44
12,136
optimizely/python-sdk
optimizely/helpers/event_tag_utils.py
get_numeric_value
def get_numeric_value(event_tags, logger=None): """ A smart getter of the numeric value from the event tags. Args: event_tags: A dictionary of event tags. logger: Optional logger. Returns: A float numeric metric value is returned when the provided numeric metric value is in the followi...
python
def get_numeric_value(event_tags, logger=None): """ A smart getter of the numeric value from the event tags. Args: event_tags: A dictionary of event tags. logger: Optional logger. Returns: A float numeric metric value is returned when the provided numeric metric value is in the followi...
[ "def", "get_numeric_value", "(", "event_tags", ",", "logger", "=", "None", ")", ":", "logger_message_debug", "=", "None", "numeric_metric_value", "=", "None", "if", "event_tags", "is", "None", ":", "logger_message_debug", "=", "'Event tags is undefined.'", "elif", "...
A smart getter of the numeric value from the event tags. Args: event_tags: A dictionary of event tags. logger: Optional logger. Returns: A float numeric metric value is returned when the provided numeric metric value is in the following format: - A string (properly formatted, e.g...
[ "A", "smart", "getter", "of", "the", "numeric", "value", "from", "the", "event", "tags", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/event_tag_utils.py#L43-L123
12,137
optimizely/python-sdk
optimizely/lib/pymmh3.py
hash
def hash( key, seed = 0x0 ): ''' Implements 32bit murmur3 hash. ''' key = bytearray( xencode(key) ) def fmix( h ): h ^= h >> 16 h = ( h * 0x85ebca6b ) & 0xFFFFFFFF h ^= h >> 13 h = ( h * 0xc2b2ae35 ) & 0xFFFFFFFF h ^= h >> 16 return h length = len( ke...
python
def hash( key, seed = 0x0 ): ''' Implements 32bit murmur3 hash. ''' key = bytearray( xencode(key) ) def fmix( h ): h ^= h >> 16 h = ( h * 0x85ebca6b ) & 0xFFFFFFFF h ^= h >> 13 h = ( h * 0xc2b2ae35 ) & 0xFFFFFFFF h ^= h >> 16 return h length = len( ke...
[ "def", "hash", "(", "key", ",", "seed", "=", "0x0", ")", ":", "key", "=", "bytearray", "(", "xencode", "(", "key", ")", ")", "def", "fmix", "(", "h", ")", ":", "h", "^=", "h", ">>", "16", "h", "=", "(", "h", "*", "0x85ebca6b", ")", "&", "0x...
Implements 32bit murmur3 hash.
[ "Implements", "32bit", "murmur3", "hash", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/lib/pymmh3.py#L34-L94
12,138
optimizely/python-sdk
optimizely/lib/pymmh3.py
hash64
def hash64( key, seed = 0x0, x64arch = True ): ''' Implements 64bit murmur3 hash. Returns a tuple. ''' hash_128 = hash128( key, seed, x64arch ) unsigned_val1 = hash_128 & 0xFFFFFFFFFFFFFFFF if unsigned_val1 & 0x8000000000000000 == 0: signed_val1 = unsigned_val1 else: signed_val1 = ...
python
def hash64( key, seed = 0x0, x64arch = True ): ''' Implements 64bit murmur3 hash. Returns a tuple. ''' hash_128 = hash128( key, seed, x64arch ) unsigned_val1 = hash_128 & 0xFFFFFFFFFFFFFFFF if unsigned_val1 & 0x8000000000000000 == 0: signed_val1 = unsigned_val1 else: signed_val1 = ...
[ "def", "hash64", "(", "key", ",", "seed", "=", "0x0", ",", "x64arch", "=", "True", ")", ":", "hash_128", "=", "hash128", "(", "key", ",", "seed", ",", "x64arch", ")", "unsigned_val1", "=", "hash_128", "&", "0xFFFFFFFFFFFFFFFF", "if", "unsigned_val1", "&"...
Implements 64bit murmur3 hash. Returns a tuple.
[ "Implements", "64bit", "murmur3", "hash", ".", "Returns", "a", "tuple", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/lib/pymmh3.py#L406-L423
12,139
optimizely/python-sdk
optimizely/lib/pymmh3.py
hash_bytes
def hash_bytes( key, seed = 0x0, x64arch = True ): ''' Implements 128bit murmur3 hash. Returns a byte string. ''' hash_128 = hash128( key, seed, x64arch ) bytestring = '' for i in xrange(0, 16, 1): lsbyte = hash_128 & 0xFF bytestring = bytestring + str( chr( lsbyte ) ) hash_12...
python
def hash_bytes( key, seed = 0x0, x64arch = True ): ''' Implements 128bit murmur3 hash. Returns a byte string. ''' hash_128 = hash128( key, seed, x64arch ) bytestring = '' for i in xrange(0, 16, 1): lsbyte = hash_128 & 0xFF bytestring = bytestring + str( chr( lsbyte ) ) hash_12...
[ "def", "hash_bytes", "(", "key", ",", "seed", "=", "0x0", ",", "x64arch", "=", "True", ")", ":", "hash_128", "=", "hash128", "(", "key", ",", "seed", ",", "x64arch", ")", "bytestring", "=", "''", "for", "i", "in", "xrange", "(", "0", ",", "16", "...
Implements 128bit murmur3 hash. Returns a byte string.
[ "Implements", "128bit", "murmur3", "hash", ".", "Returns", "a", "byte", "string", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/lib/pymmh3.py#L426-L438
12,140
optimizely/python-sdk
optimizely/bucketer.py
Bucketer._generate_bucket_value
def _generate_bucket_value(self, bucketing_id): """ Helper function to generate bucket value in half-closed interval [0, MAX_TRAFFIC_VALUE). Args: bucketing_id: ID for bucketing. Returns: Bucket value corresponding to the provided bucketing ID. """ ratio = float(self._generate_unsigne...
python
def _generate_bucket_value(self, bucketing_id): """ Helper function to generate bucket value in half-closed interval [0, MAX_TRAFFIC_VALUE). Args: bucketing_id: ID for bucketing. Returns: Bucket value corresponding to the provided bucketing ID. """ ratio = float(self._generate_unsigne...
[ "def", "_generate_bucket_value", "(", "self", ",", "bucketing_id", ")", ":", "ratio", "=", "float", "(", "self", ".", "_generate_unsigned_hash_code_32_bit", "(", "bucketing_id", ")", ")", "/", "MAX_HASH_VALUE", "return", "math", ".", "floor", "(", "ratio", "*", ...
Helper function to generate bucket value in half-closed interval [0, MAX_TRAFFIC_VALUE). Args: bucketing_id: ID for bucketing. Returns: Bucket value corresponding to the provided bucketing ID.
[ "Helper", "function", "to", "generate", "bucket", "value", "in", "half", "-", "closed", "interval", "[", "0", "MAX_TRAFFIC_VALUE", ")", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/bucketer.py#L55-L66
12,141
optimizely/python-sdk
optimizely/bucketer.py
Bucketer.find_bucket
def find_bucket(self, bucketing_id, parent_id, traffic_allocations): """ Determine entity based on bucket value and traffic allocations. Args: bucketing_id: ID to be used for bucketing the user. parent_id: ID representing group or experiment. traffic_allocations: Traffic allocations represent...
python
def find_bucket(self, bucketing_id, parent_id, traffic_allocations): """ Determine entity based on bucket value and traffic allocations. Args: bucketing_id: ID to be used for bucketing the user. parent_id: ID representing group or experiment. traffic_allocations: Traffic allocations represent...
[ "def", "find_bucket", "(", "self", ",", "bucketing_id", ",", "parent_id", ",", "traffic_allocations", ")", ":", "bucketing_key", "=", "BUCKETING_ID_TEMPLATE", ".", "format", "(", "bucketing_id", "=", "bucketing_id", ",", "parent_id", "=", "parent_id", ")", "bucket...
Determine entity based on bucket value and traffic allocations. Args: bucketing_id: ID to be used for bucketing the user. parent_id: ID representing group or experiment. traffic_allocations: Traffic allocations representing traffic allotted to experiments or variations. Returns: Entity...
[ "Determine", "entity", "based", "on", "bucket", "value", "and", "traffic", "allocations", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/bucketer.py#L68-L92
12,142
optimizely/python-sdk
optimizely/bucketer.py
Bucketer.bucket
def bucket(self, experiment, user_id, bucketing_id): """ For a given experiment and bucketing ID determines variation to be shown to user. Args: experiment: Object representing the experiment for which user is to be bucketed. user_id: ID for user. bucketing_id: ID to be used for bucketing the...
python
def bucket(self, experiment, user_id, bucketing_id): """ For a given experiment and bucketing ID determines variation to be shown to user. Args: experiment: Object representing the experiment for which user is to be bucketed. user_id: ID for user. bucketing_id: ID to be used for bucketing the...
[ "def", "bucket", "(", "self", ",", "experiment", ",", "user_id", ",", "bucketing_id", ")", ":", "if", "not", "experiment", ":", "return", "None", "# Determine if experiment is in a mutually exclusive group", "if", "experiment", ".", "groupPolicy", "in", "GROUP_POLICIE...
For a given experiment and bucketing ID determines variation to be shown to user. Args: experiment: Object representing the experiment for which user is to be bucketed. user_id: ID for user. bucketing_id: ID to be used for bucketing the user. Returns: Variation in which user with ID us...
[ "For", "a", "given", "experiment", "and", "bucketing", "ID", "determines", "variation", "to", "be", "shown", "to", "user", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/bucketer.py#L94-L147
12,143
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig._generate_key_map
def _generate_key_map(entity_list, key, entity_class): """ Helper method to generate map from key to entity object for given list of dicts. Args: entity_list: List consisting of dict. key: Key in each dict which will be key in the map. entity_class: Class representing the entity. Returns...
python
def _generate_key_map(entity_list, key, entity_class): """ Helper method to generate map from key to entity object for given list of dicts. Args: entity_list: List consisting of dict. key: Key in each dict which will be key in the map. entity_class: Class representing the entity. Returns...
[ "def", "_generate_key_map", "(", "entity_list", ",", "key", ",", "entity_class", ")", ":", "key_map", "=", "{", "}", "for", "obj", "in", "entity_list", ":", "key_map", "[", "obj", "[", "key", "]", "]", "=", "entity_class", "(", "*", "*", "obj", ")", ...
Helper method to generate map from key to entity object for given list of dicts. Args: entity_list: List consisting of dict. key: Key in each dict which will be key in the map. entity_class: Class representing the entity. Returns: Map mapping key to entity object.
[ "Helper", "method", "to", "generate", "map", "from", "key", "to", "entity", "object", "for", "given", "list", "of", "dicts", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L134-L150
12,144
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig._deserialize_audience
def _deserialize_audience(audience_map): """ Helper method to de-serialize and populate audience map with the condition list and structure. Args: audience_map: Dict mapping audience ID to audience object. Returns: Dict additionally consisting of condition list and structure on every audience o...
python
def _deserialize_audience(audience_map): """ Helper method to de-serialize and populate audience map with the condition list and structure. Args: audience_map: Dict mapping audience ID to audience object. Returns: Dict additionally consisting of condition list and structure on every audience o...
[ "def", "_deserialize_audience", "(", "audience_map", ")", ":", "for", "audience", "in", "audience_map", ".", "values", "(", ")", ":", "condition_structure", ",", "condition_list", "=", "condition_helper", ".", "loads", "(", "audience", ".", "conditions", ")", "a...
Helper method to de-serialize and populate audience map with the condition list and structure. Args: audience_map: Dict mapping audience ID to audience object. Returns: Dict additionally consisting of condition list and structure on every audience object.
[ "Helper", "method", "to", "de", "-", "serialize", "and", "populate", "audience", "map", "with", "the", "condition", "list", "and", "structure", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L153-L170
12,145
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_typecast_value
def get_typecast_value(self, value, type): """ Helper method to determine actual value based on type of feature variable. Args: value: Value in string form as it was parsed from datafile. type: Type denoting the feature flag type. Return: Value type-casted based on type of feature variab...
python
def get_typecast_value(self, value, type): """ Helper method to determine actual value based on type of feature variable. Args: value: Value in string form as it was parsed from datafile. type: Type denoting the feature flag type. Return: Value type-casted based on type of feature variab...
[ "def", "get_typecast_value", "(", "self", ",", "value", ",", "type", ")", ":", "if", "type", "==", "entities", ".", "Variable", ".", "Type", ".", "BOOLEAN", ":", "return", "value", "==", "'true'", "elif", "type", "==", "entities", ".", "Variable", ".", ...
Helper method to determine actual value based on type of feature variable. Args: value: Value in string form as it was parsed from datafile. type: Type denoting the feature flag type. Return: Value type-casted based on type of feature variable.
[ "Helper", "method", "to", "determine", "actual", "value", "based", "on", "type", "of", "feature", "variable", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L172-L190
12,146
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_experiment_from_key
def get_experiment_from_key(self, experiment_key): """ Get experiment for the provided experiment key. Args: experiment_key: Experiment key for which experiment is to be determined. Returns: Experiment corresponding to the provided experiment key. """ experiment = self.experiment_key_...
python
def get_experiment_from_key(self, experiment_key): """ Get experiment for the provided experiment key. Args: experiment_key: Experiment key for which experiment is to be determined. Returns: Experiment corresponding to the provided experiment key. """ experiment = self.experiment_key_...
[ "def", "get_experiment_from_key", "(", "self", ",", "experiment_key", ")", ":", "experiment", "=", "self", ".", "experiment_key_map", ".", "get", "(", "experiment_key", ")", "if", "experiment", ":", "return", "experiment", "self", ".", "logger", ".", "error", ...
Get experiment for the provided experiment key. Args: experiment_key: Experiment key for which experiment is to be determined. Returns: Experiment corresponding to the provided experiment key.
[ "Get", "experiment", "for", "the", "provided", "experiment", "key", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L228-L245
12,147
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_experiment_from_id
def get_experiment_from_id(self, experiment_id): """ Get experiment for the provided experiment ID. Args: experiment_id: Experiment ID for which experiment is to be determined. Returns: Experiment corresponding to the provided experiment ID. """ experiment = self.experiment_id_map.get...
python
def get_experiment_from_id(self, experiment_id): """ Get experiment for the provided experiment ID. Args: experiment_id: Experiment ID for which experiment is to be determined. Returns: Experiment corresponding to the provided experiment ID. """ experiment = self.experiment_id_map.get...
[ "def", "get_experiment_from_id", "(", "self", ",", "experiment_id", ")", ":", "experiment", "=", "self", ".", "experiment_id_map", ".", "get", "(", "experiment_id", ")", "if", "experiment", ":", "return", "experiment", "self", ".", "logger", ".", "error", "(",...
Get experiment for the provided experiment ID. Args: experiment_id: Experiment ID for which experiment is to be determined. Returns: Experiment corresponding to the provided experiment ID.
[ "Get", "experiment", "for", "the", "provided", "experiment", "ID", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L247-L264
12,148
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_group
def get_group(self, group_id): """ Get group for the provided group ID. Args: group_id: Group ID for which group is to be determined. Returns: Group corresponding to the provided group ID. """ group = self.group_id_map.get(group_id) if group: return group self.logger.e...
python
def get_group(self, group_id): """ Get group for the provided group ID. Args: group_id: Group ID for which group is to be determined. Returns: Group corresponding to the provided group ID. """ group = self.group_id_map.get(group_id) if group: return group self.logger.e...
[ "def", "get_group", "(", "self", ",", "group_id", ")", ":", "group", "=", "self", ".", "group_id_map", ".", "get", "(", "group_id", ")", "if", "group", ":", "return", "group", "self", ".", "logger", ".", "error", "(", "'Group ID \"%s\" is not in datafile.'",...
Get group for the provided group ID. Args: group_id: Group ID for which group is to be determined. Returns: Group corresponding to the provided group ID.
[ "Get", "group", "for", "the", "provided", "group", "ID", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L266-L283
12,149
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_audience
def get_audience(self, audience_id): """ Get audience object for the provided audience ID. Args: audience_id: ID of the audience. Returns: Dict representing the audience. """ audience = self.audience_id_map.get(audience_id) if audience: return audience self.logger.error...
python
def get_audience(self, audience_id): """ Get audience object for the provided audience ID. Args: audience_id: ID of the audience. Returns: Dict representing the audience. """ audience = self.audience_id_map.get(audience_id) if audience: return audience self.logger.error...
[ "def", "get_audience", "(", "self", ",", "audience_id", ")", ":", "audience", "=", "self", ".", "audience_id_map", ".", "get", "(", "audience_id", ")", "if", "audience", ":", "return", "audience", "self", ".", "logger", ".", "error", "(", "'Audience ID \"%s\...
Get audience object for the provided audience ID. Args: audience_id: ID of the audience. Returns: Dict representing the audience.
[ "Get", "audience", "object", "for", "the", "provided", "audience", "ID", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L285-L300
12,150
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_variation_from_key
def get_variation_from_key(self, experiment_key, variation_key): """ Get variation given experiment and variation key. Args: experiment: Key representing parent experiment of variation. variation_key: Key representing the variation. Returns Object representing the variation. """ ...
python
def get_variation_from_key(self, experiment_key, variation_key): """ Get variation given experiment and variation key. Args: experiment: Key representing parent experiment of variation. variation_key: Key representing the variation. Returns Object representing the variation. """ ...
[ "def", "get_variation_from_key", "(", "self", ",", "experiment_key", ",", "variation_key", ")", ":", "variation_map", "=", "self", ".", "variation_key_map", ".", "get", "(", "experiment_key", ")", "if", "variation_map", ":", "variation", "=", "variation_map", ".",...
Get variation given experiment and variation key. Args: experiment: Key representing parent experiment of variation. variation_key: Key representing the variation. Returns Object representing the variation.
[ "Get", "variation", "given", "experiment", "and", "variation", "key", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L302-L326
12,151
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_variation_from_id
def get_variation_from_id(self, experiment_key, variation_id): """ Get variation given experiment and variation ID. Args: experiment: Key representing parent experiment of variation. variation_id: ID representing the variation. Returns Object representing the variation. """ vari...
python
def get_variation_from_id(self, experiment_key, variation_id): """ Get variation given experiment and variation ID. Args: experiment: Key representing parent experiment of variation. variation_id: ID representing the variation. Returns Object representing the variation. """ vari...
[ "def", "get_variation_from_id", "(", "self", ",", "experiment_key", ",", "variation_id", ")", ":", "variation_map", "=", "self", ".", "variation_id_map", ".", "get", "(", "experiment_key", ")", "if", "variation_map", ":", "variation", "=", "variation_map", ".", ...
Get variation given experiment and variation ID. Args: experiment: Key representing parent experiment of variation. variation_id: ID representing the variation. Returns Object representing the variation.
[ "Get", "variation", "given", "experiment", "and", "variation", "ID", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L328-L352
12,152
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_event
def get_event(self, event_key): """ Get event for the provided event key. Args: event_key: Event key for which event is to be determined. Returns: Event corresponding to the provided event key. """ event = self.event_key_map.get(event_key) if event: return event self.l...
python
def get_event(self, event_key): """ Get event for the provided event key. Args: event_key: Event key for which event is to be determined. Returns: Event corresponding to the provided event key. """ event = self.event_key_map.get(event_key) if event: return event self.l...
[ "def", "get_event", "(", "self", ",", "event_key", ")", ":", "event", "=", "self", ".", "event_key_map", ".", "get", "(", "event_key", ")", "if", "event", ":", "return", "event", "self", ".", "logger", ".", "error", "(", "'Event \"%s\" is not in datafile.'",...
Get event for the provided event key. Args: event_key: Event key for which event is to be determined. Returns: Event corresponding to the provided event key.
[ "Get", "event", "for", "the", "provided", "event", "key", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L354-L371
12,153
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_attribute_id
def get_attribute_id(self, attribute_key): """ Get attribute ID for the provided attribute key. Args: attribute_key: Attribute key for which attribute is to be fetched. Returns: Attribute ID corresponding to the provided attribute key. """ attribute = self.attribute_key_map.get(attrib...
python
def get_attribute_id(self, attribute_key): """ Get attribute ID for the provided attribute key. Args: attribute_key: Attribute key for which attribute is to be fetched. Returns: Attribute ID corresponding to the provided attribute key. """ attribute = self.attribute_key_map.get(attrib...
[ "def", "get_attribute_id", "(", "self", ",", "attribute_key", ")", ":", "attribute", "=", "self", ".", "attribute_key_map", ".", "get", "(", "attribute_key", ")", "has_reserved_prefix", "=", "attribute_key", ".", "startswith", "(", "RESERVED_ATTRIBUTE_PREFIX", ")", ...
Get attribute ID for the provided attribute key. Args: attribute_key: Attribute key for which attribute is to be fetched. Returns: Attribute ID corresponding to the provided attribute key.
[ "Get", "attribute", "ID", "for", "the", "provided", "attribute", "key", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L373-L398
12,154
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_feature_from_key
def get_feature_from_key(self, feature_key): """ Get feature for the provided feature key. Args: feature_key: Feature key for which feature is to be fetched. Returns: Feature corresponding to the provided feature key. """ feature = self.feature_key_map.get(feature_key) if feature:...
python
def get_feature_from_key(self, feature_key): """ Get feature for the provided feature key. Args: feature_key: Feature key for which feature is to be fetched. Returns: Feature corresponding to the provided feature key. """ feature = self.feature_key_map.get(feature_key) if feature:...
[ "def", "get_feature_from_key", "(", "self", ",", "feature_key", ")", ":", "feature", "=", "self", ".", "feature_key_map", ".", "get", "(", "feature_key", ")", "if", "feature", ":", "return", "feature", "self", ".", "logger", ".", "error", "(", "'Feature \"%s...
Get feature for the provided feature key. Args: feature_key: Feature key for which feature is to be fetched. Returns: Feature corresponding to the provided feature key.
[ "Get", "feature", "for", "the", "provided", "feature", "key", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L400-L415
12,155
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_rollout_from_id
def get_rollout_from_id(self, rollout_id): """ Get rollout for the provided ID. Args: rollout_id: ID of the rollout to be fetched. Returns: Rollout corresponding to the provided ID. """ layer = self.rollout_id_map.get(rollout_id) if layer: return layer self.logger.error...
python
def get_rollout_from_id(self, rollout_id): """ Get rollout for the provided ID. Args: rollout_id: ID of the rollout to be fetched. Returns: Rollout corresponding to the provided ID. """ layer = self.rollout_id_map.get(rollout_id) if layer: return layer self.logger.error...
[ "def", "get_rollout_from_id", "(", "self", ",", "rollout_id", ")", ":", "layer", "=", "self", ".", "rollout_id_map", ".", "get", "(", "rollout_id", ")", "if", "layer", ":", "return", "layer", "self", ".", "logger", ".", "error", "(", "'Rollout with ID \"%s\"...
Get rollout for the provided ID. Args: rollout_id: ID of the rollout to be fetched. Returns: Rollout corresponding to the provided ID.
[ "Get", "rollout", "for", "the", "provided", "ID", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L417-L432
12,156
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_variable_value_for_variation
def get_variable_value_for_variation(self, variable, variation): """ Get the variable value for the given variation. Args: variable: The Variable for which we are getting the value. variation: The Variation for which we are getting the variable value. Returns: The variable value or None ...
python
def get_variable_value_for_variation(self, variable, variation): """ Get the variable value for the given variation. Args: variable: The Variable for which we are getting the value. variation: The Variation for which we are getting the variable value. Returns: The variable value or None ...
[ "def", "get_variable_value_for_variation", "(", "self", ",", "variable", ",", "variation", ")", ":", "if", "not", "variable", "or", "not", "variation", ":", "return", "None", "if", "variation", ".", "id", "not", "in", "self", ".", "variation_variable_usage_map",...
Get the variable value for the given variation. Args: variable: The Variable for which we are getting the value. variation: The Variation for which we are getting the variable value. Returns: The variable value or None if any of the inputs are invalid.
[ "Get", "the", "variable", "value", "for", "the", "given", "variation", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L434-L476
12,157
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_variable_for_feature
def get_variable_for_feature(self, feature_key, variable_key): """ Get the variable with the given variable key for the given feature. Args: feature_key: The key of the feature for which we are getting the variable. variable_key: The key of the variable we are getting. Returns: Variable ...
python
def get_variable_for_feature(self, feature_key, variable_key): """ Get the variable with the given variable key for the given feature. Args: feature_key: The key of the feature for which we are getting the variable. variable_key: The key of the variable we are getting. Returns: Variable ...
[ "def", "get_variable_for_feature", "(", "self", ",", "feature_key", ",", "variable_key", ")", ":", "feature", "=", "self", ".", "feature_key_map", ".", "get", "(", "feature_key", ")", "if", "not", "feature", ":", "self", ".", "logger", ".", "error", "(", "...
Get the variable with the given variable key for the given feature. Args: feature_key: The key of the feature for which we are getting the variable. variable_key: The key of the variable we are getting. Returns: Variable with the given key in the given variation.
[ "Get", "the", "variable", "with", "the", "given", "variable", "key", "for", "the", "given", "feature", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L478-L497
12,158
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.set_forced_variation
def set_forced_variation(self, experiment_key, user_id, variation_key): """ Sets users to a map of experiments to forced variations. Args: experiment_key: Key for experiment. user_id: The user ID. variation_key: Key for variation. If None, then clear the existing experiment-to-variati...
python
def set_forced_variation(self, experiment_key, user_id, variation_key): """ Sets users to a map of experiments to forced variations. Args: experiment_key: Key for experiment. user_id: The user ID. variation_key: Key for variation. If None, then clear the existing experiment-to-variati...
[ "def", "set_forced_variation", "(", "self", ",", "experiment_key", ",", "user_id", ",", "variation_key", ")", ":", "experiment", "=", "self", ".", "get_experiment_from_key", "(", "experiment_key", ")", "if", "not", "experiment", ":", "# The invalid experiment key will...
Sets users to a map of experiments to forced variations. Args: experiment_key: Key for experiment. user_id: The user ID. variation_key: Key for variation. If None, then clear the existing experiment-to-variation mapping. Returns: A boolean value that indicates if the set co...
[ "Sets", "users", "to", "a", "map", "of", "experiments", "to", "forced", "variations", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L499-L555
12,159
optimizely/python-sdk
optimizely/project_config.py
ProjectConfig.get_forced_variation
def get_forced_variation(self, experiment_key, user_id): """ Gets the forced variation key for the given user and experiment. Args: experiment_key: Key for experiment. user_id: The user ID. Returns: The variation which the given user and experiment should be forced into. ""...
python
def get_forced_variation(self, experiment_key, user_id): """ Gets the forced variation key for the given user and experiment. Args: experiment_key: Key for experiment. user_id: The user ID. Returns: The variation which the given user and experiment should be forced into. ""...
[ "def", "get_forced_variation", "(", "self", ",", "experiment_key", ",", "user_id", ")", ":", "if", "user_id", "not", "in", "self", ".", "forced_variation_map", ":", "self", ".", "logger", ".", "debug", "(", "'User \"%s\" is not in the forced variation map.'", "%", ...
Gets the forced variation key for the given user and experiment. Args: experiment_key: Key for experiment. user_id: The user ID. Returns: The variation which the given user and experiment should be forced into.
[ "Gets", "the", "forced", "variation", "key", "for", "the", "given", "user", "and", "experiment", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/project_config.py#L557-L600
12,160
optimizely/python-sdk
optimizely/event_dispatcher.py
EventDispatcher.dispatch_event
def dispatch_event(event): """ Dispatch the event being represented by the Event object. Args: event: Object holding information about the request to be dispatched to the Optimizely backend. """ try: if event.http_verb == enums.HTTPVerbs.GET: requests.get(event.url, params=event.pa...
python
def dispatch_event(event): """ Dispatch the event being represented by the Event object. Args: event: Object holding information about the request to be dispatched to the Optimizely backend. """ try: if event.http_verb == enums.HTTPVerbs.GET: requests.get(event.url, params=event.pa...
[ "def", "dispatch_event", "(", "event", ")", ":", "try", ":", "if", "event", ".", "http_verb", "==", "enums", ".", "HTTPVerbs", ".", "GET", ":", "requests", ".", "get", "(", "event", ".", "url", ",", "params", "=", "event", ".", "params", ",", "timeou...
Dispatch the event being represented by the Event object. Args: event: Object holding information about the request to be dispatched to the Optimizely backend.
[ "Dispatch", "the", "event", "being", "represented", "by", "the", "Event", "object", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/event_dispatcher.py#L28-L44
12,161
optimizely/python-sdk
optimizely/optimizely.py
Optimizely._validate_instantiation_options
def _validate_instantiation_options(self, datafile, skip_json_validation): """ Helper method to validate all instantiation parameters. Args: datafile: JSON string representing the project. skip_json_validation: Boolean representing whether JSON schema validation needs to be skipped or not. Rai...
python
def _validate_instantiation_options(self, datafile, skip_json_validation): """ Helper method to validate all instantiation parameters. Args: datafile: JSON string representing the project. skip_json_validation: Boolean representing whether JSON schema validation needs to be skipped or not. Rai...
[ "def", "_validate_instantiation_options", "(", "self", ",", "datafile", ",", "skip_json_validation", ")", ":", "if", "not", "skip_json_validation", "and", "not", "validator", ".", "is_datafile_valid", "(", "datafile", ")", ":", "raise", "exceptions", ".", "InvalidIn...
Helper method to validate all instantiation parameters. Args: datafile: JSON string representing the project. skip_json_validation: Boolean representing whether JSON schema validation needs to be skipped or not. Raises: Exception if provided instantiation options are valid.
[ "Helper", "method", "to", "validate", "all", "instantiation", "parameters", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L89-L110
12,162
optimizely/python-sdk
optimizely/optimizely.py
Optimizely._validate_user_inputs
def _validate_user_inputs(self, attributes=None, event_tags=None): """ Helper method to validate user inputs. Args: attributes: Dict representing user attributes. event_tags: Dict representing metadata associated with an event. Returns: Boolean True if inputs are valid. False otherwise. ...
python
def _validate_user_inputs(self, attributes=None, event_tags=None): """ Helper method to validate user inputs. Args: attributes: Dict representing user attributes. event_tags: Dict representing metadata associated with an event. Returns: Boolean True if inputs are valid. False otherwise. ...
[ "def", "_validate_user_inputs", "(", "self", ",", "attributes", "=", "None", ",", "event_tags", "=", "None", ")", ":", "if", "attributes", "and", "not", "validator", ".", "are_attributes_valid", "(", "attributes", ")", ":", "self", ".", "logger", ".", "error...
Helper method to validate user inputs. Args: attributes: Dict representing user attributes. event_tags: Dict representing metadata associated with an event. Returns: Boolean True if inputs are valid. False otherwise.
[ "Helper", "method", "to", "validate", "user", "inputs", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L112-L134
12,163
optimizely/python-sdk
optimizely/optimizely.py
Optimizely._send_impression_event
def _send_impression_event(self, experiment, variation, user_id, attributes): """ Helper method to send impression event. Args: experiment: Experiment for which impression event is being sent. variation: Variation picked for user for the given experiment. user_id: ID for user. attribute...
python
def _send_impression_event(self, experiment, variation, user_id, attributes): """ Helper method to send impression event. Args: experiment: Experiment for which impression event is being sent. variation: Variation picked for user for the given experiment. user_id: ID for user. attribute...
[ "def", "_send_impression_event", "(", "self", ",", "experiment", ",", "variation", ",", "user_id", ",", "attributes", ")", ":", "impression_event", "=", "self", ".", "event_builder", ".", "create_impression_event", "(", "experiment", ",", "variation", ".", "id", ...
Helper method to send impression event. Args: experiment: Experiment for which impression event is being sent. variation: Variation picked for user for the given experiment. user_id: ID for user. attributes: Dict representing user attributes and values which need to be recorded.
[ "Helper", "method", "to", "send", "impression", "event", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L136-L162
12,164
optimizely/python-sdk
optimizely/optimizely.py
Optimizely._get_feature_variable_for_type
def _get_feature_variable_for_type(self, feature_key, variable_key, variable_type, user_id, attributes): """ Helper method to determine value for a certain variable attached to a feature flag based on type of variable. Args: feature_key: Key of the feature whose variable's value is being accessed. ...
python
def _get_feature_variable_for_type(self, feature_key, variable_key, variable_type, user_id, attributes): """ Helper method to determine value for a certain variable attached to a feature flag based on type of variable. Args: feature_key: Key of the feature whose variable's value is being accessed. ...
[ "def", "_get_feature_variable_for_type", "(", "self", ",", "feature_key", ",", "variable_key", ",", "variable_type", ",", "user_id", ",", "attributes", ")", ":", "if", "not", "validator", ".", "is_non_empty_string", "(", "feature_key", ")", ":", "self", ".", "lo...
Helper method to determine value for a certain variable attached to a feature flag based on type of variable. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to be accessed. variable_type: Type of variable which coul...
[ "Helper", "method", "to", "determine", "value", "for", "a", "certain", "variable", "attached", "to", "a", "feature", "flag", "based", "on", "type", "of", "variable", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L164-L263
12,165
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.activate
def activate(self, experiment_key, user_id, attributes=None): """ Buckets visitor and sends impression event to Optimizely. Args: experiment_key: Experiment which needs to be activated. user_id: ID for user. attributes: Dict representing user attributes and values which need to be recorded. ...
python
def activate(self, experiment_key, user_id, attributes=None): """ Buckets visitor and sends impression event to Optimizely. Args: experiment_key: Experiment which needs to be activated. user_id: ID for user. attributes: Dict representing user attributes and values which need to be recorded. ...
[ "def", "activate", "(", "self", ",", "experiment_key", ",", "user_id", ",", "attributes", "=", "None", ")", ":", "if", "not", "self", ".", "is_valid", ":", "self", ".", "logger", ".", "error", "(", "enums", ".", "Errors", ".", "INVALID_DATAFILE", ".", ...
Buckets visitor and sends impression event to Optimizely. Args: experiment_key: Experiment which needs to be activated. user_id: ID for user. attributes: Dict representing user attributes and values which need to be recorded. Returns: Variation key representing the variation the user w...
[ "Buckets", "visitor", "and", "sends", "impression", "event", "to", "Optimizely", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L265-L303
12,166
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.track
def track(self, event_key, user_id, attributes=None, event_tags=None): """ Send conversion event to Optimizely. Args: event_key: Event key representing the event which needs to be recorded. user_id: ID for user. attributes: Dict representing visitor attributes and values which need to be reco...
python
def track(self, event_key, user_id, attributes=None, event_tags=None): """ Send conversion event to Optimizely. Args: event_key: Event key representing the event which needs to be recorded. user_id: ID for user. attributes: Dict representing visitor attributes and values which need to be reco...
[ "def", "track", "(", "self", ",", "event_key", ",", "user_id", ",", "attributes", "=", "None", ",", "event_tags", "=", "None", ")", ":", "if", "not", "self", ".", "is_valid", ":", "self", ".", "logger", ".", "error", "(", "enums", ".", "Errors", ".",...
Send conversion event to Optimizely. Args: event_key: Event key representing the event which needs to be recorded. user_id: ID for user. attributes: Dict representing visitor attributes and values which need to be recorded. event_tags: Dict representing metadata associated with the event.
[ "Send", "conversion", "event", "to", "Optimizely", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L305-L346
12,167
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.get_variation
def get_variation(self, experiment_key, user_id, attributes=None): """ Gets variation where user will be bucketed. Args: experiment_key: Experiment for which user variation needs to be determined. user_id: ID for user. attributes: Dict representing user attributes. Returns: Variati...
python
def get_variation(self, experiment_key, user_id, attributes=None): """ Gets variation where user will be bucketed. Args: experiment_key: Experiment for which user variation needs to be determined. user_id: ID for user. attributes: Dict representing user attributes. Returns: Variati...
[ "def", "get_variation", "(", "self", ",", "experiment_key", ",", "user_id", ",", "attributes", "=", "None", ")", ":", "if", "not", "self", ".", "is_valid", ":", "self", ".", "logger", ".", "error", "(", "enums", ".", "Errors", ".", "INVALID_DATAFILE", "....
Gets variation where user will be bucketed. Args: experiment_key: Experiment for which user variation needs to be determined. user_id: ID for user. attributes: Dict representing user attributes. Returns: Variation key representing the variation the user will be bucketed in. None ...
[ "Gets", "variation", "where", "user", "will", "be", "bucketed", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L348-L406
12,168
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.is_feature_enabled
def is_feature_enabled(self, feature_key, user_id, attributes=None): """ Returns true if the feature is enabled for the given user. Args: feature_key: The key of the feature for which we are determining if it is enabled or not for the given user. user_id: ID for user. attributes: Dict represe...
python
def is_feature_enabled(self, feature_key, user_id, attributes=None): """ Returns true if the feature is enabled for the given user. Args: feature_key: The key of the feature for which we are determining if it is enabled or not for the given user. user_id: ID for user. attributes: Dict represe...
[ "def", "is_feature_enabled", "(", "self", ",", "feature_key", ",", "user_id", ",", "attributes", "=", "None", ")", ":", "if", "not", "self", ".", "is_valid", ":", "self", ".", "logger", ".", "error", "(", "enums", ".", "Errors", ".", "INVALID_DATAFILE", ...
Returns true if the feature is enabled for the given user. Args: feature_key: The key of the feature for which we are determining if it is enabled or not for the given user. user_id: ID for user. attributes: Dict representing user attributes. Returns: True if the feature is enabled for...
[ "Returns", "true", "if", "the", "feature", "is", "enabled", "for", "the", "given", "user", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L408-L476
12,169
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.get_enabled_features
def get_enabled_features(self, user_id, attributes=None): """ Returns the list of features that are enabled for the user. Args: user_id: ID for user. attributes: Dict representing user attributes. Returns: A list of the keys of the features that are enabled for the user. """ ena...
python
def get_enabled_features(self, user_id, attributes=None): """ Returns the list of features that are enabled for the user. Args: user_id: ID for user. attributes: Dict representing user attributes. Returns: A list of the keys of the features that are enabled for the user. """ ena...
[ "def", "get_enabled_features", "(", "self", ",", "user_id", ",", "attributes", "=", "None", ")", ":", "enabled_features", "=", "[", "]", "if", "not", "self", ".", "is_valid", ":", "self", ".", "logger", ".", "error", "(", "enums", ".", "Errors", ".", "...
Returns the list of features that are enabled for the user. Args: user_id: ID for user. attributes: Dict representing user attributes. Returns: A list of the keys of the features that are enabled for the user.
[ "Returns", "the", "list", "of", "features", "that", "are", "enabled", "for", "the", "user", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L478-L505
12,170
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.get_feature_variable_boolean
def get_feature_variable_boolean(self, feature_key, variable_key, user_id, attributes=None): """ Returns value for a certain boolean variable attached to a feature flag. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is ...
python
def get_feature_variable_boolean(self, feature_key, variable_key, user_id, attributes=None): """ Returns value for a certain boolean variable attached to a feature flag. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is ...
[ "def", "get_feature_variable_boolean", "(", "self", ",", "feature_key", ",", "variable_key", ",", "user_id", ",", "attributes", "=", "None", ")", ":", "variable_type", "=", "entities", ".", "Variable", ".", "Type", ".", "BOOLEAN", "return", "self", ".", "_get_...
Returns value for a certain boolean variable attached to a feature flag. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to be accessed. user_id: ID for user. attributes: Dict representing user attributes. ...
[ "Returns", "value", "for", "a", "certain", "boolean", "variable", "attached", "to", "a", "feature", "flag", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L507-L524
12,171
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.get_feature_variable_double
def get_feature_variable_double(self, feature_key, variable_key, user_id, attributes=None): """ Returns value for a certain double variable attached to a feature flag. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to...
python
def get_feature_variable_double(self, feature_key, variable_key, user_id, attributes=None): """ Returns value for a certain double variable attached to a feature flag. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to...
[ "def", "get_feature_variable_double", "(", "self", ",", "feature_key", ",", "variable_key", ",", "user_id", ",", "attributes", "=", "None", ")", ":", "variable_type", "=", "entities", ".", "Variable", ".", "Type", ".", "DOUBLE", "return", "self", ".", "_get_fe...
Returns value for a certain double variable attached to a feature flag. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to be accessed. user_id: ID for user. attributes: Dict representing user attributes. ...
[ "Returns", "value", "for", "a", "certain", "double", "variable", "attached", "to", "a", "feature", "flag", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L526-L543
12,172
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.get_feature_variable_integer
def get_feature_variable_integer(self, feature_key, variable_key, user_id, attributes=None): """ Returns value for a certain integer variable attached to a feature flag. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is ...
python
def get_feature_variable_integer(self, feature_key, variable_key, user_id, attributes=None): """ Returns value for a certain integer variable attached to a feature flag. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is ...
[ "def", "get_feature_variable_integer", "(", "self", ",", "feature_key", ",", "variable_key", ",", "user_id", ",", "attributes", "=", "None", ")", ":", "variable_type", "=", "entities", ".", "Variable", ".", "Type", ".", "INTEGER", "return", "self", ".", "_get_...
Returns value for a certain integer variable attached to a feature flag. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to be accessed. user_id: ID for user. attributes: Dict representing user attributes. ...
[ "Returns", "value", "for", "a", "certain", "integer", "variable", "attached", "to", "a", "feature", "flag", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L545-L562
12,173
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.get_feature_variable_string
def get_feature_variable_string(self, feature_key, variable_key, user_id, attributes=None): """ Returns value for a certain string variable attached to a feature. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to be a...
python
def get_feature_variable_string(self, feature_key, variable_key, user_id, attributes=None): """ Returns value for a certain string variable attached to a feature. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to be a...
[ "def", "get_feature_variable_string", "(", "self", ",", "feature_key", ",", "variable_key", ",", "user_id", ",", "attributes", "=", "None", ")", ":", "variable_type", "=", "entities", ".", "Variable", ".", "Type", ".", "STRING", "return", "self", ".", "_get_fe...
Returns value for a certain string variable attached to a feature. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to be accessed. user_id: ID for user. attributes: Dict representing user attributes. Retur...
[ "Returns", "value", "for", "a", "certain", "string", "variable", "attached", "to", "a", "feature", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L564-L581
12,174
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.set_forced_variation
def set_forced_variation(self, experiment_key, user_id, variation_key): """ Force a user into a variation for a given experiment. Args: experiment_key: A string key identifying the experiment. user_id: The user ID. variation_key: A string variation key that specifies the variation which the user...
python
def set_forced_variation(self, experiment_key, user_id, variation_key): """ Force a user into a variation for a given experiment. Args: experiment_key: A string key identifying the experiment. user_id: The user ID. variation_key: A string variation key that specifies the variation which the user...
[ "def", "set_forced_variation", "(", "self", ",", "experiment_key", ",", "user_id", ",", "variation_key", ")", ":", "if", "not", "self", ".", "is_valid", ":", "self", ".", "logger", ".", "error", "(", "enums", ".", "Errors", ".", "INVALID_DATAFILE", ".", "f...
Force a user into a variation for a given experiment. Args: experiment_key: A string key identifying the experiment. user_id: The user ID. variation_key: A string variation key that specifies the variation which the user. will be forced into. If null, then clear the existing experiment-to-varia...
[ "Force", "a", "user", "into", "a", "variation", "for", "a", "given", "experiment", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L583-L608
12,175
optimizely/python-sdk
optimizely/optimizely.py
Optimizely.get_forced_variation
def get_forced_variation(self, experiment_key, user_id): """ Gets the forced variation for a given user and experiment. Args: experiment_key: A string key identifying the experiment. user_id: The user ID. Returns: The forced variation key. None if no forced variation key. """ if...
python
def get_forced_variation(self, experiment_key, user_id): """ Gets the forced variation for a given user and experiment. Args: experiment_key: A string key identifying the experiment. user_id: The user ID. Returns: The forced variation key. None if no forced variation key. """ if...
[ "def", "get_forced_variation", "(", "self", ",", "experiment_key", ",", "user_id", ")", ":", "if", "not", "self", ".", "is_valid", ":", "self", ".", "logger", ".", "error", "(", "enums", ".", "Errors", ".", "INVALID_DATAFILE", ".", "format", "(", "'get_for...
Gets the forced variation for a given user and experiment. Args: experiment_key: A string key identifying the experiment. user_id: The user ID. Returns: The forced variation key. None if no forced variation key.
[ "Gets", "the", "forced", "variation", "for", "a", "given", "user", "and", "experiment", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L610-L634
12,176
optimizely/python-sdk
optimizely/helpers/audience.py
is_user_in_experiment
def is_user_in_experiment(config, experiment, attributes, logger): """ Determine for given experiment if user satisfies the audiences for the experiment. Args: config: project_config.ProjectConfig object representing the project. experiment: Object representing the experiment. attributes: Dict represen...
python
def is_user_in_experiment(config, experiment, attributes, logger): """ Determine for given experiment if user satisfies the audiences for the experiment. Args: config: project_config.ProjectConfig object representing the project. experiment: Object representing the experiment. attributes: Dict represen...
[ "def", "is_user_in_experiment", "(", "config", ",", "experiment", ",", "attributes", ",", "logger", ")", ":", "audience_conditions", "=", "experiment", ".", "getAudienceConditionsOrIds", "(", ")", "logger", ".", "debug", "(", "audience_logs", ".", "EVALUATING_AUDIEN...
Determine for given experiment if user satisfies the audiences for the experiment. Args: config: project_config.ProjectConfig object representing the project. experiment: Object representing the experiment. attributes: Dict representing user attributes which will be used in determining if...
[ "Determine", "for", "given", "experiment", "if", "user", "satisfies", "the", "audiences", "for", "the", "experiment", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/audience.py#L21-L91
12,177
optimizely/python-sdk
optimizely/event_builder.py
BaseEventBuilder._get_common_params
def _get_common_params(self, user_id, attributes): """ Get params which are used same in both conversion and impression events. Args: user_id: ID for user. attributes: Dict representing user attributes and values which need to be recorded. Returns: Dict consisting of parameters common to ...
python
def _get_common_params(self, user_id, attributes): """ Get params which are used same in both conversion and impression events. Args: user_id: ID for user. attributes: Dict representing user attributes and values which need to be recorded. Returns: Dict consisting of parameters common to ...
[ "def", "_get_common_params", "(", "self", ",", "user_id", ",", "attributes", ")", ":", "commonParams", "=", "{", "}", "commonParams", "[", "self", ".", "EventParams", ".", "PROJECT_ID", "]", "=", "self", ".", "_get_project_id", "(", ")", "commonParams", "[",...
Get params which are used same in both conversion and impression events. Args: user_id: ID for user. attributes: Dict representing user attributes and values which need to be recorded. Returns: Dict consisting of parameters common to both impression and conversion events.
[ "Get", "params", "which", "are", "used", "same", "in", "both", "conversion", "and", "impression", "events", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/event_builder.py#L109-L138
12,178
optimizely/python-sdk
optimizely/event_builder.py
EventBuilder._get_required_params_for_impression
def _get_required_params_for_impression(self, experiment, variation_id): """ Get parameters that are required for the impression event to register. Args: experiment: Experiment for which impression needs to be recorded. variation_id: ID for variation which would be presented to user. Returns: ...
python
def _get_required_params_for_impression(self, experiment, variation_id): """ Get parameters that are required for the impression event to register. Args: experiment: Experiment for which impression needs to be recorded. variation_id: ID for variation which would be presented to user. Returns: ...
[ "def", "_get_required_params_for_impression", "(", "self", ",", "experiment", ",", "variation_id", ")", ":", "snapshot", "=", "{", "}", "snapshot", "[", "self", ".", "EventParams", ".", "DECISIONS", "]", "=", "[", "{", "self", ".", "EventParams", ".", "EXPER...
Get parameters that are required for the impression event to register. Args: experiment: Experiment for which impression needs to be recorded. variation_id: ID for variation which would be presented to user. Returns: Dict consisting of decisions and events info for impression event.
[ "Get", "parameters", "that", "are", "required", "for", "the", "impression", "event", "to", "register", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/event_builder.py#L211-L236
12,179
optimizely/python-sdk
optimizely/event_builder.py
EventBuilder._get_required_params_for_conversion
def _get_required_params_for_conversion(self, event_key, event_tags): """ Get parameters that are required for the conversion event to register. Args: event_key: Key representing the event which needs to be recorded. event_tags: Dict representing metadata associated with the event. Returns: ...
python
def _get_required_params_for_conversion(self, event_key, event_tags): """ Get parameters that are required for the conversion event to register. Args: event_key: Key representing the event which needs to be recorded. event_tags: Dict representing metadata associated with the event. Returns: ...
[ "def", "_get_required_params_for_conversion", "(", "self", ",", "event_key", ",", "event_tags", ")", ":", "snapshot", "=", "{", "}", "event_dict", "=", "{", "self", ".", "EventParams", ".", "EVENT_ID", ":", "self", ".", "config", ".", "get_event", "(", "even...
Get parameters that are required for the conversion event to register. Args: event_key: Key representing the event which needs to be recorded. event_tags: Dict representing metadata associated with the event. Returns: Dict consisting of the decisions and events info for conversion event.
[ "Get", "parameters", "that", "are", "required", "for", "the", "conversion", "event", "to", "register", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/event_builder.py#L238-L270
12,180
optimizely/python-sdk
optimizely/event_builder.py
EventBuilder.create_impression_event
def create_impression_event(self, experiment, variation_id, user_id, attributes): """ Create impression Event to be sent to the logging endpoint. Args: experiment: Experiment for which impression needs to be recorded. variation_id: ID for variation which would be presented to user. user_id: I...
python
def create_impression_event(self, experiment, variation_id, user_id, attributes): """ Create impression Event to be sent to the logging endpoint. Args: experiment: Experiment for which impression needs to be recorded. variation_id: ID for variation which would be presented to user. user_id: I...
[ "def", "create_impression_event", "(", "self", ",", "experiment", ",", "variation_id", ",", "user_id", ",", "attributes", ")", ":", "params", "=", "self", ".", "_get_common_params", "(", "user_id", ",", "attributes", ")", "impression_params", "=", "self", ".", ...
Create impression Event to be sent to the logging endpoint. Args: experiment: Experiment for which impression needs to be recorded. variation_id: ID for variation which would be presented to user. user_id: ID for user. attributes: Dict representing user attributes and values which need to b...
[ "Create", "impression", "Event", "to", "be", "sent", "to", "the", "logging", "endpoint", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/event_builder.py#L272-L293
12,181
optimizely/python-sdk
optimizely/event_builder.py
EventBuilder.create_conversion_event
def create_conversion_event(self, event_key, user_id, attributes, event_tags): """ Create conversion Event to be sent to the logging endpoint. Args: event_key: Key representing the event which needs to be recorded. user_id: ID for user. attributes: Dict representing user attributes and values...
python
def create_conversion_event(self, event_key, user_id, attributes, event_tags): """ Create conversion Event to be sent to the logging endpoint. Args: event_key: Key representing the event which needs to be recorded. user_id: ID for user. attributes: Dict representing user attributes and values...
[ "def", "create_conversion_event", "(", "self", ",", "event_key", ",", "user_id", ",", "attributes", ",", "event_tags", ")", ":", "params", "=", "self", ".", "_get_common_params", "(", "user_id", ",", "attributes", ")", "conversion_params", "=", "self", ".", "_...
Create conversion Event to be sent to the logging endpoint. Args: event_key: Key representing the event which needs to be recorded. user_id: ID for user. attributes: Dict representing user attributes and values. event_tags: Dict representing metadata associated with the event. Returns:...
[ "Create", "conversion", "Event", "to", "be", "sent", "to", "the", "logging", "endpoint", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/event_builder.py#L295-L315
12,182
optimizely/python-sdk
optimizely/helpers/condition.py
_audience_condition_deserializer
def _audience_condition_deserializer(obj_dict): """ Deserializer defining how dict objects need to be decoded for audience conditions. Args: obj_dict: Dict representing one audience condition. Returns: List consisting of condition key with corresponding value, type and match. """ return [ obj_di...
python
def _audience_condition_deserializer(obj_dict): """ Deserializer defining how dict objects need to be decoded for audience conditions. Args: obj_dict: Dict representing one audience condition. Returns: List consisting of condition key with corresponding value, type and match. """ return [ obj_di...
[ "def", "_audience_condition_deserializer", "(", "obj_dict", ")", ":", "return", "[", "obj_dict", ".", "get", "(", "'name'", ")", ",", "obj_dict", ".", "get", "(", "'value'", ")", ",", "obj_dict", ".", "get", "(", "'type'", ")", ",", "obj_dict", ".", "get...
Deserializer defining how dict objects need to be decoded for audience conditions. Args: obj_dict: Dict representing one audience condition. Returns: List consisting of condition key with corresponding value, type and match.
[ "Deserializer", "defining", "how", "dict", "objects", "need", "to", "be", "decoded", "for", "audience", "conditions", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition.py#L328-L342
12,183
optimizely/python-sdk
optimizely/helpers/condition.py
CustomAttributeConditionEvaluator._get_condition_json
def _get_condition_json(self, index): """ Method to generate json for logging audience condition. Args: index: Index of the condition. Returns: String: Audience condition JSON. """ condition = self.condition_data[index] condition_log = { 'name': condition[0], 'value': c...
python
def _get_condition_json(self, index): """ Method to generate json for logging audience condition. Args: index: Index of the condition. Returns: String: Audience condition JSON. """ condition = self.condition_data[index] condition_log = { 'name': condition[0], 'value': c...
[ "def", "_get_condition_json", "(", "self", ",", "index", ")", ":", "condition", "=", "self", ".", "condition_data", "[", "index", "]", "condition_log", "=", "{", "'name'", ":", "condition", "[", "0", "]", ",", "'value'", ":", "condition", "[", "1", "]", ...
Method to generate json for logging audience condition. Args: index: Index of the condition. Returns: String: Audience condition JSON.
[ "Method", "to", "generate", "json", "for", "logging", "audience", "condition", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition.py#L47-L64
12,184
optimizely/python-sdk
optimizely/helpers/condition.py
CustomAttributeConditionEvaluator.is_value_type_valid_for_exact_conditions
def is_value_type_valid_for_exact_conditions(self, value): """ Method to validate if the value is valid for exact match type evaluation. Args: value: Value to validate. Returns: Boolean: True if value is a string, boolean, or number. Otherwise False. """ # No need to check for bool sin...
python
def is_value_type_valid_for_exact_conditions(self, value): """ Method to validate if the value is valid for exact match type evaluation. Args: value: Value to validate. Returns: Boolean: True if value is a string, boolean, or number. Otherwise False. """ # No need to check for bool sin...
[ "def", "is_value_type_valid_for_exact_conditions", "(", "self", ",", "value", ")", ":", "# No need to check for bool since bool is a subclass of int", "if", "isinstance", "(", "value", ",", "string_types", ")", "or", "isinstance", "(", "value", ",", "(", "numbers", ".",...
Method to validate if the value is valid for exact match type evaluation. Args: value: Value to validate. Returns: Boolean: True if value is a string, boolean, or number. Otherwise False.
[ "Method", "to", "validate", "if", "the", "value", "is", "valid", "for", "exact", "match", "type", "evaluation", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition.py#L66-L79
12,185
optimizely/python-sdk
optimizely/helpers/condition.py
CustomAttributeConditionEvaluator.exists_evaluator
def exists_evaluator(self, index): """ Evaluate the given exists match condition for the user attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: True if the user attributes have a non-null value for the given condition, otherwise False. ...
python
def exists_evaluator(self, index): """ Evaluate the given exists match condition for the user attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: True if the user attributes have a non-null value for the given condition, otherwise False. ...
[ "def", "exists_evaluator", "(", "self", ",", "index", ")", ":", "attr_name", "=", "self", ".", "condition_data", "[", "index", "]", "[", "0", "]", "return", "self", ".", "attributes", ".", "get", "(", "attr_name", ")", "is", "not", "None" ]
Evaluate the given exists match condition for the user attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: True if the user attributes have a non-null value for the given condition, otherwise False.
[ "Evaluate", "the", "given", "exists", "match", "condition", "for", "the", "user", "attributes", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition.py#L131-L142
12,186
optimizely/python-sdk
optimizely/helpers/condition.py
CustomAttributeConditionEvaluator.greater_than_evaluator
def greater_than_evaluator(self, index): """ Evaluate the given greater than match condition for the user attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: - True if the user attribute value is greater than the condition value. - Fal...
python
def greater_than_evaluator(self, index): """ Evaluate the given greater than match condition for the user attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: - True if the user attribute value is greater than the condition value. - Fal...
[ "def", "greater_than_evaluator", "(", "self", ",", "index", ")", ":", "condition_name", "=", "self", ".", "condition_data", "[", "index", "]", "[", "0", "]", "condition_value", "=", "self", ".", "condition_data", "[", "index", "]", "[", "1", "]", "user_val...
Evaluate the given greater than match condition for the user attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: - True if the user attribute value is greater than the condition value. - False if the user attribute value is less than or eq...
[ "Evaluate", "the", "given", "greater", "than", "match", "condition", "for", "the", "user", "attributes", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition.py#L144-L181
12,187
optimizely/python-sdk
optimizely/helpers/condition.py
CustomAttributeConditionEvaluator.substring_evaluator
def substring_evaluator(self, index): """ Evaluate the given substring match condition for the given user attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: - True if the condition value is a substring of the user attribute value. - False if the ...
python
def substring_evaluator(self, index): """ Evaluate the given substring match condition for the given user attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: - True if the condition value is a substring of the user attribute value. - False if the ...
[ "def", "substring_evaluator", "(", "self", ",", "index", ")", ":", "condition_name", "=", "self", ".", "condition_data", "[", "index", "]", "[", "0", "]", "condition_value", "=", "self", ".", "condition_data", "[", "index", "]", "[", "1", "]", "user_value"...
Evaluate the given substring match condition for the given user attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: - True if the condition value is a substring of the user attribute value. - False if the condition value is not a substring of the user...
[ "Evaluate", "the", "given", "substring", "match", "condition", "for", "the", "given", "user", "attributes", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition.py#L222-L252
12,188
optimizely/python-sdk
optimizely/helpers/condition.py
CustomAttributeConditionEvaluator.evaluate
def evaluate(self, index): """ Given a custom attribute audience condition and user attributes, evaluate the condition against the attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: - True if the user attributes match the given condition. ...
python
def evaluate(self, index): """ Given a custom attribute audience condition and user attributes, evaluate the condition against the attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: - True if the user attributes match the given condition. ...
[ "def", "evaluate", "(", "self", ",", "index", ")", ":", "if", "self", ".", "condition_data", "[", "index", "]", "[", "2", "]", "!=", "self", ".", "CUSTOM_ATTRIBUTE_CONDITION_TYPE", ":", "self", ".", "logger", ".", "warning", "(", "audience_logs", ".", "U...
Given a custom attribute audience condition and user attributes, evaluate the condition against the attributes. Args: index: Index of the condition to be evaluated. Returns: Boolean: - True if the user attributes match the given condition. - False if the user attributes don...
[ "Given", "a", "custom", "attribute", "audience", "condition", "and", "user", "attributes", "evaluate", "the", "condition", "against", "the", "attributes", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition.py#L262-L298
12,189
optimizely/python-sdk
optimizely/helpers/condition.py
ConditionDecoder.object_hook
def object_hook(self, object_dict): """ Hook which when passed into a json.JSONDecoder will replace each dict in a json string with its index and convert the dict to an object as defined by the passed in condition_decoder. The newly created condition object is appended to the conditions_list. Args:...
python
def object_hook(self, object_dict): """ Hook which when passed into a json.JSONDecoder will replace each dict in a json string with its index and convert the dict to an object as defined by the passed in condition_decoder. The newly created condition object is appended to the conditions_list. Args:...
[ "def", "object_hook", "(", "self", ",", "object_dict", ")", ":", "instance", "=", "self", ".", "decoder", "(", "object_dict", ")", "self", ".", "condition_list", ".", "append", "(", "instance", ")", "self", ".", "index", "+=", "1", "return", "self", ".",...
Hook which when passed into a json.JSONDecoder will replace each dict in a json string with its index and convert the dict to an object as defined by the passed in condition_decoder. The newly created condition object is appended to the conditions_list. Args: object_dict: Dict representing an obj...
[ "Hook", "which", "when", "passed", "into", "a", "json", ".", "JSONDecoder", "will", "replace", "each", "dict", "in", "a", "json", "string", "with", "its", "index", "and", "convert", "the", "dict", "to", "an", "object", "as", "defined", "by", "the", "pass...
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition.py#L310-L325
12,190
optimizely/python-sdk
optimizely/decision_service.py
DecisionService._get_bucketing_id
def _get_bucketing_id(self, user_id, attributes): """ Helper method to determine bucketing ID for the user. Args: user_id: ID for user. attributes: Dict representing user attributes. May consist of bucketing ID to be used. Returns: String representing bucketing ID if it is a String type ...
python
def _get_bucketing_id(self, user_id, attributes): """ Helper method to determine bucketing ID for the user. Args: user_id: ID for user. attributes: Dict representing user attributes. May consist of bucketing ID to be used. Returns: String representing bucketing ID if it is a String type ...
[ "def", "_get_bucketing_id", "(", "self", ",", "user_id", ",", "attributes", ")", ":", "attributes", "=", "attributes", "or", "{", "}", "bucketing_id", "=", "attributes", ".", "get", "(", "enums", ".", "ControlAttributes", ".", "BUCKETING_ID", ")", "if", "buc...
Helper method to determine bucketing ID for the user. Args: user_id: ID for user. attributes: Dict representing user attributes. May consist of bucketing ID to be used. Returns: String representing bucketing ID if it is a String type in attributes else return user ID.
[ "Helper", "method", "to", "determine", "bucketing", "ID", "for", "the", "user", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/decision_service.py#L36-L56
12,191
optimizely/python-sdk
optimizely/decision_service.py
DecisionService.get_forced_variation
def get_forced_variation(self, experiment, user_id): """ Determine if a user is forced into a variation for the given experiment and return that variation. Args: experiment: Object representing the experiment for which user is to be bucketed. user_id: ID for the user. Returns: Variation ...
python
def get_forced_variation(self, experiment, user_id): """ Determine if a user is forced into a variation for the given experiment and return that variation. Args: experiment: Object representing the experiment for which user is to be bucketed. user_id: ID for the user. Returns: Variation ...
[ "def", "get_forced_variation", "(", "self", ",", "experiment", ",", "user_id", ")", ":", "forced_variations", "=", "experiment", ".", "forcedVariations", "if", "forced_variations", "and", "user_id", "in", "forced_variations", ":", "variation_key", "=", "forced_variati...
Determine if a user is forced into a variation for the given experiment and return that variation. Args: experiment: Object representing the experiment for which user is to be bucketed. user_id: ID for the user. Returns: Variation in which the user with ID user_id is forced into. None if no ...
[ "Determine", "if", "a", "user", "is", "forced", "into", "a", "variation", "for", "the", "given", "experiment", "and", "return", "that", "variation", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/decision_service.py#L58-L77
12,192
optimizely/python-sdk
optimizely/decision_service.py
DecisionService.get_stored_variation
def get_stored_variation(self, experiment, user_profile): """ Determine if the user has a stored variation available for the given experiment and return that. Args: experiment: Object representing the experiment for which user is to be bucketed. user_profile: UserProfile object representing the use...
python
def get_stored_variation(self, experiment, user_profile): """ Determine if the user has a stored variation available for the given experiment and return that. Args: experiment: Object representing the experiment for which user is to be bucketed. user_profile: UserProfile object representing the use...
[ "def", "get_stored_variation", "(", "self", ",", "experiment", ",", "user_profile", ")", ":", "user_id", "=", "user_profile", ".", "user_id", "variation_id", "=", "user_profile", ".", "get_variation_for_experiment", "(", "experiment", ".", "id", ")", "if", "variat...
Determine if the user has a stored variation available for the given experiment and return that. Args: experiment: Object representing the experiment for which user is to be bucketed. user_profile: UserProfile object representing the user's profile. Returns: Variation if available. None othe...
[ "Determine", "if", "the", "user", "has", "a", "stored", "variation", "available", "for", "the", "given", "experiment", "and", "return", "that", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/decision_service.py#L79-L103
12,193
optimizely/python-sdk
optimizely/decision_service.py
DecisionService.get_variation
def get_variation(self, experiment, user_id, attributes, ignore_user_profile=False): """ Top-level function to help determine variation user should be put in. First, check if experiment is running. Second, check if user is forced in a variation. Third, check if there is a stored decision for the user a...
python
def get_variation(self, experiment, user_id, attributes, ignore_user_profile=False): """ Top-level function to help determine variation user should be put in. First, check if experiment is running. Second, check if user is forced in a variation. Third, check if there is a stored decision for the user a...
[ "def", "get_variation", "(", "self", ",", "experiment", ",", "user_id", ",", "attributes", ",", "ignore_user_profile", "=", "False", ")", ":", "# Check if experiment is running", "if", "not", "experiment_helper", ".", "is_experiment_running", "(", "experiment", ")", ...
Top-level function to help determine variation user should be put in. First, check if experiment is running. Second, check if user is forced in a variation. Third, check if there is a stored decision for the user and return the corresponding variation. Fourth, figure out if user is in the experiment by...
[ "Top", "-", "level", "function", "to", "help", "determine", "variation", "user", "should", "be", "put", "in", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/decision_service.py#L105-L178
12,194
optimizely/python-sdk
optimizely/decision_service.py
DecisionService.get_experiment_in_group
def get_experiment_in_group(self, group, bucketing_id): """ Determine which experiment in the group the user is bucketed into. Args: group: The group to bucket the user into. bucketing_id: ID to be used for bucketing the user. Returns: Experiment if the user is bucketed into an experimen...
python
def get_experiment_in_group(self, group, bucketing_id): """ Determine which experiment in the group the user is bucketed into. Args: group: The group to bucket the user into. bucketing_id: ID to be used for bucketing the user. Returns: Experiment if the user is bucketed into an experimen...
[ "def", "get_experiment_in_group", "(", "self", ",", "group", ",", "bucketing_id", ")", ":", "experiment_id", "=", "self", ".", "bucketer", ".", "find_bucket", "(", "bucketing_id", ",", "group", ".", "id", ",", "group", ".", "trafficAllocation", ")", "if", "e...
Determine which experiment in the group the user is bucketed into. Args: group: The group to bucket the user into. bucketing_id: ID to be used for bucketing the user. Returns: Experiment if the user is bucketed into an experiment in the specified group. None otherwise.
[ "Determine", "which", "experiment", "in", "the", "group", "the", "user", "is", "bucketed", "into", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/decision_service.py#L238-L265
12,195
optimizely/python-sdk
optimizely/notification_center.py
NotificationCenter.add_notification_listener
def add_notification_listener(self, notification_type, notification_callback): """ Add a notification callback to the notification center. Args: notification_type: A string representing the notification type from .helpers.enums.NotificationTypes notification_callback: closure of function to call wh...
python
def add_notification_listener(self, notification_type, notification_callback): """ Add a notification callback to the notification center. Args: notification_type: A string representing the notification type from .helpers.enums.NotificationTypes notification_callback: closure of function to call wh...
[ "def", "add_notification_listener", "(", "self", ",", "notification_type", ",", "notification_callback", ")", ":", "if", "notification_type", "not", "in", "self", ".", "notifications", ":", "self", ".", "notifications", "[", "notification_type", "]", "=", "[", "("...
Add a notification callback to the notification center. Args: notification_type: A string representing the notification type from .helpers.enums.NotificationTypes notification_callback: closure of function to call when event is triggered. Returns: Integer notification id used to remove the n...
[ "Add", "a", "notification", "callback", "to", "the", "notification", "center", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/notification_center.py#L29-L53
12,196
optimizely/python-sdk
optimizely/notification_center.py
NotificationCenter.remove_notification_listener
def remove_notification_listener(self, notification_id): """ Remove a previously added notification callback. Args: notification_id: The numeric id passed back from add_notification_listener Returns: The function returns boolean true if found and removed, false otherwise. """ for v in...
python
def remove_notification_listener(self, notification_id): """ Remove a previously added notification callback. Args: notification_id: The numeric id passed back from add_notification_listener Returns: The function returns boolean true if found and removed, false otherwise. """ for v in...
[ "def", "remove_notification_listener", "(", "self", ",", "notification_id", ")", ":", "for", "v", "in", "self", ".", "notifications", ".", "values", "(", ")", ":", "toRemove", "=", "list", "(", "filter", "(", "lambda", "tup", ":", "tup", "[", "0", "]", ...
Remove a previously added notification callback. Args: notification_id: The numeric id passed back from add_notification_listener Returns: The function returns boolean true if found and removed, false otherwise.
[ "Remove", "a", "previously", "added", "notification", "callback", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/notification_center.py#L55-L71
12,197
optimizely/python-sdk
optimizely/notification_center.py
NotificationCenter.send_notifications
def send_notifications(self, notification_type, *args): """ Fires off the notification for the specific event. Uses var args to pass in a arbitrary list of parameter according to which notification type was fired. Args: notification_type: Type of notification to fire (String from .helpers.enums....
python
def send_notifications(self, notification_type, *args): """ Fires off the notification for the specific event. Uses var args to pass in a arbitrary list of parameter according to which notification type was fired. Args: notification_type: Type of notification to fire (String from .helpers.enums....
[ "def", "send_notifications", "(", "self", ",", "notification_type", ",", "*", "args", ")", ":", "if", "notification_type", "in", "self", ".", "notifications", ":", "for", "notification_id", ",", "callback", "in", "self", ".", "notifications", "[", "notification_...
Fires off the notification for the specific event. Uses var args to pass in a arbitrary list of parameter according to which notification type was fired. Args: notification_type: Type of notification to fire (String from .helpers.enums.NotificationTypes) args: variable list of arguments to the...
[ "Fires", "off", "the", "notification", "for", "the", "specific", "event", ".", "Uses", "var", "args", "to", "pass", "in", "a", "arbitrary", "list", "of", "parameter", "according", "to", "which", "notification", "type", "was", "fired", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/notification_center.py#L87-L101
12,198
optimizely/python-sdk
optimizely/helpers/condition_tree_evaluator.py
and_evaluator
def and_evaluator(conditions, leaf_evaluator): """ Evaluates a list of conditions as if the evaluator had been applied to each entry and the results AND-ed together. Args: conditions: List of conditions ex: [operand_1, operand_2]. leaf_evaluator: Function which will be called to evaluate leaf condition v...
python
def and_evaluator(conditions, leaf_evaluator): """ Evaluates a list of conditions as if the evaluator had been applied to each entry and the results AND-ed together. Args: conditions: List of conditions ex: [operand_1, operand_2]. leaf_evaluator: Function which will be called to evaluate leaf condition v...
[ "def", "and_evaluator", "(", "conditions", ",", "leaf_evaluator", ")", ":", "saw_null_result", "=", "False", "for", "condition", "in", "conditions", ":", "result", "=", "evaluate", "(", "condition", ",", "leaf_evaluator", ")", "if", "result", "is", "False", ":...
Evaluates a list of conditions as if the evaluator had been applied to each entry and the results AND-ed together. Args: conditions: List of conditions ex: [operand_1, operand_2]. leaf_evaluator: Function which will be called to evaluate leaf condition values. Returns: Boolean: - True if all o...
[ "Evaluates", "a", "list", "of", "conditions", "as", "if", "the", "evaluator", "had", "been", "applied", "to", "each", "entry", "and", "the", "results", "AND", "-", "ed", "together", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition_tree_evaluator.py#L17-L40
12,199
optimizely/python-sdk
optimizely/helpers/condition_tree_evaluator.py
not_evaluator
def not_evaluator(conditions, leaf_evaluator): """ Evaluates a list of conditions as if the evaluator had been applied to a single entry and NOT was applied to the result. Args: conditions: List of conditions ex: [operand_1, operand_2]. leaf_evaluator: Function which will be called to evaluate leaf condi...
python
def not_evaluator(conditions, leaf_evaluator): """ Evaluates a list of conditions as if the evaluator had been applied to a single entry and NOT was applied to the result. Args: conditions: List of conditions ex: [operand_1, operand_2]. leaf_evaluator: Function which will be called to evaluate leaf condi...
[ "def", "not_evaluator", "(", "conditions", ",", "leaf_evaluator", ")", ":", "if", "not", "len", "(", "conditions", ")", ">", "0", ":", "return", "None", "result", "=", "evaluate", "(", "conditions", "[", "0", "]", ",", "leaf_evaluator", ")", "return", "N...
Evaluates a list of conditions as if the evaluator had been applied to a single entry and NOT was applied to the result. Args: conditions: List of conditions ex: [operand_1, operand_2]. leaf_evaluator: Function which will be called to evaluate leaf condition values. Returns: Boolean: - True if...
[ "Evaluates", "a", "list", "of", "conditions", "as", "if", "the", "evaluator", "had", "been", "applied", "to", "a", "single", "entry", "and", "NOT", "was", "applied", "to", "the", "result", "." ]
ec028d9efcf22498c3820f2650fa10f5c30bec90
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/helpers/condition_tree_evaluator.py#L69-L87