repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
ray-project/ray
python/ray/rllib/agents/ars/utils.py
compute_ranks
def compute_ranks(x): """Returns ranks in [0, len(x)) Note: This is different from scipy.stats.rankdata, which returns ranks in [1, len(x)]. """ assert x.ndim == 1 ranks = np.empty(len(x), dtype=int) ranks[x.argsort()] = np.arange(len(x)) return ranks
python
def compute_ranks(x): """Returns ranks in [0, len(x)) Note: This is different from scipy.stats.rankdata, which returns ranks in [1, len(x)]. """ assert x.ndim == 1 ranks = np.empty(len(x), dtype=int) ranks[x.argsort()] = np.arange(len(x)) return ranks
[ "def", "compute_ranks", "(", "x", ")", ":", "assert", "x", ".", "ndim", "==", "1", "ranks", "=", "np", ".", "empty", "(", "len", "(", "x", ")", ",", "dtype", "=", "int", ")", "ranks", "[", "x", ".", "argsort", "(", ")", "]", "=", "np", ".", ...
Returns ranks in [0, len(x)) Note: This is different from scipy.stats.rankdata, which returns ranks in [1, len(x)].
[ "Returns", "ranks", "in", "[", "0", "len", "(", "x", "))" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/ars/utils.py#L12-L21
train
ray-project/ray
python/ray/experimental/sgd/tfbench/resnet_model.py
bottleneck_block_v1
def bottleneck_block_v1(cnn, depth, depth_bottleneck, stride): """Bottleneck block with identity short-cut for ResNet v1. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this bloc...
python
def bottleneck_block_v1(cnn, depth, depth_bottleneck, stride): """Bottleneck block with identity short-cut for ResNet v1. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this bloc...
[ "def", "bottleneck_block_v1", "(", "cnn", ",", "depth", ",", "depth_bottleneck", ",", "stride", ")", ":", "input_layer", "=", "cnn", ".", "top_layer", "in_size", "=", "cnn", ".", "top_size", "name_key", "=", "\"resnet_v1\"", "name", "=", "name_key", "+", "st...
Bottleneck block with identity short-cut for ResNet v1. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this block. stride: Stride used in the first layer of the bottleneck block.
[ "Bottleneck", "block", "with", "identity", "short", "-", "cut", "for", "ResNet", "v1", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/resnet_model.py#L39-L101
train
ray-project/ray
python/ray/experimental/sgd/tfbench/resnet_model.py
bottleneck_block
def bottleneck_block(cnn, depth, depth_bottleneck, stride, pre_activation): """Bottleneck block with identity short-cut. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this block...
python
def bottleneck_block(cnn, depth, depth_bottleneck, stride, pre_activation): """Bottleneck block with identity short-cut. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this block...
[ "def", "bottleneck_block", "(", "cnn", ",", "depth", ",", "depth_bottleneck", ",", "stride", ",", "pre_activation", ")", ":", "if", "pre_activation", ":", "bottleneck_block_v2", "(", "cnn", ",", "depth", ",", "depth_bottleneck", ",", "stride", ")", "else", ":"...
Bottleneck block with identity short-cut. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this block. stride: Stride used in the first layer of the bottleneck block. pre_activ...
[ "Bottleneck", "block", "with", "identity", "short", "-", "cut", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/resnet_model.py#L182-L195
train
ray-project/ray
python/ray/experimental/sgd/tfbench/resnet_model.py
residual_block
def residual_block(cnn, depth, stride, pre_activation): """Residual block with identity short-cut. Args: cnn: the network to append residual blocks. depth: the number of output filters for this residual block. stride: Stride used in the first layer of the residual block. pre_activation: use pre_a...
python
def residual_block(cnn, depth, stride, pre_activation): """Residual block with identity short-cut. Args: cnn: the network to append residual blocks. depth: the number of output filters for this residual block. stride: Stride used in the first layer of the residual block. pre_activation: use pre_a...
[ "def", "residual_block", "(", "cnn", ",", "depth", ",", "stride", ",", "pre_activation", ")", ":", "input_layer", "=", "cnn", ".", "top_layer", "in_size", "=", "cnn", ".", "top_size", "if", "in_size", "!=", "depth", ":", "# Plan A of shortcut.", "shortcut", ...
Residual block with identity short-cut. Args: cnn: the network to append residual blocks. depth: the number of output filters for this residual block. stride: Stride used in the first layer of the residual block. pre_activation: use pre_activation structure or not.
[ "Residual", "block", "with", "identity", "short", "-", "cut", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/resnet_model.py#L198-L258
train
ray-project/ray
python/ray/rllib/utils/filter.py
MeanStdFilter.apply_changes
def apply_changes(self, other, with_buffer=False): """Applies updates from the buffer of another filter. Params: other (MeanStdFilter): Other filter to apply info from with_buffer (bool): Flag for specifying if the buffer should be copied from other. Exa...
python
def apply_changes(self, other, with_buffer=False): """Applies updates from the buffer of another filter. Params: other (MeanStdFilter): Other filter to apply info from with_buffer (bool): Flag for specifying if the buffer should be copied from other. Exa...
[ "def", "apply_changes", "(", "self", ",", "other", ",", "with_buffer", "=", "False", ")", ":", "self", ".", "rs", ".", "update", "(", "other", ".", "buffer", ")", "if", "with_buffer", ":", "self", ".", "buffer", "=", "other", ".", "buffer", ".", "cop...
Applies updates from the buffer of another filter. Params: other (MeanStdFilter): Other filter to apply info from with_buffer (bool): Flag for specifying if the buffer should be copied from other. Examples: >>> a = MeanStdFilter(()) >>> a...
[ "Applies", "updates", "from", "the", "buffer", "of", "another", "filter", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/filter.py#L156-L181
train
ray-project/ray
python/ray/rllib/utils/filter.py
MeanStdFilter.copy
def copy(self): """Returns a copy of Filter.""" other = MeanStdFilter(self.shape) other.sync(self) return other
python
def copy(self): """Returns a copy of Filter.""" other = MeanStdFilter(self.shape) other.sync(self) return other
[ "def", "copy", "(", "self", ")", ":", "other", "=", "MeanStdFilter", "(", "self", ".", "shape", ")", "other", ".", "sync", "(", "self", ")", "return", "other" ]
Returns a copy of Filter.
[ "Returns", "a", "copy", "of", "Filter", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/filter.py#L183-L187
train
ray-project/ray
python/ray/rllib/utils/filter.py
MeanStdFilter.sync
def sync(self, other): """Syncs all fields together from other filter. Examples: >>> a = MeanStdFilter(()) >>> a(1) >>> a(2) >>> print([a.rs.n, a.rs.mean, a.buffer.n]) [2, array(1.5), 2] >>> b = MeanStdFilter(()) >>> b(...
python
def sync(self, other): """Syncs all fields together from other filter. Examples: >>> a = MeanStdFilter(()) >>> a(1) >>> a(2) >>> print([a.rs.n, a.rs.mean, a.buffer.n]) [2, array(1.5), 2] >>> b = MeanStdFilter(()) >>> b(...
[ "def", "sync", "(", "self", ",", "other", ")", ":", "assert", "other", ".", "shape", "==", "self", ".", "shape", ",", "\"Shapes don't match!\"", "self", ".", "demean", "=", "other", ".", "demean", "self", ".", "destd", "=", "other", ".", "destd", "self...
Syncs all fields together from other filter. Examples: >>> a = MeanStdFilter(()) >>> a(1) >>> a(2) >>> print([a.rs.n, a.rs.mean, a.buffer.n]) [2, array(1.5), 2] >>> b = MeanStdFilter(()) >>> b(10) >>> print([b.rs.n,...
[ "Syncs", "all", "fields", "together", "from", "other", "filter", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/filter.py#L192-L214
train
ray-project/ray
python/ray/rllib/utils/filter.py
ConcurrentMeanStdFilter.as_serializable
def as_serializable(self): """Returns non-concurrent version of current class""" other = MeanStdFilter(self.shape) other.sync(self) return other
python
def as_serializable(self): """Returns non-concurrent version of current class""" other = MeanStdFilter(self.shape) other.sync(self) return other
[ "def", "as_serializable", "(", "self", ")", ":", "other", "=", "MeanStdFilter", "(", "self", ".", "shape", ")", "other", ".", "sync", "(", "self", ")", "return", "other" ]
Returns non-concurrent version of current class
[ "Returns", "non", "-", "concurrent", "version", "of", "current", "class" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/filter.py#L258-L262
train
ray-project/ray
python/ray/rllib/utils/filter.py
ConcurrentMeanStdFilter.copy
def copy(self): """Returns a copy of Filter.""" other = ConcurrentMeanStdFilter(self.shape) other.sync(self) return other
python
def copy(self): """Returns a copy of Filter.""" other = ConcurrentMeanStdFilter(self.shape) other.sync(self) return other
[ "def", "copy", "(", "self", ")", ":", "other", "=", "ConcurrentMeanStdFilter", "(", "self", ".", "shape", ")", "other", ".", "sync", "(", "self", ")", "return", "other" ]
Returns a copy of Filter.
[ "Returns", "a", "copy", "of", "Filter", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/filter.py#L264-L268
train
ray-project/ray
python/ray/tune/examples/genetic_example.py
michalewicz_function
def michalewicz_function(config, reporter): """f(x) = -sum{sin(xi) * [sin(i*xi^2 / pi)]^(2m)}""" import numpy as np x = np.array( [config["x1"], config["x2"], config["x3"], config["x4"], config["x5"]]) sin_x = np.sin(x) z = (np.arange(1, 6) / np.pi * (x * x)) sin_z = np.power(np.sin(z), ...
python
def michalewicz_function(config, reporter): """f(x) = -sum{sin(xi) * [sin(i*xi^2 / pi)]^(2m)}""" import numpy as np x = np.array( [config["x1"], config["x2"], config["x3"], config["x4"], config["x5"]]) sin_x = np.sin(x) z = (np.arange(1, 6) / np.pi * (x * x)) sin_z = np.power(np.sin(z), ...
[ "def", "michalewicz_function", "(", "config", ",", "reporter", ")", ":", "import", "numpy", "as", "np", "x", "=", "np", ".", "array", "(", "[", "config", "[", "\"x1\"", "]", ",", "config", "[", "\"x2\"", "]", ",", "config", "[", "\"x3\"", "]", ",", ...
f(x) = -sum{sin(xi) * [sin(i*xi^2 / pi)]^(2m)}
[ "f", "(", "x", ")", "=", "-", "sum", "{", "sin", "(", "xi", ")", "*", "[", "sin", "(", "i", "*", "xi^2", "/", "pi", ")", "]", "^", "(", "2m", ")", "}" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/examples/genetic_example.py#L16-L27
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
parse_general_int
def parse_general_int(s): """Parse integer with power-of-2 suffix eg. 32k.""" mo = re.match(r"(\d+)([KkMGT]?)$", s) if mo: i, suffix = mo.group(1, 2) v = int(i) if suffix: if suffix == "K" or suffix == "k": v *= 1024 elif suffix == "M": ...
python
def parse_general_int(s): """Parse integer with power-of-2 suffix eg. 32k.""" mo = re.match(r"(\d+)([KkMGT]?)$", s) if mo: i, suffix = mo.group(1, 2) v = int(i) if suffix: if suffix == "K" or suffix == "k": v *= 1024 elif suffix == "M": ...
[ "def", "parse_general_int", "(", "s", ")", ":", "mo", "=", "re", ".", "match", "(", "r\"(\\d+)([KkMGT]?)$\"", ",", "s", ")", "if", "mo", ":", "i", ",", "suffix", "=", "mo", ".", "group", "(", "1", ",", "2", ")", "v", "=", "int", "(", "i", ")", ...
Parse integer with power-of-2 suffix eg. 32k.
[ "Parse", "integer", "with", "power", "-", "of", "-", "2", "suffix", "eg", ".", "32k", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L38-L58
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
parse_all_reduce_spec
def parse_all_reduce_spec(all_reduce_spec): """Parse all_reduce_spec. Args: all_reduce_spec: a string specifying a combination of all-reduce algorithms to apply for gradient reduction. Returns: a list of AllReduceSpecTuple. Raises: ValueError: all_reduce_spec is not well-formed. An all...
python
def parse_all_reduce_spec(all_reduce_spec): """Parse all_reduce_spec. Args: all_reduce_spec: a string specifying a combination of all-reduce algorithms to apply for gradient reduction. Returns: a list of AllReduceSpecTuple. Raises: ValueError: all_reduce_spec is not well-formed. An all...
[ "def", "parse_all_reduce_spec", "(", "all_reduce_spec", ")", ":", "range_parts", "=", "all_reduce_spec", ".", "split", "(", "\":\"", ")", "+", "[", "\"-1\"", "]", "if", "len", "(", "range_parts", ")", "%", "2", ":", "raise", "ValueError", "(", "\"all_reduce_...
Parse all_reduce_spec. Args: all_reduce_spec: a string specifying a combination of all-reduce algorithms to apply for gradient reduction. Returns: a list of AllReduceSpecTuple. Raises: ValueError: all_reduce_spec is not well-formed. An all_reduce_spec has BNF form: int ::= positive wh...
[ "Parse", "all_reduce_spec", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L61-L148
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
build_all_reduce_device_prefixes
def build_all_reduce_device_prefixes(job_name, num_tasks): """Build list of device prefix names for all_reduce. Args: job_name: "worker", "ps" or "localhost". num_tasks: number of jobs across which device names should be generated. Returns: A list of device name prefix strings. Each element spell...
python
def build_all_reduce_device_prefixes(job_name, num_tasks): """Build list of device prefix names for all_reduce. Args: job_name: "worker", "ps" or "localhost". num_tasks: number of jobs across which device names should be generated. Returns: A list of device name prefix strings. Each element spell...
[ "def", "build_all_reduce_device_prefixes", "(", "job_name", ",", "num_tasks", ")", ":", "if", "job_name", "!=", "\"localhost\"", ":", "return", "[", "\"/job:%s/task:%d\"", "%", "(", "job_name", ",", "d", ")", "for", "d", "in", "range", "(", "0", ",", "num_ta...
Build list of device prefix names for all_reduce. Args: job_name: "worker", "ps" or "localhost". num_tasks: number of jobs across which device names should be generated. Returns: A list of device name prefix strings. Each element spells out the full host name without adding the device. e.g....
[ "Build", "list", "of", "device", "prefix", "names", "for", "all_reduce", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L151-L167
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
group_device_names
def group_device_names(devices, group_size): """Group device names into groups of group_size. Args: devices: list of strings naming devices. group_size: int >= 1 Returns: list of lists of devices, where each inner list is group_size long, and each device appears at least once in an inner lis...
python
def group_device_names(devices, group_size): """Group device names into groups of group_size. Args: devices: list of strings naming devices. group_size: int >= 1 Returns: list of lists of devices, where each inner list is group_size long, and each device appears at least once in an inner lis...
[ "def", "group_device_names", "(", "devices", ",", "group_size", ")", ":", "num_devices", "=", "len", "(", "devices", ")", "if", "group_size", ">", "num_devices", ":", "raise", "ValueError", "(", "\"only %d devices, but group_size=%d\"", "%", "(", "num_devices", ",...
Group device names into groups of group_size. Args: devices: list of strings naming devices. group_size: int >= 1 Returns: list of lists of devices, where each inner list is group_size long, and each device appears at least once in an inner list. If len(devices) % group_size = 0 then each...
[ "Group", "device", "names", "into", "groups", "of", "group_size", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L170-L196
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
split_grads_by_size
def split_grads_by_size(threshold_size, device_grads): """Break gradients into two sets according to tensor size. Args: threshold_size: int size cutoff for small vs large tensor. device_grads: List of lists of (gradient, variable) tuples. The outer list is over devices. The inner list is over in...
python
def split_grads_by_size(threshold_size, device_grads): """Break gradients into two sets according to tensor size. Args: threshold_size: int size cutoff for small vs large tensor. device_grads: List of lists of (gradient, variable) tuples. The outer list is over devices. The inner list is over in...
[ "def", "split_grads_by_size", "(", "threshold_size", ",", "device_grads", ")", ":", "small_grads", "=", "[", "]", "large_grads", "=", "[", "]", "for", "dl", "in", "device_grads", ":", "small_dl", "=", "[", "]", "large_dl", "=", "[", "]", "for", "(", "g",...
Break gradients into two sets according to tensor size. Args: threshold_size: int size cutoff for small vs large tensor. device_grads: List of lists of (gradient, variable) tuples. The outer list is over devices. The inner list is over individual gradients. Returns: small_grads: Subset of dev...
[ "Break", "gradients", "into", "two", "sets", "according", "to", "tensor", "size", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L199-L228
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
aggregate_single_gradient
def aggregate_single_gradient(grad_and_vars, use_mean, check_inf_nan): """Calculate the average gradient for a shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: grad_and_vars: A list or tuple of (gradient, variable) tuples. Each (gra...
python
def aggregate_single_gradient(grad_and_vars, use_mean, check_inf_nan): """Calculate the average gradient for a shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: grad_and_vars: A list or tuple of (gradient, variable) tuples. Each (gra...
[ "def", "aggregate_single_gradient", "(", "grad_and_vars", ",", "use_mean", ",", "check_inf_nan", ")", ":", "grads", "=", "[", "g", "for", "g", ",", "_", "in", "grad_and_vars", "]", "grad", "=", "tf", ".", "add_n", "(", "grads", ")", "if", "use_mean", "an...
Calculate the average gradient for a shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: grad_and_vars: A list or tuple of (gradient, variable) tuples. Each (gradient, variable) pair within the outer list represents the gradient of t...
[ "Calculate", "the", "average", "gradient", "for", "a", "shared", "variable", "across", "all", "towers", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L241-L270
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
aggregate_gradients_using_copy_with_device_selection
def aggregate_gradients_using_copy_with_device_selection( tower_grads, avail_devices, use_mean=True, check_inf_nan=False): """Aggregate gradients, controlling device for the aggregation. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over towers. The inner li...
python
def aggregate_gradients_using_copy_with_device_selection( tower_grads, avail_devices, use_mean=True, check_inf_nan=False): """Aggregate gradients, controlling device for the aggregation. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over towers. The inner li...
[ "def", "aggregate_gradients_using_copy_with_device_selection", "(", "tower_grads", ",", "avail_devices", ",", "use_mean", "=", "True", ",", "check_inf_nan", "=", "False", ")", ":", "agg_grads", "=", "[", "]", "has_nan_or_inf_list", "=", "[", "]", "for", "i", ",", ...
Aggregate gradients, controlling device for the aggregation. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over towers. The inner list is over individual gradients. use_mean: if True, mean is taken, else sum of gradients is taken. check_inf_nan: If true, check g...
[ "Aggregate", "gradients", "controlling", "device", "for", "the", "aggregation", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L273-L296
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
sum_grad_and_var_all_reduce
def sum_grad_and_var_all_reduce(grad_and_vars, num_workers, alg, gpu_indices, aux_devices=None, num_shards=1): """Apply all-reduce algorithm over specified ...
python
def sum_grad_and_var_all_reduce(grad_and_vars, num_workers, alg, gpu_indices, aux_devices=None, num_shards=1): """Apply all-reduce algorithm over specified ...
[ "def", "sum_grad_and_var_all_reduce", "(", "grad_and_vars", ",", "num_workers", ",", "alg", ",", "gpu_indices", ",", "aux_devices", "=", "None", ",", "num_shards", "=", "1", ")", ":", "with", "tf", ".", "name_scope", "(", "\"allreduce\"", ")", ":", "# Note tha...
Apply all-reduce algorithm over specified gradient tensors.
[ "Apply", "all", "-", "reduce", "algorithm", "over", "specified", "gradient", "tensors", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L299-L346
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
sum_gradients_all_reduce
def sum_gradients_all_reduce(dev_prefixes, tower_grads, num_workers, alg, num_shards, gpu_indices, agg_small_grads_max_bytes=0): """Apply all-...
python
def sum_gradients_all_reduce(dev_prefixes, tower_grads, num_workers, alg, num_shards, gpu_indices, agg_small_grads_max_bytes=0): """Apply all-...
[ "def", "sum_gradients_all_reduce", "(", "dev_prefixes", ",", "tower_grads", ",", "num_workers", ",", "alg", ",", "num_shards", ",", "gpu_indices", ",", "agg_small_grads_max_bytes", "=", "0", ")", ":", "alg_contains_shuffle", "=", "contains_any", "(", "alg", ",", "...
Apply all-reduce algorithm over specified gradient tensors. Args: dev_prefixes: list of prefix strings to use to generate PS device names. tower_grads: the gradients to reduce. num_workers: number of worker processes across entire job. alg: the all-reduce algorithm to apply. num_shards: alg-speci...
[ "Apply", "all", "-", "reduce", "algorithm", "over", "specified", "gradient", "tensors", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L366-L426
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
extract_ranges
def extract_ranges(index_list, range_size_limit=32): """Extract consecutive ranges and singles from index_list. Args: index_list: List of monotone increasing non-negative integers. range_size_limit: Largest size range to return. If a larger consecutive range exists it will be returned as multiple ...
python
def extract_ranges(index_list, range_size_limit=32): """Extract consecutive ranges and singles from index_list. Args: index_list: List of monotone increasing non-negative integers. range_size_limit: Largest size range to return. If a larger consecutive range exists it will be returned as multiple ...
[ "def", "extract_ranges", "(", "index_list", ",", "range_size_limit", "=", "32", ")", ":", "if", "not", "index_list", ":", "return", "[", "]", ",", "[", "]", "first", "=", "index_list", "[", "0", "]", "last", "=", "first", "ranges", "=", "[", "]", "si...
Extract consecutive ranges and singles from index_list. Args: index_list: List of monotone increasing non-negative integers. range_size_limit: Largest size range to return. If a larger consecutive range exists it will be returned as multiple ranges. Returns: ranges, singles where ranges is...
[ "Extract", "consecutive", "ranges", "and", "singles", "from", "index_list", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L448-L482
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
pack_range
def pack_range(key, packing, grad_vars, rng): """Form the concatenation of a specified range of gradient tensors. Args: key: Value under which to store meta-data in packing that will be used later to restore the grad_var list structure. packing: Dict holding data describing packed ranges of small t...
python
def pack_range(key, packing, grad_vars, rng): """Form the concatenation of a specified range of gradient tensors. Args: key: Value under which to store meta-data in packing that will be used later to restore the grad_var list structure. packing: Dict holding data describing packed ranges of small t...
[ "def", "pack_range", "(", "key", ",", "packing", ",", "grad_vars", ",", "rng", ")", ":", "to_pack", "=", "grad_vars", "[", "rng", "[", "0", "]", ":", "rng", "[", "1", "]", "+", "1", "]", "members", "=", "[", "]", "variables", "=", "[", "]", "re...
Form the concatenation of a specified range of gradient tensors. Args: key: Value under which to store meta-data in packing that will be used later to restore the grad_var list structure. packing: Dict holding data describing packed ranges of small tensors. grad_vars: List of (grad, var) pairs for ...
[ "Form", "the", "concatenation", "of", "a", "specified", "range", "of", "gradient", "tensors", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L488-L517
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
unpack_grad_tuple
def unpack_grad_tuple(gv, gpt): """Unpack a previously packed collection of gradient tensors. Args: gv: A (grad, var) pair to be unpacked. gpt: A GradPackTuple describing the packing operation that produced gv. Returns: A list of (grad, var) pairs corresponding to the values that were origina...
python
def unpack_grad_tuple(gv, gpt): """Unpack a previously packed collection of gradient tensors. Args: gv: A (grad, var) pair to be unpacked. gpt: A GradPackTuple describing the packing operation that produced gv. Returns: A list of (grad, var) pairs corresponding to the values that were origina...
[ "def", "unpack_grad_tuple", "(", "gv", ",", "gpt", ")", ":", "elt_widths", "=", "[", "x", ".", "num_elements", "(", ")", "for", "x", "in", "gpt", ".", "shapes", "]", "with", "tf", ".", "device", "(", "gv", "[", "0", "]", "[", "0", "]", ".", "de...
Unpack a previously packed collection of gradient tensors. Args: gv: A (grad, var) pair to be unpacked. gpt: A GradPackTuple describing the packing operation that produced gv. Returns: A list of (grad, var) pairs corresponding to the values that were originally packed into gv, maybe following sub...
[ "Unpack", "a", "previously", "packed", "collection", "of", "gradient", "tensors", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L520-L540
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
pack_small_tensors
def pack_small_tensors(tower_grads, max_bytes=0): """Concatenate gradients together more intelligently. Does binpacking Args: tower_grads: List of lists of (gradient, variable) tuples. max_bytes: Int giving max number of bytes in a tensor that may be considered small. """ assert max_bytes >...
python
def pack_small_tensors(tower_grads, max_bytes=0): """Concatenate gradients together more intelligently. Does binpacking Args: tower_grads: List of lists of (gradient, variable) tuples. max_bytes: Int giving max number of bytes in a tensor that may be considered small. """ assert max_bytes >...
[ "def", "pack_small_tensors", "(", "tower_grads", ",", "max_bytes", "=", "0", ")", ":", "assert", "max_bytes", ">=", "0", "orig_grads", "=", "[", "g", "for", "g", ",", "_", "in", "tower_grads", "[", "0", "]", "]", "# Check to make sure sizes are accurate; not e...
Concatenate gradients together more intelligently. Does binpacking Args: tower_grads: List of lists of (gradient, variable) tuples. max_bytes: Int giving max number of bytes in a tensor that may be considered small.
[ "Concatenate", "gradients", "together", "more", "intelligently", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L543-L606
train
ray-project/ray
python/ray/experimental/sgd/modified_allreduce.py
unpack_small_tensors
def unpack_small_tensors(tower_grads, packing): """Undo the structure alterations to tower_grads done by pack_small_tensors. Args: tower_grads: List of List of (grad, var) tuples. packing: A dict generated by pack_small_tensors describing the changes it made to tower_grads. Returns: new_towe...
python
def unpack_small_tensors(tower_grads, packing): """Undo the structure alterations to tower_grads done by pack_small_tensors. Args: tower_grads: List of List of (grad, var) tuples. packing: A dict generated by pack_small_tensors describing the changes it made to tower_grads. Returns: new_towe...
[ "def", "unpack_small_tensors", "(", "tower_grads", ",", "packing", ")", ":", "if", "not", "packing", ":", "return", "tower_grads", "new_tower_grads", "=", "[", "]", "num_devices", "=", "len", "(", "tower_grads", ")", "num_packed", "=", "len", "(", "packing", ...
Undo the structure alterations to tower_grads done by pack_small_tensors. Args: tower_grads: List of List of (grad, var) tuples. packing: A dict generated by pack_small_tensors describing the changes it made to tower_grads. Returns: new_tower_grads: identical to tower_grads except that concatent...
[ "Undo", "the", "structure", "alterations", "to", "tower_grads", "done", "by", "pack_small_tensors", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L609-L637
train
ray-project/ray
python/ray/tune/logger.py
CSVLogger._init
def _init(self): """CSV outputted with Headers as first set of results.""" # Note that we assume params.json was already created by JsonLogger progress_file = os.path.join(self.logdir, "progress.csv") self._continuing = os.path.exists(progress_file) self._file = open(progress_fil...
python
def _init(self): """CSV outputted with Headers as first set of results.""" # Note that we assume params.json was already created by JsonLogger progress_file = os.path.join(self.logdir, "progress.csv") self._continuing = os.path.exists(progress_file) self._file = open(progress_fil...
[ "def", "_init", "(", "self", ")", ":", "# Note that we assume params.json was already created by JsonLogger", "progress_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "logdir", ",", "\"progress.csv\"", ")", "self", ".", "_continuing", "=", "os", "."...
CSV outputted with Headers as first set of results.
[ "CSV", "outputted", "with", "Headers", "as", "first", "set", "of", "results", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/logger.py#L156-L162
train
ray-project/ray
python/ray/tune/logger.py
UnifiedLogger.sync_results_to_new_location
def sync_results_to_new_location(self, worker_ip): """Sends the current log directory to the remote node. Syncing will not occur if the cluster is not started with the Ray autoscaler. """ if worker_ip != self._log_syncer.worker_ip: self._log_syncer.set_worker_ip(work...
python
def sync_results_to_new_location(self, worker_ip): """Sends the current log directory to the remote node. Syncing will not occur if the cluster is not started with the Ray autoscaler. """ if worker_ip != self._log_syncer.worker_ip: self._log_syncer.set_worker_ip(work...
[ "def", "sync_results_to_new_location", "(", "self", ",", "worker_ip", ")", ":", "if", "worker_ip", "!=", "self", ".", "_log_syncer", ".", "worker_ip", ":", "self", ".", "_log_syncer", ".", "set_worker_ip", "(", "worker_ip", ")", "self", ".", "_log_syncer", "."...
Sends the current log directory to the remote node. Syncing will not occur if the cluster is not started with the Ray autoscaler.
[ "Sends", "the", "current", "log", "directory", "to", "the", "remote", "node", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/logger.py#L241-L249
train
ray-project/ray
python/ray/tune/automl/search_policy.py
deep_insert
def deep_insert(path_list, value, config): """Inserts value into config by path, generating intermediate dictionaries. Example: >>> deep_insert(path.split("."), value, {}) """ if len(path_list) > 1: inside_config = config.setdefault(path_list[0], {}) deep_insert(path_list[1:], v...
python
def deep_insert(path_list, value, config): """Inserts value into config by path, generating intermediate dictionaries. Example: >>> deep_insert(path.split("."), value, {}) """ if len(path_list) > 1: inside_config = config.setdefault(path_list[0], {}) deep_insert(path_list[1:], v...
[ "def", "deep_insert", "(", "path_list", ",", "value", ",", "config", ")", ":", "if", "len", "(", "path_list", ")", ">", "1", ":", "inside_config", "=", "config", ".", "setdefault", "(", "path_list", "[", "0", "]", ",", "{", "}", ")", "deep_insert", "...
Inserts value into config by path, generating intermediate dictionaries. Example: >>> deep_insert(path.split("."), value, {})
[ "Inserts", "value", "into", "config", "by", "path", "generating", "intermediate", "dictionaries", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automl/search_policy.py#L18-L28
train
ray-project/ray
python/ray/function_manager.py
FunctionDescriptor.from_bytes_list
def from_bytes_list(cls, function_descriptor_list): """Create a FunctionDescriptor instance from list of bytes. This function is used to create the function descriptor from backend data. Args: cls: Current class which is required argument for classmethod. functi...
python
def from_bytes_list(cls, function_descriptor_list): """Create a FunctionDescriptor instance from list of bytes. This function is used to create the function descriptor from backend data. Args: cls: Current class which is required argument for classmethod. functi...
[ "def", "from_bytes_list", "(", "cls", ",", "function_descriptor_list", ")", ":", "assert", "isinstance", "(", "function_descriptor_list", ",", "list", ")", "if", "len", "(", "function_descriptor_list", ")", "==", "0", ":", "# This is a function descriptor of driver task...
Create a FunctionDescriptor instance from list of bytes. This function is used to create the function descriptor from backend data. Args: cls: Current class which is required argument for classmethod. function_descriptor_list: list of bytes to represent the ...
[ "Create", "a", "FunctionDescriptor", "instance", "from", "list", "of", "bytes", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L73-L103
train
ray-project/ray
python/ray/function_manager.py
FunctionDescriptor.from_function
def from_function(cls, function): """Create a FunctionDescriptor from a function instance. This function is used to create the function descriptor from a python function. If a function is a class function, it should not be used by this function. Args: cls: Current c...
python
def from_function(cls, function): """Create a FunctionDescriptor from a function instance. This function is used to create the function descriptor from a python function. If a function is a class function, it should not be used by this function. Args: cls: Current c...
[ "def", "from_function", "(", "cls", ",", "function", ")", ":", "module_name", "=", "function", ".", "__module__", "function_name", "=", "function", ".", "__name__", "class_name", "=", "\"\"", "function_source_hasher", "=", "hashlib", ".", "sha1", "(", ")", "tr...
Create a FunctionDescriptor from a function instance. This function is used to create the function descriptor from a python function. If a function is a class function, it should not be used by this function. Args: cls: Current class which is required argument for classmeth...
[ "Create", "a", "FunctionDescriptor", "from", "a", "function", "instance", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L106-L140
train
ray-project/ray
python/ray/function_manager.py
FunctionDescriptor.from_class
def from_class(cls, target_class): """Create a FunctionDescriptor from a class. Args: cls: Current class which is required argument for classmethod. target_class: the python class used to create the function descriptor. Returns: The FunctionD...
python
def from_class(cls, target_class): """Create a FunctionDescriptor from a class. Args: cls: Current class which is required argument for classmethod. target_class: the python class used to create the function descriptor. Returns: The FunctionD...
[ "def", "from_class", "(", "cls", ",", "target_class", ")", ":", "module_name", "=", "target_class", ".", "__module__", "class_name", "=", "target_class", ".", "__name__", "return", "cls", "(", "module_name", ",", "\"__init__\"", ",", "class_name", ")" ]
Create a FunctionDescriptor from a class. Args: cls: Current class which is required argument for classmethod. target_class: the python class used to create the function descriptor. Returns: The FunctionDescriptor instance created according to the cl...
[ "Create", "a", "FunctionDescriptor", "from", "a", "class", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L143-L156
train
ray-project/ray
python/ray/function_manager.py
FunctionDescriptor.is_for_driver_task
def is_for_driver_task(self): """See whether this function descriptor is for a driver or not. Returns: True if this function descriptor is for driver tasks. """ return all( len(x) == 0 for x in [self.module_name, self.class_name, self.function_name])
python
def is_for_driver_task(self): """See whether this function descriptor is for a driver or not. Returns: True if this function descriptor is for driver tasks. """ return all( len(x) == 0 for x in [self.module_name, self.class_name, self.function_name])
[ "def", "is_for_driver_task", "(", "self", ")", ":", "return", "all", "(", "len", "(", "x", ")", "==", "0", "for", "x", "in", "[", "self", ".", "module_name", ",", "self", ".", "class_name", ",", "self", ".", "function_name", "]", ")" ]
See whether this function descriptor is for a driver or not. Returns: True if this function descriptor is for driver tasks.
[ "See", "whether", "this", "function", "descriptor", "is", "for", "a", "driver", "or", "not", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L164-L172
train
ray-project/ray
python/ray/function_manager.py
FunctionDescriptor._get_function_id
def _get_function_id(self): """Calculate the function id of current function descriptor. This function id is calculated from all the fields of function descriptor. Returns: ray.ObjectID to represent the function descriptor. """ if self.is_for_driver_task: ...
python
def _get_function_id(self): """Calculate the function id of current function descriptor. This function id is calculated from all the fields of function descriptor. Returns: ray.ObjectID to represent the function descriptor. """ if self.is_for_driver_task: ...
[ "def", "_get_function_id", "(", "self", ")", ":", "if", "self", ".", "is_for_driver_task", ":", "return", "ray", ".", "FunctionID", ".", "nil", "(", ")", "function_id_hash", "=", "hashlib", ".", "sha1", "(", ")", "# Include the function module and name in the hash...
Calculate the function id of current function descriptor. This function id is calculated from all the fields of function descriptor. Returns: ray.ObjectID to represent the function descriptor.
[ "Calculate", "the", "function", "id", "of", "current", "function", "descriptor", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L221-L240
train
ray-project/ray
python/ray/function_manager.py
FunctionDescriptor.get_function_descriptor_list
def get_function_descriptor_list(self): """Return a list of bytes representing the function descriptor. This function is used to pass this function descriptor to backend. Returns: A list of bytes. """ descriptor_list = [] if self.is_for_driver_task: ...
python
def get_function_descriptor_list(self): """Return a list of bytes representing the function descriptor. This function is used to pass this function descriptor to backend. Returns: A list of bytes. """ descriptor_list = [] if self.is_for_driver_task: ...
[ "def", "get_function_descriptor_list", "(", "self", ")", ":", "descriptor_list", "=", "[", "]", "if", "self", ".", "is_for_driver_task", ":", "# Driver task returns an empty list.", "return", "descriptor_list", "else", ":", "descriptor_list", ".", "append", "(", "self...
Return a list of bytes representing the function descriptor. This function is used to pass this function descriptor to backend. Returns: A list of bytes.
[ "Return", "a", "list", "of", "bytes", "representing", "the", "function", "descriptor", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L242-L260
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager.export_cached
def export_cached(self): """Export cached remote functions Note: this should be called only once when worker is connected. """ for remote_function in self._functions_to_export: self._do_export(remote_function) self._functions_to_export = None for info in self...
python
def export_cached(self): """Export cached remote functions Note: this should be called only once when worker is connected. """ for remote_function in self._functions_to_export: self._do_export(remote_function) self._functions_to_export = None for info in self...
[ "def", "export_cached", "(", "self", ")", ":", "for", "remote_function", "in", "self", ".", "_functions_to_export", ":", "self", ".", "_do_export", "(", "remote_function", ")", "self", ".", "_functions_to_export", "=", "None", "for", "info", "in", "self", ".",...
Export cached remote functions Note: this should be called only once when worker is connected.
[ "Export", "cached", "remote", "functions" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L318-L328
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager.export
def export(self, remote_function): """Export a remote function. Args: remote_function: the RemoteFunction object. """ if self._worker.mode is None: # If the worker isn't connected, cache the function # and export it later. self._functions_...
python
def export(self, remote_function): """Export a remote function. Args: remote_function: the RemoteFunction object. """ if self._worker.mode is None: # If the worker isn't connected, cache the function # and export it later. self._functions_...
[ "def", "export", "(", "self", ",", "remote_function", ")", ":", "if", "self", ".", "_worker", ".", "mode", "is", "None", ":", "# If the worker isn't connected, cache the function", "# and export it later.", "self", ".", "_functions_to_export", ".", "append", "(", "r...
Export a remote function. Args: remote_function: the RemoteFunction object.
[ "Export", "a", "remote", "function", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L334-L348
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager._do_export
def _do_export(self, remote_function): """Pickle a remote function and export it to redis. Args: remote_function: the RemoteFunction object. """ if self._worker.load_code_from_local: return # Work around limitations of Python pickling. function = ...
python
def _do_export(self, remote_function): """Pickle a remote function and export it to redis. Args: remote_function: the RemoteFunction object. """ if self._worker.load_code_from_local: return # Work around limitations of Python pickling. function = ...
[ "def", "_do_export", "(", "self", ",", "remote_function", ")", ":", "if", "self", ".", "_worker", ".", "load_code_from_local", ":", "return", "# Work around limitations of Python pickling.", "function", "=", "remote_function", ".", "_function", "function_name_global_valid...
Pickle a remote function and export it to redis. Args: remote_function: the RemoteFunction object.
[ "Pickle", "a", "remote", "function", "and", "export", "it", "to", "redis", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L350-L391
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager.fetch_and_register_remote_function
def fetch_and_register_remote_function(self, key): """Import a remote function.""" (driver_id_str, function_id_str, function_name, serialized_function, num_return_vals, module, resources, max_calls) = self._worker.redis_client.hmget(key, [ "driver_id", "function_id", "name...
python
def fetch_and_register_remote_function(self, key): """Import a remote function.""" (driver_id_str, function_id_str, function_name, serialized_function, num_return_vals, module, resources, max_calls) = self._worker.redis_client.hmget(key, [ "driver_id", "function_id", "name...
[ "def", "fetch_and_register_remote_function", "(", "self", ",", "key", ")", ":", "(", "driver_id_str", ",", "function_id_str", ",", "function_name", ",", "serialized_function", ",", "num_return_vals", ",", "module", ",", "resources", ",", "max_calls", ")", "=", "se...
Import a remote function.
[ "Import", "a", "remote", "function", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L393-L453
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager.get_execution_info
def get_execution_info(self, driver_id, function_descriptor): """Get the FunctionExecutionInfo of a remote function. Args: driver_id: ID of the driver that the function belongs to. function_descriptor: The FunctionDescriptor of the function to get. Returns: ...
python
def get_execution_info(self, driver_id, function_descriptor): """Get the FunctionExecutionInfo of a remote function. Args: driver_id: ID of the driver that the function belongs to. function_descriptor: The FunctionDescriptor of the function to get. Returns: ...
[ "def", "get_execution_info", "(", "self", ",", "driver_id", ",", "function_descriptor", ")", ":", "if", "self", ".", "_worker", ".", "load_code_from_local", ":", "# Load function from local code.", "# Currently, we don't support isolating code by drivers,", "# thus always set d...
Get the FunctionExecutionInfo of a remote function. Args: driver_id: ID of the driver that the function belongs to. function_descriptor: The FunctionDescriptor of the function to get. Returns: A FunctionExecutionInfo object.
[ "Get", "the", "FunctionExecutionInfo", "of", "a", "remote", "function", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L455-L489
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager._wait_for_function
def _wait_for_function(self, function_descriptor, driver_id, timeout=10): """Wait until the function to be executed is present on this worker. This method will simply loop until the import thread has imported the relevant function. If we spend too long in this loop, that may indicate a ...
python
def _wait_for_function(self, function_descriptor, driver_id, timeout=10): """Wait until the function to be executed is present on this worker. This method will simply loop until the import thread has imported the relevant function. If we spend too long in this loop, that may indicate a ...
[ "def", "_wait_for_function", "(", "self", ",", "function_descriptor", ",", "driver_id", ",", "timeout", "=", "10", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "# Only send the warning once.", "warning_sent", "=", "False", "while", "True", ":", ...
Wait until the function to be executed is present on this worker. This method will simply loop until the import thread has imported the relevant function. If we spend too long in this loop, that may indicate a problem somewhere and we will push an error message to the user. If this wor...
[ "Wait", "until", "the", "function", "to", "be", "executed", "is", "present", "on", "this", "worker", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L518-L558
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager._publish_actor_class_to_key
def _publish_actor_class_to_key(self, key, actor_class_info): """Push an actor class definition to Redis. The is factored out as a separate function because it is also called on cached actor class definitions when a worker connects for the first time. Args: key: The...
python
def _publish_actor_class_to_key(self, key, actor_class_info): """Push an actor class definition to Redis. The is factored out as a separate function because it is also called on cached actor class definitions when a worker connects for the first time. Args: key: The...
[ "def", "_publish_actor_class_to_key", "(", "self", ",", "key", ",", "actor_class_info", ")", ":", "# We set the driver ID here because it may not have been available when", "# the actor class was defined.", "self", ".", "_worker", ".", "redis_client", ".", "hmset", "(", "key"...
Push an actor class definition to Redis. The is factored out as a separate function because it is also called on cached actor class definitions when a worker connects for the first time. Args: key: The key to store the actor class info at. actor_class_info: Info...
[ "Push", "an", "actor", "class", "definition", "to", "Redis", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L560-L574
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager.load_actor_class
def load_actor_class(self, driver_id, function_descriptor): """Load the actor class. Args: driver_id: Driver ID of the actor. function_descriptor: Function descriptor of the actor constructor. Returns: The actor class. """ function_id = funct...
python
def load_actor_class(self, driver_id, function_descriptor): """Load the actor class. Args: driver_id: Driver ID of the actor. function_descriptor: Function descriptor of the actor constructor. Returns: The actor class. """ function_id = funct...
[ "def", "load_actor_class", "(", "self", ",", "driver_id", ",", "function_descriptor", ")", ":", "function_id", "=", "function_descriptor", ".", "function_id", "# Check if the actor class already exists in the cache.", "actor_class", "=", "self", ".", "_loaded_actor_classes", ...
Load the actor class. Args: driver_id: Driver ID of the actor. function_descriptor: Function descriptor of the actor constructor. Returns: The actor class.
[ "Load", "the", "actor", "class", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L619-L668
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager._load_actor_from_local
def _load_actor_from_local(self, driver_id, function_descriptor): """Load actor class from local code.""" module_name, class_name = (function_descriptor.module_name, function_descriptor.class_name) try: module = importlib.import_module(module_name) ...
python
def _load_actor_from_local(self, driver_id, function_descriptor): """Load actor class from local code.""" module_name, class_name = (function_descriptor.module_name, function_descriptor.class_name) try: module = importlib.import_module(module_name) ...
[ "def", "_load_actor_from_local", "(", "self", ",", "driver_id", ",", "function_descriptor", ")", ":", "module_name", ",", "class_name", "=", "(", "function_descriptor", ".", "module_name", ",", "function_descriptor", ".", "class_name", ")", "try", ":", "module", "...
Load actor class from local code.
[ "Load", "actor", "class", "from", "local", "code", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L670-L686
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager._load_actor_class_from_gcs
def _load_actor_class_from_gcs(self, driver_id, function_descriptor): """Load actor class from GCS.""" key = (b"ActorClass:" + driver_id.binary() + b":" + function_descriptor.function_id.binary()) # Wait for the actor class key to have been imported by the # import thread....
python
def _load_actor_class_from_gcs(self, driver_id, function_descriptor): """Load actor class from GCS.""" key = (b"ActorClass:" + driver_id.binary() + b":" + function_descriptor.function_id.binary()) # Wait for the actor class key to have been imported by the # import thread....
[ "def", "_load_actor_class_from_gcs", "(", "self", ",", "driver_id", ",", "function_descriptor", ")", ":", "key", "=", "(", "b\"ActorClass:\"", "+", "driver_id", ".", "binary", "(", ")", "+", "b\":\"", "+", "function_descriptor", ".", "function_id", ".", "binary"...
Load actor class from GCS.
[ "Load", "actor", "class", "from", "GCS", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L702-L759
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager._make_actor_method_executor
def _make_actor_method_executor(self, method_name, method, actor_imported): """Make an executor that wraps a user-defined actor method. The wrapped method updates the worker's internal state and performs any necessary checkpointing operations. Args: method_name (str): The n...
python
def _make_actor_method_executor(self, method_name, method, actor_imported): """Make an executor that wraps a user-defined actor method. The wrapped method updates the worker's internal state and performs any necessary checkpointing operations. Args: method_name (str): The n...
[ "def", "_make_actor_method_executor", "(", "self", ",", "method_name", ",", "method", ",", "actor_imported", ")", ":", "def", "actor_method_executor", "(", "dummy_return_id", ",", "actor", ",", "*", "args", ")", ":", "# Update the actor's task counter to reflect the tas...
Make an executor that wraps a user-defined actor method. The wrapped method updates the worker's internal state and performs any necessary checkpointing operations. Args: method_name (str): The name of the actor method. method (instancemethod): The actor method to wrap....
[ "Make", "an", "executor", "that", "wraps", "a", "user", "-", "defined", "actor", "method", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L761-L819
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager._save_and_log_checkpoint
def _save_and_log_checkpoint(self, actor): """Save an actor checkpoint if necessary and log any errors. Args: actor: The actor to checkpoint. Returns: The result of the actor's user-defined `save_checkpoint` method. """ actor_id = self._worker.actor_id ...
python
def _save_and_log_checkpoint(self, actor): """Save an actor checkpoint if necessary and log any errors. Args: actor: The actor to checkpoint. Returns: The result of the actor's user-defined `save_checkpoint` method. """ actor_id = self._worker.actor_id ...
[ "def", "_save_and_log_checkpoint", "(", "self", ",", "actor", ")", ":", "actor_id", "=", "self", ".", "_worker", ".", "actor_id", "checkpoint_info", "=", "self", ".", "_worker", ".", "actor_checkpoint_info", "[", "actor_id", "]", "checkpoint_info", ".", "num_tas...
Save an actor checkpoint if necessary and log any errors. Args: actor: The actor to checkpoint. Returns: The result of the actor's user-defined `save_checkpoint` method.
[ "Save", "an", "actor", "checkpoint", "if", "necessary", "and", "log", "any", "errors", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L821-L862
train
ray-project/ray
python/ray/function_manager.py
FunctionActorManager._restore_and_log_checkpoint
def _restore_and_log_checkpoint(self, actor): """Restore an actor from a checkpoint if available and log any errors. This should only be called on workers that have just executed an actor creation task. Args: actor: The actor to restore from a checkpoint. """ ...
python
def _restore_and_log_checkpoint(self, actor): """Restore an actor from a checkpoint if available and log any errors. This should only be called on workers that have just executed an actor creation task. Args: actor: The actor to restore from a checkpoint. """ ...
[ "def", "_restore_and_log_checkpoint", "(", "self", ",", "actor", ")", ":", "actor_id", "=", "self", ".", "_worker", ".", "actor_id", "try", ":", "checkpoints", "=", "ray", ".", "actor", ".", "get_checkpoints_for_actor", "(", "actor_id", ")", "if", "len", "("...
Restore an actor from a checkpoint if available and log any errors. This should only be called on workers that have just executed an actor creation task. Args: actor: The actor to restore from a checkpoint.
[ "Restore", "an", "actor", "from", "a", "checkpoint", "if", "available", "and", "log", "any", "errors", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/function_manager.py#L864-L901
train
ray-project/ray
python/ray/rllib/evaluation/sampler.py
_env_runner
def _env_runner(base_env, extra_batch_callback, policies, policy_mapping_fn, unroll_length, horizon, preprocessors, obs_filters, clip_rewards, clip_actions, pack, callbacks, tf_sess, perf_stats, soft_horizon): """This implements the common experience collection logic....
python
def _env_runner(base_env, extra_batch_callback, policies, policy_mapping_fn, unroll_length, horizon, preprocessors, obs_filters, clip_rewards, clip_actions, pack, callbacks, tf_sess, perf_stats, soft_horizon): """This implements the common experience collection logic....
[ "def", "_env_runner", "(", "base_env", ",", "extra_batch_callback", ",", "policies", ",", "policy_mapping_fn", ",", "unroll_length", ",", "horizon", ",", "preprocessors", ",", "obs_filters", ",", "clip_rewards", ",", "clip_actions", ",", "pack", ",", "callbacks", ...
This implements the common experience collection logic. Args: base_env (BaseEnv): env implementing BaseEnv. extra_batch_callback (fn): function to send extra batch data to. policies (dict): Map of policy ids to PolicyGraph instances. policy_mapping_fn (func): Function that maps agen...
[ "This", "implements", "the", "common", "experience", "collection", "logic", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/evaluation/sampler.py#L230-L339
train
ray-project/ray
python/ray/rllib/evaluation/sampler.py
_process_observations
def _process_observations(base_env, policies, batch_builder_pool, active_episodes, unfiltered_obs, rewards, dones, infos, off_policy_actions, horizon, preprocessors, obs_filters, unroll_length, pack, callbacks, soft_...
python
def _process_observations(base_env, policies, batch_builder_pool, active_episodes, unfiltered_obs, rewards, dones, infos, off_policy_actions, horizon, preprocessors, obs_filters, unroll_length, pack, callbacks, soft_...
[ "def", "_process_observations", "(", "base_env", ",", "policies", ",", "batch_builder_pool", ",", "active_episodes", ",", "unfiltered_obs", ",", "rewards", ",", "dones", ",", "infos", ",", "off_policy_actions", ",", "horizon", ",", "preprocessors", ",", "obs_filters...
Record new data from the environment and prepare for policy evaluation. Returns: active_envs: set of non-terminated env ids to_eval: map of policy_id to list of agent PolicyEvalData outputs: list of metrics and samples to return from the sampler
[ "Record", "new", "data", "from", "the", "environment", "and", "prepare", "for", "policy", "evaluation", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/evaluation/sampler.py#L342-L505
train
ray-project/ray
python/ray/rllib/evaluation/sampler.py
_do_policy_eval
def _do_policy_eval(tf_sess, to_eval, policies, active_episodes): """Call compute actions on observation batches to get next actions. Returns: eval_results: dict of policy to compute_action() outputs. """ eval_results = {} if tf_sess: builder = TFRunBuilder(tf_sess, "policy_eval")...
python
def _do_policy_eval(tf_sess, to_eval, policies, active_episodes): """Call compute actions on observation batches to get next actions. Returns: eval_results: dict of policy to compute_action() outputs. """ eval_results = {} if tf_sess: builder = TFRunBuilder(tf_sess, "policy_eval")...
[ "def", "_do_policy_eval", "(", "tf_sess", ",", "to_eval", ",", "policies", ",", "active_episodes", ")", ":", "eval_results", "=", "{", "}", "if", "tf_sess", ":", "builder", "=", "TFRunBuilder", "(", "tf_sess", ",", "\"policy_eval\"", ")", "pending_fetches", "=...
Call compute actions on observation batches to get next actions. Returns: eval_results: dict of policy to compute_action() outputs.
[ "Call", "compute", "actions", "on", "observation", "batches", "to", "get", "next", "actions", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/evaluation/sampler.py#L508-L554
train
ray-project/ray
python/ray/rllib/evaluation/sampler.py
_process_policy_eval_results
def _process_policy_eval_results(to_eval, eval_results, active_episodes, active_envs, off_policy_actions, policies, clip_actions): """Process the output of policy neural network evaluation. Records policy evaluation results into the given episod...
python
def _process_policy_eval_results(to_eval, eval_results, active_episodes, active_envs, off_policy_actions, policies, clip_actions): """Process the output of policy neural network evaluation. Records policy evaluation results into the given episod...
[ "def", "_process_policy_eval_results", "(", "to_eval", ",", "eval_results", ",", "active_episodes", ",", "active_envs", ",", "off_policy_actions", ",", "policies", ",", "clip_actions", ")", ":", "actions_to_send", "=", "defaultdict", "(", "dict", ")", "for", "env_id...
Process the output of policy neural network evaluation. Records policy evaluation results into the given episode objects and returns replies to send back to agents in the env. Returns: actions_to_send: nested dict of env id -> agent id -> agent replies.
[ "Process", "the", "output", "of", "policy", "neural", "network", "evaluation", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/evaluation/sampler.py#L557-L607
train
ray-project/ray
python/ray/rllib/evaluation/sampler.py
_fetch_atari_metrics
def _fetch_atari_metrics(base_env): """Atari games have multiple logical episodes, one per life. However for metrics reporting we count full episodes all lives included. """ unwrapped = base_env.get_unwrapped() if not unwrapped: return None atari_out = [] for u in unwrapped: ...
python
def _fetch_atari_metrics(base_env): """Atari games have multiple logical episodes, one per life. However for metrics reporting we count full episodes all lives included. """ unwrapped = base_env.get_unwrapped() if not unwrapped: return None atari_out = [] for u in unwrapped: ...
[ "def", "_fetch_atari_metrics", "(", "base_env", ")", ":", "unwrapped", "=", "base_env", ".", "get_unwrapped", "(", ")", "if", "not", "unwrapped", ":", "return", "None", "atari_out", "=", "[", "]", "for", "u", "in", "unwrapped", ":", "monitor", "=", "get_wr...
Atari games have multiple logical episodes, one per life. However for metrics reporting we count full episodes all lives included.
[ "Atari", "games", "have", "multiple", "logical", "episodes", "one", "per", "life", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/evaluation/sampler.py#L610-L625
train
google/flatbuffers
android/jni/msbuild.py
compare_version
def compare_version(a, b): """Compare two version number strings of the form W.X.Y.Z. The numbers are compared most-significant to least-significant. For example, 12.345.67.89 > 2.987.88.99. Args: a: First version number string to compare b: Second version number string to compare Returns: 0 if...
python
def compare_version(a, b): """Compare two version number strings of the form W.X.Y.Z. The numbers are compared most-significant to least-significant. For example, 12.345.67.89 > 2.987.88.99. Args: a: First version number string to compare b: Second version number string to compare Returns: 0 if...
[ "def", "compare_version", "(", "a", ",", "b", ")", ":", "aa", "=", "string", ".", "split", "(", "a", ",", "\".\"", ")", "bb", "=", "string", ".", "split", "(", "b", ",", "\".\"", ")", "for", "i", "in", "range", "(", "0", ",", "4", ")", ":", ...
Compare two version number strings of the form W.X.Y.Z. The numbers are compared most-significant to least-significant. For example, 12.345.67.89 > 2.987.88.99. Args: a: First version number string to compare b: Second version number string to compare Returns: 0 if the numbers are identical, a po...
[ "Compare", "two", "version", "number", "strings", "of", "the", "form", "W", ".", "X", ".", "Y", ".", "Z", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/android/jni/msbuild.py#L37-L56
train
google/flatbuffers
conanfile.py
FlatbuffersConan.configure_cmake
def configure_cmake(self): """Create CMake instance and execute configure step """ cmake = CMake(self) cmake.definitions["FLATBUFFERS_BUILD_TESTS"] = False cmake.definitions["FLATBUFFERS_BUILD_SHAREDLIB"] = self.options.shared cmake.definitions["FLATBUFFERS_BUILD_FLATLIB"...
python
def configure_cmake(self): """Create CMake instance and execute configure step """ cmake = CMake(self) cmake.definitions["FLATBUFFERS_BUILD_TESTS"] = False cmake.definitions["FLATBUFFERS_BUILD_SHAREDLIB"] = self.options.shared cmake.definitions["FLATBUFFERS_BUILD_FLATLIB"...
[ "def", "configure_cmake", "(", "self", ")", ":", "cmake", "=", "CMake", "(", "self", ")", "cmake", ".", "definitions", "[", "\"FLATBUFFERS_BUILD_TESTS\"", "]", "=", "False", "cmake", ".", "definitions", "[", "\"FLATBUFFERS_BUILD_SHAREDLIB\"", "]", "=", "self", ...
Create CMake instance and execute configure step
[ "Create", "CMake", "instance", "and", "execute", "configure", "step" ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/conanfile.py#L38-L46
train
google/flatbuffers
conanfile.py
FlatbuffersConan.package
def package(self): """Copy Flatbuffers' artifacts to package folder """ cmake = self.configure_cmake() cmake.install() self.copy(pattern="LICENSE.txt", dst="licenses") self.copy(pattern="FindFlatBuffers.cmake", dst=os.path.join("lib", "cmake", "flatbuffers"), src="CMake")...
python
def package(self): """Copy Flatbuffers' artifacts to package folder """ cmake = self.configure_cmake() cmake.install() self.copy(pattern="LICENSE.txt", dst="licenses") self.copy(pattern="FindFlatBuffers.cmake", dst=os.path.join("lib", "cmake", "flatbuffers"), src="CMake")...
[ "def", "package", "(", "self", ")", ":", "cmake", "=", "self", ".", "configure_cmake", "(", ")", "cmake", ".", "install", "(", ")", "self", ".", "copy", "(", "pattern", "=", "\"LICENSE.txt\"", ",", "dst", "=", "\"licenses\"", ")", "self", ".", "copy", ...
Copy Flatbuffers' artifacts to package folder
[ "Copy", "Flatbuffers", "artifacts", "to", "package", "folder" ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/conanfile.py#L54-L69
train
google/flatbuffers
conanfile.py
FlatbuffersConan.package_info
def package_info(self): """Collect built libraries names and solve flatc path. """ self.cpp_info.libs = tools.collect_libs(self) self.user_info.flatc = os.path.join(self.package_folder, "bin", "flatc")
python
def package_info(self): """Collect built libraries names and solve flatc path. """ self.cpp_info.libs = tools.collect_libs(self) self.user_info.flatc = os.path.join(self.package_folder, "bin", "flatc")
[ "def", "package_info", "(", "self", ")", ":", "self", ".", "cpp_info", ".", "libs", "=", "tools", ".", "collect_libs", "(", "self", ")", "self", ".", "user_info", ".", "flatc", "=", "os", ".", "path", ".", "join", "(", "self", ".", "package_folder", ...
Collect built libraries names and solve flatc path.
[ "Collect", "built", "libraries", "names", "and", "solve", "flatc", "path", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/conanfile.py#L71-L75
train
google/flatbuffers
python/flatbuffers/table.py
Table.Offset
def Offset(self, vtableOffset): """Offset provides access into the Table's vtable. Deprecated fields are ignored by checking the vtable's length.""" vtable = self.Pos - self.Get(N.SOffsetTFlags, self.Pos) vtableEnd = self.Get(N.VOffsetTFlags, vtable) if vtableOffset < vtableEnd...
python
def Offset(self, vtableOffset): """Offset provides access into the Table's vtable. Deprecated fields are ignored by checking the vtable's length.""" vtable = self.Pos - self.Get(N.SOffsetTFlags, self.Pos) vtableEnd = self.Get(N.VOffsetTFlags, vtable) if vtableOffset < vtableEnd...
[ "def", "Offset", "(", "self", ",", "vtableOffset", ")", ":", "vtable", "=", "self", ".", "Pos", "-", "self", ".", "Get", "(", "N", ".", "SOffsetTFlags", ",", "self", ".", "Pos", ")", "vtableEnd", "=", "self", ".", "Get", "(", "N", ".", "VOffsetTFla...
Offset provides access into the Table's vtable. Deprecated fields are ignored by checking the vtable's length.
[ "Offset", "provides", "access", "into", "the", "Table", "s", "vtable", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L32-L41
train
google/flatbuffers
python/flatbuffers/table.py
Table.Indirect
def Indirect(self, off): """Indirect retrieves the relative offset stored at `offset`.""" N.enforce_number(off, N.UOffsetTFlags) return off + encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off)
python
def Indirect(self, off): """Indirect retrieves the relative offset stored at `offset`.""" N.enforce_number(off, N.UOffsetTFlags) return off + encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off)
[ "def", "Indirect", "(", "self", ",", "off", ")", ":", "N", ".", "enforce_number", "(", "off", ",", "N", ".", "UOffsetTFlags", ")", "return", "off", "+", "encode", ".", "Get", "(", "N", ".", "UOffsetTFlags", ".", "packer_type", ",", "self", ".", "Byte...
Indirect retrieves the relative offset stored at `offset`.
[ "Indirect", "retrieves", "the", "relative", "offset", "stored", "at", "offset", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L43-L46
train
google/flatbuffers
python/flatbuffers/table.py
Table.String
def String(self, off): """String gets a string from data stored inside the flatbuffer.""" N.enforce_number(off, N.UOffsetTFlags) off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) start = off + N.UOffsetTFlags.bytewidth length = encode.Get(N.UOffsetTFlags.packer_type...
python
def String(self, off): """String gets a string from data stored inside the flatbuffer.""" N.enforce_number(off, N.UOffsetTFlags) off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) start = off + N.UOffsetTFlags.bytewidth length = encode.Get(N.UOffsetTFlags.packer_type...
[ "def", "String", "(", "self", ",", "off", ")", ":", "N", ".", "enforce_number", "(", "off", ",", "N", ".", "UOffsetTFlags", ")", "off", "+=", "encode", ".", "Get", "(", "N", ".", "UOffsetTFlags", ".", "packer_type", ",", "self", ".", "Bytes", ",", ...
String gets a string from data stored inside the flatbuffer.
[ "String", "gets", "a", "string", "from", "data", "stored", "inside", "the", "flatbuffer", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L48-L54
train
google/flatbuffers
python/flatbuffers/table.py
Table.VectorLen
def VectorLen(self, off): """VectorLen retrieves the length of the vector whose offset is stored at "off" in this object.""" N.enforce_number(off, N.UOffsetTFlags) off += self.Pos off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) ret = encode.Get(N.UOffs...
python
def VectorLen(self, off): """VectorLen retrieves the length of the vector whose offset is stored at "off" in this object.""" N.enforce_number(off, N.UOffsetTFlags) off += self.Pos off += encode.Get(N.UOffsetTFlags.packer_type, self.Bytes, off) ret = encode.Get(N.UOffs...
[ "def", "VectorLen", "(", "self", ",", "off", ")", ":", "N", ".", "enforce_number", "(", "off", ",", "N", ".", "UOffsetTFlags", ")", "off", "+=", "self", ".", "Pos", "off", "+=", "encode", ".", "Get", "(", "N", ".", "UOffsetTFlags", ".", "packer_type"...
VectorLen retrieves the length of the vector whose offset is stored at "off" in this object.
[ "VectorLen", "retrieves", "the", "length", "of", "the", "vector", "whose", "offset", "is", "stored", "at", "off", "in", "this", "object", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L56-L64
train
google/flatbuffers
python/flatbuffers/table.py
Table.Vector
def Vector(self, off): """Vector retrieves the start of data of the vector whose offset is stored at "off" in this object.""" N.enforce_number(off, N.UOffsetTFlags) off += self.Pos x = off + self.Get(N.UOffsetTFlags, off) # data starts after metadata containing the ve...
python
def Vector(self, off): """Vector retrieves the start of data of the vector whose offset is stored at "off" in this object.""" N.enforce_number(off, N.UOffsetTFlags) off += self.Pos x = off + self.Get(N.UOffsetTFlags, off) # data starts after metadata containing the ve...
[ "def", "Vector", "(", "self", ",", "off", ")", ":", "N", ".", "enforce_number", "(", "off", ",", "N", ".", "UOffsetTFlags", ")", "off", "+=", "self", ".", "Pos", "x", "=", "off", "+", "self", ".", "Get", "(", "N", ".", "UOffsetTFlags", ",", "off"...
Vector retrieves the start of data of the vector whose offset is stored at "off" in this object.
[ "Vector", "retrieves", "the", "start", "of", "data", "of", "the", "vector", "whose", "offset", "is", "stored", "at", "off", "in", "this", "object", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L66-L75
train
google/flatbuffers
python/flatbuffers/table.py
Table.Union
def Union(self, t2, off): """Union initializes any Table-derived type to point to the union at the given offset.""" assert type(t2) is Table N.enforce_number(off, N.UOffsetTFlags) off += self.Pos t2.Pos = off + self.Get(N.UOffsetTFlags, off) t2.Bytes = self.By...
python
def Union(self, t2, off): """Union initializes any Table-derived type to point to the union at the given offset.""" assert type(t2) is Table N.enforce_number(off, N.UOffsetTFlags) off += self.Pos t2.Pos = off + self.Get(N.UOffsetTFlags, off) t2.Bytes = self.By...
[ "def", "Union", "(", "self", ",", "t2", ",", "off", ")", ":", "assert", "type", "(", "t2", ")", "is", "Table", "N", ".", "enforce_number", "(", "off", ",", "N", ".", "UOffsetTFlags", ")", "off", "+=", "self", ".", "Pos", "t2", ".", "Pos", "=", ...
Union initializes any Table-derived type to point to the union at the given offset.
[ "Union", "initializes", "any", "Table", "-", "derived", "type", "to", "point", "to", "the", "union", "at", "the", "given", "offset", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L77-L85
train
google/flatbuffers
python/flatbuffers/table.py
Table.Get
def Get(self, flags, off): """ Get retrieves a value of the type specified by `flags` at the given offset. """ N.enforce_number(off, N.UOffsetTFlags) return flags.py_type(encode.Get(flags.packer_type, self.Bytes, off))
python
def Get(self, flags, off): """ Get retrieves a value of the type specified by `flags` at the given offset. """ N.enforce_number(off, N.UOffsetTFlags) return flags.py_type(encode.Get(flags.packer_type, self.Bytes, off))
[ "def", "Get", "(", "self", ",", "flags", ",", "off", ")", ":", "N", ".", "enforce_number", "(", "off", ",", "N", ".", "UOffsetTFlags", ")", "return", "flags", ".", "py_type", "(", "encode", ".", "Get", "(", "flags", ".", "packer_type", ",", "self", ...
Get retrieves a value of the type specified by `flags` at the given offset.
[ "Get", "retrieves", "a", "value", "of", "the", "type", "specified", "by", "flags", "at", "the", "given", "offset", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L87-L93
train
google/flatbuffers
python/flatbuffers/table.py
Table.GetVectorAsNumpy
def GetVectorAsNumpy(self, flags, off): """ GetVectorAsNumpy returns the vector that starts at `Vector(off)` as a numpy array with the type specified by `flags`. The array is a `view` into Bytes, so modifying the returned array will modify Bytes in place. """ offs...
python
def GetVectorAsNumpy(self, flags, off): """ GetVectorAsNumpy returns the vector that starts at `Vector(off)` as a numpy array with the type specified by `flags`. The array is a `view` into Bytes, so modifying the returned array will modify Bytes in place. """ offs...
[ "def", "GetVectorAsNumpy", "(", "self", ",", "flags", ",", "off", ")", ":", "offset", "=", "self", ".", "Vector", "(", "off", ")", "length", "=", "self", ".", "VectorLen", "(", "off", ")", "# TODO: length accounts for bytewidth, right?", "numpy_dtype", "=", ...
GetVectorAsNumpy returns the vector that starts at `Vector(off)` as a numpy array with the type specified by `flags`. The array is a `view` into Bytes, so modifying the returned array will modify Bytes in place.
[ "GetVectorAsNumpy", "returns", "the", "vector", "that", "starts", "at", "Vector", "(", "off", ")", "as", "a", "numpy", "array", "with", "the", "type", "specified", "by", "flags", ".", "The", "array", "is", "a", "view", "into", "Bytes", "so", "modifying", ...
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L104-L114
train
google/flatbuffers
python/flatbuffers/table.py
Table.GetVOffsetTSlot
def GetVOffsetTSlot(self, slot, d): """ GetVOffsetTSlot retrieves the VOffsetT that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned. """ N.enforce_number(slot, N.VOffsetTFlags) N.enforce_number(d, N.VOffset...
python
def GetVOffsetTSlot(self, slot, d): """ GetVOffsetTSlot retrieves the VOffsetT that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned. """ N.enforce_number(slot, N.VOffsetTFlags) N.enforce_number(d, N.VOffset...
[ "def", "GetVOffsetTSlot", "(", "self", ",", "slot", ",", "d", ")", ":", "N", ".", "enforce_number", "(", "slot", ",", "N", ".", "VOffsetTFlags", ")", "N", ".", "enforce_number", "(", "d", ",", "N", ".", "VOffsetTFlags", ")", "off", "=", "self", ".", ...
GetVOffsetTSlot retrieves the VOffsetT that the given vtable location points to. If the vtable value is zero, the default value `d` will be returned.
[ "GetVOffsetTSlot", "retrieves", "the", "VOffsetT", "that", "the", "given", "vtable", "location", "points", "to", ".", "If", "the", "vtable", "value", "is", "zero", "the", "default", "value", "d", "will", "be", "returned", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/table.py#L116-L129
train
google/flatbuffers
python/flatbuffers/encode.py
GetVectorAsNumpy
def GetVectorAsNumpy(numpy_type, buf, count, offset): """ GetVecAsNumpy decodes values starting at buf[head] as `numpy_type`, where `numpy_type` is a numpy dtype. """ if np is not None: # TODO: could set .flags.writeable = False to make users jump through # hoops before modifying... ...
python
def GetVectorAsNumpy(numpy_type, buf, count, offset): """ GetVecAsNumpy decodes values starting at buf[head] as `numpy_type`, where `numpy_type` is a numpy dtype. """ if np is not None: # TODO: could set .flags.writeable = False to make users jump through # hoops before modifying... ...
[ "def", "GetVectorAsNumpy", "(", "numpy_type", ",", "buf", ",", "count", ",", "offset", ")", ":", "if", "np", "is", "not", "None", ":", "# TODO: could set .flags.writeable = False to make users jump through", "# hoops before modifying...", "return", "np", ".", "fro...
GetVecAsNumpy decodes values starting at buf[head] as `numpy_type`, where `numpy_type` is a numpy dtype.
[ "GetVecAsNumpy", "decodes", "values", "starting", "at", "buf", "[", "head", "]", "as", "numpy_type", "where", "numpy_type", "is", "a", "numpy", "dtype", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/encode.py#L27-L35
train
google/flatbuffers
python/flatbuffers/encode.py
Write
def Write(packer_type, buf, head, n): """ Write encodes `n` at buf[head] using `packer_type`. """ packer_type.pack_into(buf, head, n)
python
def Write(packer_type, buf, head, n): """ Write encodes `n` at buf[head] using `packer_type`. """ packer_type.pack_into(buf, head, n)
[ "def", "Write", "(", "packer_type", ",", "buf", ",", "head", ",", "n", ")", ":", "packer_type", ".", "pack_into", "(", "buf", ",", "head", ",", "n", ")" ]
Write encodes `n` at buf[head] using `packer_type`.
[ "Write", "encodes", "n", "at", "buf", "[", "head", "]", "using", "packer_type", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/encode.py#L38-L40
train
google/flatbuffers
android/jni/run_flatc.py
main
def main(): """Script that finds and runs flatc built from source.""" if len(sys.argv) < 2: sys.stderr.write('Usage: run_flatc.py flatbuffers_dir [flatc_args]\n') return 1 cwd = os.getcwd() flatc = '' flatbuffers_dir = sys.argv[1] for path in FLATC_SEARCH_PATHS: current = os.path.join(flatbuffer...
python
def main(): """Script that finds and runs flatc built from source.""" if len(sys.argv) < 2: sys.stderr.write('Usage: run_flatc.py flatbuffers_dir [flatc_args]\n') return 1 cwd = os.getcwd() flatc = '' flatbuffers_dir = sys.argv[1] for path in FLATC_SEARCH_PATHS: current = os.path.join(flatbuffer...
[ "def", "main", "(", ")", ":", "if", "len", "(", "sys", ".", "argv", ")", "<", "2", ":", "sys", ".", "stderr", ".", "write", "(", "'Usage: run_flatc.py flatbuffers_dir [flatc_args]\\n'", ")", "return", "1", "cwd", "=", "os", ".", "getcwd", "(", ")", "fl...
Script that finds and runs flatc built from source.
[ "Script", "that", "finds", "and", "runs", "flatc", "built", "from", "source", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/android/jni/run_flatc.py#L25-L43
train
google/flatbuffers
python/flatbuffers/compat.py
import_numpy
def import_numpy(): """ Returns the numpy module if it exists on the system, otherwise returns None. """ try: imp.find_module('numpy') numpy_exists = True except ImportError: numpy_exists = False if numpy_exists: # We do this outside of try/except block in ca...
python
def import_numpy(): """ Returns the numpy module if it exists on the system, otherwise returns None. """ try: imp.find_module('numpy') numpy_exists = True except ImportError: numpy_exists = False if numpy_exists: # We do this outside of try/except block in ca...
[ "def", "import_numpy", "(", ")", ":", "try", ":", "imp", ".", "find_module", "(", "'numpy'", ")", "numpy_exists", "=", "True", "except", "ImportError", ":", "numpy_exists", "=", "False", "if", "numpy_exists", ":", "# We do this outside of try/except block in case nu...
Returns the numpy module if it exists on the system, otherwise returns None.
[ "Returns", "the", "numpy", "module", "if", "it", "exists", "on", "the", "system", "otherwise", "returns", "None", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/compat.py#L50-L70
train
google/flatbuffers
python/flatbuffers/builder.py
vtableEqual
def vtableEqual(a, objectStart, b): """vtableEqual compares an unwritten vtable to a written vtable.""" N.enforce_number(objectStart, N.UOffsetTFlags) if len(a) * N.VOffsetTFlags.bytewidth != len(b): return False for i, elem in enumerate(a): x = encode.Get(packer.voffset, b, i * N.VOf...
python
def vtableEqual(a, objectStart, b): """vtableEqual compares an unwritten vtable to a written vtable.""" N.enforce_number(objectStart, N.UOffsetTFlags) if len(a) * N.VOffsetTFlags.bytewidth != len(b): return False for i, elem in enumerate(a): x = encode.Get(packer.voffset, b, i * N.VOf...
[ "def", "vtableEqual", "(", "a", ",", "objectStart", ",", "b", ")", ":", "N", ".", "enforce_number", "(", "objectStart", ",", "N", ".", "UOffsetTFlags", ")", "if", "len", "(", "a", ")", "*", "N", ".", "VOffsetTFlags", ".", "bytewidth", "!=", "len", "(...
vtableEqual compares an unwritten vtable to a written vtable.
[ "vtableEqual", "compares", "an", "unwritten", "vtable", "to", "a", "written", "vtable", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L735-L753
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.StartObject
def StartObject(self, numfields): """StartObject initializes bookkeeping for writing a new object.""" self.assertNotNested() # use 32-bit offsets so that arithmetic doesn't overflow. self.current_vtable = [0 for _ in range_func(numfields)] self.objectEnd = self.Offset() ...
python
def StartObject(self, numfields): """StartObject initializes bookkeeping for writing a new object.""" self.assertNotNested() # use 32-bit offsets so that arithmetic doesn't overflow. self.current_vtable = [0 for _ in range_func(numfields)] self.objectEnd = self.Offset() ...
[ "def", "StartObject", "(", "self", ",", "numfields", ")", ":", "self", ".", "assertNotNested", "(", ")", "# use 32-bit offsets so that arithmetic doesn't overflow.", "self", ".", "current_vtable", "=", "[", "0", "for", "_", "in", "range_func", "(", "numfields", ")...
StartObject initializes bookkeeping for writing a new object.
[ "StartObject", "initializes", "bookkeeping", "for", "writing", "a", "new", "object", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L156-L164
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.WriteVtable
def WriteVtable(self): """ WriteVtable serializes the vtable for the current object, if needed. Before writing out the vtable, this checks pre-existing vtables for equality to this one. If an equal vtable is found, point the object to the existing vtable and return. Bec...
python
def WriteVtable(self): """ WriteVtable serializes the vtable for the current object, if needed. Before writing out the vtable, this checks pre-existing vtables for equality to this one. If an equal vtable is found, point the object to the existing vtable and return. Bec...
[ "def", "WriteVtable", "(", "self", ")", ":", "# Prepend a zero scalar to the object. Later in this function we'll", "# write an offset here that points to the object's vtable:", "self", ".", "PrependSOffsetTRelative", "(", "0", ")", "objectOffset", "=", "self", ".", "Offset", "...
WriteVtable serializes the vtable for the current object, if needed. Before writing out the vtable, this checks pre-existing vtables for equality to this one. If an equal vtable is found, point the object to the existing vtable and return. Because vtable values are sensitive to alignme...
[ "WriteVtable", "serializes", "the", "vtable", "for", "the", "current", "object", "if", "needed", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L166-L273
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.growByteBuffer
def growByteBuffer(self): """Doubles the size of the byteslice, and copies the old data towards the end of the new buffer (since we build the buffer backwards).""" if len(self.Bytes) == Builder.MAX_BUFFER_SIZE: msg = "flatbuffers: cannot grow buffer beyond 2 gigabytes" ...
python
def growByteBuffer(self): """Doubles the size of the byteslice, and copies the old data towards the end of the new buffer (since we build the buffer backwards).""" if len(self.Bytes) == Builder.MAX_BUFFER_SIZE: msg = "flatbuffers: cannot grow buffer beyond 2 gigabytes" ...
[ "def", "growByteBuffer", "(", "self", ")", ":", "if", "len", "(", "self", ".", "Bytes", ")", "==", "Builder", ".", "MAX_BUFFER_SIZE", ":", "msg", "=", "\"flatbuffers: cannot grow buffer beyond 2 gigabytes\"", "raise", "BuilderSizeError", "(", "msg", ")", "newSize"...
Doubles the size of the byteslice, and copies the old data towards the end of the new buffer (since we build the buffer backwards).
[ "Doubles", "the", "size", "of", "the", "byteslice", "and", "copies", "the", "old", "data", "towards", "the", "end", "of", "the", "new", "buffer", "(", "since", "we", "build", "the", "buffer", "backwards", ")", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L281-L293
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.Pad
def Pad(self, n): """Pad places zeros at the current offset.""" for i in range_func(n): self.Place(0, N.Uint8Flags)
python
def Pad(self, n): """Pad places zeros at the current offset.""" for i in range_func(n): self.Place(0, N.Uint8Flags)
[ "def", "Pad", "(", "self", ",", "n", ")", ":", "for", "i", "in", "range_func", "(", "n", ")", ":", "self", ".", "Place", "(", "0", ",", "N", ".", "Uint8Flags", ")" ]
Pad places zeros at the current offset.
[ "Pad", "places", "zeros", "at", "the", "current", "offset", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L311-L314
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.Prep
def Prep(self, size, additionalBytes): """ Prep prepares to write an element of `size` after `additional_bytes` have been written, e.g. if you write a string, you need to align such the int length field is aligned to SizeInt32, and the string data follows it directly. If ...
python
def Prep(self, size, additionalBytes): """ Prep prepares to write an element of `size` after `additional_bytes` have been written, e.g. if you write a string, you need to align such the int length field is aligned to SizeInt32, and the string data follows it directly. If ...
[ "def", "Prep", "(", "self", ",", "size", ",", "additionalBytes", ")", ":", "# Track the biggest thing we've ever aligned to.", "if", "size", ">", "self", ".", "minalign", ":", "self", ".", "minalign", "=", "size", "# Find the amount of alignment needed such that `size` ...
Prep prepares to write an element of `size` after `additional_bytes` have been written, e.g. if you write a string, you need to align such the int length field is aligned to SizeInt32, and the string data follows it directly. If all you need to do is align, `additionalBytes` will be 0.
[ "Prep", "prepares", "to", "write", "an", "element", "of", "size", "after", "additional_bytes", "have", "been", "written", "e", ".", "g", ".", "if", "you", "write", "a", "string", "you", "need", "to", "align", "such", "the", "int", "length", "field", "is"...
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L316-L340
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.PrependSOffsetTRelative
def PrependSOffsetTRelative(self, off): """ PrependSOffsetTRelative prepends an SOffsetT, relative to where it will be written. """ # Ensure alignment is already done: self.Prep(N.SOffsetTFlags.bytewidth, 0) if not (off <= self.Offset()): msg = "flatb...
python
def PrependSOffsetTRelative(self, off): """ PrependSOffsetTRelative prepends an SOffsetT, relative to where it will be written. """ # Ensure alignment is already done: self.Prep(N.SOffsetTFlags.bytewidth, 0) if not (off <= self.Offset()): msg = "flatb...
[ "def", "PrependSOffsetTRelative", "(", "self", ",", "off", ")", ":", "# Ensure alignment is already done:", "self", ".", "Prep", "(", "N", ".", "SOffsetTFlags", ".", "bytewidth", ",", "0", ")", "if", "not", "(", "off", "<=", "self", ".", "Offset", "(", ")"...
PrependSOffsetTRelative prepends an SOffsetT, relative to where it will be written.
[ "PrependSOffsetTRelative", "prepends", "an", "SOffsetT", "relative", "to", "where", "it", "will", "be", "written", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L342-L354
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.PrependUOffsetTRelative
def PrependUOffsetTRelative(self, off): """Prepends an unsigned offset into vector data, relative to where it will be written. """ # Ensure alignment is already done: self.Prep(N.UOffsetTFlags.bytewidth, 0) if not (off <= self.Offset()): msg = "flatbuffers: O...
python
def PrependUOffsetTRelative(self, off): """Prepends an unsigned offset into vector data, relative to where it will be written. """ # Ensure alignment is already done: self.Prep(N.UOffsetTFlags.bytewidth, 0) if not (off <= self.Offset()): msg = "flatbuffers: O...
[ "def", "PrependUOffsetTRelative", "(", "self", ",", "off", ")", ":", "# Ensure alignment is already done:", "self", ".", "Prep", "(", "N", ".", "UOffsetTFlags", ".", "bytewidth", ",", "0", ")", "if", "not", "(", "off", "<=", "self", ".", "Offset", "(", ")"...
Prepends an unsigned offset into vector data, relative to where it will be written.
[ "Prepends", "an", "unsigned", "offset", "into", "vector", "data", "relative", "to", "where", "it", "will", "be", "written", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L357-L368
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.StartVector
def StartVector(self, elemSize, numElems, alignment): """ StartVector initializes bookkeeping for writing a new vector. A vector has the following format: - <UOffsetT: number of elements in this vector> - <T: data>+, where T is the type of elements of this vector. ""...
python
def StartVector(self, elemSize, numElems, alignment): """ StartVector initializes bookkeeping for writing a new vector. A vector has the following format: - <UOffsetT: number of elements in this vector> - <T: data>+, where T is the type of elements of this vector. ""...
[ "def", "StartVector", "(", "self", ",", "elemSize", ",", "numElems", ",", "alignment", ")", ":", "self", ".", "assertNotNested", "(", ")", "self", ".", "nested", "=", "True", "self", ".", "Prep", "(", "N", ".", "Uint32Flags", ".", "bytewidth", ",", "el...
StartVector initializes bookkeeping for writing a new vector. A vector has the following format: - <UOffsetT: number of elements in this vector> - <T: data>+, where T is the type of elements of this vector.
[ "StartVector", "initializes", "bookkeeping", "for", "writing", "a", "new", "vector", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L371-L384
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.EndVector
def EndVector(self, vectorNumElems): """EndVector writes data necessary to finish vector construction.""" self.assertNested() ## @cond FLATBUFFERS_INTERNAL self.nested = False ## @endcond # we already made space for this, so write without PrependUint32 self.Place...
python
def EndVector(self, vectorNumElems): """EndVector writes data necessary to finish vector construction.""" self.assertNested() ## @cond FLATBUFFERS_INTERNAL self.nested = False ## @endcond # we already made space for this, so write without PrependUint32 self.Place...
[ "def", "EndVector", "(", "self", ",", "vectorNumElems", ")", ":", "self", ".", "assertNested", "(", ")", "## @cond FLATBUFFERS_INTERNAL", "self", ".", "nested", "=", "False", "## @endcond", "# we already made space for this, so write without PrependUint32", "self", ".", ...
EndVector writes data necessary to finish vector construction.
[ "EndVector", "writes", "data", "necessary", "to", "finish", "vector", "construction", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L387-L396
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.CreateString
def CreateString(self, s, encoding='utf-8', errors='strict'): """CreateString writes a null-terminated byte string as a vector.""" self.assertNotNested() ## @cond FLATBUFFERS_INTERNAL self.nested = True ## @endcond if isinstance(s, compat.string_types): x = ...
python
def CreateString(self, s, encoding='utf-8', errors='strict'): """CreateString writes a null-terminated byte string as a vector.""" self.assertNotNested() ## @cond FLATBUFFERS_INTERNAL self.nested = True ## @endcond if isinstance(s, compat.string_types): x = ...
[ "def", "CreateString", "(", "self", ",", "s", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "self", ".", "assertNotNested", "(", ")", "## @cond FLATBUFFERS_INTERNAL", "self", ".", "nested", "=", "True", "## @endcond", "if", "isin...
CreateString writes a null-terminated byte string as a vector.
[ "CreateString", "writes", "a", "null", "-", "terminated", "byte", "string", "as", "a", "vector", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L398-L422
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.CreateByteVector
def CreateByteVector(self, x): """CreateString writes a byte vector.""" self.assertNotNested() ## @cond FLATBUFFERS_INTERNAL self.nested = True ## @endcond if not isinstance(x, compat.binary_types): raise TypeError("non-byte vector passed to CreateByteVector...
python
def CreateByteVector(self, x): """CreateString writes a byte vector.""" self.assertNotNested() ## @cond FLATBUFFERS_INTERNAL self.nested = True ## @endcond if not isinstance(x, compat.binary_types): raise TypeError("non-byte vector passed to CreateByteVector...
[ "def", "CreateByteVector", "(", "self", ",", "x", ")", ":", "self", ".", "assertNotNested", "(", ")", "## @cond FLATBUFFERS_INTERNAL", "self", ".", "nested", "=", "True", "## @endcond", "if", "not", "isinstance", "(", "x", ",", "compat", ".", "binary_types", ...
CreateString writes a byte vector.
[ "CreateString", "writes", "a", "byte", "vector", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L424-L443
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.CreateNumpyVector
def CreateNumpyVector(self, x): """CreateNumpyVector writes a numpy array into the buffer.""" if np is None: # Numpy is required for this feature raise NumpyRequiredForThisFeature("Numpy was not found.") if not isinstance(x, np.ndarray): raise TypeError("non...
python
def CreateNumpyVector(self, x): """CreateNumpyVector writes a numpy array into the buffer.""" if np is None: # Numpy is required for this feature raise NumpyRequiredForThisFeature("Numpy was not found.") if not isinstance(x, np.ndarray): raise TypeError("non...
[ "def", "CreateNumpyVector", "(", "self", ",", "x", ")", ":", "if", "np", "is", "None", ":", "# Numpy is required for this feature", "raise", "NumpyRequiredForThisFeature", "(", "\"Numpy was not found.\"", ")", "if", "not", "isinstance", "(", "x", ",", "np", ".", ...
CreateNumpyVector writes a numpy array into the buffer.
[ "CreateNumpyVector", "writes", "a", "numpy", "array", "into", "the", "buffer", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L445-L478
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.assertStructIsInline
def assertStructIsInline(self, obj): """ Structs are always stored inline, so need to be created right where they are used. You'll get this error if you created it elsewhere. """ N.enforce_number(obj, N.UOffsetTFlags) if obj != self.Offset(): msg = ("...
python
def assertStructIsInline(self, obj): """ Structs are always stored inline, so need to be created right where they are used. You'll get this error if you created it elsewhere. """ N.enforce_number(obj, N.UOffsetTFlags) if obj != self.Offset(): msg = ("...
[ "def", "assertStructIsInline", "(", "self", ",", "obj", ")", ":", "N", ".", "enforce_number", "(", "obj", ",", "N", ".", "UOffsetTFlags", ")", "if", "obj", "!=", "self", ".", "Offset", "(", ")", ":", "msg", "=", "(", "\"flatbuffers: Tried to write a Struct...
Structs are always stored inline, so need to be created right where they are used. You'll get this error if you created it elsewhere.
[ "Structs", "are", "always", "stored", "inline", "so", "need", "to", "be", "created", "right", "where", "they", "are", "used", ".", "You", "ll", "get", "this", "error", "if", "you", "created", "it", "elsewhere", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L498-L509
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.Slot
def Slot(self, slotnum): """ Slot sets the vtable key `voffset` to the current location in the buffer. """ self.assertNested() self.current_vtable[slotnum] = self.Offset()
python
def Slot(self, slotnum): """ Slot sets the vtable key `voffset` to the current location in the buffer. """ self.assertNested() self.current_vtable[slotnum] = self.Offset()
[ "def", "Slot", "(", "self", ",", "slotnum", ")", ":", "self", ".", "assertNested", "(", ")", "self", ".", "current_vtable", "[", "slotnum", "]", "=", "self", ".", "Offset", "(", ")" ]
Slot sets the vtable key `voffset` to the current location in the buffer.
[ "Slot", "sets", "the", "vtable", "key", "voffset", "to", "the", "current", "location", "in", "the", "buffer", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L511-L518
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.__Finish
def __Finish(self, rootTable, sizePrefix): """Finish finalizes a buffer, pointing to the given `rootTable`.""" N.enforce_number(rootTable, N.UOffsetTFlags) prepSize = N.UOffsetTFlags.bytewidth if sizePrefix: prepSize += N.Int32Flags.bytewidth self.Prep(self.minalign, ...
python
def __Finish(self, rootTable, sizePrefix): """Finish finalizes a buffer, pointing to the given `rootTable`.""" N.enforce_number(rootTable, N.UOffsetTFlags) prepSize = N.UOffsetTFlags.bytewidth if sizePrefix: prepSize += N.Int32Flags.bytewidth self.Prep(self.minalign, ...
[ "def", "__Finish", "(", "self", ",", "rootTable", ",", "sizePrefix", ")", ":", "N", ".", "enforce_number", "(", "rootTable", ",", "N", ".", "UOffsetTFlags", ")", "prepSize", "=", "N", ".", "UOffsetTFlags", ".", "bytewidth", "if", "sizePrefix", ":", "prepSi...
Finish finalizes a buffer, pointing to the given `rootTable`.
[ "Finish", "finalizes", "a", "buffer", "pointing", "to", "the", "given", "rootTable", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L521-L534
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.PrependUOffsetTRelativeSlot
def PrependUOffsetTRelativeSlot(self, o, x, d): """ PrependUOffsetTRelativeSlot prepends an UOffsetT onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written. """ if x != d: self....
python
def PrependUOffsetTRelativeSlot(self, o, x, d): """ PrependUOffsetTRelativeSlot prepends an UOffsetT onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written. """ if x != d: self....
[ "def", "PrependUOffsetTRelativeSlot", "(", "self", ",", "o", ",", "x", ",", "d", ")", ":", "if", "x", "!=", "d", ":", "self", ".", "PrependUOffsetTRelative", "(", "x", ")", "self", ".", "Slot", "(", "o", ")" ]
PrependUOffsetTRelativeSlot prepends an UOffsetT onto the object at vtable slot `o`. If value `x` equals default `d`, then the slot will be set to zero and no other data will be written.
[ "PrependUOffsetTRelativeSlot", "prepends", "an", "UOffsetT", "onto", "the", "object", "at", "vtable", "slot", "o", ".", "If", "value", "x", "equals", "default", "d", "then", "the", "slot", "will", "be", "set", "to", "zero", "and", "no", "other", "data", "w...
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L585-L594
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.PrependStructSlot
def PrependStructSlot(self, v, x, d): """ PrependStructSlot prepends a struct onto the object at vtable slot `o`. Structs are stored inline, so nothing additional is being added. In generated code, `d` is always 0. """ N.enforce_number(d, N.UOffsetTFlags) if x !=...
python
def PrependStructSlot(self, v, x, d): """ PrependStructSlot prepends a struct onto the object at vtable slot `o`. Structs are stored inline, so nothing additional is being added. In generated code, `d` is always 0. """ N.enforce_number(d, N.UOffsetTFlags) if x !=...
[ "def", "PrependStructSlot", "(", "self", ",", "v", ",", "x", ",", "d", ")", ":", "N", ".", "enforce_number", "(", "d", ",", "N", ".", "UOffsetTFlags", ")", "if", "x", "!=", "d", ":", "self", ".", "assertStructIsInline", "(", "x", ")", "self", ".", ...
PrependStructSlot prepends a struct onto the object at vtable slot `o`. Structs are stored inline, so nothing additional is being added. In generated code, `d` is always 0.
[ "PrependStructSlot", "prepends", "a", "struct", "onto", "the", "object", "at", "vtable", "slot", "o", ".", "Structs", "are", "stored", "inline", "so", "nothing", "additional", "is", "being", "added", ".", "In", "generated", "code", "d", "is", "always", "0", ...
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L596-L606
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.Place
def Place(self, x, flags): """ Place prepends a value specified by `flags` to the Builder, without checking for available space. """ N.enforce_number(x, flags) self.head = self.head - flags.bytewidth encode.Write(flags.packer_type, self.Bytes, self.Head(), x)
python
def Place(self, x, flags): """ Place prepends a value specified by `flags` to the Builder, without checking for available space. """ N.enforce_number(x, flags) self.head = self.head - flags.bytewidth encode.Write(flags.packer_type, self.Bytes, self.Head(), x)
[ "def", "Place", "(", "self", ",", "x", ",", "flags", ")", ":", "N", ".", "enforce_number", "(", "x", ",", "flags", ")", "self", ".", "head", "=", "self", ".", "head", "-", "flags", ".", "bytewidth", "encode", ".", "Write", "(", "flags", ".", "pac...
Place prepends a value specified by `flags` to the Builder, without checking for available space.
[ "Place", "prepends", "a", "value", "specified", "by", "flags", "to", "the", "Builder", "without", "checking", "for", "available", "space", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L699-L707
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.PlaceVOffsetT
def PlaceVOffsetT(self, x): """PlaceVOffsetT prepends a VOffsetT to the Builder, without checking for space. """ N.enforce_number(x, N.VOffsetTFlags) self.head = self.head - N.VOffsetTFlags.bytewidth encode.Write(packer.voffset, self.Bytes, self.Head(), x)
python
def PlaceVOffsetT(self, x): """PlaceVOffsetT prepends a VOffsetT to the Builder, without checking for space. """ N.enforce_number(x, N.VOffsetTFlags) self.head = self.head - N.VOffsetTFlags.bytewidth encode.Write(packer.voffset, self.Bytes, self.Head(), x)
[ "def", "PlaceVOffsetT", "(", "self", ",", "x", ")", ":", "N", ".", "enforce_number", "(", "x", ",", "N", ".", "VOffsetTFlags", ")", "self", ".", "head", "=", "self", ".", "head", "-", "N", ".", "VOffsetTFlags", ".", "bytewidth", "encode", ".", "Write...
PlaceVOffsetT prepends a VOffsetT to the Builder, without checking for space.
[ "PlaceVOffsetT", "prepends", "a", "VOffsetT", "to", "the", "Builder", "without", "checking", "for", "space", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L709-L715
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.PlaceSOffsetT
def PlaceSOffsetT(self, x): """PlaceSOffsetT prepends a SOffsetT to the Builder, without checking for space. """ N.enforce_number(x, N.SOffsetTFlags) self.head = self.head - N.SOffsetTFlags.bytewidth encode.Write(packer.soffset, self.Bytes, self.Head(), x)
python
def PlaceSOffsetT(self, x): """PlaceSOffsetT prepends a SOffsetT to the Builder, without checking for space. """ N.enforce_number(x, N.SOffsetTFlags) self.head = self.head - N.SOffsetTFlags.bytewidth encode.Write(packer.soffset, self.Bytes, self.Head(), x)
[ "def", "PlaceSOffsetT", "(", "self", ",", "x", ")", ":", "N", ".", "enforce_number", "(", "x", ",", "N", ".", "SOffsetTFlags", ")", "self", ".", "head", "=", "self", ".", "head", "-", "N", ".", "SOffsetTFlags", ".", "bytewidth", "encode", ".", "Write...
PlaceSOffsetT prepends a SOffsetT to the Builder, without checking for space.
[ "PlaceSOffsetT", "prepends", "a", "SOffsetT", "to", "the", "Builder", "without", "checking", "for", "space", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L717-L723
train
google/flatbuffers
python/flatbuffers/builder.py
Builder.PlaceUOffsetT
def PlaceUOffsetT(self, x): """PlaceUOffsetT prepends a UOffsetT to the Builder, without checking for space. """ N.enforce_number(x, N.UOffsetTFlags) self.head = self.head - N.UOffsetTFlags.bytewidth encode.Write(packer.uoffset, self.Bytes, self.Head(), x)
python
def PlaceUOffsetT(self, x): """PlaceUOffsetT prepends a UOffsetT to the Builder, without checking for space. """ N.enforce_number(x, N.UOffsetTFlags) self.head = self.head - N.UOffsetTFlags.bytewidth encode.Write(packer.uoffset, self.Bytes, self.Head(), x)
[ "def", "PlaceUOffsetT", "(", "self", ",", "x", ")", ":", "N", ".", "enforce_number", "(", "x", ",", "N", ".", "UOffsetTFlags", ")", "self", ".", "head", "=", "self", ".", "head", "-", "N", ".", "UOffsetTFlags", ".", "bytewidth", "encode", ".", "Write...
PlaceUOffsetT prepends a UOffsetT to the Builder, without checking for space.
[ "PlaceUOffsetT", "prepends", "a", "UOffsetT", "to", "the", "Builder", "without", "checking", "for", "space", "." ]
6cc30b3272d79c85db7d4871ac0aa69541dc89de
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L725-L731
train
pypa/pipenv
pipenv/vendor/appdirs.py
site_data_dir
def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of ...
python
def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of ...
[ "def", "site_data_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "multipath", "=", "False", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "...
r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
[ "r", "Return", "full", "path", "to", "the", "user", "-", "shared", "data", "dir", "for", "this", "application", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/appdirs.py#L100-L163
train
pypa/pipenv
pipenv/vendor/appdirs.py
user_config_dir
def user_config_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name...
python
def user_config_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name...
[ "def", "user_config_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "user_data_dir", ...
r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
[ "r", "Return", "full", "path", "to", "the", "user", "-", "specific", "config", "dir", "for", "this", "application", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/appdirs.py#L166-L203
train
pypa/pipenv
pipenv/vendor/requests/api.py
request
def request(method, url, **kwargs): """Constructs and sends a :class:`Request <Request>`. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary, list of tuples or bytes to send in the body of the :cla...
python
def request(method, url, **kwargs): """Constructs and sends a :class:`Request <Request>`. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary, list of tuples or bytes to send in the body of the :cla...
[ "def", "request", "(", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "# By using the 'with' statement we are sure the session is closed, thus we", "# avoid leaving sockets open which can trigger a ResourceWarning in some", "# cases, and look like a memory leak in others.", "...
Constructs and sends a :class:`Request <Request>`. :param method: method for the new :class:`Request` object. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary, list of tuples or bytes to send in the body of the :class:`Request`. :param data: (optional) D...
[ "Constructs", "and", "sends", "a", ":", "class", ":", "Request", "<Request", ">", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/api.py#L16-L60
train
pypa/pipenv
pipenv/vendor/requests/api.py
get
def get(url, params=None, **kwargs): r"""Sends a GET request. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary, list of tuples or bytes to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return...
python
def get(url, params=None, **kwargs): r"""Sends a GET request. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary, list of tuples or bytes to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return...
[ "def", "get", "(", "url", ",", "params", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'allow_redirects'", ",", "True", ")", "return", "request", "(", "'get'", ",", "url", ",", "params", "=", "params", ",", "*", ...
r"""Sends a GET request. :param url: URL for the new :class:`Request` object. :param params: (optional) Dictionary, list of tuples or bytes to send in the body of the :class:`Request`. :param \*\*kwargs: Optional arguments that ``request`` takes. :return: :class:`Response <Response>` object ...
[ "r", "Sends", "a", "GET", "request", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/api.py#L63-L75
train
pypa/pipenv
pipenv/vendor/toml/encoder.py
dump
def dump(o, f): """Writes out dict as toml to a file Args: o: Object to dump into toml f: File descriptor where the toml should be stored Returns: String containing the toml corresponding to dictionary Raises: TypeError: When anything other than file descriptor is pass...
python
def dump(o, f): """Writes out dict as toml to a file Args: o: Object to dump into toml f: File descriptor where the toml should be stored Returns: String containing the toml corresponding to dictionary Raises: TypeError: When anything other than file descriptor is pass...
[ "def", "dump", "(", "o", ",", "f", ")", ":", "if", "not", "f", ".", "write", ":", "raise", "TypeError", "(", "\"You can only dump an object to a file descriptor\"", ")", "d", "=", "dumps", "(", "o", ")", "f", ".", "write", "(", "d", ")", "return", "d" ...
Writes out dict as toml to a file Args: o: Object to dump into toml f: File descriptor where the toml should be stored Returns: String containing the toml corresponding to dictionary Raises: TypeError: When anything other than file descriptor is passed
[ "Writes", "out", "dict", "as", "toml", "to", "a", "file" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/toml/encoder.py#L11-L29
train
pypa/pipenv
pipenv/vendor/toml/encoder.py
dumps
def dumps(o, encoder=None): """Stringifies input dict as toml Args: o: Object to dump into toml preserve: Boolean parameter. If true, preserve inline tables. Returns: String containing the toml corresponding to dict """ retval = "" if encoder is None: encoder ...
python
def dumps(o, encoder=None): """Stringifies input dict as toml Args: o: Object to dump into toml preserve: Boolean parameter. If true, preserve inline tables. Returns: String containing the toml corresponding to dict """ retval = "" if encoder is None: encoder ...
[ "def", "dumps", "(", "o", ",", "encoder", "=", "None", ")", ":", "retval", "=", "\"\"", "if", "encoder", "is", "None", ":", "encoder", "=", "TomlEncoder", "(", "o", ".", "__class__", ")", "addtoretval", ",", "sections", "=", "encoder", ".", "dump_secti...
Stringifies input dict as toml Args: o: Object to dump into toml preserve: Boolean parameter. If true, preserve inline tables. Returns: String containing the toml corresponding to dict
[ "Stringifies", "input", "dict", "as", "toml" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/toml/encoder.py#L32-L64
train
pypa/pipenv
pipenv/vendor/toml/encoder.py
TomlEncoder.dump_inline_table
def dump_inline_table(self, section): """Preserve inline table in its compact syntax instead of expanding into subsection. https://github.com/toml-lang/toml#user-content-inline-table """ retval = "" if isinstance(section, dict): val_list = [] for ...
python
def dump_inline_table(self, section): """Preserve inline table in its compact syntax instead of expanding into subsection. https://github.com/toml-lang/toml#user-content-inline-table """ retval = "" if isinstance(section, dict): val_list = [] for ...
[ "def", "dump_inline_table", "(", "self", ",", "section", ")", ":", "retval", "=", "\"\"", "if", "isinstance", "(", "section", ",", "dict", ")", ":", "val_list", "=", "[", "]", "for", "k", ",", "v", "in", "section", ".", "items", "(", ")", ":", "val...
Preserve inline table in its compact syntax instead of expanding into subsection. https://github.com/toml-lang/toml#user-content-inline-table
[ "Preserve", "inline", "table", "in", "its", "compact", "syntax", "instead", "of", "expanding", "into", "subsection", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/toml/encoder.py#L137-L152
train
pypa/pipenv
pipenv/environments.py
_is_env_truthy
def _is_env_truthy(name): """An environment variable is truthy if it exists and isn't one of (0, false, no, off) """ if name not in os.environ: return False return os.environ.get(name).lower() not in ("0", "false", "no", "off")
python
def _is_env_truthy(name): """An environment variable is truthy if it exists and isn't one of (0, false, no, off) """ if name not in os.environ: return False return os.environ.get(name).lower() not in ("0", "false", "no", "off")
[ "def", "_is_env_truthy", "(", "name", ")", ":", "if", "name", "not", "in", "os", ".", "environ", ":", "return", "False", "return", "os", ".", "environ", ".", "get", "(", "name", ")", ".", "lower", "(", ")", "not", "in", "(", "\"0\"", ",", "\"false\...
An environment variable is truthy if it exists and isn't one of (0, false, no, off)
[ "An", "environment", "variable", "is", "truthy", "if", "it", "exists", "and", "isn", "t", "one", "of", "(", "0", "false", "no", "off", ")" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environments.py#L17-L22
train
pypa/pipenv
pipenv/environments.py
is_in_virtualenv
def is_in_virtualenv(): """ Check virtualenv membership dynamically :return: True or false depending on whether we are in a regular virtualenv or not :rtype: bool """ pipenv_active = os.environ.get("PIPENV_ACTIVE", False) virtual_env = None use_system = False ignore_virtualenvs = b...
python
def is_in_virtualenv(): """ Check virtualenv membership dynamically :return: True or false depending on whether we are in a regular virtualenv or not :rtype: bool """ pipenv_active = os.environ.get("PIPENV_ACTIVE", False) virtual_env = None use_system = False ignore_virtualenvs = b...
[ "def", "is_in_virtualenv", "(", ")", ":", "pipenv_active", "=", "os", ".", "environ", ".", "get", "(", "\"PIPENV_ACTIVE\"", ",", "False", ")", "virtual_env", "=", "None", "use_system", "=", "False", "ignore_virtualenvs", "=", "bool", "(", "os", ".", "environ...
Check virtualenv membership dynamically :return: True or false depending on whether we are in a regular virtualenv or not :rtype: bool
[ "Check", "virtualenv", "membership", "dynamically" ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/environments.py#L293-L309
train
pypa/pipenv
pipenv/patched/notpip/_vendor/msgpack/fallback.py
unpackb
def unpackb(packed, **kwargs): """ Unpack an object from `packed`. Raises `ExtraData` when `packed` contains extra bytes. See :class:`Unpacker` for options. """ unpacker = Unpacker(None, **kwargs) unpacker.feed(packed) try: ret = unpacker._unpack() except OutOfData: ...
python
def unpackb(packed, **kwargs): """ Unpack an object from `packed`. Raises `ExtraData` when `packed` contains extra bytes. See :class:`Unpacker` for options. """ unpacker = Unpacker(None, **kwargs) unpacker.feed(packed) try: ret = unpacker._unpack() except OutOfData: ...
[ "def", "unpackb", "(", "packed", ",", "*", "*", "kwargs", ")", ":", "unpacker", "=", "Unpacker", "(", "None", ",", "*", "*", "kwargs", ")", "unpacker", ".", "feed", "(", "packed", ")", "try", ":", "ret", "=", "unpacker", ".", "_unpack", "(", ")", ...
Unpack an object from `packed`. Raises `ExtraData` when `packed` contains extra bytes. See :class:`Unpacker` for options.
[ "Unpack", "an", "object", "from", "packed", "." ]
cae8d76c210b9777e90aab76e9c4b0e53bb19cde
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/msgpack/fallback.py#L111-L126
train