repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
raghakot/keras-vis | docs/md_autogen.py | order_by_line_nos | def order_by_line_nos(objs, line_nos):
"""Orders the set of `objs` by `line_nos`
"""
ordering = sorted(range(len(line_nos)), key=line_nos.__getitem__)
return [objs[i] for i in ordering] | python | def order_by_line_nos(objs, line_nos):
"""Orders the set of `objs` by `line_nos`
"""
ordering = sorted(range(len(line_nos)), key=line_nos.__getitem__)
return [objs[i] for i in ordering] | [
"def",
"order_by_line_nos",
"(",
"objs",
",",
"line_nos",
")",
":",
"ordering",
"=",
"sorted",
"(",
"range",
"(",
"len",
"(",
"line_nos",
")",
")",
",",
"key",
"=",
"line_nos",
".",
"__getitem__",
")",
"return",
"[",
"objs",
"[",
"i",
"]",
"for",
"i"... | Orders the set of `objs` by `line_nos` | [
"Orders",
"the",
"set",
"of",
"objs",
"by",
"line_nos"
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/docs/md_autogen.py#L71-L75 | train | Orders the set of objects by line_nos | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | docs/md_autogen.py | to_md_file | def to_md_file(string, filename, out_path="."):
"""Import a module path and create an api doc from it
Args:
string (str): string with line breaks to write to file.
filename (str): filename without the .md
out_path (str): The output directory
"""
md_file = "%s.md" % filename
... | python | def to_md_file(string, filename, out_path="."):
"""Import a module path and create an api doc from it
Args:
string (str): string with line breaks to write to file.
filename (str): filename without the .md
out_path (str): The output directory
"""
md_file = "%s.md" % filename
... | [
"def",
"to_md_file",
"(",
"string",
",",
"filename",
",",
"out_path",
"=",
"\".\"",
")",
":",
"md_file",
"=",
"\"%s.md\"",
"%",
"filename",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"out_path",
",",
"md_file",
")",
",",
"\"w\"",
")",
... | Import a module path and create an api doc from it
Args:
string (str): string with line breaks to write to file.
filename (str): filename without the .md
out_path (str): The output directory | [
"Import",
"a",
"module",
"path",
"and",
"create",
"an",
"api",
"doc",
"from",
"it"
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/docs/md_autogen.py#L78-L89 | train | Write a string with line breaks to a. md file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | docs/md_autogen.py | MarkdownAPIGenerator.get_src_path | def get_src_path(self, obj, append_base=True):
"""Creates a src path string with line info for use as markdown link.
"""
path = getsourcefile(obj)
if self.src_root not in path:
# this can happen with e.g.
# inlinefunc-wrapped functions
if hasattr(obj, ... | python | def get_src_path(self, obj, append_base=True):
"""Creates a src path string with line info for use as markdown link.
"""
path = getsourcefile(obj)
if self.src_root not in path:
# this can happen with e.g.
# inlinefunc-wrapped functions
if hasattr(obj, ... | [
"def",
"get_src_path",
"(",
"self",
",",
"obj",
",",
"append_base",
"=",
"True",
")",
":",
"path",
"=",
"getsourcefile",
"(",
"obj",
")",
"if",
"self",
".",
"src_root",
"not",
"in",
"path",
":",
"# this can happen with e.g.",
"# inlinefunc-wrapped functions",
... | Creates a src path string with line info for use as markdown link. | [
"Creates",
"a",
"src",
"path",
"string",
"with",
"line",
"info",
"for",
"use",
"as",
"markdown",
"link",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/docs/md_autogen.py#L116-L136 | train | Creates a src path string with line info for use as markdown link. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | docs/md_autogen.py | MarkdownAPIGenerator.doc2md | def doc2md(self, func):
"""Parse docstring (parsed with getdoc) according to Google-style
formatting and convert to markdown. We support the following
Google style syntax:
Args, Kwargs:
argname (type): text
freeform text
Returns, Yields:
retna... | python | def doc2md(self, func):
"""Parse docstring (parsed with getdoc) according to Google-style
formatting and convert to markdown. We support the following
Google style syntax:
Args, Kwargs:
argname (type): text
freeform text
Returns, Yields:
retna... | [
"def",
"doc2md",
"(",
"self",
",",
"func",
")",
":",
"doc",
"=",
"getdoc",
"(",
"func",
")",
"or",
"\"\"",
"blockindent",
"=",
"0",
"argindent",
"=",
"1",
"out",
"=",
"[",
"]",
"for",
"line",
"in",
"doc",
".",
"split",
"(",
"\"\\n\"",
")",
":",
... | Parse docstring (parsed with getdoc) according to Google-style
formatting and convert to markdown. We support the following
Google style syntax:
Args, Kwargs:
argname (type): text
freeform text
Returns, Yields:
retname (type): text
freefor... | [
"Parse",
"docstring",
"(",
"parsed",
"with",
"getdoc",
")",
"according",
"to",
"Google",
"-",
"style",
"formatting",
"and",
"convert",
"to",
"markdown",
".",
"We",
"support",
"the",
"following",
"Google",
"style",
"syntax",
":"
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/docs/md_autogen.py#L138-L184 | train | Parse the docstring of a function and return a markdown string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | docs/md_autogen.py | MarkdownAPIGenerator.func2md | def func2md(self, func, clsname=None, names=None, depth=3):
"""Takes a function (or method) and documents it.
Args:
clsname (str, optional): class name to prepend to funcname.
depth (int, optional): number of ### to append to function name
"""
section = "#" * de... | python | def func2md(self, func, clsname=None, names=None, depth=3):
"""Takes a function (or method) and documents it.
Args:
clsname (str, optional): class name to prepend to funcname.
depth (int, optional): number of ### to append to function name
"""
section = "#" * de... | [
"def",
"func2md",
"(",
"self",
",",
"func",
",",
"clsname",
"=",
"None",
",",
"names",
"=",
"None",
",",
"depth",
"=",
"3",
")",
":",
"section",
"=",
"\"#\"",
"*",
"depth",
"if",
"names",
"is",
"None",
":",
"names",
"=",
"[",
"func",
".",
"__name... | Takes a function (or method) and documents it.
Args:
clsname (str, optional): class name to prepend to funcname.
depth (int, optional): number of ### to append to function name | [
"Takes",
"a",
"function",
"(",
"or",
"method",
")",
"and",
"documents",
"it",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/docs/md_autogen.py#L186-L279 | train | Takes a function or method and returns a string that contains the contents of the function and its docstring. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | docs/md_autogen.py | MarkdownAPIGenerator.class2md | def class2md(self, cls, depth=2):
"""Takes a class and creates markdown text to document its methods and variables.
"""
section = "#" * depth
subsection = "#" * (depth + 2)
clsname = cls.__name__
modname = cls.__module__
header = clsname
path = self.get_s... | python | def class2md(self, cls, depth=2):
"""Takes a class and creates markdown text to document its methods and variables.
"""
section = "#" * depth
subsection = "#" * (depth + 2)
clsname = cls.__name__
modname = cls.__module__
header = clsname
path = self.get_s... | [
"def",
"class2md",
"(",
"self",
",",
"cls",
",",
"depth",
"=",
"2",
")",
":",
"section",
"=",
"\"#\"",
"*",
"depth",
"subsection",
"=",
"\"#\"",
"*",
"(",
"depth",
"+",
"2",
")",
"clsname",
"=",
"cls",
".",
"__name__",
"modname",
"=",
"cls",
".",
... | Takes a class and creates markdown text to document its methods and variables. | [
"Takes",
"a",
"class",
"and",
"creates",
"markdown",
"text",
"to",
"document",
"its",
"methods",
"and",
"variables",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/docs/md_autogen.py#L281-L325 | train | Takes a class and creates markdown text to document its methods and variables. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | docs/md_autogen.py | MarkdownAPIGenerator.module2md | def module2md(self, module):
"""Takes an imported module object and create a Markdown string containing functions and classes.
"""
modname = module.__name__
path = self.get_src_path(module, append_base=False)
path = "[{}]({})".format(path, os.path.join(self.github_link, path))
... | python | def module2md(self, module):
"""Takes an imported module object and create a Markdown string containing functions and classes.
"""
modname = module.__name__
path = self.get_src_path(module, append_base=False)
path = "[{}]({})".format(path, os.path.join(self.github_link, path))
... | [
"def",
"module2md",
"(",
"self",
",",
"module",
")",
":",
"modname",
"=",
"module",
".",
"__name__",
"path",
"=",
"self",
".",
"get_src_path",
"(",
"module",
",",
"append_base",
"=",
"False",
")",
"path",
"=",
"\"[{}]({})\"",
".",
"format",
"(",
"path",
... | Takes an imported module object and create a Markdown string containing functions and classes. | [
"Takes",
"an",
"imported",
"module",
"object",
"and",
"create",
"a",
"Markdown",
"string",
"containing",
"functions",
"and",
"classes",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/docs/md_autogen.py#L327-L392 | train | Takes an imported module object and creates a Markdown string containing functions and classes and classes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/visualization/saliency.py | _find_penultimate_layer | def _find_penultimate_layer(model, layer_idx, penultimate_layer_idx):
"""Searches for the nearest penultimate `Conv` or `Pooling` layer.
Args:
model: The `keras.models.Model` instance.
layer_idx: The layer index within `model.layers`.
penultimate_layer_idx: The pre-layer to `layer_idx`.... | python | def _find_penultimate_layer(model, layer_idx, penultimate_layer_idx):
"""Searches for the nearest penultimate `Conv` or `Pooling` layer.
Args:
model: The `keras.models.Model` instance.
layer_idx: The layer index within `model.layers`.
penultimate_layer_idx: The pre-layer to `layer_idx`.... | [
"def",
"_find_penultimate_layer",
"(",
"model",
",",
"layer_idx",
",",
"penultimate_layer_idx",
")",
":",
"if",
"penultimate_layer_idx",
"is",
"None",
":",
"for",
"idx",
",",
"layer",
"in",
"utils",
".",
"reverse_enumerate",
"(",
"model",
".",
"layers",
"[",
"... | Searches for the nearest penultimate `Conv` or `Pooling` layer.
Args:
model: The `keras.models.Model` instance.
layer_idx: The layer index within `model.layers`.
penultimate_layer_idx: The pre-layer to `layer_idx`. If set to None, the nearest penultimate
`Conv` or `Pooling` laye... | [
"Searches",
"for",
"the",
"nearest",
"penultimate",
"Conv",
"or",
"Pooling",
"layer",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/visualization/saliency.py#L17-L47 | train | Searches for the nearest penultimate CNN or Pooling layer. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/visualization/saliency.py | visualize_saliency_with_losses | def visualize_saliency_with_losses(input_tensor, losses, seed_input, wrt_tensor=None, grad_modifier='absolute', keepdims=False):
"""Generates an attention heatmap over the `seed_input` by using positive gradients of `input_tensor`
with respect to weighted `losses`.
This function is intended for advanced us... | python | def visualize_saliency_with_losses(input_tensor, losses, seed_input, wrt_tensor=None, grad_modifier='absolute', keepdims=False):
"""Generates an attention heatmap over the `seed_input` by using positive gradients of `input_tensor`
with respect to weighted `losses`.
This function is intended for advanced us... | [
"def",
"visualize_saliency_with_losses",
"(",
"input_tensor",
",",
"losses",
",",
"seed_input",
",",
"wrt_tensor",
"=",
"None",
",",
"grad_modifier",
"=",
"'absolute'",
",",
"keepdims",
"=",
"False",
")",
":",
"opt",
"=",
"Optimizer",
"(",
"input_tensor",
",",
... | Generates an attention heatmap over the `seed_input` by using positive gradients of `input_tensor`
with respect to weighted `losses`.
This function is intended for advanced use cases where a custom loss is desired. For common use cases,
refer to `visualize_class_saliency` or `visualize_regression_saliency`... | [
"Generates",
"an",
"attention",
"heatmap",
"over",
"the",
"seed_input",
"by",
"using",
"positive",
"gradients",
"of",
"input_tensor",
"with",
"respect",
"to",
"weighted",
"losses",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/visualization/saliency.py#L50-L84 | train | Generates an attention heatmap over the seed_input with respect to weighted losses. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/visualization/saliency.py | visualize_saliency | def visualize_saliency(model, layer_idx, filter_indices, seed_input, wrt_tensor=None,
backprop_modifier=None, grad_modifier='absolute', keepdims=False):
"""Generates an attention heatmap over the `seed_input` for maximizing `filter_indices`
output in the given `layer_idx`.
Args:
... | python | def visualize_saliency(model, layer_idx, filter_indices, seed_input, wrt_tensor=None,
backprop_modifier=None, grad_modifier='absolute', keepdims=False):
"""Generates an attention heatmap over the `seed_input` for maximizing `filter_indices`
output in the given `layer_idx`.
Args:
... | [
"def",
"visualize_saliency",
"(",
"model",
",",
"layer_idx",
",",
"filter_indices",
",",
"seed_input",
",",
"wrt_tensor",
"=",
"None",
",",
"backprop_modifier",
"=",
"None",
",",
"grad_modifier",
"=",
"'absolute'",
",",
"keepdims",
"=",
"False",
")",
":",
"if"... | Generates an attention heatmap over the `seed_input` for maximizing `filter_indices`
output in the given `layer_idx`.
Args:
model: The `keras.models.Model` instance. The model input shape must be: `(samples, channels, image_dims...)`
if `image_data_format=channels_first` or `(samples, image... | [
"Generates",
"an",
"attention",
"heatmap",
"over",
"the",
"seed_input",
"for",
"maximizing",
"filter_indices",
"output",
"in",
"the",
"given",
"layer_idx",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/visualization/saliency.py#L87-L134 | train | Generates a visualised Saliency layer over the seed_input for maximizing filter_indices. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/visualization/saliency.py | visualize_cam_with_losses | def visualize_cam_with_losses(input_tensor, losses, seed_input, penultimate_layer, grad_modifier=None):
"""Generates a gradient based class activation map (CAM) by using positive gradients of `input_tensor`
with respect to weighted `losses`.
For details on grad-CAM, see the paper:
[Grad-CAM: Why did yo... | python | def visualize_cam_with_losses(input_tensor, losses, seed_input, penultimate_layer, grad_modifier=None):
"""Generates a gradient based class activation map (CAM) by using positive gradients of `input_tensor`
with respect to weighted `losses`.
For details on grad-CAM, see the paper:
[Grad-CAM: Why did yo... | [
"def",
"visualize_cam_with_losses",
"(",
"input_tensor",
",",
"losses",
",",
"seed_input",
",",
"penultimate_layer",
",",
"grad_modifier",
"=",
"None",
")",
":",
"penultimate_output",
"=",
"penultimate_layer",
".",
"output",
"opt",
"=",
"Optimizer",
"(",
"input_tens... | Generates a gradient based class activation map (CAM) by using positive gradients of `input_tensor`
with respect to weighted `losses`.
For details on grad-CAM, see the paper:
[Grad-CAM: Why did you say that? Visual Explanations from Deep Networks via Gradient-based Localization]
(https://arxiv.org/pdf/... | [
"Generates",
"a",
"gradient",
"based",
"class",
"activation",
"map",
"(",
"CAM",
")",
"by",
"using",
"positive",
"gradients",
"of",
"input_tensor",
"with",
"respect",
"to",
"weighted",
"losses",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/visualization/saliency.py#L137-L196 | train | Generates a gradient based class activation map by using positive gradients of input_tensor with respect to weighted losses. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/visualization/saliency.py | visualize_cam | def visualize_cam(model, layer_idx, filter_indices,
seed_input, penultimate_layer_idx=None,
backprop_modifier=None, grad_modifier=None):
"""Generates a gradient based class activation map (grad-CAM) that maximizes the outputs of
`filter_indices` in `layer_idx`.
Args:
... | python | def visualize_cam(model, layer_idx, filter_indices,
seed_input, penultimate_layer_idx=None,
backprop_modifier=None, grad_modifier=None):
"""Generates a gradient based class activation map (grad-CAM) that maximizes the outputs of
`filter_indices` in `layer_idx`.
Args:
... | [
"def",
"visualize_cam",
"(",
"model",
",",
"layer_idx",
",",
"filter_indices",
",",
"seed_input",
",",
"penultimate_layer_idx",
"=",
"None",
",",
"backprop_modifier",
"=",
"None",
",",
"grad_modifier",
"=",
"None",
")",
":",
"if",
"backprop_modifier",
"is",
"not... | Generates a gradient based class activation map (grad-CAM) that maximizes the outputs of
`filter_indices` in `layer_idx`.
Args:
model: The `keras.models.Model` instance. The model input shape must be: `(samples, channels, image_dims...)`
if `image_data_format=channels_first` or `(samples, i... | [
"Generates",
"a",
"gradient",
"based",
"class",
"activation",
"map",
"(",
"grad",
"-",
"CAM",
")",
"that",
"maximizes",
"the",
"outputs",
"of",
"filter_indices",
"in",
"layer_idx",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/visualization/saliency.py#L199-L245 | train | Generates a gradient based class activation map that maximizes the outputs of filter_indices in layer_idx. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/backend/tensorflow_backend.py | modify_model_backprop | def modify_model_backprop(model, backprop_modifier):
"""Creates a copy of model by modifying all activations to use a custom op to modify the backprop behavior.
Args:
model: The `keras.models.Model` instance.
backprop_modifier: One of `{'guided', 'rectified'}`
Returns:
A copy of m... | python | def modify_model_backprop(model, backprop_modifier):
"""Creates a copy of model by modifying all activations to use a custom op to modify the backprop behavior.
Args:
model: The `keras.models.Model` instance.
backprop_modifier: One of `{'guided', 'rectified'}`
Returns:
A copy of m... | [
"def",
"modify_model_backprop",
"(",
"model",
",",
"backprop_modifier",
")",
":",
"# The general strategy is as follows:",
"# - Save original model so that upstream callers don't see unexpected results with their models.",
"# - Call backend specific function that registers the custom op and load... | Creates a copy of model by modifying all activations to use a custom op to modify the backprop behavior.
Args:
model: The `keras.models.Model` instance.
backprop_modifier: One of `{'guided', 'rectified'}`
Returns:
A copy of model with modified activations for backwards pass. | [
"Creates",
"a",
"copy",
"of",
"model",
"by",
"modifying",
"all",
"activations",
"to",
"use",
"a",
"custom",
"op",
"to",
"modify",
"the",
"backprop",
"behavior",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/backend/tensorflow_backend.py#L53-L103 | train | Creates a copy of model with modified activations. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/regularizers.py | normalize | def normalize(input_tensor, output_tensor):
"""Normalizes the `output_tensor` with respect to `input_tensor` dimensions.
This makes regularizer weight factor more or less uniform across various input image dimensions.
Args:
input_tensor: An tensor of shape: `(samples, channels, image_dims...)` if `... | python | def normalize(input_tensor, output_tensor):
"""Normalizes the `output_tensor` with respect to `input_tensor` dimensions.
This makes regularizer weight factor more or less uniform across various input image dimensions.
Args:
input_tensor: An tensor of shape: `(samples, channels, image_dims...)` if `... | [
"def",
"normalize",
"(",
"input_tensor",
",",
"output_tensor",
")",
":",
"image_dims",
"=",
"utils",
".",
"get_img_shape",
"(",
"input_tensor",
")",
"[",
"1",
":",
"]",
"return",
"output_tensor",
"/",
"np",
".",
"prod",
"(",
"image_dims",
")"
] | Normalizes the `output_tensor` with respect to `input_tensor` dimensions.
This makes regularizer weight factor more or less uniform across various input image dimensions.
Args:
input_tensor: An tensor of shape: `(samples, channels, image_dims...)` if `image_data_format=
channels_first` ... | [
"Normalizes",
"the",
"output_tensor",
"with",
"respect",
"to",
"input_tensor",
"dimensions",
".",
"This",
"makes",
"regularizer",
"weight",
"factor",
"more",
"or",
"less",
"uniform",
"across",
"various",
"input",
"image",
"dimensions",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/regularizers.py#L11-L24 | train | Normalizes the output_tensor with respect to input_tensor dimensions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/regularizers.py | TotalVariation.build_loss | def build_loss(self):
r"""Implements the N-dim version of function
$$TV^{\beta}(x) = \sum_{whc} \left ( \left ( x(h, w+1, c) - x(h, w, c) \right )^{2} +
\left ( x(h+1, w, c) - x(h, w, c) \right )^{2} \right )^{\frac{\beta}{2}}$$
to return total variation for all images in the batch.
... | python | def build_loss(self):
r"""Implements the N-dim version of function
$$TV^{\beta}(x) = \sum_{whc} \left ( \left ( x(h, w+1, c) - x(h, w, c) \right )^{2} +
\left ( x(h+1, w, c) - x(h, w, c) \right )^{2} \right )^{\frac{\beta}{2}}$$
to return total variation for all images in the batch.
... | [
"def",
"build_loss",
"(",
"self",
")",
":",
"image_dims",
"=",
"K",
".",
"ndim",
"(",
"self",
".",
"img",
")",
"-",
"2",
"# Constructing slice [1:] + [:-1] * (image_dims - 1) and [:-1] * (image_dims)",
"start_slice",
"=",
"[",
"slice",
"(",
"1",
",",
"None",
","... | r"""Implements the N-dim version of function
$$TV^{\beta}(x) = \sum_{whc} \left ( \left ( x(h, w+1, c) - x(h, w, c) \right )^{2} +
\left ( x(h+1, w, c) - x(h, w, c) \right )^{2} \right )^{\frac{\beta}{2}}$$
to return total variation for all images in the batch. | [
"r",
"Implements",
"the",
"N",
"-",
"dim",
"version",
"of",
"function",
"$$TV^",
"{",
"\\",
"beta",
"}",
"(",
"x",
")",
"=",
"\\",
"sum_",
"{",
"whc",
"}",
"\\",
"left",
"(",
"\\",
"left",
"(",
"x",
"(",
"h",
"w",
"+",
"1",
"c",
")",
"-",
"... | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/regularizers.py#L46-L72 | train | Implements the N - dim version of function
$$TV^{ beta } ( x ) = \ sum_{whc } \ right | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | _find_font_file | def _find_font_file(query):
"""Utility to find font file.
"""
return list(filter(lambda path: query.lower() in os.path.basename(path).lower(), fontman.findSystemFonts())) | python | def _find_font_file(query):
"""Utility to find font file.
"""
return list(filter(lambda path: query.lower() in os.path.basename(path).lower(), fontman.findSystemFonts())) | [
"def",
"_find_font_file",
"(",
"query",
")",
":",
"return",
"list",
"(",
"filter",
"(",
"lambda",
"path",
":",
"query",
".",
"lower",
"(",
")",
"in",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
".",
"lower",
"(",
")",
",",
"fontman",
".",... | Utility to find font file. | [
"Utility",
"to",
"find",
"font",
"file",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L38-L41 | train | Utility to find font file.
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | add_defaults_to_kwargs | def add_defaults_to_kwargs(defaults, **kwargs):
"""Updates `kwargs` with dict of `defaults`
Args:
defaults: A dictionary of keys and values
**kwargs: The kwargs to update.
Returns:
The updated kwargs.
"""
defaults = dict(defaults)
defaults.update(kwargs)
return defa... | python | def add_defaults_to_kwargs(defaults, **kwargs):
"""Updates `kwargs` with dict of `defaults`
Args:
defaults: A dictionary of keys and values
**kwargs: The kwargs to update.
Returns:
The updated kwargs.
"""
defaults = dict(defaults)
defaults.update(kwargs)
return defa... | [
"def",
"add_defaults_to_kwargs",
"(",
"defaults",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"dict",
"(",
"defaults",
")",
"defaults",
".",
"update",
"(",
"kwargs",
")",
"return",
"defaults"
] | Updates `kwargs` with dict of `defaults`
Args:
defaults: A dictionary of keys and values
**kwargs: The kwargs to update.
Returns:
The updated kwargs. | [
"Updates",
"kwargs",
"with",
"dict",
"of",
"defaults"
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L58-L70 | train | Updates kwargs with dict of defaults | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | get_identifier | def get_identifier(identifier, module_globals, module_name):
"""Helper utility to retrieve the callable function associated with a string identifier.
Args:
identifier: The identifier. Could be a string or function.
module_globals: The global objects of the module.
module_name: The modul... | python | def get_identifier(identifier, module_globals, module_name):
"""Helper utility to retrieve the callable function associated with a string identifier.
Args:
identifier: The identifier. Could be a string or function.
module_globals: The global objects of the module.
module_name: The modul... | [
"def",
"get_identifier",
"(",
"identifier",
",",
"module_globals",
",",
"module_name",
")",
":",
"if",
"isinstance",
"(",
"identifier",
",",
"six",
".",
"string_types",
")",
":",
"fn",
"=",
"module_globals",
".",
"get",
"(",
"identifier",
")",
"if",
"fn",
... | Helper utility to retrieve the callable function associated with a string identifier.
Args:
identifier: The identifier. Could be a string or function.
module_globals: The global objects of the module.
module_name: The module name
Returns:
The callable associated with the identi... | [
"Helper",
"utility",
"to",
"retrieve",
"the",
"callable",
"function",
"associated",
"with",
"a",
"string",
"identifier",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L73-L92 | train | Helper utility to retrieve the callable function associated with a string identifier. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | apply_modifications | def apply_modifications(model, custom_objects=None):
"""Applies modifications to the model layers to create a new Graph. For example, simply changing
`model.layers[idx].activation = new activation` does not change the graph. The entire graph needs to be updated
with modified inbound and outbound tensors bec... | python | def apply_modifications(model, custom_objects=None):
"""Applies modifications to the model layers to create a new Graph. For example, simply changing
`model.layers[idx].activation = new activation` does not change the graph. The entire graph needs to be updated
with modified inbound and outbound tensors bec... | [
"def",
"apply_modifications",
"(",
"model",
",",
"custom_objects",
"=",
"None",
")",
":",
"# The strategy is to save the modified model and load it back. This is done because setting the activation",
"# in a Keras layer doesnt actually change the graph. We have to iterate the entire graph and ... | Applies modifications to the model layers to create a new Graph. For example, simply changing
`model.layers[idx].activation = new activation` does not change the graph. The entire graph needs to be updated
with modified inbound and outbound tensors because of change in layer building function.
Args:
... | [
"Applies",
"modifications",
"to",
"the",
"model",
"layers",
"to",
"create",
"a",
"new",
"Graph",
".",
"For",
"example",
"simply",
"changing",
"model",
".",
"layers",
"[",
"idx",
"]",
".",
"activation",
"=",
"new",
"activation",
"does",
"not",
"change",
"th... | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L95-L115 | train | Applies modifications to the model layers to create a new Graph. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | random_array | def random_array(shape, mean=128., std=20.):
"""Creates a uniformly distributed random array with the given `mean` and `std`.
Args:
shape: The desired shape
mean: The desired mean (Default value = 128)
std: The desired std (Default value = 20)
Returns: Random numpy array of given `... | python | def random_array(shape, mean=128., std=20.):
"""Creates a uniformly distributed random array with the given `mean` and `std`.
Args:
shape: The desired shape
mean: The desired mean (Default value = 128)
std: The desired std (Default value = 20)
Returns: Random numpy array of given `... | [
"def",
"random_array",
"(",
"shape",
",",
"mean",
"=",
"128.",
",",
"std",
"=",
"20.",
")",
":",
"x",
"=",
"np",
".",
"random",
".",
"random",
"(",
"shape",
")",
"# normalize around mean=0, std=1",
"x",
"=",
"(",
"x",
"-",
"np",
".",
"mean",
"(",
"... | Creates a uniformly distributed random array with the given `mean` and `std`.
Args:
shape: The desired shape
mean: The desired mean (Default value = 128)
std: The desired std (Default value = 20)
Returns: Random numpy array of given `shape` uniformly distributed with desired `mean` and... | [
"Creates",
"a",
"uniformly",
"distributed",
"random",
"array",
"with",
"the",
"given",
"mean",
"and",
"std",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L118-L133 | train | Creates a uniformly distributed random array of the given shape with the given mean and std. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | find_layer_idx | def find_layer_idx(model, layer_name):
"""Looks up the layer index corresponding to `layer_name` from `model`.
Args:
model: The `keras.models.Model` instance.
layer_name: The name of the layer to lookup.
Returns:
The layer index if found. Raises an exception otherwise.
"""
... | python | def find_layer_idx(model, layer_name):
"""Looks up the layer index corresponding to `layer_name` from `model`.
Args:
model: The `keras.models.Model` instance.
layer_name: The name of the layer to lookup.
Returns:
The layer index if found. Raises an exception otherwise.
"""
... | [
"def",
"find_layer_idx",
"(",
"model",
",",
"layer_name",
")",
":",
"layer_idx",
"=",
"None",
"for",
"idx",
",",
"layer",
"in",
"enumerate",
"(",
"model",
".",
"layers",
")",
":",
"if",
"layer",
".",
"name",
"==",
"layer_name",
":",
"layer_idx",
"=",
"... | Looks up the layer index corresponding to `layer_name` from `model`.
Args:
model: The `keras.models.Model` instance.
layer_name: The name of the layer to lookup.
Returns:
The layer index if found. Raises an exception otherwise. | [
"Looks",
"up",
"the",
"layer",
"index",
"corresponding",
"to",
"layer_name",
"from",
"model",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L136-L154 | train | Looks up the layer index corresponding to layer_name from model. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | deprocess_input | def deprocess_input(input_array, input_range=(0, 255)):
"""Utility function to scale the `input_array` to `input_range` throwing away high frequency artifacts.
Args:
input_array: An N-dim numpy array.
input_range: Specifies the input range as a `(min, max)` tuple to rescale the `input_array`.
... | python | def deprocess_input(input_array, input_range=(0, 255)):
"""Utility function to scale the `input_array` to `input_range` throwing away high frequency artifacts.
Args:
input_array: An N-dim numpy array.
input_range: Specifies the input range as a `(min, max)` tuple to rescale the `input_array`.
... | [
"def",
"deprocess_input",
"(",
"input_array",
",",
"input_range",
"=",
"(",
"0",
",",
"255",
")",
")",
":",
"# normalize tensor: center on 0., ensure std is 0.1",
"input_array",
"=",
"input_array",
".",
"copy",
"(",
")",
"input_array",
"-=",
"input_array",
".",
"m... | Utility function to scale the `input_array` to `input_range` throwing away high frequency artifacts.
Args:
input_array: An N-dim numpy array.
input_range: Specifies the input range as a `(min, max)` tuple to rescale the `input_array`.
Returns:
The rescaled `input_array`. | [
"Utility",
"function",
"to",
"scale",
"the",
"input_array",
"to",
"input_range",
"throwing",
"away",
"high",
"frequency",
"artifacts",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L157-L178 | train | Utility function to scale the input_array to input_range throwing away high frequency artifacts. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | stitch_images | def stitch_images(images, margin=5, cols=5):
"""Utility function to stitch images together with a `margin`.
Args:
images: The array of 2D images to stitch.
margin: The black border margin size between images (Default value = 5)
cols: Max number of image cols. New row is created when num... | python | def stitch_images(images, margin=5, cols=5):
"""Utility function to stitch images together with a `margin`.
Args:
images: The array of 2D images to stitch.
margin: The black border margin size between images (Default value = 5)
cols: Max number of image cols. New row is created when num... | [
"def",
"stitch_images",
"(",
"images",
",",
"margin",
"=",
"5",
",",
"cols",
"=",
"5",
")",
":",
"if",
"len",
"(",
"images",
")",
"==",
"0",
":",
"return",
"None",
"h",
",",
"w",
",",
"c",
"=",
"images",
"[",
"0",
"]",
".",
"shape",
"n_rows",
... | Utility function to stitch images together with a `margin`.
Args:
images: The array of 2D images to stitch.
margin: The black border margin size between images (Default value = 5)
cols: Max number of image cols. New row is created when number of images exceed the column size.
(D... | [
"Utility",
"function",
"to",
"stitch",
"images",
"together",
"with",
"a",
"margin",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L181-L213 | train | Utility function to stitch images together with a margin. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | get_img_shape | def get_img_shape(img):
"""Returns image shape in a backend agnostic manner.
Args:
img: An image tensor of shape: `(channels, image_dims...)` if data_format='channels_first' or
`(image_dims..., channels)` if data_format='channels_last'.
Returns:
Tuple containing image shape inf... | python | def get_img_shape(img):
"""Returns image shape in a backend agnostic manner.
Args:
img: An image tensor of shape: `(channels, image_dims...)` if data_format='channels_first' or
`(image_dims..., channels)` if data_format='channels_last'.
Returns:
Tuple containing image shape inf... | [
"def",
"get_img_shape",
"(",
"img",
")",
":",
"if",
"isinstance",
"(",
"img",
",",
"np",
".",
"ndarray",
")",
":",
"shape",
"=",
"img",
".",
"shape",
"else",
":",
"shape",
"=",
"K",
".",
"int_shape",
"(",
"img",
")",
"if",
"K",
".",
"image_data_for... | Returns image shape in a backend agnostic manner.
Args:
img: An image tensor of shape: `(channels, image_dims...)` if data_format='channels_first' or
`(image_dims..., channels)` if data_format='channels_last'.
Returns:
Tuple containing image shape information in `(samples, channels... | [
"Returns",
"image",
"shape",
"in",
"a",
"backend",
"agnostic",
"manner",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L216-L235 | train | Returns image shape in a backend agnostic manner. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | load_img | def load_img(path, grayscale=False, target_size=None):
"""Utility function to load an image from disk.
Args:
path: The image file path.
grayscale: True to convert to grayscale image (Default value = False)
target_size: (w, h) to resize. (Default value = None)
Returns:
The loaded ... | python | def load_img(path, grayscale=False, target_size=None):
"""Utility function to load an image from disk.
Args:
path: The image file path.
grayscale: True to convert to grayscale image (Default value = False)
target_size: (w, h) to resize. (Default value = None)
Returns:
The loaded ... | [
"def",
"load_img",
"(",
"path",
",",
"grayscale",
"=",
"False",
",",
"target_size",
"=",
"None",
")",
":",
"img",
"=",
"io",
".",
"imread",
"(",
"path",
",",
"grayscale",
")",
"if",
"target_size",
":",
"img",
"=",
"transform",
".",
"resize",
"(",
"im... | Utility function to load an image from disk.
Args:
path: The image file path.
grayscale: True to convert to grayscale image (Default value = False)
target_size: (w, h) to resize. (Default value = None)
Returns:
The loaded numpy image. | [
"Utility",
"function",
"to",
"load",
"an",
"image",
"from",
"disk",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L238-L252 | train | Utility function to load an image from disk. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | lookup_imagenet_labels | def lookup_imagenet_labels(indices):
"""Utility function to return the image net label for the final `dense` layer output index.
Args:
indices: Could be a single value or an array of indices whose labels should be looked up.
Returns:
Image net label corresponding to the image category.
... | python | def lookup_imagenet_labels(indices):
"""Utility function to return the image net label for the final `dense` layer output index.
Args:
indices: Could be a single value or an array of indices whose labels should be looked up.
Returns:
Image net label corresponding to the image category.
... | [
"def",
"lookup_imagenet_labels",
"(",
"indices",
")",
":",
"global",
"_CLASS_INDEX",
"if",
"_CLASS_INDEX",
"is",
"None",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'../../... | Utility function to return the image net label for the final `dense` layer output index.
Args:
indices: Could be a single value or an array of indices whose labels should be looked up.
Returns:
Image net label corresponding to the image category. | [
"Utility",
"function",
"to",
"return",
"the",
"image",
"net",
"label",
"for",
"the",
"final",
"dense",
"layer",
"output",
"index",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L255-L270 | train | Utility function to return the image net label corresponding to the image category. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | draw_text | def draw_text(img, text, position=(10, 10), font='FreeSans.ttf', font_size=14, color=(0, 0, 0)):
"""Draws text over the image. Requires PIL.
Args:
img: The image to use.
text: The text string to overlay.
position: The text (x, y) position. (Default value = (10, 10))
font: The tt... | python | def draw_text(img, text, position=(10, 10), font='FreeSans.ttf', font_size=14, color=(0, 0, 0)):
"""Draws text over the image. Requires PIL.
Args:
img: The image to use.
text: The text string to overlay.
position: The text (x, y) position. (Default value = (10, 10))
font: The tt... | [
"def",
"draw_text",
"(",
"img",
",",
"text",
",",
"position",
"=",
"(",
"10",
",",
"10",
")",
",",
"font",
"=",
"'FreeSans.ttf'",
",",
"font_size",
"=",
"14",
",",
"color",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
")",
":",
"_check_pil",
"(",
")... | Draws text over the image. Requires PIL.
Args:
img: The image to use.
text: The text string to overlay.
position: The text (x, y) position. (Default value = (10, 10))
font: The ttf or open type font to use. (Default value = 'FreeSans.ttf')
font_size: The text font size. (Def... | [
"Draws",
"text",
"over",
"the",
"image",
".",
"Requires",
"PIL",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L273-L299 | train | Draws text over the image. Requires PIL. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/utils/utils.py | normalize | def normalize(array, min_value=0., max_value=1.):
"""Normalizes the numpy array to (min_value, max_value)
Args:
array: The numpy array
min_value: The min value in normalized array (Default value = 0)
max_value: The max value in normalized array (Default value = 1)
Returns:
... | python | def normalize(array, min_value=0., max_value=1.):
"""Normalizes the numpy array to (min_value, max_value)
Args:
array: The numpy array
min_value: The min value in normalized array (Default value = 0)
max_value: The max value in normalized array (Default value = 1)
Returns:
... | [
"def",
"normalize",
"(",
"array",
",",
"min_value",
"=",
"0.",
",",
"max_value",
"=",
"1.",
")",
":",
"arr_min",
"=",
"np",
".",
"min",
"(",
"array",
")",
"arr_max",
"=",
"np",
".",
"max",
"(",
"array",
")",
"normalized",
"=",
"(",
"array",
"-",
... | Normalizes the numpy array to (min_value, max_value)
Args:
array: The numpy array
min_value: The min value in normalized array (Default value = 0)
max_value: The max value in normalized array (Default value = 1)
Returns:
The array normalized to range between (min_value, max_val... | [
"Normalizes",
"the",
"numpy",
"array",
"to",
"(",
"min_value",
"max_value",
")"
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/utils/utils.py#L313-L327 | train | Normalizes the numpy array to range between min_value and max_value | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/visualization/__init__.py | get_num_filters | def get_num_filters(layer):
"""Determines the number of filters within the given `layer`.
Args:
layer: The keras layer to use.
Returns:
Total number of filters within `layer`.
For `keras.layers.Dense` layer, this is the total number of outputs.
"""
# Handle layers with no c... | python | def get_num_filters(layer):
"""Determines the number of filters within the given `layer`.
Args:
layer: The keras layer to use.
Returns:
Total number of filters within `layer`.
For `keras.layers.Dense` layer, this is the total number of outputs.
"""
# Handle layers with no c... | [
"def",
"get_num_filters",
"(",
"layer",
")",
":",
"# Handle layers with no channels.",
"if",
"K",
".",
"ndim",
"(",
"layer",
".",
"output",
")",
"==",
"2",
":",
"return",
"K",
".",
"int_shape",
"(",
"layer",
".",
"output",
")",
"[",
"-",
"1",
"]",
"cha... | Determines the number of filters within the given `layer`.
Args:
layer: The keras layer to use.
Returns:
Total number of filters within `layer`.
For `keras.layers.Dense` layer, this is the total number of outputs. | [
"Determines",
"the",
"number",
"of",
"filters",
"within",
"the",
"given",
"layer",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/visualization/__init__.py#L15-L30 | train | Determines the number of filters within the given keras layer. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
raghakot/keras-vis | vis/visualization/__init__.py | overlay | def overlay(array1, array2, alpha=0.5):
"""Overlays `array1` onto `array2` with `alpha` blending.
Args:
array1: The first numpy array.
array2: The second numpy array.
alpha: The alpha value of `array1` as overlayed onto `array2`. This value needs to be between [0, 1],
with 0... | python | def overlay(array1, array2, alpha=0.5):
"""Overlays `array1` onto `array2` with `alpha` blending.
Args:
array1: The first numpy array.
array2: The second numpy array.
alpha: The alpha value of `array1` as overlayed onto `array2`. This value needs to be between [0, 1],
with 0... | [
"def",
"overlay",
"(",
"array1",
",",
"array2",
",",
"alpha",
"=",
"0.5",
")",
":",
"if",
"alpha",
"<",
"0.",
"or",
"alpha",
">",
"1.",
":",
"raise",
"ValueError",
"(",
"\"`alpha` needs to be between [0, 1]\"",
")",
"if",
"array1",
".",
"shape",
"!=",
"a... | Overlays `array1` onto `array2` with `alpha` blending.
Args:
array1: The first numpy array.
array2: The second numpy array.
alpha: The alpha value of `array1` as overlayed onto `array2`. This value needs to be between [0, 1],
with 0 being `array2` only to 1 being `array1` only (... | [
"Overlays",
"array1",
"onto",
"array2",
"with",
"alpha",
"blending",
"."
] | 668b0e11dab93f3487f23c17e07f40554a8939e9 | https://github.com/raghakot/keras-vis/blob/668b0e11dab93f3487f23c17e07f40554a8939e9/vis/visualization/__init__.py#L33-L50 | train | Overlays array1 onto array2 using alpha blending. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | _infer_coords_and_dims | def _infer_coords_and_dims(shape, coords, dims):
"""All the logic for creating a new DataArray"""
if (coords is not None and not utils.is_dict_like(coords) and
len(coords) != len(shape)):
raise ValueError('coords is not dict-like, but it has %s items, '
'which does ... | python | def _infer_coords_and_dims(shape, coords, dims):
"""All the logic for creating a new DataArray"""
if (coords is not None and not utils.is_dict_like(coords) and
len(coords) != len(shape)):
raise ValueError('coords is not dict-like, but it has %s items, '
'which does ... | [
"def",
"_infer_coords_and_dims",
"(",
"shape",
",",
"coords",
",",
"dims",
")",
":",
"if",
"(",
"coords",
"is",
"not",
"None",
"and",
"not",
"utils",
".",
"is_dict_like",
"(",
"coords",
")",
"and",
"len",
"(",
"coords",
")",
"!=",
"len",
"(",
"shape",
... | All the logic for creating a new DataArray | [
"All",
"the",
"logic",
"for",
"creating",
"a",
"new",
"DataArray"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L28-L92 | train | Infer the coordinates and dimensions of a new DataArray. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.to_dataset | def to_dataset(self, dim=None, name=None):
"""Convert a DataArray to a Dataset.
Parameters
----------
dim : str, optional
Name of the dimension on this array along which to split this array
into separate variables. If not provided, this array is converted
... | python | def to_dataset(self, dim=None, name=None):
"""Convert a DataArray to a Dataset.
Parameters
----------
dim : str, optional
Name of the dimension on this array along which to split this array
into separate variables. If not provided, this array is converted
... | [
"def",
"to_dataset",
"(",
"self",
",",
"dim",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if",
"dim",
"is",
"not",
"None",
"and",
"dim",
"not",
"in",
"self",
".",
"dims",
":",
"warnings",
".",
"warn",
"(",
"'the order of the arguments on DataArray.... | Convert a DataArray to a Dataset.
Parameters
----------
dim : str, optional
Name of the dimension on this array along which to split this array
into separate variables. If not provided, this array is converted
into a Dataset of one variable.
name : st... | [
"Convert",
"a",
"DataArray",
"to",
"a",
"Dataset",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L328-L358 | train | Convert a DataArray into a Dataset. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray._level_coords | def _level_coords(self):
"""Return a mapping of all MultiIndex levels and their corresponding
coordinate name.
"""
level_coords = OrderedDict()
for cname, var in self._coords.items():
if var.ndim == 1 and isinstance(var, IndexVariable):
level_names = v... | python | def _level_coords(self):
"""Return a mapping of all MultiIndex levels and their corresponding
coordinate name.
"""
level_coords = OrderedDict()
for cname, var in self._coords.items():
if var.ndim == 1 and isinstance(var, IndexVariable):
level_names = v... | [
"def",
"_level_coords",
"(",
"self",
")",
":",
"level_coords",
"=",
"OrderedDict",
"(",
")",
"for",
"cname",
",",
"var",
"in",
"self",
".",
"_coords",
".",
"items",
"(",
")",
":",
"if",
"var",
".",
"ndim",
"==",
"1",
"and",
"isinstance",
"(",
"var",
... | Return a mapping of all MultiIndex levels and their corresponding
coordinate name. | [
"Return",
"a",
"mapping",
"of",
"all",
"MultiIndex",
"levels",
"and",
"their",
"corresponding",
"coordinate",
"name",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L449-L460 | train | Return a mapping of all MultiIndex levels and their corresponding
coordinate name. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.indexes | def indexes(self):
"""Mapping of pandas.Index objects used for label based indexing
"""
if self._indexes is None:
self._indexes = default_indexes(self._coords, self.dims)
return Indexes(self._indexes) | python | def indexes(self):
"""Mapping of pandas.Index objects used for label based indexing
"""
if self._indexes is None:
self._indexes = default_indexes(self._coords, self.dims)
return Indexes(self._indexes) | [
"def",
"indexes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_indexes",
"is",
"None",
":",
"self",
".",
"_indexes",
"=",
"default_indexes",
"(",
"self",
".",
"_coords",
",",
"self",
".",
"dims",
")",
"return",
"Indexes",
"(",
"self",
".",
"_indexes",
... | Mapping of pandas.Index objects used for label based indexing | [
"Mapping",
"of",
"pandas",
".",
"Index",
"objects",
"used",
"for",
"label",
"based",
"indexing"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L539-L544 | train | Mapping of pandas. Index objects used for label based indexing. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.reset_coords | def reset_coords(self, names=None, drop=False, inplace=None):
"""Given names of coordinates, reset them to become variables.
Parameters
----------
names : str or list of str, optional
Name(s) of non-index coordinates in this dataset to reset into
variables. By de... | python | def reset_coords(self, names=None, drop=False, inplace=None):
"""Given names of coordinates, reset them to become variables.
Parameters
----------
names : str or list of str, optional
Name(s) of non-index coordinates in this dataset to reset into
variables. By de... | [
"def",
"reset_coords",
"(",
"self",
",",
"names",
"=",
"None",
",",
"drop",
"=",
"False",
",",
"inplace",
"=",
"None",
")",
":",
"inplace",
"=",
"_check_inplace",
"(",
"inplace",
")",
"if",
"inplace",
"and",
"not",
"drop",
":",
"raise",
"ValueError",
"... | Given names of coordinates, reset them to become variables.
Parameters
----------
names : str or list of str, optional
Name(s) of non-index coordinates in this dataset to reset into
variables. By default, all non-index coordinates are reset.
drop : bool, optional... | [
"Given",
"names",
"of",
"coordinates",
"reset",
"them",
"to",
"become",
"variables",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L552-L588 | train | Reset the coordinates of the object to become variables. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.load | def load(self, **kwargs):
"""Manually trigger loading of this array's data from disk or a
remote source into memory and return this array.
Normally, it should not be necessary to call this method in user code,
because all xarray functions should either work on deferred data or
l... | python | def load(self, **kwargs):
"""Manually trigger loading of this array's data from disk or a
remote source into memory and return this array.
Normally, it should not be necessary to call this method in user code,
because all xarray functions should either work on deferred data or
l... | [
"def",
"load",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"load",
"(",
"*",
"*",
"kwargs",
")",
"new",
"=",
"self",
".",
"_from_temp_dataset",
"(",
"ds",
")",
"self",
".",
"_variable",... | Manually trigger loading of this array's data from disk or a
remote source into memory and return this array.
Normally, it should not be necessary to call this method in user code,
because all xarray functions should either work on deferred data or
load data automatically. However, this... | [
"Manually",
"trigger",
"loading",
"of",
"this",
"array",
"s",
"data",
"from",
"disk",
"or",
"a",
"remote",
"source",
"into",
"memory",
"and",
"return",
"this",
"array",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L622-L644 | train | Manually trigger loading of this array s data from disk or a
remote source into memory and return this array. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.persist | def persist(self, **kwargs):
""" Trigger computation in constituent dask arrays
This keeps them as dask arrays but encourages them to keep data in
memory. This is particularly useful when on a distributed machine.
When on a single machine consider using ``.compute()`` instead.
... | python | def persist(self, **kwargs):
""" Trigger computation in constituent dask arrays
This keeps them as dask arrays but encourages them to keep data in
memory. This is particularly useful when on a distributed machine.
When on a single machine consider using ``.compute()`` instead.
... | [
"def",
"persist",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"persist",
"(",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"_from_temp_dataset",
"(",
"ds",
")"
] | Trigger computation in constituent dask arrays
This keeps them as dask arrays but encourages them to keep data in
memory. This is particularly useful when on a distributed machine.
When on a single machine consider using ``.compute()`` instead.
Parameters
----------
**... | [
"Trigger",
"computation",
"in",
"constituent",
"dask",
"arrays"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L668-L685 | train | Trigger computation in constituent dask arrays
This keeps them as dask arrays but encourages them as dask arrays but encourages them as dask arrays. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.copy | def copy(self, deep=True, data=None):
"""Returns a copy of this array.
If `deep=True`, a deep copy is made of the data array.
Otherwise, a shallow copy is made, so each variable in the new
array's dataset is also a variable in this array's dataset.
Use `data` to create a new ob... | python | def copy(self, deep=True, data=None):
"""Returns a copy of this array.
If `deep=True`, a deep copy is made of the data array.
Otherwise, a shallow copy is made, so each variable in the new
array's dataset is also a variable in this array's dataset.
Use `data` to create a new ob... | [
"def",
"copy",
"(",
"self",
",",
"deep",
"=",
"True",
",",
"data",
"=",
"None",
")",
":",
"variable",
"=",
"self",
".",
"variable",
".",
"copy",
"(",
"deep",
"=",
"deep",
",",
"data",
"=",
"data",
")",
"coords",
"=",
"OrderedDict",
"(",
"(",
"k",... | Returns a copy of this array.
If `deep=True`, a deep copy is made of the data array.
Otherwise, a shallow copy is made, so each variable in the new
array's dataset is also a variable in this array's dataset.
Use `data` to create a new object with the same structure as
original ... | [
"Returns",
"a",
"copy",
"of",
"this",
"array",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L687-L760 | train | Returns a shallow copy of the current array. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.chunk | def chunk(self, chunks=None, name_prefix='xarray-', token=None,
lock=False):
"""Coerce this array's data into a dask arrays with the given chunks.
If this variable is a non-dask array, it will be converted to dask
array. If it's a dask array, it will be rechunked to the given chun... | python | def chunk(self, chunks=None, name_prefix='xarray-', token=None,
lock=False):
"""Coerce this array's data into a dask arrays with the given chunks.
If this variable is a non-dask array, it will be converted to dask
array. If it's a dask array, it will be rechunked to the given chun... | [
"def",
"chunk",
"(",
"self",
",",
"chunks",
"=",
"None",
",",
"name_prefix",
"=",
"'xarray-'",
",",
"token",
"=",
"None",
",",
"lock",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"chunks",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"chunks... | Coerce this array's data into a dask arrays with the given chunks.
If this variable is a non-dask array, it will be converted to dask
array. If it's a dask array, it will be rechunked to the given chunk
sizes.
If neither chunks is not provided for one or more dimensions, chunk
... | [
"Coerce",
"this",
"array",
"s",
"data",
"into",
"a",
"dask",
"arrays",
"with",
"the",
"given",
"chunks",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L781-L815 | train | Coerce this array s data into a dask array with the given chunks. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.isel | def isel(self, indexers=None, drop=False, **indexers_kwargs):
"""Return a new DataArray whose dataset is given by integer indexing
along the specified dimension(s).
See Also
--------
Dataset.isel
DataArray.sel
"""
indexers = either_dict_or_kwargs(indexers... | python | def isel(self, indexers=None, drop=False, **indexers_kwargs):
"""Return a new DataArray whose dataset is given by integer indexing
along the specified dimension(s).
See Also
--------
Dataset.isel
DataArray.sel
"""
indexers = either_dict_or_kwargs(indexers... | [
"def",
"isel",
"(",
"self",
",",
"indexers",
"=",
"None",
",",
"drop",
"=",
"False",
",",
"*",
"*",
"indexers_kwargs",
")",
":",
"indexers",
"=",
"either_dict_or_kwargs",
"(",
"indexers",
",",
"indexers_kwargs",
",",
"'isel'",
")",
"ds",
"=",
"self",
"."... | Return a new DataArray whose dataset is given by integer indexing
along the specified dimension(s).
See Also
--------
Dataset.isel
DataArray.sel | [
"Return",
"a",
"new",
"DataArray",
"whose",
"dataset",
"is",
"given",
"by",
"integer",
"indexing",
"along",
"the",
"specified",
"dimension",
"(",
"s",
")",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L817-L828 | train | Return a new DataArray whose dataset is given by integer indexing
along the specified dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.sel | def sel(self, indexers=None, method=None, tolerance=None, drop=False,
**indexers_kwargs):
"""Return a new DataArray whose dataset is given by selecting
index labels along the specified dimension(s).
.. warning::
Do not try to assign values when using any of the indexing m... | python | def sel(self, indexers=None, method=None, tolerance=None, drop=False,
**indexers_kwargs):
"""Return a new DataArray whose dataset is given by selecting
index labels along the specified dimension(s).
.. warning::
Do not try to assign values when using any of the indexing m... | [
"def",
"sel",
"(",
"self",
",",
"indexers",
"=",
"None",
",",
"method",
"=",
"None",
",",
"tolerance",
"=",
"None",
",",
"drop",
"=",
"False",
",",
"*",
"*",
"indexers_kwargs",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"s... | Return a new DataArray whose dataset is given by selecting
index labels along the specified dimension(s).
.. warning::
Do not try to assign values when using any of the indexing methods
``isel`` or ``sel``::
da = xr.DataArray([0, 1, 2, 3], dims=['x'])
# DO ... | [
"Return",
"a",
"new",
"DataArray",
"whose",
"dataset",
"is",
"given",
"by",
"selecting",
"index",
"labels",
"along",
"the",
"specified",
"dimension",
"(",
"s",
")",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L830-L856 | train | Return a new DataArray whose dataset is given by selecting
index labels along the specified dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.isel_points | def isel_points(self, dim='points', **indexers):
"""Return a new DataArray whose dataset is given by pointwise integer
indexing along the specified dimension(s).
See Also
--------
Dataset.isel_points
"""
ds = self._to_temp_dataset().isel_points(dim=dim, **indexer... | python | def isel_points(self, dim='points', **indexers):
"""Return a new DataArray whose dataset is given by pointwise integer
indexing along the specified dimension(s).
See Also
--------
Dataset.isel_points
"""
ds = self._to_temp_dataset().isel_points(dim=dim, **indexer... | [
"def",
"isel_points",
"(",
"self",
",",
"dim",
"=",
"'points'",
",",
"*",
"*",
"indexers",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"isel_points",
"(",
"dim",
"=",
"dim",
",",
"*",
"*",
"indexers",
")",
"return",
"self",
... | Return a new DataArray whose dataset is given by pointwise integer
indexing along the specified dimension(s).
See Also
--------
Dataset.isel_points | [
"Return",
"a",
"new",
"DataArray",
"whose",
"dataset",
"is",
"given",
"by",
"pointwise",
"integer",
"indexing",
"along",
"the",
"specified",
"dimension",
"(",
"s",
")",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L858-L867 | train | Return a new DataArray whose dataset is given by pointwise integer
indexing along the specified dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.sel_points | def sel_points(self, dim='points', method=None, tolerance=None,
**indexers):
"""Return a new DataArray whose dataset is given by pointwise selection
of index labels along the specified dimension(s).
See Also
--------
Dataset.sel_points
"""
ds =... | python | def sel_points(self, dim='points', method=None, tolerance=None,
**indexers):
"""Return a new DataArray whose dataset is given by pointwise selection
of index labels along the specified dimension(s).
See Also
--------
Dataset.sel_points
"""
ds =... | [
"def",
"sel_points",
"(",
"self",
",",
"dim",
"=",
"'points'",
",",
"method",
"=",
"None",
",",
"tolerance",
"=",
"None",
",",
"*",
"*",
"indexers",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"sel_points",
"(",
"dim",
"=",
... | Return a new DataArray whose dataset is given by pointwise selection
of index labels along the specified dimension(s).
See Also
--------
Dataset.sel_points | [
"Return",
"a",
"new",
"DataArray",
"whose",
"dataset",
"is",
"given",
"by",
"pointwise",
"selection",
"of",
"index",
"labels",
"along",
"the",
"specified",
"dimension",
"(",
"s",
")",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L869-L880 | train | Return a new DataArray whose dataset is given by pointwise selection
of index labels along the specified dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.reindex | def reindex(self, indexers=None, method=None, tolerance=None, copy=True,
**indexers_kwargs):
"""Conform this object onto a new set of indexes, filling in
missing values with NaN.
Parameters
----------
indexers : dict, optional
Dictionary with keys giv... | python | def reindex(self, indexers=None, method=None, tolerance=None, copy=True,
**indexers_kwargs):
"""Conform this object onto a new set of indexes, filling in
missing values with NaN.
Parameters
----------
indexers : dict, optional
Dictionary with keys giv... | [
"def",
"reindex",
"(",
"self",
",",
"indexers",
"=",
"None",
",",
"method",
"=",
"None",
",",
"tolerance",
"=",
"None",
",",
"copy",
"=",
"True",
",",
"*",
"*",
"indexers_kwargs",
")",
":",
"indexers",
"=",
"either_dict_or_kwargs",
"(",
"indexers",
",",
... | Conform this object onto a new set of indexes, filling in
missing values with NaN.
Parameters
----------
indexers : dict, optional
Dictionary with keys given by dimension names and values given by
arrays of coordinates tick labels. Any mis-matched coordinate
... | [
"Conform",
"this",
"object",
"onto",
"a",
"new",
"set",
"of",
"indexes",
"filling",
"in",
"missing",
"values",
"with",
"NaN",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L929-L978 | train | Conform this object onto a new set of indexes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.interp | def interp(self, coords=None, method='linear', assume_sorted=False,
kwargs={}, **coords_kwargs):
""" Multidimensional interpolation of variables.
coords : dict, optional
Mapping from dimension names to the new coordinates.
new coordinate can be an scalar, array-li... | python | def interp(self, coords=None, method='linear', assume_sorted=False,
kwargs={}, **coords_kwargs):
""" Multidimensional interpolation of variables.
coords : dict, optional
Mapping from dimension names to the new coordinates.
new coordinate can be an scalar, array-li... | [
"def",
"interp",
"(",
"self",
",",
"coords",
"=",
"None",
",",
"method",
"=",
"'linear'",
",",
"assume_sorted",
"=",
"False",
",",
"kwargs",
"=",
"{",
"}",
",",
"*",
"*",
"coords_kwargs",
")",
":",
"if",
"self",
".",
"dtype",
".",
"kind",
"not",
"i... | Multidimensional interpolation of variables.
coords : dict, optional
Mapping from dimension names to the new coordinates.
new coordinate can be an scalar, array-like or DataArray.
If DataArrays are passed as new coordates, their dimensions are
used for the broadc... | [
"Multidimensional",
"interpolation",
"of",
"variables",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L980-L1032 | train | Interpolate the multidimensional array with the given coordinates. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.interp_like | def interp_like(self, other, method='linear', assume_sorted=False,
kwargs={}):
"""Interpolate this object onto the coordinates of another object,
filling out of range values with NaN.
Parameters
----------
other : Dataset or DataArray
Object with ... | python | def interp_like(self, other, method='linear', assume_sorted=False,
kwargs={}):
"""Interpolate this object onto the coordinates of another object,
filling out of range values with NaN.
Parameters
----------
other : Dataset or DataArray
Object with ... | [
"def",
"interp_like",
"(",
"self",
",",
"other",
",",
"method",
"=",
"'linear'",
",",
"assume_sorted",
"=",
"False",
",",
"kwargs",
"=",
"{",
"}",
")",
":",
"if",
"self",
".",
"dtype",
".",
"kind",
"not",
"in",
"'uifc'",
":",
"raise",
"TypeError",
"(... | Interpolate this object onto the coordinates of another object,
filling out of range values with NaN.
Parameters
----------
other : Dataset or DataArray
Object with an 'indexes' attribute giving a mapping from dimension
names to an 1d array-like, which provides c... | [
"Interpolate",
"this",
"object",
"onto",
"the",
"coordinates",
"of",
"another",
"object",
"filling",
"out",
"of",
"range",
"values",
"with",
"NaN",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1034-L1080 | train | Interpolate this object onto the coordinates of another object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.rename | def rename(self, new_name_or_name_dict=None, **names):
"""Returns a new DataArray with renamed coordinates or a new name.
Parameters
----------
new_name_or_name_dict : str or dict-like, optional
If the argument is dict-like, it it used as a mapping from old
names... | python | def rename(self, new_name_or_name_dict=None, **names):
"""Returns a new DataArray with renamed coordinates or a new name.
Parameters
----------
new_name_or_name_dict : str or dict-like, optional
If the argument is dict-like, it it used as a mapping from old
names... | [
"def",
"rename",
"(",
"self",
",",
"new_name_or_name_dict",
"=",
"None",
",",
"*",
"*",
"names",
")",
":",
"if",
"names",
"or",
"utils",
".",
"is_dict_like",
"(",
"new_name_or_name_dict",
")",
":",
"name_dict",
"=",
"either_dict_or_kwargs",
"(",
"new_name_or_n... | Returns a new DataArray with renamed coordinates or a new name.
Parameters
----------
new_name_or_name_dict : str or dict-like, optional
If the argument is dict-like, it it used as a mapping from old
names to new names for coordinates. Otherwise, use the argument
... | [
"Returns",
"a",
"new",
"DataArray",
"with",
"renamed",
"coordinates",
"or",
"a",
"new",
"name",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1082-L1113 | train | Returns a new DataArray with renamed coordinates or a new name. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.swap_dims | def swap_dims(self, dims_dict):
"""Returns a new DataArray with swapped dimensions.
Parameters
----------
dims_dict : dict-like
Dictionary whose keys are current dimension names and whose values
are new names. Each value must already be a coordinate on this
... | python | def swap_dims(self, dims_dict):
"""Returns a new DataArray with swapped dimensions.
Parameters
----------
dims_dict : dict-like
Dictionary whose keys are current dimension names and whose values
are new names. Each value must already be a coordinate on this
... | [
"def",
"swap_dims",
"(",
"self",
",",
"dims_dict",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"swap_dims",
"(",
"dims_dict",
")",
"return",
"self",
".",
"_from_temp_dataset",
"(",
"ds",
")"
] | Returns a new DataArray with swapped dimensions.
Parameters
----------
dims_dict : dict-like
Dictionary whose keys are current dimension names and whose values
are new names. Each value must already be a coordinate on this
array.
Returns
----... | [
"Returns",
"a",
"new",
"DataArray",
"with",
"swapped",
"dimensions",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1115-L1137 | train | Returns a new Dataset containing swapped dimensions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.expand_dims | def expand_dims(self, dim=None, axis=None, **dim_kwargs):
"""Return a new object with an additional axis (or axes) inserted at
the corresponding position in the array shape.
If dim is already a scalar coordinate, it will be promoted to a 1D
coordinate consisting of a single value.
... | python | def expand_dims(self, dim=None, axis=None, **dim_kwargs):
"""Return a new object with an additional axis (or axes) inserted at
the corresponding position in the array shape.
If dim is already a scalar coordinate, it will be promoted to a 1D
coordinate consisting of a single value.
... | [
"def",
"expand_dims",
"(",
"self",
",",
"dim",
"=",
"None",
",",
"axis",
"=",
"None",
",",
"*",
"*",
"dim_kwargs",
")",
":",
"if",
"isinstance",
"(",
"dim",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"'dim should be str or sequence of strs or dict'",
... | Return a new object with an additional axis (or axes) inserted at
the corresponding position in the array shape.
If dim is already a scalar coordinate, it will be promoted to a 1D
coordinate consisting of a single value.
Parameters
----------
dim : str, sequence of str,... | [
"Return",
"a",
"new",
"object",
"with",
"an",
"additional",
"axis",
"(",
"or",
"axes",
")",
"inserted",
"at",
"the",
"corresponding",
"position",
"in",
"the",
"array",
"shape",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1139-L1196 | train | Return a new object with an additional dimension inserted at the corresponding position in the array. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.set_index | def set_index(self, indexes=None, append=False, inplace=None,
**indexes_kwargs):
"""Set DataArray (multi-)indexes using one or more existing
coordinates.
Parameters
----------
indexes : {dim: index, ...}
Mapping from names matching dimensions and va... | python | def set_index(self, indexes=None, append=False, inplace=None,
**indexes_kwargs):
"""Set DataArray (multi-)indexes using one or more existing
coordinates.
Parameters
----------
indexes : {dim: index, ...}
Mapping from names matching dimensions and va... | [
"def",
"set_index",
"(",
"self",
",",
"indexes",
"=",
"None",
",",
"append",
"=",
"False",
",",
"inplace",
"=",
"None",
",",
"*",
"*",
"indexes_kwargs",
")",
":",
"inplace",
"=",
"_check_inplace",
"(",
"inplace",
")",
"indexes",
"=",
"either_dict_or_kwargs... | Set DataArray (multi-)indexes using one or more existing
coordinates.
Parameters
----------
indexes : {dim: index, ...}
Mapping from names matching dimensions and values given
by (lists of) the names of existing coordinates or variables to set
as new ... | [
"Set",
"DataArray",
"(",
"multi",
"-",
")",
"indexes",
"using",
"one",
"or",
"more",
"existing",
"coordinates",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1198-L1234 | train | Set the index of the data array using one or more existing coordinates. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.reset_index | def reset_index(self, dims_or_levels, drop=False, inplace=None):
"""Reset the specified index(es) or multi-index level(s).
Parameters
----------
dims_or_levels : str or list
Name(s) of the dimension(s) and/or multi-index level(s) that will
be reset.
drop ... | python | def reset_index(self, dims_or_levels, drop=False, inplace=None):
"""Reset the specified index(es) or multi-index level(s).
Parameters
----------
dims_or_levels : str or list
Name(s) of the dimension(s) and/or multi-index level(s) that will
be reset.
drop ... | [
"def",
"reset_index",
"(",
"self",
",",
"dims_or_levels",
",",
"drop",
"=",
"False",
",",
"inplace",
"=",
"None",
")",
":",
"inplace",
"=",
"_check_inplace",
"(",
"inplace",
")",
"coords",
",",
"_",
"=",
"split_indexes",
"(",
"dims_or_levels",
",",
"self",... | Reset the specified index(es) or multi-index level(s).
Parameters
----------
dims_or_levels : str or list
Name(s) of the dimension(s) and/or multi-index level(s) that will
be reset.
drop : bool, optional
If True, remove the specified indexes and/or mu... | [
"Reset",
"the",
"specified",
"index",
"(",
"es",
")",
"or",
"multi",
"-",
"index",
"level",
"(",
"s",
")",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1236-L1267 | train | Reset the index of the dataarray to the specified index or multi - index level. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.reorder_levels | def reorder_levels(self, dim_order=None, inplace=None,
**dim_order_kwargs):
"""Rearrange index levels using input order.
Parameters
----------
dim_order : optional
Mapping from names matching dimensions and values given
by lists representin... | python | def reorder_levels(self, dim_order=None, inplace=None,
**dim_order_kwargs):
"""Rearrange index levels using input order.
Parameters
----------
dim_order : optional
Mapping from names matching dimensions and values given
by lists representin... | [
"def",
"reorder_levels",
"(",
"self",
",",
"dim_order",
"=",
"None",
",",
"inplace",
"=",
"None",
",",
"*",
"*",
"dim_order_kwargs",
")",
":",
"inplace",
"=",
"_check_inplace",
"(",
"inplace",
")",
"dim_order",
"=",
"either_dict_or_kwargs",
"(",
"dim_order",
... | Rearrange index levels using input order.
Parameters
----------
dim_order : optional
Mapping from names matching dimensions and values given
by lists representing new level orders. Every given dimension
must have a multi-index.
inplace : bool, optiona... | [
"Rearrange",
"index",
"levels",
"using",
"input",
"order",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1269-L1308 | train | Rearrange index levels using input order. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.stack | def stack(self, dimensions=None, **dimensions_kwargs):
"""
Stack any number of existing dimensions into a single new dimension.
New dimensions will be added at the end, and the corresponding
coordinate variables will be combined into a MultiIndex.
Parameters
----------
... | python | def stack(self, dimensions=None, **dimensions_kwargs):
"""
Stack any number of existing dimensions into a single new dimension.
New dimensions will be added at the end, and the corresponding
coordinate variables will be combined into a MultiIndex.
Parameters
----------
... | [
"def",
"stack",
"(",
"self",
",",
"dimensions",
"=",
"None",
",",
"*",
"*",
"dimensions_kwargs",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"stack",
"(",
"dimensions",
",",
"*",
"*",
"dimensions_kwargs",
")",
"return",
"self",
... | Stack any number of existing dimensions into a single new dimension.
New dimensions will be added at the end, and the corresponding
coordinate variables will be combined into a MultiIndex.
Parameters
----------
dimensions : Mapping of the form new_name=(dim1, dim2, ...)
... | [
"Stack",
"any",
"number",
"of",
"existing",
"dimensions",
"into",
"a",
"single",
"new",
"dimension",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1310-L1354 | train | Stack any number of existing dimensions into a single new dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.unstack | def unstack(self, dim=None):
"""
Unstack existing dimensions corresponding to MultiIndexes into
multiple new dimensions.
New dimensions will be added at the end.
Parameters
----------
dim : str or sequence of str, optional
Dimension(s) over which to ... | python | def unstack(self, dim=None):
"""
Unstack existing dimensions corresponding to MultiIndexes into
multiple new dimensions.
New dimensions will be added at the end.
Parameters
----------
dim : str or sequence of str, optional
Dimension(s) over which to ... | [
"def",
"unstack",
"(",
"self",
",",
"dim",
"=",
"None",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"unstack",
"(",
"dim",
")",
"return",
"self",
".",
"_from_temp_dataset",
"(",
"ds",
")"
] | Unstack existing dimensions corresponding to MultiIndexes into
multiple new dimensions.
New dimensions will be added at the end.
Parameters
----------
dim : str or sequence of str, optional
Dimension(s) over which to unstack. By default unstacks all
Mult... | [
"Unstack",
"existing",
"dimensions",
"corresponding",
"to",
"MultiIndexes",
"into",
"multiple",
"new",
"dimensions",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1356-L1400 | train | Unstack existing dimensions into multiple new dimensions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.transpose | def transpose(self, *dims) -> 'DataArray':
"""Return a new DataArray object with transposed dimensions.
Parameters
----------
*dims : str, optional
By default, reverse the dimensions. Otherwise, reorder the
dimensions to this order.
Returns
-----... | python | def transpose(self, *dims) -> 'DataArray':
"""Return a new DataArray object with transposed dimensions.
Parameters
----------
*dims : str, optional
By default, reverse the dimensions. Otherwise, reorder the
dimensions to this order.
Returns
-----... | [
"def",
"transpose",
"(",
"self",
",",
"*",
"dims",
")",
"->",
"'DataArray'",
":",
"variable",
"=",
"self",
".",
"variable",
".",
"transpose",
"(",
"*",
"dims",
")",
"return",
"self",
".",
"_replace",
"(",
"variable",
")"
] | Return a new DataArray object with transposed dimensions.
Parameters
----------
*dims : str, optional
By default, reverse the dimensions. Otherwise, reorder the
dimensions to this order.
Returns
-------
transposed : DataArray
The retu... | [
"Return",
"a",
"new",
"DataArray",
"object",
"with",
"transposed",
"dimensions",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1402-L1428 | train | Return a new DataArray with transposed dimensions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.drop | def drop(self, labels, dim=None):
"""Drop coordinates or index labels from this DataArray.
Parameters
----------
labels : scalar or list of scalars
Name(s) of coordinate variables or index labels to drop.
dim : str, optional
Dimension along which to drop ... | python | def drop(self, labels, dim=None):
"""Drop coordinates or index labels from this DataArray.
Parameters
----------
labels : scalar or list of scalars
Name(s) of coordinate variables or index labels to drop.
dim : str, optional
Dimension along which to drop ... | [
"def",
"drop",
"(",
"self",
",",
"labels",
",",
"dim",
"=",
"None",
")",
":",
"if",
"utils",
".",
"is_scalar",
"(",
"labels",
")",
":",
"labels",
"=",
"[",
"labels",
"]",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"drop",
"(",
"la... | Drop coordinates or index labels from this DataArray.
Parameters
----------
labels : scalar or list of scalars
Name(s) of coordinate variables or index labels to drop.
dim : str, optional
Dimension along which to drop index labels. By default (if
``di... | [
"Drop",
"coordinates",
"or",
"index",
"labels",
"from",
"this",
"DataArray",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1434-L1452 | train | Drop coordinates or index labels from this DataArray. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.dropna | def dropna(self, dim, how='any', thresh=None):
"""Returns a new array with dropped labels for missing values along
the provided dimension.
Parameters
----------
dim : str
Dimension along which to drop missing values. Dropping along
multiple dimensions sim... | python | def dropna(self, dim, how='any', thresh=None):
"""Returns a new array with dropped labels for missing values along
the provided dimension.
Parameters
----------
dim : str
Dimension along which to drop missing values. Dropping along
multiple dimensions sim... | [
"def",
"dropna",
"(",
"self",
",",
"dim",
",",
"how",
"=",
"'any'",
",",
"thresh",
"=",
"None",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"dropna",
"(",
"dim",
",",
"how",
"=",
"how",
",",
"thresh",
"=",
"thresh",
")",
... | Returns a new array with dropped labels for missing values along
the provided dimension.
Parameters
----------
dim : str
Dimension along which to drop missing values. Dropping along
multiple dimensions simultaneously is not yet supported.
how : {'any', 'a... | [
"Returns",
"a",
"new",
"array",
"with",
"dropped",
"labels",
"for",
"missing",
"values",
"along",
"the",
"provided",
"dimension",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1454-L1474 | train | Returns a new array with dropped labels for missing values along the provided dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.fillna | def fillna(self, value):
"""Fill missing values in this object.
This operation follows the normal broadcasting and alignment rules that
xarray uses for binary arithmetic, except the result is aligned to this
object (``join='left'``) instead of aligned to the intersection of
inde... | python | def fillna(self, value):
"""Fill missing values in this object.
This operation follows the normal broadcasting and alignment rules that
xarray uses for binary arithmetic, except the result is aligned to this
object (``join='left'``) instead of aligned to the intersection of
inde... | [
"def",
"fillna",
"(",
"self",
",",
"value",
")",
":",
"if",
"utils",
".",
"is_dict_like",
"(",
"value",
")",
":",
"raise",
"TypeError",
"(",
"'cannot provide fill value as a dictionary with '",
"'fillna on a DataArray'",
")",
"out",
"=",
"ops",
".",
"fillna",
"(... | Fill missing values in this object.
This operation follows the normal broadcasting and alignment rules that
xarray uses for binary arithmetic, except the result is aligned to this
object (``join='left'``) instead of aligned to the intersection of
index coordinates (``join='inner'``).
... | [
"Fill",
"missing",
"values",
"in",
"this",
"object",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1476-L1499 | train | Fill missing values in this array with value. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.ffill | def ffill(self, dim, limit=None):
'''Fill NaN values by propogating values forward
*Requires bottleneck.*
Parameters
----------
dim : str
Specifies the dimension along which to propagate values when
filling.
limit : int, default None
... | python | def ffill(self, dim, limit=None):
'''Fill NaN values by propogating values forward
*Requires bottleneck.*
Parameters
----------
dim : str
Specifies the dimension along which to propagate values when
filling.
limit : int, default None
... | [
"def",
"ffill",
"(",
"self",
",",
"dim",
",",
"limit",
"=",
"None",
")",
":",
"from",
".",
"missing",
"import",
"ffill",
"return",
"ffill",
"(",
"self",
",",
"dim",
",",
"limit",
"=",
"limit",
")"
] | Fill NaN values by propogating values forward
*Requires bottleneck.*
Parameters
----------
dim : str
Specifies the dimension along which to propagate values when
filling.
limit : int, default None
The maximum number of consecutive NaN values ... | [
"Fill",
"NaN",
"values",
"by",
"propogating",
"values",
"forward"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1546-L1567 | train | Fill NaN values by propogating values forward
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.bfill | def bfill(self, dim, limit=None):
'''Fill NaN values by propogating values backward
*Requires bottleneck.*
Parameters
----------
dim : str
Specifies the dimension along which to propagate values when
filling.
limit : int, default None
... | python | def bfill(self, dim, limit=None):
'''Fill NaN values by propogating values backward
*Requires bottleneck.*
Parameters
----------
dim : str
Specifies the dimension along which to propagate values when
filling.
limit : int, default None
... | [
"def",
"bfill",
"(",
"self",
",",
"dim",
",",
"limit",
"=",
"None",
")",
":",
"from",
".",
"missing",
"import",
"bfill",
"return",
"bfill",
"(",
"self",
",",
"dim",
",",
"limit",
"=",
"limit",
")"
] | Fill NaN values by propogating values backward
*Requires bottleneck.*
Parameters
----------
dim : str
Specifies the dimension along which to propagate values when
filling.
limit : int, default None
The maximum number of consecutive NaN values... | [
"Fill",
"NaN",
"values",
"by",
"propogating",
"values",
"backward"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1569-L1590 | train | Fill NaN values by propogating values backward
filling. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.reduce | def reduce(self, func, dim=None, axis=None, keep_attrs=None, **kwargs):
"""Reduce this array by applying `func` along some dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`f(x, axis=axis, **kwargs)` to return the resul... | python | def reduce(self, func, dim=None, axis=None, keep_attrs=None, **kwargs):
"""Reduce this array by applying `func` along some dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`f(x, axis=axis, **kwargs)` to return the resul... | [
"def",
"reduce",
"(",
"self",
",",
"func",
",",
"dim",
"=",
"None",
",",
"axis",
"=",
"None",
",",
"keep_attrs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"var",
"=",
"self",
".",
"variable",
".",
"reduce",
"(",
"func",
",",
"dim",
",",
"... | Reduce this array by applying `func` along some dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`f(x, axis=axis, **kwargs)` to return the result of reducing an
np.ndarray over an integer valued axis.
dim : ... | [
"Reduce",
"this",
"array",
"by",
"applying",
"func",
"along",
"some",
"dimension",
"(",
"s",
")",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1610-L1641 | train | Reduce this array by applying func along some dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.to_pandas | def to_pandas(self):
"""Convert this array into a pandas object with the same shape.
The type of the returned object depends on the number of DataArray
dimensions:
* 1D -> `pandas.Series`
* 2D -> `pandas.DataFrame`
* 3D -> `pandas.Panel`
Only works for arrays w... | python | def to_pandas(self):
"""Convert this array into a pandas object with the same shape.
The type of the returned object depends on the number of DataArray
dimensions:
* 1D -> `pandas.Series`
* 2D -> `pandas.DataFrame`
* 3D -> `pandas.Panel`
Only works for arrays w... | [
"def",
"to_pandas",
"(",
"self",
")",
":",
"# TODO: consolidate the info about pandas constructors and the",
"# attributes that correspond to their indexes into a separate module?",
"constructors",
"=",
"{",
"0",
":",
"lambda",
"x",
":",
"x",
",",
"1",
":",
"pd",
".",
"Se... | Convert this array into a pandas object with the same shape.
The type of the returned object depends on the number of DataArray
dimensions:
* 1D -> `pandas.Series`
* 2D -> `pandas.DataFrame`
* 3D -> `pandas.Panel`
Only works for arrays with 3 or fewer dimensions.
... | [
"Convert",
"this",
"array",
"into",
"a",
"pandas",
"object",
"with",
"the",
"same",
"shape",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1643-L1669 | train | Convert this array into a pandas object with the same shape. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.to_dataframe | def to_dataframe(self, name=None):
"""Convert this array and its coordinates into a tidy pandas.DataFrame.
The DataFrame is indexed by the Cartesian product of index coordinates
(in the form of a :py:class:`pandas.MultiIndex`).
Other coordinates are included as columns in the DataFrame... | python | def to_dataframe(self, name=None):
"""Convert this array and its coordinates into a tidy pandas.DataFrame.
The DataFrame is indexed by the Cartesian product of index coordinates
(in the form of a :py:class:`pandas.MultiIndex`).
Other coordinates are included as columns in the DataFrame... | [
"def",
"to_dataframe",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"self",
".",
"name",
"if",
"name",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'cannot convert an unnamed DataArray to a '",
"'DataFrame... | Convert this array and its coordinates into a tidy pandas.DataFrame.
The DataFrame is indexed by the Cartesian product of index coordinates
(in the form of a :py:class:`pandas.MultiIndex`).
Other coordinates are included as columns in the DataFrame. | [
"Convert",
"this",
"array",
"and",
"its",
"coordinates",
"into",
"a",
"tidy",
"pandas",
".",
"DataFrame",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1671-L1696 | train | Convert this array and its coordinates into a tidy pandas. DataFrame. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.to_series | def to_series(self):
"""Convert this array into a pandas.Series.
The Series is indexed by the Cartesian product of index coordinates
(in the form of a :py:class:`pandas.MultiIndex`).
"""
index = self.coords.to_index()
return pd.Series(self.values.reshape(-1), index=index... | python | def to_series(self):
"""Convert this array into a pandas.Series.
The Series is indexed by the Cartesian product of index coordinates
(in the form of a :py:class:`pandas.MultiIndex`).
"""
index = self.coords.to_index()
return pd.Series(self.values.reshape(-1), index=index... | [
"def",
"to_series",
"(",
"self",
")",
":",
"index",
"=",
"self",
".",
"coords",
".",
"to_index",
"(",
")",
"return",
"pd",
".",
"Series",
"(",
"self",
".",
"values",
".",
"reshape",
"(",
"-",
"1",
")",
",",
"index",
"=",
"index",
",",
"name",
"="... | Convert this array into a pandas.Series.
The Series is indexed by the Cartesian product of index coordinates
(in the form of a :py:class:`pandas.MultiIndex`). | [
"Convert",
"this",
"array",
"into",
"a",
"pandas",
".",
"Series",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1698-L1705 | train | Convert this array into a pandas. Series. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.to_masked_array | def to_masked_array(self, copy=True):
"""Convert this array into a numpy.ma.MaskedArray
Parameters
----------
copy : bool
If True (default) make a copy of the array in the result. If False,
a MaskedArray view of DataArray.values is returned.
Returns
... | python | def to_masked_array(self, copy=True):
"""Convert this array into a numpy.ma.MaskedArray
Parameters
----------
copy : bool
If True (default) make a copy of the array in the result. If False,
a MaskedArray view of DataArray.values is returned.
Returns
... | [
"def",
"to_masked_array",
"(",
"self",
",",
"copy",
"=",
"True",
")",
":",
"isnull",
"=",
"pd",
".",
"isnull",
"(",
"self",
".",
"values",
")",
"return",
"np",
".",
"ma",
".",
"MaskedArray",
"(",
"data",
"=",
"self",
".",
"values",
",",
"mask",
"="... | Convert this array into a numpy.ma.MaskedArray
Parameters
----------
copy : bool
If True (default) make a copy of the array in the result. If False,
a MaskedArray view of DataArray.values is returned.
Returns
-------
result : MaskedArray
... | [
"Convert",
"this",
"array",
"into",
"a",
"numpy",
".",
"ma",
".",
"MaskedArray"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1707-L1722 | train | Convert this array into a numpy. ma. MaskedArray. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.to_netcdf | def to_netcdf(self, *args, **kwargs):
"""Write DataArray contents to a netCDF file.
Parameters
----------
path : str or Path, optional
Path to which to save this dataset. If no path is provided, this
function returns the resulting netCDF file as a bytes object; i... | python | def to_netcdf(self, *args, **kwargs):
"""Write DataArray contents to a netCDF file.
Parameters
----------
path : str or Path, optional
Path to which to save this dataset. If no path is provided, this
function returns the resulting netCDF file as a bytes object; i... | [
"def",
"to_netcdf",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
".",
"backends",
".",
"api",
"import",
"DATAARRAY_NAME",
",",
"DATAARRAY_VARIABLE",
"if",
"self",
".",
"name",
"is",
"None",
":",
"# If no name is set then u... | Write DataArray contents to a netCDF file.
Parameters
----------
path : str or Path, optional
Path to which to save this dataset. If no path is provided, this
function returns the resulting netCDF file as a bytes object; in
this case, we need to use scipy.io.... | [
"Write",
"DataArray",
"contents",
"to",
"a",
"netCDF",
"file",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1724-L1795 | train | Write the contents of the array to a netCDF file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.to_dict | def to_dict(self, data=True):
"""
Convert this xarray.DataArray into a dictionary following xarray
naming conventions.
Converts all variables and attributes to native Python objects.
Useful for coverting to json. To avoid datetime incompatibility
use decode_times=False k... | python | def to_dict(self, data=True):
"""
Convert this xarray.DataArray into a dictionary following xarray
naming conventions.
Converts all variables and attributes to native Python objects.
Useful for coverting to json. To avoid datetime incompatibility
use decode_times=False k... | [
"def",
"to_dict",
"(",
"self",
",",
"data",
"=",
"True",
")",
":",
"d",
"=",
"self",
".",
"variable",
".",
"to_dict",
"(",
"data",
"=",
"data",
")",
"d",
".",
"update",
"(",
"{",
"'coords'",
":",
"{",
"}",
",",
"'name'",
":",
"self",
".",
"name... | Convert this xarray.DataArray into a dictionary following xarray
naming conventions.
Converts all variables and attributes to native Python objects.
Useful for coverting to json. To avoid datetime incompatibility
use decode_times=False kwarg in xarrray.open_dataset.
Parameters
... | [
"Convert",
"this",
"xarray",
".",
"DataArray",
"into",
"a",
"dictionary",
"following",
"xarray",
"naming",
"conventions",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1797-L1820 | train | Convert this xarray. DataArray into a dictionary following xarray. NameConventions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.from_dict | def from_dict(cls, d):
"""
Convert a dictionary into an xarray.DataArray
Input dict can take several forms::
d = {'dims': ('t'), 'data': x}
d = {'coords': {'t': {'dims': 't', 'data': t,
'attrs': {'units':'s'}}},
'attrs... | python | def from_dict(cls, d):
"""
Convert a dictionary into an xarray.DataArray
Input dict can take several forms::
d = {'dims': ('t'), 'data': x}
d = {'coords': {'t': {'dims': 't', 'data': t,
'attrs': {'units':'s'}}},
'attrs... | [
"def",
"from_dict",
"(",
"cls",
",",
"d",
")",
":",
"coords",
"=",
"None",
"if",
"'coords'",
"in",
"d",
":",
"try",
":",
"coords",
"=",
"OrderedDict",
"(",
"[",
"(",
"k",
",",
"(",
"v",
"[",
"'dims'",
"]",
",",
"v",
"[",
"'data'",
"]",
",",
"... | Convert a dictionary into an xarray.DataArray
Input dict can take several forms::
d = {'dims': ('t'), 'data': x}
d = {'coords': {'t': {'dims': 't', 'data': t,
'attrs': {'units':'s'}}},
'attrs': {'title': 'air temperature'},
... | [
"Convert",
"a",
"dictionary",
"into",
"an",
"xarray",
".",
"DataArray"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1823-L1872 | train | Convert a dictionary into an xarray. DataArray
object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.from_series | def from_series(cls, series):
"""Convert a pandas.Series into an xarray.DataArray.
If the series's index is a MultiIndex, it will be expanded into a
tensor product of one-dimensional coordinates (filling in missing
values with NaN). Thus this operation should be the inverse of the
... | python | def from_series(cls, series):
"""Convert a pandas.Series into an xarray.DataArray.
If the series's index is a MultiIndex, it will be expanded into a
tensor product of one-dimensional coordinates (filling in missing
values with NaN). Thus this operation should be the inverse of the
... | [
"def",
"from_series",
"(",
"cls",
",",
"series",
")",
":",
"# TODO: add a 'name' parameter",
"name",
"=",
"series",
".",
"name",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"{",
"name",
":",
"series",
"}",
")",
"ds",
"=",
"Dataset",
".",
"from_dataframe",
"(... | Convert a pandas.Series into an xarray.DataArray.
If the series's index is a MultiIndex, it will be expanded into a
tensor product of one-dimensional coordinates (filling in missing
values with NaN). Thus this operation should be the inverse of the
`to_series` method. | [
"Convert",
"a",
"pandas",
".",
"Series",
"into",
"an",
"xarray",
".",
"DataArray",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1875-L1887 | train | Convert a pandas. Series into an xarray. DataArray.
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray._all_compat | def _all_compat(self, other, compat_str):
"""Helper function for equals and identical"""
def compat(x, y):
return getattr(x.variable, compat_str)(y.variable)
return (utils.dict_equiv(self.coords, other.coords, compat=compat) and
compat(self, other)) | python | def _all_compat(self, other, compat_str):
"""Helper function for equals and identical"""
def compat(x, y):
return getattr(x.variable, compat_str)(y.variable)
return (utils.dict_equiv(self.coords, other.coords, compat=compat) and
compat(self, other)) | [
"def",
"_all_compat",
"(",
"self",
",",
"other",
",",
"compat_str",
")",
":",
"def",
"compat",
"(",
"x",
",",
"y",
")",
":",
"return",
"getattr",
"(",
"x",
".",
"variable",
",",
"compat_str",
")",
"(",
"y",
".",
"variable",
")",
"return",
"(",
"uti... | Helper function for equals and identical | [
"Helper",
"function",
"for",
"equals",
"and",
"identical"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1915-L1922 | train | Helper function for equals and identical | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.identical | def identical(self, other):
"""Like equals, but also checks the array name and attributes, and
attributes on all coordinates.
See Also
--------
DataArray.broadcast_equals
DataArray.equal
"""
try:
return (self.name == other.name and
... | python | def identical(self, other):
"""Like equals, but also checks the array name and attributes, and
attributes on all coordinates.
See Also
--------
DataArray.broadcast_equals
DataArray.equal
"""
try:
return (self.name == other.name and
... | [
"def",
"identical",
"(",
"self",
",",
"other",
")",
":",
"try",
":",
"return",
"(",
"self",
".",
"name",
"==",
"other",
".",
"name",
"and",
"self",
".",
"_all_compat",
"(",
"other",
",",
"'identical'",
")",
")",
"except",
"(",
"TypeError",
",",
"Attr... | Like equals, but also checks the array name and attributes, and
attributes on all coordinates.
See Also
--------
DataArray.broadcast_equals
DataArray.equal | [
"Like",
"equals",
"but",
"also",
"checks",
"the",
"array",
"name",
"and",
"attributes",
"and",
"attributes",
"on",
"all",
"coordinates",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L1959-L1972 | train | Like equals but also checks the array name attributes and attributes on all coordinates. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray._title_for_slice | def _title_for_slice(self, truncate=50):
"""
If the dataarray has 1 dimensional coordinates or comes from a slice
we can show that info in the title
Parameters
----------
truncate : integer
maximum number of characters for title
Returns
-----... | python | def _title_for_slice(self, truncate=50):
"""
If the dataarray has 1 dimensional coordinates or comes from a slice
we can show that info in the title
Parameters
----------
truncate : integer
maximum number of characters for title
Returns
-----... | [
"def",
"_title_for_slice",
"(",
"self",
",",
"truncate",
"=",
"50",
")",
":",
"one_dims",
"=",
"[",
"]",
"for",
"dim",
",",
"coord",
"in",
"self",
".",
"coords",
".",
"items",
"(",
")",
":",
"if",
"coord",
".",
"size",
"==",
"1",
":",
"one_dims",
... | If the dataarray has 1 dimensional coordinates or comes from a slice
we can show that info in the title
Parameters
----------
truncate : integer
maximum number of characters for title
Returns
-------
title : string
Can be used for plot ti... | [
"If",
"the",
"dataarray",
"has",
"1",
"dimensional",
"coordinates",
"or",
"comes",
"from",
"a",
"slice",
"we",
"can",
"show",
"that",
"info",
"in",
"the",
"title"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2061-L2087 | train | Returns a string that can be used for plot titles for a slice of the dataarray. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.diff | def diff(self, dim, n=1, label='upper'):
"""Calculate the n-th order discrete difference along given axis.
Parameters
----------
dim : str, optional
Dimension over which to calculate the finite difference.
n : int, optional
The number of times values are ... | python | def diff(self, dim, n=1, label='upper'):
"""Calculate the n-th order discrete difference along given axis.
Parameters
----------
dim : str, optional
Dimension over which to calculate the finite difference.
n : int, optional
The number of times values are ... | [
"def",
"diff",
"(",
"self",
",",
"dim",
",",
"n",
"=",
"1",
",",
"label",
"=",
"'upper'",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"diff",
"(",
"n",
"=",
"n",
",",
"dim",
"=",
"dim",
",",
"label",
"=",
"label",
")"... | Calculate the n-th order discrete difference along given axis.
Parameters
----------
dim : str, optional
Dimension over which to calculate the finite difference.
n : int, optional
The number of times values are differenced.
label : str, optional
... | [
"Calculate",
"the",
"n",
"-",
"th",
"order",
"discrete",
"difference",
"along",
"given",
"axis",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2089-L2128 | train | Calculate the n - th order discrete difference along given axis. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.shift | def shift(self, shifts=None, fill_value=dtypes.NA, **shifts_kwargs):
"""Shift this array by an offset along one or more dimensions.
Only the data is moved; coordinates stay in place. Values shifted from
beyond array bounds are replaced by NaN. This is consistent with the
behavior of ``s... | python | def shift(self, shifts=None, fill_value=dtypes.NA, **shifts_kwargs):
"""Shift this array by an offset along one or more dimensions.
Only the data is moved; coordinates stay in place. Values shifted from
beyond array bounds are replaced by NaN. This is consistent with the
behavior of ``s... | [
"def",
"shift",
"(",
"self",
",",
"shifts",
"=",
"None",
",",
"fill_value",
"=",
"dtypes",
".",
"NA",
",",
"*",
"*",
"shifts_kwargs",
")",
":",
"variable",
"=",
"self",
".",
"variable",
".",
"shift",
"(",
"shifts",
"=",
"shifts",
",",
"fill_value",
"... | Shift this array by an offset along one or more dimensions.
Only the data is moved; coordinates stay in place. Values shifted from
beyond array bounds are replaced by NaN. This is consistent with the
behavior of ``shift`` in pandas.
Parameters
----------
shifts : Mappin... | [
"Shift",
"this",
"array",
"by",
"an",
"offset",
"along",
"one",
"or",
"more",
"dimensions",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2130-L2171 | train | Shifts this array by an offset along one or more dimensions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.roll | def roll(self, shifts=None, roll_coords=None, **shifts_kwargs):
"""Roll this array by an offset along one or more dimensions.
Unlike shift, roll may rotate all variables, including coordinates
if specified. The direction of rotation is consistent with
:py:func:`numpy.roll`.
Par... | python | def roll(self, shifts=None, roll_coords=None, **shifts_kwargs):
"""Roll this array by an offset along one or more dimensions.
Unlike shift, roll may rotate all variables, including coordinates
if specified. The direction of rotation is consistent with
:py:func:`numpy.roll`.
Par... | [
"def",
"roll",
"(",
"self",
",",
"shifts",
"=",
"None",
",",
"roll_coords",
"=",
"None",
",",
"*",
"*",
"shifts_kwargs",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"roll",
"(",
"shifts",
"=",
"shifts",
",",
"roll_coords",
"=... | Roll this array by an offset along one or more dimensions.
Unlike shift, roll may rotate all variables, including coordinates
if specified. The direction of rotation is consistent with
:py:func:`numpy.roll`.
Parameters
----------
roll_coords : bool
Indicates... | [
"Roll",
"this",
"array",
"by",
"an",
"offset",
"along",
"one",
"or",
"more",
"dimensions",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2173-L2212 | train | Roll this array by an offset along one or more dimensions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.dot | def dot(self, other, dims=None):
"""Perform dot product of two DataArrays along their shared dims.
Equivalent to taking taking tensordot over all shared dims.
Parameters
----------
other : DataArray
The other array with which the dot product is performed.
di... | python | def dot(self, other, dims=None):
"""Perform dot product of two DataArrays along their shared dims.
Equivalent to taking taking tensordot over all shared dims.
Parameters
----------
other : DataArray
The other array with which the dot product is performed.
di... | [
"def",
"dot",
"(",
"self",
",",
"other",
",",
"dims",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"Dataset",
")",
":",
"raise",
"NotImplementedError",
"(",
"'dot products are not yet supported '",
"'with Dataset objects.'",
")",
"if",
"not",
... | Perform dot product of two DataArrays along their shared dims.
Equivalent to taking taking tensordot over all shared dims.
Parameters
----------
other : DataArray
The other array with which the dot product is performed.
dims: list of strings, optional
Al... | [
"Perform",
"dot",
"product",
"of",
"two",
"DataArrays",
"along",
"their",
"shared",
"dims",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2222-L2268 | train | Perform the dot product of two DataArrays along their shared dims. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.sortby | def sortby(self, variables, ascending=True):
"""
Sort object by labels or values (along an axis).
Sorts the dataarray, either along specified dimensions,
or according to values of 1-D dataarrays that share dimension
with calling object.
If the input variables are dataar... | python | def sortby(self, variables, ascending=True):
"""
Sort object by labels or values (along an axis).
Sorts the dataarray, either along specified dimensions,
or according to values of 1-D dataarrays that share dimension
with calling object.
If the input variables are dataar... | [
"def",
"sortby",
"(",
"self",
",",
"variables",
",",
"ascending",
"=",
"True",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"sortby",
"(",
"variables",
",",
"ascending",
"=",
"ascending",
")",
"return",
"self",
".",
"_from_temp_da... | Sort object by labels or values (along an axis).
Sorts the dataarray, either along specified dimensions,
or according to values of 1-D dataarrays that share dimension
with calling object.
If the input variables are dataarrays, then the dataarrays are aligned
(via left-join) to ... | [
"Sort",
"object",
"by",
"labels",
"or",
"values",
"(",
"along",
"an",
"axis",
")",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2270-L2321 | train | Sort the data array by the specified variables. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.quantile | def quantile(self, q, dim=None, interpolation='linear', keep_attrs=None):
"""Compute the qth quantile of the data along the specified dimension.
Returns the qth quantiles(s) of the array elements.
Parameters
----------
q : float in range of [0,1] (or sequence of floats)
... | python | def quantile(self, q, dim=None, interpolation='linear', keep_attrs=None):
"""Compute the qth quantile of the data along the specified dimension.
Returns the qth quantiles(s) of the array elements.
Parameters
----------
q : float in range of [0,1] (or sequence of floats)
... | [
"def",
"quantile",
"(",
"self",
",",
"q",
",",
"dim",
"=",
"None",
",",
"interpolation",
"=",
"'linear'",
",",
"keep_attrs",
"=",
"None",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"quantile",
"(",
"q",
",",
"dim",
"=",
"d... | Compute the qth quantile of the data along the specified dimension.
Returns the qth quantiles(s) of the array elements.
Parameters
----------
q : float in range of [0,1] (or sequence of floats)
Quantile to compute, which must be between 0 and 1 inclusive.
dim : str ... | [
"Compute",
"the",
"qth",
"quantile",
"of",
"the",
"data",
"along",
"the",
"specified",
"dimension",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2323-L2367 | train | Compute the qth quantile of the data along the specified dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.rank | def rank(self, dim, pct=False, keep_attrs=None):
"""Ranks the data.
Equal values are assigned a rank that is the average of the ranks that
would have been otherwise assigned to all of the values within that
set. Ranks begin at 1, not 0. If pct, computes percentage ranks.
NaNs ... | python | def rank(self, dim, pct=False, keep_attrs=None):
"""Ranks the data.
Equal values are assigned a rank that is the average of the ranks that
would have been otherwise assigned to all of the values within that
set. Ranks begin at 1, not 0. If pct, computes percentage ranks.
NaNs ... | [
"def",
"rank",
"(",
"self",
",",
"dim",
",",
"pct",
"=",
"False",
",",
"keep_attrs",
"=",
"None",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"rank",
"(",
"dim",
",",
"pct",
"=",
"pct",
",",
"keep_attrs",
"=",
"keep_attrs",... | Ranks the data.
Equal values are assigned a rank that is the average of the ranks that
would have been otherwise assigned to all of the values within that
set. Ranks begin at 1, not 0. If pct, computes percentage ranks.
NaNs in the input array are returned as NaNs.
The `bottl... | [
"Ranks",
"the",
"data",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2369-L2407 | train | Ranks the data array. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.differentiate | def differentiate(self, coord, edge_order=1, datetime_unit=None):
""" Differentiate the array with the second order accurate central
differences.
.. note::
This feature is limited to simple cartesian geometry, i.e. coord
must be one dimensional.
Parameters
... | python | def differentiate(self, coord, edge_order=1, datetime_unit=None):
""" Differentiate the array with the second order accurate central
differences.
.. note::
This feature is limited to simple cartesian geometry, i.e. coord
must be one dimensional.
Parameters
... | [
"def",
"differentiate",
"(",
"self",
",",
"coord",
",",
"edge_order",
"=",
"1",
",",
"datetime_unit",
"=",
"None",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"differentiate",
"(",
"coord",
",",
"edge_order",
",",
"datetime_unit",
... | Differentiate the array with the second order accurate central
differences.
.. note::
This feature is limited to simple cartesian geometry, i.e. coord
must be one dimensional.
Parameters
----------
coord: str
The coordinate to be used to comp... | [
"Differentiate",
"the",
"array",
"with",
"the",
"second",
"order",
"accurate",
"central",
"differences",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2409-L2462 | train | This function is used to compute the gradient of the array with the second order accurate centralization of the elements. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/dataarray.py | DataArray.integrate | def integrate(self, dim, datetime_unit=None):
""" integrate the array with the trapezoidal rule.
.. note::
This feature is limited to simple cartesian geometry, i.e. coord
must be one dimensional.
Parameters
----------
dim: str, or a sequence of str
... | python | def integrate(self, dim, datetime_unit=None):
""" integrate the array with the trapezoidal rule.
.. note::
This feature is limited to simple cartesian geometry, i.e. coord
must be one dimensional.
Parameters
----------
dim: str, or a sequence of str
... | [
"def",
"integrate",
"(",
"self",
",",
"dim",
",",
"datetime_unit",
"=",
"None",
")",
":",
"ds",
"=",
"self",
".",
"_to_temp_dataset",
"(",
")",
".",
"integrate",
"(",
"dim",
",",
"datetime_unit",
")",
"return",
"self",
".",
"_from_temp_dataset",
"(",
"ds... | integrate the array with the trapezoidal rule.
.. note::
This feature is limited to simple cartesian geometry, i.e. coord
must be one dimensional.
Parameters
----------
dim: str, or a sequence of str
Coordinate(s) used for the integration.
da... | [
"integrate",
"the",
"array",
"with",
"the",
"trapezoidal",
"rule",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataarray.py#L2464-L2509 | train | Integrate the array with the trapezoidal rule. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/rolling.py | DataArrayRolling.construct | def construct(self, window_dim, stride=1, fill_value=dtypes.NA):
"""
Convert this rolling object to xr.DataArray,
where the window dimension is stacked as a new dimension
Parameters
----------
window_dim: str
New name of the window dimension.
stride: ... | python | def construct(self, window_dim, stride=1, fill_value=dtypes.NA):
"""
Convert this rolling object to xr.DataArray,
where the window dimension is stacked as a new dimension
Parameters
----------
window_dim: str
New name of the window dimension.
stride: ... | [
"def",
"construct",
"(",
"self",
",",
"window_dim",
",",
"stride",
"=",
"1",
",",
"fill_value",
"=",
"dtypes",
".",
"NA",
")",
":",
"from",
".",
"dataarray",
"import",
"DataArray",
"window",
"=",
"self",
".",
"obj",
".",
"variable",
".",
"rolling_window"... | Convert this rolling object to xr.DataArray,
where the window dimension is stacked as a new dimension
Parameters
----------
window_dim: str
New name of the window dimension.
stride: integer, optional
Size of stride for the rolling window.
fill_val... | [
"Convert",
"this",
"rolling",
"object",
"to",
"xr",
".",
"DataArray",
"where",
"the",
"window",
"dimension",
"is",
"stacked",
"as",
"a",
"new",
"dimension"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L150-L195 | train | Convert this rolling object to xr. DataArray where the window dimension is stacked as a new dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/rolling.py | DataArrayRolling.reduce | def reduce(self, func, **kwargs):
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`func(x, **kwargs)` to return the result of collapsing an
... | python | def reduce(self, func, **kwargs):
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`func(x, **kwargs)` to return the result of collapsing an
... | [
"def",
"reduce",
"(",
"self",
",",
"func",
",",
"*",
"*",
"kwargs",
")",
":",
"rolling_dim",
"=",
"utils",
".",
"get_temp_dimname",
"(",
"self",
".",
"obj",
".",
"dims",
",",
"'_rolling_dim'",
")",
"windows",
"=",
"self",
".",
"construct",
"(",
"rollin... | Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`func(x, **kwargs)` to return the result of collapsing an
np.ndarray over an the rolling dimensio... | [
"Reduce",
"the",
"items",
"in",
"this",
"group",
"by",
"applying",
"func",
"along",
"some",
"dimension",
"(",
"s",
")",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L197-L221 | train | Reduce the items in this group by applying func along some tier dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/rolling.py | DataArrayRolling._counts | def _counts(self):
""" Number of non-nan entries in each rolling window. """
rolling_dim = utils.get_temp_dimname(self.obj.dims, '_rolling_dim')
# We use False as the fill_value instead of np.nan, since boolean
# array is faster to be reduced than object array.
# The use of skip... | python | def _counts(self):
""" Number of non-nan entries in each rolling window. """
rolling_dim = utils.get_temp_dimname(self.obj.dims, '_rolling_dim')
# We use False as the fill_value instead of np.nan, since boolean
# array is faster to be reduced than object array.
# The use of skip... | [
"def",
"_counts",
"(",
"self",
")",
":",
"rolling_dim",
"=",
"utils",
".",
"get_temp_dimname",
"(",
"self",
".",
"obj",
".",
"dims",
",",
"'_rolling_dim'",
")",
"# We use False as the fill_value instead of np.nan, since boolean",
"# array is faster to be reduced than object... | Number of non-nan entries in each rolling window. | [
"Number",
"of",
"non",
"-",
"nan",
"entries",
"in",
"each",
"rolling",
"window",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L223-L235 | train | Number of non - nan entries in each rolling window. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/rolling.py | DataArrayRolling._reduce_method | def _reduce_method(cls, func):
"""
Methods to return a wrapped function for any function `func` for
numpy methods.
"""
def wrapped_func(self, **kwargs):
return self.reduce(func, **kwargs)
return wrapped_func | python | def _reduce_method(cls, func):
"""
Methods to return a wrapped function for any function `func` for
numpy methods.
"""
def wrapped_func(self, **kwargs):
return self.reduce(func, **kwargs)
return wrapped_func | [
"def",
"_reduce_method",
"(",
"cls",
",",
"func",
")",
":",
"def",
"wrapped_func",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"reduce",
"(",
"func",
",",
"*",
"*",
"kwargs",
")",
"return",
"wrapped_func"
] | Methods to return a wrapped function for any function `func` for
numpy methods. | [
"Methods",
"to",
"return",
"a",
"wrapped",
"function",
"for",
"any",
"function",
"func",
"for",
"numpy",
"methods",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L238-L246 | train | Returns a wrapped function for any function func for the n - tuple class. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/rolling.py | DataArrayRolling._bottleneck_reduce | def _bottleneck_reduce(cls, func):
"""
Methods to return a wrapped function for any function `func` for
bottoleneck method, except for `median`.
"""
def wrapped_func(self, **kwargs):
from .dataarray import DataArray
# bottleneck doesn't allow min_count t... | python | def _bottleneck_reduce(cls, func):
"""
Methods to return a wrapped function for any function `func` for
bottoleneck method, except for `median`.
"""
def wrapped_func(self, **kwargs):
from .dataarray import DataArray
# bottleneck doesn't allow min_count t... | [
"def",
"_bottleneck_reduce",
"(",
"cls",
",",
"func",
")",
":",
"def",
"wrapped_func",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"dataarray",
"import",
"DataArray",
"# bottleneck doesn't allow min_count to be 0, although it should",
"# work the same... | Methods to return a wrapped function for any function `func` for
bottoleneck method, except for `median`. | [
"Methods",
"to",
"return",
"a",
"wrapped",
"function",
"for",
"any",
"function",
"func",
"for",
"bottoleneck",
"method",
"except",
"for",
"median",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L249-L301 | train | Decorator for bottoleneck methods. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/rolling.py | DatasetRolling.reduce | def reduce(self, func, **kwargs):
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`func(x, **kwargs)` to return the result of collapsing an
... | python | def reduce(self, func, **kwargs):
"""Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`func(x, **kwargs)` to return the result of collapsing an
... | [
"def",
"reduce",
"(",
"self",
",",
"func",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"dataset",
"import",
"Dataset",
"reduced",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
",",
"da",
"in",
"self",
".",
"obj",
".",
"data_vars",
".",
"items",
"... | Reduce the items in this group by applying `func` along some
dimension(s).
Parameters
----------
func : function
Function which can be called in the form
`func(x, **kwargs)` to return the result of collapsing an
np.ndarray over an the rolling dimensio... | [
"Reduce",
"the",
"items",
"in",
"this",
"group",
"by",
"applying",
"func",
"along",
"some",
"dimension",
"(",
"s",
")",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L350-L375 | train | Reduce the items in this group by applying func along some tier dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/rolling.py | DatasetRolling._reduce_method | def _reduce_method(cls, func):
"""
Return a wrapped function for injecting numpy and bottoleneck methods.
see ops.inject_datasetrolling_methods
"""
def wrapped_func(self, **kwargs):
from .dataset import Dataset
reduced = OrderedDict()
for key,... | python | def _reduce_method(cls, func):
"""
Return a wrapped function for injecting numpy and bottoleneck methods.
see ops.inject_datasetrolling_methods
"""
def wrapped_func(self, **kwargs):
from .dataset import Dataset
reduced = OrderedDict()
for key,... | [
"def",
"_reduce_method",
"(",
"cls",
",",
"func",
")",
":",
"def",
"wrapped_func",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"dataset",
"import",
"Dataset",
"reduced",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
",",
"da",
"in",
"s... | Return a wrapped function for injecting numpy and bottoleneck methods.
see ops.inject_datasetrolling_methods | [
"Return",
"a",
"wrapped",
"function",
"for",
"injecting",
"numpy",
"and",
"bottoleneck",
"methods",
".",
"see",
"ops",
".",
"inject_datasetrolling_methods"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L388-L404 | train | Returns a wrapped function for injecting numpy and bottoleneck methods.
is the name of the method that is used to reduce the object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/rolling.py | DatasetRolling.construct | def construct(self, window_dim, stride=1, fill_value=dtypes.NA):
"""
Convert this rolling object to xr.Dataset,
where the window dimension is stacked as a new dimension
Parameters
----------
window_dim: str
New name of the window dimension.
stride: in... | python | def construct(self, window_dim, stride=1, fill_value=dtypes.NA):
"""
Convert this rolling object to xr.Dataset,
where the window dimension is stacked as a new dimension
Parameters
----------
window_dim: str
New name of the window dimension.
stride: in... | [
"def",
"construct",
"(",
"self",
",",
"window_dim",
",",
"stride",
"=",
"1",
",",
"fill_value",
"=",
"dtypes",
".",
"NA",
")",
":",
"from",
".",
"dataset",
"import",
"Dataset",
"dataset",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
",",
"da",
"in",
"... | Convert this rolling object to xr.Dataset,
where the window dimension is stacked as a new dimension
Parameters
----------
window_dim: str
New name of the window dimension.
stride: integer, optional
size of stride for the rolling window.
fill_value... | [
"Convert",
"this",
"rolling",
"object",
"to",
"xr",
".",
"Dataset",
"where",
"the",
"window",
"dimension",
"is",
"stacked",
"as",
"a",
"new",
"dimension"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L406-L435 | train | Convert this rolling object to xr. Dataset where the dimension is stacked as a new dimension. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/rolling.py | DataArrayCoarsen._reduce_method | def _reduce_method(cls, func):
"""
Return a wrapped function for injecting numpy methods.
see ops.inject_coarsen_methods
"""
def wrapped_func(self, **kwargs):
from .dataarray import DataArray
reduced = self.obj.variable.coarsen(
self.windo... | python | def _reduce_method(cls, func):
"""
Return a wrapped function for injecting numpy methods.
see ops.inject_coarsen_methods
"""
def wrapped_func(self, **kwargs):
from .dataarray import DataArray
reduced = self.obj.variable.coarsen(
self.windo... | [
"def",
"_reduce_method",
"(",
"cls",
",",
"func",
")",
":",
"def",
"wrapped_func",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"dataarray",
"import",
"DataArray",
"reduced",
"=",
"self",
".",
"obj",
".",
"variable",
".",
"coarsen",
"("... | Return a wrapped function for injecting numpy methods.
see ops.inject_coarsen_methods | [
"Return",
"a",
"wrapped",
"function",
"for",
"injecting",
"numpy",
"methods",
".",
"see",
"ops",
".",
"inject_coarsen_methods"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L498-L521 | train | Returns a wrapped function for injecting numpy methods. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/rolling.py | DatasetCoarsen._reduce_method | def _reduce_method(cls, func):
"""
Return a wrapped function for injecting numpy methods.
see ops.inject_coarsen_methods
"""
def wrapped_func(self, **kwargs):
from .dataset import Dataset
reduced = OrderedDict()
for key, da in self.obj.data_va... | python | def _reduce_method(cls, func):
"""
Return a wrapped function for injecting numpy methods.
see ops.inject_coarsen_methods
"""
def wrapped_func(self, **kwargs):
from .dataset import Dataset
reduced = OrderedDict()
for key, da in self.obj.data_va... | [
"def",
"_reduce_method",
"(",
"cls",
",",
"func",
")",
":",
"def",
"wrapped_func",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"dataset",
"import",
"Dataset",
"reduced",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
",",
"da",
"in",
"s... | Return a wrapped function for injecting numpy methods.
see ops.inject_coarsen_methods | [
"Return",
"a",
"wrapped",
"function",
"for",
"injecting",
"numpy",
"methods",
".",
"see",
"ops",
".",
"inject_coarsen_methods"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/rolling.py#L526-L549 | train | Returns a wrapped function for injecting numpy methods. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/coding/strings.py | ensure_fixed_length_bytes | def ensure_fixed_length_bytes(var):
"""Ensure that a variable with vlen bytes is converted to fixed width."""
dims, data, attrs, encoding = unpack_for_encoding(var)
if check_vlen_dtype(data.dtype) == bytes:
# TODO: figure out how to handle this with dask
data = np.asarray(data, dtype=np.stri... | python | def ensure_fixed_length_bytes(var):
"""Ensure that a variable with vlen bytes is converted to fixed width."""
dims, data, attrs, encoding = unpack_for_encoding(var)
if check_vlen_dtype(data.dtype) == bytes:
# TODO: figure out how to handle this with dask
data = np.asarray(data, dtype=np.stri... | [
"def",
"ensure_fixed_length_bytes",
"(",
"var",
")",
":",
"dims",
",",
"data",
",",
"attrs",
",",
"encoding",
"=",
"unpack_for_encoding",
"(",
"var",
")",
"if",
"check_vlen_dtype",
"(",
"data",
".",
"dtype",
")",
"==",
"bytes",
":",
"# TODO: figure out how to ... | Ensure that a variable with vlen bytes is converted to fixed width. | [
"Ensure",
"that",
"a",
"variable",
"with",
"vlen",
"bytes",
"is",
"converted",
"to",
"fixed",
"width",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/strings.py#L88-L94 | train | Ensure that a variable with vlen bytes is converted to fixed width. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/coding/strings.py | bytes_to_char | def bytes_to_char(arr):
"""Convert numpy/dask arrays from fixed width bytes to characters."""
if arr.dtype.kind != 'S':
raise ValueError('argument must have a fixed-width bytes dtype')
if isinstance(arr, dask_array_type):
import dask.array as da
return da.map_blocks(_numpy_bytes_to_... | python | def bytes_to_char(arr):
"""Convert numpy/dask arrays from fixed width bytes to characters."""
if arr.dtype.kind != 'S':
raise ValueError('argument must have a fixed-width bytes dtype')
if isinstance(arr, dask_array_type):
import dask.array as da
return da.map_blocks(_numpy_bytes_to_... | [
"def",
"bytes_to_char",
"(",
"arr",
")",
":",
"if",
"arr",
".",
"dtype",
".",
"kind",
"!=",
"'S'",
":",
"raise",
"ValueError",
"(",
"'argument must have a fixed-width bytes dtype'",
")",
"if",
"isinstance",
"(",
"arr",
",",
"dask_array_type",
")",
":",
"import... | Convert numpy/dask arrays from fixed width bytes to characters. | [
"Convert",
"numpy",
"/",
"dask",
"arrays",
"from",
"fixed",
"width",
"bytes",
"to",
"characters",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/strings.py#L123-L135 | train | Convert numpy arrays from fixed width bytes to characters. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/coding/strings.py | _numpy_bytes_to_char | def _numpy_bytes_to_char(arr):
"""Like netCDF4.stringtochar, but faster and more flexible.
"""
# ensure the array is contiguous
arr = np.array(arr, copy=False, order='C', dtype=np.string_)
return arr.reshape(arr.shape + (1,)).view('S1') | python | def _numpy_bytes_to_char(arr):
"""Like netCDF4.stringtochar, but faster and more flexible.
"""
# ensure the array is contiguous
arr = np.array(arr, copy=False, order='C', dtype=np.string_)
return arr.reshape(arr.shape + (1,)).view('S1') | [
"def",
"_numpy_bytes_to_char",
"(",
"arr",
")",
":",
"# ensure the array is contiguous",
"arr",
"=",
"np",
".",
"array",
"(",
"arr",
",",
"copy",
"=",
"False",
",",
"order",
"=",
"'C'",
",",
"dtype",
"=",
"np",
".",
"string_",
")",
"return",
"arr",
".",
... | Like netCDF4.stringtochar, but faster and more flexible. | [
"Like",
"netCDF4",
".",
"stringtochar",
"but",
"faster",
"and",
"more",
"flexible",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/strings.py#L138-L143 | train | Like netCDF4. stringtochar but faster and more flexible.
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/coding/strings.py | char_to_bytes | def char_to_bytes(arr):
"""Convert numpy/dask arrays from characters to fixed width bytes."""
if arr.dtype != 'S1':
raise ValueError("argument must have dtype='S1'")
if not arr.ndim:
# no dimension to concatenate along
return arr
size = arr.shape[-1]
if not size:
#... | python | def char_to_bytes(arr):
"""Convert numpy/dask arrays from characters to fixed width bytes."""
if arr.dtype != 'S1':
raise ValueError("argument must have dtype='S1'")
if not arr.ndim:
# no dimension to concatenate along
return arr
size = arr.shape[-1]
if not size:
#... | [
"def",
"char_to_bytes",
"(",
"arr",
")",
":",
"if",
"arr",
".",
"dtype",
"!=",
"'S1'",
":",
"raise",
"ValueError",
"(",
"\"argument must have dtype='S1'\"",
")",
"if",
"not",
"arr",
".",
"ndim",
":",
"# no dimension to concatenate along",
"return",
"arr",
"size"... | Convert numpy/dask arrays from characters to fixed width bytes. | [
"Convert",
"numpy",
"/",
"dask",
"arrays",
"from",
"characters",
"to",
"fixed",
"width",
"bytes",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/strings.py#L146-L175 | train | Convert numpy arrays from characters to fixed width bytes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/coding/strings.py | _numpy_char_to_bytes | def _numpy_char_to_bytes(arr):
"""Like netCDF4.chartostring, but faster and more flexible.
"""
# based on: http://stackoverflow.com/a/10984878/809705
arr = np.array(arr, copy=False, order='C')
dtype = 'S' + str(arr.shape[-1])
return arr.view(dtype).reshape(arr.shape[:-1]) | python | def _numpy_char_to_bytes(arr):
"""Like netCDF4.chartostring, but faster and more flexible.
"""
# based on: http://stackoverflow.com/a/10984878/809705
arr = np.array(arr, copy=False, order='C')
dtype = 'S' + str(arr.shape[-1])
return arr.view(dtype).reshape(arr.shape[:-1]) | [
"def",
"_numpy_char_to_bytes",
"(",
"arr",
")",
":",
"# based on: http://stackoverflow.com/a/10984878/809705",
"arr",
"=",
"np",
".",
"array",
"(",
"arr",
",",
"copy",
"=",
"False",
",",
"order",
"=",
"'C'",
")",
"dtype",
"=",
"'S'",
"+",
"str",
"(",
"arr",
... | Like netCDF4.chartostring, but faster and more flexible. | [
"Like",
"netCDF4",
".",
"chartostring",
"but",
"faster",
"and",
"more",
"flexible",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/coding/strings.py#L178-L184 | train | Like netCDF4. chartostring but faster and more flexible.
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/utils.py | safe_cast_to_index | def safe_cast_to_index(array: Any) -> pd.Index:
"""Given an array, safely cast it to a pandas.Index.
If it is already a pandas.Index, return it unchanged.
Unlike pandas.Index, if the array has dtype=object or dtype=timedelta64,
this function will not attempt to do automatic type conversion but will
... | python | def safe_cast_to_index(array: Any) -> pd.Index:
"""Given an array, safely cast it to a pandas.Index.
If it is already a pandas.Index, return it unchanged.
Unlike pandas.Index, if the array has dtype=object or dtype=timedelta64,
this function will not attempt to do automatic type conversion but will
... | [
"def",
"safe_cast_to_index",
"(",
"array",
":",
"Any",
")",
"->",
"pd",
".",
"Index",
":",
"if",
"isinstance",
"(",
"array",
",",
"pd",
".",
"Index",
")",
":",
"index",
"=",
"array",
"elif",
"hasattr",
"(",
"array",
",",
"'to_index'",
")",
":",
"inde... | Given an array, safely cast it to a pandas.Index.
If it is already a pandas.Index, return it unchanged.
Unlike pandas.Index, if the array has dtype=object or dtype=timedelta64,
this function will not attempt to do automatic type conversion but will
always return an index with dtype=object. | [
"Given",
"an",
"array",
"safely",
"cast",
"it",
"to",
"a",
"pandas",
".",
"Index",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L74-L92 | train | Given an array safely cast it to a pandas. Index. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/utils.py | multiindex_from_product_levels | def multiindex_from_product_levels(levels: Sequence[pd.Index],
names: Optional[Sequence[str]] = None
) -> pd.MultiIndex:
"""Creating a MultiIndex from a product without refactorizing levels.
Keeping levels the same gives back the original la... | python | def multiindex_from_product_levels(levels: Sequence[pd.Index],
names: Optional[Sequence[str]] = None
) -> pd.MultiIndex:
"""Creating a MultiIndex from a product without refactorizing levels.
Keeping levels the same gives back the original la... | [
"def",
"multiindex_from_product_levels",
"(",
"levels",
":",
"Sequence",
"[",
"pd",
".",
"Index",
"]",
",",
"names",
":",
"Optional",
"[",
"Sequence",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"pd",
".",
"MultiIndex",
":",
"if",
"any",
"(",
"not",
... | Creating a MultiIndex from a product without refactorizing levels.
Keeping levels the same gives back the original labels when we unstack.
Parameters
----------
levels : sequence of pd.Index
Values for each MultiIndex level.
names : optional sequence of objects
Names for each level... | [
"Creating",
"a",
"MultiIndex",
"from",
"a",
"product",
"without",
"refactorizing",
"levels",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L95-L119 | train | Create a MultiIndex from a product with refactorizing levels. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/utils.py | maybe_wrap_array | def maybe_wrap_array(original, new_array):
"""Wrap a transformed array with __array_wrap__ is it can be done safely.
This lets us treat arbitrary functions that take and return ndarray objects
like ufuncs, as long as they return an array with the same shape.
"""
# in case func lost array's metadata... | python | def maybe_wrap_array(original, new_array):
"""Wrap a transformed array with __array_wrap__ is it can be done safely.
This lets us treat arbitrary functions that take and return ndarray objects
like ufuncs, as long as they return an array with the same shape.
"""
# in case func lost array's metadata... | [
"def",
"maybe_wrap_array",
"(",
"original",
",",
"new_array",
")",
":",
"# in case func lost array's metadata",
"if",
"isinstance",
"(",
"new_array",
",",
"np",
".",
"ndarray",
")",
"and",
"new_array",
".",
"shape",
"==",
"original",
".",
"shape",
":",
"return",... | Wrap a transformed array with __array_wrap__ is it can be done safely.
This lets us treat arbitrary functions that take and return ndarray objects
like ufuncs, as long as they return an array with the same shape. | [
"Wrap",
"a",
"transformed",
"array",
"with",
"__array_wrap__",
"is",
"it",
"can",
"be",
"done",
"safely",
"."
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L122-L132 | train | Wrap a transformed array with __array_wrap__ is it can be done safely. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
pydata/xarray | xarray/core/utils.py | peek_at | def peek_at(iterable: Iterable[T]) -> Tuple[T, Iterator[T]]:
"""Returns the first value from iterable, as well as a new iterator with
the same content as the original iterable
"""
gen = iter(iterable)
peek = next(gen)
return peek, itertools.chain([peek], gen) | python | def peek_at(iterable: Iterable[T]) -> Tuple[T, Iterator[T]]:
"""Returns the first value from iterable, as well as a new iterator with
the same content as the original iterable
"""
gen = iter(iterable)
peek = next(gen)
return peek, itertools.chain([peek], gen) | [
"def",
"peek_at",
"(",
"iterable",
":",
"Iterable",
"[",
"T",
"]",
")",
"->",
"Tuple",
"[",
"T",
",",
"Iterator",
"[",
"T",
"]",
"]",
":",
"gen",
"=",
"iter",
"(",
"iterable",
")",
"peek",
"=",
"next",
"(",
"gen",
")",
"return",
"peek",
",",
"i... | Returns the first value from iterable, as well as a new iterator with
the same content as the original iterable | [
"Returns",
"the",
"first",
"value",
"from",
"iterable",
"as",
"well",
"as",
"a",
"new",
"iterator",
"with",
"the",
"same",
"content",
"as",
"the",
"original",
"iterable"
] | 6d93a95d05bdbfc33fff24064f67d29dd891ab58 | https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/utils.py#L149-L155 | train | Returns the first value from iterable as well as a new iterator with
the same content as the original iterable | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.