repository_name
stringlengths 7
54
| func_path_in_repository
stringlengths 5
179
| func_name
stringlengths 1
109
| whole_func_string
stringlengths 100
30.9k
| language
stringclasses 1
value | func_code_string
stringlengths 100
30.9k
| func_code_tokens
sequencelengths 20
3.12k
| func_documentation_string
stringlengths 1
29.9k
| func_documentation_tokens
sequencelengths 1
893
| split_name
stringclasses 1
value | func_code_url
stringlengths 91
272
| formatted_prompt
stringlengths 344
61k
| input_ids
sequencelengths 512
512
| attention_mask
sequencelengths 512
512
| labels
sequencelengths 512
512
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pyviz/holoviews | holoviews/plotting/bokeh/util.py | pad_width | def pad_width(model, table_padding=0.85, tabs_padding=1.2):
"""
Computes the width of a model and sets up appropriate padding
for Tabs and DataTable types.
"""
if isinstance(model, Row):
vals = [pad_width(child) for child in model.children]
width = np.max([v for v in vals if v is not None])
elif isinstance(model, Column):
vals = [pad_width(child) for child in model.children]
width = np.sum([v for v in vals if v is not None])
elif isinstance(model, Tabs):
vals = [pad_width(t) for t in model.tabs]
width = np.max([v for v in vals if v is not None])
for model in model.tabs:
model.width = width
width = int(tabs_padding*width)
elif isinstance(model, DataTable):
width = model.width
model.width = int(table_padding*width)
elif isinstance(model, (WidgetBox, Div)):
width = model.width
elif model:
width = model.plot_width
else:
width = 0
return width | python | def pad_width(model, table_padding=0.85, tabs_padding=1.2):
"""
Computes the width of a model and sets up appropriate padding
for Tabs and DataTable types.
"""
if isinstance(model, Row):
vals = [pad_width(child) for child in model.children]
width = np.max([v for v in vals if v is not None])
elif isinstance(model, Column):
vals = [pad_width(child) for child in model.children]
width = np.sum([v for v in vals if v is not None])
elif isinstance(model, Tabs):
vals = [pad_width(t) for t in model.tabs]
width = np.max([v for v in vals if v is not None])
for model in model.tabs:
model.width = width
width = int(tabs_padding*width)
elif isinstance(model, DataTable):
width = model.width
model.width = int(table_padding*width)
elif isinstance(model, (WidgetBox, Div)):
width = model.width
elif model:
width = model.plot_width
else:
width = 0
return width | [
"def",
"pad_width",
"(",
"model",
",",
"table_padding",
"=",
"0.85",
",",
"tabs_padding",
"=",
"1.2",
")",
":",
"if",
"isinstance",
"(",
"model",
",",
"Row",
")",
":",
"vals",
"=",
"[",
"pad_width",
"(",
"child",
")",
"for",
"child",
"in",
"model",
".",
"children",
"]",
"width",
"=",
"np",
".",
"max",
"(",
"[",
"v",
"for",
"v",
"in",
"vals",
"if",
"v",
"is",
"not",
"None",
"]",
")",
"elif",
"isinstance",
"(",
"model",
",",
"Column",
")",
":",
"vals",
"=",
"[",
"pad_width",
"(",
"child",
")",
"for",
"child",
"in",
"model",
".",
"children",
"]",
"width",
"=",
"np",
".",
"sum",
"(",
"[",
"v",
"for",
"v",
"in",
"vals",
"if",
"v",
"is",
"not",
"None",
"]",
")",
"elif",
"isinstance",
"(",
"model",
",",
"Tabs",
")",
":",
"vals",
"=",
"[",
"pad_width",
"(",
"t",
")",
"for",
"t",
"in",
"model",
".",
"tabs",
"]",
"width",
"=",
"np",
".",
"max",
"(",
"[",
"v",
"for",
"v",
"in",
"vals",
"if",
"v",
"is",
"not",
"None",
"]",
")",
"for",
"model",
"in",
"model",
".",
"tabs",
":",
"model",
".",
"width",
"=",
"width",
"width",
"=",
"int",
"(",
"tabs_padding",
"*",
"width",
")",
"elif",
"isinstance",
"(",
"model",
",",
"DataTable",
")",
":",
"width",
"=",
"model",
".",
"width",
"model",
".",
"width",
"=",
"int",
"(",
"table_padding",
"*",
"width",
")",
"elif",
"isinstance",
"(",
"model",
",",
"(",
"WidgetBox",
",",
"Div",
")",
")",
":",
"width",
"=",
"model",
".",
"width",
"elif",
"model",
":",
"width",
"=",
"model",
".",
"plot_width",
"else",
":",
"width",
"=",
"0",
"return",
"width"
] | Computes the width of a model and sets up appropriate padding
for Tabs and DataTable types. | [
"Computes",
"the",
"width",
"of",
"a",
"model",
"and",
"sets",
"up",
"appropriate",
"padding",
"for",
"Tabs",
"and",
"DataTable",
"types",
"."
] | train | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/bokeh/util.py#L468-L494 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Computes the width of a model and sets up appropriate padding
for Tabs and DataTable types.
### Response:
def pad_width(model, table_padding=0.85, tabs_padding=1.2):
"""
Computes the width of a model and sets up appropriate padding
for Tabs and DataTable types.
"""
if isinstance(model, Row):
vals = [pad_width(child) for child in model.children]
width = np.max([v for v in vals if v is not None])
elif isinstance(model, Column):
vals = [pad_width(child) for child in model.children]
width = np.sum([v for v in vals if v is not None])
elif isinstance(model, Tabs):
vals = [pad_width(t) for t in model.tabs]
width = np.max([v for v in vals if v is not None])
for model in model.tabs:
model.width = width
width = int(tabs_padding*width)
elif isinstance(model, DataTable):
width = model.width
model.width = int(table_padding*width)
elif isinstance(model, (WidgetBox, Div)):
width = model.width
elif model:
width = model.plot_width
else:
width = 0
return width
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
59122,
288,
279,
2430,
315,
264,
1646,
323,
7437,
709,
8475,
5413,
198,
262,
369,
53714,
323,
17351,
4595,
382,
14711,
6075,
512,
755,
11262,
8086,
7790,
11,
2007,
41826,
28,
15,
13,
5313,
11,
23204,
41826,
28,
16,
13,
17,
997,
262,
3270,
262,
66075,
279,
2430,
315,
264,
1646,
323,
7437,
709,
8475,
5413,
198,
262,
369,
53714,
323,
17351,
4595,
627,
262,
3270,
262,
422,
11656,
7790,
11,
11035,
997,
286,
29456,
284,
510,
13545,
8086,
18272,
8,
369,
1716,
304,
1646,
13664,
933,
286,
2430,
284,
2660,
6817,
2625,
85,
369,
348,
304,
29456,
422,
348,
374,
539,
2290,
2608,
262,
4508,
11656,
7790,
11,
9516,
997,
286,
29456,
284,
510,
13545,
8086,
18272,
8,
369,
1716,
304,
1646,
13664,
933,
286,
2430,
284,
2660,
13485,
2625,
85,
369,
348,
304,
29456,
422,
348,
374,
539,
2290,
2608,
262,
4508,
11656,
7790,
11,
53714,
997,
286,
29456,
284,
510,
13545,
8086,
1175,
8,
369,
259,
304,
1646,
49486,
933,
286,
2430,
284,
2660,
6817,
2625,
85,
369,
348,
304,
29456,
422,
348,
374,
539,
2290,
2608,
286,
369,
1646,
304,
1646,
49486,
512,
310,
1646,
5558,
284,
2430,
198,
310,
2430,
284,
528,
1175,
3518,
41826,
87660,
340,
262,
4508,
11656,
7790,
11,
17351,
997,
286,
2430,
284,
1646,
5558,
198,
286,
1646,
5558,
284,
528,
16138,
41826,
87660,
340,
262,
4508,
11656,
7790,
11,
320,
4651,
1642,
11,
8940,
10162,
286,
2430,
284,
1646,
5558,
198,
262,
4508,
1646,
512,
286,
2430,
284,
1646,
12683,
8086,
198,
262,
775,
512,
286,
2430,
284,
220,
15,
198,
262,
471,
2430,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
59122,
288,
279,
2430,
315,
264,
1646,
323,
7437,
709,
8475,
5413,
198,
262,
369,
53714,
323,
17351,
4595,
382,
14711,
6075,
512,
755,
11262,
8086,
7790,
11,
2007,
41826,
28,
15,
13,
5313,
11,
23204,
41826,
28,
16,
13,
17,
997,
262,
3270,
262,
66075,
279,
2430,
315,
264,
1646,
323,
7437,
709,
8475,
5413,
198,
262,
369,
53714,
323,
17351,
4595,
627,
262,
3270,
262,
422,
11656,
7790,
11,
11035,
997,
286,
29456,
284,
510,
13545,
8086,
18272,
8,
369,
1716,
304,
1646,
13664,
933,
286,
2430,
284,
2660,
6817,
2625,
85,
369,
348,
304,
29456,
422,
348,
374,
539,
2290,
2608,
262,
4508,
11656,
7790,
11,
9516,
997,
286,
29456,
284,
510,
13545,
8086,
18272,
8,
369,
1716,
304,
1646,
13664,
933,
286,
2430,
284,
2660,
13485,
2625,
85,
369,
348,
304,
29456,
422,
348,
374,
539,
2290,
2608,
262,
4508,
11656,
7790,
11,
53714,
997,
286,
29456,
284,
510,
13545,
8086,
1175,
8,
369,
259,
304,
1646,
49486,
933,
286,
2430,
284,
2660,
6817,
2625,
85,
369,
348,
304,
29456,
422,
348,
374,
539,
2290,
2608,
286,
369,
1646,
304,
1646,
49486,
512,
310,
1646,
5558,
284,
2430,
198,
310,
2430,
284,
528,
1175,
3518,
41826,
87660,
340,
262,
4508,
11656,
7790,
11,
17351,
997,
286,
2430,
284,
1646,
5558,
198,
286,
1646,
5558,
284,
528,
16138,
41826,
87660,
340,
262,
4508,
11656,
7790,
11,
320,
4651,
1642,
11,
8940,
10162,
286,
2430,
284,
1646,
5558,
198,
262,
4508,
1646,
512,
286,
2430,
284,
1646,
12683,
8086,
198,
262,
775,
512,
286,
2430,
284,
220,
15,
198,
262,
471,
2430,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
PyCQA/astroid | astroid/node_classes.py | Raise.raises_not_implemented | def raises_not_implemented(self):
"""Check if this node raises a :class:`NotImplementedError`.
:returns: True if this node raises a :class:`NotImplementedError`,
False otherwise.
:rtype: bool
"""
if not self.exc:
return False
for name in self.exc._get_name_nodes():
if name.name == "NotImplementedError":
return True
return False | python | def raises_not_implemented(self):
"""Check if this node raises a :class:`NotImplementedError`.
:returns: True if this node raises a :class:`NotImplementedError`,
False otherwise.
:rtype: bool
"""
if not self.exc:
return False
for name in self.exc._get_name_nodes():
if name.name == "NotImplementedError":
return True
return False | [
"def",
"raises_not_implemented",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"exc",
":",
"return",
"False",
"for",
"name",
"in",
"self",
".",
"exc",
".",
"_get_name_nodes",
"(",
")",
":",
"if",
"name",
".",
"name",
"==",
"\"NotImplementedError\"",
":",
"return",
"True",
"return",
"False"
] | Check if this node raises a :class:`NotImplementedError`.
:returns: True if this node raises a :class:`NotImplementedError`,
False otherwise.
:rtype: bool | [
"Check",
"if",
"this",
"node",
"raises",
"a",
":",
"class",
":",
"NotImplementedError",
"."
] | train | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/node_classes.py#L3780-L3792 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Check if this node raises a :class:`NotImplementedError`.
:returns: True if this node raises a :class:`NotImplementedError`,
False otherwise.
:rtype: bool
### Response:
def raises_not_implemented(self):
"""Check if this node raises a :class:`NotImplementedError`.
:returns: True if this node raises a :class:`NotImplementedError`,
False otherwise.
:rtype: bool
"""
if not self.exc:
return False
for name in self.exc._get_name_nodes():
if name.name == "NotImplementedError":
return True
return False
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4061,
422,
420,
2494,
25930,
264,
551,
1058,
19258,
2688,
18804,
1480,
63438,
286,
551,
4310,
25,
3082,
422,
420,
2494,
25930,
264,
551,
1058,
19258,
2688,
18804,
1480,
13188,
310,
3641,
6062,
627,
286,
551,
33613,
25,
1845,
271,
14711,
6075,
512,
755,
25930,
8072,
18377,
14565,
1214,
997,
286,
4304,
4061,
422,
420,
2494,
25930,
264,
551,
1058,
19258,
2688,
18804,
1480,
63438,
286,
551,
4310,
25,
3082,
422,
420,
2494,
25930,
264,
551,
1058,
19258,
2688,
18804,
1480,
13188,
310,
3641,
6062,
627,
286,
551,
33613,
25,
1845,
198,
286,
3270,
286,
422,
539,
659,
65828,
512,
310,
471,
3641,
198,
286,
369,
836,
304,
659,
65828,
1462,
456,
1292,
15242,
4019,
310,
422,
836,
2710,
624,
330,
2688,
18804,
1480,
4764,
394,
471,
3082,
198,
286,
471,
3641,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4061,
422,
420,
2494,
25930,
264,
551,
1058,
19258,
2688,
18804,
1480,
63438,
286,
551,
4310,
25,
3082,
422,
420,
2494,
25930,
264,
551,
1058,
19258,
2688,
18804,
1480,
13188,
310,
3641,
6062,
627,
286,
551,
33613,
25,
1845,
271,
14711,
6075,
512,
755,
25930,
8072,
18377,
14565,
1214,
997,
286,
4304,
4061,
422,
420,
2494,
25930,
264,
551,
1058,
19258,
2688,
18804,
1480,
63438,
286,
551,
4310,
25,
3082,
422,
420,
2494,
25930,
264,
551,
1058,
19258,
2688,
18804,
1480,
13188,
310,
3641,
6062,
627,
286,
551,
33613,
25,
1845,
198,
286,
3270,
286,
422,
539,
659,
65828,
512,
310,
471,
3641,
198,
286,
369,
836,
304,
659,
65828,
1462,
456,
1292,
15242,
4019,
310,
422,
836,
2710,
624,
330,
2688,
18804,
1480,
4764,
394,
471,
3082,
198,
286,
471,
3641,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
niklasf/python-chess | chess/polyglot.py | MemoryMappedReader.find | def find(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = ()) -> Entry:
"""
Finds the main entry for the given position or Zobrist hash.
The main entry is the (first) entry with the highest weight.
By default, entries with weight ``0`` are excluded. This is a common
way to delete entries from an opening book without compacting it. Pass
*minimum_weight* ``0`` to select all entries.
:raises: :exc:`IndexError` if no entries are found. Use
:func:`~chess.polyglot.MemoryMappedReader.get()` if you prefer to
get ``None`` instead of an exception.
"""
try:
return max(self.find_all(board, minimum_weight=minimum_weight, exclude_moves=exclude_moves), key=lambda entry: entry.weight)
except ValueError:
raise IndexError() | python | def find(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = ()) -> Entry:
"""
Finds the main entry for the given position or Zobrist hash.
The main entry is the (first) entry with the highest weight.
By default, entries with weight ``0`` are excluded. This is a common
way to delete entries from an opening book without compacting it. Pass
*minimum_weight* ``0`` to select all entries.
:raises: :exc:`IndexError` if no entries are found. Use
:func:`~chess.polyglot.MemoryMappedReader.get()` if you prefer to
get ``None`` instead of an exception.
"""
try:
return max(self.find_all(board, minimum_weight=minimum_weight, exclude_moves=exclude_moves), key=lambda entry: entry.weight)
except ValueError:
raise IndexError() | [
"def",
"find",
"(",
"self",
",",
"board",
":",
"Union",
"[",
"chess",
".",
"Board",
",",
"int",
"]",
",",
"*",
",",
"minimum_weight",
":",
"int",
"=",
"1",
",",
"exclude_moves",
":",
"Container",
"[",
"chess",
".",
"Move",
"]",
"=",
"(",
")",
")",
"->",
"Entry",
":",
"try",
":",
"return",
"max",
"(",
"self",
".",
"find_all",
"(",
"board",
",",
"minimum_weight",
"=",
"minimum_weight",
",",
"exclude_moves",
"=",
"exclude_moves",
")",
",",
"key",
"=",
"lambda",
"entry",
":",
"entry",
".",
"weight",
")",
"except",
"ValueError",
":",
"raise",
"IndexError",
"(",
")"
] | Finds the main entry for the given position or Zobrist hash.
The main entry is the (first) entry with the highest weight.
By default, entries with weight ``0`` are excluded. This is a common
way to delete entries from an opening book without compacting it. Pass
*minimum_weight* ``0`` to select all entries.
:raises: :exc:`IndexError` if no entries are found. Use
:func:`~chess.polyglot.MemoryMappedReader.get()` if you prefer to
get ``None`` instead of an exception. | [
"Finds",
"the",
"main",
"entry",
"for",
"the",
"given",
"position",
"or",
"Zobrist",
"hash",
"."
] | train | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/polyglot.py#L421-L438 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Finds the main entry for the given position or Zobrist hash.
The main entry is the (first) entry with the highest weight.
By default, entries with weight ``0`` are excluded. This is a common
way to delete entries from an opening book without compacting it. Pass
*minimum_weight* ``0`` to select all entries.
:raises: :exc:`IndexError` if no entries are found. Use
:func:`~chess.polyglot.MemoryMappedReader.get()` if you prefer to
get ``None`` instead of an exception.
### Response:
def find(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = ()) -> Entry:
"""
Finds the main entry for the given position or Zobrist hash.
The main entry is the (first) entry with the highest weight.
By default, entries with weight ``0`` are excluded. This is a common
way to delete entries from an opening book without compacting it. Pass
*minimum_weight* ``0`` to select all entries.
:raises: :exc:`IndexError` if no entries are found. Use
:func:`~chess.polyglot.MemoryMappedReader.get()` if you prefer to
get ``None`` instead of an exception.
"""
try:
return max(self.find_all(board, minimum_weight=minimum_weight, exclude_moves=exclude_moves), key=lambda entry: entry.weight)
except ValueError:
raise IndexError()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
37,
8843,
279,
1925,
4441,
369,
279,
2728,
2361,
477,
1901,
677,
2889,
5286,
382,
286,
578,
1925,
4441,
374,
279,
320,
3983,
8,
4441,
449,
279,
8592,
4785,
382,
286,
3296,
1670,
11,
10925,
449,
4785,
10103,
15,
14196,
527,
28544,
13,
1115,
374,
264,
4279,
198,
286,
1648,
311,
3783,
10925,
505,
459,
8736,
2363,
2085,
17251,
287,
433,
13,
10175,
198,
286,
353,
39088,
16255,
9,
10103,
15,
14196,
311,
3373,
682,
10925,
382,
286,
551,
33371,
25,
551,
40541,
19258,
1581,
1480,
63,
422,
912,
10925,
527,
1766,
13,
5560,
198,
310,
551,
2900,
78902,
331,
434,
65681,
6200,
354,
72262,
84445,
5172,
673,
55358,
422,
499,
10932,
311,
198,
310,
636,
10103,
4155,
14196,
4619,
315,
459,
4788,
382,
14711,
6075,
512,
755,
1505,
1214,
11,
4580,
25,
9323,
58861,
434,
84384,
11,
528,
1145,
12039,
8187,
16255,
25,
528,
284,
220,
16,
11,
22429,
46490,
25,
9876,
58861,
434,
32295,
60,
284,
45581,
1492,
16165,
512,
286,
3270,
286,
51730,
279,
1925,
4441,
369,
279,
2728,
2361,
477,
1901,
677,
2889,
5286,
382,
286,
578,
1925,
4441,
374,
279,
320,
3983,
8,
4441,
449,
279,
8592,
4785,
382,
286,
3296,
1670,
11,
10925,
449,
4785,
10103,
15,
14196,
527,
28544,
13,
1115,
374,
264,
4279,
198,
286,
1648,
311,
3783,
10925,
505,
459,
8736,
2363,
2085,
17251,
287,
433,
13,
10175,
198,
286,
353,
39088,
16255,
9,
10103,
15,
14196,
311,
3373,
682,
10925,
382,
286,
551,
33371,
25,
551,
40541,
19258,
1581,
1480,
63,
422,
912,
10925,
527,
1766,
13,
5560,
198,
310,
551,
2900,
78902,
331,
434,
65681,
6200,
354,
72262,
84445,
5172,
673,
55358,
422,
499,
10932,
311,
198,
310,
636,
10103,
4155,
14196,
4619,
315,
459,
4788,
627,
286,
3270,
286,
1456,
512,
310,
471,
1973,
1214,
2725,
5823,
21433,
11,
8187,
16255,
28,
39088,
16255,
11,
22429,
46490,
28,
33513,
46490,
705,
1401,
28604,
4441,
25,
4441,
26210,
340,
286,
3734,
15764,
512,
310,
4933,
61303,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
37,
8843,
279,
1925,
4441,
369,
279,
2728,
2361,
477,
1901,
677,
2889,
5286,
382,
286,
578,
1925,
4441,
374,
279,
320,
3983,
8,
4441,
449,
279,
8592,
4785,
382,
286,
3296,
1670,
11,
10925,
449,
4785,
10103,
15,
14196,
527,
28544,
13,
1115,
374,
264,
4279,
198,
286,
1648,
311,
3783,
10925,
505,
459,
8736,
2363,
2085,
17251,
287,
433,
13,
10175,
198,
286,
353,
39088,
16255,
9,
10103,
15,
14196,
311,
3373,
682,
10925,
382,
286,
551,
33371,
25,
551,
40541,
19258,
1581,
1480,
63,
422,
912,
10925,
527,
1766,
13,
5560,
198,
310,
551,
2900,
78902,
331,
434,
65681,
6200,
354,
72262,
84445,
5172,
673,
55358,
422,
499,
10932,
311,
198,
310,
636,
10103,
4155,
14196,
4619,
315,
459,
4788,
382,
14711,
6075,
512,
755,
1505,
1214,
11,
4580,
25,
9323,
58861,
434,
84384,
11,
528,
1145,
12039,
8187,
16255,
25,
528,
284,
220,
16,
11,
22429,
46490,
25,
9876,
58861,
434,
32295,
60,
284,
45581,
1492,
16165,
512,
286,
3270,
286,
51730,
279,
1925,
4441,
369,
279,
2728,
2361,
477,
1901,
677,
2889,
5286,
382,
286,
578,
1925,
4441,
374,
279,
320,
3983,
8,
4441,
449,
279,
8592,
4785,
382,
286,
3296,
1670,
11,
10925,
449,
4785,
10103,
15,
14196,
527,
28544,
13,
1115,
374,
264,
4279,
198,
286,
1648,
311,
3783,
10925,
505,
459,
8736,
2363,
2085,
17251,
287,
433,
13,
10175,
198,
286,
353,
39088,
16255,
9,
10103,
15,
14196,
311,
3373,
682,
10925,
382,
286,
551,
33371,
25,
551,
40541,
19258,
1581,
1480,
63,
422,
912,
10925,
527,
1766,
13,
5560,
198,
310,
551,
2900,
78902,
331,
434,
65681,
6200,
354,
72262,
84445,
5172,
673,
55358,
422,
499,
10932,
311,
198,
310,
636,
10103,
4155,
14196,
4619,
315,
459,
4788,
627,
286,
3270,
286,
1456,
512,
310,
471,
1973,
1214,
2725,
5823,
21433,
11,
8187,
16255,
28,
39088,
16255,
11,
22429,
46490,
28,
33513,
46490,
705,
1401,
28604,
4441,
25,
4441,
26210,
340,
286,
3734,
15764,
512,
310,
4933,
61303,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
rbuffat/pyepw | pyepw/epw.py | DesignCondition.db996 | def db996(self, value=None):
""" Corresponds to IDD Field `db996`
Dry-bulb temperature corresponding to 99.6% annual cumulative
frequency of occurrence (cold conditions)
Args:
value (float): value for IDD Field `db996`
Unit: C
if `value` is None it will not be checked against the
specification and is assumed to be a missing value
Raises:
ValueError: if `value` is not a valid value
"""
if value is not None:
try:
value = float(value)
except ValueError:
raise ValueError('value {} need to be of type float '
'for field `db996`'.format(value))
self._db996 = value | python | def db996(self, value=None):
""" Corresponds to IDD Field `db996`
Dry-bulb temperature corresponding to 99.6% annual cumulative
frequency of occurrence (cold conditions)
Args:
value (float): value for IDD Field `db996`
Unit: C
if `value` is None it will not be checked against the
specification and is assumed to be a missing value
Raises:
ValueError: if `value` is not a valid value
"""
if value is not None:
try:
value = float(value)
except ValueError:
raise ValueError('value {} need to be of type float '
'for field `db996`'.format(value))
self._db996 = value | [
"def",
"db996",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"try",
":",
"value",
"=",
"float",
"(",
"value",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"'value {} need to be of type float '",
"'for field `db996`'",
".",
"format",
"(",
"value",
")",
")",
"self",
".",
"_db996",
"=",
"value"
] | Corresponds to IDD Field `db996`
Dry-bulb temperature corresponding to 99.6% annual cumulative
frequency of occurrence (cold conditions)
Args:
value (float): value for IDD Field `db996`
Unit: C
if `value` is None it will not be checked against the
specification and is assumed to be a missing value
Raises:
ValueError: if `value` is not a valid value | [
"Corresponds",
"to",
"IDD",
"Field",
"db996",
"Dry",
"-",
"bulb",
"temperature",
"corresponding",
"to",
"99",
".",
"6%",
"annual",
"cumulative",
"frequency",
"of",
"occurrence",
"(",
"cold",
"conditions",
")"
] | train | https://github.com/rbuffat/pyepw/blob/373d4d3c8386c8d35789f086ac5f6018c2711745/pyepw/epw.py#L1074-L1095 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Corresponds to IDD Field `db996`
Dry-bulb temperature corresponding to 99.6% annual cumulative
frequency of occurrence (cold conditions)
Args:
value (float): value for IDD Field `db996`
Unit: C
if `value` is None it will not be checked against the
specification and is assumed to be a missing value
Raises:
ValueError: if `value` is not a valid value
### Response:
def db996(self, value=None):
""" Corresponds to IDD Field `db996`
Dry-bulb temperature corresponding to 99.6% annual cumulative
frequency of occurrence (cold conditions)
Args:
value (float): value for IDD Field `db996`
Unit: C
if `value` is None it will not be checked against the
specification and is assumed to be a missing value
Raises:
ValueError: if `value` is not a valid value
"""
if value is not None:
try:
value = float(value)
except ValueError:
raise ValueError('value {} need to be of type float '
'for field `db996`'.format(value))
self._db996 = value
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
10803,
6961,
82,
311,
81983,
8771,
1595,
2042,
23031,
4077,
286,
31941,
1481,
360,
65,
9499,
12435,
311,
220,
1484,
13,
21,
4,
9974,
40944,
198,
286,
11900,
315,
32659,
320,
88172,
4787,
696,
286,
18161,
512,
310,
907,
320,
3733,
1680,
907,
369,
81983,
8771,
1595,
2042,
23031,
4077,
394,
8113,
25,
356,
198,
394,
422,
1595,
970,
63,
374,
2290,
433,
690,
539,
387,
10273,
2403,
279,
198,
394,
26185,
323,
374,
19655,
311,
387,
264,
7554,
907,
271,
286,
61411,
512,
310,
15764,
25,
422,
1595,
970,
63,
374,
539,
264,
2764,
907,
271,
14711,
6075,
512,
755,
3000,
23031,
1214,
11,
907,
5980,
997,
286,
4304,
220,
52042,
82,
311,
81983,
8771,
1595,
2042,
23031,
4077,
286,
31941,
1481,
360,
65,
9499,
12435,
311,
220,
1484,
13,
21,
4,
9974,
40944,
198,
286,
11900,
315,
32659,
320,
88172,
4787,
696,
286,
18161,
512,
310,
907,
320,
3733,
1680,
907,
369,
81983,
8771,
1595,
2042,
23031,
4077,
394,
8113,
25,
356,
198,
394,
422,
1595,
970,
63,
374,
2290,
433,
690,
539,
387,
10273,
2403,
279,
198,
394,
26185,
323,
374,
19655,
311,
387,
264,
7554,
907,
271,
286,
61411,
512,
310,
15764,
25,
422,
1595,
970,
63,
374,
539,
264,
2764,
907,
198,
286,
3270,
286,
422,
907,
374,
539,
2290,
512,
310,
1456,
512,
394,
907,
284,
2273,
3764,
340,
310,
3734,
15764,
512,
394,
4933,
15764,
493,
970,
4792,
1205,
311,
387,
315,
955,
2273,
8044,
792,
364,
2000,
2115,
1595,
2042,
23031,
63,
4527,
2293,
3764,
4489,
286,
659,
1462,
2042,
23031,
284,
907,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
10803,
6961,
82,
311,
81983,
8771,
1595,
2042,
23031,
4077,
286,
31941,
1481,
360,
65,
9499,
12435,
311,
220,
1484,
13,
21,
4,
9974,
40944,
198,
286,
11900,
315,
32659,
320,
88172,
4787,
696,
286,
18161,
512,
310,
907,
320,
3733,
1680,
907,
369,
81983,
8771,
1595,
2042,
23031,
4077,
394,
8113,
25,
356,
198,
394,
422,
1595,
970,
63,
374,
2290,
433,
690,
539,
387,
10273,
2403,
279,
198,
394,
26185,
323,
374,
19655,
311,
387,
264,
7554,
907,
271,
286,
61411,
512,
310,
15764,
25,
422,
1595,
970,
63,
374,
539,
264,
2764,
907,
271,
14711,
6075,
512,
755,
3000,
23031,
1214,
11,
907,
5980,
997,
286,
4304,
220,
52042,
82,
311,
81983,
8771,
1595,
2042,
23031,
4077,
286,
31941,
1481,
360,
65,
9499,
12435,
311,
220,
1484,
13,
21,
4,
9974,
40944,
198,
286,
11900,
315,
32659,
320,
88172,
4787,
696,
286,
18161,
512,
310,
907,
320,
3733,
1680,
907,
369,
81983,
8771,
1595,
2042,
23031,
4077,
394,
8113,
25,
356,
198,
394,
422,
1595,
970,
63,
374,
2290,
433,
690,
539,
387,
10273,
2403,
279,
198,
394,
26185,
323,
374,
19655,
311,
387,
264,
7554,
907,
271,
286,
61411,
512,
310,
15764,
25,
422,
1595,
970,
63,
374,
539,
264,
2764,
907,
198,
286,
3270,
286,
422,
907,
374,
539,
2290,
512,
310,
1456,
512,
394,
907,
284,
2273,
3764,
340,
310,
3734,
15764,
512,
394,
4933,
15764,
493,
970,
4792,
1205,
311,
387,
315,
955,
2273,
8044,
792,
364,
2000,
2115,
1595,
2042,
23031,
63,
4527,
2293,
3764,
4489,
286,
659,
1462,
2042,
23031,
284,
907,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
johntruckenbrodt/spatialist | spatialist/vector.py | Vector.write | def write(self, outfile, format='ESRI Shapefile', overwrite=True):
"""
write the Vector object to a file
Parameters
----------
outfile:
the name of the file to write
format: str
the output file format
overwrite: bool
overwrite an already existing file?
Returns
-------
"""
(outfilepath, outfilename) = os.path.split(outfile)
basename = os.path.splitext(outfilename)[0]
driver = ogr.GetDriverByName(format)
if os.path.exists(outfile):
if overwrite:
driver.DeleteDataSource(outfile)
else:
raise RuntimeError('target file already exists')
outdataset = driver.CreateDataSource(outfile)
outlayer = outdataset.CreateLayer(self.layername, geom_type=self.geomType)
outlayerdef = outlayer.GetLayerDefn()
for fieldDef in self.fieldDefs:
outlayer.CreateField(fieldDef)
self.layer.ResetReading()
for feature in self.layer:
outFeature = ogr.Feature(outlayerdef)
outFeature.SetGeometry(feature.GetGeometryRef())
for name in self.fieldnames:
outFeature.SetField(name, feature.GetField(name))
# add the feature to the shapefile
outlayer.CreateFeature(outFeature)
outFeature = None
self.layer.ResetReading()
if format == 'ESRI Shapefile':
srs_out = self.srs.Clone()
srs_out.MorphToESRI()
with open(os.path.join(outfilepath, basename + '.prj'), 'w') as prj:
prj.write(srs_out.ExportToWkt())
outdataset = None | python | def write(self, outfile, format='ESRI Shapefile', overwrite=True):
"""
write the Vector object to a file
Parameters
----------
outfile:
the name of the file to write
format: str
the output file format
overwrite: bool
overwrite an already existing file?
Returns
-------
"""
(outfilepath, outfilename) = os.path.split(outfile)
basename = os.path.splitext(outfilename)[0]
driver = ogr.GetDriverByName(format)
if os.path.exists(outfile):
if overwrite:
driver.DeleteDataSource(outfile)
else:
raise RuntimeError('target file already exists')
outdataset = driver.CreateDataSource(outfile)
outlayer = outdataset.CreateLayer(self.layername, geom_type=self.geomType)
outlayerdef = outlayer.GetLayerDefn()
for fieldDef in self.fieldDefs:
outlayer.CreateField(fieldDef)
self.layer.ResetReading()
for feature in self.layer:
outFeature = ogr.Feature(outlayerdef)
outFeature.SetGeometry(feature.GetGeometryRef())
for name in self.fieldnames:
outFeature.SetField(name, feature.GetField(name))
# add the feature to the shapefile
outlayer.CreateFeature(outFeature)
outFeature = None
self.layer.ResetReading()
if format == 'ESRI Shapefile':
srs_out = self.srs.Clone()
srs_out.MorphToESRI()
with open(os.path.join(outfilepath, basename + '.prj'), 'w') as prj:
prj.write(srs_out.ExportToWkt())
outdataset = None | [
"def",
"write",
"(",
"self",
",",
"outfile",
",",
"format",
"=",
"'ESRI Shapefile'",
",",
"overwrite",
"=",
"True",
")",
":",
"(",
"outfilepath",
",",
"outfilename",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"outfile",
")",
"basename",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"outfilename",
")",
"[",
"0",
"]",
"driver",
"=",
"ogr",
".",
"GetDriverByName",
"(",
"format",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"outfile",
")",
":",
"if",
"overwrite",
":",
"driver",
".",
"DeleteDataSource",
"(",
"outfile",
")",
"else",
":",
"raise",
"RuntimeError",
"(",
"'target file already exists'",
")",
"outdataset",
"=",
"driver",
".",
"CreateDataSource",
"(",
"outfile",
")",
"outlayer",
"=",
"outdataset",
".",
"CreateLayer",
"(",
"self",
".",
"layername",
",",
"geom_type",
"=",
"self",
".",
"geomType",
")",
"outlayerdef",
"=",
"outlayer",
".",
"GetLayerDefn",
"(",
")",
"for",
"fieldDef",
"in",
"self",
".",
"fieldDefs",
":",
"outlayer",
".",
"CreateField",
"(",
"fieldDef",
")",
"self",
".",
"layer",
".",
"ResetReading",
"(",
")",
"for",
"feature",
"in",
"self",
".",
"layer",
":",
"outFeature",
"=",
"ogr",
".",
"Feature",
"(",
"outlayerdef",
")",
"outFeature",
".",
"SetGeometry",
"(",
"feature",
".",
"GetGeometryRef",
"(",
")",
")",
"for",
"name",
"in",
"self",
".",
"fieldnames",
":",
"outFeature",
".",
"SetField",
"(",
"name",
",",
"feature",
".",
"GetField",
"(",
"name",
")",
")",
"# add the feature to the shapefile",
"outlayer",
".",
"CreateFeature",
"(",
"outFeature",
")",
"outFeature",
"=",
"None",
"self",
".",
"layer",
".",
"ResetReading",
"(",
")",
"if",
"format",
"==",
"'ESRI Shapefile'",
":",
"srs_out",
"=",
"self",
".",
"srs",
".",
"Clone",
"(",
")",
"srs_out",
".",
"MorphToESRI",
"(",
")",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"outfilepath",
",",
"basename",
"+",
"'.prj'",
")",
",",
"'w'",
")",
"as",
"prj",
":",
"prj",
".",
"write",
"(",
"srs_out",
".",
"ExportToWkt",
"(",
")",
")",
"outdataset",
"=",
"None"
] | write the Vector object to a file
Parameters
----------
outfile:
the name of the file to write
format: str
the output file format
overwrite: bool
overwrite an already existing file?
Returns
------- | [
"write",
"the",
"Vector",
"object",
"to",
"a",
"file"
] | train | https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/vector.py#L614-L666 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
write the Vector object to a file
Parameters
----------
outfile:
the name of the file to write
format: str
the output file format
overwrite: bool
overwrite an already existing file?
Returns
-------
### Response:
def write(self, outfile, format='ESRI Shapefile', overwrite=True):
"""
write the Vector object to a file
Parameters
----------
outfile:
the name of the file to write
format: str
the output file format
overwrite: bool
overwrite an already existing file?
Returns
-------
"""
(outfilepath, outfilename) = os.path.split(outfile)
basename = os.path.splitext(outfilename)[0]
driver = ogr.GetDriverByName(format)
if os.path.exists(outfile):
if overwrite:
driver.DeleteDataSource(outfile)
else:
raise RuntimeError('target file already exists')
outdataset = driver.CreateDataSource(outfile)
outlayer = outdataset.CreateLayer(self.layername, geom_type=self.geomType)
outlayerdef = outlayer.GetLayerDefn()
for fieldDef in self.fieldDefs:
outlayer.CreateField(fieldDef)
self.layer.ResetReading()
for feature in self.layer:
outFeature = ogr.Feature(outlayerdef)
outFeature.SetGeometry(feature.GetGeometryRef())
for name in self.fieldnames:
outFeature.SetField(name, feature.GetField(name))
# add the feature to the shapefile
outlayer.CreateFeature(outFeature)
outFeature = None
self.layer.ResetReading()
if format == 'ESRI Shapefile':
srs_out = self.srs.Clone()
srs_out.MorphToESRI()
with open(os.path.join(outfilepath, basename + '.prj'), 'w') as prj:
prj.write(srs_out.ExportToWkt())
outdataset = None
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5040,
279,
4290,
1665,
311,
264,
1052,
271,
286,
13831,
198,
286,
31423,
286,
34278,
512,
310,
279,
836,
315,
279,
1052,
311,
3350,
198,
286,
3645,
25,
610,
198,
310,
279,
2612,
1052,
3645,
198,
286,
33316,
25,
1845,
198,
310,
33316,
459,
2736,
6484,
1052,
1980,
286,
5295,
198,
286,
11556,
45464,
14711,
6075,
512,
755,
3350,
1214,
11,
34278,
11,
3645,
1151,
1600,
4403,
23342,
1213,
518,
33316,
3702,
997,
286,
3270,
286,
3350,
279,
4290,
1665,
311,
264,
1052,
271,
286,
13831,
198,
286,
31423,
286,
34278,
512,
310,
279,
836,
315,
279,
1052,
311,
3350,
198,
286,
3645,
25,
610,
198,
310,
279,
2612,
1052,
3645,
198,
286,
33316,
25,
1845,
198,
310,
33316,
459,
2736,
6484,
1052,
1980,
286,
5295,
198,
286,
11556,
45464,
286,
3270,
286,
320,
412,
45257,
11,
704,
8570,
8,
284,
2709,
3960,
5402,
71442,
340,
286,
39296,
284,
2709,
3960,
67406,
10029,
8570,
6758,
15,
933,
1827,
286,
5696,
284,
96361,
2283,
11603,
17325,
21355,
340,
1827,
286,
422,
2709,
3960,
12347,
71442,
997,
310,
422,
33316,
512,
394,
5696,
19404,
17616,
71442,
340,
310,
775,
512,
394,
4933,
45643,
493,
5775,
1052,
2736,
6866,
1329,
1827,
286,
704,
22090,
284,
5696,
7399,
17616,
71442,
340,
286,
704,
10546,
284,
704,
22090,
7399,
9368,
1214,
15048,
609,
11,
28355,
1857,
7822,
56305,
941,
340,
286,
704,
10546,
755,
284,
704,
10546,
2283,
9368,
2685,
77,
746,
1827,
286,
369,
2115,
2685,
304,
659,
16859,
57131,
512,
310,
704,
10546,
7399,
1915,
15944,
2685,
340,
1827,
286,
659,
15048,
37760,
32999,
746,
286,
369,
4668,
304,
659,
15048,
512,
310,
704,
14180,
284,
96361,
59534,
10029,
10546,
755,
340,
310,
704,
14180,
4296,
21450,
28161,
2283,
21450,
4032,
2455,
310,
369,
836,
304,
659,
16859,
11654,
512,
394,
704,
14180,
4296,
1915,
3232,
11,
4668,
2283,
1915,
3232,
1192,
310,
674,
923,
279,
4668,
311,
279,
6211,
1213,
198,
310,
704,
10546,
7399,
14180,
10029,
14180,
340,
310,
704,
14180,
284,
2290,
198,
286,
659,
15048,
37760,
32999,
746,
1827,
286,
422,
3645,
624,
364,
1600,
4403,
23342,
1213,
3730,
310,
274,
5544,
6196,
284,
659,
516,
5544,
65563,
746,
310,
274,
5544,
6196,
1345,
16751,
1271,
1600,
4403,
746,
310,
449,
1825,
9835,
3960,
5563,
10029,
45257,
11,
39296,
489,
6389,
652,
73,
4670,
364,
86,
873,
439,
550,
73,
512,
394,
550,
73,
3921,
1161,
5544,
6196,
82177,
1271,
54,
5964,
2455,
1827,
286,
704,
22090,
284,
2290,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5040,
279,
4290,
1665,
311,
264,
1052,
271,
286,
13831,
198,
286,
31423,
286,
34278,
512,
310,
279,
836,
315,
279,
1052,
311,
3350,
198,
286,
3645,
25,
610,
198,
310,
279,
2612,
1052,
3645,
198,
286,
33316,
25,
1845,
198,
310,
33316,
459,
2736,
6484,
1052,
1980,
286,
5295,
198,
286,
11556,
45464,
14711,
6075,
512,
755,
3350,
1214,
11,
34278,
11,
3645,
1151,
1600,
4403,
23342,
1213,
518,
33316,
3702,
997,
286,
3270,
286,
3350,
279,
4290,
1665,
311,
264,
1052,
271,
286,
13831,
198,
286,
31423,
286,
34278,
512,
310,
279,
836,
315,
279,
1052,
311,
3350,
198,
286,
3645,
25,
610,
198,
310,
279,
2612,
1052,
3645,
198,
286,
33316,
25,
1845,
198,
310,
33316,
459,
2736,
6484,
1052,
1980,
286,
5295,
198,
286,
11556,
45464,
286,
3270,
286,
320,
412,
45257,
11,
704,
8570,
8,
284,
2709,
3960,
5402,
71442,
340,
286,
39296,
284,
2709,
3960,
67406,
10029,
8570,
6758,
15,
933,
1827,
286,
5696,
284,
96361,
2283,
11603,
17325,
21355,
340,
1827,
286,
422,
2709,
3960,
12347,
71442,
997,
310,
422,
33316,
512,
394,
5696,
19404,
17616,
71442,
340,
310,
775,
512,
394,
4933,
45643,
493,
5775,
1052,
2736,
6866,
1329,
1827,
286,
704,
22090,
284,
5696,
7399,
17616,
71442,
340,
286,
704,
10546,
284,
704,
22090,
7399,
9368,
1214,
15048,
609,
11,
28355,
1857,
7822,
56305,
941,
340,
286,
704,
10546,
755,
284,
704,
10546,
2283,
9368,
2685,
77,
746,
1827,
286,
369,
2115,
2685,
304,
659,
16859,
57131,
512,
310,
704,
10546,
7399,
1915,
15944,
2685,
340,
1827,
286,
659,
15048,
37760,
32999,
746,
286,
369,
4668,
304,
659,
15048,
512,
310,
704,
14180,
284,
96361,
59534,
10029,
10546,
755,
340,
310,
704,
14180,
4296,
21450,
28161,
2283,
21450,
4032,
2455,
310,
369,
836,
304,
659,
16859,
11654,
512,
394,
704,
14180,
4296,
1915,
3232,
11,
4668,
2283,
1915,
3232,
1192,
310,
674,
923,
279,
4668,
311,
279,
6211,
1213,
198,
310,
704,
10546,
7399,
14180,
10029,
14180,
340,
310,
704,
14180,
284,
2290,
198,
286,
659,
15048,
37760,
32999,
746,
1827,
286,
422,
3645,
624,
364,
1600,
4403,
23342,
1213,
3730,
310,
274,
5544,
6196,
284,
659,
516,
5544,
65563,
746,
310,
274,
5544,
6196,
1345,
16751,
1271,
1600,
4403,
746,
310,
449,
1825,
9835,
3960,
5563,
10029,
45257,
11,
39296,
489,
6389,
652,
73,
4670,
364,
86,
873,
439,
550,
73,
512,
394,
550,
73,
3921,
1161,
5544,
6196,
82177,
1271,
54,
5964,
2455,
1827,
286,
704,
22090,
284,
2290,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pytroll/trollimage | trollimage/image.py | Image._add_channel | def _add_channel(self, chn, color_min, color_max):
"""Adds a channel to the image object
"""
if isinstance(chn, np.ma.core.MaskedArray):
chn_data = chn.data
chn_mask = chn.mask
else:
chn_data = np.array(chn)
chn_mask = False
scaled = ((chn_data - color_min) *
1.0 / (color_max - color_min))
self.channels.append(np.ma.array(scaled, mask=chn_mask)) | python | def _add_channel(self, chn, color_min, color_max):
"""Adds a channel to the image object
"""
if isinstance(chn, np.ma.core.MaskedArray):
chn_data = chn.data
chn_mask = chn.mask
else:
chn_data = np.array(chn)
chn_mask = False
scaled = ((chn_data - color_min) *
1.0 / (color_max - color_min))
self.channels.append(np.ma.array(scaled, mask=chn_mask)) | [
"def",
"_add_channel",
"(",
"self",
",",
"chn",
",",
"color_min",
",",
"color_max",
")",
":",
"if",
"isinstance",
"(",
"chn",
",",
"np",
".",
"ma",
".",
"core",
".",
"MaskedArray",
")",
":",
"chn_data",
"=",
"chn",
".",
"data",
"chn_mask",
"=",
"chn",
".",
"mask",
"else",
":",
"chn_data",
"=",
"np",
".",
"array",
"(",
"chn",
")",
"chn_mask",
"=",
"False",
"scaled",
"=",
"(",
"(",
"chn_data",
"-",
"color_min",
")",
"*",
"1.0",
"/",
"(",
"color_max",
"-",
"color_min",
")",
")",
"self",
".",
"channels",
".",
"append",
"(",
"np",
".",
"ma",
".",
"array",
"(",
"scaled",
",",
"mask",
"=",
"chn_mask",
")",
")"
] | Adds a channel to the image object | [
"Adds",
"a",
"channel",
"to",
"the",
"image",
"object"
] | train | https://github.com/pytroll/trollimage/blob/d35a7665ad475ff230e457085523e21f2cd3f454/trollimage/image.py#L221-L232 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Adds a channel to the image object
### Response:
def _add_channel(self, chn, color_min, color_max):
"""Adds a channel to the image object
"""
if isinstance(chn, np.ma.core.MaskedArray):
chn_data = chn.data
chn_mask = chn.mask
else:
chn_data = np.array(chn)
chn_mask = False
scaled = ((chn_data - color_min) *
1.0 / (color_max - color_min))
self.channels.append(np.ma.array(scaled, mask=chn_mask))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
73211,
264,
5613,
311,
279,
2217,
1665,
271,
14711,
6075,
512,
755,
721,
723,
14913,
1214,
11,
523,
77,
11,
1933,
7408,
11,
1933,
6479,
997,
286,
4304,
73211,
264,
5613,
311,
279,
2217,
1665,
198,
286,
3270,
286,
422,
11656,
7,
2174,
11,
2660,
63902,
4976,
58856,
291,
1895,
997,
310,
523,
77,
1807,
284,
523,
77,
2245,
198,
310,
523,
77,
10204,
284,
523,
77,
36279,
198,
286,
775,
512,
310,
523,
77,
1807,
284,
2660,
7382,
7,
2174,
340,
310,
523,
77,
10204,
284,
3641,
198,
286,
31790,
284,
1819,
2174,
1807,
482,
1933,
7408,
8,
1235,
1733,
220,
16,
13,
15,
611,
320,
3506,
6479,
482,
1933,
7408,
1192,
286,
659,
40995,
2102,
10101,
63902,
7382,
1161,
26294,
11,
7056,
28,
2174,
10204,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
73211,
264,
5613,
311,
279,
2217,
1665,
271,
14711,
6075,
512,
755,
721,
723,
14913,
1214,
11,
523,
77,
11,
1933,
7408,
11,
1933,
6479,
997,
286,
4304,
73211,
264,
5613,
311,
279,
2217,
1665,
198,
286,
3270,
286,
422,
11656,
7,
2174,
11,
2660,
63902,
4976,
58856,
291,
1895,
997,
310,
523,
77,
1807,
284,
523,
77,
2245,
198,
310,
523,
77,
10204,
284,
523,
77,
36279,
198,
286,
775,
512,
310,
523,
77,
1807,
284,
2660,
7382,
7,
2174,
340,
310,
523,
77,
10204,
284,
3641,
198,
286,
31790,
284,
1819,
2174,
1807,
482,
1933,
7408,
8,
1235,
1733,
220,
16,
13,
15,
611,
320,
3506,
6479,
482,
1933,
7408,
1192,
286,
659,
40995,
2102,
10101,
63902,
7382,
1161,
26294,
11,
7056,
28,
2174,
10204,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
jtwhite79/pyemu | pyemu/utils/geostats.py | Vario2d.to_struct_file | def to_struct_file(self, f):
""" write the Vario2d to a PEST-style structure file
Parameters
----------
f : (str or file handle)
item to write to
"""
if isinstance(f, str):
f = open(f,'w')
f.write("VARIOGRAM {0}\n".format(self.name))
f.write(" VARTYPE {0}\n".format(self.vartype))
f.write(" A {0}\n".format(self.a))
f.write(" ANISOTROPY {0}\n".format(self.anisotropy))
f.write(" BEARING {0}\n".format(self.bearing))
f.write("END VARIOGRAM\n\n") | python | def to_struct_file(self, f):
""" write the Vario2d to a PEST-style structure file
Parameters
----------
f : (str or file handle)
item to write to
"""
if isinstance(f, str):
f = open(f,'w')
f.write("VARIOGRAM {0}\n".format(self.name))
f.write(" VARTYPE {0}\n".format(self.vartype))
f.write(" A {0}\n".format(self.a))
f.write(" ANISOTROPY {0}\n".format(self.anisotropy))
f.write(" BEARING {0}\n".format(self.bearing))
f.write("END VARIOGRAM\n\n") | [
"def",
"to_struct_file",
"(",
"self",
",",
"f",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"str",
")",
":",
"f",
"=",
"open",
"(",
"f",
",",
"'w'",
")",
"f",
".",
"write",
"(",
"\"VARIOGRAM {0}\\n\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"f",
".",
"write",
"(",
"\" VARTYPE {0}\\n\"",
".",
"format",
"(",
"self",
".",
"vartype",
")",
")",
"f",
".",
"write",
"(",
"\" A {0}\\n\"",
".",
"format",
"(",
"self",
".",
"a",
")",
")",
"f",
".",
"write",
"(",
"\" ANISOTROPY {0}\\n\"",
".",
"format",
"(",
"self",
".",
"anisotropy",
")",
")",
"f",
".",
"write",
"(",
"\" BEARING {0}\\n\"",
".",
"format",
"(",
"self",
".",
"bearing",
")",
")",
"f",
".",
"write",
"(",
"\"END VARIOGRAM\\n\\n\"",
")"
] | write the Vario2d to a PEST-style structure file
Parameters
----------
f : (str or file handle)
item to write to | [
"write",
"the",
"Vario2d",
"to",
"a",
"PEST",
"-",
"style",
"structure",
"file"
] | train | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/utils/geostats.py#L1045-L1061 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
write the Vario2d to a PEST-style structure file
Parameters
----------
f : (str or file handle)
item to write to
### Response:
def to_struct_file(self, f):
""" write the Vario2d to a PEST-style structure file
Parameters
----------
f : (str or file handle)
item to write to
"""
if isinstance(f, str):
f = open(f,'w')
f.write("VARIOGRAM {0}\n".format(self.name))
f.write(" VARTYPE {0}\n".format(self.vartype))
f.write(" A {0}\n".format(self.a))
f.write(" ANISOTROPY {0}\n".format(self.anisotropy))
f.write(" BEARING {0}\n".format(self.bearing))
f.write("END VARIOGRAM\n\n")
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5040,
279,
650,
3370,
17,
67,
311,
264,
393,
5288,
11549,
6070,
1052,
271,
286,
13831,
198,
286,
31423,
286,
282,
551,
320,
496,
477,
1052,
3790,
340,
310,
1537,
311,
3350,
311,
271,
14711,
6075,
512,
755,
311,
15477,
2517,
1214,
11,
282,
997,
286,
4304,
3350,
279,
650,
3370,
17,
67,
311,
264,
393,
5288,
11549,
6070,
1052,
271,
286,
13831,
198,
286,
31423,
286,
282,
551,
320,
496,
477,
1052,
3790,
340,
310,
1537,
311,
3350,
311,
271,
286,
3270,
286,
422,
11656,
968,
11,
610,
997,
310,
282,
284,
1825,
968,
2965,
86,
1329,
286,
282,
3921,
446,
34140,
3895,
23826,
314,
15,
11281,
77,
3343,
2293,
1214,
2710,
1192,
286,
282,
3921,
446,
220,
650,
3065,
2699,
314,
15,
11281,
77,
3343,
2293,
1214,
3211,
472,
500,
1192,
286,
282,
3921,
446,
220,
362,
314,
15,
11281,
77,
3343,
2293,
1214,
5973,
1192,
286,
282,
3921,
446,
220,
2147,
1669,
1831,
19828,
56,
314,
15,
11281,
77,
3343,
2293,
1214,
10985,
285,
354,
18237,
1192,
286,
282,
3921,
446,
220,
7354,
92123,
314,
15,
11281,
77,
3343,
2293,
1214,
960,
13992,
1192,
286,
282,
3921,
446,
4794,
650,
36909,
23826,
1734,
1734,
1158,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5040,
279,
650,
3370,
17,
67,
311,
264,
393,
5288,
11549,
6070,
1052,
271,
286,
13831,
198,
286,
31423,
286,
282,
551,
320,
496,
477,
1052,
3790,
340,
310,
1537,
311,
3350,
311,
271,
14711,
6075,
512,
755,
311,
15477,
2517,
1214,
11,
282,
997,
286,
4304,
3350,
279,
650,
3370,
17,
67,
311,
264,
393,
5288,
11549,
6070,
1052,
271,
286,
13831,
198,
286,
31423,
286,
282,
551,
320,
496,
477,
1052,
3790,
340,
310,
1537,
311,
3350,
311,
271,
286,
3270,
286,
422,
11656,
968,
11,
610,
997,
310,
282,
284,
1825,
968,
2965,
86,
1329,
286,
282,
3921,
446,
34140,
3895,
23826,
314,
15,
11281,
77,
3343,
2293,
1214,
2710,
1192,
286,
282,
3921,
446,
220,
650,
3065,
2699,
314,
15,
11281,
77,
3343,
2293,
1214,
3211,
472,
500,
1192,
286,
282,
3921,
446,
220,
362,
314,
15,
11281,
77,
3343,
2293,
1214,
5973,
1192,
286,
282,
3921,
446,
220,
2147,
1669,
1831,
19828,
56,
314,
15,
11281,
77,
3343,
2293,
1214,
10985,
285,
354,
18237,
1192,
286,
282,
3921,
446,
220,
7354,
92123,
314,
15,
11281,
77,
3343,
2293,
1214,
960,
13992,
1192,
286,
282,
3921,
446,
4794,
650,
36909,
23826,
1734,
1734,
1158,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
mdickinson/bigfloat | bigfloat/core.py | BigFloat._format_to_floating_precision | def _format_to_floating_precision(self, precision):
""" Format a nonzero finite BigFloat instance to a given number of
significant digits.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string giving the digits of the output
- exp represents the exponent of the output,
The normalization of the exponent is such that <digits>E<exp>
represents the decimal approximation to self.
Rounding is always round-to-nearest.
"""
if precision <= 0:
raise ValueError("precision argument should be at least 1")
sign, digits, exp = _mpfr_get_str2(
10,
precision,
self,
ROUND_TIES_TO_EVEN,
)
return sign, digits, exp - len(digits) | python | def _format_to_floating_precision(self, precision):
""" Format a nonzero finite BigFloat instance to a given number of
significant digits.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string giving the digits of the output
- exp represents the exponent of the output,
The normalization of the exponent is such that <digits>E<exp>
represents the decimal approximation to self.
Rounding is always round-to-nearest.
"""
if precision <= 0:
raise ValueError("precision argument should be at least 1")
sign, digits, exp = _mpfr_get_str2(
10,
precision,
self,
ROUND_TIES_TO_EVEN,
)
return sign, digits, exp - len(digits) | [
"def",
"_format_to_floating_precision",
"(",
"self",
",",
"precision",
")",
":",
"if",
"precision",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"precision argument should be at least 1\"",
")",
"sign",
",",
"digits",
",",
"exp",
"=",
"_mpfr_get_str2",
"(",
"10",
",",
"precision",
",",
"self",
",",
"ROUND_TIES_TO_EVEN",
",",
")",
"return",
"sign",
",",
"digits",
",",
"exp",
"-",
"len",
"(",
"digits",
")"
] | Format a nonzero finite BigFloat instance to a given number of
significant digits.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string giving the digits of the output
- exp represents the exponent of the output,
The normalization of the exponent is such that <digits>E<exp>
represents the decimal approximation to self.
Rounding is always round-to-nearest. | [
"Format",
"a",
"nonzero",
"finite",
"BigFloat",
"instance",
"to",
"a",
"given",
"number",
"of",
"significant",
"digits",
"."
] | train | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L616-L641 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Format a nonzero finite BigFloat instance to a given number of
significant digits.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string giving the digits of the output
- exp represents the exponent of the output,
The normalization of the exponent is such that <digits>E<exp>
represents the decimal approximation to self.
Rounding is always round-to-nearest.
### Response:
def _format_to_floating_precision(self, precision):
""" Format a nonzero finite BigFloat instance to a given number of
significant digits.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string giving the digits of the output
- exp represents the exponent of the output,
The normalization of the exponent is such that <digits>E<exp>
represents the decimal approximation to self.
Rounding is always round-to-nearest.
"""
if precision <= 0:
raise ValueError("precision argument should be at least 1")
sign, digits, exp = _mpfr_get_str2(
10,
precision,
self,
ROUND_TIES_TO_EVEN,
)
return sign, digits, exp - len(digits)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4152,
264,
73332,
35326,
6295,
5559,
2937,
311,
264,
2728,
1396,
315,
198,
286,
5199,
19016,
382,
286,
5295,
264,
24657,
320,
43324,
11,
19016,
11,
1367,
8,
1405,
1473,
692,
482,
8389,
374,
264,
2777,
11,
3082,
369,
264,
8389,
1396,
11,
775,
3641,
198,
692,
482,
19016,
374,
264,
925,
7231,
279,
19016,
315,
279,
2612,
198,
692,
482,
1367,
11105,
279,
28790,
315,
279,
2612,
3638,
286,
578,
49823,
315,
279,
28790,
374,
1778,
430,
366,
61870,
60484,
27,
4683,
397,
286,
11105,
279,
12395,
57304,
311,
659,
382,
286,
432,
13900,
374,
2744,
4883,
4791,
41078,
15795,
382,
14711,
6075,
512,
755,
721,
2293,
2401,
766,
29593,
55718,
1214,
11,
16437,
997,
286,
4304,
15392,
264,
73332,
35326,
6295,
5559,
2937,
311,
264,
2728,
1396,
315,
198,
286,
5199,
19016,
382,
286,
5295,
264,
24657,
320,
43324,
11,
19016,
11,
1367,
8,
1405,
1473,
692,
482,
8389,
374,
264,
2777,
11,
3082,
369,
264,
8389,
1396,
11,
775,
3641,
198,
692,
482,
19016,
374,
264,
925,
7231,
279,
19016,
315,
279,
2612,
198,
692,
482,
1367,
11105,
279,
28790,
315,
279,
2612,
3638,
286,
578,
49823,
315,
279,
28790,
374,
1778,
430,
366,
61870,
60484,
27,
4683,
397,
286,
11105,
279,
12395,
57304,
311,
659,
382,
286,
432,
13900,
374,
2744,
4883,
4791,
41078,
15795,
627,
286,
3270,
286,
422,
16437,
2717,
220,
15,
512,
310,
4933,
15764,
446,
28281,
5811,
1288,
387,
520,
3325,
220,
16,
5240,
286,
1879,
11,
19016,
11,
1367,
284,
721,
1331,
1658,
3138,
2966,
17,
1021,
310,
220,
605,
345,
310,
16437,
345,
310,
659,
345,
310,
77238,
1159,
5482,
8820,
2135,
42122,
345,
286,
5235,
286,
471,
1879,
11,
19016,
11,
1367,
482,
2479,
99466,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4152,
264,
73332,
35326,
6295,
5559,
2937,
311,
264,
2728,
1396,
315,
198,
286,
5199,
19016,
382,
286,
5295,
264,
24657,
320,
43324,
11,
19016,
11,
1367,
8,
1405,
1473,
692,
482,
8389,
374,
264,
2777,
11,
3082,
369,
264,
8389,
1396,
11,
775,
3641,
198,
692,
482,
19016,
374,
264,
925,
7231,
279,
19016,
315,
279,
2612,
198,
692,
482,
1367,
11105,
279,
28790,
315,
279,
2612,
3638,
286,
578,
49823,
315,
279,
28790,
374,
1778,
430,
366,
61870,
60484,
27,
4683,
397,
286,
11105,
279,
12395,
57304,
311,
659,
382,
286,
432,
13900,
374,
2744,
4883,
4791,
41078,
15795,
382,
14711,
6075,
512,
755,
721,
2293,
2401,
766,
29593,
55718,
1214,
11,
16437,
997,
286,
4304,
15392,
264,
73332,
35326,
6295,
5559,
2937,
311,
264,
2728,
1396,
315,
198,
286,
5199,
19016,
382,
286,
5295,
264,
24657,
320,
43324,
11,
19016,
11,
1367,
8,
1405,
1473,
692,
482,
8389,
374,
264,
2777,
11,
3082,
369,
264,
8389,
1396,
11,
775,
3641,
198,
692,
482,
19016,
374,
264,
925,
7231,
279,
19016,
315,
279,
2612,
198,
692,
482,
1367,
11105,
279,
28790,
315,
279,
2612,
3638,
286,
578,
49823,
315,
279,
28790,
374,
1778,
430,
366,
61870,
60484,
27,
4683,
397,
286,
11105,
279,
12395,
57304,
311,
659,
382,
286,
432,
13900,
374,
2744,
4883,
4791,
41078,
15795,
627,
286,
3270,
286,
422,
16437,
2717,
220,
15,
512,
310,
4933,
15764,
446,
28281,
5811,
1288,
387,
520,
3325,
220,
16,
5240,
286,
1879,
11,
19016,
11,
1367,
284,
721,
1331,
1658,
3138,
2966,
17,
1021,
310,
220,
605,
345,
310,
16437,
345,
310,
659,
345,
310,
77238,
1159,
5482,
8820,
2135,
42122,
345,
286,
5235,
286,
471,
1879,
11,
19016,
11,
1367,
482,
2479,
99466,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
myusuf3/delorean | delorean/dates.py | Delorean.truncate | def truncate(self, s):
"""
Truncate the delorian object to the nearest s
(second, minute, hour, day, month, year)
This is a destructive method, modifies the internal datetime
object associated with the Delorean object.
.. testsetup::
from datetime import datetime
from delorean import Delorean
.. doctest::
>>> d = Delorean(datetime(2015, 1, 1, 12, 10), timezone='US/Pacific')
>>> d.truncate('hour')
Delorean(datetime=datetime.datetime(2015, 1, 1, 12, 0), timezone='US/Pacific')
"""
if s == 'second':
self._dt = self._dt.replace(microsecond=0)
elif s == 'minute':
self._dt = self._dt.replace(second=0, microsecond=0)
elif s == 'hour':
self._dt = self._dt.replace(minute=0, second=0, microsecond=0)
elif s == 'day':
self._dt = self._dt.replace(hour=0, minute=0, second=0, microsecond=0)
elif s == 'month':
self._dt = self._dt.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
elif s == 'year':
self._dt = self._dt.replace(month=1, day=1, hour=0, minute=0, second=0, microsecond=0)
else:
raise ValueError("Invalid truncation level")
return self | python | def truncate(self, s):
"""
Truncate the delorian object to the nearest s
(second, minute, hour, day, month, year)
This is a destructive method, modifies the internal datetime
object associated with the Delorean object.
.. testsetup::
from datetime import datetime
from delorean import Delorean
.. doctest::
>>> d = Delorean(datetime(2015, 1, 1, 12, 10), timezone='US/Pacific')
>>> d.truncate('hour')
Delorean(datetime=datetime.datetime(2015, 1, 1, 12, 0), timezone='US/Pacific')
"""
if s == 'second':
self._dt = self._dt.replace(microsecond=0)
elif s == 'minute':
self._dt = self._dt.replace(second=0, microsecond=0)
elif s == 'hour':
self._dt = self._dt.replace(minute=0, second=0, microsecond=0)
elif s == 'day':
self._dt = self._dt.replace(hour=0, minute=0, second=0, microsecond=0)
elif s == 'month':
self._dt = self._dt.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
elif s == 'year':
self._dt = self._dt.replace(month=1, day=1, hour=0, minute=0, second=0, microsecond=0)
else:
raise ValueError("Invalid truncation level")
return self | [
"def",
"truncate",
"(",
"self",
",",
"s",
")",
":",
"if",
"s",
"==",
"'second'",
":",
"self",
".",
"_dt",
"=",
"self",
".",
"_dt",
".",
"replace",
"(",
"microsecond",
"=",
"0",
")",
"elif",
"s",
"==",
"'minute'",
":",
"self",
".",
"_dt",
"=",
"self",
".",
"_dt",
".",
"replace",
"(",
"second",
"=",
"0",
",",
"microsecond",
"=",
"0",
")",
"elif",
"s",
"==",
"'hour'",
":",
"self",
".",
"_dt",
"=",
"self",
".",
"_dt",
".",
"replace",
"(",
"minute",
"=",
"0",
",",
"second",
"=",
"0",
",",
"microsecond",
"=",
"0",
")",
"elif",
"s",
"==",
"'day'",
":",
"self",
".",
"_dt",
"=",
"self",
".",
"_dt",
".",
"replace",
"(",
"hour",
"=",
"0",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0",
",",
"microsecond",
"=",
"0",
")",
"elif",
"s",
"==",
"'month'",
":",
"self",
".",
"_dt",
"=",
"self",
".",
"_dt",
".",
"replace",
"(",
"day",
"=",
"1",
",",
"hour",
"=",
"0",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0",
",",
"microsecond",
"=",
"0",
")",
"elif",
"s",
"==",
"'year'",
":",
"self",
".",
"_dt",
"=",
"self",
".",
"_dt",
".",
"replace",
"(",
"month",
"=",
"1",
",",
"day",
"=",
"1",
",",
"hour",
"=",
"0",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0",
",",
"microsecond",
"=",
"0",
")",
"else",
":",
"raise",
"ValueError",
"(",
"\"Invalid truncation level\"",
")",
"return",
"self"
] | Truncate the delorian object to the nearest s
(second, minute, hour, day, month, year)
This is a destructive method, modifies the internal datetime
object associated with the Delorean object.
.. testsetup::
from datetime import datetime
from delorean import Delorean
.. doctest::
>>> d = Delorean(datetime(2015, 1, 1, 12, 10), timezone='US/Pacific')
>>> d.truncate('hour')
Delorean(datetime=datetime.datetime(2015, 1, 1, 12, 0), timezone='US/Pacific') | [
"Truncate",
"the",
"delorian",
"object",
"to",
"the",
"nearest",
"s",
"(",
"second",
"minute",
"hour",
"day",
"month",
"year",
")"
] | train | https://github.com/myusuf3/delorean/blob/3e8a7b8cfd4c26546f62bde2f34002893adfa08a/delorean/dates.py#L336-L371 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Truncate the delorian object to the nearest s
(second, minute, hour, day, month, year)
This is a destructive method, modifies the internal datetime
object associated with the Delorean object.
.. testsetup::
from datetime import datetime
from delorean import Delorean
.. doctest::
>>> d = Delorean(datetime(2015, 1, 1, 12, 10), timezone='US/Pacific')
>>> d.truncate('hour')
Delorean(datetime=datetime.datetime(2015, 1, 1, 12, 0), timezone='US/Pacific')
### Response:
def truncate(self, s):
"""
Truncate the delorian object to the nearest s
(second, minute, hour, day, month, year)
This is a destructive method, modifies the internal datetime
object associated with the Delorean object.
.. testsetup::
from datetime import datetime
from delorean import Delorean
.. doctest::
>>> d = Delorean(datetime(2015, 1, 1, 12, 10), timezone='US/Pacific')
>>> d.truncate('hour')
Delorean(datetime=datetime.datetime(2015, 1, 1, 12, 0), timezone='US/Pacific')
"""
if s == 'second':
self._dt = self._dt.replace(microsecond=0)
elif s == 'minute':
self._dt = self._dt.replace(second=0, microsecond=0)
elif s == 'hour':
self._dt = self._dt.replace(minute=0, second=0, microsecond=0)
elif s == 'day':
self._dt = self._dt.replace(hour=0, minute=0, second=0, microsecond=0)
elif s == 'month':
self._dt = self._dt.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
elif s == 'year':
self._dt = self._dt.replace(month=1, day=1, hour=0, minute=0, second=0, microsecond=0)
else:
raise ValueError("Invalid truncation level")
return self
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1305,
27998,
279,
1624,
22865,
1665,
311,
279,
24379,
274,
198,
286,
320,
5686,
11,
9568,
11,
6596,
11,
1938,
11,
2305,
11,
1060,
696,
286,
1115,
374,
264,
40652,
1749,
11,
84049,
279,
5419,
9050,
198,
286,
1665,
5938,
449,
279,
7462,
46295,
1665,
382,
286,
5354,
1296,
15543,
66152,
310,
505,
9050,
1179,
9050,
198,
310,
505,
1624,
46295,
1179,
7462,
46295,
271,
286,
5354,
656,
68980,
66152,
310,
12382,
294,
284,
7462,
46295,
46344,
7,
679,
20,
11,
220,
16,
11,
220,
16,
11,
220,
717,
11,
220,
605,
705,
35057,
1151,
2078,
16744,
41583,
1329,
310,
12382,
294,
5543,
27998,
493,
25704,
1329,
310,
7462,
46295,
46344,
57849,
20296,
7,
679,
20,
11,
220,
16,
11,
220,
16,
11,
220,
717,
11,
220,
15,
705,
35057,
1151,
2078,
16744,
41583,
4713,
14711,
6075,
512,
755,
57872,
1214,
11,
274,
997,
286,
3270,
286,
1183,
27998,
279,
1624,
22865,
1665,
311,
279,
24379,
274,
198,
286,
320,
5686,
11,
9568,
11,
6596,
11,
1938,
11,
2305,
11,
1060,
696,
286,
1115,
374,
264,
40652,
1749,
11,
84049,
279,
5419,
9050,
198,
286,
1665,
5938,
449,
279,
7462,
46295,
1665,
382,
286,
5354,
1296,
15543,
66152,
310,
505,
9050,
1179,
9050,
198,
310,
505,
1624,
46295,
1179,
7462,
46295,
271,
286,
5354,
656,
68980,
66152,
310,
12382,
294,
284,
7462,
46295,
46344,
7,
679,
20,
11,
220,
16,
11,
220,
16,
11,
220,
717,
11,
220,
605,
705,
35057,
1151,
2078,
16744,
41583,
1329,
310,
12382,
294,
5543,
27998,
493,
25704,
1329,
310,
7462,
46295,
46344,
57849,
20296,
7,
679,
20,
11,
220,
16,
11,
220,
16,
11,
220,
717,
11,
220,
15,
705,
35057,
1151,
2078,
16744,
41583,
4713,
286,
3270,
286,
422,
274,
624,
364,
5686,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
1278,
2823,
5686,
28,
15,
340,
286,
4508,
274,
624,
364,
43657,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
46958,
28,
15,
11,
8162,
5686,
28,
15,
340,
286,
4508,
274,
624,
364,
25704,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
14478,
1088,
28,
15,
11,
2132,
28,
15,
11,
8162,
5686,
28,
15,
340,
286,
4508,
274,
624,
364,
1316,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
72135,
28,
15,
11,
9568,
28,
15,
11,
2132,
28,
15,
11,
8162,
5686,
28,
15,
340,
286,
4508,
274,
624,
364,
10460,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
38434,
28,
16,
11,
6596,
28,
15,
11,
9568,
28,
15,
11,
2132,
28,
15,
11,
8162,
5686,
28,
15,
340,
286,
4508,
274,
624,
364,
3236,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
45823,
28,
16,
11,
1938,
28,
16,
11,
6596,
28,
15,
11,
9568,
28,
15,
11,
2132,
28,
15,
11,
8162,
5686,
28,
15,
340,
286
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1305,
27998,
279,
1624,
22865,
1665,
311,
279,
24379,
274,
198,
286,
320,
5686,
11,
9568,
11,
6596,
11,
1938,
11,
2305,
11,
1060,
696,
286,
1115,
374,
264,
40652,
1749,
11,
84049,
279,
5419,
9050,
198,
286,
1665,
5938,
449,
279,
7462,
46295,
1665,
382,
286,
5354,
1296,
15543,
66152,
310,
505,
9050,
1179,
9050,
198,
310,
505,
1624,
46295,
1179,
7462,
46295,
271,
286,
5354,
656,
68980,
66152,
310,
12382,
294,
284,
7462,
46295,
46344,
7,
679,
20,
11,
220,
16,
11,
220,
16,
11,
220,
717,
11,
220,
605,
705,
35057,
1151,
2078,
16744,
41583,
1329,
310,
12382,
294,
5543,
27998,
493,
25704,
1329,
310,
7462,
46295,
46344,
57849,
20296,
7,
679,
20,
11,
220,
16,
11,
220,
16,
11,
220,
717,
11,
220,
15,
705,
35057,
1151,
2078,
16744,
41583,
4713,
14711,
6075,
512,
755,
57872,
1214,
11,
274,
997,
286,
3270,
286,
1183,
27998,
279,
1624,
22865,
1665,
311,
279,
24379,
274,
198,
286,
320,
5686,
11,
9568,
11,
6596,
11,
1938,
11,
2305,
11,
1060,
696,
286,
1115,
374,
264,
40652,
1749,
11,
84049,
279,
5419,
9050,
198,
286,
1665,
5938,
449,
279,
7462,
46295,
1665,
382,
286,
5354,
1296,
15543,
66152,
310,
505,
9050,
1179,
9050,
198,
310,
505,
1624,
46295,
1179,
7462,
46295,
271,
286,
5354,
656,
68980,
66152,
310,
12382,
294,
284,
7462,
46295,
46344,
7,
679,
20,
11,
220,
16,
11,
220,
16,
11,
220,
717,
11,
220,
605,
705,
35057,
1151,
2078,
16744,
41583,
1329,
310,
12382,
294,
5543,
27998,
493,
25704,
1329,
310,
7462,
46295,
46344,
57849,
20296,
7,
679,
20,
11,
220,
16,
11,
220,
16,
11,
220,
717,
11,
220,
15,
705,
35057,
1151,
2078,
16744,
41583,
4713,
286,
3270,
286,
422,
274,
624,
364,
5686,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
1278,
2823,
5686,
28,
15,
340,
286,
4508,
274,
624,
364,
43657,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
46958,
28,
15,
11,
8162,
5686,
28,
15,
340,
286,
4508,
274,
624,
364,
25704,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
14478,
1088,
28,
15,
11,
2132,
28,
15,
11,
8162,
5686,
28,
15,
340,
286,
4508,
274,
624,
364,
1316,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
72135,
28,
15,
11,
9568,
28,
15,
11,
2132,
28,
15,
11,
8162,
5686,
28,
15,
340,
286,
4508,
274,
624,
364,
10460,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
38434,
28,
16,
11,
6596,
28,
15,
11,
9568,
28,
15,
11,
2132,
28,
15,
11,
8162,
5686,
28,
15,
340,
286,
4508,
274,
624,
364,
3236,
3730,
310,
659,
1462,
8207,
284,
659,
1462,
8207,
7125,
45823,
28,
16,
11,
1938,
28,
16,
11,
6596,
28,
15,
11,
9568,
28,
15,
11,
2132,
28,
15,
11,
8162,
5686,
28,
15,
340,
286
] |
spyder-ide/spyder | spyder/plugins/editor/panels/manager.py | PanelsManager.refresh | def refresh(self):
"""Refreshes the editor panels (resize and update margins)."""
logger.debug('Refresh panels')
self.resize()
self._update(self.editor.contentsRect(), 0,
force_update_margins=True) | python | def refresh(self):
"""Refreshes the editor panels (resize and update margins)."""
logger.debug('Refresh panels')
self.resize()
self._update(self.editor.contentsRect(), 0,
force_update_margins=True) | [
"def",
"refresh",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Refresh panels'",
")",
"self",
".",
"resize",
"(",
")",
"self",
".",
"_update",
"(",
"self",
".",
"editor",
".",
"contentsRect",
"(",
")",
",",
"0",
",",
"force_update_margins",
"=",
"True",
")"
] | Refreshes the editor panels (resize and update margins). | [
"Refreshes",
"the",
"editor",
"panels",
"(",
"resize",
"and",
"update",
"margins",
")",
"."
] | train | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/manager.py#L156-L161 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Refreshes the editor panels (resize and update margins).
### Response:
def refresh(self):
"""Refreshes the editor panels (resize and update margins)."""
logger.debug('Refresh panels')
self.resize()
self._update(self.editor.contentsRect(), 0,
force_update_margins=True)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14909,
288,
279,
6576,
21988,
320,
17799,
323,
2713,
37682,
3677,
14711,
6075,
512,
755,
10625,
1214,
997,
286,
4304,
14909,
288,
279,
6576,
21988,
320,
17799,
323,
2713,
37682,
570,
7275,
286,
6050,
8042,
493,
14909,
21988,
1329,
286,
659,
17838,
746,
286,
659,
1462,
2443,
1214,
35993,
46908,
4515,
1535,
220,
15,
345,
3909,
5457,
9058,
722,
82939,
3702,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14909,
288,
279,
6576,
21988,
320,
17799,
323,
2713,
37682,
3677,
14711,
6075,
512,
755,
10625,
1214,
997,
286,
4304,
14909,
288,
279,
6576,
21988,
320,
17799,
323,
2713,
37682,
570,
7275,
286,
6050,
8042,
493,
14909,
21988,
1329,
286,
659,
17838,
746,
286,
659,
1462,
2443,
1214,
35993,
46908,
4515,
1535,
220,
15,
345,
3909,
5457,
9058,
722,
82939,
3702,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
tanghaibao/goatools | goatools/anno/init/reader_gaf.py | GafData._wrlog_details_illegal_gaf | def _wrlog_details_illegal_gaf(self, fout_err, err_cnts):
"""Print details regarding illegal GAF lines seen to a log file."""
# fout_err = "{}.log".format(fin_gaf)
gaf_base = os.path.basename(fout_err)
with open(fout_err, 'w') as prt:
prt.write("ILLEGAL GAF ERROR SUMMARY:\n\n")
for err_cnt in err_cnts:
prt.write(err_cnt)
prt.write("\n\nILLEGAL GAF ERROR DETAILS:\n\n")
for lnum, line in self.ignored:
prt.write("**WARNING: GAF LINE IGNORED: {FIN}[{LNUM}]:\n{L}\n".format(
FIN=gaf_base, L=line, LNUM=lnum))
self.prt_line_detail(prt, line)
prt.write("\n\n")
for error, lines in self.illegal_lines.items():
for lnum, line in lines:
prt.write("**WARNING: GAF LINE ILLEGAL({ERR}): {FIN}[{LNUM}]:\n{L}\n".format(
ERR=error, FIN=gaf_base, L=line, LNUM=lnum))
self.prt_line_detail(prt, line)
prt.write("\n\n")
return fout_err | python | def _wrlog_details_illegal_gaf(self, fout_err, err_cnts):
"""Print details regarding illegal GAF lines seen to a log file."""
# fout_err = "{}.log".format(fin_gaf)
gaf_base = os.path.basename(fout_err)
with open(fout_err, 'w') as prt:
prt.write("ILLEGAL GAF ERROR SUMMARY:\n\n")
for err_cnt in err_cnts:
prt.write(err_cnt)
prt.write("\n\nILLEGAL GAF ERROR DETAILS:\n\n")
for lnum, line in self.ignored:
prt.write("**WARNING: GAF LINE IGNORED: {FIN}[{LNUM}]:\n{L}\n".format(
FIN=gaf_base, L=line, LNUM=lnum))
self.prt_line_detail(prt, line)
prt.write("\n\n")
for error, lines in self.illegal_lines.items():
for lnum, line in lines:
prt.write("**WARNING: GAF LINE ILLEGAL({ERR}): {FIN}[{LNUM}]:\n{L}\n".format(
ERR=error, FIN=gaf_base, L=line, LNUM=lnum))
self.prt_line_detail(prt, line)
prt.write("\n\n")
return fout_err | [
"def",
"_wrlog_details_illegal_gaf",
"(",
"self",
",",
"fout_err",
",",
"err_cnts",
")",
":",
"# fout_err = \"{}.log\".format(fin_gaf)",
"gaf_base",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"fout_err",
")",
"with",
"open",
"(",
"fout_err",
",",
"'w'",
")",
"as",
"prt",
":",
"prt",
".",
"write",
"(",
"\"ILLEGAL GAF ERROR SUMMARY:\\n\\n\"",
")",
"for",
"err_cnt",
"in",
"err_cnts",
":",
"prt",
".",
"write",
"(",
"err_cnt",
")",
"prt",
".",
"write",
"(",
"\"\\n\\nILLEGAL GAF ERROR DETAILS:\\n\\n\"",
")",
"for",
"lnum",
",",
"line",
"in",
"self",
".",
"ignored",
":",
"prt",
".",
"write",
"(",
"\"**WARNING: GAF LINE IGNORED: {FIN}[{LNUM}]:\\n{L}\\n\"",
".",
"format",
"(",
"FIN",
"=",
"gaf_base",
",",
"L",
"=",
"line",
",",
"LNUM",
"=",
"lnum",
")",
")",
"self",
".",
"prt_line_detail",
"(",
"prt",
",",
"line",
")",
"prt",
".",
"write",
"(",
"\"\\n\\n\"",
")",
"for",
"error",
",",
"lines",
"in",
"self",
".",
"illegal_lines",
".",
"items",
"(",
")",
":",
"for",
"lnum",
",",
"line",
"in",
"lines",
":",
"prt",
".",
"write",
"(",
"\"**WARNING: GAF LINE ILLEGAL({ERR}): {FIN}[{LNUM}]:\\n{L}\\n\"",
".",
"format",
"(",
"ERR",
"=",
"error",
",",
"FIN",
"=",
"gaf_base",
",",
"L",
"=",
"line",
",",
"LNUM",
"=",
"lnum",
")",
")",
"self",
".",
"prt_line_detail",
"(",
"prt",
",",
"line",
")",
"prt",
".",
"write",
"(",
"\"\\n\\n\"",
")",
"return",
"fout_err"
] | Print details regarding illegal GAF lines seen to a log file. | [
"Print",
"details",
"regarding",
"illegal",
"GAF",
"lines",
"seen",
"to",
"a",
"log",
"file",
"."
] | train | https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/anno/init/reader_gaf.py#L280-L300 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Print details regarding illegal GAF lines seen to a log file.
### Response:
def _wrlog_details_illegal_gaf(self, fout_err, err_cnts):
"""Print details regarding illegal GAF lines seen to a log file."""
# fout_err = "{}.log".format(fin_gaf)
gaf_base = os.path.basename(fout_err)
with open(fout_err, 'w') as prt:
prt.write("ILLEGAL GAF ERROR SUMMARY:\n\n")
for err_cnt in err_cnts:
prt.write(err_cnt)
prt.write("\n\nILLEGAL GAF ERROR DETAILS:\n\n")
for lnum, line in self.ignored:
prt.write("**WARNING: GAF LINE IGNORED: {FIN}[{LNUM}]:\n{L}\n".format(
FIN=gaf_base, L=line, LNUM=lnum))
self.prt_line_detail(prt, line)
prt.write("\n\n")
for error, lines in self.illegal_lines.items():
for lnum, line in lines:
prt.write("**WARNING: GAF LINE ILLEGAL({ERR}): {FIN}[{LNUM}]:\n{L}\n".format(
ERR=error, FIN=gaf_base, L=line, LNUM=lnum))
self.prt_line_detail(prt, line)
prt.write("\n\n")
return fout_err
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
9171,
3649,
9002,
12079,
480,
8440,
5238,
3970,
311,
264,
1515,
1052,
382,
14711,
6075,
512,
755,
721,
19239,
848,
13563,
27841,
6564,
1928,
2642,
1214,
11,
39373,
9450,
11,
1886,
16362,
82,
997,
286,
4304,
9171,
3649,
9002,
12079,
480,
8440,
5238,
3970,
311,
264,
1515,
1052,
14781,
286,
674,
39373,
9450,
284,
36603,
13,
848,
3343,
2293,
77400,
1928,
2642,
340,
286,
342,
2642,
7806,
284,
2709,
3960,
38092,
96854,
9450,
340,
286,
449,
1825,
96854,
9450,
11,
364,
86,
873,
439,
96784,
512,
310,
96784,
3921,
446,
1750,
76334,
480,
8440,
13170,
96885,
7338,
77,
1734,
1158,
310,
369,
1886,
16362,
304,
1886,
16362,
82,
512,
394,
96784,
3921,
4052,
16362,
340,
310,
96784,
3921,
5026,
77,
1734,
1750,
76334,
480,
8440,
13170,
78096,
7338,
77,
1734,
1158,
310,
369,
326,
2470,
11,
1584,
304,
659,
13,
59571,
512,
394,
96784,
3921,
92489,
33804,
25,
480,
8440,
31951,
82390,
35,
25,
314,
17167,
44489,
90,
43,
17946,
92,
5787,
59,
77,
90,
43,
11281,
77,
3343,
2293,
1021,
504,
25338,
38262,
2642,
7806,
11,
445,
79285,
11,
445,
17946,
28,
2312,
372,
1192,
394,
659,
558,
3423,
6665,
14820,
26022,
83,
11,
1584,
340,
394,
96784,
3921,
5026,
77,
1734,
1158,
310,
369,
1493,
11,
5238,
304,
659,
13,
77098,
18828,
9812,
4019,
394,
369,
326,
2470,
11,
1584,
304,
5238,
512,
504,
96784,
3921,
92489,
33804,
25,
480,
8440,
31951,
11598,
76334,
2358,
2716,
91788,
314,
17167,
44489,
90,
43,
17946,
92,
5787,
59,
77,
90,
43,
11281,
77,
3343,
2293,
1021,
667,
10375,
28,
850,
11,
25338,
38262,
2642,
7806,
11,
445,
79285,
11,
445,
17946,
28,
2312,
372,
1192,
504,
659,
558,
3423,
6665,
14820,
26022,
83,
11,
1584,
340,
504,
96784,
3921,
5026,
77,
1734,
1158,
286,
471,
39373,
9450,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
9171,
3649,
9002,
12079,
480,
8440,
5238,
3970,
311,
264,
1515,
1052,
382,
14711,
6075,
512,
755,
721,
19239,
848,
13563,
27841,
6564,
1928,
2642,
1214,
11,
39373,
9450,
11,
1886,
16362,
82,
997,
286,
4304,
9171,
3649,
9002,
12079,
480,
8440,
5238,
3970,
311,
264,
1515,
1052,
14781,
286,
674,
39373,
9450,
284,
36603,
13,
848,
3343,
2293,
77400,
1928,
2642,
340,
286,
342,
2642,
7806,
284,
2709,
3960,
38092,
96854,
9450,
340,
286,
449,
1825,
96854,
9450,
11,
364,
86,
873,
439,
96784,
512,
310,
96784,
3921,
446,
1750,
76334,
480,
8440,
13170,
96885,
7338,
77,
1734,
1158,
310,
369,
1886,
16362,
304,
1886,
16362,
82,
512,
394,
96784,
3921,
4052,
16362,
340,
310,
96784,
3921,
5026,
77,
1734,
1750,
76334,
480,
8440,
13170,
78096,
7338,
77,
1734,
1158,
310,
369,
326,
2470,
11,
1584,
304,
659,
13,
59571,
512,
394,
96784,
3921,
92489,
33804,
25,
480,
8440,
31951,
82390,
35,
25,
314,
17167,
44489,
90,
43,
17946,
92,
5787,
59,
77,
90,
43,
11281,
77,
3343,
2293,
1021,
504,
25338,
38262,
2642,
7806,
11,
445,
79285,
11,
445,
17946,
28,
2312,
372,
1192,
394,
659,
558,
3423,
6665,
14820,
26022,
83,
11,
1584,
340,
394,
96784,
3921,
5026,
77,
1734,
1158,
310,
369,
1493,
11,
5238,
304,
659,
13,
77098,
18828,
9812,
4019,
394,
369,
326,
2470,
11,
1584,
304,
5238,
512,
504,
96784,
3921,
92489,
33804,
25,
480,
8440,
31951,
11598,
76334,
2358,
2716,
91788,
314,
17167,
44489,
90,
43,
17946,
92,
5787,
59,
77,
90,
43,
11281,
77,
3343,
2293,
1021,
667,
10375,
28,
850,
11,
25338,
38262,
2642,
7806,
11,
445,
79285,
11,
445,
17946,
28,
2312,
372,
1192,
504,
659,
558,
3423,
6665,
14820,
26022,
83,
11,
1584,
340,
504,
96784,
3921,
5026,
77,
1734,
1158,
286,
471,
39373,
9450,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
halcy/Mastodon.py | mastodon/Mastodon.py | Mastodon.__json_hooks | def __json_hooks(json_object):
"""
All the json hooks. Used in request parsing.
"""
json_object = Mastodon.__json_strnum_to_bignum(json_object)
json_object = Mastodon.__json_date_parse(json_object)
json_object = Mastodon.__json_truefalse_parse(json_object)
json_object = Mastodon.__json_allow_dict_attrs(json_object)
return json_object | python | def __json_hooks(json_object):
"""
All the json hooks. Used in request parsing.
"""
json_object = Mastodon.__json_strnum_to_bignum(json_object)
json_object = Mastodon.__json_date_parse(json_object)
json_object = Mastodon.__json_truefalse_parse(json_object)
json_object = Mastodon.__json_allow_dict_attrs(json_object)
return json_object | [
"def",
"__json_hooks",
"(",
"json_object",
")",
":",
"json_object",
"=",
"Mastodon",
".",
"__json_strnum_to_bignum",
"(",
"json_object",
")",
"json_object",
"=",
"Mastodon",
".",
"__json_date_parse",
"(",
"json_object",
")",
"json_object",
"=",
"Mastodon",
".",
"__json_truefalse_parse",
"(",
"json_object",
")",
"json_object",
"=",
"Mastodon",
".",
"__json_allow_dict_attrs",
"(",
"json_object",
")",
"return",
"json_object"
] | All the json hooks. Used in request parsing. | [
"All",
"the",
"json",
"hooks",
".",
"Used",
"in",
"request",
"parsing",
"."
] | train | https://github.com/halcy/Mastodon.py/blob/35c43562dd3d34d6ebf7a0f757c09e8fcccc957c/mastodon/Mastodon.py#L2525-L2533 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
All the json hooks. Used in request parsing.
### Response:
def __json_hooks(json_object):
"""
All the json hooks. Used in request parsing.
"""
json_object = Mastodon.__json_strnum_to_bignum(json_object)
json_object = Mastodon.__json_date_parse(json_object)
json_object = Mastodon.__json_truefalse_parse(json_object)
json_object = Mastodon.__json_allow_dict_attrs(json_object)
return json_object
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2460,
279,
3024,
30777,
13,
12477,
304,
1715,
23115,
382,
14711,
6075,
512,
755,
1328,
2285,
74213,
9488,
5427,
997,
286,
3270,
286,
2052,
279,
3024,
30777,
13,
12477,
304,
1715,
23115,
627,
286,
3270,
286,
3024,
5427,
284,
37582,
77152,
4952,
2285,
2966,
2470,
2401,
890,
93260,
9488,
5427,
8,
1827,
286,
3024,
5427,
284,
37582,
77152,
4952,
2285,
4257,
21715,
9488,
5427,
340,
286,
3024,
5427,
284,
37582,
77152,
4952,
2285,
16469,
3934,
21715,
9488,
5427,
340,
286,
3024,
5427,
284,
37582,
77152,
4952,
2285,
56831,
5356,
40678,
9488,
5427,
340,
286,
471,
3024,
5427,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2460,
279,
3024,
30777,
13,
12477,
304,
1715,
23115,
382,
14711,
6075,
512,
755,
1328,
2285,
74213,
9488,
5427,
997,
286,
3270,
286,
2052,
279,
3024,
30777,
13,
12477,
304,
1715,
23115,
627,
286,
3270,
286,
3024,
5427,
284,
37582,
77152,
4952,
2285,
2966,
2470,
2401,
890,
93260,
9488,
5427,
8,
1827,
286,
3024,
5427,
284,
37582,
77152,
4952,
2285,
4257,
21715,
9488,
5427,
340,
286,
3024,
5427,
284,
37582,
77152,
4952,
2285,
16469,
3934,
21715,
9488,
5427,
340,
286,
3024,
5427,
284,
37582,
77152,
4952,
2285,
56831,
5356,
40678,
9488,
5427,
340,
286,
471,
3024,
5427,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
awslabs/serverless-application-model | samtranslator/plugins/__init__.py | SamPlugins.register | def register(self, plugin):
"""
Register a plugin. New plugins are added to the end of the plugins list.
:param samtranslator.plugins.BasePlugin plugin: Instance/subclass of BasePlugin class that implements hooks
:raises ValueError: If plugin is not an instance of samtranslator.plugins.BasePlugin or if it is already
registered
:return: None
"""
if not plugin or not isinstance(plugin, BasePlugin):
raise ValueError("Plugin must be implemented as a subclass of BasePlugin class")
if self.is_registered(plugin.name):
raise ValueError("Plugin with name {} is already registered".format(plugin.name))
self._plugins.append(plugin) | python | def register(self, plugin):
"""
Register a plugin. New plugins are added to the end of the plugins list.
:param samtranslator.plugins.BasePlugin plugin: Instance/subclass of BasePlugin class that implements hooks
:raises ValueError: If plugin is not an instance of samtranslator.plugins.BasePlugin or if it is already
registered
:return: None
"""
if not plugin or not isinstance(plugin, BasePlugin):
raise ValueError("Plugin must be implemented as a subclass of BasePlugin class")
if self.is_registered(plugin.name):
raise ValueError("Plugin with name {} is already registered".format(plugin.name))
self._plugins.append(plugin) | [
"def",
"register",
"(",
"self",
",",
"plugin",
")",
":",
"if",
"not",
"plugin",
"or",
"not",
"isinstance",
"(",
"plugin",
",",
"BasePlugin",
")",
":",
"raise",
"ValueError",
"(",
"\"Plugin must be implemented as a subclass of BasePlugin class\"",
")",
"if",
"self",
".",
"is_registered",
"(",
"plugin",
".",
"name",
")",
":",
"raise",
"ValueError",
"(",
"\"Plugin with name {} is already registered\"",
".",
"format",
"(",
"plugin",
".",
"name",
")",
")",
"self",
".",
"_plugins",
".",
"append",
"(",
"plugin",
")"
] | Register a plugin. New plugins are added to the end of the plugins list.
:param samtranslator.plugins.BasePlugin plugin: Instance/subclass of BasePlugin class that implements hooks
:raises ValueError: If plugin is not an instance of samtranslator.plugins.BasePlugin or if it is already
registered
:return: None | [
"Register",
"a",
"plugin",
".",
"New",
"plugins",
"are",
"added",
"to",
"the",
"end",
"of",
"the",
"plugins",
"list",
"."
] | train | https://github.com/awslabs/serverless-application-model/blob/cccb0c96b5c91e53355ebc07e542467303a5eedd/samtranslator/plugins/__init__.py#L64-L80 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Register a plugin. New plugins are added to the end of the plugins list.
:param samtranslator.plugins.BasePlugin plugin: Instance/subclass of BasePlugin class that implements hooks
:raises ValueError: If plugin is not an instance of samtranslator.plugins.BasePlugin or if it is already
registered
:return: None
### Response:
def register(self, plugin):
"""
Register a plugin. New plugins are added to the end of the plugins list.
:param samtranslator.plugins.BasePlugin plugin: Instance/subclass of BasePlugin class that implements hooks
:raises ValueError: If plugin is not an instance of samtranslator.plugins.BasePlugin or if it is already
registered
:return: None
"""
if not plugin or not isinstance(plugin, BasePlugin):
raise ValueError("Plugin must be implemented as a subclass of BasePlugin class")
if self.is_registered(plugin.name):
raise ValueError("Plugin with name {} is already registered".format(plugin.name))
self._plugins.append(plugin)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
8861,
264,
9183,
13,
1561,
17658,
527,
3779,
311,
279,
842,
315,
279,
17658,
1160,
382,
286,
551,
913,
10167,
45457,
30491,
13316,
11807,
9183,
25,
19840,
38985,
1058,
315,
5464,
11807,
538,
430,
5280,
30777,
198,
286,
551,
33371,
15764,
25,
1442,
9183,
374,
539,
459,
2937,
315,
10167,
45457,
30491,
13316,
11807,
477,
422,
433,
374,
2736,
198,
310,
9879,
198,
286,
551,
693,
25,
2290,
271,
14711,
6075,
512,
755,
4254,
1214,
11,
9183,
997,
286,
3270,
286,
8618,
264,
9183,
13,
1561,
17658,
527,
3779,
311,
279,
842,
315,
279,
17658,
1160,
382,
286,
551,
913,
10167,
45457,
30491,
13316,
11807,
9183,
25,
19840,
38985,
1058,
315,
5464,
11807,
538,
430,
5280,
30777,
198,
286,
551,
33371,
15764,
25,
1442,
9183,
374,
539,
459,
2937,
315,
10167,
45457,
30491,
13316,
11807,
477,
422,
433,
374,
2736,
198,
310,
9879,
198,
286,
551,
693,
25,
2290,
198,
286,
12713,
286,
422,
539,
9183,
477,
539,
11656,
47901,
11,
5464,
11807,
997,
310,
4933,
15764,
446,
11807,
2011,
387,
11798,
439,
264,
38290,
315,
5464,
11807,
538,
5240,
286,
422,
659,
2124,
73783,
47901,
2710,
997,
310,
4933,
15764,
446,
11807,
449,
836,
4792,
374,
2736,
9879,
3343,
2293,
47901,
2710,
4489,
286,
659,
1462,
19237,
2102,
47901,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
8861,
264,
9183,
13,
1561,
17658,
527,
3779,
311,
279,
842,
315,
279,
17658,
1160,
382,
286,
551,
913,
10167,
45457,
30491,
13316,
11807,
9183,
25,
19840,
38985,
1058,
315,
5464,
11807,
538,
430,
5280,
30777,
198,
286,
551,
33371,
15764,
25,
1442,
9183,
374,
539,
459,
2937,
315,
10167,
45457,
30491,
13316,
11807,
477,
422,
433,
374,
2736,
198,
310,
9879,
198,
286,
551,
693,
25,
2290,
271,
14711,
6075,
512,
755,
4254,
1214,
11,
9183,
997,
286,
3270,
286,
8618,
264,
9183,
13,
1561,
17658,
527,
3779,
311,
279,
842,
315,
279,
17658,
1160,
382,
286,
551,
913,
10167,
45457,
30491,
13316,
11807,
9183,
25,
19840,
38985,
1058,
315,
5464,
11807,
538,
430,
5280,
30777,
198,
286,
551,
33371,
15764,
25,
1442,
9183,
374,
539,
459,
2937,
315,
10167,
45457,
30491,
13316,
11807,
477,
422,
433,
374,
2736,
198,
310,
9879,
198,
286,
551,
693,
25,
2290,
198,
286,
12713,
286,
422,
539,
9183,
477,
539,
11656,
47901,
11,
5464,
11807,
997,
310,
4933,
15764,
446,
11807,
2011,
387,
11798,
439,
264,
38290,
315,
5464,
11807,
538,
5240,
286,
422,
659,
2124,
73783,
47901,
2710,
997,
310,
4933,
15764,
446,
11807,
449,
836,
4792,
374,
2736,
9879,
3343,
2293,
47901,
2710,
4489,
286,
659,
1462,
19237,
2102,
47901,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
evhub/coconut | coconut/compiler/compiler.py | Compiler.endline_repl | def endline_repl(self, inputstring, reformatting=False, **kwargs):
"""Add end of line comments."""
out = []
ln = 1 # line number
for line in inputstring.splitlines():
add_one_to_ln = False
try:
if line.endswith(lnwrapper):
line, index = line[:-1].rsplit("#", 1)
new_ln = self.get_ref("ln", index)
if new_ln < ln:
raise CoconutInternalException("line number decreased", (ln, new_ln))
ln = new_ln
line = line.rstrip()
add_one_to_ln = True
if not reformatting or add_one_to_ln: # add_one_to_ln here is a proxy for whether there was a ln comment or not
line += self.comments.get(ln, "")
if not reformatting and line.rstrip() and not line.lstrip().startswith("#"):
line += self.ln_comment(ln)
except CoconutInternalException as err:
complain(err)
out.append(line)
if add_one_to_ln:
ln += 1
return "\n".join(out) | python | def endline_repl(self, inputstring, reformatting=False, **kwargs):
"""Add end of line comments."""
out = []
ln = 1 # line number
for line in inputstring.splitlines():
add_one_to_ln = False
try:
if line.endswith(lnwrapper):
line, index = line[:-1].rsplit("#", 1)
new_ln = self.get_ref("ln", index)
if new_ln < ln:
raise CoconutInternalException("line number decreased", (ln, new_ln))
ln = new_ln
line = line.rstrip()
add_one_to_ln = True
if not reformatting or add_one_to_ln: # add_one_to_ln here is a proxy for whether there was a ln comment or not
line += self.comments.get(ln, "")
if not reformatting and line.rstrip() and not line.lstrip().startswith("#"):
line += self.ln_comment(ln)
except CoconutInternalException as err:
complain(err)
out.append(line)
if add_one_to_ln:
ln += 1
return "\n".join(out) | [
"def",
"endline_repl",
"(",
"self",
",",
"inputstring",
",",
"reformatting",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"out",
"=",
"[",
"]",
"ln",
"=",
"1",
"# line number",
"for",
"line",
"in",
"inputstring",
".",
"splitlines",
"(",
")",
":",
"add_one_to_ln",
"=",
"False",
"try",
":",
"if",
"line",
".",
"endswith",
"(",
"lnwrapper",
")",
":",
"line",
",",
"index",
"=",
"line",
"[",
":",
"-",
"1",
"]",
".",
"rsplit",
"(",
"\"#\"",
",",
"1",
")",
"new_ln",
"=",
"self",
".",
"get_ref",
"(",
"\"ln\"",
",",
"index",
")",
"if",
"new_ln",
"<",
"ln",
":",
"raise",
"CoconutInternalException",
"(",
"\"line number decreased\"",
",",
"(",
"ln",
",",
"new_ln",
")",
")",
"ln",
"=",
"new_ln",
"line",
"=",
"line",
".",
"rstrip",
"(",
")",
"add_one_to_ln",
"=",
"True",
"if",
"not",
"reformatting",
"or",
"add_one_to_ln",
":",
"# add_one_to_ln here is a proxy for whether there was a ln comment or not",
"line",
"+=",
"self",
".",
"comments",
".",
"get",
"(",
"ln",
",",
"\"\"",
")",
"if",
"not",
"reformatting",
"and",
"line",
".",
"rstrip",
"(",
")",
"and",
"not",
"line",
".",
"lstrip",
"(",
")",
".",
"startswith",
"(",
"\"#\"",
")",
":",
"line",
"+=",
"self",
".",
"ln_comment",
"(",
"ln",
")",
"except",
"CoconutInternalException",
"as",
"err",
":",
"complain",
"(",
"err",
")",
"out",
".",
"append",
"(",
"line",
")",
"if",
"add_one_to_ln",
":",
"ln",
"+=",
"1",
"return",
"\"\\n\"",
".",
"join",
"(",
"out",
")"
] | Add end of line comments. | [
"Add",
"end",
"of",
"line",
"comments",
"."
] | train | https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/compiler.py#L973-L997 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Add end of line comments.
### Response:
def endline_repl(self, inputstring, reformatting=False, **kwargs):
"""Add end of line comments."""
out = []
ln = 1 # line number
for line in inputstring.splitlines():
add_one_to_ln = False
try:
if line.endswith(lnwrapper):
line, index = line[:-1].rsplit("#", 1)
new_ln = self.get_ref("ln", index)
if new_ln < ln:
raise CoconutInternalException("line number decreased", (ln, new_ln))
ln = new_ln
line = line.rstrip()
add_one_to_ln = True
if not reformatting or add_one_to_ln: # add_one_to_ln here is a proxy for whether there was a ln comment or not
line += self.comments.get(ln, "")
if not reformatting and line.rstrip() and not line.lstrip().startswith("#"):
line += self.ln_comment(ln)
except CoconutInternalException as err:
complain(err)
out.append(line)
if add_one_to_ln:
ln += 1
return "\n".join(out)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2261,
842,
315,
1584,
6170,
382,
14711,
6075,
512,
755,
842,
1074,
1311,
501,
1214,
11,
1988,
928,
11,
312,
2293,
1303,
5725,
11,
3146,
9872,
997,
286,
4304,
2261,
842,
315,
1584,
6170,
14781,
286,
704,
284,
4260,
286,
30490,
284,
220,
16,
220,
674,
1584,
1396,
198,
286,
369,
1584,
304,
1988,
928,
5402,
8128,
4019,
310,
923,
11929,
2401,
61501,
284,
3641,
198,
310,
1456,
512,
394,
422,
1584,
41215,
96025,
22075,
997,
504,
1584,
11,
1963,
284,
1584,
27141,
16,
948,
5544,
2344,
3668,
498,
220,
16,
340,
504,
502,
61501,
284,
659,
673,
7949,
446,
2312,
498,
1963,
340,
504,
422,
502,
61501,
366,
30490,
512,
667,
4933,
72379,
11830,
1378,
446,
1074,
1396,
25983,
498,
320,
2312,
11,
502,
61501,
1192,
504,
30490,
284,
502,
61501,
198,
504,
1584,
284,
1584,
60663,
746,
504,
923,
11929,
2401,
61501,
284,
3082,
198,
394,
422,
539,
312,
2293,
1303,
477,
923,
11929,
2401,
61501,
25,
220,
674,
923,
11929,
2401,
61501,
1618,
374,
264,
13594,
369,
3508,
1070,
574,
264,
30490,
4068,
477,
539,
198,
504,
1584,
1447,
659,
46174,
673,
96025,
11,
15018,
394,
422,
539,
312,
2293,
1303,
323,
1584,
60663,
368,
323,
539,
1584,
929,
13406,
1020,
70425,
3668,
15497,
504,
1584,
1447,
659,
929,
77,
18104,
96025,
340,
310,
3734,
72379,
11830,
1378,
439,
1886,
512,
394,
29011,
4052,
340,
310,
704,
2102,
8973,
340,
310,
422,
923,
11929,
2401,
61501,
512,
394,
30490,
1447,
220,
16,
198,
286,
471,
2990,
77,
3343,
6115,
10029,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2261,
842,
315,
1584,
6170,
382,
14711,
6075,
512,
755,
842,
1074,
1311,
501,
1214,
11,
1988,
928,
11,
312,
2293,
1303,
5725,
11,
3146,
9872,
997,
286,
4304,
2261,
842,
315,
1584,
6170,
14781,
286,
704,
284,
4260,
286,
30490,
284,
220,
16,
220,
674,
1584,
1396,
198,
286,
369,
1584,
304,
1988,
928,
5402,
8128,
4019,
310,
923,
11929,
2401,
61501,
284,
3641,
198,
310,
1456,
512,
394,
422,
1584,
41215,
96025,
22075,
997,
504,
1584,
11,
1963,
284,
1584,
27141,
16,
948,
5544,
2344,
3668,
498,
220,
16,
340,
504,
502,
61501,
284,
659,
673,
7949,
446,
2312,
498,
1963,
340,
504,
422,
502,
61501,
366,
30490,
512,
667,
4933,
72379,
11830,
1378,
446,
1074,
1396,
25983,
498,
320,
2312,
11,
502,
61501,
1192,
504,
30490,
284,
502,
61501,
198,
504,
1584,
284,
1584,
60663,
746,
504,
923,
11929,
2401,
61501,
284,
3082,
198,
394,
422,
539,
312,
2293,
1303,
477,
923,
11929,
2401,
61501,
25,
220,
674,
923,
11929,
2401,
61501,
1618,
374,
264,
13594,
369,
3508,
1070,
574,
264,
30490,
4068,
477,
539,
198,
504,
1584,
1447,
659,
46174,
673,
96025,
11,
15018,
394,
422,
539,
312,
2293,
1303,
323,
1584,
60663,
368,
323,
539,
1584,
929,
13406,
1020,
70425,
3668,
15497,
504,
1584,
1447,
659,
929,
77,
18104,
96025,
340,
310,
3734,
72379,
11830,
1378,
439,
1886,
512,
394,
29011,
4052,
340,
310,
704,
2102,
8973,
340,
310,
422,
923,
11929,
2401,
61501,
512,
394,
30490,
1447,
220,
16,
198,
286,
471,
2990,
77,
3343,
6115,
10029,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
wummel/linkchecker | linkcheck/checker/mailtourl.py | getaddresses | def getaddresses (addr):
"""Return list of email addresses from given field value."""
parsed = [mail for name, mail in AddressList(addr).addresslist if mail]
if parsed:
addresses = parsed
elif addr:
# we could not parse any mail addresses, so try with the raw string
addresses = [addr]
else:
addresses = []
return addresses | python | def getaddresses (addr):
"""Return list of email addresses from given field value."""
parsed = [mail for name, mail in AddressList(addr).addresslist if mail]
if parsed:
addresses = parsed
elif addr:
# we could not parse any mail addresses, so try with the raw string
addresses = [addr]
else:
addresses = []
return addresses | [
"def",
"getaddresses",
"(",
"addr",
")",
":",
"parsed",
"=",
"[",
"mail",
"for",
"name",
",",
"mail",
"in",
"AddressList",
"(",
"addr",
")",
".",
"addresslist",
"if",
"mail",
"]",
"if",
"parsed",
":",
"addresses",
"=",
"parsed",
"elif",
"addr",
":",
"# we could not parse any mail addresses, so try with the raw string",
"addresses",
"=",
"[",
"addr",
"]",
"else",
":",
"addresses",
"=",
"[",
"]",
"return",
"addresses"
] | Return list of email addresses from given field value. | [
"Return",
"list",
"of",
"email",
"addresses",
"from",
"given",
"field",
"value",
"."
] | train | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/mailtourl.py#L37-L47 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return list of email addresses from given field value.
### Response:
def getaddresses (addr):
"""Return list of email addresses from given field value."""
parsed = [mail for name, mail in AddressList(addr).addresslist if mail]
if parsed:
addresses = parsed
elif addr:
# we could not parse any mail addresses, so try with the raw string
addresses = [addr]
else:
addresses = []
return addresses
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
1160,
315,
2613,
14564,
505,
2728,
2115,
907,
382,
14711,
6075,
512,
755,
636,
54889,
320,
6346,
997,
262,
4304,
5715,
1160,
315,
2613,
14564,
505,
2728,
2115,
907,
14781,
262,
16051,
284,
510,
3796,
369,
836,
11,
8232,
304,
9356,
861,
25509,
570,
5102,
1638,
422,
8232,
933,
262,
422,
16051,
512,
286,
14564,
284,
16051,
198,
262,
4508,
11022,
512,
286,
674,
584,
1436,
539,
4820,
904,
8232,
14564,
11,
779,
1456,
449,
279,
7257,
925,
198,
286,
14564,
284,
510,
6346,
933,
262,
775,
512,
286,
14564,
284,
4260,
262,
471,
14564,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
1160,
315,
2613,
14564,
505,
2728,
2115,
907,
382,
14711,
6075,
512,
755,
636,
54889,
320,
6346,
997,
262,
4304,
5715,
1160,
315,
2613,
14564,
505,
2728,
2115,
907,
14781,
262,
16051,
284,
510,
3796,
369,
836,
11,
8232,
304,
9356,
861,
25509,
570,
5102,
1638,
422,
8232,
933,
262,
422,
16051,
512,
286,
14564,
284,
16051,
198,
262,
4508,
11022,
512,
286,
674,
584,
1436,
539,
4820,
904,
8232,
14564,
11,
779,
1456,
449,
279,
7257,
925,
198,
286,
14564,
284,
510,
6346,
933,
262,
775,
512,
286,
14564,
284,
4260,
262,
471,
14564,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
senaite/senaite.core | bika/lims/upgrade/v01_03_000.py | reindex_submitted_analyses | def reindex_submitted_analyses(portal):
"""Reindex submitted analyses
"""
logger.info("Reindex submitted analyses")
brains = api.search({}, "bika_analysis_catalog")
total = len(brains)
logger.info("Processing {} analyses".format(total))
for num, brain in enumerate(brains):
# skip analyses which have an analyst
if brain.getAnalyst:
continue
# reindex analyses which have no annalyst set, but a result
if brain.getResult not in ["", None]:
analysis = brain.getObject()
analysis.reindexObject()
if num > 0 and num % 5000 == 0:
logger.info("Commiting reindexed analyses {}/{} ..."
.format(num, total))
transaction.commit() | python | def reindex_submitted_analyses(portal):
"""Reindex submitted analyses
"""
logger.info("Reindex submitted analyses")
brains = api.search({}, "bika_analysis_catalog")
total = len(brains)
logger.info("Processing {} analyses".format(total))
for num, brain in enumerate(brains):
# skip analyses which have an analyst
if brain.getAnalyst:
continue
# reindex analyses which have no annalyst set, but a result
if brain.getResult not in ["", None]:
analysis = brain.getObject()
analysis.reindexObject()
if num > 0 and num % 5000 == 0:
logger.info("Commiting reindexed analyses {}/{} ..."
.format(num, total))
transaction.commit() | [
"def",
"reindex_submitted_analyses",
"(",
"portal",
")",
":",
"logger",
".",
"info",
"(",
"\"Reindex submitted analyses\"",
")",
"brains",
"=",
"api",
".",
"search",
"(",
"{",
"}",
",",
"\"bika_analysis_catalog\"",
")",
"total",
"=",
"len",
"(",
"brains",
")",
"logger",
".",
"info",
"(",
"\"Processing {} analyses\"",
".",
"format",
"(",
"total",
")",
")",
"for",
"num",
",",
"brain",
"in",
"enumerate",
"(",
"brains",
")",
":",
"# skip analyses which have an analyst",
"if",
"brain",
".",
"getAnalyst",
":",
"continue",
"# reindex analyses which have no annalyst set, but a result",
"if",
"brain",
".",
"getResult",
"not",
"in",
"[",
"\"\"",
",",
"None",
"]",
":",
"analysis",
"=",
"brain",
".",
"getObject",
"(",
")",
"analysis",
".",
"reindexObject",
"(",
")",
"if",
"num",
">",
"0",
"and",
"num",
"%",
"5000",
"==",
"0",
":",
"logger",
".",
"info",
"(",
"\"Commiting reindexed analyses {}/{} ...\"",
".",
"format",
"(",
"num",
",",
"total",
")",
")",
"transaction",
".",
"commit",
"(",
")"
] | Reindex submitted analyses | [
"Reindex",
"submitted",
"analyses"
] | train | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/upgrade/v01_03_000.py#L2123-L2143 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Reindex submitted analyses
### Response:
def reindex_submitted_analyses(portal):
"""Reindex submitted analyses
"""
logger.info("Reindex submitted analyses")
brains = api.search({}, "bika_analysis_catalog")
total = len(brains)
logger.info("Processing {} analyses".format(total))
for num, brain in enumerate(brains):
# skip analyses which have an analyst
if brain.getAnalyst:
continue
# reindex analyses which have no annalyst set, but a result
if brain.getResult not in ["", None]:
analysis = brain.getObject()
analysis.reindexObject()
if num > 0 and num % 5000 == 0:
logger.info("Commiting reindexed analyses {}/{} ..."
.format(num, total))
transaction.commit()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
697,
1275,
14976,
29060,
271,
14711,
6075,
512,
755,
312,
1275,
5341,
5600,
12277,
278,
73279,
21924,
278,
997,
262,
4304,
697,
1275,
14976,
29060,
198,
262,
3270,
262,
6050,
5506,
446,
697,
1275,
14976,
29060,
1158,
262,
35202,
284,
6464,
9472,
22715,
330,
65,
11755,
43782,
48410,
5240,
262,
2860,
284,
2479,
7,
33725,
340,
262,
6050,
5506,
446,
29992,
4792,
29060,
3343,
2293,
23689,
4489,
262,
369,
1661,
11,
8271,
304,
13555,
7,
33725,
997,
286,
674,
10936,
29060,
902,
617,
459,
18738,
198,
286,
422,
8271,
673,
63085,
599,
512,
310,
3136,
198,
286,
674,
312,
1275,
29060,
902,
617,
912,
3008,
278,
599,
743,
11,
719,
264,
1121,
198,
286,
422,
8271,
45401,
539,
304,
4482,
498,
2290,
10556,
310,
6492,
284,
8271,
46559,
746,
310,
6492,
1351,
1275,
1211,
746,
286,
422,
1661,
871,
220,
15,
323,
1661,
1034,
220,
2636,
15,
624,
220,
15,
512,
310,
6050,
5506,
446,
34541,
287,
312,
98573,
29060,
314,
4572,
6390,
95434,
667,
662,
2293,
8228,
11,
2860,
1192,
310,
7901,
16105,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
697,
1275,
14976,
29060,
271,
14711,
6075,
512,
755,
312,
1275,
5341,
5600,
12277,
278,
73279,
21924,
278,
997,
262,
4304,
697,
1275,
14976,
29060,
198,
262,
3270,
262,
6050,
5506,
446,
697,
1275,
14976,
29060,
1158,
262,
35202,
284,
6464,
9472,
22715,
330,
65,
11755,
43782,
48410,
5240,
262,
2860,
284,
2479,
7,
33725,
340,
262,
6050,
5506,
446,
29992,
4792,
29060,
3343,
2293,
23689,
4489,
262,
369,
1661,
11,
8271,
304,
13555,
7,
33725,
997,
286,
674,
10936,
29060,
902,
617,
459,
18738,
198,
286,
422,
8271,
673,
63085,
599,
512,
310,
3136,
198,
286,
674,
312,
1275,
29060,
902,
617,
912,
3008,
278,
599,
743,
11,
719,
264,
1121,
198,
286,
422,
8271,
45401,
539,
304,
4482,
498,
2290,
10556,
310,
6492,
284,
8271,
46559,
746,
310,
6492,
1351,
1275,
1211,
746,
286,
422,
1661,
871,
220,
15,
323,
1661,
1034,
220,
2636,
15,
624,
220,
15,
512,
310,
6050,
5506,
446,
34541,
287,
312,
98573,
29060,
314,
4572,
6390,
95434,
667,
662,
2293,
8228,
11,
2860,
1192,
310,
7901,
16105,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
elastic/elasticsearch-py | elasticsearch/client/cat.py | CatClient.shards | def shards(self, index=None, params=None):
"""
The shards command is the detailed view of what nodes contain which shards.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html>`_
:arg index: A comma-separated list of index names to limit the returned
information
:arg bytes: The unit in which to display byte values, valid choices are:
'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
:arg format: a short version of the Accept header, e.g. json, yaml
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg local: Return local information, do not retrieve the state from
master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master
node
:arg s: Comma-separated list of column names or column aliases to sort
by
:arg v: Verbose mode. Display column headers, default False
"""
return self.transport.perform_request('GET', _make_path('_cat',
'shards', index), params=params) | python | def shards(self, index=None, params=None):
"""
The shards command is the detailed view of what nodes contain which shards.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html>`_
:arg index: A comma-separated list of index names to limit the returned
information
:arg bytes: The unit in which to display byte values, valid choices are:
'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
:arg format: a short version of the Accept header, e.g. json, yaml
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg local: Return local information, do not retrieve the state from
master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master
node
:arg s: Comma-separated list of column names or column aliases to sort
by
:arg v: Verbose mode. Display column headers, default False
"""
return self.transport.perform_request('GET', _make_path('_cat',
'shards', index), params=params) | [
"def",
"shards",
"(",
"self",
",",
"index",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"return",
"self",
".",
"transport",
".",
"perform_request",
"(",
"'GET'",
",",
"_make_path",
"(",
"'_cat'",
",",
"'shards'",
",",
"index",
")",
",",
"params",
"=",
"params",
")"
] | The shards command is the detailed view of what nodes contain which shards.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html>`_
:arg index: A comma-separated list of index names to limit the returned
information
:arg bytes: The unit in which to display byte values, valid choices are:
'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
:arg format: a short version of the Accept header, e.g. json, yaml
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg local: Return local information, do not retrieve the state from
master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master
node
:arg s: Comma-separated list of column names or column aliases to sort
by
:arg v: Verbose mode. Display column headers, default False | [
"The",
"shards",
"command",
"is",
"the",
"detailed",
"view",
"of",
"what",
"nodes",
"contain",
"which",
"shards",
".",
"<https",
":",
"//",
"www",
".",
"elastic",
".",
"co",
"/",
"guide",
"/",
"en",
"/",
"elasticsearch",
"/",
"reference",
"/",
"current",
"/",
"cat",
"-",
"shards",
".",
"html",
">",
"_"
] | train | https://github.com/elastic/elasticsearch-py/blob/2aab285c8f506f3863cbdaba3c90a685c510ba00/elasticsearch/client/cat.py#L205-L226 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
The shards command is the detailed view of what nodes contain which shards.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html>`_
:arg index: A comma-separated list of index names to limit the returned
information
:arg bytes: The unit in which to display byte values, valid choices are:
'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
:arg format: a short version of the Accept header, e.g. json, yaml
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg local: Return local information, do not retrieve the state from
master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master
node
:arg s: Comma-separated list of column names or column aliases to sort
by
:arg v: Verbose mode. Display column headers, default False
### Response:
def shards(self, index=None, params=None):
"""
The shards command is the detailed view of what nodes contain which shards.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html>`_
:arg index: A comma-separated list of index names to limit the returned
information
:arg bytes: The unit in which to display byte values, valid choices are:
'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'
:arg format: a short version of the Accept header, e.g. json, yaml
:arg h: Comma-separated list of column names to display
:arg help: Return help information, default False
:arg local: Return local information, do not retrieve the state from
master node (default: false)
:arg master_timeout: Explicit operation timeout for connection to master
node
:arg s: Comma-separated list of column names or column aliases to sort
by
:arg v: Verbose mode. Display column headers, default False
"""
return self.transport.perform_request('GET', _make_path('_cat',
'shards', index), params=params)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
791,
75210,
3290,
374,
279,
11944,
1684,
315,
1148,
7954,
6782,
902,
75210,
627,
286,
31686,
2485,
1129,
2185,
16230,
5174,
6973,
4951,
35805,
13920,
89758,
28891,
66880,
75153,
93907,
7666,
2402,
2628,
44726,
19327,
286,
551,
867,
1963,
25,
362,
32783,
73792,
1160,
315,
1963,
5144,
311,
4017,
279,
6052,
198,
310,
2038,
198,
286,
551,
867,
5943,
25,
578,
5089,
304,
902,
311,
3113,
5027,
2819,
11,
2764,
11709,
527,
512,
310,
364,
65,
518,
364,
74,
518,
364,
22016,
518,
364,
76,
518,
364,
3172,
518,
364,
70,
518,
364,
9701,
518,
364,
83,
518,
364,
18894,
518,
364,
79,
518,
364,
17063,
1270,
286,
551,
867,
3645,
25,
264,
2875,
2373,
315,
279,
21496,
4342,
11,
384,
1326,
13,
3024,
11,
33346,
198,
286,
551,
867,
305,
25,
1219,
1764,
73792,
1160,
315,
3330,
5144,
311,
3113,
198,
286,
551,
867,
1520,
25,
3494,
1520,
2038,
11,
1670,
3641,
198,
286,
551,
867,
2254,
25,
3494,
2254,
2038,
11,
656,
539,
17622,
279,
1614,
505,
198,
310,
7491,
2494,
320,
2309,
25,
905,
340,
286,
551,
867,
7491,
21179,
25,
32430,
5784,
9829,
369,
3717,
311,
7491,
198,
310,
2494,
198,
286,
551,
867,
274,
25,
1219,
1764,
73792,
1160,
315,
3330,
5144,
477,
3330,
41486,
311,
3460,
198,
310,
555,
198,
286,
551,
867,
348,
25,
6383,
8461,
3941,
13,
10848,
3330,
7247,
11,
1670,
3641,
271,
14711,
6075,
512,
755,
75210,
1214,
11,
1963,
5980,
11,
3712,
5980,
997,
286,
3270,
286,
578,
75210,
3290,
374,
279,
11944,
1684,
315,
1148,
7954,
6782,
902,
75210,
627,
286,
31686,
2485,
1129,
2185,
16230,
5174,
6973,
4951,
35805,
13920,
89758,
28891,
66880,
75153,
93907,
7666,
2402,
2628,
44726,
19327,
286,
551,
867,
1963,
25,
362,
32783,
73792,
1160,
315,
1963,
5144,
311,
4017,
279,
6052,
198,
310,
2038,
198,
286,
551,
867,
5943,
25,
578,
5089,
304,
902,
311,
3113,
5027,
2819,
11,
2764,
11709,
527,
512,
310,
364,
65,
518,
364,
74,
518,
364,
22016,
518,
364,
76,
518,
364,
3172,
518,
364,
70,
518,
364,
9701,
518,
364,
83,
518,
364,
18894,
518,
364,
79,
518,
364,
17063,
1270,
286,
551,
867,
3645,
25,
264,
2875,
2373,
315,
279,
21496,
4342,
11,
384,
1326,
13,
3024,
11,
33346,
198,
286,
551,
867,
305,
25,
1219,
1764,
73792,
1160,
315,
3330,
5144,
311,
3113,
198,
286,
551,
867,
1520,
25,
3494,
1520,
2038,
11,
1670,
3641,
198,
286,
551,
867,
2254,
25,
3494,
2254,
2038,
11,
656,
539,
17622,
279,
1614,
505,
198,
310,
7491,
2494,
320,
2309,
25,
905,
340,
286,
551,
867,
7491,
21179,
25,
32430,
5784,
9829,
369,
3717,
311,
7491,
198,
310,
2494,
198,
286,
551,
867,
274,
25,
1219,
1764,
73792,
1160,
315,
3330,
5144,
477,
3330,
41486,
311,
3460,
198,
310,
555,
198,
286,
551,
867,
348,
25,
6383,
8461,
3941,
13
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
791,
75210,
3290,
374,
279,
11944,
1684,
315,
1148,
7954,
6782,
902,
75210,
627,
286,
31686,
2485,
1129,
2185,
16230,
5174,
6973,
4951,
35805,
13920,
89758,
28891,
66880,
75153,
93907,
7666,
2402,
2628,
44726,
19327,
286,
551,
867,
1963,
25,
362,
32783,
73792,
1160,
315,
1963,
5144,
311,
4017,
279,
6052,
198,
310,
2038,
198,
286,
551,
867,
5943,
25,
578,
5089,
304,
902,
311,
3113,
5027,
2819,
11,
2764,
11709,
527,
512,
310,
364,
65,
518,
364,
74,
518,
364,
22016,
518,
364,
76,
518,
364,
3172,
518,
364,
70,
518,
364,
9701,
518,
364,
83,
518,
364,
18894,
518,
364,
79,
518,
364,
17063,
1270,
286,
551,
867,
3645,
25,
264,
2875,
2373,
315,
279,
21496,
4342,
11,
384,
1326,
13,
3024,
11,
33346,
198,
286,
551,
867,
305,
25,
1219,
1764,
73792,
1160,
315,
3330,
5144,
311,
3113,
198,
286,
551,
867,
1520,
25,
3494,
1520,
2038,
11,
1670,
3641,
198,
286,
551,
867,
2254,
25,
3494,
2254,
2038,
11,
656,
539,
17622,
279,
1614,
505,
198,
310,
7491,
2494,
320,
2309,
25,
905,
340,
286,
551,
867,
7491,
21179,
25,
32430,
5784,
9829,
369,
3717,
311,
7491,
198,
310,
2494,
198,
286,
551,
867,
274,
25,
1219,
1764,
73792,
1160,
315,
3330,
5144,
477,
3330,
41486,
311,
3460,
198,
310,
555,
198,
286,
551,
867,
348,
25,
6383,
8461,
3941,
13,
10848,
3330,
7247,
11,
1670,
3641,
271,
14711,
6075,
512,
755,
75210,
1214,
11,
1963,
5980,
11,
3712,
5980,
997,
286,
3270,
286,
578,
75210,
3290,
374,
279,
11944,
1684,
315,
1148,
7954,
6782,
902,
75210,
627,
286,
31686,
2485,
1129,
2185,
16230,
5174,
6973,
4951,
35805,
13920,
89758,
28891,
66880,
75153,
93907,
7666,
2402,
2628,
44726,
19327,
286,
551,
867,
1963,
25,
362,
32783,
73792,
1160,
315,
1963,
5144,
311,
4017,
279,
6052,
198,
310,
2038,
198,
286,
551,
867,
5943,
25,
578,
5089,
304,
902,
311,
3113,
5027,
2819,
11,
2764,
11709,
527,
512,
310,
364,
65,
518,
364,
74,
518,
364,
22016,
518,
364,
76,
518,
364,
3172,
518,
364,
70,
518,
364,
9701,
518,
364,
83,
518,
364,
18894,
518,
364,
79,
518,
364,
17063,
1270,
286,
551,
867,
3645,
25,
264,
2875,
2373,
315,
279,
21496,
4342,
11,
384,
1326,
13,
3024,
11,
33346,
198,
286,
551,
867,
305,
25,
1219,
1764,
73792,
1160,
315,
3330,
5144,
311,
3113,
198,
286,
551,
867,
1520,
25,
3494,
1520,
2038,
11,
1670,
3641,
198,
286,
551,
867,
2254,
25,
3494,
2254,
2038,
11,
656,
539,
17622,
279,
1614,
505,
198,
310,
7491,
2494,
320,
2309,
25,
905,
340,
286,
551,
867,
7491,
21179,
25,
32430,
5784,
9829,
369,
3717,
311,
7491,
198,
310,
2494,
198,
286,
551,
867,
274,
25,
1219,
1764,
73792,
1160,
315,
3330,
5144,
477,
3330,
41486,
311,
3460,
198,
310,
555,
198,
286,
551,
867,
348,
25,
6383,
8461,
3941,
13
] |
EventRegistry/event-registry-python | eventregistry/QueryEvents.py | QueryEvents.initWithEventUriList | def initWithEventUriList(uriList):
"""
Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored).
"""
q = QueryEvents()
assert isinstance(uriList, list), "uriList has to be a list of strings that represent event uris"
q.queryParams = { "action": "getEvents", "eventUriList": ",".join(uriList) }
return q | python | def initWithEventUriList(uriList):
"""
Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored).
"""
q = QueryEvents()
assert isinstance(uriList, list), "uriList has to be a list of strings that represent event uris"
q.queryParams = { "action": "getEvents", "eventUriList": ",".join(uriList) }
return q | [
"def",
"initWithEventUriList",
"(",
"uriList",
")",
":",
"q",
"=",
"QueryEvents",
"(",
")",
"assert",
"isinstance",
"(",
"uriList",
",",
"list",
")",
",",
"\"uriList has to be a list of strings that represent event uris\"",
"q",
".",
"queryParams",
"=",
"{",
"\"action\"",
":",
"\"getEvents\"",
",",
"\"eventUriList\"",
":",
"\",\"",
".",
"join",
"(",
"uriList",
")",
"}",
"return",
"q"
] | Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored). | [
"Set",
"a",
"custom",
"list",
"of",
"event",
"uris",
".",
"The",
"results",
"will",
"be",
"then",
"computed",
"on",
"this",
"list",
"-",
"no",
"query",
"will",
"be",
"done",
"(",
"all",
"conditions",
"will",
"be",
"ignored",
")",
"."
] | train | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/QueryEvents.py#L161-L168 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored).
### Response:
def initWithEventUriList(uriList):
"""
Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored).
"""
q = QueryEvents()
assert isinstance(uriList, list), "uriList has to be a list of strings that represent event uris"
q.queryParams = { "action": "getEvents", "eventUriList": ",".join(uriList) }
return q
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1681,
264,
2587,
1160,
315,
1567,
4433,
285,
13,
578,
3135,
690,
387,
1243,
25157,
389,
420,
1160,
482,
912,
3319,
690,
387,
2884,
320,
543,
4787,
690,
387,
12305,
3677,
14711,
6075,
512,
755,
14186,
1585,
14223,
861,
26882,
861,
997,
286,
3270,
286,
2638,
264,
2587,
1160,
315,
1567,
4433,
285,
13,
578,
3135,
690,
387,
1243,
25157,
389,
420,
1160,
482,
912,
3319,
690,
387,
2884,
320,
543,
4787,
690,
387,
12305,
4390,
286,
3270,
286,
2874,
284,
11615,
8059,
746,
286,
2105,
11656,
26882,
861,
11,
1160,
705,
330,
6198,
861,
706,
311,
387,
264,
1160,
315,
9246,
430,
4097,
1567,
4433,
285,
702,
286,
2874,
4891,
4975,
284,
314,
330,
1335,
794,
330,
456,
8059,
498,
330,
3163,
14223,
861,
794,
15923,
13,
6115,
26882,
861,
8,
457,
286,
471,
2874,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1681,
264,
2587,
1160,
315,
1567,
4433,
285,
13,
578,
3135,
690,
387,
1243,
25157,
389,
420,
1160,
482,
912,
3319,
690,
387,
2884,
320,
543,
4787,
690,
387,
12305,
3677,
14711,
6075,
512,
755,
14186,
1585,
14223,
861,
26882,
861,
997,
286,
3270,
286,
2638,
264,
2587,
1160,
315,
1567,
4433,
285,
13,
578,
3135,
690,
387,
1243,
25157,
389,
420,
1160,
482,
912,
3319,
690,
387,
2884,
320,
543,
4787,
690,
387,
12305,
4390,
286,
3270,
286,
2874,
284,
11615,
8059,
746,
286,
2105,
11656,
26882,
861,
11,
1160,
705,
330,
6198,
861,
706,
311,
387,
264,
1160,
315,
9246,
430,
4097,
1567,
4433,
285,
702,
286,
2874,
4891,
4975,
284,
314,
330,
1335,
794,
330,
456,
8059,
498,
330,
3163,
14223,
861,
794,
15923,
13,
6115,
26882,
861,
8,
457,
286,
471,
2874,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
ml4ai/delphi | delphi/GrFN/networks.py | GroundedFunctionNetwork.to_call_agraph | def to_call_agraph(self):
""" Build a PyGraphviz AGraph object corresponding to a call graph of
functions. """
A = nx.nx_agraph.to_agraph(self.call_graph)
A.graph_attr.update({"dpi": 227, "fontsize": 20, "fontname": "Menlo"})
A.node_attr.update(
{"shape": "rectangle", "color": "#650021", "style": "rounded"}
)
A.edge_attr.update({"color": "#650021", "arrowsize": 0.5})
return A | python | def to_call_agraph(self):
""" Build a PyGraphviz AGraph object corresponding to a call graph of
functions. """
A = nx.nx_agraph.to_agraph(self.call_graph)
A.graph_attr.update({"dpi": 227, "fontsize": 20, "fontname": "Menlo"})
A.node_attr.update(
{"shape": "rectangle", "color": "#650021", "style": "rounded"}
)
A.edge_attr.update({"color": "#650021", "arrowsize": 0.5})
return A | [
"def",
"to_call_agraph",
"(",
"self",
")",
":",
"A",
"=",
"nx",
".",
"nx_agraph",
".",
"to_agraph",
"(",
"self",
".",
"call_graph",
")",
"A",
".",
"graph_attr",
".",
"update",
"(",
"{",
"\"dpi\"",
":",
"227",
",",
"\"fontsize\"",
":",
"20",
",",
"\"fontname\"",
":",
"\"Menlo\"",
"}",
")",
"A",
".",
"node_attr",
".",
"update",
"(",
"{",
"\"shape\"",
":",
"\"rectangle\"",
",",
"\"color\"",
":",
"\"#650021\"",
",",
"\"style\"",
":",
"\"rounded\"",
"}",
")",
"A",
".",
"edge_attr",
".",
"update",
"(",
"{",
"\"color\"",
":",
"\"#650021\"",
",",
"\"arrowsize\"",
":",
"0.5",
"}",
")",
"return",
"A"
] | Build a PyGraphviz AGraph object corresponding to a call graph of
functions. | [
"Build",
"a",
"PyGraphviz",
"AGraph",
"object",
"corresponding",
"to",
"a",
"call",
"graph",
"of",
"functions",
"."
] | train | https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/delphi/GrFN/networks.py#L641-L651 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Build a PyGraphviz AGraph object corresponding to a call graph of
functions.
### Response:
def to_call_agraph(self):
""" Build a PyGraphviz AGraph object corresponding to a call graph of
functions. """
A = nx.nx_agraph.to_agraph(self.call_graph)
A.graph_attr.update({"dpi": 227, "fontsize": 20, "fontname": "Menlo"})
A.node_attr.update(
{"shape": "rectangle", "color": "#650021", "style": "rounded"}
)
A.edge_attr.update({"color": "#650021", "arrowsize": 0.5})
return A
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
11313,
264,
5468,
11461,
70940,
362,
11461,
1665,
12435,
311,
264,
1650,
4876,
315,
198,
286,
5865,
382,
14711,
6075,
512,
755,
311,
13735,
62,
9398,
1214,
997,
286,
4304,
8012,
264,
5468,
11461,
70940,
362,
11461,
1665,
12435,
311,
264,
1650,
4876,
315,
198,
286,
5865,
13,
12713,
286,
362,
284,
25508,
1276,
87,
62,
9398,
2446,
62,
9398,
1214,
8692,
15080,
340,
286,
362,
10996,
10639,
5430,
17289,
79129,
794,
220,
14206,
11,
330,
46901,
794,
220,
508,
11,
330,
4115,
609,
794,
330,
29819,
385,
24546,
286,
362,
12368,
10639,
5430,
1021,
310,
5324,
12510,
794,
330,
56416,
498,
330,
3506,
794,
5993,
13655,
11592,
498,
330,
3612,
794,
330,
45091,
17122,
286,
1763,
286,
362,
55366,
10639,
5430,
17289,
3506,
794,
5993,
13655,
11592,
498,
330,
277,
1849,
553,
794,
220,
15,
13,
20,
3602,
286,
471,
362,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
11313,
264,
5468,
11461,
70940,
362,
11461,
1665,
12435,
311,
264,
1650,
4876,
315,
198,
286,
5865,
382,
14711,
6075,
512,
755,
311,
13735,
62,
9398,
1214,
997,
286,
4304,
8012,
264,
5468,
11461,
70940,
362,
11461,
1665,
12435,
311,
264,
1650,
4876,
315,
198,
286,
5865,
13,
12713,
286,
362,
284,
25508,
1276,
87,
62,
9398,
2446,
62,
9398,
1214,
8692,
15080,
340,
286,
362,
10996,
10639,
5430,
17289,
79129,
794,
220,
14206,
11,
330,
46901,
794,
220,
508,
11,
330,
4115,
609,
794,
330,
29819,
385,
24546,
286,
362,
12368,
10639,
5430,
1021,
310,
5324,
12510,
794,
330,
56416,
498,
330,
3506,
794,
5993,
13655,
11592,
498,
330,
3612,
794,
330,
45091,
17122,
286,
1763,
286,
362,
55366,
10639,
5430,
17289,
3506,
794,
5993,
13655,
11592,
498,
330,
277,
1849,
553,
794,
220,
15,
13,
20,
3602,
286,
471,
362,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
supercoderz/pyflightdata | pyflightdata/flightdata.py | FlightData.get_airport_metars_hist | def get_airport_metars_hist(self, iata):
"""Retrieve the metar data for past 72 hours. The data will not be parsed to readable format.
Given the IATA code of an airport, this method returns the metar information for last 72 hours.
Args:
iata (str): The IATA code for an airport, e.g. HYD
Returns:
The metar data for the airport
Example::
from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_metars_hist('HYD')
"""
url = AIRPORT_BASE.format(iata) + "/weather"
return self._fr24.get_airport_metars_hist(url) | python | def get_airport_metars_hist(self, iata):
"""Retrieve the metar data for past 72 hours. The data will not be parsed to readable format.
Given the IATA code of an airport, this method returns the metar information for last 72 hours.
Args:
iata (str): The IATA code for an airport, e.g. HYD
Returns:
The metar data for the airport
Example::
from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_metars_hist('HYD')
"""
url = AIRPORT_BASE.format(iata) + "/weather"
return self._fr24.get_airport_metars_hist(url) | [
"def",
"get_airport_metars_hist",
"(",
"self",
",",
"iata",
")",
":",
"url",
"=",
"AIRPORT_BASE",
".",
"format",
"(",
"iata",
")",
"+",
"\"/weather\"",
"return",
"self",
".",
"_fr24",
".",
"get_airport_metars_hist",
"(",
"url",
")"
] | Retrieve the metar data for past 72 hours. The data will not be parsed to readable format.
Given the IATA code of an airport, this method returns the metar information for last 72 hours.
Args:
iata (str): The IATA code for an airport, e.g. HYD
Returns:
The metar data for the airport
Example::
from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_metars_hist('HYD') | [
"Retrieve",
"the",
"metar",
"data",
"for",
"past",
"72",
"hours",
".",
"The",
"data",
"will",
"not",
"be",
"parsed",
"to",
"readable",
"format",
"."
] | train | https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L299-L320 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Retrieve the metar data for past 72 hours. The data will not be parsed to readable format.
Given the IATA code of an airport, this method returns the metar information for last 72 hours.
Args:
iata (str): The IATA code for an airport, e.g. HYD
Returns:
The metar data for the airport
Example::
from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_metars_hist('HYD')
### Response:
def get_airport_metars_hist(self, iata):
"""Retrieve the metar data for past 72 hours. The data will not be parsed to readable format.
Given the IATA code of an airport, this method returns the metar information for last 72 hours.
Args:
iata (str): The IATA code for an airport, e.g. HYD
Returns:
The metar data for the airport
Example::
from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_metars_hist('HYD')
"""
url = AIRPORT_BASE.format(iata) + "/weather"
return self._fr24.get_airport_metars_hist(url)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
88765,
279,
2322,
277,
828,
369,
3347,
220,
5332,
4207,
13,
578,
828,
690,
539,
387,
16051,
311,
34898,
3645,
382,
286,
16644,
279,
358,
4586,
2082,
315,
459,
17149,
11,
420,
1749,
4780,
279,
2322,
277,
2038,
369,
1566,
220,
5332,
4207,
382,
286,
18161,
512,
310,
602,
460,
320,
496,
1680,
578,
358,
4586,
2082,
369,
459,
17149,
11,
384,
1326,
13,
64352,
35,
271,
286,
5295,
512,
310,
578,
2322,
277,
828,
369,
279,
17149,
271,
286,
13688,
66152,
310,
505,
4611,
39490,
695,
1179,
27675,
1061,
198,
310,
282,
28,
46405,
1061,
746,
310,
674,
13099,
5982,
198,
310,
282,
14011,
14267,
2386,
13387,
1100,
1979,
340,
310,
282,
673,
51927,
403,
45617,
1590,
37499,
493,
49952,
35,
4713,
14711,
6075,
512,
755,
636,
51927,
403,
45617,
1590,
37499,
1214,
11,
602,
460,
997,
286,
4304,
88765,
279,
2322,
277,
828,
369,
3347,
220,
5332,
4207,
13,
578,
828,
690,
539,
387,
16051,
311,
34898,
3645,
382,
286,
16644,
279,
358,
4586,
2082,
315,
459,
17149,
11,
420,
1749,
4780,
279,
2322,
277,
2038,
369,
1566,
220,
5332,
4207,
382,
286,
18161,
512,
310,
602,
460,
320,
496,
1680,
578,
358,
4586,
2082,
369,
459,
17149,
11,
384,
1326,
13,
64352,
35,
271,
286,
5295,
512,
310,
578,
2322,
277,
828,
369,
279,
17149,
271,
286,
13688,
66152,
310,
505,
4611,
39490,
695,
1179,
27675,
1061,
198,
310,
282,
28,
46405,
1061,
746,
310,
674,
13099,
5982,
198,
310,
282,
14011,
14267,
2386,
13387,
1100,
1979,
340,
310,
282,
673,
51927,
403,
45617,
1590,
37499,
493,
49952,
35,
4713,
286,
3270,
286,
2576,
284,
46994,
5205,
12024,
8180,
1998,
460,
8,
489,
3605,
15561,
702,
286,
471,
659,
1462,
1658,
1187,
673,
51927,
403,
45617,
1590,
37499,
6659,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
88765,
279,
2322,
277,
828,
369,
3347,
220,
5332,
4207,
13,
578,
828,
690,
539,
387,
16051,
311,
34898,
3645,
382,
286,
16644,
279,
358,
4586,
2082,
315,
459,
17149,
11,
420,
1749,
4780,
279,
2322,
277,
2038,
369,
1566,
220,
5332,
4207,
382,
286,
18161,
512,
310,
602,
460,
320,
496,
1680,
578,
358,
4586,
2082,
369,
459,
17149,
11,
384,
1326,
13,
64352,
35,
271,
286,
5295,
512,
310,
578,
2322,
277,
828,
369,
279,
17149,
271,
286,
13688,
66152,
310,
505,
4611,
39490,
695,
1179,
27675,
1061,
198,
310,
282,
28,
46405,
1061,
746,
310,
674,
13099,
5982,
198,
310,
282,
14011,
14267,
2386,
13387,
1100,
1979,
340,
310,
282,
673,
51927,
403,
45617,
1590,
37499,
493,
49952,
35,
4713,
14711,
6075,
512,
755,
636,
51927,
403,
45617,
1590,
37499,
1214,
11,
602,
460,
997,
286,
4304,
88765,
279,
2322,
277,
828,
369,
3347,
220,
5332,
4207,
13,
578,
828,
690,
539,
387,
16051,
311,
34898,
3645,
382,
286,
16644,
279,
358,
4586,
2082,
315,
459,
17149,
11,
420,
1749,
4780,
279,
2322,
277,
2038,
369,
1566,
220,
5332,
4207,
382,
286,
18161,
512,
310,
602,
460,
320,
496,
1680,
578,
358,
4586,
2082,
369,
459,
17149,
11,
384,
1326,
13,
64352,
35,
271,
286,
5295,
512,
310,
578,
2322,
277,
828,
369,
279,
17149,
271,
286,
13688,
66152,
310,
505,
4611,
39490,
695,
1179,
27675,
1061,
198,
310,
282,
28,
46405,
1061,
746,
310,
674,
13099,
5982,
198,
310,
282,
14011,
14267,
2386,
13387,
1100,
1979,
340,
310,
282,
673,
51927,
403,
45617,
1590,
37499,
493,
49952,
35,
4713,
286,
3270,
286,
2576,
284,
46994,
5205,
12024,
8180,
1998,
460,
8,
489,
3605,
15561,
702,
286,
471,
659,
1462,
1658,
1187,
673,
51927,
403,
45617,
1590,
37499,
6659,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
avanwyk/cipy | cipy/algorithms/pso/functions.py | gbest_idx | def gbest_idx(swarm):
""" gbest Neighbourhood topology function.
Args:
swarm: list: The list of particles.
Returns:
int: The index of the gbest particle.
"""
best = 0
cmp = comparator(swarm[best].best_fitness)
for (idx, particle) in enumerate(swarm):
if cmp(particle.best_fitness, swarm[best].best_fitness):
best = idx
return best | python | def gbest_idx(swarm):
""" gbest Neighbourhood topology function.
Args:
swarm: list: The list of particles.
Returns:
int: The index of the gbest particle.
"""
best = 0
cmp = comparator(swarm[best].best_fitness)
for (idx, particle) in enumerate(swarm):
if cmp(particle.best_fitness, swarm[best].best_fitness):
best = idx
return best | [
"def",
"gbest_idx",
"(",
"swarm",
")",
":",
"best",
"=",
"0",
"cmp",
"=",
"comparator",
"(",
"swarm",
"[",
"best",
"]",
".",
"best_fitness",
")",
"for",
"(",
"idx",
",",
"particle",
")",
"in",
"enumerate",
"(",
"swarm",
")",
":",
"if",
"cmp",
"(",
"particle",
".",
"best_fitness",
",",
"swarm",
"[",
"best",
"]",
".",
"best_fitness",
")",
":",
"best",
"=",
"idx",
"return",
"best"
] | gbest Neighbourhood topology function.
Args:
swarm: list: The list of particles.
Returns:
int: The index of the gbest particle. | [
"gbest",
"Neighbourhood",
"topology",
"function",
"."
] | train | https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L202-L216 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
gbest Neighbourhood topology function.
Args:
swarm: list: The list of particles.
Returns:
int: The index of the gbest particle.
### Response:
def gbest_idx(swarm):
""" gbest Neighbourhood topology function.
Args:
swarm: list: The list of particles.
Returns:
int: The index of the gbest particle.
"""
best = 0
cmp = comparator(swarm[best].best_fitness)
for (idx, particle) in enumerate(swarm):
if cmp(particle.best_fitness, swarm[best].best_fitness):
best = idx
return best
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
9701,
478,
4275,
47918,
5812,
45982,
734,
382,
262,
18161,
512,
286,
61941,
25,
1160,
25,
578,
1160,
315,
19252,
382,
262,
5295,
512,
286,
528,
25,
578,
1963,
315,
279,
342,
16241,
19320,
382,
14711,
6075,
512,
755,
342,
16241,
7406,
60002,
2227,
997,
262,
4304,
342,
16241,
4275,
47918,
5812,
45982,
734,
382,
262,
18161,
512,
286,
61941,
25,
1160,
25,
578,
1160,
315,
19252,
382,
262,
5295,
512,
286,
528,
25,
578,
1963,
315,
279,
342,
16241,
19320,
627,
262,
3270,
262,
1888,
284,
220,
15,
198,
262,
27181,
284,
53140,
60002,
2227,
58,
16241,
948,
16241,
86446,
340,
262,
369,
320,
6495,
11,
19320,
8,
304,
13555,
60002,
2227,
997,
286,
422,
27181,
1319,
7203,
52376,
86446,
11,
61941,
58,
16241,
948,
16241,
86446,
997,
310,
1888,
284,
7335,
198,
262,
471,
1888,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
9701,
478,
4275,
47918,
5812,
45982,
734,
382,
262,
18161,
512,
286,
61941,
25,
1160,
25,
578,
1160,
315,
19252,
382,
262,
5295,
512,
286,
528,
25,
578,
1963,
315,
279,
342,
16241,
19320,
382,
14711,
6075,
512,
755,
342,
16241,
7406,
60002,
2227,
997,
262,
4304,
342,
16241,
4275,
47918,
5812,
45982,
734,
382,
262,
18161,
512,
286,
61941,
25,
1160,
25,
578,
1160,
315,
19252,
382,
262,
5295,
512,
286,
528,
25,
578,
1963,
315,
279,
342,
16241,
19320,
627,
262,
3270,
262,
1888,
284,
220,
15,
198,
262,
27181,
284,
53140,
60002,
2227,
58,
16241,
948,
16241,
86446,
340,
262,
369,
320,
6495,
11,
19320,
8,
304,
13555,
60002,
2227,
997,
286,
422,
27181,
1319,
7203,
52376,
86446,
11,
61941,
58,
16241,
948,
16241,
86446,
997,
310,
1888,
284,
7335,
198,
262,
471,
1888,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
watson-developer-cloud/python-sdk | ibm_watson/text_to_speech_v1.py | Pronunciation._to_dict | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'pronunciation') and self.pronunciation is not None:
_dict['pronunciation'] = self.pronunciation
return _dict | python | def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'pronunciation') and self.pronunciation is not None:
_dict['pronunciation'] = self.pronunciation
return _dict | [
"def",
"_to_dict",
"(",
"self",
")",
":",
"_dict",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"self",
",",
"'pronunciation'",
")",
"and",
"self",
".",
"pronunciation",
"is",
"not",
"None",
":",
"_dict",
"[",
"'pronunciation'",
"]",
"=",
"self",
".",
"pronunciation",
"return",
"_dict"
] | Return a json dictionary representing this model. | [
"Return",
"a",
"json",
"dictionary",
"representing",
"this",
"model",
"."
] | train | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/text_to_speech_v1.py#L932-L937 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return a json dictionary representing this model.
### Response:
def _to_dict(self):
"""Return a json dictionary representing this model."""
_dict = {}
if hasattr(self, 'pronunciation') and self.pronunciation is not None:
_dict['pronunciation'] = self.pronunciation
return _dict
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
264,
3024,
11240,
14393,
420,
1646,
382,
14711,
6075,
512,
755,
721,
998,
5356,
1214,
997,
286,
4304,
5715,
264,
3024,
11240,
14393,
420,
1646,
14781,
286,
721,
8644,
284,
5731,
286,
422,
32156,
1214,
11,
364,
72239,
47410,
873,
323,
659,
558,
2298,
47410,
374,
539,
2290,
512,
310,
721,
8644,
681,
72239,
47410,
663,
284,
659,
558,
2298,
47410,
198,
286,
471,
721,
8644,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
264,
3024,
11240,
14393,
420,
1646,
382,
14711,
6075,
512,
755,
721,
998,
5356,
1214,
997,
286,
4304,
5715,
264,
3024,
11240,
14393,
420,
1646,
14781,
286,
721,
8644,
284,
5731,
286,
422,
32156,
1214,
11,
364,
72239,
47410,
873,
323,
659,
558,
2298,
47410,
374,
539,
2290,
512,
310,
721,
8644,
681,
72239,
47410,
663,
284,
659,
558,
2298,
47410,
198,
286,
471,
721,
8644,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
davenquinn/Attitude | attitude/stereonet.py | iterative_plane_errors | def iterative_plane_errors(axes,covariance_matrix, **kwargs):
"""
An iterative version of `pca.plane_errors`,
which computes an error surface for a plane.
"""
sheet = kwargs.pop('sheet','upper')
level = kwargs.pop('level',1)
n = kwargs.pop('n',100)
cov = N.sqrt(N.diagonal(covariance_matrix))
u = N.linspace(0, 2*N.pi, n)
scales = dict(upper=1,lower=-1,nominal=0)
c1 = scales[sheet]
c1 *= -1 # We assume upper hemisphere
if axes[2,2] < 0:
c1 *= -1
def sdot(a,b):
return sum([i*j for i,j in zip(a,b)])
def step_func(a):
e = [
N.cos(a)*cov[0],
N.sin(a)*cov[1],
c1*cov[2]]
d = [sdot(e,i)
for i in axes.T]
x,y,z = d[2],d[0],d[1]
r = N.sqrt(x**2 + y**2 + z**2)
lat = N.arcsin(z/r)
lon = N.arctan2(y, x)
return lon,lat
# Get a bundle of vectors defining
# a full rotation around the unit circle
return N.array([step_func(i)
for i in u]) | python | def iterative_plane_errors(axes,covariance_matrix, **kwargs):
"""
An iterative version of `pca.plane_errors`,
which computes an error surface for a plane.
"""
sheet = kwargs.pop('sheet','upper')
level = kwargs.pop('level',1)
n = kwargs.pop('n',100)
cov = N.sqrt(N.diagonal(covariance_matrix))
u = N.linspace(0, 2*N.pi, n)
scales = dict(upper=1,lower=-1,nominal=0)
c1 = scales[sheet]
c1 *= -1 # We assume upper hemisphere
if axes[2,2] < 0:
c1 *= -1
def sdot(a,b):
return sum([i*j for i,j in zip(a,b)])
def step_func(a):
e = [
N.cos(a)*cov[0],
N.sin(a)*cov[1],
c1*cov[2]]
d = [sdot(e,i)
for i in axes.T]
x,y,z = d[2],d[0],d[1]
r = N.sqrt(x**2 + y**2 + z**2)
lat = N.arcsin(z/r)
lon = N.arctan2(y, x)
return lon,lat
# Get a bundle of vectors defining
# a full rotation around the unit circle
return N.array([step_func(i)
for i in u]) | [
"def",
"iterative_plane_errors",
"(",
"axes",
",",
"covariance_matrix",
",",
"*",
"*",
"kwargs",
")",
":",
"sheet",
"=",
"kwargs",
".",
"pop",
"(",
"'sheet'",
",",
"'upper'",
")",
"level",
"=",
"kwargs",
".",
"pop",
"(",
"'level'",
",",
"1",
")",
"n",
"=",
"kwargs",
".",
"pop",
"(",
"'n'",
",",
"100",
")",
"cov",
"=",
"N",
".",
"sqrt",
"(",
"N",
".",
"diagonal",
"(",
"covariance_matrix",
")",
")",
"u",
"=",
"N",
".",
"linspace",
"(",
"0",
",",
"2",
"*",
"N",
".",
"pi",
",",
"n",
")",
"scales",
"=",
"dict",
"(",
"upper",
"=",
"1",
",",
"lower",
"=",
"-",
"1",
",",
"nominal",
"=",
"0",
")",
"c1",
"=",
"scales",
"[",
"sheet",
"]",
"c1",
"*=",
"-",
"1",
"# We assume upper hemisphere",
"if",
"axes",
"[",
"2",
",",
"2",
"]",
"<",
"0",
":",
"c1",
"*=",
"-",
"1",
"def",
"sdot",
"(",
"a",
",",
"b",
")",
":",
"return",
"sum",
"(",
"[",
"i",
"*",
"j",
"for",
"i",
",",
"j",
"in",
"zip",
"(",
"a",
",",
"b",
")",
"]",
")",
"def",
"step_func",
"(",
"a",
")",
":",
"e",
"=",
"[",
"N",
".",
"cos",
"(",
"a",
")",
"*",
"cov",
"[",
"0",
"]",
",",
"N",
".",
"sin",
"(",
"a",
")",
"*",
"cov",
"[",
"1",
"]",
",",
"c1",
"*",
"cov",
"[",
"2",
"]",
"]",
"d",
"=",
"[",
"sdot",
"(",
"e",
",",
"i",
")",
"for",
"i",
"in",
"axes",
".",
"T",
"]",
"x",
",",
"y",
",",
"z",
"=",
"d",
"[",
"2",
"]",
",",
"d",
"[",
"0",
"]",
",",
"d",
"[",
"1",
"]",
"r",
"=",
"N",
".",
"sqrt",
"(",
"x",
"**",
"2",
"+",
"y",
"**",
"2",
"+",
"z",
"**",
"2",
")",
"lat",
"=",
"N",
".",
"arcsin",
"(",
"z",
"/",
"r",
")",
"lon",
"=",
"N",
".",
"arctan2",
"(",
"y",
",",
"x",
")",
"return",
"lon",
",",
"lat",
"# Get a bundle of vectors defining",
"# a full rotation around the unit circle",
"return",
"N",
".",
"array",
"(",
"[",
"step_func",
"(",
"i",
")",
"for",
"i",
"in",
"u",
"]",
")"
] | An iterative version of `pca.plane_errors`,
which computes an error surface for a plane. | [
"An",
"iterative",
"version",
"of",
"pca",
".",
"plane_errors",
"which",
"computes",
"an",
"error",
"surface",
"for",
"a",
"plane",
"."
] | train | https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/attitude/stereonet.py#L156-L193 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
An iterative version of `pca.plane_errors`,
which computes an error surface for a plane.
### Response:
def iterative_plane_errors(axes,covariance_matrix, **kwargs):
"""
An iterative version of `pca.plane_errors`,
which computes an error surface for a plane.
"""
sheet = kwargs.pop('sheet','upper')
level = kwargs.pop('level',1)
n = kwargs.pop('n',100)
cov = N.sqrt(N.diagonal(covariance_matrix))
u = N.linspace(0, 2*N.pi, n)
scales = dict(upper=1,lower=-1,nominal=0)
c1 = scales[sheet]
c1 *= -1 # We assume upper hemisphere
if axes[2,2] < 0:
c1 *= -1
def sdot(a,b):
return sum([i*j for i,j in zip(a,b)])
def step_func(a):
e = [
N.cos(a)*cov[0],
N.sin(a)*cov[1],
c1*cov[2]]
d = [sdot(e,i)
for i in axes.T]
x,y,z = d[2],d[0],d[1]
r = N.sqrt(x**2 + y**2 + z**2)
lat = N.arcsin(z/r)
lon = N.arctan2(y, x)
return lon,lat
# Get a bundle of vectors defining
# a full rotation around the unit circle
return N.array([step_func(i)
for i in u])
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2127,
87975,
2373,
315,
1595,
79,
936,
8022,
2194,
20808,
13188,
262,
902,
58303,
459,
1493,
7479,
369,
264,
11277,
382,
14711,
6075,
512,
755,
87975,
47123,
20808,
7,
20589,
10317,
869,
38005,
10403,
11,
3146,
9872,
997,
262,
3270,
262,
1556,
87975,
2373,
315,
1595,
79,
936,
8022,
2194,
20808,
13188,
262,
902,
58303,
459,
1493,
7479,
369,
264,
11277,
627,
262,
3270,
262,
11071,
284,
16901,
8452,
493,
15470,
1882,
13886,
1329,
262,
2237,
284,
16901,
8452,
493,
3374,
518,
16,
340,
262,
308,
284,
16901,
8452,
493,
77,
518,
1041,
696,
262,
22590,
284,
452,
18540,
8368,
31280,
24346,
1361,
869,
38005,
10403,
1192,
262,
577,
284,
452,
39812,
7,
15,
11,
220,
17,
45729,
25244,
11,
308,
696,
262,
29505,
284,
6587,
7,
13886,
28,
16,
11,
15115,
11065,
16,
10337,
316,
992,
28,
15,
340,
262,
272,
16,
284,
29505,
12144,
3759,
933,
262,
272,
16,
11658,
482,
16,
674,
1226,
9855,
8582,
69766,
198,
262,
422,
25776,
58,
17,
11,
17,
60,
366,
220,
15,
512,
286,
272,
16,
11658,
482,
16,
271,
262,
711,
274,
16510,
2948,
8568,
997,
286,
471,
2694,
2625,
72,
55145,
369,
602,
10540,
304,
10521,
2948,
8568,
68964,
262,
711,
3094,
9791,
2948,
997,
286,
384,
284,
2330,
310,
452,
21832,
2948,
4911,
57512,
58,
15,
1282,
310,
452,
16719,
2948,
4911,
57512,
58,
16,
1282,
310,
272,
16,
40191,
869,
58,
17,
14623,
286,
294,
284,
510,
13752,
354,
2069,
11538,
340,
310,
369,
602,
304,
25776,
844,
933,
286,
865,
7509,
23500,
284,
294,
58,
17,
1145,
67,
58,
15,
1145,
67,
58,
16,
933,
286,
436,
284,
452,
18540,
2120,
334,
17,
489,
379,
334,
17,
489,
1167,
334,
17,
340,
286,
6987,
284,
452,
17126,
4942,
258,
13476,
7534,
340,
286,
18285,
284,
452,
17126,
302,
276,
17,
7166,
11,
865,
340,
286,
471,
18285,
72583,
271,
262,
674,
2175,
264,
13190,
315,
23728,
27409,
198,
262,
674,
264,
2539,
12984,
2212,
279,
5089,
12960,
198,
262,
471,
452,
7382,
2625,
9710,
9791,
1998,
340,
286,
369,
602,
304,
577,
2608,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2127,
87975,
2373,
315,
1595,
79,
936,
8022,
2194,
20808,
13188,
262,
902,
58303,
459,
1493,
7479,
369,
264,
11277,
382,
14711,
6075,
512,
755,
87975,
47123,
20808,
7,
20589,
10317,
869,
38005,
10403,
11,
3146,
9872,
997,
262,
3270,
262,
1556,
87975,
2373,
315,
1595,
79,
936,
8022,
2194,
20808,
13188,
262,
902,
58303,
459,
1493,
7479,
369,
264,
11277,
627,
262,
3270,
262,
11071,
284,
16901,
8452,
493,
15470,
1882,
13886,
1329,
262,
2237,
284,
16901,
8452,
493,
3374,
518,
16,
340,
262,
308,
284,
16901,
8452,
493,
77,
518,
1041,
696,
262,
22590,
284,
452,
18540,
8368,
31280,
24346,
1361,
869,
38005,
10403,
1192,
262,
577,
284,
452,
39812,
7,
15,
11,
220,
17,
45729,
25244,
11,
308,
696,
262,
29505,
284,
6587,
7,
13886,
28,
16,
11,
15115,
11065,
16,
10337,
316,
992,
28,
15,
340,
262,
272,
16,
284,
29505,
12144,
3759,
933,
262,
272,
16,
11658,
482,
16,
674,
1226,
9855,
8582,
69766,
198,
262,
422,
25776,
58,
17,
11,
17,
60,
366,
220,
15,
512,
286,
272,
16,
11658,
482,
16,
271,
262,
711,
274,
16510,
2948,
8568,
997,
286,
471,
2694,
2625,
72,
55145,
369,
602,
10540,
304,
10521,
2948,
8568,
68964,
262,
711,
3094,
9791,
2948,
997,
286,
384,
284,
2330,
310,
452,
21832,
2948,
4911,
57512,
58,
15,
1282,
310,
452,
16719,
2948,
4911,
57512,
58,
16,
1282,
310,
272,
16,
40191,
869,
58,
17,
14623,
286,
294,
284,
510,
13752,
354,
2069,
11538,
340,
310,
369,
602,
304,
25776,
844,
933,
286,
865,
7509,
23500,
284,
294,
58,
17,
1145,
67,
58,
15,
1145,
67,
58,
16,
933,
286,
436,
284,
452,
18540,
2120,
334,
17,
489,
379,
334,
17,
489,
1167,
334,
17,
340,
286,
6987,
284,
452,
17126,
4942,
258,
13476,
7534,
340,
286,
18285,
284,
452,
17126,
302,
276,
17,
7166,
11,
865,
340,
286,
471,
18285,
72583,
271,
262,
674,
2175,
264,
13190,
315,
23728,
27409,
198,
262,
674,
264,
2539,
12984,
2212,
279,
5089,
12960,
198,
262,
471,
452,
7382,
2625,
9710,
9791,
1998,
340,
286,
369,
602,
304,
577,
2608,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pantsbuild/pex | pex/vendor/_vendored/wheel/wheel/metadata.py | pkginfo_unicode | def pkginfo_unicode(pkg_info, field):
"""Hack to coax Unicode out of an email Message() - Python 3.3+"""
text = pkg_info[field]
field = field.lower()
if not isinstance(text, str):
if not hasattr(pkg_info, 'raw_items'): # Python 3.2
return str(text)
for item in pkg_info.raw_items():
if item[0].lower() == field:
text = item[1].encode('ascii', 'surrogateescape') \
.decode('utf-8')
break
return text | python | def pkginfo_unicode(pkg_info, field):
"""Hack to coax Unicode out of an email Message() - Python 3.3+"""
text = pkg_info[field]
field = field.lower()
if not isinstance(text, str):
if not hasattr(pkg_info, 'raw_items'): # Python 3.2
return str(text)
for item in pkg_info.raw_items():
if item[0].lower() == field:
text = item[1].encode('ascii', 'surrogateescape') \
.decode('utf-8')
break
return text | [
"def",
"pkginfo_unicode",
"(",
"pkg_info",
",",
"field",
")",
":",
"text",
"=",
"pkg_info",
"[",
"field",
"]",
"field",
"=",
"field",
".",
"lower",
"(",
")",
"if",
"not",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"if",
"not",
"hasattr",
"(",
"pkg_info",
",",
"'raw_items'",
")",
":",
"# Python 3.2",
"return",
"str",
"(",
"text",
")",
"for",
"item",
"in",
"pkg_info",
".",
"raw_items",
"(",
")",
":",
"if",
"item",
"[",
"0",
"]",
".",
"lower",
"(",
")",
"==",
"field",
":",
"text",
"=",
"item",
"[",
"1",
"]",
".",
"encode",
"(",
"'ascii'",
",",
"'surrogateescape'",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"break",
"return",
"text"
] | Hack to coax Unicode out of an email Message() - Python 3.3+ | [
"Hack",
"to",
"coax",
"Unicode",
"out",
"of",
"an",
"email",
"Message",
"()",
"-",
"Python",
"3",
".",
"3",
"+"
] | train | https://github.com/pantsbuild/pex/blob/87b2129d860250d3b9edce75b9cb62f9789ee521/pex/vendor/_vendored/wheel/wheel/metadata.py#L93-L106 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Hack to coax Unicode out of an email Message() - Python 3.3+
### Response:
def pkginfo_unicode(pkg_info, field):
"""Hack to coax Unicode out of an email Message() - Python 3.3+"""
text = pkg_info[field]
field = field.lower()
if not isinstance(text, str):
if not hasattr(pkg_info, 'raw_items'): # Python 3.2
return str(text)
for item in pkg_info.raw_items():
if item[0].lower() == field:
text = item[1].encode('ascii', 'surrogateescape') \
.decode('utf-8')
break
return text
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
76886,
311,
91966,
36997,
704,
315,
459,
2613,
4961,
368,
482,
13325,
220,
18,
13,
18,
42125,
14711,
6075,
512,
755,
25830,
2801,
55762,
69880,
3186,
11,
2115,
997,
262,
4304,
76886,
311,
91966,
36997,
704,
315,
459,
2613,
4961,
368,
482,
13325,
220,
18,
13,
18,
10,
7275,
262,
1495,
284,
25830,
3186,
39740,
933,
262,
2115,
284,
2115,
18564,
746,
262,
422,
539,
11656,
7383,
11,
610,
997,
286,
422,
539,
32156,
69880,
3186,
11,
364,
1059,
12408,
36039,
220,
674,
13325,
220,
18,
13,
17,
198,
310,
471,
610,
7383,
340,
286,
369,
1537,
304,
25830,
3186,
18648,
12408,
4019,
310,
422,
1537,
58,
15,
948,
15115,
368,
624,
2115,
512,
394,
1495,
284,
1537,
58,
16,
948,
6311,
493,
24207,
518,
364,
20370,
49473,
13295,
873,
3120,
504,
662,
18696,
493,
4867,
12,
23,
1329,
394,
1464,
271,
262,
471,
1495,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
76886,
311,
91966,
36997,
704,
315,
459,
2613,
4961,
368,
482,
13325,
220,
18,
13,
18,
42125,
14711,
6075,
512,
755,
25830,
2801,
55762,
69880,
3186,
11,
2115,
997,
262,
4304,
76886,
311,
91966,
36997,
704,
315,
459,
2613,
4961,
368,
482,
13325,
220,
18,
13,
18,
10,
7275,
262,
1495,
284,
25830,
3186,
39740,
933,
262,
2115,
284,
2115,
18564,
746,
262,
422,
539,
11656,
7383,
11,
610,
997,
286,
422,
539,
32156,
69880,
3186,
11,
364,
1059,
12408,
36039,
220,
674,
13325,
220,
18,
13,
17,
198,
310,
471,
610,
7383,
340,
286,
369,
1537,
304,
25830,
3186,
18648,
12408,
4019,
310,
422,
1537,
58,
15,
948,
15115,
368,
624,
2115,
512,
394,
1495,
284,
1537,
58,
16,
948,
6311,
493,
24207,
518,
364,
20370,
49473,
13295,
873,
3120,
504,
662,
18696,
493,
4867,
12,
23,
1329,
394,
1464,
271,
262,
471,
1495,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
sibirrer/lenstronomy | lenstronomy/LensModel/Profiles/numerical_deflections.py | NumericalAlpha.hessian | def hessian(self, x, y, center_x = 0, center_y = 0, **kwargs):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
(un-normalized!!!) interpolated from the numerical deflection table
"""
diff = 1e-6
alpha_ra, alpha_dec = self.derivatives(x, y, center_x = center_x, center_y = center_y,
**kwargs)
alpha_ra_dx, alpha_dec_dx = self.derivatives(x + diff, y, center_x = center_x, center_y = center_y,
**kwargs)
alpha_ra_dy, alpha_dec_dy = self.derivatives(x, y + diff, center_x = center_x, center_y = center_y,
**kwargs)
dalpha_rara = (alpha_ra_dx - alpha_ra) / diff
dalpha_radec = (alpha_ra_dy - alpha_ra) / diff
dalpha_decdec = (alpha_dec_dy - alpha_dec) / diff
f_xx = dalpha_rara
f_yy = dalpha_decdec
f_xy = dalpha_radec
return f_xx, f_yy, f_xy | python | def hessian(self, x, y, center_x = 0, center_y = 0, **kwargs):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
(un-normalized!!!) interpolated from the numerical deflection table
"""
diff = 1e-6
alpha_ra, alpha_dec = self.derivatives(x, y, center_x = center_x, center_y = center_y,
**kwargs)
alpha_ra_dx, alpha_dec_dx = self.derivatives(x + diff, y, center_x = center_x, center_y = center_y,
**kwargs)
alpha_ra_dy, alpha_dec_dy = self.derivatives(x, y + diff, center_x = center_x, center_y = center_y,
**kwargs)
dalpha_rara = (alpha_ra_dx - alpha_ra) / diff
dalpha_radec = (alpha_ra_dy - alpha_ra) / diff
dalpha_decdec = (alpha_dec_dy - alpha_dec) / diff
f_xx = dalpha_rara
f_yy = dalpha_decdec
f_xy = dalpha_radec
return f_xx, f_yy, f_xy | [
"def",
"hessian",
"(",
"self",
",",
"x",
",",
"y",
",",
"center_x",
"=",
"0",
",",
"center_y",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"diff",
"=",
"1e-6",
"alpha_ra",
",",
"alpha_dec",
"=",
"self",
".",
"derivatives",
"(",
"x",
",",
"y",
",",
"center_x",
"=",
"center_x",
",",
"center_y",
"=",
"center_y",
",",
"*",
"*",
"kwargs",
")",
"alpha_ra_dx",
",",
"alpha_dec_dx",
"=",
"self",
".",
"derivatives",
"(",
"x",
"+",
"diff",
",",
"y",
",",
"center_x",
"=",
"center_x",
",",
"center_y",
"=",
"center_y",
",",
"*",
"*",
"kwargs",
")",
"alpha_ra_dy",
",",
"alpha_dec_dy",
"=",
"self",
".",
"derivatives",
"(",
"x",
",",
"y",
"+",
"diff",
",",
"center_x",
"=",
"center_x",
",",
"center_y",
"=",
"center_y",
",",
"*",
"*",
"kwargs",
")",
"dalpha_rara",
"=",
"(",
"alpha_ra_dx",
"-",
"alpha_ra",
")",
"/",
"diff",
"dalpha_radec",
"=",
"(",
"alpha_ra_dy",
"-",
"alpha_ra",
")",
"/",
"diff",
"dalpha_decdec",
"=",
"(",
"alpha_dec_dy",
"-",
"alpha_dec",
")",
"/",
"diff",
"f_xx",
"=",
"dalpha_rara",
"f_yy",
"=",
"dalpha_decdec",
"f_xy",
"=",
"dalpha_radec",
"return",
"f_xx",
",",
"f_yy",
",",
"f_xy"
] | returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
(un-normalized!!!) interpolated from the numerical deflection table | [
"returns",
"Hessian",
"matrix",
"of",
"function",
"d^2f",
"/",
"dx^2",
"d^f",
"/",
"dy^2",
"d^2",
"/",
"dxdy",
"(",
"un",
"-",
"normalized!!!",
")",
"interpolated",
"from",
"the",
"numerical",
"deflection",
"table"
] | train | https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Profiles/numerical_deflections.py#L85-L108 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
(un-normalized!!!) interpolated from the numerical deflection table
### Response:
def hessian(self, x, y, center_x = 0, center_y = 0, **kwargs):
"""
returns Hessian matrix of function d^2f/dx^2, d^f/dy^2, d^2/dxdy
(un-normalized!!!) interpolated from the numerical deflection table
"""
diff = 1e-6
alpha_ra, alpha_dec = self.derivatives(x, y, center_x = center_x, center_y = center_y,
**kwargs)
alpha_ra_dx, alpha_dec_dx = self.derivatives(x + diff, y, center_x = center_x, center_y = center_y,
**kwargs)
alpha_ra_dy, alpha_dec_dy = self.derivatives(x, y + diff, center_x = center_x, center_y = center_y,
**kwargs)
dalpha_rara = (alpha_ra_dx - alpha_ra) / diff
dalpha_radec = (alpha_ra_dy - alpha_ra) / diff
dalpha_decdec = (alpha_dec_dy - alpha_dec) / diff
f_xx = dalpha_rara
f_yy = dalpha_decdec
f_xy = dalpha_radec
return f_xx, f_yy, f_xy
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4310,
473,
75429,
6303,
315,
734,
294,
61,
17,
69,
3529,
87,
61,
17,
11,
294,
61,
69,
3529,
88,
61,
17,
11,
294,
61,
17,
3529,
9902,
88,
198,
286,
320,
359,
53183,
1534,
12340,
8,
86764,
505,
279,
35876,
711,
1191,
2007,
271,
14711,
6075,
512,
755,
305,
75429,
1214,
11,
865,
11,
379,
11,
4219,
3292,
284,
220,
15,
11,
4219,
4271,
284,
220,
15,
11,
3146,
9872,
997,
286,
3270,
286,
4780,
473,
75429,
6303,
315,
734,
294,
61,
17,
69,
3529,
87,
61,
17,
11,
294,
61,
69,
3529,
88,
61,
17,
11,
294,
61,
17,
3529,
9902,
88,
198,
286,
320,
359,
53183,
1534,
12340,
8,
86764,
505,
279,
35876,
711,
1191,
2007,
198,
286,
12713,
286,
3722,
284,
220,
16,
68,
12,
21,
198,
286,
8451,
61069,
11,
8451,
14102,
284,
659,
76919,
344,
5983,
2120,
11,
379,
11,
4219,
3292,
284,
4219,
3292,
11,
4219,
4271,
284,
4219,
4271,
345,
17712,
3146,
9872,
696,
286,
8451,
61069,
63084,
11,
8451,
14102,
63084,
284,
659,
76919,
344,
5983,
2120,
489,
3722,
11,
379,
11,
4219,
3292,
284,
4219,
3292,
11,
4219,
4271,
284,
4219,
4271,
345,
17712,
3146,
9872,
340,
286,
8451,
61069,
83735,
11,
8451,
14102,
83735,
284,
659,
76919,
344,
5983,
2120,
11,
379,
489,
3722,
11,
4219,
3292,
284,
4219,
3292,
11,
4219,
4271,
284,
4219,
4271,
345,
17712,
3146,
9872,
696,
286,
294,
7288,
1745,
5169,
284,
320,
7288,
61069,
63084,
482,
8451,
61069,
8,
611,
3722,
198,
286,
294,
7288,
40864,
762,
284,
320,
7288,
61069,
83735,
482,
8451,
61069,
8,
611,
3722,
198,
286,
294,
7288,
14102,
8332,
284,
320,
7288,
14102,
83735,
482,
8451,
14102,
8,
611,
3722,
271,
286,
282,
97068,
284,
294,
7288,
1745,
5169,
198,
286,
282,
4271,
88,
284,
294,
7288,
14102,
8332,
198,
286,
282,
42020,
284,
294,
7288,
40864,
762,
271,
286,
471,
282,
97068,
11,
282,
4271,
88,
11,
282,
42020,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4310,
473,
75429,
6303,
315,
734,
294,
61,
17,
69,
3529,
87,
61,
17,
11,
294,
61,
69,
3529,
88,
61,
17,
11,
294,
61,
17,
3529,
9902,
88,
198,
286,
320,
359,
53183,
1534,
12340,
8,
86764,
505,
279,
35876,
711,
1191,
2007,
271,
14711,
6075,
512,
755,
305,
75429,
1214,
11,
865,
11,
379,
11,
4219,
3292,
284,
220,
15,
11,
4219,
4271,
284,
220,
15,
11,
3146,
9872,
997,
286,
3270,
286,
4780,
473,
75429,
6303,
315,
734,
294,
61,
17,
69,
3529,
87,
61,
17,
11,
294,
61,
69,
3529,
88,
61,
17,
11,
294,
61,
17,
3529,
9902,
88,
198,
286,
320,
359,
53183,
1534,
12340,
8,
86764,
505,
279,
35876,
711,
1191,
2007,
198,
286,
12713,
286,
3722,
284,
220,
16,
68,
12,
21,
198,
286,
8451,
61069,
11,
8451,
14102,
284,
659,
76919,
344,
5983,
2120,
11,
379,
11,
4219,
3292,
284,
4219,
3292,
11,
4219,
4271,
284,
4219,
4271,
345,
17712,
3146,
9872,
696,
286,
8451,
61069,
63084,
11,
8451,
14102,
63084,
284,
659,
76919,
344,
5983,
2120,
489,
3722,
11,
379,
11,
4219,
3292,
284,
4219,
3292,
11,
4219,
4271,
284,
4219,
4271,
345,
17712,
3146,
9872,
340,
286,
8451,
61069,
83735,
11,
8451,
14102,
83735,
284,
659,
76919,
344,
5983,
2120,
11,
379,
489,
3722,
11,
4219,
3292,
284,
4219,
3292,
11,
4219,
4271,
284,
4219,
4271,
345,
17712,
3146,
9872,
696,
286,
294,
7288,
1745,
5169,
284,
320,
7288,
61069,
63084,
482,
8451,
61069,
8,
611,
3722,
198,
286,
294,
7288,
40864,
762,
284,
320,
7288,
61069,
83735,
482,
8451,
61069,
8,
611,
3722,
198,
286,
294,
7288,
14102,
8332,
284,
320,
7288,
14102,
83735,
482,
8451,
14102,
8,
611,
3722,
271,
286,
282,
97068,
284,
294,
7288,
1745,
5169,
198,
286,
282,
4271,
88,
284,
294,
7288,
14102,
8332,
198,
286,
282,
42020,
284,
294,
7288,
40864,
762,
271,
286,
471,
282,
97068,
11,
282,
4271,
88,
11,
282,
42020,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
costastf/locationsharinglib | _CI/library/patch.py | xstrip | def xstrip(filename):
""" Make relative path out of absolute by stripping
prefixes used on Linux, OS X and Windows.
This function is critical for security.
"""
while xisabs(filename):
# strip windows drive with all slashes
if re.match(b'\\w:[\\\\/]', filename):
filename = re.sub(b'^\\w+:[\\\\/]+', b'', filename)
# strip all slashes
elif re.match(b'[\\\\/]', filename):
filename = re.sub(b'^[\\\\/]+', b'', filename)
return filename | python | def xstrip(filename):
""" Make relative path out of absolute by stripping
prefixes used on Linux, OS X and Windows.
This function is critical for security.
"""
while xisabs(filename):
# strip windows drive with all slashes
if re.match(b'\\w:[\\\\/]', filename):
filename = re.sub(b'^\\w+:[\\\\/]+', b'', filename)
# strip all slashes
elif re.match(b'[\\\\/]', filename):
filename = re.sub(b'^[\\\\/]+', b'', filename)
return filename | [
"def",
"xstrip",
"(",
"filename",
")",
":",
"while",
"xisabs",
"(",
"filename",
")",
":",
"# strip windows drive with all slashes",
"if",
"re",
".",
"match",
"(",
"b'\\\\w:[\\\\\\\\/]'",
",",
"filename",
")",
":",
"filename",
"=",
"re",
".",
"sub",
"(",
"b'^\\\\w+:[\\\\\\\\/]+'",
",",
"b''",
",",
"filename",
")",
"# strip all slashes",
"elif",
"re",
".",
"match",
"(",
"b'[\\\\\\\\/]'",
",",
"filename",
")",
":",
"filename",
"=",
"re",
".",
"sub",
"(",
"b'^[\\\\\\\\/]+'",
",",
"b''",
",",
"filename",
")",
"return",
"filename"
] | Make relative path out of absolute by stripping
prefixes used on Linux, OS X and Windows.
This function is critical for security. | [
"Make",
"relative",
"path",
"out",
"of",
"absolute",
"by",
"stripping",
"prefixes",
"used",
"on",
"Linux",
"OS",
"X",
"and",
"Windows",
"."
] | train | https://github.com/costastf/locationsharinglib/blob/dcd74b0cdb59b951345df84987238763e50ef282/_CI/library/patch.py#L143-L156 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Make relative path out of absolute by stripping
prefixes used on Linux, OS X and Windows.
This function is critical for security.
### Response:
def xstrip(filename):
""" Make relative path out of absolute by stripping
prefixes used on Linux, OS X and Windows.
This function is critical for security.
"""
while xisabs(filename):
# strip windows drive with all slashes
if re.match(b'\\w:[\\\\/]', filename):
filename = re.sub(b'^\\w+:[\\\\/]+', b'', filename)
# strip all slashes
elif re.match(b'[\\\\/]', filename):
filename = re.sub(b'^[\\\\/]+', b'', filename)
return filename
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
8238,
8844,
1853,
704,
315,
10973,
555,
67770,
198,
415,
63676,
1511,
389,
14677,
11,
10293,
1630,
323,
5632,
382,
415,
1115,
734,
374,
9200,
369,
4868,
382,
14711,
6075,
512,
755,
865,
13406,
11202,
997,
220,
4304,
7557,
8844,
1853,
704,
315,
10973,
555,
67770,
198,
415,
63676,
1511,
389,
14677,
11,
10293,
1630,
323,
5632,
382,
415,
1115,
734,
374,
9200,
369,
4868,
627,
220,
3270,
220,
1418,
865,
285,
3518,
11202,
997,
262,
674,
13619,
11276,
6678,
449,
682,
88496,
198,
262,
422,
312,
11319,
1921,
6,
3505,
86,
7407,
52107,
14,
28938,
3986,
997,
415,
3986,
284,
312,
4407,
1921,
20826,
3505,
86,
10,
7407,
52107,
14,
7727,
518,
293,
51917,
3986,
340,
262,
674,
13619,
682,
88496,
198,
262,
4508,
312,
11319,
1921,
67995,
52107,
14,
28938,
3986,
997,
415,
3986,
284,
312,
4407,
1921,
20826,
58,
52107,
14,
7727,
518,
293,
51917,
3986,
340,
220,
471,
3986,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
8238,
8844,
1853,
704,
315,
10973,
555,
67770,
198,
415,
63676,
1511,
389,
14677,
11,
10293,
1630,
323,
5632,
382,
415,
1115,
734,
374,
9200,
369,
4868,
382,
14711,
6075,
512,
755,
865,
13406,
11202,
997,
220,
4304,
7557,
8844,
1853,
704,
315,
10973,
555,
67770,
198,
415,
63676,
1511,
389,
14677,
11,
10293,
1630,
323,
5632,
382,
415,
1115,
734,
374,
9200,
369,
4868,
627,
220,
3270,
220,
1418,
865,
285,
3518,
11202,
997,
262,
674,
13619,
11276,
6678,
449,
682,
88496,
198,
262,
422,
312,
11319,
1921,
6,
3505,
86,
7407,
52107,
14,
28938,
3986,
997,
415,
3986,
284,
312,
4407,
1921,
20826,
3505,
86,
10,
7407,
52107,
14,
7727,
518,
293,
51917,
3986,
340,
262,
674,
13619,
682,
88496,
198,
262,
4508,
312,
11319,
1921,
67995,
52107,
14,
28938,
3986,
997,
415,
3986,
284,
312,
4407,
1921,
20826,
58,
52107,
14,
7727,
518,
293,
51917,
3986,
340,
220,
471,
3986,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
dnanexus/dx-toolkit | src/python/dxpy/utils/__init__.py | wait_for_all_futures | def wait_for_all_futures(futures, print_traceback=False):
"""
Wait indefinitely for all futures in the input iterable to complete.
Use a timeout to enable interrupt handling.
Call os._exit() in case of KeyboardInterrupt. Otherwise, the atexit registered handler in concurrent.futures.thread
will run, and issue blocking join() on all worker threads, requiring us to listen to events in worker threads
in order to enable timely exit in response to Ctrl-C.
Note: This still doesn't handle situations where Ctrl-C is pressed elsewhere in the code and there are worker
threads with long-running tasks.
Note: os._exit() doesn't work well with interactive mode (e.g. ipython). This may help:
import __main__ as main; if hasattr(main, '__file__'): os._exit() else: os.exit()
"""
try:
while True:
waited_futures = concurrent.futures.wait(futures, timeout=60)
if len(waited_futures.not_done) == 0:
break
except KeyboardInterrupt:
if print_traceback:
traceback.print_stack()
else:
print('')
os._exit(os.EX_IOERR) | python | def wait_for_all_futures(futures, print_traceback=False):
"""
Wait indefinitely for all futures in the input iterable to complete.
Use a timeout to enable interrupt handling.
Call os._exit() in case of KeyboardInterrupt. Otherwise, the atexit registered handler in concurrent.futures.thread
will run, and issue blocking join() on all worker threads, requiring us to listen to events in worker threads
in order to enable timely exit in response to Ctrl-C.
Note: This still doesn't handle situations where Ctrl-C is pressed elsewhere in the code and there are worker
threads with long-running tasks.
Note: os._exit() doesn't work well with interactive mode (e.g. ipython). This may help:
import __main__ as main; if hasattr(main, '__file__'): os._exit() else: os.exit()
"""
try:
while True:
waited_futures = concurrent.futures.wait(futures, timeout=60)
if len(waited_futures.not_done) == 0:
break
except KeyboardInterrupt:
if print_traceback:
traceback.print_stack()
else:
print('')
os._exit(os.EX_IOERR) | [
"def",
"wait_for_all_futures",
"(",
"futures",
",",
"print_traceback",
"=",
"False",
")",
":",
"try",
":",
"while",
"True",
":",
"waited_futures",
"=",
"concurrent",
".",
"futures",
".",
"wait",
"(",
"futures",
",",
"timeout",
"=",
"60",
")",
"if",
"len",
"(",
"waited_futures",
".",
"not_done",
")",
"==",
"0",
":",
"break",
"except",
"KeyboardInterrupt",
":",
"if",
"print_traceback",
":",
"traceback",
".",
"print_stack",
"(",
")",
"else",
":",
"print",
"(",
"''",
")",
"os",
".",
"_exit",
"(",
"os",
".",
"EX_IOERR",
")"
] | Wait indefinitely for all futures in the input iterable to complete.
Use a timeout to enable interrupt handling.
Call os._exit() in case of KeyboardInterrupt. Otherwise, the atexit registered handler in concurrent.futures.thread
will run, and issue blocking join() on all worker threads, requiring us to listen to events in worker threads
in order to enable timely exit in response to Ctrl-C.
Note: This still doesn't handle situations where Ctrl-C is pressed elsewhere in the code and there are worker
threads with long-running tasks.
Note: os._exit() doesn't work well with interactive mode (e.g. ipython). This may help:
import __main__ as main; if hasattr(main, '__file__'): os._exit() else: os.exit() | [
"Wait",
"indefinitely",
"for",
"all",
"futures",
"in",
"the",
"input",
"iterable",
"to",
"complete",
".",
"Use",
"a",
"timeout",
"to",
"enable",
"interrupt",
"handling",
".",
"Call",
"os",
".",
"_exit",
"()",
"in",
"case",
"of",
"KeyboardInterrupt",
".",
"Otherwise",
"the",
"atexit",
"registered",
"handler",
"in",
"concurrent",
".",
"futures",
".",
"thread",
"will",
"run",
"and",
"issue",
"blocking",
"join",
"()",
"on",
"all",
"worker",
"threads",
"requiring",
"us",
"to",
"listen",
"to",
"events",
"in",
"worker",
"threads",
"in",
"order",
"to",
"enable",
"timely",
"exit",
"in",
"response",
"to",
"Ctrl",
"-",
"C",
"."
] | train | https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/__init__.py#L61-L85 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Wait indefinitely for all futures in the input iterable to complete.
Use a timeout to enable interrupt handling.
Call os._exit() in case of KeyboardInterrupt. Otherwise, the atexit registered handler in concurrent.futures.thread
will run, and issue blocking join() on all worker threads, requiring us to listen to events in worker threads
in order to enable timely exit in response to Ctrl-C.
Note: This still doesn't handle situations where Ctrl-C is pressed elsewhere in the code and there are worker
threads with long-running tasks.
Note: os._exit() doesn't work well with interactive mode (e.g. ipython). This may help:
import __main__ as main; if hasattr(main, '__file__'): os._exit() else: os.exit()
### Response:
def wait_for_all_futures(futures, print_traceback=False):
"""
Wait indefinitely for all futures in the input iterable to complete.
Use a timeout to enable interrupt handling.
Call os._exit() in case of KeyboardInterrupt. Otherwise, the atexit registered handler in concurrent.futures.thread
will run, and issue blocking join() on all worker threads, requiring us to listen to events in worker threads
in order to enable timely exit in response to Ctrl-C.
Note: This still doesn't handle situations where Ctrl-C is pressed elsewhere in the code and there are worker
threads with long-running tasks.
Note: os._exit() doesn't work well with interactive mode (e.g. ipython). This may help:
import __main__ as main; if hasattr(main, '__file__'): os._exit() else: os.exit()
"""
try:
while True:
waited_futures = concurrent.futures.wait(futures, timeout=60)
if len(waited_futures.not_done) == 0:
break
except KeyboardInterrupt:
if print_traceback:
traceback.print_stack()
else:
print('')
os._exit(os.EX_IOERR)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14524,
56334,
369,
682,
37923,
304,
279,
1988,
51934,
311,
4686,
627,
262,
5560,
264,
9829,
311,
7431,
12956,
11850,
627,
262,
7290,
2709,
1462,
13966,
368,
304,
1162,
315,
85288,
13,
18715,
11,
279,
520,
13966,
9879,
7158,
304,
35135,
840,
75706,
46310,
198,
262,
690,
1629,
11,
323,
4360,
22978,
5249,
368,
389,
682,
12128,
14906,
11,
23537,
603,
311,
9020,
311,
4455,
304,
12128,
14906,
198,
262,
304,
2015,
311,
7431,
32100,
4974,
304,
2077,
311,
38114,
7813,
382,
262,
7181,
25,
1115,
2103,
3250,
956,
3790,
15082,
1405,
38114,
7813,
374,
17770,
18403,
304,
279,
2082,
323,
1070,
527,
12128,
198,
262,
14906,
449,
1317,
54589,
9256,
382,
262,
7181,
25,
2709,
1462,
13966,
368,
3250,
956,
990,
1664,
449,
21416,
3941,
320,
68,
1326,
13,
6125,
27993,
570,
1115,
1253,
1520,
512,
262,
1179,
1328,
3902,
565,
439,
1925,
26,
422,
32156,
27664,
11,
12385,
1213,
565,
36039,
2709,
1462,
13966,
368,
775,
25,
2709,
13955,
2892,
14711,
6075,
512,
755,
3868,
5595,
5823,
766,
75706,
968,
75706,
11,
1194,
24489,
1445,
5725,
997,
262,
3270,
262,
14144,
56334,
369,
682,
37923,
304,
279,
1988,
51934,
311,
4686,
627,
262,
5560,
264,
9829,
311,
7431,
12956,
11850,
627,
262,
7290,
2709,
1462,
13966,
368,
304,
1162,
315,
85288,
13,
18715,
11,
279,
520,
13966,
9879,
7158,
304,
35135,
840,
75706,
46310,
198,
262,
690,
1629,
11,
323,
4360,
22978,
5249,
368,
389,
682,
12128,
14906,
11,
23537,
603,
311,
9020,
311,
4455,
304,
12128,
14906,
198,
262,
304,
2015,
311,
7431,
32100,
4974,
304,
2077,
311,
38114,
7813,
382,
262,
7181,
25,
1115,
2103,
3250,
956,
3790,
15082,
1405,
38114,
7813,
374,
17770,
18403,
304,
279,
2082,
323,
1070,
527,
12128,
198,
262,
14906,
449,
1317,
54589,
9256,
382,
262,
7181,
25,
2709,
1462,
13966,
368,
3250,
956,
990,
1664,
449,
21416,
3941,
320,
68,
1326,
13,
6125,
27993,
570,
1115,
1253,
1520,
512,
262,
1179,
1328,
3902,
565,
439,
1925,
26,
422,
32156,
27664,
11,
12385,
1213,
565,
36039,
2709,
1462,
13966,
368,
775,
25,
2709,
13955,
746,
262,
3270,
262,
1456,
512,
286,
1418,
3082,
512,
310,
30315,
766,
75706,
284,
35135,
840,
75706,
16693,
968,
75706,
11,
9829,
28,
1399,
340,
310,
422,
2479,
65192,
291,
766,
75706,
12238,
25391,
8,
624,
220,
15,
512,
394,
1464,
198,
262,
3734,
85288,
512,
286,
422,
1194,
24489,
1445,
512,
310,
47158,
2263,
15897,
746,
286,
775,
512,
310,
1194,
38465,
286,
2709,
1462,
13966,
9835,
23208,
20376,
2716,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14524,
56334,
369,
682,
37923,
304,
279,
1988,
51934,
311,
4686,
627,
262,
5560,
264,
9829,
311,
7431,
12956,
11850,
627,
262,
7290,
2709,
1462,
13966,
368,
304,
1162,
315,
85288,
13,
18715,
11,
279,
520,
13966,
9879,
7158,
304,
35135,
840,
75706,
46310,
198,
262,
690,
1629,
11,
323,
4360,
22978,
5249,
368,
389,
682,
12128,
14906,
11,
23537,
603,
311,
9020,
311,
4455,
304,
12128,
14906,
198,
262,
304,
2015,
311,
7431,
32100,
4974,
304,
2077,
311,
38114,
7813,
382,
262,
7181,
25,
1115,
2103,
3250,
956,
3790,
15082,
1405,
38114,
7813,
374,
17770,
18403,
304,
279,
2082,
323,
1070,
527,
12128,
198,
262,
14906,
449,
1317,
54589,
9256,
382,
262,
7181,
25,
2709,
1462,
13966,
368,
3250,
956,
990,
1664,
449,
21416,
3941,
320,
68,
1326,
13,
6125,
27993,
570,
1115,
1253,
1520,
512,
262,
1179,
1328,
3902,
565,
439,
1925,
26,
422,
32156,
27664,
11,
12385,
1213,
565,
36039,
2709,
1462,
13966,
368,
775,
25,
2709,
13955,
2892,
14711,
6075,
512,
755,
3868,
5595,
5823,
766,
75706,
968,
75706,
11,
1194,
24489,
1445,
5725,
997,
262,
3270,
262,
14144,
56334,
369,
682,
37923,
304,
279,
1988,
51934,
311,
4686,
627,
262,
5560,
264,
9829,
311,
7431,
12956,
11850,
627,
262,
7290,
2709,
1462,
13966,
368,
304,
1162,
315,
85288,
13,
18715,
11,
279,
520,
13966,
9879,
7158,
304,
35135,
840,
75706,
46310,
198,
262,
690,
1629,
11,
323,
4360,
22978,
5249,
368,
389,
682,
12128,
14906,
11,
23537,
603,
311,
9020,
311,
4455,
304,
12128,
14906,
198,
262,
304,
2015,
311,
7431,
32100,
4974,
304,
2077,
311,
38114,
7813,
382,
262,
7181,
25,
1115,
2103,
3250,
956,
3790,
15082,
1405,
38114,
7813,
374,
17770,
18403,
304,
279,
2082,
323,
1070,
527,
12128,
198,
262,
14906,
449,
1317,
54589,
9256,
382,
262,
7181,
25,
2709,
1462,
13966,
368,
3250,
956,
990,
1664,
449,
21416,
3941,
320,
68,
1326,
13,
6125,
27993,
570,
1115,
1253,
1520,
512,
262,
1179,
1328,
3902,
565,
439,
1925,
26,
422,
32156,
27664,
11,
12385,
1213,
565,
36039,
2709,
1462,
13966,
368,
775,
25,
2709,
13955,
746,
262,
3270,
262,
1456,
512,
286,
1418,
3082,
512,
310,
30315,
766,
75706,
284,
35135,
840,
75706,
16693,
968,
75706,
11,
9829,
28,
1399,
340,
310,
422,
2479,
65192,
291,
766,
75706,
12238,
25391,
8,
624,
220,
15,
512,
394,
1464,
198,
262,
3734,
85288,
512,
286,
422,
1194,
24489,
1445,
512,
310,
47158,
2263,
15897,
746,
286,
775,
512,
310,
1194,
38465,
286,
2709,
1462,
13966,
9835,
23208,
20376,
2716,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
PyCQA/pydocstyle | src/pydocstyle/violations.py | ErrorRegistry.get_error_codes | def get_error_codes(cls) -> Iterable[str]:
"""Yield all registered codes."""
for group in cls.groups:
for error in group.errors:
yield error.code | python | def get_error_codes(cls) -> Iterable[str]:
"""Yield all registered codes."""
for group in cls.groups:
for error in group.errors:
yield error.code | [
"def",
"get_error_codes",
"(",
"cls",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"for",
"group",
"in",
"cls",
".",
"groups",
":",
"for",
"error",
"in",
"group",
".",
"errors",
":",
"yield",
"error",
".",
"code"
] | Yield all registered codes. | [
"Yield",
"all",
"registered",
"codes",
"."
] | train | https://github.com/PyCQA/pydocstyle/blob/2549847f9efad225789f931e83dfe782418ca13e/src/pydocstyle/violations.py#L146-L150 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Yield all registered codes.
### Response:
def get_error_codes(cls) -> Iterable[str]:
"""Yield all registered codes."""
for group in cls.groups:
for error in group.errors:
yield error.code
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
56,
823,
682,
9879,
14236,
382,
14711,
6075,
512,
755,
636,
4188,
39582,
21024,
8,
1492,
39116,
17752,
10556,
286,
4304,
56,
823,
682,
9879,
14236,
14781,
286,
369,
1912,
304,
13082,
41721,
512,
310,
369,
1493,
304,
1912,
17765,
512,
394,
7692,
1493,
10421,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
56,
823,
682,
9879,
14236,
382,
14711,
6075,
512,
755,
636,
4188,
39582,
21024,
8,
1492,
39116,
17752,
10556,
286,
4304,
56,
823,
682,
9879,
14236,
14781,
286,
369,
1912,
304,
13082,
41721,
512,
310,
369,
1493,
304,
1912,
17765,
512,
394,
7692,
1493,
10421,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
sentinel-hub/sentinelhub-py | sentinelhub/geo_utils.py | utm_to_pixel | def utm_to_pixel(east, north, transform, truncate=True):
""" Convert UTM coordinate to image coordinate given a transform
:param east: east coordinate of point
:type east: float
:param north: north coordinate of point
:type north: float
:param transform: georeferencing transform of the image, e.g. `(x_upper_left, res_x, 0, y_upper_left, 0, -res_y)`
:type transform: tuple or list
:param truncate: Whether to truncate pixel coordinates. Default is ``True``
:type truncate: bool
:return: row and column pixel image coordinates
:rtype: float, float or int, int
"""
column = (east - transform[0]) / transform[1]
row = (north - transform[3]) / transform[5]
if truncate:
return int(row + ERR), int(column + ERR)
return row, column | python | def utm_to_pixel(east, north, transform, truncate=True):
""" Convert UTM coordinate to image coordinate given a transform
:param east: east coordinate of point
:type east: float
:param north: north coordinate of point
:type north: float
:param transform: georeferencing transform of the image, e.g. `(x_upper_left, res_x, 0, y_upper_left, 0, -res_y)`
:type transform: tuple or list
:param truncate: Whether to truncate pixel coordinates. Default is ``True``
:type truncate: bool
:return: row and column pixel image coordinates
:rtype: float, float or int, int
"""
column = (east - transform[0]) / transform[1]
row = (north - transform[3]) / transform[5]
if truncate:
return int(row + ERR), int(column + ERR)
return row, column | [
"def",
"utm_to_pixel",
"(",
"east",
",",
"north",
",",
"transform",
",",
"truncate",
"=",
"True",
")",
":",
"column",
"=",
"(",
"east",
"-",
"transform",
"[",
"0",
"]",
")",
"/",
"transform",
"[",
"1",
"]",
"row",
"=",
"(",
"north",
"-",
"transform",
"[",
"3",
"]",
")",
"/",
"transform",
"[",
"5",
"]",
"if",
"truncate",
":",
"return",
"int",
"(",
"row",
"+",
"ERR",
")",
",",
"int",
"(",
"column",
"+",
"ERR",
")",
"return",
"row",
",",
"column"
] | Convert UTM coordinate to image coordinate given a transform
:param east: east coordinate of point
:type east: float
:param north: north coordinate of point
:type north: float
:param transform: georeferencing transform of the image, e.g. `(x_upper_left, res_x, 0, y_upper_left, 0, -res_y)`
:type transform: tuple or list
:param truncate: Whether to truncate pixel coordinates. Default is ``True``
:type truncate: bool
:return: row and column pixel image coordinates
:rtype: float, float or int, int | [
"Convert",
"UTM",
"coordinate",
"to",
"image",
"coordinate",
"given",
"a",
"transform"
] | train | https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/geo_utils.py#L140-L158 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Convert UTM coordinate to image coordinate given a transform
:param east: east coordinate of point
:type east: float
:param north: north coordinate of point
:type north: float
:param transform: georeferencing transform of the image, e.g. `(x_upper_left, res_x, 0, y_upper_left, 0, -res_y)`
:type transform: tuple or list
:param truncate: Whether to truncate pixel coordinates. Default is ``True``
:type truncate: bool
:return: row and column pixel image coordinates
:rtype: float, float or int, int
### Response:
def utm_to_pixel(east, north, transform, truncate=True):
""" Convert UTM coordinate to image coordinate given a transform
:param east: east coordinate of point
:type east: float
:param north: north coordinate of point
:type north: float
:param transform: georeferencing transform of the image, e.g. `(x_upper_left, res_x, 0, y_upper_left, 0, -res_y)`
:type transform: tuple or list
:param truncate: Whether to truncate pixel coordinates. Default is ``True``
:type truncate: bool
:return: row and column pixel image coordinates
:rtype: float, float or int, int
"""
column = (east - transform[0]) / transform[1]
row = (north - transform[3]) / transform[5]
if truncate:
return int(row + ERR), int(column + ERR)
return row, column
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
12281,
549,
22809,
16580,
311,
2217,
16580,
2728,
264,
5276,
271,
262,
551,
913,
11226,
25,
11226,
16580,
315,
1486,
198,
262,
551,
1337,
11226,
25,
2273,
198,
262,
551,
913,
10411,
25,
10411,
16580,
315,
1486,
198,
262,
551,
1337,
10411,
25,
2273,
198,
262,
551,
913,
5276,
25,
3980,
461,
809,
11627,
5276,
315,
279,
2217,
11,
384,
1326,
13,
49751,
87,
35545,
9774,
11,
594,
3292,
11,
220,
15,
11,
379,
35545,
9774,
11,
220,
15,
11,
482,
417,
4271,
50337,
262,
551,
1337,
5276,
25,
14743,
477,
1160,
198,
262,
551,
913,
57872,
25,
13440,
311,
57872,
13252,
14259,
13,
8058,
374,
10103,
2575,
85374,
262,
551,
1337,
57872,
25,
1845,
198,
262,
551,
693,
25,
2872,
323,
3330,
13252,
2217,
14259,
198,
262,
551,
33613,
25,
2273,
11,
2273,
477,
528,
11,
528,
271,
14711,
6075,
512,
755,
8791,
76,
2401,
30860,
2069,
561,
11,
10411,
11,
5276,
11,
57872,
3702,
997,
262,
4304,
7316,
549,
22809,
16580,
311,
2217,
16580,
2728,
264,
5276,
271,
262,
551,
913,
11226,
25,
11226,
16580,
315,
1486,
198,
262,
551,
1337,
11226,
25,
2273,
198,
262,
551,
913,
10411,
25,
10411,
16580,
315,
1486,
198,
262,
551,
1337,
10411,
25,
2273,
198,
262,
551,
913,
5276,
25,
3980,
461,
809,
11627,
5276,
315,
279,
2217,
11,
384,
1326,
13,
49751,
87,
35545,
9774,
11,
594,
3292,
11,
220,
15,
11,
379,
35545,
9774,
11,
220,
15,
11,
482,
417,
4271,
50337,
262,
551,
1337,
5276,
25,
14743,
477,
1160,
198,
262,
551,
913,
57872,
25,
13440,
311,
57872,
13252,
14259,
13,
8058,
374,
10103,
2575,
85374,
262,
551,
1337,
57872,
25,
1845,
198,
262,
551,
693,
25,
2872,
323,
3330,
13252,
2217,
14259,
198,
262,
551,
33613,
25,
2273,
11,
2273,
477,
528,
11,
528,
198,
262,
3270,
262,
3330,
284,
320,
61601,
482,
5276,
58,
15,
2526,
611,
5276,
58,
16,
933,
262,
2872,
284,
320,
62995,
482,
5276,
58,
18,
2526,
611,
5276,
58,
20,
933,
262,
422,
57872,
512,
286,
471,
528,
7991,
489,
10375,
705,
528,
17725,
489,
10375,
340,
262,
471,
2872,
11,
3330,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
12281,
549,
22809,
16580,
311,
2217,
16580,
2728,
264,
5276,
271,
262,
551,
913,
11226,
25,
11226,
16580,
315,
1486,
198,
262,
551,
1337,
11226,
25,
2273,
198,
262,
551,
913,
10411,
25,
10411,
16580,
315,
1486,
198,
262,
551,
1337,
10411,
25,
2273,
198,
262,
551,
913,
5276,
25,
3980,
461,
809,
11627,
5276,
315,
279,
2217,
11,
384,
1326,
13,
49751,
87,
35545,
9774,
11,
594,
3292,
11,
220,
15,
11,
379,
35545,
9774,
11,
220,
15,
11,
482,
417,
4271,
50337,
262,
551,
1337,
5276,
25,
14743,
477,
1160,
198,
262,
551,
913,
57872,
25,
13440,
311,
57872,
13252,
14259,
13,
8058,
374,
10103,
2575,
85374,
262,
551,
1337,
57872,
25,
1845,
198,
262,
551,
693,
25,
2872,
323,
3330,
13252,
2217,
14259,
198,
262,
551,
33613,
25,
2273,
11,
2273,
477,
528,
11,
528,
271,
14711,
6075,
512,
755,
8791,
76,
2401,
30860,
2069,
561,
11,
10411,
11,
5276,
11,
57872,
3702,
997,
262,
4304,
7316,
549,
22809,
16580,
311,
2217,
16580,
2728,
264,
5276,
271,
262,
551,
913,
11226,
25,
11226,
16580,
315,
1486,
198,
262,
551,
1337,
11226,
25,
2273,
198,
262,
551,
913,
10411,
25,
10411,
16580,
315,
1486,
198,
262,
551,
1337,
10411,
25,
2273,
198,
262,
551,
913,
5276,
25,
3980,
461,
809,
11627,
5276,
315,
279,
2217,
11,
384,
1326,
13,
49751,
87,
35545,
9774,
11,
594,
3292,
11,
220,
15,
11,
379,
35545,
9774,
11,
220,
15,
11,
482,
417,
4271,
50337,
262,
551,
1337,
5276,
25,
14743,
477,
1160,
198,
262,
551,
913,
57872,
25,
13440,
311,
57872,
13252,
14259,
13,
8058,
374,
10103,
2575,
85374,
262,
551,
1337,
57872,
25,
1845,
198,
262,
551,
693,
25,
2872,
323,
3330,
13252,
2217,
14259,
198,
262,
551,
33613,
25,
2273,
11,
2273,
477,
528,
11,
528,
198,
262,
3270,
262,
3330,
284,
320,
61601,
482,
5276,
58,
15,
2526,
611,
5276,
58,
16,
933,
262,
2872,
284,
320,
62995,
482,
5276,
58,
18,
2526,
611,
5276,
58,
20,
933,
262,
422,
57872,
512,
286,
471,
528,
7991,
489,
10375,
705,
528,
17725,
489,
10375,
340,
262,
471,
2872,
11,
3330,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
bslatkin/dpxdt | dpxdt/server/auth.py | can_api_key_access_build | def can_api_key_access_build(param_name):
"""Determines if the current API key can access the build in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
(api_key, build) The API Key and the Build it has access to.
"""
build_id = (
request.args.get(param_name, type=int) or
request.form.get(param_name, type=int) or
request.json[param_name])
utils.jsonify_assert(build_id, 'build_id required')
if app.config.get('IGNORE_AUTH'):
api_key = models.ApiKey(
id='anonymous_superuser',
secret='',
superuser=True)
build = models.Build.query.get(build_id)
utils.jsonify_assert(build is not None, 'build must exist', 404)
else:
ops = _get_api_key_ops()
api_key, build = ops.can_access_build(build_id)
return api_key, build | python | def can_api_key_access_build(param_name):
"""Determines if the current API key can access the build in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
(api_key, build) The API Key and the Build it has access to.
"""
build_id = (
request.args.get(param_name, type=int) or
request.form.get(param_name, type=int) or
request.json[param_name])
utils.jsonify_assert(build_id, 'build_id required')
if app.config.get('IGNORE_AUTH'):
api_key = models.ApiKey(
id='anonymous_superuser',
secret='',
superuser=True)
build = models.Build.query.get(build_id)
utils.jsonify_assert(build is not None, 'build must exist', 404)
else:
ops = _get_api_key_ops()
api_key, build = ops.can_access_build(build_id)
return api_key, build | [
"def",
"can_api_key_access_build",
"(",
"param_name",
")",
":",
"build_id",
"=",
"(",
"request",
".",
"args",
".",
"get",
"(",
"param_name",
",",
"type",
"=",
"int",
")",
"or",
"request",
".",
"form",
".",
"get",
"(",
"param_name",
",",
"type",
"=",
"int",
")",
"or",
"request",
".",
"json",
"[",
"param_name",
"]",
")",
"utils",
".",
"jsonify_assert",
"(",
"build_id",
",",
"'build_id required'",
")",
"if",
"app",
".",
"config",
".",
"get",
"(",
"'IGNORE_AUTH'",
")",
":",
"api_key",
"=",
"models",
".",
"ApiKey",
"(",
"id",
"=",
"'anonymous_superuser'",
",",
"secret",
"=",
"''",
",",
"superuser",
"=",
"True",
")",
"build",
"=",
"models",
".",
"Build",
".",
"query",
".",
"get",
"(",
"build_id",
")",
"utils",
".",
"jsonify_assert",
"(",
"build",
"is",
"not",
"None",
",",
"'build must exist'",
",",
"404",
")",
"else",
":",
"ops",
"=",
"_get_api_key_ops",
"(",
")",
"api_key",
",",
"build",
"=",
"ops",
".",
"can_access_build",
"(",
"build_id",
")",
"return",
"api_key",
",",
"build"
] | Determines if the current API key can access the build in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
(api_key, build) The API Key and the Build it has access to. | [
"Determines",
"if",
"the",
"current",
"API",
"key",
"can",
"access",
"the",
"build",
"in",
"the",
"request",
"."
] | train | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/auth.py#L302-L329 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Determines if the current API key can access the build in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
(api_key, build) The API Key and the Build it has access to.
### Response:
def can_api_key_access_build(param_name):
"""Determines if the current API key can access the build in the request.
Args:
param_name: Parameter name to use for getting the build ID from the
request. Will fetch from GET or POST requests.
Returns:
(api_key, build) The API Key and the Build it has access to.
"""
build_id = (
request.args.get(param_name, type=int) or
request.form.get(param_name, type=int) or
request.json[param_name])
utils.jsonify_assert(build_id, 'build_id required')
if app.config.get('IGNORE_AUTH'):
api_key = models.ApiKey(
id='anonymous_superuser',
secret='',
superuser=True)
build = models.Build.query.get(build_id)
utils.jsonify_assert(build is not None, 'build must exist', 404)
else:
ops = _get_api_key_ops()
api_key, build = ops.can_access_build(build_id)
return api_key, build
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
93748,
288,
422,
279,
1510,
5446,
1401,
649,
2680,
279,
1977,
304,
279,
1715,
382,
262,
18161,
512,
286,
1719,
1292,
25,
15521,
836,
311,
1005,
369,
3794,
279,
1977,
3110,
505,
279,
198,
310,
1715,
13,
4946,
7963,
505,
8049,
477,
13165,
7540,
382,
262,
5295,
512,
286,
320,
2113,
3173,
11,
1977,
8,
578,
5446,
5422,
323,
279,
8012,
433,
706,
2680,
311,
382,
14711,
6075,
512,
755,
649,
11959,
3173,
13049,
21465,
9942,
1292,
997,
262,
4304,
93748,
288,
422,
279,
1510,
5446,
1401,
649,
2680,
279,
1977,
304,
279,
1715,
382,
262,
18161,
512,
286,
1719,
1292,
25,
15521,
836,
311,
1005,
369,
3794,
279,
1977,
3110,
505,
279,
198,
310,
1715,
13,
4946,
7963,
505,
8049,
477,
13165,
7540,
382,
262,
5295,
512,
286,
320,
2113,
3173,
11,
1977,
8,
578,
5446,
5422,
323,
279,
8012,
433,
706,
2680,
311,
627,
262,
3270,
262,
1977,
851,
284,
2456,
286,
1715,
16769,
673,
9942,
1292,
11,
955,
16972,
8,
477,
198,
286,
1715,
8726,
673,
9942,
1292,
11,
955,
16972,
8,
477,
198,
286,
1715,
4421,
68185,
1292,
2608,
262,
12721,
4421,
1463,
16962,
44433,
851,
11,
364,
5957,
851,
2631,
4713,
262,
422,
917,
5539,
673,
493,
36145,
23507,
11290,
286,
6464,
3173,
284,
4211,
21721,
1622,
1021,
310,
887,
1151,
26347,
86854,
756,
310,
6367,
97783,
310,
2307,
882,
3702,
340,
286,
1977,
284,
4211,
26277,
4891,
673,
44433,
851,
340,
286,
12721,
4421,
1463,
16962,
44433,
374,
539,
2290,
11,
364,
5957,
2011,
3073,
518,
220,
7507,
340,
262,
775,
512,
286,
28231,
284,
721,
456,
11959,
3173,
22726,
746,
286,
6464,
3173,
11,
1977,
284,
28231,
28499,
13049,
21465,
44433,
851,
696,
262,
471,
6464,
3173,
11,
1977,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
93748,
288,
422,
279,
1510,
5446,
1401,
649,
2680,
279,
1977,
304,
279,
1715,
382,
262,
18161,
512,
286,
1719,
1292,
25,
15521,
836,
311,
1005,
369,
3794,
279,
1977,
3110,
505,
279,
198,
310,
1715,
13,
4946,
7963,
505,
8049,
477,
13165,
7540,
382,
262,
5295,
512,
286,
320,
2113,
3173,
11,
1977,
8,
578,
5446,
5422,
323,
279,
8012,
433,
706,
2680,
311,
382,
14711,
6075,
512,
755,
649,
11959,
3173,
13049,
21465,
9942,
1292,
997,
262,
4304,
93748,
288,
422,
279,
1510,
5446,
1401,
649,
2680,
279,
1977,
304,
279,
1715,
382,
262,
18161,
512,
286,
1719,
1292,
25,
15521,
836,
311,
1005,
369,
3794,
279,
1977,
3110,
505,
279,
198,
310,
1715,
13,
4946,
7963,
505,
8049,
477,
13165,
7540,
382,
262,
5295,
512,
286,
320,
2113,
3173,
11,
1977,
8,
578,
5446,
5422,
323,
279,
8012,
433,
706,
2680,
311,
627,
262,
3270,
262,
1977,
851,
284,
2456,
286,
1715,
16769,
673,
9942,
1292,
11,
955,
16972,
8,
477,
198,
286,
1715,
8726,
673,
9942,
1292,
11,
955,
16972,
8,
477,
198,
286,
1715,
4421,
68185,
1292,
2608,
262,
12721,
4421,
1463,
16962,
44433,
851,
11,
364,
5957,
851,
2631,
4713,
262,
422,
917,
5539,
673,
493,
36145,
23507,
11290,
286,
6464,
3173,
284,
4211,
21721,
1622,
1021,
310,
887,
1151,
26347,
86854,
756,
310,
6367,
97783,
310,
2307,
882,
3702,
340,
286,
1977,
284,
4211,
26277,
4891,
673,
44433,
851,
340,
286,
12721,
4421,
1463,
16962,
44433,
374,
539,
2290,
11,
364,
5957,
2011,
3073,
518,
220,
7507,
340,
262,
775,
512,
286,
28231,
284,
721,
456,
11959,
3173,
22726,
746,
286,
6464,
3173,
11,
1977,
284,
28231,
28499,
13049,
21465,
44433,
851,
696,
262,
471,
6464,
3173,
11,
1977,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
wakatime/wakatime | wakatime/packages/requests/sessions.py | SessionRedirectMixin.resolve_redirects | def resolve_redirects(self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):
"""Receives a Response. Returns a generator of Responses or Requests."""
hist = [] # keep track of history
url = self.get_redirect_target(resp)
while url:
prepared_request = req.copy()
# Update history and keep track of redirects.
# resp.history must ignore the original request in this loop
hist.append(resp)
resp.history = hist[1:]
try:
resp.content # Consume socket so it can be released
except (ChunkedEncodingError, ContentDecodingError, RuntimeError):
resp.raw.read(decode_content=False)
if len(resp.history) >= self.max_redirects:
raise TooManyRedirects('Exceeded %s redirects.' % self.max_redirects, response=resp)
# Release the connection back into the pool.
resp.close()
# Handle redirection without scheme (see: RFC 1808 Section 4)
if url.startswith('//'):
parsed_rurl = urlparse(resp.url)
url = '%s:%s' % (to_native_string(parsed_rurl.scheme), url)
# The scheme should be lower case...
parsed = urlparse(url)
url = parsed.geturl()
# Facilitate relative 'location' headers, as allowed by RFC 7231.
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
# Compliant with RFC3986, we percent encode the url.
if not parsed.netloc:
url = urljoin(resp.url, requote_uri(url))
else:
url = requote_uri(url)
prepared_request.url = to_native_string(url)
self.rebuild_method(prepared_request, resp)
# https://github.com/requests/requests/issues/1084
if resp.status_code not in (codes.temporary_redirect, codes.permanent_redirect):
# https://github.com/requests/requests/issues/3490
purged_headers = ('Content-Length', 'Content-Type', 'Transfer-Encoding')
for header in purged_headers:
prepared_request.headers.pop(header, None)
prepared_request.body = None
headers = prepared_request.headers
try:
del headers['Cookie']
except KeyError:
pass
# Extract any cookies sent on the response to the cookiejar
# in the new request. Because we've mutated our copied prepared
# request, use the old one that we haven't yet touched.
extract_cookies_to_jar(prepared_request._cookies, req, resp.raw)
merge_cookies(prepared_request._cookies, self.cookies)
prepared_request.prepare_cookies(prepared_request._cookies)
# Rebuild auth and proxy information.
proxies = self.rebuild_proxies(prepared_request, proxies)
self.rebuild_auth(prepared_request, resp)
# A failed tell() sets `_body_position` to `object()`. This non-None
# value ensures `rewindable` will be True, allowing us to raise an
# UnrewindableBodyError, instead of hanging the connection.
rewindable = (
prepared_request._body_position is not None and
('Content-Length' in headers or 'Transfer-Encoding' in headers)
)
# Attempt to rewind consumed file-like object.
if rewindable:
rewind_body(prepared_request)
# Override the original request.
req = prepared_request
if yield_requests:
yield req
else:
resp = self.send(
req,
stream=stream,
timeout=timeout,
verify=verify,
cert=cert,
proxies=proxies,
allow_redirects=False,
**adapter_kwargs
)
extract_cookies_to_jar(self.cookies, prepared_request, resp.raw)
# extract redirect url, if any, for the next loop
url = self.get_redirect_target(resp)
yield resp | python | def resolve_redirects(self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):
"""Receives a Response. Returns a generator of Responses or Requests."""
hist = [] # keep track of history
url = self.get_redirect_target(resp)
while url:
prepared_request = req.copy()
# Update history and keep track of redirects.
# resp.history must ignore the original request in this loop
hist.append(resp)
resp.history = hist[1:]
try:
resp.content # Consume socket so it can be released
except (ChunkedEncodingError, ContentDecodingError, RuntimeError):
resp.raw.read(decode_content=False)
if len(resp.history) >= self.max_redirects:
raise TooManyRedirects('Exceeded %s redirects.' % self.max_redirects, response=resp)
# Release the connection back into the pool.
resp.close()
# Handle redirection without scheme (see: RFC 1808 Section 4)
if url.startswith('//'):
parsed_rurl = urlparse(resp.url)
url = '%s:%s' % (to_native_string(parsed_rurl.scheme), url)
# The scheme should be lower case...
parsed = urlparse(url)
url = parsed.geturl()
# Facilitate relative 'location' headers, as allowed by RFC 7231.
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
# Compliant with RFC3986, we percent encode the url.
if not parsed.netloc:
url = urljoin(resp.url, requote_uri(url))
else:
url = requote_uri(url)
prepared_request.url = to_native_string(url)
self.rebuild_method(prepared_request, resp)
# https://github.com/requests/requests/issues/1084
if resp.status_code not in (codes.temporary_redirect, codes.permanent_redirect):
# https://github.com/requests/requests/issues/3490
purged_headers = ('Content-Length', 'Content-Type', 'Transfer-Encoding')
for header in purged_headers:
prepared_request.headers.pop(header, None)
prepared_request.body = None
headers = prepared_request.headers
try:
del headers['Cookie']
except KeyError:
pass
# Extract any cookies sent on the response to the cookiejar
# in the new request. Because we've mutated our copied prepared
# request, use the old one that we haven't yet touched.
extract_cookies_to_jar(prepared_request._cookies, req, resp.raw)
merge_cookies(prepared_request._cookies, self.cookies)
prepared_request.prepare_cookies(prepared_request._cookies)
# Rebuild auth and proxy information.
proxies = self.rebuild_proxies(prepared_request, proxies)
self.rebuild_auth(prepared_request, resp)
# A failed tell() sets `_body_position` to `object()`. This non-None
# value ensures `rewindable` will be True, allowing us to raise an
# UnrewindableBodyError, instead of hanging the connection.
rewindable = (
prepared_request._body_position is not None and
('Content-Length' in headers or 'Transfer-Encoding' in headers)
)
# Attempt to rewind consumed file-like object.
if rewindable:
rewind_body(prepared_request)
# Override the original request.
req = prepared_request
if yield_requests:
yield req
else:
resp = self.send(
req,
stream=stream,
timeout=timeout,
verify=verify,
cert=cert,
proxies=proxies,
allow_redirects=False,
**adapter_kwargs
)
extract_cookies_to_jar(self.cookies, prepared_request, resp.raw)
# extract redirect url, if any, for the next loop
url = self.get_redirect_target(resp)
yield resp | [
"def",
"resolve_redirects",
"(",
"self",
",",
"resp",
",",
"req",
",",
"stream",
"=",
"False",
",",
"timeout",
"=",
"None",
",",
"verify",
"=",
"True",
",",
"cert",
"=",
"None",
",",
"proxies",
"=",
"None",
",",
"yield_requests",
"=",
"False",
",",
"*",
"*",
"adapter_kwargs",
")",
":",
"hist",
"=",
"[",
"]",
"# keep track of history",
"url",
"=",
"self",
".",
"get_redirect_target",
"(",
"resp",
")",
"while",
"url",
":",
"prepared_request",
"=",
"req",
".",
"copy",
"(",
")",
"# Update history and keep track of redirects.",
"# resp.history must ignore the original request in this loop",
"hist",
".",
"append",
"(",
"resp",
")",
"resp",
".",
"history",
"=",
"hist",
"[",
"1",
":",
"]",
"try",
":",
"resp",
".",
"content",
"# Consume socket so it can be released",
"except",
"(",
"ChunkedEncodingError",
",",
"ContentDecodingError",
",",
"RuntimeError",
")",
":",
"resp",
".",
"raw",
".",
"read",
"(",
"decode_content",
"=",
"False",
")",
"if",
"len",
"(",
"resp",
".",
"history",
")",
">=",
"self",
".",
"max_redirects",
":",
"raise",
"TooManyRedirects",
"(",
"'Exceeded %s redirects.'",
"%",
"self",
".",
"max_redirects",
",",
"response",
"=",
"resp",
")",
"# Release the connection back into the pool.",
"resp",
".",
"close",
"(",
")",
"# Handle redirection without scheme (see: RFC 1808 Section 4)",
"if",
"url",
".",
"startswith",
"(",
"'//'",
")",
":",
"parsed_rurl",
"=",
"urlparse",
"(",
"resp",
".",
"url",
")",
"url",
"=",
"'%s:%s'",
"%",
"(",
"to_native_string",
"(",
"parsed_rurl",
".",
"scheme",
")",
",",
"url",
")",
"# The scheme should be lower case...",
"parsed",
"=",
"urlparse",
"(",
"url",
")",
"url",
"=",
"parsed",
".",
"geturl",
"(",
")",
"# Facilitate relative 'location' headers, as allowed by RFC 7231.",
"# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')",
"# Compliant with RFC3986, we percent encode the url.",
"if",
"not",
"parsed",
".",
"netloc",
":",
"url",
"=",
"urljoin",
"(",
"resp",
".",
"url",
",",
"requote_uri",
"(",
"url",
")",
")",
"else",
":",
"url",
"=",
"requote_uri",
"(",
"url",
")",
"prepared_request",
".",
"url",
"=",
"to_native_string",
"(",
"url",
")",
"self",
".",
"rebuild_method",
"(",
"prepared_request",
",",
"resp",
")",
"# https://github.com/requests/requests/issues/1084",
"if",
"resp",
".",
"status_code",
"not",
"in",
"(",
"codes",
".",
"temporary_redirect",
",",
"codes",
".",
"permanent_redirect",
")",
":",
"# https://github.com/requests/requests/issues/3490",
"purged_headers",
"=",
"(",
"'Content-Length'",
",",
"'Content-Type'",
",",
"'Transfer-Encoding'",
")",
"for",
"header",
"in",
"purged_headers",
":",
"prepared_request",
".",
"headers",
".",
"pop",
"(",
"header",
",",
"None",
")",
"prepared_request",
".",
"body",
"=",
"None",
"headers",
"=",
"prepared_request",
".",
"headers",
"try",
":",
"del",
"headers",
"[",
"'Cookie'",
"]",
"except",
"KeyError",
":",
"pass",
"# Extract any cookies sent on the response to the cookiejar",
"# in the new request. Because we've mutated our copied prepared",
"# request, use the old one that we haven't yet touched.",
"extract_cookies_to_jar",
"(",
"prepared_request",
".",
"_cookies",
",",
"req",
",",
"resp",
".",
"raw",
")",
"merge_cookies",
"(",
"prepared_request",
".",
"_cookies",
",",
"self",
".",
"cookies",
")",
"prepared_request",
".",
"prepare_cookies",
"(",
"prepared_request",
".",
"_cookies",
")",
"# Rebuild auth and proxy information.",
"proxies",
"=",
"self",
".",
"rebuild_proxies",
"(",
"prepared_request",
",",
"proxies",
")",
"self",
".",
"rebuild_auth",
"(",
"prepared_request",
",",
"resp",
")",
"# A failed tell() sets `_body_position` to `object()`. This non-None",
"# value ensures `rewindable` will be True, allowing us to raise an",
"# UnrewindableBodyError, instead of hanging the connection.",
"rewindable",
"=",
"(",
"prepared_request",
".",
"_body_position",
"is",
"not",
"None",
"and",
"(",
"'Content-Length'",
"in",
"headers",
"or",
"'Transfer-Encoding'",
"in",
"headers",
")",
")",
"# Attempt to rewind consumed file-like object.",
"if",
"rewindable",
":",
"rewind_body",
"(",
"prepared_request",
")",
"# Override the original request.",
"req",
"=",
"prepared_request",
"if",
"yield_requests",
":",
"yield",
"req",
"else",
":",
"resp",
"=",
"self",
".",
"send",
"(",
"req",
",",
"stream",
"=",
"stream",
",",
"timeout",
"=",
"timeout",
",",
"verify",
"=",
"verify",
",",
"cert",
"=",
"cert",
",",
"proxies",
"=",
"proxies",
",",
"allow_redirects",
"=",
"False",
",",
"*",
"*",
"adapter_kwargs",
")",
"extract_cookies_to_jar",
"(",
"self",
".",
"cookies",
",",
"prepared_request",
",",
"resp",
".",
"raw",
")",
"# extract redirect url, if any, for the next loop",
"url",
"=",
"self",
".",
"get_redirect_target",
"(",
"resp",
")",
"yield",
"resp"
] | Receives a Response. Returns a generator of Responses or Requests. | [
"Receives",
"a",
"Response",
".",
"Returns",
"a",
"generator",
"of",
"Responses",
"or",
"Requests",
"."
] | train | https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/requests/sessions.py#L119-L225 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Receives a Response. Returns a generator of Responses or Requests.
### Response:
def resolve_redirects(self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):
"""Receives a Response. Returns a generator of Responses or Requests."""
hist = [] # keep track of history
url = self.get_redirect_target(resp)
while url:
prepared_request = req.copy()
# Update history and keep track of redirects.
# resp.history must ignore the original request in this loop
hist.append(resp)
resp.history = hist[1:]
try:
resp.content # Consume socket so it can be released
except (ChunkedEncodingError, ContentDecodingError, RuntimeError):
resp.raw.read(decode_content=False)
if len(resp.history) >= self.max_redirects:
raise TooManyRedirects('Exceeded %s redirects.' % self.max_redirects, response=resp)
# Release the connection back into the pool.
resp.close()
# Handle redirection without scheme (see: RFC 1808 Section 4)
if url.startswith('//'):
parsed_rurl = urlparse(resp.url)
url = '%s:%s' % (to_native_string(parsed_rurl.scheme), url)
# The scheme should be lower case...
parsed = urlparse(url)
url = parsed.geturl()
# Facilitate relative 'location' headers, as allowed by RFC 7231.
# (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')
# Compliant with RFC3986, we percent encode the url.
if not parsed.netloc:
url = urljoin(resp.url, requote_uri(url))
else:
url = requote_uri(url)
prepared_request.url = to_native_string(url)
self.rebuild_method(prepared_request, resp)
# https://github.com/requests/requests/issues/1084
if resp.status_code not in (codes.temporary_redirect, codes.permanent_redirect):
# https://github.com/requests/requests/issues/3490
purged_headers = ('Content-Length', 'Content-Type', 'Transfer-Encoding')
for header in purged_headers:
prepared_request.headers.pop(header, None)
prepared_request.body = None
headers = prepared_request.headers
try:
del headers['Cookie']
except KeyError:
pass
# Extract any cookies sent on the response to the cookiejar
# in the new request. Because we've mutated our copied prepared
# request, use the old one that we haven't yet touched.
extract_cookies_to_jar(prepared_request._cookies, req, resp.raw)
merge_cookies(prepared_request._cookies, self.cookies)
prepared_request.prepare_cookies(prepared_request._cookies)
# Rebuild auth and proxy information.
proxies = self.rebuild_proxies(prepared_request, proxies)
self.rebuild_auth(prepared_request, resp)
# A failed tell() sets `_body_position` to `object()`. This non-None
# value ensures `rewindable` will be True, allowing us to raise an
# UnrewindableBodyError, instead of hanging the connection.
rewindable = (
prepared_request._body_position is not None and
('Content-Length' in headers or 'Transfer-Encoding' in headers)
)
# Attempt to rewind consumed file-like object.
if rewindable:
rewind_body(prepared_request)
# Override the original request.
req = prepared_request
if yield_requests:
yield req
else:
resp = self.send(
req,
stream=stream,
timeout=timeout,
verify=verify,
cert=cert,
proxies=proxies,
allow_redirects=False,
**adapter_kwargs
)
extract_cookies_to_jar(self.cookies, prepared_request, resp.raw)
# extract redirect url, if any, for the next loop
url = self.get_redirect_target(resp)
yield resp
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
697,
346,
1924,
264,
6075,
13,
5295,
264,
14143,
315,
81567,
477,
51982,
382,
14711,
6075,
512,
755,
9006,
31143,
82,
1214,
11,
9216,
11,
4326,
11,
4365,
5725,
11,
9829,
5980,
345,
3586,
10356,
3702,
11,
2847,
5980,
11,
60465,
5980,
11,
7692,
38316,
5725,
11,
3146,
20311,
37335,
997,
286,
4304,
697,
346,
1924,
264,
6075,
13,
5295,
264,
14143,
315,
81567,
477,
51982,
30284,
286,
13034,
284,
3132,
220,
674,
2567,
3839,
315,
3925,
271,
286,
2576,
284,
659,
673,
31143,
11370,
20882,
340,
286,
1418,
2576,
512,
310,
10235,
8052,
284,
4326,
12511,
2892,
310,
674,
5666,
3925,
323,
2567,
3839,
315,
72271,
627,
310,
674,
9216,
24323,
2011,
10240,
279,
4113,
1715,
304,
420,
6471,
198,
310,
13034,
2102,
20882,
340,
310,
9216,
24323,
284,
13034,
58,
16,
65731,
310,
1456,
512,
394,
9216,
5521,
220,
674,
1221,
32423,
7728,
779,
433,
649,
387,
6004,
198,
310,
3734,
320,
29404,
291,
15032,
1480,
11,
9059,
5005,
3785,
1480,
11,
45643,
997,
394,
9216,
18648,
4217,
13089,
1889,
7647,
5725,
696,
310,
422,
2479,
20882,
24323,
8,
2669,
659,
6817,
31143,
82,
512,
394,
4933,
25619,
8607,
18195,
82,
493,
849,
95306,
1034,
82,
72271,
3238,
1034,
659,
6817,
31143,
82,
11,
2077,
28,
18744,
696,
310,
674,
17836,
279,
3717,
1203,
1139,
279,
7463,
627,
310,
9216,
4757,
2892,
310,
674,
14078,
85159,
2085,
13155,
320,
4151,
25,
40333,
220,
5245,
23,
11360,
220,
19,
340,
310,
422,
2576,
27249,
54379,
11290,
394,
16051,
1745,
1103,
284,
81167,
20882,
7464,
340,
394,
2576,
284,
7832,
82,
7685,
82,
6,
1034,
320,
998,
45594,
3991,
49562,
1745,
1103,
79281,
705,
2576,
696,
310,
674,
578,
13155,
1288,
387,
4827,
1162,
9522,
310,
16051,
284,
81167,
6659,
340,
310,
2576,
284,
16051,
673,
1103,
2892,
310,
674,
17375,
3748,
349,
8844,
364,
2588,
6,
7247,
11,
439,
5535,
555,
40333,
220,
24388,
16,
627,
310,
674,
320,
68,
1326,
13,
3434,
2398,
33529,
54200,
6,
4619,
315,
364,
1277,
1129,
12482,
739,
509,
52076,
33529,
54200,
1329,
310,
674,
1219,
60952,
449,
40333,
19838,
21,
11,
584,
3346,
16559,
279,
2576,
627,
310,
422,
539,
16051,
5181,
1092,
512,
394,
2576,
284,
2576,
6115,
20882,
7464,
11,
312,
3022,
15943,
6659,
1192,
310,
775,
512,
394,
2576,
284,
312,
3022,
15943,
6659,
696,
310,
10235,
8052,
7464,
284,
311,
45594,
3991,
6659,
696,
310,
659,
1351,
5957,
9209,
28759,
7360,
8052,
11,
9216,
696,
310,
674,
3788,
1129,
5316,
916,
14,
37342,
14,
37342,
39845,
14,
6640,
19,
198,
310,
422,
9216,
4397,
4229,
539,
304,
320,
26899,
739,
14084,
31143,
11,
14236,
558,
4858,
306,
31143,
997,
394,
674,
3788,
1129,
5316,
916,
14,
37342,
14,
37342,
39845,
14,
18634,
15,
198,
394,
4087,
3640,
27817,
284,
4417,
2831,
53593,
518,
364,
2831,
11038,
518,
364,
22737,
68458,
1329
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
697,
346,
1924,
264,
6075,
13,
5295,
264,
14143,
315,
81567,
477,
51982,
382,
14711,
6075,
512,
755,
9006,
31143,
82,
1214,
11,
9216,
11,
4326,
11,
4365,
5725,
11,
9829,
5980,
345,
3586,
10356,
3702,
11,
2847,
5980,
11,
60465,
5980,
11,
7692,
38316,
5725,
11,
3146,
20311,
37335,
997,
286,
4304,
697,
346,
1924,
264,
6075,
13,
5295,
264,
14143,
315,
81567,
477,
51982,
30284,
286,
13034,
284,
3132,
220,
674,
2567,
3839,
315,
3925,
271,
286,
2576,
284,
659,
673,
31143,
11370,
20882,
340,
286,
1418,
2576,
512,
310,
10235,
8052,
284,
4326,
12511,
2892,
310,
674,
5666,
3925,
323,
2567,
3839,
315,
72271,
627,
310,
674,
9216,
24323,
2011,
10240,
279,
4113,
1715,
304,
420,
6471,
198,
310,
13034,
2102,
20882,
340,
310,
9216,
24323,
284,
13034,
58,
16,
65731,
310,
1456,
512,
394,
9216,
5521,
220,
674,
1221,
32423,
7728,
779,
433,
649,
387,
6004,
198,
310,
3734,
320,
29404,
291,
15032,
1480,
11,
9059,
5005,
3785,
1480,
11,
45643,
997,
394,
9216,
18648,
4217,
13089,
1889,
7647,
5725,
696,
310,
422,
2479,
20882,
24323,
8,
2669,
659,
6817,
31143,
82,
512,
394,
4933,
25619,
8607,
18195,
82,
493,
849,
95306,
1034,
82,
72271,
3238,
1034,
659,
6817,
31143,
82,
11,
2077,
28,
18744,
696,
310,
674,
17836,
279,
3717,
1203,
1139,
279,
7463,
627,
310,
9216,
4757,
2892,
310,
674,
14078,
85159,
2085,
13155,
320,
4151,
25,
40333,
220,
5245,
23,
11360,
220,
19,
340,
310,
422,
2576,
27249,
54379,
11290,
394,
16051,
1745,
1103,
284,
81167,
20882,
7464,
340,
394,
2576,
284,
7832,
82,
7685,
82,
6,
1034,
320,
998,
45594,
3991,
49562,
1745,
1103,
79281,
705,
2576,
696,
310,
674,
578,
13155,
1288,
387,
4827,
1162,
9522,
310,
16051,
284,
81167,
6659,
340,
310,
2576,
284,
16051,
673,
1103,
2892,
310,
674,
17375,
3748,
349,
8844,
364,
2588,
6,
7247,
11,
439,
5535,
555,
40333,
220,
24388,
16,
627,
310,
674,
320,
68,
1326,
13,
3434,
2398,
33529,
54200,
6,
4619,
315,
364,
1277,
1129,
12482,
739,
509,
52076,
33529,
54200,
1329,
310,
674,
1219,
60952,
449,
40333,
19838,
21,
11,
584,
3346,
16559,
279,
2576,
627,
310,
422,
539,
16051,
5181,
1092,
512,
394,
2576,
284,
2576,
6115,
20882,
7464,
11,
312,
3022,
15943,
6659,
1192,
310,
775,
512,
394,
2576,
284,
312,
3022,
15943,
6659,
696,
310,
10235,
8052,
7464,
284,
311,
45594,
3991,
6659,
696,
310,
659,
1351,
5957,
9209,
28759,
7360,
8052,
11,
9216,
696,
310,
674,
3788,
1129,
5316,
916,
14,
37342,
14,
37342,
39845,
14,
6640,
19,
198,
310,
422,
9216,
4397,
4229,
539,
304,
320,
26899,
739,
14084,
31143,
11,
14236,
558,
4858,
306,
31143,
997,
394,
674,
3788,
1129,
5316,
916,
14,
37342,
14,
37342,
39845,
14,
18634,
15,
198,
394,
4087,
3640,
27817,
284,
4417,
2831,
53593,
518,
364,
2831,
11038,
518,
364,
22737,
68458,
1329
] |
pyviz/holoviews | holoviews/util/__init__.py | opts._element_keywords | def _element_keywords(cls, backend, elements=None):
"Returns a dictionary of element names to allowed keywords"
if backend not in Store.loaded_backends():
return {}
mapping = {}
backend_options = Store.options(backend)
elements = elements if elements is not None else backend_options.keys()
for element in elements:
if '.' in element: continue
element = element if isinstance(element, tuple) else (element,)
element_keywords = []
options = backend_options['.'.join(element)]
for group in Options._option_groups:
element_keywords.extend(options[group].allowed_keywords)
mapping[element[0]] = element_keywords
return mapping | python | def _element_keywords(cls, backend, elements=None):
"Returns a dictionary of element names to allowed keywords"
if backend not in Store.loaded_backends():
return {}
mapping = {}
backend_options = Store.options(backend)
elements = elements if elements is not None else backend_options.keys()
for element in elements:
if '.' in element: continue
element = element if isinstance(element, tuple) else (element,)
element_keywords = []
options = backend_options['.'.join(element)]
for group in Options._option_groups:
element_keywords.extend(options[group].allowed_keywords)
mapping[element[0]] = element_keywords
return mapping | [
"def",
"_element_keywords",
"(",
"cls",
",",
"backend",
",",
"elements",
"=",
"None",
")",
":",
"if",
"backend",
"not",
"in",
"Store",
".",
"loaded_backends",
"(",
")",
":",
"return",
"{",
"}",
"mapping",
"=",
"{",
"}",
"backend_options",
"=",
"Store",
".",
"options",
"(",
"backend",
")",
"elements",
"=",
"elements",
"if",
"elements",
"is",
"not",
"None",
"else",
"backend_options",
".",
"keys",
"(",
")",
"for",
"element",
"in",
"elements",
":",
"if",
"'.'",
"in",
"element",
":",
"continue",
"element",
"=",
"element",
"if",
"isinstance",
"(",
"element",
",",
"tuple",
")",
"else",
"(",
"element",
",",
")",
"element_keywords",
"=",
"[",
"]",
"options",
"=",
"backend_options",
"[",
"'.'",
".",
"join",
"(",
"element",
")",
"]",
"for",
"group",
"in",
"Options",
".",
"_option_groups",
":",
"element_keywords",
".",
"extend",
"(",
"options",
"[",
"group",
"]",
".",
"allowed_keywords",
")",
"mapping",
"[",
"element",
"[",
"0",
"]",
"]",
"=",
"element_keywords",
"return",
"mapping"
] | Returns a dictionary of element names to allowed keywords | [
"Returns",
"a",
"dictionary",
"of",
"element",
"names",
"to",
"allowed",
"keywords"
] | train | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/util/__init__.py#L494-L511 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Returns a dictionary of element names to allowed keywords
### Response:
def _element_keywords(cls, backend, elements=None):
"Returns a dictionary of element names to allowed keywords"
if backend not in Store.loaded_backends():
return {}
mapping = {}
backend_options = Store.options(backend)
elements = elements if elements is not None else backend_options.keys()
for element in elements:
if '.' in element: continue
element = element if isinstance(element, tuple) else (element,)
element_keywords = []
options = backend_options['.'.join(element)]
for group in Options._option_groups:
element_keywords.extend(options[group].allowed_keywords)
mapping[element[0]] = element_keywords
return mapping
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
264,
11240,
315,
2449,
5144,
311,
5535,
21513,
271,
14711,
6075,
512,
755,
721,
6229,
52454,
21024,
11,
19713,
11,
5540,
5980,
997,
286,
330,
16851,
264,
11240,
315,
2449,
5144,
311,
5535,
21513,
702,
286,
422,
19713,
539,
304,
9307,
61979,
3982,
1438,
4019,
310,
471,
10294,
286,
13021,
284,
5731,
286,
19713,
8917,
284,
9307,
11152,
7,
21615,
340,
286,
5540,
284,
5540,
422,
5540,
374,
539,
2290,
775,
19713,
8917,
9301,
746,
286,
369,
2449,
304,
5540,
512,
310,
422,
25360,
304,
2449,
25,
3136,
198,
310,
2449,
284,
2449,
422,
11656,
11747,
11,
14743,
8,
775,
320,
6229,
55245,
310,
2449,
52454,
284,
4260,
310,
2671,
284,
19713,
8917,
681,
37049,
6115,
11747,
5680,
310,
369,
1912,
304,
14908,
1462,
2091,
21833,
512,
394,
2449,
52454,
16209,
12349,
74792,
948,
21642,
52454,
696,
310,
13021,
81202,
58,
15,
5163,
284,
2449,
52454,
198,
286,
471,
13021,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
264,
11240,
315,
2449,
5144,
311,
5535,
21513,
271,
14711,
6075,
512,
755,
721,
6229,
52454,
21024,
11,
19713,
11,
5540,
5980,
997,
286,
330,
16851,
264,
11240,
315,
2449,
5144,
311,
5535,
21513,
702,
286,
422,
19713,
539,
304,
9307,
61979,
3982,
1438,
4019,
310,
471,
10294,
286,
13021,
284,
5731,
286,
19713,
8917,
284,
9307,
11152,
7,
21615,
340,
286,
5540,
284,
5540,
422,
5540,
374,
539,
2290,
775,
19713,
8917,
9301,
746,
286,
369,
2449,
304,
5540,
512,
310,
422,
25360,
304,
2449,
25,
3136,
198,
310,
2449,
284,
2449,
422,
11656,
11747,
11,
14743,
8,
775,
320,
6229,
55245,
310,
2449,
52454,
284,
4260,
310,
2671,
284,
19713,
8917,
681,
37049,
6115,
11747,
5680,
310,
369,
1912,
304,
14908,
1462,
2091,
21833,
512,
394,
2449,
52454,
16209,
12349,
74792,
948,
21642,
52454,
696,
310,
13021,
81202,
58,
15,
5163,
284,
2449,
52454,
198,
286,
471,
13021,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py | mavfile.set_mode_px4 | def set_mode_px4(self, mode, custom_mode, custom_sub_mode):
'''enter arbitrary mode'''
if isinstance(mode, str):
mode_map = self.mode_mapping()
if mode_map is None or mode not in mode_map:
print("Unknown mode '%s'" % mode)
return
# PX4 uses two fields to define modes
mode, custom_mode, custom_sub_mode = px4_map[mode]
self.mav.command_long_send(self.target_system, self.target_component,
mavlink.MAV_CMD_DO_SET_MODE, 0, mode, custom_mode, custom_sub_mode, 0, 0, 0, 0) | python | def set_mode_px4(self, mode, custom_mode, custom_sub_mode):
'''enter arbitrary mode'''
if isinstance(mode, str):
mode_map = self.mode_mapping()
if mode_map is None or mode not in mode_map:
print("Unknown mode '%s'" % mode)
return
# PX4 uses two fields to define modes
mode, custom_mode, custom_sub_mode = px4_map[mode]
self.mav.command_long_send(self.target_system, self.target_component,
mavlink.MAV_CMD_DO_SET_MODE, 0, mode, custom_mode, custom_sub_mode, 0, 0, 0, 0) | [
"def",
"set_mode_px4",
"(",
"self",
",",
"mode",
",",
"custom_mode",
",",
"custom_sub_mode",
")",
":",
"if",
"isinstance",
"(",
"mode",
",",
"str",
")",
":",
"mode_map",
"=",
"self",
".",
"mode_mapping",
"(",
")",
"if",
"mode_map",
"is",
"None",
"or",
"mode",
"not",
"in",
"mode_map",
":",
"print",
"(",
"\"Unknown mode '%s'\"",
"%",
"mode",
")",
"return",
"# PX4 uses two fields to define modes",
"mode",
",",
"custom_mode",
",",
"custom_sub_mode",
"=",
"px4_map",
"[",
"mode",
"]",
"self",
".",
"mav",
".",
"command_long_send",
"(",
"self",
".",
"target_system",
",",
"self",
".",
"target_component",
",",
"mavlink",
".",
"MAV_CMD_DO_SET_MODE",
",",
"0",
",",
"mode",
",",
"custom_mode",
",",
"custom_sub_mode",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")"
] | enter arbitrary mode | [
"enter",
"arbitrary",
"mode"
] | train | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L531-L541 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
enter arbitrary mode
### Response:
def set_mode_px4(self, mode, custom_mode, custom_sub_mode):
'''enter arbitrary mode'''
if isinstance(mode, str):
mode_map = self.mode_mapping()
if mode_map is None or mode not in mode_map:
print("Unknown mode '%s'" % mode)
return
# PX4 uses two fields to define modes
mode, custom_mode, custom_sub_mode = px4_map[mode]
self.mav.command_long_send(self.target_system, self.target_component,
mavlink.MAV_CMD_DO_SET_MODE, 0, mode, custom_mode, custom_sub_mode, 0, 0, 0, 0)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1992,
25142,
3941,
271,
14711,
6075,
512,
755,
743,
7450,
68262,
19,
1214,
11,
3941,
11,
2587,
7450,
11,
2587,
5341,
7450,
997,
286,
11712,
1992,
25142,
3941,
15029,
286,
422,
11656,
32456,
11,
610,
997,
310,
3941,
5489,
284,
659,
23841,
28028,
746,
310,
422,
3941,
5489,
374,
2290,
477,
3941,
539,
304,
3941,
5489,
512,
394,
1194,
446,
14109,
3941,
7832,
82,
15260,
1034,
3941,
340,
394,
471,
198,
310,
674,
56584,
19,
5829,
1403,
5151,
311,
7124,
20362,
198,
310,
3941,
11,
2587,
7450,
11,
2587,
5341,
7450,
284,
17585,
19,
5489,
58,
8684,
933,
286,
659,
749,
402,
14475,
18278,
13877,
1214,
6676,
18155,
11,
659,
6676,
24297,
345,
9898,
59470,
2125,
1345,
8253,
16748,
22573,
8648,
8580,
11,
220,
15,
11,
3941,
11,
2587,
7450,
11,
2587,
5341,
7450,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1992,
25142,
3941,
271,
14711,
6075,
512,
755,
743,
7450,
68262,
19,
1214,
11,
3941,
11,
2587,
7450,
11,
2587,
5341,
7450,
997,
286,
11712,
1992,
25142,
3941,
15029,
286,
422,
11656,
32456,
11,
610,
997,
310,
3941,
5489,
284,
659,
23841,
28028,
746,
310,
422,
3941,
5489,
374,
2290,
477,
3941,
539,
304,
3941,
5489,
512,
394,
1194,
446,
14109,
3941,
7832,
82,
15260,
1034,
3941,
340,
394,
471,
198,
310,
674,
56584,
19,
5829,
1403,
5151,
311,
7124,
20362,
198,
310,
3941,
11,
2587,
7450,
11,
2587,
5341,
7450,
284,
17585,
19,
5489,
58,
8684,
933,
286,
659,
749,
402,
14475,
18278,
13877,
1214,
6676,
18155,
11,
659,
6676,
24297,
345,
9898,
59470,
2125,
1345,
8253,
16748,
22573,
8648,
8580,
11,
220,
15,
11,
3941,
11,
2587,
7450,
11,
2587,
5341,
7450,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Titan-C/slaveparticles | slaveparticles/utils/plotter.py | pick_flat_z | def pick_flat_z(data):
"""Generate a 2D array of the quasiparticle weight by only selecting the
first particle data"""
zmes = []
for i in data['zeta']:
zmes.append(i[:, 0])
return np.asarray(zmes) | python | def pick_flat_z(data):
"""Generate a 2D array of the quasiparticle weight by only selecting the
first particle data"""
zmes = []
for i in data['zeta']:
zmes.append(i[:, 0])
return np.asarray(zmes) | [
"def",
"pick_flat_z",
"(",
"data",
")",
":",
"zmes",
"=",
"[",
"]",
"for",
"i",
"in",
"data",
"[",
"'zeta'",
"]",
":",
"zmes",
".",
"append",
"(",
"i",
"[",
":",
",",
"0",
"]",
")",
"return",
"np",
".",
"asarray",
"(",
"zmes",
")"
] | Generate a 2D array of the quasiparticle weight by only selecting the
first particle data | [
"Generate",
"a",
"2D",
"array",
"of",
"the",
"quasiparticle",
"weight",
"by",
"only",
"selecting",
"the",
"first",
"particle",
"data"
] | train | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/utils/plotter.py#L67-L73 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Generate a 2D array of the quasiparticle weight by only selecting the
first particle data
### Response:
def pick_flat_z(data):
"""Generate a 2D array of the quasiparticle weight by only selecting the
first particle data"""
zmes = []
for i in data['zeta']:
zmes.append(i[:, 0])
return np.asarray(zmes)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32215,
264,
220,
17,
35,
1358,
315,
279,
934,
300,
575,
7203,
4785,
555,
1193,
27397,
279,
198,
262,
1176,
19320,
828,
271,
14711,
6075,
512,
755,
3820,
50656,
6551,
2657,
997,
262,
4304,
32215,
264,
220,
17,
35,
1358,
315,
279,
934,
300,
575,
7203,
4785,
555,
1193,
27397,
279,
198,
262,
1176,
19320,
828,
7275,
262,
1167,
9004,
284,
4260,
262,
369,
602,
304,
828,
681,
89,
1955,
18888,
286,
1167,
9004,
2102,
1998,
9821,
220,
15,
2608,
262,
471,
2660,
39178,
13476,
9004,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32215,
264,
220,
17,
35,
1358,
315,
279,
934,
300,
575,
7203,
4785,
555,
1193,
27397,
279,
198,
262,
1176,
19320,
828,
271,
14711,
6075,
512,
755,
3820,
50656,
6551,
2657,
997,
262,
4304,
32215,
264,
220,
17,
35,
1358,
315,
279,
934,
300,
575,
7203,
4785,
555,
1193,
27397,
279,
198,
262,
1176,
19320,
828,
7275,
262,
1167,
9004,
284,
4260,
262,
369,
602,
304,
828,
681,
89,
1955,
18888,
286,
1167,
9004,
2102,
1998,
9821,
220,
15,
2608,
262,
471,
2660,
39178,
13476,
9004,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
KrishnaswamyLab/PHATE | Python/phate/phate.py | PHATE.von_neumann_entropy | def von_neumann_entropy(self, t_max=100):
"""Calculate Von Neumann Entropy
Determines the Von Neumann entropy of the diffusion affinities
at varying levels of `t`. The user should select a value of `t`
around the "knee" of the entropy curve.
We require that 'fit' stores the value of `PHATE.diff_op`
in order to calculate the Von Neumann entropy.
Parameters
----------
t_max : int, default: 100
Maximum value of `t` to test
Returns
-------
entropy : array, shape=[t_max]
The entropy of the diffusion affinities for each value of `t`
"""
t = np.arange(t_max)
return t, vne.compute_von_neumann_entropy(self.diff_op, t_max=t_max) | python | def von_neumann_entropy(self, t_max=100):
"""Calculate Von Neumann Entropy
Determines the Von Neumann entropy of the diffusion affinities
at varying levels of `t`. The user should select a value of `t`
around the "knee" of the entropy curve.
We require that 'fit' stores the value of `PHATE.diff_op`
in order to calculate the Von Neumann entropy.
Parameters
----------
t_max : int, default: 100
Maximum value of `t` to test
Returns
-------
entropy : array, shape=[t_max]
The entropy of the diffusion affinities for each value of `t`
"""
t = np.arange(t_max)
return t, vne.compute_von_neumann_entropy(self.diff_op, t_max=t_max) | [
"def",
"von_neumann_entropy",
"(",
"self",
",",
"t_max",
"=",
"100",
")",
":",
"t",
"=",
"np",
".",
"arange",
"(",
"t_max",
")",
"return",
"t",
",",
"vne",
".",
"compute_von_neumann_entropy",
"(",
"self",
".",
"diff_op",
",",
"t_max",
"=",
"t_max",
")"
] | Calculate Von Neumann Entropy
Determines the Von Neumann entropy of the diffusion affinities
at varying levels of `t`. The user should select a value of `t`
around the "knee" of the entropy curve.
We require that 'fit' stores the value of `PHATE.diff_op`
in order to calculate the Von Neumann entropy.
Parameters
----------
t_max : int, default: 100
Maximum value of `t` to test
Returns
-------
entropy : array, shape=[t_max]
The entropy of the diffusion affinities for each value of `t` | [
"Calculate",
"Von",
"Neumann",
"Entropy"
] | train | https://github.com/KrishnaswamyLab/PHATE/blob/346a4597dcfc523f8bef99bce482e677282b6719/Python/phate/phate.py#L865-L886 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Calculate Von Neumann Entropy
Determines the Von Neumann entropy of the diffusion affinities
at varying levels of `t`. The user should select a value of `t`
around the "knee" of the entropy curve.
We require that 'fit' stores the value of `PHATE.diff_op`
in order to calculate the Von Neumann entropy.
Parameters
----------
t_max : int, default: 100
Maximum value of `t` to test
Returns
-------
entropy : array, shape=[t_max]
The entropy of the diffusion affinities for each value of `t`
### Response:
def von_neumann_entropy(self, t_max=100):
"""Calculate Von Neumann Entropy
Determines the Von Neumann entropy of the diffusion affinities
at varying levels of `t`. The user should select a value of `t`
around the "knee" of the entropy curve.
We require that 'fit' stores the value of `PHATE.diff_op`
in order to calculate the Von Neumann entropy.
Parameters
----------
t_max : int, default: 100
Maximum value of `t` to test
Returns
-------
entropy : array, shape=[t_max]
The entropy of the diffusion affinities for each value of `t`
"""
t = np.arange(t_max)
return t, vne.compute_von_neumann_entropy(self.diff_op, t_max=t_max)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
48966,
43179,
4275,
64607,
4968,
18237,
271,
286,
53812,
279,
43179,
4275,
64607,
48602,
315,
279,
58430,
3611,
258,
1385,
198,
286,
520,
29865,
5990,
315,
1595,
83,
29687,
578,
1217,
1288,
3373,
264,
907,
315,
1595,
83,
4077,
286,
2212,
279,
330,
74,
34191,
1,
315,
279,
48602,
16029,
382,
286,
1226,
1397,
430,
364,
6410,
6,
10756,
279,
907,
315,
1595,
11079,
2390,
41779,
10499,
4077,
286,
304,
2015,
311,
11294,
279,
43179,
4275,
64607,
48602,
382,
286,
13831,
198,
286,
31423,
286,
259,
6479,
551,
528,
11,
1670,
25,
220,
1041,
198,
310,
27697,
907,
315,
1595,
83,
63,
311,
1296,
271,
286,
5295,
198,
286,
39707,
286,
48602,
551,
1358,
11,
6211,
5941,
83,
6479,
933,
310,
578,
48602,
315,
279,
58430,
3611,
258,
1385,
369,
1855,
907,
315,
1595,
83,
19884,
14711,
6075,
512,
755,
6675,
14250,
64607,
51474,
1214,
11,
259,
6479,
28,
1041,
997,
286,
4304,
48966,
43179,
4275,
64607,
4968,
18237,
271,
286,
53812,
279,
43179,
4275,
64607,
48602,
315,
279,
58430,
3611,
258,
1385,
198,
286,
520,
29865,
5990,
315,
1595,
83,
29687,
578,
1217,
1288,
3373,
264,
907,
315,
1595,
83,
4077,
286,
2212,
279,
330,
74,
34191,
1,
315,
279,
48602,
16029,
382,
286,
1226,
1397,
430,
364,
6410,
6,
10756,
279,
907,
315,
1595,
11079,
2390,
41779,
10499,
4077,
286,
304,
2015,
311,
11294,
279,
43179,
4275,
64607,
48602,
382,
286,
13831,
198,
286,
31423,
286,
259,
6479,
551,
528,
11,
1670,
25,
220,
1041,
198,
310,
27697,
907,
315,
1595,
83,
63,
311,
1296,
271,
286,
5295,
198,
286,
39707,
286,
48602,
551,
1358,
11,
6211,
5941,
83,
6479,
933,
310,
578,
48602,
315,
279,
58430,
3611,
258,
1385,
369,
1855,
907,
315,
1595,
83,
4077,
286,
3270,
286,
259,
284,
2660,
25306,
1175,
6479,
340,
286,
471,
259,
11,
348,
818,
36447,
2325,
263,
14250,
64607,
51474,
1214,
41779,
10499,
11,
259,
6479,
24957,
6479,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
48966,
43179,
4275,
64607,
4968,
18237,
271,
286,
53812,
279,
43179,
4275,
64607,
48602,
315,
279,
58430,
3611,
258,
1385,
198,
286,
520,
29865,
5990,
315,
1595,
83,
29687,
578,
1217,
1288,
3373,
264,
907,
315,
1595,
83,
4077,
286,
2212,
279,
330,
74,
34191,
1,
315,
279,
48602,
16029,
382,
286,
1226,
1397,
430,
364,
6410,
6,
10756,
279,
907,
315,
1595,
11079,
2390,
41779,
10499,
4077,
286,
304,
2015,
311,
11294,
279,
43179,
4275,
64607,
48602,
382,
286,
13831,
198,
286,
31423,
286,
259,
6479,
551,
528,
11,
1670,
25,
220,
1041,
198,
310,
27697,
907,
315,
1595,
83,
63,
311,
1296,
271,
286,
5295,
198,
286,
39707,
286,
48602,
551,
1358,
11,
6211,
5941,
83,
6479,
933,
310,
578,
48602,
315,
279,
58430,
3611,
258,
1385,
369,
1855,
907,
315,
1595,
83,
19884,
14711,
6075,
512,
755,
6675,
14250,
64607,
51474,
1214,
11,
259,
6479,
28,
1041,
997,
286,
4304,
48966,
43179,
4275,
64607,
4968,
18237,
271,
286,
53812,
279,
43179,
4275,
64607,
48602,
315,
279,
58430,
3611,
258,
1385,
198,
286,
520,
29865,
5990,
315,
1595,
83,
29687,
578,
1217,
1288,
3373,
264,
907,
315,
1595,
83,
4077,
286,
2212,
279,
330,
74,
34191,
1,
315,
279,
48602,
16029,
382,
286,
1226,
1397,
430,
364,
6410,
6,
10756,
279,
907,
315,
1595,
11079,
2390,
41779,
10499,
4077,
286,
304,
2015,
311,
11294,
279,
43179,
4275,
64607,
48602,
382,
286,
13831,
198,
286,
31423,
286,
259,
6479,
551,
528,
11,
1670,
25,
220,
1041,
198,
310,
27697,
907,
315,
1595,
83,
63,
311,
1296,
271,
286,
5295,
198,
286,
39707,
286,
48602,
551,
1358,
11,
6211,
5941,
83,
6479,
933,
310,
578,
48602,
315,
279,
58430,
3611,
258,
1385,
369,
1855,
907,
315,
1595,
83,
4077,
286,
3270,
286,
259,
284,
2660,
25306,
1175,
6479,
340,
286,
471,
259,
11,
348,
818,
36447,
2325,
263,
14250,
64607,
51474,
1214,
41779,
10499,
11,
259,
6479,
24957,
6479,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/shaders/variable.py | Varying.link | def link(self, var):
""" Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``.
"""
assert self._dtype is not None or hasattr(var, 'dtype')
self._link = var
self.changed() | python | def link(self, var):
""" Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``.
"""
assert self._dtype is not None or hasattr(var, 'dtype')
self._link = var
self.changed() | [
"def",
"link",
"(",
"self",
",",
"var",
")",
":",
"assert",
"self",
".",
"_dtype",
"is",
"not",
"None",
"or",
"hasattr",
"(",
"var",
",",
"'dtype'",
")",
"self",
".",
"_link",
"=",
"var",
"self",
".",
"changed",
"(",
")"
] | Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``. | [
"Link",
"this",
"Varying",
"to",
"another",
"object",
"from",
"which",
"it",
"will",
"derive",
"its",
"dtype",
".",
"This",
"method",
"is",
"used",
"internally",
"when",
"assigning",
"an",
"attribute",
"to",
"a",
"varying",
"using",
"syntax",
"Function",
"[",
"varying",
"]",
"=",
"attr",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/shaders/variable.py#L207-L214 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``.
### Response:
def link(self, var):
""" Link this Varying to another object from which it will derive its
dtype. This method is used internally when assigning an attribute to
a varying using syntax ``Function[varying] = attr``.
"""
assert self._dtype is not None or hasattr(var, 'dtype')
self._link = var
self.changed()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4026,
420,
650,
661,
287,
311,
2500,
1665,
505,
902,
433,
690,
43530,
1202,
198,
286,
13534,
13,
1115,
1749,
374,
1511,
34167,
994,
61853,
459,
7180,
311,
198,
286,
264,
29865,
1701,
20047,
10103,
5263,
16936,
661,
287,
60,
284,
6510,
14196,
382,
14711,
6075,
512,
755,
2723,
1214,
11,
767,
997,
286,
4304,
6074,
420,
650,
661,
287,
311,
2500,
1665,
505,
902,
433,
690,
43530,
1202,
198,
286,
13534,
13,
1115,
1749,
374,
1511,
34167,
994,
61853,
459,
7180,
311,
198,
286,
264,
29865,
1701,
20047,
10103,
5263,
16936,
661,
287,
60,
284,
6510,
14196,
627,
286,
3270,
286,
2105,
659,
1462,
48827,
374,
539,
2290,
477,
32156,
7689,
11,
364,
48827,
1329,
286,
659,
1462,
2125,
284,
767,
198,
286,
659,
69316,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4026,
420,
650,
661,
287,
311,
2500,
1665,
505,
902,
433,
690,
43530,
1202,
198,
286,
13534,
13,
1115,
1749,
374,
1511,
34167,
994,
61853,
459,
7180,
311,
198,
286,
264,
29865,
1701,
20047,
10103,
5263,
16936,
661,
287,
60,
284,
6510,
14196,
382,
14711,
6075,
512,
755,
2723,
1214,
11,
767,
997,
286,
4304,
6074,
420,
650,
661,
287,
311,
2500,
1665,
505,
902,
433,
690,
43530,
1202,
198,
286,
13534,
13,
1115,
1749,
374,
1511,
34167,
994,
61853,
459,
7180,
311,
198,
286,
264,
29865,
1701,
20047,
10103,
5263,
16936,
661,
287,
60,
284,
6510,
14196,
627,
286,
3270,
286,
2105,
659,
1462,
48827,
374,
539,
2290,
477,
32156,
7689,
11,
364,
48827,
1329,
286,
659,
1462,
2125,
284,
767,
198,
286,
659,
69316,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
tophatmonocle/ims_lti_py | ims_lti_py/tool_consumer.py | ToolConsumer.set_config | def set_config(self, config):
'''
Set launch data from a ToolConfig.
'''
if self.launch_url == None:
self.launch_url = config.launch_url
self.custom_params.update(config.custom_params) | python | def set_config(self, config):
'''
Set launch data from a ToolConfig.
'''
if self.launch_url == None:
self.launch_url = config.launch_url
self.custom_params.update(config.custom_params) | [
"def",
"set_config",
"(",
"self",
",",
"config",
")",
":",
"if",
"self",
".",
"launch_url",
"==",
"None",
":",
"self",
".",
"launch_url",
"=",
"config",
".",
"launch_url",
"self",
".",
"custom_params",
".",
"update",
"(",
"config",
".",
"custom_params",
")"
] | Set launch data from a ToolConfig. | [
"Set",
"launch",
"data",
"from",
"a",
"ToolConfig",
"."
] | train | https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_consumer.py#L38-L44 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Set launch data from a ToolConfig.
### Response:
def set_config(self, config):
'''
Set launch data from a ToolConfig.
'''
if self.launch_url == None:
self.launch_url = config.launch_url
self.custom_params.update(config.custom_params)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1681,
7195,
828,
505,
264,
13782,
2714,
382,
14711,
6075,
512,
755,
743,
5445,
1214,
11,
2242,
997,
286,
11414,
286,
2638,
7195,
828,
505,
264,
13782,
2714,
627,
286,
11414,
286,
422,
659,
37552,
2975,
624,
2290,
512,
310,
659,
37552,
2975,
284,
2242,
37552,
2975,
198,
310,
659,
25254,
6887,
5430,
8928,
25254,
6887,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1681,
7195,
828,
505,
264,
13782,
2714,
382,
14711,
6075,
512,
755,
743,
5445,
1214,
11,
2242,
997,
286,
11414,
286,
2638,
7195,
828,
505,
264,
13782,
2714,
627,
286,
11414,
286,
422,
659,
37552,
2975,
624,
2290,
512,
310,
659,
37552,
2975,
284,
2242,
37552,
2975,
198,
310,
659,
25254,
6887,
5430,
8928,
25254,
6887,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
openstack/monasca-common | monasca_common/kafka_lib/protocol.py | create_gzip_message | def create_gzip_message(payloads, key=None, compresslevel=None):
"""
Construct a Gzipped Message containing multiple Messages
The given payloads will be encoded, compressed, and sent as a single atomic
message to Kafka.
Arguments:
payloads: list(bytes), a list of payload to send be sent to Kafka
key: bytes, a key used for partition routing (optional)
"""
message_set = KafkaProtocol._encode_message_set(
[create_message(payload, pl_key) for payload, pl_key in payloads])
gzipped = gzip_encode(message_set, compresslevel=compresslevel)
codec = ATTRIBUTE_CODEC_MASK & CODEC_GZIP
return Message(0, 0x00 | codec, key, gzipped) | python | def create_gzip_message(payloads, key=None, compresslevel=None):
"""
Construct a Gzipped Message containing multiple Messages
The given payloads will be encoded, compressed, and sent as a single atomic
message to Kafka.
Arguments:
payloads: list(bytes), a list of payload to send be sent to Kafka
key: bytes, a key used for partition routing (optional)
"""
message_set = KafkaProtocol._encode_message_set(
[create_message(payload, pl_key) for payload, pl_key in payloads])
gzipped = gzip_encode(message_set, compresslevel=compresslevel)
codec = ATTRIBUTE_CODEC_MASK & CODEC_GZIP
return Message(0, 0x00 | codec, key, gzipped) | [
"def",
"create_gzip_message",
"(",
"payloads",
",",
"key",
"=",
"None",
",",
"compresslevel",
"=",
"None",
")",
":",
"message_set",
"=",
"KafkaProtocol",
".",
"_encode_message_set",
"(",
"[",
"create_message",
"(",
"payload",
",",
"pl_key",
")",
"for",
"payload",
",",
"pl_key",
"in",
"payloads",
"]",
")",
"gzipped",
"=",
"gzip_encode",
"(",
"message_set",
",",
"compresslevel",
"=",
"compresslevel",
")",
"codec",
"=",
"ATTRIBUTE_CODEC_MASK",
"&",
"CODEC_GZIP",
"return",
"Message",
"(",
"0",
",",
"0x00",
"|",
"codec",
",",
"key",
",",
"gzipped",
")"
] | Construct a Gzipped Message containing multiple Messages
The given payloads will be encoded, compressed, and sent as a single atomic
message to Kafka.
Arguments:
payloads: list(bytes), a list of payload to send be sent to Kafka
key: bytes, a key used for partition routing (optional) | [
"Construct",
"a",
"Gzipped",
"Message",
"containing",
"multiple",
"Messages"
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/protocol.py#L601-L619 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Construct a Gzipped Message containing multiple Messages
The given payloads will be encoded, compressed, and sent as a single atomic
message to Kafka.
Arguments:
payloads: list(bytes), a list of payload to send be sent to Kafka
key: bytes, a key used for partition routing (optional)
### Response:
def create_gzip_message(payloads, key=None, compresslevel=None):
"""
Construct a Gzipped Message containing multiple Messages
The given payloads will be encoded, compressed, and sent as a single atomic
message to Kafka.
Arguments:
payloads: list(bytes), a list of payload to send be sent to Kafka
key: bytes, a key used for partition routing (optional)
"""
message_set = KafkaProtocol._encode_message_set(
[create_message(payload, pl_key) for payload, pl_key in payloads])
gzipped = gzip_encode(message_set, compresslevel=compresslevel)
codec = ATTRIBUTE_CODEC_MASK & CODEC_GZIP
return Message(0, 0x00 | codec, key, gzipped)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
29568,
264,
480,
89,
6586,
4961,
8649,
5361,
27827,
271,
262,
578,
2728,
90623,
690,
387,
21136,
11,
31749,
11,
323,
3288,
439,
264,
3254,
25524,
198,
262,
1984,
311,
58125,
382,
262,
28802,
512,
286,
90623,
25,
1160,
24033,
705,
264,
1160,
315,
7885,
311,
3708,
387,
3288,
311,
58125,
198,
286,
1401,
25,
5943,
11,
264,
1401,
1511,
369,
17071,
30158,
320,
13099,
696,
14711,
6075,
512,
755,
1893,
1928,
10169,
6598,
27870,
82,
11,
1401,
5980,
11,
25633,
3374,
5980,
997,
262,
3270,
262,
19196,
264,
480,
89,
6586,
4961,
8649,
5361,
27827,
271,
262,
578,
2728,
90623,
690,
387,
21136,
11,
31749,
11,
323,
3288,
439,
264,
3254,
25524,
198,
262,
1984,
311,
58125,
382,
262,
28802,
512,
286,
90623,
25,
1160,
24033,
705,
264,
1160,
315,
7885,
311,
3708,
387,
3288,
311,
58125,
198,
286,
1401,
25,
5943,
11,
264,
1401,
1511,
369,
17071,
30158,
320,
13099,
696,
262,
3270,
262,
1984,
2667,
284,
58125,
21346,
1462,
6311,
6598,
2667,
1021,
286,
510,
3261,
6598,
27870,
11,
628,
3173,
8,
369,
7885,
11,
628,
3173,
304,
90623,
9801,
262,
78063,
6586,
284,
58895,
11473,
7483,
2667,
11,
25633,
3374,
28,
39460,
3374,
340,
262,
35747,
284,
85911,
69299,
11982,
612,
14083,
34,
2712,
62685,
271,
262,
471,
4961,
7,
15,
11,
220,
15,
87,
410,
765,
35747,
11,
1401,
11,
78063,
6586,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
29568,
264,
480,
89,
6586,
4961,
8649,
5361,
27827,
271,
262,
578,
2728,
90623,
690,
387,
21136,
11,
31749,
11,
323,
3288,
439,
264,
3254,
25524,
198,
262,
1984,
311,
58125,
382,
262,
28802,
512,
286,
90623,
25,
1160,
24033,
705,
264,
1160,
315,
7885,
311,
3708,
387,
3288,
311,
58125,
198,
286,
1401,
25,
5943,
11,
264,
1401,
1511,
369,
17071,
30158,
320,
13099,
696,
14711,
6075,
512,
755,
1893,
1928,
10169,
6598,
27870,
82,
11,
1401,
5980,
11,
25633,
3374,
5980,
997,
262,
3270,
262,
19196,
264,
480,
89,
6586,
4961,
8649,
5361,
27827,
271,
262,
578,
2728,
90623,
690,
387,
21136,
11,
31749,
11,
323,
3288,
439,
264,
3254,
25524,
198,
262,
1984,
311,
58125,
382,
262,
28802,
512,
286,
90623,
25,
1160,
24033,
705,
264,
1160,
315,
7885,
311,
3708,
387,
3288,
311,
58125,
198,
286,
1401,
25,
5943,
11,
264,
1401,
1511,
369,
17071,
30158,
320,
13099,
696,
262,
3270,
262,
1984,
2667,
284,
58125,
21346,
1462,
6311,
6598,
2667,
1021,
286,
510,
3261,
6598,
27870,
11,
628,
3173,
8,
369,
7885,
11,
628,
3173,
304,
90623,
9801,
262,
78063,
6586,
284,
58895,
11473,
7483,
2667,
11,
25633,
3374,
28,
39460,
3374,
340,
262,
35747,
284,
85911,
69299,
11982,
612,
14083,
34,
2712,
62685,
271,
262,
471,
4961,
7,
15,
11,
220,
15,
87,
410,
765,
35747,
11,
1401,
11,
78063,
6586,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
bwohlberg/sporco | sporco/admm/admm.py | ADMM.rsdl_sn | def rsdl_sn(self, U):
"""Compute dual residual normalisation term.
Overriding this method is required if methods :meth:`cnst_A`,
:meth:`cnst_AT`, :meth:`cnst_B`, and :meth:`cnst_c` are not
overridden.
"""
return self.rho * np.linalg.norm(self.cnst_AT(U)) | python | def rsdl_sn(self, U):
"""Compute dual residual normalisation term.
Overriding this method is required if methods :meth:`cnst_A`,
:meth:`cnst_AT`, :meth:`cnst_B`, and :meth:`cnst_c` are not
overridden.
"""
return self.rho * np.linalg.norm(self.cnst_AT(U)) | [
"def",
"rsdl_sn",
"(",
"self",
",",
"U",
")",
":",
"return",
"self",
".",
"rho",
"*",
"np",
".",
"linalg",
".",
"norm",
"(",
"self",
".",
"cnst_AT",
"(",
"U",
")",
")"
] | Compute dual residual normalisation term.
Overriding this method is required if methods :meth:`cnst_A`,
:meth:`cnst_AT`, :meth:`cnst_B`, and :meth:`cnst_c` are not
overridden. | [
"Compute",
"dual",
"residual",
"normalisation",
"term",
"."
] | train | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/admm.py#L766-L774 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Compute dual residual normalisation term.
Overriding this method is required if methods :meth:`cnst_A`,
:meth:`cnst_AT`, :meth:`cnst_B`, and :meth:`cnst_c` are not
overridden.
### Response:
def rsdl_sn(self, U):
"""Compute dual residual normalisation term.
Overriding this method is required if methods :meth:`cnst_A`,
:meth:`cnst_AT`, :meth:`cnst_B`, and :meth:`cnst_c` are not
overridden.
"""
return self.rho * np.linalg.norm(self.cnst_AT(U))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
47354,
19091,
33247,
4725,
8082,
4751,
382,
286,
6193,
50780,
420,
1749,
374,
2631,
422,
5528,
551,
69991,
19258,
14606,
267,
1596,
13188,
286,
551,
69991,
19258,
14606,
267,
8837,
7964,
551,
69991,
19258,
14606,
267,
1702,
7964,
323,
551,
69991,
19258,
14606,
267,
669,
63,
527,
539,
198,
286,
52556,
382,
14711,
6075,
512,
755,
10242,
8910,
29122,
1214,
11,
549,
997,
286,
4304,
47354,
19091,
33247,
4725,
8082,
4751,
382,
286,
6193,
50780,
420,
1749,
374,
2631,
422,
5528,
551,
69991,
19258,
14606,
267,
1596,
13188,
286,
551,
69991,
19258,
14606,
267,
8837,
7964,
551,
69991,
19258,
14606,
267,
1702,
7964,
323,
551,
69991,
19258,
14606,
267,
669,
63,
527,
539,
198,
286,
52556,
627,
286,
12713,
286,
471,
659,
1783,
6292,
353,
2660,
38832,
33064,
1214,
22832,
267,
8837,
12597,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
47354,
19091,
33247,
4725,
8082,
4751,
382,
286,
6193,
50780,
420,
1749,
374,
2631,
422,
5528,
551,
69991,
19258,
14606,
267,
1596,
13188,
286,
551,
69991,
19258,
14606,
267,
8837,
7964,
551,
69991,
19258,
14606,
267,
1702,
7964,
323,
551,
69991,
19258,
14606,
267,
669,
63,
527,
539,
198,
286,
52556,
382,
14711,
6075,
512,
755,
10242,
8910,
29122,
1214,
11,
549,
997,
286,
4304,
47354,
19091,
33247,
4725,
8082,
4751,
382,
286,
6193,
50780,
420,
1749,
374,
2631,
422,
5528,
551,
69991,
19258,
14606,
267,
1596,
13188,
286,
551,
69991,
19258,
14606,
267,
8837,
7964,
551,
69991,
19258,
14606,
267,
1702,
7964,
323,
551,
69991,
19258,
14606,
267,
669,
63,
527,
539,
198,
286,
52556,
627,
286,
12713,
286,
471,
659,
1783,
6292,
353,
2660,
38832,
33064,
1214,
22832,
267,
8837,
12597,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
PmagPy/PmagPy | pmagpy/pmagplotlib.py | plot_eq | def plot_eq(fignum, DIblock, s):
"""
plots directions on eqarea projection
Parameters
__________
fignum : matplotlib figure number
DIblock : nested list of dec/inc pairs
s : specimen name
"""
# make the stereonet
plt.figure(num=fignum)
if len(DIblock) < 1:
return
# plt.clf()
if not isServer:
plt.figtext(.02, .01, version_num)
plot_net(fignum)
#
# put on the directions
#
plot_di(fignum, DIblock) # plot directions
plt.axis("equal")
plt.text(-1.1, 1.15, s)
plt.draw() | python | def plot_eq(fignum, DIblock, s):
"""
plots directions on eqarea projection
Parameters
__________
fignum : matplotlib figure number
DIblock : nested list of dec/inc pairs
s : specimen name
"""
# make the stereonet
plt.figure(num=fignum)
if len(DIblock) < 1:
return
# plt.clf()
if not isServer:
plt.figtext(.02, .01, version_num)
plot_net(fignum)
#
# put on the directions
#
plot_di(fignum, DIblock) # plot directions
plt.axis("equal")
plt.text(-1.1, 1.15, s)
plt.draw() | [
"def",
"plot_eq",
"(",
"fignum",
",",
"DIblock",
",",
"s",
")",
":",
"# make the stereonet",
"plt",
".",
"figure",
"(",
"num",
"=",
"fignum",
")",
"if",
"len",
"(",
"DIblock",
")",
"<",
"1",
":",
"return",
"# plt.clf()",
"if",
"not",
"isServer",
":",
"plt",
".",
"figtext",
"(",
".02",
",",
".01",
",",
"version_num",
")",
"plot_net",
"(",
"fignum",
")",
"#",
"# put on the directions",
"#",
"plot_di",
"(",
"fignum",
",",
"DIblock",
")",
"# plot directions",
"plt",
".",
"axis",
"(",
"\"equal\"",
")",
"plt",
".",
"text",
"(",
"-",
"1.1",
",",
"1.15",
",",
"s",
")",
"plt",
".",
"draw",
"(",
")"
] | plots directions on eqarea projection
Parameters
__________
fignum : matplotlib figure number
DIblock : nested list of dec/inc pairs
s : specimen name | [
"plots",
"directions",
"on",
"eqarea",
"projection",
"Parameters",
"__________",
"fignum",
":",
"matplotlib",
"figure",
"number",
"DIblock",
":",
"nested",
"list",
"of",
"dec",
"/",
"inc",
"pairs",
"s",
":",
"specimen",
"name"
] | train | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmagplotlib.py#L1479-L1502 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
plots directions on eqarea projection
Parameters
__________
fignum : matplotlib figure number
DIblock : nested list of dec/inc pairs
s : specimen name
### Response:
def plot_eq(fignum, DIblock, s):
"""
plots directions on eqarea projection
Parameters
__________
fignum : matplotlib figure number
DIblock : nested list of dec/inc pairs
s : specimen name
"""
# make the stereonet
plt.figure(num=fignum)
if len(DIblock) < 1:
return
# plt.clf()
if not isServer:
plt.figtext(.02, .01, version_num)
plot_net(fignum)
#
# put on the directions
#
plot_di(fignum, DIblock) # plot directions
plt.axis("equal")
plt.text(-1.1, 1.15, s)
plt.draw()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
33897,
18445,
389,
9116,
4903,
22343,
198,
262,
13831,
198,
262,
1328,
4067,
198,
262,
282,
93260,
551,
17220,
7216,
1396,
198,
262,
16943,
4677,
551,
24997,
1160,
315,
1654,
73488,
13840,
198,
262,
274,
551,
58184,
836,
271,
14711,
6075,
512,
755,
7234,
10945,
968,
93260,
11,
16943,
4677,
11,
274,
997,
262,
3270,
262,
31794,
18445,
389,
9116,
4903,
22343,
198,
262,
13831,
198,
262,
1328,
4067,
198,
262,
282,
93260,
551,
17220,
7216,
1396,
198,
262,
16943,
4677,
551,
24997,
1160,
315,
1654,
73488,
13840,
198,
262,
274,
551,
58184,
836,
198,
262,
3270,
2,
1304,
279,
23473,
69786,
198,
262,
6653,
27602,
8228,
18603,
93260,
340,
262,
422,
2479,
5549,
40,
4677,
8,
366,
220,
16,
512,
286,
471,
198,
262,
674,
6653,
95356,
746,
262,
422,
539,
374,
5592,
512,
286,
6653,
71899,
1342,
14960,
2437,
11,
662,
1721,
11,
2373,
4369,
340,
262,
7234,
20301,
968,
93260,
340,
5062,
2,
256,
2231,
389,
279,
18445,
198,
5062,
262,
7234,
30577,
968,
93260,
11,
16943,
4677,
8,
220,
674,
7234,
18445,
198,
262,
6653,
36251,
446,
26880,
1158,
262,
6653,
2858,
4172,
16,
13,
16,
11,
220,
16,
13,
868,
11,
274,
340,
262,
6653,
7152,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
33897,
18445,
389,
9116,
4903,
22343,
198,
262,
13831,
198,
262,
1328,
4067,
198,
262,
282,
93260,
551,
17220,
7216,
1396,
198,
262,
16943,
4677,
551,
24997,
1160,
315,
1654,
73488,
13840,
198,
262,
274,
551,
58184,
836,
271,
14711,
6075,
512,
755,
7234,
10945,
968,
93260,
11,
16943,
4677,
11,
274,
997,
262,
3270,
262,
31794,
18445,
389,
9116,
4903,
22343,
198,
262,
13831,
198,
262,
1328,
4067,
198,
262,
282,
93260,
551,
17220,
7216,
1396,
198,
262,
16943,
4677,
551,
24997,
1160,
315,
1654,
73488,
13840,
198,
262,
274,
551,
58184,
836,
198,
262,
3270,
2,
1304,
279,
23473,
69786,
198,
262,
6653,
27602,
8228,
18603,
93260,
340,
262,
422,
2479,
5549,
40,
4677,
8,
366,
220,
16,
512,
286,
471,
198,
262,
674,
6653,
95356,
746,
262,
422,
539,
374,
5592,
512,
286,
6653,
71899,
1342,
14960,
2437,
11,
662,
1721,
11,
2373,
4369,
340,
262,
7234,
20301,
968,
93260,
340,
5062,
2,
256,
2231,
389,
279,
18445,
198,
5062,
262,
7234,
30577,
968,
93260,
11,
16943,
4677,
8,
220,
674,
7234,
18445,
198,
262,
6653,
36251,
446,
26880,
1158,
262,
6653,
2858,
4172,
16,
13,
16,
11,
220,
16,
13,
868,
11,
274,
340,
262,
6653,
7152,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
brandonxiang/geojson-python-utils | geojson_utils/geojson_utils.py | _pnpoly | def _pnpoly(x, y, coords):
"""
the algorithm to judge whether the point is located in polygon
reference: https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html#Explanation
"""
vert = [[0, 0]]
for coord in coords:
for node in coord:
vert.append(node)
vert.append(coord[0])
vert.append([0, 0])
inside = False
i = 0
j = len(vert) - 1
while i < len(vert):
if ((vert[i][0] > y) != (vert[j][0] > y)) and (x < (vert[j][1] - vert[i][1])
* (y - vert[i][0]) / (vert[j][0] - vert[i][0]) + vert[i][1]):
inside = not inside
j = i
i += 1
return inside | python | def _pnpoly(x, y, coords):
"""
the algorithm to judge whether the point is located in polygon
reference: https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html#Explanation
"""
vert = [[0, 0]]
for coord in coords:
for node in coord:
vert.append(node)
vert.append(coord[0])
vert.append([0, 0])
inside = False
i = 0
j = len(vert) - 1
while i < len(vert):
if ((vert[i][0] > y) != (vert[j][0] > y)) and (x < (vert[j][1] - vert[i][1])
* (y - vert[i][0]) / (vert[j][0] - vert[i][0]) + vert[i][1]):
inside = not inside
j = i
i += 1
return inside | [
"def",
"_pnpoly",
"(",
"x",
",",
"y",
",",
"coords",
")",
":",
"vert",
"=",
"[",
"[",
"0",
",",
"0",
"]",
"]",
"for",
"coord",
"in",
"coords",
":",
"for",
"node",
"in",
"coord",
":",
"vert",
".",
"append",
"(",
"node",
")",
"vert",
".",
"append",
"(",
"coord",
"[",
"0",
"]",
")",
"vert",
".",
"append",
"(",
"[",
"0",
",",
"0",
"]",
")",
"inside",
"=",
"False",
"i",
"=",
"0",
"j",
"=",
"len",
"(",
"vert",
")",
"-",
"1",
"while",
"i",
"<",
"len",
"(",
"vert",
")",
":",
"if",
"(",
"(",
"vert",
"[",
"i",
"]",
"[",
"0",
"]",
">",
"y",
")",
"!=",
"(",
"vert",
"[",
"j",
"]",
"[",
"0",
"]",
">",
"y",
")",
")",
"and",
"(",
"x",
"<",
"(",
"vert",
"[",
"j",
"]",
"[",
"1",
"]",
"-",
"vert",
"[",
"i",
"]",
"[",
"1",
"]",
")",
"*",
"(",
"y",
"-",
"vert",
"[",
"i",
"]",
"[",
"0",
"]",
")",
"/",
"(",
"vert",
"[",
"j",
"]",
"[",
"0",
"]",
"-",
"vert",
"[",
"i",
"]",
"[",
"0",
"]",
")",
"+",
"vert",
"[",
"i",
"]",
"[",
"1",
"]",
")",
":",
"inside",
"=",
"not",
"inside",
"j",
"=",
"i",
"i",
"+=",
"1",
"return",
"inside"
] | the algorithm to judge whether the point is located in polygon
reference: https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html#Explanation | [
"the",
"algorithm",
"to",
"judge",
"whether",
"the",
"point",
"is",
"located",
"in",
"polygon",
"reference",
":",
"https",
":",
"//",
"www",
".",
"ecse",
".",
"rpi",
".",
"edu",
"/",
"~wrf",
"/",
"Research",
"/",
"Short_Notes",
"/",
"pnpoly",
".",
"html#Explanation"
] | train | https://github.com/brandonxiang/geojson-python-utils/blob/33d0dcd5f16e0567b48c0d49fd292a4f1db16b41/geojson_utils/geojson_utils.py#L64-L89 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
the algorithm to judge whether the point is located in polygon
reference: https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html#Explanation
### Response:
def _pnpoly(x, y, coords):
"""
the algorithm to judge whether the point is located in polygon
reference: https://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html#Explanation
"""
vert = [[0, 0]]
for coord in coords:
for node in coord:
vert.append(node)
vert.append(coord[0])
vert.append([0, 0])
inside = False
i = 0
j = len(vert) - 1
while i < len(vert):
if ((vert[i][0] > y) != (vert[j][0] > y)) and (x < (vert[j][1] - vert[i][1])
* (y - vert[i][0]) / (vert[j][0] - vert[i][0]) + vert[i][1]):
inside = not inside
j = i
i += 1
return inside
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1820,
12384,
311,
11913,
3508,
279,
1486,
374,
7559,
304,
30472,
198,
262,
5905,
25,
3788,
1129,
2185,
30288,
325,
1783,
2554,
12871,
54896,
86,
8212,
14,
28528,
14,
12755,
1635,
6429,
4420,
6331,
5849,
2628,
2,
70869,
271,
14711,
6075,
512,
755,
721,
79,
6331,
5849,
2120,
11,
379,
11,
24842,
997,
262,
3270,
262,
279,
12384,
311,
11913,
3508,
279,
1486,
374,
7559,
304,
30472,
198,
262,
5905,
25,
3788,
1129,
2185,
30288,
325,
1783,
2554,
12871,
54896,
86,
8212,
14,
28528,
14,
12755,
1635,
6429,
4420,
6331,
5849,
2628,
2,
70869,
198,
262,
3270,
262,
5309,
284,
4416,
15,
11,
220,
15,
43550,
262,
369,
16896,
304,
24842,
512,
286,
369,
2494,
304,
16896,
512,
310,
5309,
2102,
7103,
340,
286,
5309,
2102,
66137,
58,
15,
2608,
286,
5309,
2102,
2625,
15,
11,
220,
15,
9801,
262,
4871,
284,
3641,
271,
262,
602,
284,
220,
15,
198,
262,
503,
284,
2479,
7,
1653,
8,
482,
220,
16,
271,
262,
1418,
602,
366,
2479,
7,
1653,
997,
286,
422,
1819,
1653,
1004,
1483,
15,
60,
871,
379,
8,
976,
320,
1653,
3894,
1483,
15,
60,
871,
379,
595,
323,
320,
87,
366,
320,
1653,
3894,
1483,
16,
60,
482,
5309,
1004,
1483,
16,
2608,
26857,
353,
320,
88,
482,
5309,
1004,
1483,
15,
2526,
611,
320,
1653,
3894,
1483,
15,
60,
482,
5309,
1004,
1483,
15,
2526,
489,
5309,
1004,
1483,
16,
22953,
310,
4871,
284,
539,
4871,
198,
286,
503,
284,
602,
198,
286,
602,
1447,
220,
16,
271,
262,
471,
4871,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1820,
12384,
311,
11913,
3508,
279,
1486,
374,
7559,
304,
30472,
198,
262,
5905,
25,
3788,
1129,
2185,
30288,
325,
1783,
2554,
12871,
54896,
86,
8212,
14,
28528,
14,
12755,
1635,
6429,
4420,
6331,
5849,
2628,
2,
70869,
271,
14711,
6075,
512,
755,
721,
79,
6331,
5849,
2120,
11,
379,
11,
24842,
997,
262,
3270,
262,
279,
12384,
311,
11913,
3508,
279,
1486,
374,
7559,
304,
30472,
198,
262,
5905,
25,
3788,
1129,
2185,
30288,
325,
1783,
2554,
12871,
54896,
86,
8212,
14,
28528,
14,
12755,
1635,
6429,
4420,
6331,
5849,
2628,
2,
70869,
198,
262,
3270,
262,
5309,
284,
4416,
15,
11,
220,
15,
43550,
262,
369,
16896,
304,
24842,
512,
286,
369,
2494,
304,
16896,
512,
310,
5309,
2102,
7103,
340,
286,
5309,
2102,
66137,
58,
15,
2608,
286,
5309,
2102,
2625,
15,
11,
220,
15,
9801,
262,
4871,
284,
3641,
271,
262,
602,
284,
220,
15,
198,
262,
503,
284,
2479,
7,
1653,
8,
482,
220,
16,
271,
262,
1418,
602,
366,
2479,
7,
1653,
997,
286,
422,
1819,
1653,
1004,
1483,
15,
60,
871,
379,
8,
976,
320,
1653,
3894,
1483,
15,
60,
871,
379,
595,
323,
320,
87,
366,
320,
1653,
3894,
1483,
16,
60,
482,
5309,
1004,
1483,
16,
2608,
26857,
353,
320,
88,
482,
5309,
1004,
1483,
15,
2526,
611,
320,
1653,
3894,
1483,
15,
60,
482,
5309,
1004,
1483,
15,
2526,
489,
5309,
1004,
1483,
16,
22953,
310,
4871,
284,
539,
4871,
198,
286,
503,
284,
602,
198,
286,
602,
1447,
220,
16,
271,
262,
471,
4871,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
hearsaycorp/normalize | normalize/coll.py | _make_generic | def _make_generic(of, coll):
"""Used to make a new Collection type, without that type having to be
defined explicitly. Generates a new type name using the item type and a
'suffix' Collection class property.
args:
``of=``\ *Record type*
The type of values of the collection
``coll=``\ *Collection sub-class*
The container class.
"""
assert(issubclass(coll, Collection))
key = (coll.__name__, "%s.%s" % (of.__module__, of.__name__))
if key in GENERIC_TYPES:
if GENERIC_TYPES[key].itemtype != of:
raise exc.PropertyNotUnique(key=key)
else:
# oh, we get to name it? Goodie!
generic_name = "%s%s" % (of.__name__, coll.suffix)
GENERIC_TYPES[key] = type(
generic_name, (coll, _Generic), dict(itemtype=of, generic_key=key)
)
mod = sys.modules[of.__module__]
if not hasattr(mod, generic_name):
setattr(mod, generic_name, GENERIC_TYPES[key])
return GENERIC_TYPES[key] | python | def _make_generic(of, coll):
"""Used to make a new Collection type, without that type having to be
defined explicitly. Generates a new type name using the item type and a
'suffix' Collection class property.
args:
``of=``\ *Record type*
The type of values of the collection
``coll=``\ *Collection sub-class*
The container class.
"""
assert(issubclass(coll, Collection))
key = (coll.__name__, "%s.%s" % (of.__module__, of.__name__))
if key in GENERIC_TYPES:
if GENERIC_TYPES[key].itemtype != of:
raise exc.PropertyNotUnique(key=key)
else:
# oh, we get to name it? Goodie!
generic_name = "%s%s" % (of.__name__, coll.suffix)
GENERIC_TYPES[key] = type(
generic_name, (coll, _Generic), dict(itemtype=of, generic_key=key)
)
mod = sys.modules[of.__module__]
if not hasattr(mod, generic_name):
setattr(mod, generic_name, GENERIC_TYPES[key])
return GENERIC_TYPES[key] | [
"def",
"_make_generic",
"(",
"of",
",",
"coll",
")",
":",
"assert",
"(",
"issubclass",
"(",
"coll",
",",
"Collection",
")",
")",
"key",
"=",
"(",
"coll",
".",
"__name__",
",",
"\"%s.%s\"",
"%",
"(",
"of",
".",
"__module__",
",",
"of",
".",
"__name__",
")",
")",
"if",
"key",
"in",
"GENERIC_TYPES",
":",
"if",
"GENERIC_TYPES",
"[",
"key",
"]",
".",
"itemtype",
"!=",
"of",
":",
"raise",
"exc",
".",
"PropertyNotUnique",
"(",
"key",
"=",
"key",
")",
"else",
":",
"# oh, we get to name it? Goodie!",
"generic_name",
"=",
"\"%s%s\"",
"%",
"(",
"of",
".",
"__name__",
",",
"coll",
".",
"suffix",
")",
"GENERIC_TYPES",
"[",
"key",
"]",
"=",
"type",
"(",
"generic_name",
",",
"(",
"coll",
",",
"_Generic",
")",
",",
"dict",
"(",
"itemtype",
"=",
"of",
",",
"generic_key",
"=",
"key",
")",
")",
"mod",
"=",
"sys",
".",
"modules",
"[",
"of",
".",
"__module__",
"]",
"if",
"not",
"hasattr",
"(",
"mod",
",",
"generic_name",
")",
":",
"setattr",
"(",
"mod",
",",
"generic_name",
",",
"GENERIC_TYPES",
"[",
"key",
"]",
")",
"return",
"GENERIC_TYPES",
"[",
"key",
"]"
] | Used to make a new Collection type, without that type having to be
defined explicitly. Generates a new type name using the item type and a
'suffix' Collection class property.
args:
``of=``\ *Record type*
The type of values of the collection
``coll=``\ *Collection sub-class*
The container class. | [
"Used",
"to",
"make",
"a",
"new",
"Collection",
"type",
"without",
"that",
"type",
"having",
"to",
"be",
"defined",
"explicitly",
".",
"Generates",
"a",
"new",
"type",
"name",
"using",
"the",
"item",
"type",
"and",
"a",
"suffix",
"Collection",
"class",
"property",
"."
] | train | https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/coll.py#L470-L498 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Used to make a new Collection type, without that type having to be
defined explicitly. Generates a new type name using the item type and a
'suffix' Collection class property.
args:
``of=``\ *Record type*
The type of values of the collection
``coll=``\ *Collection sub-class*
The container class.
### Response:
def _make_generic(of, coll):
"""Used to make a new Collection type, without that type having to be
defined explicitly. Generates a new type name using the item type and a
'suffix' Collection class property.
args:
``of=``\ *Record type*
The type of values of the collection
``coll=``\ *Collection sub-class*
The container class.
"""
assert(issubclass(coll, Collection))
key = (coll.__name__, "%s.%s" % (of.__module__, of.__name__))
if key in GENERIC_TYPES:
if GENERIC_TYPES[key].itemtype != of:
raise exc.PropertyNotUnique(key=key)
else:
# oh, we get to name it? Goodie!
generic_name = "%s%s" % (of.__name__, coll.suffix)
GENERIC_TYPES[key] = type(
generic_name, (coll, _Generic), dict(itemtype=of, generic_key=key)
)
mod = sys.modules[of.__module__]
if not hasattr(mod, generic_name):
setattr(mod, generic_name, GENERIC_TYPES[key])
return GENERIC_TYPES[key]
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
23580,
311,
1304,
264,
502,
11348,
955,
11,
2085,
430,
955,
3515,
311,
387,
198,
262,
4613,
21650,
13,
220,
53592,
264,
502,
955,
836,
1701,
279,
1537,
955,
323,
264,
198,
262,
364,
27884,
6,
11348,
538,
3424,
382,
262,
2897,
1473,
286,
10103,
1073,
28,
14196,
59,
353,
6607,
955,
5736,
310,
578,
955,
315,
2819,
315,
279,
4526,
271,
286,
10103,
17666,
28,
14196,
59,
353,
6618,
1207,
15144,
5736,
310,
578,
5593,
538,
382,
14711,
6075,
512,
755,
721,
7072,
42332,
28125,
11,
4631,
997,
262,
4304,
23580,
311,
1304,
264,
502,
11348,
955,
11,
2085,
430,
955,
3515,
311,
387,
198,
262,
4613,
21650,
13,
220,
53592,
264,
502,
955,
836,
1701,
279,
1537,
955,
323,
264,
198,
262,
364,
27884,
6,
11348,
538,
3424,
382,
262,
2897,
1473,
286,
10103,
1073,
28,
14196,
59,
353,
6607,
955,
5736,
310,
578,
955,
315,
2819,
315,
279,
4526,
271,
286,
10103,
17666,
28,
14196,
59,
353,
6618,
1207,
15144,
5736,
310,
578,
5593,
538,
627,
262,
12713,
262,
2105,
7,
1056,
392,
1058,
86729,
11,
11348,
1192,
262,
1401,
284,
320,
17666,
4952,
609,
10662,
6090,
82,
23253,
82,
1,
1034,
320,
1073,
4952,
4450,
10662,
315,
4952,
609,
65213,
262,
422,
1401,
304,
95460,
26879,
512,
286,
422,
95460,
26879,
8320,
948,
1224,
1337,
976,
315,
512,
310,
4933,
3521,
16103,
2688,
23657,
4962,
87682,
340,
262,
775,
512,
286,
674,
14346,
11,
584,
636,
311,
836,
433,
30,
220,
7839,
648,
4999,
286,
14281,
1292,
284,
6090,
82,
13249,
1,
1034,
320,
1073,
4952,
609,
10662,
4631,
516,
13866,
340,
286,
95460,
26879,
8320,
60,
284,
955,
1021,
310,
14281,
1292,
11,
320,
17666,
11,
721,
20560,
705,
6587,
5508,
1337,
28,
1073,
11,
14281,
3173,
87682,
340,
286,
1763,
286,
1491,
284,
5826,
27904,
71954,
4952,
4450,
565,
933,
286,
422,
539,
32156,
24236,
11,
14281,
1292,
997,
310,
62214,
24236,
11,
14281,
1292,
11,
95460,
26879,
8320,
2608,
262,
471,
95460,
26879,
8320,
933,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
23580,
311,
1304,
264,
502,
11348,
955,
11,
2085,
430,
955,
3515,
311,
387,
198,
262,
4613,
21650,
13,
220,
53592,
264,
502,
955,
836,
1701,
279,
1537,
955,
323,
264,
198,
262,
364,
27884,
6,
11348,
538,
3424,
382,
262,
2897,
1473,
286,
10103,
1073,
28,
14196,
59,
353,
6607,
955,
5736,
310,
578,
955,
315,
2819,
315,
279,
4526,
271,
286,
10103,
17666,
28,
14196,
59,
353,
6618,
1207,
15144,
5736,
310,
578,
5593,
538,
382,
14711,
6075,
512,
755,
721,
7072,
42332,
28125,
11,
4631,
997,
262,
4304,
23580,
311,
1304,
264,
502,
11348,
955,
11,
2085,
430,
955,
3515,
311,
387,
198,
262,
4613,
21650,
13,
220,
53592,
264,
502,
955,
836,
1701,
279,
1537,
955,
323,
264,
198,
262,
364,
27884,
6,
11348,
538,
3424,
382,
262,
2897,
1473,
286,
10103,
1073,
28,
14196,
59,
353,
6607,
955,
5736,
310,
578,
955,
315,
2819,
315,
279,
4526,
271,
286,
10103,
17666,
28,
14196,
59,
353,
6618,
1207,
15144,
5736,
310,
578,
5593,
538,
627,
262,
12713,
262,
2105,
7,
1056,
392,
1058,
86729,
11,
11348,
1192,
262,
1401,
284,
320,
17666,
4952,
609,
10662,
6090,
82,
23253,
82,
1,
1034,
320,
1073,
4952,
4450,
10662,
315,
4952,
609,
65213,
262,
422,
1401,
304,
95460,
26879,
512,
286,
422,
95460,
26879,
8320,
948,
1224,
1337,
976,
315,
512,
310,
4933,
3521,
16103,
2688,
23657,
4962,
87682,
340,
262,
775,
512,
286,
674,
14346,
11,
584,
636,
311,
836,
433,
30,
220,
7839,
648,
4999,
286,
14281,
1292,
284,
6090,
82,
13249,
1,
1034,
320,
1073,
4952,
609,
10662,
4631,
516,
13866,
340,
286,
95460,
26879,
8320,
60,
284,
955,
1021,
310,
14281,
1292,
11,
320,
17666,
11,
721,
20560,
705,
6587,
5508,
1337,
28,
1073,
11,
14281,
3173,
87682,
340,
286,
1763,
286,
1491,
284,
5826,
27904,
71954,
4952,
4450,
565,
933,
286,
422,
539,
32156,
24236,
11,
14281,
1292,
997,
310,
62214,
24236,
11,
14281,
1292,
11,
95460,
26879,
8320,
2608,
262,
471,
95460,
26879,
8320,
933,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pyrogram/pyrogram | pyrogram/client/client.py | Client.save_file | def save_file(self,
path: str,
file_id: int = None,
file_part: int = 0,
progress: callable = None,
progress_args: tuple = ()):
"""Use this method to upload a file onto Telegram servers, without actually sending the message to anyone.
This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
method you wish to use which is not available yet in the Client class as an easy-to-use method), whenever an
InputFile type is required.
Args:
path (``str``):
The path of the file you want to upload that exists on your local machine.
file_id (``int``, *optional*):
In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.
file_part (``int``, *optional*):
In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.
progress (``callable``, *optional*):
Pass a callback function to view the upload progress.
The function must take *(client, current, total, \*args)* as positional arguments (look at the section
below for a detailed description).
progress_args (``tuple``, *optional*):
Extra custom arguments for the progress callback function. Useful, for example, if you want to pass
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
client (:obj:`Client <pyrogram.Client>`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
The amount of bytes uploaded so far.
total (``int``):
The size of the file.
*args (``tuple``, *optional*):
Extra custom arguments as defined in the *progress_args* parameter.
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
On success, the uploaded file is returned in form of an InputFile object.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
"""
part_size = 512 * 1024
file_size = os.path.getsize(path)
if file_size == 0:
raise ValueError("File size equals to 0 B")
if file_size > 1500 * 1024 * 1024:
raise ValueError("Telegram doesn't support uploading files bigger than 1500 MiB")
file_total_parts = int(math.ceil(file_size / part_size))
is_big = True if file_size > 10 * 1024 * 1024 else False
is_missing_part = True if file_id is not None else False
file_id = file_id or self.rnd_id()
md5_sum = md5() if not is_big and not is_missing_part else None
session = Session(self, self.dc_id, self.auth_key, is_media=True)
session.start()
try:
with open(path, "rb") as f:
f.seek(part_size * file_part)
while True:
chunk = f.read(part_size)
if not chunk:
if not is_big:
md5_sum = "".join([hex(i)[2:].zfill(2) for i in md5_sum.digest()])
break
for _ in range(3):
if is_big:
rpc = functions.upload.SaveBigFilePart(
file_id=file_id,
file_part=file_part,
file_total_parts=file_total_parts,
bytes=chunk
)
else:
rpc = functions.upload.SaveFilePart(
file_id=file_id,
file_part=file_part,
bytes=chunk
)
if session.send(rpc):
break
else:
raise AssertionError("Telegram didn't accept chunk #{} of {}".format(file_part, path))
if is_missing_part:
return
if not is_big:
md5_sum.update(chunk)
file_part += 1
if progress:
progress(self, min(file_part * part_size, file_size), file_size, *progress_args)
except Client.StopTransmission:
raise
except Exception as e:
log.error(e, exc_info=True)
else:
if is_big:
return types.InputFileBig(
id=file_id,
parts=file_total_parts,
name=os.path.basename(path),
)
else:
return types.InputFile(
id=file_id,
parts=file_total_parts,
name=os.path.basename(path),
md5_checksum=md5_sum
)
finally:
session.stop() | python | def save_file(self,
path: str,
file_id: int = None,
file_part: int = 0,
progress: callable = None,
progress_args: tuple = ()):
"""Use this method to upload a file onto Telegram servers, without actually sending the message to anyone.
This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
method you wish to use which is not available yet in the Client class as an easy-to-use method), whenever an
InputFile type is required.
Args:
path (``str``):
The path of the file you want to upload that exists on your local machine.
file_id (``int``, *optional*):
In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.
file_part (``int``, *optional*):
In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.
progress (``callable``, *optional*):
Pass a callback function to view the upload progress.
The function must take *(client, current, total, \*args)* as positional arguments (look at the section
below for a detailed description).
progress_args (``tuple``, *optional*):
Extra custom arguments for the progress callback function. Useful, for example, if you want to pass
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
client (:obj:`Client <pyrogram.Client>`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
The amount of bytes uploaded so far.
total (``int``):
The size of the file.
*args (``tuple``, *optional*):
Extra custom arguments as defined in the *progress_args* parameter.
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
On success, the uploaded file is returned in form of an InputFile object.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
"""
part_size = 512 * 1024
file_size = os.path.getsize(path)
if file_size == 0:
raise ValueError("File size equals to 0 B")
if file_size > 1500 * 1024 * 1024:
raise ValueError("Telegram doesn't support uploading files bigger than 1500 MiB")
file_total_parts = int(math.ceil(file_size / part_size))
is_big = True if file_size > 10 * 1024 * 1024 else False
is_missing_part = True if file_id is not None else False
file_id = file_id or self.rnd_id()
md5_sum = md5() if not is_big and not is_missing_part else None
session = Session(self, self.dc_id, self.auth_key, is_media=True)
session.start()
try:
with open(path, "rb") as f:
f.seek(part_size * file_part)
while True:
chunk = f.read(part_size)
if not chunk:
if not is_big:
md5_sum = "".join([hex(i)[2:].zfill(2) for i in md5_sum.digest()])
break
for _ in range(3):
if is_big:
rpc = functions.upload.SaveBigFilePart(
file_id=file_id,
file_part=file_part,
file_total_parts=file_total_parts,
bytes=chunk
)
else:
rpc = functions.upload.SaveFilePart(
file_id=file_id,
file_part=file_part,
bytes=chunk
)
if session.send(rpc):
break
else:
raise AssertionError("Telegram didn't accept chunk #{} of {}".format(file_part, path))
if is_missing_part:
return
if not is_big:
md5_sum.update(chunk)
file_part += 1
if progress:
progress(self, min(file_part * part_size, file_size), file_size, *progress_args)
except Client.StopTransmission:
raise
except Exception as e:
log.error(e, exc_info=True)
else:
if is_big:
return types.InputFileBig(
id=file_id,
parts=file_total_parts,
name=os.path.basename(path),
)
else:
return types.InputFile(
id=file_id,
parts=file_total_parts,
name=os.path.basename(path),
md5_checksum=md5_sum
)
finally:
session.stop() | [
"def",
"save_file",
"(",
"self",
",",
"path",
":",
"str",
",",
"file_id",
":",
"int",
"=",
"None",
",",
"file_part",
":",
"int",
"=",
"0",
",",
"progress",
":",
"callable",
"=",
"None",
",",
"progress_args",
":",
"tuple",
"=",
"(",
")",
")",
":",
"part_size",
"=",
"512",
"*",
"1024",
"file_size",
"=",
"os",
".",
"path",
".",
"getsize",
"(",
"path",
")",
"if",
"file_size",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"File size equals to 0 B\"",
")",
"if",
"file_size",
">",
"1500",
"*",
"1024",
"*",
"1024",
":",
"raise",
"ValueError",
"(",
"\"Telegram doesn't support uploading files bigger than 1500 MiB\"",
")",
"file_total_parts",
"=",
"int",
"(",
"math",
".",
"ceil",
"(",
"file_size",
"/",
"part_size",
")",
")",
"is_big",
"=",
"True",
"if",
"file_size",
">",
"10",
"*",
"1024",
"*",
"1024",
"else",
"False",
"is_missing_part",
"=",
"True",
"if",
"file_id",
"is",
"not",
"None",
"else",
"False",
"file_id",
"=",
"file_id",
"or",
"self",
".",
"rnd_id",
"(",
")",
"md5_sum",
"=",
"md5",
"(",
")",
"if",
"not",
"is_big",
"and",
"not",
"is_missing_part",
"else",
"None",
"session",
"=",
"Session",
"(",
"self",
",",
"self",
".",
"dc_id",
",",
"self",
".",
"auth_key",
",",
"is_media",
"=",
"True",
")",
"session",
".",
"start",
"(",
")",
"try",
":",
"with",
"open",
"(",
"path",
",",
"\"rb\"",
")",
"as",
"f",
":",
"f",
".",
"seek",
"(",
"part_size",
"*",
"file_part",
")",
"while",
"True",
":",
"chunk",
"=",
"f",
".",
"read",
"(",
"part_size",
")",
"if",
"not",
"chunk",
":",
"if",
"not",
"is_big",
":",
"md5_sum",
"=",
"\"\"",
".",
"join",
"(",
"[",
"hex",
"(",
"i",
")",
"[",
"2",
":",
"]",
".",
"zfill",
"(",
"2",
")",
"for",
"i",
"in",
"md5_sum",
".",
"digest",
"(",
")",
"]",
")",
"break",
"for",
"_",
"in",
"range",
"(",
"3",
")",
":",
"if",
"is_big",
":",
"rpc",
"=",
"functions",
".",
"upload",
".",
"SaveBigFilePart",
"(",
"file_id",
"=",
"file_id",
",",
"file_part",
"=",
"file_part",
",",
"file_total_parts",
"=",
"file_total_parts",
",",
"bytes",
"=",
"chunk",
")",
"else",
":",
"rpc",
"=",
"functions",
".",
"upload",
".",
"SaveFilePart",
"(",
"file_id",
"=",
"file_id",
",",
"file_part",
"=",
"file_part",
",",
"bytes",
"=",
"chunk",
")",
"if",
"session",
".",
"send",
"(",
"rpc",
")",
":",
"break",
"else",
":",
"raise",
"AssertionError",
"(",
"\"Telegram didn't accept chunk #{} of {}\"",
".",
"format",
"(",
"file_part",
",",
"path",
")",
")",
"if",
"is_missing_part",
":",
"return",
"if",
"not",
"is_big",
":",
"md5_sum",
".",
"update",
"(",
"chunk",
")",
"file_part",
"+=",
"1",
"if",
"progress",
":",
"progress",
"(",
"self",
",",
"min",
"(",
"file_part",
"*",
"part_size",
",",
"file_size",
")",
",",
"file_size",
",",
"*",
"progress_args",
")",
"except",
"Client",
".",
"StopTransmission",
":",
"raise",
"except",
"Exception",
"as",
"e",
":",
"log",
".",
"error",
"(",
"e",
",",
"exc_info",
"=",
"True",
")",
"else",
":",
"if",
"is_big",
":",
"return",
"types",
".",
"InputFileBig",
"(",
"id",
"=",
"file_id",
",",
"parts",
"=",
"file_total_parts",
",",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
",",
")",
"else",
":",
"return",
"types",
".",
"InputFile",
"(",
"id",
"=",
"file_id",
",",
"parts",
"=",
"file_total_parts",
",",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
",",
"md5_checksum",
"=",
"md5_sum",
")",
"finally",
":",
"session",
".",
"stop",
"(",
")"
] | Use this method to upload a file onto Telegram servers, without actually sending the message to anyone.
This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
method you wish to use which is not available yet in the Client class as an easy-to-use method), whenever an
InputFile type is required.
Args:
path (``str``):
The path of the file you want to upload that exists on your local machine.
file_id (``int``, *optional*):
In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.
file_part (``int``, *optional*):
In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.
progress (``callable``, *optional*):
Pass a callback function to view the upload progress.
The function must take *(client, current, total, \*args)* as positional arguments (look at the section
below for a detailed description).
progress_args (``tuple``, *optional*):
Extra custom arguments for the progress callback function. Useful, for example, if you want to pass
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
client (:obj:`Client <pyrogram.Client>`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
The amount of bytes uploaded so far.
total (``int``):
The size of the file.
*args (``tuple``, *optional*):
Extra custom arguments as defined in the *progress_args* parameter.
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
On success, the uploaded file is returned in form of an InputFile object.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error. | [
"Use",
"this",
"method",
"to",
"upload",
"a",
"file",
"onto",
"Telegram",
"servers",
"without",
"actually",
"sending",
"the",
"message",
"to",
"anyone",
"."
] | train | https://github.com/pyrogram/pyrogram/blob/e7258a341ba905cfa86264c22040654db732ec1c/pyrogram/client/client.py#L1388-L1519 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Use this method to upload a file onto Telegram servers, without actually sending the message to anyone.
This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
method you wish to use which is not available yet in the Client class as an easy-to-use method), whenever an
InputFile type is required.
Args:
path (``str``):
The path of the file you want to upload that exists on your local machine.
file_id (``int``, *optional*):
In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.
file_part (``int``, *optional*):
In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.
progress (``callable``, *optional*):
Pass a callback function to view the upload progress.
The function must take *(client, current, total, \*args)* as positional arguments (look at the section
below for a detailed description).
progress_args (``tuple``, *optional*):
Extra custom arguments for the progress callback function. Useful, for example, if you want to pass
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
client (:obj:`Client <pyrogram.Client>`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
The amount of bytes uploaded so far.
total (``int``):
The size of the file.
*args (``tuple``, *optional*):
Extra custom arguments as defined in the *progress_args* parameter.
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
On success, the uploaded file is returned in form of an InputFile object.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
### Response:
def save_file(self,
path: str,
file_id: int = None,
file_part: int = 0,
progress: callable = None,
progress_args: tuple = ()):
"""Use this method to upload a file onto Telegram servers, without actually sending the message to anyone.
This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
method you wish to use which is not available yet in the Client class as an easy-to-use method), whenever an
InputFile type is required.
Args:
path (``str``):
The path of the file you want to upload that exists on your local machine.
file_id (``int``, *optional*):
In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.
file_part (``int``, *optional*):
In case a file part expired, pass the file_id and the file_part to retry uploading that specific chunk.
progress (``callable``, *optional*):
Pass a callback function to view the upload progress.
The function must take *(client, current, total, \*args)* as positional arguments (look at the section
below for a detailed description).
progress_args (``tuple``, *optional*):
Extra custom arguments for the progress callback function. Useful, for example, if you want to pass
a chat_id and a message_id in order to edit a message with the updated progress.
Other Parameters:
client (:obj:`Client <pyrogram.Client>`):
The Client itself, useful when you want to call other API methods inside the callback function.
current (``int``):
The amount of bytes uploaded so far.
total (``int``):
The size of the file.
*args (``tuple``, *optional*):
Extra custom arguments as defined in the *progress_args* parameter.
You can either keep *\*args* or add every single extra argument in your function signature.
Returns:
On success, the uploaded file is returned in form of an InputFile object.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
"""
part_size = 512 * 1024
file_size = os.path.getsize(path)
if file_size == 0:
raise ValueError("File size equals to 0 B")
if file_size > 1500 * 1024 * 1024:
raise ValueError("Telegram doesn't support uploading files bigger than 1500 MiB")
file_total_parts = int(math.ceil(file_size / part_size))
is_big = True if file_size > 10 * 1024 * 1024 else False
is_missing_part = True if file_id is not None else False
file_id = file_id or self.rnd_id()
md5_sum = md5() if not is_big and not is_missing_part else None
session = Session(self, self.dc_id, self.auth_key, is_media=True)
session.start()
try:
with open(path, "rb") as f:
f.seek(part_size * file_part)
while True:
chunk = f.read(part_size)
if not chunk:
if not is_big:
md5_sum = "".join([hex(i)[2:].zfill(2) for i in md5_sum.digest()])
break
for _ in range(3):
if is_big:
rpc = functions.upload.SaveBigFilePart(
file_id=file_id,
file_part=file_part,
file_total_parts=file_total_parts,
bytes=chunk
)
else:
rpc = functions.upload.SaveFilePart(
file_id=file_id,
file_part=file_part,
bytes=chunk
)
if session.send(rpc):
break
else:
raise AssertionError("Telegram didn't accept chunk #{} of {}".format(file_part, path))
if is_missing_part:
return
if not is_big:
md5_sum.update(chunk)
file_part += 1
if progress:
progress(self, min(file_part * part_size, file_size), file_size, *progress_args)
except Client.StopTransmission:
raise
except Exception as e:
log.error(e, exc_info=True)
else:
if is_big:
return types.InputFileBig(
id=file_id,
parts=file_total_parts,
name=os.path.basename(path),
)
else:
return types.InputFile(
id=file_id,
parts=file_total_parts,
name=os.path.basename(path),
md5_checksum=md5_sum
)
finally:
session.stop()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
10464,
420,
1749,
311,
8298,
264,
1052,
8800,
44063,
16692,
11,
2085,
3604,
11889,
279,
1984,
311,
5606,
382,
286,
1115,
374,
264,
15919,
1749,
10825,
311,
387,
1511,
3146,
3323,
334,
994,
3318,
449,
23886,
24460,
320,
72,
1770,
25,
264,
44063,
5446,
198,
286,
1749,
499,
6562,
311,
1005,
902,
374,
539,
2561,
3686,
304,
279,
8589,
538,
439,
459,
4228,
4791,
25700,
1749,
705,
15716,
459,
198,
286,
5688,
1738,
955,
374,
2631,
382,
286,
18161,
512,
310,
1853,
320,
14196,
496,
14196,
997,
394,
578,
1853,
315,
279,
1052,
499,
1390,
311,
8298,
430,
6866,
389,
701,
2254,
5780,
382,
310,
1052,
851,
320,
14196,
396,
91816,
353,
13099,
9,
997,
394,
763,
1162,
264,
1052,
961,
27489,
11,
1522,
279,
1052,
851,
323,
279,
1052,
10715,
311,
23515,
48429,
430,
3230,
12143,
382,
310,
1052,
10715,
320,
14196,
396,
91816,
353,
13099,
9,
997,
394,
763,
1162,
264,
1052,
961,
27489,
11,
1522,
279,
1052,
851,
323,
279,
1052,
10715,
311,
23515,
48429,
430,
3230,
12143,
382,
310,
5208,
320,
14196,
96292,
91816,
353,
13099,
9,
997,
394,
10175,
264,
4927,
734,
311,
1684,
279,
8298,
5208,
627,
394,
578,
734,
2011,
1935,
13157,
3045,
11,
1510,
11,
2860,
11,
1144,
9,
2164,
4911,
439,
68647,
6105,
320,
7349,
520,
279,
3857,
198,
394,
3770,
369,
264,
11944,
4096,
3677,
310,
5208,
8550,
320,
14196,
25609,
91816,
353,
13099,
9,
997,
394,
26041,
2587,
6105,
369,
279,
5208,
4927,
734,
13,
51612,
11,
369,
3187,
11,
422,
499,
1390,
311,
1522,
198,
394,
264,
6369,
851,
323,
264,
1984,
851,
304,
2015,
311,
4600,
264,
1984,
449,
279,
6177,
5208,
382,
286,
7089,
13831,
512,
310,
3016,
30354,
2347,
19258,
3032,
366,
3368,
87220,
11978,
44726,
997,
394,
578,
8589,
5196,
11,
5505,
994,
499,
1390,
311,
1650,
1023,
5446,
5528,
4871,
279,
4927,
734,
382,
310,
1510,
320,
14196,
396,
14196,
997,
394,
578,
3392,
315,
5943,
23700,
779,
3117,
382,
310,
2860,
320,
14196,
396,
14196,
997,
394,
578,
1404,
315,
279,
1052,
382,
310,
353,
2164,
320,
14196,
25609,
91816,
353,
13099,
9,
997,
394,
26041,
2587,
6105,
439,
4613,
304,
279,
353,
14703,
8550,
9,
5852,
627,
394,
1472,
649,
3060,
2567,
88887,
9,
2164,
9,
477,
923,
1475,
3254,
5066,
5811,
304,
701,
734,
12223,
382,
286,
5295,
512,
310,
1952,
2450,
11,
279,
23700,
1052,
374,
6052,
304,
1376,
315,
459,
5688,
1738,
1665,
382,
286,
61411,
512,
310,
551,
1058,
19258,
30628,
1480,
366,
3368,
87220,
2056,
4977,
1480,
44726,
304,
1162,
315,
264,
44063,
35108,
1493,
382,
14711,
6075,
512,
755,
3665,
2517,
1214,
345,
1733,
1853,
25,
610,
345,
1733,
1052,
851,
25,
528,
284,
2290,
345,
1733,
1052,
10715,
25,
528,
284,
220,
15,
345,
1733,
5208,
25,
42022,
284,
2290,
345,
1733,
5208,
8550,
25,
14743,
284
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
10464,
420,
1749,
311,
8298,
264,
1052,
8800,
44063,
16692,
11,
2085,
3604,
11889,
279,
1984,
311,
5606,
382,
286,
1115,
374,
264,
15919,
1749,
10825,
311,
387,
1511,
3146,
3323,
334,
994,
3318,
449,
23886,
24460,
320,
72,
1770,
25,
264,
44063,
5446,
198,
286,
1749,
499,
6562,
311,
1005,
902,
374,
539,
2561,
3686,
304,
279,
8589,
538,
439,
459,
4228,
4791,
25700,
1749,
705,
15716,
459,
198,
286,
5688,
1738,
955,
374,
2631,
382,
286,
18161,
512,
310,
1853,
320,
14196,
496,
14196,
997,
394,
578,
1853,
315,
279,
1052,
499,
1390,
311,
8298,
430,
6866,
389,
701,
2254,
5780,
382,
310,
1052,
851,
320,
14196,
396,
91816,
353,
13099,
9,
997,
394,
763,
1162,
264,
1052,
961,
27489,
11,
1522,
279,
1052,
851,
323,
279,
1052,
10715,
311,
23515,
48429,
430,
3230,
12143,
382,
310,
1052,
10715,
320,
14196,
396,
91816,
353,
13099,
9,
997,
394,
763,
1162,
264,
1052,
961,
27489,
11,
1522,
279,
1052,
851,
323,
279,
1052,
10715,
311,
23515,
48429,
430,
3230,
12143,
382,
310,
5208,
320,
14196,
96292,
91816,
353,
13099,
9,
997,
394,
10175,
264,
4927,
734,
311,
1684,
279,
8298,
5208,
627,
394,
578,
734,
2011,
1935,
13157,
3045,
11,
1510,
11,
2860,
11,
1144,
9,
2164,
4911,
439,
68647,
6105,
320,
7349,
520,
279,
3857,
198,
394,
3770,
369,
264,
11944,
4096,
3677,
310,
5208,
8550,
320,
14196,
25609,
91816,
353,
13099,
9,
997,
394,
26041,
2587,
6105,
369,
279,
5208,
4927,
734,
13,
51612,
11,
369,
3187,
11,
422,
499,
1390,
311,
1522,
198,
394,
264,
6369,
851,
323,
264,
1984,
851,
304,
2015,
311,
4600,
264,
1984,
449,
279,
6177,
5208,
382,
286,
7089,
13831,
512,
310,
3016,
30354,
2347,
19258,
3032,
366,
3368,
87220,
11978,
44726,
997,
394,
578,
8589,
5196,
11,
5505,
994,
499,
1390,
311,
1650,
1023,
5446,
5528,
4871,
279,
4927,
734,
382,
310,
1510,
320,
14196,
396,
14196,
997,
394,
578,
3392,
315,
5943,
23700,
779,
3117,
382,
310,
2860,
320,
14196,
396,
14196,
997,
394,
578,
1404,
315,
279,
1052,
382,
310,
353,
2164,
320,
14196,
25609,
91816,
353,
13099,
9,
997,
394,
26041,
2587,
6105,
439,
4613,
304,
279,
353,
14703,
8550,
9,
5852,
627,
394,
1472,
649,
3060,
2567,
88887,
9,
2164,
9,
477,
923,
1475,
3254,
5066,
5811,
304,
701,
734,
12223,
382,
286,
5295,
512,
310,
1952,
2450,
11,
279,
23700,
1052,
374,
6052,
304,
1376,
315,
459,
5688,
1738,
1665,
382,
286,
61411,
512,
310,
551,
1058,
19258,
30628,
1480,
366,
3368,
87220,
2056,
4977,
1480,
44726,
304,
1162,
315,
264,
44063,
35108,
1493,
382,
14711,
6075,
512,
755,
3665,
2517,
1214,
345,
1733,
1853,
25,
610,
345,
1733,
1052,
851,
25,
528,
284,
2290,
345,
1733,
1052,
10715,
25,
528,
284,
220,
15,
345,
1733,
5208,
25,
42022,
284,
2290,
345,
1733,
5208,
8550,
25,
14743,
284
] |
dwavesystems/dimod | dimod/generators/random.py | uniform | def uniform(graph, vartype, low=0.0, high=1.0, cls=BinaryQuadraticModel,
seed=None):
"""Generate a bqm with random biases and offset.
Biases and offset are drawn from a uniform distribution range (low, high).
Args:
graph (int/tuple[nodes, edges]/:obj:`~networkx.Graph`):
The graph to build the bqm loops on. Either an integer n, interpreted as a
complete graph of size n, or a nodes/edges pair, or a NetworkX graph.
vartype (:class:`.Vartype`/str/set):
Variable type for the binary quadratic model. Accepted input values:
* :class:`.Vartype.SPIN`, ``'SPIN'``, ``{-1, 1}``
* :class:`.Vartype.BINARY`, ``'BINARY'``, ``{0, 1}``
low (float, optional, default=0.0):
The low end of the range for the random biases.
high (float, optional, default=1.0):
The high end of the range for the random biases.
cls (:class:`.BinaryQuadraticModel`):
Binary quadratic model class to build from.
seed (int, optional, default=None):
Random seed.
Returns:
:obj:`.BinaryQuadraticModel`
"""
if seed is None:
seed = numpy.random.randint(2**32, dtype=np.uint32)
r = numpy.random.RandomState(seed)
variables, edges = graph
index = {v: idx for idx, v in enumerate(variables)}
if edges:
irow, icol = zip(*((index[u], index[v]) for u, v in edges))
else:
irow = icol = tuple()
ldata = r.uniform(low, high, size=len(variables))
qdata = r.uniform(low, high, size=len(irow))
offset = r.uniform(low, high)
return cls.from_numpy_vectors(ldata, (irow, icol, qdata), offset, vartype,
variable_order=variables) | python | def uniform(graph, vartype, low=0.0, high=1.0, cls=BinaryQuadraticModel,
seed=None):
"""Generate a bqm with random biases and offset.
Biases and offset are drawn from a uniform distribution range (low, high).
Args:
graph (int/tuple[nodes, edges]/:obj:`~networkx.Graph`):
The graph to build the bqm loops on. Either an integer n, interpreted as a
complete graph of size n, or a nodes/edges pair, or a NetworkX graph.
vartype (:class:`.Vartype`/str/set):
Variable type for the binary quadratic model. Accepted input values:
* :class:`.Vartype.SPIN`, ``'SPIN'``, ``{-1, 1}``
* :class:`.Vartype.BINARY`, ``'BINARY'``, ``{0, 1}``
low (float, optional, default=0.0):
The low end of the range for the random biases.
high (float, optional, default=1.0):
The high end of the range for the random biases.
cls (:class:`.BinaryQuadraticModel`):
Binary quadratic model class to build from.
seed (int, optional, default=None):
Random seed.
Returns:
:obj:`.BinaryQuadraticModel`
"""
if seed is None:
seed = numpy.random.randint(2**32, dtype=np.uint32)
r = numpy.random.RandomState(seed)
variables, edges = graph
index = {v: idx for idx, v in enumerate(variables)}
if edges:
irow, icol = zip(*((index[u], index[v]) for u, v in edges))
else:
irow = icol = tuple()
ldata = r.uniform(low, high, size=len(variables))
qdata = r.uniform(low, high, size=len(irow))
offset = r.uniform(low, high)
return cls.from_numpy_vectors(ldata, (irow, icol, qdata), offset, vartype,
variable_order=variables) | [
"def",
"uniform",
"(",
"graph",
",",
"vartype",
",",
"low",
"=",
"0.0",
",",
"high",
"=",
"1.0",
",",
"cls",
"=",
"BinaryQuadraticModel",
",",
"seed",
"=",
"None",
")",
":",
"if",
"seed",
"is",
"None",
":",
"seed",
"=",
"numpy",
".",
"random",
".",
"randint",
"(",
"2",
"**",
"32",
",",
"dtype",
"=",
"np",
".",
"uint32",
")",
"r",
"=",
"numpy",
".",
"random",
".",
"RandomState",
"(",
"seed",
")",
"variables",
",",
"edges",
"=",
"graph",
"index",
"=",
"{",
"v",
":",
"idx",
"for",
"idx",
",",
"v",
"in",
"enumerate",
"(",
"variables",
")",
"}",
"if",
"edges",
":",
"irow",
",",
"icol",
"=",
"zip",
"(",
"*",
"(",
"(",
"index",
"[",
"u",
"]",
",",
"index",
"[",
"v",
"]",
")",
"for",
"u",
",",
"v",
"in",
"edges",
")",
")",
"else",
":",
"irow",
"=",
"icol",
"=",
"tuple",
"(",
")",
"ldata",
"=",
"r",
".",
"uniform",
"(",
"low",
",",
"high",
",",
"size",
"=",
"len",
"(",
"variables",
")",
")",
"qdata",
"=",
"r",
".",
"uniform",
"(",
"low",
",",
"high",
",",
"size",
"=",
"len",
"(",
"irow",
")",
")",
"offset",
"=",
"r",
".",
"uniform",
"(",
"low",
",",
"high",
")",
"return",
"cls",
".",
"from_numpy_vectors",
"(",
"ldata",
",",
"(",
"irow",
",",
"icol",
",",
"qdata",
")",
",",
"offset",
",",
"vartype",
",",
"variable_order",
"=",
"variables",
")"
] | Generate a bqm with random biases and offset.
Biases and offset are drawn from a uniform distribution range (low, high).
Args:
graph (int/tuple[nodes, edges]/:obj:`~networkx.Graph`):
The graph to build the bqm loops on. Either an integer n, interpreted as a
complete graph of size n, or a nodes/edges pair, or a NetworkX graph.
vartype (:class:`.Vartype`/str/set):
Variable type for the binary quadratic model. Accepted input values:
* :class:`.Vartype.SPIN`, ``'SPIN'``, ``{-1, 1}``
* :class:`.Vartype.BINARY`, ``'BINARY'``, ``{0, 1}``
low (float, optional, default=0.0):
The low end of the range for the random biases.
high (float, optional, default=1.0):
The high end of the range for the random biases.
cls (:class:`.BinaryQuadraticModel`):
Binary quadratic model class to build from.
seed (int, optional, default=None):
Random seed.
Returns:
:obj:`.BinaryQuadraticModel` | [
"Generate",
"a",
"bqm",
"with",
"random",
"biases",
"and",
"offset",
"."
] | train | https://github.com/dwavesystems/dimod/blob/beff1b7f86b559d923ac653c1de6d593876d6d38/dimod/generators/random.py#L28-L79 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Generate a bqm with random biases and offset.
Biases and offset are drawn from a uniform distribution range (low, high).
Args:
graph (int/tuple[nodes, edges]/:obj:`~networkx.Graph`):
The graph to build the bqm loops on. Either an integer n, interpreted as a
complete graph of size n, or a nodes/edges pair, or a NetworkX graph.
vartype (:class:`.Vartype`/str/set):
Variable type for the binary quadratic model. Accepted input values:
* :class:`.Vartype.SPIN`, ``'SPIN'``, ``{-1, 1}``
* :class:`.Vartype.BINARY`, ``'BINARY'``, ``{0, 1}``
low (float, optional, default=0.0):
The low end of the range for the random biases.
high (float, optional, default=1.0):
The high end of the range for the random biases.
cls (:class:`.BinaryQuadraticModel`):
Binary quadratic model class to build from.
seed (int, optional, default=None):
Random seed.
Returns:
:obj:`.BinaryQuadraticModel`
### Response:
def uniform(graph, vartype, low=0.0, high=1.0, cls=BinaryQuadraticModel,
seed=None):
"""Generate a bqm with random biases and offset.
Biases and offset are drawn from a uniform distribution range (low, high).
Args:
graph (int/tuple[nodes, edges]/:obj:`~networkx.Graph`):
The graph to build the bqm loops on. Either an integer n, interpreted as a
complete graph of size n, or a nodes/edges pair, or a NetworkX graph.
vartype (:class:`.Vartype`/str/set):
Variable type for the binary quadratic model. Accepted input values:
* :class:`.Vartype.SPIN`, ``'SPIN'``, ``{-1, 1}``
* :class:`.Vartype.BINARY`, ``'BINARY'``, ``{0, 1}``
low (float, optional, default=0.0):
The low end of the range for the random biases.
high (float, optional, default=1.0):
The high end of the range for the random biases.
cls (:class:`.BinaryQuadraticModel`):
Binary quadratic model class to build from.
seed (int, optional, default=None):
Random seed.
Returns:
:obj:`.BinaryQuadraticModel`
"""
if seed is None:
seed = numpy.random.randint(2**32, dtype=np.uint32)
r = numpy.random.RandomState(seed)
variables, edges = graph
index = {v: idx for idx, v in enumerate(variables)}
if edges:
irow, icol = zip(*((index[u], index[v]) for u, v in edges))
else:
irow = icol = tuple()
ldata = r.uniform(low, high, size=len(variables))
qdata = r.uniform(low, high, size=len(irow))
offset = r.uniform(low, high)
return cls.from_numpy_vectors(ldata, (irow, icol, qdata), offset, vartype,
variable_order=variables)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32215,
264,
293,
78498,
449,
4288,
50183,
323,
4445,
382,
262,
12371,
2315,
323,
4445,
527,
15107,
505,
264,
14113,
8141,
2134,
320,
10516,
11,
1579,
3677,
262,
18161,
512,
286,
4876,
320,
396,
5640,
6189,
7824,
2601,
11,
13116,
9968,
25,
2347,
78902,
17969,
87,
41337,
63,
997,
310,
578,
4876,
311,
1977,
279,
293,
78498,
30853,
389,
13,
21663,
459,
7698,
308,
11,
33398,
439,
264,
198,
310,
4686,
4876,
315,
1404,
308,
11,
477,
264,
7954,
14,
17327,
6857,
11,
477,
264,
8304,
55,
4876,
382,
286,
348,
472,
500,
30354,
1058,
19258,
13,
53,
472,
500,
63,
14,
496,
48367,
997,
310,
12689,
955,
369,
279,
8026,
80251,
1646,
13,
64389,
1988,
2819,
1473,
310,
353,
551,
1058,
19258,
13,
53,
472,
500,
815,
57161,
7964,
10103,
6,
4695,
691,
6,
91816,
10103,
20597,
16,
11,
220,
16,
5658,
4077,
310,
353,
551,
1058,
19258,
13,
53,
472,
500,
1823,
33693,
7964,
10103,
6,
33,
33693,
6,
91816,
10103,
90,
15,
11,
220,
16,
5658,
19884,
286,
3428,
320,
3733,
11,
10309,
11,
1670,
28,
15,
13,
15,
997,
310,
578,
3428,
842,
315,
279,
2134,
369,
279,
4288,
50183,
382,
286,
1579,
320,
3733,
11,
10309,
11,
1670,
28,
16,
13,
15,
997,
310,
578,
1579,
842,
315,
279,
2134,
369,
279,
4288,
50183,
382,
286,
13082,
30354,
1058,
19258,
13,
22045,
2232,
89778,
1747,
63,
997,
310,
18188,
80251,
1646,
538,
311,
1977,
505,
382,
286,
10533,
320,
396,
11,
10309,
11,
1670,
5980,
997,
310,
10836,
10533,
382,
262,
5295,
512,
286,
551,
2347,
19258,
13,
22045,
2232,
89778,
1747,
19884,
14711,
6075,
512,
755,
14113,
25301,
11,
348,
472,
500,
11,
3428,
28,
15,
13,
15,
11,
1579,
28,
16,
13,
15,
11,
13082,
28,
22045,
2232,
89778,
1747,
345,
310,
10533,
5980,
997,
262,
4304,
32215,
264,
293,
78498,
449,
4288,
50183,
323,
4445,
382,
262,
12371,
2315,
323,
4445,
527,
15107,
505,
264,
14113,
8141,
2134,
320,
10516,
11,
1579,
3677,
262,
18161,
512,
286,
4876,
320,
396,
5640,
6189,
7824,
2601,
11,
13116,
9968,
25,
2347,
78902,
17969,
87,
41337,
63,
997,
310,
578,
4876,
311,
1977,
279,
293,
78498,
30853,
389,
13,
21663,
459,
7698,
308,
11,
33398,
439,
264,
198,
310,
4686,
4876,
315,
1404,
308,
11,
477,
264,
7954,
14,
17327,
6857,
11,
477,
264,
8304,
55,
4876,
382,
286,
348,
472,
500,
30354,
1058,
19258,
13,
53,
472,
500,
63,
14,
496,
48367,
997,
310,
12689,
955,
369,
279,
8026,
80251,
1646,
13,
64389,
1988,
2819,
1473,
310,
353,
551,
1058,
19258,
13,
53,
472,
500,
815,
57161,
7964,
10103,
6,
4695,
691,
6,
91816,
10103,
20597,
16,
11,
220,
16,
5658,
4077,
310,
353,
551,
1058,
19258,
13,
53,
472,
500,
1823,
33693,
7964,
10103,
6,
33,
33693,
6,
91816,
10103,
90,
15,
11,
220,
16,
5658
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32215,
264,
293,
78498,
449,
4288,
50183,
323,
4445,
382,
262,
12371,
2315,
323,
4445,
527,
15107,
505,
264,
14113,
8141,
2134,
320,
10516,
11,
1579,
3677,
262,
18161,
512,
286,
4876,
320,
396,
5640,
6189,
7824,
2601,
11,
13116,
9968,
25,
2347,
78902,
17969,
87,
41337,
63,
997,
310,
578,
4876,
311,
1977,
279,
293,
78498,
30853,
389,
13,
21663,
459,
7698,
308,
11,
33398,
439,
264,
198,
310,
4686,
4876,
315,
1404,
308,
11,
477,
264,
7954,
14,
17327,
6857,
11,
477,
264,
8304,
55,
4876,
382,
286,
348,
472,
500,
30354,
1058,
19258,
13,
53,
472,
500,
63,
14,
496,
48367,
997,
310,
12689,
955,
369,
279,
8026,
80251,
1646,
13,
64389,
1988,
2819,
1473,
310,
353,
551,
1058,
19258,
13,
53,
472,
500,
815,
57161,
7964,
10103,
6,
4695,
691,
6,
91816,
10103,
20597,
16,
11,
220,
16,
5658,
4077,
310,
353,
551,
1058,
19258,
13,
53,
472,
500,
1823,
33693,
7964,
10103,
6,
33,
33693,
6,
91816,
10103,
90,
15,
11,
220,
16,
5658,
19884,
286,
3428,
320,
3733,
11,
10309,
11,
1670,
28,
15,
13,
15,
997,
310,
578,
3428,
842,
315,
279,
2134,
369,
279,
4288,
50183,
382,
286,
1579,
320,
3733,
11,
10309,
11,
1670,
28,
16,
13,
15,
997,
310,
578,
1579,
842,
315,
279,
2134,
369,
279,
4288,
50183,
382,
286,
13082,
30354,
1058,
19258,
13,
22045,
2232,
89778,
1747,
63,
997,
310,
18188,
80251,
1646,
538,
311,
1977,
505,
382,
286,
10533,
320,
396,
11,
10309,
11,
1670,
5980,
997,
310,
10836,
10533,
382,
262,
5295,
512,
286,
551,
2347,
19258,
13,
22045,
2232,
89778,
1747,
19884,
14711,
6075,
512,
755,
14113,
25301,
11,
348,
472,
500,
11,
3428,
28,
15,
13,
15,
11,
1579,
28,
16,
13,
15,
11,
13082,
28,
22045,
2232,
89778,
1747,
345,
310,
10533,
5980,
997,
262,
4304,
32215,
264,
293,
78498,
449,
4288,
50183,
323,
4445,
382,
262,
12371,
2315,
323,
4445,
527,
15107,
505,
264,
14113,
8141,
2134,
320,
10516,
11,
1579,
3677,
262,
18161,
512,
286,
4876,
320,
396,
5640,
6189,
7824,
2601,
11,
13116,
9968,
25,
2347,
78902,
17969,
87,
41337,
63,
997,
310,
578,
4876,
311,
1977,
279,
293,
78498,
30853,
389,
13,
21663,
459,
7698,
308,
11,
33398,
439,
264,
198,
310,
4686,
4876,
315,
1404,
308,
11,
477,
264,
7954,
14,
17327,
6857,
11,
477,
264,
8304,
55,
4876,
382,
286,
348,
472,
500,
30354,
1058,
19258,
13,
53,
472,
500,
63,
14,
496,
48367,
997,
310,
12689,
955,
369,
279,
8026,
80251,
1646,
13,
64389,
1988,
2819,
1473,
310,
353,
551,
1058,
19258,
13,
53,
472,
500,
815,
57161,
7964,
10103,
6,
4695,
691,
6,
91816,
10103,
20597,
16,
11,
220,
16,
5658,
4077,
310,
353,
551,
1058,
19258,
13,
53,
472,
500,
1823,
33693,
7964,
10103,
6,
33,
33693,
6,
91816,
10103,
90,
15,
11,
220,
16,
5658
] |
OLC-Bioinformatics/sipprverse | cgecore/argumentparsing.py | get_arguments | def get_arguments(options):
""" This function handles and validates the wrapper arguments. """
# These the next couple of lines defines the header of the Help output
parser = ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
usage=("""%(prog)s
--------------------------------------------------------------------------------
"""),
description=("""
Service Wrapper
===============
This is the service wrapper script, which is a part of the CGE services.
Read the online manual for help.
A list of all published services can be found at:
cge.cbs.dtu.dk/services
"""), epilog=("""
--------------------------------------------------------------------------------
"""))
#ADDING ARGUMENTS
setarg = parser.add_argument
#SERVICE SPECIFIC ARGUMENTS
if isinstance(options, str):
options = [[x for i,x in enumerate(line.split()) if i in [1,2]] for line in options.split('\n') if len(line)>0]
for o in options:
try:
setarg(o[1], type=str, dest=o[0], default=None, help=SUPPRESS)
except:
None
else:
for o in options:
if o[2] is True:
# Handle negative flags
setarg(o[0], action="store_false", dest=o[1], default=o[2],
help=o[3])
elif o[2] is False:
# Handle positive flags
setarg(o[0], action="store_true", dest=o[1], default=o[2],
help=o[3])
else:
help_ = o[3] if o[2] is None else "%s [%s]"%(o[3], '%(default)s')
setarg(o[0], type=str, dest=o[1], default=o[2],
help=help_)
# VALIDATION OF ARGUMENTS
args = parser.parse_args()
debug.log("ARGS: %s"%args)
return args | python | def get_arguments(options):
""" This function handles and validates the wrapper arguments. """
# These the next couple of lines defines the header of the Help output
parser = ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
usage=("""%(prog)s
--------------------------------------------------------------------------------
"""),
description=("""
Service Wrapper
===============
This is the service wrapper script, which is a part of the CGE services.
Read the online manual for help.
A list of all published services can be found at:
cge.cbs.dtu.dk/services
"""), epilog=("""
--------------------------------------------------------------------------------
"""))
#ADDING ARGUMENTS
setarg = parser.add_argument
#SERVICE SPECIFIC ARGUMENTS
if isinstance(options, str):
options = [[x for i,x in enumerate(line.split()) if i in [1,2]] for line in options.split('\n') if len(line)>0]
for o in options:
try:
setarg(o[1], type=str, dest=o[0], default=None, help=SUPPRESS)
except:
None
else:
for o in options:
if o[2] is True:
# Handle negative flags
setarg(o[0], action="store_false", dest=o[1], default=o[2],
help=o[3])
elif o[2] is False:
# Handle positive flags
setarg(o[0], action="store_true", dest=o[1], default=o[2],
help=o[3])
else:
help_ = o[3] if o[2] is None else "%s [%s]"%(o[3], '%(default)s')
setarg(o[0], type=str, dest=o[1], default=o[2],
help=help_)
# VALIDATION OF ARGUMENTS
args = parser.parse_args()
debug.log("ARGS: %s"%args)
return args | [
"def",
"get_arguments",
"(",
"options",
")",
":",
"# These the next couple of lines defines the header of the Help output",
"parser",
"=",
"ArgumentParser",
"(",
"formatter_class",
"=",
"RawDescriptionHelpFormatter",
",",
"usage",
"=",
"(",
"\"\"\"%(prog)s\n--------------------------------------------------------------------------------\n\"\"\"",
")",
",",
"description",
"=",
"(",
"\"\"\"\nService Wrapper\n===============\nThis is the service wrapper script, which is a part of the CGE services.\nRead the online manual for help.\nA list of all published services can be found at:\ncge.cbs.dtu.dk/services\n\n\"\"\"",
")",
",",
"epilog",
"=",
"(",
"\"\"\"\n--------------------------------------------------------------------------------\n \"\"\"",
")",
")",
"#ADDING ARGUMENTS",
"setarg",
"=",
"parser",
".",
"add_argument",
"#SERVICE SPECIFIC ARGUMENTS",
"if",
"isinstance",
"(",
"options",
",",
"str",
")",
":",
"options",
"=",
"[",
"[",
"x",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"line",
".",
"split",
"(",
")",
")",
"if",
"i",
"in",
"[",
"1",
",",
"2",
"]",
"]",
"for",
"line",
"in",
"options",
".",
"split",
"(",
"'\\n'",
")",
"if",
"len",
"(",
"line",
")",
">",
"0",
"]",
"for",
"o",
"in",
"options",
":",
"try",
":",
"setarg",
"(",
"o",
"[",
"1",
"]",
",",
"type",
"=",
"str",
",",
"dest",
"=",
"o",
"[",
"0",
"]",
",",
"default",
"=",
"None",
",",
"help",
"=",
"SUPPRESS",
")",
"except",
":",
"None",
"else",
":",
"for",
"o",
"in",
"options",
":",
"if",
"o",
"[",
"2",
"]",
"is",
"True",
":",
"# Handle negative flags",
"setarg",
"(",
"o",
"[",
"0",
"]",
",",
"action",
"=",
"\"store_false\"",
",",
"dest",
"=",
"o",
"[",
"1",
"]",
",",
"default",
"=",
"o",
"[",
"2",
"]",
",",
"help",
"=",
"o",
"[",
"3",
"]",
")",
"elif",
"o",
"[",
"2",
"]",
"is",
"False",
":",
"# Handle positive flags",
"setarg",
"(",
"o",
"[",
"0",
"]",
",",
"action",
"=",
"\"store_true\"",
",",
"dest",
"=",
"o",
"[",
"1",
"]",
",",
"default",
"=",
"o",
"[",
"2",
"]",
",",
"help",
"=",
"o",
"[",
"3",
"]",
")",
"else",
":",
"help_",
"=",
"o",
"[",
"3",
"]",
"if",
"o",
"[",
"2",
"]",
"is",
"None",
"else",
"\"%s [%s]\"",
"%",
"(",
"o",
"[",
"3",
"]",
",",
"'%(default)s'",
")",
"setarg",
"(",
"o",
"[",
"0",
"]",
",",
"type",
"=",
"str",
",",
"dest",
"=",
"o",
"[",
"1",
"]",
",",
"default",
"=",
"o",
"[",
"2",
"]",
",",
"help",
"=",
"help_",
")",
"# VALIDATION OF ARGUMENTS",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"debug",
".",
"log",
"(",
"\"ARGS: %s\"",
"%",
"args",
")",
"return",
"args"
] | This function handles and validates the wrapper arguments. | [
"This",
"function",
"handles",
"and",
"validates",
"the",
"wrapper",
"arguments",
"."
] | train | https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/argumentparsing.py#L29-L76 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
This function handles and validates the wrapper arguments.
### Response:
def get_arguments(options):
""" This function handles and validates the wrapper arguments. """
# These the next couple of lines defines the header of the Help output
parser = ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
usage=("""%(prog)s
--------------------------------------------------------------------------------
"""),
description=("""
Service Wrapper
===============
This is the service wrapper script, which is a part of the CGE services.
Read the online manual for help.
A list of all published services can be found at:
cge.cbs.dtu.dk/services
"""), epilog=("""
--------------------------------------------------------------------------------
"""))
#ADDING ARGUMENTS
setarg = parser.add_argument
#SERVICE SPECIFIC ARGUMENTS
if isinstance(options, str):
options = [[x for i,x in enumerate(line.split()) if i in [1,2]] for line in options.split('\n') if len(line)>0]
for o in options:
try:
setarg(o[1], type=str, dest=o[0], default=None, help=SUPPRESS)
except:
None
else:
for o in options:
if o[2] is True:
# Handle negative flags
setarg(o[0], action="store_false", dest=o[1], default=o[2],
help=o[3])
elif o[2] is False:
# Handle positive flags
setarg(o[0], action="store_true", dest=o[1], default=o[2],
help=o[3])
else:
help_ = o[3] if o[2] is None else "%s [%s]"%(o[3], '%(default)s')
setarg(o[0], type=str, dest=o[1], default=o[2],
help=help_)
# VALIDATION OF ARGUMENTS
args = parser.parse_args()
debug.log("ARGS: %s"%args)
return args
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2028,
734,
13777,
323,
27353,
279,
13564,
6105,
382,
14711,
6075,
512,
755,
636,
44533,
12349,
997,
256,
4304,
1115,
734,
13777,
323,
27353,
279,
13564,
6105,
13,
3270,
256,
674,
4314,
279,
1828,
5743,
315,
5238,
19170,
279,
4342,
315,
279,
11736,
2612,
198,
256,
6871,
284,
14138,
6707,
1021,
415,
25851,
4895,
28,
20613,
5116,
12978,
14517,
345,
415,
10648,
50097,
3089,
20939,
34092,
16871,
198,
44549,
198,
94288,
415,
4096,
28,
69860,
1898,
36588,
198,
58979,
2028,
374,
279,
2532,
13564,
5429,
11,
902,
374,
264,
961,
315,
279,
6290,
36,
3600,
627,
4518,
279,
2930,
11630,
369,
1520,
627,
32,
1160,
315,
682,
4756,
3600,
649,
387,
1766,
520,
512,
66,
713,
522,
1302,
962,
25506,
72166,
23054,
271,
3089,
4063,
4248,
51873,
28,
69860,
44549,
198,
415,
1621,
29175,
256,
674,
53578,
33846,
18380,
50,
198,
256,
743,
867,
284,
6871,
1388,
9202,
198,
256,
674,
66175,
48204,
34735,
33846,
18380,
50,
198,
256,
422,
11656,
12349,
11,
610,
997,
415,
2671,
284,
4416,
87,
369,
602,
13095,
304,
13555,
8973,
5402,
2189,
422,
602,
304,
510,
16,
11,
17,
5163,
369,
1584,
304,
2671,
5402,
11270,
77,
873,
422,
2479,
8973,
16401,
15,
933,
415,
369,
297,
304,
2671,
512,
260,
1456,
512,
310,
743,
867,
10316,
58,
16,
1145,
955,
16311,
11,
3281,
86976,
58,
15,
1145,
1670,
5980,
11,
1520,
73296,
3202,
73630,
340,
260,
3734,
512,
310,
2290,
198,
256,
775,
512,
415,
369,
297,
304,
2671,
512,
260,
422,
297,
58,
17,
60,
374,
3082,
512,
310,
674,
14078,
8389,
8202,
198,
310,
743,
867,
10316,
58,
15,
1145,
1957,
429,
4412,
37115,
498,
3281,
86976,
58,
16,
1145,
1670,
86976,
58,
17,
1282,
4391,
1520,
86976,
58,
18,
2608,
260,
4508,
297,
58,
17,
60,
374,
3641,
512,
310,
674,
14078,
6928,
8202,
198,
310,
743,
867,
10316,
58,
15,
1145,
1957,
429,
4412,
16469,
498,
3281,
86976,
58,
16,
1145,
1670,
86976,
58,
17,
1282,
4391,
1520,
86976,
58,
18,
2608,
260,
775,
512,
310,
1520,
62,
284,
297,
58,
18,
60,
422,
297,
58,
17,
60,
374,
2290,
775,
6090,
82,
24528,
82,
19727,
20939,
78,
58,
18,
1145,
7832,
7,
2309,
16871,
1329,
310,
743,
867,
10316,
58,
15,
1145,
955,
16311,
11,
3281,
86976,
58,
16,
1145,
1670,
86976,
58,
17,
1282,
4391,
1520,
28,
8823,
24262,
256,
674,
44391,
3579,
3083,
33846,
18380,
50,
198,
256,
2897,
284,
6871,
4736,
8550,
746,
256,
7542,
1699,
446,
48583,
25,
1034,
82,
32491,
2164,
340,
256,
471,
2897,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2028,
734,
13777,
323,
27353,
279,
13564,
6105,
382,
14711,
6075,
512,
755,
636,
44533,
12349,
997,
256,
4304,
1115,
734,
13777,
323,
27353,
279,
13564,
6105,
13,
3270,
256,
674,
4314,
279,
1828,
5743,
315,
5238,
19170,
279,
4342,
315,
279,
11736,
2612,
198,
256,
6871,
284,
14138,
6707,
1021,
415,
25851,
4895,
28,
20613,
5116,
12978,
14517,
345,
415,
10648,
50097,
3089,
20939,
34092,
16871,
198,
44549,
198,
94288,
415,
4096,
28,
69860,
1898,
36588,
198,
58979,
2028,
374,
279,
2532,
13564,
5429,
11,
902,
374,
264,
961,
315,
279,
6290,
36,
3600,
627,
4518,
279,
2930,
11630,
369,
1520,
627,
32,
1160,
315,
682,
4756,
3600,
649,
387,
1766,
520,
512,
66,
713,
522,
1302,
962,
25506,
72166,
23054,
271,
3089,
4063,
4248,
51873,
28,
69860,
44549,
198,
415,
1621,
29175,
256,
674,
53578,
33846,
18380,
50,
198,
256,
743,
867,
284,
6871,
1388,
9202,
198,
256,
674,
66175,
48204,
34735,
33846,
18380,
50,
198,
256,
422,
11656,
12349,
11,
610,
997,
415,
2671,
284,
4416,
87,
369,
602,
13095,
304,
13555,
8973,
5402,
2189,
422,
602,
304,
510,
16,
11,
17,
5163,
369,
1584,
304,
2671,
5402,
11270,
77,
873,
422,
2479,
8973,
16401,
15,
933,
415,
369,
297,
304,
2671,
512,
260,
1456,
512,
310,
743,
867,
10316,
58,
16,
1145,
955,
16311,
11,
3281,
86976,
58,
15,
1145,
1670,
5980,
11,
1520,
73296,
3202,
73630,
340,
260,
3734,
512,
310,
2290,
198,
256,
775,
512,
415,
369,
297,
304,
2671,
512,
260,
422,
297,
58,
17,
60,
374,
3082,
512,
310,
674,
14078,
8389,
8202,
198,
310,
743,
867,
10316,
58,
15,
1145,
1957,
429,
4412,
37115,
498,
3281,
86976,
58,
16,
1145,
1670,
86976,
58,
17,
1282,
4391,
1520,
86976,
58,
18,
2608,
260,
4508,
297,
58,
17,
60,
374,
3641,
512,
310,
674,
14078,
6928,
8202,
198,
310,
743,
867,
10316,
58,
15,
1145,
1957,
429,
4412,
16469,
498,
3281,
86976,
58,
16,
1145,
1670,
86976,
58,
17,
1282,
4391,
1520,
86976,
58,
18,
2608,
260,
775,
512,
310,
1520,
62,
284,
297,
58,
18,
60,
422,
297,
58,
17,
60,
374,
2290,
775,
6090,
82,
24528,
82,
19727,
20939,
78,
58,
18,
1145,
7832,
7,
2309,
16871,
1329,
310,
743,
867,
10316,
58,
15,
1145,
955,
16311,
11,
3281,
86976,
58,
16,
1145,
1670,
86976,
58,
17,
1282,
4391,
1520,
28,
8823,
24262,
256,
674,
44391,
3579,
3083,
33846,
18380,
50,
198,
256,
2897,
284,
6871,
4736,
8550,
746,
256,
7542,
1699,
446,
48583,
25,
1034,
82,
32491,
2164,
340,
256,
471,
2897,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
tensorflow/hub | tensorflow_hub/tensor_info.py | _convert_to_compatible_tensor | def _convert_to_compatible_tensor(value, target, error_prefix):
"""Converts `value` into a tensor that can be feed into `tensor_info`.
Args:
value: A value to convert into Tensor or SparseTensor.
target: An object returned by `parse_tensor_info_map`.
error_prefix: A string to prefix on raised TypeErrors.
Raises:
TypeError: If it fails to convert.
Returns:
A Tensor or SparseTensor compatible with tensor_info.
"""
try:
tensor = tf_v1.convert_to_tensor_or_indexed_slices(value, target.dtype)
except TypeError as e:
raise TypeError("%s: %s" % (error_prefix, e))
if _is_sparse(tensor) != _is_sparse(target):
if _is_sparse(tensor):
raise TypeError("%s: Is sparse. Expected dense." % error_prefix)
else:
raise TypeError("%s: Is dense. Expected sparse." % error_prefix)
if not tensor.get_shape().is_compatible_with(target.get_shape()):
raise TypeError("%s: Shape %r is incompatible with %r" %
(error_prefix, tensor.get_shape(), target.get_shape()))
return tensor | python | def _convert_to_compatible_tensor(value, target, error_prefix):
"""Converts `value` into a tensor that can be feed into `tensor_info`.
Args:
value: A value to convert into Tensor or SparseTensor.
target: An object returned by `parse_tensor_info_map`.
error_prefix: A string to prefix on raised TypeErrors.
Raises:
TypeError: If it fails to convert.
Returns:
A Tensor or SparseTensor compatible with tensor_info.
"""
try:
tensor = tf_v1.convert_to_tensor_or_indexed_slices(value, target.dtype)
except TypeError as e:
raise TypeError("%s: %s" % (error_prefix, e))
if _is_sparse(tensor) != _is_sparse(target):
if _is_sparse(tensor):
raise TypeError("%s: Is sparse. Expected dense." % error_prefix)
else:
raise TypeError("%s: Is dense. Expected sparse." % error_prefix)
if not tensor.get_shape().is_compatible_with(target.get_shape()):
raise TypeError("%s: Shape %r is incompatible with %r" %
(error_prefix, tensor.get_shape(), target.get_shape()))
return tensor | [
"def",
"_convert_to_compatible_tensor",
"(",
"value",
",",
"target",
",",
"error_prefix",
")",
":",
"try",
":",
"tensor",
"=",
"tf_v1",
".",
"convert_to_tensor_or_indexed_slices",
"(",
"value",
",",
"target",
".",
"dtype",
")",
"except",
"TypeError",
"as",
"e",
":",
"raise",
"TypeError",
"(",
"\"%s: %s\"",
"%",
"(",
"error_prefix",
",",
"e",
")",
")",
"if",
"_is_sparse",
"(",
"tensor",
")",
"!=",
"_is_sparse",
"(",
"target",
")",
":",
"if",
"_is_sparse",
"(",
"tensor",
")",
":",
"raise",
"TypeError",
"(",
"\"%s: Is sparse. Expected dense.\"",
"%",
"error_prefix",
")",
"else",
":",
"raise",
"TypeError",
"(",
"\"%s: Is dense. Expected sparse.\"",
"%",
"error_prefix",
")",
"if",
"not",
"tensor",
".",
"get_shape",
"(",
")",
".",
"is_compatible_with",
"(",
"target",
".",
"get_shape",
"(",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"%s: Shape %r is incompatible with %r\"",
"%",
"(",
"error_prefix",
",",
"tensor",
".",
"get_shape",
"(",
")",
",",
"target",
".",
"get_shape",
"(",
")",
")",
")",
"return",
"tensor"
] | Converts `value` into a tensor that can be feed into `tensor_info`.
Args:
value: A value to convert into Tensor or SparseTensor.
target: An object returned by `parse_tensor_info_map`.
error_prefix: A string to prefix on raised TypeErrors.
Raises:
TypeError: If it fails to convert.
Returns:
A Tensor or SparseTensor compatible with tensor_info. | [
"Converts",
"value",
"into",
"a",
"tensor",
"that",
"can",
"be",
"feed",
"into",
"tensor_info",
"."
] | train | https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/tensor_info.py#L104-L130 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Converts `value` into a tensor that can be feed into `tensor_info`.
Args:
value: A value to convert into Tensor or SparseTensor.
target: An object returned by `parse_tensor_info_map`.
error_prefix: A string to prefix on raised TypeErrors.
Raises:
TypeError: If it fails to convert.
Returns:
A Tensor or SparseTensor compatible with tensor_info.
### Response:
def _convert_to_compatible_tensor(value, target, error_prefix):
"""Converts `value` into a tensor that can be feed into `tensor_info`.
Args:
value: A value to convert into Tensor or SparseTensor.
target: An object returned by `parse_tensor_info_map`.
error_prefix: A string to prefix on raised TypeErrors.
Raises:
TypeError: If it fails to convert.
Returns:
A Tensor or SparseTensor compatible with tensor_info.
"""
try:
tensor = tf_v1.convert_to_tensor_or_indexed_slices(value, target.dtype)
except TypeError as e:
raise TypeError("%s: %s" % (error_prefix, e))
if _is_sparse(tensor) != _is_sparse(target):
if _is_sparse(tensor):
raise TypeError("%s: Is sparse. Expected dense." % error_prefix)
else:
raise TypeError("%s: Is dense. Expected sparse." % error_prefix)
if not tensor.get_shape().is_compatible_with(target.get_shape()):
raise TypeError("%s: Shape %r is incompatible with %r" %
(error_prefix, tensor.get_shape(), target.get_shape()))
return tensor
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
12281,
82,
1595,
970,
63,
1139,
264,
16000,
430,
649,
387,
5510,
1139,
1595,
47211,
3186,
63438,
220,
18161,
512,
262,
907,
25,
362,
907,
311,
5625,
1139,
27127,
477,
72894,
26404,
627,
262,
2218,
25,
1556,
1665,
6052,
555,
1595,
6534,
24065,
3186,
5489,
19154,
262,
1493,
14301,
25,
362,
925,
311,
9436,
389,
9408,
4078,
14199,
382,
220,
61411,
512,
262,
26082,
25,
1442,
433,
14865,
311,
5625,
382,
220,
5295,
512,
262,
362,
27127,
477,
72894,
26404,
18641,
449,
16000,
3186,
382,
14711,
6075,
512,
755,
721,
14500,
2401,
3038,
38179,
24065,
3764,
11,
2218,
11,
1493,
14301,
997,
220,
4304,
12281,
82,
1595,
970,
63,
1139,
264,
16000,
430,
649,
387,
5510,
1139,
1595,
47211,
3186,
63438,
220,
18161,
512,
262,
907,
25,
362,
907,
311,
5625,
1139,
27127,
477,
72894,
26404,
627,
262,
2218,
25,
1556,
1665,
6052,
555,
1595,
6534,
24065,
3186,
5489,
19154,
262,
1493,
14301,
25,
362,
925,
311,
9436,
389,
9408,
4078,
14199,
382,
220,
61411,
512,
262,
26082,
25,
1442,
433,
14865,
311,
5625,
382,
220,
5295,
512,
262,
362,
27127,
477,
72894,
26404,
18641,
449,
16000,
3186,
627,
220,
3270,
220,
1456,
512,
262,
16000,
284,
6543,
2325,
16,
24973,
2401,
24065,
8908,
3644,
291,
88388,
3764,
11,
2218,
46855,
340,
220,
3734,
26082,
439,
384,
512,
262,
4933,
26082,
4530,
82,
25,
1034,
82,
1,
1034,
320,
850,
14301,
11,
384,
1192,
220,
422,
721,
285,
72223,
87125,
8,
976,
721,
285,
72223,
8807,
997,
262,
422,
721,
285,
72223,
87125,
997,
415,
4933,
26082,
4530,
82,
25,
2209,
34544,
13,
32121,
29050,
1210,
1034,
1493,
14301,
340,
262,
775,
512,
415,
4933,
26082,
4530,
82,
25,
2209,
29050,
13,
32121,
34544,
1210,
1034,
1493,
14301,
340,
220,
422,
539,
16000,
673,
13911,
1020,
285,
3038,
38179,
6753,
8807,
673,
13911,
34257,
262,
4933,
26082,
4530,
82,
25,
23342,
1034,
81,
374,
53924,
449,
1034,
81,
1,
33648,
504,
320,
850,
14301,
11,
16000,
673,
13911,
1535,
2218,
673,
13911,
12419,
220,
471,
16000,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
12281,
82,
1595,
970,
63,
1139,
264,
16000,
430,
649,
387,
5510,
1139,
1595,
47211,
3186,
63438,
220,
18161,
512,
262,
907,
25,
362,
907,
311,
5625,
1139,
27127,
477,
72894,
26404,
627,
262,
2218,
25,
1556,
1665,
6052,
555,
1595,
6534,
24065,
3186,
5489,
19154,
262,
1493,
14301,
25,
362,
925,
311,
9436,
389,
9408,
4078,
14199,
382,
220,
61411,
512,
262,
26082,
25,
1442,
433,
14865,
311,
5625,
382,
220,
5295,
512,
262,
362,
27127,
477,
72894,
26404,
18641,
449,
16000,
3186,
382,
14711,
6075,
512,
755,
721,
14500,
2401,
3038,
38179,
24065,
3764,
11,
2218,
11,
1493,
14301,
997,
220,
4304,
12281,
82,
1595,
970,
63,
1139,
264,
16000,
430,
649,
387,
5510,
1139,
1595,
47211,
3186,
63438,
220,
18161,
512,
262,
907,
25,
362,
907,
311,
5625,
1139,
27127,
477,
72894,
26404,
627,
262,
2218,
25,
1556,
1665,
6052,
555,
1595,
6534,
24065,
3186,
5489,
19154,
262,
1493,
14301,
25,
362,
925,
311,
9436,
389,
9408,
4078,
14199,
382,
220,
61411,
512,
262,
26082,
25,
1442,
433,
14865,
311,
5625,
382,
220,
5295,
512,
262,
362,
27127,
477,
72894,
26404,
18641,
449,
16000,
3186,
627,
220,
3270,
220,
1456,
512,
262,
16000,
284,
6543,
2325,
16,
24973,
2401,
24065,
8908,
3644,
291,
88388,
3764,
11,
2218,
46855,
340,
220,
3734,
26082,
439,
384,
512,
262,
4933,
26082,
4530,
82,
25,
1034,
82,
1,
1034,
320,
850,
14301,
11,
384,
1192,
220,
422,
721,
285,
72223,
87125,
8,
976,
721,
285,
72223,
8807,
997,
262,
422,
721,
285,
72223,
87125,
997,
415,
4933,
26082,
4530,
82,
25,
2209,
34544,
13,
32121,
29050,
1210,
1034,
1493,
14301,
340,
262,
775,
512,
415,
4933,
26082,
4530,
82,
25,
2209,
29050,
13,
32121,
34544,
1210,
1034,
1493,
14301,
340,
220,
422,
539,
16000,
673,
13911,
1020,
285,
3038,
38179,
6753,
8807,
673,
13911,
34257,
262,
4933,
26082,
4530,
82,
25,
23342,
1034,
81,
374,
53924,
449,
1034,
81,
1,
33648,
504,
320,
850,
14301,
11,
16000,
673,
13911,
1535,
2218,
673,
13911,
12419,
220,
471,
16000,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
ludbb/secp256k1-py | secp256k1/__init__.py | PrivateKey.schnorr_partial_sign | def schnorr_partial_sign(self, msg, privnonce, pubnonce_others,
raw=False, digest=hashlib.sha256):
"""
Produce a partial Schnorr signature, which can be combined using
schnorr_partial_combine to end up with a full signature that is
verifiable using PublicKey.schnorr_verify.
To combine pubnonces, use PublicKey.combine.
Do not pass the pubnonce produced for the respective privnonce;
combine the pubnonces from other signers and pass that instead.
"""
if not HAS_SCHNORR:
raise Exception("secp256k1_schnorr not enabled")
msg32 = _hash32(msg, raw, digest)
sig64 = ffi.new('char [64]')
res = lib.secp256k1_schnorr_partial_sign(
self.ctx, sig64, msg32, self.private_key,
pubnonce_others, privnonce)
if res <= 0:
raise Exception('failed to partially sign ({})'.format(res))
return bytes(ffi.buffer(sig64, 64)) | python | def schnorr_partial_sign(self, msg, privnonce, pubnonce_others,
raw=False, digest=hashlib.sha256):
"""
Produce a partial Schnorr signature, which can be combined using
schnorr_partial_combine to end up with a full signature that is
verifiable using PublicKey.schnorr_verify.
To combine pubnonces, use PublicKey.combine.
Do not pass the pubnonce produced for the respective privnonce;
combine the pubnonces from other signers and pass that instead.
"""
if not HAS_SCHNORR:
raise Exception("secp256k1_schnorr not enabled")
msg32 = _hash32(msg, raw, digest)
sig64 = ffi.new('char [64]')
res = lib.secp256k1_schnorr_partial_sign(
self.ctx, sig64, msg32, self.private_key,
pubnonce_others, privnonce)
if res <= 0:
raise Exception('failed to partially sign ({})'.format(res))
return bytes(ffi.buffer(sig64, 64)) | [
"def",
"schnorr_partial_sign",
"(",
"self",
",",
"msg",
",",
"privnonce",
",",
"pubnonce_others",
",",
"raw",
"=",
"False",
",",
"digest",
"=",
"hashlib",
".",
"sha256",
")",
":",
"if",
"not",
"HAS_SCHNORR",
":",
"raise",
"Exception",
"(",
"\"secp256k1_schnorr not enabled\"",
")",
"msg32",
"=",
"_hash32",
"(",
"msg",
",",
"raw",
",",
"digest",
")",
"sig64",
"=",
"ffi",
".",
"new",
"(",
"'char [64]'",
")",
"res",
"=",
"lib",
".",
"secp256k1_schnorr_partial_sign",
"(",
"self",
".",
"ctx",
",",
"sig64",
",",
"msg32",
",",
"self",
".",
"private_key",
",",
"pubnonce_others",
",",
"privnonce",
")",
"if",
"res",
"<=",
"0",
":",
"raise",
"Exception",
"(",
"'failed to partially sign ({})'",
".",
"format",
"(",
"res",
")",
")",
"return",
"bytes",
"(",
"ffi",
".",
"buffer",
"(",
"sig64",
",",
"64",
")",
")"
] | Produce a partial Schnorr signature, which can be combined using
schnorr_partial_combine to end up with a full signature that is
verifiable using PublicKey.schnorr_verify.
To combine pubnonces, use PublicKey.combine.
Do not pass the pubnonce produced for the respective privnonce;
combine the pubnonces from other signers and pass that instead. | [
"Produce",
"a",
"partial",
"Schnorr",
"signature",
"which",
"can",
"be",
"combined",
"using",
"schnorr_partial_combine",
"to",
"end",
"up",
"with",
"a",
"full",
"signature",
"that",
"is",
"verifiable",
"using",
"PublicKey",
".",
"schnorr_verify",
"."
] | train | https://github.com/ludbb/secp256k1-py/blob/f5e455227bf1e833128adf80de8ee0ebcebf218c/secp256k1/__init__.py#L442-L466 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Produce a partial Schnorr signature, which can be combined using
schnorr_partial_combine to end up with a full signature that is
verifiable using PublicKey.schnorr_verify.
To combine pubnonces, use PublicKey.combine.
Do not pass the pubnonce produced for the respective privnonce;
combine the pubnonces from other signers and pass that instead.
### Response:
def schnorr_partial_sign(self, msg, privnonce, pubnonce_others,
raw=False, digest=hashlib.sha256):
"""
Produce a partial Schnorr signature, which can be combined using
schnorr_partial_combine to end up with a full signature that is
verifiable using PublicKey.schnorr_verify.
To combine pubnonces, use PublicKey.combine.
Do not pass the pubnonce produced for the respective privnonce;
combine the pubnonces from other signers and pass that instead.
"""
if not HAS_SCHNORR:
raise Exception("secp256k1_schnorr not enabled")
msg32 = _hash32(msg, raw, digest)
sig64 = ffi.new('char [64]')
res = lib.secp256k1_schnorr_partial_sign(
self.ctx, sig64, msg32, self.private_key,
pubnonce_others, privnonce)
if res <= 0:
raise Exception('failed to partially sign ({})'.format(res))
return bytes(ffi.buffer(sig64, 64))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1360,
13677,
264,
7276,
61174,
17847,
12223,
11,
902,
649,
387,
11093,
1701,
198,
286,
42230,
17847,
53168,
73474,
311,
842,
709,
449,
264,
2539,
12223,
430,
374,
198,
286,
2807,
23444,
1701,
71380,
516,
2174,
17847,
36738,
382,
286,
2057,
16343,
6814,
6414,
1634,
11,
1005,
71380,
90390,
382,
286,
3234,
539,
1522,
279,
6814,
40693,
9124,
369,
279,
20081,
6223,
40693,
280,
286,
16343,
279,
6814,
6414,
1634,
505,
1023,
1879,
388,
323,
1522,
430,
4619,
382,
14711,
6075,
512,
755,
42230,
17847,
53168,
11420,
1214,
11,
3835,
11,
6223,
40693,
11,
6814,
40693,
14513,
3058,
345,
6663,
7257,
5725,
11,
21552,
28,
8460,
2808,
65470,
4146,
997,
286,
3270,
286,
87988,
264,
7276,
61174,
17847,
12223,
11,
902,
649,
387,
11093,
1701,
198,
286,
42230,
17847,
53168,
73474,
311,
842,
709,
449,
264,
2539,
12223,
430,
374,
198,
286,
2807,
23444,
1701,
71380,
516,
2174,
17847,
36738,
382,
286,
2057,
16343,
6814,
6414,
1634,
11,
1005,
71380,
90390,
382,
286,
3234,
539,
1522,
279,
6814,
40693,
9124,
369,
279,
20081,
6223,
40693,
280,
286,
16343,
279,
6814,
6414,
1634,
505,
1023,
1879,
388,
323,
1522,
430,
4619,
627,
286,
3270,
286,
422,
539,
36848,
1117,
2198,
45,
878,
49,
512,
310,
4933,
4204,
446,
325,
4777,
4146,
74,
16,
646,
2174,
17847,
539,
9147,
5240,
286,
3835,
843,
284,
721,
8460,
843,
8282,
11,
7257,
11,
21552,
340,
286,
8531,
1227,
284,
78056,
4721,
493,
1799,
510,
1227,
60,
4713,
286,
594,
284,
3127,
4624,
4777,
4146,
74,
16,
646,
2174,
17847,
53168,
11420,
1021,
310,
659,
31708,
11,
8531,
1227,
11,
3835,
843,
11,
659,
62703,
3173,
345,
310,
6814,
40693,
14513,
3058,
11,
6223,
40693,
340,
286,
422,
594,
2717,
220,
15,
512,
310,
4933,
4204,
493,
16479,
311,
26310,
1879,
9657,
5525,
4527,
2293,
4693,
4489,
286,
471,
5943,
7,
54899,
25472,
50229,
1227,
11,
220,
1227,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1360,
13677,
264,
7276,
61174,
17847,
12223,
11,
902,
649,
387,
11093,
1701,
198,
286,
42230,
17847,
53168,
73474,
311,
842,
709,
449,
264,
2539,
12223,
430,
374,
198,
286,
2807,
23444,
1701,
71380,
516,
2174,
17847,
36738,
382,
286,
2057,
16343,
6814,
6414,
1634,
11,
1005,
71380,
90390,
382,
286,
3234,
539,
1522,
279,
6814,
40693,
9124,
369,
279,
20081,
6223,
40693,
280,
286,
16343,
279,
6814,
6414,
1634,
505,
1023,
1879,
388,
323,
1522,
430,
4619,
382,
14711,
6075,
512,
755,
42230,
17847,
53168,
11420,
1214,
11,
3835,
11,
6223,
40693,
11,
6814,
40693,
14513,
3058,
345,
6663,
7257,
5725,
11,
21552,
28,
8460,
2808,
65470,
4146,
997,
286,
3270,
286,
87988,
264,
7276,
61174,
17847,
12223,
11,
902,
649,
387,
11093,
1701,
198,
286,
42230,
17847,
53168,
73474,
311,
842,
709,
449,
264,
2539,
12223,
430,
374,
198,
286,
2807,
23444,
1701,
71380,
516,
2174,
17847,
36738,
382,
286,
2057,
16343,
6814,
6414,
1634,
11,
1005,
71380,
90390,
382,
286,
3234,
539,
1522,
279,
6814,
40693,
9124,
369,
279,
20081,
6223,
40693,
280,
286,
16343,
279,
6814,
6414,
1634,
505,
1023,
1879,
388,
323,
1522,
430,
4619,
627,
286,
3270,
286,
422,
539,
36848,
1117,
2198,
45,
878,
49,
512,
310,
4933,
4204,
446,
325,
4777,
4146,
74,
16,
646,
2174,
17847,
539,
9147,
5240,
286,
3835,
843,
284,
721,
8460,
843,
8282,
11,
7257,
11,
21552,
340,
286,
8531,
1227,
284,
78056,
4721,
493,
1799,
510,
1227,
60,
4713,
286,
594,
284,
3127,
4624,
4777,
4146,
74,
16,
646,
2174,
17847,
53168,
11420,
1021,
310,
659,
31708,
11,
8531,
1227,
11,
3835,
843,
11,
659,
62703,
3173,
345,
310,
6814,
40693,
14513,
3058,
11,
6223,
40693,
340,
286,
422,
594,
2717,
220,
15,
512,
310,
4933,
4204,
493,
16479,
311,
26310,
1879,
9657,
5525,
4527,
2293,
4693,
4489,
286,
471,
5943,
7,
54899,
25472,
50229,
1227,
11,
220,
1227,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
crocs-muni/roca | roca/detect.py | RocaFingerprinter.dump | def dump(self, ret):
"""
Dumps the return value
:param ret:
:return:
"""
if self.args.flatten:
ret = drop_none(flatten(ret))
logger.info('Dump: \n' + json.dumps(ret, cls=AutoJSONEncoder, indent=2 if self.args.indent else None)) | python | def dump(self, ret):
"""
Dumps the return value
:param ret:
:return:
"""
if self.args.flatten:
ret = drop_none(flatten(ret))
logger.info('Dump: \n' + json.dumps(ret, cls=AutoJSONEncoder, indent=2 if self.args.indent else None)) | [
"def",
"dump",
"(",
"self",
",",
"ret",
")",
":",
"if",
"self",
".",
"args",
".",
"flatten",
":",
"ret",
"=",
"drop_none",
"(",
"flatten",
"(",
"ret",
")",
")",
"logger",
".",
"info",
"(",
"'Dump: \\n'",
"+",
"json",
".",
"dumps",
"(",
"ret",
",",
"cls",
"=",
"AutoJSONEncoder",
",",
"indent",
"=",
"2",
"if",
"self",
".",
"args",
".",
"indent",
"else",
"None",
")",
")"
] | Dumps the return value
:param ret:
:return: | [
"Dumps",
"the",
"return",
"value",
":",
"param",
"ret",
":",
":",
"return",
":"
] | train | https://github.com/crocs-muni/roca/blob/74ad6ce63c428d83dcffce9c5e26ef7b9e30faa5/roca/detect.py#L2123-L2132 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Dumps the return value
:param ret:
:return:
### Response:
def dump(self, ret):
"""
Dumps the return value
:param ret:
:return:
"""
if self.args.flatten:
ret = drop_none(flatten(ret))
logger.info('Dump: \n' + json.dumps(ret, cls=AutoJSONEncoder, indent=2 if self.args.indent else None))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
35,
12055,
279,
471,
907,
198,
286,
551,
913,
2160,
512,
286,
551,
693,
1473,
14711,
6075,
512,
755,
10488,
1214,
11,
2160,
997,
286,
3270,
286,
423,
12055,
279,
471,
907,
198,
286,
551,
913,
2160,
512,
286,
551,
693,
512,
286,
3270,
286,
422,
659,
16769,
49298,
512,
310,
2160,
284,
6068,
32588,
50847,
14795,
16442,
4489,
286,
6050,
5506,
493,
52156,
25,
1144,
77,
6,
489,
3024,
22252,
16442,
11,
13082,
28,
13556,
5483,
20516,
11,
17962,
28,
17,
422,
659,
16769,
83211,
775,
2290,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
35,
12055,
279,
471,
907,
198,
286,
551,
913,
2160,
512,
286,
551,
693,
1473,
14711,
6075,
512,
755,
10488,
1214,
11,
2160,
997,
286,
3270,
286,
423,
12055,
279,
471,
907,
198,
286,
551,
913,
2160,
512,
286,
551,
693,
512,
286,
3270,
286,
422,
659,
16769,
49298,
512,
310,
2160,
284,
6068,
32588,
50847,
14795,
16442,
4489,
286,
6050,
5506,
493,
52156,
25,
1144,
77,
6,
489,
3024,
22252,
16442,
11,
13082,
28,
13556,
5483,
20516,
11,
17962,
28,
17,
422,
659,
16769,
83211,
775,
2290,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
TangoAlpha/liffylights | liffylights.py | LiffyLights.probe | def probe(self, ipaddr=None):
""" Probe given address for bulb. """
if ipaddr is None:
# no address so use broadcast
ipaddr = self._broadcast_addr
cmd = {"payloadtype": PayloadType.GET,
"target": ipaddr}
self._send_command(cmd) | python | def probe(self, ipaddr=None):
""" Probe given address for bulb. """
if ipaddr is None:
# no address so use broadcast
ipaddr = self._broadcast_addr
cmd = {"payloadtype": PayloadType.GET,
"target": ipaddr}
self._send_command(cmd) | [
"def",
"probe",
"(",
"self",
",",
"ipaddr",
"=",
"None",
")",
":",
"if",
"ipaddr",
"is",
"None",
":",
"# no address so use broadcast",
"ipaddr",
"=",
"self",
".",
"_broadcast_addr",
"cmd",
"=",
"{",
"\"payloadtype\"",
":",
"PayloadType",
".",
"GET",
",",
"\"target\"",
":",
"ipaddr",
"}",
"self",
".",
"_send_command",
"(",
"cmd",
")"
] | Probe given address for bulb. | [
"Probe",
"given",
"address",
"for",
"bulb",
"."
] | train | https://github.com/TangoAlpha/liffylights/blob/7ae9ed947ecf039734014d98b6e18de0f26fa1d3/liffylights.py#L421-L430 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Probe given address for bulb.
### Response:
def probe(self, ipaddr=None):
""" Probe given address for bulb. """
if ipaddr is None:
# no address so use broadcast
ipaddr = self._broadcast_addr
cmd = {"payloadtype": PayloadType.GET,
"target": ipaddr}
self._send_command(cmd)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
82526,
2728,
2686,
369,
46912,
382,
14711,
6075,
512,
755,
22477,
1214,
11,
6125,
6346,
5980,
997,
286,
4304,
78378,
2728,
2686,
369,
46912,
13,
3270,
286,
422,
6125,
6346,
374,
2290,
512,
310,
674,
912,
2686,
779,
1005,
13195,
198,
310,
6125,
6346,
284,
659,
1462,
55262,
7539,
271,
286,
5556,
284,
5324,
19992,
1337,
794,
54016,
941,
17866,
345,
2342,
330,
5775,
794,
6125,
6346,
633,
286,
659,
1462,
6820,
11045,
14493,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
82526,
2728,
2686,
369,
46912,
382,
14711,
6075,
512,
755,
22477,
1214,
11,
6125,
6346,
5980,
997,
286,
4304,
78378,
2728,
2686,
369,
46912,
13,
3270,
286,
422,
6125,
6346,
374,
2290,
512,
310,
674,
912,
2686,
779,
1005,
13195,
198,
310,
6125,
6346,
284,
659,
1462,
55262,
7539,
271,
286,
5556,
284,
5324,
19992,
1337,
794,
54016,
941,
17866,
345,
2342,
330,
5775,
794,
6125,
6346,
633,
286,
659,
1462,
6820,
11045,
14493,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
cbclab/MOT | mot/stats.py | deviance_information_criterions | def deviance_information_criterions(mean_posterior_lls, ll_per_sample):
r"""Calculates the Deviance Information Criteria (DIC) using three methods.
This returns a dictionary returning the ``DIC_2002``, the ``DIC_2004`` and the ``DIC_Ando_2011`` method.
The first is based on Spiegelhalter et al (2002), the second based on Gelman et al. (2004) and the last on
Ando (2011). All cases differ in how they calculate model complexity, i.e. the effective number of parameters
in the model. In all cases the model with the smallest DIC is preferred.
All these DIC methods measure fitness using the deviance, which is, for a likelihood :math:`p(y | \theta)`
defined as:
.. math::
D(\theta) = -2\log p(y|\theta)
From this, the posterior mean deviance,
.. math::
\bar{D} = \mathbb{E}_{\theta}[D(\theta)]
is then used as a measure of how well the model fits the data.
The complexity, or measure of effective number of parameters, can be measured in see ways, see
Spiegelhalter et al. (2002), Gelman et al (2004) and Ando (2011). The first method calculated the parameter
deviance as:
.. math::
:nowrap:
\begin{align}
p_{D} &= \mathbb{E}_{\theta}[D(\theta)] - D(\mathbb{E}[\theta)]) \\
&= \bar{D} - D(\bar{\theta})
\end{align}
i.e. posterior mean deviance minus the deviance evaluated at the posterior mean of the parameters.
The second method calculated :math:`p_{D}` as:
.. math::
p_{D} = p_{V} = \frac{1}{2}\hat{var}(D(\theta))
i.e. half the variance of the deviance is used as an estimate of the number of free parameters in the model.
The third method calculates the parameter deviance as:
.. math::
p_{D} = 2 \cdot (\bar{D} - D(\bar{\theta}))
That is, twice the complexity of that of the first method.
Finally, the DIC is (for all cases) defined as:
.. math::
DIC = \bar{D} + p_{D}
Args:
mean_posterior_lls (ndarray): a 1d matrix containing the log likelihood for the average posterior
point estimate. That is, the single log likelihood of the average parameters.
ll_per_sample (ndarray): a (d, n) array with for d problems the n log likelihoods.
This is the log likelihood per sample.
Returns:
dict: a dictionary containing the ``DIC_2002``, the ``DIC_2004`` and the ``DIC_Ando_2011`` information
criterion maps.
"""
mean_deviance = -2 * np.mean(ll_per_sample, axis=1)
deviance_at_mean = -2 * mean_posterior_lls
pd_2002 = mean_deviance - deviance_at_mean
pd_2004 = np.var(ll_per_sample, axis=1) / 2.0
return {'DIC_2002': np.nan_to_num(mean_deviance + pd_2002),
'DIC_2004': np.nan_to_num(mean_deviance + pd_2004),
'DIC_Ando_2011': np.nan_to_num(mean_deviance + 2 * pd_2002)} | python | def deviance_information_criterions(mean_posterior_lls, ll_per_sample):
r"""Calculates the Deviance Information Criteria (DIC) using three methods.
This returns a dictionary returning the ``DIC_2002``, the ``DIC_2004`` and the ``DIC_Ando_2011`` method.
The first is based on Spiegelhalter et al (2002), the second based on Gelman et al. (2004) and the last on
Ando (2011). All cases differ in how they calculate model complexity, i.e. the effective number of parameters
in the model. In all cases the model with the smallest DIC is preferred.
All these DIC methods measure fitness using the deviance, which is, for a likelihood :math:`p(y | \theta)`
defined as:
.. math::
D(\theta) = -2\log p(y|\theta)
From this, the posterior mean deviance,
.. math::
\bar{D} = \mathbb{E}_{\theta}[D(\theta)]
is then used as a measure of how well the model fits the data.
The complexity, or measure of effective number of parameters, can be measured in see ways, see
Spiegelhalter et al. (2002), Gelman et al (2004) and Ando (2011). The first method calculated the parameter
deviance as:
.. math::
:nowrap:
\begin{align}
p_{D} &= \mathbb{E}_{\theta}[D(\theta)] - D(\mathbb{E}[\theta)]) \\
&= \bar{D} - D(\bar{\theta})
\end{align}
i.e. posterior mean deviance minus the deviance evaluated at the posterior mean of the parameters.
The second method calculated :math:`p_{D}` as:
.. math::
p_{D} = p_{V} = \frac{1}{2}\hat{var}(D(\theta))
i.e. half the variance of the deviance is used as an estimate of the number of free parameters in the model.
The third method calculates the parameter deviance as:
.. math::
p_{D} = 2 \cdot (\bar{D} - D(\bar{\theta}))
That is, twice the complexity of that of the first method.
Finally, the DIC is (for all cases) defined as:
.. math::
DIC = \bar{D} + p_{D}
Args:
mean_posterior_lls (ndarray): a 1d matrix containing the log likelihood for the average posterior
point estimate. That is, the single log likelihood of the average parameters.
ll_per_sample (ndarray): a (d, n) array with for d problems the n log likelihoods.
This is the log likelihood per sample.
Returns:
dict: a dictionary containing the ``DIC_2002``, the ``DIC_2004`` and the ``DIC_Ando_2011`` information
criterion maps.
"""
mean_deviance = -2 * np.mean(ll_per_sample, axis=1)
deviance_at_mean = -2 * mean_posterior_lls
pd_2002 = mean_deviance - deviance_at_mean
pd_2004 = np.var(ll_per_sample, axis=1) / 2.0
return {'DIC_2002': np.nan_to_num(mean_deviance + pd_2002),
'DIC_2004': np.nan_to_num(mean_deviance + pd_2004),
'DIC_Ando_2011': np.nan_to_num(mean_deviance + 2 * pd_2002)} | [
"def",
"deviance_information_criterions",
"(",
"mean_posterior_lls",
",",
"ll_per_sample",
")",
":",
"mean_deviance",
"=",
"-",
"2",
"*",
"np",
".",
"mean",
"(",
"ll_per_sample",
",",
"axis",
"=",
"1",
")",
"deviance_at_mean",
"=",
"-",
"2",
"*",
"mean_posterior_lls",
"pd_2002",
"=",
"mean_deviance",
"-",
"deviance_at_mean",
"pd_2004",
"=",
"np",
".",
"var",
"(",
"ll_per_sample",
",",
"axis",
"=",
"1",
")",
"/",
"2.0",
"return",
"{",
"'DIC_2002'",
":",
"np",
".",
"nan_to_num",
"(",
"mean_deviance",
"+",
"pd_2002",
")",
",",
"'DIC_2004'",
":",
"np",
".",
"nan_to_num",
"(",
"mean_deviance",
"+",
"pd_2004",
")",
",",
"'DIC_Ando_2011'",
":",
"np",
".",
"nan_to_num",
"(",
"mean_deviance",
"+",
"2",
"*",
"pd_2002",
")",
"}"
] | r"""Calculates the Deviance Information Criteria (DIC) using three methods.
This returns a dictionary returning the ``DIC_2002``, the ``DIC_2004`` and the ``DIC_Ando_2011`` method.
The first is based on Spiegelhalter et al (2002), the second based on Gelman et al. (2004) and the last on
Ando (2011). All cases differ in how they calculate model complexity, i.e. the effective number of parameters
in the model. In all cases the model with the smallest DIC is preferred.
All these DIC methods measure fitness using the deviance, which is, for a likelihood :math:`p(y | \theta)`
defined as:
.. math::
D(\theta) = -2\log p(y|\theta)
From this, the posterior mean deviance,
.. math::
\bar{D} = \mathbb{E}_{\theta}[D(\theta)]
is then used as a measure of how well the model fits the data.
The complexity, or measure of effective number of parameters, can be measured in see ways, see
Spiegelhalter et al. (2002), Gelman et al (2004) and Ando (2011). The first method calculated the parameter
deviance as:
.. math::
:nowrap:
\begin{align}
p_{D} &= \mathbb{E}_{\theta}[D(\theta)] - D(\mathbb{E}[\theta)]) \\
&= \bar{D} - D(\bar{\theta})
\end{align}
i.e. posterior mean deviance minus the deviance evaluated at the posterior mean of the parameters.
The second method calculated :math:`p_{D}` as:
.. math::
p_{D} = p_{V} = \frac{1}{2}\hat{var}(D(\theta))
i.e. half the variance of the deviance is used as an estimate of the number of free parameters in the model.
The third method calculates the parameter deviance as:
.. math::
p_{D} = 2 \cdot (\bar{D} - D(\bar{\theta}))
That is, twice the complexity of that of the first method.
Finally, the DIC is (for all cases) defined as:
.. math::
DIC = \bar{D} + p_{D}
Args:
mean_posterior_lls (ndarray): a 1d matrix containing the log likelihood for the average posterior
point estimate. That is, the single log likelihood of the average parameters.
ll_per_sample (ndarray): a (d, n) array with for d problems the n log likelihoods.
This is the log likelihood per sample.
Returns:
dict: a dictionary containing the ``DIC_2002``, the ``DIC_2004`` and the ``DIC_Ando_2011`` information
criterion maps. | [
"r",
"Calculates",
"the",
"Deviance",
"Information",
"Criteria",
"(",
"DIC",
")",
"using",
"three",
"methods",
"."
] | train | https://github.com/cbclab/MOT/blob/fb3243b65025705842e82704705c00902f9a35af/mot/stats.py#L162-L239 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
r"""Calculates the Deviance Information Criteria (DIC) using three methods.
This returns a dictionary returning the ``DIC_2002``, the ``DIC_2004`` and the ``DIC_Ando_2011`` method.
The first is based on Spiegelhalter et al (2002), the second based on Gelman et al. (2004) and the last on
Ando (2011). All cases differ in how they calculate model complexity, i.e. the effective number of parameters
in the model. In all cases the model with the smallest DIC is preferred.
All these DIC methods measure fitness using the deviance, which is, for a likelihood :math:`p(y | \theta)`
defined as:
.. math::
D(\theta) = -2\log p(y|\theta)
From this, the posterior mean deviance,
.. math::
\bar{D} = \mathbb{E}_{\theta}[D(\theta)]
is then used as a measure of how well the model fits the data.
The complexity, or measure of effective number of parameters, can be measured in see ways, see
Spiegelhalter et al. (2002), Gelman et al (2004) and Ando (2011). The first method calculated the parameter
deviance as:
.. math::
:nowrap:
\begin{align}
p_{D} &= \mathbb{E}_{\theta}[D(\theta)] - D(\mathbb{E}[\theta)]) \\
&= \bar{D} - D(\bar{\theta})
\end{align}
i.e. posterior mean deviance minus the deviance evaluated at the posterior mean of the parameters.
The second method calculated :math:`p_{D}` as:
.. math::
p_{D} = p_{V} = \frac{1}{2}\hat{var}(D(\theta))
i.e. half the variance of the deviance is used as an estimate of the number of free parameters in the model.
The third method calculates the parameter deviance as:
.. math::
p_{D} = 2 \cdot (\bar{D} - D(\bar{\theta}))
That is, twice the complexity of that of the first method.
Finally, the DIC is (for all cases) defined as:
.. math::
DIC = \bar{D} + p_{D}
Args:
mean_posterior_lls (ndarray): a 1d matrix containing the log likelihood for the average posterior
point estimate. That is, the single log likelihood of the average parameters.
ll_per_sample (ndarray): a (d, n) array with for d problems the n log likelihoods.
This is the log likelihood per sample.
Returns:
dict: a dictionary containing the ``DIC_2002``, the ``DIC_2004`` and the ``DIC_Ando_2011`` information
criterion maps.
### Response:
def deviance_information_criterions(mean_posterior_lls, ll_per_sample):
r"""Calculates the Deviance Information Criteria (DIC) using three methods.
This returns a dictionary returning the ``DIC_2002``, the ``DIC_2004`` and the ``DIC_Ando_2011`` method.
The first is based on Spiegelhalter et al (2002), the second based on Gelman et al. (2004) and the last on
Ando (2011). All cases differ in how they calculate model complexity, i.e. the effective number of parameters
in the model. In all cases the model with the smallest DIC is preferred.
All these DIC methods measure fitness using the deviance, which is, for a likelihood :math:`p(y | \theta)`
defined as:
.. math::
D(\theta) = -2\log p(y|\theta)
From this, the posterior mean deviance,
.. math::
\bar{D} = \mathbb{E}_{\theta}[D(\theta)]
is then used as a measure of how well the model fits the data.
The complexity, or measure of effective number of parameters, can be measured in see ways, see
Spiegelhalter et al. (2002), Gelman et al (2004) and Ando (2011). The first method calculated the parameter
deviance as:
.. math::
:nowrap:
\begin{align}
p_{D} &= \mathbb{E}_{\theta}[D(\theta)] - D(\mathbb{E}[\theta)]) \\
&= \bar{D} - D(\bar{\theta})
\end{align}
i.e. posterior mean deviance minus the deviance evaluated at the posterior mean of the parameters.
The second method calculated :math:`p_{D}` as:
.. math::
p_{D} = p_{V} = \frac{1}{2}\hat{var}(D(\theta))
i.e. half the variance of the deviance is used as an estimate of the number of free parameters in the model.
The third method calculates the parameter deviance as:
.. math::
p_{D} = 2 \cdot (\bar{D} - D(\bar{\theta}))
That is, twice the complexity of that of the first method.
Finally, the DIC is (for all cases) defined as:
.. math::
DIC = \bar{D} + p_{D}
Args:
mean_posterior_lls (ndarray): a 1d matrix containing the log likelihood for the average posterior
point estimate. That is, the single log likelihood of the average parameters.
ll_per_sample (ndarray): a (d, n) array with for d problems the n log likelihoods.
This is the log likelihood per sample.
Returns:
dict: a dictionary containing the ``DIC_2002``, the ``DIC_2004`` and the ``DIC_Ando_2011`` information
criterion maps.
"""
mean_deviance = -2 * np.mean(ll_per_sample, axis=1)
deviance_at_mean = -2 * mean_posterior_lls
pd_2002 = mean_deviance - deviance_at_mean
pd_2004 = np.var(ll_per_sample, axis=1) / 2.0
return {'DIC_2002': np.nan_to_num(mean_deviance + pd_2002),
'DIC_2004': np.nan_to_num(mean_deviance + pd_2004),
'DIC_Ando_2011': np.nan_to_num(mean_deviance + 2 * pd_2002)}
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
81,
12885,
59008,
988,
279,
6168,
5397,
8245,
14577,
320,
94261,
8,
1701,
2380,
5528,
382,
262,
1115,
4780,
264,
11240,
13758,
279,
10103,
94261,
62,
1049,
17,
91816,
279,
10103,
94261,
62,
1049,
19,
14196,
323,
279,
10103,
94261,
1596,
90314,
62,
679,
16,
14196,
1749,
627,
262,
578,
1176,
374,
3196,
389,
3165,
76047,
12130,
466,
1880,
453,
320,
1049,
17,
705,
279,
2132,
3196,
389,
45482,
1543,
1880,
453,
13,
320,
1049,
19,
8,
323,
279,
1566,
389,
198,
262,
1628,
78,
320,
679,
16,
570,
2052,
5157,
1782,
304,
1268,
814,
11294,
1646,
23965,
11,
602,
1770,
13,
279,
7524,
1396,
315,
5137,
198,
262,
304,
279,
1646,
13,
763,
682,
5157,
279,
1646,
449,
279,
25655,
98860,
374,
15236,
382,
262,
2052,
1521,
98860,
5528,
6767,
17479,
1701,
279,
3567,
5397,
11,
902,
374,
11,
369,
264,
29736,
551,
10590,
19258,
79,
7166,
765,
1144,
16356,
50337,
262,
4613,
439,
1473,
262,
5354,
7033,
66152,
286,
423,
11781,
16356,
8,
284,
482,
17,
59,
848,
281,
7166,
23813,
16356,
696,
262,
5659,
420,
11,
279,
46000,
3152,
3567,
5397,
3638,
262,
5354,
7033,
66152,
286,
1144,
2308,
90,
35,
92,
284,
1144,
10590,
6194,
90,
36,
52635,
59,
16356,
44489,
35,
11781,
16356,
28871,
262,
374,
1243,
1511,
439,
264,
6767,
315,
1268,
1664,
279,
1646,
18809,
279,
828,
382,
262,
578,
23965,
11,
477,
6767,
315,
7524,
1396,
315,
5137,
11,
649,
387,
17303,
304,
1518,
5627,
11,
1518,
198,
262,
3165,
76047,
12130,
466,
1880,
453,
13,
320,
1049,
17,
705,
45482,
1543,
1880,
453,
320,
1049,
19,
8,
323,
1628,
78,
320,
679,
16,
570,
578,
1176,
1749,
16997,
279,
5852,
198,
262,
3567,
5397,
439,
1473,
262,
5354,
7033,
50677,
286,
551,
56523,
1473,
286,
1144,
7413,
90,
6750,
534,
286,
281,
15511,
35,
92,
14923,
1144,
10590,
6194,
90,
36,
52635,
59,
16356,
44489,
35,
11781,
16356,
7400,
482,
423,
11781,
10590,
6194,
90,
36,
92,
27148,
16356,
47705,
91255,
1078,
14923,
1144,
2308,
90,
35,
92,
482,
423,
11781,
2308,
36802,
16356,
3602,
286,
1144,
408,
90,
6750,
633,
262,
602,
1770,
13,
46000,
3152,
3567,
5397,
28382,
279,
3567,
5397,
26126,
520,
279,
46000,
3152,
315,
279,
5137,
382,
262,
578,
2132,
1749,
16997,
551,
10590,
19258,
79,
15511,
35,
5658,
439,
1473,
262,
5354,
7033,
66152,
286,
281,
15511,
35,
92,
284,
281,
15511,
53,
92,
284,
1144,
38118,
90,
16,
15523,
17,
11281,
9379,
90,
959,
26628,
35,
11781,
16356,
4489,
262,
602,
1770,
13,
4376,
279,
33373,
315,
279,
3567,
5397,
374,
1511,
439,
459,
16430,
315,
279,
1396,
315,
1949,
5137,
304,
279,
1646,
382,
262,
578,
4948,
1749,
48517,
279,
5852,
3567,
5397,
439,
1473,
262,
5354,
7033,
66152,
286,
281,
15511,
35,
92,
284,
220,
17,
1144,
51953,
20374,
2308,
90,
35,
92,
482,
423
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
81,
12885,
59008,
988,
279,
6168,
5397,
8245,
14577,
320,
94261,
8,
1701,
2380,
5528,
382,
262,
1115,
4780,
264,
11240,
13758,
279,
10103,
94261,
62,
1049,
17,
91816,
279,
10103,
94261,
62,
1049,
19,
14196,
323,
279,
10103,
94261,
1596,
90314,
62,
679,
16,
14196,
1749,
627,
262,
578,
1176,
374,
3196,
389,
3165,
76047,
12130,
466,
1880,
453,
320,
1049,
17,
705,
279,
2132,
3196,
389,
45482,
1543,
1880,
453,
13,
320,
1049,
19,
8,
323,
279,
1566,
389,
198,
262,
1628,
78,
320,
679,
16,
570,
2052,
5157,
1782,
304,
1268,
814,
11294,
1646,
23965,
11,
602,
1770,
13,
279,
7524,
1396,
315,
5137,
198,
262,
304,
279,
1646,
13,
763,
682,
5157,
279,
1646,
449,
279,
25655,
98860,
374,
15236,
382,
262,
2052,
1521,
98860,
5528,
6767,
17479,
1701,
279,
3567,
5397,
11,
902,
374,
11,
369,
264,
29736,
551,
10590,
19258,
79,
7166,
765,
1144,
16356,
50337,
262,
4613,
439,
1473,
262,
5354,
7033,
66152,
286,
423,
11781,
16356,
8,
284,
482,
17,
59,
848,
281,
7166,
23813,
16356,
696,
262,
5659,
420,
11,
279,
46000,
3152,
3567,
5397,
3638,
262,
5354,
7033,
66152,
286,
1144,
2308,
90,
35,
92,
284,
1144,
10590,
6194,
90,
36,
52635,
59,
16356,
44489,
35,
11781,
16356,
28871,
262,
374,
1243,
1511,
439,
264,
6767,
315,
1268,
1664,
279,
1646,
18809,
279,
828,
382,
262,
578,
23965,
11,
477,
6767,
315,
7524,
1396,
315,
5137,
11,
649,
387,
17303,
304,
1518,
5627,
11,
1518,
198,
262,
3165,
76047,
12130,
466,
1880,
453,
13,
320,
1049,
17,
705,
45482,
1543,
1880,
453,
320,
1049,
19,
8,
323,
1628,
78,
320,
679,
16,
570,
578,
1176,
1749,
16997,
279,
5852,
198,
262,
3567,
5397,
439,
1473,
262,
5354,
7033,
50677,
286,
551,
56523,
1473,
286,
1144,
7413,
90,
6750,
534,
286,
281,
15511,
35,
92,
14923,
1144,
10590,
6194,
90,
36,
52635,
59,
16356,
44489,
35,
11781,
16356,
7400,
482,
423,
11781,
10590,
6194,
90,
36,
92,
27148,
16356,
47705,
91255,
1078,
14923,
1144,
2308,
90,
35,
92,
482,
423,
11781,
2308,
36802,
16356,
3602,
286,
1144,
408,
90,
6750,
633,
262,
602,
1770,
13,
46000,
3152,
3567,
5397,
28382,
279,
3567,
5397,
26126,
520,
279,
46000,
3152,
315,
279,
5137,
382,
262,
578,
2132,
1749,
16997,
551,
10590,
19258,
79,
15511,
35,
5658,
439,
1473,
262,
5354,
7033,
66152,
286,
281,
15511,
35,
92,
284,
281,
15511,
53,
92,
284,
1144,
38118,
90,
16,
15523,
17,
11281,
9379,
90,
959,
26628,
35,
11781,
16356,
4489,
262,
602,
1770,
13,
4376,
279,
33373,
315,
279,
3567,
5397,
374,
1511,
439,
459,
16430,
315,
279,
1396,
315,
1949,
5137,
304,
279,
1646,
382,
262,
578,
4948,
1749,
48517,
279,
5852,
3567,
5397,
439,
1473,
262,
5354,
7033,
66152,
286,
281,
15511,
35,
92,
284,
220,
17,
1144,
51953,
20374,
2308,
90,
35,
92,
482,
423
] |
genomoncology/related | src/related/fields.py | RegexField | def RegexField(regex, default=NOTHING, required=True, repr=True, cmp=True,
key=None):
"""
Create new str field on a model.
:param regex: regex validation string (e.g. "[^@]+@[^@]+" for email)
:param default: any string value
:param bool required: whether or not the object is invalid if not provided.
:param bool repr: include this field should appear in object's repr.
:param bool cmp: include this field in generated comparison.
:param string key: override name of the value when converted to dict.
"""
default = _init_fields.init_default(required, default, None)
validator = _init_fields.init_validator(required, string_types,
validators.regex(regex))
return attrib(default=default, converter=converters.str_if_not_none,
validator=validator, repr=repr, cmp=cmp,
metadata=dict(key=key)) | python | def RegexField(regex, default=NOTHING, required=True, repr=True, cmp=True,
key=None):
"""
Create new str field on a model.
:param regex: regex validation string (e.g. "[^@]+@[^@]+" for email)
:param default: any string value
:param bool required: whether or not the object is invalid if not provided.
:param bool repr: include this field should appear in object's repr.
:param bool cmp: include this field in generated comparison.
:param string key: override name of the value when converted to dict.
"""
default = _init_fields.init_default(required, default, None)
validator = _init_fields.init_validator(required, string_types,
validators.regex(regex))
return attrib(default=default, converter=converters.str_if_not_none,
validator=validator, repr=repr, cmp=cmp,
metadata=dict(key=key)) | [
"def",
"RegexField",
"(",
"regex",
",",
"default",
"=",
"NOTHING",
",",
"required",
"=",
"True",
",",
"repr",
"=",
"True",
",",
"cmp",
"=",
"True",
",",
"key",
"=",
"None",
")",
":",
"default",
"=",
"_init_fields",
".",
"init_default",
"(",
"required",
",",
"default",
",",
"None",
")",
"validator",
"=",
"_init_fields",
".",
"init_validator",
"(",
"required",
",",
"string_types",
",",
"validators",
".",
"regex",
"(",
"regex",
")",
")",
"return",
"attrib",
"(",
"default",
"=",
"default",
",",
"converter",
"=",
"converters",
".",
"str_if_not_none",
",",
"validator",
"=",
"validator",
",",
"repr",
"=",
"repr",
",",
"cmp",
"=",
"cmp",
",",
"metadata",
"=",
"dict",
"(",
"key",
"=",
"key",
")",
")"
] | Create new str field on a model.
:param regex: regex validation string (e.g. "[^@]+@[^@]+" for email)
:param default: any string value
:param bool required: whether or not the object is invalid if not provided.
:param bool repr: include this field should appear in object's repr.
:param bool cmp: include this field in generated comparison.
:param string key: override name of the value when converted to dict. | [
"Create",
"new",
"str",
"field",
"on",
"a",
"model",
"."
] | train | https://github.com/genomoncology/related/blob/be47c0081e60fc60afcde3a25f00ebcad5d18510/src/related/fields.py#L167-L184 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Create new str field on a model.
:param regex: regex validation string (e.g. "[^@]+@[^@]+" for email)
:param default: any string value
:param bool required: whether or not the object is invalid if not provided.
:param bool repr: include this field should appear in object's repr.
:param bool cmp: include this field in generated comparison.
:param string key: override name of the value when converted to dict.
### Response:
def RegexField(regex, default=NOTHING, required=True, repr=True, cmp=True,
key=None):
"""
Create new str field on a model.
:param regex: regex validation string (e.g. "[^@]+@[^@]+" for email)
:param default: any string value
:param bool required: whether or not the object is invalid if not provided.
:param bool repr: include this field should appear in object's repr.
:param bool cmp: include this field in generated comparison.
:param string key: override name of the value when converted to dict.
"""
default = _init_fields.init_default(required, default, None)
validator = _init_fields.init_validator(required, string_types,
validators.regex(regex))
return attrib(default=default, converter=converters.str_if_not_none,
validator=validator, repr=repr, cmp=cmp,
metadata=dict(key=key))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4110,
502,
610,
2115,
389,
264,
1646,
382,
262,
551,
913,
20791,
25,
20791,
10741,
925,
320,
68,
1326,
13,
10768,
61,
31,
7727,
31,
39913,
31,
53964,
369,
2613,
340,
262,
551,
913,
1670,
25,
904,
925,
907,
198,
262,
551,
913,
1845,
2631,
25,
3508,
477,
539,
279,
1665,
374,
8482,
422,
539,
3984,
627,
262,
551,
913,
1845,
31736,
25,
2997,
420,
2115,
1288,
5101,
304,
1665,
596,
31736,
627,
262,
551,
913,
1845,
27181,
25,
2997,
420,
2115,
304,
8066,
12593,
627,
262,
551,
913,
925,
1401,
25,
2882,
836,
315,
279,
907,
994,
16489,
311,
6587,
382,
14711,
6075,
512,
755,
27238,
1915,
62657,
11,
1670,
28,
14394,
55727,
11,
2631,
3702,
11,
31736,
3702,
11,
27181,
3702,
345,
2342,
1401,
5980,
997,
262,
3270,
262,
4324,
502,
610,
2115,
389,
264,
1646,
382,
262,
551,
913,
20791,
25,
20791,
10741,
925,
320,
68,
1326,
13,
10768,
61,
31,
7727,
31,
39913,
31,
53964,
369,
2613,
340,
262,
551,
913,
1670,
25,
904,
925,
907,
198,
262,
551,
913,
1845,
2631,
25,
3508,
477,
539,
279,
1665,
374,
8482,
422,
539,
3984,
627,
262,
551,
913,
1845,
31736,
25,
2997,
420,
2115,
1288,
5101,
304,
1665,
596,
31736,
627,
262,
551,
913,
1845,
27181,
25,
2997,
420,
2115,
304,
8066,
12593,
627,
262,
551,
913,
925,
1401,
25,
2882,
836,
315,
279,
907,
994,
16489,
311,
6587,
627,
262,
3270,
262,
1670,
284,
721,
2381,
12406,
8435,
10198,
41187,
11,
1670,
11,
2290,
340,
262,
23787,
284,
721,
2381,
12406,
8435,
66059,
41187,
11,
925,
9962,
345,
3425,
39688,
44218,
62657,
1192,
262,
471,
17780,
19515,
93728,
11,
28157,
28,
14500,
388,
9720,
11366,
8072,
32588,
345,
1733,
23787,
28,
16503,
11,
31736,
28,
31937,
11,
27181,
28,
7441,
345,
1733,
11408,
40697,
4962,
87682,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4110,
502,
610,
2115,
389,
264,
1646,
382,
262,
551,
913,
20791,
25,
20791,
10741,
925,
320,
68,
1326,
13,
10768,
61,
31,
7727,
31,
39913,
31,
53964,
369,
2613,
340,
262,
551,
913,
1670,
25,
904,
925,
907,
198,
262,
551,
913,
1845,
2631,
25,
3508,
477,
539,
279,
1665,
374,
8482,
422,
539,
3984,
627,
262,
551,
913,
1845,
31736,
25,
2997,
420,
2115,
1288,
5101,
304,
1665,
596,
31736,
627,
262,
551,
913,
1845,
27181,
25,
2997,
420,
2115,
304,
8066,
12593,
627,
262,
551,
913,
925,
1401,
25,
2882,
836,
315,
279,
907,
994,
16489,
311,
6587,
382,
14711,
6075,
512,
755,
27238,
1915,
62657,
11,
1670,
28,
14394,
55727,
11,
2631,
3702,
11,
31736,
3702,
11,
27181,
3702,
345,
2342,
1401,
5980,
997,
262,
3270,
262,
4324,
502,
610,
2115,
389,
264,
1646,
382,
262,
551,
913,
20791,
25,
20791,
10741,
925,
320,
68,
1326,
13,
10768,
61,
31,
7727,
31,
39913,
31,
53964,
369,
2613,
340,
262,
551,
913,
1670,
25,
904,
925,
907,
198,
262,
551,
913,
1845,
2631,
25,
3508,
477,
539,
279,
1665,
374,
8482,
422,
539,
3984,
627,
262,
551,
913,
1845,
31736,
25,
2997,
420,
2115,
1288,
5101,
304,
1665,
596,
31736,
627,
262,
551,
913,
1845,
27181,
25,
2997,
420,
2115,
304,
8066,
12593,
627,
262,
551,
913,
925,
1401,
25,
2882,
836,
315,
279,
907,
994,
16489,
311,
6587,
627,
262,
3270,
262,
1670,
284,
721,
2381,
12406,
8435,
10198,
41187,
11,
1670,
11,
2290,
340,
262,
23787,
284,
721,
2381,
12406,
8435,
66059,
41187,
11,
925,
9962,
345,
3425,
39688,
44218,
62657,
1192,
262,
471,
17780,
19515,
93728,
11,
28157,
28,
14500,
388,
9720,
11366,
8072,
32588,
345,
1733,
23787,
28,
16503,
11,
31736,
28,
31937,
11,
27181,
28,
7441,
345,
1733,
11408,
40697,
4962,
87682,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Microsoft/azure-devops-python-api | azure-devops/azure/devops/v5_0/member_entitlement_management/member_entitlement_management_client.py | MemberEntitlementManagementClient.update_user_entitlement | def update_user_entitlement(self, document, user_id):
"""UpdateUserEntitlement.
[Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for a user.
:param :class:`<[JsonPatchOperation]> <azure.devops.v5_0.member_entitlement_management.models.[JsonPatchOperation]>` document: JsonPatchDocument containing the operations to perform on the user.
:param str user_id: ID of the user.
:rtype: :class:`<UserEntitlementsPatchResponse> <azure.devops.v5_0.member_entitlement_management.models.UserEntitlementsPatchResponse>`
"""
route_values = {}
if user_id is not None:
route_values['userId'] = self._serialize.url('user_id', user_id, 'str')
content = self._serialize.body(document, '[JsonPatchOperation]')
response = self._send(http_method='PATCH',
location_id='8480c6eb-ce60-47e9-88df-eca3c801638b',
version='5.0-preview.2',
route_values=route_values,
content=content,
media_type='application/json-patch+json')
return self._deserialize('UserEntitlementsPatchResponse', response) | python | def update_user_entitlement(self, document, user_id):
"""UpdateUserEntitlement.
[Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for a user.
:param :class:`<[JsonPatchOperation]> <azure.devops.v5_0.member_entitlement_management.models.[JsonPatchOperation]>` document: JsonPatchDocument containing the operations to perform on the user.
:param str user_id: ID of the user.
:rtype: :class:`<UserEntitlementsPatchResponse> <azure.devops.v5_0.member_entitlement_management.models.UserEntitlementsPatchResponse>`
"""
route_values = {}
if user_id is not None:
route_values['userId'] = self._serialize.url('user_id', user_id, 'str')
content = self._serialize.body(document, '[JsonPatchOperation]')
response = self._send(http_method='PATCH',
location_id='8480c6eb-ce60-47e9-88df-eca3c801638b',
version='5.0-preview.2',
route_values=route_values,
content=content,
media_type='application/json-patch+json')
return self._deserialize('UserEntitlementsPatchResponse', response) | [
"def",
"update_user_entitlement",
"(",
"self",
",",
"document",
",",
"user_id",
")",
":",
"route_values",
"=",
"{",
"}",
"if",
"user_id",
"is",
"not",
"None",
":",
"route_values",
"[",
"'userId'",
"]",
"=",
"self",
".",
"_serialize",
".",
"url",
"(",
"'user_id'",
",",
"user_id",
",",
"'str'",
")",
"content",
"=",
"self",
".",
"_serialize",
".",
"body",
"(",
"document",
",",
"'[JsonPatchOperation]'",
")",
"response",
"=",
"self",
".",
"_send",
"(",
"http_method",
"=",
"'PATCH'",
",",
"location_id",
"=",
"'8480c6eb-ce60-47e9-88df-eca3c801638b'",
",",
"version",
"=",
"'5.0-preview.2'",
",",
"route_values",
"=",
"route_values",
",",
"content",
"=",
"content",
",",
"media_type",
"=",
"'application/json-patch+json'",
")",
"return",
"self",
".",
"_deserialize",
"(",
"'UserEntitlementsPatchResponse'",
",",
"response",
")"
] | UpdateUserEntitlement.
[Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for a user.
:param :class:`<[JsonPatchOperation]> <azure.devops.v5_0.member_entitlement_management.models.[JsonPatchOperation]>` document: JsonPatchDocument containing the operations to perform on the user.
:param str user_id: ID of the user.
:rtype: :class:`<UserEntitlementsPatchResponse> <azure.devops.v5_0.member_entitlement_management.models.UserEntitlementsPatchResponse>` | [
"UpdateUserEntitlement",
".",
"[",
"Preview",
"API",
"]",
"Edit",
"the",
"entitlements",
"(",
"License",
"Extensions",
"Projects",
"Teams",
"etc",
")",
"for",
"a",
"user",
".",
":",
"param",
":",
"class",
":",
"<",
"[",
"JsonPatchOperation",
"]",
">",
"<azure",
".",
"devops",
".",
"v5_0",
".",
"member_entitlement_management",
".",
"models",
".",
"[",
"JsonPatchOperation",
"]",
">",
"document",
":",
"JsonPatchDocument",
"containing",
"the",
"operations",
"to",
"perform",
"on",
"the",
"user",
".",
":",
"param",
"str",
"user_id",
":",
"ID",
"of",
"the",
"user",
".",
":",
"rtype",
":",
":",
"class",
":",
"<UserEntitlementsPatchResponse",
">",
"<azure",
".",
"devops",
".",
"v5_0",
".",
"member_entitlement_management",
".",
"models",
".",
"UserEntitlementsPatchResponse",
">"
] | train | https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/member_entitlement_management/member_entitlement_management_client.py#L257-L274 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
UpdateUserEntitlement.
[Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for a user.
:param :class:`<[JsonPatchOperation]> <azure.devops.v5_0.member_entitlement_management.models.[JsonPatchOperation]>` document: JsonPatchDocument containing the operations to perform on the user.
:param str user_id: ID of the user.
:rtype: :class:`<UserEntitlementsPatchResponse> <azure.devops.v5_0.member_entitlement_management.models.UserEntitlementsPatchResponse>`
### Response:
def update_user_entitlement(self, document, user_id):
"""UpdateUserEntitlement.
[Preview API] Edit the entitlements (License, Extensions, Projects, Teams etc) for a user.
:param :class:`<[JsonPatchOperation]> <azure.devops.v5_0.member_entitlement_management.models.[JsonPatchOperation]>` document: JsonPatchDocument containing the operations to perform on the user.
:param str user_id: ID of the user.
:rtype: :class:`<UserEntitlementsPatchResponse> <azure.devops.v5_0.member_entitlement_management.models.UserEntitlementsPatchResponse>`
"""
route_values = {}
if user_id is not None:
route_values['userId'] = self._serialize.url('user_id', user_id, 'str')
content = self._serialize.body(document, '[JsonPatchOperation]')
response = self._send(http_method='PATCH',
location_id='8480c6eb-ce60-47e9-88df-eca3c801638b',
version='5.0-preview.2',
route_values=route_values,
content=content,
media_type='application/json-patch+json')
return self._deserialize('UserEntitlementsPatchResponse', response)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4387,
1502,
2300,
46437,
627,
286,
510,
25648,
5446,
60,
8505,
279,
55001,
82,
320,
10028,
11,
56895,
11,
32323,
11,
40713,
5099,
8,
369,
264,
1217,
627,
286,
551,
913,
551,
1058,
19258,
67846,
5122,
44722,
8598,
26753,
366,
40595,
22247,
3806,
3211,
20,
62,
15,
33446,
28525,
46437,
46463,
8399,
8032,
5122,
44722,
8598,
26753,
63,
2246,
25,
8472,
44722,
7676,
8649,
279,
7677,
311,
2804,
389,
279,
1217,
627,
286,
551,
913,
610,
1217,
851,
25,
3110,
315,
279,
1217,
627,
286,
551,
33613,
25,
551,
1058,
19258,
27,
1502,
2300,
46437,
82,
44722,
2647,
29,
366,
40595,
22247,
3806,
3211,
20,
62,
15,
33446,
28525,
46437,
46463,
8399,
7494,
2300,
46437,
82,
44722,
2647,
29,
19884,
14711,
6075,
512,
755,
2713,
3398,
28525,
46437,
1214,
11,
2246,
11,
1217,
851,
997,
286,
4304,
4387,
1502,
2300,
46437,
627,
286,
510,
25648,
5446,
60,
8505,
279,
55001,
82,
320,
10028,
11,
56895,
11,
32323,
11,
40713,
5099,
8,
369,
264,
1217,
627,
286,
551,
913,
551,
1058,
19258,
67846,
5122,
44722,
8598,
26753,
366,
40595,
22247,
3806,
3211,
20,
62,
15,
33446,
28525,
46437,
46463,
8399,
8032,
5122,
44722,
8598,
26753,
63,
2246,
25,
8472,
44722,
7676,
8649,
279,
7677,
311,
2804,
389,
279,
1217,
627,
286,
551,
913,
610,
1217,
851,
25,
3110,
315,
279,
1217,
627,
286,
551,
33613,
25,
551,
1058,
19258,
27,
1502,
2300,
46437,
82,
44722,
2647,
29,
366,
40595,
22247,
3806,
3211,
20,
62,
15,
33446,
28525,
46437,
46463,
8399,
7494,
2300,
46437,
82,
44722,
2647,
54822,
286,
3270,
286,
6149,
9324,
284,
5731,
286,
422,
1217,
851,
374,
539,
2290,
512,
310,
6149,
9324,
681,
13816,
663,
284,
659,
1462,
25140,
7464,
493,
882,
851,
518,
1217,
851,
11,
364,
496,
1329,
286,
2262,
284,
659,
1462,
25140,
5189,
15649,
11,
18814,
5122,
44722,
8598,
59510,
286,
2077,
284,
659,
1462,
6820,
20480,
9209,
1151,
32265,
756,
4700,
3813,
851,
1151,
24951,
15,
66,
21,
3141,
54312,
1399,
12,
2618,
68,
24,
12,
2421,
3013,
12,
23637,
18,
66,
17973,
24495,
65,
756,
4700,
2373,
1151,
20,
13,
15,
51981,
13,
17,
756,
4700,
6149,
9324,
28,
9143,
9324,
345,
4700,
2262,
28,
1834,
345,
4700,
3772,
1857,
1151,
5242,
9108,
2320,
759,
10,
2285,
1329,
286,
471,
659,
1462,
67877,
493,
1502,
2300,
46437,
82,
44722,
2647,
518,
2077,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4387,
1502,
2300,
46437,
627,
286,
510,
25648,
5446,
60,
8505,
279,
55001,
82,
320,
10028,
11,
56895,
11,
32323,
11,
40713,
5099,
8,
369,
264,
1217,
627,
286,
551,
913,
551,
1058,
19258,
67846,
5122,
44722,
8598,
26753,
366,
40595,
22247,
3806,
3211,
20,
62,
15,
33446,
28525,
46437,
46463,
8399,
8032,
5122,
44722,
8598,
26753,
63,
2246,
25,
8472,
44722,
7676,
8649,
279,
7677,
311,
2804,
389,
279,
1217,
627,
286,
551,
913,
610,
1217,
851,
25,
3110,
315,
279,
1217,
627,
286,
551,
33613,
25,
551,
1058,
19258,
27,
1502,
2300,
46437,
82,
44722,
2647,
29,
366,
40595,
22247,
3806,
3211,
20,
62,
15,
33446,
28525,
46437,
46463,
8399,
7494,
2300,
46437,
82,
44722,
2647,
29,
19884,
14711,
6075,
512,
755,
2713,
3398,
28525,
46437,
1214,
11,
2246,
11,
1217,
851,
997,
286,
4304,
4387,
1502,
2300,
46437,
627,
286,
510,
25648,
5446,
60,
8505,
279,
55001,
82,
320,
10028,
11,
56895,
11,
32323,
11,
40713,
5099,
8,
369,
264,
1217,
627,
286,
551,
913,
551,
1058,
19258,
67846,
5122,
44722,
8598,
26753,
366,
40595,
22247,
3806,
3211,
20,
62,
15,
33446,
28525,
46437,
46463,
8399,
8032,
5122,
44722,
8598,
26753,
63,
2246,
25,
8472,
44722,
7676,
8649,
279,
7677,
311,
2804,
389,
279,
1217,
627,
286,
551,
913,
610,
1217,
851,
25,
3110,
315,
279,
1217,
627,
286,
551,
33613,
25,
551,
1058,
19258,
27,
1502,
2300,
46437,
82,
44722,
2647,
29,
366,
40595,
22247,
3806,
3211,
20,
62,
15,
33446,
28525,
46437,
46463,
8399,
7494,
2300,
46437,
82,
44722,
2647,
54822,
286,
3270,
286,
6149,
9324,
284,
5731,
286,
422,
1217,
851,
374,
539,
2290,
512,
310,
6149,
9324,
681,
13816,
663,
284,
659,
1462,
25140,
7464,
493,
882,
851,
518,
1217,
851,
11,
364,
496,
1329,
286,
2262,
284,
659,
1462,
25140,
5189,
15649,
11,
18814,
5122,
44722,
8598,
59510,
286,
2077,
284,
659,
1462,
6820,
20480,
9209,
1151,
32265,
756,
4700,
3813,
851,
1151,
24951,
15,
66,
21,
3141,
54312,
1399,
12,
2618,
68,
24,
12,
2421,
3013,
12,
23637,
18,
66,
17973,
24495,
65,
756,
4700,
2373,
1151,
20,
13,
15,
51981,
13,
17,
756,
4700,
6149,
9324,
28,
9143,
9324,
345,
4700,
2262,
28,
1834,
345,
4700,
3772,
1857,
1151,
5242,
9108,
2320,
759,
10,
2285,
1329,
286,
471,
659,
1462,
67877,
493,
1502,
2300,
46437,
82,
44722,
2647,
518,
2077,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
saltstack/salt | salt/modules/win_wua.py | download | def download(names):
'''
.. versionadded:: 2017.7.0
Downloads updates that match the list of passed identifiers. It's easier to
use this function by using list_updates and setting install=True.
Args:
names (str, list):
A single update or a list of updates to download. This can be any
combination of GUIDs, KB numbers, or names. GUIDs or KBs are
preferred.
.. note::
An error will be raised if there are more results than there are items
in the names parameter
Returns:
dict: A dictionary containing the details about the downloaded updates
CLI Examples:
.. code-block:: bash
# Normal Usage
salt '*' win_wua.download names=['12345678-abcd-1234-abcd-1234567890ab', 'KB2131233']
'''
# Create a Windows Update Agent instance
wua = salt.utils.win_update.WindowsUpdateAgent()
# Search for Update
updates = wua.search(names)
if updates.count() == 0:
raise CommandExecutionError('No updates found')
# Make sure it's a list so count comparison is correct
if isinstance(names, six.string_types):
names = [names]
if isinstance(names, six.integer_types):
names = [six.text_type(names)]
if updates.count() > len(names):
raise CommandExecutionError('Multiple updates found, names need to be '
'more specific')
return wua.download(updates) | python | def download(names):
'''
.. versionadded:: 2017.7.0
Downloads updates that match the list of passed identifiers. It's easier to
use this function by using list_updates and setting install=True.
Args:
names (str, list):
A single update or a list of updates to download. This can be any
combination of GUIDs, KB numbers, or names. GUIDs or KBs are
preferred.
.. note::
An error will be raised if there are more results than there are items
in the names parameter
Returns:
dict: A dictionary containing the details about the downloaded updates
CLI Examples:
.. code-block:: bash
# Normal Usage
salt '*' win_wua.download names=['12345678-abcd-1234-abcd-1234567890ab', 'KB2131233']
'''
# Create a Windows Update Agent instance
wua = salt.utils.win_update.WindowsUpdateAgent()
# Search for Update
updates = wua.search(names)
if updates.count() == 0:
raise CommandExecutionError('No updates found')
# Make sure it's a list so count comparison is correct
if isinstance(names, six.string_types):
names = [names]
if isinstance(names, six.integer_types):
names = [six.text_type(names)]
if updates.count() > len(names):
raise CommandExecutionError('Multiple updates found, names need to be '
'more specific')
return wua.download(updates) | [
"def",
"download",
"(",
"names",
")",
":",
"# Create a Windows Update Agent instance",
"wua",
"=",
"salt",
".",
"utils",
".",
"win_update",
".",
"WindowsUpdateAgent",
"(",
")",
"# Search for Update",
"updates",
"=",
"wua",
".",
"search",
"(",
"names",
")",
"if",
"updates",
".",
"count",
"(",
")",
"==",
"0",
":",
"raise",
"CommandExecutionError",
"(",
"'No updates found'",
")",
"# Make sure it's a list so count comparison is correct",
"if",
"isinstance",
"(",
"names",
",",
"six",
".",
"string_types",
")",
":",
"names",
"=",
"[",
"names",
"]",
"if",
"isinstance",
"(",
"names",
",",
"six",
".",
"integer_types",
")",
":",
"names",
"=",
"[",
"six",
".",
"text_type",
"(",
"names",
")",
"]",
"if",
"updates",
".",
"count",
"(",
")",
">",
"len",
"(",
"names",
")",
":",
"raise",
"CommandExecutionError",
"(",
"'Multiple updates found, names need to be '",
"'more specific'",
")",
"return",
"wua",
".",
"download",
"(",
"updates",
")"
] | .. versionadded:: 2017.7.0
Downloads updates that match the list of passed identifiers. It's easier to
use this function by using list_updates and setting install=True.
Args:
names (str, list):
A single update or a list of updates to download. This can be any
combination of GUIDs, KB numbers, or names. GUIDs or KBs are
preferred.
.. note::
An error will be raised if there are more results than there are items
in the names parameter
Returns:
dict: A dictionary containing the details about the downloaded updates
CLI Examples:
.. code-block:: bash
# Normal Usage
salt '*' win_wua.download names=['12345678-abcd-1234-abcd-1234567890ab', 'KB2131233'] | [
"..",
"versionadded",
"::",
"2017",
".",
"7",
".",
"0"
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_wua.py#L482-L531 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
.. versionadded:: 2017.7.0
Downloads updates that match the list of passed identifiers. It's easier to
use this function by using list_updates and setting install=True.
Args:
names (str, list):
A single update or a list of updates to download. This can be any
combination of GUIDs, KB numbers, or names. GUIDs or KBs are
preferred.
.. note::
An error will be raised if there are more results than there are items
in the names parameter
Returns:
dict: A dictionary containing the details about the downloaded updates
CLI Examples:
.. code-block:: bash
# Normal Usage
salt '*' win_wua.download names=['12345678-abcd-1234-abcd-1234567890ab', 'KB2131233']
### Response:
def download(names):
'''
.. versionadded:: 2017.7.0
Downloads updates that match the list of passed identifiers. It's easier to
use this function by using list_updates and setting install=True.
Args:
names (str, list):
A single update or a list of updates to download. This can be any
combination of GUIDs, KB numbers, or names. GUIDs or KBs are
preferred.
.. note::
An error will be raised if there are more results than there are items
in the names parameter
Returns:
dict: A dictionary containing the details about the downloaded updates
CLI Examples:
.. code-block:: bash
# Normal Usage
salt '*' win_wua.download names=['12345678-abcd-1234-abcd-1234567890ab', 'KB2131233']
'''
# Create a Windows Update Agent instance
wua = salt.utils.win_update.WindowsUpdateAgent()
# Search for Update
updates = wua.search(names)
if updates.count() == 0:
raise CommandExecutionError('No updates found')
# Make sure it's a list so count comparison is correct
if isinstance(names, six.string_types):
names = [names]
if isinstance(names, six.integer_types):
names = [six.text_type(names)]
if updates.count() > len(names):
raise CommandExecutionError('Multiple updates found, names need to be '
'more specific')
return wua.download(updates)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
497,
2373,
17249,
487,
220,
679,
22,
13,
22,
13,
15,
271,
262,
50261,
9013,
430,
2489,
279,
1160,
315,
5946,
48316,
13,
1102,
596,
8831,
311,
198,
262,
1005,
420,
734,
555,
1701,
1160,
58929,
323,
6376,
4685,
3702,
382,
262,
18161,
1473,
286,
5144,
320,
496,
11,
1160,
997,
310,
362,
3254,
2713,
477,
264,
1160,
315,
9013,
311,
4232,
13,
1115,
649,
387,
904,
198,
310,
10824,
315,
31321,
82,
11,
26068,
5219,
11,
477,
5144,
13,
31321,
82,
477,
26068,
82,
527,
198,
310,
15236,
382,
262,
5354,
5296,
50677,
286,
1556,
1493,
690,
387,
9408,
422,
1070,
527,
810,
3135,
1109,
1070,
527,
3673,
198,
286,
304,
279,
5144,
5852,
271,
262,
5295,
1473,
286,
6587,
25,
362,
11240,
8649,
279,
3649,
922,
279,
24174,
9013,
271,
262,
40377,
26379,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
674,
18944,
25585,
198,
286,
12290,
31801,
3243,
1704,
4381,
36481,
5144,
14314,
4513,
10961,
2495,
39130,
4484,
12,
4513,
19,
39130,
4484,
12,
4513,
10961,
16474,
15,
370,
518,
364,
30962,
11702,
4513,
18,
16049,
14711,
6075,
512,
755,
4232,
41501,
997,
262,
11414,
262,
5354,
2373,
17249,
487,
220,
679,
22,
13,
22,
13,
15,
271,
262,
50261,
9013,
430,
2489,
279,
1160,
315,
5946,
48316,
13,
1102,
596,
8831,
311,
198,
262,
1005,
420,
734,
555,
1701,
1160,
58929,
323,
6376,
4685,
3702,
382,
262,
18161,
1473,
286,
5144,
320,
496,
11,
1160,
997,
310,
362,
3254,
2713,
477,
264,
1160,
315,
9013,
311,
4232,
13,
1115,
649,
387,
904,
198,
310,
10824,
315,
31321,
82,
11,
26068,
5219,
11,
477,
5144,
13,
31321,
82,
477,
26068,
82,
527,
198,
310,
15236,
382,
262,
5354,
5296,
50677,
286,
1556,
1493,
690,
387,
9408,
422,
1070,
527,
810,
3135,
1109,
1070,
527,
3673,
198,
286,
304,
279,
5144,
5852,
271,
262,
5295,
1473,
286,
6587,
25,
362,
11240,
8649,
279,
3649,
922,
279,
24174,
9013,
271,
262,
40377,
26379,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
674,
18944,
25585,
198,
286,
12290,
31801,
3243,
1704,
4381,
36481,
5144,
14314,
4513,
10961,
2495,
39130,
4484,
12,
4513,
19,
39130,
4484,
12,
4513,
10961,
16474,
15,
370,
518,
364,
30962,
11702,
4513,
18,
4532,
262,
11414,
262,
674,
4324,
264,
5632,
5666,
21372,
2937,
198,
262,
289,
4381,
284,
12290,
8576,
44709,
9058,
1970,
4387,
17230,
2892,
262,
674,
7694,
369,
5666,
198,
262,
9013,
284,
289,
4381,
9472,
41501,
696,
262,
422,
9013,
6637,
368,
624,
220,
15,
512,
286,
4933,
7498,
20912,
1480,
493,
2822,
9013,
1766,
4713,
262,
674,
7557,
2771,
433,
596,
264,
1160,
779,
1797,
12593,
374,
4495,
198,
262,
422,
11656,
41501,
11,
4848,
4909,
9962,
997,
286,
5144,
284,
510,
11654,
2595,
262,
422,
11656,
41501,
11,
4848,
28693,
9962,
997,
286,
5144,
284,
510,
51464,
2858,
1857,
41501,
28871
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
497,
2373,
17249,
487,
220,
679,
22,
13,
22,
13,
15,
271,
262,
50261,
9013,
430,
2489,
279,
1160,
315,
5946,
48316,
13,
1102,
596,
8831,
311,
198,
262,
1005,
420,
734,
555,
1701,
1160,
58929,
323,
6376,
4685,
3702,
382,
262,
18161,
1473,
286,
5144,
320,
496,
11,
1160,
997,
310,
362,
3254,
2713,
477,
264,
1160,
315,
9013,
311,
4232,
13,
1115,
649,
387,
904,
198,
310,
10824,
315,
31321,
82,
11,
26068,
5219,
11,
477,
5144,
13,
31321,
82,
477,
26068,
82,
527,
198,
310,
15236,
382,
262,
5354,
5296,
50677,
286,
1556,
1493,
690,
387,
9408,
422,
1070,
527,
810,
3135,
1109,
1070,
527,
3673,
198,
286,
304,
279,
5144,
5852,
271,
262,
5295,
1473,
286,
6587,
25,
362,
11240,
8649,
279,
3649,
922,
279,
24174,
9013,
271,
262,
40377,
26379,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
674,
18944,
25585,
198,
286,
12290,
31801,
3243,
1704,
4381,
36481,
5144,
14314,
4513,
10961,
2495,
39130,
4484,
12,
4513,
19,
39130,
4484,
12,
4513,
10961,
16474,
15,
370,
518,
364,
30962,
11702,
4513,
18,
16049,
14711,
6075,
512,
755,
4232,
41501,
997,
262,
11414,
262,
5354,
2373,
17249,
487,
220,
679,
22,
13,
22,
13,
15,
271,
262,
50261,
9013,
430,
2489,
279,
1160,
315,
5946,
48316,
13,
1102,
596,
8831,
311,
198,
262,
1005,
420,
734,
555,
1701,
1160,
58929,
323,
6376,
4685,
3702,
382,
262,
18161,
1473,
286,
5144,
320,
496,
11,
1160,
997,
310,
362,
3254,
2713,
477,
264,
1160,
315,
9013,
311,
4232,
13,
1115,
649,
387,
904,
198,
310,
10824,
315,
31321,
82,
11,
26068,
5219,
11,
477,
5144,
13,
31321,
82,
477,
26068,
82,
527,
198,
310,
15236,
382,
262,
5354,
5296,
50677,
286,
1556,
1493,
690,
387,
9408,
422,
1070,
527,
810,
3135,
1109,
1070,
527,
3673,
198,
286,
304,
279,
5144,
5852,
271,
262,
5295,
1473,
286,
6587,
25,
362,
11240,
8649,
279,
3649,
922,
279,
24174,
9013,
271,
262,
40377,
26379,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
674,
18944,
25585,
198,
286,
12290,
31801,
3243,
1704,
4381,
36481,
5144,
14314,
4513,
10961,
2495,
39130,
4484,
12,
4513,
19,
39130,
4484,
12,
4513,
10961,
16474,
15,
370,
518,
364,
30962,
11702,
4513,
18,
4532,
262,
11414,
262,
674,
4324,
264,
5632,
5666,
21372,
2937,
198,
262,
289,
4381,
284,
12290,
8576,
44709,
9058,
1970,
4387,
17230,
2892,
262,
674,
7694,
369,
5666,
198,
262,
9013,
284,
289,
4381,
9472,
41501,
696,
262,
422,
9013,
6637,
368,
624,
220,
15,
512,
286,
4933,
7498,
20912,
1480,
493,
2822,
9013,
1766,
4713,
262,
674,
7557,
2771,
433,
596,
264,
1160,
779,
1797,
12593,
374,
4495,
198,
262,
422,
11656,
41501,
11,
4848,
4909,
9962,
997,
286,
5144,
284,
510,
11654,
2595,
262,
422,
11656,
41501,
11,
4848,
28693,
9962,
997,
286,
5144,
284,
510,
51464,
2858,
1857,
41501,
28871
] |
fracpete/python-weka-wrapper3 | python/weka/core/classes.py | get_static_field | def get_static_field(classname, fieldname, signature):
"""
Returns the Java object associated with the static field of the specified class.
:param classname: the classname of the class to get the field from
:type classname: str
:param fieldname: the name of the field to retriev
:type fieldname: str
:return: the object
:rtype: JB_Object
"""
try:
return javabridge.get_static_field(classname, fieldname, signature)
except:
return javabridge.static_call(
"Lweka/core/ClassHelper;", "getStaticField",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;",
classname, fieldname) | python | def get_static_field(classname, fieldname, signature):
"""
Returns the Java object associated with the static field of the specified class.
:param classname: the classname of the class to get the field from
:type classname: str
:param fieldname: the name of the field to retriev
:type fieldname: str
:return: the object
:rtype: JB_Object
"""
try:
return javabridge.get_static_field(classname, fieldname, signature)
except:
return javabridge.static_call(
"Lweka/core/ClassHelper;", "getStaticField",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;",
classname, fieldname) | [
"def",
"get_static_field",
"(",
"classname",
",",
"fieldname",
",",
"signature",
")",
":",
"try",
":",
"return",
"javabridge",
".",
"get_static_field",
"(",
"classname",
",",
"fieldname",
",",
"signature",
")",
"except",
":",
"return",
"javabridge",
".",
"static_call",
"(",
"\"Lweka/core/ClassHelper;\"",
",",
"\"getStaticField\"",
",",
"\"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;\"",
",",
"classname",
",",
"fieldname",
")"
] | Returns the Java object associated with the static field of the specified class.
:param classname: the classname of the class to get the field from
:type classname: str
:param fieldname: the name of the field to retriev
:type fieldname: str
:return: the object
:rtype: JB_Object | [
"Returns",
"the",
"Java",
"object",
"associated",
"with",
"the",
"static",
"field",
"of",
"the",
"specified",
"class",
"."
] | train | https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L70-L87 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Returns the Java object associated with the static field of the specified class.
:param classname: the classname of the class to get the field from
:type classname: str
:param fieldname: the name of the field to retriev
:type fieldname: str
:return: the object
:rtype: JB_Object
### Response:
def get_static_field(classname, fieldname, signature):
"""
Returns the Java object associated with the static field of the specified class.
:param classname: the classname of the class to get the field from
:type classname: str
:param fieldname: the name of the field to retriev
:type fieldname: str
:return: the object
:rtype: JB_Object
"""
try:
return javabridge.get_static_field(classname, fieldname, signature)
except:
return javabridge.static_call(
"Lweka/core/ClassHelper;", "getStaticField",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;",
classname, fieldname)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
279,
8102,
1665,
5938,
449,
279,
1118,
2115,
315,
279,
5300,
538,
382,
262,
551,
913,
71750,
25,
279,
71750,
315,
279,
538,
311,
636,
279,
2115,
505,
198,
262,
551,
1337,
71750,
25,
610,
198,
262,
551,
913,
2115,
609,
25,
279,
836,
315,
279,
2115,
311,
10992,
85,
198,
262,
551,
1337,
2115,
609,
25,
610,
198,
262,
551,
693,
25,
279,
1665,
198,
262,
551,
33613,
25,
77379,
28939,
271,
14711,
6075,
512,
755,
636,
26430,
5121,
22723,
609,
11,
2115,
609,
11,
12223,
997,
262,
3270,
262,
5295,
279,
8102,
1665,
5938,
449,
279,
1118,
2115,
315,
279,
5300,
538,
382,
262,
551,
913,
71750,
25,
279,
71750,
315,
279,
538,
311,
636,
279,
2115,
505,
198,
262,
551,
1337,
71750,
25,
610,
198,
262,
551,
913,
2115,
609,
25,
279,
836,
315,
279,
2115,
311,
10992,
85,
198,
262,
551,
1337,
2115,
609,
25,
610,
198,
262,
551,
693,
25,
279,
1665,
198,
262,
551,
33613,
25,
77379,
28939,
198,
262,
3270,
262,
1456,
512,
286,
471,
1281,
370,
11431,
673,
26430,
5121,
22723,
609,
11,
2115,
609,
11,
12223,
340,
262,
3734,
512,
286,
471,
1281,
370,
11431,
27273,
13735,
1021,
310,
330,
43,
906,
4657,
5433,
14,
1999,
5628,
33603,
330,
456,
11952,
1915,
761,
310,
12262,
39024,
26319,
37364,
26,
39024,
26319,
37364,
37274,
39024,
26319,
69626,
65597,
310,
71750,
11,
2115,
609,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
279,
8102,
1665,
5938,
449,
279,
1118,
2115,
315,
279,
5300,
538,
382,
262,
551,
913,
71750,
25,
279,
71750,
315,
279,
538,
311,
636,
279,
2115,
505,
198,
262,
551,
1337,
71750,
25,
610,
198,
262,
551,
913,
2115,
609,
25,
279,
836,
315,
279,
2115,
311,
10992,
85,
198,
262,
551,
1337,
2115,
609,
25,
610,
198,
262,
551,
693,
25,
279,
1665,
198,
262,
551,
33613,
25,
77379,
28939,
271,
14711,
6075,
512,
755,
636,
26430,
5121,
22723,
609,
11,
2115,
609,
11,
12223,
997,
262,
3270,
262,
5295,
279,
8102,
1665,
5938,
449,
279,
1118,
2115,
315,
279,
5300,
538,
382,
262,
551,
913,
71750,
25,
279,
71750,
315,
279,
538,
311,
636,
279,
2115,
505,
198,
262,
551,
1337,
71750,
25,
610,
198,
262,
551,
913,
2115,
609,
25,
279,
836,
315,
279,
2115,
311,
10992,
85,
198,
262,
551,
1337,
2115,
609,
25,
610,
198,
262,
551,
693,
25,
279,
1665,
198,
262,
551,
33613,
25,
77379,
28939,
198,
262,
3270,
262,
1456,
512,
286,
471,
1281,
370,
11431,
673,
26430,
5121,
22723,
609,
11,
2115,
609,
11,
12223,
340,
262,
3734,
512,
286,
471,
1281,
370,
11431,
27273,
13735,
1021,
310,
330,
43,
906,
4657,
5433,
14,
1999,
5628,
33603,
330,
456,
11952,
1915,
761,
310,
12262,
39024,
26319,
37364,
26,
39024,
26319,
37364,
37274,
39024,
26319,
69626,
65597,
310,
71750,
11,
2115,
609,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
erikrose/more-itertools | more_itertools/more.py | one | def one(iterable, too_short=None, too_long=None):
"""Return the first item from *iterable*, which is expected to contain only
that item. Raise an exception if *iterable* is empty or has more than one
item.
:func:`one` is useful for ensuring that an iterable contains only one item.
For example, it can be used to retrieve the result of a database query
that is expected to return a single row.
If *iterable* is empty, ``ValueError`` will be raised. You may specify a
different exception with the *too_short* keyword:
>>> it = []
>>> one(it) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: too many items in iterable (expected 1)'
>>> too_short = IndexError('too few items')
>>> one(it, too_short=too_short) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
IndexError: too few items
Similarly, if *iterable* contains more than one item, ``ValueError`` will
be raised. You may specify a different exception with the *too_long*
keyword:
>>> it = ['too', 'many']
>>> one(it) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: too many items in iterable (expected 1)'
>>> too_long = RuntimeError
>>> one(it, too_long=too_long) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
RuntimeError
Note that :func:`one` attempts to advance *iterable* twice to ensure there
is only one item. See :func:`spy` or :func:`peekable` to check iterable
contents less destructively.
"""
it = iter(iterable)
try:
value = next(it)
except StopIteration:
raise too_short or ValueError('too few items in iterable (expected 1)')
try:
next(it)
except StopIteration:
pass
else:
raise too_long or ValueError('too many items in iterable (expected 1)')
return value | python | def one(iterable, too_short=None, too_long=None):
"""Return the first item from *iterable*, which is expected to contain only
that item. Raise an exception if *iterable* is empty or has more than one
item.
:func:`one` is useful for ensuring that an iterable contains only one item.
For example, it can be used to retrieve the result of a database query
that is expected to return a single row.
If *iterable* is empty, ``ValueError`` will be raised. You may specify a
different exception with the *too_short* keyword:
>>> it = []
>>> one(it) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: too many items in iterable (expected 1)'
>>> too_short = IndexError('too few items')
>>> one(it, too_short=too_short) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
IndexError: too few items
Similarly, if *iterable* contains more than one item, ``ValueError`` will
be raised. You may specify a different exception with the *too_long*
keyword:
>>> it = ['too', 'many']
>>> one(it) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: too many items in iterable (expected 1)'
>>> too_long = RuntimeError
>>> one(it, too_long=too_long) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
RuntimeError
Note that :func:`one` attempts to advance *iterable* twice to ensure there
is only one item. See :func:`spy` or :func:`peekable` to check iterable
contents less destructively.
"""
it = iter(iterable)
try:
value = next(it)
except StopIteration:
raise too_short or ValueError('too few items in iterable (expected 1)')
try:
next(it)
except StopIteration:
pass
else:
raise too_long or ValueError('too many items in iterable (expected 1)')
return value | [
"def",
"one",
"(",
"iterable",
",",
"too_short",
"=",
"None",
",",
"too_long",
"=",
"None",
")",
":",
"it",
"=",
"iter",
"(",
"iterable",
")",
"try",
":",
"value",
"=",
"next",
"(",
"it",
")",
"except",
"StopIteration",
":",
"raise",
"too_short",
"or",
"ValueError",
"(",
"'too few items in iterable (expected 1)'",
")",
"try",
":",
"next",
"(",
"it",
")",
"except",
"StopIteration",
":",
"pass",
"else",
":",
"raise",
"too_long",
"or",
"ValueError",
"(",
"'too many items in iterable (expected 1)'",
")",
"return",
"value"
] | Return the first item from *iterable*, which is expected to contain only
that item. Raise an exception if *iterable* is empty or has more than one
item.
:func:`one` is useful for ensuring that an iterable contains only one item.
For example, it can be used to retrieve the result of a database query
that is expected to return a single row.
If *iterable* is empty, ``ValueError`` will be raised. You may specify a
different exception with the *too_short* keyword:
>>> it = []
>>> one(it) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: too many items in iterable (expected 1)'
>>> too_short = IndexError('too few items')
>>> one(it, too_short=too_short) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
IndexError: too few items
Similarly, if *iterable* contains more than one item, ``ValueError`` will
be raised. You may specify a different exception with the *too_long*
keyword:
>>> it = ['too', 'many']
>>> one(it) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: too many items in iterable (expected 1)'
>>> too_long = RuntimeError
>>> one(it, too_long=too_long) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
RuntimeError
Note that :func:`one` attempts to advance *iterable* twice to ensure there
is only one item. See :func:`spy` or :func:`peekable` to check iterable
contents less destructively. | [
"Return",
"the",
"first",
"item",
"from",
"*",
"iterable",
"*",
"which",
"is",
"expected",
"to",
"contain",
"only",
"that",
"item",
".",
"Raise",
"an",
"exception",
"if",
"*",
"iterable",
"*",
"is",
"empty",
"or",
"has",
"more",
"than",
"one",
"item",
"."
] | train | https://github.com/erikrose/more-itertools/blob/6a91b4e25c8e12fcf9fc2b53cf8ee0fba293e6f9/more_itertools/more.py#L468-L525 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return the first item from *iterable*, which is expected to contain only
that item. Raise an exception if *iterable* is empty or has more than one
item.
:func:`one` is useful for ensuring that an iterable contains only one item.
For example, it can be used to retrieve the result of a database query
that is expected to return a single row.
If *iterable* is empty, ``ValueError`` will be raised. You may specify a
different exception with the *too_short* keyword:
>>> it = []
>>> one(it) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: too many items in iterable (expected 1)'
>>> too_short = IndexError('too few items')
>>> one(it, too_short=too_short) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
IndexError: too few items
Similarly, if *iterable* contains more than one item, ``ValueError`` will
be raised. You may specify a different exception with the *too_long*
keyword:
>>> it = ['too', 'many']
>>> one(it) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: too many items in iterable (expected 1)'
>>> too_long = RuntimeError
>>> one(it, too_long=too_long) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
RuntimeError
Note that :func:`one` attempts to advance *iterable* twice to ensure there
is only one item. See :func:`spy` or :func:`peekable` to check iterable
contents less destructively.
### Response:
def one(iterable, too_short=None, too_long=None):
"""Return the first item from *iterable*, which is expected to contain only
that item. Raise an exception if *iterable* is empty or has more than one
item.
:func:`one` is useful for ensuring that an iterable contains only one item.
For example, it can be used to retrieve the result of a database query
that is expected to return a single row.
If *iterable* is empty, ``ValueError`` will be raised. You may specify a
different exception with the *too_short* keyword:
>>> it = []
>>> one(it) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: too many items in iterable (expected 1)'
>>> too_short = IndexError('too few items')
>>> one(it, too_short=too_short) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
IndexError: too few items
Similarly, if *iterable* contains more than one item, ``ValueError`` will
be raised. You may specify a different exception with the *too_long*
keyword:
>>> it = ['too', 'many']
>>> one(it) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
ValueError: too many items in iterable (expected 1)'
>>> too_long = RuntimeError
>>> one(it, too_long=too_long) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
RuntimeError
Note that :func:`one` attempts to advance *iterable* twice to ensure there
is only one item. See :func:`spy` or :func:`peekable` to check iterable
contents less destructively.
"""
it = iter(iterable)
try:
value = next(it)
except StopIteration:
raise too_short or ValueError('too few items in iterable (expected 1)')
try:
next(it)
except StopIteration:
pass
else:
raise too_long or ValueError('too many items in iterable (expected 1)')
return value
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
279,
1176,
1537,
505,
353,
2058,
481,
12594,
902,
374,
3685,
311,
6782,
1193,
198,
262,
430,
1537,
13,
43646,
459,
4788,
422,
353,
2058,
481,
9,
374,
4384,
477,
706,
810,
1109,
832,
198,
262,
1537,
382,
262,
551,
2900,
19258,
606,
63,
374,
5505,
369,
23391,
430,
459,
51934,
5727,
1193,
832,
1537,
627,
262,
1789,
3187,
11,
433,
649,
387,
1511,
311,
17622,
279,
1121,
315,
264,
4729,
3319,
198,
262,
430,
374,
3685,
311,
471,
264,
3254,
2872,
382,
262,
1442,
353,
2058,
481,
9,
374,
4384,
11,
10103,
1150,
1480,
14196,
690,
387,
9408,
13,
1472,
1253,
14158,
264,
198,
262,
2204,
4788,
449,
279,
353,
37227,
17087,
9,
16570,
1473,
286,
12382,
433,
284,
4260,
286,
12382,
832,
13641,
8,
220,
674,
656,
68980,
25,
489,
36145,
28385,
34005,
198,
286,
28262,
1445,
320,
3646,
3293,
1650,
1566,
997,
286,
12515,
286,
15764,
25,
2288,
1690,
3673,
304,
51934,
320,
7475,
220,
16,
40667,
286,
12382,
2288,
17087,
284,
61303,
493,
37227,
2478,
3673,
1329,
286,
12382,
832,
13641,
11,
2288,
17087,
28,
37227,
17087,
8,
220,
674,
656,
68980,
25,
489,
36145,
28385,
34005,
198,
286,
28262,
1445,
320,
3646,
3293,
1650,
1566,
997,
286,
12515,
286,
61303,
25,
2288,
2478,
3673,
271,
262,
35339,
11,
422,
353,
2058,
481,
9,
5727,
810,
1109,
832,
1537,
11,
10103,
1150,
1480,
14196,
690,
198,
262,
387,
9408,
13,
1472,
1253,
14158,
264,
2204,
4788,
449,
279,
353,
37227,
18278,
5736,
262,
16570,
1473,
286,
12382,
433,
284,
2570,
37227,
518,
364,
35676,
4532,
286,
12382,
832,
13641,
8,
220,
674,
656,
68980,
25,
489,
36145,
28385,
34005,
198,
286,
28262,
1445,
320,
3646,
3293,
1650,
1566,
997,
286,
12515,
286,
15764,
25,
2288,
1690,
3673,
304,
51934,
320,
7475,
220,
16,
40667,
286,
12382,
2288,
18278,
284,
45643,
198,
286,
12382,
832,
13641,
11,
2288,
18278,
28,
37227,
18278,
8,
220,
674,
656,
68980,
25,
489,
36145,
28385,
34005,
198,
286,
28262,
1445,
320,
3646,
3293,
1650,
1566,
997,
286,
12515,
286,
45643,
271,
262,
7181,
430,
551,
2900,
19258,
606,
63,
13865,
311,
12178,
353,
2058,
481,
9,
11157,
311,
6106,
1070,
198,
262,
374,
1193,
832,
1537,
13,
3580,
551,
2900,
19258,
29291,
63,
477,
551,
2900,
19258,
30207,
481,
63,
311,
1817,
51934,
198,
262,
8970,
2753,
21443,
3210,
382,
14711,
6075,
512,
755,
832,
28169,
481,
11,
2288,
17087,
5980,
11,
2288,
18278,
5980,
997,
262,
4304,
5715,
279,
1176,
1537,
505,
353,
2058,
481,
12594,
902,
374,
3685,
311,
6782,
1193,
198,
262,
430,
1537,
13,
43646,
459,
4788,
422,
353,
2058,
481,
9,
374,
4384,
477,
706,
810,
1109,
832,
198,
262,
1537,
382,
262,
551,
2900,
19258,
606,
63,
374,
5505,
369,
23391,
430,
459,
51934,
5727,
1193,
832,
1537,
627,
262,
1789,
3187,
11,
433,
649,
387,
1511
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
279,
1176,
1537,
505,
353,
2058,
481,
12594,
902,
374,
3685,
311,
6782,
1193,
198,
262,
430,
1537,
13,
43646,
459,
4788,
422,
353,
2058,
481,
9,
374,
4384,
477,
706,
810,
1109,
832,
198,
262,
1537,
382,
262,
551,
2900,
19258,
606,
63,
374,
5505,
369,
23391,
430,
459,
51934,
5727,
1193,
832,
1537,
627,
262,
1789,
3187,
11,
433,
649,
387,
1511,
311,
17622,
279,
1121,
315,
264,
4729,
3319,
198,
262,
430,
374,
3685,
311,
471,
264,
3254,
2872,
382,
262,
1442,
353,
2058,
481,
9,
374,
4384,
11,
10103,
1150,
1480,
14196,
690,
387,
9408,
13,
1472,
1253,
14158,
264,
198,
262,
2204,
4788,
449,
279,
353,
37227,
17087,
9,
16570,
1473,
286,
12382,
433,
284,
4260,
286,
12382,
832,
13641,
8,
220,
674,
656,
68980,
25,
489,
36145,
28385,
34005,
198,
286,
28262,
1445,
320,
3646,
3293,
1650,
1566,
997,
286,
12515,
286,
15764,
25,
2288,
1690,
3673,
304,
51934,
320,
7475,
220,
16,
40667,
286,
12382,
2288,
17087,
284,
61303,
493,
37227,
2478,
3673,
1329,
286,
12382,
832,
13641,
11,
2288,
17087,
28,
37227,
17087,
8,
220,
674,
656,
68980,
25,
489,
36145,
28385,
34005,
198,
286,
28262,
1445,
320,
3646,
3293,
1650,
1566,
997,
286,
12515,
286,
61303,
25,
2288,
2478,
3673,
271,
262,
35339,
11,
422,
353,
2058,
481,
9,
5727,
810,
1109,
832,
1537,
11,
10103,
1150,
1480,
14196,
690,
198,
262,
387,
9408,
13,
1472,
1253,
14158,
264,
2204,
4788,
449,
279,
353,
37227,
18278,
5736,
262,
16570,
1473,
286,
12382,
433,
284,
2570,
37227,
518,
364,
35676,
4532,
286,
12382,
832,
13641,
8,
220,
674,
656,
68980,
25,
489,
36145,
28385,
34005,
198,
286,
28262,
1445,
320,
3646,
3293,
1650,
1566,
997,
286,
12515,
286,
15764,
25,
2288,
1690,
3673,
304,
51934,
320,
7475,
220,
16,
40667,
286,
12382,
2288,
18278,
284,
45643,
198,
286,
12382,
832,
13641,
11,
2288,
18278,
28,
37227,
18278,
8,
220,
674,
656,
68980,
25,
489,
36145,
28385,
34005,
198,
286,
28262,
1445,
320,
3646,
3293,
1650,
1566,
997,
286,
12515,
286,
45643,
271,
262,
7181,
430,
551,
2900,
19258,
606,
63,
13865,
311,
12178,
353,
2058,
481,
9,
11157,
311,
6106,
1070,
198,
262,
374,
1193,
832,
1537,
13,
3580,
551,
2900,
19258,
29291,
63,
477,
551,
2900,
19258,
30207,
481,
63,
311,
1817,
51934,
198,
262,
8970,
2753,
21443,
3210,
382,
14711,
6075,
512,
755,
832,
28169,
481,
11,
2288,
17087,
5980,
11,
2288,
18278,
5980,
997,
262,
4304,
5715,
279,
1176,
1537,
505,
353,
2058,
481,
12594,
902,
374,
3685,
311,
6782,
1193,
198,
262,
430,
1537,
13,
43646,
459,
4788,
422,
353,
2058,
481,
9,
374,
4384,
477,
706,
810,
1109,
832,
198,
262,
1537,
382,
262,
551,
2900,
19258,
606,
63,
374,
5505,
369,
23391,
430,
459,
51934,
5727,
1193,
832,
1537,
627,
262,
1789,
3187,
11,
433,
649,
387,
1511
] |
soravux/scoop | scoop/utils.py | getHostsFromList | def getHostsFromList(hostlist):
"""Return the hosts from the command line"""
# check to see if it is a SLURM grouping instead of a
# regular list of hosts
if any(re.search('[\[\]]', x) for x in hostlist):
return parseSLURM(str(hostlist))
# Counter would be more efficient but:
# 1. Won't be Python 2.6 compatible
# 2. Won't be ordered
hostlist = groupTogether(hostlist)
retVal = []
for key, group in groupby(hostlist):
retVal.append((key, len(list(group))))
return retVal | python | def getHostsFromList(hostlist):
"""Return the hosts from the command line"""
# check to see if it is a SLURM grouping instead of a
# regular list of hosts
if any(re.search('[\[\]]', x) for x in hostlist):
return parseSLURM(str(hostlist))
# Counter would be more efficient but:
# 1. Won't be Python 2.6 compatible
# 2. Won't be ordered
hostlist = groupTogether(hostlist)
retVal = []
for key, group in groupby(hostlist):
retVal.append((key, len(list(group))))
return retVal | [
"def",
"getHostsFromList",
"(",
"hostlist",
")",
":",
"# check to see if it is a SLURM grouping instead of a",
"# regular list of hosts",
"if",
"any",
"(",
"re",
".",
"search",
"(",
"'[\\[\\]]'",
",",
"x",
")",
"for",
"x",
"in",
"hostlist",
")",
":",
"return",
"parseSLURM",
"(",
"str",
"(",
"hostlist",
")",
")",
"# Counter would be more efficient but:",
"# 1. Won't be Python 2.6 compatible",
"# 2. Won't be ordered",
"hostlist",
"=",
"groupTogether",
"(",
"hostlist",
")",
"retVal",
"=",
"[",
"]",
"for",
"key",
",",
"group",
"in",
"groupby",
"(",
"hostlist",
")",
":",
"retVal",
".",
"append",
"(",
"(",
"key",
",",
"len",
"(",
"list",
"(",
"group",
")",
")",
")",
")",
"return",
"retVal"
] | Return the hosts from the command line | [
"Return",
"the",
"hosts",
"from",
"the",
"command",
"line"
] | train | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/utils.py#L187-L201 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return the hosts from the command line
### Response:
def getHostsFromList(hostlist):
"""Return the hosts from the command line"""
# check to see if it is a SLURM grouping instead of a
# regular list of hosts
if any(re.search('[\[\]]', x) for x in hostlist):
return parseSLURM(str(hostlist))
# Counter would be more efficient but:
# 1. Won't be Python 2.6 compatible
# 2. Won't be ordered
hostlist = groupTogether(hostlist)
retVal = []
for key, group in groupby(hostlist):
retVal.append((key, len(list(group))))
return retVal
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
279,
18939,
505,
279,
3290,
1584,
271,
14711,
6075,
512,
755,
636,
9480,
82,
3915,
861,
20569,
1638,
997,
262,
4304,
5715,
279,
18939,
505,
279,
3290,
1584,
7275,
262,
674,
1817,
311,
1518,
422,
433,
374,
264,
17216,
1539,
44,
50284,
4619,
315,
264,
198,
262,
674,
5912,
1160,
315,
18939,
198,
262,
422,
904,
5921,
9472,
21227,
59,
27148,
5163,
518,
865,
8,
369,
865,
304,
3552,
1638,
997,
286,
471,
4820,
8143,
1539,
44,
4293,
20569,
1638,
4489,
262,
674,
20315,
1053,
387,
810,
11297,
719,
512,
262,
674,
220,
16,
13,
43549,
956,
387,
13325,
220,
17,
13,
21,
18641,
198,
262,
674,
220,
17,
13,
43549,
956,
387,
11713,
198,
262,
3552,
1638,
284,
1912,
82087,
20569,
1638,
340,
262,
35830,
284,
4260,
262,
369,
1401,
11,
1912,
304,
1912,
1729,
20569,
1638,
997,
286,
35830,
2102,
1209,
798,
11,
2479,
7455,
18158,
23631,
262,
471,
35830,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
279,
18939,
505,
279,
3290,
1584,
271,
14711,
6075,
512,
755,
636,
9480,
82,
3915,
861,
20569,
1638,
997,
262,
4304,
5715,
279,
18939,
505,
279,
3290,
1584,
7275,
262,
674,
1817,
311,
1518,
422,
433,
374,
264,
17216,
1539,
44,
50284,
4619,
315,
264,
198,
262,
674,
5912,
1160,
315,
18939,
198,
262,
422,
904,
5921,
9472,
21227,
59,
27148,
5163,
518,
865,
8,
369,
865,
304,
3552,
1638,
997,
286,
471,
4820,
8143,
1539,
44,
4293,
20569,
1638,
4489,
262,
674,
20315,
1053,
387,
810,
11297,
719,
512,
262,
674,
220,
16,
13,
43549,
956,
387,
13325,
220,
17,
13,
21,
18641,
198,
262,
674,
220,
17,
13,
43549,
956,
387,
11713,
198,
262,
3552,
1638,
284,
1912,
82087,
20569,
1638,
340,
262,
35830,
284,
4260,
262,
369,
1401,
11,
1912,
304,
1912,
1729,
20569,
1638,
997,
286,
35830,
2102,
1209,
798,
11,
2479,
7455,
18158,
23631,
262,
471,
35830,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
TeamHG-Memex/eli5 | eli5/sklearn/utils.py | has_intercept | def has_intercept(estimator):
# type: (Any) -> bool
""" Return True if an estimator has intercept fit. """
if hasattr(estimator, 'fit_intercept'):
return estimator.fit_intercept
if hasattr(estimator, 'intercept_'):
if estimator.intercept_ is None:
return False
# scikit-learn sets intercept to zero vector if it is not fit
return np.any(estimator.intercept_)
return False | python | def has_intercept(estimator):
# type: (Any) -> bool
""" Return True if an estimator has intercept fit. """
if hasattr(estimator, 'fit_intercept'):
return estimator.fit_intercept
if hasattr(estimator, 'intercept_'):
if estimator.intercept_ is None:
return False
# scikit-learn sets intercept to zero vector if it is not fit
return np.any(estimator.intercept_)
return False | [
"def",
"has_intercept",
"(",
"estimator",
")",
":",
"# type: (Any) -> bool",
"if",
"hasattr",
"(",
"estimator",
",",
"'fit_intercept'",
")",
":",
"return",
"estimator",
".",
"fit_intercept",
"if",
"hasattr",
"(",
"estimator",
",",
"'intercept_'",
")",
":",
"if",
"estimator",
".",
"intercept_",
"is",
"None",
":",
"return",
"False",
"# scikit-learn sets intercept to zero vector if it is not fit",
"return",
"np",
".",
"any",
"(",
"estimator",
".",
"intercept_",
")",
"return",
"False"
] | Return True if an estimator has intercept fit. | [
"Return",
"True",
"if",
"an",
"estimator",
"has",
"intercept",
"fit",
"."
] | train | https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/sklearn/utils.py#L57-L67 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return True if an estimator has intercept fit.
### Response:
def has_intercept(estimator):
# type: (Any) -> bool
""" Return True if an estimator has intercept fit. """
if hasattr(estimator, 'fit_intercept'):
return estimator.fit_intercept
if hasattr(estimator, 'intercept_'):
if estimator.intercept_ is None:
return False
# scikit-learn sets intercept to zero vector if it is not fit
return np.any(estimator.intercept_)
return False
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
3082,
422,
459,
68398,
706,
29739,
5052,
382,
14711,
6075,
512,
755,
706,
15678,
1512,
90982,
14003,
997,
262,
674,
955,
25,
320,
8780,
8,
1492,
1845,
198,
262,
4304,
3494,
3082,
422,
459,
68398,
706,
29739,
5052,
13,
3270,
262,
422,
32156,
90982,
14003,
11,
364,
6410,
15678,
1512,
11290,
286,
471,
68398,
21529,
15678,
1512,
198,
262,
422,
32156,
90982,
14003,
11,
364,
2295,
1512,
62,
11290,
286,
422,
68398,
14471,
1512,
62,
374,
2290,
512,
310,
471,
3641,
198,
286,
674,
1156,
61503,
12,
12964,
7437,
29739,
311,
7315,
4724,
422,
433,
374,
539,
5052,
198,
286,
471,
2660,
30415,
90982,
14003,
14471,
1512,
24262,
262,
471,
3641,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
3082,
422,
459,
68398,
706,
29739,
5052,
382,
14711,
6075,
512,
755,
706,
15678,
1512,
90982,
14003,
997,
262,
674,
955,
25,
320,
8780,
8,
1492,
1845,
198,
262,
4304,
3494,
3082,
422,
459,
68398,
706,
29739,
5052,
13,
3270,
262,
422,
32156,
90982,
14003,
11,
364,
6410,
15678,
1512,
11290,
286,
471,
68398,
21529,
15678,
1512,
198,
262,
422,
32156,
90982,
14003,
11,
364,
2295,
1512,
62,
11290,
286,
422,
68398,
14471,
1512,
62,
374,
2290,
512,
310,
471,
3641,
198,
286,
674,
1156,
61503,
12,
12964,
7437,
29739,
311,
7315,
4724,
422,
433,
374,
539,
5052,
198,
286,
471,
2660,
30415,
90982,
14003,
14471,
1512,
24262,
262,
471,
3641,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
carpyncho/feets | doc/source/JSAnimation/IPython_display.py | display_animation | def display_animation(anim, **kwargs):
"""Display the animation with an IPython HTML object"""
from IPython.display import HTML
return HTML(anim_to_html(anim, **kwargs)) | python | def display_animation(anim, **kwargs):
"""Display the animation with an IPython HTML object"""
from IPython.display import HTML
return HTML(anim_to_html(anim, **kwargs)) | [
"def",
"display_animation",
"(",
"anim",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"IPython",
".",
"display",
"import",
"HTML",
"return",
"HTML",
"(",
"anim_to_html",
"(",
"anim",
",",
"*",
"*",
"kwargs",
")",
")"
] | Display the animation with an IPython HTML object | [
"Display",
"the",
"animation",
"with",
"an",
"IPython",
"HTML",
"object"
] | train | https://github.com/carpyncho/feets/blob/53bdfb73b53845561914fc1f756e0c2377b9b76b/doc/source/JSAnimation/IPython_display.py#L83-L86 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Display the animation with an IPython HTML object
### Response:
def display_animation(anim, **kwargs):
"""Display the animation with an IPython HTML object"""
from IPython.display import HTML
return HTML(anim_to_html(anim, **kwargs))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
7165,
279,
10571,
449,
459,
6933,
27993,
9492,
1665,
271,
14711,
6075,
512,
755,
3113,
49587,
7,
16348,
11,
3146,
9872,
997,
262,
4304,
7165,
279,
10571,
449,
459,
6933,
27993,
9492,
1665,
7275,
262,
505,
6933,
27993,
8344,
1179,
9492,
198,
262,
471,
9492,
7,
16348,
2401,
9759,
7,
16348,
11,
3146,
9872,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
7165,
279,
10571,
449,
459,
6933,
27993,
9492,
1665,
271,
14711,
6075,
512,
755,
3113,
49587,
7,
16348,
11,
3146,
9872,
997,
262,
4304,
7165,
279,
10571,
449,
459,
6933,
27993,
9492,
1665,
7275,
262,
505,
6933,
27993,
8344,
1179,
9492,
198,
262,
471,
9492,
7,
16348,
2401,
9759,
7,
16348,
11,
3146,
9872,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
tensorflow/tensor2tensor | tensor2tensor/layers/area_attention.py | _pool_one_shape | def _pool_one_shape(features_2d, area_width, area_height, batch_size,
width, height, depth, fn=tf.reduce_max, name=None):
"""Pools for an area in features_2d.
Args:
features_2d: a Tensor in a shape of [batch_size, height, width, depth].
area_width: the max width allowed for an area.
area_height: the max height allowed for an area.
batch_size: the batch size.
width: the width of the memory.
height: the height of the memory.
depth: the depth of the features.
fn: the TF function for the pooling.
name: the op name.
Returns:
pool_tensor: A Tensor of shape [batch_size, num_areas, depth]
"""
with tf.name_scope(name, default_name="pool_one_shape"):
images = []
for y_shift in range(area_height):
image_height = tf.maximum(height - area_height + 1 + y_shift, 0)
for x_shift in range(area_width):
image_width = tf.maximum(width - area_width + 1 + x_shift, 0)
area = features_2d[:, y_shift:image_height, x_shift:image_width, :]
flatten_area = tf.reshape(area, [batch_size, -1, depth, 1])
images.append(flatten_area)
image_tensor = tf.concat(images, axis=3)
max_tensor = fn(image_tensor, axis=3)
return max_tensor | python | def _pool_one_shape(features_2d, area_width, area_height, batch_size,
width, height, depth, fn=tf.reduce_max, name=None):
"""Pools for an area in features_2d.
Args:
features_2d: a Tensor in a shape of [batch_size, height, width, depth].
area_width: the max width allowed for an area.
area_height: the max height allowed for an area.
batch_size: the batch size.
width: the width of the memory.
height: the height of the memory.
depth: the depth of the features.
fn: the TF function for the pooling.
name: the op name.
Returns:
pool_tensor: A Tensor of shape [batch_size, num_areas, depth]
"""
with tf.name_scope(name, default_name="pool_one_shape"):
images = []
for y_shift in range(area_height):
image_height = tf.maximum(height - area_height + 1 + y_shift, 0)
for x_shift in range(area_width):
image_width = tf.maximum(width - area_width + 1 + x_shift, 0)
area = features_2d[:, y_shift:image_height, x_shift:image_width, :]
flatten_area = tf.reshape(area, [batch_size, -1, depth, 1])
images.append(flatten_area)
image_tensor = tf.concat(images, axis=3)
max_tensor = fn(image_tensor, axis=3)
return max_tensor | [
"def",
"_pool_one_shape",
"(",
"features_2d",
",",
"area_width",
",",
"area_height",
",",
"batch_size",
",",
"width",
",",
"height",
",",
"depth",
",",
"fn",
"=",
"tf",
".",
"reduce_max",
",",
"name",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"name",
",",
"default_name",
"=",
"\"pool_one_shape\"",
")",
":",
"images",
"=",
"[",
"]",
"for",
"y_shift",
"in",
"range",
"(",
"area_height",
")",
":",
"image_height",
"=",
"tf",
".",
"maximum",
"(",
"height",
"-",
"area_height",
"+",
"1",
"+",
"y_shift",
",",
"0",
")",
"for",
"x_shift",
"in",
"range",
"(",
"area_width",
")",
":",
"image_width",
"=",
"tf",
".",
"maximum",
"(",
"width",
"-",
"area_width",
"+",
"1",
"+",
"x_shift",
",",
"0",
")",
"area",
"=",
"features_2d",
"[",
":",
",",
"y_shift",
":",
"image_height",
",",
"x_shift",
":",
"image_width",
",",
":",
"]",
"flatten_area",
"=",
"tf",
".",
"reshape",
"(",
"area",
",",
"[",
"batch_size",
",",
"-",
"1",
",",
"depth",
",",
"1",
"]",
")",
"images",
".",
"append",
"(",
"flatten_area",
")",
"image_tensor",
"=",
"tf",
".",
"concat",
"(",
"images",
",",
"axis",
"=",
"3",
")",
"max_tensor",
"=",
"fn",
"(",
"image_tensor",
",",
"axis",
"=",
"3",
")",
"return",
"max_tensor"
] | Pools for an area in features_2d.
Args:
features_2d: a Tensor in a shape of [batch_size, height, width, depth].
area_width: the max width allowed for an area.
area_height: the max height allowed for an area.
batch_size: the batch size.
width: the width of the memory.
height: the height of the memory.
depth: the depth of the features.
fn: the TF function for the pooling.
name: the op name.
Returns:
pool_tensor: A Tensor of shape [batch_size, num_areas, depth] | [
"Pools",
"for",
"an",
"area",
"in",
"features_2d",
"."
] | train | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/area_attention.py#L47-L75 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Pools for an area in features_2d.
Args:
features_2d: a Tensor in a shape of [batch_size, height, width, depth].
area_width: the max width allowed for an area.
area_height: the max height allowed for an area.
batch_size: the batch size.
width: the width of the memory.
height: the height of the memory.
depth: the depth of the features.
fn: the TF function for the pooling.
name: the op name.
Returns:
pool_tensor: A Tensor of shape [batch_size, num_areas, depth]
### Response:
def _pool_one_shape(features_2d, area_width, area_height, batch_size,
width, height, depth, fn=tf.reduce_max, name=None):
"""Pools for an area in features_2d.
Args:
features_2d: a Tensor in a shape of [batch_size, height, width, depth].
area_width: the max width allowed for an area.
area_height: the max height allowed for an area.
batch_size: the batch size.
width: the width of the memory.
height: the height of the memory.
depth: the depth of the features.
fn: the TF function for the pooling.
name: the op name.
Returns:
pool_tensor: A Tensor of shape [batch_size, num_areas, depth]
"""
with tf.name_scope(name, default_name="pool_one_shape"):
images = []
for y_shift in range(area_height):
image_height = tf.maximum(height - area_height + 1 + y_shift, 0)
for x_shift in range(area_width):
image_width = tf.maximum(width - area_width + 1 + x_shift, 0)
area = features_2d[:, y_shift:image_height, x_shift:image_width, :]
flatten_area = tf.reshape(area, [batch_size, -1, depth, 1])
images.append(flatten_area)
image_tensor = tf.concat(images, axis=3)
max_tensor = fn(image_tensor, axis=3)
return max_tensor
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
47,
6309,
369,
459,
3158,
304,
4519,
62,
17,
67,
382,
220,
18161,
512,
262,
4519,
62,
17,
67,
25,
264,
27127,
304,
264,
6211,
315,
510,
14377,
2424,
11,
2673,
11,
2430,
11,
8149,
27218,
262,
3158,
8086,
25,
279,
1973,
2430,
5535,
369,
459,
3158,
627,
262,
3158,
9755,
25,
279,
1973,
2673,
5535,
369,
459,
3158,
627,
262,
7309,
2424,
25,
279,
7309,
1404,
627,
262,
2430,
25,
279,
2430,
315,
279,
5044,
627,
262,
2673,
25,
279,
2673,
315,
279,
5044,
627,
262,
8149,
25,
279,
8149,
315,
279,
4519,
627,
262,
5279,
25,
279,
30245,
734,
369,
279,
75510,
627,
262,
836,
25,
279,
1200,
836,
627,
220,
5295,
512,
262,
7463,
24065,
25,
362,
27127,
315,
6211,
510,
14377,
2424,
11,
1661,
79672,
11,
8149,
2595,
14711,
6075,
512,
755,
721,
10497,
11929,
13911,
48652,
62,
17,
67,
11,
3158,
8086,
11,
3158,
9755,
11,
7309,
2424,
345,
504,
2430,
11,
2673,
11,
8149,
11,
5279,
34019,
24726,
6479,
11,
836,
5980,
997,
220,
4304,
47,
6309,
369,
459,
3158,
304,
4519,
62,
17,
67,
382,
220,
18161,
512,
262,
4519,
62,
17,
67,
25,
264,
27127,
304,
264,
6211,
315,
510,
14377,
2424,
11,
2673,
11,
2430,
11,
8149,
27218,
262,
3158,
8086,
25,
279,
1973,
2430,
5535,
369,
459,
3158,
627,
262,
3158,
9755,
25,
279,
1973,
2673,
5535,
369,
459,
3158,
627,
262,
7309,
2424,
25,
279,
7309,
1404,
627,
262,
2430,
25,
279,
2430,
315,
279,
5044,
627,
262,
2673,
25,
279,
2673,
315,
279,
5044,
627,
262,
8149,
25,
279,
8149,
315,
279,
4519,
627,
262,
5279,
25,
279,
30245,
734,
369,
279,
75510,
627,
262,
836,
25,
279,
1200,
836,
627,
220,
5295,
512,
262,
7463,
24065,
25,
362,
27127,
315,
6211,
510,
14377,
2424,
11,
1661,
79672,
11,
8149,
933,
220,
3270,
220,
449,
6543,
2710,
24077,
3232,
11,
1670,
1292,
429,
10497,
11929,
13911,
15497,
262,
5448,
284,
4260,
262,
369,
379,
23022,
304,
2134,
56802,
9755,
997,
415,
2217,
9755,
284,
6543,
59430,
23921,
482,
3158,
9755,
489,
220,
16,
489,
379,
23022,
11,
220,
15,
340,
415,
369,
865,
23022,
304,
2134,
56802,
8086,
997,
286,
2217,
8086,
284,
6543,
59430,
16830,
482,
3158,
8086,
489,
220,
16,
489,
865,
23022,
11,
220,
15,
340,
286,
3158,
284,
4519,
62,
17,
67,
9821,
379,
23022,
38770,
9755,
11,
865,
23022,
38770,
8086,
11,
67253,
286,
46443,
15380,
284,
6543,
23967,
56802,
11,
510,
14377,
2424,
11,
482,
16,
11,
8149,
11,
220,
16,
2608,
286,
5448,
2102,
50847,
14795,
15380,
340,
262,
2217,
24065,
284,
6543,
15614,
41977,
11,
8183,
28,
18,
340,
262,
1973,
24065,
284,
5279,
10281,
24065,
11,
8183,
28,
18,
340,
220,
471,
1973,
24065,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
47,
6309,
369,
459,
3158,
304,
4519,
62,
17,
67,
382,
220,
18161,
512,
262,
4519,
62,
17,
67,
25,
264,
27127,
304,
264,
6211,
315,
510,
14377,
2424,
11,
2673,
11,
2430,
11,
8149,
27218,
262,
3158,
8086,
25,
279,
1973,
2430,
5535,
369,
459,
3158,
627,
262,
3158,
9755,
25,
279,
1973,
2673,
5535,
369,
459,
3158,
627,
262,
7309,
2424,
25,
279,
7309,
1404,
627,
262,
2430,
25,
279,
2430,
315,
279,
5044,
627,
262,
2673,
25,
279,
2673,
315,
279,
5044,
627,
262,
8149,
25,
279,
8149,
315,
279,
4519,
627,
262,
5279,
25,
279,
30245,
734,
369,
279,
75510,
627,
262,
836,
25,
279,
1200,
836,
627,
220,
5295,
512,
262,
7463,
24065,
25,
362,
27127,
315,
6211,
510,
14377,
2424,
11,
1661,
79672,
11,
8149,
2595,
14711,
6075,
512,
755,
721,
10497,
11929,
13911,
48652,
62,
17,
67,
11,
3158,
8086,
11,
3158,
9755,
11,
7309,
2424,
345,
504,
2430,
11,
2673,
11,
8149,
11,
5279,
34019,
24726,
6479,
11,
836,
5980,
997,
220,
4304,
47,
6309,
369,
459,
3158,
304,
4519,
62,
17,
67,
382,
220,
18161,
512,
262,
4519,
62,
17,
67,
25,
264,
27127,
304,
264,
6211,
315,
510,
14377,
2424,
11,
2673,
11,
2430,
11,
8149,
27218,
262,
3158,
8086,
25,
279,
1973,
2430,
5535,
369,
459,
3158,
627,
262,
3158,
9755,
25,
279,
1973,
2673,
5535,
369,
459,
3158,
627,
262,
7309,
2424,
25,
279,
7309,
1404,
627,
262,
2430,
25,
279,
2430,
315,
279,
5044,
627,
262,
2673,
25,
279,
2673,
315,
279,
5044,
627,
262,
8149,
25,
279,
8149,
315,
279,
4519,
627,
262,
5279,
25,
279,
30245,
734,
369,
279,
75510,
627,
262,
836,
25,
279,
1200,
836,
627,
220,
5295,
512,
262,
7463,
24065,
25,
362,
27127,
315,
6211,
510,
14377,
2424,
11,
1661,
79672,
11,
8149,
933,
220,
3270,
220,
449,
6543,
2710,
24077,
3232,
11,
1670,
1292,
429,
10497,
11929,
13911,
15497,
262,
5448,
284,
4260,
262,
369,
379,
23022,
304,
2134,
56802,
9755,
997,
415,
2217,
9755,
284,
6543,
59430,
23921,
482,
3158,
9755,
489,
220,
16,
489,
379,
23022,
11,
220,
15,
340,
415,
369,
865,
23022,
304,
2134,
56802,
8086,
997,
286,
2217,
8086,
284,
6543,
59430,
16830,
482,
3158,
8086,
489,
220,
16,
489,
865,
23022,
11,
220,
15,
340,
286,
3158,
284,
4519,
62,
17,
67,
9821,
379,
23022,
38770,
9755,
11,
865,
23022,
38770,
8086,
11,
67253,
286,
46443,
15380,
284,
6543,
23967,
56802,
11,
510,
14377,
2424,
11,
482,
16,
11,
8149,
11,
220,
16,
2608,
286,
5448,
2102,
50847,
14795,
15380,
340,
262,
2217,
24065,
284,
6543,
15614,
41977,
11,
8183,
28,
18,
340,
262,
1973,
24065,
284,
5279,
10281,
24065,
11,
8183,
28,
18,
340,
220,
471,
1973,
24065,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
bitesofcode/projexui | projexui/widgets/xtimerlabel.py | XTimerLabel.reset | def reset(self):
"""
Stops the timer and resets its values to 0.
"""
self._elapsed = datetime.timedelta()
self._delta = datetime.timedelta()
self._starttime = datetime.datetime.now()
self.refresh() | python | def reset(self):
"""
Stops the timer and resets its values to 0.
"""
self._elapsed = datetime.timedelta()
self._delta = datetime.timedelta()
self._starttime = datetime.datetime.now()
self.refresh() | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_elapsed",
"=",
"datetime",
".",
"timedelta",
"(",
")",
"self",
".",
"_delta",
"=",
"datetime",
".",
"timedelta",
"(",
")",
"self",
".",
"_starttime",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"self",
".",
"refresh",
"(",
")"
] | Stops the timer and resets its values to 0. | [
"Stops",
"the",
"timer",
"and",
"resets",
"its",
"values",
"to",
"0",
"."
] | train | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtimerlabel.py#L157-L165 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Stops the timer and resets its values to 0.
### Response:
def reset(self):
"""
Stops the timer and resets its values to 0.
"""
self._elapsed = datetime.timedelta()
self._delta = datetime.timedelta()
self._starttime = datetime.datetime.now()
self.refresh()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
626,
3806,
279,
9198,
323,
67297,
1202,
2819,
311,
220,
15,
382,
14711,
6075,
512,
755,
7738,
1214,
5903,
286,
26547,
286,
90073,
279,
9198,
323,
67297,
1202,
2819,
311,
220,
15,
3304,
286,
26547,
286,
659,
1462,
54218,
284,
9050,
58939,
3652,
286,
659,
1462,
20869,
284,
9050,
58939,
3652,
286,
659,
1462,
89886,
284,
9050,
20296,
10930,
3652,
9175,
286,
659,
27122,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
626,
3806,
279,
9198,
323,
67297,
1202,
2819,
311,
220,
15,
382,
14711,
6075,
512,
755,
7738,
1214,
5903,
286,
26547,
286,
90073,
279,
9198,
323,
67297,
1202,
2819,
311,
220,
15,
3304,
286,
26547,
286,
659,
1462,
54218,
284,
9050,
58939,
3652,
286,
659,
1462,
20869,
284,
9050,
58939,
3652,
286,
659,
1462,
89886,
284,
9050,
20296,
10930,
3652,
9175,
286,
659,
27122,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pypa/pipenv | pipenv/vendor/urllib3/util/ssl_.py | resolve_ssl_version | def resolve_ssl_version(candidate):
"""
like resolve_cert_reqs
"""
if candidate is None:
return PROTOCOL_SSLv23
if isinstance(candidate, str):
res = getattr(ssl, candidate, None)
if res is None:
res = getattr(ssl, 'PROTOCOL_' + candidate)
return res
return candidate | python | def resolve_ssl_version(candidate):
"""
like resolve_cert_reqs
"""
if candidate is None:
return PROTOCOL_SSLv23
if isinstance(candidate, str):
res = getattr(ssl, candidate, None)
if res is None:
res = getattr(ssl, 'PROTOCOL_' + candidate)
return res
return candidate | [
"def",
"resolve_ssl_version",
"(",
"candidate",
")",
":",
"if",
"candidate",
"is",
"None",
":",
"return",
"PROTOCOL_SSLv23",
"if",
"isinstance",
"(",
"candidate",
",",
"str",
")",
":",
"res",
"=",
"getattr",
"(",
"ssl",
",",
"candidate",
",",
"None",
")",
"if",
"res",
"is",
"None",
":",
"res",
"=",
"getattr",
"(",
"ssl",
",",
"'PROTOCOL_'",
"+",
"candidate",
")",
"return",
"res",
"return",
"candidate"
] | like resolve_cert_reqs | [
"like",
"resolve_cert_reqs"
] | train | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/urllib3/util/ssl_.py#L213-L226 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
like resolve_cert_reqs
### Response:
def resolve_ssl_version(candidate):
"""
like resolve_cert_reqs
"""
if candidate is None:
return PROTOCOL_SSLv23
if isinstance(candidate, str):
res = getattr(ssl, candidate, None)
if res is None:
res = getattr(ssl, 'PROTOCOL_' + candidate)
return res
return candidate
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4908,
9006,
38197,
18110,
82,
271,
14711,
6075,
512,
755,
9006,
49310,
9625,
73121,
997,
262,
3270,
262,
1093,
9006,
38197,
18110,
82,
198,
262,
3270,
262,
422,
9322,
374,
2290,
512,
286,
471,
5421,
65094,
46537,
85,
1419,
271,
262,
422,
11656,
73121,
11,
610,
997,
286,
594,
284,
31097,
7,
25658,
11,
9322,
11,
2290,
340,
286,
422,
594,
374,
2290,
512,
310,
594,
284,
31097,
7,
25658,
11,
364,
9295,
65094,
19893,
489,
9322,
340,
286,
471,
594,
271,
262,
471,
9322,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4908,
9006,
38197,
18110,
82,
271,
14711,
6075,
512,
755,
9006,
49310,
9625,
73121,
997,
262,
3270,
262,
1093,
9006,
38197,
18110,
82,
198,
262,
3270,
262,
422,
9322,
374,
2290,
512,
286,
471,
5421,
65094,
46537,
85,
1419,
271,
262,
422,
11656,
73121,
11,
610,
997,
286,
594,
284,
31097,
7,
25658,
11,
9322,
11,
2290,
340,
286,
422,
594,
374,
2290,
512,
310,
594,
284,
31097,
7,
25658,
11,
364,
9295,
65094,
19893,
489,
9322,
340,
286,
471,
594,
271,
262,
471,
9322,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
mbj4668/pyang | pyang/yin_parser.py | YinParser.split_qname | def split_qname(qname):
"""Split `qname` into namespace URI and local name
Return namespace and local name as a tuple. This is a static
method."""
res = qname.split(YinParser.ns_sep)
if len(res) == 1: # no namespace
return None, res[0]
else:
return res | python | def split_qname(qname):
"""Split `qname` into namespace URI and local name
Return namespace and local name as a tuple. This is a static
method."""
res = qname.split(YinParser.ns_sep)
if len(res) == 1: # no namespace
return None, res[0]
else:
return res | [
"def",
"split_qname",
"(",
"qname",
")",
":",
"res",
"=",
"qname",
".",
"split",
"(",
"YinParser",
".",
"ns_sep",
")",
"if",
"len",
"(",
"res",
")",
"==",
"1",
":",
"# no namespace",
"return",
"None",
",",
"res",
"[",
"0",
"]",
"else",
":",
"return",
"res"
] | Split `qname` into namespace URI and local name
Return namespace and local name as a tuple. This is a static
method. | [
"Split",
"qname",
"into",
"namespace",
"URI",
"and",
"local",
"name"
] | train | https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/yin_parser.py#L55-L64 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Split `qname` into namespace URI and local name
Return namespace and local name as a tuple. This is a static
method.
### Response:
def split_qname(qname):
"""Split `qname` into namespace URI and local name
Return namespace and local name as a tuple. This is a static
method."""
res = qname.split(YinParser.ns_sep)
if len(res) == 1: # no namespace
return None, res[0]
else:
return res
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
20805,
1595,
80,
609,
63,
1139,
4573,
16403,
323,
2254,
836,
271,
286,
3494,
4573,
323,
2254,
836,
439,
264,
14743,
13,
1115,
374,
264,
1118,
198,
286,
1749,
382,
14711,
6075,
512,
755,
6859,
9153,
609,
10806,
609,
997,
286,
4304,
20805,
1595,
80,
609,
63,
1139,
4573,
16403,
323,
2254,
836,
271,
286,
3494,
4573,
323,
2254,
836,
439,
264,
14743,
13,
1115,
374,
264,
1118,
198,
286,
1749,
14781,
286,
594,
284,
2874,
609,
5402,
20818,
258,
6707,
53428,
55875,
340,
286,
422,
2479,
4693,
8,
624,
220,
16,
25,
996,
674,
912,
4573,
198,
310,
471,
2290,
11,
594,
58,
15,
933,
286,
775,
512,
310,
471,
594,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
20805,
1595,
80,
609,
63,
1139,
4573,
16403,
323,
2254,
836,
271,
286,
3494,
4573,
323,
2254,
836,
439,
264,
14743,
13,
1115,
374,
264,
1118,
198,
286,
1749,
382,
14711,
6075,
512,
755,
6859,
9153,
609,
10806,
609,
997,
286,
4304,
20805,
1595,
80,
609,
63,
1139,
4573,
16403,
323,
2254,
836,
271,
286,
3494,
4573,
323,
2254,
836,
439,
264,
14743,
13,
1115,
374,
264,
1118,
198,
286,
1749,
14781,
286,
594,
284,
2874,
609,
5402,
20818,
258,
6707,
53428,
55875,
340,
286,
422,
2479,
4693,
8,
624,
220,
16,
25,
996,
674,
912,
4573,
198,
310,
471,
2290,
11,
594,
58,
15,
933,
286,
775,
512,
310,
471,
594,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
chaoss/grimoirelab-sortinghat | sortinghat/db/api.py | add_identity | def add_identity(session, uidentity, identity_id, source,
name=None, email=None, username=None):
"""Add an identity to the session.
This function adds a new identity to the session using
`identity_id` as its identifier. The new identity will
also be linked to the unique identity object of `uidentity`.
Neither the values given to `identity_id` nor to `source` can
be `None` or empty. Moreover, `name`, `email` or `username`
parameters need a non empty value.
As a result, the function returns a new `Identity` object.
:param session: database session
:param uidentity: links the new identity to this unique identity object
:param identity_id: identifier for the new identity
:param source: data source where this identity was found
:param name: full name of the identity
:param email: email of the identity
:param username: user name used by the identity
:return: a new identity
:raises ValueError: when `identity_id` and `source` are `None` or empty;
when all of the data parameters are `None` or empty.
"""
if identity_id is None:
raise ValueError("'identity_id' cannot be None")
if identity_id == '':
raise ValueError("'identity_id' cannot be an empty string")
if source is None:
raise ValueError("'source' cannot be None")
if source == '':
raise ValueError("'source' cannot be an empty string")
if not (name or email or username):
raise ValueError("identity data cannot be None or empty")
identity = Identity(id=identity_id, name=name, email=email,
username=username, source=source)
identity.last_modified = datetime.datetime.utcnow()
identity.uidentity = uidentity
identity.uidentity.last_modified = identity.last_modified
session.add(identity)
return identity | python | def add_identity(session, uidentity, identity_id, source,
name=None, email=None, username=None):
"""Add an identity to the session.
This function adds a new identity to the session using
`identity_id` as its identifier. The new identity will
also be linked to the unique identity object of `uidentity`.
Neither the values given to `identity_id` nor to `source` can
be `None` or empty. Moreover, `name`, `email` or `username`
parameters need a non empty value.
As a result, the function returns a new `Identity` object.
:param session: database session
:param uidentity: links the new identity to this unique identity object
:param identity_id: identifier for the new identity
:param source: data source where this identity was found
:param name: full name of the identity
:param email: email of the identity
:param username: user name used by the identity
:return: a new identity
:raises ValueError: when `identity_id` and `source` are `None` or empty;
when all of the data parameters are `None` or empty.
"""
if identity_id is None:
raise ValueError("'identity_id' cannot be None")
if identity_id == '':
raise ValueError("'identity_id' cannot be an empty string")
if source is None:
raise ValueError("'source' cannot be None")
if source == '':
raise ValueError("'source' cannot be an empty string")
if not (name or email or username):
raise ValueError("identity data cannot be None or empty")
identity = Identity(id=identity_id, name=name, email=email,
username=username, source=source)
identity.last_modified = datetime.datetime.utcnow()
identity.uidentity = uidentity
identity.uidentity.last_modified = identity.last_modified
session.add(identity)
return identity | [
"def",
"add_identity",
"(",
"session",
",",
"uidentity",
",",
"identity_id",
",",
"source",
",",
"name",
"=",
"None",
",",
"email",
"=",
"None",
",",
"username",
"=",
"None",
")",
":",
"if",
"identity_id",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"'identity_id' cannot be None\"",
")",
"if",
"identity_id",
"==",
"''",
":",
"raise",
"ValueError",
"(",
"\"'identity_id' cannot be an empty string\"",
")",
"if",
"source",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"'source' cannot be None\"",
")",
"if",
"source",
"==",
"''",
":",
"raise",
"ValueError",
"(",
"\"'source' cannot be an empty string\"",
")",
"if",
"not",
"(",
"name",
"or",
"email",
"or",
"username",
")",
":",
"raise",
"ValueError",
"(",
"\"identity data cannot be None or empty\"",
")",
"identity",
"=",
"Identity",
"(",
"id",
"=",
"identity_id",
",",
"name",
"=",
"name",
",",
"email",
"=",
"email",
",",
"username",
"=",
"username",
",",
"source",
"=",
"source",
")",
"identity",
".",
"last_modified",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"identity",
".",
"uidentity",
"=",
"uidentity",
"identity",
".",
"uidentity",
".",
"last_modified",
"=",
"identity",
".",
"last_modified",
"session",
".",
"add",
"(",
"identity",
")",
"return",
"identity"
] | Add an identity to the session.
This function adds a new identity to the session using
`identity_id` as its identifier. The new identity will
also be linked to the unique identity object of `uidentity`.
Neither the values given to `identity_id` nor to `source` can
be `None` or empty. Moreover, `name`, `email` or `username`
parameters need a non empty value.
As a result, the function returns a new `Identity` object.
:param session: database session
:param uidentity: links the new identity to this unique identity object
:param identity_id: identifier for the new identity
:param source: data source where this identity was found
:param name: full name of the identity
:param email: email of the identity
:param username: user name used by the identity
:return: a new identity
:raises ValueError: when `identity_id` and `source` are `None` or empty;
when all of the data parameters are `None` or empty. | [
"Add",
"an",
"identity",
"to",
"the",
"session",
"."
] | train | https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/db/api.py#L184-L230 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Add an identity to the session.
This function adds a new identity to the session using
`identity_id` as its identifier. The new identity will
also be linked to the unique identity object of `uidentity`.
Neither the values given to `identity_id` nor to `source` can
be `None` or empty. Moreover, `name`, `email` or `username`
parameters need a non empty value.
As a result, the function returns a new `Identity` object.
:param session: database session
:param uidentity: links the new identity to this unique identity object
:param identity_id: identifier for the new identity
:param source: data source where this identity was found
:param name: full name of the identity
:param email: email of the identity
:param username: user name used by the identity
:return: a new identity
:raises ValueError: when `identity_id` and `source` are `None` or empty;
when all of the data parameters are `None` or empty.
### Response:
def add_identity(session, uidentity, identity_id, source,
name=None, email=None, username=None):
"""Add an identity to the session.
This function adds a new identity to the session using
`identity_id` as its identifier. The new identity will
also be linked to the unique identity object of `uidentity`.
Neither the values given to `identity_id` nor to `source` can
be `None` or empty. Moreover, `name`, `email` or `username`
parameters need a non empty value.
As a result, the function returns a new `Identity` object.
:param session: database session
:param uidentity: links the new identity to this unique identity object
:param identity_id: identifier for the new identity
:param source: data source where this identity was found
:param name: full name of the identity
:param email: email of the identity
:param username: user name used by the identity
:return: a new identity
:raises ValueError: when `identity_id` and `source` are `None` or empty;
when all of the data parameters are `None` or empty.
"""
if identity_id is None:
raise ValueError("'identity_id' cannot be None")
if identity_id == '':
raise ValueError("'identity_id' cannot be an empty string")
if source is None:
raise ValueError("'source' cannot be None")
if source == '':
raise ValueError("'source' cannot be an empty string")
if not (name or email or username):
raise ValueError("identity data cannot be None or empty")
identity = Identity(id=identity_id, name=name, email=email,
username=username, source=source)
identity.last_modified = datetime.datetime.utcnow()
identity.uidentity = uidentity
identity.uidentity.last_modified = identity.last_modified
session.add(identity)
return identity
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2261,
459,
9764,
311,
279,
3882,
382,
262,
1115,
734,
11621,
264,
502,
9764,
311,
279,
3882,
1701,
198,
262,
1595,
17341,
851,
63,
439,
1202,
13110,
13,
578,
502,
9764,
690,
198,
262,
1101,
387,
10815,
311,
279,
5016,
9764,
1665,
315,
1595,
84,
17341,
63438,
262,
25215,
279,
2819,
2728,
311,
1595,
17341,
851,
63,
6463,
311,
1595,
2484,
63,
649,
198,
262,
387,
1595,
4155,
63,
477,
4384,
13,
23674,
11,
1595,
609,
7964,
1595,
2386,
63,
477,
1595,
5223,
4077,
262,
5137,
1205,
264,
2536,
4384,
907,
382,
262,
1666,
264,
1121,
11,
279,
734,
4780,
264,
502,
1595,
19069,
63,
1665,
382,
262,
551,
913,
3882,
25,
4729,
3882,
198,
262,
551,
913,
577,
17341,
25,
7902,
279,
502,
9764,
311,
420,
5016,
9764,
1665,
198,
262,
551,
913,
9764,
851,
25,
13110,
369,
279,
502,
9764,
198,
262,
551,
913,
2592,
25,
828,
2592,
1405,
420,
9764,
574,
1766,
198,
262,
551,
913,
836,
25,
2539,
836,
315,
279,
9764,
198,
262,
551,
913,
2613,
25,
2613,
315,
279,
9764,
198,
262,
551,
913,
6059,
25,
1217,
836,
1511,
555,
279,
9764,
271,
262,
551,
693,
25,
264,
502,
9764,
271,
262,
551,
33371,
15764,
25,
994,
1595,
17341,
851,
63,
323,
1595,
2484,
63,
527,
1595,
4155,
63,
477,
4384,
280,
286,
994,
682,
315,
279,
828,
5137,
527,
1595,
4155,
63,
477,
4384,
382,
14711,
6075,
512,
755,
923,
47344,
16663,
11,
577,
17341,
11,
9764,
851,
11,
2592,
345,
338,
836,
5980,
11,
2613,
5980,
11,
6059,
5980,
997,
262,
4304,
2261,
459,
9764,
311,
279,
3882,
382,
262,
1115,
734,
11621,
264,
502,
9764,
311,
279,
3882,
1701,
198,
262,
1595,
17341,
851,
63,
439,
1202,
13110,
13,
578,
502,
9764,
690,
198,
262,
1101,
387,
10815,
311,
279,
5016,
9764,
1665,
315,
1595,
84,
17341,
63438,
262,
25215,
279,
2819,
2728,
311,
1595,
17341,
851,
63,
6463,
311,
1595,
2484,
63,
649,
198,
262,
387,
1595,
4155,
63,
477,
4384,
13,
23674,
11,
1595,
609,
7964,
1595,
2386,
63,
477,
1595,
5223,
4077,
262,
5137,
1205,
264,
2536,
4384,
907,
382,
262,
1666,
264,
1121,
11,
279,
734,
4780,
264,
502,
1595,
19069,
63,
1665,
382,
262,
551,
913,
3882,
25,
4729,
3882,
198,
262,
551,
913,
577,
17341,
25,
7902,
279,
502,
9764,
311,
420,
5016,
9764,
1665,
198,
262,
551,
913,
9764,
851,
25,
13110,
369,
279,
502,
9764,
198,
262,
551,
913,
2592,
25,
828,
2592,
1405,
420,
9764,
574,
1766,
198,
262,
551,
913,
836,
25,
2539,
836,
315,
279,
9764,
198,
262,
551,
913,
2613,
25,
2613,
315,
279,
9764,
198,
262,
551,
913,
6059,
25,
1217,
836,
1511,
555,
279,
9764,
271,
262,
551,
693,
25,
264,
502,
9764,
271,
262,
551,
33371,
15764,
25,
994,
1595,
17341,
851,
63,
323,
1595,
2484,
63,
527,
1595
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2261,
459,
9764,
311,
279,
3882,
382,
262,
1115,
734,
11621,
264,
502,
9764,
311,
279,
3882,
1701,
198,
262,
1595,
17341,
851,
63,
439,
1202,
13110,
13,
578,
502,
9764,
690,
198,
262,
1101,
387,
10815,
311,
279,
5016,
9764,
1665,
315,
1595,
84,
17341,
63438,
262,
25215,
279,
2819,
2728,
311,
1595,
17341,
851,
63,
6463,
311,
1595,
2484,
63,
649,
198,
262,
387,
1595,
4155,
63,
477,
4384,
13,
23674,
11,
1595,
609,
7964,
1595,
2386,
63,
477,
1595,
5223,
4077,
262,
5137,
1205,
264,
2536,
4384,
907,
382,
262,
1666,
264,
1121,
11,
279,
734,
4780,
264,
502,
1595,
19069,
63,
1665,
382,
262,
551,
913,
3882,
25,
4729,
3882,
198,
262,
551,
913,
577,
17341,
25,
7902,
279,
502,
9764,
311,
420,
5016,
9764,
1665,
198,
262,
551,
913,
9764,
851,
25,
13110,
369,
279,
502,
9764,
198,
262,
551,
913,
2592,
25,
828,
2592,
1405,
420,
9764,
574,
1766,
198,
262,
551,
913,
836,
25,
2539,
836,
315,
279,
9764,
198,
262,
551,
913,
2613,
25,
2613,
315,
279,
9764,
198,
262,
551,
913,
6059,
25,
1217,
836,
1511,
555,
279,
9764,
271,
262,
551,
693,
25,
264,
502,
9764,
271,
262,
551,
33371,
15764,
25,
994,
1595,
17341,
851,
63,
323,
1595,
2484,
63,
527,
1595,
4155,
63,
477,
4384,
280,
286,
994,
682,
315,
279,
828,
5137,
527,
1595,
4155,
63,
477,
4384,
382,
14711,
6075,
512,
755,
923,
47344,
16663,
11,
577,
17341,
11,
9764,
851,
11,
2592,
345,
338,
836,
5980,
11,
2613,
5980,
11,
6059,
5980,
997,
262,
4304,
2261,
459,
9764,
311,
279,
3882,
382,
262,
1115,
734,
11621,
264,
502,
9764,
311,
279,
3882,
1701,
198,
262,
1595,
17341,
851,
63,
439,
1202,
13110,
13,
578,
502,
9764,
690,
198,
262,
1101,
387,
10815,
311,
279,
5016,
9764,
1665,
315,
1595,
84,
17341,
63438,
262,
25215,
279,
2819,
2728,
311,
1595,
17341,
851,
63,
6463,
311,
1595,
2484,
63,
649,
198,
262,
387,
1595,
4155,
63,
477,
4384,
13,
23674,
11,
1595,
609,
7964,
1595,
2386,
63,
477,
1595,
5223,
4077,
262,
5137,
1205,
264,
2536,
4384,
907,
382,
262,
1666,
264,
1121,
11,
279,
734,
4780,
264,
502,
1595,
19069,
63,
1665,
382,
262,
551,
913,
3882,
25,
4729,
3882,
198,
262,
551,
913,
577,
17341,
25,
7902,
279,
502,
9764,
311,
420,
5016,
9764,
1665,
198,
262,
551,
913,
9764,
851,
25,
13110,
369,
279,
502,
9764,
198,
262,
551,
913,
2592,
25,
828,
2592,
1405,
420,
9764,
574,
1766,
198,
262,
551,
913,
836,
25,
2539,
836,
315,
279,
9764,
198,
262,
551,
913,
2613,
25,
2613,
315,
279,
9764,
198,
262,
551,
913,
6059,
25,
1217,
836,
1511,
555,
279,
9764,
271,
262,
551,
693,
25,
264,
502,
9764,
271,
262,
551,
33371,
15764,
25,
994,
1595,
17341,
851,
63,
323,
1595,
2484,
63,
527,
1595
] |
clalancette/pycdlib | pycdlib/dr.py | DirectoryRecord._rr_new | def _rr_new(self, rr_version, rr_name, rr_symlink_target, rr_relocated_child,
rr_relocated, rr_relocated_parent, file_mode):
# type: (str, bytes, bytes, bool, bool, bool, int) -> None
'''
Internal method to add Rock Ridge to a Directory Record.
Parameters:
rr_version - A string containing the version of Rock Ridge to use for
this record.
rr_name - The Rock Ridge name to associate with this directory record.
rr_symlink_target - The target for the symlink, if this is a symlink
record (otherwise, None).
rr_relocated_child - True if this is a directory record for a rock
ridge relocated child.
rr_relocated - True if this is a directory record for a relocated
entry.
rr_relocated_parent - True if this is a directory record for a rock
ridge relocated parent.
file_mode - The Unix file mode for this Rock Ridge entry.
Returns:
Nothing.
'''
if self.parent is None:
raise pycdlibexception.PyCdlibInternalError('Invalid call to create new Rock Ridge on root directory')
self.rock_ridge = rockridge.RockRidge()
is_first_dir_record_of_root = self.file_ident == b'\x00' and self.parent.is_root
bytes_to_skip = 0
if self.xa_record is not None:
bytes_to_skip = XARecord.length()
self.dr_len = self.rock_ridge.new(is_first_dir_record_of_root, rr_name,
file_mode, rr_symlink_target,
rr_version, rr_relocated_child,
rr_relocated, rr_relocated_parent,
bytes_to_skip, self.dr_len)
# For files, we are done
if not self.isdir:
return
# If this is a directory, we have to manipulate the file links
# appropriately.
if self.parent.is_root:
if self.file_ident == b'\x00' or self.file_ident == b'\x01':
# For the dot and dotdot children of the root, add one
# directly to their Rock Ridge links.
self.rock_ridge.add_to_file_links()
else:
# For all other children of the root, make sure to add one
# to each of the dot and dotdot entries.
if len(self.parent.children) < 2:
raise pycdlibexception.PyCdlibInvalidISO('Expected at least 2 children of the root directory record, saw %d' % (len(self.parent.children)))
if self.parent.children[0].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Dot child of directory has no Rock Ridge; ISO is corrupt')
self.parent.children[0].rock_ridge.add_to_file_links()
if self.parent.children[1].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Dot-dot child of directory has no Rock Ridge; ISO is corrupt')
self.parent.children[1].rock_ridge.add_to_file_links()
else:
if self.parent.rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Parent of the entry did not have Rock Ridge, ISO is corrupt')
if self.file_ident == b'\x00':
# If we are adding the dot directory, increment the parent
# file links and our file links.
self.parent.rock_ridge.add_to_file_links()
self.rock_ridge.add_to_file_links()
elif self.file_ident == b'\x01':
# If we are adding the dotdot directory, copy the file links
# from the dot directory of the grandparent.
if self.parent.parent is None:
raise pycdlibexception.PyCdlibInternalError('Grandparent of the entry did not exist; this cannot be')
if not self.parent.children:
raise pycdlibexception.PyCdlibInvalidISO('Grandparent of the entry did not have a dot entry; ISO is corrupt')
if self.parent.parent.children[0].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Grandparent dotdot entry did not have Rock Ridge; ISO is corrupt')
self.rock_ridge.copy_file_links(self.parent.parent.children[0].rock_ridge)
else:
# For all other entries, increment the parents file links
# and the parents dot file links.
self.parent.rock_ridge.add_to_file_links()
if not self.parent.children:
raise pycdlibexception.PyCdlibInvalidISO('Parent of the entry did not have a dot entry; ISO is corrupt')
if self.parent.children[0].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Dot child of the parent did not have a dot entry; ISO is corrupt')
self.parent.children[0].rock_ridge.add_to_file_links() | python | def _rr_new(self, rr_version, rr_name, rr_symlink_target, rr_relocated_child,
rr_relocated, rr_relocated_parent, file_mode):
# type: (str, bytes, bytes, bool, bool, bool, int) -> None
'''
Internal method to add Rock Ridge to a Directory Record.
Parameters:
rr_version - A string containing the version of Rock Ridge to use for
this record.
rr_name - The Rock Ridge name to associate with this directory record.
rr_symlink_target - The target for the symlink, if this is a symlink
record (otherwise, None).
rr_relocated_child - True if this is a directory record for a rock
ridge relocated child.
rr_relocated - True if this is a directory record for a relocated
entry.
rr_relocated_parent - True if this is a directory record for a rock
ridge relocated parent.
file_mode - The Unix file mode for this Rock Ridge entry.
Returns:
Nothing.
'''
if self.parent is None:
raise pycdlibexception.PyCdlibInternalError('Invalid call to create new Rock Ridge on root directory')
self.rock_ridge = rockridge.RockRidge()
is_first_dir_record_of_root = self.file_ident == b'\x00' and self.parent.is_root
bytes_to_skip = 0
if self.xa_record is not None:
bytes_to_skip = XARecord.length()
self.dr_len = self.rock_ridge.new(is_first_dir_record_of_root, rr_name,
file_mode, rr_symlink_target,
rr_version, rr_relocated_child,
rr_relocated, rr_relocated_parent,
bytes_to_skip, self.dr_len)
# For files, we are done
if not self.isdir:
return
# If this is a directory, we have to manipulate the file links
# appropriately.
if self.parent.is_root:
if self.file_ident == b'\x00' or self.file_ident == b'\x01':
# For the dot and dotdot children of the root, add one
# directly to their Rock Ridge links.
self.rock_ridge.add_to_file_links()
else:
# For all other children of the root, make sure to add one
# to each of the dot and dotdot entries.
if len(self.parent.children) < 2:
raise pycdlibexception.PyCdlibInvalidISO('Expected at least 2 children of the root directory record, saw %d' % (len(self.parent.children)))
if self.parent.children[0].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Dot child of directory has no Rock Ridge; ISO is corrupt')
self.parent.children[0].rock_ridge.add_to_file_links()
if self.parent.children[1].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Dot-dot child of directory has no Rock Ridge; ISO is corrupt')
self.parent.children[1].rock_ridge.add_to_file_links()
else:
if self.parent.rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Parent of the entry did not have Rock Ridge, ISO is corrupt')
if self.file_ident == b'\x00':
# If we are adding the dot directory, increment the parent
# file links and our file links.
self.parent.rock_ridge.add_to_file_links()
self.rock_ridge.add_to_file_links()
elif self.file_ident == b'\x01':
# If we are adding the dotdot directory, copy the file links
# from the dot directory of the grandparent.
if self.parent.parent is None:
raise pycdlibexception.PyCdlibInternalError('Grandparent of the entry did not exist; this cannot be')
if not self.parent.children:
raise pycdlibexception.PyCdlibInvalidISO('Grandparent of the entry did not have a dot entry; ISO is corrupt')
if self.parent.parent.children[0].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Grandparent dotdot entry did not have Rock Ridge; ISO is corrupt')
self.rock_ridge.copy_file_links(self.parent.parent.children[0].rock_ridge)
else:
# For all other entries, increment the parents file links
# and the parents dot file links.
self.parent.rock_ridge.add_to_file_links()
if not self.parent.children:
raise pycdlibexception.PyCdlibInvalidISO('Parent of the entry did not have a dot entry; ISO is corrupt')
if self.parent.children[0].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Dot child of the parent did not have a dot entry; ISO is corrupt')
self.parent.children[0].rock_ridge.add_to_file_links() | [
"def",
"_rr_new",
"(",
"self",
",",
"rr_version",
",",
"rr_name",
",",
"rr_symlink_target",
",",
"rr_relocated_child",
",",
"rr_relocated",
",",
"rr_relocated_parent",
",",
"file_mode",
")",
":",
"# type: (str, bytes, bytes, bool, bool, bool, int) -> None",
"if",
"self",
".",
"parent",
"is",
"None",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Invalid call to create new Rock Ridge on root directory'",
")",
"self",
".",
"rock_ridge",
"=",
"rockridge",
".",
"RockRidge",
"(",
")",
"is_first_dir_record_of_root",
"=",
"self",
".",
"file_ident",
"==",
"b'\\x00'",
"and",
"self",
".",
"parent",
".",
"is_root",
"bytes_to_skip",
"=",
"0",
"if",
"self",
".",
"xa_record",
"is",
"not",
"None",
":",
"bytes_to_skip",
"=",
"XARecord",
".",
"length",
"(",
")",
"self",
".",
"dr_len",
"=",
"self",
".",
"rock_ridge",
".",
"new",
"(",
"is_first_dir_record_of_root",
",",
"rr_name",
",",
"file_mode",
",",
"rr_symlink_target",
",",
"rr_version",
",",
"rr_relocated_child",
",",
"rr_relocated",
",",
"rr_relocated_parent",
",",
"bytes_to_skip",
",",
"self",
".",
"dr_len",
")",
"# For files, we are done",
"if",
"not",
"self",
".",
"isdir",
":",
"return",
"# If this is a directory, we have to manipulate the file links",
"# appropriately.",
"if",
"self",
".",
"parent",
".",
"is_root",
":",
"if",
"self",
".",
"file_ident",
"==",
"b'\\x00'",
"or",
"self",
".",
"file_ident",
"==",
"b'\\x01'",
":",
"# For the dot and dotdot children of the root, add one",
"# directly to their Rock Ridge links.",
"self",
".",
"rock_ridge",
".",
"add_to_file_links",
"(",
")",
"else",
":",
"# For all other children of the root, make sure to add one",
"# to each of the dot and dotdot entries.",
"if",
"len",
"(",
"self",
".",
"parent",
".",
"children",
")",
"<",
"2",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Expected at least 2 children of the root directory record, saw %d'",
"%",
"(",
"len",
"(",
"self",
".",
"parent",
".",
"children",
")",
")",
")",
"if",
"self",
".",
"parent",
".",
"children",
"[",
"0",
"]",
".",
"rock_ridge",
"is",
"None",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Dot child of directory has no Rock Ridge; ISO is corrupt'",
")",
"self",
".",
"parent",
".",
"children",
"[",
"0",
"]",
".",
"rock_ridge",
".",
"add_to_file_links",
"(",
")",
"if",
"self",
".",
"parent",
".",
"children",
"[",
"1",
"]",
".",
"rock_ridge",
"is",
"None",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Dot-dot child of directory has no Rock Ridge; ISO is corrupt'",
")",
"self",
".",
"parent",
".",
"children",
"[",
"1",
"]",
".",
"rock_ridge",
".",
"add_to_file_links",
"(",
")",
"else",
":",
"if",
"self",
".",
"parent",
".",
"rock_ridge",
"is",
"None",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Parent of the entry did not have Rock Ridge, ISO is corrupt'",
")",
"if",
"self",
".",
"file_ident",
"==",
"b'\\x00'",
":",
"# If we are adding the dot directory, increment the parent",
"# file links and our file links.",
"self",
".",
"parent",
".",
"rock_ridge",
".",
"add_to_file_links",
"(",
")",
"self",
".",
"rock_ridge",
".",
"add_to_file_links",
"(",
")",
"elif",
"self",
".",
"file_ident",
"==",
"b'\\x01'",
":",
"# If we are adding the dotdot directory, copy the file links",
"# from the dot directory of the grandparent.",
"if",
"self",
".",
"parent",
".",
"parent",
"is",
"None",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'Grandparent of the entry did not exist; this cannot be'",
")",
"if",
"not",
"self",
".",
"parent",
".",
"children",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Grandparent of the entry did not have a dot entry; ISO is corrupt'",
")",
"if",
"self",
".",
"parent",
".",
"parent",
".",
"children",
"[",
"0",
"]",
".",
"rock_ridge",
"is",
"None",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Grandparent dotdot entry did not have Rock Ridge; ISO is corrupt'",
")",
"self",
".",
"rock_ridge",
".",
"copy_file_links",
"(",
"self",
".",
"parent",
".",
"parent",
".",
"children",
"[",
"0",
"]",
".",
"rock_ridge",
")",
"else",
":",
"# For all other entries, increment the parents file links",
"# and the parents dot file links.",
"self",
".",
"parent",
".",
"rock_ridge",
".",
"add_to_file_links",
"(",
")",
"if",
"not",
"self",
".",
"parent",
".",
"children",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Parent of the entry did not have a dot entry; ISO is corrupt'",
")",
"if",
"self",
".",
"parent",
".",
"children",
"[",
"0",
"]",
".",
"rock_ridge",
"is",
"None",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInvalidISO",
"(",
"'Dot child of the parent did not have a dot entry; ISO is corrupt'",
")",
"self",
".",
"parent",
".",
"children",
"[",
"0",
"]",
".",
"rock_ridge",
".",
"add_to_file_links",
"(",
")"
] | Internal method to add Rock Ridge to a Directory Record.
Parameters:
rr_version - A string containing the version of Rock Ridge to use for
this record.
rr_name - The Rock Ridge name to associate with this directory record.
rr_symlink_target - The target for the symlink, if this is a symlink
record (otherwise, None).
rr_relocated_child - True if this is a directory record for a rock
ridge relocated child.
rr_relocated - True if this is a directory record for a relocated
entry.
rr_relocated_parent - True if this is a directory record for a rock
ridge relocated parent.
file_mode - The Unix file mode for this Rock Ridge entry.
Returns:
Nothing. | [
"Internal",
"method",
"to",
"add",
"Rock",
"Ridge",
"to",
"a",
"Directory",
"Record",
"."
] | train | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/dr.py#L311-L400 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Internal method to add Rock Ridge to a Directory Record.
Parameters:
rr_version - A string containing the version of Rock Ridge to use for
this record.
rr_name - The Rock Ridge name to associate with this directory record.
rr_symlink_target - The target for the symlink, if this is a symlink
record (otherwise, None).
rr_relocated_child - True if this is a directory record for a rock
ridge relocated child.
rr_relocated - True if this is a directory record for a relocated
entry.
rr_relocated_parent - True if this is a directory record for a rock
ridge relocated parent.
file_mode - The Unix file mode for this Rock Ridge entry.
Returns:
Nothing.
### Response:
def _rr_new(self, rr_version, rr_name, rr_symlink_target, rr_relocated_child,
rr_relocated, rr_relocated_parent, file_mode):
# type: (str, bytes, bytes, bool, bool, bool, int) -> None
'''
Internal method to add Rock Ridge to a Directory Record.
Parameters:
rr_version - A string containing the version of Rock Ridge to use for
this record.
rr_name - The Rock Ridge name to associate with this directory record.
rr_symlink_target - The target for the symlink, if this is a symlink
record (otherwise, None).
rr_relocated_child - True if this is a directory record for a rock
ridge relocated child.
rr_relocated - True if this is a directory record for a relocated
entry.
rr_relocated_parent - True if this is a directory record for a rock
ridge relocated parent.
file_mode - The Unix file mode for this Rock Ridge entry.
Returns:
Nothing.
'''
if self.parent is None:
raise pycdlibexception.PyCdlibInternalError('Invalid call to create new Rock Ridge on root directory')
self.rock_ridge = rockridge.RockRidge()
is_first_dir_record_of_root = self.file_ident == b'\x00' and self.parent.is_root
bytes_to_skip = 0
if self.xa_record is not None:
bytes_to_skip = XARecord.length()
self.dr_len = self.rock_ridge.new(is_first_dir_record_of_root, rr_name,
file_mode, rr_symlink_target,
rr_version, rr_relocated_child,
rr_relocated, rr_relocated_parent,
bytes_to_skip, self.dr_len)
# For files, we are done
if not self.isdir:
return
# If this is a directory, we have to manipulate the file links
# appropriately.
if self.parent.is_root:
if self.file_ident == b'\x00' or self.file_ident == b'\x01':
# For the dot and dotdot children of the root, add one
# directly to their Rock Ridge links.
self.rock_ridge.add_to_file_links()
else:
# For all other children of the root, make sure to add one
# to each of the dot and dotdot entries.
if len(self.parent.children) < 2:
raise pycdlibexception.PyCdlibInvalidISO('Expected at least 2 children of the root directory record, saw %d' % (len(self.parent.children)))
if self.parent.children[0].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Dot child of directory has no Rock Ridge; ISO is corrupt')
self.parent.children[0].rock_ridge.add_to_file_links()
if self.parent.children[1].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Dot-dot child of directory has no Rock Ridge; ISO is corrupt')
self.parent.children[1].rock_ridge.add_to_file_links()
else:
if self.parent.rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Parent of the entry did not have Rock Ridge, ISO is corrupt')
if self.file_ident == b'\x00':
# If we are adding the dot directory, increment the parent
# file links and our file links.
self.parent.rock_ridge.add_to_file_links()
self.rock_ridge.add_to_file_links()
elif self.file_ident == b'\x01':
# If we are adding the dotdot directory, copy the file links
# from the dot directory of the grandparent.
if self.parent.parent is None:
raise pycdlibexception.PyCdlibInternalError('Grandparent of the entry did not exist; this cannot be')
if not self.parent.children:
raise pycdlibexception.PyCdlibInvalidISO('Grandparent of the entry did not have a dot entry; ISO is corrupt')
if self.parent.parent.children[0].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Grandparent dotdot entry did not have Rock Ridge; ISO is corrupt')
self.rock_ridge.copy_file_links(self.parent.parent.children[0].rock_ridge)
else:
# For all other entries, increment the parents file links
# and the parents dot file links.
self.parent.rock_ridge.add_to_file_links()
if not self.parent.children:
raise pycdlibexception.PyCdlibInvalidISO('Parent of the entry did not have a dot entry; ISO is corrupt')
if self.parent.children[0].rock_ridge is None:
raise pycdlibexception.PyCdlibInvalidISO('Dot child of the parent did not have a dot entry; ISO is corrupt')
self.parent.children[0].rock_ridge.add_to_file_links()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
11830,
1749,
311,
923,
9305,
35305,
311,
264,
18524,
13896,
382,
286,
13831,
512,
260,
35493,
9625,
482,
362,
925,
8649,
279,
2373,
315,
9305,
35305,
311,
1005,
369,
198,
2611,
420,
3335,
627,
260,
35493,
1292,
482,
578,
9305,
35305,
836,
311,
22712,
449,
420,
6352,
3335,
627,
260,
35493,
59630,
45343,
11370,
482,
578,
2218,
369,
279,
84321,
11,
422,
420,
374,
264,
84321,
198,
6663,
3335,
320,
61036,
11,
2290,
4390,
260,
35493,
1311,
40563,
17716,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
7091,
198,
4700,
58933,
70209,
1716,
627,
260,
35493,
1311,
40563,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
70209,
198,
667,
4441,
627,
260,
35493,
1311,
40563,
16340,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
7091,
198,
7714,
58933,
70209,
2748,
627,
260,
1052,
7450,
482,
578,
48095,
1052,
3941,
369,
420,
9305,
35305,
4441,
627,
286,
5295,
512,
260,
12334,
382,
14711,
6075,
512,
755,
721,
637,
6046,
1214,
11,
35493,
9625,
11,
35493,
1292,
11,
35493,
59630,
45343,
11370,
11,
35493,
1311,
40563,
17716,
345,
394,
35493,
1311,
40563,
11,
35493,
1311,
40563,
16340,
11,
1052,
7450,
997,
286,
674,
955,
25,
320,
496,
11,
5943,
11,
5943,
11,
1845,
11,
1845,
11,
1845,
11,
528,
8,
1492,
2290,
198,
286,
11414,
286,
15774,
1749,
311,
923,
9305,
35305,
311,
264,
18524,
13896,
382,
286,
13831,
512,
260,
35493,
9625,
482,
362,
925,
8649,
279,
2373,
315,
9305,
35305,
311,
1005,
369,
198,
2611,
420,
3335,
627,
260,
35493,
1292,
482,
578,
9305,
35305,
836,
311,
22712,
449,
420,
6352,
3335,
627,
260,
35493,
59630,
45343,
11370,
482,
578,
2218,
369,
279,
84321,
11,
422,
420,
374,
264,
84321,
198,
6663,
3335,
320,
61036,
11,
2290,
4390,
260,
35493,
1311,
40563,
17716,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
7091,
198,
4700,
58933,
70209,
1716,
627,
260,
35493,
1311,
40563,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
70209,
198,
667,
4441,
627,
260,
35493,
1311,
40563,
16340,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
7091,
198,
7714,
58933,
70209,
2748,
627,
260,
1052,
7450,
482,
578,
48095,
1052,
3941,
369,
420,
9305,
35305,
4441,
627,
286,
5295,
512,
260,
12334,
627,
286,
45832,
286,
422,
659,
8829,
374,
2290,
512,
310,
4933,
281,
3418,
67,
2808,
7959,
1087,
88,
91300,
2808,
11830,
1480,
493,
8087,
1650,
311,
1893,
502,
9305,
35305,
389,
3789,
6352,
4713,
286,
659,
13,
21161,
1745,
6614,
284,
7091,
11431,
2056,
1197,
49,
6614,
746,
286,
374,
13275,
4432,
14526,
3659,
13290,
284,
659,
9914,
39499,
624,
293,
16154,
87,
410,
6,
323,
659,
8829,
2124,
13290,
198,
286,
5943,
2401,
45930,
284,
220,
15,
198,
286,
422,
659,
2036,
64,
14526,
374,
539,
2290,
512,
310,
5943,
2401,
45930,
284,
1630,
32
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
11830,
1749,
311,
923,
9305,
35305,
311,
264,
18524,
13896,
382,
286,
13831,
512,
260,
35493,
9625,
482,
362,
925,
8649,
279,
2373,
315,
9305,
35305,
311,
1005,
369,
198,
2611,
420,
3335,
627,
260,
35493,
1292,
482,
578,
9305,
35305,
836,
311,
22712,
449,
420,
6352,
3335,
627,
260,
35493,
59630,
45343,
11370,
482,
578,
2218,
369,
279,
84321,
11,
422,
420,
374,
264,
84321,
198,
6663,
3335,
320,
61036,
11,
2290,
4390,
260,
35493,
1311,
40563,
17716,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
7091,
198,
4700,
58933,
70209,
1716,
627,
260,
35493,
1311,
40563,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
70209,
198,
667,
4441,
627,
260,
35493,
1311,
40563,
16340,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
7091,
198,
7714,
58933,
70209,
2748,
627,
260,
1052,
7450,
482,
578,
48095,
1052,
3941,
369,
420,
9305,
35305,
4441,
627,
286,
5295,
512,
260,
12334,
382,
14711,
6075,
512,
755,
721,
637,
6046,
1214,
11,
35493,
9625,
11,
35493,
1292,
11,
35493,
59630,
45343,
11370,
11,
35493,
1311,
40563,
17716,
345,
394,
35493,
1311,
40563,
11,
35493,
1311,
40563,
16340,
11,
1052,
7450,
997,
286,
674,
955,
25,
320,
496,
11,
5943,
11,
5943,
11,
1845,
11,
1845,
11,
1845,
11,
528,
8,
1492,
2290,
198,
286,
11414,
286,
15774,
1749,
311,
923,
9305,
35305,
311,
264,
18524,
13896,
382,
286,
13831,
512,
260,
35493,
9625,
482,
362,
925,
8649,
279,
2373,
315,
9305,
35305,
311,
1005,
369,
198,
2611,
420,
3335,
627,
260,
35493,
1292,
482,
578,
9305,
35305,
836,
311,
22712,
449,
420,
6352,
3335,
627,
260,
35493,
59630,
45343,
11370,
482,
578,
2218,
369,
279,
84321,
11,
422,
420,
374,
264,
84321,
198,
6663,
3335,
320,
61036,
11,
2290,
4390,
260,
35493,
1311,
40563,
17716,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
7091,
198,
4700,
58933,
70209,
1716,
627,
260,
35493,
1311,
40563,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
70209,
198,
667,
4441,
627,
260,
35493,
1311,
40563,
16340,
482,
3082,
422,
420,
374,
264,
6352,
3335,
369,
264,
7091,
198,
7714,
58933,
70209,
2748,
627,
260,
1052,
7450,
482,
578,
48095,
1052,
3941,
369,
420,
9305,
35305,
4441,
627,
286,
5295,
512,
260,
12334,
627,
286,
45832,
286,
422,
659,
8829,
374,
2290,
512,
310,
4933,
281,
3418,
67,
2808,
7959,
1087,
88,
91300,
2808,
11830,
1480,
493,
8087,
1650,
311,
1893,
502,
9305,
35305,
389,
3789,
6352,
4713,
286,
659,
13,
21161,
1745,
6614,
284,
7091,
11431,
2056,
1197,
49,
6614,
746,
286,
374,
13275,
4432,
14526,
3659,
13290,
284,
659,
9914,
39499,
624,
293,
16154,
87,
410,
6,
323,
659,
8829,
2124,
13290,
198,
286,
5943,
2401,
45930,
284,
220,
15,
198,
286,
422,
659,
2036,
64,
14526,
374,
539,
2290,
512,
310,
5943,
2401,
45930,
284,
1630,
32
] |
bradrf/configstruct | configstruct/section_struct.py | SectionStruct.might_prefer | def might_prefer(self, **items):
'''Items to take precedence if their values are not None (never saved)'''
self._overrides = dict((k, v) for (k, v) in items.items() if v is not None) | python | def might_prefer(self, **items):
'''Items to take precedence if their values are not None (never saved)'''
self._overrides = dict((k, v) for (k, v) in items.items() if v is not None) | [
"def",
"might_prefer",
"(",
"self",
",",
"*",
"*",
"items",
")",
":",
"self",
".",
"_overrides",
"=",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"(",
"k",
",",
"v",
")",
"in",
"items",
".",
"items",
"(",
")",
"if",
"v",
"is",
"not",
"None",
")"
] | Items to take precedence if their values are not None (never saved) | [
"Items",
"to",
"take",
"precedence",
"if",
"their",
"values",
"are",
"not",
"None",
"(",
"never",
"saved",
")"
] | train | https://github.com/bradrf/configstruct/blob/aeea8fbba1e2daa0a0c38eeb9622d1716c0bb3e8/configstruct/section_struct.py#L13-L15 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Items to take precedence if their values are not None (never saved)
### Response:
def might_prefer(self, **items):
'''Items to take precedence if their values are not None (never saved)'''
self._overrides = dict((k, v) for (k, v) in items.items() if v is not None)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4451,
311,
1935,
54156,
422,
872,
2819,
527,
539,
2290,
320,
37593,
6924,
696,
14711,
6075,
512,
755,
2643,
10659,
809,
1214,
11,
3146,
3699,
997,
286,
11712,
4451,
311,
1935,
54156,
422,
872,
2819,
527,
539,
2290,
320,
37593,
6924,
8,
15029,
286,
659,
1462,
84458,
284,
6587,
1209,
74,
11,
348,
8,
369,
320,
74,
11,
348,
8,
304,
3673,
9812,
368,
422,
348,
374,
539,
2290,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4451,
311,
1935,
54156,
422,
872,
2819,
527,
539,
2290,
320,
37593,
6924,
696,
14711,
6075,
512,
755,
2643,
10659,
809,
1214,
11,
3146,
3699,
997,
286,
11712,
4451,
311,
1935,
54156,
422,
872,
2819,
527,
539,
2290,
320,
37593,
6924,
8,
15029,
286,
659,
1462,
84458,
284,
6587,
1209,
74,
11,
348,
8,
369,
320,
74,
11,
348,
8,
304,
3673,
9812,
368,
422,
348,
374,
539,
2290,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
dylanaraps/bum | bum/brainz.py | get_cover | def get_cover(song, size=250):
"""Download the cover art."""
try:
data = mus.search_releases(artist=song["artist"],
release=song["album"],
limit=1)
release_id = data["release-list"][0]["release-group"]["id"]
print(f"album: Using release-id: {data['release-list'][0]['id']}")
return mus.get_release_group_image_front(release_id, size=size)
except mus.NetworkError:
get_cover(song, size)
except mus.ResponseError:
print("error: Couldn't find album art for",
f"{song['artist']} - {song['album']}") | python | def get_cover(song, size=250):
"""Download the cover art."""
try:
data = mus.search_releases(artist=song["artist"],
release=song["album"],
limit=1)
release_id = data["release-list"][0]["release-group"]["id"]
print(f"album: Using release-id: {data['release-list'][0]['id']}")
return mus.get_release_group_image_front(release_id, size=size)
except mus.NetworkError:
get_cover(song, size)
except mus.ResponseError:
print("error: Couldn't find album art for",
f"{song['artist']} - {song['album']}") | [
"def",
"get_cover",
"(",
"song",
",",
"size",
"=",
"250",
")",
":",
"try",
":",
"data",
"=",
"mus",
".",
"search_releases",
"(",
"artist",
"=",
"song",
"[",
"\"artist\"",
"]",
",",
"release",
"=",
"song",
"[",
"\"album\"",
"]",
",",
"limit",
"=",
"1",
")",
"release_id",
"=",
"data",
"[",
"\"release-list\"",
"]",
"[",
"0",
"]",
"[",
"\"release-group\"",
"]",
"[",
"\"id\"",
"]",
"print",
"(",
"f\"album: Using release-id: {data['release-list'][0]['id']}\"",
")",
"return",
"mus",
".",
"get_release_group_image_front",
"(",
"release_id",
",",
"size",
"=",
"size",
")",
"except",
"mus",
".",
"NetworkError",
":",
"get_cover",
"(",
"song",
",",
"size",
")",
"except",
"mus",
".",
"ResponseError",
":",
"print",
"(",
"\"error: Couldn't find album art for\"",
",",
"f\"{song['artist']} - {song['album']}\"",
")"
] | Download the cover art. | [
"Download",
"the",
"cover",
"art",
"."
] | train | https://github.com/dylanaraps/bum/blob/004d795a67398e79f2c098d7775e9cd97231646b/bum/brainz.py#L16-L32 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Download the cover art.
### Response:
def get_cover(song, size=250):
"""Download the cover art."""
try:
data = mus.search_releases(artist=song["artist"],
release=song["album"],
limit=1)
release_id = data["release-list"][0]["release-group"]["id"]
print(f"album: Using release-id: {data['release-list'][0]['id']}")
return mus.get_release_group_image_front(release_id, size=size)
except mus.NetworkError:
get_cover(song, size)
except mus.ResponseError:
print("error: Couldn't find album art for",
f"{song['artist']} - {song['album']}")
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
11631,
279,
3504,
1989,
382,
14711,
6075,
512,
755,
636,
39187,
61973,
11,
1404,
28,
5154,
997,
262,
4304,
11631,
279,
3504,
1989,
14781,
262,
1456,
512,
286,
828,
284,
3167,
9472,
1311,
29399,
93980,
14481,
647,
1204,
19135,
8257,
9898,
4984,
14481,
647,
1204,
21687,
8257,
9898,
4017,
28,
16,
340,
286,
4984,
851,
284,
828,
1204,
23859,
9206,
18613,
15,
10069,
23859,
4449,
11264,
307,
7171,
286,
1194,
968,
1,
21687,
25,
12362,
4984,
13193,
25,
314,
695,
681,
23859,
9206,
10136,
15,
5465,
307,
33841,
5240,
286,
471,
3167,
673,
25596,
6422,
5060,
23777,
5921,
1655,
851,
11,
1404,
75278,
696,
262,
3734,
3167,
31249,
1480,
512,
286,
636,
39187,
61973,
11,
1404,
696,
262,
3734,
3167,
12859,
1480,
512,
286,
1194,
446,
850,
25,
73788,
956,
1505,
8176,
1989,
369,
761,
1078,
282,
14461,
32851,
681,
19135,
33841,
482,
314,
32851,
681,
21687,
663,
14790,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
11631,
279,
3504,
1989,
382,
14711,
6075,
512,
755,
636,
39187,
61973,
11,
1404,
28,
5154,
997,
262,
4304,
11631,
279,
3504,
1989,
14781,
262,
1456,
512,
286,
828,
284,
3167,
9472,
1311,
29399,
93980,
14481,
647,
1204,
19135,
8257,
9898,
4984,
14481,
647,
1204,
21687,
8257,
9898,
4017,
28,
16,
340,
286,
4984,
851,
284,
828,
1204,
23859,
9206,
18613,
15,
10069,
23859,
4449,
11264,
307,
7171,
286,
1194,
968,
1,
21687,
25,
12362,
4984,
13193,
25,
314,
695,
681,
23859,
9206,
10136,
15,
5465,
307,
33841,
5240,
286,
471,
3167,
673,
25596,
6422,
5060,
23777,
5921,
1655,
851,
11,
1404,
75278,
696,
262,
3734,
3167,
31249,
1480,
512,
286,
636,
39187,
61973,
11,
1404,
696,
262,
3734,
3167,
12859,
1480,
512,
286,
1194,
446,
850,
25,
73788,
956,
1505,
8176,
1989,
369,
761,
1078,
282,
14461,
32851,
681,
19135,
33841,
482,
314,
32851,
681,
21687,
663,
14790,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
klahnakoski/pyLibrary | jx_python/jx.py | sort | def sort(data, fieldnames=None, already_normalized=False):
"""
PASS A FIELD NAME, OR LIST OF FIELD NAMES, OR LIST OF STRUCTS WITH {"field":field_name, "sort":direction}
"""
try:
if data == None:
return Null
if not fieldnames:
return wrap(sort_using_cmp(data, value_compare))
if already_normalized:
formal = fieldnames
else:
formal = query._normalize_sort(fieldnames)
funcs = [(jx_expression_to_function(f.value), f.sort) for f in formal]
def comparer(left, right):
for func, sort_ in funcs:
try:
result = value_compare(func(left), func(right), sort_)
if result != 0:
return result
except Exception as e:
Log.error("problem with compare", e)
return 0
if is_list(data):
output = FlatList([unwrap(d) for d in sort_using_cmp(data, cmp=comparer)])
elif hasattr(data, "__iter__"):
output = FlatList(
[unwrap(d) for d in sort_using_cmp(list(data), cmp=comparer)]
)
else:
Log.error("Do not know how to handle")
output = None
return output
except Exception as e:
Log.error("Problem sorting\n{{data}}", data=data, cause=e) | python | def sort(data, fieldnames=None, already_normalized=False):
"""
PASS A FIELD NAME, OR LIST OF FIELD NAMES, OR LIST OF STRUCTS WITH {"field":field_name, "sort":direction}
"""
try:
if data == None:
return Null
if not fieldnames:
return wrap(sort_using_cmp(data, value_compare))
if already_normalized:
formal = fieldnames
else:
formal = query._normalize_sort(fieldnames)
funcs = [(jx_expression_to_function(f.value), f.sort) for f in formal]
def comparer(left, right):
for func, sort_ in funcs:
try:
result = value_compare(func(left), func(right), sort_)
if result != 0:
return result
except Exception as e:
Log.error("problem with compare", e)
return 0
if is_list(data):
output = FlatList([unwrap(d) for d in sort_using_cmp(data, cmp=comparer)])
elif hasattr(data, "__iter__"):
output = FlatList(
[unwrap(d) for d in sort_using_cmp(list(data), cmp=comparer)]
)
else:
Log.error("Do not know how to handle")
output = None
return output
except Exception as e:
Log.error("Problem sorting\n{{data}}", data=data, cause=e) | [
"def",
"sort",
"(",
"data",
",",
"fieldnames",
"=",
"None",
",",
"already_normalized",
"=",
"False",
")",
":",
"try",
":",
"if",
"data",
"==",
"None",
":",
"return",
"Null",
"if",
"not",
"fieldnames",
":",
"return",
"wrap",
"(",
"sort_using_cmp",
"(",
"data",
",",
"value_compare",
")",
")",
"if",
"already_normalized",
":",
"formal",
"=",
"fieldnames",
"else",
":",
"formal",
"=",
"query",
".",
"_normalize_sort",
"(",
"fieldnames",
")",
"funcs",
"=",
"[",
"(",
"jx_expression_to_function",
"(",
"f",
".",
"value",
")",
",",
"f",
".",
"sort",
")",
"for",
"f",
"in",
"formal",
"]",
"def",
"comparer",
"(",
"left",
",",
"right",
")",
":",
"for",
"func",
",",
"sort_",
"in",
"funcs",
":",
"try",
":",
"result",
"=",
"value_compare",
"(",
"func",
"(",
"left",
")",
",",
"func",
"(",
"right",
")",
",",
"sort_",
")",
"if",
"result",
"!=",
"0",
":",
"return",
"result",
"except",
"Exception",
"as",
"e",
":",
"Log",
".",
"error",
"(",
"\"problem with compare\"",
",",
"e",
")",
"return",
"0",
"if",
"is_list",
"(",
"data",
")",
":",
"output",
"=",
"FlatList",
"(",
"[",
"unwrap",
"(",
"d",
")",
"for",
"d",
"in",
"sort_using_cmp",
"(",
"data",
",",
"cmp",
"=",
"comparer",
")",
"]",
")",
"elif",
"hasattr",
"(",
"data",
",",
"\"__iter__\"",
")",
":",
"output",
"=",
"FlatList",
"(",
"[",
"unwrap",
"(",
"d",
")",
"for",
"d",
"in",
"sort_using_cmp",
"(",
"list",
"(",
"data",
")",
",",
"cmp",
"=",
"comparer",
")",
"]",
")",
"else",
":",
"Log",
".",
"error",
"(",
"\"Do not know how to handle\"",
")",
"output",
"=",
"None",
"return",
"output",
"except",
"Exception",
"as",
"e",
":",
"Log",
".",
"error",
"(",
"\"Problem sorting\\n{{data}}\"",
",",
"data",
"=",
"data",
",",
"cause",
"=",
"e",
")"
] | PASS A FIELD NAME, OR LIST OF FIELD NAMES, OR LIST OF STRUCTS WITH {"field":field_name, "sort":direction} | [
"PASS",
"A",
"FIELD",
"NAME",
"OR",
"LIST",
"OF",
"FIELD",
"NAMES",
"OR",
"LIST",
"OF",
"STRUCTS",
"WITH",
"{",
"field",
":",
"field_name",
"sort",
":",
"direction",
"}"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L548-L588 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
PASS A FIELD NAME, OR LIST OF FIELD NAMES, OR LIST OF STRUCTS WITH {"field":field_name, "sort":direction}
### Response:
def sort(data, fieldnames=None, already_normalized=False):
"""
PASS A FIELD NAME, OR LIST OF FIELD NAMES, OR LIST OF STRUCTS WITH {"field":field_name, "sort":direction}
"""
try:
if data == None:
return Null
if not fieldnames:
return wrap(sort_using_cmp(data, value_compare))
if already_normalized:
formal = fieldnames
else:
formal = query._normalize_sort(fieldnames)
funcs = [(jx_expression_to_function(f.value), f.sort) for f in formal]
def comparer(left, right):
for func, sort_ in funcs:
try:
result = value_compare(func(left), func(right), sort_)
if result != 0:
return result
except Exception as e:
Log.error("problem with compare", e)
return 0
if is_list(data):
output = FlatList([unwrap(d) for d in sort_using_cmp(data, cmp=comparer)])
elif hasattr(data, "__iter__"):
output = FlatList(
[unwrap(d) for d in sort_using_cmp(list(data), cmp=comparer)]
)
else:
Log.error("Do not know how to handle")
output = None
return output
except Exception as e:
Log.error("Problem sorting\n{{data}}", data=data, cause=e)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
50892,
362,
41378,
19668,
11,
2794,
28064,
3083,
41378,
92010,
11,
2794,
28064,
3083,
60678,
50,
4874,
5324,
2630,
794,
2630,
1292,
11,
330,
7003,
794,
19612,
633,
14711,
6075,
512,
755,
3460,
2657,
11,
2115,
11654,
5980,
11,
2736,
81106,
5725,
997,
262,
3270,
262,
51935,
362,
41378,
19668,
11,
2794,
28064,
3083,
41378,
92010,
11,
2794,
28064,
3083,
60678,
50,
4874,
5324,
2630,
794,
2630,
1292,
11,
330,
7003,
794,
19612,
534,
262,
3270,
262,
1456,
512,
286,
422,
828,
624,
2290,
512,
310,
471,
18576,
271,
286,
422,
539,
2115,
11654,
512,
310,
471,
15411,
48098,
76280,
36293,
2657,
11,
907,
33335,
4489,
286,
422,
2736,
81106,
512,
310,
16287,
284,
2115,
11654,
198,
286,
775,
512,
310,
16287,
284,
3319,
1462,
31690,
18942,
15944,
11654,
696,
286,
77971,
284,
18305,
73,
87,
29168,
2401,
9353,
968,
2894,
705,
282,
10838,
8,
369,
282,
304,
16287,
2595,
286,
711,
93455,
18139,
11,
1314,
997,
310,
369,
2988,
11,
3460,
62,
304,
77971,
512,
394,
1456,
512,
504,
1121,
284,
907,
33335,
19062,
18139,
705,
2988,
28804,
705,
3460,
24262,
504,
422,
1121,
976,
220,
15,
512,
667,
471,
1121,
198,
394,
3734,
4204,
439,
384,
512,
504,
2905,
4517,
446,
35686,
449,
9616,
498,
384,
340,
310,
471,
220,
15,
271,
286,
422,
374,
2062,
2657,
997,
310,
2612,
284,
24492,
861,
2625,
15818,
1528,
8,
369,
294,
304,
3460,
76280,
36293,
2657,
11,
27181,
59946,
62219,
28243,
286,
4508,
32156,
2657,
11,
13568,
2058,
565,
15497,
310,
2612,
284,
24492,
861,
1021,
394,
510,
15818,
1528,
8,
369,
294,
304,
3460,
76280,
36293,
7455,
2657,
705,
27181,
59946,
62219,
5680,
310,
1763,
286,
775,
512,
310,
2905,
4517,
446,
5519,
539,
1440,
1268,
311,
3790,
1158,
310,
2612,
284,
2290,
271,
286,
471,
2612,
198,
262,
3734,
4204,
439,
384,
512,
286,
2905,
4517,
446,
32298,
29373,
1734,
3052,
695,
3500,
498,
828,
23686,
11,
5353,
41491,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
50892,
362,
41378,
19668,
11,
2794,
28064,
3083,
41378,
92010,
11,
2794,
28064,
3083,
60678,
50,
4874,
5324,
2630,
794,
2630,
1292,
11,
330,
7003,
794,
19612,
633,
14711,
6075,
512,
755,
3460,
2657,
11,
2115,
11654,
5980,
11,
2736,
81106,
5725,
997,
262,
3270,
262,
51935,
362,
41378,
19668,
11,
2794,
28064,
3083,
41378,
92010,
11,
2794,
28064,
3083,
60678,
50,
4874,
5324,
2630,
794,
2630,
1292,
11,
330,
7003,
794,
19612,
534,
262,
3270,
262,
1456,
512,
286,
422,
828,
624,
2290,
512,
310,
471,
18576,
271,
286,
422,
539,
2115,
11654,
512,
310,
471,
15411,
48098,
76280,
36293,
2657,
11,
907,
33335,
4489,
286,
422,
2736,
81106,
512,
310,
16287,
284,
2115,
11654,
198,
286,
775,
512,
310,
16287,
284,
3319,
1462,
31690,
18942,
15944,
11654,
696,
286,
77971,
284,
18305,
73,
87,
29168,
2401,
9353,
968,
2894,
705,
282,
10838,
8,
369,
282,
304,
16287,
2595,
286,
711,
93455,
18139,
11,
1314,
997,
310,
369,
2988,
11,
3460,
62,
304,
77971,
512,
394,
1456,
512,
504,
1121,
284,
907,
33335,
19062,
18139,
705,
2988,
28804,
705,
3460,
24262,
504,
422,
1121,
976,
220,
15,
512,
667,
471,
1121,
198,
394,
3734,
4204,
439,
384,
512,
504,
2905,
4517,
446,
35686,
449,
9616,
498,
384,
340,
310,
471,
220,
15,
271,
286,
422,
374,
2062,
2657,
997,
310,
2612,
284,
24492,
861,
2625,
15818,
1528,
8,
369,
294,
304,
3460,
76280,
36293,
2657,
11,
27181,
59946,
62219,
28243,
286,
4508,
32156,
2657,
11,
13568,
2058,
565,
15497,
310,
2612,
284,
24492,
861,
1021,
394,
510,
15818,
1528,
8,
369,
294,
304,
3460,
76280,
36293,
7455,
2657,
705,
27181,
59946,
62219,
5680,
310,
1763,
286,
775,
512,
310,
2905,
4517,
446,
5519,
539,
1440,
1268,
311,
3790,
1158,
310,
2612,
284,
2290,
271,
286,
471,
2612,
198,
262,
3734,
4204,
439,
384,
512,
286,
2905,
4517,
446,
32298,
29373,
1734,
3052,
695,
3500,
498,
828,
23686,
11,
5353,
41491,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
fredericklussier/Lifepo4weredPy | lifepo4weredPy/functions.py | canRead | def canRead(variable):
"""
mention if an element can be read.
:param variable: the element to evaluate.
:type variable: Lifepo4weredEnum
:return: true when read access is available, otherwise false.
:rtype: bool
:raises ValueError: if parameter value is not a member of Lifepo4weredEnum.
"""
if variable not in variablesEnum:
raise ValueError('Use a lifepo4wered enum element as parameter.')
return lifepo4weredSO.access_lifepo4wered(variable.value, defines.ACCESS_READ) | python | def canRead(variable):
"""
mention if an element can be read.
:param variable: the element to evaluate.
:type variable: Lifepo4weredEnum
:return: true when read access is available, otherwise false.
:rtype: bool
:raises ValueError: if parameter value is not a member of Lifepo4weredEnum.
"""
if variable not in variablesEnum:
raise ValueError('Use a lifepo4wered enum element as parameter.')
return lifepo4weredSO.access_lifepo4wered(variable.value, defines.ACCESS_READ) | [
"def",
"canRead",
"(",
"variable",
")",
":",
"if",
"variable",
"not",
"in",
"variablesEnum",
":",
"raise",
"ValueError",
"(",
"'Use a lifepo4wered enum element as parameter.'",
")",
"return",
"lifepo4weredSO",
".",
"access_lifepo4wered",
"(",
"variable",
".",
"value",
",",
"defines",
".",
"ACCESS_READ",
")"
] | mention if an element can be read.
:param variable: the element to evaluate.
:type variable: Lifepo4weredEnum
:return: true when read access is available, otherwise false.
:rtype: bool
:raises ValueError: if parameter value is not a member of Lifepo4weredEnum. | [
"mention",
"if",
"an",
"element",
"can",
"be",
"read",
"."
] | train | https://github.com/fredericklussier/Lifepo4weredPy/blob/f5b3fedf896d0d616bf5ae603953e5541d493640/lifepo4weredPy/functions.py#L12-L25 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
mention if an element can be read.
:param variable: the element to evaluate.
:type variable: Lifepo4weredEnum
:return: true when read access is available, otherwise false.
:rtype: bool
:raises ValueError: if parameter value is not a member of Lifepo4weredEnum.
### Response:
def canRead(variable):
"""
mention if an element can be read.
:param variable: the element to evaluate.
:type variable: Lifepo4weredEnum
:return: true when read access is available, otherwise false.
:rtype: bool
:raises ValueError: if parameter value is not a member of Lifepo4weredEnum.
"""
if variable not in variablesEnum:
raise ValueError('Use a lifepo4wered enum element as parameter.')
return lifepo4weredSO.access_lifepo4wered(variable.value, defines.ACCESS_READ)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
30348,
422,
459,
2449,
649,
387,
1373,
382,
262,
551,
913,
3977,
25,
279,
2449,
311,
15806,
627,
262,
551,
1337,
3977,
25,
65863,
752,
78,
19,
6703,
291,
10999,
198,
262,
551,
693,
25,
837,
994,
1373,
2680,
374,
2561,
11,
6062,
905,
627,
262,
551,
33613,
25,
1845,
198,
262,
551,
33371,
15764,
25,
422,
5852,
907,
374,
539,
264,
4562,
315,
65863,
752,
78,
19,
6703,
291,
10999,
382,
14711,
6075,
512,
755,
649,
4518,
46129,
997,
262,
3270,
262,
6420,
422,
459,
2449,
649,
387,
1373,
382,
262,
551,
913,
3977,
25,
279,
2449,
311,
15806,
627,
262,
551,
1337,
3977,
25,
65863,
752,
78,
19,
6703,
291,
10999,
198,
262,
551,
693,
25,
837,
994,
1373,
2680,
374,
2561,
11,
6062,
905,
627,
262,
551,
33613,
25,
1845,
198,
262,
551,
33371,
15764,
25,
422,
5852,
907,
374,
539,
264,
4562,
315,
65863,
752,
78,
19,
6703,
291,
10999,
627,
262,
3270,
262,
422,
3977,
539,
304,
7482,
10999,
512,
286,
4933,
15764,
493,
10464,
264,
10345,
752,
78,
19,
6703,
291,
7773,
2449,
439,
5852,
49420,
262,
471,
10345,
752,
78,
19,
6703,
291,
14202,
22757,
918,
333,
752,
78,
19,
6703,
291,
46129,
2894,
11,
19170,
67091,
13418,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
30348,
422,
459,
2449,
649,
387,
1373,
382,
262,
551,
913,
3977,
25,
279,
2449,
311,
15806,
627,
262,
551,
1337,
3977,
25,
65863,
752,
78,
19,
6703,
291,
10999,
198,
262,
551,
693,
25,
837,
994,
1373,
2680,
374,
2561,
11,
6062,
905,
627,
262,
551,
33613,
25,
1845,
198,
262,
551,
33371,
15764,
25,
422,
5852,
907,
374,
539,
264,
4562,
315,
65863,
752,
78,
19,
6703,
291,
10999,
382,
14711,
6075,
512,
755,
649,
4518,
46129,
997,
262,
3270,
262,
6420,
422,
459,
2449,
649,
387,
1373,
382,
262,
551,
913,
3977,
25,
279,
2449,
311,
15806,
627,
262,
551,
1337,
3977,
25,
65863,
752,
78,
19,
6703,
291,
10999,
198,
262,
551,
693,
25,
837,
994,
1373,
2680,
374,
2561,
11,
6062,
905,
627,
262,
551,
33613,
25,
1845,
198,
262,
551,
33371,
15764,
25,
422,
5852,
907,
374,
539,
264,
4562,
315,
65863,
752,
78,
19,
6703,
291,
10999,
627,
262,
3270,
262,
422,
3977,
539,
304,
7482,
10999,
512,
286,
4933,
15764,
493,
10464,
264,
10345,
752,
78,
19,
6703,
291,
7773,
2449,
439,
5852,
49420,
262,
471,
10345,
752,
78,
19,
6703,
291,
14202,
22757,
918,
333,
752,
78,
19,
6703,
291,
46129,
2894,
11,
19170,
67091,
13418,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Min-ops/cruddy | cruddy/scripts/cli.py | create | def create(handler, item_document):
"""Create a new item from a JSON document"""
data = {'operation': 'create',
'item': json.load(item_document)}
handler.invoke(data) | python | def create(handler, item_document):
"""Create a new item from a JSON document"""
data = {'operation': 'create',
'item': json.load(item_document)}
handler.invoke(data) | [
"def",
"create",
"(",
"handler",
",",
"item_document",
")",
":",
"data",
"=",
"{",
"'operation'",
":",
"'create'",
",",
"'item'",
":",
"json",
".",
"load",
"(",
"item_document",
")",
"}",
"handler",
".",
"invoke",
"(",
"data",
")"
] | Create a new item from a JSON document | [
"Create",
"a",
"new",
"item",
"from",
"a",
"JSON",
"document"
] | train | https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/scripts/cli.py#L187-L191 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Create a new item from a JSON document
### Response:
def create(handler, item_document):
"""Create a new item from a JSON document"""
data = {'operation': 'create',
'item': json.load(item_document)}
handler.invoke(data)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4110,
264,
502,
1537,
505,
264,
4823,
2246,
271,
14711,
6075,
512,
755,
1893,
37614,
11,
1537,
27326,
997,
262,
4304,
4110,
264,
502,
1537,
505,
264,
4823,
2246,
7275,
262,
828,
284,
5473,
9446,
1232,
364,
3261,
756,
310,
364,
1224,
1232,
3024,
5214,
5508,
27326,
10792,
262,
7158,
28209,
2657,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4110,
264,
502,
1537,
505,
264,
4823,
2246,
271,
14711,
6075,
512,
755,
1893,
37614,
11,
1537,
27326,
997,
262,
4304,
4110,
264,
502,
1537,
505,
264,
4823,
2246,
7275,
262,
828,
284,
5473,
9446,
1232,
364,
3261,
756,
310,
364,
1224,
1232,
3024,
5214,
5508,
27326,
10792,
262,
7158,
28209,
2657,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
saltstack/salt | salt/modules/pcs.py | item_show | def item_show(item, item_id=None, item_type=None, show='show', extra_args=None, cibfile=None):
'''
Show an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
show
show command (probably None, default: show)
extra_args
additional options for the pcs command
cibfile
use cibfile instead of the live CIB
'''
cmd = ['pcs']
if isinstance(cibfile, six.string_types):
cmd += ['-f', cibfile]
if isinstance(item, six.string_types):
cmd += [item]
elif isinstance(item, (list, tuple)):
cmd += item
# constraint command follows a different order
if item in ['constraint']:
cmd += [item_type]
if isinstance(show, six.string_types):
cmd += [show]
elif isinstance(show, (list, tuple)):
cmd += show
if isinstance(item_id, six.string_types):
cmd += [item_id]
if isinstance(extra_args, (list, tuple)):
cmd += extra_args
# constraint command only shows id, when using '--full'-parameter
if item in ['constraint']:
if not isinstance(extra_args, (list, tuple)) or '--full' not in extra_args:
cmd += ['--full']
return __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=False) | python | def item_show(item, item_id=None, item_type=None, show='show', extra_args=None, cibfile=None):
'''
Show an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
show
show command (probably None, default: show)
extra_args
additional options for the pcs command
cibfile
use cibfile instead of the live CIB
'''
cmd = ['pcs']
if isinstance(cibfile, six.string_types):
cmd += ['-f', cibfile]
if isinstance(item, six.string_types):
cmd += [item]
elif isinstance(item, (list, tuple)):
cmd += item
# constraint command follows a different order
if item in ['constraint']:
cmd += [item_type]
if isinstance(show, six.string_types):
cmd += [show]
elif isinstance(show, (list, tuple)):
cmd += show
if isinstance(item_id, six.string_types):
cmd += [item_id]
if isinstance(extra_args, (list, tuple)):
cmd += extra_args
# constraint command only shows id, when using '--full'-parameter
if item in ['constraint']:
if not isinstance(extra_args, (list, tuple)) or '--full' not in extra_args:
cmd += ['--full']
return __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=False) | [
"def",
"item_show",
"(",
"item",
",",
"item_id",
"=",
"None",
",",
"item_type",
"=",
"None",
",",
"show",
"=",
"'show'",
",",
"extra_args",
"=",
"None",
",",
"cibfile",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"'pcs'",
"]",
"if",
"isinstance",
"(",
"cibfile",
",",
"six",
".",
"string_types",
")",
":",
"cmd",
"+=",
"[",
"'-f'",
",",
"cibfile",
"]",
"if",
"isinstance",
"(",
"item",
",",
"six",
".",
"string_types",
")",
":",
"cmd",
"+=",
"[",
"item",
"]",
"elif",
"isinstance",
"(",
"item",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"cmd",
"+=",
"item",
"# constraint command follows a different order",
"if",
"item",
"in",
"[",
"'constraint'",
"]",
":",
"cmd",
"+=",
"[",
"item_type",
"]",
"if",
"isinstance",
"(",
"show",
",",
"six",
".",
"string_types",
")",
":",
"cmd",
"+=",
"[",
"show",
"]",
"elif",
"isinstance",
"(",
"show",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"cmd",
"+=",
"show",
"if",
"isinstance",
"(",
"item_id",
",",
"six",
".",
"string_types",
")",
":",
"cmd",
"+=",
"[",
"item_id",
"]",
"if",
"isinstance",
"(",
"extra_args",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"cmd",
"+=",
"extra_args",
"# constraint command only shows id, when using '--full'-parameter",
"if",
"item",
"in",
"[",
"'constraint'",
"]",
":",
"if",
"not",
"isinstance",
"(",
"extra_args",
",",
"(",
"list",
",",
"tuple",
")",
")",
"or",
"'--full'",
"not",
"in",
"extra_args",
":",
"cmd",
"+=",
"[",
"'--full'",
"]",
"return",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
",",
"output_loglevel",
"=",
"'trace'",
",",
"python_shell",
"=",
"False",
")"
] | Show an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
show
show command (probably None, default: show)
extra_args
additional options for the pcs command
cibfile
use cibfile instead of the live CIB | [
"Show",
"an",
"item",
"via",
"pcs",
"command",
"(",
"mainly",
"for",
"use",
"with",
"the",
"pcs",
"state",
"module",
")"
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pcs.py#L29-L77 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Show an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
show
show command (probably None, default: show)
extra_args
additional options for the pcs command
cibfile
use cibfile instead of the live CIB
### Response:
def item_show(item, item_id=None, item_type=None, show='show', extra_args=None, cibfile=None):
'''
Show an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
show
show command (probably None, default: show)
extra_args
additional options for the pcs command
cibfile
use cibfile instead of the live CIB
'''
cmd = ['pcs']
if isinstance(cibfile, six.string_types):
cmd += ['-f', cibfile]
if isinstance(item, six.string_types):
cmd += [item]
elif isinstance(item, (list, tuple)):
cmd += item
# constraint command follows a different order
if item in ['constraint']:
cmd += [item_type]
if isinstance(show, six.string_types):
cmd += [show]
elif isinstance(show, (list, tuple)):
cmd += show
if isinstance(item_id, six.string_types):
cmd += [item_id]
if isinstance(extra_args, (list, tuple)):
cmd += extra_args
# constraint command only shows id, when using '--full'-parameter
if item in ['constraint']:
if not isinstance(extra_args, (list, tuple)) or '--full' not in extra_args:
cmd += ['--full']
return __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=False)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
7968,
459,
1537,
4669,
71399,
3290,
198,
262,
320,
3902,
398,
369,
1005,
449,
279,
71399,
1614,
4793,
696,
262,
1537,
198,
286,
2242,
11,
3424,
11,
5211,
11,
22295,
5099,
627,
262,
1537,
851,
198,
286,
887,
315,
279,
1537,
198,
262,
1537,
1857,
198,
286,
1537,
955,
198,
262,
1501,
198,
286,
1501,
3290,
320,
55540,
2290,
11,
1670,
25,
1501,
340,
262,
5066,
8550,
198,
286,
5217,
2671,
369,
279,
71399,
3290,
198,
262,
272,
581,
1213,
198,
286,
1005,
272,
581,
1213,
4619,
315,
279,
3974,
356,
3336,
271,
14711,
6075,
512,
755,
1537,
15625,
5508,
11,
1537,
851,
5980,
11,
1537,
1857,
5980,
11,
1501,
1151,
3528,
518,
5066,
8550,
5980,
11,
272,
581,
1213,
5980,
997,
262,
11414,
262,
7073,
459,
1537,
4669,
71399,
3290,
198,
262,
320,
3902,
398,
369,
1005,
449,
279,
71399,
1614,
4793,
696,
262,
1537,
198,
286,
2242,
11,
3424,
11,
5211,
11,
22295,
5099,
627,
262,
1537,
851,
198,
286,
887,
315,
279,
1537,
198,
262,
1537,
1857,
198,
286,
1537,
955,
198,
262,
1501,
198,
286,
1501,
3290,
320,
55540,
2290,
11,
1670,
25,
1501,
340,
262,
5066,
8550,
198,
286,
5217,
2671,
369,
279,
71399,
3290,
198,
262,
272,
581,
1213,
198,
286,
1005,
272,
581,
1213,
4619,
315,
279,
3974,
356,
3336,
198,
262,
11414,
262,
5556,
284,
2570,
48413,
16049,
262,
422,
11656,
1361,
581,
1213,
11,
4848,
4909,
9962,
997,
286,
5556,
1447,
88741,
69,
518,
272,
581,
1213,
2595,
262,
422,
11656,
5508,
11,
4848,
4909,
9962,
997,
286,
5556,
1447,
510,
1224,
933,
262,
4508,
11656,
5508,
11,
320,
1638,
11,
14743,
10162,
286,
5556,
1447,
1537,
271,
262,
674,
22295,
3290,
11263,
264,
2204,
2015,
198,
262,
422,
1537,
304,
2570,
49157,
18888,
286,
5556,
1447,
510,
1224,
1857,
2595,
262,
422,
11656,
47677,
11,
4848,
4909,
9962,
997,
286,
5556,
1447,
510,
3528,
933,
262,
4508,
11656,
47677,
11,
320,
1638,
11,
14743,
10162,
286,
5556,
1447,
1501,
271,
262,
422,
11656,
5508,
851,
11,
4848,
4909,
9962,
997,
286,
5556,
1447,
510,
1224,
851,
2595,
262,
422,
11656,
84890,
8550,
11,
320,
1638,
11,
14743,
10162,
286,
5556,
1447,
5066,
8550,
271,
262,
674,
22295,
3290,
1193,
5039,
887,
11,
994,
1701,
17753,
9054,
25279,
16577,
198,
262,
422,
1537,
304,
2570,
49157,
18888,
286,
422,
539,
11656,
84890,
8550,
11,
320,
1638,
11,
14743,
595,
477,
17753,
9054,
6,
539,
304,
5066,
8550,
512,
310,
5556,
1447,
2570,
313,
9054,
16049,
262,
471,
1328,
43326,
565,
681,
8883,
7789,
5823,
85433,
8883,
11,
2612,
5337,
3374,
1151,
15417,
518,
10344,
50045,
5725,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
7968,
459,
1537,
4669,
71399,
3290,
198,
262,
320,
3902,
398,
369,
1005,
449,
279,
71399,
1614,
4793,
696,
262,
1537,
198,
286,
2242,
11,
3424,
11,
5211,
11,
22295,
5099,
627,
262,
1537,
851,
198,
286,
887,
315,
279,
1537,
198,
262,
1537,
1857,
198,
286,
1537,
955,
198,
262,
1501,
198,
286,
1501,
3290,
320,
55540,
2290,
11,
1670,
25,
1501,
340,
262,
5066,
8550,
198,
286,
5217,
2671,
369,
279,
71399,
3290,
198,
262,
272,
581,
1213,
198,
286,
1005,
272,
581,
1213,
4619,
315,
279,
3974,
356,
3336,
271,
14711,
6075,
512,
755,
1537,
15625,
5508,
11,
1537,
851,
5980,
11,
1537,
1857,
5980,
11,
1501,
1151,
3528,
518,
5066,
8550,
5980,
11,
272,
581,
1213,
5980,
997,
262,
11414,
262,
7073,
459,
1537,
4669,
71399,
3290,
198,
262,
320,
3902,
398,
369,
1005,
449,
279,
71399,
1614,
4793,
696,
262,
1537,
198,
286,
2242,
11,
3424,
11,
5211,
11,
22295,
5099,
627,
262,
1537,
851,
198,
286,
887,
315,
279,
1537,
198,
262,
1537,
1857,
198,
286,
1537,
955,
198,
262,
1501,
198,
286,
1501,
3290,
320,
55540,
2290,
11,
1670,
25,
1501,
340,
262,
5066,
8550,
198,
286,
5217,
2671,
369,
279,
71399,
3290,
198,
262,
272,
581,
1213,
198,
286,
1005,
272,
581,
1213,
4619,
315,
279,
3974,
356,
3336,
198,
262,
11414,
262,
5556,
284,
2570,
48413,
16049,
262,
422,
11656,
1361,
581,
1213,
11,
4848,
4909,
9962,
997,
286,
5556,
1447,
88741,
69,
518,
272,
581,
1213,
2595,
262,
422,
11656,
5508,
11,
4848,
4909,
9962,
997,
286,
5556,
1447,
510,
1224,
933,
262,
4508,
11656,
5508,
11,
320,
1638,
11,
14743,
10162,
286,
5556,
1447,
1537,
271,
262,
674,
22295,
3290,
11263,
264,
2204,
2015,
198,
262,
422,
1537,
304,
2570,
49157,
18888,
286,
5556,
1447,
510,
1224,
1857,
2595,
262,
422,
11656,
47677,
11,
4848,
4909,
9962,
997,
286,
5556,
1447,
510,
3528,
933,
262,
4508,
11656,
47677,
11,
320,
1638,
11,
14743,
10162,
286,
5556,
1447,
1501,
271,
262,
422,
11656,
5508,
851,
11,
4848,
4909,
9962,
997,
286,
5556,
1447,
510,
1224,
851,
2595,
262,
422,
11656,
84890,
8550,
11,
320,
1638,
11,
14743,
10162,
286,
5556,
1447,
5066,
8550,
271,
262,
674,
22295,
3290,
1193,
5039,
887,
11,
994,
1701,
17753,
9054,
25279,
16577,
198,
262,
422,
1537,
304,
2570,
49157,
18888,
286,
422,
539,
11656,
84890,
8550,
11,
320,
1638,
11,
14743,
595,
477,
17753,
9054,
6,
539,
304,
5066,
8550,
512,
310,
5556,
1447,
2570,
313,
9054,
16049,
262,
471,
1328,
43326,
565,
681,
8883,
7789,
5823,
85433,
8883,
11,
2612,
5337,
3374,
1151,
15417,
518,
10344,
50045,
5725,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
jtwhite79/pyemu | pyemu/la.py | LinearAnalysis.xtqx | def xtqx(self):
"""get the normal matrix attribute. Create the attribute if
it has not yet been created
Returns
-------
xtqx : pyemu.Matrix
"""
if self.__xtqx is None:
self.log("xtqx")
self.__xtqx = self.jco.T * (self.obscov ** -1) * self.jco
self.log("xtqx")
return self.__xtqx | python | def xtqx(self):
"""get the normal matrix attribute. Create the attribute if
it has not yet been created
Returns
-------
xtqx : pyemu.Matrix
"""
if self.__xtqx is None:
self.log("xtqx")
self.__xtqx = self.jco.T * (self.obscov ** -1) * self.jco
self.log("xtqx")
return self.__xtqx | [
"def",
"xtqx",
"(",
"self",
")",
":",
"if",
"self",
".",
"__xtqx",
"is",
"None",
":",
"self",
".",
"log",
"(",
"\"xtqx\"",
")",
"self",
".",
"__xtqx",
"=",
"self",
".",
"jco",
".",
"T",
"*",
"(",
"self",
".",
"obscov",
"**",
"-",
"1",
")",
"*",
"self",
".",
"jco",
"self",
".",
"log",
"(",
"\"xtqx\"",
")",
"return",
"self",
".",
"__xtqx"
] | get the normal matrix attribute. Create the attribute if
it has not yet been created
Returns
-------
xtqx : pyemu.Matrix | [
"get",
"the",
"normal",
"matrix",
"attribute",
".",
"Create",
"the",
"attribute",
"if",
"it",
"has",
"not",
"yet",
"been",
"created"
] | train | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/la.py#L729-L742 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
get the normal matrix attribute. Create the attribute if
it has not yet been created
Returns
-------
xtqx : pyemu.Matrix
### Response:
def xtqx(self):
"""get the normal matrix attribute. Create the attribute if
it has not yet been created
Returns
-------
xtqx : pyemu.Matrix
"""
if self.__xtqx is None:
self.log("xtqx")
self.__xtqx = self.jco.T * (self.obscov ** -1) * self.jco
self.log("xtqx")
return self.__xtqx
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
456,
279,
4725,
6303,
7180,
13,
4324,
279,
7180,
422,
198,
286,
433,
706,
539,
3686,
1027,
3549,
271,
286,
5295,
198,
286,
39707,
286,
63490,
89835,
551,
4611,
34163,
61531,
271,
14711,
6075,
512,
755,
63490,
89835,
1214,
997,
286,
4304,
456,
279,
4725,
6303,
7180,
13,
4324,
279,
7180,
422,
198,
286,
433,
706,
539,
3686,
1027,
3549,
271,
286,
5295,
198,
286,
39707,
286,
63490,
89835,
551,
4611,
34163,
61531,
271,
286,
3270,
286,
422,
659,
4952,
2302,
89835,
374,
2290,
512,
310,
659,
1699,
446,
2302,
89835,
1158,
310,
659,
4952,
2302,
89835,
284,
659,
1190,
1030,
844,
353,
320,
726,
27703,
2445,
869,
3146,
482,
16,
8,
353,
659,
1190,
1030,
198,
310,
659,
1699,
446,
2302,
89835,
1158,
286,
471,
659,
4952,
2302,
89835,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
456,
279,
4725,
6303,
7180,
13,
4324,
279,
7180,
422,
198,
286,
433,
706,
539,
3686,
1027,
3549,
271,
286,
5295,
198,
286,
39707,
286,
63490,
89835,
551,
4611,
34163,
61531,
271,
14711,
6075,
512,
755,
63490,
89835,
1214,
997,
286,
4304,
456,
279,
4725,
6303,
7180,
13,
4324,
279,
7180,
422,
198,
286,
433,
706,
539,
3686,
1027,
3549,
271,
286,
5295,
198,
286,
39707,
286,
63490,
89835,
551,
4611,
34163,
61531,
271,
286,
3270,
286,
422,
659,
4952,
2302,
89835,
374,
2290,
512,
310,
659,
1699,
446,
2302,
89835,
1158,
310,
659,
4952,
2302,
89835,
284,
659,
1190,
1030,
844,
353,
320,
726,
27703,
2445,
869,
3146,
482,
16,
8,
353,
659,
1190,
1030,
198,
310,
659,
1699,
446,
2302,
89835,
1158,
286,
471,
659,
4952,
2302,
89835,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
all-umass/graphs | graphs/mixins/analysis.py | AnalysisMixin.directed_laplacian | def directed_laplacian(self, D=None, eta=0.99, tol=1e-12, max_iter=500):
'''Computes the directed combinatorial graph laplacian.
http://www-all.cs.umass.edu/pubs/2007/johns_m_ICML07.pdf
D: (optional) N-array of degrees
eta: probability of not teleporting (see the paper)
tol, max_iter: convergence params for Perron vector calculation
'''
W = self.matrix('dense')
n = W.shape[0]
if D is None:
D = W.sum(axis=1)
# compute probability transition matrix
with np.errstate(invalid='ignore', divide='ignore'):
P = W.astype(float) / D[:,None]
P[D==0] = 0
# start at the uniform distribution Perron vector (phi)
old_phi = np.ones(n) / n
# iterate to the fixed point (teleporting random walk)
for _ in range(max_iter):
phi = eta * old_phi.dot(P) + (1-eta)/n
if np.abs(phi - old_phi).max() < tol:
break
old_phi = phi
else:
warnings.warn("phi failed to converge after %d iterations" % max_iter)
# L = Phi - (Phi P + P' Phi)/2
return np.diag(phi) - ((phi * P.T).T + P.T * phi)/2 | python | def directed_laplacian(self, D=None, eta=0.99, tol=1e-12, max_iter=500):
'''Computes the directed combinatorial graph laplacian.
http://www-all.cs.umass.edu/pubs/2007/johns_m_ICML07.pdf
D: (optional) N-array of degrees
eta: probability of not teleporting (see the paper)
tol, max_iter: convergence params for Perron vector calculation
'''
W = self.matrix('dense')
n = W.shape[0]
if D is None:
D = W.sum(axis=1)
# compute probability transition matrix
with np.errstate(invalid='ignore', divide='ignore'):
P = W.astype(float) / D[:,None]
P[D==0] = 0
# start at the uniform distribution Perron vector (phi)
old_phi = np.ones(n) / n
# iterate to the fixed point (teleporting random walk)
for _ in range(max_iter):
phi = eta * old_phi.dot(P) + (1-eta)/n
if np.abs(phi - old_phi).max() < tol:
break
old_phi = phi
else:
warnings.warn("phi failed to converge after %d iterations" % max_iter)
# L = Phi - (Phi P + P' Phi)/2
return np.diag(phi) - ((phi * P.T).T + P.T * phi)/2 | [
"def",
"directed_laplacian",
"(",
"self",
",",
"D",
"=",
"None",
",",
"eta",
"=",
"0.99",
",",
"tol",
"=",
"1e-12",
",",
"max_iter",
"=",
"500",
")",
":",
"W",
"=",
"self",
".",
"matrix",
"(",
"'dense'",
")",
"n",
"=",
"W",
".",
"shape",
"[",
"0",
"]",
"if",
"D",
"is",
"None",
":",
"D",
"=",
"W",
".",
"sum",
"(",
"axis",
"=",
"1",
")",
"# compute probability transition matrix",
"with",
"np",
".",
"errstate",
"(",
"invalid",
"=",
"'ignore'",
",",
"divide",
"=",
"'ignore'",
")",
":",
"P",
"=",
"W",
".",
"astype",
"(",
"float",
")",
"/",
"D",
"[",
":",
",",
"None",
"]",
"P",
"[",
"D",
"==",
"0",
"]",
"=",
"0",
"# start at the uniform distribution Perron vector (phi)",
"old_phi",
"=",
"np",
".",
"ones",
"(",
"n",
")",
"/",
"n",
"# iterate to the fixed point (teleporting random walk)",
"for",
"_",
"in",
"range",
"(",
"max_iter",
")",
":",
"phi",
"=",
"eta",
"*",
"old_phi",
".",
"dot",
"(",
"P",
")",
"+",
"(",
"1",
"-",
"eta",
")",
"/",
"n",
"if",
"np",
".",
"abs",
"(",
"phi",
"-",
"old_phi",
")",
".",
"max",
"(",
")",
"<",
"tol",
":",
"break",
"old_phi",
"=",
"phi",
"else",
":",
"warnings",
".",
"warn",
"(",
"\"phi failed to converge after %d iterations\"",
"%",
"max_iter",
")",
"# L = Phi - (Phi P + P' Phi)/2",
"return",
"np",
".",
"diag",
"(",
"phi",
")",
"-",
"(",
"(",
"phi",
"*",
"P",
".",
"T",
")",
".",
"T",
"+",
"P",
".",
"T",
"*",
"phi",
")",
"/",
"2"
] | Computes the directed combinatorial graph laplacian.
http://www-all.cs.umass.edu/pubs/2007/johns_m_ICML07.pdf
D: (optional) N-array of degrees
eta: probability of not teleporting (see the paper)
tol, max_iter: convergence params for Perron vector calculation | [
"Computes",
"the",
"directed",
"combinatorial",
"graph",
"laplacian",
".",
"http",
":",
"//",
"www",
"-",
"all",
".",
"cs",
".",
"umass",
".",
"edu",
"/",
"pubs",
"/",
"2007",
"/",
"johns_m_ICML07",
".",
"pdf"
] | train | https://github.com/all-umass/graphs/blob/4fbeb025dfe33340335f34300f58dd3809228822/graphs/mixins/analysis.py#L61-L88 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Computes the directed combinatorial graph laplacian.
http://www-all.cs.umass.edu/pubs/2007/johns_m_ICML07.pdf
D: (optional) N-array of degrees
eta: probability of not teleporting (see the paper)
tol, max_iter: convergence params for Perron vector calculation
### Response:
def directed_laplacian(self, D=None, eta=0.99, tol=1e-12, max_iter=500):
'''Computes the directed combinatorial graph laplacian.
http://www-all.cs.umass.edu/pubs/2007/johns_m_ICML07.pdf
D: (optional) N-array of degrees
eta: probability of not teleporting (see the paper)
tol, max_iter: convergence params for Perron vector calculation
'''
W = self.matrix('dense')
n = W.shape[0]
if D is None:
D = W.sum(axis=1)
# compute probability transition matrix
with np.errstate(invalid='ignore', divide='ignore'):
P = W.astype(float) / D[:,None]
P[D==0] = 0
# start at the uniform distribution Perron vector (phi)
old_phi = np.ones(n) / n
# iterate to the fixed point (teleporting random walk)
for _ in range(max_iter):
phi = eta * old_phi.dot(P) + (1-eta)/n
if np.abs(phi - old_phi).max() < tol:
break
old_phi = phi
else:
warnings.warn("phi failed to converge after %d iterations" % max_iter)
# L = Phi - (Phi P + P' Phi)/2
return np.diag(phi) - ((phi * P.T).T + P.T * phi)/2
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
59122,
288,
279,
15910,
3698,
17720,
532,
4876,
24301,
93529,
1122,
627,
262,
1795,
1129,
2185,
23148,
19302,
78351,
395,
12871,
4420,
16115,
14,
1049,
22,
4537,
3180,
82,
722,
23817,
2735,
2589,
16378,
271,
262,
423,
25,
320,
13099,
8,
452,
63158,
315,
12628,
198,
262,
40097,
25,
19463,
315,
539,
50589,
287,
320,
4151,
279,
5684,
340,
262,
39674,
11,
1973,
11985,
25,
56541,
3712,
369,
86848,
263,
4724,
22702,
271,
14711,
6075,
512,
755,
15910,
918,
73389,
582,
1122,
1214,
11,
423,
5980,
11,
40097,
28,
15,
13,
1484,
11,
39674,
28,
16,
68,
12,
717,
11,
1973,
11985,
28,
2636,
997,
262,
11712,
59122,
288,
279,
15910,
3698,
17720,
532,
4876,
24301,
93529,
1122,
627,
262,
1795,
1129,
2185,
23148,
19302,
78351,
395,
12871,
4420,
16115,
14,
1049,
22,
4537,
3180,
82,
722,
23817,
2735,
2589,
16378,
271,
262,
423,
25,
320,
13099,
8,
452,
63158,
315,
12628,
198,
262,
40097,
25,
19463,
315,
539,
50589,
287,
320,
4151,
279,
5684,
340,
262,
39674,
11,
1973,
11985,
25,
56541,
3712,
369,
86848,
263,
4724,
22702,
198,
262,
11414,
262,
468,
284,
659,
34345,
493,
81386,
1329,
262,
308,
284,
468,
7201,
58,
15,
933,
262,
422,
423,
374,
2290,
512,
415,
423,
284,
468,
13485,
32984,
28,
16,
340,
262,
674,
12849,
19463,
9320,
6303,
198,
262,
449,
2660,
18948,
2513,
6024,
1930,
1151,
13431,
518,
22497,
1151,
13431,
11290,
415,
393,
284,
468,
44138,
8432,
8,
611,
423,
9821,
4155,
933,
262,
393,
66020,
419,
15,
60,
284,
220,
15,
198,
262,
674,
1212,
520,
279,
14113,
8141,
86848,
263,
4724,
320,
17247,
340,
262,
2362,
43109,
284,
2660,
32890,
1471,
8,
611,
308,
198,
262,
674,
30729,
311,
279,
8521,
1486,
320,
15772,
403,
287,
4288,
4321,
340,
262,
369,
721,
304,
2134,
8913,
11985,
997,
415,
23526,
284,
40097,
353,
2362,
43109,
23633,
5417,
8,
489,
320,
16,
12,
1955,
5738,
77,
198,
415,
422,
2660,
14914,
49330,
482,
2362,
43109,
570,
2880,
368,
366,
39674,
512,
286,
1464,
198,
415,
2362,
43109,
284,
23526,
198,
262,
775,
512,
415,
19530,
22123,
446,
17247,
4745,
311,
80867,
1306,
1034,
67,
26771,
1,
1034,
1973,
11985,
340,
262,
674,
445,
284,
64913,
482,
320,
46267,
393,
489,
393,
6,
64913,
5738,
17,
198,
262,
471,
2660,
93046,
49330,
8,
482,
1819,
17247,
353,
393,
844,
570,
51,
489,
393,
844,
353,
23526,
5738,
17,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
59122,
288,
279,
15910,
3698,
17720,
532,
4876,
24301,
93529,
1122,
627,
262,
1795,
1129,
2185,
23148,
19302,
78351,
395,
12871,
4420,
16115,
14,
1049,
22,
4537,
3180,
82,
722,
23817,
2735,
2589,
16378,
271,
262,
423,
25,
320,
13099,
8,
452,
63158,
315,
12628,
198,
262,
40097,
25,
19463,
315,
539,
50589,
287,
320,
4151,
279,
5684,
340,
262,
39674,
11,
1973,
11985,
25,
56541,
3712,
369,
86848,
263,
4724,
22702,
271,
14711,
6075,
512,
755,
15910,
918,
73389,
582,
1122,
1214,
11,
423,
5980,
11,
40097,
28,
15,
13,
1484,
11,
39674,
28,
16,
68,
12,
717,
11,
1973,
11985,
28,
2636,
997,
262,
11712,
59122,
288,
279,
15910,
3698,
17720,
532,
4876,
24301,
93529,
1122,
627,
262,
1795,
1129,
2185,
23148,
19302,
78351,
395,
12871,
4420,
16115,
14,
1049,
22,
4537,
3180,
82,
722,
23817,
2735,
2589,
16378,
271,
262,
423,
25,
320,
13099,
8,
452,
63158,
315,
12628,
198,
262,
40097,
25,
19463,
315,
539,
50589,
287,
320,
4151,
279,
5684,
340,
262,
39674,
11,
1973,
11985,
25,
56541,
3712,
369,
86848,
263,
4724,
22702,
198,
262,
11414,
262,
468,
284,
659,
34345,
493,
81386,
1329,
262,
308,
284,
468,
7201,
58,
15,
933,
262,
422,
423,
374,
2290,
512,
415,
423,
284,
468,
13485,
32984,
28,
16,
340,
262,
674,
12849,
19463,
9320,
6303,
198,
262,
449,
2660,
18948,
2513,
6024,
1930,
1151,
13431,
518,
22497,
1151,
13431,
11290,
415,
393,
284,
468,
44138,
8432,
8,
611,
423,
9821,
4155,
933,
262,
393,
66020,
419,
15,
60,
284,
220,
15,
198,
262,
674,
1212,
520,
279,
14113,
8141,
86848,
263,
4724,
320,
17247,
340,
262,
2362,
43109,
284,
2660,
32890,
1471,
8,
611,
308,
198,
262,
674,
30729,
311,
279,
8521,
1486,
320,
15772,
403,
287,
4288,
4321,
340,
262,
369,
721,
304,
2134,
8913,
11985,
997,
415,
23526,
284,
40097,
353,
2362,
43109,
23633,
5417,
8,
489,
320,
16,
12,
1955,
5738,
77,
198,
415,
422,
2660,
14914,
49330,
482,
2362,
43109,
570,
2880,
368,
366,
39674,
512,
286,
1464,
198,
415,
2362,
43109,
284,
23526,
198,
262,
775,
512,
415,
19530,
22123,
446,
17247,
4745,
311,
80867,
1306,
1034,
67,
26771,
1,
1034,
1973,
11985,
340,
262,
674,
445,
284,
64913,
482,
320,
46267,
393,
489,
393,
6,
64913,
5738,
17,
198,
262,
471,
2660,
93046,
49330,
8,
482,
1819,
17247,
353,
393,
844,
570,
51,
489,
393,
844,
353,
23526,
5738,
17,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
twilio/twilio-python | twilio/rest/api/v2010/account/call/notification.py | NotificationList.stream | def stream(self, log=values.unset, message_date_before=values.unset,
message_date=values.unset, message_date_after=values.unset,
limit=None, page_size=None):
"""
Streams NotificationInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param unicode log: Filter by log level
:param date message_date_before: Filter by date
:param date message_date: Filter by date
:param date message_date_after: Filter by date
:param int limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param int page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
:rtype: list[twilio.rest.api.v2010.account.call.notification.NotificationInstance]
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
log=log,
message_date_before=message_date_before,
message_date=message_date,
message_date_after=message_date_after,
page_size=limits['page_size'],
)
return self._version.stream(page, limits['limit'], limits['page_limit']) | python | def stream(self, log=values.unset, message_date_before=values.unset,
message_date=values.unset, message_date_after=values.unset,
limit=None, page_size=None):
"""
Streams NotificationInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param unicode log: Filter by log level
:param date message_date_before: Filter by date
:param date message_date: Filter by date
:param date message_date_after: Filter by date
:param int limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param int page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
:rtype: list[twilio.rest.api.v2010.account.call.notification.NotificationInstance]
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
log=log,
message_date_before=message_date_before,
message_date=message_date,
message_date_after=message_date_after,
page_size=limits['page_size'],
)
return self._version.stream(page, limits['limit'], limits['page_limit']) | [
"def",
"stream",
"(",
"self",
",",
"log",
"=",
"values",
".",
"unset",
",",
"message_date_before",
"=",
"values",
".",
"unset",
",",
"message_date",
"=",
"values",
".",
"unset",
",",
"message_date_after",
"=",
"values",
".",
"unset",
",",
"limit",
"=",
"None",
",",
"page_size",
"=",
"None",
")",
":",
"limits",
"=",
"self",
".",
"_version",
".",
"read_limits",
"(",
"limit",
",",
"page_size",
")",
"page",
"=",
"self",
".",
"page",
"(",
"log",
"=",
"log",
",",
"message_date_before",
"=",
"message_date_before",
",",
"message_date",
"=",
"message_date",
",",
"message_date_after",
"=",
"message_date_after",
",",
"page_size",
"=",
"limits",
"[",
"'page_size'",
"]",
",",
")",
"return",
"self",
".",
"_version",
".",
"stream",
"(",
"page",
",",
"limits",
"[",
"'limit'",
"]",
",",
"limits",
"[",
"'page_limit'",
"]",
")"
] | Streams NotificationInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param unicode log: Filter by log level
:param date message_date_before: Filter by date
:param date message_date: Filter by date
:param date message_date_after: Filter by date
:param int limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param int page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
:rtype: list[twilio.rest.api.v2010.account.call.notification.NotificationInstance] | [
"Streams",
"NotificationInstance",
"records",
"from",
"the",
"API",
"as",
"a",
"generator",
"stream",
".",
"This",
"operation",
"lazily",
"loads",
"records",
"as",
"efficiently",
"as",
"possible",
"until",
"the",
"limit",
"is",
"reached",
".",
"The",
"results",
"are",
"returned",
"as",
"a",
"generator",
"so",
"this",
"operation",
"is",
"memory",
"efficient",
"."
] | train | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/call/notification.py#L38-L71 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Streams NotificationInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param unicode log: Filter by log level
:param date message_date_before: Filter by date
:param date message_date: Filter by date
:param date message_date_after: Filter by date
:param int limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param int page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
:rtype: list[twilio.rest.api.v2010.account.call.notification.NotificationInstance]
### Response:
def stream(self, log=values.unset, message_date_before=values.unset,
message_date=values.unset, message_date_after=values.unset,
limit=None, page_size=None):
"""
Streams NotificationInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the limit
is reached.
The results are returned as a generator, so this operation is memory efficient.
:param unicode log: Filter by log level
:param date message_date_before: Filter by date
:param date message_date: Filter by date
:param date message_date_after: Filter by date
:param int limit: Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
:param int page_size: Number of records to fetch per request, when not set will use
the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the
limit with the most efficient page size, i.e. min(limit, 1000)
:returns: Generator that will yield up to limit results
:rtype: list[twilio.rest.api.v2010.account.call.notification.NotificationInstance]
"""
limits = self._version.read_limits(limit, page_size)
page = self.page(
log=log,
message_date_before=message_date_before,
message_date=message_date,
message_date_after=message_date_after,
page_size=limits['page_size'],
)
return self._version.stream(page, limits['limit'], limits['page_limit'])
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
74676,
16980,
2584,
7576,
505,
279,
5446,
439,
264,
14143,
4365,
627,
286,
1115,
5784,
65536,
1570,
21577,
7576,
439,
30820,
439,
3284,
3156,
279,
4017,
198,
286,
374,
8813,
627,
286,
578,
3135,
527,
6052,
439,
264,
14143,
11,
779,
420,
5784,
374,
5044,
11297,
382,
286,
551,
913,
27169,
1515,
25,
12619,
555,
1515,
2237,
198,
286,
551,
913,
2457,
1984,
4257,
24638,
25,
12619,
555,
2457,
198,
286,
551,
913,
2457,
1984,
4257,
25,
12619,
555,
2457,
198,
286,
551,
913,
2457,
1984,
4257,
20434,
25,
12619,
555,
2457,
198,
286,
551,
913,
528,
4017,
25,
31714,
4017,
369,
279,
1396,
315,
7576,
311,
471,
13,
4365,
746,
3586,
36755,
311,
2646,
471,
810,
1109,
4017,
13,
220,
8058,
374,
912,
4017,
198,
286,
551,
913,
528,
2199,
2424,
25,
5742,
315,
7576,
311,
7963,
824,
1715,
11,
994,
539,
743,
690,
1005,
198,
4700,
279,
1670,
907,
315,
220,
1135,
7576,
13,
220,
1442,
912,
2199,
2424,
374,
4613,
198,
4700,
719,
264,
4017,
374,
4613,
11,
4365,
368,
690,
4879,
311,
1373,
279,
198,
4700,
4017,
449,
279,
1455,
11297,
2199,
1404,
11,
602,
1770,
13,
1332,
53362,
11,
220,
1041,
15,
696,
286,
551,
4310,
25,
29458,
430,
690,
7692,
709,
311,
4017,
3135,
198,
286,
551,
33613,
25,
1160,
14527,
86,
34429,
22113,
6314,
3211,
679,
15,
19315,
8692,
46903,
50429,
2584,
2595,
14711,
6075,
512,
755,
4365,
1214,
11,
1515,
28,
3745,
6441,
751,
11,
1984,
4257,
24638,
28,
3745,
6441,
751,
345,
2342,
1984,
4257,
28,
3745,
6441,
751,
11,
1984,
4257,
20434,
28,
3745,
6441,
751,
345,
2342,
4017,
5980,
11,
2199,
2424,
5980,
997,
286,
3270,
286,
95622,
16980,
2584,
7576,
505,
279,
5446,
439,
264,
14143,
4365,
627,
286,
1115,
5784,
65536,
1570,
21577,
7576,
439,
30820,
439,
3284,
3156,
279,
4017,
198,
286,
374,
8813,
627,
286,
578,
3135,
527,
6052,
439,
264,
14143,
11,
779,
420,
5784,
374,
5044,
11297,
382,
286,
551,
913,
27169,
1515,
25,
12619,
555,
1515,
2237,
198,
286,
551,
913,
2457,
1984,
4257,
24638,
25,
12619,
555,
2457,
198,
286,
551,
913,
2457,
1984,
4257,
25,
12619,
555,
2457,
198,
286,
551,
913,
2457,
1984,
4257,
20434,
25,
12619,
555,
2457,
198,
286,
551,
913,
528,
4017,
25,
31714,
4017,
369,
279,
1396,
315,
7576,
311,
471,
13,
4365,
746,
3586,
36755,
311,
2646,
471,
810,
1109,
4017,
13,
220,
8058,
374,
912,
4017,
198,
286,
551,
913,
528,
2199,
2424,
25,
5742,
315,
7576,
311,
7963,
824,
1715,
11,
994,
539,
743,
690,
1005,
198,
4700,
279,
1670,
907,
315,
220,
1135,
7576,
13,
220,
1442,
912,
2199,
2424,
374,
4613,
198,
4700,
719,
264,
4017,
374,
4613,
11,
4365,
368,
690,
4879,
311,
1373,
279,
198,
4700,
4017,
449,
279,
1455,
11297,
2199,
1404,
11,
602,
1770,
13,
1332,
53362,
11,
220
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
74676,
16980,
2584,
7576,
505,
279,
5446,
439,
264,
14143,
4365,
627,
286,
1115,
5784,
65536,
1570,
21577,
7576,
439,
30820,
439,
3284,
3156,
279,
4017,
198,
286,
374,
8813,
627,
286,
578,
3135,
527,
6052,
439,
264,
14143,
11,
779,
420,
5784,
374,
5044,
11297,
382,
286,
551,
913,
27169,
1515,
25,
12619,
555,
1515,
2237,
198,
286,
551,
913,
2457,
1984,
4257,
24638,
25,
12619,
555,
2457,
198,
286,
551,
913,
2457,
1984,
4257,
25,
12619,
555,
2457,
198,
286,
551,
913,
2457,
1984,
4257,
20434,
25,
12619,
555,
2457,
198,
286,
551,
913,
528,
4017,
25,
31714,
4017,
369,
279,
1396,
315,
7576,
311,
471,
13,
4365,
746,
3586,
36755,
311,
2646,
471,
810,
1109,
4017,
13,
220,
8058,
374,
912,
4017,
198,
286,
551,
913,
528,
2199,
2424,
25,
5742,
315,
7576,
311,
7963,
824,
1715,
11,
994,
539,
743,
690,
1005,
198,
4700,
279,
1670,
907,
315,
220,
1135,
7576,
13,
220,
1442,
912,
2199,
2424,
374,
4613,
198,
4700,
719,
264,
4017,
374,
4613,
11,
4365,
368,
690,
4879,
311,
1373,
279,
198,
4700,
4017,
449,
279,
1455,
11297,
2199,
1404,
11,
602,
1770,
13,
1332,
53362,
11,
220,
1041,
15,
696,
286,
551,
4310,
25,
29458,
430,
690,
7692,
709,
311,
4017,
3135,
198,
286,
551,
33613,
25,
1160,
14527,
86,
34429,
22113,
6314,
3211,
679,
15,
19315,
8692,
46903,
50429,
2584,
2595,
14711,
6075,
512,
755,
4365,
1214,
11,
1515,
28,
3745,
6441,
751,
11,
1984,
4257,
24638,
28,
3745,
6441,
751,
345,
2342,
1984,
4257,
28,
3745,
6441,
751,
11,
1984,
4257,
20434,
28,
3745,
6441,
751,
345,
2342,
4017,
5980,
11,
2199,
2424,
5980,
997,
286,
3270,
286,
95622,
16980,
2584,
7576,
505,
279,
5446,
439,
264,
14143,
4365,
627,
286,
1115,
5784,
65536,
1570,
21577,
7576,
439,
30820,
439,
3284,
3156,
279,
4017,
198,
286,
374,
8813,
627,
286,
578,
3135,
527,
6052,
439,
264,
14143,
11,
779,
420,
5784,
374,
5044,
11297,
382,
286,
551,
913,
27169,
1515,
25,
12619,
555,
1515,
2237,
198,
286,
551,
913,
2457,
1984,
4257,
24638,
25,
12619,
555,
2457,
198,
286,
551,
913,
2457,
1984,
4257,
25,
12619,
555,
2457,
198,
286,
551,
913,
2457,
1984,
4257,
20434,
25,
12619,
555,
2457,
198,
286,
551,
913,
528,
4017,
25,
31714,
4017,
369,
279,
1396,
315,
7576,
311,
471,
13,
4365,
746,
3586,
36755,
311,
2646,
471,
810,
1109,
4017,
13,
220,
8058,
374,
912,
4017,
198,
286,
551,
913,
528,
2199,
2424,
25,
5742,
315,
7576,
311,
7963,
824,
1715,
11,
994,
539,
743,
690,
1005,
198,
4700,
279,
1670,
907,
315,
220,
1135,
7576,
13,
220,
1442,
912,
2199,
2424,
374,
4613,
198,
4700,
719,
264,
4017,
374,
4613,
11,
4365,
368,
690,
4879,
311,
1373,
279,
198,
4700,
4017,
449,
279,
1455,
11297,
2199,
1404,
11,
602,
1770,
13,
1332,
53362,
11,
220
] |
emory-libraries/eulcommon | eulcommon/binfile/outlookexpress.py | MacIndex.messages | def messages(self):
'''A generator yielding the :class:`MacIndexMessage`
structures in this index file.'''
# The file contains the fixed-size file header followed by
# fixed-size message structures, followed by minimal message
# information (subject, from, to). Start after the file
# header and then simply return the message structures in
# sequence until we have returned the number of messages in
# this folder, ignoring the minimal message information at the
# end of the file.
offset = self.header_length # initial offset
# how much of the data in this file we expect to use, based on
# the number of messages in this folder and the index message block size
maxlen = self.header_length + self.total_messages * MacIndexMessage.LENGTH
while offset < maxlen:
yield MacIndexMessage(mm=self.mmap, offset=offset)
offset += MacIndexMessage.LENGTH | python | def messages(self):
'''A generator yielding the :class:`MacIndexMessage`
structures in this index file.'''
# The file contains the fixed-size file header followed by
# fixed-size message structures, followed by minimal message
# information (subject, from, to). Start after the file
# header and then simply return the message structures in
# sequence until we have returned the number of messages in
# this folder, ignoring the minimal message information at the
# end of the file.
offset = self.header_length # initial offset
# how much of the data in this file we expect to use, based on
# the number of messages in this folder and the index message block size
maxlen = self.header_length + self.total_messages * MacIndexMessage.LENGTH
while offset < maxlen:
yield MacIndexMessage(mm=self.mmap, offset=offset)
offset += MacIndexMessage.LENGTH | [
"def",
"messages",
"(",
"self",
")",
":",
"# The file contains the fixed-size file header followed by",
"# fixed-size message structures, followed by minimal message",
"# information (subject, from, to). Start after the file",
"# header and then simply return the message structures in",
"# sequence until we have returned the number of messages in",
"# this folder, ignoring the minimal message information at the",
"# end of the file.",
"offset",
"=",
"self",
".",
"header_length",
"# initial offset",
"# how much of the data in this file we expect to use, based on",
"# the number of messages in this folder and the index message block size",
"maxlen",
"=",
"self",
".",
"header_length",
"+",
"self",
".",
"total_messages",
"*",
"MacIndexMessage",
".",
"LENGTH",
"while",
"offset",
"<",
"maxlen",
":",
"yield",
"MacIndexMessage",
"(",
"mm",
"=",
"self",
".",
"mmap",
",",
"offset",
"=",
"offset",
")",
"offset",
"+=",
"MacIndexMessage",
".",
"LENGTH"
] | A generator yielding the :class:`MacIndexMessage`
structures in this index file. | [
"A",
"generator",
"yielding",
"the",
":",
"class",
":",
"MacIndexMessage",
"structures",
"in",
"this",
"index",
"file",
"."
] | train | https://github.com/emory-libraries/eulcommon/blob/dc63a9b3b5e38205178235e0d716d1b28158d3a9/eulcommon/binfile/outlookexpress.py#L62-L80 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
A generator yielding the :class:`MacIndexMessage`
structures in this index file.
### Response:
def messages(self):
'''A generator yielding the :class:`MacIndexMessage`
structures in this index file.'''
# The file contains the fixed-size file header followed by
# fixed-size message structures, followed by minimal message
# information (subject, from, to). Start after the file
# header and then simply return the message structures in
# sequence until we have returned the number of messages in
# this folder, ignoring the minimal message information at the
# end of the file.
offset = self.header_length # initial offset
# how much of the data in this file we expect to use, based on
# the number of messages in this folder and the index message block size
maxlen = self.header_length + self.total_messages * MacIndexMessage.LENGTH
while offset < maxlen:
yield MacIndexMessage(mm=self.mmap, offset=offset)
offset += MacIndexMessage.LENGTH
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32,
14143,
78504,
279,
551,
1058,
19258,
20122,
1581,
2097,
4077,
286,
14726,
304,
420,
1963,
1052,
382,
14711,
6075,
512,
755,
6743,
1214,
997,
286,
11712,
32,
14143,
78504,
279,
551,
1058,
19258,
20122,
1581,
2097,
4077,
286,
14726,
304,
420,
1963,
1052,
43584,
3961,
286,
674,
578,
1052,
5727,
279,
8521,
7321,
1052,
4342,
8272,
555,
198,
286,
674,
8521,
7321,
1984,
14726,
11,
8272,
555,
17832,
1984,
198,
286,
674,
2038,
320,
11760,
11,
505,
11,
311,
570,
220,
5256,
1306,
279,
1052,
198,
286,
674,
4342,
323,
1243,
5042,
471,
279,
1984,
14726,
304,
198,
286,
674,
8668,
3156,
584,
617,
6052,
279,
1396,
315,
6743,
304,
198,
286,
674,
420,
8695,
11,
32003,
279,
17832,
1984,
2038,
520,
279,
198,
286,
674,
842,
315,
279,
1052,
382,
286,
4445,
284,
659,
17531,
5228,
674,
2926,
4445,
198,
286,
674,
1268,
1790,
315,
279,
828,
304,
420,
1052,
584,
1755,
311,
1005,
11,
3196,
389,
198,
286,
674,
279,
1396,
315,
6743,
304,
420,
8695,
323,
279,
1963,
1984,
2565,
1404,
198,
286,
76548,
284,
659,
17531,
5228,
489,
659,
14032,
24321,
353,
7553,
1581,
2097,
15807,
198,
286,
1418,
4445,
366,
76548,
512,
1835,
7692,
7553,
1581,
2097,
68183,
7822,
749,
2235,
11,
4445,
28,
3255,
340,
1835,
4445,
1447,
7553,
1581,
2097,
15807,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32,
14143,
78504,
279,
551,
1058,
19258,
20122,
1581,
2097,
4077,
286,
14726,
304,
420,
1963,
1052,
382,
14711,
6075,
512,
755,
6743,
1214,
997,
286,
11712,
32,
14143,
78504,
279,
551,
1058,
19258,
20122,
1581,
2097,
4077,
286,
14726,
304,
420,
1963,
1052,
43584,
3961,
286,
674,
578,
1052,
5727,
279,
8521,
7321,
1052,
4342,
8272,
555,
198,
286,
674,
8521,
7321,
1984,
14726,
11,
8272,
555,
17832,
1984,
198,
286,
674,
2038,
320,
11760,
11,
505,
11,
311,
570,
220,
5256,
1306,
279,
1052,
198,
286,
674,
4342,
323,
1243,
5042,
471,
279,
1984,
14726,
304,
198,
286,
674,
8668,
3156,
584,
617,
6052,
279,
1396,
315,
6743,
304,
198,
286,
674,
420,
8695,
11,
32003,
279,
17832,
1984,
2038,
520,
279,
198,
286,
674,
842,
315,
279,
1052,
382,
286,
4445,
284,
659,
17531,
5228,
674,
2926,
4445,
198,
286,
674,
1268,
1790,
315,
279,
828,
304,
420,
1052,
584,
1755,
311,
1005,
11,
3196,
389,
198,
286,
674,
279,
1396,
315,
6743,
304,
420,
8695,
323,
279,
1963,
1984,
2565,
1404,
198,
286,
76548,
284,
659,
17531,
5228,
489,
659,
14032,
24321,
353,
7553,
1581,
2097,
15807,
198,
286,
1418,
4445,
366,
76548,
512,
1835,
7692,
7553,
1581,
2097,
68183,
7822,
749,
2235,
11,
4445,
28,
3255,
340,
1835,
4445,
1447,
7553,
1581,
2097,
15807,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
maxcountryman/atomos | atomos/util.py | synchronized | def synchronized(fn):
'''
A decorator which acquires a lock before attempting to execute its wrapped
function. Releases the lock in a finally clause.
:param fn: The function to wrap.
'''
lock = threading.Lock()
@functools.wraps(fn)
def decorated(*args, **kwargs):
lock.acquire()
try:
return fn(*args, **kwargs)
finally:
lock.release()
return decorated | python | def synchronized(fn):
'''
A decorator which acquires a lock before attempting to execute its wrapped
function. Releases the lock in a finally clause.
:param fn: The function to wrap.
'''
lock = threading.Lock()
@functools.wraps(fn)
def decorated(*args, **kwargs):
lock.acquire()
try:
return fn(*args, **kwargs)
finally:
lock.release()
return decorated | [
"def",
"synchronized",
"(",
"fn",
")",
":",
"lock",
"=",
"threading",
".",
"Lock",
"(",
")",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lock",
".",
"acquire",
"(",
")",
"try",
":",
"return",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"finally",
":",
"lock",
".",
"release",
"(",
")",
"return",
"decorated"
] | A decorator which acquires a lock before attempting to execute its wrapped
function. Releases the lock in a finally clause.
:param fn: The function to wrap. | [
"A",
"decorator",
"which",
"acquires",
"a",
"lock",
"before",
"attempting",
"to",
"execute",
"its",
"wrapped",
"function",
".",
"Releases",
"the",
"lock",
"in",
"a",
"finally",
"clause",
"."
] | train | https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/util.py#L21-L38 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
A decorator which acquires a lock before attempting to execute its wrapped
function. Releases the lock in a finally clause.
:param fn: The function to wrap.
### Response:
def synchronized(fn):
'''
A decorator which acquires a lock before attempting to execute its wrapped
function. Releases the lock in a finally clause.
:param fn: The function to wrap.
'''
lock = threading.Lock()
@functools.wraps(fn)
def decorated(*args, **kwargs):
lock.acquire()
try:
return fn(*args, **kwargs)
finally:
lock.release()
return decorated
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32,
51778,
902,
1645,
18164,
264,
5409,
1603,
19969,
311,
9203,
1202,
20037,
198,
262,
734,
13,
62115,
279,
5409,
304,
264,
5616,
22381,
382,
262,
551,
913,
5279,
25,
578,
734,
311,
15411,
382,
14711,
6075,
512,
755,
22183,
24968,
997,
262,
11414,
262,
362,
51778,
902,
1645,
18164,
264,
5409,
1603,
19969,
311,
9203,
1202,
20037,
198,
262,
734,
13,
62115,
279,
5409,
304,
264,
5616,
22381,
382,
262,
551,
913,
5279,
25,
578,
734,
311,
15411,
627,
262,
11414,
262,
5409,
284,
31259,
32503,
2892,
262,
571,
12158,
302,
6309,
82393,
2690,
24968,
340,
262,
711,
37109,
4163,
2164,
11,
3146,
9872,
997,
286,
5409,
70727,
746,
286,
1456,
512,
310,
471,
5279,
4163,
2164,
11,
3146,
9872,
340,
286,
5616,
512,
310,
5409,
26642,
2892,
262,
471,
37109,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32,
51778,
902,
1645,
18164,
264,
5409,
1603,
19969,
311,
9203,
1202,
20037,
198,
262,
734,
13,
62115,
279,
5409,
304,
264,
5616,
22381,
382,
262,
551,
913,
5279,
25,
578,
734,
311,
15411,
382,
14711,
6075,
512,
755,
22183,
24968,
997,
262,
11414,
262,
362,
51778,
902,
1645,
18164,
264,
5409,
1603,
19969,
311,
9203,
1202,
20037,
198,
262,
734,
13,
62115,
279,
5409,
304,
264,
5616,
22381,
382,
262,
551,
913,
5279,
25,
578,
734,
311,
15411,
627,
262,
11414,
262,
5409,
284,
31259,
32503,
2892,
262,
571,
12158,
302,
6309,
82393,
2690,
24968,
340,
262,
711,
37109,
4163,
2164,
11,
3146,
9872,
997,
286,
5409,
70727,
746,
286,
1456,
512,
310,
471,
5279,
4163,
2164,
11,
3146,
9872,
340,
286,
5616,
512,
310,
5409,
26642,
2892,
262,
471,
37109,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
sigsep/sigsep-mus-eval | museval/cli.py | bsseval | def bsseval(inargs=None):
"""
Generic cli app for bsseval results. Expects two folder with
"""
parser = argparse.ArgumentParser()
parser.add_argument(
'reference_dir',
type=str
)
parser.add_argument(
'estimates_dir',
type=str
)
parser.add_argument('-o', help='output_dir')
parser.add_argument(
'--win', type=float, help='Window size in seconds', default=1.0
)
parser.add_argument(
'--hop', type=float, help='Hop size in seconds', default=1.0
)
parser.add_argument(
'-m', type=str, help='bss_eval version [`v3`, `v4`]', default='v4'
)
parser.add_argument(
'--version', '-v',
action='version',
version='%%(prog)s %s' % util.__version__
)
args = parser.parse_args(inargs)
if not args.o:
output_dir = args.estimates_dir
else:
output_dir = args.o
# evaluate an existing estimate folder with wav files
data = eval_dir(
args.reference_dir,
args.estimates_dir,
output_dir=output_dir,
mode=args.m,
win=args.win,
hop=args.hop
)
print(data) | python | def bsseval(inargs=None):
"""
Generic cli app for bsseval results. Expects two folder with
"""
parser = argparse.ArgumentParser()
parser.add_argument(
'reference_dir',
type=str
)
parser.add_argument(
'estimates_dir',
type=str
)
parser.add_argument('-o', help='output_dir')
parser.add_argument(
'--win', type=float, help='Window size in seconds', default=1.0
)
parser.add_argument(
'--hop', type=float, help='Hop size in seconds', default=1.0
)
parser.add_argument(
'-m', type=str, help='bss_eval version [`v3`, `v4`]', default='v4'
)
parser.add_argument(
'--version', '-v',
action='version',
version='%%(prog)s %s' % util.__version__
)
args = parser.parse_args(inargs)
if not args.o:
output_dir = args.estimates_dir
else:
output_dir = args.o
# evaluate an existing estimate folder with wav files
data = eval_dir(
args.reference_dir,
args.estimates_dir,
output_dir=output_dir,
mode=args.m,
win=args.win,
hop=args.hop
)
print(data) | [
"def",
"bsseval",
"(",
"inargs",
"=",
"None",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'reference_dir'",
",",
"type",
"=",
"str",
")",
"parser",
".",
"add_argument",
"(",
"'estimates_dir'",
",",
"type",
"=",
"str",
")",
"parser",
".",
"add_argument",
"(",
"'-o'",
",",
"help",
"=",
"'output_dir'",
")",
"parser",
".",
"add_argument",
"(",
"'--win'",
",",
"type",
"=",
"float",
",",
"help",
"=",
"'Window size in seconds'",
",",
"default",
"=",
"1.0",
")",
"parser",
".",
"add_argument",
"(",
"'--hop'",
",",
"type",
"=",
"float",
",",
"help",
"=",
"'Hop size in seconds'",
",",
"default",
"=",
"1.0",
")",
"parser",
".",
"add_argument",
"(",
"'-m'",
",",
"type",
"=",
"str",
",",
"help",
"=",
"'bss_eval version [`v3`, `v4`]'",
",",
"default",
"=",
"'v4'",
")",
"parser",
".",
"add_argument",
"(",
"'--version'",
",",
"'-v'",
",",
"action",
"=",
"'version'",
",",
"version",
"=",
"'%%(prog)s %s'",
"%",
"util",
".",
"__version__",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
"inargs",
")",
"if",
"not",
"args",
".",
"o",
":",
"output_dir",
"=",
"args",
".",
"estimates_dir",
"else",
":",
"output_dir",
"=",
"args",
".",
"o",
"# evaluate an existing estimate folder with wav files",
"data",
"=",
"eval_dir",
"(",
"args",
".",
"reference_dir",
",",
"args",
".",
"estimates_dir",
",",
"output_dir",
"=",
"output_dir",
",",
"mode",
"=",
"args",
".",
"m",
",",
"win",
"=",
"args",
".",
"win",
",",
"hop",
"=",
"args",
".",
"hop",
")",
"print",
"(",
"data",
")"
] | Generic cli app for bsseval results. Expects two folder with | [
"Generic",
"cli",
"app",
"for",
"bsseval",
"results",
".",
"Expects",
"two",
"folder",
"with"
] | train | https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/cli.py#L8-L61 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Generic cli app for bsseval results. Expects two folder with
### Response:
def bsseval(inargs=None):
"""
Generic cli app for bsseval results. Expects two folder with
"""
parser = argparse.ArgumentParser()
parser.add_argument(
'reference_dir',
type=str
)
parser.add_argument(
'estimates_dir',
type=str
)
parser.add_argument('-o', help='output_dir')
parser.add_argument(
'--win', type=float, help='Window size in seconds', default=1.0
)
parser.add_argument(
'--hop', type=float, help='Hop size in seconds', default=1.0
)
parser.add_argument(
'-m', type=str, help='bss_eval version [`v3`, `v4`]', default='v4'
)
parser.add_argument(
'--version', '-v',
action='version',
version='%%(prog)s %s' % util.__version__
)
args = parser.parse_args(inargs)
if not args.o:
output_dir = args.estimates_dir
else:
output_dir = args.o
# evaluate an existing estimate folder with wav files
data = eval_dir(
args.reference_dir,
args.estimates_dir,
output_dir=output_dir,
mode=args.m,
win=args.win,
hop=args.hop
)
print(data)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
20560,
22059,
917,
369,
17502,
325,
838,
3135,
13,
1398,
8132,
1403,
8695,
449,
271,
14711,
6075,
512,
755,
17502,
325,
838,
6024,
2164,
5980,
997,
262,
3270,
262,
21981,
22059,
917,
369,
17502,
325,
838,
3135,
13,
1398,
8132,
1403,
8695,
449,
198,
262,
3270,
262,
6871,
284,
23122,
39066,
2892,
262,
6871,
1388,
9202,
1021,
286,
364,
16690,
4432,
756,
286,
955,
16311,
198,
262,
5235,
262,
6871,
1388,
9202,
1021,
286,
364,
478,
48571,
4432,
756,
286,
955,
16311,
198,
262,
5235,
262,
6871,
1388,
9202,
14996,
78,
518,
1520,
1151,
3081,
4432,
4713,
262,
6871,
1388,
9202,
1021,
286,
17753,
7678,
518,
955,
34915,
11,
1520,
1151,
4362,
1404,
304,
6622,
518,
1670,
28,
16,
13,
15,
198,
262,
5235,
262,
6871,
1388,
9202,
1021,
286,
17753,
26172,
518,
955,
34915,
11,
1520,
1151,
88373,
1404,
304,
6622,
518,
1670,
28,
16,
13,
15,
198,
262,
5235,
262,
6871,
1388,
9202,
1021,
286,
7944,
76,
518,
955,
16311,
11,
1520,
1151,
65,
784,
22001,
2373,
41618,
85,
18,
7964,
1595,
85,
19,
63,
28938,
1670,
1151,
85,
19,
1270,
262,
5235,
262,
6871,
1388,
9202,
1021,
286,
17753,
4464,
518,
7944,
85,
756,
286,
1957,
1151,
4464,
756,
286,
2373,
1151,
2838,
7,
34092,
16871,
1034,
82,
6,
1034,
4186,
4952,
4464,
12423,
262,
5235,
262,
2897,
284,
6871,
4736,
8550,
6024,
2164,
696,
262,
422,
539,
2897,
14778,
512,
286,
2612,
4432,
284,
2897,
62062,
48571,
4432,
198,
262,
775,
512,
286,
2612,
4432,
284,
2897,
14778,
271,
262,
674,
15806,
459,
6484,
16430,
8695,
449,
54907,
3626,
198,
262,
828,
284,
5720,
4432,
1021,
286,
2897,
51613,
4432,
345,
286,
2897,
62062,
48571,
4432,
345,
286,
2612,
4432,
87047,
4432,
345,
286,
3941,
32358,
749,
345,
286,
3243,
32358,
44709,
345,
286,
7598,
32358,
870,
454,
198,
262,
5235,
262,
1194,
2657,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
20560,
22059,
917,
369,
17502,
325,
838,
3135,
13,
1398,
8132,
1403,
8695,
449,
271,
14711,
6075,
512,
755,
17502,
325,
838,
6024,
2164,
5980,
997,
262,
3270,
262,
21981,
22059,
917,
369,
17502,
325,
838,
3135,
13,
1398,
8132,
1403,
8695,
449,
198,
262,
3270,
262,
6871,
284,
23122,
39066,
2892,
262,
6871,
1388,
9202,
1021,
286,
364,
16690,
4432,
756,
286,
955,
16311,
198,
262,
5235,
262,
6871,
1388,
9202,
1021,
286,
364,
478,
48571,
4432,
756,
286,
955,
16311,
198,
262,
5235,
262,
6871,
1388,
9202,
14996,
78,
518,
1520,
1151,
3081,
4432,
4713,
262,
6871,
1388,
9202,
1021,
286,
17753,
7678,
518,
955,
34915,
11,
1520,
1151,
4362,
1404,
304,
6622,
518,
1670,
28,
16,
13,
15,
198,
262,
5235,
262,
6871,
1388,
9202,
1021,
286,
17753,
26172,
518,
955,
34915,
11,
1520,
1151,
88373,
1404,
304,
6622,
518,
1670,
28,
16,
13,
15,
198,
262,
5235,
262,
6871,
1388,
9202,
1021,
286,
7944,
76,
518,
955,
16311,
11,
1520,
1151,
65,
784,
22001,
2373,
41618,
85,
18,
7964,
1595,
85,
19,
63,
28938,
1670,
1151,
85,
19,
1270,
262,
5235,
262,
6871,
1388,
9202,
1021,
286,
17753,
4464,
518,
7944,
85,
756,
286,
1957,
1151,
4464,
756,
286,
2373,
1151,
2838,
7,
34092,
16871,
1034,
82,
6,
1034,
4186,
4952,
4464,
12423,
262,
5235,
262,
2897,
284,
6871,
4736,
8550,
6024,
2164,
696,
262,
422,
539,
2897,
14778,
512,
286,
2612,
4432,
284,
2897,
62062,
48571,
4432,
198,
262,
775,
512,
286,
2612,
4432,
284,
2897,
14778,
271,
262,
674,
15806,
459,
6484,
16430,
8695,
449,
54907,
3626,
198,
262,
828,
284,
5720,
4432,
1021,
286,
2897,
51613,
4432,
345,
286,
2897,
62062,
48571,
4432,
345,
286,
2612,
4432,
87047,
4432,
345,
286,
3941,
32358,
749,
345,
286,
3243,
32358,
44709,
345,
286,
7598,
32358,
870,
454,
198,
262,
5235,
262,
1194,
2657,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
bcbio/bcbio-nextgen | bcbio/variation/mutect2.py | _af_filter | def _af_filter(data, in_file, out_file):
"""Soft-filter variants with AF below min_allele_fraction (appends "MinAF" to FILTER)
"""
min_freq = float(utils.get_in(data["config"], ("algorithm", "min_allele_fraction"), 10)) / 100.0
logger.debug("Filtering MuTect2 calls with allele fraction threshold of %s" % min_freq)
ungz_out_file = "%s.vcf" % utils.splitext_plus(out_file)[0]
if not utils.file_exists(ungz_out_file) and not utils.file_exists(ungz_out_file + ".gz"):
with file_transaction(data, ungz_out_file) as tx_out_file:
vcf = cyvcf2.VCF(in_file)
vcf.add_filter_to_header({
'ID': 'MinAF',
'Description': 'Allele frequency is lower than %s%% ' % (min_freq*100) + (
'(configured in bcbio as min_allele_fraction)'
if utils.get_in(data["config"], ("algorithm", "min_allele_fraction"))
else '(default threshold in bcbio; override with min_allele_fraction in the algorithm section)')})
w = cyvcf2.Writer(tx_out_file, vcf)
# GATK 3.x can produce VCFs without sample names for empty VCFs
try:
tumor_index = vcf.samples.index(dd.get_sample_name(data))
except ValueError:
tumor_index = None
for rec in vcf:
if tumor_index is not None and np.all(rec.format('AF')[tumor_index] < min_freq):
vcfutils.cyvcf_add_filter(rec, 'MinAF')
w.write_record(rec)
w.close()
return vcfutils.bgzip_and_index(ungz_out_file, data["config"]) | python | def _af_filter(data, in_file, out_file):
"""Soft-filter variants with AF below min_allele_fraction (appends "MinAF" to FILTER)
"""
min_freq = float(utils.get_in(data["config"], ("algorithm", "min_allele_fraction"), 10)) / 100.0
logger.debug("Filtering MuTect2 calls with allele fraction threshold of %s" % min_freq)
ungz_out_file = "%s.vcf" % utils.splitext_plus(out_file)[0]
if not utils.file_exists(ungz_out_file) and not utils.file_exists(ungz_out_file + ".gz"):
with file_transaction(data, ungz_out_file) as tx_out_file:
vcf = cyvcf2.VCF(in_file)
vcf.add_filter_to_header({
'ID': 'MinAF',
'Description': 'Allele frequency is lower than %s%% ' % (min_freq*100) + (
'(configured in bcbio as min_allele_fraction)'
if utils.get_in(data["config"], ("algorithm", "min_allele_fraction"))
else '(default threshold in bcbio; override with min_allele_fraction in the algorithm section)')})
w = cyvcf2.Writer(tx_out_file, vcf)
# GATK 3.x can produce VCFs without sample names for empty VCFs
try:
tumor_index = vcf.samples.index(dd.get_sample_name(data))
except ValueError:
tumor_index = None
for rec in vcf:
if tumor_index is not None and np.all(rec.format('AF')[tumor_index] < min_freq):
vcfutils.cyvcf_add_filter(rec, 'MinAF')
w.write_record(rec)
w.close()
return vcfutils.bgzip_and_index(ungz_out_file, data["config"]) | [
"def",
"_af_filter",
"(",
"data",
",",
"in_file",
",",
"out_file",
")",
":",
"min_freq",
"=",
"float",
"(",
"utils",
".",
"get_in",
"(",
"data",
"[",
"\"config\"",
"]",
",",
"(",
"\"algorithm\"",
",",
"\"min_allele_fraction\"",
")",
",",
"10",
")",
")",
"/",
"100.0",
"logger",
".",
"debug",
"(",
"\"Filtering MuTect2 calls with allele fraction threshold of %s\"",
"%",
"min_freq",
")",
"ungz_out_file",
"=",
"\"%s.vcf\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"out_file",
")",
"[",
"0",
"]",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"ungz_out_file",
")",
"and",
"not",
"utils",
".",
"file_exists",
"(",
"ungz_out_file",
"+",
"\".gz\"",
")",
":",
"with",
"file_transaction",
"(",
"data",
",",
"ungz_out_file",
")",
"as",
"tx_out_file",
":",
"vcf",
"=",
"cyvcf2",
".",
"VCF",
"(",
"in_file",
")",
"vcf",
".",
"add_filter_to_header",
"(",
"{",
"'ID'",
":",
"'MinAF'",
",",
"'Description'",
":",
"'Allele frequency is lower than %s%% '",
"%",
"(",
"min_freq",
"*",
"100",
")",
"+",
"(",
"'(configured in bcbio as min_allele_fraction)'",
"if",
"utils",
".",
"get_in",
"(",
"data",
"[",
"\"config\"",
"]",
",",
"(",
"\"algorithm\"",
",",
"\"min_allele_fraction\"",
")",
")",
"else",
"'(default threshold in bcbio; override with min_allele_fraction in the algorithm section)'",
")",
"}",
")",
"w",
"=",
"cyvcf2",
".",
"Writer",
"(",
"tx_out_file",
",",
"vcf",
")",
"# GATK 3.x can produce VCFs without sample names for empty VCFs",
"try",
":",
"tumor_index",
"=",
"vcf",
".",
"samples",
".",
"index",
"(",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
")",
"except",
"ValueError",
":",
"tumor_index",
"=",
"None",
"for",
"rec",
"in",
"vcf",
":",
"if",
"tumor_index",
"is",
"not",
"None",
"and",
"np",
".",
"all",
"(",
"rec",
".",
"format",
"(",
"'AF'",
")",
"[",
"tumor_index",
"]",
"<",
"min_freq",
")",
":",
"vcfutils",
".",
"cyvcf_add_filter",
"(",
"rec",
",",
"'MinAF'",
")",
"w",
".",
"write_record",
"(",
"rec",
")",
"w",
".",
"close",
"(",
")",
"return",
"vcfutils",
".",
"bgzip_and_index",
"(",
"ungz_out_file",
",",
"data",
"[",
"\"config\"",
"]",
")"
] | Soft-filter variants with AF below min_allele_fraction (appends "MinAF" to FILTER) | [
"Soft",
"-",
"filter",
"variants",
"with",
"AF",
"below",
"min_allele_fraction",
"(",
"appends",
"MinAF",
"to",
"FILTER",
")"
] | train | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/mutect2.py#L134-L160 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Soft-filter variants with AF below min_allele_fraction (appends "MinAF" to FILTER)
### Response:
def _af_filter(data, in_file, out_file):
"""Soft-filter variants with AF below min_allele_fraction (appends "MinAF" to FILTER)
"""
min_freq = float(utils.get_in(data["config"], ("algorithm", "min_allele_fraction"), 10)) / 100.0
logger.debug("Filtering MuTect2 calls with allele fraction threshold of %s" % min_freq)
ungz_out_file = "%s.vcf" % utils.splitext_plus(out_file)[0]
if not utils.file_exists(ungz_out_file) and not utils.file_exists(ungz_out_file + ".gz"):
with file_transaction(data, ungz_out_file) as tx_out_file:
vcf = cyvcf2.VCF(in_file)
vcf.add_filter_to_header({
'ID': 'MinAF',
'Description': 'Allele frequency is lower than %s%% ' % (min_freq*100) + (
'(configured in bcbio as min_allele_fraction)'
if utils.get_in(data["config"], ("algorithm", "min_allele_fraction"))
else '(default threshold in bcbio; override with min_allele_fraction in the algorithm section)')})
w = cyvcf2.Writer(tx_out_file, vcf)
# GATK 3.x can produce VCFs without sample names for empty VCFs
try:
tumor_index = vcf.samples.index(dd.get_sample_name(data))
except ValueError:
tumor_index = None
for rec in vcf:
if tumor_index is not None and np.all(rec.format('AF')[tumor_index] < min_freq):
vcfutils.cyvcf_add_filter(rec, 'MinAF')
w.write_record(rec)
w.close()
return vcfutils.bgzip_and_index(ungz_out_file, data["config"])
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
31631,
33548,
27103,
449,
20479,
3770,
1332,
62,
95620,
60123,
320,
680,
1438,
330,
6349,
8440,
1,
311,
36452,
696,
14711,
6075,
512,
755,
721,
2642,
8901,
2657,
11,
304,
2517,
11,
704,
2517,
997,
262,
4304,
31631,
33548,
27103,
449,
20479,
3770,
1332,
62,
95620,
60123,
320,
680,
1438,
330,
6349,
8440,
1,
311,
36452,
340,
262,
3270,
262,
1332,
22543,
284,
2273,
65266,
673,
1265,
2657,
1204,
1710,
8073,
3573,
20266,
498,
330,
1083,
62,
95620,
60123,
4063,
220,
605,
595,
611,
220,
1041,
13,
15,
198,
262,
6050,
8042,
446,
5750,
287,
15130,
51,
440,
17,
6880,
449,
70510,
19983,
12447,
315,
1034,
82,
1,
1034,
1332,
22543,
340,
262,
653,
47689,
6196,
2517,
284,
6090,
82,
3211,
9991,
1,
1034,
12721,
67406,
29143,
10029,
2517,
6758,
15,
933,
262,
422,
539,
12721,
9914,
9965,
7,
2234,
89,
6196,
2517,
8,
323,
539,
12721,
9914,
9965,
7,
2234,
89,
6196,
2517,
489,
6058,
47689,
15497,
286,
449,
1052,
29984,
2657,
11,
653,
47689,
6196,
2517,
8,
439,
10055,
6196,
2517,
512,
310,
348,
9991,
284,
9693,
7513,
69,
17,
5168,
9847,
6024,
2517,
340,
310,
348,
9991,
1388,
8901,
2401,
8932,
2313,
394,
364,
926,
1232,
364,
6349,
8440,
756,
394,
364,
5116,
1232,
364,
71551,
273,
11900,
374,
4827,
1109,
1034,
82,
2838,
364,
1034,
320,
1083,
22543,
9,
1041,
8,
489,
2456,
504,
22796,
82543,
304,
293,
7369,
822,
439,
1332,
62,
95620,
60123,
40667,
504,
422,
12721,
673,
1265,
2657,
1204,
1710,
8073,
3573,
20266,
498,
330,
1083,
62,
95620,
60123,
5572,
504,
775,
22796,
2309,
12447,
304,
293,
7369,
822,
26,
2882,
449,
1332,
62,
95620,
60123,
304,
279,
12384,
3857,
8,
873,
3602,
310,
289,
284,
9693,
7513,
69,
17,
48938,
28401,
6196,
2517,
11,
348,
9991,
340,
310,
674,
480,
835,
42,
220,
18,
2036,
649,
8356,
650,
9847,
82,
2085,
6205,
5144,
369,
4384,
650,
9847,
82,
198,
310,
1456,
512,
394,
36254,
3644,
284,
348,
9991,
63307,
5265,
53959,
673,
17949,
1292,
2657,
1192,
310,
3734,
15764,
512,
394,
36254,
3644,
284,
2290,
198,
310,
369,
1421,
304,
348,
9991,
512,
394,
422,
36254,
3644,
374,
539,
2290,
323,
2660,
7825,
21285,
8180,
493,
8440,
13588,
83,
69361,
3644,
60,
366,
1332,
22543,
997,
504,
348,
9991,
6159,
57786,
7513,
69,
2962,
8901,
21285,
11,
364,
6349,
8440,
1329,
394,
289,
3921,
14526,
21285,
340,
310,
289,
4757,
746,
262,
471,
348,
9991,
6159,
38381,
10169,
8543,
3644,
7,
2234,
89,
6196,
2517,
11,
828,
1204,
1710,
14440,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
31631,
33548,
27103,
449,
20479,
3770,
1332,
62,
95620,
60123,
320,
680,
1438,
330,
6349,
8440,
1,
311,
36452,
696,
14711,
6075,
512,
755,
721,
2642,
8901,
2657,
11,
304,
2517,
11,
704,
2517,
997,
262,
4304,
31631,
33548,
27103,
449,
20479,
3770,
1332,
62,
95620,
60123,
320,
680,
1438,
330,
6349,
8440,
1,
311,
36452,
340,
262,
3270,
262,
1332,
22543,
284,
2273,
65266,
673,
1265,
2657,
1204,
1710,
8073,
3573,
20266,
498,
330,
1083,
62,
95620,
60123,
4063,
220,
605,
595,
611,
220,
1041,
13,
15,
198,
262,
6050,
8042,
446,
5750,
287,
15130,
51,
440,
17,
6880,
449,
70510,
19983,
12447,
315,
1034,
82,
1,
1034,
1332,
22543,
340,
262,
653,
47689,
6196,
2517,
284,
6090,
82,
3211,
9991,
1,
1034,
12721,
67406,
29143,
10029,
2517,
6758,
15,
933,
262,
422,
539,
12721,
9914,
9965,
7,
2234,
89,
6196,
2517,
8,
323,
539,
12721,
9914,
9965,
7,
2234,
89,
6196,
2517,
489,
6058,
47689,
15497,
286,
449,
1052,
29984,
2657,
11,
653,
47689,
6196,
2517,
8,
439,
10055,
6196,
2517,
512,
310,
348,
9991,
284,
9693,
7513,
69,
17,
5168,
9847,
6024,
2517,
340,
310,
348,
9991,
1388,
8901,
2401,
8932,
2313,
394,
364,
926,
1232,
364,
6349,
8440,
756,
394,
364,
5116,
1232,
364,
71551,
273,
11900,
374,
4827,
1109,
1034,
82,
2838,
364,
1034,
320,
1083,
22543,
9,
1041,
8,
489,
2456,
504,
22796,
82543,
304,
293,
7369,
822,
439,
1332,
62,
95620,
60123,
40667,
504,
422,
12721,
673,
1265,
2657,
1204,
1710,
8073,
3573,
20266,
498,
330,
1083,
62,
95620,
60123,
5572,
504,
775,
22796,
2309,
12447,
304,
293,
7369,
822,
26,
2882,
449,
1332,
62,
95620,
60123,
304,
279,
12384,
3857,
8,
873,
3602,
310,
289,
284,
9693,
7513,
69,
17,
48938,
28401,
6196,
2517,
11,
348,
9991,
340,
310,
674,
480,
835,
42,
220,
18,
2036,
649,
8356,
650,
9847,
82,
2085,
6205,
5144,
369,
4384,
650,
9847,
82,
198,
310,
1456,
512,
394,
36254,
3644,
284,
348,
9991,
63307,
5265,
53959,
673,
17949,
1292,
2657,
1192,
310,
3734,
15764,
512,
394,
36254,
3644,
284,
2290,
198,
310,
369,
1421,
304,
348,
9991,
512,
394,
422,
36254,
3644,
374,
539,
2290,
323,
2660,
7825,
21285,
8180,
493,
8440,
13588,
83,
69361,
3644,
60,
366,
1332,
22543,
997,
504,
348,
9991,
6159,
57786,
7513,
69,
2962,
8901,
21285,
11,
364,
6349,
8440,
1329,
394,
289,
3921,
14526,
21285,
340,
310,
289,
4757,
746,
262,
471,
348,
9991,
6159,
38381,
10169,
8543,
3644,
7,
2234,
89,
6196,
2517,
11,
828,
1204,
1710,
14440,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
projectatomic/osbs-client | osbs/api.py | OSBS.retries_disabled | def retries_disabled(self):
"""
Context manager to disable retries on requests
:returns: OSBS object
"""
self.os.retries_enabled = False
yield
self.os.retries_enabled = True | python | def retries_disabled(self):
"""
Context manager to disable retries on requests
:returns: OSBS object
"""
self.os.retries_enabled = False
yield
self.os.retries_enabled = True | [
"def",
"retries_disabled",
"(",
"self",
")",
":",
"self",
".",
"os",
".",
"retries_enabled",
"=",
"False",
"yield",
"self",
".",
"os",
".",
"retries_enabled",
"=",
"True"
] | Context manager to disable retries on requests
:returns: OSBS object | [
"Context",
"manager",
"to",
"disable",
"retries",
"on",
"requests",
":",
"returns",
":",
"OSBS",
"object"
] | train | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/api.py#L1356-L1363 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Context manager to disable retries on requests
:returns: OSBS object
### Response:
def retries_disabled(self):
"""
Context manager to disable retries on requests
:returns: OSBS object
"""
self.os.retries_enabled = False
yield
self.os.retries_enabled = True
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2014,
6783,
311,
11404,
61701,
389,
7540,
198,
286,
551,
4310,
25,
10293,
7497,
1665,
271,
14711,
6075,
512,
755,
61701,
52501,
1214,
997,
286,
3270,
286,
9805,
6783,
311,
11404,
61701,
389,
7540,
198,
286,
551,
4310,
25,
10293,
7497,
1665,
198,
286,
3270,
286,
659,
9475,
1351,
4646,
18721,
284,
3641,
198,
286,
7692,
198,
286,
659,
9475,
1351,
4646,
18721,
284,
3082,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2014,
6783,
311,
11404,
61701,
389,
7540,
198,
286,
551,
4310,
25,
10293,
7497,
1665,
271,
14711,
6075,
512,
755,
61701,
52501,
1214,
997,
286,
3270,
286,
9805,
6783,
311,
11404,
61701,
389,
7540,
198,
286,
551,
4310,
25,
10293,
7497,
1665,
198,
286,
3270,
286,
659,
9475,
1351,
4646,
18721,
284,
3641,
198,
286,
7692,
198,
286,
659,
9475,
1351,
4646,
18721,
284,
3082,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
googledatalab/pydatalab | datalab/bigquery/_query_job.py | QueryJob.results | def results(self):
""" Get the table used for the results of the query. If the query is incomplete, this blocks.
Raises:
Exception if we timed out waiting for results or the query failed.
"""
self.wait()
if self.failed:
raise Exception('Query failed: %s' % str(self.errors))
return self._table | python | def results(self):
""" Get the table used for the results of the query. If the query is incomplete, this blocks.
Raises:
Exception if we timed out waiting for results or the query failed.
"""
self.wait()
if self.failed:
raise Exception('Query failed: %s' % str(self.errors))
return self._table | [
"def",
"results",
"(",
"self",
")",
":",
"self",
".",
"wait",
"(",
")",
"if",
"self",
".",
"failed",
":",
"raise",
"Exception",
"(",
"'Query failed: %s'",
"%",
"str",
"(",
"self",
".",
"errors",
")",
")",
"return",
"self",
".",
"_table"
] | Get the table used for the results of the query. If the query is incomplete, this blocks.
Raises:
Exception if we timed out waiting for results or the query failed. | [
"Get",
"the",
"table",
"used",
"for",
"the",
"results",
"of",
"the",
"query",
".",
"If",
"the",
"query",
"is",
"incomplete",
"this",
"blocks",
"."
] | train | https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query_job.py#L102-L111 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Get the table used for the results of the query. If the query is incomplete, this blocks.
Raises:
Exception if we timed out waiting for results or the query failed.
### Response:
def results(self):
""" Get the table used for the results of the query. If the query is incomplete, this blocks.
Raises:
Exception if we timed out waiting for results or the query failed.
"""
self.wait()
if self.failed:
raise Exception('Query failed: %s' % str(self.errors))
return self._table
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
279,
2007,
1511,
369,
279,
3135,
315,
279,
3319,
13,
1442,
279,
3319,
374,
33243,
11,
420,
10215,
382,
262,
61411,
512,
415,
4204,
422,
584,
26245,
704,
8748,
369,
3135,
477,
279,
3319,
4745,
382,
14711,
6075,
512,
755,
3135,
1214,
997,
262,
4304,
2175,
279,
2007,
1511,
369,
279,
3135,
315,
279,
3319,
13,
1442,
279,
3319,
374,
33243,
11,
420,
10215,
382,
262,
61411,
512,
415,
4204,
422,
584,
26245,
704,
8748,
369,
3135,
477,
279,
3319,
4745,
627,
262,
3270,
262,
659,
16693,
746,
262,
422,
659,
63668,
512,
415,
4933,
4204,
493,
2929,
4745,
25,
1034,
82,
6,
1034,
610,
1214,
17765,
1192,
262,
471,
659,
1462,
2048,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
279,
2007,
1511,
369,
279,
3135,
315,
279,
3319,
13,
1442,
279,
3319,
374,
33243,
11,
420,
10215,
382,
262,
61411,
512,
415,
4204,
422,
584,
26245,
704,
8748,
369,
3135,
477,
279,
3319,
4745,
382,
14711,
6075,
512,
755,
3135,
1214,
997,
262,
4304,
2175,
279,
2007,
1511,
369,
279,
3135,
315,
279,
3319,
13,
1442,
279,
3319,
374,
33243,
11,
420,
10215,
382,
262,
61411,
512,
415,
4204,
422,
584,
26245,
704,
8748,
369,
3135,
477,
279,
3319,
4745,
627,
262,
3270,
262,
659,
16693,
746,
262,
422,
659,
63668,
512,
415,
4933,
4204,
493,
2929,
4745,
25,
1034,
82,
6,
1034,
610,
1214,
17765,
1192,
262,
471,
659,
1462,
2048,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
lemieuxl/pyplink | pyplink/pyplink.py | PyPlink.seek | def seek(self, n):
"""Gets to a certain marker position in the BED file.
Args:
n (int): The index of the marker to seek to.
"""
if self._mode != "r":
raise UnsupportedOperation("not available in 'w' mode")
if 0 <= n < self._nb_markers:
self._n = n
self._bed.seek(self._get_seek_position(n))
else:
# Invalid seek value
raise ValueError("invalid position in BED: {}".format(n)) | python | def seek(self, n):
"""Gets to a certain marker position in the BED file.
Args:
n (int): The index of the marker to seek to.
"""
if self._mode != "r":
raise UnsupportedOperation("not available in 'w' mode")
if 0 <= n < self._nb_markers:
self._n = n
self._bed.seek(self._get_seek_position(n))
else:
# Invalid seek value
raise ValueError("invalid position in BED: {}".format(n)) | [
"def",
"seek",
"(",
"self",
",",
"n",
")",
":",
"if",
"self",
".",
"_mode",
"!=",
"\"r\"",
":",
"raise",
"UnsupportedOperation",
"(",
"\"not available in 'w' mode\"",
")",
"if",
"0",
"<=",
"n",
"<",
"self",
".",
"_nb_markers",
":",
"self",
".",
"_n",
"=",
"n",
"self",
".",
"_bed",
".",
"seek",
"(",
"self",
".",
"_get_seek_position",
"(",
"n",
")",
")",
"else",
":",
"# Invalid seek value",
"raise",
"ValueError",
"(",
"\"invalid position in BED: {}\"",
".",
"format",
"(",
"n",
")",
")"
] | Gets to a certain marker position in the BED file.
Args:
n (int): The index of the marker to seek to. | [
"Gets",
"to",
"a",
"certain",
"marker",
"position",
"in",
"the",
"BED",
"file",
"."
] | train | https://github.com/lemieuxl/pyplink/blob/31d47c86f589064bda98206314a2d0b20e7fd2f0/pyplink/pyplink.py#L204-L220 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Gets to a certain marker position in the BED file.
Args:
n (int): The index of the marker to seek to.
### Response:
def seek(self, n):
"""Gets to a certain marker position in the BED file.
Args:
n (int): The index of the marker to seek to.
"""
if self._mode != "r":
raise UnsupportedOperation("not available in 'w' mode")
if 0 <= n < self._nb_markers:
self._n = n
self._bed.seek(self._get_seek_position(n))
else:
# Invalid seek value
raise ValueError("invalid position in BED: {}".format(n))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
50458,
311,
264,
3738,
11381,
2361,
304,
279,
83364,
1052,
382,
286,
18161,
512,
310,
308,
320,
396,
1680,
578,
1963,
315,
279,
11381,
311,
6056,
311,
382,
14711,
6075,
512,
755,
6056,
1214,
11,
308,
997,
286,
4304,
50458,
311,
264,
3738,
11381,
2361,
304,
279,
83364,
1052,
382,
286,
18161,
512,
310,
308,
320,
396,
1680,
578,
1963,
315,
279,
11381,
311,
6056,
311,
382,
286,
3270,
286,
422,
659,
1462,
8684,
976,
330,
81,
4764,
310,
4933,
34181,
8598,
446,
1962,
2561,
304,
364,
86,
6,
3941,
5240,
286,
422,
220,
15,
2717,
308,
366,
659,
1462,
18571,
93182,
512,
310,
659,
1462,
77,
284,
308,
198,
310,
659,
1462,
2788,
39279,
1214,
1462,
456,
75573,
9858,
1471,
4489,
286,
775,
512,
310,
674,
14204,
6056,
907,
198,
310,
4933,
15764,
446,
12071,
2361,
304,
83364,
25,
21532,
2293,
1471,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
50458,
311,
264,
3738,
11381,
2361,
304,
279,
83364,
1052,
382,
286,
18161,
512,
310,
308,
320,
396,
1680,
578,
1963,
315,
279,
11381,
311,
6056,
311,
382,
14711,
6075,
512,
755,
6056,
1214,
11,
308,
997,
286,
4304,
50458,
311,
264,
3738,
11381,
2361,
304,
279,
83364,
1052,
382,
286,
18161,
512,
310,
308,
320,
396,
1680,
578,
1963,
315,
279,
11381,
311,
6056,
311,
382,
286,
3270,
286,
422,
659,
1462,
8684,
976,
330,
81,
4764,
310,
4933,
34181,
8598,
446,
1962,
2561,
304,
364,
86,
6,
3941,
5240,
286,
422,
220,
15,
2717,
308,
366,
659,
1462,
18571,
93182,
512,
310,
659,
1462,
77,
284,
308,
198,
310,
659,
1462,
2788,
39279,
1214,
1462,
456,
75573,
9858,
1471,
4489,
286,
775,
512,
310,
674,
14204,
6056,
907,
198,
310,
4933,
15764,
446,
12071,
2361,
304,
83364,
25,
21532,
2293,
1471,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
saltstack/salt | salt/modules/aptly.py | get_mirror | def get_mirror(name, config_path=_DEFAULT_CONFIG_PATH, with_packages=False):
'''
Get detailed information about a mirrored remote repository.
:param str name: The name of the remote repository mirror.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool with_packages: Return a list of packages in the repo.
:return: A dictionary containing information about the mirror.
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' aptly.get_mirror name="test-mirror"
'''
_validate_config(config_path)
ret = dict()
cmd = ['mirror', 'show', '-config={}'.format(config_path),
'-with-packages={}'.format(str(with_packages).lower()),
name]
cmd_ret = _cmd_run(cmd)
ret = _parse_show_output(cmd_ret=cmd_ret)
if ret:
log.debug('Found mirror: %s', name)
else:
log.debug('Unable to find mirror: %s', name)
return ret | python | def get_mirror(name, config_path=_DEFAULT_CONFIG_PATH, with_packages=False):
'''
Get detailed information about a mirrored remote repository.
:param str name: The name of the remote repository mirror.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool with_packages: Return a list of packages in the repo.
:return: A dictionary containing information about the mirror.
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' aptly.get_mirror name="test-mirror"
'''
_validate_config(config_path)
ret = dict()
cmd = ['mirror', 'show', '-config={}'.format(config_path),
'-with-packages={}'.format(str(with_packages).lower()),
name]
cmd_ret = _cmd_run(cmd)
ret = _parse_show_output(cmd_ret=cmd_ret)
if ret:
log.debug('Found mirror: %s', name)
else:
log.debug('Unable to find mirror: %s', name)
return ret | [
"def",
"get_mirror",
"(",
"name",
",",
"config_path",
"=",
"_DEFAULT_CONFIG_PATH",
",",
"with_packages",
"=",
"False",
")",
":",
"_validate_config",
"(",
"config_path",
")",
"ret",
"=",
"dict",
"(",
")",
"cmd",
"=",
"[",
"'mirror'",
",",
"'show'",
",",
"'-config={}'",
".",
"format",
"(",
"config_path",
")",
",",
"'-with-packages={}'",
".",
"format",
"(",
"str",
"(",
"with_packages",
")",
".",
"lower",
"(",
")",
")",
",",
"name",
"]",
"cmd_ret",
"=",
"_cmd_run",
"(",
"cmd",
")",
"ret",
"=",
"_parse_show_output",
"(",
"cmd_ret",
"=",
"cmd_ret",
")",
"if",
"ret",
":",
"log",
".",
"debug",
"(",
"'Found mirror: %s'",
",",
"name",
")",
"else",
":",
"log",
".",
"debug",
"(",
"'Unable to find mirror: %s'",
",",
"name",
")",
"return",
"ret"
] | Get detailed information about a mirrored remote repository.
:param str name: The name of the remote repository mirror.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool with_packages: Return a list of packages in the repo.
:return: A dictionary containing information about the mirror.
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' aptly.get_mirror name="test-mirror" | [
"Get",
"detailed",
"information",
"about",
"a",
"mirrored",
"remote",
"repository",
"."
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aptly.py#L488-L521 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Get detailed information about a mirrored remote repository.
:param str name: The name of the remote repository mirror.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool with_packages: Return a list of packages in the repo.
:return: A dictionary containing information about the mirror.
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' aptly.get_mirror name="test-mirror"
### Response:
def get_mirror(name, config_path=_DEFAULT_CONFIG_PATH, with_packages=False):
'''
Get detailed information about a mirrored remote repository.
:param str name: The name of the remote repository mirror.
:param str config_path: The path to the configuration file for the aptly instance.
:param bool with_packages: Return a list of packages in the repo.
:return: A dictionary containing information about the mirror.
:rtype: dict
CLI Example:
.. code-block:: bash
salt '*' aptly.get_mirror name="test-mirror"
'''
_validate_config(config_path)
ret = dict()
cmd = ['mirror', 'show', '-config={}'.format(config_path),
'-with-packages={}'.format(str(with_packages).lower()),
name]
cmd_ret = _cmd_run(cmd)
ret = _parse_show_output(cmd_ret=cmd_ret)
if ret:
log.debug('Found mirror: %s', name)
else:
log.debug('Unable to find mirror: %s', name)
return ret
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
11944,
2038,
922,
264,
70137,
8870,
12827,
382,
262,
551,
913,
610,
836,
25,
578,
836,
315,
279,
8870,
12827,
18327,
627,
262,
551,
913,
610,
2242,
2703,
25,
578,
1853,
311,
279,
6683,
1052,
369,
279,
20697,
398,
2937,
627,
262,
551,
913,
1845,
449,
42974,
25,
3494,
264,
1160,
315,
14519,
304,
279,
16246,
382,
262,
551,
693,
25,
362,
11240,
8649,
2038,
922,
279,
18327,
627,
262,
551,
33613,
25,
6587,
271,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
20697,
398,
673,
89693,
836,
429,
1985,
1474,
29912,
1875,
14711,
6075,
512,
755,
636,
89693,
3232,
11,
2242,
2703,
21574,
17733,
12853,
8103,
11,
449,
42974,
5725,
997,
262,
11414,
262,
2175,
11944,
2038,
922,
264,
70137,
8870,
12827,
382,
262,
551,
913,
610,
836,
25,
578,
836,
315,
279,
8870,
12827,
18327,
627,
262,
551,
913,
610,
2242,
2703,
25,
578,
1853,
311,
279,
6683,
1052,
369,
279,
20697,
398,
2937,
627,
262,
551,
913,
1845,
449,
42974,
25,
3494,
264,
1160,
315,
14519,
304,
279,
16246,
382,
262,
551,
693,
25,
362,
11240,
8649,
2038,
922,
279,
18327,
627,
262,
551,
33613,
25,
6587,
271,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
20697,
398,
673,
89693,
836,
429,
1985,
1474,
29912,
702,
262,
11414,
262,
721,
7212,
5445,
8928,
2703,
696,
262,
2160,
284,
6587,
746,
262,
5556,
284,
2570,
74325,
518,
364,
3528,
518,
7944,
1710,
1185,
24398,
2293,
8928,
2703,
1350,
1881,
7944,
4291,
76861,
1185,
24398,
2293,
4293,
17411,
42974,
570,
15115,
15044,
1881,
836,
2595,
262,
5556,
22437,
284,
721,
8883,
14334,
14493,
696,
262,
2160,
284,
721,
6534,
15625,
7800,
14493,
22437,
28,
8883,
22437,
696,
262,
422,
2160,
512,
286,
1515,
8042,
493,
6788,
18327,
25,
1034,
82,
518,
836,
340,
262,
775,
512,
286,
1515,
8042,
493,
17512,
311,
1505,
18327,
25,
1034,
82,
518,
836,
696,
262,
471,
2160,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
11944,
2038,
922,
264,
70137,
8870,
12827,
382,
262,
551,
913,
610,
836,
25,
578,
836,
315,
279,
8870,
12827,
18327,
627,
262,
551,
913,
610,
2242,
2703,
25,
578,
1853,
311,
279,
6683,
1052,
369,
279,
20697,
398,
2937,
627,
262,
551,
913,
1845,
449,
42974,
25,
3494,
264,
1160,
315,
14519,
304,
279,
16246,
382,
262,
551,
693,
25,
362,
11240,
8649,
2038,
922,
279,
18327,
627,
262,
551,
33613,
25,
6587,
271,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
20697,
398,
673,
89693,
836,
429,
1985,
1474,
29912,
1875,
14711,
6075,
512,
755,
636,
89693,
3232,
11,
2242,
2703,
21574,
17733,
12853,
8103,
11,
449,
42974,
5725,
997,
262,
11414,
262,
2175,
11944,
2038,
922,
264,
70137,
8870,
12827,
382,
262,
551,
913,
610,
836,
25,
578,
836,
315,
279,
8870,
12827,
18327,
627,
262,
551,
913,
610,
2242,
2703,
25,
578,
1853,
311,
279,
6683,
1052,
369,
279,
20697,
398,
2937,
627,
262,
551,
913,
1845,
449,
42974,
25,
3494,
264,
1160,
315,
14519,
304,
279,
16246,
382,
262,
551,
693,
25,
362,
11240,
8649,
2038,
922,
279,
18327,
627,
262,
551,
33613,
25,
6587,
271,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
20697,
398,
673,
89693,
836,
429,
1985,
1474,
29912,
702,
262,
11414,
262,
721,
7212,
5445,
8928,
2703,
696,
262,
2160,
284,
6587,
746,
262,
5556,
284,
2570,
74325,
518,
364,
3528,
518,
7944,
1710,
1185,
24398,
2293,
8928,
2703,
1350,
1881,
7944,
4291,
76861,
1185,
24398,
2293,
4293,
17411,
42974,
570,
15115,
15044,
1881,
836,
2595,
262,
5556,
22437,
284,
721,
8883,
14334,
14493,
696,
262,
2160,
284,
721,
6534,
15625,
7800,
14493,
22437,
28,
8883,
22437,
696,
262,
422,
2160,
512,
286,
1515,
8042,
493,
6788,
18327,
25,
1034,
82,
518,
836,
340,
262,
775,
512,
286,
1515,
8042,
493,
17512,
311,
1505,
18327,
25,
1034,
82,
518,
836,
696,
262,
471,
2160,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
dfm/george | george/modeling.py | Model.parameter_vector | def parameter_vector(self):
"""An array of all parameters (including frozen parameters)"""
return np.array([getattr(self, k) for k in self.parameter_names]) | python | def parameter_vector(self):
"""An array of all parameters (including frozen parameters)"""
return np.array([getattr(self, k) for k in self.parameter_names]) | [
"def",
"parameter_vector",
"(",
"self",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"getattr",
"(",
"self",
",",
"k",
")",
"for",
"k",
"in",
"self",
".",
"parameter_names",
"]",
")"
] | An array of all parameters (including frozen parameters) | [
"An",
"array",
"of",
"all",
"parameters",
"(",
"including",
"frozen",
"parameters",
")"
] | train | https://github.com/dfm/george/blob/44819680036387625ee89f81c55104f3c1600759/george/modeling.py#L164-L166 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
An array of all parameters (including frozen parameters)
### Response:
def parameter_vector(self):
"""An array of all parameters (including frozen parameters)"""
return np.array([getattr(self, k) for k in self.parameter_names])
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2127,
1358,
315,
682,
5137,
320,
16564,
20268,
5137,
696,
14711,
6075,
512,
755,
5852,
12526,
1214,
997,
286,
4304,
2127,
1358,
315,
682,
5137,
320,
16564,
20268,
5137,
8,
7275,
286,
471,
2660,
7382,
2625,
82832,
1214,
11,
597,
8,
369,
597,
304,
659,
55948,
9366,
2608,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2127,
1358,
315,
682,
5137,
320,
16564,
20268,
5137,
696,
14711,
6075,
512,
755,
5852,
12526,
1214,
997,
286,
4304,
2127,
1358,
315,
682,
5137,
320,
16564,
20268,
5137,
8,
7275,
286,
471,
2660,
7382,
2625,
82832,
1214,
11,
597,
8,
369,
597,
304,
659,
55948,
9366,
2608,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
juju/python-libjuju | juju/model.py | Model.get_info | async def get_info(self):
"""Return a client.ModelInfo object for this Model.
Retrieves latest info for this Model from the api server. The
return value is cached on the Model.info attribute so that the
valued may be accessed again without another api call, if
desired.
This method is called automatically when the Model is connected,
resulting in Model.info being initialized without requiring an
explicit call to this method.
"""
facade = client.ClientFacade.from_connection(self.connection())
self._info = await facade.ModelInfo()
log.debug('Got ModelInfo: %s', vars(self.info))
return self.info | python | async def get_info(self):
"""Return a client.ModelInfo object for this Model.
Retrieves latest info for this Model from the api server. The
return value is cached on the Model.info attribute so that the
valued may be accessed again without another api call, if
desired.
This method is called automatically when the Model is connected,
resulting in Model.info being initialized without requiring an
explicit call to this method.
"""
facade = client.ClientFacade.from_connection(self.connection())
self._info = await facade.ModelInfo()
log.debug('Got ModelInfo: %s', vars(self.info))
return self.info | [
"async",
"def",
"get_info",
"(",
"self",
")",
":",
"facade",
"=",
"client",
".",
"ClientFacade",
".",
"from_connection",
"(",
"self",
".",
"connection",
"(",
")",
")",
"self",
".",
"_info",
"=",
"await",
"facade",
".",
"ModelInfo",
"(",
")",
"log",
".",
"debug",
"(",
"'Got ModelInfo: %s'",
",",
"vars",
"(",
"self",
".",
"info",
")",
")",
"return",
"self",
".",
"info"
] | Return a client.ModelInfo object for this Model.
Retrieves latest info for this Model from the api server. The
return value is cached on the Model.info attribute so that the
valued may be accessed again without another api call, if
desired.
This method is called automatically when the Model is connected,
resulting in Model.info being initialized without requiring an
explicit call to this method. | [
"Return",
"a",
"client",
".",
"ModelInfo",
"object",
"for",
"this",
"Model",
"."
] | train | https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/model.py#L731-L749 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return a client.ModelInfo object for this Model.
Retrieves latest info for this Model from the api server. The
return value is cached on the Model.info attribute so that the
valued may be accessed again without another api call, if
desired.
This method is called automatically when the Model is connected,
resulting in Model.info being initialized without requiring an
explicit call to this method.
### Response:
async def get_info(self):
"""Return a client.ModelInfo object for this Model.
Retrieves latest info for this Model from the api server. The
return value is cached on the Model.info attribute so that the
valued may be accessed again without another api call, if
desired.
This method is called automatically when the Model is connected,
resulting in Model.info being initialized without requiring an
explicit call to this method.
"""
facade = client.ClientFacade.from_connection(self.connection())
self._info = await facade.ModelInfo()
log.debug('Got ModelInfo: %s', vars(self.info))
return self.info
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
264,
3016,
5777,
1767,
1665,
369,
420,
5008,
382,
286,
49761,
5652,
3630,
369,
420,
5008,
505,
279,
6464,
3622,
13,
578,
198,
286,
471,
907,
374,
21224,
389,
279,
5008,
5506,
7180,
779,
430,
279,
198,
286,
33647,
1253,
387,
25790,
1578,
2085,
2500,
6464,
1650,
11,
422,
198,
286,
12974,
382,
286,
1115,
1749,
374,
2663,
9651,
994,
279,
5008,
374,
8599,
345,
286,
13239,
304,
5008,
5506,
1694,
17719,
2085,
23537,
459,
198,
286,
11720,
1650,
311,
420,
1749,
382,
14711,
6075,
512,
7847,
711,
636,
3186,
1214,
997,
286,
4304,
5715,
264,
3016,
5777,
1767,
1665,
369,
420,
5008,
382,
286,
49761,
5652,
3630,
369,
420,
5008,
505,
279,
6464,
3622,
13,
578,
198,
286,
471,
907,
374,
21224,
389,
279,
5008,
5506,
7180,
779,
430,
279,
198,
286,
33647,
1253,
387,
25790,
1578,
2085,
2500,
6464,
1650,
11,
422,
198,
286,
12974,
382,
286,
1115,
1749,
374,
2663,
9651,
994,
279,
5008,
374,
8599,
345,
286,
13239,
304,
5008,
5506,
1694,
17719,
2085,
23537,
459,
198,
286,
11720,
1650,
311,
420,
1749,
382,
286,
3270,
286,
62716,
284,
3016,
11978,
56431,
6521,
16245,
1214,
20928,
12647,
286,
659,
1462,
2801,
284,
2597,
62716,
5777,
1767,
746,
286,
1515,
8042,
493,
33562,
5008,
1767,
25,
1034,
82,
518,
20537,
1214,
5506,
4489,
286,
471,
659,
5506,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
264,
3016,
5777,
1767,
1665,
369,
420,
5008,
382,
286,
49761,
5652,
3630,
369,
420,
5008,
505,
279,
6464,
3622,
13,
578,
198,
286,
471,
907,
374,
21224,
389,
279,
5008,
5506,
7180,
779,
430,
279,
198,
286,
33647,
1253,
387,
25790,
1578,
2085,
2500,
6464,
1650,
11,
422,
198,
286,
12974,
382,
286,
1115,
1749,
374,
2663,
9651,
994,
279,
5008,
374,
8599,
345,
286,
13239,
304,
5008,
5506,
1694,
17719,
2085,
23537,
459,
198,
286,
11720,
1650,
311,
420,
1749,
382,
14711,
6075,
512,
7847,
711,
636,
3186,
1214,
997,
286,
4304,
5715,
264,
3016,
5777,
1767,
1665,
369,
420,
5008,
382,
286,
49761,
5652,
3630,
369,
420,
5008,
505,
279,
6464,
3622,
13,
578,
198,
286,
471,
907,
374,
21224,
389,
279,
5008,
5506,
7180,
779,
430,
279,
198,
286,
33647,
1253,
387,
25790,
1578,
2085,
2500,
6464,
1650,
11,
422,
198,
286,
12974,
382,
286,
1115,
1749,
374,
2663,
9651,
994,
279,
5008,
374,
8599,
345,
286,
13239,
304,
5008,
5506,
1694,
17719,
2085,
23537,
459,
198,
286,
11720,
1650,
311,
420,
1749,
382,
286,
3270,
286,
62716,
284,
3016,
11978,
56431,
6521,
16245,
1214,
20928,
12647,
286,
659,
1462,
2801,
284,
2597,
62716,
5777,
1767,
746,
286,
1515,
8042,
493,
33562,
5008,
1767,
25,
1034,
82,
518,
20537,
1214,
5506,
4489,
286,
471,
659,
5506,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
oauthlib/oauthlib | oauthlib/common.py | extract_params | def extract_params(raw):
"""Extract parameters and return them as a list of 2-tuples.
Will successfully extract parameters from urlencoded query strings,
dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an
empty list of parameters. Any other input will result in a return
value of None.
"""
if isinstance(raw, (bytes, unicode_type)):
try:
params = urldecode(raw)
except ValueError:
params = None
elif hasattr(raw, '__iter__'):
try:
dict(raw)
except ValueError:
params = None
except TypeError:
params = None
else:
params = list(raw.items() if isinstance(raw, dict) else raw)
params = decode_params_utf8(params)
else:
params = None
return params | python | def extract_params(raw):
"""Extract parameters and return them as a list of 2-tuples.
Will successfully extract parameters from urlencoded query strings,
dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an
empty list of parameters. Any other input will result in a return
value of None.
"""
if isinstance(raw, (bytes, unicode_type)):
try:
params = urldecode(raw)
except ValueError:
params = None
elif hasattr(raw, '__iter__'):
try:
dict(raw)
except ValueError:
params = None
except TypeError:
params = None
else:
params = list(raw.items() if isinstance(raw, dict) else raw)
params = decode_params_utf8(params)
else:
params = None
return params | [
"def",
"extract_params",
"(",
"raw",
")",
":",
"if",
"isinstance",
"(",
"raw",
",",
"(",
"bytes",
",",
"unicode_type",
")",
")",
":",
"try",
":",
"params",
"=",
"urldecode",
"(",
"raw",
")",
"except",
"ValueError",
":",
"params",
"=",
"None",
"elif",
"hasattr",
"(",
"raw",
",",
"'__iter__'",
")",
":",
"try",
":",
"dict",
"(",
"raw",
")",
"except",
"ValueError",
":",
"params",
"=",
"None",
"except",
"TypeError",
":",
"params",
"=",
"None",
"else",
":",
"params",
"=",
"list",
"(",
"raw",
".",
"items",
"(",
")",
"if",
"isinstance",
"(",
"raw",
",",
"dict",
")",
"else",
"raw",
")",
"params",
"=",
"decode_params_utf8",
"(",
"params",
")",
"else",
":",
"params",
"=",
"None",
"return",
"params"
] | Extract parameters and return them as a list of 2-tuples.
Will successfully extract parameters from urlencoded query strings,
dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an
empty list of parameters. Any other input will result in a return
value of None. | [
"Extract",
"parameters",
"and",
"return",
"them",
"as",
"a",
"list",
"of",
"2",
"-",
"tuples",
"."
] | train | https://github.com/oauthlib/oauthlib/blob/30321dd3c0ca784d3508a1970cf90d9f76835c79/oauthlib/common.py#L168-L194 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Extract parameters and return them as a list of 2-tuples.
Will successfully extract parameters from urlencoded query strings,
dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an
empty list of parameters. Any other input will result in a return
value of None.
### Response:
def extract_params(raw):
"""Extract parameters and return them as a list of 2-tuples.
Will successfully extract parameters from urlencoded query strings,
dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an
empty list of parameters. Any other input will result in a return
value of None.
"""
if isinstance(raw, (bytes, unicode_type)):
try:
params = urldecode(raw)
except ValueError:
params = None
elif hasattr(raw, '__iter__'):
try:
dict(raw)
except ValueError:
params = None
except TypeError:
params = None
else:
params = list(raw.items() if isinstance(raw, dict) else raw)
params = decode_params_utf8(params)
else:
params = None
return params
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
30059,
5137,
323,
471,
1124,
439,
264,
1160,
315,
220,
17,
2442,
29423,
382,
262,
4946,
7946,
8819,
5137,
505,
2576,
19889,
3319,
9246,
345,
262,
98699,
11,
477,
11725,
315,
220,
17,
2442,
29423,
13,
23020,
9246,
3529,
31095,
99381,
690,
471,
459,
198,
262,
4384,
1160,
315,
5137,
13,
5884,
1023,
1988,
690,
1121,
304,
264,
471,
198,
262,
907,
315,
2290,
382,
14711,
6075,
512,
755,
8819,
6887,
23269,
997,
262,
4304,
30059,
5137,
323,
471,
1124,
439,
264,
1160,
315,
220,
17,
2442,
29423,
382,
262,
4946,
7946,
8819,
5137,
505,
2576,
19889,
3319,
9246,
345,
262,
98699,
11,
477,
11725,
315,
220,
17,
2442,
29423,
13,
23020,
9246,
3529,
31095,
99381,
690,
471,
459,
198,
262,
4384,
1160,
315,
5137,
13,
5884,
1023,
1988,
690,
1121,
304,
264,
471,
198,
262,
907,
315,
2290,
627,
262,
3270,
262,
422,
11656,
23269,
11,
320,
9848,
11,
27169,
1857,
10162,
286,
1456,
512,
310,
3712,
284,
2576,
18696,
23269,
340,
286,
3734,
15764,
512,
310,
3712,
284,
2290,
198,
262,
4508,
32156,
23269,
11,
12385,
2058,
565,
11290,
286,
1456,
512,
310,
6587,
23269,
340,
286,
3734,
15764,
512,
310,
3712,
284,
2290,
198,
286,
3734,
26082,
512,
310,
3712,
284,
2290,
198,
286,
775,
512,
310,
3712,
284,
1160,
23269,
9812,
368,
422,
11656,
23269,
11,
6587,
8,
775,
7257,
340,
310,
3712,
284,
17322,
6887,
40553,
23,
9094,
340,
262,
775,
512,
286,
3712,
284,
2290,
271,
262,
471,
3712,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
30059,
5137,
323,
471,
1124,
439,
264,
1160,
315,
220,
17,
2442,
29423,
382,
262,
4946,
7946,
8819,
5137,
505,
2576,
19889,
3319,
9246,
345,
262,
98699,
11,
477,
11725,
315,
220,
17,
2442,
29423,
13,
23020,
9246,
3529,
31095,
99381,
690,
471,
459,
198,
262,
4384,
1160,
315,
5137,
13,
5884,
1023,
1988,
690,
1121,
304,
264,
471,
198,
262,
907,
315,
2290,
382,
14711,
6075,
512,
755,
8819,
6887,
23269,
997,
262,
4304,
30059,
5137,
323,
471,
1124,
439,
264,
1160,
315,
220,
17,
2442,
29423,
382,
262,
4946,
7946,
8819,
5137,
505,
2576,
19889,
3319,
9246,
345,
262,
98699,
11,
477,
11725,
315,
220,
17,
2442,
29423,
13,
23020,
9246,
3529,
31095,
99381,
690,
471,
459,
198,
262,
4384,
1160,
315,
5137,
13,
5884,
1023,
1988,
690,
1121,
304,
264,
471,
198,
262,
907,
315,
2290,
627,
262,
3270,
262,
422,
11656,
23269,
11,
320,
9848,
11,
27169,
1857,
10162,
286,
1456,
512,
310,
3712,
284,
2576,
18696,
23269,
340,
286,
3734,
15764,
512,
310,
3712,
284,
2290,
198,
262,
4508,
32156,
23269,
11,
12385,
2058,
565,
11290,
286,
1456,
512,
310,
6587,
23269,
340,
286,
3734,
15764,
512,
310,
3712,
284,
2290,
198,
286,
3734,
26082,
512,
310,
3712,
284,
2290,
198,
286,
775,
512,
310,
3712,
284,
1160,
23269,
9812,
368,
422,
11656,
23269,
11,
6587,
8,
775,
7257,
340,
310,
3712,
284,
17322,
6887,
40553,
23,
9094,
340,
262,
775,
512,
286,
3712,
284,
2290,
271,
262,
471,
3712,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
fitnr/convertdate | convertdate/holidays.py | columbus_day | def columbus_day(year, country='usa'):
'''in USA: 2nd Monday in Oct
Elsewhere: Oct 12'''
if country == 'usa':
return nth_day_of_month(2, MON, OCT, year)
else:
return (year, OCT, 12) | python | def columbus_day(year, country='usa'):
'''in USA: 2nd Monday in Oct
Elsewhere: Oct 12'''
if country == 'usa':
return nth_day_of_month(2, MON, OCT, year)
else:
return (year, OCT, 12) | [
"def",
"columbus_day",
"(",
"year",
",",
"country",
"=",
"'usa'",
")",
":",
"if",
"country",
"==",
"'usa'",
":",
"return",
"nth_day_of_month",
"(",
"2",
",",
"MON",
",",
"OCT",
",",
"year",
")",
"else",
":",
"return",
"(",
"year",
",",
"OCT",
",",
"12",
")"
] | in USA: 2nd Monday in Oct
Elsewhere: Oct 12 | [
"in",
"USA",
":",
"2nd",
"Monday",
"in",
"Oct",
"Elsewhere",
":",
"Oct",
"12"
] | train | https://github.com/fitnr/convertdate/blob/e920f168a87f99183b0aa7290d6c3af222582d43/convertdate/holidays.py#L141-L147 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
in USA: 2nd Monday in Oct
Elsewhere: Oct 12
### Response:
def columbus_day(year, country='usa'):
'''in USA: 2nd Monday in Oct
Elsewhere: Oct 12'''
if country == 'usa':
return nth_day_of_month(2, MON, OCT, year)
else:
return (year, OCT, 12)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
258,
7427,
25,
220,
17,
303,
7159,
304,
5020,
198,
996,
19334,
2940,
25,
5020,
220,
717,
271,
14711,
6075,
512,
755,
94325,
10551,
17181,
29381,
11,
3224,
1151,
31853,
11290,
262,
11712,
258,
7427,
25,
220,
17,
303,
7159,
304,
5020,
198,
996,
19334,
2940,
25,
5020,
220,
717,
15029,
262,
422,
3224,
624,
364,
31853,
3730,
286,
471,
56229,
17181,
3659,
19469,
7,
17,
11,
29637,
11,
67277,
11,
1060,
340,
262,
775,
512,
286,
471,
320,
3236,
11,
67277,
11,
220,
717,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
258,
7427,
25,
220,
17,
303,
7159,
304,
5020,
198,
996,
19334,
2940,
25,
5020,
220,
717,
271,
14711,
6075,
512,
755,
94325,
10551,
17181,
29381,
11,
3224,
1151,
31853,
11290,
262,
11712,
258,
7427,
25,
220,
17,
303,
7159,
304,
5020,
198,
996,
19334,
2940,
25,
5020,
220,
717,
15029,
262,
422,
3224,
624,
364,
31853,
3730,
286,
471,
56229,
17181,
3659,
19469,
7,
17,
11,
29637,
11,
67277,
11,
1060,
340,
262,
775,
512,
286,
471,
320,
3236,
11,
67277,
11,
220,
717,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
openstack/swauth | swauth/authtypes.py | validate_creds | def validate_creds(creds):
"""Parse and validate user credentials whether format is right
:param creds: User credentials
:returns: Auth_type class instance and parsed user credentials in dict
:raises ValueError: If credential format is wrong (eg: bad auth_type)
"""
try:
auth_type, auth_rest = creds.split(':', 1)
except ValueError:
raise ValueError("Missing ':' in %s" % creds)
authtypes = sys.modules[__name__]
auth_encoder = getattr(authtypes, auth_type.title(), None)
if auth_encoder is None:
raise ValueError('Invalid auth_type: %s' % auth_type)
auth_encoder = auth_encoder()
parsed_creds = dict(type=auth_type, salt=None, hash=None)
parsed_creds.update(auth_encoder.validate(auth_rest))
return auth_encoder, parsed_creds | python | def validate_creds(creds):
"""Parse and validate user credentials whether format is right
:param creds: User credentials
:returns: Auth_type class instance and parsed user credentials in dict
:raises ValueError: If credential format is wrong (eg: bad auth_type)
"""
try:
auth_type, auth_rest = creds.split(':', 1)
except ValueError:
raise ValueError("Missing ':' in %s" % creds)
authtypes = sys.modules[__name__]
auth_encoder = getattr(authtypes, auth_type.title(), None)
if auth_encoder is None:
raise ValueError('Invalid auth_type: %s' % auth_type)
auth_encoder = auth_encoder()
parsed_creds = dict(type=auth_type, salt=None, hash=None)
parsed_creds.update(auth_encoder.validate(auth_rest))
return auth_encoder, parsed_creds | [
"def",
"validate_creds",
"(",
"creds",
")",
":",
"try",
":",
"auth_type",
",",
"auth_rest",
"=",
"creds",
".",
"split",
"(",
"':'",
",",
"1",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"\"Missing ':' in %s\"",
"%",
"creds",
")",
"authtypes",
"=",
"sys",
".",
"modules",
"[",
"__name__",
"]",
"auth_encoder",
"=",
"getattr",
"(",
"authtypes",
",",
"auth_type",
".",
"title",
"(",
")",
",",
"None",
")",
"if",
"auth_encoder",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Invalid auth_type: %s'",
"%",
"auth_type",
")",
"auth_encoder",
"=",
"auth_encoder",
"(",
")",
"parsed_creds",
"=",
"dict",
"(",
"type",
"=",
"auth_type",
",",
"salt",
"=",
"None",
",",
"hash",
"=",
"None",
")",
"parsed_creds",
".",
"update",
"(",
"auth_encoder",
".",
"validate",
"(",
"auth_rest",
")",
")",
"return",
"auth_encoder",
",",
"parsed_creds"
] | Parse and validate user credentials whether format is right
:param creds: User credentials
:returns: Auth_type class instance and parsed user credentials in dict
:raises ValueError: If credential format is wrong (eg: bad auth_type) | [
"Parse",
"and",
"validate",
"user",
"credentials",
"whether",
"format",
"is",
"right"
] | train | https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/authtypes.py#L42-L60 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Parse and validate user credentials whether format is right
:param creds: User credentials
:returns: Auth_type class instance and parsed user credentials in dict
:raises ValueError: If credential format is wrong (eg: bad auth_type)
### Response:
def validate_creds(creds):
"""Parse and validate user credentials whether format is right
:param creds: User credentials
:returns: Auth_type class instance and parsed user credentials in dict
:raises ValueError: If credential format is wrong (eg: bad auth_type)
"""
try:
auth_type, auth_rest = creds.split(':', 1)
except ValueError:
raise ValueError("Missing ':' in %s" % creds)
authtypes = sys.modules[__name__]
auth_encoder = getattr(authtypes, auth_type.title(), None)
if auth_encoder is None:
raise ValueError('Invalid auth_type: %s' % auth_type)
auth_encoder = auth_encoder()
parsed_creds = dict(type=auth_type, salt=None, hash=None)
parsed_creds.update(auth_encoder.validate(auth_rest))
return auth_encoder, parsed_creds
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14802,
323,
9788,
1217,
16792,
3508,
3645,
374,
1314,
271,
262,
551,
913,
74277,
25,
2724,
16792,
198,
262,
551,
4310,
25,
7517,
1857,
538,
2937,
323,
16051,
1217,
16792,
304,
6587,
198,
262,
551,
33371,
15764,
25,
1442,
41307,
3645,
374,
5076,
320,
797,
25,
3958,
4259,
1857,
696,
14711,
6075,
512,
755,
9788,
669,
54469,
7,
86834,
997,
262,
4304,
14802,
323,
9788,
1217,
16792,
3508,
3645,
374,
1314,
271,
262,
551,
913,
74277,
25,
2724,
16792,
198,
262,
551,
4310,
25,
7517,
1857,
538,
2937,
323,
16051,
1217,
16792,
304,
6587,
198,
262,
551,
33371,
15764,
25,
1442,
41307,
3645,
374,
5076,
320,
797,
25,
3958,
4259,
1857,
340,
262,
3270,
262,
1456,
512,
286,
4259,
1857,
11,
4259,
33331,
284,
74277,
5402,
97680,
220,
16,
340,
262,
3734,
15764,
512,
286,
4933,
15764,
446,
26136,
37404,
304,
1034,
82,
1,
1034,
74277,
340,
262,
3154,
427,
1842,
284,
5826,
27904,
93247,
609,
565,
933,
262,
4259,
40168,
284,
31097,
7,
2784,
427,
1842,
11,
4259,
1857,
6195,
1535,
2290,
340,
262,
422,
4259,
40168,
374,
2290,
512,
286,
4933,
15764,
493,
8087,
4259,
1857,
25,
1034,
82,
6,
1034,
4259,
1857,
340,
262,
4259,
40168,
284,
4259,
40168,
746,
262,
16051,
669,
54469,
284,
6587,
5930,
28,
3322,
1857,
11,
12290,
5980,
11,
5286,
5980,
340,
262,
16051,
669,
54469,
5430,
28535,
40168,
20090,
28535,
33331,
1192,
262,
471,
4259,
40168,
11,
16051,
669,
54469,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14802,
323,
9788,
1217,
16792,
3508,
3645,
374,
1314,
271,
262,
551,
913,
74277,
25,
2724,
16792,
198,
262,
551,
4310,
25,
7517,
1857,
538,
2937,
323,
16051,
1217,
16792,
304,
6587,
198,
262,
551,
33371,
15764,
25,
1442,
41307,
3645,
374,
5076,
320,
797,
25,
3958,
4259,
1857,
696,
14711,
6075,
512,
755,
9788,
669,
54469,
7,
86834,
997,
262,
4304,
14802,
323,
9788,
1217,
16792,
3508,
3645,
374,
1314,
271,
262,
551,
913,
74277,
25,
2724,
16792,
198,
262,
551,
4310,
25,
7517,
1857,
538,
2937,
323,
16051,
1217,
16792,
304,
6587,
198,
262,
551,
33371,
15764,
25,
1442,
41307,
3645,
374,
5076,
320,
797,
25,
3958,
4259,
1857,
340,
262,
3270,
262,
1456,
512,
286,
4259,
1857,
11,
4259,
33331,
284,
74277,
5402,
97680,
220,
16,
340,
262,
3734,
15764,
512,
286,
4933,
15764,
446,
26136,
37404,
304,
1034,
82,
1,
1034,
74277,
340,
262,
3154,
427,
1842,
284,
5826,
27904,
93247,
609,
565,
933,
262,
4259,
40168,
284,
31097,
7,
2784,
427,
1842,
11,
4259,
1857,
6195,
1535,
2290,
340,
262,
422,
4259,
40168,
374,
2290,
512,
286,
4933,
15764,
493,
8087,
4259,
1857,
25,
1034,
82,
6,
1034,
4259,
1857,
340,
262,
4259,
40168,
284,
4259,
40168,
746,
262,
16051,
669,
54469,
284,
6587,
5930,
28,
3322,
1857,
11,
12290,
5980,
11,
5286,
5980,
340,
262,
16051,
669,
54469,
5430,
28535,
40168,
20090,
28535,
33331,
1192,
262,
471,
4259,
40168,
11,
16051,
669,
54469,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
log2timeline/dfdatetime | dfdatetime/fake_time.py | FakeTime._GetNormalizedTimestamp | def _GetNormalizedTimestamp(self):
"""Retrieves the normalized timestamp.
Returns:
decimal.Decimal: normalized timestamp, which contains the number of
seconds since January 1, 1970 00:00:00 and a fraction of second used
for increased precision, or None if the normalized timestamp cannot be
determined.
"""
if self._normalized_timestamp is None:
if self._number_of_seconds is not None:
self._normalized_timestamp = (
decimal.Decimal(self._microseconds) /
definitions.MICROSECONDS_PER_SECOND)
self._normalized_timestamp += decimal.Decimal(self._number_of_seconds)
return self._normalized_timestamp | python | def _GetNormalizedTimestamp(self):
"""Retrieves the normalized timestamp.
Returns:
decimal.Decimal: normalized timestamp, which contains the number of
seconds since January 1, 1970 00:00:00 and a fraction of second used
for increased precision, or None if the normalized timestamp cannot be
determined.
"""
if self._normalized_timestamp is None:
if self._number_of_seconds is not None:
self._normalized_timestamp = (
decimal.Decimal(self._microseconds) /
definitions.MICROSECONDS_PER_SECOND)
self._normalized_timestamp += decimal.Decimal(self._number_of_seconds)
return self._normalized_timestamp | [
"def",
"_GetNormalizedTimestamp",
"(",
"self",
")",
":",
"if",
"self",
".",
"_normalized_timestamp",
"is",
"None",
":",
"if",
"self",
".",
"_number_of_seconds",
"is",
"not",
"None",
":",
"self",
".",
"_normalized_timestamp",
"=",
"(",
"decimal",
".",
"Decimal",
"(",
"self",
".",
"_microseconds",
")",
"/",
"definitions",
".",
"MICROSECONDS_PER_SECOND",
")",
"self",
".",
"_normalized_timestamp",
"+=",
"decimal",
".",
"Decimal",
"(",
"self",
".",
"_number_of_seconds",
")",
"return",
"self",
".",
"_normalized_timestamp"
] | Retrieves the normalized timestamp.
Returns:
decimal.Decimal: normalized timestamp, which contains the number of
seconds since January 1, 1970 00:00:00 and a fraction of second used
for increased precision, or None if the normalized timestamp cannot be
determined. | [
"Retrieves",
"the",
"normalized",
"timestamp",
"."
] | train | https://github.com/log2timeline/dfdatetime/blob/141ca4ef1eff3d354b5deaac3d81cb08506f98d6/dfdatetime/fake_time.py#L37-L53 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Retrieves the normalized timestamp.
Returns:
decimal.Decimal: normalized timestamp, which contains the number of
seconds since January 1, 1970 00:00:00 and a fraction of second used
for increased precision, or None if the normalized timestamp cannot be
determined.
### Response:
def _GetNormalizedTimestamp(self):
"""Retrieves the normalized timestamp.
Returns:
decimal.Decimal: normalized timestamp, which contains the number of
seconds since January 1, 1970 00:00:00 and a fraction of second used
for increased precision, or None if the normalized timestamp cannot be
determined.
"""
if self._normalized_timestamp is None:
if self._number_of_seconds is not None:
self._normalized_timestamp = (
decimal.Decimal(self._microseconds) /
definitions.MICROSECONDS_PER_SECOND)
self._normalized_timestamp += decimal.Decimal(self._number_of_seconds)
return self._normalized_timestamp
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
12289,
7379,
2396,
279,
30510,
11695,
382,
262,
5295,
512,
415,
12395,
41775,
25,
30510,
11695,
11,
902,
5727,
279,
1396,
315,
198,
692,
6622,
2533,
6186,
220,
16,
11,
220,
4468,
15,
220,
410,
25,
410,
25,
410,
323,
264,
19983,
315,
2132,
1511,
198,
692,
369,
7319,
16437,
11,
477,
2290,
422,
279,
30510,
11695,
4250,
387,
198,
692,
11075,
382,
14711,
6075,
512,
755,
721,
1991,
80182,
21479,
1214,
997,
262,
4304,
12289,
7379,
2396,
279,
30510,
11695,
382,
262,
5295,
512,
415,
12395,
41775,
25,
30510,
11695,
11,
902,
5727,
279,
1396,
315,
198,
692,
6622,
2533,
6186,
220,
16,
11,
220,
4468,
15,
220,
410,
25,
410,
25,
410,
323,
264,
19983,
315,
2132,
1511,
198,
692,
369,
7319,
16437,
11,
477,
2290,
422,
279,
30510,
11695,
4250,
387,
198,
692,
11075,
627,
262,
3270,
262,
422,
659,
1462,
39560,
23943,
374,
2290,
512,
415,
422,
659,
1462,
4174,
3659,
35925,
374,
539,
2290,
512,
286,
659,
1462,
39560,
23943,
284,
2456,
310,
12395,
41775,
1214,
1462,
41543,
17859,
8,
40081,
310,
17931,
1345,
1341,
1308,
937,
28002,
10842,
57324,
340,
286,
659,
1462,
39560,
23943,
1447,
12395,
41775,
1214,
1462,
4174,
3659,
35925,
696,
262,
471,
659,
1462,
39560,
23943,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
12289,
7379,
2396,
279,
30510,
11695,
382,
262,
5295,
512,
415,
12395,
41775,
25,
30510,
11695,
11,
902,
5727,
279,
1396,
315,
198,
692,
6622,
2533,
6186,
220,
16,
11,
220,
4468,
15,
220,
410,
25,
410,
25,
410,
323,
264,
19983,
315,
2132,
1511,
198,
692,
369,
7319,
16437,
11,
477,
2290,
422,
279,
30510,
11695,
4250,
387,
198,
692,
11075,
382,
14711,
6075,
512,
755,
721,
1991,
80182,
21479,
1214,
997,
262,
4304,
12289,
7379,
2396,
279,
30510,
11695,
382,
262,
5295,
512,
415,
12395,
41775,
25,
30510,
11695,
11,
902,
5727,
279,
1396,
315,
198,
692,
6622,
2533,
6186,
220,
16,
11,
220,
4468,
15,
220,
410,
25,
410,
25,
410,
323,
264,
19983,
315,
2132,
1511,
198,
692,
369,
7319,
16437,
11,
477,
2290,
422,
279,
30510,
11695,
4250,
387,
198,
692,
11075,
627,
262,
3270,
262,
422,
659,
1462,
39560,
23943,
374,
2290,
512,
415,
422,
659,
1462,
4174,
3659,
35925,
374,
539,
2290,
512,
286,
659,
1462,
39560,
23943,
284,
2456,
310,
12395,
41775,
1214,
1462,
41543,
17859,
8,
40081,
310,
17931,
1345,
1341,
1308,
937,
28002,
10842,
57324,
340,
286,
659,
1462,
39560,
23943,
1447,
12395,
41775,
1214,
1462,
4174,
3659,
35925,
696,
262,
471,
659,
1462,
39560,
23943,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pkgw/pwkit | pwkit/inifile.py | write_stream | def write_stream (stream, holders, defaultsection=None):
"""Very simple writing in ini format. The simple stringification of each value
in each Holder is printed, and no escaping is performed. (This is most
relevant for multiline values or ones containing pound signs.) `None` values are
skipped.
Arguments:
stream
A text stream to write to.
holders
An iterable of objects to write. Their fields will be
written as sections.
defaultsection=None
Section name to use if a holder doesn't contain a
`section` field.
"""
anybefore = False
for h in holders:
if anybefore:
print ('', file=stream)
s = h.get ('section', defaultsection)
if s is None:
raise ValueError ('cannot determine section name for item <%s>' % h)
print ('[%s]' % s, file=stream)
for k in sorted (x for x in six.iterkeys (h.__dict__) if x != 'section'):
v = h.get (k)
if v is None:
continue
print ('%s = %s' % (k, v), file=stream)
anybefore = True | python | def write_stream (stream, holders, defaultsection=None):
"""Very simple writing in ini format. The simple stringification of each value
in each Holder is printed, and no escaping is performed. (This is most
relevant for multiline values or ones containing pound signs.) `None` values are
skipped.
Arguments:
stream
A text stream to write to.
holders
An iterable of objects to write. Their fields will be
written as sections.
defaultsection=None
Section name to use if a holder doesn't contain a
`section` field.
"""
anybefore = False
for h in holders:
if anybefore:
print ('', file=stream)
s = h.get ('section', defaultsection)
if s is None:
raise ValueError ('cannot determine section name for item <%s>' % h)
print ('[%s]' % s, file=stream)
for k in sorted (x for x in six.iterkeys (h.__dict__) if x != 'section'):
v = h.get (k)
if v is None:
continue
print ('%s = %s' % (k, v), file=stream)
anybefore = True | [
"def",
"write_stream",
"(",
"stream",
",",
"holders",
",",
"defaultsection",
"=",
"None",
")",
":",
"anybefore",
"=",
"False",
"for",
"h",
"in",
"holders",
":",
"if",
"anybefore",
":",
"print",
"(",
"''",
",",
"file",
"=",
"stream",
")",
"s",
"=",
"h",
".",
"get",
"(",
"'section'",
",",
"defaultsection",
")",
"if",
"s",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'cannot determine section name for item <%s>'",
"%",
"h",
")",
"print",
"(",
"'[%s]'",
"%",
"s",
",",
"file",
"=",
"stream",
")",
"for",
"k",
"in",
"sorted",
"(",
"x",
"for",
"x",
"in",
"six",
".",
"iterkeys",
"(",
"h",
".",
"__dict__",
")",
"if",
"x",
"!=",
"'section'",
")",
":",
"v",
"=",
"h",
".",
"get",
"(",
"k",
")",
"if",
"v",
"is",
"None",
":",
"continue",
"print",
"(",
"'%s = %s'",
"%",
"(",
"k",
",",
"v",
")",
",",
"file",
"=",
"stream",
")",
"anybefore",
"=",
"True"
] | Very simple writing in ini format. The simple stringification of each value
in each Holder is printed, and no escaping is performed. (This is most
relevant for multiline values or ones containing pound signs.) `None` values are
skipped.
Arguments:
stream
A text stream to write to.
holders
An iterable of objects to write. Their fields will be
written as sections.
defaultsection=None
Section name to use if a holder doesn't contain a
`section` field. | [
"Very",
"simple",
"writing",
"in",
"ini",
"format",
".",
"The",
"simple",
"stringification",
"of",
"each",
"value",
"in",
"each",
"Holder",
"is",
"printed",
"and",
"no",
"escaping",
"is",
"performed",
".",
"(",
"This",
"is",
"most",
"relevant",
"for",
"multiline",
"values",
"or",
"ones",
"containing",
"pound",
"signs",
".",
")",
"None",
"values",
"are",
"skipped",
"."
] | train | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/inifile.py#L120-L156 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Very simple writing in ini format. The simple stringification of each value
in each Holder is printed, and no escaping is performed. (This is most
relevant for multiline values or ones containing pound signs.) `None` values are
skipped.
Arguments:
stream
A text stream to write to.
holders
An iterable of objects to write. Their fields will be
written as sections.
defaultsection=None
Section name to use if a holder doesn't contain a
`section` field.
### Response:
def write_stream (stream, holders, defaultsection=None):
"""Very simple writing in ini format. The simple stringification of each value
in each Holder is printed, and no escaping is performed. (This is most
relevant for multiline values or ones containing pound signs.) `None` values are
skipped.
Arguments:
stream
A text stream to write to.
holders
An iterable of objects to write. Their fields will be
written as sections.
defaultsection=None
Section name to use if a holder doesn't contain a
`section` field.
"""
anybefore = False
for h in holders:
if anybefore:
print ('', file=stream)
s = h.get ('section', defaultsection)
if s is None:
raise ValueError ('cannot determine section name for item <%s>' % h)
print ('[%s]' % s, file=stream)
for k in sorted (x for x in six.iterkeys (h.__dict__) if x != 'section'):
v = h.get (k)
if v is None:
continue
print ('%s = %s' % (k, v), file=stream)
anybefore = True
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
26840,
4382,
4477,
304,
17225,
3645,
13,
578,
4382,
925,
2461,
315,
1855,
907,
198,
262,
304,
1855,
41433,
374,
17124,
11,
323,
912,
53754,
374,
10887,
13,
320,
2028,
374,
1455,
198,
262,
9959,
369,
86318,
2819,
477,
6305,
8649,
31123,
12195,
6266,
1595,
4155,
63,
2819,
527,
198,
262,
36257,
382,
262,
28802,
1473,
262,
4365,
198,
415,
362,
1495,
4365,
311,
3350,
311,
627,
262,
29809,
198,
415,
1556,
51934,
315,
6302,
311,
3350,
13,
11205,
5151,
690,
387,
198,
415,
5439,
439,
14491,
627,
262,
1670,
2879,
5980,
198,
415,
11360,
836,
311,
1005,
422,
264,
12102,
3250,
956,
6782,
264,
198,
415,
1595,
2879,
63,
2115,
382,
14711,
6075,
512,
755,
3350,
12962,
320,
4116,
11,
29809,
11,
1670,
2879,
5980,
997,
262,
4304,
26840,
4382,
4477,
304,
17225,
3645,
13,
578,
4382,
925,
2461,
315,
1855,
907,
198,
262,
304,
1855,
41433,
374,
17124,
11,
323,
912,
53754,
374,
10887,
13,
320,
2028,
374,
1455,
198,
262,
9959,
369,
86318,
2819,
477,
6305,
8649,
31123,
12195,
6266,
1595,
4155,
63,
2819,
527,
198,
262,
36257,
382,
262,
28802,
1473,
262,
4365,
198,
415,
362,
1495,
4365,
311,
3350,
311,
627,
262,
29809,
198,
415,
1556,
51934,
315,
6302,
311,
3350,
13,
11205,
5151,
690,
387,
198,
415,
5439,
439,
14491,
627,
262,
1670,
2879,
5980,
198,
415,
11360,
836,
311,
1005,
422,
264,
12102,
3250,
956,
6782,
264,
198,
415,
1595,
2879,
63,
2115,
382,
262,
3270,
262,
904,
15145,
284,
3641,
271,
262,
369,
305,
304,
29809,
512,
286,
422,
904,
15145,
512,
310,
1194,
4417,
518,
1052,
28,
4116,
696,
286,
274,
284,
305,
673,
4417,
2879,
518,
1670,
2879,
340,
286,
422,
274,
374,
2290,
512,
310,
4933,
15764,
4417,
34360,
8417,
3857,
836,
369,
1537,
60330,
82,
5709,
1034,
305,
340,
286,
1194,
4417,
26170,
82,
31751,
1034,
274,
11,
1052,
28,
4116,
696,
286,
369,
597,
304,
10839,
320,
87,
369,
865,
304,
4848,
20036,
10786,
320,
71,
4952,
8644,
19688,
422,
865,
976,
364,
2879,
11290,
310,
348,
284,
305,
673,
320,
74,
340,
310,
422,
348,
374,
2290,
512,
394,
3136,
271,
310,
1194,
4417,
4,
82,
284,
1034,
82,
6,
1034,
320,
74,
11,
348,
705,
1052,
28,
4116,
696,
286,
904,
15145,
284,
3082,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
26840,
4382,
4477,
304,
17225,
3645,
13,
578,
4382,
925,
2461,
315,
1855,
907,
198,
262,
304,
1855,
41433,
374,
17124,
11,
323,
912,
53754,
374,
10887,
13,
320,
2028,
374,
1455,
198,
262,
9959,
369,
86318,
2819,
477,
6305,
8649,
31123,
12195,
6266,
1595,
4155,
63,
2819,
527,
198,
262,
36257,
382,
262,
28802,
1473,
262,
4365,
198,
415,
362,
1495,
4365,
311,
3350,
311,
627,
262,
29809,
198,
415,
1556,
51934,
315,
6302,
311,
3350,
13,
11205,
5151,
690,
387,
198,
415,
5439,
439,
14491,
627,
262,
1670,
2879,
5980,
198,
415,
11360,
836,
311,
1005,
422,
264,
12102,
3250,
956,
6782,
264,
198,
415,
1595,
2879,
63,
2115,
382,
14711,
6075,
512,
755,
3350,
12962,
320,
4116,
11,
29809,
11,
1670,
2879,
5980,
997,
262,
4304,
26840,
4382,
4477,
304,
17225,
3645,
13,
578,
4382,
925,
2461,
315,
1855,
907,
198,
262,
304,
1855,
41433,
374,
17124,
11,
323,
912,
53754,
374,
10887,
13,
320,
2028,
374,
1455,
198,
262,
9959,
369,
86318,
2819,
477,
6305,
8649,
31123,
12195,
6266,
1595,
4155,
63,
2819,
527,
198,
262,
36257,
382,
262,
28802,
1473,
262,
4365,
198,
415,
362,
1495,
4365,
311,
3350,
311,
627,
262,
29809,
198,
415,
1556,
51934,
315,
6302,
311,
3350,
13,
11205,
5151,
690,
387,
198,
415,
5439,
439,
14491,
627,
262,
1670,
2879,
5980,
198,
415,
11360,
836,
311,
1005,
422,
264,
12102,
3250,
956,
6782,
264,
198,
415,
1595,
2879,
63,
2115,
382,
262,
3270,
262,
904,
15145,
284,
3641,
271,
262,
369,
305,
304,
29809,
512,
286,
422,
904,
15145,
512,
310,
1194,
4417,
518,
1052,
28,
4116,
696,
286,
274,
284,
305,
673,
4417,
2879,
518,
1670,
2879,
340,
286,
422,
274,
374,
2290,
512,
310,
4933,
15764,
4417,
34360,
8417,
3857,
836,
369,
1537,
60330,
82,
5709,
1034,
305,
340,
286,
1194,
4417,
26170,
82,
31751,
1034,
274,
11,
1052,
28,
4116,
696,
286,
369,
597,
304,
10839,
320,
87,
369,
865,
304,
4848,
20036,
10786,
320,
71,
4952,
8644,
19688,
422,
865,
976,
364,
2879,
11290,
310,
348,
284,
305,
673,
320,
74,
340,
310,
422,
348,
374,
2290,
512,
394,
3136,
271,
310,
1194,
4417,
4,
82,
284,
1034,
82,
6,
1034,
320,
74,
11,
348,
705,
1052,
28,
4116,
696,
286,
904,
15145,
284,
3082,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
jasonrbriggs/stomp.py | stomp/transport.py | Transport.receive | def receive(self):
"""
:rtype: bytes
"""
try:
return self.socket.recv(self.__recv_bytes)
except socket.error:
_, e, _ = sys.exc_info()
if get_errno(e) in (errno.EAGAIN, errno.EINTR):
log.debug("socket read interrupted, restarting")
raise exception.InterruptedException()
if self.is_connected():
raise | python | def receive(self):
"""
:rtype: bytes
"""
try:
return self.socket.recv(self.__recv_bytes)
except socket.error:
_, e, _ = sys.exc_info()
if get_errno(e) in (errno.EAGAIN, errno.EINTR):
log.debug("socket read interrupted, restarting")
raise exception.InterruptedException()
if self.is_connected():
raise | [
"def",
"receive",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"socket",
".",
"recv",
"(",
"self",
".",
"__recv_bytes",
")",
"except",
"socket",
".",
"error",
":",
"_",
",",
"e",
",",
"_",
"=",
"sys",
".",
"exc_info",
"(",
")",
"if",
"get_errno",
"(",
"e",
")",
"in",
"(",
"errno",
".",
"EAGAIN",
",",
"errno",
".",
"EINTR",
")",
":",
"log",
".",
"debug",
"(",
"\"socket read interrupted, restarting\"",
")",
"raise",
"exception",
".",
"InterruptedException",
"(",
")",
"if",
"self",
".",
"is_connected",
"(",
")",
":",
"raise"
] | :rtype: bytes | [
":",
"rtype",
":",
"bytes"
] | train | https://github.com/jasonrbriggs/stomp.py/blob/643843c5fbf25fd24339dd0e69a9411c3d8b94c7/stomp/transport.py#L645-L657 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
:rtype: bytes
### Response:
def receive(self):
"""
:rtype: bytes
"""
try:
return self.socket.recv(self.__recv_bytes)
except socket.error:
_, e, _ = sys.exc_info()
if get_errno(e) in (errno.EAGAIN, errno.EINTR):
log.debug("socket read interrupted, restarting")
raise exception.InterruptedException()
if self.is_connected():
raise
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
25,
33613,
25,
5943,
271,
14711,
6075,
512,
755,
5371,
1214,
997,
286,
3270,
286,
551,
33613,
25,
5943,
198,
286,
3270,
286,
1456,
512,
310,
471,
659,
27015,
41533,
1214,
4952,
35077,
12807,
340,
286,
3734,
7728,
4517,
512,
310,
8523,
384,
11,
721,
284,
5826,
65828,
3186,
746,
310,
422,
636,
38463,
2069,
8,
304,
320,
27477,
5253,
86495,
11,
28053,
5253,
80179,
997,
394,
1515,
8042,
446,
9750,
1373,
37883,
11,
93624,
1158,
394,
4933,
4788,
7522,
10802,
19357,
746,
310,
422,
659,
2124,
44376,
4019,
394,
4933,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
25,
33613,
25,
5943,
271,
14711,
6075,
512,
755,
5371,
1214,
997,
286,
3270,
286,
551,
33613,
25,
5943,
198,
286,
3270,
286,
1456,
512,
310,
471,
659,
27015,
41533,
1214,
4952,
35077,
12807,
340,
286,
3734,
7728,
4517,
512,
310,
8523,
384,
11,
721,
284,
5826,
65828,
3186,
746,
310,
422,
636,
38463,
2069,
8,
304,
320,
27477,
5253,
86495,
11,
28053,
5253,
80179,
997,
394,
1515,
8042,
446,
9750,
1373,
37883,
11,
93624,
1158,
394,
4933,
4788,
7522,
10802,
19357,
746,
310,
422,
659,
2124,
44376,
4019,
394,
4933,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
rdireen/spherepy | spherepy/spherepy.py | TransversePatternUniform.single_val | def single_val(self):
"""return relative error of worst point that might make the data none
symmetric.
"""
sv_t = self._sv(self._tdsphere)
sv_p = self._sv(self._tdsphere)
return (sv_t, sv_p) | python | def single_val(self):
"""return relative error of worst point that might make the data none
symmetric.
"""
sv_t = self._sv(self._tdsphere)
sv_p = self._sv(self._tdsphere)
return (sv_t, sv_p) | [
"def",
"single_val",
"(",
"self",
")",
":",
"sv_t",
"=",
"self",
".",
"_sv",
"(",
"self",
".",
"_tdsphere",
")",
"sv_p",
"=",
"self",
".",
"_sv",
"(",
"self",
".",
"_tdsphere",
")",
"return",
"(",
"sv_t",
",",
"sv_p",
")"
] | return relative error of worst point that might make the data none
symmetric. | [
"return",
"relative",
"error",
"of",
"worst",
"point",
"that",
"might",
"make",
"the",
"data",
"none",
"symmetric",
"."
] | train | https://github.com/rdireen/spherepy/blob/241521401d4d76851d4a1a564a365cfab8e98496/spherepy/spherepy.py#L1235-L1243 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
return relative error of worst point that might make the data none
symmetric.
### Response:
def single_val(self):
"""return relative error of worst point that might make the data none
symmetric.
"""
sv_t = self._sv(self._tdsphere)
sv_p = self._sv(self._tdsphere)
return (sv_t, sv_p)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
693,
8844,
1493,
315,
12047,
1486,
430,
2643,
1304,
279,
828,
7000,
319,
286,
55443,
382,
14711,
6075,
512,
755,
3254,
6320,
1214,
5903,
286,
4304,
693,
8844,
1493,
315,
12047,
1486,
430,
2643,
1304,
279,
828,
7000,
319,
286,
55443,
3304,
286,
26547,
9175,
286,
13871,
530,
284,
659,
1462,
3576,
1214,
1462,
1320,
88510,
1240,
286,
13871,
623,
284,
659,
1462,
3576,
1214,
1462,
1320,
88510,
1240,
9175,
286,
471,
320,
3576,
530,
11,
13871,
623,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
693,
8844,
1493,
315,
12047,
1486,
430,
2643,
1304,
279,
828,
7000,
319,
286,
55443,
382,
14711,
6075,
512,
755,
3254,
6320,
1214,
5903,
286,
4304,
693,
8844,
1493,
315,
12047,
1486,
430,
2643,
1304,
279,
828,
7000,
319,
286,
55443,
3304,
286,
26547,
9175,
286,
13871,
530,
284,
659,
1462,
3576,
1214,
1462,
1320,
88510,
1240,
286,
13871,
623,
284,
659,
1462,
3576,
1214,
1462,
1320,
88510,
1240,
9175,
286,
471,
320,
3576,
530,
11,
13871,
623,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
f3at/feat | src/feat/extern/log/log.py | doLog | def doLog(level, object, category, format, args, where=-1,
filePath=None, line=None):
"""
@param where: what to log file and line number for;
-1 for one frame above log.py; -2 and down for higher up;
a function for a (future) code object
@type where: int or callable
@param filePath: file to show the message as coming from, if caller
knows best
@type filePath: str
@param line: line to show the message as coming from, if caller
knows best
@type line: int
@return: dict of calculated variables, if they needed calculating.
currently contains file and line; this prevents us from
doing this work in the caller when it isn't needed because
of the debug level
"""
ret = {}
if category is None:
category = 'feat'
if args:
message = format % args
else:
message = format
# first all the unlimited ones
if _log_handlers:
if filePath is None and line is None:
(filePath, line) = getFileLine(where=where)
ret['filePath'] = filePath
ret['line'] = line
for handler in _log_handlers:
try:
handler(level, object, category, file, line, message)
except TypeError, e:
raise SystemError("handler %r raised a TypeError: %s" % (
handler, getExceptionMessage(e)))
if level > getCategoryLevel(category):
return ret
if _log_handlers_limited:
if filePath is None and line is None:
(filePath, line) = getFileLine(where=where)
ret['filePath'] = filePath
ret['line'] = line
for handler in _log_handlers_limited:
# set this a second time, just in case there weren't unlimited
# loggers there before
try:
handler(level, object, category, filePath, line, message)
except TypeError, e:
raise SystemError("handler %r raised a TypeError: %s" % (
handler, getExceptionMessage(e)))
return ret | python | def doLog(level, object, category, format, args, where=-1,
filePath=None, line=None):
"""
@param where: what to log file and line number for;
-1 for one frame above log.py; -2 and down for higher up;
a function for a (future) code object
@type where: int or callable
@param filePath: file to show the message as coming from, if caller
knows best
@type filePath: str
@param line: line to show the message as coming from, if caller
knows best
@type line: int
@return: dict of calculated variables, if they needed calculating.
currently contains file and line; this prevents us from
doing this work in the caller when it isn't needed because
of the debug level
"""
ret = {}
if category is None:
category = 'feat'
if args:
message = format % args
else:
message = format
# first all the unlimited ones
if _log_handlers:
if filePath is None and line is None:
(filePath, line) = getFileLine(where=where)
ret['filePath'] = filePath
ret['line'] = line
for handler in _log_handlers:
try:
handler(level, object, category, file, line, message)
except TypeError, e:
raise SystemError("handler %r raised a TypeError: %s" % (
handler, getExceptionMessage(e)))
if level > getCategoryLevel(category):
return ret
if _log_handlers_limited:
if filePath is None and line is None:
(filePath, line) = getFileLine(where=where)
ret['filePath'] = filePath
ret['line'] = line
for handler in _log_handlers_limited:
# set this a second time, just in case there weren't unlimited
# loggers there before
try:
handler(level, object, category, filePath, line, message)
except TypeError, e:
raise SystemError("handler %r raised a TypeError: %s" % (
handler, getExceptionMessage(e)))
return ret | [
"def",
"doLog",
"(",
"level",
",",
"object",
",",
"category",
",",
"format",
",",
"args",
",",
"where",
"=",
"-",
"1",
",",
"filePath",
"=",
"None",
",",
"line",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"category",
"is",
"None",
":",
"category",
"=",
"'feat'",
"if",
"args",
":",
"message",
"=",
"format",
"%",
"args",
"else",
":",
"message",
"=",
"format",
"# first all the unlimited ones",
"if",
"_log_handlers",
":",
"if",
"filePath",
"is",
"None",
"and",
"line",
"is",
"None",
":",
"(",
"filePath",
",",
"line",
")",
"=",
"getFileLine",
"(",
"where",
"=",
"where",
")",
"ret",
"[",
"'filePath'",
"]",
"=",
"filePath",
"ret",
"[",
"'line'",
"]",
"=",
"line",
"for",
"handler",
"in",
"_log_handlers",
":",
"try",
":",
"handler",
"(",
"level",
",",
"object",
",",
"category",
",",
"file",
",",
"line",
",",
"message",
")",
"except",
"TypeError",
",",
"e",
":",
"raise",
"SystemError",
"(",
"\"handler %r raised a TypeError: %s\"",
"%",
"(",
"handler",
",",
"getExceptionMessage",
"(",
"e",
")",
")",
")",
"if",
"level",
">",
"getCategoryLevel",
"(",
"category",
")",
":",
"return",
"ret",
"if",
"_log_handlers_limited",
":",
"if",
"filePath",
"is",
"None",
"and",
"line",
"is",
"None",
":",
"(",
"filePath",
",",
"line",
")",
"=",
"getFileLine",
"(",
"where",
"=",
"where",
")",
"ret",
"[",
"'filePath'",
"]",
"=",
"filePath",
"ret",
"[",
"'line'",
"]",
"=",
"line",
"for",
"handler",
"in",
"_log_handlers_limited",
":",
"# set this a second time, just in case there weren't unlimited",
"# loggers there before",
"try",
":",
"handler",
"(",
"level",
",",
"object",
",",
"category",
",",
"filePath",
",",
"line",
",",
"message",
")",
"except",
"TypeError",
",",
"e",
":",
"raise",
"SystemError",
"(",
"\"handler %r raised a TypeError: %s\"",
"%",
"(",
"handler",
",",
"getExceptionMessage",
"(",
"e",
")",
")",
")",
"return",
"ret"
] | @param where: what to log file and line number for;
-1 for one frame above log.py; -2 and down for higher up;
a function for a (future) code object
@type where: int or callable
@param filePath: file to show the message as coming from, if caller
knows best
@type filePath: str
@param line: line to show the message as coming from, if caller
knows best
@type line: int
@return: dict of calculated variables, if they needed calculating.
currently contains file and line; this prevents us from
doing this work in the caller when it isn't needed because
of the debug level | [
"@param",
"where",
":",
"what",
"to",
"log",
"file",
"and",
"line",
"number",
"for",
";",
"-",
"1",
"for",
"one",
"frame",
"above",
"log",
".",
"py",
";",
"-",
"2",
"and",
"down",
"for",
"higher",
"up",
";",
"a",
"function",
"for",
"a",
"(",
"future",
")",
"code",
"object",
"@type",
"where",
":",
"int",
"or",
"callable",
"@param",
"filePath",
":",
"file",
"to",
"show",
"the",
"message",
"as",
"coming",
"from",
"if",
"caller",
"knows",
"best",
"@type",
"filePath",
":",
"str",
"@param",
"line",
":",
"line",
"to",
"show",
"the",
"message",
"as",
"coming",
"from",
"if",
"caller",
"knows",
"best",
"@type",
"line",
":",
"int"
] | train | https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/extern/log/log.py#L299-L358 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
@param where: what to log file and line number for;
-1 for one frame above log.py; -2 and down for higher up;
a function for a (future) code object
@type where: int or callable
@param filePath: file to show the message as coming from, if caller
knows best
@type filePath: str
@param line: line to show the message as coming from, if caller
knows best
@type line: int
@return: dict of calculated variables, if they needed calculating.
currently contains file and line; this prevents us from
doing this work in the caller when it isn't needed because
of the debug level
### Response:
def doLog(level, object, category, format, args, where=-1,
filePath=None, line=None):
"""
@param where: what to log file and line number for;
-1 for one frame above log.py; -2 and down for higher up;
a function for a (future) code object
@type where: int or callable
@param filePath: file to show the message as coming from, if caller
knows best
@type filePath: str
@param line: line to show the message as coming from, if caller
knows best
@type line: int
@return: dict of calculated variables, if they needed calculating.
currently contains file and line; this prevents us from
doing this work in the caller when it isn't needed because
of the debug level
"""
ret = {}
if category is None:
category = 'feat'
if args:
message = format % args
else:
message = format
# first all the unlimited ones
if _log_handlers:
if filePath is None and line is None:
(filePath, line) = getFileLine(where=where)
ret['filePath'] = filePath
ret['line'] = line
for handler in _log_handlers:
try:
handler(level, object, category, file, line, message)
except TypeError, e:
raise SystemError("handler %r raised a TypeError: %s" % (
handler, getExceptionMessage(e)))
if level > getCategoryLevel(category):
return ret
if _log_handlers_limited:
if filePath is None and line is None:
(filePath, line) = getFileLine(where=where)
ret['filePath'] = filePath
ret['line'] = line
for handler in _log_handlers_limited:
# set this a second time, just in case there weren't unlimited
# loggers there before
try:
handler(level, object, category, filePath, line, message)
except TypeError, e:
raise SystemError("handler %r raised a TypeError: %s" % (
handler, getExceptionMessage(e)))
return ret
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
36913,
1405,
25,
257,
1148,
311,
1515,
1052,
323,
1584,
1396,
369,
280,
2611,
482,
16,
369,
832,
4124,
3485,
1515,
7345,
26,
482,
17,
323,
1523,
369,
5190,
709,
280,
2611,
264,
734,
369,
264,
320,
21733,
8,
2082,
1665,
198,
262,
571,
1337,
220,
1405,
25,
257,
528,
477,
42022,
198,
262,
571,
913,
23420,
25,
220,
1052,
311,
1501,
279,
1984,
439,
5108,
505,
11,
422,
20456,
198,
2611,
8964,
1888,
198,
262,
571,
1337,
220,
23420,
25,
220,
610,
198,
262,
571,
913,
1584,
25,
415,
1584,
311,
1501,
279,
1984,
439,
5108,
505,
11,
422,
20456,
198,
2611,
8964,
1888,
198,
262,
571,
1337,
220,
1584,
25,
415,
528,
271,
262,
571,
693,
25,
6587,
315,
16997,
7482,
11,
422,
814,
4460,
38714,
627,
1835,
5131,
5727,
1052,
323,
1584,
26,
420,
29034,
603,
505,
198,
1835,
3815,
420,
990,
304,
279,
20456,
994,
433,
4536,
956,
4460,
1606,
198,
1835,
315,
279,
7542,
2237,
271,
14711,
6075,
512,
755,
656,
2250,
24593,
11,
1665,
11,
5699,
11,
3645,
11,
2897,
11,
1405,
11065,
16,
345,
262,
23420,
5980,
11,
1584,
5980,
997,
262,
3270,
262,
571,
913,
1405,
25,
257,
1148,
311,
1515,
1052,
323,
1584,
1396,
369,
280,
2611,
482,
16,
369,
832,
4124,
3485,
1515,
7345,
26,
482,
17,
323,
1523,
369,
5190,
709,
280,
2611,
264,
734,
369,
264,
320,
21733,
8,
2082,
1665,
198,
262,
571,
1337,
220,
1405,
25,
257,
528,
477,
42022,
198,
262,
571,
913,
23420,
25,
220,
1052,
311,
1501,
279,
1984,
439,
5108,
505,
11,
422,
20456,
198,
2611,
8964,
1888,
198,
262,
571,
1337,
220,
23420,
25,
220,
610,
198,
262,
571,
913,
1584,
25,
415,
1584,
311,
1501,
279,
1984,
439,
5108,
505,
11,
422,
20456,
198,
2611,
8964,
1888,
198,
262,
571,
1337,
220,
1584,
25,
415,
528,
271,
262,
571,
693,
25,
6587,
315,
16997,
7482,
11,
422,
814,
4460,
38714,
627,
1835,
5131,
5727,
1052,
323,
1584,
26,
420,
29034,
603,
505,
198,
1835,
3815,
420,
990,
304,
279,
20456,
994,
433,
4536,
956,
4460,
1606,
198,
1835,
315,
279,
7542,
2237,
198,
262,
3270,
262,
2160,
284,
10294,
262,
422,
5699,
374,
2290,
512,
286,
5699,
284,
364,
45744,
3961,
262,
422,
2897,
512,
286,
1984,
284,
3645,
1034,
2897,
198,
262,
775,
512,
286,
1984,
284,
3645,
271,
262,
674,
1176,
682,
279,
27862,
6305,
198,
262,
422,
721,
848,
58137,
512,
286,
422,
23420,
374,
2290,
323,
1584,
374,
2290,
512,
310,
320,
37797,
11,
1584,
8,
284,
63542,
2519,
59533,
28,
2940,
340,
286,
2160,
681,
37797,
663,
284,
23420,
198,
286,
2160,
681,
1074,
663,
284,
1584,
198,
286,
369,
7158,
304,
721,
848,
58137,
512,
310,
1456,
512,
394,
7158,
24593,
11,
1665,
11,
5699,
11,
1052,
11,
1584,
11,
1984,
340,
310,
3734,
26082,
11,
384
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
36913,
1405,
25,
257,
1148,
311,
1515,
1052,
323,
1584,
1396,
369,
280,
2611,
482,
16,
369,
832,
4124,
3485,
1515,
7345,
26,
482,
17,
323,
1523,
369,
5190,
709,
280,
2611,
264,
734,
369,
264,
320,
21733,
8,
2082,
1665,
198,
262,
571,
1337,
220,
1405,
25,
257,
528,
477,
42022,
198,
262,
571,
913,
23420,
25,
220,
1052,
311,
1501,
279,
1984,
439,
5108,
505,
11,
422,
20456,
198,
2611,
8964,
1888,
198,
262,
571,
1337,
220,
23420,
25,
220,
610,
198,
262,
571,
913,
1584,
25,
415,
1584,
311,
1501,
279,
1984,
439,
5108,
505,
11,
422,
20456,
198,
2611,
8964,
1888,
198,
262,
571,
1337,
220,
1584,
25,
415,
528,
271,
262,
571,
693,
25,
6587,
315,
16997,
7482,
11,
422,
814,
4460,
38714,
627,
1835,
5131,
5727,
1052,
323,
1584,
26,
420,
29034,
603,
505,
198,
1835,
3815,
420,
990,
304,
279,
20456,
994,
433,
4536,
956,
4460,
1606,
198,
1835,
315,
279,
7542,
2237,
271,
14711,
6075,
512,
755,
656,
2250,
24593,
11,
1665,
11,
5699,
11,
3645,
11,
2897,
11,
1405,
11065,
16,
345,
262,
23420,
5980,
11,
1584,
5980,
997,
262,
3270,
262,
571,
913,
1405,
25,
257,
1148,
311,
1515,
1052,
323,
1584,
1396,
369,
280,
2611,
482,
16,
369,
832,
4124,
3485,
1515,
7345,
26,
482,
17,
323,
1523,
369,
5190,
709,
280,
2611,
264,
734,
369,
264,
320,
21733,
8,
2082,
1665,
198,
262,
571,
1337,
220,
1405,
25,
257,
528,
477,
42022,
198,
262,
571,
913,
23420,
25,
220,
1052,
311,
1501,
279,
1984,
439,
5108,
505,
11,
422,
20456,
198,
2611,
8964,
1888,
198,
262,
571,
1337,
220,
23420,
25,
220,
610,
198,
262,
571,
913,
1584,
25,
415,
1584,
311,
1501,
279,
1984,
439,
5108,
505,
11,
422,
20456,
198,
2611,
8964,
1888,
198,
262,
571,
1337,
220,
1584,
25,
415,
528,
271,
262,
571,
693,
25,
6587,
315,
16997,
7482,
11,
422,
814,
4460,
38714,
627,
1835,
5131,
5727,
1052,
323,
1584,
26,
420,
29034,
603,
505,
198,
1835,
3815,
420,
990,
304,
279,
20456,
994,
433,
4536,
956,
4460,
1606,
198,
1835,
315,
279,
7542,
2237,
198,
262,
3270,
262,
2160,
284,
10294,
262,
422,
5699,
374,
2290,
512,
286,
5699,
284,
364,
45744,
3961,
262,
422,
2897,
512,
286,
1984,
284,
3645,
1034,
2897,
198,
262,
775,
512,
286,
1984,
284,
3645,
271,
262,
674,
1176,
682,
279,
27862,
6305,
198,
262,
422,
721,
848,
58137,
512,
286,
422,
23420,
374,
2290,
323,
1584,
374,
2290,
512,
310,
320,
37797,
11,
1584,
8,
284,
63542,
2519,
59533,
28,
2940,
340,
286,
2160,
681,
37797,
663,
284,
23420,
198,
286,
2160,
681,
1074,
663,
284,
1584,
198,
286,
369,
7158,
304,
721,
848,
58137,
512,
310,
1456,
512,
394,
7158,
24593,
11,
1665,
11,
5699,
11,
1052,
11,
1584,
11,
1984,
340,
310,
3734,
26082,
11,
384
] |
nephila/python-taiga | taiga/models/models.py | Project.add_user_story_status | def add_user_story_status(self, name, **attrs):
"""
Add a UserStory status to the project and returns a
:class:`UserStoryStatus` object.
:param name: name of the :class:`UserStoryStatus`
:param attrs: optional attributes for :class:`UserStoryStatus`
"""
return UserStoryStatuses(self.requester).create(self.id, name, **attrs) | python | def add_user_story_status(self, name, **attrs):
"""
Add a UserStory status to the project and returns a
:class:`UserStoryStatus` object.
:param name: name of the :class:`UserStoryStatus`
:param attrs: optional attributes for :class:`UserStoryStatus`
"""
return UserStoryStatuses(self.requester).create(self.id, name, **attrs) | [
"def",
"add_user_story_status",
"(",
"self",
",",
"name",
",",
"*",
"*",
"attrs",
")",
":",
"return",
"UserStoryStatuses",
"(",
"self",
".",
"requester",
")",
".",
"create",
"(",
"self",
".",
"id",
",",
"name",
",",
"*",
"*",
"attrs",
")"
] | Add a UserStory status to the project and returns a
:class:`UserStoryStatus` object.
:param name: name of the :class:`UserStoryStatus`
:param attrs: optional attributes for :class:`UserStoryStatus` | [
"Add",
"a",
"UserStory",
"status",
"to",
"the",
"project",
"and",
"returns",
"a",
":",
"class",
":",
"UserStoryStatus",
"object",
"."
] | train | https://github.com/nephila/python-taiga/blob/5b471d6b8b59e5d410162a6f1c2f0d4188445a56/taiga/models/models.py#L1300-L1308 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Add a UserStory status to the project and returns a
:class:`UserStoryStatus` object.
:param name: name of the :class:`UserStoryStatus`
:param attrs: optional attributes for :class:`UserStoryStatus`
### Response:
def add_user_story_status(self, name, **attrs):
"""
Add a UserStory status to the project and returns a
:class:`UserStoryStatus` object.
:param name: name of the :class:`UserStoryStatus`
:param attrs: optional attributes for :class:`UserStoryStatus`
"""
return UserStoryStatuses(self.requester).create(self.id, name, **attrs)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2261,
264,
2724,
18422,
2704,
311,
279,
2447,
323,
4780,
264,
198,
286,
551,
1058,
19258,
1502,
18422,
2583,
63,
1665,
382,
286,
551,
913,
836,
25,
836,
315,
279,
551,
1058,
19258,
1502,
18422,
2583,
4077,
286,
551,
913,
16602,
25,
10309,
8365,
369,
551,
1058,
19258,
1502,
18422,
2583,
19884,
14711,
6075,
512,
755,
923,
3398,
67442,
4878,
1214,
11,
836,
11,
3146,
21101,
997,
286,
3270,
286,
2758,
264,
2724,
18422,
2704,
311,
279,
2447,
323,
4780,
264,
198,
286,
551,
1058,
19258,
1502,
18422,
2583,
63,
1665,
382,
286,
551,
913,
836,
25,
836,
315,
279,
551,
1058,
19258,
1502,
18422,
2583,
4077,
286,
551,
913,
16602,
25,
10309,
8365,
369,
551,
1058,
19258,
1502,
18422,
2583,
4077,
286,
3270,
286,
471,
2724,
18422,
2583,
288,
1214,
8387,
261,
570,
3261,
1214,
1801,
11,
836,
11,
3146,
21101,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2261,
264,
2724,
18422,
2704,
311,
279,
2447,
323,
4780,
264,
198,
286,
551,
1058,
19258,
1502,
18422,
2583,
63,
1665,
382,
286,
551,
913,
836,
25,
836,
315,
279,
551,
1058,
19258,
1502,
18422,
2583,
4077,
286,
551,
913,
16602,
25,
10309,
8365,
369,
551,
1058,
19258,
1502,
18422,
2583,
19884,
14711,
6075,
512,
755,
923,
3398,
67442,
4878,
1214,
11,
836,
11,
3146,
21101,
997,
286,
3270,
286,
2758,
264,
2724,
18422,
2704,
311,
279,
2447,
323,
4780,
264,
198,
286,
551,
1058,
19258,
1502,
18422,
2583,
63,
1665,
382,
286,
551,
913,
836,
25,
836,
315,
279,
551,
1058,
19258,
1502,
18422,
2583,
4077,
286,
551,
913,
16602,
25,
10309,
8365,
369,
551,
1058,
19258,
1502,
18422,
2583,
4077,
286,
3270,
286,
471,
2724,
18422,
2583,
288,
1214,
8387,
261,
570,
3261,
1214,
1801,
11,
836,
11,
3146,
21101,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
jborean93/ntlm-auth | ntlm_auth/compute_hash.py | _lmowfv1 | def _lmowfv1(password):
"""
[MS-NLMP] v28.0 2016-07-14
3.3.1 NTLM v1 Authentication
Same function as LMOWFv1 in document to create a one way hash of the
password. Only used in NTLMv1 auth without session security
:param password: The password or hash of the user we are trying to
authenticate with
:return res: A Lan Manager hash of the password supplied
"""
# if the password is a hash, return the LM hash
if re.match(r'^[a-fA-F\d]{32}:[a-fA-F\d]{32}$', password):
lm_hash = binascii.unhexlify(password.split(':')[0])
return lm_hash
# fix the password to upper case and length to 14 bytes
password = password.upper()
lm_pw = password.encode('utf-8')
padding_size = 0 if len(lm_pw) >= 14 else (14 - len(lm_pw))
lm_pw += b"\x00" * padding_size
# do hash
magic_str = b"KGS!@#$%" # page 56 in [MS-NLMP v28.0]
res = b""
dobj = DES(DES.key56_to_key64(lm_pw[0:7]))
res += dobj.encrypt(magic_str)
dobj = DES(DES.key56_to_key64(lm_pw[7:14]))
res += dobj.encrypt(magic_str)
return res | python | def _lmowfv1(password):
"""
[MS-NLMP] v28.0 2016-07-14
3.3.1 NTLM v1 Authentication
Same function as LMOWFv1 in document to create a one way hash of the
password. Only used in NTLMv1 auth without session security
:param password: The password or hash of the user we are trying to
authenticate with
:return res: A Lan Manager hash of the password supplied
"""
# if the password is a hash, return the LM hash
if re.match(r'^[a-fA-F\d]{32}:[a-fA-F\d]{32}$', password):
lm_hash = binascii.unhexlify(password.split(':')[0])
return lm_hash
# fix the password to upper case and length to 14 bytes
password = password.upper()
lm_pw = password.encode('utf-8')
padding_size = 0 if len(lm_pw) >= 14 else (14 - len(lm_pw))
lm_pw += b"\x00" * padding_size
# do hash
magic_str = b"KGS!@#$%" # page 56 in [MS-NLMP v28.0]
res = b""
dobj = DES(DES.key56_to_key64(lm_pw[0:7]))
res += dobj.encrypt(magic_str)
dobj = DES(DES.key56_to_key64(lm_pw[7:14]))
res += dobj.encrypt(magic_str)
return res | [
"def",
"_lmowfv1",
"(",
"password",
")",
":",
"# if the password is a hash, return the LM hash",
"if",
"re",
".",
"match",
"(",
"r'^[a-fA-F\\d]{32}:[a-fA-F\\d]{32}$'",
",",
"password",
")",
":",
"lm_hash",
"=",
"binascii",
".",
"unhexlify",
"(",
"password",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]",
")",
"return",
"lm_hash",
"# fix the password to upper case and length to 14 bytes",
"password",
"=",
"password",
".",
"upper",
"(",
")",
"lm_pw",
"=",
"password",
".",
"encode",
"(",
"'utf-8'",
")",
"padding_size",
"=",
"0",
"if",
"len",
"(",
"lm_pw",
")",
">=",
"14",
"else",
"(",
"14",
"-",
"len",
"(",
"lm_pw",
")",
")",
"lm_pw",
"+=",
"b\"\\x00\"",
"*",
"padding_size",
"# do hash",
"magic_str",
"=",
"b\"KGS!@#$%\"",
"# page 56 in [MS-NLMP v28.0]",
"res",
"=",
"b\"\"",
"dobj",
"=",
"DES",
"(",
"DES",
".",
"key56_to_key64",
"(",
"lm_pw",
"[",
"0",
":",
"7",
"]",
")",
")",
"res",
"+=",
"dobj",
".",
"encrypt",
"(",
"magic_str",
")",
"dobj",
"=",
"DES",
"(",
"DES",
".",
"key56_to_key64",
"(",
"lm_pw",
"[",
"7",
":",
"14",
"]",
")",
")",
"res",
"+=",
"dobj",
".",
"encrypt",
"(",
"magic_str",
")",
"return",
"res"
] | [MS-NLMP] v28.0 2016-07-14
3.3.1 NTLM v1 Authentication
Same function as LMOWFv1 in document to create a one way hash of the
password. Only used in NTLMv1 auth without session security
:param password: The password or hash of the user we are trying to
authenticate with
:return res: A Lan Manager hash of the password supplied | [
"[",
"MS",
"-",
"NLMP",
"]",
"v28",
".",
"0",
"2016",
"-",
"07",
"-",
"14"
] | train | https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_hash.py#L12-L45 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
[MS-NLMP] v28.0 2016-07-14
3.3.1 NTLM v1 Authentication
Same function as LMOWFv1 in document to create a one way hash of the
password. Only used in NTLMv1 auth without session security
:param password: The password or hash of the user we are trying to
authenticate with
:return res: A Lan Manager hash of the password supplied
### Response:
def _lmowfv1(password):
"""
[MS-NLMP] v28.0 2016-07-14
3.3.1 NTLM v1 Authentication
Same function as LMOWFv1 in document to create a one way hash of the
password. Only used in NTLMv1 auth without session security
:param password: The password or hash of the user we are trying to
authenticate with
:return res: A Lan Manager hash of the password supplied
"""
# if the password is a hash, return the LM hash
if re.match(r'^[a-fA-F\d]{32}:[a-fA-F\d]{32}$', password):
lm_hash = binascii.unhexlify(password.split(':')[0])
return lm_hash
# fix the password to upper case and length to 14 bytes
password = password.upper()
lm_pw = password.encode('utf-8')
padding_size = 0 if len(lm_pw) >= 14 else (14 - len(lm_pw))
lm_pw += b"\x00" * padding_size
# do hash
magic_str = b"KGS!@#$%" # page 56 in [MS-NLMP v28.0]
res = b""
dobj = DES(DES.key56_to_key64(lm_pw[0:7]))
res += dobj.encrypt(magic_str)
dobj = DES(DES.key56_to_key64(lm_pw[7:14]))
res += dobj.encrypt(magic_str)
return res
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
58,
4931,
11500,
43,
5901,
60,
348,
1591,
13,
15,
220,
679,
21,
12,
2589,
12,
975,
271,
262,
220,
18,
13,
18,
13,
16,
18125,
11237,
348,
16,
24446,
198,
262,
26823,
734,
439,
47514,
3387,
37,
85,
16,
304,
2246,
311,
1893,
264,
832,
1648,
5286,
315,
279,
198,
262,
3636,
13,
8442,
1511,
304,
18125,
11237,
85,
16,
4259,
2085,
3882,
4868,
271,
262,
551,
913,
3636,
25,
578,
3636,
477,
5286,
315,
279,
1217,
584,
527,
4560,
311,
198,
286,
34289,
449,
198,
262,
551,
693,
594,
25,
362,
35882,
10790,
5286,
315,
279,
3636,
17665,
271,
14711,
6075,
512,
755,
721,
18244,
363,
28990,
16,
23608,
997,
262,
3270,
262,
510,
4931,
11500,
43,
5901,
60,
348,
1591,
13,
15,
220,
679,
21,
12,
2589,
12,
975,
271,
262,
220,
18,
13,
18,
13,
16,
18125,
11237,
348,
16,
24446,
198,
262,
26823,
734,
439,
47514,
3387,
37,
85,
16,
304,
2246,
311,
1893,
264,
832,
1648,
5286,
315,
279,
198,
262,
3636,
13,
8442,
1511,
304,
18125,
11237,
85,
16,
4259,
2085,
3882,
4868,
271,
262,
551,
913,
3636,
25,
578,
3636,
477,
5286,
315,
279,
1217,
584,
527,
4560,
311,
198,
286,
34289,
449,
198,
262,
551,
693,
594,
25,
362,
35882,
10790,
5286,
315,
279,
3636,
17665,
198,
262,
3270,
262,
674,
422,
279,
3636,
374,
264,
5286,
11,
471,
279,
47514,
5286,
198,
262,
422,
312,
11319,
2666,
20826,
58,
64,
2269,
32,
7424,
35587,
15731,
843,
92,
7407,
64,
2269,
32,
7424,
35587,
15731,
843,
32816,
518,
3636,
997,
286,
41338,
9127,
284,
9736,
24207,
6441,
17757,
56600,
23608,
5402,
92628,
15,
2608,
286,
471,
41338,
9127,
271,
262,
674,
5155,
279,
3636,
311,
8582,
1162,
323,
3160,
311,
220,
975,
5943,
198,
262,
3636,
284,
3636,
34764,
746,
262,
41338,
61281,
284,
3636,
17762,
493,
4867,
12,
23,
1329,
262,
5413,
2424,
284,
220,
15,
422,
2479,
2387,
76,
61281,
8,
2669,
220,
975,
775,
320,
975,
482,
2479,
2387,
76,
61281,
1192,
262,
41338,
61281,
1447,
293,
12200,
87,
410,
1,
353,
5413,
2424,
271,
262,
674,
656,
5286,
198,
262,
11204,
2966,
284,
293,
1,
42,
16929,
0,
31,
49177,
16171,
220,
674,
2199,
220,
3487,
304,
510,
4931,
11500,
43,
5901,
348,
1591,
13,
15,
2595,
262,
594,
284,
293,
90362,
262,
656,
36851,
284,
13022,
7,
39087,
4840,
3487,
2401,
3173,
1227,
2387,
76,
61281,
58,
15,
25,
22,
11147,
262,
594,
1447,
656,
36851,
66426,
1278,
13070,
2966,
696,
262,
656,
36851,
284,
13022,
7,
39087,
4840,
3487,
2401,
3173,
1227,
2387,
76,
61281,
58,
22,
25,
975,
11147,
262,
594,
1447,
656,
36851,
66426,
1278,
13070,
2966,
696,
262,
471,
594,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
58,
4931,
11500,
43,
5901,
60,
348,
1591,
13,
15,
220,
679,
21,
12,
2589,
12,
975,
271,
262,
220,
18,
13,
18,
13,
16,
18125,
11237,
348,
16,
24446,
198,
262,
26823,
734,
439,
47514,
3387,
37,
85,
16,
304,
2246,
311,
1893,
264,
832,
1648,
5286,
315,
279,
198,
262,
3636,
13,
8442,
1511,
304,
18125,
11237,
85,
16,
4259,
2085,
3882,
4868,
271,
262,
551,
913,
3636,
25,
578,
3636,
477,
5286,
315,
279,
1217,
584,
527,
4560,
311,
198,
286,
34289,
449,
198,
262,
551,
693,
594,
25,
362,
35882,
10790,
5286,
315,
279,
3636,
17665,
271,
14711,
6075,
512,
755,
721,
18244,
363,
28990,
16,
23608,
997,
262,
3270,
262,
510,
4931,
11500,
43,
5901,
60,
348,
1591,
13,
15,
220,
679,
21,
12,
2589,
12,
975,
271,
262,
220,
18,
13,
18,
13,
16,
18125,
11237,
348,
16,
24446,
198,
262,
26823,
734,
439,
47514,
3387,
37,
85,
16,
304,
2246,
311,
1893,
264,
832,
1648,
5286,
315,
279,
198,
262,
3636,
13,
8442,
1511,
304,
18125,
11237,
85,
16,
4259,
2085,
3882,
4868,
271,
262,
551,
913,
3636,
25,
578,
3636,
477,
5286,
315,
279,
1217,
584,
527,
4560,
311,
198,
286,
34289,
449,
198,
262,
551,
693,
594,
25,
362,
35882,
10790,
5286,
315,
279,
3636,
17665,
198,
262,
3270,
262,
674,
422,
279,
3636,
374,
264,
5286,
11,
471,
279,
47514,
5286,
198,
262,
422,
312,
11319,
2666,
20826,
58,
64,
2269,
32,
7424,
35587,
15731,
843,
92,
7407,
64,
2269,
32,
7424,
35587,
15731,
843,
32816,
518,
3636,
997,
286,
41338,
9127,
284,
9736,
24207,
6441,
17757,
56600,
23608,
5402,
92628,
15,
2608,
286,
471,
41338,
9127,
271,
262,
674,
5155,
279,
3636,
311,
8582,
1162,
323,
3160,
311,
220,
975,
5943,
198,
262,
3636,
284,
3636,
34764,
746,
262,
41338,
61281,
284,
3636,
17762,
493,
4867,
12,
23,
1329,
262,
5413,
2424,
284,
220,
15,
422,
2479,
2387,
76,
61281,
8,
2669,
220,
975,
775,
320,
975,
482,
2479,
2387,
76,
61281,
1192,
262,
41338,
61281,
1447,
293,
12200,
87,
410,
1,
353,
5413,
2424,
271,
262,
674,
656,
5286,
198,
262,
11204,
2966,
284,
293,
1,
42,
16929,
0,
31,
49177,
16171,
220,
674,
2199,
220,
3487,
304,
510,
4931,
11500,
43,
5901,
348,
1591,
13,
15,
2595,
262,
594,
284,
293,
90362,
262,
656,
36851,
284,
13022,
7,
39087,
4840,
3487,
2401,
3173,
1227,
2387,
76,
61281,
58,
15,
25,
22,
11147,
262,
594,
1447,
656,
36851,
66426,
1278,
13070,
2966,
696,
262,
656,
36851,
284,
13022,
7,
39087,
4840,
3487,
2401,
3173,
1227,
2387,
76,
61281,
58,
22,
25,
975,
11147,
262,
594,
1447,
656,
36851,
66426,
1278,
13070,
2966,
696,
262,
471,
594,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
MycroftAI/adapt | adapt/engine.py | DomainIntentDeterminationEngine._regex_strings | def _regex_strings(self):
"""
A property to link into IntentEngine's _regex_strings.
Warning: this is only for backwards compatiblility and should not be used if you
intend on using domains.
Returns: the domains _regex_strings from its IntentEngine
"""
domain = 0
if domain not in self.domains:
self.register_domain(domain=domain)
return self.domains[domain]._regex_strings | python | def _regex_strings(self):
"""
A property to link into IntentEngine's _regex_strings.
Warning: this is only for backwards compatiblility and should not be used if you
intend on using domains.
Returns: the domains _regex_strings from its IntentEngine
"""
domain = 0
if domain not in self.domains:
self.register_domain(domain=domain)
return self.domains[domain]._regex_strings | [
"def",
"_regex_strings",
"(",
"self",
")",
":",
"domain",
"=",
"0",
"if",
"domain",
"not",
"in",
"self",
".",
"domains",
":",
"self",
".",
"register_domain",
"(",
"domain",
"=",
"domain",
")",
"return",
"self",
".",
"domains",
"[",
"domain",
"]",
".",
"_regex_strings"
] | A property to link into IntentEngine's _regex_strings.
Warning: this is only for backwards compatiblility and should not be used if you
intend on using domains.
Returns: the domains _regex_strings from its IntentEngine | [
"A",
"property",
"to",
"link",
"into",
"IntentEngine",
"s",
"_regex_strings",
"."
] | train | https://github.com/MycroftAI/adapt/blob/334f23248b8e09fb9d84a88398424ec5bd3bae4c/adapt/engine.py#L258-L270 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
A property to link into IntentEngine's _regex_strings.
Warning: this is only for backwards compatiblility and should not be used if you
intend on using domains.
Returns: the domains _regex_strings from its IntentEngine
### Response:
def _regex_strings(self):
"""
A property to link into IntentEngine's _regex_strings.
Warning: this is only for backwards compatiblility and should not be used if you
intend on using domains.
Returns: the domains _regex_strings from its IntentEngine
"""
domain = 0
if domain not in self.domains:
self.register_domain(domain=domain)
return self.domains[domain]._regex_strings
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32,
3424,
311,
2723,
1139,
9005,
4674,
596,
721,
27485,
34600,
382,
286,
27956,
25,
420,
374,
1193,
369,
29512,
12413,
581,
75,
1429,
323,
1288,
539,
387,
1511,
422,
499,
198,
310,
30730,
389,
1701,
31576,
382,
286,
5295,
25,
279,
31576,
721,
27485,
34600,
505,
1202,
9005,
4674,
271,
14711,
6075,
512,
755,
721,
27485,
34600,
1214,
997,
286,
3270,
286,
362,
3424,
311,
2723,
1139,
9005,
4674,
596,
721,
27485,
34600,
382,
286,
27956,
25,
420,
374,
1193,
369,
29512,
12413,
581,
75,
1429,
323,
1288,
539,
387,
1511,
422,
499,
198,
310,
30730,
389,
1701,
31576,
382,
286,
5295,
25,
279,
31576,
721,
27485,
34600,
505,
1202,
9005,
4674,
198,
286,
3270,
286,
8106,
284,
220,
15,
198,
286,
422,
8106,
539,
304,
659,
22151,
1771,
512,
310,
659,
10131,
20715,
42269,
28,
12482,
340,
286,
471,
659,
22151,
1771,
58,
12482,
41081,
27485,
34600,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32,
3424,
311,
2723,
1139,
9005,
4674,
596,
721,
27485,
34600,
382,
286,
27956,
25,
420,
374,
1193,
369,
29512,
12413,
581,
75,
1429,
323,
1288,
539,
387,
1511,
422,
499,
198,
310,
30730,
389,
1701,
31576,
382,
286,
5295,
25,
279,
31576,
721,
27485,
34600,
505,
1202,
9005,
4674,
271,
14711,
6075,
512,
755,
721,
27485,
34600,
1214,
997,
286,
3270,
286,
362,
3424,
311,
2723,
1139,
9005,
4674,
596,
721,
27485,
34600,
382,
286,
27956,
25,
420,
374,
1193,
369,
29512,
12413,
581,
75,
1429,
323,
1288,
539,
387,
1511,
422,
499,
198,
310,
30730,
389,
1701,
31576,
382,
286,
5295,
25,
279,
31576,
721,
27485,
34600,
505,
1202,
9005,
4674,
198,
286,
3270,
286,
8106,
284,
220,
15,
198,
286,
422,
8106,
539,
304,
659,
22151,
1771,
512,
310,
659,
10131,
20715,
42269,
28,
12482,
340,
286,
471,
659,
22151,
1771,
58,
12482,
41081,
27485,
34600,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
devassistant/devassistant | devassistant/gui/gui_helper.py | GuiHelper.menu_item | def menu_item(self, sub_assistant, path):
"""
The function creates a menu item
and assigns signal like select and button-press-event for
manipulation with menu_item. sub_assistant and path
"""
if not sub_assistant[0].icon_path:
menu_item = self.create_menu_item(sub_assistant[0].fullname)
else:
menu_item = self.create_image_menu_item(
sub_assistant[0].fullname, sub_assistant[0].icon_path
)
if sub_assistant[0].description:
menu_item.set_has_tooltip(True)
menu_item.connect("query-tooltip",
self.parent.tooltip_queries,
self.get_formatted_description(sub_assistant[0].description),
)
menu_item.connect("select", self.parent.sub_menu_select, path)
menu_item.connect("button-press-event", self.parent.sub_menu_pressed)
menu_item.show()
return menu_item | python | def menu_item(self, sub_assistant, path):
"""
The function creates a menu item
and assigns signal like select and button-press-event for
manipulation with menu_item. sub_assistant and path
"""
if not sub_assistant[0].icon_path:
menu_item = self.create_menu_item(sub_assistant[0].fullname)
else:
menu_item = self.create_image_menu_item(
sub_assistant[0].fullname, sub_assistant[0].icon_path
)
if sub_assistant[0].description:
menu_item.set_has_tooltip(True)
menu_item.connect("query-tooltip",
self.parent.tooltip_queries,
self.get_formatted_description(sub_assistant[0].description),
)
menu_item.connect("select", self.parent.sub_menu_select, path)
menu_item.connect("button-press-event", self.parent.sub_menu_pressed)
menu_item.show()
return menu_item | [
"def",
"menu_item",
"(",
"self",
",",
"sub_assistant",
",",
"path",
")",
":",
"if",
"not",
"sub_assistant",
"[",
"0",
"]",
".",
"icon_path",
":",
"menu_item",
"=",
"self",
".",
"create_menu_item",
"(",
"sub_assistant",
"[",
"0",
"]",
".",
"fullname",
")",
"else",
":",
"menu_item",
"=",
"self",
".",
"create_image_menu_item",
"(",
"sub_assistant",
"[",
"0",
"]",
".",
"fullname",
",",
"sub_assistant",
"[",
"0",
"]",
".",
"icon_path",
")",
"if",
"sub_assistant",
"[",
"0",
"]",
".",
"description",
":",
"menu_item",
".",
"set_has_tooltip",
"(",
"True",
")",
"menu_item",
".",
"connect",
"(",
"\"query-tooltip\"",
",",
"self",
".",
"parent",
".",
"tooltip_queries",
",",
"self",
".",
"get_formatted_description",
"(",
"sub_assistant",
"[",
"0",
"]",
".",
"description",
")",
",",
")",
"menu_item",
".",
"connect",
"(",
"\"select\"",
",",
"self",
".",
"parent",
".",
"sub_menu_select",
",",
"path",
")",
"menu_item",
".",
"connect",
"(",
"\"button-press-event\"",
",",
"self",
".",
"parent",
".",
"sub_menu_pressed",
")",
"menu_item",
".",
"show",
"(",
")",
"return",
"menu_item"
] | The function creates a menu item
and assigns signal like select and button-press-event for
manipulation with menu_item. sub_assistant and path | [
"The",
"function",
"creates",
"a",
"menu",
"item",
"and",
"assigns",
"signal",
"like",
"select",
"and",
"button",
"-",
"press",
"-",
"event",
"for",
"manipulation",
"with",
"menu_item",
".",
"sub_assistant",
"and",
"path"
] | train | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L224-L245 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
The function creates a menu item
and assigns signal like select and button-press-event for
manipulation with menu_item. sub_assistant and path
### Response:
def menu_item(self, sub_assistant, path):
"""
The function creates a menu item
and assigns signal like select and button-press-event for
manipulation with menu_item. sub_assistant and path
"""
if not sub_assistant[0].icon_path:
menu_item = self.create_menu_item(sub_assistant[0].fullname)
else:
menu_item = self.create_image_menu_item(
sub_assistant[0].fullname, sub_assistant[0].icon_path
)
if sub_assistant[0].description:
menu_item.set_has_tooltip(True)
menu_item.connect("query-tooltip",
self.parent.tooltip_queries,
self.get_formatted_description(sub_assistant[0].description),
)
menu_item.connect("select", self.parent.sub_menu_select, path)
menu_item.connect("button-press-event", self.parent.sub_menu_pressed)
menu_item.show()
return menu_item
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
791,
734,
11705,
264,
5130,
1537,
198,
286,
323,
51012,
8450,
1093,
3373,
323,
3215,
12,
1911,
40787,
369,
198,
286,
34786,
449,
5130,
5752,
13,
1207,
12354,
11451,
323,
1853,
271,
14711,
6075,
512,
755,
5130,
5752,
1214,
11,
1207,
12354,
11451,
11,
1853,
997,
286,
3270,
286,
578,
734,
11705,
264,
5130,
1537,
198,
286,
323,
51012,
8450,
1093,
3373,
323,
3215,
12,
1911,
40787,
369,
198,
286,
34786,
449,
5130,
5752,
13,
1207,
12354,
11451,
323,
1853,
198,
286,
3270,
286,
422,
539,
1207,
12354,
11451,
58,
15,
948,
1965,
2703,
512,
310,
5130,
5752,
284,
659,
2581,
10620,
5752,
10849,
12354,
11451,
58,
15,
948,
45946,
340,
286,
775,
512,
310,
5130,
5752,
284,
659,
2581,
5060,
10620,
5752,
1021,
394,
1207,
12354,
11451,
58,
15,
948,
45946,
11,
1207,
12354,
11451,
58,
15,
948,
1965,
2703,
198,
310,
1763,
286,
422,
1207,
12354,
11451,
58,
15,
948,
4789,
512,
310,
5130,
5752,
995,
22527,
77365,
23922,
340,
310,
5130,
5752,
11034,
446,
1663,
61746,
761,
4700,
659,
8829,
68266,
66688,
345,
4700,
659,
673,
87710,
11703,
10849,
12354,
11451,
58,
15,
948,
4789,
1350,
310,
1763,
286,
5130,
5752,
11034,
446,
1779,
498,
659,
8829,
4407,
10620,
13350,
11,
1853,
340,
286,
5130,
5752,
11034,
446,
2208,
12,
1911,
40787,
498,
659,
8829,
4407,
10620,
47278,
340,
286,
5130,
5752,
5577,
746,
286,
471,
5130,
5752,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
791,
734,
11705,
264,
5130,
1537,
198,
286,
323,
51012,
8450,
1093,
3373,
323,
3215,
12,
1911,
40787,
369,
198,
286,
34786,
449,
5130,
5752,
13,
1207,
12354,
11451,
323,
1853,
271,
14711,
6075,
512,
755,
5130,
5752,
1214,
11,
1207,
12354,
11451,
11,
1853,
997,
286,
3270,
286,
578,
734,
11705,
264,
5130,
1537,
198,
286,
323,
51012,
8450,
1093,
3373,
323,
3215,
12,
1911,
40787,
369,
198,
286,
34786,
449,
5130,
5752,
13,
1207,
12354,
11451,
323,
1853,
198,
286,
3270,
286,
422,
539,
1207,
12354,
11451,
58,
15,
948,
1965,
2703,
512,
310,
5130,
5752,
284,
659,
2581,
10620,
5752,
10849,
12354,
11451,
58,
15,
948,
45946,
340,
286,
775,
512,
310,
5130,
5752,
284,
659,
2581,
5060,
10620,
5752,
1021,
394,
1207,
12354,
11451,
58,
15,
948,
45946,
11,
1207,
12354,
11451,
58,
15,
948,
1965,
2703,
198,
310,
1763,
286,
422,
1207,
12354,
11451,
58,
15,
948,
4789,
512,
310,
5130,
5752,
995,
22527,
77365,
23922,
340,
310,
5130,
5752,
11034,
446,
1663,
61746,
761,
4700,
659,
8829,
68266,
66688,
345,
4700,
659,
673,
87710,
11703,
10849,
12354,
11451,
58,
15,
948,
4789,
1350,
310,
1763,
286,
5130,
5752,
11034,
446,
1779,
498,
659,
8829,
4407,
10620,
13350,
11,
1853,
340,
286,
5130,
5752,
11034,
446,
2208,
12,
1911,
40787,
498,
659,
8829,
4407,
10620,
47278,
340,
286,
5130,
5752,
5577,
746,
286,
471,
5130,
5752,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
blockstack/blockstack-core | blockstack/lib/client.py | get_atlas_peers | def get_atlas_peers(hostport, timeout=30, my_hostport=None, proxy=None):
"""
Get an atlas peer's neighbors.
Return {'status': True, 'peers': [peers]} on success.
Return {'error': ...} on error
"""
assert hostport or proxy, 'need either hostport or proxy'
peers_schema = {
'type': 'object',
'properties': {
'peers': {
'type': 'array',
'items': {
'type': 'string',
'pattern': '^([^:]+):([1-9][0-9]{1,4})$',
},
},
},
'required': [
'peers'
],
}
schema = json_response_schema( peers_schema )
if proxy is None:
proxy = connect_hostport(hostport)
peers = None
try:
peer_list_resp = proxy.get_atlas_peers()
peer_list_resp = json_validate(schema, peer_list_resp)
if json_is_error(peer_list_resp):
return peer_list_resp
# verify that all strings are host:ports
for peer_hostport in peer_list_resp['peers']:
peer_host, peer_port = url_to_host_port(peer_hostport)
if peer_host is None or peer_port is None:
return {'error': 'Server did not return valid Atlas peers', 'http_status': 503}
peers = peer_list_resp
except ValidationError as ve:
if BLOCKSTACK_DEBUG:
log.exception(ve)
resp = {'error': 'Server response did not match expected schema. You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
return resp
except socket.timeout:
log.error("Connection timed out")
resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
return resp
except socket.error as se:
log.error("Connection error {}".format(se.errno))
resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
return resp
except Exception as ee:
if BLOCKSTACK_DEBUG:
log.exception(ee)
log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
resp = {'error': 'Failed to contact Blockstack node {}. Try again with `--debug`.'.format(hostport), 'http_status': 500}
return resp
return peers | python | def get_atlas_peers(hostport, timeout=30, my_hostport=None, proxy=None):
"""
Get an atlas peer's neighbors.
Return {'status': True, 'peers': [peers]} on success.
Return {'error': ...} on error
"""
assert hostport or proxy, 'need either hostport or proxy'
peers_schema = {
'type': 'object',
'properties': {
'peers': {
'type': 'array',
'items': {
'type': 'string',
'pattern': '^([^:]+):([1-9][0-9]{1,4})$',
},
},
},
'required': [
'peers'
],
}
schema = json_response_schema( peers_schema )
if proxy is None:
proxy = connect_hostport(hostport)
peers = None
try:
peer_list_resp = proxy.get_atlas_peers()
peer_list_resp = json_validate(schema, peer_list_resp)
if json_is_error(peer_list_resp):
return peer_list_resp
# verify that all strings are host:ports
for peer_hostport in peer_list_resp['peers']:
peer_host, peer_port = url_to_host_port(peer_hostport)
if peer_host is None or peer_port is None:
return {'error': 'Server did not return valid Atlas peers', 'http_status': 503}
peers = peer_list_resp
except ValidationError as ve:
if BLOCKSTACK_DEBUG:
log.exception(ve)
resp = {'error': 'Server response did not match expected schema. You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
return resp
except socket.timeout:
log.error("Connection timed out")
resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
return resp
except socket.error as se:
log.error("Connection error {}".format(se.errno))
resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
return resp
except Exception as ee:
if BLOCKSTACK_DEBUG:
log.exception(ee)
log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
resp = {'error': 'Failed to contact Blockstack node {}. Try again with `--debug`.'.format(hostport), 'http_status': 500}
return resp
return peers | [
"def",
"get_atlas_peers",
"(",
"hostport",
",",
"timeout",
"=",
"30",
",",
"my_hostport",
"=",
"None",
",",
"proxy",
"=",
"None",
")",
":",
"assert",
"hostport",
"or",
"proxy",
",",
"'need either hostport or proxy'",
"peers_schema",
"=",
"{",
"'type'",
":",
"'object'",
",",
"'properties'",
":",
"{",
"'peers'",
":",
"{",
"'type'",
":",
"'array'",
",",
"'items'",
":",
"{",
"'type'",
":",
"'string'",
",",
"'pattern'",
":",
"'^([^:]+):([1-9][0-9]{1,4})$'",
",",
"}",
",",
"}",
",",
"}",
",",
"'required'",
":",
"[",
"'peers'",
"]",
",",
"}",
"schema",
"=",
"json_response_schema",
"(",
"peers_schema",
")",
"if",
"proxy",
"is",
"None",
":",
"proxy",
"=",
"connect_hostport",
"(",
"hostport",
")",
"peers",
"=",
"None",
"try",
":",
"peer_list_resp",
"=",
"proxy",
".",
"get_atlas_peers",
"(",
")",
"peer_list_resp",
"=",
"json_validate",
"(",
"schema",
",",
"peer_list_resp",
")",
"if",
"json_is_error",
"(",
"peer_list_resp",
")",
":",
"return",
"peer_list_resp",
"# verify that all strings are host:ports",
"for",
"peer_hostport",
"in",
"peer_list_resp",
"[",
"'peers'",
"]",
":",
"peer_host",
",",
"peer_port",
"=",
"url_to_host_port",
"(",
"peer_hostport",
")",
"if",
"peer_host",
"is",
"None",
"or",
"peer_port",
"is",
"None",
":",
"return",
"{",
"'error'",
":",
"'Server did not return valid Atlas peers'",
",",
"'http_status'",
":",
"503",
"}",
"peers",
"=",
"peer_list_resp",
"except",
"ValidationError",
"as",
"ve",
":",
"if",
"BLOCKSTACK_DEBUG",
":",
"log",
".",
"exception",
"(",
"ve",
")",
"resp",
"=",
"{",
"'error'",
":",
"'Server response did not match expected schema. You are likely communicating with an out-of-date Blockstack node.'",
",",
"'http_status'",
":",
"502",
"}",
"return",
"resp",
"except",
"socket",
".",
"timeout",
":",
"log",
".",
"error",
"(",
"\"Connection timed out\"",
")",
"resp",
"=",
"{",
"'error'",
":",
"'Connection to remote host timed out.'",
",",
"'http_status'",
":",
"503",
"}",
"return",
"resp",
"except",
"socket",
".",
"error",
"as",
"se",
":",
"log",
".",
"error",
"(",
"\"Connection error {}\"",
".",
"format",
"(",
"se",
".",
"errno",
")",
")",
"resp",
"=",
"{",
"'error'",
":",
"'Connection to remote host failed.'",
",",
"'http_status'",
":",
"502",
"}",
"return",
"resp",
"except",
"Exception",
"as",
"ee",
":",
"if",
"BLOCKSTACK_DEBUG",
":",
"log",
".",
"exception",
"(",
"ee",
")",
"log",
".",
"error",
"(",
"\"Caught exception while connecting to Blockstack node: {}\"",
".",
"format",
"(",
"ee",
")",
")",
"resp",
"=",
"{",
"'error'",
":",
"'Failed to contact Blockstack node {}. Try again with `--debug`.'",
".",
"format",
"(",
"hostport",
")",
",",
"'http_status'",
":",
"500",
"}",
"return",
"resp",
"return",
"peers"
] | Get an atlas peer's neighbors.
Return {'status': True, 'peers': [peers]} on success.
Return {'error': ...} on error | [
"Get",
"an",
"atlas",
"peer",
"s",
"neighbors",
".",
"Return",
"{",
"status",
":",
"True",
"peers",
":",
"[",
"peers",
"]",
"}",
"on",
"success",
".",
"Return",
"{",
"error",
":",
"...",
"}",
"on",
"error"
] | train | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L648-L717 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Get an atlas peer's neighbors.
Return {'status': True, 'peers': [peers]} on success.
Return {'error': ...} on error
### Response:
def get_atlas_peers(hostport, timeout=30, my_hostport=None, proxy=None):
"""
Get an atlas peer's neighbors.
Return {'status': True, 'peers': [peers]} on success.
Return {'error': ...} on error
"""
assert hostport or proxy, 'need either hostport or proxy'
peers_schema = {
'type': 'object',
'properties': {
'peers': {
'type': 'array',
'items': {
'type': 'string',
'pattern': '^([^:]+):([1-9][0-9]{1,4})$',
},
},
},
'required': [
'peers'
],
}
schema = json_response_schema( peers_schema )
if proxy is None:
proxy = connect_hostport(hostport)
peers = None
try:
peer_list_resp = proxy.get_atlas_peers()
peer_list_resp = json_validate(schema, peer_list_resp)
if json_is_error(peer_list_resp):
return peer_list_resp
# verify that all strings are host:ports
for peer_hostport in peer_list_resp['peers']:
peer_host, peer_port = url_to_host_port(peer_hostport)
if peer_host is None or peer_port is None:
return {'error': 'Server did not return valid Atlas peers', 'http_status': 503}
peers = peer_list_resp
except ValidationError as ve:
if BLOCKSTACK_DEBUG:
log.exception(ve)
resp = {'error': 'Server response did not match expected schema. You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
return resp
except socket.timeout:
log.error("Connection timed out")
resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
return resp
except socket.error as se:
log.error("Connection error {}".format(se.errno))
resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
return resp
except Exception as ee:
if BLOCKSTACK_DEBUG:
log.exception(ee)
log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
resp = {'error': 'Failed to contact Blockstack node {}. Try again with `--debug`.'.format(hostport), 'http_status': 500}
return resp
return peers
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
459,
62032,
14734,
596,
19228,
13,
720,
262,
3494,
5473,
2899,
1232,
3082,
11,
364,
375,
388,
1232,
510,
375,
388,
14316,
389,
2450,
627,
262,
3494,
5473,
850,
1232,
2564,
92,
389,
1493,
271,
14711,
6075,
512,
755,
636,
3837,
14833,
37467,
388,
20569,
403,
11,
9829,
28,
966,
11,
856,
13144,
403,
5980,
11,
13594,
5980,
997,
262,
3270,
262,
2175,
459,
62032,
14734,
596,
19228,
13,
720,
262,
3494,
5473,
2899,
1232,
3082,
11,
364,
375,
388,
1232,
510,
375,
388,
14316,
389,
2450,
627,
262,
3494,
5473,
850,
1232,
2564,
92,
389,
1493,
198,
262,
3270,
262,
2105,
3552,
403,
477,
13594,
11,
364,
17483,
3060,
3552,
403,
477,
13594,
3961,
262,
26081,
26443,
284,
341,
286,
364,
1337,
1232,
364,
1735,
756,
286,
364,
13495,
1232,
341,
310,
364,
375,
388,
1232,
341,
394,
364,
1337,
1232,
364,
1686,
756,
394,
364,
3699,
1232,
341,
504,
364,
1337,
1232,
364,
928,
756,
504,
364,
14676,
1232,
50538,
71219,
25,
7727,
1680,
2625,
16,
12,
24,
1483,
15,
12,
24,
15731,
16,
11,
19,
5525,
3,
756,
394,
1173,
310,
1173,
286,
1173,
286,
364,
6413,
1232,
2330,
310,
364,
375,
388,
1270,
286,
3291,
262,
557,
262,
11036,
284,
3024,
9852,
26443,
7,
26081,
26443,
5235,
262,
422,
13594,
374,
2290,
512,
286,
13594,
284,
4667,
13144,
403,
20569,
403,
696,
262,
26081,
284,
2290,
198,
262,
1456,
512,
286,
14734,
2062,
36260,
284,
13594,
673,
3837,
14833,
37467,
388,
746,
286,
14734,
2062,
36260,
284,
3024,
43781,
43835,
11,
14734,
2062,
36260,
340,
286,
422,
3024,
7037,
4188,
64472,
2062,
36260,
997,
310,
471,
14734,
2062,
36260,
271,
286,
674,
10356,
430,
682,
9246,
527,
3552,
25,
3476,
198,
286,
369,
14734,
13144,
403,
304,
14734,
2062,
36260,
681,
375,
388,
18888,
310,
14734,
13144,
11,
14734,
8889,
284,
2576,
2401,
13144,
8889,
64472,
13144,
403,
340,
310,
422,
14734,
13144,
374,
2290,
477,
14734,
8889,
374,
2290,
512,
394,
471,
5473,
850,
1232,
364,
5592,
1550,
539,
471,
2764,
43443,
26081,
518,
364,
1277,
4878,
1232,
220,
17735,
633,
286,
26081,
284,
14734,
2062,
36260,
271,
262,
3734,
54129,
439,
5320,
512,
286,
422,
29777,
46076,
11386,
512,
310,
1515,
14161,
7,
588,
696,
286,
9216,
284,
5473,
850,
1232,
364,
5592,
2077,
1550,
539,
2489,
3685,
11036,
13,
220,
1472,
527,
4461,
42247,
449,
459,
704,
8838,
18920,
8527,
7848,
2494,
16045,
364,
1277,
4878,
1232,
220,
17824,
534,
286,
471,
9216,
271,
262,
3734,
7728,
37210,
512,
286,
1515,
4517,
446,
4627,
26245,
704,
1158,
286,
9216,
284,
5473,
850,
1232,
364,
4627,
311,
8870,
3552,
26245,
704,
16045,
364,
1277,
4878,
1232,
220,
17735,
534,
286,
471,
9216,
271,
262,
3734,
7728,
4517,
439,
513,
512,
286,
1515,
4517,
446,
4627,
1493,
21532,
2293,
10698,
18948,
2201,
1192,
286,
9216,
284,
5473
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
459,
62032,
14734,
596,
19228,
13,
720,
262,
3494,
5473,
2899,
1232,
3082,
11,
364,
375,
388,
1232,
510,
375,
388,
14316,
389,
2450,
627,
262,
3494,
5473,
850,
1232,
2564,
92,
389,
1493,
271,
14711,
6075,
512,
755,
636,
3837,
14833,
37467,
388,
20569,
403,
11,
9829,
28,
966,
11,
856,
13144,
403,
5980,
11,
13594,
5980,
997,
262,
3270,
262,
2175,
459,
62032,
14734,
596,
19228,
13,
720,
262,
3494,
5473,
2899,
1232,
3082,
11,
364,
375,
388,
1232,
510,
375,
388,
14316,
389,
2450,
627,
262,
3494,
5473,
850,
1232,
2564,
92,
389,
1493,
198,
262,
3270,
262,
2105,
3552,
403,
477,
13594,
11,
364,
17483,
3060,
3552,
403,
477,
13594,
3961,
262,
26081,
26443,
284,
341,
286,
364,
1337,
1232,
364,
1735,
756,
286,
364,
13495,
1232,
341,
310,
364,
375,
388,
1232,
341,
394,
364,
1337,
1232,
364,
1686,
756,
394,
364,
3699,
1232,
341,
504,
364,
1337,
1232,
364,
928,
756,
504,
364,
14676,
1232,
50538,
71219,
25,
7727,
1680,
2625,
16,
12,
24,
1483,
15,
12,
24,
15731,
16,
11,
19,
5525,
3,
756,
394,
1173,
310,
1173,
286,
1173,
286,
364,
6413,
1232,
2330,
310,
364,
375,
388,
1270,
286,
3291,
262,
557,
262,
11036,
284,
3024,
9852,
26443,
7,
26081,
26443,
5235,
262,
422,
13594,
374,
2290,
512,
286,
13594,
284,
4667,
13144,
403,
20569,
403,
696,
262,
26081,
284,
2290,
198,
262,
1456,
512,
286,
14734,
2062,
36260,
284,
13594,
673,
3837,
14833,
37467,
388,
746,
286,
14734,
2062,
36260,
284,
3024,
43781,
43835,
11,
14734,
2062,
36260,
340,
286,
422,
3024,
7037,
4188,
64472,
2062,
36260,
997,
310,
471,
14734,
2062,
36260,
271,
286,
674,
10356,
430,
682,
9246,
527,
3552,
25,
3476,
198,
286,
369,
14734,
13144,
403,
304,
14734,
2062,
36260,
681,
375,
388,
18888,
310,
14734,
13144,
11,
14734,
8889,
284,
2576,
2401,
13144,
8889,
64472,
13144,
403,
340,
310,
422,
14734,
13144,
374,
2290,
477,
14734,
8889,
374,
2290,
512,
394,
471,
5473,
850,
1232,
364,
5592,
1550,
539,
471,
2764,
43443,
26081,
518,
364,
1277,
4878,
1232,
220,
17735,
633,
286,
26081,
284,
14734,
2062,
36260,
271,
262,
3734,
54129,
439,
5320,
512,
286,
422,
29777,
46076,
11386,
512,
310,
1515,
14161,
7,
588,
696,
286,
9216,
284,
5473,
850,
1232,
364,
5592,
2077,
1550,
539,
2489,
3685,
11036,
13,
220,
1472,
527,
4461,
42247,
449,
459,
704,
8838,
18920,
8527,
7848,
2494,
16045,
364,
1277,
4878,
1232,
220,
17824,
534,
286,
471,
9216,
271,
262,
3734,
7728,
37210,
512,
286,
1515,
4517,
446,
4627,
26245,
704,
1158,
286,
9216,
284,
5473,
850,
1232,
364,
4627,
311,
8870,
3552,
26245,
704,
16045,
364,
1277,
4878,
1232,
220,
17735,
534,
286,
471,
9216,
271,
262,
3734,
7728,
4517,
439,
513,
512,
286,
1515,
4517,
446,
4627,
1493,
21532,
2293,
10698,
18948,
2201,
1192,
286,
9216,
284,
5473
] |
expfactory/expfactory | expfactory/experiment.py | load_experiments | def load_experiments(folders):
'''load_experiments
a wrapper for load_experiment to read multiple experiments
:param experiment_folders: a list of experiment folders to load, full paths
'''
experiments = []
if isinstance(folders,str):
folders = [experiment_folders]
for folder in folders:
exp = load_experiment(folder)
experiments.append(exp)
return experiments | python | def load_experiments(folders):
'''load_experiments
a wrapper for load_experiment to read multiple experiments
:param experiment_folders: a list of experiment folders to load, full paths
'''
experiments = []
if isinstance(folders,str):
folders = [experiment_folders]
for folder in folders:
exp = load_experiment(folder)
experiments.append(exp)
return experiments | [
"def",
"load_experiments",
"(",
"folders",
")",
":",
"experiments",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"folders",
",",
"str",
")",
":",
"folders",
"=",
"[",
"experiment_folders",
"]",
"for",
"folder",
"in",
"folders",
":",
"exp",
"=",
"load_experiment",
"(",
"folder",
")",
"experiments",
".",
"append",
"(",
"exp",
")",
"return",
"experiments"
] | load_experiments
a wrapper for load_experiment to read multiple experiments
:param experiment_folders: a list of experiment folders to load, full paths | [
"load_experiments",
"a",
"wrapper",
"for",
"load_experiment",
"to",
"read",
"multiple",
"experiments",
":",
"param",
"experiment_folders",
":",
"a",
"list",
"of",
"experiment",
"folders",
"to",
"load",
"full",
"paths"
] | train | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/experiment.py#L70-L81 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
load_experiments
a wrapper for load_experiment to read multiple experiments
:param experiment_folders: a list of experiment folders to load, full paths
### Response:
def load_experiments(folders):
'''load_experiments
a wrapper for load_experiment to read multiple experiments
:param experiment_folders: a list of experiment folders to load, full paths
'''
experiments = []
if isinstance(folders,str):
folders = [experiment_folders]
for folder in folders:
exp = load_experiment(folder)
experiments.append(exp)
return experiments
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1096,
2769,
50732,
198,
262,
264,
13564,
369,
2865,
83402,
311,
1373,
5361,
21896,
198,
262,
551,
913,
9526,
85028,
25,
264,
1160,
315,
9526,
30342,
311,
2865,
11,
2539,
13006,
271,
14711,
6075,
512,
755,
2865,
2769,
50732,
968,
33220,
997,
262,
11712,
1096,
2769,
50732,
198,
262,
264,
13564,
369,
2865,
83402,
311,
1373,
5361,
21896,
198,
262,
551,
913,
9526,
85028,
25,
264,
1160,
315,
9526,
30342,
311,
2865,
11,
2539,
13006,
198,
262,
11414,
262,
21896,
284,
4260,
262,
422,
11656,
968,
33220,
43421,
997,
286,
30342,
284,
510,
60529,
85028,
933,
262,
369,
8695,
304,
30342,
512,
286,
1367,
284,
2865,
83402,
35029,
340,
286,
21896,
2102,
26950,
340,
262,
471,
21896,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1096,
2769,
50732,
198,
262,
264,
13564,
369,
2865,
83402,
311,
1373,
5361,
21896,
198,
262,
551,
913,
9526,
85028,
25,
264,
1160,
315,
9526,
30342,
311,
2865,
11,
2539,
13006,
271,
14711,
6075,
512,
755,
2865,
2769,
50732,
968,
33220,
997,
262,
11712,
1096,
2769,
50732,
198,
262,
264,
13564,
369,
2865,
83402,
311,
1373,
5361,
21896,
198,
262,
551,
913,
9526,
85028,
25,
264,
1160,
315,
9526,
30342,
311,
2865,
11,
2539,
13006,
198,
262,
11414,
262,
21896,
284,
4260,
262,
422,
11656,
968,
33220,
43421,
997,
286,
30342,
284,
510,
60529,
85028,
933,
262,
369,
8695,
304,
30342,
512,
286,
1367,
284,
2865,
83402,
35029,
340,
286,
21896,
2102,
26950,
340,
262,
471,
21896,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
CTPUG/wafer | wafer/pages/views.py | ShowPage.build_object | def build_object(self, obj):
"""Override django-bakery to skip pages marked exclude_from_static"""
if not obj.exclude_from_static:
super(ShowPage, self).build_object(obj) | python | def build_object(self, obj):
"""Override django-bakery to skip pages marked exclude_from_static"""
if not obj.exclude_from_static:
super(ShowPage, self).build_object(obj) | [
"def",
"build_object",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"obj",
".",
"exclude_from_static",
":",
"super",
"(",
"ShowPage",
",",
"self",
")",
".",
"build_object",
"(",
"obj",
")"
] | Override django-bakery to skip pages marked exclude_from_static | [
"Override",
"django",
"-",
"bakery",
"to",
"skip",
"pages",
"marked",
"exclude_from_static"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/pages/views.py#L23-L26 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Override django-bakery to skip pages marked exclude_from_static
### Response:
def build_object(self, obj):
"""Override django-bakery to skip pages marked exclude_from_static"""
if not obj.exclude_from_static:
super(ShowPage, self).build_object(obj)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2226,
8426,
1481,
587,
727,
311,
10936,
6959,
13160,
22429,
5791,
26430,
271,
14711,
6075,
512,
755,
1977,
5427,
1214,
11,
2909,
997,
286,
4304,
2226,
8426,
1481,
587,
727,
311,
10936,
6959,
13160,
22429,
5791,
26430,
7275,
286,
422,
539,
2909,
91041,
5791,
26430,
512,
310,
2307,
7,
7968,
2732,
11,
659,
570,
5957,
5427,
6922,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2226,
8426,
1481,
587,
727,
311,
10936,
6959,
13160,
22429,
5791,
26430,
271,
14711,
6075,
512,
755,
1977,
5427,
1214,
11,
2909,
997,
286,
4304,
2226,
8426,
1481,
587,
727,
311,
10936,
6959,
13160,
22429,
5791,
26430,
7275,
286,
422,
539,
2909,
91041,
5791,
26430,
512,
310,
2307,
7,
7968,
2732,
11,
659,
570,
5957,
5427,
6922,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
bastibe/SoundFile | soundfile.py | SoundFile._create_empty_array | def _create_empty_array(self, frames, always_2d, dtype):
"""Create an empty array with appropriate shape."""
import numpy as np
if always_2d or self.channels > 1:
shape = frames, self.channels
else:
shape = frames,
return np.empty(shape, dtype, order='C') | python | def _create_empty_array(self, frames, always_2d, dtype):
"""Create an empty array with appropriate shape."""
import numpy as np
if always_2d or self.channels > 1:
shape = frames, self.channels
else:
shape = frames,
return np.empty(shape, dtype, order='C') | [
"def",
"_create_empty_array",
"(",
"self",
",",
"frames",
",",
"always_2d",
",",
"dtype",
")",
":",
"import",
"numpy",
"as",
"np",
"if",
"always_2d",
"or",
"self",
".",
"channels",
">",
"1",
":",
"shape",
"=",
"frames",
",",
"self",
".",
"channels",
"else",
":",
"shape",
"=",
"frames",
",",
"return",
"np",
".",
"empty",
"(",
"shape",
",",
"dtype",
",",
"order",
"=",
"'C'",
")"
] | Create an empty array with appropriate shape. | [
"Create",
"an",
"empty",
"array",
"with",
"appropriate",
"shape",
"."
] | train | https://github.com/bastibe/SoundFile/blob/161e930da9c9ea76579b6ee18a131e10bca8a605/soundfile.py#L1284-L1291 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Create an empty array with appropriate shape.
### Response:
def _create_empty_array(self, frames, always_2d, dtype):
"""Create an empty array with appropriate shape."""
import numpy as np
if always_2d or self.channels > 1:
shape = frames, self.channels
else:
shape = frames,
return np.empty(shape, dtype, order='C')
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4110,
459,
4384,
1358,
449,
8475,
6211,
382,
14711,
6075,
512,
755,
721,
3261,
15475,
3943,
1214,
11,
14418,
11,
2744,
62,
17,
67,
11,
13534,
997,
286,
4304,
4110,
459,
4384,
1358,
449,
8475,
6211,
14781,
286,
1179,
8760,
439,
2660,
198,
286,
422,
2744,
62,
17,
67,
477,
659,
40995,
871,
220,
16,
512,
310,
6211,
284,
14418,
11,
659,
40995,
198,
286,
775,
512,
310,
6211,
284,
14418,
345,
286,
471,
2660,
9357,
27022,
11,
13534,
11,
2015,
1151,
34,
1329,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4110,
459,
4384,
1358,
449,
8475,
6211,
382,
14711,
6075,
512,
755,
721,
3261,
15475,
3943,
1214,
11,
14418,
11,
2744,
62,
17,
67,
11,
13534,
997,
286,
4304,
4110,
459,
4384,
1358,
449,
8475,
6211,
14781,
286,
1179,
8760,
439,
2660,
198,
286,
422,
2744,
62,
17,
67,
477,
659,
40995,
871,
220,
16,
512,
310,
6211,
284,
14418,
11,
659,
40995,
198,
286,
775,
512,
310,
6211,
284,
14418,
345,
286,
471,
2660,
9357,
27022,
11,
13534,
11,
2015,
1151,
34,
1329,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.device_text_string_request | def device_text_string_request(self):
"""Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message.
"""
msg = StandardSend(self._address, COMMAND_FX_USERNAME_0X03_0X01)
self._send_msg(msg) | python | def device_text_string_request(self):
"""Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message.
"""
msg = StandardSend(self._address, COMMAND_FX_USERNAME_0X03_0X01)
self._send_msg(msg) | [
"def",
"device_text_string_request",
"(",
"self",
")",
":",
"msg",
"=",
"StandardSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_FX_USERNAME_0X03_0X01",
")",
"self",
".",
"_send_msg",
"(",
"msg",
")"
] | Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message. | [
"Get",
"FX",
"Username",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L232-L239 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message.
### Response:
def device_text_string_request(self):
"""Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message.
"""
msg = StandardSend(self._address, COMMAND_FX_USERNAME_0X03_0X01)
self._send_msg(msg)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
30001,
30645,
382,
286,
8442,
2631,
369,
7766,
430,
1862,
30001,
48283,
627,
286,
30001,
2758,
417,
4151,
31680,
449,
459,
16421,
220,
15,
87,
14649,
16,
30001,
30645,
6075,
1984,
382,
14711,
6075,
512,
755,
3756,
4424,
3991,
8052,
1214,
997,
286,
4304,
1991,
30001,
30645,
382,
286,
8442,
2631,
369,
7766,
430,
1862,
30001,
48283,
627,
286,
30001,
2758,
417,
4151,
31680,
449,
459,
16421,
220,
15,
87,
14649,
16,
30001,
30645,
6075,
1984,
627,
286,
3270,
286,
3835,
284,
12028,
11764,
1214,
1462,
5102,
11,
41318,
1426,
55,
43796,
62,
15,
55,
2839,
62,
15,
55,
1721,
340,
286,
659,
1462,
6820,
6619,
8282,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
30001,
30645,
382,
286,
8442,
2631,
369,
7766,
430,
1862,
30001,
48283,
627,
286,
30001,
2758,
417,
4151,
31680,
449,
459,
16421,
220,
15,
87,
14649,
16,
30001,
30645,
6075,
1984,
382,
14711,
6075,
512,
755,
3756,
4424,
3991,
8052,
1214,
997,
286,
4304,
1991,
30001,
30645,
382,
286,
8442,
2631,
369,
7766,
430,
1862,
30001,
48283,
627,
286,
30001,
2758,
417,
4151,
31680,
449,
459,
16421,
220,
15,
87,
14649,
16,
30001,
30645,
6075,
1984,
627,
286,
3270,
286,
3835,
284,
12028,
11764,
1214,
1462,
5102,
11,
41318,
1426,
55,
43796,
62,
15,
55,
2839,
62,
15,
55,
1721,
340,
286,
659,
1462,
6820,
6619,
8282,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.