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
227,900
tensorflow/mesh
mesh_tensorflow/ops.py
serialize_training_step
def serialize_training_step(features, model_fn, batch_dim, num_splits): """Break the training batch into multiple microbatches. Returns two structures: grads - a list of Tensors corresponding to the gradients on graph.trainable_variables. These are summed across all microbatches outputs - a dictionary ...
python
def serialize_training_step(features, model_fn, batch_dim, num_splits): """Break the training batch into multiple microbatches. Returns two structures: grads - a list of Tensors corresponding to the gradients on graph.trainable_variables. These are summed across all microbatches outputs - a dictionary ...
[ "def", "serialize_training_step", "(", "features", ",", "model_fn", ",", "batch_dim", ",", "num_splits", ")", ":", "for", "v", "in", "features", ".", "values", "(", ")", ":", "mesh", "=", "v", ".", "mesh", "graph", "=", "v", ".", "graph", "microbatch_dim...
Break the training batch into multiple microbatches. Returns two structures: grads - a list of Tensors corresponding to the gradients on graph.trainable_variables. These are summed across all microbatches outputs - a dictionary of Tensors corresponding to the output dictionary of model_fn. Each va...
[ "Break", "the", "training", "batch", "into", "multiple", "microbatches", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L5146-L5231
227,901
tensorflow/mesh
mesh_tensorflow/ops.py
Shape.rename_dimension
def rename_dimension(self, old_name, new_name): """Returns a copy where one dimension is renamed.""" if old_name not in self.dimension_names: raise ValueError("Shape %s does not have dimension named %s" % (self, old_name)) return Shape( [Dimension(new_name, d.size) if d....
python
def rename_dimension(self, old_name, new_name): """Returns a copy where one dimension is renamed.""" if old_name not in self.dimension_names: raise ValueError("Shape %s does not have dimension named %s" % (self, old_name)) return Shape( [Dimension(new_name, d.size) if d....
[ "def", "rename_dimension", "(", "self", ",", "old_name", ",", "new_name", ")", ":", "if", "old_name", "not", "in", "self", ".", "dimension_names", ":", "raise", "ValueError", "(", "\"Shape %s does not have dimension named %s\"", "%", "(", "self", ",", "old_name", ...
Returns a copy where one dimension is renamed.
[ "Returns", "a", "copy", "where", "one", "dimension", "is", "renamed", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L163-L170
227,902
tensorflow/mesh
mesh_tensorflow/ops.py
Shape.resize_dimension
def resize_dimension(self, name, new_size): """Returns a copy where one dimension has a different size.""" if name not in self.dimension_names: raise ValueError("Shape %s does not have dimension named %s" % (self, name)) return Shape( [Dimension(name, new_size) if d.name...
python
def resize_dimension(self, name, new_size): """Returns a copy where one dimension has a different size.""" if name not in self.dimension_names: raise ValueError("Shape %s does not have dimension named %s" % (self, name)) return Shape( [Dimension(name, new_size) if d.name...
[ "def", "resize_dimension", "(", "self", ",", "name", ",", "new_size", ")", ":", "if", "name", "not", "in", "self", ".", "dimension_names", ":", "raise", "ValueError", "(", "\"Shape %s does not have dimension named %s\"", "%", "(", "self", ",", "name", ")", ")"...
Returns a copy where one dimension has a different size.
[ "Returns", "a", "copy", "where", "one", "dimension", "has", "a", "different", "size", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L172-L179
227,903
tensorflow/mesh
mesh_tensorflow/ops.py
LayoutRules.tensor_layout
def tensor_layout(self, tensor_shape, mesh_shape): """Computes TensorLayout given a Tensor Shape and a Mesh Shape. Args: tensor_shape: Shape. mesh_shape: Shape. Returns: TensorLayout. Raises: ValueError: If two Tensor Dimensions map to the same Mesh Dimensions. """ ret...
python
def tensor_layout(self, tensor_shape, mesh_shape): """Computes TensorLayout given a Tensor Shape and a Mesh Shape. Args: tensor_shape: Shape. mesh_shape: Shape. Returns: TensorLayout. Raises: ValueError: If two Tensor Dimensions map to the same Mesh Dimensions. """ ret...
[ "def", "tensor_layout", "(", "self", ",", "tensor_shape", ",", "mesh_shape", ")", ":", "ret", "=", "[", "self", ".", "tensor_dimension_to_mesh_axis", "(", "d", ",", "mesh_shape", ")", "for", "d", "in", "tensor_shape", "]", "not_nones", "=", "[", "a", "for"...
Computes TensorLayout given a Tensor Shape and a Mesh Shape. Args: tensor_shape: Shape. mesh_shape: Shape. Returns: TensorLayout. Raises: ValueError: If two Tensor Dimensions map to the same Mesh Dimensions.
[ "Computes", "TensorLayout", "given", "a", "Tensor", "Shape", "and", "a", "Mesh", "Shape", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L247-L268
227,904
tensorflow/mesh
mesh_tensorflow/ops.py
TensorLayout.mesh_axis_to_tensor_axis
def mesh_axis_to_tensor_axis(self, mesh_ndims): """For each mesh axis, which Tensor axis maps to it. Args: mesh_ndims: int. Returns: Tuple of optional integers, with length mesh_ndims. """ ta2ma = self._tensor_axis_to_mesh_axis return tuple( [ta2ma.index(mesh_axis) if mesh_...
python
def mesh_axis_to_tensor_axis(self, mesh_ndims): """For each mesh axis, which Tensor axis maps to it. Args: mesh_ndims: int. Returns: Tuple of optional integers, with length mesh_ndims. """ ta2ma = self._tensor_axis_to_mesh_axis return tuple( [ta2ma.index(mesh_axis) if mesh_...
[ "def", "mesh_axis_to_tensor_axis", "(", "self", ",", "mesh_ndims", ")", ":", "ta2ma", "=", "self", ".", "_tensor_axis_to_mesh_axis", "return", "tuple", "(", "[", "ta2ma", ".", "index", "(", "mesh_axis", ")", "if", "mesh_axis", "in", "ta2ma", "else", "None", ...
For each mesh axis, which Tensor axis maps to it. Args: mesh_ndims: int. Returns: Tuple of optional integers, with length mesh_ndims.
[ "For", "each", "mesh", "axis", "which", "Tensor", "axis", "maps", "to", "it", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L339-L351
227,905
tensorflow/mesh
mesh_tensorflow/ops.py
Graph.unique_name
def unique_name(self, name, mark_as_used=True): """Like tf.Graph.unique_name, returns a unique operation name for `name`. Args: name: The name for an operation. mark_as_used: whether to mark this name as being used. Returns: A string to use as the name for the operation. """ scop...
python
def unique_name(self, name, mark_as_used=True): """Like tf.Graph.unique_name, returns a unique operation name for `name`. Args: name: The name for an operation. mark_as_used: whether to mark this name as being used. Returns: A string to use as the name for the operation. """ scop...
[ "def", "unique_name", "(", "self", ",", "name", ",", "mark_as_used", "=", "True", ")", ":", "scope_name", "=", "tf", ".", "get_variable_scope", "(", ")", ".", "name", "if", "scope_name", ":", "name", "=", "scope_name", "+", "\"/\"", "+", "name", "# As in...
Like tf.Graph.unique_name, returns a unique operation name for `name`. Args: name: The name for an operation. mark_as_used: whether to mark this name as being used. Returns: A string to use as the name for the operation.
[ "Like", "tf", ".", "Graph", ".", "unique_name", "returns", "a", "unique", "operation", "name", "for", "name", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L384-L413
227,906
tensorflow/mesh
mesh_tensorflow/ops.py
Graph.combine_assignments
def combine_assignments(self, assignments): """Rewrite the current graph to combine "Assign" operations. Combine similar Assign operations into grouped Assign operations. This is useful when using the rewrite_stack_variables() optimization, since variables can only be stacked if they are present in the...
python
def combine_assignments(self, assignments): """Rewrite the current graph to combine "Assign" operations. Combine similar Assign operations into grouped Assign operations. This is useful when using the rewrite_stack_variables() optimization, since variables can only be stacked if they are present in the...
[ "def", "combine_assignments", "(", "self", ",", "assignments", ")", ":", "group_by_fn", "=", "collections", ".", "defaultdict", "(", "list", ")", "for", "a", "in", "assignments", ":", "if", "not", "isinstance", "(", "a", ",", "Assign", ")", ":", "raise", ...
Rewrite the current graph to combine "Assign" operations. Combine similar Assign operations into grouped Assign operations. This is useful when using the rewrite_stack_variables() optimization, since variables can only be stacked if they are present in the same set of Assign operations. This funct...
[ "Rewrite", "the", "current", "graph", "to", "combine", "Assign", "operations", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L534-L567
227,907
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.tensor_layout
def tensor_layout(self, arg): """Compute TensorLayout for a Tensor or a Shape. Args: arg: Tensor or Shape. Returns: TensorLayout. """ if isinstance(arg, Tensor): arg = arg.shape return self.layout_rules.tensor_layout(arg, self.shape)
python
def tensor_layout(self, arg): """Compute TensorLayout for a Tensor or a Shape. Args: arg: Tensor or Shape. Returns: TensorLayout. """ if isinstance(arg, Tensor): arg = arg.shape return self.layout_rules.tensor_layout(arg, self.shape)
[ "def", "tensor_layout", "(", "self", ",", "arg", ")", ":", "if", "isinstance", "(", "arg", ",", "Tensor", ")", ":", "arg", "=", "arg", ".", "shape", "return", "self", ".", "layout_rules", ".", "tensor_layout", "(", "arg", ",", "self", ".", "shape", "...
Compute TensorLayout for a Tensor or a Shape. Args: arg: Tensor or Shape. Returns: TensorLayout.
[ "Compute", "TensorLayout", "for", "a", "Tensor", "or", "a", "Shape", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L803-L814
227,908
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.mesh_axis_to_cumprod
def mesh_axis_to_cumprod(self, tensor_shape): """For each mesh axis, give the product of previous tensor axes. Args: tensor_shape: Shape. Returns: list with length self.ndims where each element is an integer or None. """ tensor_layout = self.tensor_layout(tensor_shape) ma2ta = tens...
python
def mesh_axis_to_cumprod(self, tensor_shape): """For each mesh axis, give the product of previous tensor axes. Args: tensor_shape: Shape. Returns: list with length self.ndims where each element is an integer or None. """ tensor_layout = self.tensor_layout(tensor_shape) ma2ta = tens...
[ "def", "mesh_axis_to_cumprod", "(", "self", ",", "tensor_shape", ")", ":", "tensor_layout", "=", "self", ".", "tensor_layout", "(", "tensor_shape", ")", "ma2ta", "=", "tensor_layout", ".", "mesh_axis_to_tensor_axis", "(", "self", ".", "ndims", ")", "ta2cumprod", ...
For each mesh axis, give the product of previous tensor axes. Args: tensor_shape: Shape. Returns: list with length self.ndims where each element is an integer or None.
[ "For", "each", "mesh", "axis", "give", "the", "product", "of", "previous", "tensor", "axes", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L816-L828
227,909
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.slice_shape
def slice_shape(self, tensor_shape): """Shape of each slice of the Tensor. Args: tensor_shape: Shape. Returns: list of integers with length tensor_shape.ndims. Raises: ValueError: If a Tensor dimension is not divisible by the corresponding Mesh dimension. """ tensor_...
python
def slice_shape(self, tensor_shape): """Shape of each slice of the Tensor. Args: tensor_shape: Shape. Returns: list of integers with length tensor_shape.ndims. Raises: ValueError: If a Tensor dimension is not divisible by the corresponding Mesh dimension. """ tensor_...
[ "def", "slice_shape", "(", "self", ",", "tensor_shape", ")", ":", "tensor_layout", "=", "self", ".", "tensor_layout", "(", "tensor_shape", ")", "ret", "=", "[", "]", "for", "tensor_dim", ",", "mesh_axis", "in", "zip", "(", "tensor_shape", ",", "tensor_layout...
Shape of each slice of the Tensor. Args: tensor_shape: Shape. Returns: list of integers with length tensor_shape.ndims. Raises: ValueError: If a Tensor dimension is not divisible by the corresponding Mesh dimension.
[ "Shape", "of", "each", "slice", "of", "the", "Tensor", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L830-L857
227,910
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.slice_begin
def slice_begin(self, tensor_shape, pnum): """Begin position for the tensor slice for the given processor. Args: tensor_shape: Shape. pnum: int <= self.size. Returns: list of integers with length tensor_shape.ndims. """ tensor_layout = self.tensor_layout(tensor_shape) coordin...
python
def slice_begin(self, tensor_shape, pnum): """Begin position for the tensor slice for the given processor. Args: tensor_shape: Shape. pnum: int <= self.size. Returns: list of integers with length tensor_shape.ndims. """ tensor_layout = self.tensor_layout(tensor_shape) coordin...
[ "def", "slice_begin", "(", "self", ",", "tensor_shape", ",", "pnum", ")", ":", "tensor_layout", "=", "self", ".", "tensor_layout", "(", "tensor_shape", ")", "coordinates", "=", "pnum_to_processor_coordinates", "(", "self", ".", "shape", ",", "pnum", ")", "ret"...
Begin position for the tensor slice for the given processor. Args: tensor_shape: Shape. pnum: int <= self.size. Returns: list of integers with length tensor_shape.ndims.
[ "Begin", "position", "for", "the", "tensor", "slice", "for", "the", "given", "processor", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L859-L879
227,911
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.Print
def Print(self, x, data, message, **kwargs): # pylint: disable=invalid-name """Calls tf.Print. Args: x: LaidOutTensor. data: list of LaidOutTensor. message: str. **kwargs: keyword arguments to tf.print. Returns: LaidOutTensor. """ del data, message, kwargs tf.log...
python
def Print(self, x, data, message, **kwargs): # pylint: disable=invalid-name """Calls tf.Print. Args: x: LaidOutTensor. data: list of LaidOutTensor. message: str. **kwargs: keyword arguments to tf.print. Returns: LaidOutTensor. """ del data, message, kwargs tf.log...
[ "def", "Print", "(", "self", ",", "x", ",", "data", ",", "message", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=invalid-name", "del", "data", ",", "message", ",", "kwargs", "tf", ".", "logging", ".", "warning", "(", "\"Warning - mtf.Print not imple...
Calls tf.Print. Args: x: LaidOutTensor. data: list of LaidOutTensor. message: str. **kwargs: keyword arguments to tf.print. Returns: LaidOutTensor.
[ "Calls", "tf", ".", "Print", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L908-L922
227,912
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.allsplit
def allsplit(self, x, mesh_axis, split_axis, which=None): """Inverse of allconcat - split each slice and keep only one piece of it. The number of ways to split is the number of processors in the group. The part that is kept corresponds to the processor's index in the group. Args: x: LaidOutTenso...
python
def allsplit(self, x, mesh_axis, split_axis, which=None): """Inverse of allconcat - split each slice and keep only one piece of it. The number of ways to split is the number of processors in the group. The part that is kept corresponds to the processor's index in the group. Args: x: LaidOutTenso...
[ "def", "allsplit", "(", "self", ",", "x", ",", "mesh_axis", ",", "split_axis", ",", "which", "=", "None", ")", ":", "if", "which", "is", "None", ":", "which", "=", "self", ".", "laid_out_pcoord", "(", "mesh_axis", ")", "num_splits", "=", "self", ".", ...
Inverse of allconcat - split each slice and keep only one piece of it. The number of ways to split is the number of processors in the group. The part that is kept corresponds to the processor's index in the group. Args: x: LaidOutTensor. mesh_axis: int, the mesh axis along which to split. ...
[ "Inverse", "of", "allconcat", "-", "split", "each", "slice", "and", "keep", "only", "one", "piece", "of", "it", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L937-L964
227,913
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.shift_by_n_processors
def shift_by_n_processors(self, x, mesh_axis, offset, wrap): """Receive the slice from processor pcoord - offset. Args: x: a LaidOutTensor mesh_axis: an integer offset: an integer wrap: a boolean. If True, then wrap around. Otherwise, pad with zeros. """ n = self.shape[mesh_axis...
python
def shift_by_n_processors(self, x, mesh_axis, offset, wrap): """Receive the slice from processor pcoord - offset. Args: x: a LaidOutTensor mesh_axis: an integer offset: an integer wrap: a boolean. If True, then wrap around. Otherwise, pad with zeros. """ n = self.shape[mesh_axis...
[ "def", "shift_by_n_processors", "(", "self", ",", "x", ",", "mesh_axis", ",", "offset", ",", "wrap", ")", ":", "n", "=", "self", ".", "shape", "[", "mesh_axis", "]", ".", "size", "source_pcoord", "=", "[", "]", "for", "i", "in", "xrange", "(", "n", ...
Receive the slice from processor pcoord - offset. Args: x: a LaidOutTensor mesh_axis: an integer offset: an integer wrap: a boolean. If True, then wrap around. Otherwise, pad with zeros.
[ "Receive", "the", "slice", "from", "processor", "pcoord", "-", "offset", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L1017-L1036
227,914
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.laid_out_pcoord
def laid_out_pcoord(self, mesh_axis): """Returns a LaidOutTensor containing the processor coordinate. Args: mesh_axis: int. Returns: LaidOutTensor where each slice is an integer scalar. """ divisor = list_product(self.shape.to_integer_list[mesh_axis + 1:]) modulus = self.shape[mesh...
python
def laid_out_pcoord(self, mesh_axis): """Returns a LaidOutTensor containing the processor coordinate. Args: mesh_axis: int. Returns: LaidOutTensor where each slice is an integer scalar. """ divisor = list_product(self.shape.to_integer_list[mesh_axis + 1:]) modulus = self.shape[mesh...
[ "def", "laid_out_pcoord", "(", "self", ",", "mesh_axis", ")", ":", "divisor", "=", "list_product", "(", "self", ".", "shape", ".", "to_integer_list", "[", "mesh_axis", "+", "1", ":", "]", ")", "modulus", "=", "self", ".", "shape", "[", "mesh_axis", "]", ...
Returns a LaidOutTensor containing the processor coordinate. Args: mesh_axis: int. Returns: LaidOutTensor where each slice is an integer scalar.
[ "Returns", "a", "LaidOutTensor", "containing", "the", "processor", "coordinate", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L1046-L1059
227,915
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.laid_out_slice_num
def laid_out_slice_num(self, tensor_shape): """A LaidOutTensor with an int32 scalar, identical for identical slices. This is useful for synchronizing random operations. Args: tensor_shape: a TensorShape Returns: a LaidOutTensor where each slice is an integer scalar. """ ret = self....
python
def laid_out_slice_num(self, tensor_shape): """A LaidOutTensor with an int32 scalar, identical for identical slices. This is useful for synchronizing random operations. Args: tensor_shape: a TensorShape Returns: a LaidOutTensor where each slice is an integer scalar. """ ret = self....
[ "def", "laid_out_slice_num", "(", "self", ",", "tensor_shape", ")", ":", "ret", "=", "self", ".", "slicewise", "(", "lambda", ":", "tf", ".", "to_int32", "(", "0", ")", ")", "tensor_layout", "=", "self", ".", "tensor_layout", "(", "tensor_shape", ")", "f...
A LaidOutTensor with an int32 scalar, identical for identical slices. This is useful for synchronizing random operations. Args: tensor_shape: a TensorShape Returns: a LaidOutTensor where each slice is an integer scalar.
[ "A", "LaidOutTensor", "with", "an", "int32", "scalar", "identical", "for", "identical", "slices", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L1061-L1080
227,916
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.broadcast_impl
def broadcast_impl(self, old_slices, old_shape, new_shape): """Implementation of a broadcast operation. Args: old_slices: LaidOutTensor. old_shape: Shape. new_shape: Shape. Returns: LaidOutTensor. """ new_slice_shape = self.slice_shape(new_shape) def tf_fn(x): ret...
python
def broadcast_impl(self, old_slices, old_shape, new_shape): """Implementation of a broadcast operation. Args: old_slices: LaidOutTensor. old_shape: Shape. new_shape: Shape. Returns: LaidOutTensor. """ new_slice_shape = self.slice_shape(new_shape) def tf_fn(x): ret...
[ "def", "broadcast_impl", "(", "self", ",", "old_slices", ",", "old_shape", ",", "new_shape", ")", ":", "new_slice_shape", "=", "self", ".", "slice_shape", "(", "new_shape", ")", "def", "tf_fn", "(", "x", ")", ":", "return", "(", "tf", ".", "zeros", "(", ...
Implementation of a broadcast operation. Args: old_slices: LaidOutTensor. old_shape: Shape. new_shape: Shape. Returns: LaidOutTensor.
[ "Implementation", "of", "a", "broadcast", "operation", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L1082-L1097
227,917
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.make_slices
def make_slices(self, tf_tensor, tensor_shape): """Turns a single tf.Tensor into a list of slices, one for each processor. Args: tf_tensor: tf.Tensor. tensor_shape: Shape. Returns: list of tf.tensor with length self.size. """ tensor_layout = self.tensor_layout(tensor_shape) s...
python
def make_slices(self, tf_tensor, tensor_shape): """Turns a single tf.Tensor into a list of slices, one for each processor. Args: tf_tensor: tf.Tensor. tensor_shape: Shape. Returns: list of tf.tensor with length self.size. """ tensor_layout = self.tensor_layout(tensor_shape) s...
[ "def", "make_slices", "(", "self", ",", "tf_tensor", ",", "tensor_shape", ")", ":", "tensor_layout", "=", "self", ".", "tensor_layout", "(", "tensor_shape", ")", "slice_shape", "=", "self", ".", "slice_shape", "(", "tensor_shape", ")", "def", "my_fn", "(", "...
Turns a single tf.Tensor into a list of slices, one for each processor. Args: tf_tensor: tf.Tensor. tensor_shape: Shape. Returns: list of tf.tensor with length self.size.
[ "Turns", "a", "single", "tf", ".", "Tensor", "into", "a", "list", "of", "slices", "one", "for", "each", "processor", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L1099-L1119
227,918
tensorflow/mesh
mesh_tensorflow/ops.py
MeshImpl.combine_slices
def combine_slices(self, slices, tensor_shape, device=None): """Turns a set of slices into a single tensor. Args: slices: list of tf.Tensor with length self.size. tensor_shape: Shape. device: optional str. If absent, we use the devices of the slices. Returns: tf.Tensor. """ ...
python
def combine_slices(self, slices, tensor_shape, device=None): """Turns a set of slices into a single tensor. Args: slices: list of tf.Tensor with length self.size. tensor_shape: Shape. device: optional str. If absent, we use the devices of the slices. Returns: tf.Tensor. """ ...
[ "def", "combine_slices", "(", "self", ",", "slices", ",", "tensor_shape", ",", "device", "=", "None", ")", ":", "if", "tensor_shape", ".", "ndims", "==", "0", ":", "return", "slices", "[", "0", "]", "ret", "=", "slices", "[", ":", "]", "tensor_layout",...
Turns a set of slices into a single tensor. Args: slices: list of tf.Tensor with length self.size. tensor_shape: Shape. device: optional str. If absent, we use the devices of the slices. Returns: tf.Tensor.
[ "Turns", "a", "set", "of", "slices", "into", "a", "single", "tensor", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L1121-L1155
227,919
tensorflow/mesh
mesh_tensorflow/ops.py
Operation._initialize_splittable_and_unsplittable_dims
def _initialize_splittable_and_unsplittable_dims( self, default_splittability, exception_dims_iterable=None): """Initializer for splittable_dims and unsplittable_dims. Helper method to categorize all dimensions in the input/output tensors as either splittable or unsplittable. Args: default...
python
def _initialize_splittable_and_unsplittable_dims( self, default_splittability, exception_dims_iterable=None): """Initializer for splittable_dims and unsplittable_dims. Helper method to categorize all dimensions in the input/output tensors as either splittable or unsplittable. Args: default...
[ "def", "_initialize_splittable_and_unsplittable_dims", "(", "self", ",", "default_splittability", ",", "exception_dims_iterable", "=", "None", ")", ":", "default_dims", "=", "set", "(", ")", "exception_dims", "=", "set", "(", ")", "if", "exception_dims_iterable", ":",...
Initializer for splittable_dims and unsplittable_dims. Helper method to categorize all dimensions in the input/output tensors as either splittable or unsplittable. Args: default_splittability: a string which is either "splittable" or "unsplittable". exception_dims_iterable: an optional...
[ "Initializer", "for", "splittable_dims", "and", "unsplittable_dims", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L1448-L1486
227,920
tensorflow/mesh
mesh_tensorflow/ops.py
ReshapeOperation.lower
def lower(self, lowering): """Lower the ReshapeOperation. Reshaping can require collective communication between processors. We haven't yet implemented all possible reshapes. We try to handle the common cases here - otherwise we raise a NotImplementedError. Args: lowering: a Lowering Ra...
python
def lower(self, lowering): """Lower the ReshapeOperation. Reshaping can require collective communication between processors. We haven't yet implemented all possible reshapes. We try to handle the common cases here - otherwise we raise a NotImplementedError. Args: lowering: a Lowering Ra...
[ "def", "lower", "(", "self", ",", "lowering", ")", ":", "old_shape", "=", "self", ".", "inputs", "[", "0", "]", ".", "shape", "new_shape", "=", "self", ".", "outputs", "[", "0", "]", ".", "shape", "mesh_impl", "=", "lowering", ".", "mesh_impl", "(", ...
Lower the ReshapeOperation. Reshaping can require collective communication between processors. We haven't yet implemented all possible reshapes. We try to handle the common cases here - otherwise we raise a NotImplementedError. Args: lowering: a Lowering Raises: NotImplementedError: i...
[ "Lower", "the", "ReshapeOperation", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L3478-L3558
227,921
tensorflow/mesh
mesh_tensorflow/transformer/utils.py
get_variable_dtype
def get_variable_dtype( master_dtype=tf.bfloat16, slice_dtype=tf.float32, activation_dtype=tf.float32): """Datatypes to use for the run. Args: master_dtype: string, datatype for checkpoints keep this the same between training and eval/inference slice_dtype: string, datatype for variables ...
python
def get_variable_dtype( master_dtype=tf.bfloat16, slice_dtype=tf.float32, activation_dtype=tf.float32): """Datatypes to use for the run. Args: master_dtype: string, datatype for checkpoints keep this the same between training and eval/inference slice_dtype: string, datatype for variables ...
[ "def", "get_variable_dtype", "(", "master_dtype", "=", "tf", ".", "bfloat16", ",", "slice_dtype", "=", "tf", ".", "float32", ",", "activation_dtype", "=", "tf", ".", "float32", ")", ":", "return", "mtf", ".", "VariableDType", "(", "master_dtype", "=", "tf", ...
Datatypes to use for the run. Args: master_dtype: string, datatype for checkpoints keep this the same between training and eval/inference slice_dtype: string, datatype for variables in memory must be tf.float32 for training activation_dtype: string, datatype for activations less memory ...
[ "Datatypes", "to", "use", "for", "the", "run", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/transformer/utils.py#L38-L57
227,922
tensorflow/mesh
mesh_tensorflow/transformer/utils.py
build_model
def build_model(model_type="bitransformer", input_vocab_size=gin.REQUIRED, output_vocab_size=gin.REQUIRED, layout_rules=None, mesh_shape=None): """Build a transformer model. Currently, three types of models are supported: "bitransformer": The tradi...
python
def build_model(model_type="bitransformer", input_vocab_size=gin.REQUIRED, output_vocab_size=gin.REQUIRED, layout_rules=None, mesh_shape=None): """Build a transformer model. Currently, three types of models are supported: "bitransformer": The tradi...
[ "def", "build_model", "(", "model_type", "=", "\"bitransformer\"", ",", "input_vocab_size", "=", "gin", ".", "REQUIRED", ",", "output_vocab_size", "=", "gin", ".", "REQUIRED", ",", "layout_rules", "=", "None", ",", "mesh_shape", "=", "None", ")", ":", "if", ...
Build a transformer model. Currently, three types of models are supported: "bitransformer": The traditional encoder-decoder architecture from "attention is all you need". Requires a non-text2self dataset. "lm": an autoregressive language model (one layer stack). This is similar to the decoder part ...
[ "Build", "a", "transformer", "model", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/transformer/utils.py#L94-L139
227,923
tensorflow/mesh
mesh_tensorflow/transformer/utils.py
decode_from_file
def decode_from_file(estimator, vocabulary, model_type, batch_size, sequence_length, checkpoint_path="", input_filename=gin.REQUIRED, output_filename=gin.REQUIRED, ...
python
def decode_from_file(estimator, vocabulary, model_type, batch_size, sequence_length, checkpoint_path="", input_filename=gin.REQUIRED, output_filename=gin.REQUIRED, ...
[ "def", "decode_from_file", "(", "estimator", ",", "vocabulary", ",", "model_type", ",", "batch_size", ",", "sequence_length", ",", "checkpoint_path", "=", "\"\"", ",", "input_filename", "=", "gin", ".", "REQUIRED", ",", "output_filename", "=", "gin", ".", "REQUI...
Decode from a text file. Args: estimator: a TPUEstimator vocabulary: a mtf.transformer.vocabulary.Vocabulary model_type: a string batch_size: an integer sequence_length: an integer (maximum decode length) checkpoint_path: an optional string input_filename: a string output_filename: a ...
[ "Decode", "from", "a", "text", "file", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/transformer/utils.py#L385-L473
227,924
tensorflow/mesh
mesh_tensorflow/transformer/utils.py
clean_decodes
def clean_decodes(ids, vocab_size, eos_id=1): """Stop at EOS or padding or OOV. Args: ids: a list of integers vocab_size: an integer eos_id: EOS id Returns: a list of integers """ ret = [] for i in ids: if i == eos_id: break if i >= vocab_size: break ret.append(int(...
python
def clean_decodes(ids, vocab_size, eos_id=1): """Stop at EOS or padding or OOV. Args: ids: a list of integers vocab_size: an integer eos_id: EOS id Returns: a list of integers """ ret = [] for i in ids: if i == eos_id: break if i >= vocab_size: break ret.append(int(...
[ "def", "clean_decodes", "(", "ids", ",", "vocab_size", ",", "eos_id", "=", "1", ")", ":", "ret", "=", "[", "]", "for", "i", "in", "ids", ":", "if", "i", "==", "eos_id", ":", "break", "if", "i", ">=", "vocab_size", ":", "break", "ret", ".", "appen...
Stop at EOS or padding or OOV. Args: ids: a list of integers vocab_size: an integer eos_id: EOS id Returns: a list of integers
[ "Stop", "at", "EOS", "or", "padding", "or", "OOV", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/transformer/utils.py#L477-L495
227,925
tensorflow/mesh
mesh_tensorflow/transformer/utils.py
auto_batch_size
def auto_batch_size(sequence_length, mesh_shape, layout_rules, tokens_per_split=2048): """Automatically compute batch size. Args: sequence_length: an integer mesh_shape: an input to mtf.convert_to_shape() layout_rules: an input to mtf.convert_...
python
def auto_batch_size(sequence_length, mesh_shape, layout_rules, tokens_per_split=2048): """Automatically compute batch size. Args: sequence_length: an integer mesh_shape: an input to mtf.convert_to_shape() layout_rules: an input to mtf.convert_...
[ "def", "auto_batch_size", "(", "sequence_length", ",", "mesh_shape", ",", "layout_rules", ",", "tokens_per_split", "=", "2048", ")", ":", "num_splits", "=", "mtf", ".", "tensor_dim_to_mesh_dim_size", "(", "layout_rules", ",", "mesh_shape", ",", "mtf", ".", "Dimens...
Automatically compute batch size. Args: sequence_length: an integer mesh_shape: an input to mtf.convert_to_shape() layout_rules: an input to mtf.convert_to_layout_rules() tokens_per_split: an integer Returns: an integer
[ "Automatically", "compute", "batch", "size", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/transformer/utils.py#L499-L520
227,926
tensorflow/mesh
mesh_tensorflow/transformer/utils.py
evaluate
def evaluate(estimator, eval_args): """Runs evaluation on the latest model checkpoint & logs to tensorboard. Args: estimator: A tf.Estimator object. eval_args: Dictionary of {eval_name: (input_fn, eval_steps)} where eval_name is the name of the evaluation set, e.g. "train" or "val", input_fn is an ...
python
def evaluate(estimator, eval_args): """Runs evaluation on the latest model checkpoint & logs to tensorboard. Args: estimator: A tf.Estimator object. eval_args: Dictionary of {eval_name: (input_fn, eval_steps)} where eval_name is the name of the evaluation set, e.g. "train" or "val", input_fn is an ...
[ "def", "evaluate", "(", "estimator", ",", "eval_args", ")", ":", "values", "=", "{", "}", "# Default return value if evaluation fails.", "checkpoint_path", "=", "estimator", ".", "latest_checkpoint", "(", ")", "if", "not", "checkpoint_path", ":", "# This is expected i...
Runs evaluation on the latest model checkpoint & logs to tensorboard. Args: estimator: A tf.Estimator object. eval_args: Dictionary of {eval_name: (input_fn, eval_steps)} where eval_name is the name of the evaluation set, e.g. "train" or "val", input_fn is an input function returning a tuple (fea...
[ "Runs", "evaluation", "on", "the", "latest", "model", "checkpoint", "&", "logs", "to", "tensorboard", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/transformer/utils.py#L715-L750
227,927
tensorflow/mesh
mesh_tensorflow/simd_mesh_impl.py
_ring_2d
def _ring_2d(m, n): """Ring-order of a mxn mesh. Args: m: an integer n: an integer Returns: a list of mxn pairs """ if m == 1: return [(0, i) for i in range(n)] if n == 1: return [(i, 0) for i in range(m)] if m % 2 != 0: tf.logging.warning("Odd dimension") return [(i % m, i //...
python
def _ring_2d(m, n): """Ring-order of a mxn mesh. Args: m: an integer n: an integer Returns: a list of mxn pairs """ if m == 1: return [(0, i) for i in range(n)] if n == 1: return [(i, 0) for i in range(m)] if m % 2 != 0: tf.logging.warning("Odd dimension") return [(i % m, i //...
[ "def", "_ring_2d", "(", "m", ",", "n", ")", ":", "if", "m", "==", "1", ":", "return", "[", "(", "0", ",", "i", ")", "for", "i", "in", "range", "(", "n", ")", "]", "if", "n", "==", "1", ":", "return", "[", "(", "i", ",", "0", ")", "for",...
Ring-order of a mxn mesh. Args: m: an integer n: an integer Returns: a list of mxn pairs
[ "Ring", "-", "order", "of", "a", "mxn", "mesh", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/simd_mesh_impl.py#L568-L592
227,928
tensorflow/mesh
mesh_tensorflow/simd_mesh_impl.py
tile_2d
def tile_2d(physical_shape, tile_shape, outer_name="outer", inner_name="inner", cores_name=None): """2D tiling of a 3d physical mesh. The "outer" mesh dimension corresponds to which tile. The "inner" mesh dimension corresponds to the position within a tile of processors. ...
python
def tile_2d(physical_shape, tile_shape, outer_name="outer", inner_name="inner", cores_name=None): """2D tiling of a 3d physical mesh. The "outer" mesh dimension corresponds to which tile. The "inner" mesh dimension corresponds to the position within a tile of processors. ...
[ "def", "tile_2d", "(", "physical_shape", ",", "tile_shape", ",", "outer_name", "=", "\"outer\"", ",", "inner_name", "=", "\"inner\"", ",", "cores_name", "=", "None", ")", ":", "logical_to_physical", "=", "[", "]", "p0", ",", "p1", ",", "p2", "=", "physical...
2D tiling of a 3d physical mesh. The "outer" mesh dimension corresponds to which tile. The "inner" mesh dimension corresponds to the position within a tile of processors. Optionally, if cores_name is specified, then a 3 dimensional logical mesh is returned, with the third dimension representing the two diff...
[ "2D", "tiling", "of", "a", "3d", "physical", "mesh", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/simd_mesh_impl.py#L595-L661
227,929
tensorflow/mesh
mesh_tensorflow/simd_mesh_impl.py
SimdMeshImpl.slice
def slice(self, tf_tensor, tensor_shape): """"Slice out the corresponding part of tensor given the pnum variable.""" tensor_layout = self.tensor_layout(tensor_shape) if tensor_layout.is_fully_replicated: return self.LaidOutTensor([tf_tensor]) else: slice_shape = self.slice_shape(tensor_shap...
python
def slice(self, tf_tensor, tensor_shape): """"Slice out the corresponding part of tensor given the pnum variable.""" tensor_layout = self.tensor_layout(tensor_shape) if tensor_layout.is_fully_replicated: return self.LaidOutTensor([tf_tensor]) else: slice_shape = self.slice_shape(tensor_shap...
[ "def", "slice", "(", "self", ",", "tf_tensor", ",", "tensor_shape", ")", ":", "tensor_layout", "=", "self", ".", "tensor_layout", "(", "tensor_shape", ")", "if", "tensor_layout", ".", "is_fully_replicated", ":", "return", "self", ".", "LaidOutTensor", "(", "["...
Slice out the corresponding part of tensor given the pnum variable.
[ "Slice", "out", "the", "corresponding", "part", "of", "tensor", "given", "the", "pnum", "variable", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/simd_mesh_impl.py#L443-L458
227,930
tensorflow/mesh
examples/mnist_dataset.py
read32
def read32(bytestream): """Read 4 bytes from bytestream as an unsigned 32-bit integer.""" dt = np.dtype(np.uint32).newbyteorder('>') return np.frombuffer(bytestream.read(4), dtype=dt)[0]
python
def read32(bytestream): """Read 4 bytes from bytestream as an unsigned 32-bit integer.""" dt = np.dtype(np.uint32).newbyteorder('>') return np.frombuffer(bytestream.read(4), dtype=dt)[0]
[ "def", "read32", "(", "bytestream", ")", ":", "dt", "=", "np", ".", "dtype", "(", "np", ".", "uint32", ")", ".", "newbyteorder", "(", "'>'", ")", "return", "np", ".", "frombuffer", "(", "bytestream", ".", "read", "(", "4", ")", ",", "dtype", "=", ...
Read 4 bytes from bytestream as an unsigned 32-bit integer.
[ "Read", "4", "bytes", "from", "bytestream", "as", "an", "unsigned", "32", "-", "bit", "integer", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/examples/mnist_dataset.py#L45-L48
227,931
tensorflow/mesh
examples/mnist_dataset.py
check_image_file_header
def check_image_file_header(filename): """Validate that filename corresponds to images for the MNIST dataset.""" with tf.gfile.Open(filename, 'rb') as f: magic = read32(f) read32(f) # num_images, unused rows = read32(f) cols = read32(f) if magic != 2051: raise ValueError('Invalid magic nu...
python
def check_image_file_header(filename): """Validate that filename corresponds to images for the MNIST dataset.""" with tf.gfile.Open(filename, 'rb') as f: magic = read32(f) read32(f) # num_images, unused rows = read32(f) cols = read32(f) if magic != 2051: raise ValueError('Invalid magic nu...
[ "def", "check_image_file_header", "(", "filename", ")", ":", "with", "tf", ".", "gfile", ".", "Open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "magic", "=", "read32", "(", "f", ")", "read32", "(", "f", ")", "# num_images, unused", "rows", "="...
Validate that filename corresponds to images for the MNIST dataset.
[ "Validate", "that", "filename", "corresponds", "to", "images", "for", "the", "MNIST", "dataset", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/examples/mnist_dataset.py#L51-L64
227,932
tensorflow/mesh
examples/mnist_dataset.py
check_labels_file_header
def check_labels_file_header(filename): """Validate that filename corresponds to labels for the MNIST dataset.""" with tf.gfile.Open(filename, 'rb') as f: magic = read32(f) read32(f) # num_items, unused if magic != 2049: raise ValueError('Invalid magic number %d in MNIST file %s' % (magic, ...
python
def check_labels_file_header(filename): """Validate that filename corresponds to labels for the MNIST dataset.""" with tf.gfile.Open(filename, 'rb') as f: magic = read32(f) read32(f) # num_items, unused if magic != 2049: raise ValueError('Invalid magic number %d in MNIST file %s' % (magic, ...
[ "def", "check_labels_file_header", "(", "filename", ")", ":", "with", "tf", ".", "gfile", ".", "Open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "magic", "=", "read32", "(", "f", ")", "read32", "(", "f", ")", "# num_items, unused", "if", "magi...
Validate that filename corresponds to labels for the MNIST dataset.
[ "Validate", "that", "filename", "corresponds", "to", "labels", "for", "the", "MNIST", "dataset", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/examples/mnist_dataset.py#L67-L74
227,933
tensorflow/mesh
examples/mnist_dataset.py
dataset
def dataset(directory, images_file, labels_file): """Download and parse MNIST dataset.""" images_file = download(directory, images_file) labels_file = download(directory, labels_file) check_image_file_header(images_file) check_labels_file_header(labels_file) def decode_image(image): # Normalize from ...
python
def dataset(directory, images_file, labels_file): """Download and parse MNIST dataset.""" images_file = download(directory, images_file) labels_file = download(directory, labels_file) check_image_file_header(images_file) check_labels_file_header(labels_file) def decode_image(image): # Normalize from ...
[ "def", "dataset", "(", "directory", ",", "images_file", ",", "labels_file", ")", ":", "images_file", "=", "download", "(", "directory", ",", "images_file", ")", "labels_file", "=", "download", "(", "directory", ",", "labels_file", ")", "check_image_file_header", ...
Download and parse MNIST dataset.
[ "Download", "and", "parse", "MNIST", "dataset", "." ]
3921196e5e43302e820da0a87329f25d7e2a3016
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/examples/mnist_dataset.py#L95-L120
227,934
mattjj/pyhsmm
pyhsmm/util/stats.py
sample_discrete
def sample_discrete(distn,size=[],dtype=np.int32): 'samples from a one-dimensional finite pmf' distn = np.atleast_1d(distn) assert (distn >=0).all() and distn.ndim == 1 if (0 == distn).all(): return np.random.randint(distn.shape[0],size=size) cumvals = np.cumsum(distn) return np.sum(np.a...
python
def sample_discrete(distn,size=[],dtype=np.int32): 'samples from a one-dimensional finite pmf' distn = np.atleast_1d(distn) assert (distn >=0).all() and distn.ndim == 1 if (0 == distn).all(): return np.random.randint(distn.shape[0],size=size) cumvals = np.cumsum(distn) return np.sum(np.a...
[ "def", "sample_discrete", "(", "distn", ",", "size", "=", "[", "]", ",", "dtype", "=", "np", ".", "int32", ")", ":", "distn", "=", "np", ".", "atleast_1d", "(", "distn", ")", "assert", "(", "distn", ">=", "0", ")", ".", "all", "(", ")", "and", ...
samples from a one-dimensional finite pmf
[ "samples", "from", "a", "one", "-", "dimensional", "finite", "pmf" ]
a9a39c2bfd539048e35877cb13283552eadc24e2
https://github.com/mattjj/pyhsmm/blob/a9a39c2bfd539048e35877cb13283552eadc24e2/pyhsmm/util/stats.py#L116-L123
227,935
mattjj/pyhsmm
pyhsmm/models.py
_HMMBase.used_states
def used_states(self): 'a list of the used states in the order they appear' c = itertools.count() canonical_ids = collections.defaultdict(lambda: next(c)) for s in self.states_list: for state in s.stateseq: canonical_ids[state] return list(map(operator...
python
def used_states(self): 'a list of the used states in the order they appear' c = itertools.count() canonical_ids = collections.defaultdict(lambda: next(c)) for s in self.states_list: for state in s.stateseq: canonical_ids[state] return list(map(operator...
[ "def", "used_states", "(", "self", ")", ":", "c", "=", "itertools", ".", "count", "(", ")", "canonical_ids", "=", "collections", ".", "defaultdict", "(", "lambda", ":", "next", "(", "c", ")", ")", "for", "s", "in", "self", ".", "states_list", ":", "f...
a list of the used states in the order they appear
[ "a", "list", "of", "the", "used", "states", "in", "the", "order", "they", "appear" ]
a9a39c2bfd539048e35877cb13283552eadc24e2
https://github.com/mattjj/pyhsmm/blob/a9a39c2bfd539048e35877cb13283552eadc24e2/pyhsmm/models.py#L188-L196
227,936
mattjj/pyhsmm
pyhsmm/util/plot.py
plot_gaussian_2D
def plot_gaussian_2D(mu, lmbda, color='b', centermarker=True,label='',alpha=1.,ax=None,artists=None): ''' Plots mean and cov ellipsoid into current axes. Must be 2D. lmbda is a covariance matrix. ''' assert len(mu) == 2 ax = ax if ax else plt.gca() # TODO use artists! t = np.hstack([np.ara...
python
def plot_gaussian_2D(mu, lmbda, color='b', centermarker=True,label='',alpha=1.,ax=None,artists=None): ''' Plots mean and cov ellipsoid into current axes. Must be 2D. lmbda is a covariance matrix. ''' assert len(mu) == 2 ax = ax if ax else plt.gca() # TODO use artists! t = np.hstack([np.ara...
[ "def", "plot_gaussian_2D", "(", "mu", ",", "lmbda", ",", "color", "=", "'b'", ",", "centermarker", "=", "True", ",", "label", "=", "''", ",", "alpha", "=", "1.", ",", "ax", "=", "None", ",", "artists", "=", "None", ")", ":", "assert", "len", "(", ...
Plots mean and cov ellipsoid into current axes. Must be 2D. lmbda is a covariance matrix.
[ "Plots", "mean", "and", "cov", "ellipsoid", "into", "current", "axes", ".", "Must", "be", "2D", ".", "lmbda", "is", "a", "covariance", "matrix", "." ]
a9a39c2bfd539048e35877cb13283552eadc24e2
https://github.com/mattjj/pyhsmm/blob/a9a39c2bfd539048e35877cb13283552eadc24e2/pyhsmm/util/plot.py#L7-L34
227,937
mattjj/pyhsmm
pyhsmm/basic/abstractions.py
DurationDistribution.resample_with_censoring
def resample_with_censoring(self,data=[],censored_data=[]): ''' censored_data is full of observations that were censored, meaning a value of x really could have been anything >= x, so this method samples them out to be at least that large ''' filled_in = self._uncensor_da...
python
def resample_with_censoring(self,data=[],censored_data=[]): ''' censored_data is full of observations that were censored, meaning a value of x really could have been anything >= x, so this method samples them out to be at least that large ''' filled_in = self._uncensor_da...
[ "def", "resample_with_censoring", "(", "self", ",", "data", "=", "[", "]", ",", "censored_data", "=", "[", "]", ")", ":", "filled_in", "=", "self", ".", "_uncensor_data", "(", "censored_data", ")", "return", "self", ".", "resample", "(", "data", "=", "co...
censored_data is full of observations that were censored, meaning a value of x really could have been anything >= x, so this method samples them out to be at least that large
[ "censored_data", "is", "full", "of", "observations", "that", "were", "censored", "meaning", "a", "value", "of", "x", "really", "could", "have", "been", "anything", ">", "=", "x", "so", "this", "method", "samples", "them", "out", "to", "be", "at", "least", ...
a9a39c2bfd539048e35877cb13283552eadc24e2
https://github.com/mattjj/pyhsmm/blob/a9a39c2bfd539048e35877cb13283552eadc24e2/pyhsmm/basic/abstractions.py#L70-L77
227,938
mattjj/pyhsmm
pyhsmm/util/general.py
scoreatpercentile
def scoreatpercentile(data,per,axis=0): 'like the function in scipy.stats but with an axis argument and works on arrays' a = np.sort(data,axis=axis) idx = per/100. * (data.shape[axis]-1) if (idx % 1 == 0): return a[[slice(None) if ii != axis else idx for ii in range(a.ndim)]] else: ...
python
def scoreatpercentile(data,per,axis=0): 'like the function in scipy.stats but with an axis argument and works on arrays' a = np.sort(data,axis=axis) idx = per/100. * (data.shape[axis]-1) if (idx % 1 == 0): return a[[slice(None) if ii != axis else idx for ii in range(a.ndim)]] else: ...
[ "def", "scoreatpercentile", "(", "data", ",", "per", ",", "axis", "=", "0", ")", ":", "a", "=", "np", ".", "sort", "(", "data", ",", "axis", "=", "axis", ")", "idx", "=", "per", "/", "100.", "*", "(", "data", ".", "shape", "[", "axis", "]", "...
like the function in scipy.stats but with an axis argument and works on arrays
[ "like", "the", "function", "in", "scipy", ".", "stats", "but", "with", "an", "axis", "argument", "and", "works", "on", "arrays" ]
a9a39c2bfd539048e35877cb13283552eadc24e2
https://github.com/mattjj/pyhsmm/blob/a9a39c2bfd539048e35877cb13283552eadc24e2/pyhsmm/util/general.py#L119-L131
227,939
lk-geimfari/mimesis
mimesis/providers/internet.py
Internet.content_type
def content_type(self, mime_type: Optional[MimeType] = None) -> str: """Get a random HTTP content type. :return: Content type. :Example: Content-Type: application/json """ fmt = self.__file.mime_type(type_=mime_type) return 'Content-Type: {}'.format(fmt)
python
def content_type(self, mime_type: Optional[MimeType] = None) -> str: """Get a random HTTP content type. :return: Content type. :Example: Content-Type: application/json """ fmt = self.__file.mime_type(type_=mime_type) return 'Content-Type: {}'.format(fmt)
[ "def", "content_type", "(", "self", ",", "mime_type", ":", "Optional", "[", "MimeType", "]", "=", "None", ")", "->", "str", ":", "fmt", "=", "self", ".", "__file", ".", "mime_type", "(", "type_", "=", "mime_type", ")", "return", "'Content-Type: {}'", "."...
Get a random HTTP content type. :return: Content type. :Example: Content-Type: application/json
[ "Get", "a", "random", "HTTP", "content", "type", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L46-L55
227,940
lk-geimfari/mimesis
mimesis/providers/internet.py
Internet.ip_v4
def ip_v4(self, with_port: bool = False) -> str: """Generate a random IPv4 address. :param with_port: Add port to IP. :return: Random IPv4 address. :Example: 19.121.223.58 """ ip = '.'.join(str(self.random.randint(0, 255)) for _ in range(4)) if with...
python
def ip_v4(self, with_port: bool = False) -> str: """Generate a random IPv4 address. :param with_port: Add port to IP. :return: Random IPv4 address. :Example: 19.121.223.58 """ ip = '.'.join(str(self.random.randint(0, 255)) for _ in range(4)) if with...
[ "def", "ip_v4", "(", "self", ",", "with_port", ":", "bool", "=", "False", ")", "->", "str", ":", "ip", "=", "'.'", ".", "join", "(", "str", "(", "self", ".", "random", ".", "randint", "(", "0", ",", "255", ")", ")", "for", "_", "in", "range", ...
Generate a random IPv4 address. :param with_port: Add port to IP. :return: Random IPv4 address. :Example: 19.121.223.58
[ "Generate", "a", "random", "IPv4", "address", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L87-L101
227,941
lk-geimfari/mimesis
mimesis/providers/internet.py
Internet.ip_v6
def ip_v6(self) -> str: """Generate a random IPv6 address. :return: Random IPv6 address. :Example: 2001:c244:cf9d:1fb1:c56d:f52c:8a04:94f3 """ ipv6 = IPv6Address( self.random.randint( 0, 2 ** 128 - 1, ), ) retu...
python
def ip_v6(self) -> str: """Generate a random IPv6 address. :return: Random IPv6 address. :Example: 2001:c244:cf9d:1fb1:c56d:f52c:8a04:94f3 """ ipv6 = IPv6Address( self.random.randint( 0, 2 ** 128 - 1, ), ) retu...
[ "def", "ip_v6", "(", "self", ")", "->", "str", ":", "ipv6", "=", "IPv6Address", "(", "self", ".", "random", ".", "randint", "(", "0", ",", "2", "**", "128", "-", "1", ",", ")", ",", ")", "return", "str", "(", "ipv6", ")" ]
Generate a random IPv6 address. :return: Random IPv6 address. :Example: 2001:c244:cf9d:1fb1:c56d:f52c:8a04:94f3
[ "Generate", "a", "random", "IPv6", "address", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L103-L116
227,942
lk-geimfari/mimesis
mimesis/providers/internet.py
Internet.mac_address
def mac_address(self) -> str: """Generate a random MAC address. :return: Random MAC address. :Example: 00:16:3e:25:e7:b1 """ mac_hex = [ 0x00, 0x16, 0x3e, self.random.randint(0x00, 0x7f), self.random.randint(0x00, 0xff), ...
python
def mac_address(self) -> str: """Generate a random MAC address. :return: Random MAC address. :Example: 00:16:3e:25:e7:b1 """ mac_hex = [ 0x00, 0x16, 0x3e, self.random.randint(0x00, 0x7f), self.random.randint(0x00, 0xff), ...
[ "def", "mac_address", "(", "self", ")", "->", "str", ":", "mac_hex", "=", "[", "0x00", ",", "0x16", ",", "0x3e", ",", "self", ".", "random", ".", "randint", "(", "0x00", ",", "0x7f", ")", ",", "self", ".", "random", ".", "randint", "(", "0x00", "...
Generate a random MAC address. :return: Random MAC address. :Example: 00:16:3e:25:e7:b1
[ "Generate", "a", "random", "MAC", "address", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L118-L133
227,943
lk-geimfari/mimesis
mimesis/providers/internet.py
Internet.image_placeholder
def image_placeholder(width: Union[int, str] = 1920, height: Union[int, str] = 1080) -> str: """Generate a link to the image placeholder. :param width: Width of image. :param height: Height of image. :return: URL to image placeholder. """ url = ...
python
def image_placeholder(width: Union[int, str] = 1920, height: Union[int, str] = 1080) -> str: """Generate a link to the image placeholder. :param width: Width of image. :param height: Height of image. :return: URL to image placeholder. """ url = ...
[ "def", "image_placeholder", "(", "width", ":", "Union", "[", "int", ",", "str", "]", "=", "1920", ",", "height", ":", "Union", "[", "int", ",", "str", "]", "=", "1080", ")", "->", "str", ":", "url", "=", "'http://placehold.it/{width}x{height}'", "return"...
Generate a link to the image placeholder. :param width: Width of image. :param height: Height of image. :return: URL to image placeholder.
[ "Generate", "a", "link", "to", "the", "image", "placeholder", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L146-L155
227,944
lk-geimfari/mimesis
mimesis/providers/internet.py
Internet.hashtags
def hashtags(self, quantity: int = 4) -> Union[str, list]: """Generate a list of hashtags. :param quantity: The quantity of hashtags. :return: The list of hashtags. :raises NonEnumerableError: if category is not in Hashtag. :Example: ['#love', '#sky', '#nice'] ...
python
def hashtags(self, quantity: int = 4) -> Union[str, list]: """Generate a list of hashtags. :param quantity: The quantity of hashtags. :return: The list of hashtags. :raises NonEnumerableError: if category is not in Hashtag. :Example: ['#love', '#sky', '#nice'] ...
[ "def", "hashtags", "(", "self", ",", "quantity", ":", "int", "=", "4", ")", "->", "Union", "[", "str", ",", "list", "]", ":", "tags", "=", "[", "'#'", "+", "self", ".", "random", ".", "choice", "(", "HASHTAGS", ")", "for", "_", "in", "range", "...
Generate a list of hashtags. :param quantity: The quantity of hashtags. :return: The list of hashtags. :raises NonEnumerableError: if category is not in Hashtag. :Example: ['#love', '#sky', '#nice']
[ "Generate", "a", "list", "of", "hashtags", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L191-L207
227,945
lk-geimfari/mimesis
mimesis/providers/internet.py
Internet.home_page
def home_page(self, tld_type: Optional[TLDType] = None) -> str: """Generate a random home page. :param tld_type: TLD type. :return: Random home page. :Example: http://www.fontir.info """ resource = self.random.choice(USERNAMES) domain = self.top_leve...
python
def home_page(self, tld_type: Optional[TLDType] = None) -> str: """Generate a random home page. :param tld_type: TLD type. :return: Random home page. :Example: http://www.fontir.info """ resource = self.random.choice(USERNAMES) domain = self.top_leve...
[ "def", "home_page", "(", "self", ",", "tld_type", ":", "Optional", "[", "TLDType", "]", "=", "None", ")", "->", "str", ":", "resource", "=", "self", ".", "random", ".", "choice", "(", "USERNAMES", ")", "domain", "=", "self", ".", "top_level_domain", "(...
Generate a random home page. :param tld_type: TLD type. :return: Random home page. :Example: http://www.fontir.info
[ "Generate", "a", "random", "home", "page", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L209-L224
227,946
lk-geimfari/mimesis
mimesis/providers/internet.py
Internet.top_level_domain
def top_level_domain(self, tld_type: Optional[TLDType] = None) -> str: """Return random top level domain. :param tld_type: Enum object DomainType :return: Top level domain. :raises NonEnumerableError: if tld_type not in DomainType. """ key = self._validate_enum(item=tld_...
python
def top_level_domain(self, tld_type: Optional[TLDType] = None) -> str: """Return random top level domain. :param tld_type: Enum object DomainType :return: Top level domain. :raises NonEnumerableError: if tld_type not in DomainType. """ key = self._validate_enum(item=tld_...
[ "def", "top_level_domain", "(", "self", ",", "tld_type", ":", "Optional", "[", "TLDType", "]", "=", "None", ")", "->", "str", ":", "key", "=", "self", ".", "_validate_enum", "(", "item", "=", "tld_type", ",", "enum", "=", "TLDType", ")", "return", "sel...
Return random top level domain. :param tld_type: Enum object DomainType :return: Top level domain. :raises NonEnumerableError: if tld_type not in DomainType.
[ "Return", "random", "top", "level", "domain", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L226-L234
227,947
lk-geimfari/mimesis
mimesis/providers/internet.py
Internet.network_protocol
def network_protocol(self, layer: Optional[Layer] = None) -> str: """Get a random network protocol form OSI model. :param layer: Enum object Layer. :return: Protocol name. :Example: AMQP """ key = self._validate_enum(item=layer, enum=Layer) protocols...
python
def network_protocol(self, layer: Optional[Layer] = None) -> str: """Get a random network protocol form OSI model. :param layer: Enum object Layer. :return: Protocol name. :Example: AMQP """ key = self._validate_enum(item=layer, enum=Layer) protocols...
[ "def", "network_protocol", "(", "self", ",", "layer", ":", "Optional", "[", "Layer", "]", "=", "None", ")", "->", "str", ":", "key", "=", "self", ".", "_validate_enum", "(", "item", "=", "layer", ",", "enum", "=", "Layer", ")", "protocols", "=", "NET...
Get a random network protocol form OSI model. :param layer: Enum object Layer. :return: Protocol name. :Example: AMQP
[ "Get", "a", "random", "network", "protocol", "form", "OSI", "model", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L247-L258
227,948
lk-geimfari/mimesis
mimesis/providers/internet.py
Internet.port
def port(self, port_range: PortRange = PortRange.ALL) -> int: """Generate random port. :param port_range: Range enum object. :return: Port number. :raises NonEnumerableError: if port_range is not in PortRange. :Example: 8080 """ if port_range and por...
python
def port(self, port_range: PortRange = PortRange.ALL) -> int: """Generate random port. :param port_range: Range enum object. :return: Port number. :raises NonEnumerableError: if port_range is not in PortRange. :Example: 8080 """ if port_range and por...
[ "def", "port", "(", "self", ",", "port_range", ":", "PortRange", "=", "PortRange", ".", "ALL", ")", "->", "int", ":", "if", "port_range", "and", "port_range", "in", "PortRange", ":", "return", "self", ".", "random", ".", "randint", "(", "*", "port_range"...
Generate random port. :param port_range: Range enum object. :return: Port number. :raises NonEnumerableError: if port_range is not in PortRange. :Example: 8080
[ "Generate", "random", "port", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/internet.py#L260-L273
227,949
lk-geimfari/mimesis
mimesis/providers/transport.py
Transport.truck
def truck(self, model_mask: str = '#### @@') -> str: """Generate a truck model. :param model_mask: Mask of truck model. Here '@' is a placeholder of characters and '#' is a placeholder of digits. :return: Dummy truck model. :Example: Caledon-966O. """ ...
python
def truck(self, model_mask: str = '#### @@') -> str: """Generate a truck model. :param model_mask: Mask of truck model. Here '@' is a placeholder of characters and '#' is a placeholder of digits. :return: Dummy truck model. :Example: Caledon-966O. """ ...
[ "def", "truck", "(", "self", ",", "model_mask", ":", "str", "=", "'#### @@'", ")", "->", "str", ":", "return", "'{}-{}'", ".", "format", "(", "self", ".", "random", ".", "choice", "(", "TRUCKS", ")", ",", "self", ".", "random", ".", "custom_code", "(...
Generate a truck model. :param model_mask: Mask of truck model. Here '@' is a placeholder of characters and '#' is a placeholder of digits. :return: Dummy truck model. :Example: Caledon-966O.
[ "Generate", "a", "truck", "model", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/transport.py#L29-L42
227,950
lk-geimfari/mimesis
mimesis/providers/transport.py
Transport.airplane
def airplane(self, model_mask: str = '###') -> str: """Generate a dummy airplane model. :param model_mask: Mask of truck model. Here '@' is a placeholder of characters and '#' is a placeholder of digits. :return: Airplane model. :Example: Boeing 727. """...
python
def airplane(self, model_mask: str = '###') -> str: """Generate a dummy airplane model. :param model_mask: Mask of truck model. Here '@' is a placeholder of characters and '#' is a placeholder of digits. :return: Airplane model. :Example: Boeing 727. """...
[ "def", "airplane", "(", "self", ",", "model_mask", ":", "str", "=", "'###'", ")", "->", "str", ":", "model", "=", "self", ".", "random", ".", "custom_code", "(", "mask", "=", "model_mask", ")", "plane", "=", "self", ".", "random", ".", "choice", "(",...
Generate a dummy airplane model. :param model_mask: Mask of truck model. Here '@' is a placeholder of characters and '#' is a placeholder of digits. :return: Airplane model. :Example: Boeing 727.
[ "Generate", "a", "dummy", "airplane", "model", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/transport.py#L54-L66
227,951
lk-geimfari/mimesis
mimesis/providers/transport.py
Transport.vehicle_registration_code
def vehicle_registration_code(self, locale: Optional[str] = None) -> str: """Get vehicle registration code of country. :param locale: Registration code for locale (country). :return: Vehicle registration code. """ if locale: return VRC_BY_LOCALES[locale] ret...
python
def vehicle_registration_code(self, locale: Optional[str] = None) -> str: """Get vehicle registration code of country. :param locale: Registration code for locale (country). :return: Vehicle registration code. """ if locale: return VRC_BY_LOCALES[locale] ret...
[ "def", "vehicle_registration_code", "(", "self", ",", "locale", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "if", "locale", ":", "return", "VRC_BY_LOCALES", "[", "locale", "]", "return", "self", ".", "random", ".", "choice", "("...
Get vehicle registration code of country. :param locale: Registration code for locale (country). :return: Vehicle registration code.
[ "Get", "vehicle", "registration", "code", "of", "country", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/transport.py#L68-L77
227,952
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.bulk_create_datetimes
def bulk_create_datetimes(date_start: DateTime, date_end: DateTime, **kwargs) -> List[DateTime]: """Bulk create datetime objects. This method creates list of datetime objects from ``date_start`` to ``date_end``. You can use the following keyword arguments:...
python
def bulk_create_datetimes(date_start: DateTime, date_end: DateTime, **kwargs) -> List[DateTime]: """Bulk create datetime objects. This method creates list of datetime objects from ``date_start`` to ``date_end``. You can use the following keyword arguments:...
[ "def", "bulk_create_datetimes", "(", "date_start", ":", "DateTime", ",", "date_end", ":", "DateTime", ",", "*", "*", "kwargs", ")", "->", "List", "[", "DateTime", "]", ":", "dt_objects", "=", "[", "]", "if", "not", "date_start", "and", "not", "date_end", ...
Bulk create datetime objects. This method creates list of datetime objects from ``date_start`` to ``date_end``. You can use the following keyword arguments: * ``days`` * ``hours`` * ``minutes`` * ``seconds`` * ``microseconds`` See datetime modu...
[ "Bulk", "create", "datetime", "objects", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L35-L73
227,953
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.week_date
def week_date(self, start: int = 2017, end: int = 2018) -> str: """Get week number with year. :param start: From start. :param end: To end. :return: Week number. """ year = self.year(start, end) week = self.random.randint(1, 52) return '{year}-W{week}'.fo...
python
def week_date(self, start: int = 2017, end: int = 2018) -> str: """Get week number with year. :param start: From start. :param end: To end. :return: Week number. """ year = self.year(start, end) week = self.random.randint(1, 52) return '{year}-W{week}'.fo...
[ "def", "week_date", "(", "self", ",", "start", ":", "int", "=", "2017", ",", "end", ":", "int", "=", "2018", ")", "->", "str", ":", "year", "=", "self", ".", "year", "(", "start", ",", "end", ")", "week", "=", "self", ".", "random", ".", "randi...
Get week number with year. :param start: From start. :param end: To end. :return: Week number.
[ "Get", "week", "number", "with", "year", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L75-L87
227,954
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.day_of_week
def day_of_week(self, abbr: bool = False) -> str: """Get a random day of week. :param abbr: Abbreviated day name. :return: Day of the week. """ key = 'abbr' if abbr else 'name' days = self._data['day'].get(key) return self.random.choice(days)
python
def day_of_week(self, abbr: bool = False) -> str: """Get a random day of week. :param abbr: Abbreviated day name. :return: Day of the week. """ key = 'abbr' if abbr else 'name' days = self._data['day'].get(key) return self.random.choice(days)
[ "def", "day_of_week", "(", "self", ",", "abbr", ":", "bool", "=", "False", ")", "->", "str", ":", "key", "=", "'abbr'", "if", "abbr", "else", "'name'", "days", "=", "self", ".", "_data", "[", "'day'", "]", ".", "get", "(", "key", ")", "return", "...
Get a random day of week. :param abbr: Abbreviated day name. :return: Day of the week.
[ "Get", "a", "random", "day", "of", "week", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L89-L97
227,955
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.month
def month(self, abbr: bool = False) -> str: """Get a random month. :param abbr: Abbreviated month name. :return: Month name. """ key = 'abbr' if abbr else 'name' months = self._data['month'].get(key) return self.random.choice(months)
python
def month(self, abbr: bool = False) -> str: """Get a random month. :param abbr: Abbreviated month name. :return: Month name. """ key = 'abbr' if abbr else 'name' months = self._data['month'].get(key) return self.random.choice(months)
[ "def", "month", "(", "self", ",", "abbr", ":", "bool", "=", "False", ")", "->", "str", ":", "key", "=", "'abbr'", "if", "abbr", "else", "'name'", "months", "=", "self", ".", "_data", "[", "'month'", "]", ".", "get", "(", "key", ")", "return", "se...
Get a random month. :param abbr: Abbreviated month name. :return: Month name.
[ "Get", "a", "random", "month", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L99-L107
227,956
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.year
def year(self, minimum: int = 1990, maximum: int = 2050) -> int: """Generate a random year. :param minimum: Minimum value. :param maximum: Maximum value. :return: Year. """ return self.random.randint(minimum, maximum)
python
def year(self, minimum: int = 1990, maximum: int = 2050) -> int: """Generate a random year. :param minimum: Minimum value. :param maximum: Maximum value. :return: Year. """ return self.random.randint(minimum, maximum)
[ "def", "year", "(", "self", ",", "minimum", ":", "int", "=", "1990", ",", "maximum", ":", "int", "=", "2050", ")", "->", "int", ":", "return", "self", ".", "random", ".", "randint", "(", "minimum", ",", "maximum", ")" ]
Generate a random year. :param minimum: Minimum value. :param maximum: Maximum value. :return: Year.
[ "Generate", "a", "random", "year", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L109-L116
227,957
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.periodicity
def periodicity(self) -> str: """Get a random periodicity string. :return: Periodicity. """ periodicity = self._data['periodicity'] return self.random.choice(periodicity)
python
def periodicity(self) -> str: """Get a random periodicity string. :return: Periodicity. """ periodicity = self._data['periodicity'] return self.random.choice(periodicity)
[ "def", "periodicity", "(", "self", ")", "->", "str", ":", "periodicity", "=", "self", ".", "_data", "[", "'periodicity'", "]", "return", "self", ".", "random", ".", "choice", "(", "periodicity", ")" ]
Get a random periodicity string. :return: Periodicity.
[ "Get", "a", "random", "periodicity", "string", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L125-L131
227,958
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.date
def date(self, start: int = 2000, end: int = 2019) -> Date: """Generate random date object. :param start: Minimum value of year. :param end: Maximum value of year. :return: Formatted date. """ year = self.random.randint(start, end) month = self.random.randint(1, ...
python
def date(self, start: int = 2000, end: int = 2019) -> Date: """Generate random date object. :param start: Minimum value of year. :param end: Maximum value of year. :return: Formatted date. """ year = self.random.randint(start, end) month = self.random.randint(1, ...
[ "def", "date", "(", "self", ",", "start", ":", "int", "=", "2000", ",", "end", ":", "int", "=", "2019", ")", "->", "Date", ":", "year", "=", "self", ".", "random", ".", "randint", "(", "start", ",", "end", ")", "month", "=", "self", ".", "rando...
Generate random date object. :param start: Minimum value of year. :param end: Maximum value of year. :return: Formatted date.
[ "Generate", "random", "date", "object", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L133-L144
227,959
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.formatted_date
def formatted_date(self, fmt: str = '', **kwargs) -> str: """Generate random date as string. :param fmt: The format of date, if None then use standard accepted in the current locale. :param kwargs: Keyword arguments for :meth:`~Datetime.date()` :return: Formatted date. ...
python
def formatted_date(self, fmt: str = '', **kwargs) -> str: """Generate random date as string. :param fmt: The format of date, if None then use standard accepted in the current locale. :param kwargs: Keyword arguments for :meth:`~Datetime.date()` :return: Formatted date. ...
[ "def", "formatted_date", "(", "self", ",", "fmt", ":", "str", "=", "''", ",", "*", "*", "kwargs", ")", "->", "str", ":", "date_obj", "=", "self", ".", "date", "(", "*", "*", "kwargs", ")", "if", "not", "fmt", ":", "fmt", "=", "self", ".", "_dat...
Generate random date as string. :param fmt: The format of date, if None then use standard accepted in the current locale. :param kwargs: Keyword arguments for :meth:`~Datetime.date()` :return: Formatted date.
[ "Generate", "random", "date", "as", "string", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L146-L159
227,960
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.time
def time(self) -> Time: """Generate a random time object. :return: ``datetime.time`` object. """ random_time = time( self.random.randint(0, 23), self.random.randint(0, 59), self.random.randint(0, 59), self.random.randint(0, 999999), ...
python
def time(self) -> Time: """Generate a random time object. :return: ``datetime.time`` object. """ random_time = time( self.random.randint(0, 23), self.random.randint(0, 59), self.random.randint(0, 59), self.random.randint(0, 999999), ...
[ "def", "time", "(", "self", ")", "->", "Time", ":", "random_time", "=", "time", "(", "self", ".", "random", ".", "randint", "(", "0", ",", "23", ")", ",", "self", ".", "random", ".", "randint", "(", "0", ",", "59", ")", ",", "self", ".", "rando...
Generate a random time object. :return: ``datetime.time`` object.
[ "Generate", "a", "random", "time", "object", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L161-L172
227,961
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.formatted_time
def formatted_time(self, fmt: str = '') -> str: """Generate string formatted time. :param fmt: The format of time, if None then use standard accepted in the current locale. :return: String formatted time. """ time_obj = self.time() if not fmt: fm...
python
def formatted_time(self, fmt: str = '') -> str: """Generate string formatted time. :param fmt: The format of time, if None then use standard accepted in the current locale. :return: String formatted time. """ time_obj = self.time() if not fmt: fm...
[ "def", "formatted_time", "(", "self", ",", "fmt", ":", "str", "=", "''", ")", "->", "str", ":", "time_obj", "=", "self", ".", "time", "(", ")", "if", "not", "fmt", ":", "fmt", "=", "self", ".", "_data", "[", "'formats'", "]", ".", "get", "(", "...
Generate string formatted time. :param fmt: The format of time, if None then use standard accepted in the current locale. :return: String formatted time.
[ "Generate", "string", "formatted", "time", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L174-L185
227,962
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.datetime
def datetime(self, start: int = 2000, end: int = 2035, timezone: Optional[str] = None) -> DateTime: """Generate random datetime. :param start: Minimum value of year. :param end: Maximum value of year. :param timezone: Set custom timezone (pytz required). :return...
python
def datetime(self, start: int = 2000, end: int = 2035, timezone: Optional[str] = None) -> DateTime: """Generate random datetime. :param start: Minimum value of year. :param end: Maximum value of year. :param timezone: Set custom timezone (pytz required). :return...
[ "def", "datetime", "(", "self", ",", "start", ":", "int", "=", "2000", ",", "end", ":", "int", "=", "2035", ",", "timezone", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "DateTime", ":", "datetime_obj", "=", "datetime", ".", "combine", ...
Generate random datetime. :param start: Minimum value of year. :param end: Maximum value of year. :param timezone: Set custom timezone (pytz required). :return: Datetime
[ "Generate", "random", "datetime", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L208-L227
227,963
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.formatted_datetime
def formatted_datetime(self, fmt: str = '', **kwargs) -> str: """Generate datetime string in human readable format. :param fmt: Custom format (default is format for current locale) :param kwargs: Keyword arguments for :meth:`~Datetime.datetime()` :return: Formatted datetime string. ...
python
def formatted_datetime(self, fmt: str = '', **kwargs) -> str: """Generate datetime string in human readable format. :param fmt: Custom format (default is format for current locale) :param kwargs: Keyword arguments for :meth:`~Datetime.datetime()` :return: Formatted datetime string. ...
[ "def", "formatted_datetime", "(", "self", ",", "fmt", ":", "str", "=", "''", ",", "*", "*", "kwargs", ")", "->", "str", ":", "dt_obj", "=", "self", ".", "datetime", "(", "*", "*", "kwargs", ")", "if", "not", "fmt", ":", "date_fmt", "=", "self", "...
Generate datetime string in human readable format. :param fmt: Custom format (default is format for current locale) :param kwargs: Keyword arguments for :meth:`~Datetime.datetime()` :return: Formatted datetime string.
[ "Generate", "datetime", "string", "in", "human", "readable", "format", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L229-L243
227,964
lk-geimfari/mimesis
mimesis/providers/date.py
Datetime.timestamp
def timestamp(self, posix: bool = True, **kwargs) -> Union[str, int]: """Generate random timestamp. :param posix: POSIX time. :param kwargs: Kwargs for :meth:`~Datetime.datetime()`. :return: Timestamp. """ stamp = self.datetime(**kwargs) if posix: re...
python
def timestamp(self, posix: bool = True, **kwargs) -> Union[str, int]: """Generate random timestamp. :param posix: POSIX time. :param kwargs: Kwargs for :meth:`~Datetime.datetime()`. :return: Timestamp. """ stamp = self.datetime(**kwargs) if posix: re...
[ "def", "timestamp", "(", "self", ",", "posix", ":", "bool", "=", "True", ",", "*", "*", "kwargs", ")", "->", "Union", "[", "str", ",", "int", "]", ":", "stamp", "=", "self", ".", "datetime", "(", "*", "*", "kwargs", ")", "if", "posix", ":", "re...
Generate random timestamp. :param posix: POSIX time. :param kwargs: Kwargs for :meth:`~Datetime.datetime()`. :return: Timestamp.
[ "Generate", "random", "timestamp", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/date.py#L245-L257
227,965
lk-geimfari/mimesis
mimesis/providers/cryptographic.py
Cryptographic.uuid
def uuid(self, version: int = None) -> str: """Generate random UUID. :param version: UUID version. :return: UUID """ bits = self.random.getrandbits(128) return str(uuid.UUID(int=bits, version=version))
python
def uuid(self, version: int = None) -> str: """Generate random UUID. :param version: UUID version. :return: UUID """ bits = self.random.getrandbits(128) return str(uuid.UUID(int=bits, version=version))
[ "def", "uuid", "(", "self", ",", "version", ":", "int", "=", "None", ")", "->", "str", ":", "bits", "=", "self", ".", "random", ".", "getrandbits", "(", "128", ")", "return", "str", "(", "uuid", ".", "UUID", "(", "int", "=", "bits", ",", "version...
Generate random UUID. :param version: UUID version. :return: UUID
[ "Generate", "random", "UUID", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/cryptographic.py#L32-L39
227,966
lk-geimfari/mimesis
mimesis/providers/cryptographic.py
Cryptographic.hash
def hash(self, algorithm: Algorithm = None) -> str: # noqa: A003 """Generate random hash. To change hashing algorithm, pass parameter ``algorithm`` with needed value of the enum object :class:`~mimesis.enums.Algorithm` :param algorithm: Enum object :class:`~mimesis.enums.Algorithm`. ...
python
def hash(self, algorithm: Algorithm = None) -> str: # noqa: A003 """Generate random hash. To change hashing algorithm, pass parameter ``algorithm`` with needed value of the enum object :class:`~mimesis.enums.Algorithm` :param algorithm: Enum object :class:`~mimesis.enums.Algorithm`. ...
[ "def", "hash", "(", "self", ",", "algorithm", ":", "Algorithm", "=", "None", ")", "->", "str", ":", "# noqa: A003", "key", "=", "self", ".", "_validate_enum", "(", "algorithm", ",", "Algorithm", ")", "if", "hasattr", "(", "hashlib", ",", "key", ")", ":...
Generate random hash. To change hashing algorithm, pass parameter ``algorithm`` with needed value of the enum object :class:`~mimesis.enums.Algorithm` :param algorithm: Enum object :class:`~mimesis.enums.Algorithm`. :return: Hash. :raises NonEnumerableError: if algorithm is not...
[ "Generate", "random", "hash", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/cryptographic.py#L41-L55
227,967
lk-geimfari/mimesis
mimesis/providers/cryptographic.py
Cryptographic.mnemonic_phrase
def mnemonic_phrase(self, length: int = 12) -> str: """Generate pseudo mnemonic phrase. :param length: Number of words. :return: Mnemonic code. """ words = self.__words['normal'] return ' '.join(self.random.choice(words) for _ in range(length))
python
def mnemonic_phrase(self, length: int = 12) -> str: """Generate pseudo mnemonic phrase. :param length: Number of words. :return: Mnemonic code. """ words = self.__words['normal'] return ' '.join(self.random.choice(words) for _ in range(length))
[ "def", "mnemonic_phrase", "(", "self", ",", "length", ":", "int", "=", "12", ")", "->", "str", ":", "words", "=", "self", ".", "__words", "[", "'normal'", "]", "return", "' '", ".", "join", "(", "self", ".", "random", ".", "choice", "(", "words", "...
Generate pseudo mnemonic phrase. :param length: Number of words. :return: Mnemonic code.
[ "Generate", "pseudo", "mnemonic", "phrase", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/cryptographic.py#L104-L111
227,968
lk-geimfari/mimesis
setup.py
Minimizer.initialize_options
def initialize_options(self): """Find all files of all locales.""" self.paths = [] self.separators = (',', ':') self.data_dir = join(here, 'mimesis', 'data') self.before_total = 0 self.after_total = 0 for root, _, files in os.walk(self.data_dir): for ...
python
def initialize_options(self): """Find all files of all locales.""" self.paths = [] self.separators = (',', ':') self.data_dir = join(here, 'mimesis', 'data') self.before_total = 0 self.after_total = 0 for root, _, files in os.walk(self.data_dir): for ...
[ "def", "initialize_options", "(", "self", ")", ":", "self", ".", "paths", "=", "[", "]", "self", ".", "separators", "=", "(", "','", ",", "':'", ")", "self", ".", "data_dir", "=", "join", "(", "here", ",", "'mimesis'", ",", "'data'", ")", "self", "...
Find all files of all locales.
[ "Find", "all", "files", "of", "all", "locales", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/setup.py#L34-L46
227,969
lk-geimfari/mimesis
setup.py
Minimizer.run
def run(self): """Start json minimizer and exit when all json files were minimized.""" for rel_path in sorted(self.paths): file_path = join(self.data_dir, rel_path) self.minify(file_path) after = self.size_of(self.after_total) before = self.size_of(self.before_to...
python
def run(self): """Start json minimizer and exit when all json files were minimized.""" for rel_path in sorted(self.paths): file_path = join(self.data_dir, rel_path) self.minify(file_path) after = self.size_of(self.after_total) before = self.size_of(self.before_to...
[ "def", "run", "(", "self", ")", ":", "for", "rel_path", "in", "sorted", "(", "self", ".", "paths", ")", ":", "file_path", "=", "join", "(", "self", ".", "data_dir", ",", "rel_path", ")", "self", ".", "minify", "(", "file_path", ")", "after", "=", "...
Start json minimizer and exit when all json files were minimized.
[ "Start", "json", "minimizer", "and", "exit", "when", "all", "json", "files", "were", "minimized", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/setup.py#L92-L106
227,970
lk-geimfari/mimesis
mimesis/providers/structure.py
Structure.css
def css(self) -> str: """Generate a random snippet of CSS. :return: CSS. """ selector = self.random.choice(CSS_SELECTORS) css_sel = '{}{}'.format(selector, self.__text.word()) cont_tag = self.random.choice(list(HTML_CONTAINER_TAGS.keys())) mrk_tag = self.random....
python
def css(self) -> str: """Generate a random snippet of CSS. :return: CSS. """ selector = self.random.choice(CSS_SELECTORS) css_sel = '{}{}'.format(selector, self.__text.word()) cont_tag = self.random.choice(list(HTML_CONTAINER_TAGS.keys())) mrk_tag = self.random....
[ "def", "css", "(", "self", ")", "->", "str", ":", "selector", "=", "self", ".", "random", ".", "choice", "(", "CSS_SELECTORS", ")", "css_sel", "=", "'{}{}'", ".", "format", "(", "selector", ",", "self", ".", "__text", ".", "word", "(", ")", ")", "c...
Generate a random snippet of CSS. :return: CSS.
[ "Generate", "a", "random", "snippet", "of", "CSS", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/structure.py#L37-L51
227,971
lk-geimfari/mimesis
mimesis/providers/structure.py
Structure.css_property
def css_property(self) -> str: """Generate a random snippet of CSS that assigns value to a property. :return: CSS property. :Examples: 'background-color: #f4d3a1' """ prop = self.random.choice(list(CSS_PROPERTIES.keys())) val = CSS_PROPERTIES[prop] ...
python
def css_property(self) -> str: """Generate a random snippet of CSS that assigns value to a property. :return: CSS property. :Examples: 'background-color: #f4d3a1' """ prop = self.random.choice(list(CSS_PROPERTIES.keys())) val = CSS_PROPERTIES[prop] ...
[ "def", "css_property", "(", "self", ")", "->", "str", ":", "prop", "=", "self", ".", "random", ".", "choice", "(", "list", "(", "CSS_PROPERTIES", ".", "keys", "(", ")", ")", ")", "val", "=", "CSS_PROPERTIES", "[", "prop", "]", "if", "isinstance", "("...
Generate a random snippet of CSS that assigns value to a property. :return: CSS property. :Examples: 'background-color: #f4d3a1'
[ "Generate", "a", "random", "snippet", "of", "CSS", "that", "assigns", "value", "to", "a", "property", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/structure.py#L53-L72
227,972
lk-geimfari/mimesis
mimesis/providers/structure.py
Structure.html
def html(self) -> str: """Generate a random HTML tag with text inside and some attrs set. :return: HTML. :Examples: '<span class="select" id="careers"> Ports are created with the built-in function open_port. </span>' """ tag_name = self.rando...
python
def html(self) -> str: """Generate a random HTML tag with text inside and some attrs set. :return: HTML. :Examples: '<span class="select" id="careers"> Ports are created with the built-in function open_port. </span>' """ tag_name = self.rando...
[ "def", "html", "(", "self", ")", "->", "str", ":", "tag_name", "=", "self", ".", "random", ".", "choice", "(", "list", "(", "HTML_CONTAINER_TAGS", ")", ")", "tag_attributes", "=", "list", "(", "HTML_CONTAINER_TAGS", "[", "tag_name", "]", ")", "# type: igno...
Generate a random HTML tag with text inside and some attrs set. :return: HTML. :Examples: '<span class="select" id="careers"> Ports are created with the built-in function open_port. </span>'
[ "Generate", "a", "random", "HTML", "tag", "with", "text", "inside", "and", "some", "attrs", "set", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/structure.py#L74-L100
227,973
lk-geimfari/mimesis
mimesis/providers/structure.py
Structure.html_attribute_value
def html_attribute_value(self, tag: str = None, attribute: str = None) -> str: """Generate random value for specified HTML tag attribute. :param tag: An HTML tag. :param attribute: An attribute of the specified tag. :return: An attribute. :raises Not...
python
def html_attribute_value(self, tag: str = None, attribute: str = None) -> str: """Generate random value for specified HTML tag attribute. :param tag: An HTML tag. :param attribute: An attribute of the specified tag. :return: An attribute. :raises Not...
[ "def", "html_attribute_value", "(", "self", ",", "tag", ":", "str", "=", "None", ",", "attribute", ":", "str", "=", "None", ")", "->", "str", ":", "if", "not", "tag", ":", "tag", "=", "self", ".", "random", ".", "choice", "(", "list", "(", "HTML_CO...
Generate random value for specified HTML tag attribute. :param tag: An HTML tag. :param attribute: An attribute of the specified tag. :return: An attribute. :raises NotImplementedError: if tag is unsupported.
[ "Generate", "random", "value", "for", "specified", "HTML", "tag", "attribute", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/structure.py#L102-L138
227,974
lk-geimfari/mimesis
mimesis/providers/development.py
Development.version
def version(self, calver: bool = False, pre_release: bool = False) -> str: """Generate version number. :param calver: Calendar versioning. :param pre_release: Pre-release. :return: Version. :Example: 0.2.1 """ # TODO: Optimize version = '{}.{...
python
def version(self, calver: bool = False, pre_release: bool = False) -> str: """Generate version number. :param calver: Calendar versioning. :param pre_release: Pre-release. :return: Version. :Example: 0.2.1 """ # TODO: Optimize version = '{}.{...
[ "def", "version", "(", "self", ",", "calver", ":", "bool", "=", "False", ",", "pre_release", ":", "bool", "=", "False", ")", "->", "str", ":", "# TODO: Optimize", "version", "=", "'{}.{}.{}'", "major", ",", "minor", ",", "patch", "=", "self", ".", "ran...
Generate version number. :param calver: Calendar versioning. :param pre_release: Pre-release. :return: Version. :Example: 0.2.1
[ "Generate", "version", "number", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/development.py#L29-L60
227,975
lk-geimfari/mimesis
mimesis/providers/science.py
Science.chemical_element
def chemical_element(self, name_only: bool = True) -> Union[dict, str]: """Generate a random chemical element. :param name_only: If False then will be returned dict. :return: Name of chemical element or dict. :rtype: dict or str :Example: {'Symbol': 'S', 'Name': 'Su...
python
def chemical_element(self, name_only: bool = True) -> Union[dict, str]: """Generate a random chemical element. :param name_only: If False then will be returned dict. :return: Name of chemical element or dict. :rtype: dict or str :Example: {'Symbol': 'S', 'Name': 'Su...
[ "def", "chemical_element", "(", "self", ",", "name_only", ":", "bool", "=", "True", ")", "->", "Union", "[", "dict", ",", "str", "]", ":", "elements", "=", "self", ".", "_data", "[", "'chemical_element'", "]", "nm", ",", "sm", ",", "an", "=", "self",...
Generate a random chemical element. :param name_only: If False then will be returned dict. :return: Name of chemical element or dict. :rtype: dict or str :Example: {'Symbol': 'S', 'Name': 'Sulfur', 'Atomic number': '16'}
[ "Generate", "a", "random", "chemical", "element", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/science.py#L42-L62
227,976
lk-geimfari/mimesis
mimesis/builtins/pt_br.py
BrazilSpecProvider.cpf
def cpf(self, with_mask: bool = True) -> str: """Get a random CPF. :param with_mask: Use CPF mask (###.###.###-##). :returns: Random CPF. :Example: 001.137.297-40 """ def get_verifying_digit_cpf(cpf, peso): """Calculate the verifying digit for th...
python
def cpf(self, with_mask: bool = True) -> str: """Get a random CPF. :param with_mask: Use CPF mask (###.###.###-##). :returns: Random CPF. :Example: 001.137.297-40 """ def get_verifying_digit_cpf(cpf, peso): """Calculate the verifying digit for th...
[ "def", "cpf", "(", "self", ",", "with_mask", ":", "bool", "=", "True", ")", "->", "str", ":", "def", "get_verifying_digit_cpf", "(", "cpf", ",", "peso", ")", ":", "\"\"\"Calculate the verifying digit for the CPF.\n\n :param cpf: List of integers with the CPF.\n...
Get a random CPF. :param with_mask: Use CPF mask (###.###.###-##). :returns: Random CPF. :Example: 001.137.297-40
[ "Get", "a", "random", "CPF", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/pt_br.py#L23-L58
227,977
lk-geimfari/mimesis
mimesis/builtins/pt_br.py
BrazilSpecProvider.cnpj
def cnpj(self, with_mask: bool = True) -> str: """Get a random CNPJ. :param with_mask: Use cnpj mask (###.###.###-##) :returns: Random cnpj. :Example: 77.732.230/0001-70 """ def get_verifying_digit_cnpj(cnpj, peso): """Calculate the verifying dig...
python
def cnpj(self, with_mask: bool = True) -> str: """Get a random CNPJ. :param with_mask: Use cnpj mask (###.###.###-##) :returns: Random cnpj. :Example: 77.732.230/0001-70 """ def get_verifying_digit_cnpj(cnpj, peso): """Calculate the verifying dig...
[ "def", "cnpj", "(", "self", ",", "with_mask", ":", "bool", "=", "True", ")", "->", "str", ":", "def", "get_verifying_digit_cnpj", "(", "cnpj", ",", "peso", ")", ":", "\"\"\"Calculate the verifying digit for the CNPJ.\n\n :param cnpj: List of integers with the C...
Get a random CNPJ. :param with_mask: Use cnpj mask (###.###.###-##) :returns: Random cnpj. :Example: 77.732.230/0001-70
[ "Get", "a", "random", "CNPJ", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/pt_br.py#L60-L101
227,978
lk-geimfari/mimesis
mimesis/decorators.py
romanized
def romanized(locale: str = '') -> Callable: """Romanize the Cyrillic text. Transliterate the Cyrillic language from the Cyrillic script into the Latin alphabet. .. note:: At this moment it works only for `ru`, `uk`, `kk`. :param locale: Locale code. :return: Latinized text. """ def r...
python
def romanized(locale: str = '') -> Callable: """Romanize the Cyrillic text. Transliterate the Cyrillic language from the Cyrillic script into the Latin alphabet. .. note:: At this moment it works only for `ru`, `uk`, `kk`. :param locale: Locale code. :return: Latinized text. """ def r...
[ "def", "romanized", "(", "locale", ":", "str", "=", "''", ")", "->", "Callable", ":", "def", "romanized_deco", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")"...
Romanize the Cyrillic text. Transliterate the Cyrillic language from the Cyrillic script into the Latin alphabet. .. note:: At this moment it works only for `ru`, `uk`, `kk`. :param locale: Locale code. :return: Latinized text.
[ "Romanize", "the", "Cyrillic", "text", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/decorators.py#L14-L44
227,979
lk-geimfari/mimesis
mimesis/providers/food.py
Food._choice_from
def _choice_from(self, key: str) -> str: """Choice random element.""" data = self._data[key] return self.random.choice(data)
python
def _choice_from(self, key: str) -> str: """Choice random element.""" data = self._data[key] return self.random.choice(data)
[ "def", "_choice_from", "(", "self", ",", "key", ":", "str", ")", "->", "str", ":", "data", "=", "self", ".", "_data", "[", "key", "]", "return", "self", ".", "random", ".", "choice", "(", "data", ")" ]
Choice random element.
[ "Choice", "random", "element", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/food.py#L27-L30
227,980
lk-geimfari/mimesis
mimesis/builtins/ru.py
RussiaSpecProvider.generate_sentence
def generate_sentence(self) -> str: """Generate sentence from the parts. :return: Sentence. """ sentences = self._data['sentence'] sentence = [ self.random.choice(sentences[k]) for k in ('head', 'p1', 'p2', 'tail') ] return '{0} {1} {2} {3...
python
def generate_sentence(self) -> str: """Generate sentence from the parts. :return: Sentence. """ sentences = self._data['sentence'] sentence = [ self.random.choice(sentences[k]) for k in ('head', 'p1', 'p2', 'tail') ] return '{0} {1} {2} {3...
[ "def", "generate_sentence", "(", "self", ")", "->", "str", ":", "sentences", "=", "self", ".", "_data", "[", "'sentence'", "]", "sentence", "=", "[", "self", ".", "random", ".", "choice", "(", "sentences", "[", "k", "]", ")", "for", "k", "in", "(", ...
Generate sentence from the parts. :return: Sentence.
[ "Generate", "sentence", "from", "the", "parts", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L25-L35
227,981
lk-geimfari/mimesis
mimesis/builtins/ru.py
RussiaSpecProvider.patronymic
def patronymic(self, gender: Gender = None) -> str: """Generate random patronymic name. :param gender: Gender of person. :return: Patronymic name. :Example: Алексеевна. """ gender = self._validate_enum(gender, Gender) patronymics = self._data['patron...
python
def patronymic(self, gender: Gender = None) -> str: """Generate random patronymic name. :param gender: Gender of person. :return: Patronymic name. :Example: Алексеевна. """ gender = self._validate_enum(gender, Gender) patronymics = self._data['patron...
[ "def", "patronymic", "(", "self", ",", "gender", ":", "Gender", "=", "None", ")", "->", "str", ":", "gender", "=", "self", ".", "_validate_enum", "(", "gender", ",", "Gender", ")", "patronymics", "=", "self", ".", "_data", "[", "'patronymic'", "]", "["...
Generate random patronymic name. :param gender: Gender of person. :return: Patronymic name. :Example: Алексеевна.
[ "Generate", "random", "patronymic", "name", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L37-L48
227,982
lk-geimfari/mimesis
mimesis/builtins/ru.py
RussiaSpecProvider.passport_series
def passport_series(self, year: int = None) -> str: """Generate random series of passport. :param year: Year of manufacture. :type year: int or None :return: Series. :Example: 02 15. """ if not year: year = self.random.randint(10, 18) ...
python
def passport_series(self, year: int = None) -> str: """Generate random series of passport. :param year: Year of manufacture. :type year: int or None :return: Series. :Example: 02 15. """ if not year: year = self.random.randint(10, 18) ...
[ "def", "passport_series", "(", "self", ",", "year", ":", "int", "=", "None", ")", "->", "str", ":", "if", "not", "year", ":", "year", "=", "self", ".", "random", ".", "randint", "(", "10", ",", "18", ")", "region", "=", "self", ".", "random", "."...
Generate random series of passport. :param year: Year of manufacture. :type year: int or None :return: Series. :Example: 02 15.
[ "Generate", "random", "series", "of", "passport", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L50-L64
227,983
lk-geimfari/mimesis
mimesis/builtins/ru.py
RussiaSpecProvider.snils
def snils(self) -> str: """Generate snils with special algorithm. :return: SNILS. :Example: 41917492600. """ numbers = [] control_codes = [] for i in range(0, 9): numbers.append(self.random.randint(0, 9)) for i in range(9, 0, -1...
python
def snils(self) -> str: """Generate snils with special algorithm. :return: SNILS. :Example: 41917492600. """ numbers = [] control_codes = [] for i in range(0, 9): numbers.append(self.random.randint(0, 9)) for i in range(9, 0, -1...
[ "def", "snils", "(", "self", ")", "->", "str", ":", "numbers", "=", "[", "]", "control_codes", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "9", ")", ":", "numbers", ".", "append", "(", "self", ".", "random", ".", "randint", "(", "0...
Generate snils with special algorithm. :return: SNILS. :Example: 41917492600.
[ "Generate", "snils", "with", "special", "algorithm", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L90-L123
227,984
lk-geimfari/mimesis
mimesis/builtins/ru.py
RussiaSpecProvider.inn
def inn(self) -> str: """Generate random, but valid ``INN``. :return: INN. """ def control_sum(nums: list, t: str) -> int: digits = { 'n2': [7, 2, 4, 10, 3, 5, 9, 4, 6, 8], 'n1': [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8], } nu...
python
def inn(self) -> str: """Generate random, but valid ``INN``. :return: INN. """ def control_sum(nums: list, t: str) -> int: digits = { 'n2': [7, 2, 4, 10, 3, 5, 9, 4, 6, 8], 'n1': [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8], } nu...
[ "def", "inn", "(", "self", ")", "->", "str", ":", "def", "control_sum", "(", "nums", ":", "list", ",", "t", ":", "str", ")", "->", "int", ":", "digits", "=", "{", "'n2'", ":", "[", "7", ",", "2", ",", "4", ",", "10", ",", "3", ",", "5", "...
Generate random, but valid ``INN``. :return: INN.
[ "Generate", "random", "but", "valid", "INN", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L125-L149
227,985
lk-geimfari/mimesis
mimesis/builtins/ru.py
RussiaSpecProvider.ogrn
def ogrn(self) -> str: """Generate random valid ``OGRN``. :return: OGRN. :Example: 4715113303725. """ numbers = [] for _ in range(0, 12): numbers.append(self.random.randint(1 if _ == 0 else 0, 9)) ogrn = ''.join([str(x) for x in numbers]...
python
def ogrn(self) -> str: """Generate random valid ``OGRN``. :return: OGRN. :Example: 4715113303725. """ numbers = [] for _ in range(0, 12): numbers.append(self.random.randint(1 if _ == 0 else 0, 9)) ogrn = ''.join([str(x) for x in numbers]...
[ "def", "ogrn", "(", "self", ")", "->", "str", ":", "numbers", "=", "[", "]", "for", "_", "in", "range", "(", "0", ",", "12", ")", ":", "numbers", ".", "append", "(", "self", ".", "random", ".", "randint", "(", "1", "if", "_", "==", "0", "else...
Generate random valid ``OGRN``. :return: OGRN. :Example: 4715113303725.
[ "Generate", "random", "valid", "OGRN", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L151-L166
227,986
lk-geimfari/mimesis
mimesis/builtins/ru.py
RussiaSpecProvider.kpp
def kpp(self) -> str: """Generate random ``KPP``. :return: 'KPP'. :Example: 560058652. """ tax_codes = [ '7700', '7800', '5000', '0100', '0200', '0300', '0500', '0600', '0700', '0800', '0900', '1000', '1100', '1200', '...
python
def kpp(self) -> str: """Generate random ``KPP``. :return: 'KPP'. :Example: 560058652. """ tax_codes = [ '7700', '7800', '5000', '0100', '0200', '0300', '0500', '0600', '0700', '0800', '0900', '1000', '1100', '1200', '...
[ "def", "kpp", "(", "self", ")", "->", "str", ":", "tax_codes", "=", "[", "'7700'", ",", "'7800'", ",", "'5000'", ",", "'0100'", ",", "'0200'", ",", "'0300'", ",", "'0500'", ",", "'0600'", ",", "'0700'", ",", "'0800'", ",", "'0900'", ",", "'1000'", ...
Generate random ``KPP``. :return: 'KPP'. :Example: 560058652.
[ "Generate", "random", "KPP", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/builtins/ru.py#L183-L224
227,987
lk-geimfari/mimesis
mimesis/providers/hardware.py
Hardware.cpu_frequency
def cpu_frequency(self) -> str: """Get a random frequency of CPU. :return: Frequency of CPU. :Example: 4.0 GHz. """ return '{}GHz'.format( self.random.uniform( a=1.5, b=4.3, precision=1, ), ...
python
def cpu_frequency(self) -> str: """Get a random frequency of CPU. :return: Frequency of CPU. :Example: 4.0 GHz. """ return '{}GHz'.format( self.random.uniform( a=1.5, b=4.3, precision=1, ), ...
[ "def", "cpu_frequency", "(", "self", ")", "->", "str", ":", "return", "'{}GHz'", ".", "format", "(", "self", ".", "random", ".", "uniform", "(", "a", "=", "1.5", ",", "b", "=", "4.3", ",", "precision", "=", "1", ",", ")", ",", ")" ]
Get a random frequency of CPU. :return: Frequency of CPU. :Example: 4.0 GHz.
[ "Get", "a", "random", "frequency", "of", "CPU", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/hardware.py#L62-L76
227,988
lk-geimfari/mimesis
mimesis/providers/numbers.py
Numbers.floats
def floats(self, n: int = 2) -> List[float]: """Generate a list of random float numbers. :param n: Raise 10 to the 'n' power. :return: The list of floating-point numbers. """ nums = [self.random.random() for _ in range(10 ** int(n))] return nums
python
def floats(self, n: int = 2) -> List[float]: """Generate a list of random float numbers. :param n: Raise 10 to the 'n' power. :return: The list of floating-point numbers. """ nums = [self.random.random() for _ in range(10 ** int(n))] return nums
[ "def", "floats", "(", "self", ",", "n", ":", "int", "=", "2", ")", "->", "List", "[", "float", "]", ":", "nums", "=", "[", "self", ".", "random", ".", "random", "(", ")", "for", "_", "in", "range", "(", "10", "**", "int", "(", "n", ")", ")"...
Generate a list of random float numbers. :param n: Raise 10 to the 'n' power. :return: The list of floating-point numbers.
[ "Generate", "a", "list", "of", "random", "float", "numbers", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L20-L28
227,989
lk-geimfari/mimesis
mimesis/providers/numbers.py
Numbers.integers
def integers(self, start: int = 0, end: int = 10, length: int = 10) -> List[int]: """Generate a list of random integers. Integers can be negative or positive numbers. .. note: You can use both positive and negative numbers. :param start: Start. :param end: End....
python
def integers(self, start: int = 0, end: int = 10, length: int = 10) -> List[int]: """Generate a list of random integers. Integers can be negative or positive numbers. .. note: You can use both positive and negative numbers. :param start: Start. :param end: End....
[ "def", "integers", "(", "self", ",", "start", ":", "int", "=", "0", ",", "end", ":", "int", "=", "10", ",", "length", ":", "int", "=", "10", ")", "->", "List", "[", "int", "]", ":", "return", "self", ".", "random", ".", "randints", "(", "length...
Generate a list of random integers. Integers can be negative or positive numbers. .. note: You can use both positive and negative numbers. :param start: Start. :param end: End. :param length: Length of list. :return: List of integers. :Example: [-20...
[ "Generate", "a", "list", "of", "random", "integers", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L30-L46
227,990
lk-geimfari/mimesis
mimesis/providers/numbers.py
Numbers.primes
def primes(start: int = 1, end: int = 999) -> List[int]: """Generate a list of prime numbers. :param start: First value of range. :param end: Last value of range. :return: A list of prime numbers from start to end. """ # TODO: It should generate random primes with passed...
python
def primes(start: int = 1, end: int = 999) -> List[int]: """Generate a list of prime numbers. :param start: First value of range. :param end: Last value of range. :return: A list of prime numbers from start to end. """ # TODO: It should generate random primes with passed...
[ "def", "primes", "(", "start", ":", "int", "=", "1", ",", "end", ":", "int", "=", "999", ")", "->", "List", "[", "int", "]", ":", "# TODO: It should generate random primes with passed length.", "sieve_size", "=", "(", "end", "//", "2", "-", "1", ")", "if...
Generate a list of prime numbers. :param start: First value of range. :param end: Last value of range. :return: A list of prime numbers from start to end.
[ "Generate", "a", "list", "of", "prime", "numbers", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L49-L76
227,991
lk-geimfari/mimesis
mimesis/providers/numbers.py
Numbers.digit
def digit(self, to_bin: bool = False) -> Union[str, int]: """Get a random digit. :param to_bin: If True then convert to binary. :return: Digit. :Example: 4. """ digit = self.random.randint(0, 9) if to_bin: return bin(digit) retu...
python
def digit(self, to_bin: bool = False) -> Union[str, int]: """Get a random digit. :param to_bin: If True then convert to binary. :return: Digit. :Example: 4. """ digit = self.random.randint(0, 9) if to_bin: return bin(digit) retu...
[ "def", "digit", "(", "self", ",", "to_bin", ":", "bool", "=", "False", ")", "->", "Union", "[", "str", ",", "int", "]", ":", "digit", "=", "self", ".", "random", ".", "randint", "(", "0", ",", "9", ")", "if", "to_bin", ":", "return", "bin", "("...
Get a random digit. :param to_bin: If True then convert to binary. :return: Digit. :Example: 4.
[ "Get", "a", "random", "digit", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L78-L92
227,992
lk-geimfari/mimesis
mimesis/providers/numbers.py
Numbers.between
def between(self, minimum: int = 1, maximum: int = 1000) -> int: """Generate a random number between minimum and maximum. :param minimum: Minimum of range. :param maximum: Maximum of range. :return: Number. """ return self.random.randint(minimum, maximum)
python
def between(self, minimum: int = 1, maximum: int = 1000) -> int: """Generate a random number between minimum and maximum. :param minimum: Minimum of range. :param maximum: Maximum of range. :return: Number. """ return self.random.randint(minimum, maximum)
[ "def", "between", "(", "self", ",", "minimum", ":", "int", "=", "1", ",", "maximum", ":", "int", "=", "1000", ")", "->", "int", ":", "return", "self", ".", "random", ".", "randint", "(", "minimum", ",", "maximum", ")" ]
Generate a random number between minimum and maximum. :param minimum: Minimum of range. :param maximum: Maximum of range. :return: Number.
[ "Generate", "a", "random", "number", "between", "minimum", "and", "maximum", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/numbers.py#L94-L101
227,993
lk-geimfari/mimesis
mimesis/providers/person.py
Person.age
def age(self, minimum: int = 16, maximum: int = 66) -> int: """Get a random integer value. :param maximum: Maximum value of age. :param minimum: Minimum value of age. :return: Random integer. :Example: 23. """ age = self.random.randint(minimum, maxim...
python
def age(self, minimum: int = 16, maximum: int = 66) -> int: """Get a random integer value. :param maximum: Maximum value of age. :param minimum: Minimum value of age. :return: Random integer. :Example: 23. """ age = self.random.randint(minimum, maxim...
[ "def", "age", "(", "self", ",", "minimum", ":", "int", "=", "16", ",", "maximum", ":", "int", "=", "66", ")", "->", "int", ":", "age", "=", "self", ".", "random", ".", "randint", "(", "minimum", ",", "maximum", ")", "self", ".", "_store", "[", ...
Get a random integer value. :param maximum: Maximum value of age. :param minimum: Minimum value of age. :return: Random integer. :Example: 23.
[ "Get", "a", "random", "integer", "value", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L48-L60
227,994
lk-geimfari/mimesis
mimesis/providers/person.py
Person.work_experience
def work_experience(self, working_start_age: int = 22) -> int: """Get a work experience. :param working_start_age: Age then person start to work. :return: Depend on previous generated age. """ age = self._store['age'] if age == 0: age = self.age() re...
python
def work_experience(self, working_start_age: int = 22) -> int: """Get a work experience. :param working_start_age: Age then person start to work. :return: Depend on previous generated age. """ age = self._store['age'] if age == 0: age = self.age() re...
[ "def", "work_experience", "(", "self", ",", "working_start_age", ":", "int", "=", "22", ")", "->", "int", ":", "age", "=", "self", ".", "_store", "[", "'age'", "]", "if", "age", "==", "0", ":", "age", "=", "self", ".", "age", "(", ")", "return", ...
Get a work experience. :param working_start_age: Age then person start to work. :return: Depend on previous generated age.
[ "Get", "a", "work", "experience", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L62-L72
227,995
lk-geimfari/mimesis
mimesis/providers/person.py
Person.name
def name(self, gender: Optional[Gender] = None) -> str: """Generate a random name. :param gender: Gender's enum object. :return: Name. :Example: John. """ key = self._validate_enum(gender, Gender) names = self._data['names'].get(key) return s...
python
def name(self, gender: Optional[Gender] = None) -> str: """Generate a random name. :param gender: Gender's enum object. :return: Name. :Example: John. """ key = self._validate_enum(gender, Gender) names = self._data['names'].get(key) return s...
[ "def", "name", "(", "self", ",", "gender", ":", "Optional", "[", "Gender", "]", "=", "None", ")", "->", "str", ":", "key", "=", "self", ".", "_validate_enum", "(", "gender", ",", "Gender", ")", "names", "=", "self", ".", "_data", "[", "'names'", "]...
Generate a random name. :param gender: Gender's enum object. :return: Name. :Example: John.
[ "Generate", "a", "random", "name", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L74-L85
227,996
lk-geimfari/mimesis
mimesis/providers/person.py
Person.surname
def surname(self, gender: Optional[Gender] = None) -> str: """Generate a random surname. :param gender: Gender's enum object. :return: Surname. :Example: Smith. """ surnames = self._data['surnames'] # Surnames separated by gender. if isinsta...
python
def surname(self, gender: Optional[Gender] = None) -> str: """Generate a random surname. :param gender: Gender's enum object. :return: Surname. :Example: Smith. """ surnames = self._data['surnames'] # Surnames separated by gender. if isinsta...
[ "def", "surname", "(", "self", ",", "gender", ":", "Optional", "[", "Gender", "]", "=", "None", ")", "->", "str", ":", "surnames", "=", "self", ".", "_data", "[", "'surnames'", "]", "# Surnames separated by gender.", "if", "isinstance", "(", "surnames", ",...
Generate a random surname. :param gender: Gender's enum object. :return: Surname. :Example: Smith.
[ "Generate", "a", "random", "surname", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L87-L103
227,997
lk-geimfari/mimesis
mimesis/providers/person.py
Person.title
def title(self, gender: Optional[Gender] = None, title_type: Optional[TitleType] = None) -> str: """Generate a random title for name. You can generate random prefix or suffix for name using this method. :param gender: The gender. :param title_type: TitleType enum ...
python
def title(self, gender: Optional[Gender] = None, title_type: Optional[TitleType] = None) -> str: """Generate a random title for name. You can generate random prefix or suffix for name using this method. :param gender: The gender. :param title_type: TitleType enum ...
[ "def", "title", "(", "self", ",", "gender", ":", "Optional", "[", "Gender", "]", "=", "None", ",", "title_type", ":", "Optional", "[", "TitleType", "]", "=", "None", ")", "->", "str", ":", "gender_key", "=", "self", ".", "_validate_enum", "(", "gender"...
Generate a random title for name. You can generate random prefix or suffix for name using this method. :param gender: The gender. :param title_type: TitleType enum object. :return: The title. :raises NonEnumerableError: if gender or title_type in incorrect format. ...
[ "Generate", "a", "random", "title", "for", "name", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L115-L134
227,998
lk-geimfari/mimesis
mimesis/providers/person.py
Person.full_name
def full_name(self, gender: Optional[Gender] = None, reverse: bool = False) -> str: """Generate a random full name. :param reverse: Return reversed full name. :param gender: Gender's enum object. :return: Full name. :Example: Johann Wolfgang. ...
python
def full_name(self, gender: Optional[Gender] = None, reverse: bool = False) -> str: """Generate a random full name. :param reverse: Return reversed full name. :param gender: Gender's enum object. :return: Full name. :Example: Johann Wolfgang. ...
[ "def", "full_name", "(", "self", ",", "gender", ":", "Optional", "[", "Gender", "]", "=", "None", ",", "reverse", ":", "bool", "=", "False", ")", "->", "str", ":", "if", "gender", "is", "None", ":", "gender", "=", "get_random_item", "(", "Gender", ",...
Generate a random full name. :param reverse: Return reversed full name. :param gender: Gender's enum object. :return: Full name. :Example: Johann Wolfgang.
[ "Generate", "a", "random", "full", "name", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L136-L159
227,999
lk-geimfari/mimesis
mimesis/providers/person.py
Person.username
def username(self, template: Optional[str] = None) -> str: """Generate username by template. Supported template placeholders: (U, l, d) Supported separators: (-, ., _) Template must contain at least one "U" or "l" placeholder. If template is None one of the following template...
python
def username(self, template: Optional[str] = None) -> str: """Generate username by template. Supported template placeholders: (U, l, d) Supported separators: (-, ., _) Template must contain at least one "U" or "l" placeholder. If template is None one of the following template...
[ "def", "username", "(", "self", ",", "template", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "MIN_DATE", "=", "1800", "MAX_DATE", "=", "2070", "DEFAULT_TEMPLATE", "=", "'l.d'", "templates", "=", "(", "'U_d'", ",", "'U.d'", ","...
Generate username by template. Supported template placeholders: (U, l, d) Supported separators: (-, ., _) Template must contain at least one "U" or "l" placeholder. If template is None one of the following templates is used: ('U_d', 'U.d', 'U-d', 'UU-d', 'UU.d', 'UU_d', ...
[ "Generate", "username", "by", "template", "." ]
4b16ee7a8dba6281a904654a88dbb4b052869fc5
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/person.py#L161-L211