id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
30,200
tensorflow/hub
tensorflow_hub/saved_model_lib.py
SavedModelHandler.add_graph_copy
def add_graph_copy(self, graph, tags=None): """Adds a copy of Graph with the specified set of tags.""" with graph.as_default(): # Remove default attrs so that Modules created by a tensorflow version # with ops that have new attrs that are left to their default values can # still be loaded by o...
python
def add_graph_copy(self, graph, tags=None): """Adds a copy of Graph with the specified set of tags.""" with graph.as_default(): # Remove default attrs so that Modules created by a tensorflow version # with ops that have new attrs that are left to their default values can # still be loaded by o...
[ "def", "add_graph_copy", "(", "self", ",", "graph", ",", "tags", "=", "None", ")", ":", "with", "graph", ".", "as_default", "(", ")", ":", "# Remove default attrs so that Modules created by a tensorflow version", "# with ops that have new attrs that are left to their default ...
Adds a copy of Graph with the specified set of tags.
[ "Adds", "a", "copy", "of", "Graph", "with", "the", "specified", "set", "of", "tags", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/saved_model_lib.py#L357-L367
30,201
tensorflow/hub
tensorflow_hub/saved_model_lib.py
SavedModelHandler.get_meta_graph_copy
def get_meta_graph_copy(self, tags=None): """Returns a copy of a MetaGraph with the identical set of tags.""" meta_graph = self.get_meta_graph(tags) copy = tf_v1.MetaGraphDef() copy.CopyFrom(meta_graph) return copy
python
def get_meta_graph_copy(self, tags=None): """Returns a copy of a MetaGraph with the identical set of tags.""" meta_graph = self.get_meta_graph(tags) copy = tf_v1.MetaGraphDef() copy.CopyFrom(meta_graph) return copy
[ "def", "get_meta_graph_copy", "(", "self", ",", "tags", "=", "None", ")", ":", "meta_graph", "=", "self", ".", "get_meta_graph", "(", "tags", ")", "copy", "=", "tf_v1", ".", "MetaGraphDef", "(", ")", "copy", ".", "CopyFrom", "(", "meta_graph", ")", "retu...
Returns a copy of a MetaGraph with the identical set of tags.
[ "Returns", "a", "copy", "of", "a", "MetaGraph", "with", "the", "identical", "set", "of", "tags", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/saved_model_lib.py#L372-L377
30,202
tensorflow/hub
tensorflow_hub/saved_model_lib.py
SavedModelHandler.get_tags
def get_tags(self): """Returns a list of set of tags.""" return sorted([frozenset(meta_graph.meta_info_def.tags) for meta_graph in self.meta_graphs])
python
def get_tags(self): """Returns a list of set of tags.""" return sorted([frozenset(meta_graph.meta_info_def.tags) for meta_graph in self.meta_graphs])
[ "def", "get_tags", "(", "self", ")", ":", "return", "sorted", "(", "[", "frozenset", "(", "meta_graph", ".", "meta_info_def", ".", "tags", ")", "for", "meta_graph", "in", "self", ".", "meta_graphs", "]", ")" ]
Returns a list of set of tags.
[ "Returns", "a", "list", "of", "set", "of", "tags", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/saved_model_lib.py#L383-L386
30,203
tensorflow/hub
tensorflow_hub/saved_model_lib.py
SavedModelHandler.export
def export(self, path, variables_saver=None): """Exports to SavedModel directory. Args: path: path where to export the SavedModel to. variables_saver: lambda that receives a directory path where to export checkpoints of variables. """ # Operate on a copy of self._proto since it need...
python
def export(self, path, variables_saver=None): """Exports to SavedModel directory. Args: path: path where to export the SavedModel to. variables_saver: lambda that receives a directory path where to export checkpoints of variables. """ # Operate on a copy of self._proto since it need...
[ "def", "export", "(", "self", ",", "path", ",", "variables_saver", "=", "None", ")", ":", "# Operate on a copy of self._proto since it needs to be modified.", "proto", "=", "saved_model_pb2", ".", "SavedModel", "(", ")", "proto", ".", "CopyFrom", "(", "self", ".", ...
Exports to SavedModel directory. Args: path: path where to export the SavedModel to. variables_saver: lambda that receives a directory path where to export checkpoints of variables.
[ "Exports", "to", "SavedModel", "directory", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/saved_model_lib.py#L391-L406
30,204
tensorflow/hub
tensorflow_hub/saved_model_lib.py
SavedModelHandler.get_meta_graph
def get_meta_graph(self, tags=None): """Returns the matching MetaGraphDef or raises KeyError.""" matches = [meta_graph for meta_graph in self.meta_graphs if set(meta_graph.meta_info_def.tags) == set(tags or [])] if not matches: raise KeyError("SavedModelHandler has no gra...
python
def get_meta_graph(self, tags=None): """Returns the matching MetaGraphDef or raises KeyError.""" matches = [meta_graph for meta_graph in self.meta_graphs if set(meta_graph.meta_info_def.tags) == set(tags or [])] if not matches: raise KeyError("SavedModelHandler has no gra...
[ "def", "get_meta_graph", "(", "self", ",", "tags", "=", "None", ")", ":", "matches", "=", "[", "meta_graph", "for", "meta_graph", "in", "self", ".", "meta_graphs", "if", "set", "(", "meta_graph", ".", "meta_info_def", ".", "tags", ")", "==", "set", "(", ...
Returns the matching MetaGraphDef or raises KeyError.
[ "Returns", "the", "matching", "MetaGraphDef", "or", "raises", "KeyError", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/saved_model_lib.py#L408-L418
30,205
tensorflow/hub
tensorflow_hub/module.py
_convert_dict_inputs
def _convert_dict_inputs(inputs, tensor_info_map): """Converts from inputs into dict of input tensors. This handles: - putting inputs into a dict, per _prepare_dict_inputs(), - converting all input values into tensors compatible with the expected input tensor (dtype, shape). - check sparse/non-sp...
python
def _convert_dict_inputs(inputs, tensor_info_map): """Converts from inputs into dict of input tensors. This handles: - putting inputs into a dict, per _prepare_dict_inputs(), - converting all input values into tensors compatible with the expected input tensor (dtype, shape). - check sparse/non-sp...
[ "def", "_convert_dict_inputs", "(", "inputs", ",", "tensor_info_map", ")", ":", "dict_inputs", "=", "_prepare_dict_inputs", "(", "inputs", ",", "tensor_info_map", ")", "return", "tensor_info", ".", "convert_dict_to_compatible_tensor", "(", "dict_inputs", ",", "tensor_in...
Converts from inputs into dict of input tensors. This handles: - putting inputs into a dict, per _prepare_dict_inputs(), - converting all input values into tensors compatible with the expected input tensor (dtype, shape). - check sparse/non-sparse tensor types. Args: inputs: inputs fed to Mo...
[ "Converts", "from", "inputs", "into", "dict", "of", "input", "tensors", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/module.py#L424-L447
30,206
tensorflow/hub
tensorflow_hub/module.py
eval_function_for_module
def eval_function_for_module(spec, tags=None): """Context manager that yields a function to directly evaluate a Module. This creates a separate graph, in which all of the signatures of the module are instantiated. Then, it creates a session and initializes the module variables. Finally, it returns a function w...
python
def eval_function_for_module(spec, tags=None): """Context manager that yields a function to directly evaluate a Module. This creates a separate graph, in which all of the signatures of the module are instantiated. Then, it creates a session and initializes the module variables. Finally, it returns a function w...
[ "def", "eval_function_for_module", "(", "spec", ",", "tags", "=", "None", ")", ":", "# We create a separate graph and add all the signatures of the module to it.", "original_graph", "=", "tf_v1", ".", "get_default_graph", "(", ")", "with", "tf", ".", "Graph", "(", ")", ...
Context manager that yields a function to directly evaluate a Module. This creates a separate graph, in which all of the signatures of the module are instantiated. Then, it creates a session and initializes the module variables. Finally, it returns a function which can be used to evaluate the module signatures...
[ "Context", "manager", "that", "yields", "a", "function", "to", "directly", "evaluate", "a", "Module", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/module.py#L474-L559
30,207
tensorflow/hub
tensorflow_hub/module.py
Module.get_input_info_dict
def get_input_info_dict(self, signature=None): """Describes the inputs required by a signature. Args: signature: A string with the signature to get inputs information for. If None, the default signature is used if defined. Returns: The result of ModuleSpec.get_input_info_dict() for the...
python
def get_input_info_dict(self, signature=None): """Describes the inputs required by a signature. Args: signature: A string with the signature to get inputs information for. If None, the default signature is used if defined. Returns: The result of ModuleSpec.get_input_info_dict() for the...
[ "def", "get_input_info_dict", "(", "self", ",", "signature", "=", "None", ")", ":", "return", "self", ".", "_spec", ".", "get_input_info_dict", "(", "signature", "=", "signature", ",", "tags", "=", "self", ".", "_tags", ")" ]
Describes the inputs required by a signature. Args: signature: A string with the signature to get inputs information for. If None, the default signature is used if defined. Returns: The result of ModuleSpec.get_input_info_dict() for the given signature, and the graph variant selected...
[ "Describes", "the", "inputs", "required", "by", "a", "signature", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/module.py#L257-L271
30,208
tensorflow/hub
tensorflow_hub/module.py
Module.get_output_info_dict
def get_output_info_dict(self, signature=None): """Describes the outputs provided by a signature. Args: signature: A string with the signature to get ouputs information for. If None, the default signature is used if defined. Returns: The result of ModuleSpec.get_output_info_dict() for ...
python
def get_output_info_dict(self, signature=None): """Describes the outputs provided by a signature. Args: signature: A string with the signature to get ouputs information for. If None, the default signature is used if defined. Returns: The result of ModuleSpec.get_output_info_dict() for ...
[ "def", "get_output_info_dict", "(", "self", ",", "signature", "=", "None", ")", ":", "return", "self", ".", "_spec", ".", "get_output_info_dict", "(", "signature", "=", "signature", ",", "tags", "=", "self", ".", "_tags", ")" ]
Describes the outputs provided by a signature. Args: signature: A string with the signature to get ouputs information for. If None, the default signature is used if defined. Returns: The result of ModuleSpec.get_output_info_dict() for the given signature, and the graph variant select...
[ "Describes", "the", "outputs", "provided", "by", "a", "signature", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/module.py#L273-L287
30,209
tensorflow/hub
tensorflow_hub/module.py
Module.export
def export(self, path, session): """Exports the module with the variables from the session in `path`. Note that it is the module definition in the ModuleSpec used to create this module that gets exported. The session is only used to provide the value of variables. Args: path: path where to e...
python
def export(self, path, session): """Exports the module with the variables from the session in `path`. Note that it is the module definition in the ModuleSpec used to create this module that gets exported. The session is only used to provide the value of variables. Args: path: path where to e...
[ "def", "export", "(", "self", ",", "path", ",", "session", ")", ":", "if", "self", ".", "_graph", "is", "not", "tf_v1", ".", "get_default_graph", "(", ")", ":", "raise", "RuntimeError", "(", "\"default graph differs from the graph where the \"", "\"module was inst...
Exports the module with the variables from the session in `path`. Note that it is the module definition in the ModuleSpec used to create this module that gets exported. The session is only used to provide the value of variables. Args: path: path where to export the module to. session: sess...
[ "Exports", "the", "module", "with", "the", "variables", "from", "the", "session", "in", "path", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/module.py#L294-L314
30,210
tensorflow/hub
tensorflow_hub/module.py
Module.variables
def variables(self): """Returns the list of all tf.Variables created by module instantiation.""" result = [] for _, value in sorted(self.variable_map.items()): if isinstance(value, list): result.extend(value) else: result.append(value) return result
python
def variables(self): """Returns the list of all tf.Variables created by module instantiation.""" result = [] for _, value in sorted(self.variable_map.items()): if isinstance(value, list): result.extend(value) else: result.append(value) return result
[ "def", "variables", "(", "self", ")", ":", "result", "=", "[", "]", "for", "_", ",", "value", "in", "sorted", "(", "self", ".", "variable_map", ".", "items", "(", ")", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "result", "...
Returns the list of all tf.Variables created by module instantiation.
[ "Returns", "the", "list", "of", "all", "tf", ".", "Variables", "created", "by", "module", "instantiation", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/module.py#L341-L349
30,211
tensorflow/hub
tensorflow_hub/feature_column.py
text_embedding_column
def text_embedding_column(key, module_spec, trainable=False): """Uses a Module to construct a dense representation from a text feature. This feature column can be used on an input feature whose values are strings of arbitrary size. The result of this feature column is the result of passing its `input` throu...
python
def text_embedding_column(key, module_spec, trainable=False): """Uses a Module to construct a dense representation from a text feature. This feature column can be used on an input feature whose values are strings of arbitrary size. The result of this feature column is the result of passing its `input` throu...
[ "def", "text_embedding_column", "(", "key", ",", "module_spec", ",", "trainable", "=", "False", ")", ":", "module_spec", "=", "module", ".", "as_module_spec", "(", "module_spec", ")", "_check_module_is_text_embedding", "(", "module_spec", ")", "return", "_TextEmbedd...
Uses a Module to construct a dense representation from a text feature. This feature column can be used on an input feature whose values are strings of arbitrary size. The result of this feature column is the result of passing its `input` through the module `m` instantiated from `module_spec`, as per `result...
[ "Uses", "a", "Module", "to", "construct", "a", "dense", "representation", "from", "a", "text", "feature", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/feature_column.py#L33-L80
30,212
tensorflow/hub
tensorflow_hub/feature_column.py
_check_module_is_text_embedding
def _check_module_is_text_embedding(module_spec): """Raises ValueError if `module_spec` is not a text-embedding module. Args: module_spec: A `ModuleSpec` to test. Raises: ValueError: if `module_spec` default signature is not compatible with Tensor(string, shape=(?,)) -> Tensor(float32, shape=(?,K))....
python
def _check_module_is_text_embedding(module_spec): """Raises ValueError if `module_spec` is not a text-embedding module. Args: module_spec: A `ModuleSpec` to test. Raises: ValueError: if `module_spec` default signature is not compatible with Tensor(string, shape=(?,)) -> Tensor(float32, shape=(?,K))....
[ "def", "_check_module_is_text_embedding", "(", "module_spec", ")", ":", "issues", "=", "[", "]", "# Find issues with signature inputs.", "input_info_dict", "=", "module_spec", ".", "get_input_info_dict", "(", ")", "if", "len", "(", "input_info_dict", ")", "!=", "1", ...
Raises ValueError if `module_spec` is not a text-embedding module. Args: module_spec: A `ModuleSpec` to test. Raises: ValueError: if `module_spec` default signature is not compatible with Tensor(string, shape=(?,)) -> Tensor(float32, shape=(?,K)).
[ "Raises", "ValueError", "if", "module_spec", "is", "not", "a", "text", "-", "embedding", "module", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/feature_column.py#L83-L124
30,213
tensorflow/hub
tensorflow_hub/feature_column.py
image_embedding_column
def image_embedding_column(key, module_spec): """Uses a Module to get a dense 1-D representation from the pixels of images. This feature column can be used on images, represented as float32 tensors of RGB pixel data in the range [0,1]. This can be read from a numeric_column() if the tf.Example input data happe...
python
def image_embedding_column(key, module_spec): """Uses a Module to get a dense 1-D representation from the pixels of images. This feature column can be used on images, represented as float32 tensors of RGB pixel data in the range [0,1]. This can be read from a numeric_column() if the tf.Example input data happe...
[ "def", "image_embedding_column", "(", "key", ",", "module_spec", ")", ":", "module_spec", "=", "module", ".", "as_module_spec", "(", "module_spec", ")", "_check_module_is_image_embedding", "(", "module_spec", ")", "return", "_ImageEmbeddingColumn", "(", "key", "=", ...
Uses a Module to get a dense 1-D representation from the pixels of images. This feature column can be used on images, represented as float32 tensors of RGB pixel data in the range [0,1]. This can be read from a numeric_column() if the tf.Example input data happens to have decoded images, all with the same shap...
[ "Uses", "a", "Module", "to", "get", "a", "dense", "1", "-", "D", "representation", "from", "the", "pixels", "of", "images", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/feature_column.py#L162-L201
30,214
tensorflow/hub
tensorflow_hub/feature_column.py
_check_module_is_image_embedding
def _check_module_is_image_embedding(module_spec): """Raises ValueError if `module_spec` is not usable as image embedding. Args: module_spec: A `_ModuleSpec` to test. Raises: ValueError: if `module_spec` default signature is not compatible with mappingan "images" input to a Tensor(float32, shape...
python
def _check_module_is_image_embedding(module_spec): """Raises ValueError if `module_spec` is not usable as image embedding. Args: module_spec: A `_ModuleSpec` to test. Raises: ValueError: if `module_spec` default signature is not compatible with mappingan "images" input to a Tensor(float32, shape...
[ "def", "_check_module_is_image_embedding", "(", "module_spec", ")", ":", "issues", "=", "[", "]", "# Find issues with \"default\" signature inputs. The common signatures for", "# image models prescribe a specific name; we trust it if we find it", "# and if we can do the necessary inference o...
Raises ValueError if `module_spec` is not usable as image embedding. Args: module_spec: A `_ModuleSpec` to test. Raises: ValueError: if `module_spec` default signature is not compatible with mappingan "images" input to a Tensor(float32, shape=(_,K)).
[ "Raises", "ValueError", "if", "module_spec", "is", "not", "usable", "as", "image", "embedding", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/feature_column.py#L204-L245
30,215
tensorflow/hub
tensorflow_hub/feature_column.py
_TextEmbeddingColumn.name
def name(self): """Returns string. Used for variable_scope and naming.""" if not hasattr(self, "_name"): self._name = "{}_hub_module_embedding".format(self.key) return self._name
python
def name(self): """Returns string. Used for variable_scope and naming.""" if not hasattr(self, "_name"): self._name = "{}_hub_module_embedding".format(self.key) return self._name
[ "def", "name", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"_name\"", ")", ":", "self", ".", "_name", "=", "\"{}_hub_module_embedding\"", ".", "format", "(", "self", ".", "key", ")", "return", "self", ".", "_name" ]
Returns string. Used for variable_scope and naming.
[ "Returns", "string", ".", "Used", "for", "variable_scope", "and", "naming", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/feature_column.py#L134-L138
30,216
tensorflow/hub
tensorflow_hub/feature_column.py
_TextEmbeddingColumn._get_dense_tensor
def _get_dense_tensor(self, inputs, weight_collections=None, trainable=None): """Returns a `Tensor`.""" del weight_collections text_batch = tf.reshape(inputs.get(self), shape=[-1]) m = module.Module(self.module_spec, trainable=self.trainable and trainable) return m(text_batch)
python
def _get_dense_tensor(self, inputs, weight_collections=None, trainable=None): """Returns a `Tensor`.""" del weight_collections text_batch = tf.reshape(inputs.get(self), shape=[-1]) m = module.Module(self.module_spec, trainable=self.trainable and trainable) return m(text_batch)
[ "def", "_get_dense_tensor", "(", "self", ",", "inputs", ",", "weight_collections", "=", "None", ",", "trainable", "=", "None", ")", ":", "del", "weight_collections", "text_batch", "=", "tf", ".", "reshape", "(", "inputs", ".", "get", "(", "self", ")", ",",...
Returns a `Tensor`.
[ "Returns", "a", "Tensor", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/feature_column.py#L154-L159
30,217
tensorflow/hub
tensorflow_hub/feature_column.py
_ImageEmbeddingColumn._parse_example_spec
def _parse_example_spec(self): """Returns a `tf.Example` parsing spec as dict.""" height, width = image_util.get_expected_image_size(self.module_spec) input_shape = [height, width, 3] return {self.key: tf_v1.FixedLenFeature(input_shape, tf.float32)}
python
def _parse_example_spec(self): """Returns a `tf.Example` parsing spec as dict.""" height, width = image_util.get_expected_image_size(self.module_spec) input_shape = [height, width, 3] return {self.key: tf_v1.FixedLenFeature(input_shape, tf.float32)}
[ "def", "_parse_example_spec", "(", "self", ")", ":", "height", ",", "width", "=", "image_util", ".", "get_expected_image_size", "(", "self", ".", "module_spec", ")", "input_shape", "=", "[", "height", ",", "width", ",", "3", "]", "return", "{", "self", "."...
Returns a `tf.Example` parsing spec as dict.
[ "Returns", "a", "tf", ".", "Example", "parsing", "spec", "as", "dict", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/feature_column.py#L265-L269
30,218
tensorflow/hub
tensorflow_hub/resolver.py
tfhub_cache_dir
def tfhub_cache_dir(default_cache_dir=None, use_temp=False): """Returns cache directory. Returns cache directory from either TFHUB_CACHE_DIR environment variable or --tfhub_cache_dir or default, if set. Args: default_cache_dir: Default cache location to use if neither TFHUB_CACHE_DIR ...
python
def tfhub_cache_dir(default_cache_dir=None, use_temp=False): """Returns cache directory. Returns cache directory from either TFHUB_CACHE_DIR environment variable or --tfhub_cache_dir or default, if set. Args: default_cache_dir: Default cache location to use if neither TFHUB_CACHE_DIR ...
[ "def", "tfhub_cache_dir", "(", "default_cache_dir", "=", "None", ",", "use_temp", "=", "False", ")", ":", "# Note: We are using FLAGS[\"tfhub_cache_dir\"] (and not FLAGS.tfhub_cache_dir)", "# to access the flag value in order to avoid parsing argv list. The flags", "# should have been pa...
Returns cache directory. Returns cache directory from either TFHUB_CACHE_DIR environment variable or --tfhub_cache_dir or default, if set. Args: default_cache_dir: Default cache location to use if neither TFHUB_CACHE_DIR environment variable nor --tfhub_cache_dir are ...
[ "Returns", "cache", "directory", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/resolver.py#L50-L80
30,219
tensorflow/hub
tensorflow_hub/resolver.py
create_local_module_dir
def create_local_module_dir(cache_dir, module_name): """Creates and returns the name of directory where to cache a module.""" tf_v1.gfile.MakeDirs(cache_dir) return os.path.join(cache_dir, module_name)
python
def create_local_module_dir(cache_dir, module_name): """Creates and returns the name of directory where to cache a module.""" tf_v1.gfile.MakeDirs(cache_dir) return os.path.join(cache_dir, module_name)
[ "def", "create_local_module_dir", "(", "cache_dir", ",", "module_name", ")", ":", "tf_v1", ".", "gfile", ".", "MakeDirs", "(", "cache_dir", ")", "return", "os", ".", "path", ".", "join", "(", "cache_dir", ",", "module_name", ")" ]
Creates and returns the name of directory where to cache a module.
[ "Creates", "and", "returns", "the", "name", "of", "directory", "where", "to", "cache", "a", "module", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/resolver.py#L83-L86
30,220
tensorflow/hub
tensorflow_hub/resolver.py
_write_module_descriptor_file
def _write_module_descriptor_file(handle, module_dir): """Writes a descriptor file about the directory containing a module. Args: handle: Module name/handle. module_dir: Directory where a module was downloaded. """ readme = _module_descriptor_file(module_dir) readme_content = ( "Module: %s\nDow...
python
def _write_module_descriptor_file(handle, module_dir): """Writes a descriptor file about the directory containing a module. Args: handle: Module name/handle. module_dir: Directory where a module was downloaded. """ readme = _module_descriptor_file(module_dir) readme_content = ( "Module: %s\nDow...
[ "def", "_write_module_descriptor_file", "(", "handle", ",", "module_dir", ")", ":", "readme", "=", "_module_descriptor_file", "(", "module_dir", ")", "readme_content", "=", "(", "\"Module: %s\\nDownload Time: %s\\nDownloader Hostname: %s (PID:%d)\"", "%", "(", "handle", ","...
Writes a descriptor file about the directory containing a module. Args: handle: Module name/handle. module_dir: Directory where a module was downloaded.
[ "Writes", "a", "descriptor", "file", "about", "the", "directory", "containing", "a", "module", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/resolver.py#L219-L234
30,221
tensorflow/hub
tensorflow_hub/resolver.py
_locked_tmp_dir_size
def _locked_tmp_dir_size(lock_filename): """Returns the size of the temp dir pointed to by the given lock file.""" task_uid = _task_uid_from_lock_file(lock_filename) try: return _dir_size( _temp_download_dir(_module_dir(lock_filename), task_uid)) except tf.errors.NotFoundError: return 0
python
def _locked_tmp_dir_size(lock_filename): """Returns the size of the temp dir pointed to by the given lock file.""" task_uid = _task_uid_from_lock_file(lock_filename) try: return _dir_size( _temp_download_dir(_module_dir(lock_filename), task_uid)) except tf.errors.NotFoundError: return 0
[ "def", "_locked_tmp_dir_size", "(", "lock_filename", ")", ":", "task_uid", "=", "_task_uid_from_lock_file", "(", "lock_filename", ")", "try", ":", "return", "_dir_size", "(", "_temp_download_dir", "(", "_module_dir", "(", "lock_filename", ")", ",", "task_uid", ")", ...
Returns the size of the temp dir pointed to by the given lock file.
[ "Returns", "the", "size", "of", "the", "temp", "dir", "pointed", "to", "by", "the", "given", "lock", "file", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/resolver.py#L283-L290
30,222
tensorflow/hub
tensorflow_hub/resolver.py
_wait_for_lock_to_disappear
def _wait_for_lock_to_disappear(handle, lock_file, lock_file_timeout_sec): """Waits for the lock file to disappear. The lock file was created by another process that is performing a download into its own temporary directory. The name of this temp directory is sha1(<module>).<uuid>.tmp where <uuid> comes from t...
python
def _wait_for_lock_to_disappear(handle, lock_file, lock_file_timeout_sec): """Waits for the lock file to disappear. The lock file was created by another process that is performing a download into its own temporary directory. The name of this temp directory is sha1(<module>).<uuid>.tmp where <uuid> comes from t...
[ "def", "_wait_for_lock_to_disappear", "(", "handle", ",", "lock_file", ",", "lock_file_timeout_sec", ")", ":", "locked_tmp_dir_size", "=", "0", "locked_tmp_dir_size_check_time", "=", "time", ".", "time", "(", ")", "lock_file_content", "=", "None", "while", "tf_v1", ...
Waits for the lock file to disappear. The lock file was created by another process that is performing a download into its own temporary directory. The name of this temp directory is sha1(<module>).<uuid>.tmp where <uuid> comes from the lock file. Args: handle: The location from where a module is being dow...
[ "Waits", "for", "the", "lock", "file", "to", "disappear", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/resolver.py#L293-L342
30,223
tensorflow/hub
tensorflow_hub/resolver.py
atomic_download
def atomic_download(handle, download_fn, module_dir, lock_file_timeout_sec=10 * 60): """Returns the path to a Module directory for a given TF-Hub Module handle. Args: handle: (string) Location of a TF-Hub Module. download_fn: Callback function tha...
python
def atomic_download(handle, download_fn, module_dir, lock_file_timeout_sec=10 * 60): """Returns the path to a Module directory for a given TF-Hub Module handle. Args: handle: (string) Location of a TF-Hub Module. download_fn: Callback function tha...
[ "def", "atomic_download", "(", "handle", ",", "download_fn", ",", "module_dir", ",", "lock_file_timeout_sec", "=", "10", "*", "60", ")", ":", "lock_file", "=", "_lock_filename", "(", "module_dir", ")", "task_uid", "=", "uuid", ".", "uuid4", "(", ")", ".", ...
Returns the path to a Module directory for a given TF-Hub Module handle. Args: handle: (string) Location of a TF-Hub Module. download_fn: Callback function that actually performs download. The callback receives two arguments, handle and the location of a temporary directory ...
[ "Returns", "the", "path", "to", "a", "Module", "directory", "for", "a", "given", "TF", "-", "Hub", "Module", "handle", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/resolver.py#L345-L434
30,224
tensorflow/hub
tensorflow_hub/resolver.py
DownloadManager._print_download_progress_msg
def _print_download_progress_msg(self, msg, flush=False): """Prints a message about download progress either to the console or TF log. Args: msg: Message to print. flush: Indicates whether to flush the output (only used in interactive mode). """ if self._interactive_mode(): ...
python
def _print_download_progress_msg(self, msg, flush=False): """Prints a message about download progress either to the console or TF log. Args: msg: Message to print. flush: Indicates whether to flush the output (only used in interactive mode). """ if self._interactive_mode(): ...
[ "def", "_print_download_progress_msg", "(", "self", ",", "msg", ",", "flush", "=", "False", ")", ":", "if", "self", ".", "_interactive_mode", "(", ")", ":", "# Print progress message to console overwriting previous progress", "# message.", "self", ".", "_max_prog_str", ...
Prints a message about download progress either to the console or TF log. Args: msg: Message to print. flush: Indicates whether to flush the output (only used in interactive mode).
[ "Prints", "a", "message", "about", "download", "progress", "either", "to", "the", "console", "or", "TF", "log", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/resolver.py#L103-L122
30,225
tensorflow/hub
tensorflow_hub/resolver.py
DownloadManager._log_progress
def _log_progress(self, bytes_downloaded): """Logs progress information about ongoing module download. Args: bytes_downloaded: Number of bytes downloaded. """ self._total_bytes_downloaded += bytes_downloaded now = time.time() if (self._interactive_mode() or now - self._last_progre...
python
def _log_progress(self, bytes_downloaded): """Logs progress information about ongoing module download. Args: bytes_downloaded: Number of bytes downloaded. """ self._total_bytes_downloaded += bytes_downloaded now = time.time() if (self._interactive_mode() or now - self._last_progre...
[ "def", "_log_progress", "(", "self", ",", "bytes_downloaded", ")", ":", "self", ".", "_total_bytes_downloaded", "+=", "bytes_downloaded", "now", "=", "time", ".", "time", "(", ")", "if", "(", "self", ".", "_interactive_mode", "(", ")", "or", "now", "-", "s...
Logs progress information about ongoing module download. Args: bytes_downloaded: Number of bytes downloaded.
[ "Logs", "progress", "information", "about", "ongoing", "module", "download", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/resolver.py#L124-L140
30,226
tensorflow/hub
tensorflow_hub/resolver.py
DownloadManager._extract_file
def _extract_file(self, tgz, tarinfo, dst_path, buffer_size=10<<20): """Extracts 'tarinfo' from 'tgz' and writes to 'dst_path'.""" src = tgz.extractfile(tarinfo) dst = tf_v1.gfile.GFile(dst_path, "wb") while 1: buf = src.read(buffer_size) if not buf: break dst.write(buf) ...
python
def _extract_file(self, tgz, tarinfo, dst_path, buffer_size=10<<20): """Extracts 'tarinfo' from 'tgz' and writes to 'dst_path'.""" src = tgz.extractfile(tarinfo) dst = tf_v1.gfile.GFile(dst_path, "wb") while 1: buf = src.read(buffer_size) if not buf: break dst.write(buf) ...
[ "def", "_extract_file", "(", "self", ",", "tgz", ",", "tarinfo", ",", "dst_path", ",", "buffer_size", "=", "10", "<<", "20", ")", ":", "src", "=", "tgz", ".", "extractfile", "(", "tarinfo", ")", "dst", "=", "tf_v1", ".", "gfile", ".", "GFile", "(", ...
Extracts 'tarinfo' from 'tgz' and writes to 'dst_path'.
[ "Extracts", "tarinfo", "from", "tgz", "and", "writes", "to", "dst_path", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/resolver.py#L146-L157
30,227
tensorflow/hub
tensorflow_hub/resolver.py
DownloadManager.download_and_uncompress
def download_and_uncompress(self, fileobj, dst_path): """Streams the content for the 'fileobj' and stores the result in dst_path. Args: fileobj: File handle pointing to .tar/.tar.gz content. dst_path: Absolute path where to store uncompressed data from 'fileobj'. Raises: ValueError: Unkn...
python
def download_and_uncompress(self, fileobj, dst_path): """Streams the content for the 'fileobj' and stores the result in dst_path. Args: fileobj: File handle pointing to .tar/.tar.gz content. dst_path: Absolute path where to store uncompressed data from 'fileobj'. Raises: ValueError: Unkn...
[ "def", "download_and_uncompress", "(", "self", ",", "fileobj", ",", "dst_path", ")", ":", "try", ":", "with", "tarfile", ".", "open", "(", "mode", "=", "\"r|*\"", ",", "fileobj", "=", "fileobj", ")", "as", "tgz", ":", "for", "tarinfo", "in", "tgz", ":"...
Streams the content for the 'fileobj' and stores the result in dst_path. Args: fileobj: File handle pointing to .tar/.tar.gz content. dst_path: Absolute path where to store uncompressed data from 'fileobj'. Raises: ValueError: Unknown object encountered inside the TAR file.
[ "Streams", "the", "content", "for", "the", "fileobj", "and", "stores", "the", "result", "in", "dst_path", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/resolver.py#L159-L189
30,228
tensorflow/hub
tensorflow_hub/meta_graph_lib.py
prepend_name_scope
def prepend_name_scope(name, import_scope): """Prepends name scope to a name.""" # Based on tensorflow/python/framework/ops.py implementation. if import_scope: try: str_to_replace = r"([\^]|loc:@|^)(.*)" return re.sub(str_to_replace, r"\1" + import_scope + r"/\2", tf.compat.as_...
python
def prepend_name_scope(name, import_scope): """Prepends name scope to a name.""" # Based on tensorflow/python/framework/ops.py implementation. if import_scope: try: str_to_replace = r"([\^]|loc:@|^)(.*)" return re.sub(str_to_replace, r"\1" + import_scope + r"/\2", tf.compat.as_...
[ "def", "prepend_name_scope", "(", "name", ",", "import_scope", ")", ":", "# Based on tensorflow/python/framework/ops.py implementation.", "if", "import_scope", ":", "try", ":", "str_to_replace", "=", "r\"([\\^]|loc:@|^)(.*)\"", "return", "re", ".", "sub", "(", "str_to_rep...
Prepends name scope to a name.
[ "Prepends", "name", "scope", "to", "a", "name", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/meta_graph_lib.py#L32-L45
30,229
tensorflow/hub
tensorflow_hub/meta_graph_lib.py
prefix_shared_name_attributes
def prefix_shared_name_attributes(meta_graph, absolute_import_scope): """In-place prefixes shared_name attributes of nodes.""" shared_name_attr = "shared_name" for node in meta_graph.graph_def.node: shared_name_value = node.attr.get(shared_name_attr, None) if shared_name_value and shared_name_value.HasFie...
python
def prefix_shared_name_attributes(meta_graph, absolute_import_scope): """In-place prefixes shared_name attributes of nodes.""" shared_name_attr = "shared_name" for node in meta_graph.graph_def.node: shared_name_value = node.attr.get(shared_name_attr, None) if shared_name_value and shared_name_value.HasFie...
[ "def", "prefix_shared_name_attributes", "(", "meta_graph", ",", "absolute_import_scope", ")", ":", "shared_name_attr", "=", "\"shared_name\"", "for", "node", "in", "meta_graph", ".", "graph_def", ".", "node", ":", "shared_name_value", "=", "node", ".", "attr", ".", ...
In-place prefixes shared_name attributes of nodes.
[ "In", "-", "place", "prefixes", "shared_name", "attributes", "of", "nodes", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/meta_graph_lib.py#L48-L57
30,230
tensorflow/hub
tensorflow_hub/meta_graph_lib.py
mark_backward
def mark_backward(output_tensor, used_node_names): """Function to propagate backwards in the graph and mark nodes as used. Traverses recursively through the graph from the end tensor, through the op that generates the tensor, and then to the input tensors that feed the op. Nodes encountered are stored in used_...
python
def mark_backward(output_tensor, used_node_names): """Function to propagate backwards in the graph and mark nodes as used. Traverses recursively through the graph from the end tensor, through the op that generates the tensor, and then to the input tensors that feed the op. Nodes encountered are stored in used_...
[ "def", "mark_backward", "(", "output_tensor", ",", "used_node_names", ")", ":", "op", "=", "output_tensor", ".", "op", "if", "op", ".", "name", "in", "used_node_names", ":", "return", "used_node_names", ".", "add", "(", "op", ".", "name", ")", "for", "inpu...
Function to propagate backwards in the graph and mark nodes as used. Traverses recursively through the graph from the end tensor, through the op that generates the tensor, and then to the input tensors that feed the op. Nodes encountered are stored in used_node_names. Args: output_tensor: A Tensor which w...
[ "Function", "to", "propagate", "backwards", "in", "the", "graph", "and", "mark", "nodes", "as", "used", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/meta_graph_lib.py#L60-L81
30,231
tensorflow/hub
tensorflow_hub/meta_graph_lib.py
prune_unused_nodes
def prune_unused_nodes(meta_graph, signature_def): """Function to prune unused ops given a signature def. This function does a graph traversal through from all outputs as defined in the signature_def to collect all used nodes. Then, any nodes which are unused can be discarded. This is useful for graph which ar...
python
def prune_unused_nodes(meta_graph, signature_def): """Function to prune unused ops given a signature def. This function does a graph traversal through from all outputs as defined in the signature_def to collect all used nodes. Then, any nodes which are unused can be discarded. This is useful for graph which ar...
[ "def", "prune_unused_nodes", "(", "meta_graph", ",", "signature_def", ")", ":", "# Instantiate a temporary empty graph so that we have access to Graph API", "# and import the meta_graph.", "graph", "=", "tf_v1", ".", "Graph", "(", ")", "with", "graph", ".", "as_default", "(...
Function to prune unused ops given a signature def. This function does a graph traversal through from all outputs as defined in the signature_def to collect all used nodes. Then, any nodes which are unused can be discarded. This is useful for graph which are executing eagerly or on TPUs. Args: meta_grap...
[ "Function", "to", "prune", "unused", "ops", "given", "a", "signature", "def", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/meta_graph_lib.py#L84-L118
30,232
tensorflow/hub
tensorflow_hub/meta_graph_lib.py
prune_feed_map
def prune_feed_map(meta_graph, feed_map): """Function to prune the feedmap of nodes which no longer exist.""" node_names = [x.name + ":0" for x in meta_graph.graph_def.node] keys_to_delete = [] for k, _ in feed_map.items(): if k not in node_names: keys_to_delete.append(k) for k in keys_to_delete: ...
python
def prune_feed_map(meta_graph, feed_map): """Function to prune the feedmap of nodes which no longer exist.""" node_names = [x.name + ":0" for x in meta_graph.graph_def.node] keys_to_delete = [] for k, _ in feed_map.items(): if k not in node_names: keys_to_delete.append(k) for k in keys_to_delete: ...
[ "def", "prune_feed_map", "(", "meta_graph", ",", "feed_map", ")", ":", "node_names", "=", "[", "x", ".", "name", "+", "\":0\"", "for", "x", "in", "meta_graph", ".", "graph_def", ".", "node", "]", "keys_to_delete", "=", "[", "]", "for", "k", ",", "_", ...
Function to prune the feedmap of nodes which no longer exist.
[ "Function", "to", "prune", "the", "feedmap", "of", "nodes", "which", "no", "longer", "exist", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/meta_graph_lib.py#L121-L129
30,233
tensorflow/hub
tensorflow_hub/tf_utils.py
atomic_write_string_to_file
def atomic_write_string_to_file(filename, contents, overwrite): """Writes to `filename` atomically. This means that when `filename` appears in the filesystem, it will contain all of `contents`. With write_string_to_file, it is possible for the file to appear in the filesystem with `contents` only partially wri...
python
def atomic_write_string_to_file(filename, contents, overwrite): """Writes to `filename` atomically. This means that when `filename` appears in the filesystem, it will contain all of `contents`. With write_string_to_file, it is possible for the file to appear in the filesystem with `contents` only partially wri...
[ "def", "atomic_write_string_to_file", "(", "filename", ",", "contents", ",", "overwrite", ")", ":", "temp_pathname", "=", "(", "tf", ".", "compat", ".", "as_bytes", "(", "filename", ")", "+", "tf", ".", "compat", ".", "as_bytes", "(", "\".tmp\"", ")", "+",...
Writes to `filename` atomically. This means that when `filename` appears in the filesystem, it will contain all of `contents`. With write_string_to_file, it is possible for the file to appear in the filesystem with `contents` only partially written. Accomplished by writing to a temp file and then renaming it....
[ "Writes", "to", "filename", "atomically", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tf_utils.py#L40-L64
30,234
tensorflow/hub
tensorflow_hub/tf_utils.py
get_timestamped_export_dir
def get_timestamped_export_dir(export_dir_base): """Builds a path to a new subdirectory within the base directory. Each export is written into a new subdirectory named using the current time. This guarantees monotonically increasing version numbers even across multiple runs of the pipeline. The timestamp us...
python
def get_timestamped_export_dir(export_dir_base): """Builds a path to a new subdirectory within the base directory. Each export is written into a new subdirectory named using the current time. This guarantees monotonically increasing version numbers even across multiple runs of the pipeline. The timestamp us...
[ "def", "get_timestamped_export_dir", "(", "export_dir_base", ")", ":", "attempts", "=", "0", "while", "attempts", "<", "MAX_DIRECTORY_CREATION_ATTEMPTS", ":", "export_timestamp", "=", "int", "(", "time", ".", "time", "(", ")", ")", "export_dir", "=", "os", ".", ...
Builds a path to a new subdirectory within the base directory. Each export is written into a new subdirectory named using the current time. This guarantees monotonically increasing version numbers even across multiple runs of the pipeline. The timestamp used is the number of seconds since epoch UTC. Args: ...
[ "Builds", "a", "path", "to", "a", "new", "subdirectory", "within", "the", "base", "directory", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tf_utils.py#L74-L110
30,235
tensorflow/hub
tensorflow_hub/tf_utils.py
get_temp_export_dir
def get_temp_export_dir(timestamped_export_dir): """Builds a directory name based on the argument but starting with 'temp-'. This relies on the fact that TensorFlow Serving ignores subdirectories of the base directory that can't be parsed as integers. Args: timestamped_export_dir: the name of the eventual...
python
def get_temp_export_dir(timestamped_export_dir): """Builds a directory name based on the argument but starting with 'temp-'. This relies on the fact that TensorFlow Serving ignores subdirectories of the base directory that can't be parsed as integers. Args: timestamped_export_dir: the name of the eventual...
[ "def", "get_temp_export_dir", "(", "timestamped_export_dir", ")", ":", "(", "dirname", ",", "basename", ")", "=", "os", ".", "path", ".", "split", "(", "timestamped_export_dir", ")", "temp_export_dir", "=", "os", ".", "path", ".", "join", "(", "tf", ".", "...
Builds a directory name based on the argument but starting with 'temp-'. This relies on the fact that TensorFlow Serving ignores subdirectories of the base directory that can't be parsed as integers. Args: timestamped_export_dir: the name of the eventual export directory, e.g. /foo/bar/<timestamp> ...
[ "Builds", "a", "directory", "name", "based", "on", "the", "argument", "but", "starting", "with", "temp", "-", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tf_utils.py#L113-L130
30,236
tensorflow/hub
tensorflow_hub/tf_utils.py
garbage_collect_exports
def garbage_collect_exports(export_dir_base, exports_to_keep): """Deletes older exports, retaining only a given number of the most recent. Export subdirectories are assumed to be named with monotonically increasing integers; the most recent are taken to be those with the largest values. Args: export_dir_b...
python
def garbage_collect_exports(export_dir_base, exports_to_keep): """Deletes older exports, retaining only a given number of the most recent. Export subdirectories are assumed to be named with monotonically increasing integers; the most recent are taken to be those with the largest values. Args: export_dir_b...
[ "def", "garbage_collect_exports", "(", "export_dir_base", ",", "exports_to_keep", ")", ":", "if", "exports_to_keep", "is", "None", ":", "return", "version_paths", "=", "[", "]", "# List of tuples (version, path)", "for", "filename", "in", "tf_v1", ".", "gfile", ".",...
Deletes older exports, retaining only a given number of the most recent. Export subdirectories are assumed to be named with monotonically increasing integers; the most recent are taken to be those with the largest values. Args: export_dir_base: the base directory under which each export is in a versio...
[ "Deletes", "older", "exports", "retaining", "only", "a", "given", "number", "of", "the", "most", "recent", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tf_utils.py#L135-L162
30,237
tensorflow/hub
tensorflow_hub/tf_utils.py
bytes_to_readable_str
def bytes_to_readable_str(num_bytes, include_b=False): """Generate a human-readable string representing number of bytes. The units B, kB, MB and GB are used. Args: num_bytes: (`int` or None) Number of bytes. include_b: (`bool`) Include the letter B at the end of the unit. Returns: (`str`) A strin...
python
def bytes_to_readable_str(num_bytes, include_b=False): """Generate a human-readable string representing number of bytes. The units B, kB, MB and GB are used. Args: num_bytes: (`int` or None) Number of bytes. include_b: (`bool`) Include the letter B at the end of the unit. Returns: (`str`) A strin...
[ "def", "bytes_to_readable_str", "(", "num_bytes", ",", "include_b", "=", "False", ")", ":", "if", "num_bytes", "is", "None", ":", "return", "str", "(", "num_bytes", ")", "if", "num_bytes", "<", "1024", ":", "result", "=", "\"%d\"", "%", "num_bytes", "elif"...
Generate a human-readable string representing number of bytes. The units B, kB, MB and GB are used. Args: num_bytes: (`int` or None) Number of bytes. include_b: (`bool`) Include the letter B at the end of the unit. Returns: (`str`) A string representing the number of bytes in a human-readable way, ...
[ "Generate", "a", "human", "-", "readable", "string", "representing", "number", "of", "bytes", "." ]
09f45963f6787322967b6fec61459f3ac56fbb27
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tf_utils.py#L165-L192
30,238
pytest-dev/pytest
scripts/release.py
announce
def announce(version): """Generates a new release announcement entry in the docs.""" # Get our list of authors stdout = check_output(["git", "describe", "--abbrev=0", "--tags"]) stdout = stdout.decode("utf-8") last_version = stdout.strip() stdout = check_output( ["git", "log", "{}..HEAD...
python
def announce(version): """Generates a new release announcement entry in the docs.""" # Get our list of authors stdout = check_output(["git", "describe", "--abbrev=0", "--tags"]) stdout = stdout.decode("utf-8") last_version = stdout.strip() stdout = check_output( ["git", "log", "{}..HEAD...
[ "def", "announce", "(", "version", ")", ":", "# Get our list of authors", "stdout", "=", "check_output", "(", "[", "\"git\"", ",", "\"describe\"", ",", "\"--abbrev=0\"", ",", "\"--tags\"", "]", ")", "stdout", "=", "stdout", ".", "decode", "(", "\"utf-8\"", ")"...
Generates a new release announcement entry in the docs.
[ "Generates", "a", "new", "release", "announcement", "entry", "in", "the", "docs", "." ]
204004c8b8b743110a5f12f2bfa31154e0f59815
https://github.com/pytest-dev/pytest/blob/204004c8b8b743110a5f12f2bfa31154e0f59815/scripts/release.py#L14-L65
30,239
kubernetes-client/python
kubernetes/client/models/v1alpha1_webhook_client_config.py
V1alpha1WebhookClientConfig.ca_bundle
def ca_bundle(self, ca_bundle): """ Sets the ca_bundle of this V1alpha1WebhookClientConfig. `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used. :param ca_bundle: The ca_bundl...
python
def ca_bundle(self, ca_bundle): """ Sets the ca_bundle of this V1alpha1WebhookClientConfig. `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used. :param ca_bundle: The ca_bundl...
[ "def", "ca_bundle", "(", "self", ",", "ca_bundle", ")", ":", "if", "ca_bundle", "is", "not", "None", "and", "not", "re", ".", "search", "(", "'^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$'", ",", "ca_bundle", ")", ":", "raise", "ValueError"...
Sets the ca_bundle of this V1alpha1WebhookClientConfig. `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used. :param ca_bundle: The ca_bundle of this V1alpha1WebhookClientConfig. :type...
[ "Sets", "the", "ca_bundle", "of", "this", "V1alpha1WebhookClientConfig", ".", "caBundle", "is", "a", "PEM", "encoded", "CA", "bundle", "which", "will", "be", "used", "to", "validate", "the", "webhook", "s", "server", "certificate", ".", "If", "unspecified", "s...
5e512ff564c244c50cab780d821542ed56aa965a
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/models/v1alpha1_webhook_client_config.py#L74-L85
30,240
kubernetes-client/python
kubernetes/client/models/runtime_raw_extension.py
RuntimeRawExtension.raw
def raw(self, raw): """ Sets the raw of this RuntimeRawExtension. Raw is the underlying serialization of this object. :param raw: The raw of this RuntimeRawExtension. :type: str """ if raw is None: raise ValueError("Invalid value for `raw`, must not b...
python
def raw(self, raw): """ Sets the raw of this RuntimeRawExtension. Raw is the underlying serialization of this object. :param raw: The raw of this RuntimeRawExtension. :type: str """ if raw is None: raise ValueError("Invalid value for `raw`, must not b...
[ "def", "raw", "(", "self", ",", "raw", ")", ":", "if", "raw", "is", "None", ":", "raise", "ValueError", "(", "\"Invalid value for `raw`, must not be `None`\"", ")", "if", "raw", "is", "not", "None", "and", "not", "re", ".", "search", "(", "'^(?:[A-Za-z0-9+\\...
Sets the raw of this RuntimeRawExtension. Raw is the underlying serialization of this object. :param raw: The raw of this RuntimeRawExtension. :type: str
[ "Sets", "the", "raw", "of", "this", "RuntimeRawExtension", ".", "Raw", "is", "the", "underlying", "serialization", "of", "this", "object", "." ]
5e512ff564c244c50cab780d821542ed56aa965a
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/models/runtime_raw_extension.py#L63-L76
30,241
kubernetes-client/python
kubernetes/client/api_client.py
ApiClient.pool
def pool(self): """Create thread pool on first request avoids instantiating unused threadpool for blocking clients. """ if self._pool is None: self._pool = ThreadPool(self.pool_threads) return self._pool
python
def pool(self): """Create thread pool on first request avoids instantiating unused threadpool for blocking clients. """ if self._pool is None: self._pool = ThreadPool(self.pool_threads) return self._pool
[ "def", "pool", "(", "self", ")", ":", "if", "self", ".", "_pool", "is", "None", ":", "self", ".", "_pool", "=", "ThreadPool", "(", "self", ".", "pool_threads", ")", "return", "self", ".", "_pool" ]
Create thread pool on first request avoids instantiating unused threadpool for blocking clients.
[ "Create", "thread", "pool", "on", "first", "request", "avoids", "instantiating", "unused", "threadpool", "for", "blocking", "clients", "." ]
5e512ff564c244c50cab780d821542ed56aa965a
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/api_client.py#L85-L91
30,242
kubernetes-client/python
kubernetes/client/configuration.py
Configuration.debug
def debug(self, value): """ Sets the debug status. :param value: The debug status, True or False. :type: bool """ self.__debug = value if self.__debug: # if debug status is True, turn on debug logging for _, logger in iteritems(self.logger...
python
def debug(self, value): """ Sets the debug status. :param value: The debug status, True or False. :type: bool """ self.__debug = value if self.__debug: # if debug status is True, turn on debug logging for _, logger in iteritems(self.logger...
[ "def", "debug", "(", "self", ",", "value", ")", ":", "self", ".", "__debug", "=", "value", "if", "self", ".", "__debug", ":", "# if debug status is True, turn on debug logging", "for", "_", ",", "logger", "in", "iteritems", "(", "self", ".", "logger", ")", ...
Sets the debug status. :param value: The debug status, True or False. :type: bool
[ "Sets", "the", "debug", "status", "." ]
5e512ff564c244c50cab780d821542ed56aa965a
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/configuration.py#L153-L173
30,243
kubernetes-client/python
kubernetes/client/configuration.py
Configuration.logger_format
def logger_format(self, value): """ Sets the logger_format. The logger_formatter will be updated when sets logger_format. :param value: The format string. :type: str """ self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger...
python
def logger_format(self, value): """ Sets the logger_format. The logger_formatter will be updated when sets logger_format. :param value: The format string. :type: str """ self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger...
[ "def", "logger_format", "(", "self", ",", "value", ")", ":", "self", ".", "__logger_format", "=", "value", "self", ".", "logger_formatter", "=", "logging", ".", "Formatter", "(", "self", ".", "__logger_format", ")" ]
Sets the logger_format. The logger_formatter will be updated when sets logger_format. :param value: The format string. :type: str
[ "Sets", "the", "logger_format", "." ]
5e512ff564c244c50cab780d821542ed56aa965a
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/configuration.py#L183-L193
30,244
kubernetes-client/python
kubernetes/client/models/v1beta1_certificate_signing_request_status.py
V1beta1CertificateSigningRequestStatus.certificate
def certificate(self, certificate): """ Sets the certificate of this V1beta1CertificateSigningRequestStatus. If request was approved, the controller will place the issued certificate here. :param certificate: The certificate of this V1beta1CertificateSigningRequestStatus. :type:...
python
def certificate(self, certificate): """ Sets the certificate of this V1beta1CertificateSigningRequestStatus. If request was approved, the controller will place the issued certificate here. :param certificate: The certificate of this V1beta1CertificateSigningRequestStatus. :type:...
[ "def", "certificate", "(", "self", ",", "certificate", ")", ":", "if", "certificate", "is", "not", "None", "and", "not", "re", ".", "search", "(", "'^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$'", ",", "certificate", ")", ":", "raise", "Val...
Sets the certificate of this V1beta1CertificateSigningRequestStatus. If request was approved, the controller will place the issued certificate here. :param certificate: The certificate of this V1beta1CertificateSigningRequestStatus. :type: str
[ "Sets", "the", "certificate", "of", "this", "V1beta1CertificateSigningRequestStatus", ".", "If", "request", "was", "approved", "the", "controller", "will", "place", "the", "issued", "certificate", "here", "." ]
5e512ff564c244c50cab780d821542ed56aa965a
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/models/v1beta1_certificate_signing_request_status.py#L69-L80
30,245
bokeh/bokeh
bokeh/core/property/wrappers.py
notify_owner
def notify_owner(func): ''' A decorator for mutating methods of property container classes that notifies owners of the property container about mutating changes. Args: func (callable) : the container method to wrap in a notification Returns: wrapped method Examples: A ``_...
python
def notify_owner(func): ''' A decorator for mutating methods of property container classes that notifies owners of the property container about mutating changes. Args: func (callable) : the container method to wrap in a notification Returns: wrapped method Examples: A ``_...
[ "def", "notify_owner", "(", "func", ")", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "old", "=", "self", ".", "_saved_copy", "(", ")", "result", "=", "func", "(", "self", ",", "*", "args", ",", "*", ...
A decorator for mutating methods of property container classes that notifies owners of the property container about mutating changes. Args: func (callable) : the container method to wrap in a notification Returns: wrapped method Examples: A ``__setitem__`` could be wrapped li...
[ "A", "decorator", "for", "mutating", "methods", "of", "property", "container", "classes", "that", "notifies", "owners", "of", "the", "property", "container", "about", "mutating", "changes", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/wrappers.py#L97-L128
30,246
bokeh/bokeh
bokeh/core/property/wrappers.py
PropertyValueColumnData._stream
def _stream(self, doc, source, new_data, rollover=None, setter=None): ''' Internal implementation to handle special-casing stream events on ``ColumnDataSource`` columns. Normally any changes to the ``.data`` dict attribute on a ``ColumnDataSource`` triggers a notification, causing all o...
python
def _stream(self, doc, source, new_data, rollover=None, setter=None): ''' Internal implementation to handle special-casing stream events on ``ColumnDataSource`` columns. Normally any changes to the ``.data`` dict attribute on a ``ColumnDataSource`` triggers a notification, causing all o...
[ "def", "_stream", "(", "self", ",", "doc", ",", "source", ",", "new_data", ",", "rollover", "=", "None", ",", "setter", "=", "None", ")", ":", "old", "=", "self", ".", "_saved_copy", "(", ")", "# TODO (bev) Currently this reports old differently for array vs lis...
Internal implementation to handle special-casing stream events on ``ColumnDataSource`` columns. Normally any changes to the ``.data`` dict attribute on a ``ColumnDataSource`` triggers a notification, causing all of the data to be synchronized between server and clients. The ``....
[ "Internal", "implementation", "to", "handle", "special", "-", "casing", "stream", "events", "on", "ColumnDataSource", "columns", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/wrappers.py#L398-L444
30,247
bokeh/bokeh
bokeh/core/property/wrappers.py
PropertyValueColumnData._patch
def _patch(self, doc, source, patches, setter=None): ''' Internal implementation to handle special-casing patch events on ``ColumnDataSource`` columns. Normally any changes to the ``.data`` dict attribute on a ``ColumnDataSource`` triggers a notification, causing all of the data ...
python
def _patch(self, doc, source, patches, setter=None): ''' Internal implementation to handle special-casing patch events on ``ColumnDataSource`` columns. Normally any changes to the ``.data`` dict attribute on a ``ColumnDataSource`` triggers a notification, causing all of the data ...
[ "def", "_patch", "(", "self", ",", "doc", ",", "source", ",", "patches", ",", "setter", "=", "None", ")", ":", "old", "=", "self", ".", "_saved_copy", "(", ")", "for", "name", ",", "patch", "in", "patches", ".", "items", "(", ")", ":", "for", "in...
Internal implementation to handle special-casing patch events on ``ColumnDataSource`` columns. Normally any changes to the ``.data`` dict attribute on a ``ColumnDataSource`` triggers a notification, causing all of the data to be synchronized between server and clients. The ``.p...
[ "Internal", "implementation", "to", "handle", "special", "-", "casing", "patch", "events", "on", "ColumnDataSource", "columns", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/wrappers.py#L447-L485
30,248
bokeh/bokeh
bokeh/__init__.py
license
def license(): ''' Print the Bokeh license to the console. Returns: None ''' from os.path import join with open(join(__path__[0], 'LICENSE.txt')) as lic: print(lic.read())
python
def license(): ''' Print the Bokeh license to the console. Returns: None ''' from os.path import join with open(join(__path__[0], 'LICENSE.txt')) as lic: print(lic.read())
[ "def", "license", "(", ")", ":", "from", "os", ".", "path", "import", "join", "with", "open", "(", "join", "(", "__path__", "[", "0", "]", ",", "'LICENSE.txt'", ")", ")", "as", "lic", ":", "print", "(", "lic", ".", "read", "(", ")", ")" ]
Print the Bokeh license to the console. Returns: None
[ "Print", "the", "Bokeh", "license", "to", "the", "console", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/__init__.py#L51-L60
30,249
bokeh/bokeh
bokeh/core/property/bases.py
Property._copy_default
def _copy_default(cls, default): ''' Return a copy of the default, or a new value if the default is specified by a function. ''' if not isinstance(default, types.FunctionType): return copy(default) else: return default()
python
def _copy_default(cls, default): ''' Return a copy of the default, or a new value if the default is specified by a function. ''' if not isinstance(default, types.FunctionType): return copy(default) else: return default()
[ "def", "_copy_default", "(", "cls", ",", "default", ")", ":", "if", "not", "isinstance", "(", "default", ",", "types", ".", "FunctionType", ")", ":", "return", "copy", "(", "default", ")", "else", ":", "return", "default", "(", ")" ]
Return a copy of the default, or a new value if the default is specified by a function.
[ "Return", "a", "copy", "of", "the", "default", "or", "a", "new", "value", "if", "the", "default", "is", "specified", "by", "a", "function", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/bases.py#L153-L161
30,250
bokeh/bokeh
bokeh/core/property/bases.py
Property.matches
def matches(self, new, old): ''' Whether two parameters match values. If either ``new`` or ``old`` is a NumPy array or Pandas Series or Index, then the result of ``np.array_equal`` will determine if the values match. Otherwise, the result of standard Python equality will be returned. ...
python
def matches(self, new, old): ''' Whether two parameters match values. If either ``new`` or ``old`` is a NumPy array or Pandas Series or Index, then the result of ``np.array_equal`` will determine if the values match. Otherwise, the result of standard Python equality will be returned. ...
[ "def", "matches", "(", "self", ",", "new", ",", "old", ")", ":", "if", "isinstance", "(", "new", ",", "np", ".", "ndarray", ")", "or", "isinstance", "(", "old", ",", "np", ".", "ndarray", ")", ":", "return", "np", ".", "array_equal", "(", "new", ...
Whether two parameters match values. If either ``new`` or ``old`` is a NumPy array or Pandas Series or Index, then the result of ``np.array_equal`` will determine if the values match. Otherwise, the result of standard Python equality will be returned. Returns: True, if new...
[ "Whether", "two", "parameters", "match", "values", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/bases.py#L206-L241
30,251
bokeh/bokeh
bokeh/core/property/bases.py
Property.is_valid
def is_valid(self, value): ''' Whether the value passes validation Args: value (obj) : the value to validate against this property type Returns: True if valid, False otherwise ''' try: if validation_on(): self.validate(value,...
python
def is_valid(self, value): ''' Whether the value passes validation Args: value (obj) : the value to validate against this property type Returns: True if valid, False otherwise ''' try: if validation_on(): self.validate(value,...
[ "def", "is_valid", "(", "self", ",", "value", ")", ":", "try", ":", "if", "validation_on", "(", ")", ":", "self", ".", "validate", "(", "value", ",", "False", ")", "except", "ValueError", ":", "return", "False", "else", ":", "return", "True" ]
Whether the value passes validation Args: value (obj) : the value to validate against this property type Returns: True if valid, False otherwise
[ "Whether", "the", "value", "passes", "validation" ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/bases.py#L292-L308
30,252
bokeh/bokeh
bokeh/core/property/bases.py
Property.accepts
def accepts(self, tp, converter): ''' Declare that other types may be converted to this property type. Args: tp (Property) : A type that may be converted automatically to this property type. converter (callable) : A function accep...
python
def accepts(self, tp, converter): ''' Declare that other types may be converted to this property type. Args: tp (Property) : A type that may be converted automatically to this property type. converter (callable) : A function accep...
[ "def", "accepts", "(", "self", ",", "tp", ",", "converter", ")", ":", "tp", "=", "ParameterizedProperty", ".", "_validate_type_param", "(", "tp", ")", "self", ".", "alternatives", ".", "append", "(", "(", "tp", ",", "converter", ")", ")", "return", "self...
Declare that other types may be converted to this property type. Args: tp (Property) : A type that may be converted automatically to this property type. converter (callable) : A function accepting ``value`` to perform conversion of the ...
[ "Declare", "that", "other", "types", "may", "be", "converted", "to", "this", "property", "type", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/bases.py#L354-L373
30,253
bokeh/bokeh
bokeh/core/property/bases.py
Property.asserts
def asserts(self, fn, msg_or_fn): ''' Assert that prepared values satisfy given conditions. Assertions are intended in enforce conditions beyond simple value type validation. For instance, this method can be use to assert that the columns of a ``ColumnDataSource`` all collectively have ...
python
def asserts(self, fn, msg_or_fn): ''' Assert that prepared values satisfy given conditions. Assertions are intended in enforce conditions beyond simple value type validation. For instance, this method can be use to assert that the columns of a ``ColumnDataSource`` all collectively have ...
[ "def", "asserts", "(", "self", ",", "fn", ",", "msg_or_fn", ")", ":", "self", ".", "assertions", ".", "append", "(", "(", "fn", ",", "msg_or_fn", ")", ")", "return", "self" ]
Assert that prepared values satisfy given conditions. Assertions are intended in enforce conditions beyond simple value type validation. For instance, this method can be use to assert that the columns of a ``ColumnDataSource`` all collectively have the same length at all times. ...
[ "Assert", "that", "prepared", "values", "satisfy", "given", "conditions", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/bases.py#L375-L398
30,254
bokeh/bokeh
bokeh/application/handlers/code.py
CodeHandler.url_path
def url_path(self): ''' The last path component for the basename of the configured filename. ''' if self.failed: return None else: # TODO should fix invalid URL characters return '/' + os.path.splitext(os.path.basename(self._runner.path))[0]
python
def url_path(self): ''' The last path component for the basename of the configured filename. ''' if self.failed: return None else: # TODO should fix invalid URL characters return '/' + os.path.splitext(os.path.basename(self._runner.path))[0]
[ "def", "url_path", "(", "self", ")", ":", "if", "self", ".", "failed", ":", "return", "None", "else", ":", "# TODO should fix invalid URL characters", "return", "'/'", "+", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", ...
The last path component for the basename of the configured filename.
[ "The", "last", "path", "component", "for", "the", "basename", "of", "the", "configured", "filename", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/application/handlers/code.py#L176-L184
30,255
bokeh/bokeh
bokeh/core/property/dataspec.py
UnitsSpec.make_descriptors
def make_descriptors(self, base_name): ''' Return a list of ``PropertyDescriptor`` instances to install on a class, in order to delegate attribute access to this property. Unlike simpler property types, ``UnitsSpec`` returns multiple descriptors to install. In particular, descriptors fo...
python
def make_descriptors(self, base_name): ''' Return a list of ``PropertyDescriptor`` instances to install on a class, in order to delegate attribute access to this property. Unlike simpler property types, ``UnitsSpec`` returns multiple descriptors to install. In particular, descriptors fo...
[ "def", "make_descriptors", "(", "self", ",", "base_name", ")", ":", "units_name", "=", "base_name", "+", "\"_units\"", "units_props", "=", "self", ".", "_units_type", ".", "make_descriptors", "(", "units_name", ")", "return", "units_props", "+", "[", "UnitsSpecP...
Return a list of ``PropertyDescriptor`` instances to install on a class, in order to delegate attribute access to this property. Unlike simpler property types, ``UnitsSpec`` returns multiple descriptors to install. In particular, descriptors for the base property as well as the associat...
[ "Return", "a", "list", "of", "PropertyDescriptor", "instances", "to", "install", "on", "a", "class", "in", "order", "to", "delegate", "attribute", "access", "to", "this", "property", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/dataspec.py#L363-L382
30,256
bokeh/bokeh
bokeh/core/property/dataspec.py
ColorSpec.isconst
def isconst(cls, val): ''' Whether the value is a string color literal. Checks for a well-formed hexadecimal color value or a named color. Args: val (str) : the value to check Returns: True, if the value is a string color literal ''' return isi...
python
def isconst(cls, val): ''' Whether the value is a string color literal. Checks for a well-formed hexadecimal color value or a named color. Args: val (str) : the value to check Returns: True, if the value is a string color literal ''' return isi...
[ "def", "isconst", "(", "cls", ",", "val", ")", ":", "return", "isinstance", "(", "val", ",", "string_types", ")", "and", "(", "(", "len", "(", "val", ")", "==", "7", "and", "val", "[", "0", "]", "==", "\"#\"", ")", "or", "val", "in", "enums", "...
Whether the value is a string color literal. Checks for a well-formed hexadecimal color value or a named color. Args: val (str) : the value to check Returns: True, if the value is a string color literal
[ "Whether", "the", "value", "is", "a", "string", "color", "literal", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/dataspec.py#L553-L566
30,257
bokeh/bokeh
scripts/issues.py
save_object
def save_object(filename, obj): """Compresses and pickles given object to the given filename.""" logging.info('saving {}...'.format(filename)) try: with gzip.GzipFile(filename, 'wb') as f: f.write(pickle.dumps(obj, 1)) except Exception as e: logging.error('save failure: {}'.f...
python
def save_object(filename, obj): """Compresses and pickles given object to the given filename.""" logging.info('saving {}...'.format(filename)) try: with gzip.GzipFile(filename, 'wb') as f: f.write(pickle.dumps(obj, 1)) except Exception as e: logging.error('save failure: {}'.f...
[ "def", "save_object", "(", "filename", ",", "obj", ")", ":", "logging", ".", "info", "(", "'saving {}...'", ".", "format", "(", "filename", ")", ")", "try", ":", "with", "gzip", ".", "GzipFile", "(", "filename", ",", "'wb'", ")", "as", "f", ":", "f",...
Compresses and pickles given object to the given filename.
[ "Compresses", "and", "pickles", "given", "object", "to", "the", "given", "filename", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L47-L55
30,258
bokeh/bokeh
scripts/issues.py
load_object
def load_object(filename): """Unpickles and decompresses the given filename and returns the created object.""" logging.info('loading {}...'.format(filename)) try: with gzip.GzipFile(filename, 'rb') as f: buf = '' while True: data = f.read() if ...
python
def load_object(filename): """Unpickles and decompresses the given filename and returns the created object.""" logging.info('loading {}...'.format(filename)) try: with gzip.GzipFile(filename, 'rb') as f: buf = '' while True: data = f.read() if ...
[ "def", "load_object", "(", "filename", ")", ":", "logging", ".", "info", "(", "'loading {}...'", ".", "format", "(", "filename", ")", ")", "try", ":", "with", "gzip", ".", "GzipFile", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "buf", "=", "''...
Unpickles and decompresses the given filename and returns the created object.
[ "Unpickles", "and", "decompresses", "the", "given", "filename", "and", "returns", "the", "created", "object", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L58-L72
30,259
bokeh/bokeh
scripts/issues.py
issue_section
def issue_section(issue): """Returns the section heading for the issue, or None if this issue should be ignored.""" labels = issue.get('labels', []) for label in labels: if not label['name'].startswith('type: '): continue if label['name'] in LOG_SECTION: return LOG_S...
python
def issue_section(issue): """Returns the section heading for the issue, or None if this issue should be ignored.""" labels = issue.get('labels', []) for label in labels: if not label['name'].startswith('type: '): continue if label['name'] in LOG_SECTION: return LOG_S...
[ "def", "issue_section", "(", "issue", ")", ":", "labels", "=", "issue", ".", "get", "(", "'labels'", ",", "[", "]", ")", "for", "label", "in", "labels", ":", "if", "not", "label", "[", "'name'", "]", ".", "startswith", "(", "'type: '", ")", ":", "c...
Returns the section heading for the issue, or None if this issue should be ignored.
[ "Returns", "the", "section", "heading", "for", "the", "issue", "or", "None", "if", "this", "issue", "should", "be", "ignored", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L92-L106
30,260
bokeh/bokeh
scripts/issues.py
issue_tags
def issue_tags(issue): """Returns list of tags for this issue.""" labels = issue.get('labels', []) return [label['name'].replace('tag: ', '') for label in labels if label['name'].startswith('tag: ')]
python
def issue_tags(issue): """Returns list of tags for this issue.""" labels = issue.get('labels', []) return [label['name'].replace('tag: ', '') for label in labels if label['name'].startswith('tag: ')]
[ "def", "issue_tags", "(", "issue", ")", ":", "labels", "=", "issue", ".", "get", "(", "'labels'", ",", "[", "]", ")", "return", "[", "label", "[", "'name'", "]", ".", "replace", "(", "'tag: '", ",", "''", ")", "for", "label", "in", "labels", "if", ...
Returns list of tags for this issue.
[ "Returns", "list", "of", "tags", "for", "this", "issue", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L109-L112
30,261
bokeh/bokeh
scripts/issues.py
closed_issue
def closed_issue(issue, after=None): """Returns True iff this issue was closed after given date. If after not given, only checks if issue is closed.""" if issue['state'] == 'closed': if after is None or parse_timestamp(issue['closed_at']) > after: return True return False
python
def closed_issue(issue, after=None): """Returns True iff this issue was closed after given date. If after not given, only checks if issue is closed.""" if issue['state'] == 'closed': if after is None or parse_timestamp(issue['closed_at']) > after: return True return False
[ "def", "closed_issue", "(", "issue", ",", "after", "=", "None", ")", ":", "if", "issue", "[", "'state'", "]", "==", "'closed'", ":", "if", "after", "is", "None", "or", "parse_timestamp", "(", "issue", "[", "'closed_at'", "]", ")", ">", "after", ":", ...
Returns True iff this issue was closed after given date. If after not given, only checks if issue is closed.
[ "Returns", "True", "iff", "this", "issue", "was", "closed", "after", "given", "date", ".", "If", "after", "not", "given", "only", "checks", "if", "issue", "is", "closed", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L115-L120
30,262
bokeh/bokeh
scripts/issues.py
relevent_issue
def relevent_issue(issue, after): """Returns True iff this issue is something we should show in the changelog.""" return (closed_issue(issue, after) and issue_completed(issue) and issue_section(issue))
python
def relevent_issue(issue, after): """Returns True iff this issue is something we should show in the changelog.""" return (closed_issue(issue, after) and issue_completed(issue) and issue_section(issue))
[ "def", "relevent_issue", "(", "issue", ",", "after", ")", ":", "return", "(", "closed_issue", "(", "issue", ",", "after", ")", "and", "issue_completed", "(", "issue", ")", "and", "issue_section", "(", "issue", ")", ")" ]
Returns True iff this issue is something we should show in the changelog.
[ "Returns", "True", "iff", "this", "issue", "is", "something", "we", "should", "show", "in", "the", "changelog", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L123-L127
30,263
bokeh/bokeh
scripts/issues.py
all_issues
def all_issues(issues): """Yields unique set of issues given a list of issues.""" logging.info('finding issues...') seen = set() for issue in issues: if issue['title'] not in seen: seen.add(issue['title']) yield issue
python
def all_issues(issues): """Yields unique set of issues given a list of issues.""" logging.info('finding issues...') seen = set() for issue in issues: if issue['title'] not in seen: seen.add(issue['title']) yield issue
[ "def", "all_issues", "(", "issues", ")", ":", "logging", ".", "info", "(", "'finding issues...'", ")", "seen", "=", "set", "(", ")", "for", "issue", "in", "issues", ":", "if", "issue", "[", "'title'", "]", "not", "in", "seen", ":", "seen", ".", "add"...
Yields unique set of issues given a list of issues.
[ "Yields", "unique", "set", "of", "issues", "given", "a", "list", "of", "issues", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L150-L157
30,264
bokeh/bokeh
scripts/issues.py
get_issues_url
def get_issues_url(page, after): """Returns github API URL for querying tags.""" template = '{base_url}/{owner}/{repo}/issues?state=closed&per_page=100&page={page}&since={after}' return template.format(page=page, after=after.isoformat(), **API_PARAMS)
python
def get_issues_url(page, after): """Returns github API URL for querying tags.""" template = '{base_url}/{owner}/{repo}/issues?state=closed&per_page=100&page={page}&since={after}' return template.format(page=page, after=after.isoformat(), **API_PARAMS)
[ "def", "get_issues_url", "(", "page", ",", "after", ")", ":", "template", "=", "'{base_url}/{owner}/{repo}/issues?state=closed&per_page=100&page={page}&since={after}'", "return", "template", ".", "format", "(", "page", "=", "page", ",", "after", "=", "after", ".", "is...
Returns github API URL for querying tags.
[ "Returns", "github", "API", "URL", "for", "querying", "tags", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L168-L171
30,265
bokeh/bokeh
scripts/issues.py
parse_timestamp
def parse_timestamp(timestamp): """Parse ISO8601 timestamps given by github API.""" dt = dateutil.parser.parse(timestamp) return dt.astimezone(dateutil.tz.tzutc())
python
def parse_timestamp(timestamp): """Parse ISO8601 timestamps given by github API.""" dt = dateutil.parser.parse(timestamp) return dt.astimezone(dateutil.tz.tzutc())
[ "def", "parse_timestamp", "(", "timestamp", ")", ":", "dt", "=", "dateutil", ".", "parser", ".", "parse", "(", "timestamp", ")", "return", "dt", ".", "astimezone", "(", "dateutil", ".", "tz", ".", "tzutc", "(", ")", ")" ]
Parse ISO8601 timestamps given by github API.
[ "Parse", "ISO8601", "timestamps", "given", "by", "github", "API", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L179-L182
30,266
bokeh/bokeh
scripts/issues.py
read_url
def read_url(url): """Reads given URL as JSON and returns data as loaded python object.""" logging.debug('reading {url} ...'.format(url=url)) token = os.environ.get("BOKEH_GITHUB_API_TOKEN") headers = {} if token: headers['Authorization'] = 'token %s' % token request = Request(url, heade...
python
def read_url(url): """Reads given URL as JSON and returns data as loaded python object.""" logging.debug('reading {url} ...'.format(url=url)) token = os.environ.get("BOKEH_GITHUB_API_TOKEN") headers = {} if token: headers['Authorization'] = 'token %s' % token request = Request(url, heade...
[ "def", "read_url", "(", "url", ")", ":", "logging", ".", "debug", "(", "'reading {url} ...'", ".", "format", "(", "url", "=", "url", ")", ")", "token", "=", "os", ".", "environ", ".", "get", "(", "\"BOKEH_GITHUB_API_TOKEN\"", ")", "headers", "=", "{", ...
Reads given URL as JSON and returns data as loaded python object.
[ "Reads", "given", "URL", "as", "JSON", "and", "returns", "data", "as", "loaded", "python", "object", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L185-L194
30,267
bokeh/bokeh
scripts/issues.py
query_all_issues
def query_all_issues(after): """Hits the github API for all closed issues after the given date, returns the data.""" page = count(1) data = [] while True: page_data = query_issues(next(page), after) if not page_data: break data.extend(page_data) return data
python
def query_all_issues(after): """Hits the github API for all closed issues after the given date, returns the data.""" page = count(1) data = [] while True: page_data = query_issues(next(page), after) if not page_data: break data.extend(page_data) return data
[ "def", "query_all_issues", "(", "after", ")", ":", "page", "=", "count", "(", "1", ")", "data", "=", "[", "]", "while", "True", ":", "page_data", "=", "query_issues", "(", "next", "(", "page", ")", ",", "after", ")", "if", "not", "page_data", ":", ...
Hits the github API for all closed issues after the given date, returns the data.
[ "Hits", "the", "github", "API", "for", "all", "closed", "issues", "after", "the", "given", "date", "returns", "the", "data", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L207-L216
30,268
bokeh/bokeh
scripts/issues.py
dateof
def dateof(tag_name, tags): """Given a list of tags, returns the datetime of the tag with the given name; Otherwise None.""" for tag in tags: if tag['name'] == tag_name: commit = read_url(tag['commit']['url']) return parse_timestamp(commit['commit']['committer']['date']) retu...
python
def dateof(tag_name, tags): """Given a list of tags, returns the datetime of the tag with the given name; Otherwise None.""" for tag in tags: if tag['name'] == tag_name: commit = read_url(tag['commit']['url']) return parse_timestamp(commit['commit']['committer']['date']) retu...
[ "def", "dateof", "(", "tag_name", ",", "tags", ")", ":", "for", "tag", "in", "tags", ":", "if", "tag", "[", "'name'", "]", "==", "tag_name", ":", "commit", "=", "read_url", "(", "tag", "[", "'commit'", "]", "[", "'url'", "]", ")", "return", "parse_...
Given a list of tags, returns the datetime of the tag with the given name; Otherwise None.
[ "Given", "a", "list", "of", "tags", "returns", "the", "datetime", "of", "the", "tag", "with", "the", "given", "name", ";", "Otherwise", "None", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L219-L225
30,269
bokeh/bokeh
scripts/issues.py
get_data
def get_data(query_func, load_data=False, save_data=False): """Gets data from query_func, optionally saving that data to a file; or loads data from a file.""" if hasattr(query_func, '__name__'): func_name = query_func.__name__ elif hasattr(query_func, 'func'): func_name = query_func.func.__n...
python
def get_data(query_func, load_data=False, save_data=False): """Gets data from query_func, optionally saving that data to a file; or loads data from a file.""" if hasattr(query_func, '__name__'): func_name = query_func.__name__ elif hasattr(query_func, 'func'): func_name = query_func.func.__n...
[ "def", "get_data", "(", "query_func", ",", "load_data", "=", "False", ",", "save_data", "=", "False", ")", ":", "if", "hasattr", "(", "query_func", ",", "'__name__'", ")", ":", "func_name", "=", "query_func", ".", "__name__", "elif", "hasattr", "(", "query...
Gets data from query_func, optionally saving that data to a file; or loads data from a file.
[ "Gets", "data", "from", "query_func", "optionally", "saving", "that", "data", "to", "a", "file", ";", "or", "loads", "data", "from", "a", "file", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L228-L243
30,270
bokeh/bokeh
scripts/issues.py
check_issues
def check_issues(issues, after=None): """Checks issues for BEP 1 compliance.""" issues = closed_issues(issues, after) if after else all_issues(issues) issues = sorted(issues, key=ISSUES_SORT_KEY) have_warnings = False for section, issue_group in groupby(issues, key=ISSUES_BY_SECTION): for ...
python
def check_issues(issues, after=None): """Checks issues for BEP 1 compliance.""" issues = closed_issues(issues, after) if after else all_issues(issues) issues = sorted(issues, key=ISSUES_SORT_KEY) have_warnings = False for section, issue_group in groupby(issues, key=ISSUES_BY_SECTION): for ...
[ "def", "check_issues", "(", "issues", ",", "after", "=", "None", ")", ":", "issues", "=", "closed_issues", "(", "issues", ",", "after", ")", "if", "after", "else", "all_issues", "(", "issues", ")", "issues", "=", "sorted", "(", "issues", ",", "key", "=...
Checks issues for BEP 1 compliance.
[ "Checks", "issues", "for", "BEP", "1", "compliance", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L270-L281
30,271
bokeh/bokeh
scripts/issues.py
issue_line
def issue_line(issue): """Returns log line for given issue.""" template = '#{number} {tags}{title}' tags = issue_tags(issue) params = { 'title': issue['title'].capitalize().rstrip('.'), 'number': issue['number'], 'tags': ' '.join('[{}]'.format(tag) for tag in tags) + (' ' if tags...
python
def issue_line(issue): """Returns log line for given issue.""" template = '#{number} {tags}{title}' tags = issue_tags(issue) params = { 'title': issue['title'].capitalize().rstrip('.'), 'number': issue['number'], 'tags': ' '.join('[{}]'.format(tag) for tag in tags) + (' ' if tags...
[ "def", "issue_line", "(", "issue", ")", ":", "template", "=", "'#{number} {tags}{title}'", "tags", "=", "issue_tags", "(", "issue", ")", "params", "=", "{", "'title'", ":", "issue", "[", "'title'", "]", ".", "capitalize", "(", ")", ".", "rstrip", "(", "'...
Returns log line for given issue.
[ "Returns", "log", "line", "for", "given", "issue", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L286-L295
30,272
bokeh/bokeh
scripts/issues.py
generate_changelog
def generate_changelog(issues, after, heading, rtag=False): """Prints out changelog.""" relevent = relevant_issues(issues, after) relevent = sorted(relevent, key=ISSUES_BY_SECTION) def write(func, endofline="", append=""): func(heading + '\n' + '-' * 20 + endofline) for section, issue_g...
python
def generate_changelog(issues, after, heading, rtag=False): """Prints out changelog.""" relevent = relevant_issues(issues, after) relevent = sorted(relevent, key=ISSUES_BY_SECTION) def write(func, endofline="", append=""): func(heading + '\n' + '-' * 20 + endofline) for section, issue_g...
[ "def", "generate_changelog", "(", "issues", ",", "after", ",", "heading", ",", "rtag", "=", "False", ")", ":", "relevent", "=", "relevant_issues", "(", "issues", ",", "after", ")", "relevent", "=", "sorted", "(", "relevent", ",", "key", "=", "ISSUES_BY_SEC...
Prints out changelog.
[ "Prints", "out", "changelog", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/scripts/issues.py#L298-L317
30,273
bokeh/bokeh
bokeh/colors/rgb.py
RGB.to_css
def to_css(self): ''' Generate the CSS representation of this RGB color. Returns: str, ``"rgb(...)"`` or ``"rgba(...)"`` ''' if self.a == 1.0: return "rgb(%d, %d, %d)" % (self.r, self.g, self.b) else: return "rgba(%d, %d, %d, %s)" % (self.r, ...
python
def to_css(self): ''' Generate the CSS representation of this RGB color. Returns: str, ``"rgb(...)"`` or ``"rgba(...)"`` ''' if self.a == 1.0: return "rgb(%d, %d, %d)" % (self.r, self.g, self.b) else: return "rgba(%d, %d, %d, %s)" % (self.r, ...
[ "def", "to_css", "(", "self", ")", ":", "if", "self", ".", "a", "==", "1.0", ":", "return", "\"rgb(%d, %d, %d)\"", "%", "(", "self", ".", "r", ",", "self", ".", "g", ",", "self", ".", "b", ")", "else", ":", "return", "\"rgba(%d, %d, %d, %s)\"", "%", ...
Generate the CSS representation of this RGB color. Returns: str, ``"rgb(...)"`` or ``"rgba(...)"``
[ "Generate", "the", "CSS", "representation", "of", "this", "RGB", "color", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/colors/rgb.py#L110-L120
30,274
bokeh/bokeh
bokeh/colors/rgb.py
RGB.to_hsl
def to_hsl(self): ''' Return a corresponding HSL color for this RGB color. Returns: :class:`~bokeh.colors.rgb.RGB` ''' from .hsl import HSL # prevent circular import h, l, s = colorsys.rgb_to_hls(float(self.r)/255, float(self.g)/255, float(self.b)/255) retur...
python
def to_hsl(self): ''' Return a corresponding HSL color for this RGB color. Returns: :class:`~bokeh.colors.rgb.RGB` ''' from .hsl import HSL # prevent circular import h, l, s = colorsys.rgb_to_hls(float(self.r)/255, float(self.g)/255, float(self.b)/255) retur...
[ "def", "to_hsl", "(", "self", ")", ":", "from", ".", "hsl", "import", "HSL", "# prevent circular import", "h", ",", "l", ",", "s", "=", "colorsys", ".", "rgb_to_hls", "(", "float", "(", "self", ".", "r", ")", "/", "255", ",", "float", "(", "self", ...
Return a corresponding HSL color for this RGB color. Returns: :class:`~bokeh.colors.rgb.RGB`
[ "Return", "a", "corresponding", "HSL", "color", "for", "this", "RGB", "color", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/colors/rgb.py#L134-L143
30,275
bokeh/bokeh
bokeh/util/tornado.py
yield_for_all_futures
def yield_for_all_futures(result): """ Converts result into a Future by collapsing any futures inside result. If result is a Future we yield until it's done, then if the value inside the Future is another Future we yield until it's done as well, and so on. """ while True: # This is needed ...
python
def yield_for_all_futures(result): """ Converts result into a Future by collapsing any futures inside result. If result is a Future we yield until it's done, then if the value inside the Future is another Future we yield until it's done as well, and so on. """ while True: # This is needed ...
[ "def", "yield_for_all_futures", "(", "result", ")", ":", "while", "True", ":", "# This is needed for Tornado >= 4.5 where convert_yielded will no", "# longer raise BadYieldError on None", "if", "result", "is", "None", ":", "break", "try", ":", "future", "=", "gen", ".", ...
Converts result into a Future by collapsing any futures inside result. If result is a Future we yield until it's done, then if the value inside the Future is another Future we yield until it's done as well, and so on.
[ "Converts", "result", "into", "a", "Future", "by", "collapsing", "any", "futures", "inside", "result", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/tornado.py#L49-L70
30,276
bokeh/bokeh
bokeh/util/tornado.py
_CallbackGroup.remove_all_callbacks
def remove_all_callbacks(self): """ Removes all registered callbacks.""" for cb_id in list(self._next_tick_callback_removers.keys()): self.remove_next_tick_callback(cb_id) for cb_id in list(self._timeout_callback_removers.keys()): self.remove_timeout_callback(cb_id) ...
python
def remove_all_callbacks(self): """ Removes all registered callbacks.""" for cb_id in list(self._next_tick_callback_removers.keys()): self.remove_next_tick_callback(cb_id) for cb_id in list(self._timeout_callback_removers.keys()): self.remove_timeout_callback(cb_id) ...
[ "def", "remove_all_callbacks", "(", "self", ")", ":", "for", "cb_id", "in", "list", "(", "self", ".", "_next_tick_callback_removers", ".", "keys", "(", ")", ")", ":", "self", ".", "remove_next_tick_callback", "(", "cb_id", ")", "for", "cb_id", "in", "list", ...
Removes all registered callbacks.
[ "Removes", "all", "registered", "callbacks", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/tornado.py#L164-L171
30,277
bokeh/bokeh
bokeh/util/tornado.py
_CallbackGroup.add_next_tick_callback
def add_next_tick_callback(self, callback, callback_id=None): """ Adds a callback to be run on the next tick. Returns an ID that can be used with remove_next_tick_callback.""" def wrapper(*args, **kwargs): # this 'removed' flag is a hack because Tornado has no way # to re...
python
def add_next_tick_callback(self, callback, callback_id=None): """ Adds a callback to be run on the next tick. Returns an ID that can be used with remove_next_tick_callback.""" def wrapper(*args, **kwargs): # this 'removed' flag is a hack because Tornado has no way # to re...
[ "def", "add_next_tick_callback", "(", "self", ",", "callback", ",", "callback_id", "=", "None", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# this 'removed' flag is a hack because Tornado has no way", "# to remove a \"next tick\" ...
Adds a callback to be run on the next tick. Returns an ID that can be used with remove_next_tick_callback.
[ "Adds", "a", "callback", "to", "be", "run", "on", "the", "next", "tick", ".", "Returns", "an", "ID", "that", "can", "be", "used", "with", "remove_next_tick_callback", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/tornado.py#L207-L228
30,278
bokeh/bokeh
bokeh/util/tornado.py
_CallbackGroup.add_timeout_callback
def add_timeout_callback(self, callback, timeout_milliseconds, callback_id=None): """ Adds a callback to be run once after timeout_milliseconds. Returns an ID that can be used with remove_timeout_callback.""" def wrapper(*args, **kwargs): self.remove_timeout_callback(callback_id) ...
python
def add_timeout_callback(self, callback, timeout_milliseconds, callback_id=None): """ Adds a callback to be run once after timeout_milliseconds. Returns an ID that can be used with remove_timeout_callback.""" def wrapper(*args, **kwargs): self.remove_timeout_callback(callback_id) ...
[ "def", "add_timeout_callback", "(", "self", ",", "callback", ",", "timeout_milliseconds", ",", "callback_id", "=", "None", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "remove_timeout_callback", "(", "callback...
Adds a callback to be run once after timeout_milliseconds. Returns an ID that can be used with remove_timeout_callback.
[ "Adds", "a", "callback", "to", "be", "run", "once", "after", "timeout_milliseconds", ".", "Returns", "an", "ID", "that", "can", "be", "used", "with", "remove_timeout_callback", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/tornado.py#L234-L249
30,279
bokeh/bokeh
bokeh/util/tornado.py
_CallbackGroup.add_periodic_callback
def add_periodic_callback(self, callback, period_milliseconds, callback_id=None): """ Adds a callback to be run every period_milliseconds until it is removed. Returns an ID that can be used with remove_periodic_callback.""" cb = _AsyncPeriodic(callback, period_milliseconds, io_loop=self._loop) ...
python
def add_periodic_callback(self, callback, period_milliseconds, callback_id=None): """ Adds a callback to be run every period_milliseconds until it is removed. Returns an ID that can be used with remove_periodic_callback.""" cb = _AsyncPeriodic(callback, period_milliseconds, io_loop=self._loop) ...
[ "def", "add_periodic_callback", "(", "self", ",", "callback", ",", "period_milliseconds", ",", "callback_id", "=", "None", ")", ":", "cb", "=", "_AsyncPeriodic", "(", "callback", ",", "period_milliseconds", ",", "io_loop", "=", "self", ".", "_loop", ")", "call...
Adds a callback to be run every period_milliseconds until it is removed. Returns an ID that can be used with remove_periodic_callback.
[ "Adds", "a", "callback", "to", "be", "run", "every", "period_milliseconds", "until", "it", "is", "removed", ".", "Returns", "an", "ID", "that", "can", "be", "used", "with", "remove_periodic_callback", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/tornado.py#L255-L262
30,280
bokeh/bokeh
bokeh/sphinxext/bokeh_github.py
bokeh_tree
def bokeh_tree(name, rawtext, text, lineno, inliner, options=None, content=None): ''' Link to a URL in the Bokeh GitHub tree, pointing to appropriate tags for releases, or to master otherwise. The link text is simply the URL path supplied, so typical usage might look like: .. code-block:: none ...
python
def bokeh_tree(name, rawtext, text, lineno, inliner, options=None, content=None): ''' Link to a URL in the Bokeh GitHub tree, pointing to appropriate tags for releases, or to master otherwise. The link text is simply the URL path supplied, so typical usage might look like: .. code-block:: none ...
[ "def", "bokeh_tree", "(", "name", ",", "rawtext", ",", "text", ",", "lineno", ",", "inliner", ",", "options", "=", "None", ",", "content", "=", "None", ")", ":", "app", "=", "inliner", ".", "document", ".", "settings", ".", "env", ".", "app", "tag", ...
Link to a URL in the Bokeh GitHub tree, pointing to appropriate tags for releases, or to master otherwise. The link text is simply the URL path supplied, so typical usage might look like: .. code-block:: none All of the examples are located in the :bokeh-tree:`examples` subdirectory o...
[ "Link", "to", "a", "URL", "in", "the", "Bokeh", "GitHub", "tree", "pointing", "to", "appropriate", "tags", "for", "releases", "or", "to", "master", "otherwise", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/sphinxext/bokeh_github.py#L135-L162
30,281
bokeh/bokeh
bokeh/sphinxext/bokeh_github.py
_make_gh_link_node
def _make_gh_link_node(app, rawtext, role, kind, api_type, id, options=None): ''' Return a link to a Bokeh Github resource. Args: app (Sphinx app) : current app rawtext (str) : text being replaced with link node. role (str) : role name kind (str) : resource type (issue, pull, et...
python
def _make_gh_link_node(app, rawtext, role, kind, api_type, id, options=None): ''' Return a link to a Bokeh Github resource. Args: app (Sphinx app) : current app rawtext (str) : text being replaced with link node. role (str) : role name kind (str) : resource type (issue, pull, et...
[ "def", "_make_gh_link_node", "(", "app", ",", "rawtext", ",", "role", ",", "kind", ",", "api_type", ",", "id", ",", "options", "=", "None", ")", ":", "url", "=", "\"%s/%s/%s\"", "%", "(", "_BOKEH_GH", ",", "api_type", ",", "id", ")", "options", "=", ...
Return a link to a Bokeh Github resource. Args: app (Sphinx app) : current app rawtext (str) : text being replaced with link node. role (str) : role name kind (str) : resource type (issue, pull, etc.) api_type (str) : type for api link id : (str) : id of the resource...
[ "Return", "a", "link", "to", "a", "Bokeh", "Github", "resource", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/sphinxext/bokeh_github.py#L177-L195
30,282
bokeh/bokeh
_setup_support.py
show_bokehjs
def show_bokehjs(bokehjs_action, develop=False): ''' Print a useful report after setuptools output describing where and how BokehJS is installed. Args: bokehjs_action (str) : one of 'built', 'installed', or 'packaged' how (or if) BokehJS was installed into the python source tree ...
python
def show_bokehjs(bokehjs_action, develop=False): ''' Print a useful report after setuptools output describing where and how BokehJS is installed. Args: bokehjs_action (str) : one of 'built', 'installed', or 'packaged' how (or if) BokehJS was installed into the python source tree ...
[ "def", "show_bokehjs", "(", "bokehjs_action", ",", "develop", "=", "False", ")", ":", "print", "(", ")", "if", "develop", ":", "print", "(", "\"Installed Bokeh for DEVELOPMENT:\"", ")", "else", ":", "print", "(", "\"Installed Bokeh:\"", ")", "if", "bokehjs_actio...
Print a useful report after setuptools output describing where and how BokehJS is installed. Args: bokehjs_action (str) : one of 'built', 'installed', or 'packaged' how (or if) BokehJS was installed into the python source tree develop (bool, optional) : whether the comm...
[ "Print", "a", "useful", "report", "after", "setuptools", "output", "describing", "where", "and", "how", "BokehJS", "is", "installed", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/_setup_support.py#L50-L74
30,283
bokeh/bokeh
_setup_support.py
show_help
def show_help(bokehjs_action): ''' Print information about extra Bokeh-specific command line options. Args: bokehjs_action (str) : one of 'built', 'installed', or 'packaged' how (or if) BokehJS was installed into the python source tree Returns: None ''' print() if ...
python
def show_help(bokehjs_action): ''' Print information about extra Bokeh-specific command line options. Args: bokehjs_action (str) : one of 'built', 'installed', or 'packaged' how (or if) BokehJS was installed into the python source tree Returns: None ''' print() if ...
[ "def", "show_help", "(", "bokehjs_action", ")", ":", "print", "(", ")", "if", "bokehjs_action", "in", "[", "'built'", ",", "'installed'", "]", ":", "print", "(", "\"Bokeh-specific options available with 'install' or 'develop':\"", ")", "print", "(", ")", "print", ...
Print information about extra Bokeh-specific command line options. Args: bokehjs_action (str) : one of 'built', 'installed', or 'packaged' how (or if) BokehJS was installed into the python source tree Returns: None
[ "Print", "information", "about", "extra", "Bokeh", "-", "specific", "command", "line", "options", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/_setup_support.py#L76-L97
30,284
bokeh/bokeh
_setup_support.py
fixup_building_sdist
def fixup_building_sdist(): ''' Check for 'sdist' and ensure we always build BokehJS when packaging Source distributions do not ship with BokehJS source code, but must ship with a pre-built BokehJS library. This function modifies ``sys.argv`` as necessary so that ``--build-js`` IS present, and ``--inst...
python
def fixup_building_sdist(): ''' Check for 'sdist' and ensure we always build BokehJS when packaging Source distributions do not ship with BokehJS source code, but must ship with a pre-built BokehJS library. This function modifies ``sys.argv`` as necessary so that ``--build-js`` IS present, and ``--inst...
[ "def", "fixup_building_sdist", "(", ")", ":", "if", "\"sdist\"", "in", "sys", ".", "argv", ":", "if", "\"--install-js\"", "in", "sys", ".", "argv", ":", "print", "(", "\"Removing '--install-js' incompatible with 'sdist'\"", ")", "sys", ".", "argv", ".", "remove"...
Check for 'sdist' and ensure we always build BokehJS when packaging Source distributions do not ship with BokehJS source code, but must ship with a pre-built BokehJS library. This function modifies ``sys.argv`` as necessary so that ``--build-js`` IS present, and ``--install-js` is NOT. Returns: ...
[ "Check", "for", "sdist", "and", "ensure", "we", "always", "build", "BokehJS", "when", "packaging" ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/_setup_support.py#L157-L174
30,285
bokeh/bokeh
_setup_support.py
fixup_for_packaged
def fixup_for_packaged(): ''' If we are installing FROM an sdist, then a pre-built BokehJS is already installed in the python source tree. The command line options ``--build-js`` or ``--install-js`` are removed from ``sys.argv``, with a warning. Also adds ``--existing-js`` to ``sys.argv`` to signa...
python
def fixup_for_packaged(): ''' If we are installing FROM an sdist, then a pre-built BokehJS is already installed in the python source tree. The command line options ``--build-js`` or ``--install-js`` are removed from ``sys.argv``, with a warning. Also adds ``--existing-js`` to ``sys.argv`` to signa...
[ "def", "fixup_for_packaged", "(", ")", ":", "if", "exists", "(", "join", "(", "ROOT", ",", "'PKG-INFO'", ")", ")", ":", "if", "\"--build-js\"", "in", "sys", ".", "argv", "or", "\"--install-js\"", "in", "sys", ".", "argv", ":", "print", "(", "SDIST_BUILD_...
If we are installing FROM an sdist, then a pre-built BokehJS is already installed in the python source tree. The command line options ``--build-js`` or ``--install-js`` are removed from ``sys.argv``, with a warning. Also adds ``--existing-js`` to ``sys.argv`` to signal that BokehJS is already pack...
[ "If", "we", "are", "installing", "FROM", "an", "sdist", "then", "a", "pre", "-", "built", "BokehJS", "is", "already", "installed", "in", "the", "python", "source", "tree", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/_setup_support.py#L176-L198
30,286
bokeh/bokeh
_setup_support.py
get_cmdclass
def get_cmdclass(): ''' A ``cmdclass`` that works around a setuptools deficiency. There is no need to build wheels when installing a package, however some versions of setuptools seem to mandate this. This is a hacky workaround that modifies the ``cmdclass`` returned by versioneer so that not having ...
python
def get_cmdclass(): ''' A ``cmdclass`` that works around a setuptools deficiency. There is no need to build wheels when installing a package, however some versions of setuptools seem to mandate this. This is a hacky workaround that modifies the ``cmdclass`` returned by versioneer so that not having ...
[ "def", "get_cmdclass", "(", ")", ":", "cmdclass", "=", "versioneer", ".", "get_cmdclass", "(", ")", "try", ":", "from", "wheel", ".", "bdist_wheel", "import", "bdist_wheel", "except", "ImportError", ":", "# pip is not claiming for bdist_wheel when wheel is not installed...
A ``cmdclass`` that works around a setuptools deficiency. There is no need to build wheels when installing a package, however some versions of setuptools seem to mandate this. This is a hacky workaround that modifies the ``cmdclass`` returned by versioneer so that not having wheel installed is not a fa...
[ "A", "cmdclass", "that", "works", "around", "a", "setuptools", "deficiency", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/_setup_support.py#L203-L223
30,287
bokeh/bokeh
_setup_support.py
jsbuild_prompt
def jsbuild_prompt(): ''' Prompt users whether to build a new BokehJS or install an existing one. Returns: bool : True, if a new build is requested, False otherwise ''' print(BOKEHJS_BUILD_PROMPT) mapping = {"1": True, "2": False} value = input("Choice? ") while value not in mappin...
python
def jsbuild_prompt(): ''' Prompt users whether to build a new BokehJS or install an existing one. Returns: bool : True, if a new build is requested, False otherwise ''' print(BOKEHJS_BUILD_PROMPT) mapping = {"1": True, "2": False} value = input("Choice? ") while value not in mappin...
[ "def", "jsbuild_prompt", "(", ")", ":", "print", "(", "BOKEHJS_BUILD_PROMPT", ")", "mapping", "=", "{", "\"1\"", ":", "True", ",", "\"2\"", ":", "False", "}", "value", "=", "input", "(", "\"Choice? \"", ")", "while", "value", "not", "in", "mapping", ":",...
Prompt users whether to build a new BokehJS or install an existing one. Returns: bool : True, if a new build is requested, False otherwise
[ "Prompt", "users", "whether", "to", "build", "a", "new", "BokehJS", "or", "install", "an", "existing", "one", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/_setup_support.py#L245-L258
30,288
bokeh/bokeh
_setup_support.py
install_js
def install_js(): ''' Copy built BokehJS files into the Python source tree. Returns: None ''' target_jsdir = join(SERVER, 'static', 'js') target_cssdir = join(SERVER, 'static', 'css') target_tslibdir = join(SERVER, 'static', 'lib') STATIC_ASSETS = [ join(JS, 'bokeh.js'), ...
python
def install_js(): ''' Copy built BokehJS files into the Python source tree. Returns: None ''' target_jsdir = join(SERVER, 'static', 'js') target_cssdir = join(SERVER, 'static', 'css') target_tslibdir = join(SERVER, 'static', 'lib') STATIC_ASSETS = [ join(JS, 'bokeh.js'), ...
[ "def", "install_js", "(", ")", ":", "target_jsdir", "=", "join", "(", "SERVER", ",", "'static'", ",", "'js'", ")", "target_cssdir", "=", "join", "(", "SERVER", ",", "'static'", ",", "'css'", ")", "target_tslibdir", "=", "join", "(", "SERVER", ",", "'stat...
Copy built BokehJS files into the Python source tree. Returns: None
[ "Copy", "built", "BokehJS", "files", "into", "the", "Python", "source", "tree", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/_setup_support.py#L340-L381
30,289
bokeh/bokeh
bokeh/util/hex.py
hexbin
def hexbin(x, y, size, orientation="pointytop", aspect_scale=1): ''' Perform an equal-weight binning of data points into hexagonal tiles. For more sophisticated use cases, e.g. weighted binning or scaling individual tiles proportional to some other quantity, consider using HoloViews. Args: ...
python
def hexbin(x, y, size, orientation="pointytop", aspect_scale=1): ''' Perform an equal-weight binning of data points into hexagonal tiles. For more sophisticated use cases, e.g. weighted binning or scaling individual tiles proportional to some other quantity, consider using HoloViews. Args: ...
[ "def", "hexbin", "(", "x", ",", "y", ",", "size", ",", "orientation", "=", "\"pointytop\"", ",", "aspect_scale", "=", "1", ")", ":", "pd", "=", "import_required", "(", "'pandas'", ",", "'hexbin requires pandas to be installed'", ")", "q", ",", "r", "=", "c...
Perform an equal-weight binning of data points into hexagonal tiles. For more sophisticated use cases, e.g. weighted binning or scaling individual tiles proportional to some other quantity, consider using HoloViews. Args: x (array[float]) : A NumPy array of x-coordinates for binnin...
[ "Perform", "an", "equal", "-", "weight", "binning", "of", "data", "points", "into", "hexagonal", "tiles", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/hex.py#L152-L204
30,290
bokeh/bokeh
bokeh/core/property/container.py
ColumnData.from_json
def from_json(self, json, models=None): ''' Decodes column source data encoded as lists or base64 strings. ''' if json is None: return None elif not isinstance(json, dict): raise DeserializationError("%s expected a dict or None, got %s" % (self, json)) new...
python
def from_json(self, json, models=None): ''' Decodes column source data encoded as lists or base64 strings. ''' if json is None: return None elif not isinstance(json, dict): raise DeserializationError("%s expected a dict or None, got %s" % (self, json)) new...
[ "def", "from_json", "(", "self", ",", "json", ",", "models", "=", "None", ")", ":", "if", "json", "is", "None", ":", "return", "None", "elif", "not", "isinstance", "(", "json", ",", "dict", ")", ":", "raise", "DeserializationError", "(", "\"%s expected a...
Decodes column source data encoded as lists or base64 strings.
[ "Decodes", "column", "source", "data", "encoded", "as", "lists", "or", "base64", "strings", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/container.py#L234-L257
30,291
bokeh/bokeh
bokeh/util/serialization.py
convert_timedelta_type
def convert_timedelta_type(obj): ''' Convert any recognized timedelta value to floating point absolute milliseconds. Arg: obj (object) : the object to convert Returns: float : milliseconds ''' if isinstance(obj, dt.timedelta): return obj.total_seconds() * 1000. eli...
python
def convert_timedelta_type(obj): ''' Convert any recognized timedelta value to floating point absolute milliseconds. Arg: obj (object) : the object to convert Returns: float : milliseconds ''' if isinstance(obj, dt.timedelta): return obj.total_seconds() * 1000. eli...
[ "def", "convert_timedelta_type", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "dt", ".", "timedelta", ")", ":", "return", "obj", ".", "total_seconds", "(", ")", "*", "1000.", "elif", "isinstance", "(", "obj", ",", "np", ".", "timedelta64", ...
Convert any recognized timedelta value to floating point absolute milliseconds. Arg: obj (object) : the object to convert Returns: float : milliseconds
[ "Convert", "any", "recognized", "timedelta", "value", "to", "floating", "point", "absolute", "milliseconds", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L136-L150
30,292
bokeh/bokeh
bokeh/util/serialization.py
convert_datetime_type
def convert_datetime_type(obj): ''' Convert any recognized date, time, or datetime value to floating point milliseconds since epoch. Arg: obj (object) : the object to convert Returns: float : milliseconds ''' # Pandas NaT if pd and obj is pd.NaT: return np.nan ...
python
def convert_datetime_type(obj): ''' Convert any recognized date, time, or datetime value to floating point milliseconds since epoch. Arg: obj (object) : the object to convert Returns: float : milliseconds ''' # Pandas NaT if pd and obj is pd.NaT: return np.nan ...
[ "def", "convert_datetime_type", "(", "obj", ")", ":", "# Pandas NaT", "if", "pd", "and", "obj", "is", "pd", ".", "NaT", ":", "return", "np", ".", "nan", "# Pandas Period", "if", "pd", "and", "isinstance", "(", "obj", ",", "pd", ".", "Period", ")", ":",...
Convert any recognized date, time, or datetime value to floating point milliseconds since epoch. Arg: obj (object) : the object to convert Returns: float : milliseconds
[ "Convert", "any", "recognized", "date", "time", "or", "datetime", "value", "to", "floating", "point", "milliseconds", "since", "epoch", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L152-L193
30,293
bokeh/bokeh
bokeh/util/serialization.py
convert_datetime_array
def convert_datetime_array(array): ''' Convert NumPy datetime arrays to arrays to milliseconds since epoch. Args: array : (obj) A NumPy array of datetime to convert If the value passed in is not a NumPy array, it will be returned as-is. Returns: array ''' ...
python
def convert_datetime_array(array): ''' Convert NumPy datetime arrays to arrays to milliseconds since epoch. Args: array : (obj) A NumPy array of datetime to convert If the value passed in is not a NumPy array, it will be returned as-is. Returns: array ''' ...
[ "def", "convert_datetime_array", "(", "array", ")", ":", "if", "not", "isinstance", "(", "array", ",", "np", ".", "ndarray", ")", ":", "return", "array", "try", ":", "dt2001", "=", "np", ".", "datetime64", "(", "'2001'", ")", "legacy_datetime64", "=", "(...
Convert NumPy datetime arrays to arrays to milliseconds since epoch. Args: array : (obj) A NumPy array of datetime to convert If the value passed in is not a NumPy array, it will be returned as-is. Returns: array
[ "Convert", "NumPy", "datetime", "arrays", "to", "arrays", "to", "milliseconds", "since", "epoch", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L195-L238
30,294
bokeh/bokeh
bokeh/util/serialization.py
make_id
def make_id(): ''' Return a new unique ID for a Bokeh object. Normally this function will return simple monotonically increasing integer IDs (as strings) for identifying Bokeh objects within a Document. However, if it is desirable to have globally unique for every object, this behavior can be overr...
python
def make_id(): ''' Return a new unique ID for a Bokeh object. Normally this function will return simple monotonically increasing integer IDs (as strings) for identifying Bokeh objects within a Document. However, if it is desirable to have globally unique for every object, this behavior can be overr...
[ "def", "make_id", "(", ")", ":", "global", "_simple_id", "if", "settings", ".", "simple_ids", "(", "True", ")", ":", "with", "_simple_id_lock", ":", "_simple_id", "+=", "1", "return", "str", "(", "_simple_id", ")", "else", ":", "return", "make_globally_uniqu...
Return a new unique ID for a Bokeh object. Normally this function will return simple monotonically increasing integer IDs (as strings) for identifying Bokeh objects within a Document. However, if it is desirable to have globally unique for every object, this behavior can be overridden by setting the en...
[ "Return", "a", "new", "unique", "ID", "for", "a", "Bokeh", "object", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L240-L259
30,295
bokeh/bokeh
bokeh/util/serialization.py
transform_array
def transform_array(array, force_list=False, buffers=None): ''' Transform a NumPy arrays into serialized format Converts un-serializable dtypes and returns JSON serializable format Args: array (np.ndarray) : a NumPy array to be transformed force_list (bool, optional) : whether to only ...
python
def transform_array(array, force_list=False, buffers=None): ''' Transform a NumPy arrays into serialized format Converts un-serializable dtypes and returns JSON serializable format Args: array (np.ndarray) : a NumPy array to be transformed force_list (bool, optional) : whether to only ...
[ "def", "transform_array", "(", "array", ",", "force_list", "=", "False", ",", "buffers", "=", "None", ")", ":", "array", "=", "convert_datetime_array", "(", "array", ")", "return", "serialize_array", "(", "array", ",", "force_list", "=", "force_list", ",", "...
Transform a NumPy arrays into serialized format Converts un-serializable dtypes and returns JSON serializable format Args: array (np.ndarray) : a NumPy array to be transformed force_list (bool, optional) : whether to only output to standard lists This function can encode some d...
[ "Transform", "a", "NumPy", "arrays", "into", "serialized", "format" ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L295-L328
30,296
bokeh/bokeh
bokeh/util/serialization.py
transform_array_to_list
def transform_array_to_list(array): ''' Transforms a NumPy array into a list of values Args: array (np.nadarray) : the NumPy array series to transform Returns: list or dict ''' if (array.dtype.kind in ('u', 'i', 'f') and (~np.isfinite(array)).any()): transformed = array.as...
python
def transform_array_to_list(array): ''' Transforms a NumPy array into a list of values Args: array (np.nadarray) : the NumPy array series to transform Returns: list or dict ''' if (array.dtype.kind in ('u', 'i', 'f') and (~np.isfinite(array)).any()): transformed = array.as...
[ "def", "transform_array_to_list", "(", "array", ")", ":", "if", "(", "array", ".", "dtype", ".", "kind", "in", "(", "'u'", ",", "'i'", ",", "'f'", ")", "and", "(", "~", "np", ".", "isfinite", "(", "array", ")", ")", ".", "any", "(", ")", ")", "...
Transforms a NumPy array into a list of values Args: array (np.nadarray) : the NumPy array series to transform Returns: list or dict
[ "Transforms", "a", "NumPy", "array", "into", "a", "list", "of", "values" ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L330-L350
30,297
bokeh/bokeh
bokeh/util/serialization.py
transform_series
def transform_series(series, force_list=False, buffers=None): ''' Transforms a Pandas series into serialized form Args: series (pd.Series) : the Pandas series to transform force_list (bool, optional) : whether to only output to standard lists This function can encode some dtypes usi...
python
def transform_series(series, force_list=False, buffers=None): ''' Transforms a Pandas series into serialized form Args: series (pd.Series) : the Pandas series to transform force_list (bool, optional) : whether to only output to standard lists This function can encode some dtypes usi...
[ "def", "transform_series", "(", "series", ",", "force_list", "=", "False", ",", "buffers", "=", "None", ")", ":", "# not checking for pd here, this function should only be called if it", "# is already known that series is a Pandas Series type", "if", "isinstance", "(", "series"...
Transforms a Pandas series into serialized form Args: series (pd.Series) : the Pandas series to transform force_list (bool, optional) : whether to only output to standard lists This function can encode some dtypes using a binary encoding, but setting this argument to True wi...
[ "Transforms", "a", "Pandas", "series", "into", "serialized", "form" ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L352-L384
30,298
bokeh/bokeh
bokeh/util/serialization.py
serialize_array
def serialize_array(array, force_list=False, buffers=None): ''' Transforms a NumPy array into serialized form. Args: array (np.ndarray) : the NumPy array to transform force_list (bool, optional) : whether to only output to standard lists This function can encode some dtypes using a ...
python
def serialize_array(array, force_list=False, buffers=None): ''' Transforms a NumPy array into serialized form. Args: array (np.ndarray) : the NumPy array to transform force_list (bool, optional) : whether to only output to standard lists This function can encode some dtypes using a ...
[ "def", "serialize_array", "(", "array", ",", "force_list", "=", "False", ",", "buffers", "=", "None", ")", ":", "if", "isinstance", "(", "array", ",", "np", ".", "ma", ".", "MaskedArray", ")", ":", "array", "=", "array", ".", "filled", "(", "np", "."...
Transforms a NumPy array into serialized form. Args: array (np.ndarray) : the NumPy array to transform force_list (bool, optional) : whether to only output to standard lists This function can encode some dtypes using a binary encoding, but setting this argument to True will ...
[ "Transforms", "a", "NumPy", "array", "into", "serialized", "form", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L386-L421
30,299
bokeh/bokeh
bokeh/util/serialization.py
traverse_data
def traverse_data(obj, use_numpy=True, buffers=None): ''' Recursively traverse an object until a flat list is found. If NumPy is available, the flat list is converted to a numpy array and passed to transform_array() to handle ``nan``, ``inf``, and ``-inf``. Otherwise, iterate through all items, co...
python
def traverse_data(obj, use_numpy=True, buffers=None): ''' Recursively traverse an object until a flat list is found. If NumPy is available, the flat list is converted to a numpy array and passed to transform_array() to handle ``nan``, ``inf``, and ``-inf``. Otherwise, iterate through all items, co...
[ "def", "traverse_data", "(", "obj", ",", "use_numpy", "=", "True", ",", "buffers", "=", "None", ")", ":", "if", "use_numpy", "and", "all", "(", "isinstance", "(", "el", ",", "np", ".", "ndarray", ")", "for", "el", "in", "obj", ")", ":", "return", "...
Recursively traverse an object until a flat list is found. If NumPy is available, the flat list is converted to a numpy array and passed to transform_array() to handle ``nan``, ``inf``, and ``-inf``. Otherwise, iterate through all items, converting non-JSON items Args: obj (list) : a list...
[ "Recursively", "traverse", "an", "object", "until", "a", "flat", "list", "is", "found", "." ]
dc8cf49e4e4302fd38537ad089ece81fbcca4737
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L423-L456