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
apache/incubator-mxnet
python/mxnet/metric.py
np
def np(numpy_feval, name=None, allow_extra_outputs=False): """Creates a custom evaluation metric that receives its inputs as numpy arrays. Parameters ---------- numpy_feval : callable(label, pred) Custom evaluation function that receives labels and predictions for a minibatch as numpy arrays and returns the corresponding custom metric as a floating point number. name : str, optional Name of the custom metric. allow_extra_outputs : bool, optional Whether prediction output is allowed to have extra outputs. This is useful in cases like RNN where states are also part of output which can then be fed back to the RNN in the next step. By default, extra outputs are not allowed. Returns ------- float Custom metric corresponding to the provided labels and predictions. Example ------- >>> def custom_metric(label, pred): ... return np.mean(np.abs(label-pred)) ... >>> metric = mx.metric.np(custom_metric) """ def feval(label, pred): """Internal eval function.""" return numpy_feval(label, pred) feval.__name__ = numpy_feval.__name__ return CustomMetric(feval, name, allow_extra_outputs)
python
def np(numpy_feval, name=None, allow_extra_outputs=False): """Creates a custom evaluation metric that receives its inputs as numpy arrays. Parameters ---------- numpy_feval : callable(label, pred) Custom evaluation function that receives labels and predictions for a minibatch as numpy arrays and returns the corresponding custom metric as a floating point number. name : str, optional Name of the custom metric. allow_extra_outputs : bool, optional Whether prediction output is allowed to have extra outputs. This is useful in cases like RNN where states are also part of output which can then be fed back to the RNN in the next step. By default, extra outputs are not allowed. Returns ------- float Custom metric corresponding to the provided labels and predictions. Example ------- >>> def custom_metric(label, pred): ... return np.mean(np.abs(label-pred)) ... >>> metric = mx.metric.np(custom_metric) """ def feval(label, pred): """Internal eval function.""" return numpy_feval(label, pred) feval.__name__ = numpy_feval.__name__ return CustomMetric(feval, name, allow_extra_outputs)
[ "def", "np", "(", "numpy_feval", ",", "name", "=", "None", ",", "allow_extra_outputs", "=", "False", ")", ":", "def", "feval", "(", "label", ",", "pred", ")", ":", "\"\"\"Internal eval function.\"\"\"", "return", "numpy_feval", "(", "label", ",", "pred", ")", "feval", ".", "__name__", "=", "numpy_feval", ".", "__name__", "return", "CustomMetric", "(", "feval", ",", "name", ",", "allow_extra_outputs", ")" ]
Creates a custom evaluation metric that receives its inputs as numpy arrays. Parameters ---------- numpy_feval : callable(label, pred) Custom evaluation function that receives labels and predictions for a minibatch as numpy arrays and returns the corresponding custom metric as a floating point number. name : str, optional Name of the custom metric. allow_extra_outputs : bool, optional Whether prediction output is allowed to have extra outputs. This is useful in cases like RNN where states are also part of output which can then be fed back to the RNN in the next step. By default, extra outputs are not allowed. Returns ------- float Custom metric corresponding to the provided labels and predictions. Example ------- >>> def custom_metric(label, pred): ... return np.mean(np.abs(label-pred)) ... >>> metric = mx.metric.np(custom_metric)
[ "Creates", "a", "custom", "evaluation", "metric", "that", "receives", "its", "inputs", "as", "numpy", "arrays", "." ]
train
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L1747-L1778
<|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: Creates a custom evaluation metric that receives its inputs as numpy arrays. Parameters ---------- numpy_feval : callable(label, pred) Custom evaluation function that receives labels and predictions for a minibatch as numpy arrays and returns the corresponding custom metric as a floating point number. name : str, optional Name of the custom metric. allow_extra_outputs : bool, optional Whether prediction output is allowed to have extra outputs. This is useful in cases like RNN where states are also part of output which can then be fed back to the RNN in the next step. By default, extra outputs are not allowed. Returns ------- float Custom metric corresponding to the provided labels and predictions. Example ------- >>> def custom_metric(label, pred): ... return np.mean(np.abs(label-pred)) ... >>> metric = mx.metric.np(custom_metric) ### Response: def np(numpy_feval, name=None, allow_extra_outputs=False): """Creates a custom evaluation metric that receives its inputs as numpy arrays. Parameters ---------- numpy_feval : callable(label, pred) Custom evaluation function that receives labels and predictions for a minibatch as numpy arrays and returns the corresponding custom metric as a floating point number. name : str, optional Name of the custom metric. allow_extra_outputs : bool, optional Whether prediction output is allowed to have extra outputs. This is useful in cases like RNN where states are also part of output which can then be fed back to the RNN in the next step. By default, extra outputs are not allowed. Returns ------- float Custom metric corresponding to the provided labels and predictions. Example ------- >>> def custom_metric(label, pred): ... return np.mean(np.abs(label-pred)) ... >>> metric = mx.metric.np(custom_metric) """ def feval(label, pred): """Internal eval function.""" return numpy_feval(label, pred) feval.__name__ = numpy_feval.__name__ return CustomMetric(feval, name, allow_extra_outputs) <|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, 55968, 264, 2587, 16865, 18767, 430, 21879, 1202, 11374, 439, 8760, 18893, 382, 262, 13831, 198, 262, 31423, 262, 8760, 7797, 838, 551, 42022, 13648, 11, 4255, 340, 286, 8572, 16865, 734, 430, 21879, 9382, 323, 20492, 369, 264, 77017, 759, 198, 286, 439, 8760, 18893, 323, 4780, 279, 12435, 2587, 18767, 439, 264, 19596, 1486, 1396, 627, 262, 836, 551, 610, 11, 10309, 198, 286, 4076, 315, 279, 2587, 18767, 627, 262, 2187, 32958, 36289, 551, 1845, 11, 10309, 198, 286, 13440, 20212, 2612, 374, 5535, 311, 617, 5066, 16674, 13, 1115, 374, 5505, 304, 5157, 198, 286, 1093, 432, 9944, 1405, 5415, 527, 1101, 961, 315, 2612, 902, 649, 1243, 387, 23114, 1203, 311, 279, 432, 9944, 198, 286, 304, 279, 1828, 3094, 13, 3296, 1670, 11, 5066, 16674, 527, 539, 5535, 382, 262, 5295, 198, 262, 39707, 262, 2273, 198, 286, 8572, 18767, 12435, 311, 279, 3984, 9382, 323, 20492, 382, 262, 13688, 198, 262, 39707, 262, 12382, 711, 2587, 42394, 13648, 11, 4255, 997, 262, 2564, 257, 471, 2660, 19231, 10101, 14914, 13648, 2320, 1171, 1192, 262, 12515, 262, 12382, 18767, 284, 14961, 86916, 1276, 79, 62401, 42394, 696, 14711, 6075, 512, 755, 2660, 83948, 7797, 838, 11, 836, 5980, 11, 2187, 32958, 36289, 5725, 997, 262, 4304, 55968, 264, 2587, 16865, 18767, 430, 21879, 1202, 11374, 439, 8760, 18893, 382, 262, 13831, 198, 262, 31423, 262, 8760, 7797, 838, 551, 42022, 13648, 11, 4255, 340, 286, 8572, 16865, 734, 430, 21879, 9382, 323, 20492, 369, 264, 77017, 759, 198, 286, 439, 8760, 18893, 323, 4780, 279, 12435, 2587, 18767, 439, 264, 19596, 1486, 1396, 627, 262, 836, 551, 610, 11, 10309, 198, 286, 4076, 315, 279, 2587, 18767, 627, 262, 2187, 32958, 36289, 551, 1845, 11, 10309, 198, 286, 13440, 20212, 2612, 374, 5535, 311, 617, 5066, 16674, 13, 1115, 374, 5505, 304, 5157, 198, 286, 1093, 432, 9944, 1405, 5415, 527, 1101, 961, 315, 2612, 902, 649, 1243, 387, 23114, 1203, 311, 279, 432, 9944, 198, 286, 304, 279, 1828, 3094, 13, 3296, 1670, 11, 5066, 16674, 527, 539, 5535, 382, 262, 5295, 198, 262, 39707, 262, 2273, 198, 286, 8572, 18767, 12435, 311, 279, 3984, 9382, 323, 20492, 382, 262, 13688, 198, 262, 39707, 262, 12382, 711, 2587, 42394, 13648, 11, 4255, 997, 262, 2564, 257, 471, 2660, 19231, 10101, 14914, 13648, 2320, 1171, 1192, 262, 12515, 262, 12382, 18767, 284, 14961, 86916, 1276, 79, 62401, 42394, 340, 262, 3270, 262, 711, 1172, 838, 13648, 11, 4255, 997, 286, 4304, 11830, 5720, 734, 14781, 286, 471, 8760, 7797, 838, 13648, 11, 4255, 340, 262, 1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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 55968, 264, 2587, 16865, 18767, 430, 21879, 1202, 11374, 439, 8760, 18893, 382, 262, 13831, 198, 262, 31423, 262, 8760, 7797, 838, 551, 42022, 13648, 11, 4255, 340, 286, 8572, 16865, 734, 430, 21879, 9382, 323, 20492, 369, 264, 77017, 759, 198, 286, 439, 8760, 18893, 323, 4780, 279, 12435, 2587, 18767, 439, 264, 19596, 1486, 1396, 627, 262, 836, 551, 610, 11, 10309, 198, 286, 4076, 315, 279, 2587, 18767, 627, 262, 2187, 32958, 36289, 551, 1845, 11, 10309, 198, 286, 13440, 20212, 2612, 374, 5535, 311, 617, 5066, 16674, 13, 1115, 374, 5505, 304, 5157, 198, 286, 1093, 432, 9944, 1405, 5415, 527, 1101, 961, 315, 2612, 902, 649, 1243, 387, 23114, 1203, 311, 279, 432, 9944, 198, 286, 304, 279, 1828, 3094, 13, 3296, 1670, 11, 5066, 16674, 527, 539, 5535, 382, 262, 5295, 198, 262, 39707, 262, 2273, 198, 286, 8572, 18767, 12435, 311, 279, 3984, 9382, 323, 20492, 382, 262, 13688, 198, 262, 39707, 262, 12382, 711, 2587, 42394, 13648, 11, 4255, 997, 262, 2564, 257, 471, 2660, 19231, 10101, 14914, 13648, 2320, 1171, 1192, 262, 12515, 262, 12382, 18767, 284, 14961, 86916, 1276, 79, 62401, 42394, 696, 14711, 6075, 512, 755, 2660, 83948, 7797, 838, 11, 836, 5980, 11, 2187, 32958, 36289, 5725, 997, 262, 4304, 55968, 264, 2587, 16865, 18767, 430, 21879, 1202, 11374, 439, 8760, 18893, 382, 262, 13831, 198, 262, 31423, 262, 8760, 7797, 838, 551, 42022, 13648, 11, 4255, 340, 286, 8572, 16865, 734, 430, 21879, 9382, 323, 20492, 369, 264, 77017, 759, 198, 286, 439, 8760, 18893, 323, 4780, 279, 12435, 2587, 18767, 439, 264, 19596, 1486, 1396, 627, 262, 836, 551, 610, 11, 10309, 198, 286, 4076, 315, 279, 2587, 18767, 627, 262, 2187, 32958, 36289, 551, 1845, 11, 10309, 198, 286, 13440, 20212, 2612, 374, 5535, 311, 617, 5066, 16674, 13, 1115, 374, 5505, 304, 5157, 198, 286, 1093, 432, 9944, 1405, 5415, 527, 1101, 961, 315, 2612, 902, 649, 1243, 387, 23114, 1203, 311, 279, 432, 9944, 198, 286, 304, 279, 1828, 3094, 13, 3296, 1670, 11, 5066, 16674, 527, 539, 5535, 382, 262, 5295, 198, 262, 39707, 262, 2273, 198, 286, 8572, 18767, 12435, 311, 279, 3984, 9382, 323, 20492, 382, 262, 13688, 198, 262, 39707, 262, 12382, 711, 2587, 42394, 13648, 11, 4255, 997, 262, 2564, 257, 471, 2660, 19231, 10101, 14914, 13648, 2320, 1171, 1192, 262, 12515, 262, 12382, 18767, 284, 14961, 86916, 1276, 79, 62401, 42394, 340, 262, 3270, 262, 711, 1172, 838, 13648, 11, 4255, 997, 286, 4304, 11830, 5720, 734, 14781, 286, 471, 8760, 7797, 838, 13648, 11, 4255, 340, 262, 1172, 838, 4952, 609, 565, 284, 8760, 7797, 838, 4952, 609, 12423, 262, 471, 8572, 55410, 968, 14504, 11, 836, 11, 2187, 32958, 36289, 340, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
asweigart/pyautogui
pyautogui/_pyautogui_win.py
_scroll
def _scroll(clicks, x=None, y=None): """Send the mouse vertical scroll event to Windows by calling the mouse_event() win32 function. Args: clicks (int): The amount of scrolling to do. A positive value is the mouse wheel moving forward (scrolling up), a negative value is backwards (down). x (int): The x position of the mouse event. y (int): The y position of the mouse event. Returns: None """ startx, starty = _position() width, height = _size() if x is None: x = startx else: if x < 0: x = 0 elif x >= width: x = width - 1 if y is None: y = starty else: if y < 0: y = 0 elif y >= height: y = height - 1 try: _sendMouseEvent(MOUSEEVENTF_WHEEL, x, y, dwData=clicks) except (PermissionError, OSError): # TODO: We need to figure out how to prevent these errors, see https://github.com/asweigart/pyautogui/issues/60 pass
python
def _scroll(clicks, x=None, y=None): """Send the mouse vertical scroll event to Windows by calling the mouse_event() win32 function. Args: clicks (int): The amount of scrolling to do. A positive value is the mouse wheel moving forward (scrolling up), a negative value is backwards (down). x (int): The x position of the mouse event. y (int): The y position of the mouse event. Returns: None """ startx, starty = _position() width, height = _size() if x is None: x = startx else: if x < 0: x = 0 elif x >= width: x = width - 1 if y is None: y = starty else: if y < 0: y = 0 elif y >= height: y = height - 1 try: _sendMouseEvent(MOUSEEVENTF_WHEEL, x, y, dwData=clicks) except (PermissionError, OSError): # TODO: We need to figure out how to prevent these errors, see https://github.com/asweigart/pyautogui/issues/60 pass
[ "def", "_scroll", "(", "clicks", ",", "x", "=", "None", ",", "y", "=", "None", ")", ":", "startx", ",", "starty", "=", "_position", "(", ")", "width", ",", "height", "=", "_size", "(", ")", "if", "x", "is", "None", ":", "x", "=", "startx", "else", ":", "if", "x", "<", "0", ":", "x", "=", "0", "elif", "x", ">=", "width", ":", "x", "=", "width", "-", "1", "if", "y", "is", "None", ":", "y", "=", "starty", "else", ":", "if", "y", "<", "0", ":", "y", "=", "0", "elif", "y", ">=", "height", ":", "y", "=", "height", "-", "1", "try", ":", "_sendMouseEvent", "(", "MOUSEEVENTF_WHEEL", ",", "x", ",", "y", ",", "dwData", "=", "clicks", ")", "except", "(", "PermissionError", ",", "OSError", ")", ":", "# TODO: We need to figure out how to prevent these errors, see https://github.com/asweigart/pyautogui/issues/60", "pass" ]
Send the mouse vertical scroll event to Windows by calling the mouse_event() win32 function. Args: clicks (int): The amount of scrolling to do. A positive value is the mouse wheel moving forward (scrolling up), a negative value is backwards (down). x (int): The x position of the mouse event. y (int): The y position of the mouse event. Returns: None
[ "Send", "the", "mouse", "vertical", "scroll", "event", "to", "Windows", "by", "calling", "the", "mouse_event", "()", "win32", "function", "." ]
train
https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_win.py#L520-L554
<|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: Send the mouse vertical scroll event to Windows by calling the mouse_event() win32 function. Args: clicks (int): The amount of scrolling to do. A positive value is the mouse wheel moving forward (scrolling up), a negative value is backwards (down). x (int): The x position of the mouse event. y (int): The y position of the mouse event. Returns: None ### Response: def _scroll(clicks, x=None, y=None): """Send the mouse vertical scroll event to Windows by calling the mouse_event() win32 function. Args: clicks (int): The amount of scrolling to do. A positive value is the mouse wheel moving forward (scrolling up), a negative value is backwards (down). x (int): The x position of the mouse event. y (int): The y position of the mouse event. Returns: None """ startx, starty = _position() width, height = _size() if x is None: x = startx else: if x < 0: x = 0 elif x >= width: x = width - 1 if y is None: y = starty else: if y < 0: y = 0 elif y >= height: y = height - 1 try: _sendMouseEvent(MOUSEEVENTF_WHEEL, x, y, dwData=clicks) except (PermissionError, OSError): # TODO: We need to figure out how to prevent these errors, see https://github.com/asweigart/pyautogui/issues/60 pass <|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, 11764, 279, 8814, 12414, 9236, 1567, 311, 5632, 555, 8260, 279, 198, 262, 8814, 6891, 368, 3243, 843, 734, 382, 262, 18161, 512, 415, 28849, 320, 396, 1680, 578, 3392, 315, 39076, 311, 656, 13, 362, 6928, 907, 374, 279, 8814, 198, 415, 13587, 7366, 4741, 320, 12891, 287, 709, 705, 264, 8389, 907, 374, 29512, 320, 2996, 4390, 415, 865, 320, 396, 1680, 578, 865, 2361, 315, 279, 8814, 1567, 627, 415, 379, 320, 396, 1680, 578, 379, 2361, 315, 279, 8814, 1567, 382, 262, 5295, 512, 415, 2290, 271, 14711, 6075, 512, 755, 721, 12891, 44417, 82, 11, 865, 5980, 11, 379, 5980, 997, 262, 4304, 11764, 279, 8814, 12414, 9236, 1567, 311, 5632, 555, 8260, 279, 198, 262, 8814, 6891, 368, 3243, 843, 734, 382, 262, 18161, 512, 415, 28849, 320, 396, 1680, 578, 3392, 315, 39076, 311, 656, 13, 362, 6928, 907, 374, 279, 8814, 198, 415, 13587, 7366, 4741, 320, 12891, 287, 709, 705, 264, 8389, 907, 374, 29512, 320, 2996, 4390, 415, 865, 320, 396, 1680, 578, 865, 2361, 315, 279, 8814, 1567, 627, 415, 379, 320, 396, 1680, 578, 379, 2361, 315, 279, 8814, 1567, 382, 262, 5295, 512, 415, 2290, 198, 262, 3270, 262, 1212, 87, 11, 1212, 88, 284, 721, 3571, 746, 262, 2430, 11, 2673, 284, 721, 2190, 2892, 262, 422, 865, 374, 2290, 512, 286, 865, 284, 1212, 87, 198, 262, 775, 512, 286, 422, 865, 366, 220, 15, 512, 310, 865, 284, 220, 15, 198, 286, 4508, 865, 2669, 2430, 512, 310, 865, 284, 2430, 482, 220, 16, 198, 262, 422, 379, 374, 2290, 512, 286, 379, 284, 1212, 88, 198, 262, 775, 512, 286, 422, 379, 366, 220, 15, 512, 310, 379, 284, 220, 15, 198, 286, 4508, 379, 2669, 2673, 512, 310, 379, 284, 2673, 482, 220, 16, 271, 262, 1456, 512, 286, 721, 6820, 41487, 3269, 58258, 38449, 37, 2832, 70102, 11, 865, 11, 379, 11, 14156, 1061, 28, 3763, 82, 340, 262, 3734, 320, 15315, 1480, 11, 75342, 1680, 674, 5456, 25, 1226, 1205, 311, 7216, 704, 1268, 311, 5471, 1521, 6103, 11, 1518, 3788, 1129, 5316, 916, 73583, 906, 343, 472, 91934, 2784, 91570, 39845, 14, 1399, 198, 310, 1522, 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,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 11764, 279, 8814, 12414, 9236, 1567, 311, 5632, 555, 8260, 279, 198, 262, 8814, 6891, 368, 3243, 843, 734, 382, 262, 18161, 512, 415, 28849, 320, 396, 1680, 578, 3392, 315, 39076, 311, 656, 13, 362, 6928, 907, 374, 279, 8814, 198, 415, 13587, 7366, 4741, 320, 12891, 287, 709, 705, 264, 8389, 907, 374, 29512, 320, 2996, 4390, 415, 865, 320, 396, 1680, 578, 865, 2361, 315, 279, 8814, 1567, 627, 415, 379, 320, 396, 1680, 578, 379, 2361, 315, 279, 8814, 1567, 382, 262, 5295, 512, 415, 2290, 271, 14711, 6075, 512, 755, 721, 12891, 44417, 82, 11, 865, 5980, 11, 379, 5980, 997, 262, 4304, 11764, 279, 8814, 12414, 9236, 1567, 311, 5632, 555, 8260, 279, 198, 262, 8814, 6891, 368, 3243, 843, 734, 382, 262, 18161, 512, 415, 28849, 320, 396, 1680, 578, 3392, 315, 39076, 311, 656, 13, 362, 6928, 907, 374, 279, 8814, 198, 415, 13587, 7366, 4741, 320, 12891, 287, 709, 705, 264, 8389, 907, 374, 29512, 320, 2996, 4390, 415, 865, 320, 396, 1680, 578, 865, 2361, 315, 279, 8814, 1567, 627, 415, 379, 320, 396, 1680, 578, 379, 2361, 315, 279, 8814, 1567, 382, 262, 5295, 512, 415, 2290, 198, 262, 3270, 262, 1212, 87, 11, 1212, 88, 284, 721, 3571, 746, 262, 2430, 11, 2673, 284, 721, 2190, 2892, 262, 422, 865, 374, 2290, 512, 286, 865, 284, 1212, 87, 198, 262, 775, 512, 286, 422, 865, 366, 220, 15, 512, 310, 865, 284, 220, 15, 198, 286, 4508, 865, 2669, 2430, 512, 310, 865, 284, 2430, 482, 220, 16, 198, 262, 422, 379, 374, 2290, 512, 286, 379, 284, 1212, 88, 198, 262, 775, 512, 286, 422, 379, 366, 220, 15, 512, 310, 379, 284, 220, 15, 198, 286, 4508, 379, 2669, 2673, 512, 310, 379, 284, 2673, 482, 220, 16, 271, 262, 1456, 512, 286, 721, 6820, 41487, 3269, 58258, 38449, 37, 2832, 70102, 11, 865, 11, 379, 11, 14156, 1061, 28, 3763, 82, 340, 262, 3734, 320, 15315, 1480, 11, 75342, 1680, 674, 5456, 25, 1226, 1205, 311, 7216, 704, 1268, 311, 5471, 1521, 6103, 11, 1518, 3788, 1129, 5316, 916, 73583, 906, 343, 472, 91934, 2784, 91570, 39845, 14, 1399, 198, 310, 1522, 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 ]
deepmind/pysc2
pysc2/env/lan_sc2_env.py
tcp_client
def tcp_client(tcp_addr): """Connect to the tcp server, and return the settings.""" family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET sock = socket.socket(family, socket.SOCK_STREAM, socket.IPPROTO_TCP) for i in range(300): logging.info("Connecting to: %s, attempt %d", tcp_addr, i) try: sock.connect(tcp_addr) break except socket.error: time.sleep(1) else: sock.connect(tcp_addr) # One last try, but don't catch this error. logging.info("Connected.") map_data = read_tcp(sock) settings_str = read_tcp(sock) if not settings_str: raise socket.error("Failed to read") settings = json.loads(settings_str.decode()) logging.info("Got settings. map_name: %s.", settings["map_name"]) logging.debug("settings: %s", settings) settings["map_data"] = map_data return sock, settings
python
def tcp_client(tcp_addr): """Connect to the tcp server, and return the settings.""" family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET sock = socket.socket(family, socket.SOCK_STREAM, socket.IPPROTO_TCP) for i in range(300): logging.info("Connecting to: %s, attempt %d", tcp_addr, i) try: sock.connect(tcp_addr) break except socket.error: time.sleep(1) else: sock.connect(tcp_addr) # One last try, but don't catch this error. logging.info("Connected.") map_data = read_tcp(sock) settings_str = read_tcp(sock) if not settings_str: raise socket.error("Failed to read") settings = json.loads(settings_str.decode()) logging.info("Got settings. map_name: %s.", settings["map_name"]) logging.debug("settings: %s", settings) settings["map_data"] = map_data return sock, settings
[ "def", "tcp_client", "(", "tcp_addr", ")", ":", "family", "=", "socket", ".", "AF_INET6", "if", "\":\"", "in", "tcp_addr", ".", "ip", "else", "socket", ".", "AF_INET", "sock", "=", "socket", ".", "socket", "(", "family", ",", "socket", ".", "SOCK_STREAM", ",", "socket", ".", "IPPROTO_TCP", ")", "for", "i", "in", "range", "(", "300", ")", ":", "logging", ".", "info", "(", "\"Connecting to: %s, attempt %d\"", ",", "tcp_addr", ",", "i", ")", "try", ":", "sock", ".", "connect", "(", "tcp_addr", ")", "break", "except", "socket", ".", "error", ":", "time", ".", "sleep", "(", "1", ")", "else", ":", "sock", ".", "connect", "(", "tcp_addr", ")", "# One last try, but don't catch this error.", "logging", ".", "info", "(", "\"Connected.\"", ")", "map_data", "=", "read_tcp", "(", "sock", ")", "settings_str", "=", "read_tcp", "(", "sock", ")", "if", "not", "settings_str", ":", "raise", "socket", ".", "error", "(", "\"Failed to read\"", ")", "settings", "=", "json", ".", "loads", "(", "settings_str", ".", "decode", "(", ")", ")", "logging", ".", "info", "(", "\"Got settings. map_name: %s.\"", ",", "settings", "[", "\"map_name\"", "]", ")", "logging", ".", "debug", "(", "\"settings: %s\"", ",", "settings", ")", "settings", "[", "\"map_data\"", "]", "=", "map_data", "return", "sock", ",", "settings" ]
Connect to the tcp server, and return the settings.
[ "Connect", "to", "the", "tcp", "server", "and", "return", "the", "settings", "." ]
train
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L83-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: Connect to the tcp server, and return the settings. ### Response: def tcp_client(tcp_addr): """Connect to the tcp server, and return the settings.""" family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET sock = socket.socket(family, socket.SOCK_STREAM, socket.IPPROTO_TCP) for i in range(300): logging.info("Connecting to: %s, attempt %d", tcp_addr, i) try: sock.connect(tcp_addr) break except socket.error: time.sleep(1) else: sock.connect(tcp_addr) # One last try, but don't catch this error. logging.info("Connected.") map_data = read_tcp(sock) settings_str = read_tcp(sock) if not settings_str: raise socket.error("Failed to read") settings = json.loads(settings_str.decode()) logging.info("Got settings. map_name: %s.", settings["map_name"]) logging.debug("settings: %s", settings) settings["map_data"] = map_data return sock, settings <|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, 14953, 311, 279, 29151, 3622, 11, 323, 471, 279, 5110, 382, 14711, 6075, 512, 755, 29151, 8342, 99303, 7539, 997, 220, 4304, 14953, 311, 279, 29151, 3622, 11, 323, 471, 279, 5110, 14781, 220, 3070, 284, 7728, 71960, 27932, 21, 422, 24320, 304, 29151, 7539, 24046, 775, 7728, 71960, 27932, 198, 220, 11334, 284, 7728, 27015, 968, 5285, 11, 7728, 80022, 24500, 11, 7728, 2506, 4505, 77615, 51714, 340, 220, 369, 602, 304, 2134, 7, 3101, 997, 262, 8558, 5506, 446, 64024, 311, 25, 1034, 82, 11, 4879, 1034, 67, 498, 29151, 7539, 11, 602, 340, 262, 1456, 512, 415, 11334, 11034, 99303, 7539, 340, 415, 1464, 198, 262, 3734, 7728, 4517, 512, 415, 892, 11365, 7, 16, 340, 220, 775, 512, 262, 11334, 11034, 99303, 7539, 8, 220, 674, 3861, 1566, 1456, 11, 719, 1541, 956, 2339, 420, 1493, 627, 220, 8558, 5506, 446, 21831, 32325, 220, 2472, 1807, 284, 1373, 46662, 31950, 340, 220, 5110, 2966, 284, 1373, 46662, 31950, 340, 220, 422, 539, 5110, 2966, 512, 262, 4933, 7728, 4517, 446, 9595, 311, 1373, 1158, 220, 5110, 284, 3024, 23818, 24258, 2966, 16301, 2455, 220, 8558, 5506, 446, 33562, 5110, 13, 2472, 1292, 25, 1034, 82, 10684, 5110, 1204, 2235, 1292, 14440, 220, 8558, 8042, 446, 6648, 25, 1034, 82, 498, 5110, 340, 220, 5110, 1204, 2235, 1807, 1365, 284, 2472, 1807, 198, 220, 471, 11334, 11, 5110, 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, 128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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 14953, 311, 279, 29151, 3622, 11, 323, 471, 279, 5110, 382, 14711, 6075, 512, 755, 29151, 8342, 99303, 7539, 997, 220, 4304, 14953, 311, 279, 29151, 3622, 11, 323, 471, 279, 5110, 14781, 220, 3070, 284, 7728, 71960, 27932, 21, 422, 24320, 304, 29151, 7539, 24046, 775, 7728, 71960, 27932, 198, 220, 11334, 284, 7728, 27015, 968, 5285, 11, 7728, 80022, 24500, 11, 7728, 2506, 4505, 77615, 51714, 340, 220, 369, 602, 304, 2134, 7, 3101, 997, 262, 8558, 5506, 446, 64024, 311, 25, 1034, 82, 11, 4879, 1034, 67, 498, 29151, 7539, 11, 602, 340, 262, 1456, 512, 415, 11334, 11034, 99303, 7539, 340, 415, 1464, 198, 262, 3734, 7728, 4517, 512, 415, 892, 11365, 7, 16, 340, 220, 775, 512, 262, 11334, 11034, 99303, 7539, 8, 220, 674, 3861, 1566, 1456, 11, 719, 1541, 956, 2339, 420, 1493, 627, 220, 8558, 5506, 446, 21831, 32325, 220, 2472, 1807, 284, 1373, 46662, 31950, 340, 220, 5110, 2966, 284, 1373, 46662, 31950, 340, 220, 422, 539, 5110, 2966, 512, 262, 4933, 7728, 4517, 446, 9595, 311, 1373, 1158, 220, 5110, 284, 3024, 23818, 24258, 2966, 16301, 2455, 220, 8558, 5506, 446, 33562, 5110, 13, 2472, 1292, 25, 1034, 82, 10684, 5110, 1204, 2235, 1292, 14440, 220, 8558, 8042, 446, 6648, 25, 1034, 82, 498, 5110, 340, 220, 5110, 1204, 2235, 1807, 1365, 284, 2472, 1807, 198, 220, 471, 11334, 11, 5110, 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 ]
openid/python-openid
openid/yadis/xri.py
_escape_xref
def _escape_xref(xref_match): """Escape things that need to be escaped if they're in a cross-reference. """ xref = xref_match.group() xref = xref.replace('/', '%2F') xref = xref.replace('?', '%3F') xref = xref.replace('#', '%23') return xref
python
def _escape_xref(xref_match): """Escape things that need to be escaped if they're in a cross-reference. """ xref = xref_match.group() xref = xref.replace('/', '%2F') xref = xref.replace('?', '%3F') xref = xref.replace('#', '%23') return xref
[ "def", "_escape_xref", "(", "xref_match", ")", ":", "xref", "=", "xref_match", ".", "group", "(", ")", "xref", "=", "xref", ".", "replace", "(", "'/'", ",", "'%2F'", ")", "xref", "=", "xref", ".", "replace", "(", "'?'", ",", "'%3F'", ")", "xref", "=", "xref", ".", "replace", "(", "'#'", ",", "'%23'", ")", "return", "xref" ]
Escape things that need to be escaped if they're in a cross-reference.
[ "Escape", "things", "that", "need", "to", "be", "escaped", "if", "they", "re", "in", "a", "cross", "-", "reference", "." ]
train
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/xri.py#L79-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: Escape things that need to be escaped if they're in a cross-reference. ### Response: def _escape_xref(xref_match): """Escape things that need to be escaped if they're in a cross-reference. """ xref = xref_match.group() xref = xref.replace('/', '%2F') xref = xref.replace('?', '%3F') xref = xref.replace('#', '%23') return xref <|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, 49224, 2574, 430, 1205, 311, 387, 28883, 422, 814, 2351, 304, 264, 5425, 73723, 382, 14711, 6075, 512, 755, 721, 13295, 3292, 1116, 2120, 1116, 10938, 997, 262, 4304, 49224, 2574, 430, 1205, 311, 387, 28883, 422, 814, 2351, 304, 264, 5425, 73723, 627, 262, 3270, 262, 865, 1116, 284, 865, 1116, 10938, 6306, 746, 262, 865, 1116, 284, 865, 1116, 7125, 21049, 7832, 17, 37, 1329, 262, 865, 1116, 284, 865, 1116, 7125, 493, 50734, 7832, 18, 37, 1329, 262, 865, 1116, 284, 865, 1116, 7125, 3599, 518, 7832, 1419, 1329, 262, 471, 865, 1116, 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, 128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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 49224, 2574, 430, 1205, 311, 387, 28883, 422, 814, 2351, 304, 264, 5425, 73723, 382, 14711, 6075, 512, 755, 721, 13295, 3292, 1116, 2120, 1116, 10938, 997, 262, 4304, 49224, 2574, 430, 1205, 311, 387, 28883, 422, 814, 2351, 304, 264, 5425, 73723, 627, 262, 3270, 262, 865, 1116, 284, 865, 1116, 10938, 6306, 746, 262, 865, 1116, 284, 865, 1116, 7125, 21049, 7832, 17, 37, 1329, 262, 865, 1116, 284, 865, 1116, 7125, 493, 50734, 7832, 18, 37, 1329, 262, 865, 1116, 284, 865, 1116, 7125, 3599, 518, 7832, 1419, 1329, 262, 471, 865, 1116, 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 ]
biolink/biolink-model
metamodel/generators/yumlgen.py
YumlGenerator.prop_modifier
def prop_modifier(self, cls: ClassDefinition, slot: SlotDefinition) -> str: """ Return the modifiers for the slot: (i) - inherited (m) - inherited through mixin (a) - injected (pk) - primary ckey @param cls: @param slot: @return: """ pk = '(pk)' if slot.primary_key else '' inherited = slot.name not in cls.slots mixin = inherited and slot.name in \ [mslot.name for mslot in [self.schema.classes[m] for m in cls.mixins]] injected = cls.name in self.synopsis.applytos and \ slot.name in [aslot.name for aslot in [self.schema.classes[a] for a in sorted(self.synopsis.applytos[cls.name].classrefs)]] return pk + '(a)' if injected else '(m)' if mixin else '(i)' if inherited else ''
python
def prop_modifier(self, cls: ClassDefinition, slot: SlotDefinition) -> str: """ Return the modifiers for the slot: (i) - inherited (m) - inherited through mixin (a) - injected (pk) - primary ckey @param cls: @param slot: @return: """ pk = '(pk)' if slot.primary_key else '' inherited = slot.name not in cls.slots mixin = inherited and slot.name in \ [mslot.name for mslot in [self.schema.classes[m] for m in cls.mixins]] injected = cls.name in self.synopsis.applytos and \ slot.name in [aslot.name for aslot in [self.schema.classes[a] for a in sorted(self.synopsis.applytos[cls.name].classrefs)]] return pk + '(a)' if injected else '(m)' if mixin else '(i)' if inherited else ''
[ "def", "prop_modifier", "(", "self", ",", "cls", ":", "ClassDefinition", ",", "slot", ":", "SlotDefinition", ")", "->", "str", ":", "pk", "=", "'(pk)'", "if", "slot", ".", "primary_key", "else", "''", "inherited", "=", "slot", ".", "name", "not", "in", "cls", ".", "slots", "mixin", "=", "inherited", "and", "slot", ".", "name", "in", "[", "mslot", ".", "name", "for", "mslot", "in", "[", "self", ".", "schema", ".", "classes", "[", "m", "]", "for", "m", "in", "cls", ".", "mixins", "]", "]", "injected", "=", "cls", ".", "name", "in", "self", ".", "synopsis", ".", "applytos", "and", "slot", ".", "name", "in", "[", "aslot", ".", "name", "for", "aslot", "in", "[", "self", ".", "schema", ".", "classes", "[", "a", "]", "for", "a", "in", "sorted", "(", "self", ".", "synopsis", ".", "applytos", "[", "cls", ".", "name", "]", ".", "classrefs", ")", "]", "]", "return", "pk", "+", "'(a)'", "if", "injected", "else", "'(m)'", "if", "mixin", "else", "'(i)'", "if", "inherited", "else", "''" ]
Return the modifiers for the slot: (i) - inherited (m) - inherited through mixin (a) - injected (pk) - primary ckey @param cls: @param slot: @return:
[ "Return", "the", "modifiers", "for", "the", "slot", ":", "(", "i", ")", "-", "inherited", "(", "m", ")", "-", "inherited", "through", "mixin", "(", "a", ")", "-", "injected", "(", "pk", ")", "-", "primary", "ckey" ]
train
https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/yumlgen.py#L192-L210
<|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 modifiers for the slot: (i) - inherited (m) - inherited through mixin (a) - injected (pk) - primary ckey @param cls: @param slot: @return: ### Response: def prop_modifier(self, cls: ClassDefinition, slot: SlotDefinition) -> str: """ Return the modifiers for the slot: (i) - inherited (m) - inherited through mixin (a) - injected (pk) - primary ckey @param cls: @param slot: @return: """ pk = '(pk)' if slot.primary_key else '' inherited = slot.name not in cls.slots mixin = inherited and slot.name in \ [mslot.name for mslot in [self.schema.classes[m] for m in cls.mixins]] injected = cls.name in self.synopsis.applytos and \ slot.name in [aslot.name for aslot in [self.schema.classes[a] for a in sorted(self.synopsis.applytos[cls.name].classrefs)]] return pk + '(a)' if injected else '(m)' if mixin else '(i)' if inherited else '' <|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, 36770, 369, 279, 9633, 512, 310, 320, 72, 8, 482, 28088, 198, 310, 320, 76, 8, 482, 28088, 1555, 90703, 198, 310, 320, 64, 8, 482, 41772, 198, 310, 320, 21486, 8, 482, 6156, 272, 798, 271, 286, 571, 913, 13082, 512, 286, 571, 913, 9633, 512, 286, 571, 693, 1473, 14711, 6075, 512, 755, 2047, 62873, 1214, 11, 13082, 25, 3308, 10614, 11, 9633, 25, 32416, 10614, 8, 1492, 610, 512, 286, 4304, 3494, 279, 36770, 369, 279, 9633, 512, 310, 320, 72, 8, 482, 28088, 198, 310, 320, 76, 8, 482, 28088, 1555, 90703, 198, 310, 320, 64, 8, 482, 41772, 198, 310, 320, 21486, 8, 482, 6156, 272, 798, 271, 286, 571, 913, 13082, 512, 286, 571, 913, 9633, 512, 286, 571, 693, 512, 286, 3270, 286, 23266, 284, 22796, 21486, 22367, 422, 9633, 36597, 3173, 775, 12038, 286, 28088, 284, 9633, 2710, 539, 304, 13082, 26157, 2469, 198, 286, 90703, 284, 28088, 323, 9633, 2710, 304, 3120, 394, 510, 1026, 9363, 2710, 369, 296, 22261, 304, 510, 726, 31992, 44097, 12335, 60, 369, 296, 304, 13082, 81981, 1354, 14623, 286, 41772, 284, 13082, 2710, 304, 659, 36335, 33906, 13344, 43681, 323, 3120, 4391, 9633, 2710, 304, 510, 300, 9363, 2710, 369, 439, 9363, 304, 198, 792, 510, 726, 31992, 44097, 15848, 60, 369, 264, 304, 10839, 1214, 36335, 33906, 13344, 43681, 58, 18565, 2710, 948, 1058, 16541, 7400, 933, 286, 471, 23266, 489, 22796, 64, 22367, 422, 41772, 775, 22796, 76, 22367, 422, 90703, 775, 22796, 72, 22367, 422, 28088, 775, 12038, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 36770, 369, 279, 9633, 512, 310, 320, 72, 8, 482, 28088, 198, 310, 320, 76, 8, 482, 28088, 1555, 90703, 198, 310, 320, 64, 8, 482, 41772, 198, 310, 320, 21486, 8, 482, 6156, 272, 798, 271, 286, 571, 913, 13082, 512, 286, 571, 913, 9633, 512, 286, 571, 693, 1473, 14711, 6075, 512, 755, 2047, 62873, 1214, 11, 13082, 25, 3308, 10614, 11, 9633, 25, 32416, 10614, 8, 1492, 610, 512, 286, 4304, 3494, 279, 36770, 369, 279, 9633, 512, 310, 320, 72, 8, 482, 28088, 198, 310, 320, 76, 8, 482, 28088, 1555, 90703, 198, 310, 320, 64, 8, 482, 41772, 198, 310, 320, 21486, 8, 482, 6156, 272, 798, 271, 286, 571, 913, 13082, 512, 286, 571, 913, 9633, 512, 286, 571, 693, 512, 286, 3270, 286, 23266, 284, 22796, 21486, 22367, 422, 9633, 36597, 3173, 775, 12038, 286, 28088, 284, 9633, 2710, 539, 304, 13082, 26157, 2469, 198, 286, 90703, 284, 28088, 323, 9633, 2710, 304, 3120, 394, 510, 1026, 9363, 2710, 369, 296, 22261, 304, 510, 726, 31992, 44097, 12335, 60, 369, 296, 304, 13082, 81981, 1354, 14623, 286, 41772, 284, 13082, 2710, 304, 659, 36335, 33906, 13344, 43681, 323, 3120, 4391, 9633, 2710, 304, 510, 300, 9363, 2710, 369, 439, 9363, 304, 198, 792, 510, 726, 31992, 44097, 15848, 60, 369, 264, 304, 10839, 1214, 36335, 33906, 13344, 43681, 58, 18565, 2710, 948, 1058, 16541, 7400, 933, 286, 471, 23266, 489, 22796, 64, 22367, 422, 41772, 775, 22796, 76, 22367, 422, 90703, 775, 22796, 72, 22367, 422, 28088, 775, 12038, 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 ]
scot-dev/scot
scot/ooapi.py
Workspace.optimize_var
def optimize_var(self): """ Optimize the VAR model's hyperparameters (such as regularization). Returns ------- self : Workspace The Workspace object. Raises ------ RuntimeError If the :class:`Workspace` instance does not contain source activations. """ if self.activations_ is None: raise RuntimeError("VAR fitting requires source activations (run do_mvarica first)") self.var_.optimize(self.activations_[self.trial_mask_, :, :]) return self
python
def optimize_var(self): """ Optimize the VAR model's hyperparameters (such as regularization). Returns ------- self : Workspace The Workspace object. Raises ------ RuntimeError If the :class:`Workspace` instance does not contain source activations. """ if self.activations_ is None: raise RuntimeError("VAR fitting requires source activations (run do_mvarica first)") self.var_.optimize(self.activations_[self.trial_mask_, :, :]) return self
[ "def", "optimize_var", "(", "self", ")", ":", "if", "self", ".", "activations_", "is", "None", ":", "raise", "RuntimeError", "(", "\"VAR fitting requires source activations (run do_mvarica first)\"", ")", "self", ".", "var_", ".", "optimize", "(", "self", ".", "activations_", "[", "self", ".", "trial_mask_", ",", ":", ",", ":", "]", ")", "return", "self" ]
Optimize the VAR model's hyperparameters (such as regularization). Returns ------- self : Workspace The Workspace object. Raises ------ RuntimeError If the :class:`Workspace` instance does not contain source activations.
[ "Optimize", "the", "VAR", "model", "s", "hyperparameters", "(", "such", "as", "regularization", ")", "." ]
train
https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/scot/ooapi.py#L403-L420
<|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: Optimize the VAR model's hyperparameters (such as regularization). Returns ------- self : Workspace The Workspace object. Raises ------ RuntimeError If the :class:`Workspace` instance does not contain source activations. ### Response: def optimize_var(self): """ Optimize the VAR model's hyperparameters (such as regularization). Returns ------- self : Workspace The Workspace object. Raises ------ RuntimeError If the :class:`Workspace` instance does not contain source activations. """ if self.activations_ is None: raise RuntimeError("VAR fitting requires source activations (run do_mvarica first)") self.var_.optimize(self.activations_[self.trial_mask_, :, :]) 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, 22078, 12117, 279, 44608, 1646, 596, 17508, 14105, 320, 21470, 439, 88394, 3677, 286, 5295, 198, 286, 39707, 286, 659, 551, 72034, 198, 310, 578, 72034, 1665, 382, 286, 61411, 198, 286, 11556, 7233, 286, 45643, 198, 310, 1442, 279, 551, 1058, 19258, 47081, 63, 2937, 1587, 539, 6782, 2592, 93595, 382, 14711, 6075, 512, 755, 30536, 4715, 1214, 997, 286, 4304, 16963, 12117, 279, 44608, 1646, 596, 17508, 14105, 320, 21470, 439, 88394, 3677, 286, 5295, 198, 286, 39707, 286, 659, 551, 72034, 198, 310, 578, 72034, 1665, 382, 286, 61411, 198, 286, 11556, 7233, 286, 45643, 198, 310, 1442, 279, 551, 1058, 19258, 47081, 63, 2937, 1587, 539, 6782, 2592, 93595, 627, 286, 3270, 286, 422, 659, 58590, 811, 62, 374, 2290, 512, 310, 4933, 45643, 446, 34140, 27442, 7612, 2592, 93595, 320, 6236, 656, 722, 959, 3074, 1176, 96477, 286, 659, 20096, 5056, 95432, 1214, 58590, 811, 12147, 726, 5543, 532, 10204, 7022, 28882, 551, 2608, 286, 471, 659, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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6498, 382, 14711, 5546, 512, 22078, 12117, 279, 44608, 1646, 596, 17508, 14105, 320, 21470, 439, 88394, 3677, 286, 5295, 198, 286, 39707, 286, 659, 551, 72034, 198, 310, 578, 72034, 1665, 382, 286, 61411, 198, 286, 11556, 7233, 286, 45643, 198, 310, 1442, 279, 551, 1058, 19258, 47081, 63, 2937, 1587, 539, 6782, 2592, 93595, 382, 14711, 6075, 512, 755, 30536, 4715, 1214, 997, 286, 4304, 16963, 12117, 279, 44608, 1646, 596, 17508, 14105, 320, 21470, 439, 88394, 3677, 286, 5295, 198, 286, 39707, 286, 659, 551, 72034, 198, 310, 578, 72034, 1665, 382, 286, 61411, 198, 286, 11556, 7233, 286, 45643, 198, 310, 1442, 279, 551, 1058, 19258, 47081, 63, 2937, 1587, 539, 6782, 2592, 93595, 627, 286, 3270, 286, 422, 659, 58590, 811, 62, 374, 2290, 512, 310, 4933, 45643, 446, 34140, 27442, 7612, 2592, 93595, 320, 6236, 656, 722, 959, 3074, 1176, 96477, 286, 659, 20096, 5056, 95432, 1214, 58590, 811, 12147, 726, 5543, 532, 10204, 7022, 28882, 551, 2608, 286, 471, 659, 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 ]
saltstack/salt
salt/modules/boto_s3_bucket.py
delete_website
def delete_website(Bucket, region=None, key=None, keyid=None, profile=None): ''' Remove the website configuration from the given bucket Returns {deleted: true} if website configuration was deleted and returns {deleted: False} if website configuration was not deleted. CLI Example: .. code-block:: bash salt myminion boto_s3_bucket.delete_website my_bucket ''' try: conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) conn.delete_bucket_website(Bucket=Bucket) return {'deleted': True, 'name': Bucket} except ClientError as e: return {'deleted': False, 'error': __utils__['boto3.get_error'](e)}
python
def delete_website(Bucket, region=None, key=None, keyid=None, profile=None): ''' Remove the website configuration from the given bucket Returns {deleted: true} if website configuration was deleted and returns {deleted: False} if website configuration was not deleted. CLI Example: .. code-block:: bash salt myminion boto_s3_bucket.delete_website my_bucket ''' try: conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) conn.delete_bucket_website(Bucket=Bucket) return {'deleted': True, 'name': Bucket} except ClientError as e: return {'deleted': False, 'error': __utils__['boto3.get_error'](e)}
[ "def", "delete_website", "(", "Bucket", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "try", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid", "=", "keyid", ",", "profile", "=", "profile", ")", "conn", ".", "delete_bucket_website", "(", "Bucket", "=", "Bucket", ")", "return", "{", "'deleted'", ":", "True", ",", "'name'", ":", "Bucket", "}", "except", "ClientError", "as", "e", ":", "return", "{", "'deleted'", ":", "False", ",", "'error'", ":", "__utils__", "[", "'boto3.get_error'", "]", "(", "e", ")", "}" ]
Remove the website configuration from the given bucket Returns {deleted: true} if website configuration was deleted and returns {deleted: False} if website configuration was not deleted. CLI Example: .. code-block:: bash salt myminion boto_s3_bucket.delete_website my_bucket
[ "Remove", "the", "website", "configuration", "from", "the", "given", "bucket" ]
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_s3_bucket.py#L965-L986
<|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: Remove the website configuration from the given bucket Returns {deleted: true} if website configuration was deleted and returns {deleted: False} if website configuration was not deleted. CLI Example: .. code-block:: bash salt myminion boto_s3_bucket.delete_website my_bucket ### Response: def delete_website(Bucket, region=None, key=None, keyid=None, profile=None): ''' Remove the website configuration from the given bucket Returns {deleted: true} if website configuration was deleted and returns {deleted: False} if website configuration was not deleted. CLI Example: .. code-block:: bash salt myminion boto_s3_bucket.delete_website my_bucket ''' try: conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) conn.delete_bucket_website(Bucket=Bucket) return {'deleted': True, 'name': Bucket} except ClientError as e: return {'deleted': False, 'error': __utils__['boto3.get_error'](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, 13319, 279, 3997, 6683, 505, 279, 2728, 15994, 271, 262, 5295, 314, 27619, 25, 837, 92, 422, 3997, 6683, 574, 11309, 323, 4780, 198, 262, 314, 27619, 25, 3641, 92, 422, 3997, 6683, 574, 539, 11309, 382, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 286, 12290, 856, 1083, 290, 61879, 646, 18, 39849, 7592, 80132, 856, 39849, 271, 14711, 6075, 512, 755, 3783, 80132, 5462, 11400, 345, 1881, 5654, 5980, 11, 1401, 5980, 11, 1401, 307, 5980, 11, 5643, 5980, 997, 262, 11414, 262, 11016, 279, 3997, 6683, 505, 279, 2728, 15994, 271, 262, 5295, 314, 27619, 25, 837, 92, 422, 3997, 6683, 574, 11309, 323, 4780, 198, 262, 314, 27619, 25, 3641, 92, 422, 3997, 6683, 574, 539, 11309, 382, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 286, 12290, 856, 1083, 290, 61879, 646, 18, 39849, 7592, 80132, 856, 39849, 271, 262, 45832, 262, 1456, 512, 286, 4635, 284, 721, 456, 17686, 49159, 28, 4030, 11, 1401, 87682, 11, 1401, 307, 87682, 307, 11, 5643, 28, 5478, 340, 286, 4635, 7592, 39849, 80132, 5462, 11400, 28, 37118, 340, 286, 471, 5473, 27619, 1232, 3082, 11, 364, 609, 1232, 48868, 534, 262, 3734, 8589, 1480, 439, 384, 512, 286, 471, 5473, 27619, 1232, 3641, 11, 364, 850, 1232, 1328, 6159, 565, 681, 65, 2117, 18, 673, 4188, 85433, 68, 10792, 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,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 13319, 279, 3997, 6683, 505, 279, 2728, 15994, 271, 262, 5295, 314, 27619, 25, 837, 92, 422, 3997, 6683, 574, 11309, 323, 4780, 198, 262, 314, 27619, 25, 3641, 92, 422, 3997, 6683, 574, 539, 11309, 382, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 286, 12290, 856, 1083, 290, 61879, 646, 18, 39849, 7592, 80132, 856, 39849, 271, 14711, 6075, 512, 755, 3783, 80132, 5462, 11400, 345, 1881, 5654, 5980, 11, 1401, 5980, 11, 1401, 307, 5980, 11, 5643, 5980, 997, 262, 11414, 262, 11016, 279, 3997, 6683, 505, 279, 2728, 15994, 271, 262, 5295, 314, 27619, 25, 837, 92, 422, 3997, 6683, 574, 11309, 323, 4780, 198, 262, 314, 27619, 25, 3641, 92, 422, 3997, 6683, 574, 539, 11309, 382, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 286, 12290, 856, 1083, 290, 61879, 646, 18, 39849, 7592, 80132, 856, 39849, 271, 262, 45832, 262, 1456, 512, 286, 4635, 284, 721, 456, 17686, 49159, 28, 4030, 11, 1401, 87682, 11, 1401, 307, 87682, 307, 11, 5643, 28, 5478, 340, 286, 4635, 7592, 39849, 80132, 5462, 11400, 28, 37118, 340, 286, 471, 5473, 27619, 1232, 3082, 11, 364, 609, 1232, 48868, 534, 262, 3734, 8589, 1480, 439, 384, 512, 286, 471, 5473, 27619, 1232, 3641, 11, 364, 850, 1232, 1328, 6159, 565, 681, 65, 2117, 18, 673, 4188, 85433, 68, 10792, 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 ]
fracpete/python-weka-wrapper3
python/weka/core/packages.py
install_package
def install_package(pkge, version="Latest"): """ The list of packages to install. :param pkge: the name of the repository package, a URL (http/https) or a zip file :type pkge: str :param version: in case of the repository packages, the version :type version: str :return: whether successfully installed :rtype: bool """ establish_cache() if pkge.startswith("http://") or pkge.startswith("https://"): url = javabridge.make_instance( "java/net/URL", "(Ljava/lang/String;)V", javabridge.get_env().new_string_utf(pkge)) return not javabridge.static_call( "weka/core/WekaPackageManager", "installPackageFromURL", "(Ljava/net/URL;[Ljava/io/PrintStream;)Ljava/lang/String;", url, []) is None elif pkge.lower().endswith(".zip"): return not javabridge.static_call( "weka/core/WekaPackageManager", "installPackageFromArchive", "(Ljava/lang/String;[Ljava/io/PrintStream;)Ljava/lang/String;", pkge, []) is None else: return javabridge.static_call( "weka/core/WekaPackageManager", "installPackageFromRepository", "(Ljava/lang/String;Ljava/lang/String;[Ljava/io/PrintStream;)Z", pkge, version, [])
python
def install_package(pkge, version="Latest"): """ The list of packages to install. :param pkge: the name of the repository package, a URL (http/https) or a zip file :type pkge: str :param version: in case of the repository packages, the version :type version: str :return: whether successfully installed :rtype: bool """ establish_cache() if pkge.startswith("http://") or pkge.startswith("https://"): url = javabridge.make_instance( "java/net/URL", "(Ljava/lang/String;)V", javabridge.get_env().new_string_utf(pkge)) return not javabridge.static_call( "weka/core/WekaPackageManager", "installPackageFromURL", "(Ljava/net/URL;[Ljava/io/PrintStream;)Ljava/lang/String;", url, []) is None elif pkge.lower().endswith(".zip"): return not javabridge.static_call( "weka/core/WekaPackageManager", "installPackageFromArchive", "(Ljava/lang/String;[Ljava/io/PrintStream;)Ljava/lang/String;", pkge, []) is None else: return javabridge.static_call( "weka/core/WekaPackageManager", "installPackageFromRepository", "(Ljava/lang/String;Ljava/lang/String;[Ljava/io/PrintStream;)Z", pkge, version, [])
[ "def", "install_package", "(", "pkge", ",", "version", "=", "\"Latest\"", ")", ":", "establish_cache", "(", ")", "if", "pkge", ".", "startswith", "(", "\"http://\"", ")", "or", "pkge", ".", "startswith", "(", "\"https://\"", ")", ":", "url", "=", "javabridge", ".", "make_instance", "(", "\"java/net/URL\"", ",", "\"(Ljava/lang/String;)V\"", ",", "javabridge", ".", "get_env", "(", ")", ".", "new_string_utf", "(", "pkge", ")", ")", "return", "not", "javabridge", ".", "static_call", "(", "\"weka/core/WekaPackageManager\"", ",", "\"installPackageFromURL\"", ",", "\"(Ljava/net/URL;[Ljava/io/PrintStream;)Ljava/lang/String;\"", ",", "url", ",", "[", "]", ")", "is", "None", "elif", "pkge", ".", "lower", "(", ")", ".", "endswith", "(", "\".zip\"", ")", ":", "return", "not", "javabridge", ".", "static_call", "(", "\"weka/core/WekaPackageManager\"", ",", "\"installPackageFromArchive\"", ",", "\"(Ljava/lang/String;[Ljava/io/PrintStream;)Ljava/lang/String;\"", ",", "pkge", ",", "[", "]", ")", "is", "None", "else", ":", "return", "javabridge", ".", "static_call", "(", "\"weka/core/WekaPackageManager\"", ",", "\"installPackageFromRepository\"", ",", "\"(Ljava/lang/String;Ljava/lang/String;[Ljava/io/PrintStream;)Z\"", ",", "pkge", ",", "version", ",", "[", "]", ")" ]
The list of packages to install. :param pkge: the name of the repository package, a URL (http/https) or a zip file :type pkge: str :param version: in case of the repository packages, the version :type version: str :return: whether successfully installed :rtype: bool
[ "The", "list", "of", "packages", "to", "install", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/packages.py#L279-L304
<|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 list of packages to install. :param pkge: the name of the repository package, a URL (http/https) or a zip file :type pkge: str :param version: in case of the repository packages, the version :type version: str :return: whether successfully installed :rtype: bool ### Response: def install_package(pkge, version="Latest"): """ The list of packages to install. :param pkge: the name of the repository package, a URL (http/https) or a zip file :type pkge: str :param version: in case of the repository packages, the version :type version: str :return: whether successfully installed :rtype: bool """ establish_cache() if pkge.startswith("http://") or pkge.startswith("https://"): url = javabridge.make_instance( "java/net/URL", "(Ljava/lang/String;)V", javabridge.get_env().new_string_utf(pkge)) return not javabridge.static_call( "weka/core/WekaPackageManager", "installPackageFromURL", "(Ljava/net/URL;[Ljava/io/PrintStream;)Ljava/lang/String;", url, []) is None elif pkge.lower().endswith(".zip"): return not javabridge.static_call( "weka/core/WekaPackageManager", "installPackageFromArchive", "(Ljava/lang/String;[Ljava/io/PrintStream;)Ljava/lang/String;", pkge, []) is None else: return javabridge.static_call( "weka/core/WekaPackageManager", "installPackageFromRepository", "(Ljava/lang/String;Ljava/lang/String;[Ljava/io/PrintStream;)Z", pkge, version, []) <|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, 1160, 315, 14519, 311, 4685, 382, 262, 551, 913, 23266, 713, 25, 279, 836, 315, 279, 12827, 6462, 11, 264, 5665, 320, 1277, 14, 2485, 8, 477, 264, 10521, 1052, 198, 262, 551, 1337, 23266, 713, 25, 610, 198, 262, 551, 913, 2373, 25, 304, 1162, 315, 279, 12827, 14519, 11, 279, 2373, 198, 262, 551, 1337, 2373, 25, 610, 198, 262, 551, 693, 25, 3508, 7946, 10487, 198, 262, 551, 33613, 25, 1845, 271, 14711, 6075, 512, 755, 4685, 27425, 41028, 713, 11, 2373, 429, 33092, 15497, 262, 3270, 262, 578, 1160, 315, 14519, 311, 4685, 382, 262, 551, 913, 23266, 713, 25, 279, 836, 315, 279, 12827, 6462, 11, 264, 5665, 320, 1277, 14, 2485, 8, 477, 264, 10521, 1052, 198, 262, 551, 1337, 23266, 713, 25, 610, 198, 262, 551, 913, 2373, 25, 304, 1162, 315, 279, 12827, 14519, 11, 279, 2373, 198, 262, 551, 1337, 2373, 25, 610, 198, 262, 551, 693, 25, 3508, 7946, 10487, 198, 262, 551, 33613, 25, 1845, 198, 262, 3270, 262, 5813, 11790, 746, 262, 422, 23266, 713, 27249, 446, 1277, 1129, 909, 477, 23266, 713, 27249, 446, 2485, 1129, 15497, 286, 2576, 284, 1281, 370, 11431, 10325, 12169, 1021, 310, 330, 10248, 39165, 14, 3222, 498, 12262, 39024, 26319, 37364, 37274, 53, 498, 1281, 370, 11431, 673, 16258, 1020, 943, 3991, 40553, 41028, 713, 1192, 286, 471, 539, 1281, 370, 11431, 27273, 13735, 1021, 310, 330, 906, 4657, 5433, 22964, 53413, 90270, 498, 330, 12527, 13401, 3915, 3222, 761, 310, 12262, 39024, 39165, 14, 3222, 26, 58, 39024, 42490, 14, 9171, 3103, 37274, 39024, 26319, 37364, 33603, 2576, 11, 43282, 374, 2290, 198, 262, 4508, 23266, 713, 18564, 1020, 1438, 4291, 5798, 10169, 15497, 286, 471, 539, 1281, 370, 11431, 27273, 13735, 1021, 310, 330, 906, 4657, 5433, 22964, 53413, 90270, 498, 330, 12527, 13401, 3915, 43602, 761, 310, 12262, 39024, 26319, 37364, 26, 58, 39024, 42490, 14, 9171, 3103, 37274, 39024, 26319, 37364, 33603, 23266, 713, 11, 43282, 374, 2290, 198, 262, 775, 512, 286, 471, 1281, 370, 11431, 27273, 13735, 1021, 310, 330, 906, 4657, 5433, 22964, 53413, 90270, 498, 330, 12527, 13401, 3915, 4727, 761, 310, 12262, 39024, 26319, 37364, 26, 39024, 26319, 37364, 26, 58, 39024, 42490, 14, 9171, 3103, 37274, 57, 498, 23266, 713, 11, 2373, 11, 28714, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 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, 1160, 315, 14519, 311, 4685, 382, 262, 551, 913, 23266, 713, 25, 279, 836, 315, 279, 12827, 6462, 11, 264, 5665, 320, 1277, 14, 2485, 8, 477, 264, 10521, 1052, 198, 262, 551, 1337, 23266, 713, 25, 610, 198, 262, 551, 913, 2373, 25, 304, 1162, 315, 279, 12827, 14519, 11, 279, 2373, 198, 262, 551, 1337, 2373, 25, 610, 198, 262, 551, 693, 25, 3508, 7946, 10487, 198, 262, 551, 33613, 25, 1845, 271, 14711, 6075, 512, 755, 4685, 27425, 41028, 713, 11, 2373, 429, 33092, 15497, 262, 3270, 262, 578, 1160, 315, 14519, 311, 4685, 382, 262, 551, 913, 23266, 713, 25, 279, 836, 315, 279, 12827, 6462, 11, 264, 5665, 320, 1277, 14, 2485, 8, 477, 264, 10521, 1052, 198, 262, 551, 1337, 23266, 713, 25, 610, 198, 262, 551, 913, 2373, 25, 304, 1162, 315, 279, 12827, 14519, 11, 279, 2373, 198, 262, 551, 1337, 2373, 25, 610, 198, 262, 551, 693, 25, 3508, 7946, 10487, 198, 262, 551, 33613, 25, 1845, 198, 262, 3270, 262, 5813, 11790, 746, 262, 422, 23266, 713, 27249, 446, 1277, 1129, 909, 477, 23266, 713, 27249, 446, 2485, 1129, 15497, 286, 2576, 284, 1281, 370, 11431, 10325, 12169, 1021, 310, 330, 10248, 39165, 14, 3222, 498, 12262, 39024, 26319, 37364, 37274, 53, 498, 1281, 370, 11431, 673, 16258, 1020, 943, 3991, 40553, 41028, 713, 1192, 286, 471, 539, 1281, 370, 11431, 27273, 13735, 1021, 310, 330, 906, 4657, 5433, 22964, 53413, 90270, 498, 330, 12527, 13401, 3915, 3222, 761, 310, 12262, 39024, 39165, 14, 3222, 26, 58, 39024, 42490, 14, 9171, 3103, 37274, 39024, 26319, 37364, 33603, 2576, 11, 43282, 374, 2290, 198, 262, 4508, 23266, 713, 18564, 1020, 1438, 4291, 5798, 10169, 15497, 286, 471, 539, 1281, 370, 11431, 27273, 13735, 1021, 310, 330, 906, 4657, 5433, 22964, 53413, 90270, 498, 330, 12527, 13401, 3915, 43602, 761, 310, 12262, 39024, 26319, 37364, 26, 58, 39024, 42490, 14, 9171, 3103, 37274, 39024, 26319, 37364, 33603, 23266, 713, 11, 43282, 374, 2290, 198, 262, 775, 512, 286, 471, 1281, 370, 11431, 27273, 13735, 1021, 310, 330, 906, 4657, 5433, 22964, 53413, 90270, 498, 330, 12527, 13401, 3915, 4727, 761, 310, 12262, 39024, 26319, 37364, 26, 39024, 26319, 37364, 26, 58, 39024, 42490, 14, 9171, 3103, 37274, 57, 498, 23266, 713, 11, 2373, 11, 28714, 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 ]
yfpeng/bioc
bioc/validator.py
validate
def validate(collection, onerror: Callable[[str, List], None] = None): """Validate BioC data structure.""" BioCValidator(onerror).validate(collection)
python
def validate(collection, onerror: Callable[[str, List], None] = None): """Validate BioC data structure.""" BioCValidator(onerror).validate(collection)
[ "def", "validate", "(", "collection", ",", "onerror", ":", "Callable", "[", "[", "str", ",", "List", "]", ",", "None", "]", "=", "None", ")", ":", "BioCValidator", "(", "onerror", ")", ".", "validate", "(", "collection", ")" ]
Validate BioC data structure.
[ "Validate", "BioC", "data", "structure", "." ]
train
https://github.com/yfpeng/bioc/blob/47ddaa010960d9ba673aefe068e7bbaf39f0fff4/bioc/validator.py#L131-L133
<|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: Validate BioC data structure. ### Response: def validate(collection, onerror: Callable[[str, List], None] = None): """Validate BioC data structure.""" BioCValidator(onerror).validate(collection) <|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, 18409, 24432, 34, 828, 6070, 382, 14711, 6075, 512, 755, 9788, 36966, 11, 389, 850, 25, 54223, 15873, 496, 11, 1796, 1145, 2290, 60, 284, 2290, 997, 262, 4304, 18409, 24432, 34, 828, 6070, 14781, 262, 24432, 34, 14591, 30455, 850, 570, 7212, 36966, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 18409, 24432, 34, 828, 6070, 382, 14711, 6075, 512, 755, 9788, 36966, 11, 389, 850, 25, 54223, 15873, 496, 11, 1796, 1145, 2290, 60, 284, 2290, 997, 262, 4304, 18409, 24432, 34, 828, 6070, 14781, 262, 24432, 34, 14591, 30455, 850, 570, 7212, 36966, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py
WorkItemTrackingClient.delete_field
def delete_field(self, field_name_or_ref_name, project=None): """DeleteField. [Preview API] Deletes the field. :param str field_name_or_ref_name: Field simple name or reference name :param str project: Project ID or project name """ route_values = {} if project is not None: route_values['project'] = self._serialize.url('project', project, 'str') if field_name_or_ref_name is not None: route_values['fieldNameOrRefName'] = self._serialize.url('field_name_or_ref_name', field_name_or_ref_name, 'str') self._send(http_method='DELETE', location_id='b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94', version='5.1-preview.2', route_values=route_values)
python
def delete_field(self, field_name_or_ref_name, project=None): """DeleteField. [Preview API] Deletes the field. :param str field_name_or_ref_name: Field simple name or reference name :param str project: Project ID or project name """ route_values = {} if project is not None: route_values['project'] = self._serialize.url('project', project, 'str') if field_name_or_ref_name is not None: route_values['fieldNameOrRefName'] = self._serialize.url('field_name_or_ref_name', field_name_or_ref_name, 'str') self._send(http_method='DELETE', location_id='b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94', version='5.1-preview.2', route_values=route_values)
[ "def", "delete_field", "(", "self", ",", "field_name_or_ref_name", ",", "project", "=", "None", ")", ":", "route_values", "=", "{", "}", "if", "project", "is", "not", "None", ":", "route_values", "[", "'project'", "]", "=", "self", ".", "_serialize", ".", "url", "(", "'project'", ",", "project", ",", "'str'", ")", "if", "field_name_or_ref_name", "is", "not", "None", ":", "route_values", "[", "'fieldNameOrRefName'", "]", "=", "self", ".", "_serialize", ".", "url", "(", "'field_name_or_ref_name'", ",", "field_name_or_ref_name", ",", "'str'", ")", "self", ".", "_send", "(", "http_method", "=", "'DELETE'", ",", "location_id", "=", "'b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94'", ",", "version", "=", "'5.1-preview.2'", ",", "route_values", "=", "route_values", ")" ]
DeleteField. [Preview API] Deletes the field. :param str field_name_or_ref_name: Field simple name or reference name :param str project: Project ID or project name
[ "DeleteField", ".", "[", "Preview", "API", "]", "Deletes", "the", "field", ".", ":", "param", "str", "field_name_or_ref_name", ":", "Field", "simple", "name", "or", "reference", "name", ":", "param", "str", "project", ":", "Project", "ID", "or", "project", "name" ]
train
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py#L626-L640
<|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: DeleteField. [Preview API] Deletes the field. :param str field_name_or_ref_name: Field simple name or reference name :param str project: Project ID or project name ### Response: def delete_field(self, field_name_or_ref_name, project=None): """DeleteField. [Preview API] Deletes the field. :param str field_name_or_ref_name: Field simple name or reference name :param str project: Project ID or project name """ route_values = {} if project is not None: route_values['project'] = self._serialize.url('project', project, 'str') if field_name_or_ref_name is not None: route_values['fieldNameOrRefName'] = self._serialize.url('field_name_or_ref_name', field_name_or_ref_name, 'str') self._send(http_method='DELETE', location_id='b51fd764-e5c2-4b9b-aaf7-3395cf4bdd94', version='5.1-preview.2', route_values=route_values) <|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, 6571, 1915, 627, 286, 510, 25648, 5446, 60, 56624, 279, 2115, 627, 286, 551, 913, 610, 2115, 1292, 8908, 7949, 1292, 25, 8771, 4382, 836, 477, 5905, 836, 198, 286, 551, 913, 610, 2447, 25, 5907, 3110, 477, 2447, 836, 271, 14711, 6075, 512, 755, 3783, 5121, 1214, 11, 2115, 1292, 8908, 7949, 1292, 11, 2447, 5980, 997, 286, 4304, 6571, 1915, 627, 286, 510, 25648, 5446, 60, 56624, 279, 2115, 627, 286, 551, 913, 610, 2115, 1292, 8908, 7949, 1292, 25, 8771, 4382, 836, 477, 5905, 836, 198, 286, 551, 913, 610, 2447, 25, 5907, 3110, 477, 2447, 836, 198, 286, 3270, 286, 6149, 9324, 284, 5731, 286, 422, 2447, 374, 539, 2290, 512, 310, 6149, 9324, 681, 5094, 663, 284, 659, 1462, 25140, 7464, 493, 5094, 518, 2447, 11, 364, 496, 1329, 286, 422, 2115, 1292, 8908, 7949, 1292, 374, 539, 2290, 512, 310, 6149, 9324, 681, 45694, 2244, 4032, 678, 663, 284, 659, 1462, 25140, 7464, 493, 2630, 1292, 8908, 7949, 1292, 518, 2115, 1292, 8908, 7949, 1292, 11, 364, 496, 1329, 286, 659, 1462, 6820, 20480, 9209, 1151, 14762, 756, 4391, 3813, 851, 1151, 65, 3971, 7047, 24402, 5773, 20, 66, 17, 12, 19, 65, 24, 65, 7561, 2642, 22, 12, 17887, 20, 9991, 19, 51542, 6281, 756, 4391, 2373, 1151, 20, 13, 16, 51981, 13, 17, 756, 4391, 6149, 9324, 28, 9143, 9324, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 6571, 1915, 627, 286, 510, 25648, 5446, 60, 56624, 279, 2115, 627, 286, 551, 913, 610, 2115, 1292, 8908, 7949, 1292, 25, 8771, 4382, 836, 477, 5905, 836, 198, 286, 551, 913, 610, 2447, 25, 5907, 3110, 477, 2447, 836, 271, 14711, 6075, 512, 755, 3783, 5121, 1214, 11, 2115, 1292, 8908, 7949, 1292, 11, 2447, 5980, 997, 286, 4304, 6571, 1915, 627, 286, 510, 25648, 5446, 60, 56624, 279, 2115, 627, 286, 551, 913, 610, 2115, 1292, 8908, 7949, 1292, 25, 8771, 4382, 836, 477, 5905, 836, 198, 286, 551, 913, 610, 2447, 25, 5907, 3110, 477, 2447, 836, 198, 286, 3270, 286, 6149, 9324, 284, 5731, 286, 422, 2447, 374, 539, 2290, 512, 310, 6149, 9324, 681, 5094, 663, 284, 659, 1462, 25140, 7464, 493, 5094, 518, 2447, 11, 364, 496, 1329, 286, 422, 2115, 1292, 8908, 7949, 1292, 374, 539, 2290, 512, 310, 6149, 9324, 681, 45694, 2244, 4032, 678, 663, 284, 659, 1462, 25140, 7464, 493, 2630, 1292, 8908, 7949, 1292, 518, 2115, 1292, 8908, 7949, 1292, 11, 364, 496, 1329, 286, 659, 1462, 6820, 20480, 9209, 1151, 14762, 756, 4391, 3813, 851, 1151, 65, 3971, 7047, 24402, 5773, 20, 66, 17, 12, 19, 65, 24, 65, 7561, 2642, 22, 12, 17887, 20, 9991, 19, 51542, 6281, 756, 4391, 2373, 1151, 20, 13, 16, 51981, 13, 17, 756, 4391, 6149, 9324, 28, 9143, 9324, 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 ]
cggh/scikit-allel
allel/stats/selection.py
moving_hfs_rank
def moving_hfs_rank(h, size, start=0, stop=None): """Helper function for plotting haplotype frequencies in moving windows. Parameters ---------- h : array_like, int, shape (n_variants, n_haplotypes) Haplotype array. size : int The window size (number of variants). start : int, optional The index at which to start. stop : int, optional The index at which to stop. Returns ------- hr : ndarray, int, shape (n_windows, n_haplotypes) Haplotype rank array. """ # determine windows windows = np.asarray(list(index_windows(h, size=size, start=start, stop=stop, step=None))) # setup output hr = np.zeros((windows.shape[0], h.shape[1]), dtype='i4') # iterate over windows for i, (window_start, window_stop) in enumerate(windows): # extract haplotypes for the current window hw = h[window_start:window_stop] # count haplotypes hc = hw.distinct_counts() # ensure sorted descending hc.sort() hc = hc[::-1] # compute ranks for non-singleton haplotypes cp = 0 for j, c in enumerate(hc): if c > 1: hr[i, cp:cp+c] = j+1 cp += c return hr
python
def moving_hfs_rank(h, size, start=0, stop=None): """Helper function for plotting haplotype frequencies in moving windows. Parameters ---------- h : array_like, int, shape (n_variants, n_haplotypes) Haplotype array. size : int The window size (number of variants). start : int, optional The index at which to start. stop : int, optional The index at which to stop. Returns ------- hr : ndarray, int, shape (n_windows, n_haplotypes) Haplotype rank array. """ # determine windows windows = np.asarray(list(index_windows(h, size=size, start=start, stop=stop, step=None))) # setup output hr = np.zeros((windows.shape[0], h.shape[1]), dtype='i4') # iterate over windows for i, (window_start, window_stop) in enumerate(windows): # extract haplotypes for the current window hw = h[window_start:window_stop] # count haplotypes hc = hw.distinct_counts() # ensure sorted descending hc.sort() hc = hc[::-1] # compute ranks for non-singleton haplotypes cp = 0 for j, c in enumerate(hc): if c > 1: hr[i, cp:cp+c] = j+1 cp += c return hr
[ "def", "moving_hfs_rank", "(", "h", ",", "size", ",", "start", "=", "0", ",", "stop", "=", "None", ")", ":", "# determine windows", "windows", "=", "np", ".", "asarray", "(", "list", "(", "index_windows", "(", "h", ",", "size", "=", "size", ",", "start", "=", "start", ",", "stop", "=", "stop", ",", "step", "=", "None", ")", ")", ")", "# setup output", "hr", "=", "np", ".", "zeros", "(", "(", "windows", ".", "shape", "[", "0", "]", ",", "h", ".", "shape", "[", "1", "]", ")", ",", "dtype", "=", "'i4'", ")", "# iterate over windows", "for", "i", ",", "(", "window_start", ",", "window_stop", ")", "in", "enumerate", "(", "windows", ")", ":", "# extract haplotypes for the current window", "hw", "=", "h", "[", "window_start", ":", "window_stop", "]", "# count haplotypes", "hc", "=", "hw", ".", "distinct_counts", "(", ")", "# ensure sorted descending", "hc", ".", "sort", "(", ")", "hc", "=", "hc", "[", ":", ":", "-", "1", "]", "# compute ranks for non-singleton haplotypes", "cp", "=", "0", "for", "j", ",", "c", "in", "enumerate", "(", "hc", ")", ":", "if", "c", ">", "1", ":", "hr", "[", "i", ",", "cp", ":", "cp", "+", "c", "]", "=", "j", "+", "1", "cp", "+=", "c", "return", "hr" ]
Helper function for plotting haplotype frequencies in moving windows. Parameters ---------- h : array_like, int, shape (n_variants, n_haplotypes) Haplotype array. size : int The window size (number of variants). start : int, optional The index at which to start. stop : int, optional The index at which to stop. Returns ------- hr : ndarray, int, shape (n_windows, n_haplotypes) Haplotype rank array.
[ "Helper", "function", "for", "plotting", "haplotype", "frequencies", "in", "moving", "windows", "." ]
train
https://github.com/cggh/scikit-allel/blob/3c979a57a100240ba959dd13f98839349530f215/allel/stats/selection.py#L948-L996
<|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: Helper function for plotting haplotype frequencies in moving windows. Parameters ---------- h : array_like, int, shape (n_variants, n_haplotypes) Haplotype array. size : int The window size (number of variants). start : int, optional The index at which to start. stop : int, optional The index at which to stop. Returns ------- hr : ndarray, int, shape (n_windows, n_haplotypes) Haplotype rank array. ### Response: def moving_hfs_rank(h, size, start=0, stop=None): """Helper function for plotting haplotype frequencies in moving windows. Parameters ---------- h : array_like, int, shape (n_variants, n_haplotypes) Haplotype array. size : int The window size (number of variants). start : int, optional The index at which to start. stop : int, optional The index at which to stop. Returns ------- hr : ndarray, int, shape (n_windows, n_haplotypes) Haplotype rank array. """ # determine windows windows = np.asarray(list(index_windows(h, size=size, start=start, stop=stop, step=None))) # setup output hr = np.zeros((windows.shape[0], h.shape[1]), dtype='i4') # iterate over windows for i, (window_start, window_stop) in enumerate(windows): # extract haplotypes for the current window hw = h[window_start:window_stop] # count haplotypes hc = hw.distinct_counts() # ensure sorted descending hc.sort() hc = hc[::-1] # compute ranks for non-singleton haplotypes cp = 0 for j, c in enumerate(hc): if c > 1: hr[i, cp:cp+c] = j+1 cp += c return hr <|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, 5628, 734, 369, 45002, 46900, 75, 4249, 34873, 304, 7366, 11276, 382, 262, 13831, 198, 262, 31423, 262, 305, 551, 1358, 26616, 11, 528, 11, 6211, 320, 77, 4715, 63378, 11, 308, 1552, 391, 9363, 1842, 340, 286, 473, 73389, 4249, 1358, 627, 262, 1404, 551, 528, 198, 286, 578, 3321, 1404, 320, 4174, 315, 27103, 4390, 262, 1212, 551, 528, 11, 10309, 198, 286, 578, 1963, 520, 902, 311, 1212, 627, 262, 3009, 551, 528, 11, 10309, 198, 286, 578, 1963, 520, 902, 311, 3009, 382, 262, 5295, 198, 262, 39707, 262, 18514, 551, 67983, 11, 528, 11, 6211, 320, 77, 59320, 11, 308, 1552, 391, 9363, 1842, 340, 286, 473, 73389, 4249, 7222, 1358, 382, 14711, 6075, 512, 755, 7366, 1552, 3933, 21048, 3283, 11, 1404, 11, 1212, 28, 15, 11, 3009, 5980, 997, 262, 4304, 5628, 734, 369, 45002, 46900, 75, 4249, 34873, 304, 7366, 11276, 382, 262, 13831, 198, 262, 31423, 262, 305, 551, 1358, 26616, 11, 528, 11, 6211, 320, 77, 4715, 63378, 11, 308, 1552, 391, 9363, 1842, 340, 286, 473, 73389, 4249, 1358, 627, 262, 1404, 551, 528, 198, 286, 578, 3321, 1404, 320, 4174, 315, 27103, 4390, 262, 1212, 551, 528, 11, 10309, 198, 286, 578, 1963, 520, 902, 311, 1212, 627, 262, 3009, 551, 528, 11, 10309, 198, 286, 578, 1963, 520, 902, 311, 3009, 382, 262, 5295, 198, 262, 39707, 262, 18514, 551, 67983, 11, 528, 11, 6211, 320, 77, 59320, 11, 308, 1552, 391, 9363, 1842, 340, 286, 473, 73389, 4249, 7222, 1358, 382, 262, 12713, 262, 674, 8417, 11276, 198, 262, 11276, 284, 2660, 39178, 7455, 7343, 59320, 3283, 11, 1404, 75278, 11, 1212, 56722, 345, 3425, 3009, 28, 9684, 11, 3094, 5980, 19789, 262, 674, 6642, 2612, 198, 262, 18514, 284, 2660, 13064, 1209, 28176, 7201, 58, 15, 1145, 305, 7201, 58, 16, 9918, 13534, 1151, 72, 19, 4713, 262, 674, 30729, 927, 11276, 198, 262, 369, 602, 11, 320, 5624, 5011, 11, 3321, 19577, 8, 304, 13555, 3706, 1519, 7887, 286, 674, 8819, 46900, 9363, 1842, 369, 279, 1510, 3321, 198, 286, 32356, 284, 305, 58, 5624, 5011, 25, 5624, 19577, 2595, 286, 674, 1797, 46900, 9363, 1842, 198, 286, 51494, 284, 32356, 39077, 7956, 27067, 2892, 286, 674, 6106, 10839, 44184, 198, 286, 51494, 10838, 746, 286, 51494, 284, 51494, 63254, 16, 2595, 286, 674, 12849, 21467, 369, 2536, 57787, 783, 46900, 9363, 1842, 198, 286, 12773, 284, 220, 15, 198, 286, 369, 503, 11, 272, 304, 13555, 3283, 66, 997, 310, 422, 272, 871, 220, 16, 512, 394, 18514, 1004, 11, 12773, 25, 4777, 50238, 60, 284, 503, 10, 16, 198, 310, 12773, 1447, 272, 271, 262, 471, 18514, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 5628, 734, 369, 45002, 46900, 75, 4249, 34873, 304, 7366, 11276, 382, 262, 13831, 198, 262, 31423, 262, 305, 551, 1358, 26616, 11, 528, 11, 6211, 320, 77, 4715, 63378, 11, 308, 1552, 391, 9363, 1842, 340, 286, 473, 73389, 4249, 1358, 627, 262, 1404, 551, 528, 198, 286, 578, 3321, 1404, 320, 4174, 315, 27103, 4390, 262, 1212, 551, 528, 11, 10309, 198, 286, 578, 1963, 520, 902, 311, 1212, 627, 262, 3009, 551, 528, 11, 10309, 198, 286, 578, 1963, 520, 902, 311, 3009, 382, 262, 5295, 198, 262, 39707, 262, 18514, 551, 67983, 11, 528, 11, 6211, 320, 77, 59320, 11, 308, 1552, 391, 9363, 1842, 340, 286, 473, 73389, 4249, 7222, 1358, 382, 14711, 6075, 512, 755, 7366, 1552, 3933, 21048, 3283, 11, 1404, 11, 1212, 28, 15, 11, 3009, 5980, 997, 262, 4304, 5628, 734, 369, 45002, 46900, 75, 4249, 34873, 304, 7366, 11276, 382, 262, 13831, 198, 262, 31423, 262, 305, 551, 1358, 26616, 11, 528, 11, 6211, 320, 77, 4715, 63378, 11, 308, 1552, 391, 9363, 1842, 340, 286, 473, 73389, 4249, 1358, 627, 262, 1404, 551, 528, 198, 286, 578, 3321, 1404, 320, 4174, 315, 27103, 4390, 262, 1212, 551, 528, 11, 10309, 198, 286, 578, 1963, 520, 902, 311, 1212, 627, 262, 3009, 551, 528, 11, 10309, 198, 286, 578, 1963, 520, 902, 311, 3009, 382, 262, 5295, 198, 262, 39707, 262, 18514, 551, 67983, 11, 528, 11, 6211, 320, 77, 59320, 11, 308, 1552, 391, 9363, 1842, 340, 286, 473, 73389, 4249, 7222, 1358, 382, 262, 12713, 262, 674, 8417, 11276, 198, 262, 11276, 284, 2660, 39178, 7455, 7343, 59320, 3283, 11, 1404, 75278, 11, 1212, 56722, 345, 3425, 3009, 28, 9684, 11, 3094, 5980, 19789, 262, 674, 6642, 2612, 198, 262, 18514, 284, 2660, 13064, 1209, 28176, 7201, 58, 15, 1145, 305, 7201, 58, 16, 9918, 13534, 1151, 72, 19, 4713, 262, 674, 30729, 927, 11276, 198, 262, 369, 602, 11, 320, 5624, 5011, 11, 3321, 19577, 8, 304, 13555, 3706, 1519, 7887, 286, 674, 8819, 46900, 9363, 1842, 369, 279, 1510, 3321, 198, 286, 32356, 284, 305, 58, 5624, 5011, 25, 5624, 19577, 2595, 286, 674, 1797, 46900, 9363, 1842, 198, 286, 51494, 284, 32356, 39077, 7956, 27067, 2892, 286, 674, 6106, 10839, 44184, 198, 286, 51494, 10838, 746, 286, 51494, 284, 51494, 63254, 16, 2595, 286, 674, 12849, 21467, 369, 2536, 57787, 783, 46900, 9363, 1842, 198, 286, 12773, 284, 220, 15, 198, 286, 369, 503, 11, 272, 304, 13555, 3283, 66, 997, 310, 422, 272, 871, 220, 16, 512, 394, 18514, 1004, 11, 12773, 25, 4777, 50238, 60, 284, 503, 10, 16, 198, 310, 12773, 1447, 272, 271, 262, 471, 18514, 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 ]
underworldcode/stripy
stripy-src/stripy/spherical.py
sTriangulation._generate_permutation
def _generate_permutation(self, npoints): """ Create shuffle and deshuffle vectors """ i = np.arange(0, npoints) # permutation p = np.random.permutation(npoints) ip = np.empty_like(p) # inverse permutation ip[p[i]] = i return p, ip
python
def _generate_permutation(self, npoints): """ Create shuffle and deshuffle vectors """ i = np.arange(0, npoints) # permutation p = np.random.permutation(npoints) ip = np.empty_like(p) # inverse permutation ip[p[i]] = i return p, ip
[ "def", "_generate_permutation", "(", "self", ",", "npoints", ")", ":", "i", "=", "np", ".", "arange", "(", "0", ",", "npoints", ")", "# permutation", "p", "=", "np", ".", "random", ".", "permutation", "(", "npoints", ")", "ip", "=", "np", ".", "empty_like", "(", "p", ")", "# inverse permutation", "ip", "[", "p", "[", "i", "]", "]", "=", "i", "return", "p", ",", "ip" ]
Create shuffle and deshuffle vectors
[ "Create", "shuffle", "and", "deshuffle", "vectors" ]
train
https://github.com/underworldcode/stripy/blob/d4c3480c3e58c88489ded695eadbe7cd5bf94b48/stripy-src/stripy/spherical.py#L128-L138
<|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 shuffle and deshuffle vectors ### Response: def _generate_permutation(self, npoints): """ Create shuffle and deshuffle vectors """ i = np.arange(0, npoints) # permutation p = np.random.permutation(npoints) ip = np.empty_like(p) # inverse permutation ip[p[i]] = i return p, ip <|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, 27037, 323, 951, 71, 13511, 23728, 271, 14711, 6075, 512, 755, 721, 19927, 33061, 23539, 1214, 11, 2660, 14737, 997, 286, 3270, 286, 4324, 27037, 323, 951, 71, 13511, 23728, 198, 286, 3270, 286, 602, 284, 2660, 25306, 7, 15, 11, 2660, 14737, 340, 286, 674, 59541, 198, 286, 281, 284, 2660, 7985, 63781, 23539, 1471, 7862, 340, 286, 6125, 284, 2660, 9357, 26616, 1319, 340, 286, 674, 29049, 59541, 198, 286, 6125, 11661, 1004, 5163, 284, 602, 198, 286, 471, 281, 11, 6125, 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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 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, 27037, 323, 951, 71, 13511, 23728, 271, 14711, 6075, 512, 755, 721, 19927, 33061, 23539, 1214, 11, 2660, 14737, 997, 286, 3270, 286, 4324, 27037, 323, 951, 71, 13511, 23728, 198, 286, 3270, 286, 602, 284, 2660, 25306, 7, 15, 11, 2660, 14737, 340, 286, 674, 59541, 198, 286, 281, 284, 2660, 7985, 63781, 23539, 1471, 7862, 340, 286, 6125, 284, 2660, 9357, 26616, 1319, 340, 286, 674, 29049, 59541, 198, 286, 6125, 11661, 1004, 5163, 284, 602, 198, 286, 471, 281, 11, 6125, 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 ]
ioos/compliance-checker
compliance_checker/cfutil.py
get_z_variables
def get_z_variables(nc): ''' Returns a list of all variables matching definitions for Z :param netcdf4.dataset nc: an open netcdf dataset object ''' z_variables = [] # Vertical coordinates will be identifiable by units of pressure or the # presence of the positive attribute with a value of up/down # optionally, the vertical type may be indicated by providing the # standard_name attribute or axis='Z' total_coords = get_coordinate_variables(nc) + get_auxiliary_coordinate_variables(nc) for coord_name in total_coords: if coord_name in z_variables: continue coord_var = nc.variables[coord_name] units = getattr(coord_var, 'units', None) positive = getattr(coord_var, 'positive', None) standard_name = getattr(coord_var, 'standard_name', None) axis = getattr(coord_var, 'axis', None) # If there are no units, we can't identify it as a vertical coordinate # by checking pressure or positive if units is not None: if units_convertible(units, 'bar'): z_variables.append(coord_name) elif isinstance(positive, basestring): if positive.lower() in ['up', 'down']: z_variables.append(coord_name) # if axis='Z' we're good if coord_name not in z_variables and axis == 'Z': z_variables.append(coord_name) if coord_name not in z_variables and standard_name in ('depth', 'height', 'altitude'): z_variables.append(coord_name) if coord_name not in z_variables and standard_name in DIMENSIONLESS_VERTICAL_COORDINATES: z_variables.append(coord_name) return z_variables
python
def get_z_variables(nc): ''' Returns a list of all variables matching definitions for Z :param netcdf4.dataset nc: an open netcdf dataset object ''' z_variables = [] # Vertical coordinates will be identifiable by units of pressure or the # presence of the positive attribute with a value of up/down # optionally, the vertical type may be indicated by providing the # standard_name attribute or axis='Z' total_coords = get_coordinate_variables(nc) + get_auxiliary_coordinate_variables(nc) for coord_name in total_coords: if coord_name in z_variables: continue coord_var = nc.variables[coord_name] units = getattr(coord_var, 'units', None) positive = getattr(coord_var, 'positive', None) standard_name = getattr(coord_var, 'standard_name', None) axis = getattr(coord_var, 'axis', None) # If there are no units, we can't identify it as a vertical coordinate # by checking pressure or positive if units is not None: if units_convertible(units, 'bar'): z_variables.append(coord_name) elif isinstance(positive, basestring): if positive.lower() in ['up', 'down']: z_variables.append(coord_name) # if axis='Z' we're good if coord_name not in z_variables and axis == 'Z': z_variables.append(coord_name) if coord_name not in z_variables and standard_name in ('depth', 'height', 'altitude'): z_variables.append(coord_name) if coord_name not in z_variables and standard_name in DIMENSIONLESS_VERTICAL_COORDINATES: z_variables.append(coord_name) return z_variables
[ "def", "get_z_variables", "(", "nc", ")", ":", "z_variables", "=", "[", "]", "# Vertical coordinates will be identifiable by units of pressure or the", "# presence of the positive attribute with a value of up/down", "# optionally, the vertical type may be indicated by providing the", "# standard_name attribute or axis='Z'", "total_coords", "=", "get_coordinate_variables", "(", "nc", ")", "+", "get_auxiliary_coordinate_variables", "(", "nc", ")", "for", "coord_name", "in", "total_coords", ":", "if", "coord_name", "in", "z_variables", ":", "continue", "coord_var", "=", "nc", ".", "variables", "[", "coord_name", "]", "units", "=", "getattr", "(", "coord_var", ",", "'units'", ",", "None", ")", "positive", "=", "getattr", "(", "coord_var", ",", "'positive'", ",", "None", ")", "standard_name", "=", "getattr", "(", "coord_var", ",", "'standard_name'", ",", "None", ")", "axis", "=", "getattr", "(", "coord_var", ",", "'axis'", ",", "None", ")", "# If there are no units, we can't identify it as a vertical coordinate", "# by checking pressure or positive", "if", "units", "is", "not", "None", ":", "if", "units_convertible", "(", "units", ",", "'bar'", ")", ":", "z_variables", ".", "append", "(", "coord_name", ")", "elif", "isinstance", "(", "positive", ",", "basestring", ")", ":", "if", "positive", ".", "lower", "(", ")", "in", "[", "'up'", ",", "'down'", "]", ":", "z_variables", ".", "append", "(", "coord_name", ")", "# if axis='Z' we're good", "if", "coord_name", "not", "in", "z_variables", "and", "axis", "==", "'Z'", ":", "z_variables", ".", "append", "(", "coord_name", ")", "if", "coord_name", "not", "in", "z_variables", "and", "standard_name", "in", "(", "'depth'", ",", "'height'", ",", "'altitude'", ")", ":", "z_variables", ".", "append", "(", "coord_name", ")", "if", "coord_name", "not", "in", "z_variables", "and", "standard_name", "in", "DIMENSIONLESS_VERTICAL_COORDINATES", ":", "z_variables", ".", "append", "(", "coord_name", ")", "return", "z_variables" ]
Returns a list of all variables matching definitions for Z :param netcdf4.dataset nc: an open netcdf dataset object
[ "Returns", "a", "list", "of", "all", "variables", "matching", "definitions", "for", "Z" ]
train
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L383-L421
<|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 list of all variables matching definitions for Z :param netcdf4.dataset nc: an open netcdf dataset object ### Response: def get_z_variables(nc): ''' Returns a list of all variables matching definitions for Z :param netcdf4.dataset nc: an open netcdf dataset object ''' z_variables = [] # Vertical coordinates will be identifiable by units of pressure or the # presence of the positive attribute with a value of up/down # optionally, the vertical type may be indicated by providing the # standard_name attribute or axis='Z' total_coords = get_coordinate_variables(nc) + get_auxiliary_coordinate_variables(nc) for coord_name in total_coords: if coord_name in z_variables: continue coord_var = nc.variables[coord_name] units = getattr(coord_var, 'units', None) positive = getattr(coord_var, 'positive', None) standard_name = getattr(coord_var, 'standard_name', None) axis = getattr(coord_var, 'axis', None) # If there are no units, we can't identify it as a vertical coordinate # by checking pressure or positive if units is not None: if units_convertible(units, 'bar'): z_variables.append(coord_name) elif isinstance(positive, basestring): if positive.lower() in ['up', 'down']: z_variables.append(coord_name) # if axis='Z' we're good if coord_name not in z_variables and axis == 'Z': z_variables.append(coord_name) if coord_name not in z_variables and standard_name in ('depth', 'height', 'altitude'): z_variables.append(coord_name) if coord_name not in z_variables and standard_name in DIMENSIONLESS_VERTICAL_COORDINATES: z_variables.append(coord_name) return z_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, 16851, 264, 1160, 315, 682, 7482, 12864, 17931, 369, 1901, 271, 262, 551, 913, 4272, 59448, 19, 25600, 26183, 25, 459, 1825, 4272, 59448, 10550, 1665, 271, 14711, 6075, 512, 755, 636, 6551, 29282, 58168, 997, 262, 11414, 262, 5295, 264, 1160, 315, 682, 7482, 12864, 17931, 369, 1901, 271, 262, 551, 913, 4272, 59448, 19, 25600, 26183, 25, 459, 1825, 4272, 59448, 10550, 1665, 198, 262, 11414, 262, 1167, 29282, 284, 4260, 262, 674, 36563, 14259, 690, 387, 72450, 555, 8316, 315, 7410, 477, 279, 198, 262, 674, 9546, 315, 279, 6928, 7180, 449, 264, 907, 315, 709, 80167, 271, 262, 674, 46624, 11, 279, 12414, 955, 1253, 387, 16717, 555, 8405, 279, 198, 262, 674, 5410, 1292, 7180, 477, 8183, 1151, 57, 3961, 262, 2860, 33676, 284, 636, 69749, 29282, 58168, 8, 489, 636, 31568, 35546, 69749, 29282, 58168, 340, 262, 369, 16896, 1292, 304, 2860, 33676, 512, 286, 422, 16896, 1292, 304, 1167, 29282, 512, 310, 3136, 198, 286, 16896, 4715, 284, 26183, 52393, 58, 27500, 1292, 933, 286, 8316, 284, 31097, 66137, 4715, 11, 364, 26726, 518, 2290, 340, 286, 6928, 284, 31097, 66137, 4715, 11, 364, 31587, 518, 2290, 340, 286, 5410, 1292, 284, 31097, 66137, 4715, 11, 364, 20885, 1292, 518, 2290, 340, 286, 8183, 284, 31097, 66137, 4715, 11, 364, 7332, 518, 2290, 340, 286, 674, 1442, 1070, 527, 912, 8316, 11, 584, 649, 956, 10765, 433, 439, 264, 12414, 16580, 198, 286, 674, 555, 13598, 7410, 477, 6928, 198, 286, 422, 8316, 374, 539, 2290, 512, 310, 422, 8316, 36010, 1260, 84165, 11, 364, 2308, 11290, 394, 1167, 29282, 2102, 66137, 1292, 340, 310, 4508, 11656, 7, 31587, 11, 3122, 66140, 997, 394, 422, 6928, 18564, 368, 304, 2570, 455, 518, 364, 2996, 18888, 504, 1167, 29282, 2102, 66137, 1292, 340, 286, 674, 422, 8183, 1151, 57, 6, 584, 2351, 1695, 198, 286, 422, 16896, 1292, 539, 304, 1167, 29282, 323, 8183, 624, 364, 57, 3730, 310, 1167, 29282, 2102, 66137, 1292, 340, 286, 422, 16896, 1292, 539, 304, 1167, 29282, 323, 5410, 1292, 304, 4417, 18021, 518, 364, 2627, 518, 364, 99111, 11290, 310, 1167, 29282, 2102, 66137, 1292, 340, 286, 422, 16896, 1292, 539, 304, 1167, 29282, 323, 5410, 1292, 304, 51959, 24557, 38873, 74659, 61608, 691, 31404, 512, 310, 1167, 29282, 2102, 66137, 1292, 696, 262, 471, 1167, 29282, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 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, 1160, 315, 682, 7482, 12864, 17931, 369, 1901, 271, 262, 551, 913, 4272, 59448, 19, 25600, 26183, 25, 459, 1825, 4272, 59448, 10550, 1665, 271, 14711, 6075, 512, 755, 636, 6551, 29282, 58168, 997, 262, 11414, 262, 5295, 264, 1160, 315, 682, 7482, 12864, 17931, 369, 1901, 271, 262, 551, 913, 4272, 59448, 19, 25600, 26183, 25, 459, 1825, 4272, 59448, 10550, 1665, 198, 262, 11414, 262, 1167, 29282, 284, 4260, 262, 674, 36563, 14259, 690, 387, 72450, 555, 8316, 315, 7410, 477, 279, 198, 262, 674, 9546, 315, 279, 6928, 7180, 449, 264, 907, 315, 709, 80167, 271, 262, 674, 46624, 11, 279, 12414, 955, 1253, 387, 16717, 555, 8405, 279, 198, 262, 674, 5410, 1292, 7180, 477, 8183, 1151, 57, 3961, 262, 2860, 33676, 284, 636, 69749, 29282, 58168, 8, 489, 636, 31568, 35546, 69749, 29282, 58168, 340, 262, 369, 16896, 1292, 304, 2860, 33676, 512, 286, 422, 16896, 1292, 304, 1167, 29282, 512, 310, 3136, 198, 286, 16896, 4715, 284, 26183, 52393, 58, 27500, 1292, 933, 286, 8316, 284, 31097, 66137, 4715, 11, 364, 26726, 518, 2290, 340, 286, 6928, 284, 31097, 66137, 4715, 11, 364, 31587, 518, 2290, 340, 286, 5410, 1292, 284, 31097, 66137, 4715, 11, 364, 20885, 1292, 518, 2290, 340, 286, 8183, 284, 31097, 66137, 4715, 11, 364, 7332, 518, 2290, 340, 286, 674, 1442, 1070, 527, 912, 8316, 11, 584, 649, 956, 10765, 433, 439, 264, 12414, 16580, 198, 286, 674, 555, 13598, 7410, 477, 6928, 198, 286, 422, 8316, 374, 539, 2290, 512, 310, 422, 8316, 36010, 1260, 84165, 11, 364, 2308, 11290, 394, 1167, 29282, 2102, 66137, 1292, 340, 310, 4508, 11656, 7, 31587, 11, 3122, 66140, 997, 394, 422, 6928, 18564, 368, 304, 2570, 455, 518, 364, 2996, 18888, 504, 1167, 29282, 2102, 66137, 1292, 340, 286, 674, 422, 8183, 1151, 57, 6, 584, 2351, 1695, 198, 286, 422, 16896, 1292, 539, 304, 1167, 29282, 323, 8183, 624, 364, 57, 3730, 310, 1167, 29282, 2102, 66137, 1292, 340, 286, 422, 16896, 1292, 539, 304, 1167, 29282, 323, 5410, 1292, 304, 4417, 18021, 518, 364, 2627, 518, 364, 99111, 11290, 310, 1167, 29282, 2102, 66137, 1292, 340, 286, 422, 16896, 1292, 539, 304, 1167, 29282, 323, 5410, 1292, 304, 51959, 24557, 38873, 74659, 61608, 691, 31404, 512, 310, 1167, 29282, 2102, 66137, 1292, 696, 262, 471, 1167, 29282, 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 ]
openearth/bmi-python
bmi/wrapper.py
BMIWrapper._load_library
def _load_library(self): """Return the fortran library, loaded with """ path = self._library_path() logger.info("Loading library from path {}".format(path)) library_dir = os.path.dirname(path) if platform.system() == 'Windows': import win32api olddir = os.getcwd() os.chdir(library_dir) win32api.SetDllDirectory('.') result = cdll.LoadLibrary(path) if platform.system() == 'Windows': os.chdir(olddir) return result
python
def _load_library(self): """Return the fortran library, loaded with """ path = self._library_path() logger.info("Loading library from path {}".format(path)) library_dir = os.path.dirname(path) if platform.system() == 'Windows': import win32api olddir = os.getcwd() os.chdir(library_dir) win32api.SetDllDirectory('.') result = cdll.LoadLibrary(path) if platform.system() == 'Windows': os.chdir(olddir) return result
[ "def", "_load_library", "(", "self", ")", ":", "path", "=", "self", ".", "_library_path", "(", ")", "logger", ".", "info", "(", "\"Loading library from path {}\"", ".", "format", "(", "path", ")", ")", "library_dir", "=", "os", ".", "path", ".", "dirname", "(", "path", ")", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", "import", "win32api", "olddir", "=", "os", ".", "getcwd", "(", ")", "os", ".", "chdir", "(", "library_dir", ")", "win32api", ".", "SetDllDirectory", "(", "'.'", ")", "result", "=", "cdll", ".", "LoadLibrary", "(", "path", ")", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", "os", ".", "chdir", "(", "olddir", ")", "return", "result" ]
Return the fortran library, loaded with
[ "Return", "the", "fortran", "library", "loaded", "with" ]
train
https://github.com/openearth/bmi-python/blob/2f53f24d45515eb0711c2d28ddd6c1582045248f/bmi/wrapper.py#L309-L325
<|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 fortran library, loaded with ### Response: def _load_library(self): """Return the fortran library, loaded with """ path = self._library_path() logger.info("Loading library from path {}".format(path)) library_dir = os.path.dirname(path) if platform.system() == 'Windows': import win32api olddir = os.getcwd() os.chdir(library_dir) win32api.SetDllDirectory('.') result = cdll.LoadLibrary(path) if platform.system() == 'Windows': os.chdir(olddir) return result <|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, 369, 44469, 6875, 11, 6799, 449, 271, 14711, 6075, 512, 755, 721, 1096, 40561, 1214, 997, 286, 4304, 5715, 279, 369, 44469, 6875, 11, 6799, 449, 3270, 286, 1853, 284, 659, 1462, 18556, 2703, 746, 286, 6050, 5506, 446, 8746, 6875, 505, 1853, 21532, 2293, 5698, 1192, 286, 6875, 4432, 284, 2709, 3960, 21803, 5698, 340, 286, 422, 5452, 16315, 368, 624, 364, 13466, 3730, 310, 1179, 3243, 843, 2113, 198, 310, 2362, 3826, 284, 2709, 47574, 746, 310, 2709, 52110, 94399, 4432, 340, 310, 3243, 843, 2113, 4296, 35112, 9494, 493, 49420, 286, 1121, 284, 15667, 657, 14296, 17344, 5698, 696, 286, 422, 5452, 16315, 368, 624, 364, 13466, 3730, 310, 2709, 52110, 7, 337, 634, 404, 696, 286, 471, 1121, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 369, 44469, 6875, 11, 6799, 449, 271, 14711, 6075, 512, 755, 721, 1096, 40561, 1214, 997, 286, 4304, 5715, 279, 369, 44469, 6875, 11, 6799, 449, 3270, 286, 1853, 284, 659, 1462, 18556, 2703, 746, 286, 6050, 5506, 446, 8746, 6875, 505, 1853, 21532, 2293, 5698, 1192, 286, 6875, 4432, 284, 2709, 3960, 21803, 5698, 340, 286, 422, 5452, 16315, 368, 624, 364, 13466, 3730, 310, 1179, 3243, 843, 2113, 198, 310, 2362, 3826, 284, 2709, 47574, 746, 310, 2709, 52110, 94399, 4432, 340, 310, 3243, 843, 2113, 4296, 35112, 9494, 493, 49420, 286, 1121, 284, 15667, 657, 14296, 17344, 5698, 696, 286, 422, 5452, 16315, 368, 624, 364, 13466, 3730, 310, 2709, 52110, 7, 337, 634, 404, 696, 286, 471, 1121, 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 ]
dropbox/stone
stone/backends/obj_c_types.py
ObjCTypesBackend._generate_struct_cstor
def _generate_struct_cstor(self, struct): """Emits struct standard constructor.""" with self.block_func( func=self._cstor_name_from_fields(struct.all_fields), args=fmt_func_args_from_fields(struct.all_fields), return_type='instancetype'): for field in struct.all_fields: self._generate_validator(field) self.emit() super_fields = [ f for f in struct.all_fields if f not in struct.fields ] if super_fields: super_args = fmt_func_args([(fmt_var(f.name), fmt_var(f.name)) for f in super_fields]) self.emit('self = [super {}:{}];'.format( self._cstor_name_from_fields(super_fields), super_args)) else: if struct.parent_type: self.emit('self = [super initDefault];') else: self.emit('self = [super init];') with self.block_init(): for field in struct.fields: field_name = fmt_var(field.name) if field.has_default: self.emit('_{} = {} ?: {};'.format( field_name, field_name, fmt_default_value(field))) else: self.emit('_{} = {};'.format(field_name, field_name)) self.emit()
python
def _generate_struct_cstor(self, struct): """Emits struct standard constructor.""" with self.block_func( func=self._cstor_name_from_fields(struct.all_fields), args=fmt_func_args_from_fields(struct.all_fields), return_type='instancetype'): for field in struct.all_fields: self._generate_validator(field) self.emit() super_fields = [ f for f in struct.all_fields if f not in struct.fields ] if super_fields: super_args = fmt_func_args([(fmt_var(f.name), fmt_var(f.name)) for f in super_fields]) self.emit('self = [super {}:{}];'.format( self._cstor_name_from_fields(super_fields), super_args)) else: if struct.parent_type: self.emit('self = [super initDefault];') else: self.emit('self = [super init];') with self.block_init(): for field in struct.fields: field_name = fmt_var(field.name) if field.has_default: self.emit('_{} = {} ?: {};'.format( field_name, field_name, fmt_default_value(field))) else: self.emit('_{} = {};'.format(field_name, field_name)) self.emit()
[ "def", "_generate_struct_cstor", "(", "self", ",", "struct", ")", ":", "with", "self", ".", "block_func", "(", "func", "=", "self", ".", "_cstor_name_from_fields", "(", "struct", ".", "all_fields", ")", ",", "args", "=", "fmt_func_args_from_fields", "(", "struct", ".", "all_fields", ")", ",", "return_type", "=", "'instancetype'", ")", ":", "for", "field", "in", "struct", ".", "all_fields", ":", "self", ".", "_generate_validator", "(", "field", ")", "self", ".", "emit", "(", ")", "super_fields", "=", "[", "f", "for", "f", "in", "struct", ".", "all_fields", "if", "f", "not", "in", "struct", ".", "fields", "]", "if", "super_fields", ":", "super_args", "=", "fmt_func_args", "(", "[", "(", "fmt_var", "(", "f", ".", "name", ")", ",", "fmt_var", "(", "f", ".", "name", ")", ")", "for", "f", "in", "super_fields", "]", ")", "self", ".", "emit", "(", "'self = [super {}:{}];'", ".", "format", "(", "self", ".", "_cstor_name_from_fields", "(", "super_fields", ")", ",", "super_args", ")", ")", "else", ":", "if", "struct", ".", "parent_type", ":", "self", ".", "emit", "(", "'self = [super initDefault];'", ")", "else", ":", "self", ".", "emit", "(", "'self = [super init];'", ")", "with", "self", ".", "block_init", "(", ")", ":", "for", "field", "in", "struct", ".", "fields", ":", "field_name", "=", "fmt_var", "(", "field", ".", "name", ")", "if", "field", ".", "has_default", ":", "self", ".", "emit", "(", "'_{} = {} ?: {};'", ".", "format", "(", "field_name", ",", "field_name", ",", "fmt_default_value", "(", "field", ")", ")", ")", "else", ":", "self", ".", "emit", "(", "'_{} = {};'", ".", "format", "(", "field_name", ",", "field_name", ")", ")", "self", ".", "emit", "(", ")" ]
Emits struct standard constructor.
[ "Emits", "struct", "standard", "constructor", "." ]
train
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/obj_c_types.py#L461-L495
<|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: Emits struct standard constructor. ### Response: def _generate_struct_cstor(self, struct): """Emits struct standard constructor.""" with self.block_func( func=self._cstor_name_from_fields(struct.all_fields), args=fmt_func_args_from_fields(struct.all_fields), return_type='instancetype'): for field in struct.all_fields: self._generate_validator(field) self.emit() super_fields = [ f for f in struct.all_fields if f not in struct.fields ] if super_fields: super_args = fmt_func_args([(fmt_var(f.name), fmt_var(f.name)) for f in super_fields]) self.emit('self = [super {}:{}];'.format( self._cstor_name_from_fields(super_fields), super_args)) else: if struct.parent_type: self.emit('self = [super initDefault];') else: self.emit('self = [super init];') with self.block_init(): for field in struct.fields: field_name = fmt_var(field.name) if field.has_default: self.emit('_{} = {} ?: {};'.format( field_name, field_name, fmt_default_value(field))) else: self.emit('_{} = {};'.format(field_name, field_name)) self.emit() <|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, 2321, 1220, 2080, 5410, 4797, 382, 14711, 6075, 512, 755, 721, 19927, 15477, 669, 48465, 1214, 11, 2080, 997, 286, 4304, 2321, 1220, 2080, 5410, 4797, 14781, 286, 449, 659, 16072, 9791, 1021, 394, 2988, 7822, 1462, 66, 48465, 1292, 5791, 12406, 6294, 7825, 12406, 1350, 394, 2897, 28, 12784, 9791, 8550, 5791, 12406, 6294, 7825, 12406, 1350, 394, 471, 1857, 1151, 34784, 11290, 310, 369, 2115, 304, 2080, 7825, 12406, 512, 394, 659, 1462, 19927, 66059, 15944, 696, 310, 659, 17232, 2892, 310, 2307, 12406, 284, 2330, 394, 282, 369, 282, 304, 2080, 7825, 12406, 422, 282, 539, 304, 2080, 13216, 198, 310, 10661, 310, 422, 2307, 12406, 512, 394, 2307, 8550, 284, 9055, 9791, 8550, 59690, 12784, 4715, 968, 2710, 705, 9055, 4715, 968, 2710, 1192, 3425, 369, 282, 304, 2307, 12406, 2608, 394, 659, 17232, 493, 726, 284, 510, 9712, 4792, 80511, 5378, 4527, 2293, 1021, 504, 659, 1462, 66, 48465, 1292, 5791, 12406, 57140, 12406, 705, 2307, 8550, 1192, 310, 775, 512, 394, 422, 2080, 8829, 1857, 512, 504, 659, 17232, 493, 726, 284, 510, 9712, 3003, 3760, 5378, 1329, 394, 775, 512, 504, 659, 17232, 493, 726, 284, 510, 9712, 3003, 5378, 1329, 310, 449, 659, 16072, 6265, 4019, 394, 369, 2115, 304, 2080, 13216, 512, 504, 2115, 1292, 284, 9055, 4715, 15944, 2710, 696, 504, 422, 2115, 7001, 10198, 512, 667, 659, 17232, 16359, 6390, 284, 4792, 28356, 53266, 4527, 2293, 1021, 1014, 2115, 1292, 11, 2115, 1292, 11, 9055, 10198, 3220, 15944, 6054, 504, 775, 512, 667, 659, 17232, 16359, 6390, 284, 53266, 4527, 2293, 15944, 1292, 11, 2115, 1292, 1192, 286, 659, 17232, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 2321, 1220, 2080, 5410, 4797, 382, 14711, 6075, 512, 755, 721, 19927, 15477, 669, 48465, 1214, 11, 2080, 997, 286, 4304, 2321, 1220, 2080, 5410, 4797, 14781, 286, 449, 659, 16072, 9791, 1021, 394, 2988, 7822, 1462, 66, 48465, 1292, 5791, 12406, 6294, 7825, 12406, 1350, 394, 2897, 28, 12784, 9791, 8550, 5791, 12406, 6294, 7825, 12406, 1350, 394, 471, 1857, 1151, 34784, 11290, 310, 369, 2115, 304, 2080, 7825, 12406, 512, 394, 659, 1462, 19927, 66059, 15944, 696, 310, 659, 17232, 2892, 310, 2307, 12406, 284, 2330, 394, 282, 369, 282, 304, 2080, 7825, 12406, 422, 282, 539, 304, 2080, 13216, 198, 310, 10661, 310, 422, 2307, 12406, 512, 394, 2307, 8550, 284, 9055, 9791, 8550, 59690, 12784, 4715, 968, 2710, 705, 9055, 4715, 968, 2710, 1192, 3425, 369, 282, 304, 2307, 12406, 2608, 394, 659, 17232, 493, 726, 284, 510, 9712, 4792, 80511, 5378, 4527, 2293, 1021, 504, 659, 1462, 66, 48465, 1292, 5791, 12406, 57140, 12406, 705, 2307, 8550, 1192, 310, 775, 512, 394, 422, 2080, 8829, 1857, 512, 504, 659, 17232, 493, 726, 284, 510, 9712, 3003, 3760, 5378, 1329, 394, 775, 512, 504, 659, 17232, 493, 726, 284, 510, 9712, 3003, 5378, 1329, 310, 449, 659, 16072, 6265, 4019, 394, 369, 2115, 304, 2080, 13216, 512, 504, 2115, 1292, 284, 9055, 4715, 15944, 2710, 696, 504, 422, 2115, 7001, 10198, 512, 667, 659, 17232, 16359, 6390, 284, 4792, 28356, 53266, 4527, 2293, 1021, 1014, 2115, 1292, 11, 2115, 1292, 11, 9055, 10198, 3220, 15944, 6054, 504, 775, 512, 667, 659, 17232, 16359, 6390, 284, 53266, 4527, 2293, 15944, 1292, 11, 2115, 1292, 1192, 286, 659, 17232, 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 ]
tensorflow/tensor2tensor
tensor2tensor/data_generators/wikisum/wikisum.py
rank_reference_paragraphs
def rank_reference_paragraphs(wiki_title, references_content, normalize=True): """Rank and return reference paragraphs by tf-idf score on title tokens.""" normalized_title = _normalize_text(wiki_title) title_tokens = _tokens_to_score( set(tokenizer.encode(text_encoder.native_to_unicode(normalized_title)))) ref_paragraph_info = [] doc_counts = collections.defaultdict(int) for ref in references_content: for paragraph in ref.split("\n"): normalized_paragraph = _normalize_text(paragraph) if cc_utils.filter_paragraph(normalized_paragraph): # Skip paragraph continue counts = _token_counts(normalized_paragraph, title_tokens) for token in title_tokens: if counts[token]: doc_counts[token] += 1 content = normalized_paragraph if normalize else paragraph info = {"content": content, "counts": counts} ref_paragraph_info.append(info) for info in ref_paragraph_info: score = 0. for token in title_tokens: term_frequency = info["counts"][token] inv_doc_frequency = ( float(len(ref_paragraph_info)) / max(doc_counts[token], 1)) score += term_frequency * math.log(inv_doc_frequency) info["score"] = score ref_paragraph_info.sort(key=lambda el: el["score"], reverse=True) return [info["content"] for info in ref_paragraph_info]
python
def rank_reference_paragraphs(wiki_title, references_content, normalize=True): """Rank and return reference paragraphs by tf-idf score on title tokens.""" normalized_title = _normalize_text(wiki_title) title_tokens = _tokens_to_score( set(tokenizer.encode(text_encoder.native_to_unicode(normalized_title)))) ref_paragraph_info = [] doc_counts = collections.defaultdict(int) for ref in references_content: for paragraph in ref.split("\n"): normalized_paragraph = _normalize_text(paragraph) if cc_utils.filter_paragraph(normalized_paragraph): # Skip paragraph continue counts = _token_counts(normalized_paragraph, title_tokens) for token in title_tokens: if counts[token]: doc_counts[token] += 1 content = normalized_paragraph if normalize else paragraph info = {"content": content, "counts": counts} ref_paragraph_info.append(info) for info in ref_paragraph_info: score = 0. for token in title_tokens: term_frequency = info["counts"][token] inv_doc_frequency = ( float(len(ref_paragraph_info)) / max(doc_counts[token], 1)) score += term_frequency * math.log(inv_doc_frequency) info["score"] = score ref_paragraph_info.sort(key=lambda el: el["score"], reverse=True) return [info["content"] for info in ref_paragraph_info]
[ "def", "rank_reference_paragraphs", "(", "wiki_title", ",", "references_content", ",", "normalize", "=", "True", ")", ":", "normalized_title", "=", "_normalize_text", "(", "wiki_title", ")", "title_tokens", "=", "_tokens_to_score", "(", "set", "(", "tokenizer", ".", "encode", "(", "text_encoder", ".", "native_to_unicode", "(", "normalized_title", ")", ")", ")", ")", "ref_paragraph_info", "=", "[", "]", "doc_counts", "=", "collections", ".", "defaultdict", "(", "int", ")", "for", "ref", "in", "references_content", ":", "for", "paragraph", "in", "ref", ".", "split", "(", "\"\\n\"", ")", ":", "normalized_paragraph", "=", "_normalize_text", "(", "paragraph", ")", "if", "cc_utils", ".", "filter_paragraph", "(", "normalized_paragraph", ")", ":", "# Skip paragraph", "continue", "counts", "=", "_token_counts", "(", "normalized_paragraph", ",", "title_tokens", ")", "for", "token", "in", "title_tokens", ":", "if", "counts", "[", "token", "]", ":", "doc_counts", "[", "token", "]", "+=", "1", "content", "=", "normalized_paragraph", "if", "normalize", "else", "paragraph", "info", "=", "{", "\"content\"", ":", "content", ",", "\"counts\"", ":", "counts", "}", "ref_paragraph_info", ".", "append", "(", "info", ")", "for", "info", "in", "ref_paragraph_info", ":", "score", "=", "0.", "for", "token", "in", "title_tokens", ":", "term_frequency", "=", "info", "[", "\"counts\"", "]", "[", "token", "]", "inv_doc_frequency", "=", "(", "float", "(", "len", "(", "ref_paragraph_info", ")", ")", "/", "max", "(", "doc_counts", "[", "token", "]", ",", "1", ")", ")", "score", "+=", "term_frequency", "*", "math", ".", "log", "(", "inv_doc_frequency", ")", "info", "[", "\"score\"", "]", "=", "score", "ref_paragraph_info", ".", "sort", "(", "key", "=", "lambda", "el", ":", "el", "[", "\"score\"", "]", ",", "reverse", "=", "True", ")", "return", "[", "info", "[", "\"content\"", "]", "for", "info", "in", "ref_paragraph_info", "]" ]
Rank and return reference paragraphs by tf-idf score on title tokens.
[ "Rank", "and", "return", "reference", "paragraphs", "by", "tf", "-", "idf", "score", "on", "title", "tokens", "." ]
train
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/wikisum/wikisum.py#L348-L379
<|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: Rank and return reference paragraphs by tf-idf score on title tokens. ### Response: def rank_reference_paragraphs(wiki_title, references_content, normalize=True): """Rank and return reference paragraphs by tf-idf score on title tokens.""" normalized_title = _normalize_text(wiki_title) title_tokens = _tokens_to_score( set(tokenizer.encode(text_encoder.native_to_unicode(normalized_title)))) ref_paragraph_info = [] doc_counts = collections.defaultdict(int) for ref in references_content: for paragraph in ref.split("\n"): normalized_paragraph = _normalize_text(paragraph) if cc_utils.filter_paragraph(normalized_paragraph): # Skip paragraph continue counts = _token_counts(normalized_paragraph, title_tokens) for token in title_tokens: if counts[token]: doc_counts[token] += 1 content = normalized_paragraph if normalize else paragraph info = {"content": content, "counts": counts} ref_paragraph_info.append(info) for info in ref_paragraph_info: score = 0. for token in title_tokens: term_frequency = info["counts"][token] inv_doc_frequency = ( float(len(ref_paragraph_info)) / max(doc_counts[token], 1)) score += term_frequency * math.log(inv_doc_frequency) info["score"] = score ref_paragraph_info.sort(key=lambda el: el["score"], reverse=True) return [info["content"] for info in ref_paragraph_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, 23366, 323, 471, 5905, 43743, 555, 6543, 13193, 69, 5573, 389, 2316, 11460, 382, 14711, 6075, 512, 755, 7222, 26508, 97813, 82, 3706, 7723, 6240, 11, 15407, 7647, 11, 22436, 3702, 997, 220, 4304, 23366, 323, 471, 5905, 43743, 555, 6543, 13193, 69, 5573, 389, 2316, 11460, 14781, 220, 30510, 6240, 284, 721, 31690, 4424, 3706, 7723, 6240, 340, 220, 2316, 29938, 284, 721, 31666, 2401, 10622, 1021, 415, 743, 13577, 3213, 17762, 7383, 40168, 15054, 2401, 55762, 53180, 1534, 6240, 23631, 220, 2098, 97813, 3186, 284, 4260, 220, 4733, 27067, 284, 15661, 8939, 8644, 1577, 340, 220, 369, 2098, 304, 15407, 7647, 512, 262, 369, 14646, 304, 2098, 5402, 5026, 77, 15497, 415, 30510, 97813, 284, 721, 31690, 4424, 33075, 9398, 340, 415, 422, 12810, 17758, 7081, 97813, 53180, 1534, 97813, 997, 286, 674, 26869, 14646, 198, 286, 3136, 198, 415, 14921, 284, 721, 5963, 27067, 53180, 1534, 97813, 11, 2316, 29938, 340, 415, 369, 4037, 304, 2316, 29938, 512, 286, 422, 14921, 88346, 10556, 692, 4733, 27067, 88346, 60, 1447, 220, 16, 198, 415, 2262, 284, 30510, 97813, 422, 22436, 775, 14646, 198, 415, 3630, 284, 5324, 1834, 794, 2262, 11, 330, 45959, 794, 14921, 534, 415, 2098, 97813, 3186, 2102, 14542, 696, 220, 369, 3630, 304, 2098, 97813, 3186, 512, 262, 5573, 284, 220, 15, 627, 262, 369, 4037, 304, 2316, 29938, 512, 415, 4751, 41232, 284, 3630, 1204, 45959, 18613, 5963, 933, 415, 1558, 19401, 41232, 284, 2456, 692, 2273, 7046, 13624, 97813, 3186, 595, 611, 1973, 19702, 27067, 88346, 1145, 220, 16, 1192, 415, 5573, 1447, 4751, 41232, 353, 7033, 1699, 57069, 19401, 41232, 340, 262, 3630, 1204, 12618, 1365, 284, 5573, 271, 220, 2098, 97813, 3186, 10838, 4962, 28604, 658, 25, 658, 1204, 12618, 8073, 10134, 3702, 340, 220, 471, 510, 2801, 1204, 1834, 1365, 369, 3630, 304, 2098, 97813, 3186, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 23366, 323, 471, 5905, 43743, 555, 6543, 13193, 69, 5573, 389, 2316, 11460, 382, 14711, 6075, 512, 755, 7222, 26508, 97813, 82, 3706, 7723, 6240, 11, 15407, 7647, 11, 22436, 3702, 997, 220, 4304, 23366, 323, 471, 5905, 43743, 555, 6543, 13193, 69, 5573, 389, 2316, 11460, 14781, 220, 30510, 6240, 284, 721, 31690, 4424, 3706, 7723, 6240, 340, 220, 2316, 29938, 284, 721, 31666, 2401, 10622, 1021, 415, 743, 13577, 3213, 17762, 7383, 40168, 15054, 2401, 55762, 53180, 1534, 6240, 23631, 220, 2098, 97813, 3186, 284, 4260, 220, 4733, 27067, 284, 15661, 8939, 8644, 1577, 340, 220, 369, 2098, 304, 15407, 7647, 512, 262, 369, 14646, 304, 2098, 5402, 5026, 77, 15497, 415, 30510, 97813, 284, 721, 31690, 4424, 33075, 9398, 340, 415, 422, 12810, 17758, 7081, 97813, 53180, 1534, 97813, 997, 286, 674, 26869, 14646, 198, 286, 3136, 198, 415, 14921, 284, 721, 5963, 27067, 53180, 1534, 97813, 11, 2316, 29938, 340, 415, 369, 4037, 304, 2316, 29938, 512, 286, 422, 14921, 88346, 10556, 692, 4733, 27067, 88346, 60, 1447, 220, 16, 198, 415, 2262, 284, 30510, 97813, 422, 22436, 775, 14646, 198, 415, 3630, 284, 5324, 1834, 794, 2262, 11, 330, 45959, 794, 14921, 534, 415, 2098, 97813, 3186, 2102, 14542, 696, 220, 369, 3630, 304, 2098, 97813, 3186, 512, 262, 5573, 284, 220, 15, 627, 262, 369, 4037, 304, 2316, 29938, 512, 415, 4751, 41232, 284, 3630, 1204, 45959, 18613, 5963, 933, 415, 1558, 19401, 41232, 284, 2456, 692, 2273, 7046, 13624, 97813, 3186, 595, 611, 1973, 19702, 27067, 88346, 1145, 220, 16, 1192, 415, 5573, 1447, 4751, 41232, 353, 7033, 1699, 57069, 19401, 41232, 340, 262, 3630, 1204, 12618, 1365, 284, 5573, 271, 220, 2098, 97813, 3186, 10838, 4962, 28604, 658, 25, 658, 1204, 12618, 8073, 10134, 3702, 340, 220, 471, 510, 2801, 1204, 1834, 1365, 369, 3630, 304, 2098, 97813, 3186, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
trailofbits/protofuzz
protofuzz/gen.py
Permuter._resolve_child
def _resolve_child(self, path): 'Return a member generator by a dot-delimited path' obj = self for component in path.split('.'): ptr = obj if not isinstance(ptr, Permuter): raise self.MessageNotFound("Bad element path [wrong type]") # pylint: disable=protected-access found_gen = (_ for _ in ptr._generators if _.name() == component) obj = next(found_gen, None) if not obj: raise self.MessageNotFound("Path '{}' unresolved to member." .format(path)) return ptr, obj
python
def _resolve_child(self, path): 'Return a member generator by a dot-delimited path' obj = self for component in path.split('.'): ptr = obj if not isinstance(ptr, Permuter): raise self.MessageNotFound("Bad element path [wrong type]") # pylint: disable=protected-access found_gen = (_ for _ in ptr._generators if _.name() == component) obj = next(found_gen, None) if not obj: raise self.MessageNotFound("Path '{}' unresolved to member." .format(path)) return ptr, obj
[ "def", "_resolve_child", "(", "self", ",", "path", ")", ":", "obj", "=", "self", "for", "component", "in", "path", ".", "split", "(", "'.'", ")", ":", "ptr", "=", "obj", "if", "not", "isinstance", "(", "ptr", ",", "Permuter", ")", ":", "raise", "self", ".", "MessageNotFound", "(", "\"Bad element path [wrong type]\"", ")", "# pylint: disable=protected-access", "found_gen", "=", "(", "_", "for", "_", "in", "ptr", ".", "_generators", "if", "_", ".", "name", "(", ")", "==", "component", ")", "obj", "=", "next", "(", "found_gen", ",", "None", ")", "if", "not", "obj", ":", "raise", "self", ".", "MessageNotFound", "(", "\"Path '{}' unresolved to member.\"", ".", "format", "(", "path", ")", ")", "return", "ptr", ",", "obj" ]
Return a member generator by a dot-delimited path
[ "Return", "a", "member", "generator", "by", "a", "dot", "-", "delimited", "path" ]
train
https://github.com/trailofbits/protofuzz/blob/589492d34de9a0da6cc5554094e2588b893b2fd8/protofuzz/gen.py#L111-L128
<|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 member generator by a dot-delimited path ### Response: def _resolve_child(self, path): 'Return a member generator by a dot-delimited path' obj = self for component in path.split('.'): ptr = obj if not isinstance(ptr, Permuter): raise self.MessageNotFound("Bad element path [wrong type]") # pylint: disable=protected-access found_gen = (_ for _ in ptr._generators if _.name() == component) obj = next(found_gen, None) if not obj: raise self.MessageNotFound("Path '{}' unresolved to member." .format(path)) return ptr, 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, 5715, 264, 4562, 14143, 555, 264, 13046, 48226, 32611, 1853, 271, 14711, 6075, 512, 755, 721, 17775, 17716, 1214, 11, 1853, 997, 286, 364, 5715, 264, 4562, 14143, 555, 264, 13046, 48226, 32611, 1853, 1270, 286, 2909, 284, 659, 271, 286, 369, 3777, 304, 1853, 5402, 4389, 11290, 310, 10295, 284, 2909, 198, 310, 422, 539, 11656, 24807, 11, 3700, 7129, 261, 997, 394, 4933, 659, 8639, 10588, 446, 17519, 2449, 1853, 510, 35970, 955, 60, 5240, 310, 674, 51471, 25, 11404, 28, 5883, 43256, 198, 310, 1766, 16724, 284, 5570, 369, 721, 304, 10295, 1462, 7642, 3046, 422, 13496, 609, 368, 624, 3777, 696, 310, 2909, 284, 1828, 56798, 16724, 11, 2290, 696, 310, 422, 539, 2909, 512, 394, 4933, 659, 8639, 10588, 446, 1858, 70522, 81261, 311, 4562, 10246, 14600, 662, 2293, 5698, 1192, 286, 471, 10295, 11, 2909, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 4562, 14143, 555, 264, 13046, 48226, 32611, 1853, 271, 14711, 6075, 512, 755, 721, 17775, 17716, 1214, 11, 1853, 997, 286, 364, 5715, 264, 4562, 14143, 555, 264, 13046, 48226, 32611, 1853, 1270, 286, 2909, 284, 659, 271, 286, 369, 3777, 304, 1853, 5402, 4389, 11290, 310, 10295, 284, 2909, 198, 310, 422, 539, 11656, 24807, 11, 3700, 7129, 261, 997, 394, 4933, 659, 8639, 10588, 446, 17519, 2449, 1853, 510, 35970, 955, 60, 5240, 310, 674, 51471, 25, 11404, 28, 5883, 43256, 198, 310, 1766, 16724, 284, 5570, 369, 721, 304, 10295, 1462, 7642, 3046, 422, 13496, 609, 368, 624, 3777, 696, 310, 2909, 284, 1828, 56798, 16724, 11, 2290, 696, 310, 422, 539, 2909, 512, 394, 4933, 659, 8639, 10588, 446, 1858, 70522, 81261, 311, 4562, 10246, 14600, 662, 2293, 5698, 1192, 286, 471, 10295, 11, 2909, 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 ]
brocade/pynos
pynos/versions/base/bgp.py
BGP.enabled
def enabled(self): """bool: ``True`` if BGP is enabled; ``False`` if BGP is disabled. """ namespace = 'urn:ietf:params:xml:ns:netconf:base:1.0' bgp_filter = 'rbridge-id/router/bgp' bgp_config = ET.Element('get-config', xmlns="%s" % namespace) source = ET.SubElement(bgp_config, 'source') ET.SubElement(source, 'running') ET.SubElement(bgp_config, 'filter', type="xpath", select="%s" % bgp_filter) bgp_config = self._callback(bgp_config, handler='get') namespace = 'urn:brocade.com:mgmt:brocade-bgp' enabled = bgp_config.find('.//*{%s}bgp' % namespace) if enabled is not None: return True return False
python
def enabled(self): """bool: ``True`` if BGP is enabled; ``False`` if BGP is disabled. """ namespace = 'urn:ietf:params:xml:ns:netconf:base:1.0' bgp_filter = 'rbridge-id/router/bgp' bgp_config = ET.Element('get-config', xmlns="%s" % namespace) source = ET.SubElement(bgp_config, 'source') ET.SubElement(source, 'running') ET.SubElement(bgp_config, 'filter', type="xpath", select="%s" % bgp_filter) bgp_config = self._callback(bgp_config, handler='get') namespace = 'urn:brocade.com:mgmt:brocade-bgp' enabled = bgp_config.find('.//*{%s}bgp' % namespace) if enabled is not None: return True return False
[ "def", "enabled", "(", "self", ")", ":", "namespace", "=", "'urn:ietf:params:xml:ns:netconf:base:1.0'", "bgp_filter", "=", "'rbridge-id/router/bgp'", "bgp_config", "=", "ET", ".", "Element", "(", "'get-config'", ",", "xmlns", "=", "\"%s\"", "%", "namespace", ")", "source", "=", "ET", ".", "SubElement", "(", "bgp_config", ",", "'source'", ")", "ET", ".", "SubElement", "(", "source", ",", "'running'", ")", "ET", ".", "SubElement", "(", "bgp_config", ",", "'filter'", ",", "type", "=", "\"xpath\"", ",", "select", "=", "\"%s\"", "%", "bgp_filter", ")", "bgp_config", "=", "self", ".", "_callback", "(", "bgp_config", ",", "handler", "=", "'get'", ")", "namespace", "=", "'urn:brocade.com:mgmt:brocade-bgp'", "enabled", "=", "bgp_config", ".", "find", "(", "'.//*{%s}bgp'", "%", "namespace", ")", "if", "enabled", "is", "not", "None", ":", "return", "True", "return", "False" ]
bool: ``True`` if BGP is enabled; ``False`` if BGP is disabled.
[ "bool", ":", "True", "if", "BGP", "is", "enabled", ";", "False", "if", "BGP", "is", "disabled", "." ]
train
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/bgp.py#L48-L63
<|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: bool: ``True`` if BGP is enabled; ``False`` if BGP is disabled. ### Response: def enabled(self): """bool: ``True`` if BGP is enabled; ``False`` if BGP is disabled. """ namespace = 'urn:ietf:params:xml:ns:netconf:base:1.0' bgp_filter = 'rbridge-id/router/bgp' bgp_config = ET.Element('get-config', xmlns="%s" % namespace) source = ET.SubElement(bgp_config, 'source') ET.SubElement(source, 'running') ET.SubElement(bgp_config, 'filter', type="xpath", select="%s" % bgp_filter) bgp_config = self._callback(bgp_config, handler='get') namespace = 'urn:brocade.com:mgmt:brocade-bgp' enabled = bgp_config.find('.//*{%s}bgp' % namespace) if enabled is not None: 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, 2707, 25, 10103, 2575, 14196, 422, 426, 25434, 374, 9147, 26, 10103, 4139, 14196, 422, 426, 25434, 374, 8552, 382, 14711, 6075, 512, 755, 9147, 1214, 997, 286, 4304, 2707, 25, 10103, 2575, 14196, 422, 426, 25434, 374, 9147, 26, 10103, 4139, 14196, 422, 426, 25434, 374, 8552, 627, 286, 3270, 286, 4573, 284, 364, 399, 25, 75168, 96111, 25, 6591, 25, 4511, 25, 4816, 6263, 25, 3231, 25, 16, 13, 15, 1270, 286, 9128, 79, 8901, 284, 364, 81, 14024, 13193, 19055, 3554, 22650, 1270, 286, 9128, 79, 5445, 284, 18241, 20743, 493, 456, 26187, 518, 26015, 36320, 82, 1, 1034, 4573, 340, 286, 2592, 284, 18241, 93442, 1921, 22650, 5445, 11, 364, 2484, 1329, 286, 18241, 93442, 12719, 11, 364, 28272, 1329, 286, 18241, 93442, 1921, 22650, 5445, 11, 364, 5428, 756, 2611, 955, 429, 51251, 498, 3373, 36320, 82, 1, 1034, 9128, 79, 8901, 340, 286, 9128, 79, 5445, 284, 659, 1462, 13802, 1921, 22650, 5445, 11, 7158, 1151, 456, 1329, 286, 4573, 284, 364, 399, 25, 15222, 33896, 916, 25, 12591, 2562, 25, 15222, 33896, 1481, 22650, 1270, 286, 9147, 284, 9128, 79, 5445, 2725, 4389, 22132, 67465, 82, 92, 12498, 79, 6, 1034, 4573, 340, 286, 422, 9147, 374, 539, 2290, 512, 310, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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, 2707, 25, 10103, 2575, 14196, 422, 426, 25434, 374, 9147, 26, 10103, 4139, 14196, 422, 426, 25434, 374, 8552, 382, 14711, 6075, 512, 755, 9147, 1214, 997, 286, 4304, 2707, 25, 10103, 2575, 14196, 422, 426, 25434, 374, 9147, 26, 10103, 4139, 14196, 422, 426, 25434, 374, 8552, 627, 286, 3270, 286, 4573, 284, 364, 399, 25, 75168, 96111, 25, 6591, 25, 4511, 25, 4816, 6263, 25, 3231, 25, 16, 13, 15, 1270, 286, 9128, 79, 8901, 284, 364, 81, 14024, 13193, 19055, 3554, 22650, 1270, 286, 9128, 79, 5445, 284, 18241, 20743, 493, 456, 26187, 518, 26015, 36320, 82, 1, 1034, 4573, 340, 286, 2592, 284, 18241, 93442, 1921, 22650, 5445, 11, 364, 2484, 1329, 286, 18241, 93442, 12719, 11, 364, 28272, 1329, 286, 18241, 93442, 1921, 22650, 5445, 11, 364, 5428, 756, 2611, 955, 429, 51251, 498, 3373, 36320, 82, 1, 1034, 9128, 79, 8901, 340, 286, 9128, 79, 5445, 284, 659, 1462, 13802, 1921, 22650, 5445, 11, 7158, 1151, 456, 1329, 286, 4573, 284, 364, 399, 25, 15222, 33896, 916, 25, 12591, 2562, 25, 15222, 33896, 1481, 22650, 1270, 286, 9147, 284, 9128, 79, 5445, 2725, 4389, 22132, 67465, 82, 92, 12498, 79, 6, 1034, 4573, 340, 286, 422, 9147, 374, 539, 2290, 512, 310, 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 ]
dswah/pyGAM
pygam/pygam.py
LogisticGAM.accuracy
def accuracy(self, X=None, y=None, mu=None): """ computes the accuracy of the LogisticGAM Parameters ---------- note: X or mu must be defined. defaults to mu X : array-like of shape (n_samples, m_features), optional (default=None) containing input data y : array-like of shape (n,) containing target data mu : array-like of shape (n_samples,), optional (default=None expected value of the targets given the model and inputs Returns ------- float in [0, 1] """ if not self._is_fitted: raise AttributeError('GAM has not been fitted. Call fit first.') y = check_y(y, self.link, self.distribution, verbose=self.verbose) if X is not None: X = check_X(X, n_feats=self.statistics_['m_features'], edge_knots=self.edge_knots_, dtypes=self.dtype, features=self.feature, verbose=self.verbose) if mu is None: mu = self.predict_mu(X) check_X_y(mu, y) return ((mu > 0.5).astype(int) == y).mean()
python
def accuracy(self, X=None, y=None, mu=None): """ computes the accuracy of the LogisticGAM Parameters ---------- note: X or mu must be defined. defaults to mu X : array-like of shape (n_samples, m_features), optional (default=None) containing input data y : array-like of shape (n,) containing target data mu : array-like of shape (n_samples,), optional (default=None expected value of the targets given the model and inputs Returns ------- float in [0, 1] """ if not self._is_fitted: raise AttributeError('GAM has not been fitted. Call fit first.') y = check_y(y, self.link, self.distribution, verbose=self.verbose) if X is not None: X = check_X(X, n_feats=self.statistics_['m_features'], edge_knots=self.edge_knots_, dtypes=self.dtype, features=self.feature, verbose=self.verbose) if mu is None: mu = self.predict_mu(X) check_X_y(mu, y) return ((mu > 0.5).astype(int) == y).mean()
[ "def", "accuracy", "(", "self", ",", "X", "=", "None", ",", "y", "=", "None", ",", "mu", "=", "None", ")", ":", "if", "not", "self", ".", "_is_fitted", ":", "raise", "AttributeError", "(", "'GAM has not been fitted. Call fit first.'", ")", "y", "=", "check_y", "(", "y", ",", "self", ".", "link", ",", "self", ".", "distribution", ",", "verbose", "=", "self", ".", "verbose", ")", "if", "X", "is", "not", "None", ":", "X", "=", "check_X", "(", "X", ",", "n_feats", "=", "self", ".", "statistics_", "[", "'m_features'", "]", ",", "edge_knots", "=", "self", ".", "edge_knots_", ",", "dtypes", "=", "self", ".", "dtype", ",", "features", "=", "self", ".", "feature", ",", "verbose", "=", "self", ".", "verbose", ")", "if", "mu", "is", "None", ":", "mu", "=", "self", ".", "predict_mu", "(", "X", ")", "check_X_y", "(", "mu", ",", "y", ")", "return", "(", "(", "mu", ">", "0.5", ")", ".", "astype", "(", "int", ")", "==", "y", ")", ".", "mean", "(", ")" ]
computes the accuracy of the LogisticGAM Parameters ---------- note: X or mu must be defined. defaults to mu X : array-like of shape (n_samples, m_features), optional (default=None) containing input data y : array-like of shape (n,) containing target data mu : array-like of shape (n_samples,), optional (default=None expected value of the targets given the model and inputs Returns ------- float in [0, 1]
[ "computes", "the", "accuracy", "of", "the", "LogisticGAM" ]
train
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/pygam.py#L2395-L2426
<|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 accuracy of the LogisticGAM Parameters ---------- note: X or mu must be defined. defaults to mu X : array-like of shape (n_samples, m_features), optional (default=None) containing input data y : array-like of shape (n,) containing target data mu : array-like of shape (n_samples,), optional (default=None expected value of the targets given the model and inputs Returns ------- float in [0, 1] ### Response: def accuracy(self, X=None, y=None, mu=None): """ computes the accuracy of the LogisticGAM Parameters ---------- note: X or mu must be defined. defaults to mu X : array-like of shape (n_samples, m_features), optional (default=None) containing input data y : array-like of shape (n,) containing target data mu : array-like of shape (n_samples,), optional (default=None expected value of the targets given the model and inputs Returns ------- float in [0, 1] """ if not self._is_fitted: raise AttributeError('GAM has not been fitted. Call fit first.') y = check_y(y, self.link, self.distribution, verbose=self.verbose) if X is not None: X = check_X(X, n_feats=self.statistics_['m_features'], edge_knots=self.edge_knots_, dtypes=self.dtype, features=self.feature, verbose=self.verbose) if mu is None: mu = self.predict_mu(X) check_X_y(mu, y) return ((mu > 0.5).astype(int) == y).mean() <|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, 66047, 288, 279, 13708, 315, 279, 79168, 38, 1428, 271, 286, 13831, 198, 286, 31423, 286, 5296, 25, 1630, 477, 12097, 2011, 387, 4613, 13, 17088, 311, 12097, 271, 286, 1630, 551, 1358, 12970, 315, 6211, 320, 77, 18801, 11, 296, 15314, 705, 10309, 320, 2309, 5980, 340, 310, 8649, 1988, 828, 198, 286, 379, 551, 1358, 12970, 315, 6211, 320, 77, 55245, 310, 8649, 2218, 828, 198, 286, 12097, 551, 1358, 12970, 315, 6211, 320, 77, 18801, 60664, 10309, 320, 2309, 5980, 198, 310, 3685, 907, 315, 279, 11811, 2728, 279, 1646, 323, 11374, 271, 286, 5295, 198, 286, 39707, 286, 2273, 304, 510, 15, 11, 220, 16, 2595, 14711, 6075, 512, 755, 13708, 1214, 11, 1630, 5980, 11, 379, 5980, 11, 12097, 5980, 997, 286, 3270, 286, 58303, 279, 13708, 315, 279, 79168, 38, 1428, 271, 286, 13831, 198, 286, 31423, 286, 5296, 25, 1630, 477, 12097, 2011, 387, 4613, 13, 17088, 311, 12097, 271, 286, 1630, 551, 1358, 12970, 315, 6211, 320, 77, 18801, 11, 296, 15314, 705, 10309, 320, 2309, 5980, 340, 310, 8649, 1988, 828, 198, 286, 379, 551, 1358, 12970, 315, 6211, 320, 77, 55245, 310, 8649, 2218, 828, 198, 286, 12097, 551, 1358, 12970, 315, 6211, 320, 77, 18801, 60664, 10309, 320, 2309, 5980, 198, 310, 3685, 907, 315, 279, 11811, 2728, 279, 1646, 323, 11374, 271, 286, 5295, 198, 286, 39707, 286, 2273, 304, 510, 15, 11, 220, 16, 933, 286, 3270, 286, 422, 539, 659, 1462, 285, 766, 3847, 512, 310, 4933, 54731, 493, 38, 1428, 706, 539, 1027, 29441, 13, 7290, 5052, 1176, 49420, 286, 379, 284, 1817, 4271, 7166, 11, 659, 18567, 11, 659, 962, 13408, 11, 14008, 7822, 45749, 340, 286, 422, 1630, 374, 539, 2290, 512, 310, 1630, 284, 1817, 7002, 7799, 11, 308, 71746, 7822, 92784, 62, 681, 76, 15314, 4479, 667, 6964, 4803, 1962, 82, 7822, 55366, 4803, 1962, 82, 7022, 7748, 1842, 7822, 46855, 345, 667, 4519, 7822, 30691, 11, 14008, 7822, 45749, 696, 286, 422, 12097, 374, 2290, 512, 310, 12097, 284, 659, 24706, 44621, 7799, 340, 286, 1817, 7002, 4271, 66231, 11, 379, 340, 286, 471, 1819, 15479, 871, 220, 15, 13, 20, 570, 22502, 1577, 8, 624, 379, 570, 14622, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 66047, 288, 279, 13708, 315, 279, 79168, 38, 1428, 271, 286, 13831, 198, 286, 31423, 286, 5296, 25, 1630, 477, 12097, 2011, 387, 4613, 13, 17088, 311, 12097, 271, 286, 1630, 551, 1358, 12970, 315, 6211, 320, 77, 18801, 11, 296, 15314, 705, 10309, 320, 2309, 5980, 340, 310, 8649, 1988, 828, 198, 286, 379, 551, 1358, 12970, 315, 6211, 320, 77, 55245, 310, 8649, 2218, 828, 198, 286, 12097, 551, 1358, 12970, 315, 6211, 320, 77, 18801, 60664, 10309, 320, 2309, 5980, 198, 310, 3685, 907, 315, 279, 11811, 2728, 279, 1646, 323, 11374, 271, 286, 5295, 198, 286, 39707, 286, 2273, 304, 510, 15, 11, 220, 16, 2595, 14711, 6075, 512, 755, 13708, 1214, 11, 1630, 5980, 11, 379, 5980, 11, 12097, 5980, 997, 286, 3270, 286, 58303, 279, 13708, 315, 279, 79168, 38, 1428, 271, 286, 13831, 198, 286, 31423, 286, 5296, 25, 1630, 477, 12097, 2011, 387, 4613, 13, 17088, 311, 12097, 271, 286, 1630, 551, 1358, 12970, 315, 6211, 320, 77, 18801, 11, 296, 15314, 705, 10309, 320, 2309, 5980, 340, 310, 8649, 1988, 828, 198, 286, 379, 551, 1358, 12970, 315, 6211, 320, 77, 55245, 310, 8649, 2218, 828, 198, 286, 12097, 551, 1358, 12970, 315, 6211, 320, 77, 18801, 60664, 10309, 320, 2309, 5980, 198, 310, 3685, 907, 315, 279, 11811, 2728, 279, 1646, 323, 11374, 271, 286, 5295, 198, 286, 39707, 286, 2273, 304, 510, 15, 11, 220, 16, 933, 286, 3270, 286, 422, 539, 659, 1462, 285, 766, 3847, 512, 310, 4933, 54731, 493, 38, 1428, 706, 539, 1027, 29441, 13, 7290, 5052, 1176, 49420, 286, 379, 284, 1817, 4271, 7166, 11, 659, 18567, 11, 659, 962, 13408, 11, 14008, 7822, 45749, 340, 286, 422, 1630, 374, 539, 2290, 512, 310, 1630, 284, 1817, 7002, 7799, 11, 308, 71746, 7822, 92784, 62, 681, 76, 15314, 4479, 667, 6964, 4803, 1962, 82, 7822, 55366, 4803, 1962, 82, 7022, 7748, 1842, 7822, 46855, 345, 667, 4519, 7822, 30691, 11, 14008, 7822, 45749, 696, 286, 422, 12097, 374, 2290, 512, 310, 12097, 284, 659, 24706, 44621, 7799, 340, 286, 1817, 7002, 4271, 66231, 11, 379, 340, 286, 471, 1819, 15479, 871, 220, 15, 13, 20, 570, 22502, 1577, 8, 624, 379, 570, 14622, 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 ]
batiste/django-page-cms
pages/placeholders.py
MarkdownPlaceholderNode.render
def render(self, context): """Render markdown.""" import markdown content = self.get_content_from_context(context) return markdown.markdown(content)
python
def render(self, context): """Render markdown.""" import markdown content = self.get_content_from_context(context) return markdown.markdown(content)
[ "def", "render", "(", "self", ",", "context", ")", ":", "import", "markdown", "content", "=", "self", ".", "get_content_from_context", "(", "context", ")", "return", "markdown", ".", "markdown", "(", "content", ")" ]
Render markdown.
[ "Render", "markdown", "." ]
train
https://github.com/batiste/django-page-cms/blob/3c72111eb7c3997a63c462c1776ffd8ce8c50a5d/pages/placeholders.py#L472-L476
<|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: Render markdown. ### Response: def render(self, context): """Render markdown.""" import markdown content = self.get_content_from_context(context) return markdown.markdown(content) <|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, 6893, 51594, 382, 14711, 6075, 512, 755, 3219, 1214, 11, 2317, 997, 286, 4304, 6893, 51594, 14781, 286, 1179, 51594, 198, 286, 2262, 284, 659, 673, 7647, 5791, 8634, 5491, 340, 286, 471, 51594, 18913, 2996, 15413, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 6893, 51594, 382, 14711, 6075, 512, 755, 3219, 1214, 11, 2317, 997, 286, 4304, 6893, 51594, 14781, 286, 1179, 51594, 198, 286, 2262, 284, 659, 673, 7647, 5791, 8634, 5491, 340, 286, 471, 51594, 18913, 2996, 15413, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
tanghaibao/goatools
goatools/grouper/aart_geneproducts_one.py
AArtGeneProductSetsOne.prt_report_grp1
def prt_report_grp1(self, prt=sys.stdout, **kws_grp): """Print full GO/gene report with grouping.""" summaryline = self.str_summaryline() # Print grouped GO IDs prt.write("{SUMMARY}\n".format(SUMMARY=summaryline)) self.prt_gos_grouped(prt, **kws_grp) # genes genes = sorted(self.gene2gos.keys()) prt.write("\n\n{SUMMARY}\n\n".format(SUMMARY=summaryline)) self.prt_section_key(prt) self.prt_gene_aart(genes, prt) # Sort genes prt.write("\n\n{SUMMARY}\n\n".format(SUMMARY=summaryline)) self.prt_gene_aart_details(genes, prt) return (self.name, self.get_section_marks())
python
def prt_report_grp1(self, prt=sys.stdout, **kws_grp): """Print full GO/gene report with grouping.""" summaryline = self.str_summaryline() # Print grouped GO IDs prt.write("{SUMMARY}\n".format(SUMMARY=summaryline)) self.prt_gos_grouped(prt, **kws_grp) # genes genes = sorted(self.gene2gos.keys()) prt.write("\n\n{SUMMARY}\n\n".format(SUMMARY=summaryline)) self.prt_section_key(prt) self.prt_gene_aart(genes, prt) # Sort genes prt.write("\n\n{SUMMARY}\n\n".format(SUMMARY=summaryline)) self.prt_gene_aart_details(genes, prt) return (self.name, self.get_section_marks())
[ "def", "prt_report_grp1", "(", "self", ",", "prt", "=", "sys", ".", "stdout", ",", "*", "*", "kws_grp", ")", ":", "summaryline", "=", "self", ".", "str_summaryline", "(", ")", "# Print grouped GO IDs", "prt", ".", "write", "(", "\"{SUMMARY}\\n\"", ".", "format", "(", "SUMMARY", "=", "summaryline", ")", ")", "self", ".", "prt_gos_grouped", "(", "prt", ",", "*", "*", "kws_grp", ")", "# genes", "genes", "=", "sorted", "(", "self", ".", "gene2gos", ".", "keys", "(", ")", ")", "prt", ".", "write", "(", "\"\\n\\n{SUMMARY}\\n\\n\"", ".", "format", "(", "SUMMARY", "=", "summaryline", ")", ")", "self", ".", "prt_section_key", "(", "prt", ")", "self", ".", "prt_gene_aart", "(", "genes", ",", "prt", ")", "# Sort genes", "prt", ".", "write", "(", "\"\\n\\n{SUMMARY}\\n\\n\"", ".", "format", "(", "SUMMARY", "=", "summaryline", ")", ")", "self", ".", "prt_gene_aart_details", "(", "genes", ",", "prt", ")", "return", "(", "self", ".", "name", ",", "self", ".", "get_section_marks", "(", ")", ")" ]
Print full GO/gene report with grouping.
[ "Print", "full", "GO", "/", "gene", "report", "with", "grouping", "." ]
train
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L52-L66
<|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 full GO/gene report with grouping. ### Response: def prt_report_grp1(self, prt=sys.stdout, **kws_grp): """Print full GO/gene report with grouping.""" summaryline = self.str_summaryline() # Print grouped GO IDs prt.write("{SUMMARY}\n".format(SUMMARY=summaryline)) self.prt_gos_grouped(prt, **kws_grp) # genes genes = sorted(self.gene2gos.keys()) prt.write("\n\n{SUMMARY}\n\n".format(SUMMARY=summaryline)) self.prt_section_key(prt) self.prt_gene_aart(genes, prt) # Sort genes prt.write("\n\n{SUMMARY}\n\n".format(SUMMARY=summaryline)) self.prt_gene_aart_details(genes, prt) return (self.name, self.get_section_marks()) <|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, 2539, 12890, 4951, 1994, 1934, 449, 50284, 382, 14711, 6075, 512, 755, 96784, 15157, 60548, 16, 1214, 11, 96784, 59970, 25880, 11, 3146, 74, 9092, 60548, 997, 286, 4304, 9171, 2539, 12890, 4951, 1994, 1934, 449, 50284, 14781, 286, 12399, 1074, 284, 659, 9720, 28350, 1074, 746, 286, 674, 8377, 41141, 12890, 29460, 198, 286, 96784, 3921, 14303, 28477, 49970, 11281, 77, 3343, 2293, 3844, 2864, 49970, 28, 1743, 1074, 1192, 286, 659, 558, 3423, 1928, 437, 6422, 291, 26022, 83, 11, 3146, 74, 9092, 60548, 340, 286, 674, 21389, 198, 286, 21389, 284, 10839, 1214, 1326, 1994, 17, 35173, 9301, 2455, 286, 96784, 3921, 5026, 77, 1734, 90, 28477, 49970, 11281, 77, 1734, 3343, 2293, 3844, 2864, 49970, 28, 1743, 1074, 1192, 286, 659, 558, 3423, 16619, 3173, 26022, 83, 340, 286, 659, 558, 3423, 60702, 4404, 472, 3348, 22383, 11, 96784, 340, 286, 674, 16347, 21389, 198, 286, 96784, 3921, 5026, 77, 1734, 90, 28477, 49970, 11281, 77, 1734, 3343, 2293, 3844, 2864, 49970, 28, 1743, 1074, 1192, 286, 659, 558, 3423, 60702, 4404, 472, 13563, 3348, 22383, 11, 96784, 340, 286, 471, 320, 726, 2710, 11, 659, 673, 16619, 75304, 2455, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 9171, 2539, 12890, 4951, 1994, 1934, 449, 50284, 382, 14711, 6075, 512, 755, 96784, 15157, 60548, 16, 1214, 11, 96784, 59970, 25880, 11, 3146, 74, 9092, 60548, 997, 286, 4304, 9171, 2539, 12890, 4951, 1994, 1934, 449, 50284, 14781, 286, 12399, 1074, 284, 659, 9720, 28350, 1074, 746, 286, 674, 8377, 41141, 12890, 29460, 198, 286, 96784, 3921, 14303, 28477, 49970, 11281, 77, 3343, 2293, 3844, 2864, 49970, 28, 1743, 1074, 1192, 286, 659, 558, 3423, 1928, 437, 6422, 291, 26022, 83, 11, 3146, 74, 9092, 60548, 340, 286, 674, 21389, 198, 286, 21389, 284, 10839, 1214, 1326, 1994, 17, 35173, 9301, 2455, 286, 96784, 3921, 5026, 77, 1734, 90, 28477, 49970, 11281, 77, 1734, 3343, 2293, 3844, 2864, 49970, 28, 1743, 1074, 1192, 286, 659, 558, 3423, 16619, 3173, 26022, 83, 340, 286, 659, 558, 3423, 60702, 4404, 472, 3348, 22383, 11, 96784, 340, 286, 674, 16347, 21389, 198, 286, 96784, 3921, 5026, 77, 1734, 90, 28477, 49970, 11281, 77, 1734, 3343, 2293, 3844, 2864, 49970, 28, 1743, 1074, 1192, 286, 659, 558, 3423, 60702, 4404, 472, 13563, 3348, 22383, 11, 96784, 340, 286, 471, 320, 726, 2710, 11, 659, 673, 16619, 75304, 2455, 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 ]
xtrementl/focus
focus/task.py
Task.exists
def exists(self, task_name): """ Determines if task directory exists. `task_name` Task name. Returns ``True`` if task exists. """ try: return os.path.exists(self._get_task_dir(task_name)) except OSError: return False
python
def exists(self, task_name): """ Determines if task directory exists. `task_name` Task name. Returns ``True`` if task exists. """ try: return os.path.exists(self._get_task_dir(task_name)) except OSError: return False
[ "def", "exists", "(", "self", ",", "task_name", ")", ":", "try", ":", "return", "os", ".", "path", ".", "exists", "(", "self", ".", "_get_task_dir", "(", "task_name", ")", ")", "except", "OSError", ":", "return", "False" ]
Determines if task directory exists. `task_name` Task name. Returns ``True`` if task exists.
[ "Determines", "if", "task", "directory", "exists", "." ]
train
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L179-L192
<|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 task directory exists. `task_name` Task name. Returns ``True`` if task exists. ### Response: def exists(self, task_name): """ Determines if task directory exists. `task_name` Task name. Returns ``True`` if task exists. """ try: return os.path.exists(self._get_task_dir(task_name)) except OSError: 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, 93748, 288, 422, 3465, 6352, 6866, 382, 310, 1595, 8366, 1292, 4077, 394, 5546, 836, 382, 310, 5295, 10103, 2575, 14196, 422, 3465, 6866, 382, 14711, 6075, 512, 755, 6866, 1214, 11, 3465, 1292, 997, 286, 4304, 53812, 422, 3465, 6352, 6866, 382, 310, 1595, 8366, 1292, 4077, 394, 5546, 836, 382, 310, 5295, 10103, 2575, 14196, 422, 3465, 6866, 627, 310, 12713, 286, 1456, 512, 310, 471, 2709, 3960, 12347, 1214, 1462, 456, 12461, 4432, 17941, 1292, 4489, 286, 3734, 75342, 512, 310, 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, 128009, 128009, 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,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, 6498, 382, 14711, 5546, 512, 93748, 288, 422, 3465, 6352, 6866, 382, 310, 1595, 8366, 1292, 4077, 394, 5546, 836, 382, 310, 5295, 10103, 2575, 14196, 422, 3465, 6866, 382, 14711, 6075, 512, 755, 6866, 1214, 11, 3465, 1292, 997, 286, 4304, 53812, 422, 3465, 6352, 6866, 382, 310, 1595, 8366, 1292, 4077, 394, 5546, 836, 382, 310, 5295, 10103, 2575, 14196, 422, 3465, 6866, 627, 310, 12713, 286, 1456, 512, 310, 471, 2709, 3960, 12347, 1214, 1462, 456, 12461, 4432, 17941, 1292, 4489, 286, 3734, 75342, 512, 310, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
nornir-automation/nornir
nornir/core/inventory.py
Host.get_connection_state
def get_connection_state(self, connection: str) -> Dict[str, Any]: """ For an already established connection return its state. """ if connection not in self.connections: raise ConnectionNotOpen(connection) return self.connections[connection].state
python
def get_connection_state(self, connection: str) -> Dict[str, Any]: """ For an already established connection return its state. """ if connection not in self.connections: raise ConnectionNotOpen(connection) return self.connections[connection].state
[ "def", "get_connection_state", "(", "self", ",", "connection", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "connection", "not", "in", "self", ".", "connections", ":", "raise", "ConnectionNotOpen", "(", "connection", ")", "return", "self", ".", "connections", "[", "connection", "]", ".", "state" ]
For an already established connection return its state.
[ "For", "an", "already", "established", "connection", "return", "its", "state", "." ]
train
https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L306-L313
<|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: For an already established connection return its state. ### Response: def get_connection_state(self, connection: str) -> Dict[str, Any]: """ For an already established connection return its state. """ if connection not in self.connections: raise ConnectionNotOpen(connection) return self.connections[connection].state <|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, 2520, 459, 2736, 9749, 3717, 471, 1202, 1614, 382, 14711, 6075, 512, 755, 636, 16245, 4486, 1214, 11, 3717, 25, 610, 8, 1492, 30226, 17752, 11, 5884, 10556, 286, 3270, 286, 1789, 459, 2736, 9749, 3717, 471, 1202, 1614, 627, 286, 3270, 286, 422, 3717, 539, 304, 659, 80075, 512, 310, 4933, 11278, 2688, 5109, 25119, 696, 286, 471, 659, 80075, 58, 7898, 948, 2513, 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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193, 304, 6498, 382, 14711, 5546, 512, 2520, 459, 2736, 9749, 3717, 471, 1202, 1614, 382, 14711, 6075, 512, 755, 636, 16245, 4486, 1214, 11, 3717, 25, 610, 8, 1492, 30226, 17752, 11, 5884, 10556, 286, 3270, 286, 1789, 459, 2736, 9749, 3717, 471, 1202, 1614, 627, 286, 3270, 286, 422, 3717, 539, 304, 659, 80075, 512, 310, 4933, 11278, 2688, 5109, 25119, 696, 286, 471, 659, 80075, 58, 7898, 948, 2513, 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 ]
welbornprod/colr
colr/__main__.py
list_known_codes
def list_known_codes(s, unique=True, rgb_mode=False): """ Find and print all known escape codes in a string, using get_known_codes. """ total = 0 for codedesc in get_known_codes(s, unique=unique, rgb_mode=rgb_mode): total += 1 print(codedesc) plural = 'code' if total == 1 else 'codes' codetype = ' unique' if unique else '' print('\nFound {}{} escape {}.'.format(total, codetype, plural)) return 0 if total > 0 else 1
python
def list_known_codes(s, unique=True, rgb_mode=False): """ Find and print all known escape codes in a string, using get_known_codes. """ total = 0 for codedesc in get_known_codes(s, unique=unique, rgb_mode=rgb_mode): total += 1 print(codedesc) plural = 'code' if total == 1 else 'codes' codetype = ' unique' if unique else '' print('\nFound {}{} escape {}.'.format(total, codetype, plural)) return 0 if total > 0 else 1
[ "def", "list_known_codes", "(", "s", ",", "unique", "=", "True", ",", "rgb_mode", "=", "False", ")", ":", "total", "=", "0", "for", "codedesc", "in", "get_known_codes", "(", "s", ",", "unique", "=", "unique", ",", "rgb_mode", "=", "rgb_mode", ")", ":", "total", "+=", "1", "print", "(", "codedesc", ")", "plural", "=", "'code'", "if", "total", "==", "1", "else", "'codes'", "codetype", "=", "' unique'", "if", "unique", "else", "''", "print", "(", "'\\nFound {}{} escape {}.'", ".", "format", "(", "total", ",", "codetype", ",", "plural", ")", ")", "return", "0", "if", "total", ">", "0", "else", "1" ]
Find and print all known escape codes in a string, using get_known_codes.
[ "Find", "and", "print", "all", "known", "escape", "codes", "in", "a", "string", "using", "get_known_codes", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/__main__.py#L333-L344
<|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: Find and print all known escape codes in a string, using get_known_codes. ### Response: def list_known_codes(s, unique=True, rgb_mode=False): """ Find and print all known escape codes in a string, using get_known_codes. """ total = 0 for codedesc in get_known_codes(s, unique=unique, rgb_mode=rgb_mode): total += 1 print(codedesc) plural = 'code' if total == 1 else 'codes' codetype = ' unique' if unique else '' print('\nFound {}{} escape {}.'.format(total, codetype, plural)) return 0 if total > 0 else 1 <|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, 10086, 323, 1194, 682, 3967, 12731, 14236, 304, 264, 925, 345, 286, 1701, 636, 72790, 39582, 382, 14711, 6075, 512, 755, 1160, 72790, 39582, 1161, 11, 5016, 3702, 11, 18477, 7450, 5725, 997, 262, 4304, 7531, 323, 1194, 682, 3967, 12731, 14236, 304, 264, 925, 345, 286, 1701, 636, 72790, 39582, 627, 262, 3270, 262, 2860, 284, 220, 15, 198, 262, 369, 47773, 3380, 304, 636, 72790, 39582, 1161, 11, 5016, 28, 9782, 11, 18477, 7450, 28, 16916, 7450, 997, 286, 2860, 1447, 220, 16, 198, 286, 1194, 1361, 6879, 3380, 340, 262, 39598, 284, 364, 1889, 6, 422, 2860, 624, 220, 16, 775, 364, 26899, 1270, 262, 20950, 16612, 284, 364, 5016, 6, 422, 5016, 775, 12038, 262, 1194, 11270, 77, 6788, 4792, 6390, 12731, 4792, 37049, 2293, 23689, 11, 20950, 16612, 11, 39598, 1192, 262, 471, 220, 15, 422, 2860, 871, 220, 15, 775, 220, 16, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 10086, 323, 1194, 682, 3967, 12731, 14236, 304, 264, 925, 345, 286, 1701, 636, 72790, 39582, 382, 14711, 6075, 512, 755, 1160, 72790, 39582, 1161, 11, 5016, 3702, 11, 18477, 7450, 5725, 997, 262, 4304, 7531, 323, 1194, 682, 3967, 12731, 14236, 304, 264, 925, 345, 286, 1701, 636, 72790, 39582, 627, 262, 3270, 262, 2860, 284, 220, 15, 198, 262, 369, 47773, 3380, 304, 636, 72790, 39582, 1161, 11, 5016, 28, 9782, 11, 18477, 7450, 28, 16916, 7450, 997, 286, 2860, 1447, 220, 16, 198, 286, 1194, 1361, 6879, 3380, 340, 262, 39598, 284, 364, 1889, 6, 422, 2860, 624, 220, 16, 775, 364, 26899, 1270, 262, 20950, 16612, 284, 364, 5016, 6, 422, 5016, 775, 12038, 262, 1194, 11270, 77, 6788, 4792, 6390, 12731, 4792, 37049, 2293, 23689, 11, 20950, 16612, 11, 39598, 1192, 262, 471, 220, 15, 422, 2860, 871, 220, 15, 775, 220, 16, 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 ]
google/grr
grr/core/grr_response_core/lib/config_lib.py
ParseConfigCommandLine
def ParseConfigCommandLine(): """Parse all the command line options which control the config system.""" # The user may specify the primary config file on the command line. if flags.FLAGS.config: _CONFIG.Initialize(filename=flags.FLAGS.config, must_exist=True) else: raise RuntimeError("A config file is not specified.") # Allow secondary configuration files to be specified. if flags.FLAGS.secondary_configs: for config_file in flags.FLAGS.secondary_configs: _CONFIG.LoadSecondaryConfig(config_file) # Allow individual options to be specified as global overrides. for statement in flags.FLAGS.parameter: if "=" not in statement: raise RuntimeError("statement %s on command line not valid." % statement) name, value = statement.split("=", 1) _CONFIG.global_override[name] = value # Load additional contexts from the command line. for context in flags.FLAGS.context: if context: _CONFIG.AddContext(context) if _CONFIG["Config.writeback"]: _CONFIG.SetWriteBack(_CONFIG["Config.writeback"]) # Does the user want to dump help? We do this after the config system is # initialized so the user can examine what we think the value of all the # parameters are. if flags.FLAGS.config_help: print("Configuration overview.") _CONFIG.PrintHelp() sys.exit(0)
python
def ParseConfigCommandLine(): """Parse all the command line options which control the config system.""" # The user may specify the primary config file on the command line. if flags.FLAGS.config: _CONFIG.Initialize(filename=flags.FLAGS.config, must_exist=True) else: raise RuntimeError("A config file is not specified.") # Allow secondary configuration files to be specified. if flags.FLAGS.secondary_configs: for config_file in flags.FLAGS.secondary_configs: _CONFIG.LoadSecondaryConfig(config_file) # Allow individual options to be specified as global overrides. for statement in flags.FLAGS.parameter: if "=" not in statement: raise RuntimeError("statement %s on command line not valid." % statement) name, value = statement.split("=", 1) _CONFIG.global_override[name] = value # Load additional contexts from the command line. for context in flags.FLAGS.context: if context: _CONFIG.AddContext(context) if _CONFIG["Config.writeback"]: _CONFIG.SetWriteBack(_CONFIG["Config.writeback"]) # Does the user want to dump help? We do this after the config system is # initialized so the user can examine what we think the value of all the # parameters are. if flags.FLAGS.config_help: print("Configuration overview.") _CONFIG.PrintHelp() sys.exit(0)
[ "def", "ParseConfigCommandLine", "(", ")", ":", "# The user may specify the primary config file on the command line.", "if", "flags", ".", "FLAGS", ".", "config", ":", "_CONFIG", ".", "Initialize", "(", "filename", "=", "flags", ".", "FLAGS", ".", "config", ",", "must_exist", "=", "True", ")", "else", ":", "raise", "RuntimeError", "(", "\"A config file is not specified.\"", ")", "# Allow secondary configuration files to be specified.", "if", "flags", ".", "FLAGS", ".", "secondary_configs", ":", "for", "config_file", "in", "flags", ".", "FLAGS", ".", "secondary_configs", ":", "_CONFIG", ".", "LoadSecondaryConfig", "(", "config_file", ")", "# Allow individual options to be specified as global overrides.", "for", "statement", "in", "flags", ".", "FLAGS", ".", "parameter", ":", "if", "\"=\"", "not", "in", "statement", ":", "raise", "RuntimeError", "(", "\"statement %s on command line not valid.\"", "%", "statement", ")", "name", ",", "value", "=", "statement", ".", "split", "(", "\"=\"", ",", "1", ")", "_CONFIG", ".", "global_override", "[", "name", "]", "=", "value", "# Load additional contexts from the command line.", "for", "context", "in", "flags", ".", "FLAGS", ".", "context", ":", "if", "context", ":", "_CONFIG", ".", "AddContext", "(", "context", ")", "if", "_CONFIG", "[", "\"Config.writeback\"", "]", ":", "_CONFIG", ".", "SetWriteBack", "(", "_CONFIG", "[", "\"Config.writeback\"", "]", ")", "# Does the user want to dump help? We do this after the config system is", "# initialized so the user can examine what we think the value of all the", "# parameters are.", "if", "flags", ".", "FLAGS", ".", "config_help", ":", "print", "(", "\"Configuration overview.\"", ")", "_CONFIG", ".", "PrintHelp", "(", ")", "sys", ".", "exit", "(", "0", ")" ]
Parse all the command line options which control the config system.
[ "Parse", "all", "the", "command", "line", "options", "which", "control", "the", "config", "system", "." ]
train
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1704-L1740
<|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 all the command line options which control the config system. ### Response: def ParseConfigCommandLine(): """Parse all the command line options which control the config system.""" # The user may specify the primary config file on the command line. if flags.FLAGS.config: _CONFIG.Initialize(filename=flags.FLAGS.config, must_exist=True) else: raise RuntimeError("A config file is not specified.") # Allow secondary configuration files to be specified. if flags.FLAGS.secondary_configs: for config_file in flags.FLAGS.secondary_configs: _CONFIG.LoadSecondaryConfig(config_file) # Allow individual options to be specified as global overrides. for statement in flags.FLAGS.parameter: if "=" not in statement: raise RuntimeError("statement %s on command line not valid." % statement) name, value = statement.split("=", 1) _CONFIG.global_override[name] = value # Load additional contexts from the command line. for context in flags.FLAGS.context: if context: _CONFIG.AddContext(context) if _CONFIG["Config.writeback"]: _CONFIG.SetWriteBack(_CONFIG["Config.writeback"]) # Does the user want to dump help? We do this after the config system is # initialized so the user can examine what we think the value of all the # parameters are. if flags.FLAGS.config_help: print("Configuration overview.") _CONFIG.PrintHelp() sys.exit(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, 14802, 682, 279, 3290, 1584, 2671, 902, 2585, 279, 2242, 1887, 382, 14711, 6075, 512, 755, 15118, 2714, 72985, 4019, 220, 4304, 14802, 682, 279, 3290, 1584, 2671, 902, 2585, 279, 2242, 1887, 14781, 220, 674, 578, 1217, 1253, 14158, 279, 6156, 2242, 1052, 389, 279, 3290, 1584, 627, 220, 422, 8202, 37590, 50, 5539, 512, 262, 721, 25677, 46929, 11202, 28, 11409, 37590, 50, 5539, 11, 2011, 37006, 3702, 340, 220, 775, 512, 262, 4933, 45643, 446, 32, 2242, 1052, 374, 539, 5300, 32325, 220, 674, 27628, 14580, 6683, 3626, 311, 387, 5300, 627, 220, 422, 8202, 37590, 50, 70156, 60250, 512, 262, 369, 2242, 2517, 304, 8202, 37590, 50, 70156, 60250, 512, 415, 721, 25677, 14296, 50063, 2714, 8928, 2517, 696, 220, 674, 27628, 3927, 2671, 311, 387, 5300, 439, 3728, 36555, 627, 220, 369, 5224, 304, 8202, 37590, 50, 55948, 512, 262, 422, 37334, 539, 304, 5224, 512, 415, 4933, 45643, 446, 25159, 1034, 82, 389, 3290, 1584, 539, 2764, 1210, 1034, 5224, 696, 262, 836, 11, 907, 284, 5224, 5402, 446, 22080, 220, 16, 340, 262, 721, 25677, 22697, 49676, 11174, 60, 284, 907, 271, 220, 674, 9069, 5217, 38697, 505, 279, 3290, 1584, 627, 220, 369, 2317, 304, 8202, 37590, 50, 8852, 512, 262, 422, 2317, 512, 415, 721, 25677, 1943, 2014, 5491, 696, 220, 422, 721, 25677, 1204, 2714, 3921, 1445, 34834, 262, 721, 25677, 4296, 8144, 3792, 2551, 25677, 1204, 2714, 3921, 1445, 46200, 220, 674, 12838, 279, 1217, 1390, 311, 10488, 1520, 30, 1226, 656, 420, 1306, 279, 2242, 1887, 374, 198, 220, 674, 17719, 779, 279, 1217, 649, 21635, 1148, 584, 1781, 279, 907, 315, 682, 279, 198, 220, 674, 5137, 527, 627, 220, 422, 8202, 37590, 50, 5539, 28024, 512, 262, 1194, 446, 7843, 24131, 32325, 262, 721, 25677, 8077, 12978, 746, 262, 5826, 13955, 7, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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, 682, 279, 3290, 1584, 2671, 902, 2585, 279, 2242, 1887, 382, 14711, 6075, 512, 755, 15118, 2714, 72985, 4019, 220, 4304, 14802, 682, 279, 3290, 1584, 2671, 902, 2585, 279, 2242, 1887, 14781, 220, 674, 578, 1217, 1253, 14158, 279, 6156, 2242, 1052, 389, 279, 3290, 1584, 627, 220, 422, 8202, 37590, 50, 5539, 512, 262, 721, 25677, 46929, 11202, 28, 11409, 37590, 50, 5539, 11, 2011, 37006, 3702, 340, 220, 775, 512, 262, 4933, 45643, 446, 32, 2242, 1052, 374, 539, 5300, 32325, 220, 674, 27628, 14580, 6683, 3626, 311, 387, 5300, 627, 220, 422, 8202, 37590, 50, 70156, 60250, 512, 262, 369, 2242, 2517, 304, 8202, 37590, 50, 70156, 60250, 512, 415, 721, 25677, 14296, 50063, 2714, 8928, 2517, 696, 220, 674, 27628, 3927, 2671, 311, 387, 5300, 439, 3728, 36555, 627, 220, 369, 5224, 304, 8202, 37590, 50, 55948, 512, 262, 422, 37334, 539, 304, 5224, 512, 415, 4933, 45643, 446, 25159, 1034, 82, 389, 3290, 1584, 539, 2764, 1210, 1034, 5224, 696, 262, 836, 11, 907, 284, 5224, 5402, 446, 22080, 220, 16, 340, 262, 721, 25677, 22697, 49676, 11174, 60, 284, 907, 271, 220, 674, 9069, 5217, 38697, 505, 279, 3290, 1584, 627, 220, 369, 2317, 304, 8202, 37590, 50, 8852, 512, 262, 422, 2317, 512, 415, 721, 25677, 1943, 2014, 5491, 696, 220, 422, 721, 25677, 1204, 2714, 3921, 1445, 34834, 262, 721, 25677, 4296, 8144, 3792, 2551, 25677, 1204, 2714, 3921, 1445, 46200, 220, 674, 12838, 279, 1217, 1390, 311, 10488, 1520, 30, 1226, 656, 420, 1306, 279, 2242, 1887, 374, 198, 220, 674, 17719, 779, 279, 1217, 649, 21635, 1148, 584, 1781, 279, 907, 315, 682, 279, 198, 220, 674, 5137, 527, 627, 220, 422, 8202, 37590, 50, 5539, 28024, 512, 262, 1194, 446, 7843, 24131, 32325, 262, 721, 25677, 8077, 12978, 746, 262, 5826, 13955, 7, 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 ]
gabstopper/smc-python
smc/api/session.py
Session._build_auth_request
def _build_auth_request(self, verify=False, **kwargs): """ Build the authentication request to SMC """ json = { 'domain': self.domain } credential = self.credential params = {} if credential.provider_name.startswith('lms'): params = dict( login=credential._login, pwd=credential._pwd) else: json.update(authenticationkey=credential._api_key) if kwargs: json.update(**kwargs) self._extra_args.update(**kwargs) # Store in case we need to rebuild later request = dict( url=self.credential.get_provider_entry_point(self.url, self.api_version), json=json, params=params, headers={'content-type': 'application/json'}, verify=verify) return request
python
def _build_auth_request(self, verify=False, **kwargs): """ Build the authentication request to SMC """ json = { 'domain': self.domain } credential = self.credential params = {} if credential.provider_name.startswith('lms'): params = dict( login=credential._login, pwd=credential._pwd) else: json.update(authenticationkey=credential._api_key) if kwargs: json.update(**kwargs) self._extra_args.update(**kwargs) # Store in case we need to rebuild later request = dict( url=self.credential.get_provider_entry_point(self.url, self.api_version), json=json, params=params, headers={'content-type': 'application/json'}, verify=verify) return request
[ "def", "_build_auth_request", "(", "self", ",", "verify", "=", "False", ",", "*", "*", "kwargs", ")", ":", "json", "=", "{", "'domain'", ":", "self", ".", "domain", "}", "credential", "=", "self", ".", "credential", "params", "=", "{", "}", "if", "credential", ".", "provider_name", ".", "startswith", "(", "'lms'", ")", ":", "params", "=", "dict", "(", "login", "=", "credential", ".", "_login", ",", "pwd", "=", "credential", ".", "_pwd", ")", "else", ":", "json", ".", "update", "(", "authenticationkey", "=", "credential", ".", "_api_key", ")", "if", "kwargs", ":", "json", ".", "update", "(", "*", "*", "kwargs", ")", "self", ".", "_extra_args", ".", "update", "(", "*", "*", "kwargs", ")", "# Store in case we need to rebuild later", "request", "=", "dict", "(", "url", "=", "self", ".", "credential", ".", "get_provider_entry_point", "(", "self", ".", "url", ",", "self", ".", "api_version", ")", ",", "json", "=", "json", ",", "params", "=", "params", ",", "headers", "=", "{", "'content-type'", ":", "'application/json'", "}", ",", "verify", "=", "verify", ")", "return", "request" ]
Build the authentication request to SMC
[ "Build", "the", "authentication", "request", "to", "SMC" ]
train
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/api/session.py#L521-L550
<|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 the authentication request to SMC ### Response: def _build_auth_request(self, verify=False, **kwargs): """ Build the authentication request to SMC """ json = { 'domain': self.domain } credential = self.credential params = {} if credential.provider_name.startswith('lms'): params = dict( login=credential._login, pwd=credential._pwd) else: json.update(authenticationkey=credential._api_key) if kwargs: json.update(**kwargs) self._extra_args.update(**kwargs) # Store in case we need to rebuild later request = dict( url=self.credential.get_provider_entry_point(self.url, self.api_version), json=json, params=params, headers={'content-type': 'application/json'}, verify=verify) return request <|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, 279, 17066, 1715, 311, 328, 11865, 271, 14711, 6075, 512, 755, 721, 5957, 14341, 8052, 1214, 11, 10356, 5725, 11, 3146, 9872, 997, 286, 3270, 286, 8012, 279, 17066, 1715, 311, 328, 11865, 198, 286, 3270, 286, 3024, 284, 341, 310, 364, 12482, 1232, 659, 11248, 198, 286, 457, 1827, 286, 41307, 284, 659, 522, 31420, 198, 286, 3712, 284, 5731, 1827, 286, 422, 41307, 29406, 1292, 27249, 493, 75, 1026, 11290, 310, 3712, 284, 6587, 1021, 394, 5982, 28, 67899, 1462, 3758, 345, 394, 33806, 28, 67899, 1462, 26646, 340, 286, 775, 512, 310, 3024, 5430, 28535, 7311, 798, 28, 67899, 1462, 2113, 3173, 340, 1827, 286, 422, 16901, 512, 310, 3024, 5430, 22551, 9872, 340, 310, 659, 1462, 15824, 8550, 5430, 22551, 9872, 8, 674, 9307, 304, 1162, 584, 1205, 311, 32593, 3010, 9122, 286, 1715, 284, 6587, 1021, 310, 2576, 7822, 522, 31420, 673, 30618, 9255, 6213, 1214, 7464, 11, 659, 6314, 9625, 1350, 310, 3024, 38607, 345, 310, 3712, 58743, 345, 310, 7247, 13150, 1834, 10827, 1232, 364, 5242, 9108, 11950, 310, 10356, 28, 12728, 340, 1827, 286, 471, 1715, 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,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 279, 17066, 1715, 311, 328, 11865, 271, 14711, 6075, 512, 755, 721, 5957, 14341, 8052, 1214, 11, 10356, 5725, 11, 3146, 9872, 997, 286, 3270, 286, 8012, 279, 17066, 1715, 311, 328, 11865, 198, 286, 3270, 286, 3024, 284, 341, 310, 364, 12482, 1232, 659, 11248, 198, 286, 457, 1827, 286, 41307, 284, 659, 522, 31420, 198, 286, 3712, 284, 5731, 1827, 286, 422, 41307, 29406, 1292, 27249, 493, 75, 1026, 11290, 310, 3712, 284, 6587, 1021, 394, 5982, 28, 67899, 1462, 3758, 345, 394, 33806, 28, 67899, 1462, 26646, 340, 286, 775, 512, 310, 3024, 5430, 28535, 7311, 798, 28, 67899, 1462, 2113, 3173, 340, 1827, 286, 422, 16901, 512, 310, 3024, 5430, 22551, 9872, 340, 310, 659, 1462, 15824, 8550, 5430, 22551, 9872, 8, 674, 9307, 304, 1162, 584, 1205, 311, 32593, 3010, 9122, 286, 1715, 284, 6587, 1021, 310, 2576, 7822, 522, 31420, 673, 30618, 9255, 6213, 1214, 7464, 11, 659, 6314, 9625, 1350, 310, 3024, 38607, 345, 310, 3712, 58743, 345, 310, 7247, 13150, 1834, 10827, 1232, 364, 5242, 9108, 11950, 310, 10356, 28, 12728, 340, 1827, 286, 471, 1715, 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 ]
evhub/coconut
coconut/compiler/grammar.py
subscriptgroup_handle
def subscriptgroup_handle(tokens): """Process subscriptgroups.""" internal_assert(0 < len(tokens) <= 3, "invalid slice args", tokens) args = [] for arg in tokens: if not arg: arg = "None" args.append(arg) if len(args) == 1: return args[0] else: return "_coconut.slice(" + ", ".join(args) + ")"
python
def subscriptgroup_handle(tokens): """Process subscriptgroups.""" internal_assert(0 < len(tokens) <= 3, "invalid slice args", tokens) args = [] for arg in tokens: if not arg: arg = "None" args.append(arg) if len(args) == 1: return args[0] else: return "_coconut.slice(" + ", ".join(args) + ")"
[ "def", "subscriptgroup_handle", "(", "tokens", ")", ":", "internal_assert", "(", "0", "<", "len", "(", "tokens", ")", "<=", "3", ",", "\"invalid slice args\"", ",", "tokens", ")", "args", "=", "[", "]", "for", "arg", "in", "tokens", ":", "if", "not", "arg", ":", "arg", "=", "\"None\"", "args", ".", "append", "(", "arg", ")", "if", "len", "(", "args", ")", "==", "1", ":", "return", "args", "[", "0", "]", "else", ":", "return", "\"_coconut.slice(\"", "+", "\", \"", ".", "join", "(", "args", ")", "+", "\")\"" ]
Process subscriptgroups.
[ "Process", "subscriptgroups", "." ]
train
https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/grammar.py#L563-L574
<|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: Process subscriptgroups. ### Response: def subscriptgroup_handle(tokens): """Process subscriptgroups.""" internal_assert(0 < len(tokens) <= 3, "invalid slice args", tokens) args = [] for arg in tokens: if not arg: arg = "None" args.append(arg) if len(args) == 1: return args[0] else: return "_coconut.slice(" + ", ".join(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, 7575, 99350, 17171, 382, 14711, 6075, 512, 755, 99350, 4166, 10855, 35152, 997, 262, 4304, 7575, 99350, 17171, 14781, 262, 5419, 16962, 7, 15, 366, 2479, 35152, 8, 2717, 220, 18, 11, 330, 12071, 16363, 2897, 498, 11460, 340, 262, 2897, 284, 4260, 262, 369, 1417, 304, 11460, 512, 286, 422, 539, 1417, 512, 310, 1417, 284, 330, 4155, 702, 286, 2897, 2102, 9590, 340, 262, 422, 2479, 7506, 8, 624, 220, 16, 512, 286, 471, 2897, 58, 15, 933, 262, 775, 512, 286, 471, 9177, 1030, 27357, 14872, 446, 489, 3755, 6058, 6115, 7506, 8, 489, 88776, 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, 7575, 99350, 17171, 382, 14711, 6075, 512, 755, 99350, 4166, 10855, 35152, 997, 262, 4304, 7575, 99350, 17171, 14781, 262, 5419, 16962, 7, 15, 366, 2479, 35152, 8, 2717, 220, 18, 11, 330, 12071, 16363, 2897, 498, 11460, 340, 262, 2897, 284, 4260, 262, 369, 1417, 304, 11460, 512, 286, 422, 539, 1417, 512, 310, 1417, 284, 330, 4155, 702, 286, 2897, 2102, 9590, 340, 262, 422, 2479, 7506, 8, 624, 220, 16, 512, 286, 471, 2897, 58, 15, 933, 262, 775, 512, 286, 471, 9177, 1030, 27357, 14872, 446, 489, 3755, 6058, 6115, 7506, 8, 489, 88776, 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 ]
ANTsX/ANTsPy
ants/utils/invariant_image_similarity.py
invariant_image_similarity
def invariant_image_similarity(image1, image2, local_search_iterations=0, metric='MI', thetas=np.linspace(0,360,5), thetas2=np.linspace(0,360,5), thetas3=np.linspace(0,360,5), scale_image=1, do_reflection=False, txfn=None, transform='Affine'): """ Similarity metrics between two images as a function of geometry Compute similarity metric between two images as image is rotated about its center w/ or w/o optimization ANTsR function: `invariantImageSimilarity` Arguments --------- image1 : ANTsImage reference image image2 : ANTsImage moving image local_search_iterations : integer integer controlling local search in multistart metric : string which metric to use MI GC thetas : 1D-ndarray/list/tuple numeric vector of search angles in degrees thetas2 : 1D-ndarray/list/tuple numeric vector of search angles in degrees around principal axis 2 (3D) thetas3 : 1D-ndarray/list/tuple numeric vector of search angles in degrees around principal axis 3 (3D) scale_image : scalar global scale do_reflection : boolean whether to reflect image about principal axis txfn : string (optional) if present, write optimal tx to .mat file transform : string type of transform to use Rigid Similarity Affine Returns ------- pd.DataFrame dataframe with metric values and transformation parameters Example ------- >>> import ants >>> img1 = ants.image_read(ants.get_ants_data('r16')) >>> img2 = ants.image_read(ants.get_ants_data('r64')) >>> metric = ants.invariant_image_similarity(img1,img2) """ if transform not in {'Rigid', 'Similarity', 'Affine'}: raise ValueError('transform must be one of Rigid/Similarity/Affine') if image1.pixeltype != 'float': image1 = image1.clone('float') if image2.pixeltype != 'float': image2 = image2.clone('float') if txfn is None: txfn = mktemp(suffix='.mat') # convert thetas to radians thetain = (thetas * math.pi) / 180. thetain2 = (thetas2 * math.pi) / 180. thetain3 = (thetas3 * math.pi) / 180. image1 = utils.iMath(image1, 'Normalize') image2 = utils.iMath(image2, 'Normalize') idim = image1.dimension fpname = ['FixedParam%i'%i for i in range(1,idim+1)] if not do_reflection: libfn = utils.get_lib_fn('invariantImageSimilarity_%s%iD' % (transform, idim)) r1 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, int(do_reflection), txfn) r1 = np.asarray(r1) pnames = ['Param%i'%i for i in range(1,r1.shape[1])] pnames[(len(pnames)-idim):len(pnames)] = fpname r1 = pd.DataFrame(r1, columns=['MetricValue']+pnames) return r1, txfn else: txfn1 = mktemp(suffix='.mat') txfn2 = mktemp(suffix='.mat') txfn3 = mktemp(suffix='.mat') txfn4 = mktemp(suffix='.mat') libfn = utils.get_lib_fn('invariantImageSimilarity_%s%iD' % (transform, idim)) ## R1 ## r1 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 0, txfn1) r1 = np.asarray(r1) pnames = ['Param%i'%i for i in range(1,r1.shape[1])] pnames[(len(pnames)-idim):len(pnames)] = fpname r1 = pd.DataFrame(r1, columns=['MetricValue']+pnames) ## R2 ## r2 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 1, txfn2) r2 = np.asarray(r2) r2 = pd.DataFrame(r2, columns=['MetricValue']+pnames) ## R3 ## r3 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 2, txfn3) r3 = np.asarray(r3) r3 = pd.DataFrame(r3, columns=['MetricValue']+pnames) ## R4 ## r4 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 3, txfn4) r4 = np.asarray(r4) r4 = pd.DataFrame(r4, columns=['MetricValue']+pnames) rmins = [np.min(r1.iloc[:,0]), np.min(r2.iloc[:,0]), np.min(r3.iloc[:,0]), np.min(r4.iloc[:,0])] ww = np.argmin(rmins) if ww == 0: return r1, txfn1 elif ww == 1: return r2, txfn2 elif ww == 2: return r3, txfn3 elif ww == 3: return r4, txfn4
python
def invariant_image_similarity(image1, image2, local_search_iterations=0, metric='MI', thetas=np.linspace(0,360,5), thetas2=np.linspace(0,360,5), thetas3=np.linspace(0,360,5), scale_image=1, do_reflection=False, txfn=None, transform='Affine'): """ Similarity metrics between two images as a function of geometry Compute similarity metric between two images as image is rotated about its center w/ or w/o optimization ANTsR function: `invariantImageSimilarity` Arguments --------- image1 : ANTsImage reference image image2 : ANTsImage moving image local_search_iterations : integer integer controlling local search in multistart metric : string which metric to use MI GC thetas : 1D-ndarray/list/tuple numeric vector of search angles in degrees thetas2 : 1D-ndarray/list/tuple numeric vector of search angles in degrees around principal axis 2 (3D) thetas3 : 1D-ndarray/list/tuple numeric vector of search angles in degrees around principal axis 3 (3D) scale_image : scalar global scale do_reflection : boolean whether to reflect image about principal axis txfn : string (optional) if present, write optimal tx to .mat file transform : string type of transform to use Rigid Similarity Affine Returns ------- pd.DataFrame dataframe with metric values and transformation parameters Example ------- >>> import ants >>> img1 = ants.image_read(ants.get_ants_data('r16')) >>> img2 = ants.image_read(ants.get_ants_data('r64')) >>> metric = ants.invariant_image_similarity(img1,img2) """ if transform not in {'Rigid', 'Similarity', 'Affine'}: raise ValueError('transform must be one of Rigid/Similarity/Affine') if image1.pixeltype != 'float': image1 = image1.clone('float') if image2.pixeltype != 'float': image2 = image2.clone('float') if txfn is None: txfn = mktemp(suffix='.mat') # convert thetas to radians thetain = (thetas * math.pi) / 180. thetain2 = (thetas2 * math.pi) / 180. thetain3 = (thetas3 * math.pi) / 180. image1 = utils.iMath(image1, 'Normalize') image2 = utils.iMath(image2, 'Normalize') idim = image1.dimension fpname = ['FixedParam%i'%i for i in range(1,idim+1)] if not do_reflection: libfn = utils.get_lib_fn('invariantImageSimilarity_%s%iD' % (transform, idim)) r1 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, int(do_reflection), txfn) r1 = np.asarray(r1) pnames = ['Param%i'%i for i in range(1,r1.shape[1])] pnames[(len(pnames)-idim):len(pnames)] = fpname r1 = pd.DataFrame(r1, columns=['MetricValue']+pnames) return r1, txfn else: txfn1 = mktemp(suffix='.mat') txfn2 = mktemp(suffix='.mat') txfn3 = mktemp(suffix='.mat') txfn4 = mktemp(suffix='.mat') libfn = utils.get_lib_fn('invariantImageSimilarity_%s%iD' % (transform, idim)) ## R1 ## r1 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 0, txfn1) r1 = np.asarray(r1) pnames = ['Param%i'%i for i in range(1,r1.shape[1])] pnames[(len(pnames)-idim):len(pnames)] = fpname r1 = pd.DataFrame(r1, columns=['MetricValue']+pnames) ## R2 ## r2 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 1, txfn2) r2 = np.asarray(r2) r2 = pd.DataFrame(r2, columns=['MetricValue']+pnames) ## R3 ## r3 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 2, txfn3) r3 = np.asarray(r3) r3 = pd.DataFrame(r3, columns=['MetricValue']+pnames) ## R4 ## r4 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 3, txfn4) r4 = np.asarray(r4) r4 = pd.DataFrame(r4, columns=['MetricValue']+pnames) rmins = [np.min(r1.iloc[:,0]), np.min(r2.iloc[:,0]), np.min(r3.iloc[:,0]), np.min(r4.iloc[:,0])] ww = np.argmin(rmins) if ww == 0: return r1, txfn1 elif ww == 1: return r2, txfn2 elif ww == 2: return r3, txfn3 elif ww == 3: return r4, txfn4
[ "def", "invariant_image_similarity", "(", "image1", ",", "image2", ",", "local_search_iterations", "=", "0", ",", "metric", "=", "'MI'", ",", "thetas", "=", "np", ".", "linspace", "(", "0", ",", "360", ",", "5", ")", ",", "thetas2", "=", "np", ".", "linspace", "(", "0", ",", "360", ",", "5", ")", ",", "thetas3", "=", "np", ".", "linspace", "(", "0", ",", "360", ",", "5", ")", ",", "scale_image", "=", "1", ",", "do_reflection", "=", "False", ",", "txfn", "=", "None", ",", "transform", "=", "'Affine'", ")", ":", "if", "transform", "not", "in", "{", "'Rigid'", ",", "'Similarity'", ",", "'Affine'", "}", ":", "raise", "ValueError", "(", "'transform must be one of Rigid/Similarity/Affine'", ")", "if", "image1", ".", "pixeltype", "!=", "'float'", ":", "image1", "=", "image1", ".", "clone", "(", "'float'", ")", "if", "image2", ".", "pixeltype", "!=", "'float'", ":", "image2", "=", "image2", ".", "clone", "(", "'float'", ")", "if", "txfn", "is", "None", ":", "txfn", "=", "mktemp", "(", "suffix", "=", "'.mat'", ")", "# convert thetas to radians", "thetain", "=", "(", "thetas", "*", "math", ".", "pi", ")", "/", "180.", "thetain2", "=", "(", "thetas2", "*", "math", ".", "pi", ")", "/", "180.", "thetain3", "=", "(", "thetas3", "*", "math", ".", "pi", ")", "/", "180.", "image1", "=", "utils", ".", "iMath", "(", "image1", ",", "'Normalize'", ")", "image2", "=", "utils", ".", "iMath", "(", "image2", ",", "'Normalize'", ")", "idim", "=", "image1", ".", "dimension", "fpname", "=", "[", "'FixedParam%i'", "%", "i", "for", "i", "in", "range", "(", "1", ",", "idim", "+", "1", ")", "]", "if", "not", "do_reflection", ":", "libfn", "=", "utils", ".", "get_lib_fn", "(", "'invariantImageSimilarity_%s%iD'", "%", "(", "transform", ",", "idim", ")", ")", "r1", "=", "libfn", "(", "image1", ".", "pointer", ",", "image2", ".", "pointer", ",", "list", "(", "thetain", ")", ",", "list", "(", "thetain2", ")", ",", "list", "(", "thetain3", ")", ",", "local_search_iterations", ",", "metric", ",", "scale_image", ",", "int", "(", "do_reflection", ")", ",", "txfn", ")", "r1", "=", "np", ".", "asarray", "(", "r1", ")", "pnames", "=", "[", "'Param%i'", "%", "i", "for", "i", "in", "range", "(", "1", ",", "r1", ".", "shape", "[", "1", "]", ")", "]", "pnames", "[", "(", "len", "(", "pnames", ")", "-", "idim", ")", ":", "len", "(", "pnames", ")", "]", "=", "fpname", "r1", "=", "pd", ".", "DataFrame", "(", "r1", ",", "columns", "=", "[", "'MetricValue'", "]", "+", "pnames", ")", "return", "r1", ",", "txfn", "else", ":", "txfn1", "=", "mktemp", "(", "suffix", "=", "'.mat'", ")", "txfn2", "=", "mktemp", "(", "suffix", "=", "'.mat'", ")", "txfn3", "=", "mktemp", "(", "suffix", "=", "'.mat'", ")", "txfn4", "=", "mktemp", "(", "suffix", "=", "'.mat'", ")", "libfn", "=", "utils", ".", "get_lib_fn", "(", "'invariantImageSimilarity_%s%iD'", "%", "(", "transform", ",", "idim", ")", ")", "## R1 ##", "r1", "=", "libfn", "(", "image1", ".", "pointer", ",", "image2", ".", "pointer", ",", "list", "(", "thetain", ")", ",", "list", "(", "thetain2", ")", ",", "list", "(", "thetain3", ")", ",", "local_search_iterations", ",", "metric", ",", "scale_image", ",", "0", ",", "txfn1", ")", "r1", "=", "np", ".", "asarray", "(", "r1", ")", "pnames", "=", "[", "'Param%i'", "%", "i", "for", "i", "in", "range", "(", "1", ",", "r1", ".", "shape", "[", "1", "]", ")", "]", "pnames", "[", "(", "len", "(", "pnames", ")", "-", "idim", ")", ":", "len", "(", "pnames", ")", "]", "=", "fpname", "r1", "=", "pd", ".", "DataFrame", "(", "r1", ",", "columns", "=", "[", "'MetricValue'", "]", "+", "pnames", ")", "## R2 ##", "r2", "=", "libfn", "(", "image1", ".", "pointer", ",", "image2", ".", "pointer", ",", "list", "(", "thetain", ")", ",", "list", "(", "thetain2", ")", ",", "list", "(", "thetain3", ")", ",", "local_search_iterations", ",", "metric", ",", "scale_image", ",", "1", ",", "txfn2", ")", "r2", "=", "np", ".", "asarray", "(", "r2", ")", "r2", "=", "pd", ".", "DataFrame", "(", "r2", ",", "columns", "=", "[", "'MetricValue'", "]", "+", "pnames", ")", "## R3 ##", "r3", "=", "libfn", "(", "image1", ".", "pointer", ",", "image2", ".", "pointer", ",", "list", "(", "thetain", ")", ",", "list", "(", "thetain2", ")", ",", "list", "(", "thetain3", ")", ",", "local_search_iterations", ",", "metric", ",", "scale_image", ",", "2", ",", "txfn3", ")", "r3", "=", "np", ".", "asarray", "(", "r3", ")", "r3", "=", "pd", ".", "DataFrame", "(", "r3", ",", "columns", "=", "[", "'MetricValue'", "]", "+", "pnames", ")", "## R4 ##", "r4", "=", "libfn", "(", "image1", ".", "pointer", ",", "image2", ".", "pointer", ",", "list", "(", "thetain", ")", ",", "list", "(", "thetain2", ")", ",", "list", "(", "thetain3", ")", ",", "local_search_iterations", ",", "metric", ",", "scale_image", ",", "3", ",", "txfn4", ")", "r4", "=", "np", ".", "asarray", "(", "r4", ")", "r4", "=", "pd", ".", "DataFrame", "(", "r4", ",", "columns", "=", "[", "'MetricValue'", "]", "+", "pnames", ")", "rmins", "=", "[", "np", ".", "min", "(", "r1", ".", "iloc", "[", ":", ",", "0", "]", ")", ",", "np", ".", "min", "(", "r2", ".", "iloc", "[", ":", ",", "0", "]", ")", ",", "np", ".", "min", "(", "r3", ".", "iloc", "[", ":", ",", "0", "]", ")", ",", "np", ".", "min", "(", "r4", ".", "iloc", "[", ":", ",", "0", "]", ")", "]", "ww", "=", "np", ".", "argmin", "(", "rmins", ")", "if", "ww", "==", "0", ":", "return", "r1", ",", "txfn1", "elif", "ww", "==", "1", ":", "return", "r2", ",", "txfn2", "elif", "ww", "==", "2", ":", "return", "r3", ",", "txfn3", "elif", "ww", "==", "3", ":", "return", "r4", ",", "txfn4" ]
Similarity metrics between two images as a function of geometry Compute similarity metric between two images as image is rotated about its center w/ or w/o optimization ANTsR function: `invariantImageSimilarity` Arguments --------- image1 : ANTsImage reference image image2 : ANTsImage moving image local_search_iterations : integer integer controlling local search in multistart metric : string which metric to use MI GC thetas : 1D-ndarray/list/tuple numeric vector of search angles in degrees thetas2 : 1D-ndarray/list/tuple numeric vector of search angles in degrees around principal axis 2 (3D) thetas3 : 1D-ndarray/list/tuple numeric vector of search angles in degrees around principal axis 3 (3D) scale_image : scalar global scale do_reflection : boolean whether to reflect image about principal axis txfn : string (optional) if present, write optimal tx to .mat file transform : string type of transform to use Rigid Similarity Affine Returns ------- pd.DataFrame dataframe with metric values and transformation parameters Example ------- >>> import ants >>> img1 = ants.image_read(ants.get_ants_data('r16')) >>> img2 = ants.image_read(ants.get_ants_data('r64')) >>> metric = ants.invariant_image_similarity(img1,img2)
[ "Similarity", "metrics", "between", "two", "images", "as", "a", "function", "of", "geometry" ]
train
https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/invariant_image_similarity.py#L15-L197
<|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: Similarity metrics between two images as a function of geometry Compute similarity metric between two images as image is rotated about its center w/ or w/o optimization ANTsR function: `invariantImageSimilarity` Arguments --------- image1 : ANTsImage reference image image2 : ANTsImage moving image local_search_iterations : integer integer controlling local search in multistart metric : string which metric to use MI GC thetas : 1D-ndarray/list/tuple numeric vector of search angles in degrees thetas2 : 1D-ndarray/list/tuple numeric vector of search angles in degrees around principal axis 2 (3D) thetas3 : 1D-ndarray/list/tuple numeric vector of search angles in degrees around principal axis 3 (3D) scale_image : scalar global scale do_reflection : boolean whether to reflect image about principal axis txfn : string (optional) if present, write optimal tx to .mat file transform : string type of transform to use Rigid Similarity Affine Returns ------- pd.DataFrame dataframe with metric values and transformation parameters Example ------- >>> import ants >>> img1 = ants.image_read(ants.get_ants_data('r16')) >>> img2 = ants.image_read(ants.get_ants_data('r64')) >>> metric = ants.invariant_image_similarity(img1,img2) ### Response: def invariant_image_similarity(image1, image2, local_search_iterations=0, metric='MI', thetas=np.linspace(0,360,5), thetas2=np.linspace(0,360,5), thetas3=np.linspace(0,360,5), scale_image=1, do_reflection=False, txfn=None, transform='Affine'): """ Similarity metrics between two images as a function of geometry Compute similarity metric between two images as image is rotated about its center w/ or w/o optimization ANTsR function: `invariantImageSimilarity` Arguments --------- image1 : ANTsImage reference image image2 : ANTsImage moving image local_search_iterations : integer integer controlling local search in multistart metric : string which metric to use MI GC thetas : 1D-ndarray/list/tuple numeric vector of search angles in degrees thetas2 : 1D-ndarray/list/tuple numeric vector of search angles in degrees around principal axis 2 (3D) thetas3 : 1D-ndarray/list/tuple numeric vector of search angles in degrees around principal axis 3 (3D) scale_image : scalar global scale do_reflection : boolean whether to reflect image about principal axis txfn : string (optional) if present, write optimal tx to .mat file transform : string type of transform to use Rigid Similarity Affine Returns ------- pd.DataFrame dataframe with metric values and transformation parameters Example ------- >>> import ants >>> img1 = ants.image_read(ants.get_ants_data('r16')) >>> img2 = ants.image_read(ants.get_ants_data('r64')) >>> metric = ants.invariant_image_similarity(img1,img2) """ if transform not in {'Rigid', 'Similarity', 'Affine'}: raise ValueError('transform must be one of Rigid/Similarity/Affine') if image1.pixeltype != 'float': image1 = image1.clone('float') if image2.pixeltype != 'float': image2 = image2.clone('float') if txfn is None: txfn = mktemp(suffix='.mat') # convert thetas to radians thetain = (thetas * math.pi) / 180. thetain2 = (thetas2 * math.pi) / 180. thetain3 = (thetas3 * math.pi) / 180. image1 = utils.iMath(image1, 'Normalize') image2 = utils.iMath(image2, 'Normalize') idim = image1.dimension fpname = ['FixedParam%i'%i for i in range(1,idim+1)] if not do_reflection: libfn = utils.get_lib_fn('invariantImageSimilarity_%s%iD' % (transform, idim)) r1 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, int(do_reflection), txfn) r1 = np.asarray(r1) pnames = ['Param%i'%i for i in range(1,r1.shape[1])] pnames[(len(pnames)-idim):len(pnames)] = fpname r1 = pd.DataFrame(r1, columns=['MetricValue']+pnames) return r1, txfn else: txfn1 = mktemp(suffix='.mat') txfn2 = mktemp(suffix='.mat') txfn3 = mktemp(suffix='.mat') txfn4 = mktemp(suffix='.mat') libfn = utils.get_lib_fn('invariantImageSimilarity_%s%iD' % (transform, idim)) ## R1 ## r1 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 0, txfn1) r1 = np.asarray(r1) pnames = ['Param%i'%i for i in range(1,r1.shape[1])] pnames[(len(pnames)-idim):len(pnames)] = fpname r1 = pd.DataFrame(r1, columns=['MetricValue']+pnames) ## R2 ## r2 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 1, txfn2) r2 = np.asarray(r2) r2 = pd.DataFrame(r2, columns=['MetricValue']+pnames) ## R3 ## r3 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 2, txfn3) r3 = np.asarray(r3) r3 = pd.DataFrame(r3, columns=['MetricValue']+pnames) ## R4 ## r4 = libfn(image1.pointer, image2.pointer, list(thetain), list(thetain2), list(thetain3), local_search_iterations, metric, scale_image, 3, txfn4) r4 = np.asarray(r4) r4 = pd.DataFrame(r4, columns=['MetricValue']+pnames) rmins = [np.min(r1.iloc[:,0]), np.min(r2.iloc[:,0]), np.min(r3.iloc[:,0]), np.min(r4.iloc[:,0])] ww = np.argmin(rmins) if ww == 0: return r1, txfn1 elif ww == 1: return r2, txfn2 elif ww == 2: return r3, txfn3 elif ww == 3: return r4, txfn4 <|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, 35502, 488, 17150, 1990, 1403, 5448, 439, 264, 734, 315, 17484, 271, 262, 23426, 38723, 18767, 1990, 1403, 5448, 439, 2217, 374, 46720, 922, 1202, 198, 262, 4219, 289, 14, 477, 289, 20886, 26329, 271, 262, 2147, 53893, 49, 734, 25, 1595, 258, 16349, 1945, 35502, 488, 19884, 262, 28802, 198, 262, 220, 29547, 262, 2217, 16, 551, 2147, 53893, 1945, 198, 286, 5905, 2217, 7361, 262, 2217, 17, 551, 2147, 53893, 1945, 198, 286, 7366, 2217, 7361, 262, 2254, 10947, 56707, 551, 7698, 198, 286, 7698, 26991, 2254, 2778, 304, 2814, 380, 472, 7361, 262, 18767, 551, 925, 198, 286, 902, 18767, 311, 1005, 198, 310, 18983, 198, 310, 23186, 198, 262, 279, 48642, 551, 220, 16, 35, 12, 303, 1686, 21609, 5640, 6189, 198, 286, 25031, 4724, 315, 2778, 27030, 304, 12628, 7361, 262, 279, 48642, 17, 551, 220, 16, 35, 12, 303, 1686, 21609, 5640, 6189, 198, 286, 25031, 4724, 315, 2778, 27030, 304, 12628, 2212, 12717, 8183, 220, 17, 320, 18, 35, 340, 1084, 262, 279, 48642, 18, 551, 220, 16, 35, 12, 303, 1686, 21609, 5640, 6189, 198, 286, 25031, 4724, 315, 2778, 27030, 304, 12628, 2212, 12717, 8183, 220, 18, 320, 18, 35, 340, 1084, 262, 5569, 5060, 551, 17722, 198, 286, 3728, 5569, 7361, 262, 656, 7949, 1191, 551, 2777, 198, 286, 3508, 311, 8881, 2217, 922, 12717, 8183, 7361, 262, 259, 5972, 77, 551, 925, 320, 13099, 340, 286, 422, 3118, 11, 3350, 23669, 10055, 311, 662, 8637, 1052, 7361, 262, 5276, 551, 925, 198, 286, 955, 315, 5276, 311, 1005, 198, 310, 432, 21596, 198, 310, 22196, 488, 198, 310, 9947, 483, 4815, 262, 5295, 198, 262, 39707, 262, 7900, 21756, 198, 286, 39328, 449, 18767, 2819, 323, 18475, 5137, 271, 262, 13688, 198, 262, 39707, 262, 12382, 1179, 61495, 198, 262, 12382, 5071, 16, 284, 61495, 7502, 6579, 7, 1821, 673, 62, 1821, 1807, 493, 81, 845, 7132, 262, 12382, 5071, 17, 284, 61495, 7502, 6579, 7, 1821, 673, 62, 1821, 1807, 493, 81, 1227, 7132, 262, 12382, 18767, 284, 61495, 1896, 16349, 5060, 77336, 11268, 16, 76222, 17, 696, 14711, 6075, 512, 755, 58720, 5060, 77336, 10281, 16, 11, 2217, 17, 11, 720, 1408, 2254, 10947, 56707, 28, 15, 11, 18767, 1151, 9972, 518, 720, 1408, 279, 48642, 17874, 39812, 7, 15, 11, 6843, 11, 20, 1350, 1408, 279, 48642, 17, 17874, 39812, 7, 15, 11, 6843, 11, 20, 1350, 1408, 279, 48642, 18, 17874, 39812, 7, 15, 11, 6843, 11, 20, 705, 2355, 1408, 5569, 5060, 28, 16, 11, 656, 7949, 1191, 5725, 345, 1408, 259, 5972, 77, 5980, 11, 5276, 1151, 26926, 483, 11290, 262, 3270, 262, 22196, 488, 17150, 1990, 1403, 5448, 439, 264, 734, 315, 17484, 271, 262, 23426, 38723, 18767, 1990, 1403, 5448, 439, 2217, 374, 46720, 922, 1202, 198, 262, 4219, 289, 14, 477, 289, 20886 ]
[ 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 35502, 488, 17150, 1990, 1403, 5448, 439, 264, 734, 315, 17484, 271, 262, 23426, 38723, 18767, 1990, 1403, 5448, 439, 2217, 374, 46720, 922, 1202, 198, 262, 4219, 289, 14, 477, 289, 20886, 26329, 271, 262, 2147, 53893, 49, 734, 25, 1595, 258, 16349, 1945, 35502, 488, 19884, 262, 28802, 198, 262, 220, 29547, 262, 2217, 16, 551, 2147, 53893, 1945, 198, 286, 5905, 2217, 7361, 262, 2217, 17, 551, 2147, 53893, 1945, 198, 286, 7366, 2217, 7361, 262, 2254, 10947, 56707, 551, 7698, 198, 286, 7698, 26991, 2254, 2778, 304, 2814, 380, 472, 7361, 262, 18767, 551, 925, 198, 286, 902, 18767, 311, 1005, 198, 310, 18983, 198, 310, 23186, 198, 262, 279, 48642, 551, 220, 16, 35, 12, 303, 1686, 21609, 5640, 6189, 198, 286, 25031, 4724, 315, 2778, 27030, 304, 12628, 7361, 262, 279, 48642, 17, 551, 220, 16, 35, 12, 303, 1686, 21609, 5640, 6189, 198, 286, 25031, 4724, 315, 2778, 27030, 304, 12628, 2212, 12717, 8183, 220, 17, 320, 18, 35, 340, 1084, 262, 279, 48642, 18, 551, 220, 16, 35, 12, 303, 1686, 21609, 5640, 6189, 198, 286, 25031, 4724, 315, 2778, 27030, 304, 12628, 2212, 12717, 8183, 220, 18, 320, 18, 35, 340, 1084, 262, 5569, 5060, 551, 17722, 198, 286, 3728, 5569, 7361, 262, 656, 7949, 1191, 551, 2777, 198, 286, 3508, 311, 8881, 2217, 922, 12717, 8183, 7361, 262, 259, 5972, 77, 551, 925, 320, 13099, 340, 286, 422, 3118, 11, 3350, 23669, 10055, 311, 662, 8637, 1052, 7361, 262, 5276, 551, 925, 198, 286, 955, 315, 5276, 311, 1005, 198, 310, 432, 21596, 198, 310, 22196, 488, 198, 310, 9947, 483, 4815, 262, 5295, 198, 262, 39707, 262, 7900, 21756, 198, 286, 39328, 449, 18767, 2819, 323, 18475, 5137, 271, 262, 13688, 198, 262, 39707, 262, 12382, 1179, 61495, 198, 262, 12382, 5071, 16, 284, 61495, 7502, 6579, 7, 1821, 673, 62, 1821, 1807, 493, 81, 845, 7132, 262, 12382, 5071, 17, 284, 61495, 7502, 6579, 7, 1821, 673, 62, 1821, 1807, 493, 81, 1227, 7132, 262, 12382, 18767, 284, 61495, 1896, 16349, 5060, 77336, 11268, 16, 76222, 17, 696, 14711, 6075, 512, 755, 58720, 5060, 77336, 10281, 16, 11, 2217, 17, 11, 720, 1408, 2254, 10947, 56707, 28, 15, 11, 18767, 1151, 9972, 518, 720, 1408, 279, 48642, 17874, 39812, 7, 15, 11, 6843, 11, 20, 1350, 1408, 279, 48642, 17, 17874, 39812, 7, 15, 11, 6843, 11, 20, 1350, 1408, 279, 48642, 18, 17874, 39812, 7, 15, 11, 6843, 11, 20, 705, 2355, 1408, 5569, 5060, 28, 16, 11, 656, 7949, 1191, 5725, 345, 1408, 259, 5972, 77, 5980, 11, 5276, 1151, 26926, 483, 11290, 262, 3270, 262, 22196, 488, 17150, 1990, 1403, 5448, 439, 264, 734, 315, 17484, 271, 262, 23426, 38723, 18767, 1990, 1403, 5448, 439, 2217, 374, 46720, 922, 1202, 198, 262, 4219, 289, 14, 477, 289, 20886 ]
bigchaindb/bigchaindb-driver
bigchaindb_driver/driver.py
TransactionsEndpoint.prepare
def prepare(*, operation='CREATE', signers=None, recipients=None, asset=None, metadata=None, inputs=None): """Prepares a transaction payload, ready to be fulfilled. Args: operation (str): The operation to perform. Must be ``'CREATE'`` or ``'TRANSFER'``. Case insensitive. Defaults to ``'CREATE'``. signers (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or more public keys representing the issuer(s) of the asset being created. Only applies for ``'CREATE'`` operations. Defaults to ``None``. recipients (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or more public keys representing the new recipients(s) of the asset being created or transferred. Defaults to ``None``. asset (:obj:`dict`, optional): The asset to be created or transferred. MUST be supplied for ``'TRANSFER'`` operations. Defaults to ``None``. metadata (:obj:`dict`, optional): Metadata associated with the transaction. Defaults to ``None``. inputs (:obj:`dict` | :obj:`list` | :obj:`tuple`, optional): One or more inputs holding the condition(s) that this transaction intends to fulfill. Each input is expected to be a :obj:`dict`. Only applies to, and MUST be supplied for, ``'TRANSFER'`` operations. Returns: dict: The prepared transaction. Raises: :class:`~.exceptions.BigchaindbException`: If ``operation`` is not ``'CREATE'`` or ``'TRANSFER'``. .. important:: **CREATE operations** * ``signers`` MUST be set. * ``recipients``, ``asset``, and ``metadata`` MAY be set. * If ``asset`` is set, it MUST be in the form of:: { 'data': { ... } } * The argument ``inputs`` is ignored. * If ``recipients`` is not given, or evaluates to ``False``, it will be set equal to ``signers``:: if not recipients: recipients = signers **TRANSFER operations** * ``recipients``, ``asset``, and ``inputs`` MUST be set. * ``asset`` MUST be in the form of:: { 'id': '<Asset ID (i.e. TX ID of its CREATE transaction)>' } * ``metadata`` MAY be set. * The argument ``signers`` is ignored. """ return prepare_transaction( operation=operation, signers=signers, recipients=recipients, asset=asset, metadata=metadata, inputs=inputs, )
python
def prepare(*, operation='CREATE', signers=None, recipients=None, asset=None, metadata=None, inputs=None): """Prepares a transaction payload, ready to be fulfilled. Args: operation (str): The operation to perform. Must be ``'CREATE'`` or ``'TRANSFER'``. Case insensitive. Defaults to ``'CREATE'``. signers (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or more public keys representing the issuer(s) of the asset being created. Only applies for ``'CREATE'`` operations. Defaults to ``None``. recipients (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or more public keys representing the new recipients(s) of the asset being created or transferred. Defaults to ``None``. asset (:obj:`dict`, optional): The asset to be created or transferred. MUST be supplied for ``'TRANSFER'`` operations. Defaults to ``None``. metadata (:obj:`dict`, optional): Metadata associated with the transaction. Defaults to ``None``. inputs (:obj:`dict` | :obj:`list` | :obj:`tuple`, optional): One or more inputs holding the condition(s) that this transaction intends to fulfill. Each input is expected to be a :obj:`dict`. Only applies to, and MUST be supplied for, ``'TRANSFER'`` operations. Returns: dict: The prepared transaction. Raises: :class:`~.exceptions.BigchaindbException`: If ``operation`` is not ``'CREATE'`` or ``'TRANSFER'``. .. important:: **CREATE operations** * ``signers`` MUST be set. * ``recipients``, ``asset``, and ``metadata`` MAY be set. * If ``asset`` is set, it MUST be in the form of:: { 'data': { ... } } * The argument ``inputs`` is ignored. * If ``recipients`` is not given, or evaluates to ``False``, it will be set equal to ``signers``:: if not recipients: recipients = signers **TRANSFER operations** * ``recipients``, ``asset``, and ``inputs`` MUST be set. * ``asset`` MUST be in the form of:: { 'id': '<Asset ID (i.e. TX ID of its CREATE transaction)>' } * ``metadata`` MAY be set. * The argument ``signers`` is ignored. """ return prepare_transaction( operation=operation, signers=signers, recipients=recipients, asset=asset, metadata=metadata, inputs=inputs, )
[ "def", "prepare", "(", "*", ",", "operation", "=", "'CREATE'", ",", "signers", "=", "None", ",", "recipients", "=", "None", ",", "asset", "=", "None", ",", "metadata", "=", "None", ",", "inputs", "=", "None", ")", ":", "return", "prepare_transaction", "(", "operation", "=", "operation", ",", "signers", "=", "signers", ",", "recipients", "=", "recipients", ",", "asset", "=", "asset", ",", "metadata", "=", "metadata", ",", "inputs", "=", "inputs", ",", ")" ]
Prepares a transaction payload, ready to be fulfilled. Args: operation (str): The operation to perform. Must be ``'CREATE'`` or ``'TRANSFER'``. Case insensitive. Defaults to ``'CREATE'``. signers (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or more public keys representing the issuer(s) of the asset being created. Only applies for ``'CREATE'`` operations. Defaults to ``None``. recipients (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or more public keys representing the new recipients(s) of the asset being created or transferred. Defaults to ``None``. asset (:obj:`dict`, optional): The asset to be created or transferred. MUST be supplied for ``'TRANSFER'`` operations. Defaults to ``None``. metadata (:obj:`dict`, optional): Metadata associated with the transaction. Defaults to ``None``. inputs (:obj:`dict` | :obj:`list` | :obj:`tuple`, optional): One or more inputs holding the condition(s) that this transaction intends to fulfill. Each input is expected to be a :obj:`dict`. Only applies to, and MUST be supplied for, ``'TRANSFER'`` operations. Returns: dict: The prepared transaction. Raises: :class:`~.exceptions.BigchaindbException`: If ``operation`` is not ``'CREATE'`` or ``'TRANSFER'``. .. important:: **CREATE operations** * ``signers`` MUST be set. * ``recipients``, ``asset``, and ``metadata`` MAY be set. * If ``asset`` is set, it MUST be in the form of:: { 'data': { ... } } * The argument ``inputs`` is ignored. * If ``recipients`` is not given, or evaluates to ``False``, it will be set equal to ``signers``:: if not recipients: recipients = signers **TRANSFER operations** * ``recipients``, ``asset``, and ``inputs`` MUST be set. * ``asset`` MUST be in the form of:: { 'id': '<Asset ID (i.e. TX ID of its CREATE transaction)>' } * ``metadata`` MAY be set. * The argument ``signers`` is ignored.
[ "Prepares", "a", "transaction", "payload", "ready", "to", "be", "fulfilled", "." ]
train
https://github.com/bigchaindb/bigchaindb-driver/blob/c294a535f0696bd19483ae11a4882b74e6fc061e/bigchaindb_driver/driver.py#L181-L255
<|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: Prepares a transaction payload, ready to be fulfilled. Args: operation (str): The operation to perform. Must be ``'CREATE'`` or ``'TRANSFER'``. Case insensitive. Defaults to ``'CREATE'``. signers (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or more public keys representing the issuer(s) of the asset being created. Only applies for ``'CREATE'`` operations. Defaults to ``None``. recipients (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or more public keys representing the new recipients(s) of the asset being created or transferred. Defaults to ``None``. asset (:obj:`dict`, optional): The asset to be created or transferred. MUST be supplied for ``'TRANSFER'`` operations. Defaults to ``None``. metadata (:obj:`dict`, optional): Metadata associated with the transaction. Defaults to ``None``. inputs (:obj:`dict` | :obj:`list` | :obj:`tuple`, optional): One or more inputs holding the condition(s) that this transaction intends to fulfill. Each input is expected to be a :obj:`dict`. Only applies to, and MUST be supplied for, ``'TRANSFER'`` operations. Returns: dict: The prepared transaction. Raises: :class:`~.exceptions.BigchaindbException`: If ``operation`` is not ``'CREATE'`` or ``'TRANSFER'``. .. important:: **CREATE operations** * ``signers`` MUST be set. * ``recipients``, ``asset``, and ``metadata`` MAY be set. * If ``asset`` is set, it MUST be in the form of:: { 'data': { ... } } * The argument ``inputs`` is ignored. * If ``recipients`` is not given, or evaluates to ``False``, it will be set equal to ``signers``:: if not recipients: recipients = signers **TRANSFER operations** * ``recipients``, ``asset``, and ``inputs`` MUST be set. * ``asset`` MUST be in the form of:: { 'id': '<Asset ID (i.e. TX ID of its CREATE transaction)>' } * ``metadata`` MAY be set. * The argument ``signers`` is ignored. ### Response: def prepare(*, operation='CREATE', signers=None, recipients=None, asset=None, metadata=None, inputs=None): """Prepares a transaction payload, ready to be fulfilled. Args: operation (str): The operation to perform. Must be ``'CREATE'`` or ``'TRANSFER'``. Case insensitive. Defaults to ``'CREATE'``. signers (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or more public keys representing the issuer(s) of the asset being created. Only applies for ``'CREATE'`` operations. Defaults to ``None``. recipients (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or more public keys representing the new recipients(s) of the asset being created or transferred. Defaults to ``None``. asset (:obj:`dict`, optional): The asset to be created or transferred. MUST be supplied for ``'TRANSFER'`` operations. Defaults to ``None``. metadata (:obj:`dict`, optional): Metadata associated with the transaction. Defaults to ``None``. inputs (:obj:`dict` | :obj:`list` | :obj:`tuple`, optional): One or more inputs holding the condition(s) that this transaction intends to fulfill. Each input is expected to be a :obj:`dict`. Only applies to, and MUST be supplied for, ``'TRANSFER'`` operations. Returns: dict: The prepared transaction. Raises: :class:`~.exceptions.BigchaindbException`: If ``operation`` is not ``'CREATE'`` or ``'TRANSFER'``. .. important:: **CREATE operations** * ``signers`` MUST be set. * ``recipients``, ``asset``, and ``metadata`` MAY be set. * If ``asset`` is set, it MUST be in the form of:: { 'data': { ... } } * The argument ``inputs`` is ignored. * If ``recipients`` is not given, or evaluates to ``False``, it will be set equal to ``signers``:: if not recipients: recipients = signers **TRANSFER operations** * ``recipients``, ``asset``, and ``inputs`` MUST be set. * ``asset`` MUST be in the form of:: { 'id': '<Asset ID (i.e. TX ID of its CREATE transaction)>' } * ``metadata`` MAY be set. * The argument ``signers`` is ignored. """ return prepare_transaction( operation=operation, signers=signers, recipients=recipients, asset=asset, metadata=metadata, inputs=inputs, ) <|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, 4808, 79, 5518, 264, 7901, 7885, 11, 5644, 311, 387, 41834, 382, 286, 18161, 512, 310, 5784, 320, 496, 1680, 578, 5784, 311, 2804, 13, 15832, 387, 10103, 6, 23421, 6, 85374, 394, 477, 10103, 6, 62476, 6, 14196, 13, 11799, 71580, 13, 37090, 311, 10103, 6, 23421, 6, 14196, 627, 310, 1879, 388, 30354, 2347, 19258, 1638, 63, 765, 551, 2347, 19258, 25609, 63, 765, 551, 2347, 19258, 496, 7964, 10309, 997, 394, 3861, 477, 810, 586, 7039, 14393, 279, 55935, 1161, 8, 315, 198, 394, 279, 9513, 1694, 3549, 13, 8442, 17208, 369, 10103, 6, 23421, 6, 85374, 394, 7677, 13, 37090, 311, 10103, 4155, 14196, 627, 310, 34876, 30354, 2347, 19258, 1638, 63, 765, 551, 2347, 19258, 25609, 63, 765, 551, 2347, 19258, 496, 7964, 10309, 997, 394, 3861, 477, 810, 586, 7039, 14393, 279, 502, 34876, 1161, 340, 394, 315, 279, 9513, 1694, 3549, 477, 23217, 627, 394, 37090, 311, 10103, 4155, 14196, 627, 310, 9513, 30354, 2347, 19258, 8644, 7964, 10309, 1680, 578, 9513, 311, 387, 3549, 477, 198, 394, 23217, 13, 28832, 387, 17665, 369, 10103, 6, 62476, 6, 14196, 7677, 627, 394, 37090, 311, 10103, 4155, 14196, 627, 310, 11408, 30354, 2347, 19258, 8644, 7964, 10309, 1680, 34689, 5938, 449, 279, 198, 394, 7901, 13, 37090, 311, 10103, 4155, 14196, 627, 310, 11374, 30354, 2347, 19258, 8644, 63, 765, 551, 2347, 19258, 1638, 63, 765, 551, 2347, 19258, 25609, 7964, 10309, 997, 394, 3861, 477, 810, 11374, 10168, 279, 3044, 1161, 8, 430, 420, 198, 394, 7901, 44330, 311, 21054, 13, 9062, 1988, 374, 3685, 311, 198, 394, 387, 264, 551, 2347, 19258, 8644, 29687, 8442, 17208, 311, 11, 323, 28832, 387, 17665, 369, 345, 394, 10103, 6, 62476, 6, 14196, 7677, 382, 286, 5295, 512, 310, 6587, 25, 578, 10235, 7901, 382, 286, 61411, 512, 310, 551, 1058, 78902, 13, 62852, 70323, 8995, 2042, 1378, 45722, 1442, 10103, 9446, 14196, 374, 198, 394, 539, 10103, 6, 23421, 6, 14196, 477, 10103, 6, 62476, 6, 14196, 382, 286, 5354, 3062, 66152, 310, 3146, 23421, 7677, 57277, 310, 353, 10103, 7908, 388, 14196, 28832, 387, 743, 627, 310, 353, 10103, 2827, 48747, 91816, 10103, 10053, 91816, 323, 10103, 18103, 14196, 40330, 387, 743, 627, 310, 353, 1442, 10103, 10053, 14196, 374, 743, 11, 433, 28832, 387, 304, 279, 1376, 315, 66152, 394, 341, 504, 364, 695, 1232, 341, 667, 12515, 504, 457, 394, 557, 310, 353, 578, 5811, 10103, 25986, 14196, 374, 12305, 627, 310, 353, 1442, 10103, 2827, 48747, 14196, 374, 539, 2728, 11, 477, 67349, 311, 198, 1078, 10103, 4139, 91816, 433, 690, 387, 743, 6273, 311, 10103, 7908, 388, 14196, 66152, 394, 422, 539, 34876, 512, 504, 34876, 284, 1879, 388, 271, 310, 3146, 62476, 7677, 57277, 310, 353, 10103, 2827, 48747, 91816, 10103, 10053, 91816, 323, 10103, 25986, 14196, 28832, 387, 743, 627 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 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, 4808, 79, 5518, 264, 7901, 7885, 11, 5644, 311, 387, 41834, 382, 286, 18161, 512, 310, 5784, 320, 496, 1680, 578, 5784, 311, 2804, 13, 15832, 387, 10103, 6, 23421, 6, 85374, 394, 477, 10103, 6, 62476, 6, 14196, 13, 11799, 71580, 13, 37090, 311, 10103, 6, 23421, 6, 14196, 627, 310, 1879, 388, 30354, 2347, 19258, 1638, 63, 765, 551, 2347, 19258, 25609, 63, 765, 551, 2347, 19258, 496, 7964, 10309, 997, 394, 3861, 477, 810, 586, 7039, 14393, 279, 55935, 1161, 8, 315, 198, 394, 279, 9513, 1694, 3549, 13, 8442, 17208, 369, 10103, 6, 23421, 6, 85374, 394, 7677, 13, 37090, 311, 10103, 4155, 14196, 627, 310, 34876, 30354, 2347, 19258, 1638, 63, 765, 551, 2347, 19258, 25609, 63, 765, 551, 2347, 19258, 496, 7964, 10309, 997, 394, 3861, 477, 810, 586, 7039, 14393, 279, 502, 34876, 1161, 340, 394, 315, 279, 9513, 1694, 3549, 477, 23217, 627, 394, 37090, 311, 10103, 4155, 14196, 627, 310, 9513, 30354, 2347, 19258, 8644, 7964, 10309, 1680, 578, 9513, 311, 387, 3549, 477, 198, 394, 23217, 13, 28832, 387, 17665, 369, 10103, 6, 62476, 6, 14196, 7677, 627, 394, 37090, 311, 10103, 4155, 14196, 627, 310, 11408, 30354, 2347, 19258, 8644, 7964, 10309, 1680, 34689, 5938, 449, 279, 198, 394, 7901, 13, 37090, 311, 10103, 4155, 14196, 627, 310, 11374, 30354, 2347, 19258, 8644, 63, 765, 551, 2347, 19258, 1638, 63, 765, 551, 2347, 19258, 25609, 7964, 10309, 997, 394, 3861, 477, 810, 11374, 10168, 279, 3044, 1161, 8, 430, 420, 198, 394, 7901, 44330, 311, 21054, 13, 9062, 1988, 374, 3685, 311, 198, 394, 387, 264, 551, 2347, 19258, 8644, 29687, 8442, 17208, 311, 11, 323, 28832, 387, 17665, 369, 345, 394, 10103, 6, 62476, 6, 14196, 7677, 382, 286, 5295, 512, 310, 6587, 25, 578, 10235, 7901, 382, 286, 61411, 512, 310, 551, 1058, 78902, 13, 62852, 70323, 8995, 2042, 1378, 45722, 1442, 10103, 9446, 14196, 374, 198, 394, 539, 10103, 6, 23421, 6, 14196, 477, 10103, 6, 62476, 6, 14196, 382, 286, 5354, 3062, 66152, 310, 3146, 23421, 7677, 57277, 310, 353, 10103, 7908, 388, 14196, 28832, 387, 743, 627, 310, 353, 10103, 2827, 48747, 91816, 10103, 10053, 91816, 323, 10103, 18103, 14196, 40330, 387, 743, 627, 310, 353, 1442, 10103, 10053, 14196, 374, 743, 11, 433, 28832, 387, 304, 279, 1376, 315, 66152, 394, 341, 504, 364, 695, 1232, 341, 667, 12515, 504, 457, 394, 557, 310, 353, 578, 5811, 10103, 25986, 14196, 374, 12305, 627, 310, 353, 1442, 10103, 2827, 48747, 14196, 374, 539, 2728, 11, 477, 67349, 311, 198, 1078, 10103, 4139, 91816, 433, 690, 387, 743, 6273, 311, 10103, 7908, 388, 14196, 66152, 394, 422, 539, 34876, 512, 504, 34876, 284, 1879, 388, 271, 310, 3146, 62476, 7677, 57277, 310, 353, 10103, 2827, 48747, 91816, 10103, 10053, 91816, 323, 10103, 25986, 14196, 28832, 387, 743, 627 ]
zsimic/runez
src/runez/click.py
debug
def debug(*args, **attrs): """Show debugging information.""" attrs.setdefault("is_flag", True) attrs.setdefault("default", None) return option(debug, *args, **attrs)
python
def debug(*args, **attrs): """Show debugging information.""" attrs.setdefault("is_flag", True) attrs.setdefault("default", None) return option(debug, *args, **attrs)
[ "def", "debug", "(", "*", "args", ",", "*", "*", "attrs", ")", ":", "attrs", ".", "setdefault", "(", "\"is_flag\"", ",", "True", ")", "attrs", ".", "setdefault", "(", "\"default\"", ",", "None", ")", "return", "option", "(", "debug", ",", "*", "args", ",", "*", "*", "attrs", ")" ]
Show debugging information.
[ "Show", "debugging", "information", "." ]
train
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/click.py#L49-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: Show debugging information. ### Response: def debug(*args, **attrs): """Show debugging information.""" attrs.setdefault("is_flag", True) attrs.setdefault("default", None) return option(debug, *args, **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, 7968, 28803, 2038, 382, 14711, 6075, 512, 755, 7542, 4163, 2164, 11, 3146, 21101, 997, 262, 4304, 7968, 28803, 2038, 14781, 262, 16602, 54114, 446, 285, 11173, 498, 3082, 340, 262, 16602, 54114, 446, 2309, 498, 2290, 340, 262, 471, 3072, 43254, 11, 353, 2164, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 512, 755, 7542, 4163, 2164, 11, 3146, 21101, 997, 262, 4304, 7968, 28803, 2038, 14781, 262, 16602, 54114, 446, 285, 11173, 498, 3082, 340, 262, 16602, 54114, 446, 2309, 498, 2290, 340, 262, 471, 3072, 43254, 11, 353, 2164, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
celiao/rtsimple
rtsimple/movies.py
Movies.cast
def cast(self, **kwargs): """Get the cast for a movie specified by id from the API. Returns: A dict respresentation of the JSON returned from the API. """ path = self._get_id_path('cast') response = self._GET(path, kwargs) self._set_attrs_to_values(response) return response
python
def cast(self, **kwargs): """Get the cast for a movie specified by id from the API. Returns: A dict respresentation of the JSON returned from the API. """ path = self._get_id_path('cast') response = self._GET(path, kwargs) self._set_attrs_to_values(response) return response
[ "def", "cast", "(", "self", ",", "*", "*", "kwargs", ")", ":", "path", "=", "self", ".", "_get_id_path", "(", "'cast'", ")", "response", "=", "self", ".", "_GET", "(", "path", ",", "kwargs", ")", "self", ".", "_set_attrs_to_values", "(", "response", ")", "return", "response" ]
Get the cast for a movie specified by id from the API. Returns: A dict respresentation of the JSON returned from the API.
[ "Get", "the", "cast", "for", "a", "movie", "specified", "by", "id", "from", "the", "API", "." ]
train
https://github.com/celiao/rtsimple/blob/91f82cbd61a745bbe3a2cca54dfbb6b0ac123b86/rtsimple/movies.py#L60-L70
<|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 cast for a movie specified by id from the API. Returns: A dict respresentation of the JSON returned from the API. ### Response: def cast(self, **kwargs): """Get the cast for a movie specified by id from the API. Returns: A dict respresentation of the JSON returned from the API. """ path = self._get_id_path('cast') response = self._GET(path, kwargs) self._set_attrs_to_values(response) return 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, 1991, 279, 6445, 369, 264, 5818, 5300, 555, 887, 505, 279, 5446, 382, 286, 5295, 512, 692, 362, 6587, 9216, 13898, 315, 279, 4823, 6052, 505, 279, 5446, 382, 14711, 6075, 512, 755, 6445, 1214, 11, 3146, 9872, 997, 286, 4304, 1991, 279, 6445, 369, 264, 5818, 5300, 555, 887, 505, 279, 5446, 382, 286, 5295, 512, 692, 362, 6587, 9216, 13898, 315, 279, 4823, 6052, 505, 279, 5446, 627, 286, 3270, 286, 1853, 284, 659, 1462, 456, 851, 2703, 493, 3914, 4713, 286, 2077, 284, 659, 1462, 3891, 5698, 11, 16901, 340, 286, 659, 1462, 751, 40678, 2401, 9324, 5802, 340, 286, 471, 2077, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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 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, 6445, 369, 264, 5818, 5300, 555, 887, 505, 279, 5446, 382, 286, 5295, 512, 692, 362, 6587, 9216, 13898, 315, 279, 4823, 6052, 505, 279, 5446, 382, 14711, 6075, 512, 755, 6445, 1214, 11, 3146, 9872, 997, 286, 4304, 1991, 279, 6445, 369, 264, 5818, 5300, 555, 887, 505, 279, 5446, 382, 286, 5295, 512, 692, 362, 6587, 9216, 13898, 315, 279, 4823, 6052, 505, 279, 5446, 627, 286, 3270, 286, 1853, 284, 659, 1462, 456, 851, 2703, 493, 3914, 4713, 286, 2077, 284, 659, 1462, 3891, 5698, 11, 16901, 340, 286, 659, 1462, 751, 40678, 2401, 9324, 5802, 340, 286, 471, 2077, 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 ]
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.leaf
def leaf(self, node, elem, module, path): """Create a sample leaf element.""" if node.i_default is None: nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: nel.append(etree.Comment( " type: %s " % node.search_one("type").arg)) elif self.defaults: nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return nel.text = str(node.i_default_str)
python
def leaf(self, node, elem, module, path): """Create a sample leaf element.""" if node.i_default is None: nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: nel.append(etree.Comment( " type: %s " % node.search_one("type").arg)) elif self.defaults: nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return nel.text = str(node.i_default_str)
[ "def", "leaf", "(", "self", ",", "node", ",", "elem", ",", "module", ",", "path", ")", ":", "if", "node", ".", "i_default", "is", "None", ":", "nel", ",", "newm", ",", "path", "=", "self", ".", "sample_element", "(", "node", ",", "elem", ",", "module", ",", "path", ")", "if", "path", "is", "None", ":", "return", "if", "self", ".", "annots", ":", "nel", ".", "append", "(", "etree", ".", "Comment", "(", "\" type: %s \"", "%", "node", ".", "search_one", "(", "\"type\"", ")", ".", "arg", ")", ")", "elif", "self", ".", "defaults", ":", "nel", ",", "newm", ",", "path", "=", "self", ".", "sample_element", "(", "node", ",", "elem", ",", "module", ",", "path", ")", "if", "path", "is", "None", ":", "return", "nel", ".", "text", "=", "str", "(", "node", ".", "i_default_str", ")" ]
Create a sample leaf element.
[ "Create", "a", "sample", "leaf", "element", "." ]
train
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L153-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: Create a sample leaf element. ### Response: def leaf(self, node, elem, module, path): """Create a sample leaf element.""" if node.i_default is None: nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: nel.append(etree.Comment( " type: %s " % node.search_one("type").arg)) elif self.defaults: nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return nel.text = str(node.i_default_str) <|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, 6205, 16312, 2449, 382, 14711, 6075, 512, 755, 16312, 1214, 11, 2494, 11, 12012, 11, 4793, 11, 1853, 997, 286, 4304, 4110, 264, 6205, 16312, 2449, 14781, 286, 422, 2494, 8777, 10198, 374, 2290, 512, 310, 25334, 11, 502, 76, 11, 1853, 284, 659, 24825, 8053, 7103, 11, 12012, 11, 4793, 11, 1853, 340, 310, 422, 1853, 374, 2290, 512, 394, 471, 198, 310, 422, 659, 13, 1036, 2469, 512, 394, 25334, 2102, 77322, 770, 57830, 1021, 504, 330, 955, 25, 1034, 82, 330, 1034, 2494, 9472, 11929, 446, 1337, 1865, 867, 1192, 286, 4508, 659, 45044, 512, 310, 25334, 11, 502, 76, 11, 1853, 284, 659, 24825, 8053, 7103, 11, 12012, 11, 4793, 11, 1853, 340, 310, 422, 1853, 374, 2290, 512, 394, 471, 198, 310, 25334, 2858, 284, 610, 7103, 8777, 10198, 2966, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 6205, 16312, 2449, 382, 14711, 6075, 512, 755, 16312, 1214, 11, 2494, 11, 12012, 11, 4793, 11, 1853, 997, 286, 4304, 4110, 264, 6205, 16312, 2449, 14781, 286, 422, 2494, 8777, 10198, 374, 2290, 512, 310, 25334, 11, 502, 76, 11, 1853, 284, 659, 24825, 8053, 7103, 11, 12012, 11, 4793, 11, 1853, 340, 310, 422, 1853, 374, 2290, 512, 394, 471, 198, 310, 422, 659, 13, 1036, 2469, 512, 394, 25334, 2102, 77322, 770, 57830, 1021, 504, 330, 955, 25, 1034, 82, 330, 1034, 2494, 9472, 11929, 446, 1337, 1865, 867, 1192, 286, 4508, 659, 45044, 512, 310, 25334, 11, 502, 76, 11, 1853, 284, 659, 24825, 8053, 7103, 11, 12012, 11, 4793, 11, 1853, 340, 310, 422, 1853, 374, 2290, 512, 394, 471, 198, 310, 25334, 2858, 284, 610, 7103, 8777, 10198, 2966, 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 ]
gabstopper/smc-python
smc/core/collection.py
PhysicalInterfaceCollection.add_layer3_vlan_interface
def add_layer3_vlan_interface(self, interface_id, vlan_id, address=None, network_value=None, virtual_mapping=None, virtual_resource_name=None, zone_ref=None, comment=None, **kw): """ Add a Layer 3 VLAN interface. Optionally specify an address and network if assigning an IP to the VLAN. This method will also assign an IP address to an existing VLAN, or add an additional address to an existing VLAN. This method may commonly be used on a Master Engine to create VLANs for virtual firewall engines. Example of creating a VLAN and passing kwargs to define a DHCP server service on the VLAN interface:: engine = Engine('engine1') engine.physical_interface.add_layer3_vlan_interface(interface_id=20, vlan_id=20, address='20.20.20.20', network_value='20.20.20.0/24', comment='foocomment', dhcp_server_on_interface={ 'default_gateway': '20.20.20.1', 'default_lease_time': 7200, 'dhcp_address_range': '20.20.20.101-20.20.20.120', 'dhcp_range_per_node': [], 'primary_dns_server': '8.8.8.8'}) :param str,int interface_id: interface identifier :param int vlan_id: vlan identifier :param str address: optional IP address to assign to VLAN :param str network_value: network cidr if address is specified. In format: 10.10.10.0/24. :param str zone_ref: zone to use, by name, href, or Zone :param str comment: optional comment for VLAN level of interface :param int virtual_mapping: virtual engine mapping id See :class:`smc.core.engine.VirtualResource.vfw_id` :param str virtual_resource_name: name of virtual resource See :class:`smc.core.engine.VirtualResource.name` :param dict kw: keyword arguments are passed to top level of VLAN interface, not the base level physical interface. This is useful if you want to pass in a configuration that enables the DHCP server on a VLAN for example. :raises EngineCommandFailed: failure creating interface :return: None """ interfaces = {'nodes': [{'address': address, 'network_value': network_value}] if address and network_value else [], 'zone_ref': zone_ref, 'virtual_mapping': virtual_mapping, 'virtual_resource_name': virtual_resource_name, 'comment': comment} interfaces.update(**kw) _interface = {'interface_id': interface_id, 'interfaces': [interfaces]} if 'single_fw' in self._engine.type: # L2FW / IPS _interface.update(interface='single_node_interface') try: interface = self._engine.interface.get(interface_id) vlan = interface.vlan_interface.get(vlan_id) # Interface exists, so we need to update but check if VLAN already exists if vlan is None: interfaces.update(vlan_id=vlan_id) interface._add_interface(**_interface) else: _interface.update(interface_id='{}.{}'.format(interface_id, vlan_id)) vlan._add_interface(**_interface) return interface.update() except InterfaceNotFound: interfaces.update(vlan_id=vlan_id) interface = Layer3PhysicalInterface(**_interface) return self._engine.add_interface(interface)
python
def add_layer3_vlan_interface(self, interface_id, vlan_id, address=None, network_value=None, virtual_mapping=None, virtual_resource_name=None, zone_ref=None, comment=None, **kw): """ Add a Layer 3 VLAN interface. Optionally specify an address and network if assigning an IP to the VLAN. This method will also assign an IP address to an existing VLAN, or add an additional address to an existing VLAN. This method may commonly be used on a Master Engine to create VLANs for virtual firewall engines. Example of creating a VLAN and passing kwargs to define a DHCP server service on the VLAN interface:: engine = Engine('engine1') engine.physical_interface.add_layer3_vlan_interface(interface_id=20, vlan_id=20, address='20.20.20.20', network_value='20.20.20.0/24', comment='foocomment', dhcp_server_on_interface={ 'default_gateway': '20.20.20.1', 'default_lease_time': 7200, 'dhcp_address_range': '20.20.20.101-20.20.20.120', 'dhcp_range_per_node': [], 'primary_dns_server': '8.8.8.8'}) :param str,int interface_id: interface identifier :param int vlan_id: vlan identifier :param str address: optional IP address to assign to VLAN :param str network_value: network cidr if address is specified. In format: 10.10.10.0/24. :param str zone_ref: zone to use, by name, href, or Zone :param str comment: optional comment for VLAN level of interface :param int virtual_mapping: virtual engine mapping id See :class:`smc.core.engine.VirtualResource.vfw_id` :param str virtual_resource_name: name of virtual resource See :class:`smc.core.engine.VirtualResource.name` :param dict kw: keyword arguments are passed to top level of VLAN interface, not the base level physical interface. This is useful if you want to pass in a configuration that enables the DHCP server on a VLAN for example. :raises EngineCommandFailed: failure creating interface :return: None """ interfaces = {'nodes': [{'address': address, 'network_value': network_value}] if address and network_value else [], 'zone_ref': zone_ref, 'virtual_mapping': virtual_mapping, 'virtual_resource_name': virtual_resource_name, 'comment': comment} interfaces.update(**kw) _interface = {'interface_id': interface_id, 'interfaces': [interfaces]} if 'single_fw' in self._engine.type: # L2FW / IPS _interface.update(interface='single_node_interface') try: interface = self._engine.interface.get(interface_id) vlan = interface.vlan_interface.get(vlan_id) # Interface exists, so we need to update but check if VLAN already exists if vlan is None: interfaces.update(vlan_id=vlan_id) interface._add_interface(**_interface) else: _interface.update(interface_id='{}.{}'.format(interface_id, vlan_id)) vlan._add_interface(**_interface) return interface.update() except InterfaceNotFound: interfaces.update(vlan_id=vlan_id) interface = Layer3PhysicalInterface(**_interface) return self._engine.add_interface(interface)
[ "def", "add_layer3_vlan_interface", "(", "self", ",", "interface_id", ",", "vlan_id", ",", "address", "=", "None", ",", "network_value", "=", "None", ",", "virtual_mapping", "=", "None", ",", "virtual_resource_name", "=", "None", ",", "zone_ref", "=", "None", ",", "comment", "=", "None", ",", "*", "*", "kw", ")", ":", "interfaces", "=", "{", "'nodes'", ":", "[", "{", "'address'", ":", "address", ",", "'network_value'", ":", "network_value", "}", "]", "if", "address", "and", "network_value", "else", "[", "]", ",", "'zone_ref'", ":", "zone_ref", ",", "'virtual_mapping'", ":", "virtual_mapping", ",", "'virtual_resource_name'", ":", "virtual_resource_name", ",", "'comment'", ":", "comment", "}", "interfaces", ".", "update", "(", "*", "*", "kw", ")", "_interface", "=", "{", "'interface_id'", ":", "interface_id", ",", "'interfaces'", ":", "[", "interfaces", "]", "}", "if", "'single_fw'", "in", "self", ".", "_engine", ".", "type", ":", "# L2FW / IPS", "_interface", ".", "update", "(", "interface", "=", "'single_node_interface'", ")", "try", ":", "interface", "=", "self", ".", "_engine", ".", "interface", ".", "get", "(", "interface_id", ")", "vlan", "=", "interface", ".", "vlan_interface", ".", "get", "(", "vlan_id", ")", "# Interface exists, so we need to update but check if VLAN already exists", "if", "vlan", "is", "None", ":", "interfaces", ".", "update", "(", "vlan_id", "=", "vlan_id", ")", "interface", ".", "_add_interface", "(", "*", "*", "_interface", ")", "else", ":", "_interface", ".", "update", "(", "interface_id", "=", "'{}.{}'", ".", "format", "(", "interface_id", ",", "vlan_id", ")", ")", "vlan", ".", "_add_interface", "(", "*", "*", "_interface", ")", "return", "interface", ".", "update", "(", ")", "except", "InterfaceNotFound", ":", "interfaces", ".", "update", "(", "vlan_id", "=", "vlan_id", ")", "interface", "=", "Layer3PhysicalInterface", "(", "*", "*", "_interface", ")", "return", "self", ".", "_engine", ".", "add_interface", "(", "interface", ")" ]
Add a Layer 3 VLAN interface. Optionally specify an address and network if assigning an IP to the VLAN. This method will also assign an IP address to an existing VLAN, or add an additional address to an existing VLAN. This method may commonly be used on a Master Engine to create VLANs for virtual firewall engines. Example of creating a VLAN and passing kwargs to define a DHCP server service on the VLAN interface:: engine = Engine('engine1') engine.physical_interface.add_layer3_vlan_interface(interface_id=20, vlan_id=20, address='20.20.20.20', network_value='20.20.20.0/24', comment='foocomment', dhcp_server_on_interface={ 'default_gateway': '20.20.20.1', 'default_lease_time': 7200, 'dhcp_address_range': '20.20.20.101-20.20.20.120', 'dhcp_range_per_node': [], 'primary_dns_server': '8.8.8.8'}) :param str,int interface_id: interface identifier :param int vlan_id: vlan identifier :param str address: optional IP address to assign to VLAN :param str network_value: network cidr if address is specified. In format: 10.10.10.0/24. :param str zone_ref: zone to use, by name, href, or Zone :param str comment: optional comment for VLAN level of interface :param int virtual_mapping: virtual engine mapping id See :class:`smc.core.engine.VirtualResource.vfw_id` :param str virtual_resource_name: name of virtual resource See :class:`smc.core.engine.VirtualResource.name` :param dict kw: keyword arguments are passed to top level of VLAN interface, not the base level physical interface. This is useful if you want to pass in a configuration that enables the DHCP server on a VLAN for example. :raises EngineCommandFailed: failure creating interface :return: None
[ "Add", "a", "Layer", "3", "VLAN", "interface", ".", "Optionally", "specify", "an", "address", "and", "network", "if", "assigning", "an", "IP", "to", "the", "VLAN", ".", "This", "method", "will", "also", "assign", "an", "IP", "address", "to", "an", "existing", "VLAN", "or", "add", "an", "additional", "address", "to", "an", "existing", "VLAN", ".", "This", "method", "may", "commonly", "be", "used", "on", "a", "Master", "Engine", "to", "create", "VLANs", "for", "virtual", "firewall", "engines", ".", "Example", "of", "creating", "a", "VLAN", "and", "passing", "kwargs", "to", "define", "a", "DHCP", "server", "service", "on", "the", "VLAN", "interface", "::", "engine", "=", "Engine", "(", "engine1", ")", "engine", ".", "physical_interface", ".", "add_layer3_vlan_interface", "(", "interface_id", "=", "20", "vlan_id", "=", "20", "address", "=", "20", ".", "20", ".", "20", ".", "20", "network_value", "=", "20", ".", "20", ".", "20", ".", "0", "/", "24", "comment", "=", "foocomment", "dhcp_server_on_interface", "=", "{", "default_gateway", ":", "20", ".", "20", ".", "20", ".", "1", "default_lease_time", ":", "7200", "dhcp_address_range", ":", "20", ".", "20", ".", "20", ".", "101", "-", "20", ".", "20", ".", "20", ".", "120", "dhcp_range_per_node", ":", "[]", "primary_dns_server", ":", "8", ".", "8", ".", "8", ".", "8", "}", ")", ":", "param", "str", "int", "interface_id", ":", "interface", "identifier", ":", "param", "int", "vlan_id", ":", "vlan", "identifier", ":", "param", "str", "address", ":", "optional", "IP", "address", "to", "assign", "to", "VLAN", ":", "param", "str", "network_value", ":", "network", "cidr", "if", "address", "is", "specified", ".", "In", "format", ":", "10", ".", "10", ".", "10", ".", "0", "/", "24", ".", ":", "param", "str", "zone_ref", ":", "zone", "to", "use", "by", "name", "href", "or", "Zone", ":", "param", "str", "comment", ":", "optional", "comment", "for", "VLAN", "level", "of", "interface", ":", "param", "int", "virtual_mapping", ":", "virtual", "engine", "mapping", "id", "See", ":", "class", ":", "smc", ".", "core", ".", "engine", ".", "VirtualResource", ".", "vfw_id", ":", "param", "str", "virtual_resource_name", ":", "name", "of", "virtual", "resource", "See", ":", "class", ":", "smc", ".", "core", ".", "engine", ".", "VirtualResource", ".", "name", ":", "param", "dict", "kw", ":", "keyword", "arguments", "are", "passed", "to", "top", "level", "of", "VLAN", "interface", "not", "the", "base", "level", "physical", "interface", ".", "This", "is", "useful", "if", "you", "want", "to", "pass", "in", "a", "configuration", "that", "enables", "the", "DHCP", "server", "on", "a", "VLAN", "for", "example", ".", ":", "raises", "EngineCommandFailed", ":", "failure", "creating", "interface", ":", "return", ":", "None" ]
train
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/collection.py#L467-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: Add a Layer 3 VLAN interface. Optionally specify an address and network if assigning an IP to the VLAN. This method will also assign an IP address to an existing VLAN, or add an additional address to an existing VLAN. This method may commonly be used on a Master Engine to create VLANs for virtual firewall engines. Example of creating a VLAN and passing kwargs to define a DHCP server service on the VLAN interface:: engine = Engine('engine1') engine.physical_interface.add_layer3_vlan_interface(interface_id=20, vlan_id=20, address='20.20.20.20', network_value='20.20.20.0/24', comment='foocomment', dhcp_server_on_interface={ 'default_gateway': '20.20.20.1', 'default_lease_time': 7200, 'dhcp_address_range': '20.20.20.101-20.20.20.120', 'dhcp_range_per_node': [], 'primary_dns_server': '8.8.8.8'}) :param str,int interface_id: interface identifier :param int vlan_id: vlan identifier :param str address: optional IP address to assign to VLAN :param str network_value: network cidr if address is specified. In format: 10.10.10.0/24. :param str zone_ref: zone to use, by name, href, or Zone :param str comment: optional comment for VLAN level of interface :param int virtual_mapping: virtual engine mapping id See :class:`smc.core.engine.VirtualResource.vfw_id` :param str virtual_resource_name: name of virtual resource See :class:`smc.core.engine.VirtualResource.name` :param dict kw: keyword arguments are passed to top level of VLAN interface, not the base level physical interface. This is useful if you want to pass in a configuration that enables the DHCP server on a VLAN for example. :raises EngineCommandFailed: failure creating interface :return: None ### Response: def add_layer3_vlan_interface(self, interface_id, vlan_id, address=None, network_value=None, virtual_mapping=None, virtual_resource_name=None, zone_ref=None, comment=None, **kw): """ Add a Layer 3 VLAN interface. Optionally specify an address and network if assigning an IP to the VLAN. This method will also assign an IP address to an existing VLAN, or add an additional address to an existing VLAN. This method may commonly be used on a Master Engine to create VLANs for virtual firewall engines. Example of creating a VLAN and passing kwargs to define a DHCP server service on the VLAN interface:: engine = Engine('engine1') engine.physical_interface.add_layer3_vlan_interface(interface_id=20, vlan_id=20, address='20.20.20.20', network_value='20.20.20.0/24', comment='foocomment', dhcp_server_on_interface={ 'default_gateway': '20.20.20.1', 'default_lease_time': 7200, 'dhcp_address_range': '20.20.20.101-20.20.20.120', 'dhcp_range_per_node': [], 'primary_dns_server': '8.8.8.8'}) :param str,int interface_id: interface identifier :param int vlan_id: vlan identifier :param str address: optional IP address to assign to VLAN :param str network_value: network cidr if address is specified. In format: 10.10.10.0/24. :param str zone_ref: zone to use, by name, href, or Zone :param str comment: optional comment for VLAN level of interface :param int virtual_mapping: virtual engine mapping id See :class:`smc.core.engine.VirtualResource.vfw_id` :param str virtual_resource_name: name of virtual resource See :class:`smc.core.engine.VirtualResource.name` :param dict kw: keyword arguments are passed to top level of VLAN interface, not the base level physical interface. This is useful if you want to pass in a configuration that enables the DHCP server on a VLAN for example. :raises EngineCommandFailed: failure creating interface :return: None """ interfaces = {'nodes': [{'address': address, 'network_value': network_value}] if address and network_value else [], 'zone_ref': zone_ref, 'virtual_mapping': virtual_mapping, 'virtual_resource_name': virtual_resource_name, 'comment': comment} interfaces.update(**kw) _interface = {'interface_id': interface_id, 'interfaces': [interfaces]} if 'single_fw' in self._engine.type: # L2FW / IPS _interface.update(interface='single_node_interface') try: interface = self._engine.interface.get(interface_id) vlan = interface.vlan_interface.get(vlan_id) # Interface exists, so we need to update but check if VLAN already exists if vlan is None: interfaces.update(vlan_id=vlan_id) interface._add_interface(**_interface) else: _interface.update(interface_id='{}.{}'.format(interface_id, vlan_id)) vlan._add_interface(**_interface) return interface.update() except InterfaceNotFound: interfaces.update(vlan_id=vlan_id) interface = Layer3PhysicalInterface(**_interface) return self._engine.add_interface(interface) <|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, 23570, 220, 18, 76980, 3834, 13, 97295, 14158, 459, 2686, 323, 4009, 422, 198, 286, 61853, 459, 6933, 311, 279, 76980, 13, 1115, 1749, 690, 1101, 9993, 459, 6933, 2686, 311, 198, 286, 459, 6484, 76980, 11, 477, 923, 459, 5217, 2686, 311, 459, 6484, 76980, 13, 1115, 198, 286, 1749, 1253, 17037, 387, 1511, 389, 264, 11060, 8364, 311, 1893, 76980, 82, 369, 4200, 198, 286, 50977, 21787, 627, 1827, 286, 13688, 315, 6968, 264, 76980, 323, 12579, 16901, 311, 7124, 264, 58687, 3622, 198, 286, 2532, 389, 279, 76980, 3834, 50677, 1827, 310, 4817, 284, 8364, 493, 8680, 16, 1329, 310, 4817, 2180, 19506, 21188, 1388, 12969, 18, 72396, 21188, 76587, 851, 28, 508, 11, 66520, 851, 28, 508, 345, 394, 2686, 1151, 508, 13, 508, 13, 508, 13, 508, 518, 4009, 3220, 1151, 508, 13, 508, 13, 508, 13, 15, 14, 1187, 518, 4068, 1151, 831, 12255, 479, 756, 394, 86887, 12284, 4570, 21188, 18013, 504, 364, 2309, 65149, 1232, 364, 508, 13, 508, 13, 508, 13, 16, 756, 504, 364, 2309, 62, 1655, 3084, 1232, 220, 13104, 15, 345, 504, 364, 97320, 6886, 9897, 1232, 364, 508, 13, 508, 13, 508, 13, 4645, 12, 508, 13, 508, 13, 508, 13, 4364, 756, 504, 364, 97320, 9897, 5796, 5194, 1232, 10450, 504, 364, 6682, 72225, 12284, 1232, 364, 23, 13, 23, 13, 23, 13, 23, 27482, 1827, 286, 551, 913, 610, 10072, 3834, 851, 25, 3834, 13110, 198, 286, 551, 913, 528, 66520, 851, 25, 66520, 13110, 198, 286, 551, 913, 610, 2686, 25, 10309, 6933, 2686, 311, 9993, 311, 76980, 198, 286, 551, 913, 610, 4009, 3220, 25, 4009, 33241, 81, 422, 2686, 374, 5300, 13, 763, 198, 310, 3645, 25, 220, 605, 13, 605, 13, 605, 13, 15, 14, 1187, 627, 286, 551, 913, 610, 10353, 7949, 25, 10353, 311, 1005, 11, 555, 836, 11, 1839, 11, 477, 22967, 198, 286, 551, 913, 610, 4068, 25, 10309, 4068, 369, 76980, 2237, 315, 3834, 198, 286, 551, 913, 528, 4200, 28028, 25, 4200, 4817, 13021, 887, 198, 2342, 3580, 551, 1058, 19258, 3647, 66, 4976, 25421, 97079, 4888, 3211, 21206, 851, 4077, 286, 551, 913, 610, 4200, 18446, 1292, 25, 836, 315, 4200, 5211, 198, 2342, 3580, 551, 1058, 19258, 3647, 66, 4976, 25421, 97079, 4888, 2710, 4077, 286, 551, 913, 6587, 30625, 25, 16570, 6105, 527, 5946, 311, 1948, 2237, 315, 76980, 3834, 345, 310, 539, 279, 2385, 2237, 7106, 3834, 13, 1115, 374, 5505, 422, 499, 1390, 311, 198, 310, 1522, 304, 264, 6683, 430, 20682, 279, 58687, 3622, 389, 264, 76980, 369, 3187, 627, 286, 551, 33371, 8364, 4153, 9595, 25, 8060, 6968, 3834, 198, 286, 551, 693, 25, 2290, 271, 14711, 6075, 512, 755, 923, 12969, 18, 72396, 21188, 1214, 11, 3834, 851, 11, 66520, 851, 11, 2686, 5980, 345, 286, 4009, 3220 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 264, 23570, 220, 18, 76980, 3834, 13, 97295, 14158, 459, 2686, 323, 4009, 422, 198, 286, 61853, 459, 6933, 311, 279, 76980, 13, 1115, 1749, 690, 1101, 9993, 459, 6933, 2686, 311, 198, 286, 459, 6484, 76980, 11, 477, 923, 459, 5217, 2686, 311, 459, 6484, 76980, 13, 1115, 198, 286, 1749, 1253, 17037, 387, 1511, 389, 264, 11060, 8364, 311, 1893, 76980, 82, 369, 4200, 198, 286, 50977, 21787, 627, 1827, 286, 13688, 315, 6968, 264, 76980, 323, 12579, 16901, 311, 7124, 264, 58687, 3622, 198, 286, 2532, 389, 279, 76980, 3834, 50677, 1827, 310, 4817, 284, 8364, 493, 8680, 16, 1329, 310, 4817, 2180, 19506, 21188, 1388, 12969, 18, 72396, 21188, 76587, 851, 28, 508, 11, 66520, 851, 28, 508, 345, 394, 2686, 1151, 508, 13, 508, 13, 508, 13, 508, 518, 4009, 3220, 1151, 508, 13, 508, 13, 508, 13, 15, 14, 1187, 518, 4068, 1151, 831, 12255, 479, 756, 394, 86887, 12284, 4570, 21188, 18013, 504, 364, 2309, 65149, 1232, 364, 508, 13, 508, 13, 508, 13, 16, 756, 504, 364, 2309, 62, 1655, 3084, 1232, 220, 13104, 15, 345, 504, 364, 97320, 6886, 9897, 1232, 364, 508, 13, 508, 13, 508, 13, 4645, 12, 508, 13, 508, 13, 508, 13, 4364, 756, 504, 364, 97320, 9897, 5796, 5194, 1232, 10450, 504, 364, 6682, 72225, 12284, 1232, 364, 23, 13, 23, 13, 23, 13, 23, 27482, 1827, 286, 551, 913, 610, 10072, 3834, 851, 25, 3834, 13110, 198, 286, 551, 913, 528, 66520, 851, 25, 66520, 13110, 198, 286, 551, 913, 610, 2686, 25, 10309, 6933, 2686, 311, 9993, 311, 76980, 198, 286, 551, 913, 610, 4009, 3220, 25, 4009, 33241, 81, 422, 2686, 374, 5300, 13, 763, 198, 310, 3645, 25, 220, 605, 13, 605, 13, 605, 13, 15, 14, 1187, 627, 286, 551, 913, 610, 10353, 7949, 25, 10353, 311, 1005, 11, 555, 836, 11, 1839, 11, 477, 22967, 198, 286, 551, 913, 610, 4068, 25, 10309, 4068, 369, 76980, 2237, 315, 3834, 198, 286, 551, 913, 528, 4200, 28028, 25, 4200, 4817, 13021, 887, 198, 2342, 3580, 551, 1058, 19258, 3647, 66, 4976, 25421, 97079, 4888, 3211, 21206, 851, 4077, 286, 551, 913, 610, 4200, 18446, 1292, 25, 836, 315, 4200, 5211, 198, 2342, 3580, 551, 1058, 19258, 3647, 66, 4976, 25421, 97079, 4888, 2710, 4077, 286, 551, 913, 6587, 30625, 25, 16570, 6105, 527, 5946, 311, 1948, 2237, 315, 76980, 3834, 345, 310, 539, 279, 2385, 2237, 7106, 3834, 13, 1115, 374, 5505, 422, 499, 1390, 311, 198, 310, 1522, 304, 264, 6683, 430, 20682, 279, 58687, 3622, 389, 264, 76980, 369, 3187, 627, 286, 551, 33371, 8364, 4153, 9595, 25, 8060, 6968, 3834, 198, 286, 551, 693, 25, 2290, 271, 14711, 6075, 512, 755, 923, 12969, 18, 72396, 21188, 1214, 11, 3834, 851, 11, 66520, 851, 11, 2686, 5980, 345, 286, 4009, 3220 ]
jjgomera/iapws
iapws/iapws95.py
MEoS._phir
def _phir(self, tau, delta): """Residual contribution to the free Helmholtz energy Parameters ---------- tau : float Inverse reduced temperature Tc/T, [-] delta : float Reduced density rho/rhoc, [-] Returns ------- prop : dict Dictionary with residual adimensional helmholtz energy and deriv: * fir * firt: ∂fir/∂τ|δ,x * fird: ∂fir/∂δ|τ,x * firtt: ∂²fir/∂τ²|δ,x * firdt: ∂²fir/∂τ∂δ|x * firdd: ∂²fir/∂δ²|τ,x References ---------- IAPWS, Revised Release on the IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use, September 2016, Table 5 http://www.iapws.org/relguide/IAPWS-95.html """ fir = fird = firdd = firt = firtt = firdt = 0 # Polinomial terms nr1 = self._constants.get("nr1", []) d1 = self._constants.get("d1", []) t1 = self._constants.get("t1", []) for n, d, t in zip(nr1, d1, t1): fir += n*delta**d*tau**t fird += n*d*delta**(d-1)*tau**t firdd += n*d*(d-1)*delta**(d-2)*tau**t firt += n*t*delta**d*tau**(t-1) firtt += n*t*(t-1)*delta**d*tau**(t-2) firdt += n*t*d*delta**(d-1)*tau**(t-1) # Exponential terms nr2 = self._constants.get("nr2", []) d2 = self._constants.get("d2", []) g2 = self._constants.get("gamma2", []) t2 = self._constants.get("t2", []) c2 = self._constants.get("c2", []) for n, d, g, t, c in zip(nr2, d2, g2, t2, c2): fir += n*delta**d*tau**t*exp(-g*delta**c) fird += n*exp(-g*delta**c)*delta**(d-1)*tau**t*(d-g*c*delta**c) firdd += n*exp(-g*delta**c)*delta**(d-2)*tau**t * \ ((d-g*c*delta**c)*(d-1-g*c*delta**c)-g**2*c**2*delta**c) firt += n*t*delta**d*tau**(t-1)*exp(-g*delta**c) firtt += n*t*(t-1)*delta**d*tau**(t-2)*exp(-g*delta**c) firdt += n*t*delta**(d-1)*tau**(t-1)*(d-g*c*delta**c)*exp( -g*delta**c) # Gaussian terms nr3 = self._constants.get("nr3", []) d3 = self._constants.get("d3", []) t3 = self._constants.get("t3", []) a3 = self._constants.get("alfa3", []) e3 = self._constants.get("epsilon3", []) b3 = self._constants.get("beta3", []) g3 = self._constants.get("gamma3", []) for n, d, t, a, e, b, g in zip(nr3, d3, t3, a3, e3, b3, g3): fir += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2) fird += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( d/delta-2*a*(delta-e)) firdd += n*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( -2*a*delta**d + 4*a**2*delta**d*(delta-e)**2 - 4*d*a*delta**(d-1)*(delta-e) + d*(d-1)*delta**(d-2)) firt += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( t/tau-2*b*(tau-g)) firtt += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( (t/tau-2*b*(tau-g))**2-t/tau**2-2*b) firdt += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( t/tau-2*b*(tau-g))*(d/delta-2*a*(delta-e)) # Non analitic terms nr4 = self._constants.get("nr4", []) a4 = self._constants.get("a4", []) b4 = self._constants.get("b4", []) Ai = self._constants.get("A", []) Bi = self._constants.get("B", []) Ci = self._constants.get("C", []) Di = self._constants.get("D", []) bt4 = self._constants.get("beta4", []) for n, a, b, A, B, C, D, bt in zip(nr4, a4, b4, Ai, Bi, Ci, Di, bt4): Tita = (1-tau)+A*((delta-1)**2)**(0.5/bt) F = exp(-C*(delta-1)**2-D*(tau-1)**2) Fd = -2*C*F*(delta-1) Fdd = 2*C*F*(2*C*(delta-1)**2-1) Ft = -2*D*F*(tau-1) Ftt = 2*D*F*(2*D*(tau-1)**2-1) Fdt = 4*C*D*F*(delta-1)*(tau-1) Delta = Tita**2+B*((delta-1)**2)**a Deltad = (delta-1)*(A*Tita*2/bt*((delta-1)**2)**(0.5/bt-1) + 2*B*a*((delta-1)**2)**(a-1)) if delta == 1: Deltadd = 0 else: Deltadd = Deltad/(delta-1)+(delta-1)**2*( 4*B*a*(a-1)*((delta-1)**2)**(a-2) + 2*A**2/bt**2*(((delta-1)**2)**(0.5/bt-1))**2 + A*Tita*4/bt*(0.5/bt-1)*((delta-1)**2)**(0.5/bt-2)) DeltaBd = b*Delta**(b-1)*Deltad DeltaBdd = b*(Delta**(b-1)*Deltadd+(b-1)*Delta**(b-2)*Deltad**2) DeltaBt = -2*Tita*b*Delta**(b-1) DeltaBtt = 2*b*Delta**(b-1)+4*Tita**2*b*(b-1)*Delta**(b-2) DeltaBdt = -A*b*2/bt*Delta**(b-1)*(delta-1)*((delta-1)**2)**( 0.5/bt-1)-2*Tita*b*(b-1)*Delta**(b-2)*Deltad fir += n*Delta**b*delta*F fird += n*(Delta**b*(F+delta*Fd)+DeltaBd*delta*F) firdd += n*(Delta**b*(2*Fd+delta*Fdd) + 2*DeltaBd*(F+delta*Fd) + DeltaBdd*delta*F) firt += n*delta*(DeltaBt*F+Delta**b*Ft) firtt += n*delta*(DeltaBtt*F+2*DeltaBt*Ft+Delta**b*Ftt) firdt += n*(Delta**b*(Ft+delta*Fdt)+delta*DeltaBd*Ft + DeltaBt*(F+delta*Fd)+DeltaBdt*delta*F) prop = {} prop["fir"] = fir prop["firt"] = firt prop["firtt"] = firtt prop["fird"] = fird prop["firdd"] = firdd prop["firdt"] = firdt return prop
python
def _phir(self, tau, delta): """Residual contribution to the free Helmholtz energy Parameters ---------- tau : float Inverse reduced temperature Tc/T, [-] delta : float Reduced density rho/rhoc, [-] Returns ------- prop : dict Dictionary with residual adimensional helmholtz energy and deriv: * fir * firt: ∂fir/∂τ|δ,x * fird: ∂fir/∂δ|τ,x * firtt: ∂²fir/∂τ²|δ,x * firdt: ∂²fir/∂τ∂δ|x * firdd: ∂²fir/∂δ²|τ,x References ---------- IAPWS, Revised Release on the IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use, September 2016, Table 5 http://www.iapws.org/relguide/IAPWS-95.html """ fir = fird = firdd = firt = firtt = firdt = 0 # Polinomial terms nr1 = self._constants.get("nr1", []) d1 = self._constants.get("d1", []) t1 = self._constants.get("t1", []) for n, d, t in zip(nr1, d1, t1): fir += n*delta**d*tau**t fird += n*d*delta**(d-1)*tau**t firdd += n*d*(d-1)*delta**(d-2)*tau**t firt += n*t*delta**d*tau**(t-1) firtt += n*t*(t-1)*delta**d*tau**(t-2) firdt += n*t*d*delta**(d-1)*tau**(t-1) # Exponential terms nr2 = self._constants.get("nr2", []) d2 = self._constants.get("d2", []) g2 = self._constants.get("gamma2", []) t2 = self._constants.get("t2", []) c2 = self._constants.get("c2", []) for n, d, g, t, c in zip(nr2, d2, g2, t2, c2): fir += n*delta**d*tau**t*exp(-g*delta**c) fird += n*exp(-g*delta**c)*delta**(d-1)*tau**t*(d-g*c*delta**c) firdd += n*exp(-g*delta**c)*delta**(d-2)*tau**t * \ ((d-g*c*delta**c)*(d-1-g*c*delta**c)-g**2*c**2*delta**c) firt += n*t*delta**d*tau**(t-1)*exp(-g*delta**c) firtt += n*t*(t-1)*delta**d*tau**(t-2)*exp(-g*delta**c) firdt += n*t*delta**(d-1)*tau**(t-1)*(d-g*c*delta**c)*exp( -g*delta**c) # Gaussian terms nr3 = self._constants.get("nr3", []) d3 = self._constants.get("d3", []) t3 = self._constants.get("t3", []) a3 = self._constants.get("alfa3", []) e3 = self._constants.get("epsilon3", []) b3 = self._constants.get("beta3", []) g3 = self._constants.get("gamma3", []) for n, d, t, a, e, b, g in zip(nr3, d3, t3, a3, e3, b3, g3): fir += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2) fird += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( d/delta-2*a*(delta-e)) firdd += n*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( -2*a*delta**d + 4*a**2*delta**d*(delta-e)**2 - 4*d*a*delta**(d-1)*(delta-e) + d*(d-1)*delta**(d-2)) firt += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( t/tau-2*b*(tau-g)) firtt += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( (t/tau-2*b*(tau-g))**2-t/tau**2-2*b) firdt += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( t/tau-2*b*(tau-g))*(d/delta-2*a*(delta-e)) # Non analitic terms nr4 = self._constants.get("nr4", []) a4 = self._constants.get("a4", []) b4 = self._constants.get("b4", []) Ai = self._constants.get("A", []) Bi = self._constants.get("B", []) Ci = self._constants.get("C", []) Di = self._constants.get("D", []) bt4 = self._constants.get("beta4", []) for n, a, b, A, B, C, D, bt in zip(nr4, a4, b4, Ai, Bi, Ci, Di, bt4): Tita = (1-tau)+A*((delta-1)**2)**(0.5/bt) F = exp(-C*(delta-1)**2-D*(tau-1)**2) Fd = -2*C*F*(delta-1) Fdd = 2*C*F*(2*C*(delta-1)**2-1) Ft = -2*D*F*(tau-1) Ftt = 2*D*F*(2*D*(tau-1)**2-1) Fdt = 4*C*D*F*(delta-1)*(tau-1) Delta = Tita**2+B*((delta-1)**2)**a Deltad = (delta-1)*(A*Tita*2/bt*((delta-1)**2)**(0.5/bt-1) + 2*B*a*((delta-1)**2)**(a-1)) if delta == 1: Deltadd = 0 else: Deltadd = Deltad/(delta-1)+(delta-1)**2*( 4*B*a*(a-1)*((delta-1)**2)**(a-2) + 2*A**2/bt**2*(((delta-1)**2)**(0.5/bt-1))**2 + A*Tita*4/bt*(0.5/bt-1)*((delta-1)**2)**(0.5/bt-2)) DeltaBd = b*Delta**(b-1)*Deltad DeltaBdd = b*(Delta**(b-1)*Deltadd+(b-1)*Delta**(b-2)*Deltad**2) DeltaBt = -2*Tita*b*Delta**(b-1) DeltaBtt = 2*b*Delta**(b-1)+4*Tita**2*b*(b-1)*Delta**(b-2) DeltaBdt = -A*b*2/bt*Delta**(b-1)*(delta-1)*((delta-1)**2)**( 0.5/bt-1)-2*Tita*b*(b-1)*Delta**(b-2)*Deltad fir += n*Delta**b*delta*F fird += n*(Delta**b*(F+delta*Fd)+DeltaBd*delta*F) firdd += n*(Delta**b*(2*Fd+delta*Fdd) + 2*DeltaBd*(F+delta*Fd) + DeltaBdd*delta*F) firt += n*delta*(DeltaBt*F+Delta**b*Ft) firtt += n*delta*(DeltaBtt*F+2*DeltaBt*Ft+Delta**b*Ftt) firdt += n*(Delta**b*(Ft+delta*Fdt)+delta*DeltaBd*Ft + DeltaBt*(F+delta*Fd)+DeltaBdt*delta*F) prop = {} prop["fir"] = fir prop["firt"] = firt prop["firtt"] = firtt prop["fird"] = fird prop["firdd"] = firdd prop["firdt"] = firdt return prop
[ "def", "_phir", "(", "self", ",", "tau", ",", "delta", ")", ":", "fir", "=", "fird", "=", "firdd", "=", "firt", "=", "firtt", "=", "firdt", "=", "0", "# Polinomial terms", "nr1", "=", "self", ".", "_constants", ".", "get", "(", "\"nr1\"", ",", "[", "]", ")", "d1", "=", "self", ".", "_constants", ".", "get", "(", "\"d1\"", ",", "[", "]", ")", "t1", "=", "self", ".", "_constants", ".", "get", "(", "\"t1\"", ",", "[", "]", ")", "for", "n", ",", "d", ",", "t", "in", "zip", "(", "nr1", ",", "d1", ",", "t1", ")", ":", "fir", "+=", "n", "*", "delta", "**", "d", "*", "tau", "**", "t", "fird", "+=", "n", "*", "d", "*", "delta", "**", "(", "d", "-", "1", ")", "*", "tau", "**", "t", "firdd", "+=", "n", "*", "d", "*", "(", "d", "-", "1", ")", "*", "delta", "**", "(", "d", "-", "2", ")", "*", "tau", "**", "t", "firt", "+=", "n", "*", "t", "*", "delta", "**", "d", "*", "tau", "**", "(", "t", "-", "1", ")", "firtt", "+=", "n", "*", "t", "*", "(", "t", "-", "1", ")", "*", "delta", "**", "d", "*", "tau", "**", "(", "t", "-", "2", ")", "firdt", "+=", "n", "*", "t", "*", "d", "*", "delta", "**", "(", "d", "-", "1", ")", "*", "tau", "**", "(", "t", "-", "1", ")", "# Exponential terms", "nr2", "=", "self", ".", "_constants", ".", "get", "(", "\"nr2\"", ",", "[", "]", ")", "d2", "=", "self", ".", "_constants", ".", "get", "(", "\"d2\"", ",", "[", "]", ")", "g2", "=", "self", ".", "_constants", ".", "get", "(", "\"gamma2\"", ",", "[", "]", ")", "t2", "=", "self", ".", "_constants", ".", "get", "(", "\"t2\"", ",", "[", "]", ")", "c2", "=", "self", ".", "_constants", ".", "get", "(", "\"c2\"", ",", "[", "]", ")", "for", "n", ",", "d", ",", "g", ",", "t", ",", "c", "in", "zip", "(", "nr2", ",", "d2", ",", "g2", ",", "t2", ",", "c2", ")", ":", "fir", "+=", "n", "*", "delta", "**", "d", "*", "tau", "**", "t", "*", "exp", "(", "-", "g", "*", "delta", "**", "c", ")", "fird", "+=", "n", "*", "exp", "(", "-", "g", "*", "delta", "**", "c", ")", "*", "delta", "**", "(", "d", "-", "1", ")", "*", "tau", "**", "t", "*", "(", "d", "-", "g", "*", "c", "*", "delta", "**", "c", ")", "firdd", "+=", "n", "*", "exp", "(", "-", "g", "*", "delta", "**", "c", ")", "*", "delta", "**", "(", "d", "-", "2", ")", "*", "tau", "**", "t", "*", "(", "(", "d", "-", "g", "*", "c", "*", "delta", "**", "c", ")", "*", "(", "d", "-", "1", "-", "g", "*", "c", "*", "delta", "**", "c", ")", "-", "g", "**", "2", "*", "c", "**", "2", "*", "delta", "**", "c", ")", "firt", "+=", "n", "*", "t", "*", "delta", "**", "d", "*", "tau", "**", "(", "t", "-", "1", ")", "*", "exp", "(", "-", "g", "*", "delta", "**", "c", ")", "firtt", "+=", "n", "*", "t", "*", "(", "t", "-", "1", ")", "*", "delta", "**", "d", "*", "tau", "**", "(", "t", "-", "2", ")", "*", "exp", "(", "-", "g", "*", "delta", "**", "c", ")", "firdt", "+=", "n", "*", "t", "*", "delta", "**", "(", "d", "-", "1", ")", "*", "tau", "**", "(", "t", "-", "1", ")", "*", "(", "d", "-", "g", "*", "c", "*", "delta", "**", "c", ")", "*", "exp", "(", "-", "g", "*", "delta", "**", "c", ")", "# Gaussian terms", "nr3", "=", "self", ".", "_constants", ".", "get", "(", "\"nr3\"", ",", "[", "]", ")", "d3", "=", "self", ".", "_constants", ".", "get", "(", "\"d3\"", ",", "[", "]", ")", "t3", "=", "self", ".", "_constants", ".", "get", "(", "\"t3\"", ",", "[", "]", ")", "a3", "=", "self", ".", "_constants", ".", "get", "(", "\"alfa3\"", ",", "[", "]", ")", "e3", "=", "self", ".", "_constants", ".", "get", "(", "\"epsilon3\"", ",", "[", "]", ")", "b3", "=", "self", ".", "_constants", ".", "get", "(", "\"beta3\"", ",", "[", "]", ")", "g3", "=", "self", ".", "_constants", ".", "get", "(", "\"gamma3\"", ",", "[", "]", ")", "for", "n", ",", "d", ",", "t", ",", "a", ",", "e", ",", "b", ",", "g", "in", "zip", "(", "nr3", ",", "d3", ",", "t3", ",", "a3", ",", "e3", ",", "b3", ",", "g3", ")", ":", "fir", "+=", "n", "*", "delta", "**", "d", "*", "tau", "**", "t", "*", "exp", "(", "-", "a", "*", "(", "delta", "-", "e", ")", "**", "2", "-", "b", "*", "(", "tau", "-", "g", ")", "**", "2", ")", "fird", "+=", "n", "*", "delta", "**", "d", "*", "tau", "**", "t", "*", "exp", "(", "-", "a", "*", "(", "delta", "-", "e", ")", "**", "2", "-", "b", "*", "(", "tau", "-", "g", ")", "**", "2", ")", "*", "(", "d", "/", "delta", "-", "2", "*", "a", "*", "(", "delta", "-", "e", ")", ")", "firdd", "+=", "n", "*", "tau", "**", "t", "*", "exp", "(", "-", "a", "*", "(", "delta", "-", "e", ")", "**", "2", "-", "b", "*", "(", "tau", "-", "g", ")", "**", "2", ")", "*", "(", "-", "2", "*", "a", "*", "delta", "**", "d", "+", "4", "*", "a", "**", "2", "*", "delta", "**", "d", "*", "(", "delta", "-", "e", ")", "**", "2", "-", "4", "*", "d", "*", "a", "*", "delta", "**", "(", "d", "-", "1", ")", "*", "(", "delta", "-", "e", ")", "+", "d", "*", "(", "d", "-", "1", ")", "*", "delta", "**", "(", "d", "-", "2", ")", ")", "firt", "+=", "n", "*", "delta", "**", "d", "*", "tau", "**", "t", "*", "exp", "(", "-", "a", "*", "(", "delta", "-", "e", ")", "**", "2", "-", "b", "*", "(", "tau", "-", "g", ")", "**", "2", ")", "*", "(", "t", "/", "tau", "-", "2", "*", "b", "*", "(", "tau", "-", "g", ")", ")", "firtt", "+=", "n", "*", "delta", "**", "d", "*", "tau", "**", "t", "*", "exp", "(", "-", "a", "*", "(", "delta", "-", "e", ")", "**", "2", "-", "b", "*", "(", "tau", "-", "g", ")", "**", "2", ")", "*", "(", "(", "t", "/", "tau", "-", "2", "*", "b", "*", "(", "tau", "-", "g", ")", ")", "**", "2", "-", "t", "/", "tau", "**", "2", "-", "2", "*", "b", ")", "firdt", "+=", "n", "*", "delta", "**", "d", "*", "tau", "**", "t", "*", "exp", "(", "-", "a", "*", "(", "delta", "-", "e", ")", "**", "2", "-", "b", "*", "(", "tau", "-", "g", ")", "**", "2", ")", "*", "(", "t", "/", "tau", "-", "2", "*", "b", "*", "(", "tau", "-", "g", ")", ")", "*", "(", "d", "/", "delta", "-", "2", "*", "a", "*", "(", "delta", "-", "e", ")", ")", "# Non analitic terms", "nr4", "=", "self", ".", "_constants", ".", "get", "(", "\"nr4\"", ",", "[", "]", ")", "a4", "=", "self", ".", "_constants", ".", "get", "(", "\"a4\"", ",", "[", "]", ")", "b4", "=", "self", ".", "_constants", ".", "get", "(", "\"b4\"", ",", "[", "]", ")", "Ai", "=", "self", ".", "_constants", ".", "get", "(", "\"A\"", ",", "[", "]", ")", "Bi", "=", "self", ".", "_constants", ".", "get", "(", "\"B\"", ",", "[", "]", ")", "Ci", "=", "self", ".", "_constants", ".", "get", "(", "\"C\"", ",", "[", "]", ")", "Di", "=", "self", ".", "_constants", ".", "get", "(", "\"D\"", ",", "[", "]", ")", "bt4", "=", "self", ".", "_constants", ".", "get", "(", "\"beta4\"", ",", "[", "]", ")", "for", "n", ",", "a", ",", "b", ",", "A", ",", "B", ",", "C", ",", "D", ",", "bt", "in", "zip", "(", "nr4", ",", "a4", ",", "b4", ",", "Ai", ",", "Bi", ",", "Ci", ",", "Di", ",", "bt4", ")", ":", "Tita", "=", "(", "1", "-", "tau", ")", "+", "A", "*", "(", "(", "delta", "-", "1", ")", "**", "2", ")", "**", "(", "0.5", "/", "bt", ")", "F", "=", "exp", "(", "-", "C", "*", "(", "delta", "-", "1", ")", "**", "2", "-", "D", "*", "(", "tau", "-", "1", ")", "**", "2", ")", "Fd", "=", "-", "2", "*", "C", "*", "F", "*", "(", "delta", "-", "1", ")", "Fdd", "=", "2", "*", "C", "*", "F", "*", "(", "2", "*", "C", "*", "(", "delta", "-", "1", ")", "**", "2", "-", "1", ")", "Ft", "=", "-", "2", "*", "D", "*", "F", "*", "(", "tau", "-", "1", ")", "Ftt", "=", "2", "*", "D", "*", "F", "*", "(", "2", "*", "D", "*", "(", "tau", "-", "1", ")", "**", "2", "-", "1", ")", "Fdt", "=", "4", "*", "C", "*", "D", "*", "F", "*", "(", "delta", "-", "1", ")", "*", "(", "tau", "-", "1", ")", "Delta", "=", "Tita", "**", "2", "+", "B", "*", "(", "(", "delta", "-", "1", ")", "**", "2", ")", "**", "a", "Deltad", "=", "(", "delta", "-", "1", ")", "*", "(", "A", "*", "Tita", "*", "2", "/", "bt", "*", "(", "(", "delta", "-", "1", ")", "**", "2", ")", "**", "(", "0.5", "/", "bt", "-", "1", ")", "+", "2", "*", "B", "*", "a", "*", "(", "(", "delta", "-", "1", ")", "**", "2", ")", "**", "(", "a", "-", "1", ")", ")", "if", "delta", "==", "1", ":", "Deltadd", "=", "0", "else", ":", "Deltadd", "=", "Deltad", "/", "(", "delta", "-", "1", ")", "+", "(", "delta", "-", "1", ")", "**", "2", "*", "(", "4", "*", "B", "*", "a", "*", "(", "a", "-", "1", ")", "*", "(", "(", "delta", "-", "1", ")", "**", "2", ")", "**", "(", "a", "-", "2", ")", "+", "2", "*", "A", "**", "2", "/", "bt", "**", "2", "*", "(", "(", "(", "delta", "-", "1", ")", "**", "2", ")", "**", "(", "0.5", "/", "bt", "-", "1", ")", ")", "**", "2", "+", "A", "*", "Tita", "*", "4", "/", "bt", "*", "(", "0.5", "/", "bt", "-", "1", ")", "*", "(", "(", "delta", "-", "1", ")", "**", "2", ")", "**", "(", "0.5", "/", "bt", "-", "2", ")", ")", "DeltaBd", "=", "b", "*", "Delta", "**", "(", "b", "-", "1", ")", "*", "Deltad", "DeltaBdd", "=", "b", "*", "(", "Delta", "**", "(", "b", "-", "1", ")", "*", "Deltadd", "+", "(", "b", "-", "1", ")", "*", "Delta", "**", "(", "b", "-", "2", ")", "*", "Deltad", "**", "2", ")", "DeltaBt", "=", "-", "2", "*", "Tita", "*", "b", "*", "Delta", "**", "(", "b", "-", "1", ")", "DeltaBtt", "=", "2", "*", "b", "*", "Delta", "**", "(", "b", "-", "1", ")", "+", "4", "*", "Tita", "**", "2", "*", "b", "*", "(", "b", "-", "1", ")", "*", "Delta", "**", "(", "b", "-", "2", ")", "DeltaBdt", "=", "-", "A", "*", "b", "*", "2", "/", "bt", "*", "Delta", "**", "(", "b", "-", "1", ")", "*", "(", "delta", "-", "1", ")", "*", "(", "(", "delta", "-", "1", ")", "**", "2", ")", "**", "(", "0.5", "/", "bt", "-", "1", ")", "-", "2", "*", "Tita", "*", "b", "*", "(", "b", "-", "1", ")", "*", "Delta", "**", "(", "b", "-", "2", ")", "*", "Deltad", "fir", "+=", "n", "*", "Delta", "**", "b", "*", "delta", "*", "F", "fird", "+=", "n", "*", "(", "Delta", "**", "b", "*", "(", "F", "+", "delta", "*", "Fd", ")", "+", "DeltaBd", "*", "delta", "*", "F", ")", "firdd", "+=", "n", "*", "(", "Delta", "**", "b", "*", "(", "2", "*", "Fd", "+", "delta", "*", "Fdd", ")", "+", "2", "*", "DeltaBd", "*", "(", "F", "+", "delta", "*", "Fd", ")", "+", "DeltaBdd", "*", "delta", "*", "F", ")", "firt", "+=", "n", "*", "delta", "*", "(", "DeltaBt", "*", "F", "+", "Delta", "**", "b", "*", "Ft", ")", "firtt", "+=", "n", "*", "delta", "*", "(", "DeltaBtt", "*", "F", "+", "2", "*", "DeltaBt", "*", "Ft", "+", "Delta", "**", "b", "*", "Ftt", ")", "firdt", "+=", "n", "*", "(", "Delta", "**", "b", "*", "(", "Ft", "+", "delta", "*", "Fdt", ")", "+", "delta", "*", "DeltaBd", "*", "Ft", "+", "DeltaBt", "*", "(", "F", "+", "delta", "*", "Fd", ")", "+", "DeltaBdt", "*", "delta", "*", "F", ")", "prop", "=", "{", "}", "prop", "[", "\"fir\"", "]", "=", "fir", "prop", "[", "\"firt\"", "]", "=", "firt", "prop", "[", "\"firtt\"", "]", "=", "firtt", "prop", "[", "\"fird\"", "]", "=", "fird", "prop", "[", "\"firdd\"", "]", "=", "firdd", "prop", "[", "\"firdt\"", "]", "=", "firdt", "return", "prop" ]
Residual contribution to the free Helmholtz energy Parameters ---------- tau : float Inverse reduced temperature Tc/T, [-] delta : float Reduced density rho/rhoc, [-] Returns ------- prop : dict Dictionary with residual adimensional helmholtz energy and deriv: * fir * firt: ∂fir/∂τ|δ,x * fird: ∂fir/∂δ|τ,x * firtt: ∂²fir/∂τ²|δ,x * firdt: ∂²fir/∂τ∂δ|x * firdd: ∂²fir/∂δ²|τ,x References ---------- IAPWS, Revised Release on the IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use, September 2016, Table 5 http://www.iapws.org/relguide/IAPWS-95.html
[ "Residual", "contribution", "to", "the", "free", "Helmholtz", "energy" ]
train
https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/iapws95.py#L1758-L1890
<|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: Residual contribution to the free Helmholtz energy Parameters ---------- tau : float Inverse reduced temperature Tc/T, [-] delta : float Reduced density rho/rhoc, [-] Returns ------- prop : dict Dictionary with residual adimensional helmholtz energy and deriv: * fir * firt: ∂fir/∂τ|δ,x * fird: ∂fir/∂δ|τ,x * firtt: ∂²fir/∂τ²|δ,x * firdt: ∂²fir/∂τ∂δ|x * firdd: ∂²fir/∂δ²|τ,x References ---------- IAPWS, Revised Release on the IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use, September 2016, Table 5 http://www.iapws.org/relguide/IAPWS-95.html ### Response: def _phir(self, tau, delta): """Residual contribution to the free Helmholtz energy Parameters ---------- tau : float Inverse reduced temperature Tc/T, [-] delta : float Reduced density rho/rhoc, [-] Returns ------- prop : dict Dictionary with residual adimensional helmholtz energy and deriv: * fir * firt: ∂fir/∂τ|δ,x * fird: ∂fir/∂δ|τ,x * firtt: ∂²fir/∂τ²|δ,x * firdt: ∂²fir/∂τ∂δ|x * firdd: ∂²fir/∂δ²|τ,x References ---------- IAPWS, Revised Release on the IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use, September 2016, Table 5 http://www.iapws.org/relguide/IAPWS-95.html """ fir = fird = firdd = firt = firtt = firdt = 0 # Polinomial terms nr1 = self._constants.get("nr1", []) d1 = self._constants.get("d1", []) t1 = self._constants.get("t1", []) for n, d, t in zip(nr1, d1, t1): fir += n*delta**d*tau**t fird += n*d*delta**(d-1)*tau**t firdd += n*d*(d-1)*delta**(d-2)*tau**t firt += n*t*delta**d*tau**(t-1) firtt += n*t*(t-1)*delta**d*tau**(t-2) firdt += n*t*d*delta**(d-1)*tau**(t-1) # Exponential terms nr2 = self._constants.get("nr2", []) d2 = self._constants.get("d2", []) g2 = self._constants.get("gamma2", []) t2 = self._constants.get("t2", []) c2 = self._constants.get("c2", []) for n, d, g, t, c in zip(nr2, d2, g2, t2, c2): fir += n*delta**d*tau**t*exp(-g*delta**c) fird += n*exp(-g*delta**c)*delta**(d-1)*tau**t*(d-g*c*delta**c) firdd += n*exp(-g*delta**c)*delta**(d-2)*tau**t * \ ((d-g*c*delta**c)*(d-1-g*c*delta**c)-g**2*c**2*delta**c) firt += n*t*delta**d*tau**(t-1)*exp(-g*delta**c) firtt += n*t*(t-1)*delta**d*tau**(t-2)*exp(-g*delta**c) firdt += n*t*delta**(d-1)*tau**(t-1)*(d-g*c*delta**c)*exp( -g*delta**c) # Gaussian terms nr3 = self._constants.get("nr3", []) d3 = self._constants.get("d3", []) t3 = self._constants.get("t3", []) a3 = self._constants.get("alfa3", []) e3 = self._constants.get("epsilon3", []) b3 = self._constants.get("beta3", []) g3 = self._constants.get("gamma3", []) for n, d, t, a, e, b, g in zip(nr3, d3, t3, a3, e3, b3, g3): fir += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2) fird += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( d/delta-2*a*(delta-e)) firdd += n*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( -2*a*delta**d + 4*a**2*delta**d*(delta-e)**2 - 4*d*a*delta**(d-1)*(delta-e) + d*(d-1)*delta**(d-2)) firt += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( t/tau-2*b*(tau-g)) firtt += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( (t/tau-2*b*(tau-g))**2-t/tau**2-2*b) firdt += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( t/tau-2*b*(tau-g))*(d/delta-2*a*(delta-e)) # Non analitic terms nr4 = self._constants.get("nr4", []) a4 = self._constants.get("a4", []) b4 = self._constants.get("b4", []) Ai = self._constants.get("A", []) Bi = self._constants.get("B", []) Ci = self._constants.get("C", []) Di = self._constants.get("D", []) bt4 = self._constants.get("beta4", []) for n, a, b, A, B, C, D, bt in zip(nr4, a4, b4, Ai, Bi, Ci, Di, bt4): Tita = (1-tau)+A*((delta-1)**2)**(0.5/bt) F = exp(-C*(delta-1)**2-D*(tau-1)**2) Fd = -2*C*F*(delta-1) Fdd = 2*C*F*(2*C*(delta-1)**2-1) Ft = -2*D*F*(tau-1) Ftt = 2*D*F*(2*D*(tau-1)**2-1) Fdt = 4*C*D*F*(delta-1)*(tau-1) Delta = Tita**2+B*((delta-1)**2)**a Deltad = (delta-1)*(A*Tita*2/bt*((delta-1)**2)**(0.5/bt-1) + 2*B*a*((delta-1)**2)**(a-1)) if delta == 1: Deltadd = 0 else: Deltadd = Deltad/(delta-1)+(delta-1)**2*( 4*B*a*(a-1)*((delta-1)**2)**(a-2) + 2*A**2/bt**2*(((delta-1)**2)**(0.5/bt-1))**2 + A*Tita*4/bt*(0.5/bt-1)*((delta-1)**2)**(0.5/bt-2)) DeltaBd = b*Delta**(b-1)*Deltad DeltaBdd = b*(Delta**(b-1)*Deltadd+(b-1)*Delta**(b-2)*Deltad**2) DeltaBt = -2*Tita*b*Delta**(b-1) DeltaBtt = 2*b*Delta**(b-1)+4*Tita**2*b*(b-1)*Delta**(b-2) DeltaBdt = -A*b*2/bt*Delta**(b-1)*(delta-1)*((delta-1)**2)**( 0.5/bt-1)-2*Tita*b*(b-1)*Delta**(b-2)*Deltad fir += n*Delta**b*delta*F fird += n*(Delta**b*(F+delta*Fd)+DeltaBd*delta*F) firdd += n*(Delta**b*(2*Fd+delta*Fdd) + 2*DeltaBd*(F+delta*Fd) + DeltaBdd*delta*F) firt += n*delta*(DeltaBt*F+Delta**b*Ft) firtt += n*delta*(DeltaBtt*F+2*DeltaBt*Ft+Delta**b*Ftt) firdt += n*(Delta**b*(Ft+delta*Fdt)+delta*DeltaBd*Ft + DeltaBt*(F+delta*Fd)+DeltaBdt*delta*F) prop = {} prop["fir"] = fir prop["firt"] = firt prop["firtt"] = firtt prop["fird"] = fird prop["firdd"] = firdd prop["firdt"] = firdt return prop <|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, 1079, 3421, 19035, 311, 279, 1949, 16183, 53016, 6312, 89, 4907, 271, 286, 13831, 198, 286, 31423, 286, 32923, 551, 2273, 198, 310, 763, 4550, 11293, 9499, 350, 66, 17146, 11, 10261, 933, 286, 9665, 551, 2273, 198, 310, 80569, 17915, 32481, 7534, 89573, 11, 10261, 2595, 286, 5295, 198, 286, 39707, 286, 2047, 551, 6587, 198, 692, 10685, 449, 33247, 1008, 29321, 34865, 71, 6312, 89, 4907, 323, 19290, 512, 310, 353, 35092, 198, 310, 353, 282, 2154, 25, 12264, 224, 92736, 14, 22447, 224, 36924, 91, 86486, 13095, 198, 310, 353, 282, 2668, 25, 12264, 224, 92736, 14, 22447, 224, 86486, 91, 36924, 13095, 198, 310, 353, 282, 2154, 83, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 36924, 30556, 91, 86486, 13095, 198, 310, 353, 282, 2668, 83, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 36924, 22447, 224, 86486, 63927, 198, 310, 353, 35092, 634, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 86486, 30556, 91, 36924, 13095, 271, 286, 45178, 198, 286, 31423, 286, 358, 2599, 7585, 11, 67830, 17836, 389, 279, 358, 2599, 7585, 3459, 2987, 220, 2550, 20, 369, 279, 198, 286, 68372, 61002, 12094, 315, 99011, 10164, 95387, 369, 3331, 323, 198, 286, 38130, 5560, 11, 6250, 220, 679, 21, 11, 6771, 220, 20, 198, 286, 1795, 1129, 2185, 8777, 391, 9092, 2726, 14, 3833, 49470, 39251, 2599, 7585, 12, 2721, 2628, 271, 14711, 6075, 512, 755, 721, 764, 404, 1214, 11, 32923, 11, 9665, 997, 286, 4304, 1079, 3421, 19035, 311, 279, 1949, 16183, 53016, 6312, 89, 4907, 271, 286, 13831, 198, 286, 31423, 286, 32923, 551, 2273, 198, 310, 763, 4550, 11293, 9499, 350, 66, 17146, 11, 10261, 933, 286, 9665, 551, 2273, 198, 310, 80569, 17915, 32481, 7534, 89573, 11, 10261, 2595, 286, 5295, 198, 286, 39707, 286, 2047, 551, 6587, 198, 692, 10685, 449, 33247, 1008, 29321, 34865, 71, 6312, 89, 4907, 323, 19290, 512, 310, 353, 35092, 198, 310, 353, 282, 2154, 25, 12264, 224, 92736, 14, 22447, 224, 36924, 91, 86486, 13095, 198, 310, 353, 282, 2668, 25, 12264, 224, 92736, 14, 22447, 224, 86486, 91, 36924, 13095, 198, 310, 353, 282, 2154, 83, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 36924, 30556, 91, 86486, 13095, 198, 310, 353, 282, 2668, 83, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 36924, 22447, 224, 86486, 63927, 198, 310, 353, 35092, 634, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 86486, 30556, 91, 36924, 13095, 271, 286, 45178, 198, 286, 31423, 286, 358, 2599, 7585, 11, 67830, 17836, 389, 279, 358, 2599, 7585, 3459, 2987, 220, 2550, 20, 369, 279, 198, 286, 68372, 61002, 12094, 315, 99011, 10164, 95387, 369, 3331, 323, 198, 286, 38130, 5560, 11, 6250, 220, 679, 21, 11, 6771, 220, 20, 198, 286, 1795, 1129, 2185, 8777, 391, 9092, 2726, 14, 3833, 49470, 39251, 2599, 7585 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1079, 3421, 19035, 311, 279, 1949, 16183, 53016, 6312, 89, 4907, 271, 286, 13831, 198, 286, 31423, 286, 32923, 551, 2273, 198, 310, 763, 4550, 11293, 9499, 350, 66, 17146, 11, 10261, 933, 286, 9665, 551, 2273, 198, 310, 80569, 17915, 32481, 7534, 89573, 11, 10261, 2595, 286, 5295, 198, 286, 39707, 286, 2047, 551, 6587, 198, 692, 10685, 449, 33247, 1008, 29321, 34865, 71, 6312, 89, 4907, 323, 19290, 512, 310, 353, 35092, 198, 310, 353, 282, 2154, 25, 12264, 224, 92736, 14, 22447, 224, 36924, 91, 86486, 13095, 198, 310, 353, 282, 2668, 25, 12264, 224, 92736, 14, 22447, 224, 86486, 91, 36924, 13095, 198, 310, 353, 282, 2154, 83, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 36924, 30556, 91, 86486, 13095, 198, 310, 353, 282, 2668, 83, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 36924, 22447, 224, 86486, 63927, 198, 310, 353, 35092, 634, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 86486, 30556, 91, 36924, 13095, 271, 286, 45178, 198, 286, 31423, 286, 358, 2599, 7585, 11, 67830, 17836, 389, 279, 358, 2599, 7585, 3459, 2987, 220, 2550, 20, 369, 279, 198, 286, 68372, 61002, 12094, 315, 99011, 10164, 95387, 369, 3331, 323, 198, 286, 38130, 5560, 11, 6250, 220, 679, 21, 11, 6771, 220, 20, 198, 286, 1795, 1129, 2185, 8777, 391, 9092, 2726, 14, 3833, 49470, 39251, 2599, 7585, 12, 2721, 2628, 271, 14711, 6075, 512, 755, 721, 764, 404, 1214, 11, 32923, 11, 9665, 997, 286, 4304, 1079, 3421, 19035, 311, 279, 1949, 16183, 53016, 6312, 89, 4907, 271, 286, 13831, 198, 286, 31423, 286, 32923, 551, 2273, 198, 310, 763, 4550, 11293, 9499, 350, 66, 17146, 11, 10261, 933, 286, 9665, 551, 2273, 198, 310, 80569, 17915, 32481, 7534, 89573, 11, 10261, 2595, 286, 5295, 198, 286, 39707, 286, 2047, 551, 6587, 198, 692, 10685, 449, 33247, 1008, 29321, 34865, 71, 6312, 89, 4907, 323, 19290, 512, 310, 353, 35092, 198, 310, 353, 282, 2154, 25, 12264, 224, 92736, 14, 22447, 224, 36924, 91, 86486, 13095, 198, 310, 353, 282, 2668, 25, 12264, 224, 92736, 14, 22447, 224, 86486, 91, 36924, 13095, 198, 310, 353, 282, 2154, 83, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 36924, 30556, 91, 86486, 13095, 198, 310, 353, 282, 2668, 83, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 36924, 22447, 224, 86486, 63927, 198, 310, 353, 35092, 634, 25, 12264, 224, 30556, 92736, 14, 22447, 224, 86486, 30556, 91, 36924, 13095, 271, 286, 45178, 198, 286, 31423, 286, 358, 2599, 7585, 11, 67830, 17836, 389, 279, 358, 2599, 7585, 3459, 2987, 220, 2550, 20, 369, 279, 198, 286, 68372, 61002, 12094, 315, 99011, 10164, 95387, 369, 3331, 323, 198, 286, 38130, 5560, 11, 6250, 220, 679, 21, 11, 6771, 220, 20, 198, 286, 1795, 1129, 2185, 8777, 391, 9092, 2726, 14, 3833, 49470, 39251, 2599, 7585 ]
cebel/pyuniprot
src/pyuniprot/manager/query.py
QueryManager.function
def function(self, text=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.Function` objects in database :param text: description(s) of function(s) :type text: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tuple(str) or None :param limit: - if `isinstance(limit,int)==True` -> limit - if `isinstance(limit,tuple)==True` -> format:= tuple(page_number, results_per_page) - if limit == None -> all results :type limit: int or tuple(int) or None :param bool as_df: if `True` results are returned as :class:`pandas.DataFrame` :return: - if `as_df == False` -> list(:class:`.models.Function`) - if `as_df == True` -> :class:`pandas.DataFrame` :rtype: list(:class:`.models.Function`) or :class:`pandas.DataFrame` """ q = self.session.query(models.Function) model_queries_config = ( (text, models.Function.text), ) q = self.get_model_queries(q, model_queries_config) q = self.get_one_to_many_queries(q, ((entry_name, models.Entry.name),)) return self._limit_and_df(q, limit, as_df)
python
def function(self, text=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.Function` objects in database :param text: description(s) of function(s) :type text: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tuple(str) or None :param limit: - if `isinstance(limit,int)==True` -> limit - if `isinstance(limit,tuple)==True` -> format:= tuple(page_number, results_per_page) - if limit == None -> all results :type limit: int or tuple(int) or None :param bool as_df: if `True` results are returned as :class:`pandas.DataFrame` :return: - if `as_df == False` -> list(:class:`.models.Function`) - if `as_df == True` -> :class:`pandas.DataFrame` :rtype: list(:class:`.models.Function`) or :class:`pandas.DataFrame` """ q = self.session.query(models.Function) model_queries_config = ( (text, models.Function.text), ) q = self.get_model_queries(q, model_queries_config) q = self.get_one_to_many_queries(q, ((entry_name, models.Entry.name),)) return self._limit_and_df(q, limit, as_df)
[ "def", "function", "(", "self", ",", "text", "=", "None", ",", "entry_name", "=", "None", ",", "limit", "=", "None", ",", "as_df", "=", "False", ")", ":", "q", "=", "self", ".", "session", ".", "query", "(", "models", ".", "Function", ")", "model_queries_config", "=", "(", "(", "text", ",", "models", ".", "Function", ".", "text", ")", ",", ")", "q", "=", "self", ".", "get_model_queries", "(", "q", ",", "model_queries_config", ")", "q", "=", "self", ".", "get_one_to_many_queries", "(", "q", ",", "(", "(", "entry_name", ",", "models", ".", "Entry", ".", "name", ")", ",", ")", ")", "return", "self", ".", "_limit_and_df", "(", "q", ",", "limit", ",", "as_df", ")" ]
Method to query :class:`.models.Function` objects in database :param text: description(s) of function(s) :type text: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tuple(str) or None :param limit: - if `isinstance(limit,int)==True` -> limit - if `isinstance(limit,tuple)==True` -> format:= tuple(page_number, results_per_page) - if limit == None -> all results :type limit: int or tuple(int) or None :param bool as_df: if `True` results are returned as :class:`pandas.DataFrame` :return: - if `as_df == False` -> list(:class:`.models.Function`) - if `as_df == True` -> :class:`pandas.DataFrame` :rtype: list(:class:`.models.Function`) or :class:`pandas.DataFrame`
[ "Method", "to", "query", ":", "class", ":", ".", "models", ".", "Function", "objects", "in", "database" ]
train
https://github.com/cebel/pyuniprot/blob/9462a6042c7c9295415a5eb589b77b27cb7c142b/src/pyuniprot/manager/query.py#L740-L771
<|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: Method to query :class:`.models.Function` objects in database :param text: description(s) of function(s) :type text: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tuple(str) or None :param limit: - if `isinstance(limit,int)==True` -> limit - if `isinstance(limit,tuple)==True` -> format:= tuple(page_number, results_per_page) - if limit == None -> all results :type limit: int or tuple(int) or None :param bool as_df: if `True` results are returned as :class:`pandas.DataFrame` :return: - if `as_df == False` -> list(:class:`.models.Function`) - if `as_df == True` -> :class:`pandas.DataFrame` :rtype: list(:class:`.models.Function`) or :class:`pandas.DataFrame` ### Response: def function(self, text=None, entry_name=None, limit=None, as_df=False): """Method to query :class:`.models.Function` objects in database :param text: description(s) of function(s) :type text: str or tuple(str) or None :param entry_name: name(s) in :class:`.models.Entry` :type entry_name: str or tuple(str) or None :param limit: - if `isinstance(limit,int)==True` -> limit - if `isinstance(limit,tuple)==True` -> format:= tuple(page_number, results_per_page) - if limit == None -> all results :type limit: int or tuple(int) or None :param bool as_df: if `True` results are returned as :class:`pandas.DataFrame` :return: - if `as_df == False` -> list(:class:`.models.Function`) - if `as_df == True` -> :class:`pandas.DataFrame` :rtype: list(:class:`.models.Function`) or :class:`pandas.DataFrame` """ q = self.session.query(models.Function) model_queries_config = ( (text, models.Function.text), ) q = self.get_model_queries(q, model_queries_config) q = self.get_one_to_many_queries(q, ((entry_name, models.Entry.name),)) return self._limit_and_df(q, limit, as_df) <|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, 3607, 311, 3319, 551, 1058, 19258, 13, 6644, 31647, 63, 6302, 304, 4729, 271, 286, 551, 913, 1495, 25, 4096, 1161, 8, 315, 734, 1161, 340, 286, 551, 1337, 1495, 25, 610, 477, 14743, 4293, 8, 477, 2290, 271, 286, 551, 913, 4441, 1292, 25, 836, 1161, 8, 304, 551, 1058, 19258, 13, 6644, 23131, 4077, 286, 551, 1337, 4441, 1292, 25, 610, 477, 14743, 4293, 8, 477, 2290, 271, 286, 551, 913, 4017, 512, 310, 482, 422, 1595, 285, 4956, 53362, 10072, 15708, 2575, 63, 1492, 4017, 198, 310, 482, 422, 1595, 285, 4956, 53362, 14287, 6189, 15708, 2575, 63, 1492, 3645, 14543, 14743, 12293, 5617, 11, 3135, 5796, 6257, 340, 310, 482, 422, 4017, 624, 2290, 1492, 682, 3135, 198, 286, 551, 1337, 4017, 25, 528, 477, 14743, 1577, 8, 477, 2290, 271, 286, 551, 913, 1845, 439, 11133, 25, 422, 1595, 2575, 63, 3135, 527, 6052, 439, 551, 1058, 19258, 79, 56533, 21756, 19884, 286, 551, 693, 512, 310, 482, 422, 1595, 300, 11133, 624, 3641, 63, 1492, 1160, 3964, 1058, 19258, 13, 6644, 31647, 25158, 310, 482, 422, 1595, 300, 11133, 624, 3082, 63, 220, 1492, 551, 1058, 19258, 79, 56533, 21756, 4077, 286, 551, 33613, 25, 1160, 3964, 1058, 19258, 13, 6644, 31647, 33981, 477, 551, 1058, 19258, 79, 56533, 21756, 19884, 14711, 6075, 512, 755, 734, 1214, 11, 1495, 5980, 11, 4441, 1292, 5980, 11, 4017, 5980, 11, 439, 11133, 5725, 997, 286, 4304, 3607, 311, 3319, 551, 1058, 19258, 13, 6644, 31647, 63, 6302, 304, 4729, 271, 286, 551, 913, 1495, 25, 4096, 1161, 8, 315, 734, 1161, 340, 286, 551, 1337, 1495, 25, 610, 477, 14743, 4293, 8, 477, 2290, 271, 286, 551, 913, 4441, 1292, 25, 836, 1161, 8, 304, 551, 1058, 19258, 13, 6644, 23131, 4077, 286, 551, 1337, 4441, 1292, 25, 610, 477, 14743, 4293, 8, 477, 2290, 271, 286, 551, 913, 4017, 512, 310, 482, 422, 1595, 285, 4956, 53362, 10072, 15708, 2575, 63, 1492, 4017, 198, 310, 482, 422, 1595, 285, 4956, 53362, 14287, 6189, 15708, 2575, 63, 1492, 3645, 14543, 14743, 12293, 5617, 11, 3135, 5796, 6257, 340, 310, 482, 422, 4017, 624, 2290, 1492, 682, 3135, 198, 286, 551, 1337, 4017, 25, 528, 477, 14743, 1577, 8, 477, 2290, 271, 286, 551, 913, 1845, 439, 11133, 25, 422, 1595, 2575, 63, 3135, 527, 6052, 439, 551, 1058, 19258, 79, 56533, 21756, 19884, 286, 551, 693, 512, 310, 482, 422, 1595, 300, 11133, 624, 3641, 63, 1492, 1160, 3964, 1058, 19258, 13, 6644, 31647, 25158, 310, 482, 422, 1595, 300, 11133, 624, 3082, 63, 220, 1492, 551, 1058, 19258, 79, 56533, 21756, 4077, 286, 551, 33613, 25, 1160, 3964, 1058, 19258, 13, 6644, 31647, 33981, 477, 551, 1058, 19258, 79, 56533, 21756, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 3607, 311, 3319, 551, 1058, 19258, 13, 6644, 31647, 63, 6302, 304, 4729, 271, 286, 551, 913, 1495, 25, 4096, 1161, 8, 315, 734, 1161, 340, 286, 551, 1337, 1495, 25, 610, 477, 14743, 4293, 8, 477, 2290, 271, 286, 551, 913, 4441, 1292, 25, 836, 1161, 8, 304, 551, 1058, 19258, 13, 6644, 23131, 4077, 286, 551, 1337, 4441, 1292, 25, 610, 477, 14743, 4293, 8, 477, 2290, 271, 286, 551, 913, 4017, 512, 310, 482, 422, 1595, 285, 4956, 53362, 10072, 15708, 2575, 63, 1492, 4017, 198, 310, 482, 422, 1595, 285, 4956, 53362, 14287, 6189, 15708, 2575, 63, 1492, 3645, 14543, 14743, 12293, 5617, 11, 3135, 5796, 6257, 340, 310, 482, 422, 4017, 624, 2290, 1492, 682, 3135, 198, 286, 551, 1337, 4017, 25, 528, 477, 14743, 1577, 8, 477, 2290, 271, 286, 551, 913, 1845, 439, 11133, 25, 422, 1595, 2575, 63, 3135, 527, 6052, 439, 551, 1058, 19258, 79, 56533, 21756, 19884, 286, 551, 693, 512, 310, 482, 422, 1595, 300, 11133, 624, 3641, 63, 1492, 1160, 3964, 1058, 19258, 13, 6644, 31647, 25158, 310, 482, 422, 1595, 300, 11133, 624, 3082, 63, 220, 1492, 551, 1058, 19258, 79, 56533, 21756, 4077, 286, 551, 33613, 25, 1160, 3964, 1058, 19258, 13, 6644, 31647, 33981, 477, 551, 1058, 19258, 79, 56533, 21756, 19884, 14711, 6075, 512, 755, 734, 1214, 11, 1495, 5980, 11, 4441, 1292, 5980, 11, 4017, 5980, 11, 439, 11133, 5725, 997, 286, 4304, 3607, 311, 3319, 551, 1058, 19258, 13, 6644, 31647, 63, 6302, 304, 4729, 271, 286, 551, 913, 1495, 25, 4096, 1161, 8, 315, 734, 1161, 340, 286, 551, 1337, 1495, 25, 610, 477, 14743, 4293, 8, 477, 2290, 271, 286, 551, 913, 4441, 1292, 25, 836, 1161, 8, 304, 551, 1058, 19258, 13, 6644, 23131, 4077, 286, 551, 1337, 4441, 1292, 25, 610, 477, 14743, 4293, 8, 477, 2290, 271, 286, 551, 913, 4017, 512, 310, 482, 422, 1595, 285, 4956, 53362, 10072, 15708, 2575, 63, 1492, 4017, 198, 310, 482, 422, 1595, 285, 4956, 53362, 14287, 6189, 15708, 2575, 63, 1492, 3645, 14543, 14743, 12293, 5617, 11, 3135, 5796, 6257, 340, 310, 482, 422, 4017, 624, 2290, 1492, 682, 3135, 198, 286, 551, 1337, 4017, 25, 528, 477, 14743, 1577, 8, 477, 2290, 271, 286, 551, 913, 1845, 439, 11133, 25, 422, 1595, 2575, 63, 3135, 527, 6052, 439, 551, 1058, 19258, 79, 56533, 21756, 19884, 286, 551, 693, 512, 310, 482, 422, 1595, 300, 11133, 624, 3641, 63, 1492, 1160, 3964, 1058, 19258, 13, 6644, 31647, 25158, 310, 482, 422, 1595, 300, 11133, 624, 3082, 63, 220, 1492, 551, 1058, 19258, 79, 56533, 21756, 4077, 286, 551, 33613, 25, 1160, 3964, 1058, 19258, 13, 6644, 31647, 33981, 477, 551, 1058, 19258, 79, 56533, 21756, 4077, 286, 3270, 286, 2874, 284, 659, 10387, 4891, 20905, 31647, 696, 286, 1646, 66688, 5445, 284 ]
Autodesk/aomi
aomi/cli.py
ux_actions
def ux_actions(parser, args): """Handle some human triggers actions""" # cryptorito uses native logging (as aomi should tbh) normal_fmt = '%(message)s' if hasattr(args, 'verbose') and args.verbose and args.verbose >= 2: logging.basicConfig(level=logging.DEBUG) elif hasattr(args, 'verbose') and args.verbose >= 1: logging.basicConfig(level=logging.INFO, format=normal_fmt) else: logging.basicConfig(level=logging.WARN, format=normal_fmt) if args.operation == 'help': help_me(parser, args)
python
def ux_actions(parser, args): """Handle some human triggers actions""" # cryptorito uses native logging (as aomi should tbh) normal_fmt = '%(message)s' if hasattr(args, 'verbose') and args.verbose and args.verbose >= 2: logging.basicConfig(level=logging.DEBUG) elif hasattr(args, 'verbose') and args.verbose >= 1: logging.basicConfig(level=logging.INFO, format=normal_fmt) else: logging.basicConfig(level=logging.WARN, format=normal_fmt) if args.operation == 'help': help_me(parser, args)
[ "def", "ux_actions", "(", "parser", ",", "args", ")", ":", "# cryptorito uses native logging (as aomi should tbh)", "normal_fmt", "=", "'%(message)s'", "if", "hasattr", "(", "args", ",", "'verbose'", ")", "and", "args", ".", "verbose", "and", "args", ".", "verbose", ">=", "2", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "DEBUG", ")", "elif", "hasattr", "(", "args", ",", "'verbose'", ")", "and", "args", ".", "verbose", ">=", "1", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ",", "format", "=", "normal_fmt", ")", "else", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "WARN", ",", "format", "=", "normal_fmt", ")", "if", "args", ".", "operation", "==", "'help'", ":", "help_me", "(", "parser", ",", "args", ")" ]
Handle some human triggers actions
[ "Handle", "some", "human", "triggers", "actions" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/cli.py#L388-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: Handle some human triggers actions ### Response: def ux_actions(parser, args): """Handle some human triggers actions""" # cryptorito uses native logging (as aomi should tbh) normal_fmt = '%(message)s' if hasattr(args, 'verbose') and args.verbose and args.verbose >= 2: logging.basicConfig(level=logging.DEBUG) elif hasattr(args, 'verbose') and args.verbose >= 1: logging.basicConfig(level=logging.INFO, format=normal_fmt) else: logging.basicConfig(level=logging.WARN, format=normal_fmt) if args.operation == 'help': help_me(parser, 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, 7144, 1063, 3823, 31854, 6299, 271, 14711, 6075, 512, 755, 90903, 26440, 36435, 11, 2897, 997, 262, 4304, 7144, 1063, 3823, 31854, 6299, 7275, 262, 674, 14774, 269, 6491, 5829, 10068, 8558, 320, 300, 264, 22157, 1288, 16767, 71, 340, 262, 4725, 39228, 284, 7832, 7, 2037, 16871, 1270, 262, 422, 32156, 7506, 11, 364, 15228, 873, 323, 2897, 45749, 323, 2897, 45749, 2669, 220, 17, 512, 286, 8558, 69897, 24593, 71328, 39236, 340, 262, 4508, 32156, 7506, 11, 364, 15228, 873, 323, 2897, 45749, 2669, 220, 16, 512, 286, 8558, 69897, 24593, 71328, 39417, 11, 3645, 28, 8416, 39228, 340, 262, 775, 512, 286, 8558, 69897, 24593, 71328, 1196, 9228, 11, 3645, 28, 8416, 39228, 696, 262, 422, 2897, 49956, 624, 364, 8823, 3730, 286, 1520, 17023, 36435, 11, 2897, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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527, 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, 7144, 1063, 3823, 31854, 6299, 271, 14711, 6075, 512, 755, 90903, 26440, 36435, 11, 2897, 997, 262, 4304, 7144, 1063, 3823, 31854, 6299, 7275, 262, 674, 14774, 269, 6491, 5829, 10068, 8558, 320, 300, 264, 22157, 1288, 16767, 71, 340, 262, 4725, 39228, 284, 7832, 7, 2037, 16871, 1270, 262, 422, 32156, 7506, 11, 364, 15228, 873, 323, 2897, 45749, 323, 2897, 45749, 2669, 220, 17, 512, 286, 8558, 69897, 24593, 71328, 39236, 340, 262, 4508, 32156, 7506, 11, 364, 15228, 873, 323, 2897, 45749, 2669, 220, 16, 512, 286, 8558, 69897, 24593, 71328, 39417, 11, 3645, 28, 8416, 39228, 340, 262, 775, 512, 286, 8558, 69897, 24593, 71328, 1196, 9228, 11, 3645, 28, 8416, 39228, 696, 262, 422, 2897, 49956, 624, 364, 8823, 3730, 286, 1520, 17023, 36435, 11, 2897, 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 ]
crocs-muni/roca
roca/detect.py
RocaFingerprinter.process_ssh
def process_ssh(self, data, name): """ Processes SSH keys :param data: :param name: :return: """ if data is None or len(data) == 0: return ret = [] try: lines = [x.strip() for x in data.split(b'\n')] for idx, line in enumerate(lines): ret.append(self.process_ssh_line(line, name, idx)) except Exception as e: logger.debug('Exception in processing SSH public key %s : %s' % (name, e)) self.trace_logger.log(e) return ret
python
def process_ssh(self, data, name): """ Processes SSH keys :param data: :param name: :return: """ if data is None or len(data) == 0: return ret = [] try: lines = [x.strip() for x in data.split(b'\n')] for idx, line in enumerate(lines): ret.append(self.process_ssh_line(line, name, idx)) except Exception as e: logger.debug('Exception in processing SSH public key %s : %s' % (name, e)) self.trace_logger.log(e) return ret
[ "def", "process_ssh", "(", "self", ",", "data", ",", "name", ")", ":", "if", "data", "is", "None", "or", "len", "(", "data", ")", "==", "0", ":", "return", "ret", "=", "[", "]", "try", ":", "lines", "=", "[", "x", ".", "strip", "(", ")", "for", "x", "in", "data", ".", "split", "(", "b'\\n'", ")", "]", "for", "idx", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "ret", ".", "append", "(", "self", ".", "process_ssh_line", "(", "line", ",", "name", ",", "idx", ")", ")", "except", "Exception", "as", "e", ":", "logger", ".", "debug", "(", "'Exception in processing SSH public key %s : %s'", "%", "(", "name", ",", "e", ")", ")", "self", ".", "trace_logger", ".", "log", "(", "e", ")", "return", "ret" ]
Processes SSH keys :param data: :param name: :return:
[ "Processes", "SSH", "keys", ":", "param", "data", ":", ":", "param", "name", ":", ":", "return", ":" ]
train
https://github.com/crocs-muni/roca/blob/74ad6ce63c428d83dcffce9c5e26ef7b9e30faa5/roca/detect.py#L1605-L1624
<|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: Processes SSH keys :param data: :param name: :return: ### Response: def process_ssh(self, data, name): """ Processes SSH keys :param data: :param name: :return: """ if data is None or len(data) == 0: return ret = [] try: lines = [x.strip() for x in data.split(b'\n')] for idx, line in enumerate(lines): ret.append(self.process_ssh_line(line, name, idx)) except Exception as e: logger.debug('Exception in processing SSH public key %s : %s' % (name, e)) self.trace_logger.log(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, 93827, 41563, 7039, 198, 286, 551, 913, 828, 512, 286, 551, 913, 836, 512, 286, 551, 693, 1473, 14711, 6075, 512, 755, 1920, 83905, 1214, 11, 828, 11, 836, 997, 286, 3270, 286, 63403, 41563, 7039, 198, 286, 551, 913, 828, 512, 286, 551, 913, 836, 512, 286, 551, 693, 512, 286, 3270, 286, 422, 828, 374, 2290, 477, 2479, 2657, 8, 624, 220, 15, 512, 310, 471, 271, 286, 2160, 284, 4260, 286, 1456, 512, 310, 5238, 284, 510, 87, 17624, 368, 369, 865, 304, 828, 5402, 1921, 16154, 77, 50724, 310, 369, 7335, 11, 1584, 304, 13555, 34252, 997, 394, 2160, 2102, 1214, 17421, 83905, 6665, 8973, 11, 836, 11, 7335, 4489, 286, 3734, 4204, 439, 384, 512, 310, 6050, 8042, 493, 1378, 304, 8863, 41563, 586, 1401, 1034, 82, 551, 1034, 82, 6, 1034, 320, 609, 11, 384, 1192, 310, 659, 35512, 28513, 1699, 2069, 340, 286, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 93827, 41563, 7039, 198, 286, 551, 913, 828, 512, 286, 551, 913, 836, 512, 286, 551, 693, 1473, 14711, 6075, 512, 755, 1920, 83905, 1214, 11, 828, 11, 836, 997, 286, 3270, 286, 63403, 41563, 7039, 198, 286, 551, 913, 828, 512, 286, 551, 913, 836, 512, 286, 551, 693, 512, 286, 3270, 286, 422, 828, 374, 2290, 477, 2479, 2657, 8, 624, 220, 15, 512, 310, 471, 271, 286, 2160, 284, 4260, 286, 1456, 512, 310, 5238, 284, 510, 87, 17624, 368, 369, 865, 304, 828, 5402, 1921, 16154, 77, 50724, 310, 369, 7335, 11, 1584, 304, 13555, 34252, 997, 394, 2160, 2102, 1214, 17421, 83905, 6665, 8973, 11, 836, 11, 7335, 4489, 286, 3734, 4204, 439, 384, 512, 310, 6050, 8042, 493, 1378, 304, 8863, 41563, 586, 1401, 1034, 82, 551, 1034, 82, 6, 1034, 320, 609, 11, 384, 1192, 310, 659, 35512, 28513, 1699, 2069, 340, 286, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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/attr/_compat.py
make_set_closure_cell
def make_set_closure_cell(): """ Moved into a function for testability. """ if PYPY: # pragma: no cover def set_closure_cell(cell, value): cell.__setstate__((value,)) else: try: ctypes = import_ctypes() set_closure_cell = ctypes.pythonapi.PyCell_Set set_closure_cell.argtypes = (ctypes.py_object, ctypes.py_object) set_closure_cell.restype = ctypes.c_int except Exception: # We try best effort to set the cell, but sometimes it's not # possible. For example on Jython or on GAE. set_closure_cell = just_warn return set_closure_cell
python
def make_set_closure_cell(): """ Moved into a function for testability. """ if PYPY: # pragma: no cover def set_closure_cell(cell, value): cell.__setstate__((value,)) else: try: ctypes = import_ctypes() set_closure_cell = ctypes.pythonapi.PyCell_Set set_closure_cell.argtypes = (ctypes.py_object, ctypes.py_object) set_closure_cell.restype = ctypes.c_int except Exception: # We try best effort to set the cell, but sometimes it's not # possible. For example on Jython or on GAE. set_closure_cell = just_warn return set_closure_cell
[ "def", "make_set_closure_cell", "(", ")", ":", "if", "PYPY", ":", "# pragma: no cover", "def", "set_closure_cell", "(", "cell", ",", "value", ")", ":", "cell", ".", "__setstate__", "(", "(", "value", ",", ")", ")", "else", ":", "try", ":", "ctypes", "=", "import_ctypes", "(", ")", "set_closure_cell", "=", "ctypes", ".", "pythonapi", ".", "PyCell_Set", "set_closure_cell", ".", "argtypes", "=", "(", "ctypes", ".", "py_object", ",", "ctypes", ".", "py_object", ")", "set_closure_cell", ".", "restype", "=", "ctypes", ".", "c_int", "except", "Exception", ":", "# We try best effort to set the cell, but sometimes it's not", "# possible. For example on Jython or on GAE.", "set_closure_cell", "=", "just_warn", "return", "set_closure_cell" ]
Moved into a function for testability.
[ "Moved", "into", "a", "function", "for", "testability", "." ]
train
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/attr/_compat.py#L136-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: Moved into a function for testability. ### Response: def make_set_closure_cell(): """ Moved into a function for testability. """ if PYPY: # pragma: no cover def set_closure_cell(cell, value): cell.__setstate__((value,)) else: try: ctypes = import_ctypes() set_closure_cell = ctypes.pythonapi.PyCell_Set set_closure_cell.argtypes = (ctypes.py_object, ctypes.py_object) set_closure_cell.restype = ctypes.c_int except Exception: # We try best effort to set the cell, but sometimes it's not # possible. For example on Jython or on GAE. set_closure_cell = just_warn return set_closure_cell <|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, 54332, 1139, 264, 734, 369, 1296, 2968, 382, 14711, 6075, 512, 755, 1304, 2667, 73923, 17061, 4019, 262, 3270, 262, 90797, 1139, 264, 734, 369, 1296, 2968, 627, 262, 3270, 262, 422, 393, 10158, 56, 25, 220, 674, 63220, 25, 912, 3504, 271, 286, 711, 743, 73923, 17061, 23521, 11, 907, 997, 310, 2849, 4952, 751, 2513, 31509, 970, 11, 4489, 262, 775, 512, 286, 1456, 512, 310, 49319, 284, 1179, 27226, 1842, 2892, 310, 743, 73923, 17061, 284, 49319, 44293, 2113, 1087, 88, 3683, 15156, 198, 310, 743, 73923, 17061, 21875, 9426, 284, 320, 302, 1842, 7345, 5427, 11, 49319, 7345, 5427, 340, 310, 743, 73923, 17061, 22113, 500, 284, 49319, 522, 4132, 198, 286, 3734, 4204, 512, 310, 674, 1226, 1456, 1888, 5149, 311, 743, 279, 2849, 11, 719, 7170, 433, 596, 539, 198, 310, 674, 3284, 13, 220, 1789, 3187, 389, 622, 27993, 477, 389, 480, 13983, 627, 310, 743, 73923, 17061, 284, 1120, 56145, 198, 262, 471, 743, 73923, 17061, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 54332, 1139, 264, 734, 369, 1296, 2968, 382, 14711, 6075, 512, 755, 1304, 2667, 73923, 17061, 4019, 262, 3270, 262, 90797, 1139, 264, 734, 369, 1296, 2968, 627, 262, 3270, 262, 422, 393, 10158, 56, 25, 220, 674, 63220, 25, 912, 3504, 271, 286, 711, 743, 73923, 17061, 23521, 11, 907, 997, 310, 2849, 4952, 751, 2513, 31509, 970, 11, 4489, 262, 775, 512, 286, 1456, 512, 310, 49319, 284, 1179, 27226, 1842, 2892, 310, 743, 73923, 17061, 284, 49319, 44293, 2113, 1087, 88, 3683, 15156, 198, 310, 743, 73923, 17061, 21875, 9426, 284, 320, 302, 1842, 7345, 5427, 11, 49319, 7345, 5427, 340, 310, 743, 73923, 17061, 22113, 500, 284, 49319, 522, 4132, 198, 286, 3734, 4204, 512, 310, 674, 1226, 1456, 1888, 5149, 311, 743, 279, 2849, 11, 719, 7170, 433, 596, 539, 198, 310, 674, 3284, 13, 220, 1789, 3187, 389, 622, 27993, 477, 389, 480, 13983, 627, 310, 743, 73923, 17061, 284, 1120, 56145, 198, 262, 471, 743, 73923, 17061, 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 ]
sander76/aio-powerview-api
aiopvapi/hub.py
Hub.query_firmware
async def query_firmware(self): """Query the firmware versions.""" _version = await self.request.get(join_path(self._base_path, "/fwversion")) _fw = _version.get("firmware") if _fw: _main = _fw.get("mainProcessor") if _main: self._main_processor_version = self._make_version(_main) _radio = _fw.get("radio") if _radio: self._radio_version = self._make_version(_radio)
python
async def query_firmware(self): """Query the firmware versions.""" _version = await self.request.get(join_path(self._base_path, "/fwversion")) _fw = _version.get("firmware") if _fw: _main = _fw.get("mainProcessor") if _main: self._main_processor_version = self._make_version(_main) _radio = _fw.get("radio") if _radio: self._radio_version = self._make_version(_radio)
[ "async", "def", "query_firmware", "(", "self", ")", ":", "_version", "=", "await", "self", ".", "request", ".", "get", "(", "join_path", "(", "self", ".", "_base_path", ",", "\"/fwversion\"", ")", ")", "_fw", "=", "_version", ".", "get", "(", "\"firmware\"", ")", "if", "_fw", ":", "_main", "=", "_fw", ".", "get", "(", "\"mainProcessor\"", ")", "if", "_main", ":", "self", ".", "_main_processor_version", "=", "self", ".", "_make_version", "(", "_main", ")", "_radio", "=", "_fw", ".", "get", "(", "\"radio\"", ")", "if", "_radio", ":", "self", ".", "_radio_version", "=", "self", ".", "_make_version", "(", "_radio", ")" ]
Query the firmware versions.
[ "Query", "the", "firmware", "versions", "." ]
train
https://github.com/sander76/aio-powerview-api/blob/08b6ac747aba9de19842359a981a7ff1292f5a6c/aiopvapi/hub.py#L88-L99
<|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: Query the firmware versions. ### Response: async def query_firmware(self): """Query the firmware versions.""" _version = await self.request.get(join_path(self._base_path, "/fwversion")) _fw = _version.get("firmware") if _fw: _main = _fw.get("mainProcessor") if _main: self._main_processor_version = self._make_version(_main) _radio = _fw.get("radio") if _radio: self._radio_version = self._make_version(_radio) <|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, 2929, 279, 30778, 11028, 382, 14711, 6075, 512, 7847, 711, 3319, 766, 54360, 1214, 997, 286, 4304, 2929, 279, 30778, 11028, 30284, 286, 721, 4464, 284, 2597, 659, 8387, 673, 61815, 2703, 1214, 1462, 3231, 2703, 11, 3605, 21206, 4464, 5572, 286, 721, 21206, 284, 721, 4464, 673, 446, 8978, 1698, 1158, 286, 422, 721, 21206, 512, 310, 721, 3902, 284, 721, 21206, 673, 446, 3902, 23798, 1158, 310, 422, 721, 3902, 512, 394, 659, 1462, 3902, 51227, 9625, 284, 659, 1462, 7072, 9625, 2551, 3902, 340, 310, 721, 12924, 284, 721, 21206, 673, 446, 12924, 1158, 310, 422, 721, 12924, 512, 394, 659, 1462, 12924, 9625, 284, 659, 1462, 7072, 9625, 2551, 12924, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2929, 279, 30778, 11028, 382, 14711, 6075, 512, 7847, 711, 3319, 766, 54360, 1214, 997, 286, 4304, 2929, 279, 30778, 11028, 30284, 286, 721, 4464, 284, 2597, 659, 8387, 673, 61815, 2703, 1214, 1462, 3231, 2703, 11, 3605, 21206, 4464, 5572, 286, 721, 21206, 284, 721, 4464, 673, 446, 8978, 1698, 1158, 286, 422, 721, 21206, 512, 310, 721, 3902, 284, 721, 21206, 673, 446, 3902, 23798, 1158, 310, 422, 721, 3902, 512, 394, 659, 1462, 3902, 51227, 9625, 284, 659, 1462, 7072, 9625, 2551, 3902, 340, 310, 721, 12924, 284, 721, 21206, 673, 446, 12924, 1158, 310, 422, 721, 12924, 512, 394, 659, 1462, 12924, 9625, 284, 659, 1462, 7072, 9625, 2551, 12924, 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 ]
siznax/wptools
wptools/wikidata.py
WPToolsWikidata._update_what
def _update_what(self): """ set what this thing is! "instance of (P31)" """ if 'P31' not in self.data['claims']: # missing Wikidata msg = ("Note: Wikidata item %s" % self.data['wikibase'], "missing 'instance of' (P31)") utils.stderr(" ".join(msg)) return instance_of = self.data['claims']['P31'][0] labels = self.data['labels'] if instance_of in labels: self.data['what'] = labels[instance_of]
python
def _update_what(self): """ set what this thing is! "instance of (P31)" """ if 'P31' not in self.data['claims']: # missing Wikidata msg = ("Note: Wikidata item %s" % self.data['wikibase'], "missing 'instance of' (P31)") utils.stderr(" ".join(msg)) return instance_of = self.data['claims']['P31'][0] labels = self.data['labels'] if instance_of in labels: self.data['what'] = labels[instance_of]
[ "def", "_update_what", "(", "self", ")", ":", "if", "'P31'", "not", "in", "self", ".", "data", "[", "'claims'", "]", ":", "# missing Wikidata", "msg", "=", "(", "\"Note: Wikidata item %s\"", "%", "self", ".", "data", "[", "'wikibase'", "]", ",", "\"missing 'instance of' (P31)\"", ")", "utils", ".", "stderr", "(", "\" \"", ".", "join", "(", "msg", ")", ")", "return", "instance_of", "=", "self", ".", "data", "[", "'claims'", "]", "[", "'P31'", "]", "[", "0", "]", "labels", "=", "self", ".", "data", "[", "'labels'", "]", "if", "instance_of", "in", "labels", ":", "self", ".", "data", "[", "'what'", "]", "=", "labels", "[", "instance_of", "]" ]
set what this thing is! "instance of (P31)"
[ "set", "what", "this", "thing", "is!", "instance", "of", "(", "P31", ")" ]
train
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/wikidata.py#L207-L221
<|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 what this thing is! "instance of (P31)" ### Response: def _update_what(self): """ set what this thing is! "instance of (P31)" """ if 'P31' not in self.data['claims']: # missing Wikidata msg = ("Note: Wikidata item %s" % self.data['wikibase'], "missing 'instance of' (P31)") utils.stderr(" ".join(msg)) return instance_of = self.data['claims']['P31'][0] labels = self.data['labels'] if instance_of in labels: self.data['what'] = labels[instance_of] <|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, 751, 1148, 420, 3245, 374, 0, 330, 4956, 315, 320, 47, 2148, 53394, 14711, 6075, 512, 755, 721, 2443, 62, 12840, 1214, 997, 286, 3270, 286, 743, 1148, 420, 3245, 374, 0, 330, 4956, 315, 320, 47, 2148, 13251, 286, 3270, 286, 422, 364, 47, 2148, 6, 539, 304, 659, 2245, 681, 49661, 44520, 220, 674, 7554, 43205, 82180, 198, 310, 3835, 284, 3573, 9290, 25, 43205, 82180, 1537, 1034, 82, 1, 1034, 659, 2245, 681, 49537, 99846, 4479, 4391, 330, 31716, 364, 4956, 315, 6, 320, 47, 2148, 19652, 310, 12721, 35842, 446, 6058, 6115, 8282, 1192, 310, 471, 271, 286, 2937, 3659, 284, 659, 2245, 681, 49661, 4274, 47, 2148, 10136, 15, 933, 286, 9382, 284, 659, 2245, 681, 17298, 16049, 286, 422, 2937, 3659, 304, 9382, 512, 310, 659, 2245, 681, 12840, 663, 284, 9382, 58, 4956, 3659, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 751, 1148, 420, 3245, 374, 0, 330, 4956, 315, 320, 47, 2148, 53394, 14711, 6075, 512, 755, 721, 2443, 62, 12840, 1214, 997, 286, 3270, 286, 743, 1148, 420, 3245, 374, 0, 330, 4956, 315, 320, 47, 2148, 13251, 286, 3270, 286, 422, 364, 47, 2148, 6, 539, 304, 659, 2245, 681, 49661, 44520, 220, 674, 7554, 43205, 82180, 198, 310, 3835, 284, 3573, 9290, 25, 43205, 82180, 1537, 1034, 82, 1, 1034, 659, 2245, 681, 49537, 99846, 4479, 4391, 330, 31716, 364, 4956, 315, 6, 320, 47, 2148, 19652, 310, 12721, 35842, 446, 6058, 6115, 8282, 1192, 310, 471, 271, 286, 2937, 3659, 284, 659, 2245, 681, 49661, 4274, 47, 2148, 10136, 15, 933, 286, 9382, 284, 659, 2245, 681, 17298, 16049, 286, 422, 2937, 3659, 304, 9382, 512, 310, 659, 2245, 681, 12840, 663, 284, 9382, 58, 4956, 3659, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
brentp/cruzdb
cruzdb/sqlsoup.py
SQLSoup.join
def join(self, left, right, onclause=None, isouter=False, base=None, **mapper_args): """Create an :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or table object. :param right: a mapped class or table object. :param onclause: optional "ON" clause construct.. :param isouter: if True, the join will be an OUTER join. :param base: a Python class which will be used as the base for the mapped class. If ``None``, the "base" argument specified by this :class:`.SQLSoup` instance's constructor will be used, which defaults to ``object``. :param mapper_args: Dictionary of arguments which will be passed directly to :func:`.orm.mapper`. """ j = join(left, right, onclause=onclause, isouter=isouter) return self.map(j, base=base, **mapper_args)
python
def join(self, left, right, onclause=None, isouter=False, base=None, **mapper_args): """Create an :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or table object. :param right: a mapped class or table object. :param onclause: optional "ON" clause construct.. :param isouter: if True, the join will be an OUTER join. :param base: a Python class which will be used as the base for the mapped class. If ``None``, the "base" argument specified by this :class:`.SQLSoup` instance's constructor will be used, which defaults to ``object``. :param mapper_args: Dictionary of arguments which will be passed directly to :func:`.orm.mapper`. """ j = join(left, right, onclause=onclause, isouter=isouter) return self.map(j, base=base, **mapper_args)
[ "def", "join", "(", "self", ",", "left", ",", "right", ",", "onclause", "=", "None", ",", "isouter", "=", "False", ",", "base", "=", "None", ",", "*", "*", "mapper_args", ")", ":", "j", "=", "join", "(", "left", ",", "right", ",", "onclause", "=", "onclause", ",", "isouter", "=", "isouter", ")", "return", "self", ".", "map", "(", "j", ",", "base", "=", "base", ",", "*", "*", "mapper_args", ")" ]
Create an :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or table object. :param right: a mapped class or table object. :param onclause: optional "ON" clause construct.. :param isouter: if True, the join will be an OUTER join. :param base: a Python class which will be used as the base for the mapped class. If ``None``, the "base" argument specified by this :class:`.SQLSoup` instance's constructor will be used, which defaults to ``object``. :param mapper_args: Dictionary of arguments which will be passed directly to :func:`.orm.mapper`.
[ "Create", "an", ":", "func", ":", ".", "expression", ".", "join", "and", "map", "to", "it", "." ]
train
https://github.com/brentp/cruzdb/blob/9068d46e25952f4a929dde0242beb31fa4c7e89a/cruzdb/sqlsoup.py#L425-L447
<|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 :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or table object. :param right: a mapped class or table object. :param onclause: optional "ON" clause construct.. :param isouter: if True, the join will be an OUTER join. :param base: a Python class which will be used as the base for the mapped class. If ``None``, the "base" argument specified by this :class:`.SQLSoup` instance's constructor will be used, which defaults to ``object``. :param mapper_args: Dictionary of arguments which will be passed directly to :func:`.orm.mapper`. ### Response: def join(self, left, right, onclause=None, isouter=False, base=None, **mapper_args): """Create an :func:`.expression.join` and map to it. The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6). :param left: a mapped class or table object. :param right: a mapped class or table object. :param onclause: optional "ON" clause construct.. :param isouter: if True, the join will be an OUTER join. :param base: a Python class which will be used as the base for the mapped class. If ``None``, the "base" argument specified by this :class:`.SQLSoup` instance's constructor will be used, which defaults to ``object``. :param mapper_args: Dictionary of arguments which will be passed directly to :func:`.orm.mapper`. """ j = join(left, right, onclause=onclause, isouter=isouter) return self.map(j, base=base, **mapper_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, 4110, 459, 551, 2900, 19258, 13, 29199, 5563, 63, 323, 2472, 311, 433, 382, 286, 578, 538, 323, 1202, 13021, 527, 539, 21224, 323, 690, 198, 286, 387, 44310, 3131, 26344, 809, 5886, 320, 300, 315, 220, 15, 13, 21, 13, 21, 3677, 286, 551, 913, 2163, 25, 264, 24784, 538, 477, 2007, 1665, 627, 286, 551, 913, 1314, 25, 264, 24784, 538, 477, 2007, 1665, 627, 286, 551, 913, 389, 83182, 25, 10309, 330, 715, 1, 22381, 9429, 35047, 286, 551, 913, 374, 2743, 25, 422, 3082, 11, 279, 5249, 690, 387, 459, 90775, 5249, 627, 286, 551, 913, 2385, 25, 264, 13325, 538, 902, 690, 387, 1511, 439, 279, 198, 692, 2385, 369, 279, 24784, 538, 13, 1442, 10103, 4155, 91816, 279, 330, 3231, 702, 692, 5811, 5300, 555, 420, 551, 1058, 19258, 13, 6827, 33642, 4077, 692, 2937, 596, 4797, 690, 387, 1511, 11, 902, 17088, 311, 198, 692, 10103, 1735, 14196, 627, 286, 551, 913, 25514, 8550, 25, 10685, 315, 6105, 902, 690, 198, 692, 387, 5946, 6089, 311, 551, 2900, 19258, 13, 494, 36076, 63438, 14711, 6075, 512, 755, 5249, 1214, 11, 2163, 11, 1314, 11, 389, 83182, 5980, 11, 374, 2743, 5725, 11, 720, 394, 2385, 5980, 11, 3146, 39176, 8550, 997, 286, 4304, 4110, 459, 551, 2900, 19258, 13, 29199, 5563, 63, 323, 2472, 311, 433, 382, 286, 578, 538, 323, 1202, 13021, 527, 539, 21224, 323, 690, 198, 286, 387, 44310, 3131, 26344, 809, 5886, 320, 300, 315, 220, 15, 13, 21, 13, 21, 3677, 286, 551, 913, 2163, 25, 264, 24784, 538, 477, 2007, 1665, 627, 286, 551, 913, 1314, 25, 264, 24784, 538, 477, 2007, 1665, 627, 286, 551, 913, 389, 83182, 25, 10309, 330, 715, 1, 22381, 9429, 35047, 286, 551, 913, 374, 2743, 25, 422, 3082, 11, 279, 5249, 690, 387, 459, 90775, 5249, 627, 286, 551, 913, 2385, 25, 264, 13325, 538, 902, 690, 387, 1511, 439, 279, 198, 692, 2385, 369, 279, 24784, 538, 13, 1442, 10103, 4155, 91816, 279, 330, 3231, 702, 692, 5811, 5300, 555, 420, 551, 1058, 19258, 13, 6827, 33642, 4077, 692, 2937, 596, 4797, 690, 387, 1511, 11, 902, 17088, 311, 198, 692, 10103, 1735, 14196, 627, 286, 551, 913, 25514, 8550, 25, 10685, 315, 6105, 902, 690, 198, 692, 387, 5946, 6089, 311, 551, 2900, 19258, 13, 494, 36076, 63438, 286, 12713, 286, 503, 284, 5249, 18139, 11, 1314, 11, 389, 83182, 28, 263, 83182, 11, 374, 2743, 93410, 2743, 340, 286, 471, 659, 4875, 3406, 11, 2385, 28, 3231, 11, 3146, 39176, 8550, 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 ]
[ 1, 1, 1,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 551, 2900, 19258, 13, 29199, 5563, 63, 323, 2472, 311, 433, 382, 286, 578, 538, 323, 1202, 13021, 527, 539, 21224, 323, 690, 198, 286, 387, 44310, 3131, 26344, 809, 5886, 320, 300, 315, 220, 15, 13, 21, 13, 21, 3677, 286, 551, 913, 2163, 25, 264, 24784, 538, 477, 2007, 1665, 627, 286, 551, 913, 1314, 25, 264, 24784, 538, 477, 2007, 1665, 627, 286, 551, 913, 389, 83182, 25, 10309, 330, 715, 1, 22381, 9429, 35047, 286, 551, 913, 374, 2743, 25, 422, 3082, 11, 279, 5249, 690, 387, 459, 90775, 5249, 627, 286, 551, 913, 2385, 25, 264, 13325, 538, 902, 690, 387, 1511, 439, 279, 198, 692, 2385, 369, 279, 24784, 538, 13, 1442, 10103, 4155, 91816, 279, 330, 3231, 702, 692, 5811, 5300, 555, 420, 551, 1058, 19258, 13, 6827, 33642, 4077, 692, 2937, 596, 4797, 690, 387, 1511, 11, 902, 17088, 311, 198, 692, 10103, 1735, 14196, 627, 286, 551, 913, 25514, 8550, 25, 10685, 315, 6105, 902, 690, 198, 692, 387, 5946, 6089, 311, 551, 2900, 19258, 13, 494, 36076, 63438, 14711, 6075, 512, 755, 5249, 1214, 11, 2163, 11, 1314, 11, 389, 83182, 5980, 11, 374, 2743, 5725, 11, 720, 394, 2385, 5980, 11, 3146, 39176, 8550, 997, 286, 4304, 4110, 459, 551, 2900, 19258, 13, 29199, 5563, 63, 323, 2472, 311, 433, 382, 286, 578, 538, 323, 1202, 13021, 527, 539, 21224, 323, 690, 198, 286, 387, 44310, 3131, 26344, 809, 5886, 320, 300, 315, 220, 15, 13, 21, 13, 21, 3677, 286, 551, 913, 2163, 25, 264, 24784, 538, 477, 2007, 1665, 627, 286, 551, 913, 1314, 25, 264, 24784, 538, 477, 2007, 1665, 627, 286, 551, 913, 389, 83182, 25, 10309, 330, 715, 1, 22381, 9429, 35047, 286, 551, 913, 374, 2743, 25, 422, 3082, 11, 279, 5249, 690, 387, 459, 90775, 5249, 627, 286, 551, 913, 2385, 25, 264, 13325, 538, 902, 690, 387, 1511, 439, 279, 198, 692, 2385, 369, 279, 24784, 538, 13, 1442, 10103, 4155, 91816, 279, 330, 3231, 702, 692, 5811, 5300, 555, 420, 551, 1058, 19258, 13, 6827, 33642, 4077, 692, 2937, 596, 4797, 690, 387, 1511, 11, 902, 17088, 311, 198, 692, 10103, 1735, 14196, 627, 286, 551, 913, 25514, 8550, 25, 10685, 315, 6105, 902, 690, 198, 692, 387, 5946, 6089, 311, 551, 2900, 19258, 13, 494, 36076, 63438, 286, 12713, 286, 503, 284, 5249, 18139, 11, 1314, 11, 389, 83182, 28, 263, 83182, 11, 374, 2743, 93410, 2743, 340, 286, 471, 659, 4875, 3406, 11, 2385, 28, 3231, 11, 3146, 39176, 8550, 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 ]
Zaeb0s/epoll-socket-server
esockets/socket_server.py
SocketServer._mainthread_accept_clients
def _mainthread_accept_clients(self): """Accepts new clients and sends them to the to _handle_accepted within a subthread """ try: if self._accept_selector.select(timeout=self.block_time): client = self._server_socket.accept() logging.info('Client connected: {}'.format(client[1])) self._threads_limiter.start_thread(target=self._subthread_handle_accepted, args=(client,)) except socket.error: pass
python
def _mainthread_accept_clients(self): """Accepts new clients and sends them to the to _handle_accepted within a subthread """ try: if self._accept_selector.select(timeout=self.block_time): client = self._server_socket.accept() logging.info('Client connected: {}'.format(client[1])) self._threads_limiter.start_thread(target=self._subthread_handle_accepted, args=(client,)) except socket.error: pass
[ "def", "_mainthread_accept_clients", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_accept_selector", ".", "select", "(", "timeout", "=", "self", ".", "block_time", ")", ":", "client", "=", "self", ".", "_server_socket", ".", "accept", "(", ")", "logging", ".", "info", "(", "'Client connected: {}'", ".", "format", "(", "client", "[", "1", "]", ")", ")", "self", ".", "_threads_limiter", ".", "start_thread", "(", "target", "=", "self", ".", "_subthread_handle_accepted", ",", "args", "=", "(", "client", ",", ")", ")", "except", "socket", ".", "error", ":", "pass" ]
Accepts new clients and sends them to the to _handle_accepted within a subthread
[ "Accepts", "new", "clients", "and", "sends", "them", "to", "the", "to", "_handle_accepted", "within", "a", "subthread" ]
train
https://github.com/Zaeb0s/epoll-socket-server/blob/0b8c8b3c368f8948777579ea1e89e75ab5899372/esockets/socket_server.py#L103-L114
<|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: Accepts new clients and sends them to the to _handle_accepted within a subthread ### Response: def _mainthread_accept_clients(self): """Accepts new clients and sends them to the to _handle_accepted within a subthread """ try: if self._accept_selector.select(timeout=self.block_time): client = self._server_socket.accept() logging.info('Client connected: {}'.format(client[1])) self._threads_limiter.start_thread(target=self._subthread_handle_accepted, args=(client,)) except socket.error: pass <|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, 17059, 82, 502, 8403, 323, 22014, 1124, 311, 279, 311, 721, 8355, 91454, 2949, 264, 1207, 4629, 271, 14711, 6075, 512, 755, 721, 3902, 4629, 36828, 57999, 1214, 997, 286, 4304, 17059, 82, 502, 8403, 323, 22014, 1124, 311, 279, 311, 721, 8355, 91454, 2949, 264, 1207, 4629, 198, 286, 3270, 286, 1456, 512, 310, 422, 659, 1462, 10543, 29990, 9911, 40066, 7822, 16072, 3084, 997, 394, 3016, 284, 659, 1462, 4120, 20125, 29662, 746, 394, 8558, 5506, 493, 3032, 8599, 25, 26307, 2293, 13097, 58, 16, 38028, 394, 659, 1462, 28386, 918, 18170, 5069, 11048, 8807, 7822, 1462, 2008, 4629, 10855, 91454, 345, 22232, 2897, 4640, 3045, 54378, 286, 3734, 7728, 4517, 512, 310, 1522, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 17059, 82, 502, 8403, 323, 22014, 1124, 311, 279, 311, 721, 8355, 91454, 2949, 264, 1207, 4629, 271, 14711, 6075, 512, 755, 721, 3902, 4629, 36828, 57999, 1214, 997, 286, 4304, 17059, 82, 502, 8403, 323, 22014, 1124, 311, 279, 311, 721, 8355, 91454, 2949, 264, 1207, 4629, 198, 286, 3270, 286, 1456, 512, 310, 422, 659, 1462, 10543, 29990, 9911, 40066, 7822, 16072, 3084, 997, 394, 3016, 284, 659, 1462, 4120, 20125, 29662, 746, 394, 8558, 5506, 493, 3032, 8599, 25, 26307, 2293, 13097, 58, 16, 38028, 394, 659, 1462, 28386, 918, 18170, 5069, 11048, 8807, 7822, 1462, 2008, 4629, 10855, 91454, 345, 22232, 2897, 4640, 3045, 54378, 286, 3734, 7728, 4517, 512, 310, 1522, 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 ]
uogbuji/versa
tools/py/pipeline/core_actions.py
res
def res(arg): ''' Convert the argument into an IRI ref ''' def _res(ctx): _arg = arg(ctx) if callable(arg) else arg return I(arg) return _res
python
def res(arg): ''' Convert the argument into an IRI ref ''' def _res(ctx): _arg = arg(ctx) if callable(arg) else arg return I(arg) return _res
[ "def", "res", "(", "arg", ")", ":", "def", "_res", "(", "ctx", ")", ":", "_arg", "=", "arg", "(", "ctx", ")", "if", "callable", "(", "arg", ")", "else", "arg", "return", "I", "(", "arg", ")", "return", "_res" ]
Convert the argument into an IRI ref
[ "Convert", "the", "argument", "into", "an", "IRI", "ref" ]
train
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/core_actions.py#L322-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: Convert the argument into an IRI ref ### Response: def res(arg): ''' Convert the argument into an IRI ref ''' def _res(ctx): _arg = arg(ctx) if callable(arg) else arg return I(arg) 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, 12281, 279, 5811, 1139, 459, 358, 4403, 2098, 271, 14711, 6075, 512, 755, 594, 9590, 997, 262, 11414, 262, 7316, 279, 5811, 1139, 459, 358, 4403, 2098, 198, 262, 11414, 262, 711, 721, 417, 7654, 997, 286, 721, 867, 284, 1417, 7654, 8, 422, 42022, 9590, 8, 775, 1417, 198, 286, 471, 358, 9590, 340, 262, 471, 721, 417, 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,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 279, 5811, 1139, 459, 358, 4403, 2098, 271, 14711, 6075, 512, 755, 594, 9590, 997, 262, 11414, 262, 7316, 279, 5811, 1139, 459, 358, 4403, 2098, 198, 262, 11414, 262, 711, 721, 417, 7654, 997, 286, 721, 867, 284, 1417, 7654, 8, 422, 42022, 9590, 8, 775, 1417, 198, 286, 471, 358, 9590, 340, 262, 471, 721, 417, 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 ]
RJT1990/pyflux
pyflux/families/t.py
t.second_order_score
def second_order_score(y, mean, scale, shape, skewness): """ GAS t Update term potentially using second-order information - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the t distribution scale : float scale parameter for the t distribution shape : float tail thickness parameter for the t distribution skewness : float skewness parameter for the t distribution Returns ---------- - Adjusted score of the t family """ return ((shape+1)/shape)*(y-mean)/(np.power(scale,2) + (np.power(y-mean,2)/shape))/((shape+1)*((np.power(scale,2)*shape) - np.power(y-mean,2))/np.power((np.power(scale,2)*shape) + np.power(y-mean,2),2))
python
def second_order_score(y, mean, scale, shape, skewness): """ GAS t Update term potentially using second-order information - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the t distribution scale : float scale parameter for the t distribution shape : float tail thickness parameter for the t distribution skewness : float skewness parameter for the t distribution Returns ---------- - Adjusted score of the t family """ return ((shape+1)/shape)*(y-mean)/(np.power(scale,2) + (np.power(y-mean,2)/shape))/((shape+1)*((np.power(scale,2)*shape) - np.power(y-mean,2))/np.power((np.power(scale,2)*shape) + np.power(y-mean,2),2))
[ "def", "second_order_score", "(", "y", ",", "mean", ",", "scale", ",", "shape", ",", "skewness", ")", ":", "return", "(", "(", "shape", "+", "1", ")", "/", "shape", ")", "*", "(", "y", "-", "mean", ")", "/", "(", "np", ".", "power", "(", "scale", ",", "2", ")", "+", "(", "np", ".", "power", "(", "y", "-", "mean", ",", "2", ")", "/", "shape", ")", ")", "/", "(", "(", "shape", "+", "1", ")", "*", "(", "(", "np", ".", "power", "(", "scale", ",", "2", ")", "*", "shape", ")", "-", "np", ".", "power", "(", "y", "-", "mean", ",", "2", ")", ")", "/", "np", ".", "power", "(", "(", "np", ".", "power", "(", "scale", ",", "2", ")", "*", "shape", ")", "+", "np", ".", "power", "(", "y", "-", "mean", ",", "2", ")", ",", "2", ")", ")" ]
GAS t Update term potentially using second-order information - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the t distribution scale : float scale parameter for the t distribution shape : float tail thickness parameter for the t distribution skewness : float skewness parameter for the t distribution Returns ---------- - Adjusted score of the t family
[ "GAS", "t", "Update", "term", "potentially", "using", "second", "-", "order", "information", "-", "native", "Python", "function" ]
train
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/t.py#L330-L354
<|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: GAS t Update term potentially using second-order information - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the t distribution scale : float scale parameter for the t distribution shape : float tail thickness parameter for the t distribution skewness : float skewness parameter for the t distribution Returns ---------- - Adjusted score of the t family ### Response: def second_order_score(y, mean, scale, shape, skewness): """ GAS t Update term potentially using second-order information - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the t distribution scale : float scale parameter for the t distribution shape : float tail thickness parameter for the t distribution skewness : float skewness parameter for the t distribution Returns ---------- - Adjusted score of the t family """ return ((shape+1)/shape)*(y-mean)/(np.power(scale,2) + (np.power(y-mean,2)/shape))/((shape+1)*((np.power(scale,2)*shape) - np.power(y-mean,2))/np.power((np.power(scale,2)*shape) + np.power(y-mean,2),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, 38, 1950, 259, 5666, 4751, 13893, 1701, 2132, 24747, 2038, 482, 10068, 13325, 734, 271, 286, 13831, 198, 286, 31423, 286, 379, 551, 2273, 198, 310, 62823, 787, 369, 279, 892, 4101, 271, 286, 3152, 551, 2273, 198, 310, 3813, 5852, 369, 279, 259, 8141, 271, 286, 5569, 551, 2273, 198, 310, 5569, 5852, 369, 279, 259, 8141, 271, 286, 6211, 551, 2273, 198, 310, 9986, 26839, 5852, 369, 279, 259, 8141, 271, 286, 41643, 2136, 551, 2273, 198, 310, 41643, 2136, 5852, 369, 279, 259, 8141, 271, 286, 5295, 198, 286, 31423, 286, 482, 28295, 291, 5573, 315, 279, 259, 3070, 271, 14711, 6075, 512, 755, 2132, 8028, 10622, 7166, 11, 3152, 11, 5569, 11, 6211, 11, 41643, 2136, 997, 286, 4304, 90809, 259, 5666, 4751, 13893, 1701, 2132, 24747, 2038, 482, 10068, 13325, 734, 271, 286, 13831, 198, 286, 31423, 286, 379, 551, 2273, 198, 310, 62823, 787, 369, 279, 892, 4101, 271, 286, 3152, 551, 2273, 198, 310, 3813, 5852, 369, 279, 259, 8141, 271, 286, 5569, 551, 2273, 198, 310, 5569, 5852, 369, 279, 259, 8141, 271, 286, 6211, 551, 2273, 198, 310, 9986, 26839, 5852, 369, 279, 259, 8141, 271, 286, 41643, 2136, 551, 2273, 198, 310, 41643, 2136, 5852, 369, 279, 259, 8141, 271, 286, 5295, 198, 286, 31423, 286, 482, 28295, 291, 5573, 315, 279, 259, 3070, 198, 286, 3270, 286, 471, 1819, 12510, 10, 16, 5738, 12510, 18201, 88, 84096, 25239, 6331, 40645, 43173, 11, 17, 8, 489, 320, 6331, 40645, 7166, 84096, 11, 17, 5738, 12510, 31185, 1209, 12510, 10, 16, 4911, 1209, 6331, 40645, 43173, 11, 17, 4911, 12510, 8, 482, 2660, 40645, 7166, 84096, 11, 17, 31185, 6331, 40645, 1209, 6331, 40645, 43173, 11, 17, 4911, 12510, 8, 489, 2660, 40645, 7166, 84096, 11, 17, 705, 17, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 38, 1950, 259, 5666, 4751, 13893, 1701, 2132, 24747, 2038, 482, 10068, 13325, 734, 271, 286, 13831, 198, 286, 31423, 286, 379, 551, 2273, 198, 310, 62823, 787, 369, 279, 892, 4101, 271, 286, 3152, 551, 2273, 198, 310, 3813, 5852, 369, 279, 259, 8141, 271, 286, 5569, 551, 2273, 198, 310, 5569, 5852, 369, 279, 259, 8141, 271, 286, 6211, 551, 2273, 198, 310, 9986, 26839, 5852, 369, 279, 259, 8141, 271, 286, 41643, 2136, 551, 2273, 198, 310, 41643, 2136, 5852, 369, 279, 259, 8141, 271, 286, 5295, 198, 286, 31423, 286, 482, 28295, 291, 5573, 315, 279, 259, 3070, 271, 14711, 6075, 512, 755, 2132, 8028, 10622, 7166, 11, 3152, 11, 5569, 11, 6211, 11, 41643, 2136, 997, 286, 4304, 90809, 259, 5666, 4751, 13893, 1701, 2132, 24747, 2038, 482, 10068, 13325, 734, 271, 286, 13831, 198, 286, 31423, 286, 379, 551, 2273, 198, 310, 62823, 787, 369, 279, 892, 4101, 271, 286, 3152, 551, 2273, 198, 310, 3813, 5852, 369, 279, 259, 8141, 271, 286, 5569, 551, 2273, 198, 310, 5569, 5852, 369, 279, 259, 8141, 271, 286, 6211, 551, 2273, 198, 310, 9986, 26839, 5852, 369, 279, 259, 8141, 271, 286, 41643, 2136, 551, 2273, 198, 310, 41643, 2136, 5852, 369, 279, 259, 8141, 271, 286, 5295, 198, 286, 31423, 286, 482, 28295, 291, 5573, 315, 279, 259, 3070, 198, 286, 3270, 286, 471, 1819, 12510, 10, 16, 5738, 12510, 18201, 88, 84096, 25239, 6331, 40645, 43173, 11, 17, 8, 489, 320, 6331, 40645, 7166, 84096, 11, 17, 5738, 12510, 31185, 1209, 12510, 10, 16, 4911, 1209, 6331, 40645, 43173, 11, 17, 4911, 12510, 8, 482, 2660, 40645, 7166, 84096, 11, 17, 31185, 6331, 40645, 1209, 6331, 40645, 43173, 11, 17, 4911, 12510, 8, 489, 2660, 40645, 7166, 84096, 11, 17, 705, 17, 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 ]
googleapis/google-cloud-python
translate/google/cloud/translate_v3beta1/gapic/translation_service_client.py
TranslationServiceClient.translate_text
def translate_text( self, contents, target_language_code, mime_type=None, source_language_code=None, parent=None, model=None, glossary_config=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Translates input text and returns translated text. Example: >>> from google.cloud import translate_v3beta1 >>> >>> client = translate_v3beta1.TranslationServiceClient() >>> >>> # TODO: Initialize `contents`: >>> contents = [] >>> >>> # TODO: Initialize `target_language_code`: >>> target_language_code = '' >>> >>> response = client.translate_text(contents, target_language_code) Args: contents (list[str]): Required. The content of the input in string format. We recommend the total contents to be less than 30k codepoints. Please use BatchTranslateText for larger text. target_language_code (str): Required. The BCP-47 language code to use for translation of the input text, set to one of the language codes listed in Language Support. mime_type (str): Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type is assumed to be "text/html". source_language_code (str): Optional. The BCP-47 language code of the input text if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the the source language within the response. parent (str): Optional. Only used when making regionalized call. Format: projects/{project-id}/locations/{location-id}. Only custom model/glossary within the same location-id can be used. Otherwise 400 is returned. model (str): Optional. The ``model`` type requested for this translation. The format depends on model type: 1. Custom models: projects/{project-id}/locations/{location-id}/models/{model-id}. 2. General (built-in) models: projects/{project-id}/locations/{location-id}/models/general/nmt projects/{project-id}/locations/{location-id}/models/general/base For global (non-regionalized) requests, use {location-id} 'global'. For example, projects/{project-id}/locations/global/models/general/nmt If missing, the system decides which google base model to use. glossary_config (Union[dict, ~google.cloud.translate_v3beta1.types.TranslateTextGlossaryConfig]): Optional. Glossary to be applied. The glossary needs to be in the same region as the model, otherwise an INVALID\_ARGUMENT error is returned. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.translate_v3beta1.types.TranslateTextGlossaryConfig` retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will not be retried. timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata that is provided to the method. Returns: A :class:`~google.cloud.translate_v3beta1.types.TranslateTextResponse` instance. Raises: google.api_core.exceptions.GoogleAPICallError: If the request failed for any reason. google.api_core.exceptions.RetryError: If the request failed due to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. if "translate_text" not in self._inner_api_calls: self._inner_api_calls[ "translate_text" ] = google.api_core.gapic_v1.method.wrap_method( self.transport.translate_text, default_retry=self._method_configs["TranslateText"].retry, default_timeout=self._method_configs["TranslateText"].timeout, client_info=self._client_info, ) request = translation_service_pb2.TranslateTextRequest( contents=contents, target_language_code=target_language_code, mime_type=mime_type, source_language_code=source_language_code, parent=parent, model=model, glossary_config=glossary_config, ) if metadata is None: metadata = [] metadata = list(metadata) try: routing_header = [("parent", parent)] except AttributeError: pass else: routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( routing_header ) metadata.append(routing_metadata) return self._inner_api_calls["translate_text"]( request, retry=retry, timeout=timeout, metadata=metadata )
python
def translate_text( self, contents, target_language_code, mime_type=None, source_language_code=None, parent=None, model=None, glossary_config=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Translates input text and returns translated text. Example: >>> from google.cloud import translate_v3beta1 >>> >>> client = translate_v3beta1.TranslationServiceClient() >>> >>> # TODO: Initialize `contents`: >>> contents = [] >>> >>> # TODO: Initialize `target_language_code`: >>> target_language_code = '' >>> >>> response = client.translate_text(contents, target_language_code) Args: contents (list[str]): Required. The content of the input in string format. We recommend the total contents to be less than 30k codepoints. Please use BatchTranslateText for larger text. target_language_code (str): Required. The BCP-47 language code to use for translation of the input text, set to one of the language codes listed in Language Support. mime_type (str): Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type is assumed to be "text/html". source_language_code (str): Optional. The BCP-47 language code of the input text if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the the source language within the response. parent (str): Optional. Only used when making regionalized call. Format: projects/{project-id}/locations/{location-id}. Only custom model/glossary within the same location-id can be used. Otherwise 400 is returned. model (str): Optional. The ``model`` type requested for this translation. The format depends on model type: 1. Custom models: projects/{project-id}/locations/{location-id}/models/{model-id}. 2. General (built-in) models: projects/{project-id}/locations/{location-id}/models/general/nmt projects/{project-id}/locations/{location-id}/models/general/base For global (non-regionalized) requests, use {location-id} 'global'. For example, projects/{project-id}/locations/global/models/general/nmt If missing, the system decides which google base model to use. glossary_config (Union[dict, ~google.cloud.translate_v3beta1.types.TranslateTextGlossaryConfig]): Optional. Glossary to be applied. The glossary needs to be in the same region as the model, otherwise an INVALID\_ARGUMENT error is returned. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.translate_v3beta1.types.TranslateTextGlossaryConfig` retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will not be retried. timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata that is provided to the method. Returns: A :class:`~google.cloud.translate_v3beta1.types.TranslateTextResponse` instance. Raises: google.api_core.exceptions.GoogleAPICallError: If the request failed for any reason. google.api_core.exceptions.RetryError: If the request failed due to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. if "translate_text" not in self._inner_api_calls: self._inner_api_calls[ "translate_text" ] = google.api_core.gapic_v1.method.wrap_method( self.transport.translate_text, default_retry=self._method_configs["TranslateText"].retry, default_timeout=self._method_configs["TranslateText"].timeout, client_info=self._client_info, ) request = translation_service_pb2.TranslateTextRequest( contents=contents, target_language_code=target_language_code, mime_type=mime_type, source_language_code=source_language_code, parent=parent, model=model, glossary_config=glossary_config, ) if metadata is None: metadata = [] metadata = list(metadata) try: routing_header = [("parent", parent)] except AttributeError: pass else: routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( routing_header ) metadata.append(routing_metadata) return self._inner_api_calls["translate_text"]( request, retry=retry, timeout=timeout, metadata=metadata )
[ "def", "translate_text", "(", "self", ",", "contents", ",", "target_language_code", ",", "mime_type", "=", "None", ",", "source_language_code", "=", "None", ",", "parent", "=", "None", ",", "model", "=", "None", ",", "glossary_config", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "metadata", "=", "None", ",", ")", ":", "# Wrap the transport method to add retry and timeout logic.", "if", "\"translate_text\"", "not", "in", "self", ".", "_inner_api_calls", ":", "self", ".", "_inner_api_calls", "[", "\"translate_text\"", "]", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "wrap_method", "(", "self", ".", "transport", ".", "translate_text", ",", "default_retry", "=", "self", ".", "_method_configs", "[", "\"TranslateText\"", "]", ".", "retry", ",", "default_timeout", "=", "self", ".", "_method_configs", "[", "\"TranslateText\"", "]", ".", "timeout", ",", "client_info", "=", "self", ".", "_client_info", ",", ")", "request", "=", "translation_service_pb2", ".", "TranslateTextRequest", "(", "contents", "=", "contents", ",", "target_language_code", "=", "target_language_code", ",", "mime_type", "=", "mime_type", ",", "source_language_code", "=", "source_language_code", ",", "parent", "=", "parent", ",", "model", "=", "model", ",", "glossary_config", "=", "glossary_config", ",", ")", "if", "metadata", "is", "None", ":", "metadata", "=", "[", "]", "metadata", "=", "list", "(", "metadata", ")", "try", ":", "routing_header", "=", "[", "(", "\"parent\"", ",", "parent", ")", "]", "except", "AttributeError", ":", "pass", "else", ":", "routing_metadata", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "routing_header", ".", "to_grpc_metadata", "(", "routing_header", ")", "metadata", ".", "append", "(", "routing_metadata", ")", "return", "self", ".", "_inner_api_calls", "[", "\"translate_text\"", "]", "(", "request", ",", "retry", "=", "retry", ",", "timeout", "=", "timeout", ",", "metadata", "=", "metadata", ")" ]
Translates input text and returns translated text. Example: >>> from google.cloud import translate_v3beta1 >>> >>> client = translate_v3beta1.TranslationServiceClient() >>> >>> # TODO: Initialize `contents`: >>> contents = [] >>> >>> # TODO: Initialize `target_language_code`: >>> target_language_code = '' >>> >>> response = client.translate_text(contents, target_language_code) Args: contents (list[str]): Required. The content of the input in string format. We recommend the total contents to be less than 30k codepoints. Please use BatchTranslateText for larger text. target_language_code (str): Required. The BCP-47 language code to use for translation of the input text, set to one of the language codes listed in Language Support. mime_type (str): Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type is assumed to be "text/html". source_language_code (str): Optional. The BCP-47 language code of the input text if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the the source language within the response. parent (str): Optional. Only used when making regionalized call. Format: projects/{project-id}/locations/{location-id}. Only custom model/glossary within the same location-id can be used. Otherwise 400 is returned. model (str): Optional. The ``model`` type requested for this translation. The format depends on model type: 1. Custom models: projects/{project-id}/locations/{location-id}/models/{model-id}. 2. General (built-in) models: projects/{project-id}/locations/{location-id}/models/general/nmt projects/{project-id}/locations/{location-id}/models/general/base For global (non-regionalized) requests, use {location-id} 'global'. For example, projects/{project-id}/locations/global/models/general/nmt If missing, the system decides which google base model to use. glossary_config (Union[dict, ~google.cloud.translate_v3beta1.types.TranslateTextGlossaryConfig]): Optional. Glossary to be applied. The glossary needs to be in the same region as the model, otherwise an INVALID\_ARGUMENT error is returned. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.translate_v3beta1.types.TranslateTextGlossaryConfig` retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will not be retried. timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata that is provided to the method. Returns: A :class:`~google.cloud.translate_v3beta1.types.TranslateTextResponse` instance. Raises: google.api_core.exceptions.GoogleAPICallError: If the request failed for any reason. google.api_core.exceptions.RetryError: If the request failed due to a retryable error and retry attempts failed. ValueError: If the parameters are invalid.
[ "Translates", "input", "text", "and", "returns", "translated", "text", "." ]
train
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/translate/google/cloud/translate_v3beta1/gapic/translation_service_client.py#L196-L317
<|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: Translates input text and returns translated text. Example: >>> from google.cloud import translate_v3beta1 >>> >>> client = translate_v3beta1.TranslationServiceClient() >>> >>> # TODO: Initialize `contents`: >>> contents = [] >>> >>> # TODO: Initialize `target_language_code`: >>> target_language_code = '' >>> >>> response = client.translate_text(contents, target_language_code) Args: contents (list[str]): Required. The content of the input in string format. We recommend the total contents to be less than 30k codepoints. Please use BatchTranslateText for larger text. target_language_code (str): Required. The BCP-47 language code to use for translation of the input text, set to one of the language codes listed in Language Support. mime_type (str): Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type is assumed to be "text/html". source_language_code (str): Optional. The BCP-47 language code of the input text if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the the source language within the response. parent (str): Optional. Only used when making regionalized call. Format: projects/{project-id}/locations/{location-id}. Only custom model/glossary within the same location-id can be used. Otherwise 400 is returned. model (str): Optional. The ``model`` type requested for this translation. The format depends on model type: 1. Custom models: projects/{project-id}/locations/{location-id}/models/{model-id}. 2. General (built-in) models: projects/{project-id}/locations/{location-id}/models/general/nmt projects/{project-id}/locations/{location-id}/models/general/base For global (non-regionalized) requests, use {location-id} 'global'. For example, projects/{project-id}/locations/global/models/general/nmt If missing, the system decides which google base model to use. glossary_config (Union[dict, ~google.cloud.translate_v3beta1.types.TranslateTextGlossaryConfig]): Optional. Glossary to be applied. The glossary needs to be in the same region as the model, otherwise an INVALID\_ARGUMENT error is returned. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.translate_v3beta1.types.TranslateTextGlossaryConfig` retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will not be retried. timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata that is provided to the method. Returns: A :class:`~google.cloud.translate_v3beta1.types.TranslateTextResponse` instance. Raises: google.api_core.exceptions.GoogleAPICallError: If the request failed for any reason. google.api_core.exceptions.RetryError: If the request failed due to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. ### Response: def translate_text( self, contents, target_language_code, mime_type=None, source_language_code=None, parent=None, model=None, glossary_config=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Translates input text and returns translated text. Example: >>> from google.cloud import translate_v3beta1 >>> >>> client = translate_v3beta1.TranslationServiceClient() >>> >>> # TODO: Initialize `contents`: >>> contents = [] >>> >>> # TODO: Initialize `target_language_code`: >>> target_language_code = '' >>> >>> response = client.translate_text(contents, target_language_code) Args: contents (list[str]): Required. The content of the input in string format. We recommend the total contents to be less than 30k codepoints. Please use BatchTranslateText for larger text. target_language_code (str): Required. The BCP-47 language code to use for translation of the input text, set to one of the language codes listed in Language Support. mime_type (str): Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type is assumed to be "text/html". source_language_code (str): Optional. The BCP-47 language code of the input text if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the the source language within the response. parent (str): Optional. Only used when making regionalized call. Format: projects/{project-id}/locations/{location-id}. Only custom model/glossary within the same location-id can be used. Otherwise 400 is returned. model (str): Optional. The ``model`` type requested for this translation. The format depends on model type: 1. Custom models: projects/{project-id}/locations/{location-id}/models/{model-id}. 2. General (built-in) models: projects/{project-id}/locations/{location-id}/models/general/nmt projects/{project-id}/locations/{location-id}/models/general/base For global (non-regionalized) requests, use {location-id} 'global'. For example, projects/{project-id}/locations/global/models/general/nmt If missing, the system decides which google base model to use. glossary_config (Union[dict, ~google.cloud.translate_v3beta1.types.TranslateTextGlossaryConfig]): Optional. Glossary to be applied. The glossary needs to be in the same region as the model, otherwise an INVALID\_ARGUMENT error is returned. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.translate_v3beta1.types.TranslateTextGlossaryConfig` retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will not be retried. timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata that is provided to the method. Returns: A :class:`~google.cloud.translate_v3beta1.types.TranslateTextResponse` instance. Raises: google.api_core.exceptions.GoogleAPICallError: If the request failed for any reason. google.api_core.exceptions.RetryError: If the request failed due to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. if "translate_text" not in self._inner_api_calls: self._inner_api_calls[ "translate_text" ] = google.api_core.gapic_v1.method.wrap_method( self.transport.translate_text, default_retry=self._method_configs["TranslateText"].retry, default_timeout=self._method_configs["TranslateText"].timeout, client_info=self._client_info, ) request = translation_service_pb2.TranslateTextRequest( contents=contents, target_language_code=target_language_code, mime_type=mime_type, source_language_code=source_language_code, parent=parent, model=model, glossary_config=glossary_config, ) if metadata is None: metadata = [] metadata = list(metadata) try: routing_header = [("parent", parent)] except AttributeError: pass else: routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( routing_header ) metadata.append(routing_metadata) return self._inner_api_calls["translate_text"]( request, retry=retry, timeout=timeout, metadata=metadata ) <|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, 3246, 49346, 1988, 1495, 323, 4780, 25548, 1495, 382, 286, 13688, 512, 310, 12382, 505, 11819, 17365, 1179, 15025, 2325, 18, 19674, 16, 198, 310, 3662, 397, 310, 12382, 3016, 284, 15025, 2325, 18, 19674, 16, 12078, 2354, 1898, 3032, 746, 310, 3662, 397, 310, 12382, 674, 5456, 25, 9185, 1595, 18075, 63, 512, 310, 12382, 8970, 284, 4260, 310, 3662, 397, 310, 12382, 674, 5456, 25, 9185, 1595, 5775, 30121, 4229, 63, 512, 310, 12382, 2218, 30121, 4229, 284, 12038, 310, 3662, 397, 310, 12382, 2077, 284, 3016, 26998, 4424, 48064, 11, 2218, 30121, 4229, 696, 286, 18161, 512, 310, 8970, 320, 1638, 17752, 25312, 12948, 13, 578, 2262, 315, 279, 1988, 304, 925, 3645, 627, 394, 1226, 7079, 279, 2860, 8970, 311, 387, 2753, 1109, 220, 966, 74, 2082, 7862, 627, 394, 5321, 1005, 35004, 28573, 1199, 369, 8294, 1495, 627, 310, 2218, 30121, 4229, 320, 496, 1680, 12948, 13, 578, 426, 7269, 12, 2618, 4221, 2082, 311, 1005, 369, 14807, 315, 279, 1988, 198, 394, 1495, 11, 743, 311, 832, 315, 279, 4221, 14236, 10212, 304, 11688, 9365, 627, 310, 46370, 1857, 320, 496, 1680, 12536, 13, 578, 3645, 315, 279, 2592, 1495, 11, 369, 3187, 11, 330, 1342, 14056, 761, 338, 330, 1342, 38071, 3343, 1442, 2163, 10321, 11, 279, 58577, 955, 374, 19655, 311, 387, 330, 1342, 14056, 23811, 310, 2592, 30121, 4229, 320, 496, 1680, 12536, 13, 578, 426, 7269, 12, 2618, 4221, 2082, 315, 279, 1988, 1495, 422, 198, 394, 3967, 11, 369, 3187, 11, 330, 268, 33440, 1, 477, 330, 15444, 8288, 266, 77, 3343, 50080, 4221, 14236, 527, 198, 394, 10212, 304, 11688, 9365, 13, 1442, 279, 2592, 4221, 4536, 956, 5300, 11, 279, 5446, 198, 394, 13865, 311, 10765, 279, 2592, 4221, 9651, 323, 4780, 279, 198, 394, 279, 2592, 4221, 2949, 279, 2077, 627, 310, 2748, 320, 496, 1680, 12536, 13, 8442, 1511, 994, 3339, 15481, 1534, 1650, 627, 394, 15392, 512, 394, 7224, 9573, 5094, 13193, 4572, 32409, 9573, 2588, 13193, 92, 382, 394, 8442, 2587, 1646, 4951, 9563, 661, 2949, 279, 1890, 3813, 13193, 649, 387, 1511, 627, 394, 18715, 220, 3443, 374, 6052, 627, 310, 1646, 320, 496, 1680, 12536, 13, 578, 10103, 2590, 14196, 955, 11472, 369, 420, 14807, 382, 394, 578, 3645, 14117, 389, 1646, 955, 1473, 394, 220, 16, 13, 8572, 4211, 512, 4391, 7224, 9573, 5094, 13193, 4572, 32409, 9573, 2588, 13193, 4572, 6644, 9573, 2590, 13193, 28374, 394, 220, 17, 13, 3331, 320, 47339, 3502, 8, 4211, 512, 4391, 7224, 9573, 5094, 13193, 4572, 32409, 9573, 2588, 13193, 4572, 6644, 67061, 9809, 2562, 198, 4391, 7224, 9573, 5094, 13193, 4572, 32409, 9573, 2588, 13193, 4572, 6644, 67061, 27182, 271, 394, 1789, 3728, 320, 6414, 33263, 4001, 1534, 8, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 3246, 49346, 1988, 1495, 323, 4780, 25548, 1495, 382, 286, 13688, 512, 310, 12382, 505, 11819, 17365, 1179, 15025, 2325, 18, 19674, 16, 198, 310, 3662, 397, 310, 12382, 3016, 284, 15025, 2325, 18, 19674, 16, 12078, 2354, 1898, 3032, 746, 310, 3662, 397, 310, 12382, 674, 5456, 25, 9185, 1595, 18075, 63, 512, 310, 12382, 8970, 284, 4260, 310, 3662, 397, 310, 12382, 674, 5456, 25, 9185, 1595, 5775, 30121, 4229, 63, 512, 310, 12382, 2218, 30121, 4229, 284, 12038, 310, 3662, 397, 310, 12382, 2077, 284, 3016, 26998, 4424, 48064, 11, 2218, 30121, 4229, 696, 286, 18161, 512, 310, 8970, 320, 1638, 17752, 25312, 12948, 13, 578, 2262, 315, 279, 1988, 304, 925, 3645, 627, 394, 1226, 7079, 279, 2860, 8970, 311, 387, 2753, 1109, 220, 966, 74, 2082, 7862, 627, 394, 5321, 1005, 35004, 28573, 1199, 369, 8294, 1495, 627, 310, 2218, 30121, 4229, 320, 496, 1680, 12948, 13, 578, 426, 7269, 12, 2618, 4221, 2082, 311, 1005, 369, 14807, 315, 279, 1988, 198, 394, 1495, 11, 743, 311, 832, 315, 279, 4221, 14236, 10212, 304, 11688, 9365, 627, 310, 46370, 1857, 320, 496, 1680, 12536, 13, 578, 3645, 315, 279, 2592, 1495, 11, 369, 3187, 11, 330, 1342, 14056, 761, 338, 330, 1342, 38071, 3343, 1442, 2163, 10321, 11, 279, 58577, 955, 374, 19655, 311, 387, 330, 1342, 14056, 23811, 310, 2592, 30121, 4229, 320, 496, 1680, 12536, 13, 578, 426, 7269, 12, 2618, 4221, 2082, 315, 279, 1988, 1495, 422, 198, 394, 3967, 11, 369, 3187, 11, 330, 268, 33440, 1, 477, 330, 15444, 8288, 266, 77, 3343, 50080, 4221, 14236, 527, 198, 394, 10212, 304, 11688, 9365, 13, 1442, 279, 2592, 4221, 4536, 956, 5300, 11, 279, 5446, 198, 394, 13865, 311, 10765, 279, 2592, 4221, 9651, 323, 4780, 279, 198, 394, 279, 2592, 4221, 2949, 279, 2077, 627, 310, 2748, 320, 496, 1680, 12536, 13, 8442, 1511, 994, 3339, 15481, 1534, 1650, 627, 394, 15392, 512, 394, 7224, 9573, 5094, 13193, 4572, 32409, 9573, 2588, 13193, 92, 382, 394, 8442, 2587, 1646, 4951, 9563, 661, 2949, 279, 1890, 3813, 13193, 649, 387, 1511, 627, 394, 18715, 220, 3443, 374, 6052, 627, 310, 1646, 320, 496, 1680, 12536, 13, 578, 10103, 2590, 14196, 955, 11472, 369, 420, 14807, 382, 394, 578, 3645, 14117, 389, 1646, 955, 1473, 394, 220, 16, 13, 8572, 4211, 512, 4391, 7224, 9573, 5094, 13193, 4572, 32409, 9573, 2588, 13193, 4572, 6644, 9573, 2590, 13193, 28374, 394, 220, 17, 13, 3331, 320, 47339, 3502, 8, 4211, 512, 4391, 7224, 9573, 5094, 13193, 4572, 32409, 9573, 2588, 13193, 4572, 6644, 67061, 9809, 2562, 198, 4391, 7224, 9573, 5094, 13193, 4572, 32409, 9573, 2588, 13193, 4572, 6644, 67061, 27182, 271, 394, 1789, 3728, 320, 6414, 33263, 4001, 1534, 8, 7540, 11, 1005, 314, 2588, 13193, 92, 364, 9951, 4527, 1789, 198, 394, 3187, 11, 7224 ]
vmware/pyvmomi
pyVim/connect.py
VimSessionOrientedStub.makeUserLoginMethod
def makeUserLoginMethod(username, password, locale=None): '''Return a function that will call the vim.SessionManager.Login() method with the given parameters. The result of this function can be passed as the "loginMethod" to a SessionOrientedStub constructor.''' def _doLogin(soapStub): si = vim.ServiceInstance("ServiceInstance", soapStub) sm = si.content.sessionManager if not sm.currentSession: si.content.sessionManager.Login(username, password, locale) return _doLogin
python
def makeUserLoginMethod(username, password, locale=None): '''Return a function that will call the vim.SessionManager.Login() method with the given parameters. The result of this function can be passed as the "loginMethod" to a SessionOrientedStub constructor.''' def _doLogin(soapStub): si = vim.ServiceInstance("ServiceInstance", soapStub) sm = si.content.sessionManager if not sm.currentSession: si.content.sessionManager.Login(username, password, locale) return _doLogin
[ "def", "makeUserLoginMethod", "(", "username", ",", "password", ",", "locale", "=", "None", ")", ":", "def", "_doLogin", "(", "soapStub", ")", ":", "si", "=", "vim", ".", "ServiceInstance", "(", "\"ServiceInstance\"", ",", "soapStub", ")", "sm", "=", "si", ".", "content", ".", "sessionManager", "if", "not", "sm", ".", "currentSession", ":", "si", ".", "content", ".", "sessionManager", ".", "Login", "(", "username", ",", "password", ",", "locale", ")", "return", "_doLogin" ]
Return a function that will call the vim.SessionManager.Login() method with the given parameters. The result of this function can be passed as the "loginMethod" to a SessionOrientedStub constructor.
[ "Return", "a", "function", "that", "will", "call", "the", "vim", ".", "SessionManager", ".", "Login", "()", "method", "with", "the", "given", "parameters", ".", "The", "result", "of", "this", "function", "can", "be", "passed", "as", "the", "loginMethod", "to", "a", "SessionOrientedStub", "constructor", "." ]
train
https://github.com/vmware/pyvmomi/blob/3ffcb23bf77d757175c0d5216ba9a25345d824cd/pyVim/connect.py#L92-L102
<|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 function that will call the vim.SessionManager.Login() method with the given parameters. The result of this function can be passed as the "loginMethod" to a SessionOrientedStub constructor. ### Response: def makeUserLoginMethod(username, password, locale=None): '''Return a function that will call the vim.SessionManager.Login() method with the given parameters. The result of this function can be passed as the "loginMethod" to a SessionOrientedStub constructor.''' def _doLogin(soapStub): si = vim.ServiceInstance("ServiceInstance", soapStub) sm = si.content.sessionManager if not sm.currentSession: si.content.sessionManager.Login(username, password, locale) return _doLogin <|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, 734, 430, 690, 1650, 279, 37257, 21331, 2087, 33599, 368, 1749, 198, 415, 449, 279, 2728, 5137, 13, 220, 578, 1121, 315, 420, 734, 649, 387, 5946, 439, 198, 415, 279, 330, 3758, 3607, 1, 311, 264, 9343, 46, 13283, 291, 34938, 4797, 382, 14711, 6075, 512, 755, 1304, 1502, 6363, 3607, 17522, 11, 3636, 11, 19076, 5980, 997, 415, 11712, 5715, 264, 734, 430, 690, 1650, 279, 37257, 21331, 2087, 33599, 368, 1749, 198, 415, 449, 279, 2728, 5137, 13, 220, 578, 1121, 315, 420, 734, 649, 387, 5946, 439, 198, 415, 279, 330, 3758, 3607, 1, 311, 264, 9343, 46, 13283, 291, 34938, 4797, 88785, 415, 711, 721, 3055, 6363, 7, 36112, 34938, 997, 260, 4502, 284, 37257, 14181, 2584, 446, 1898, 2584, 498, 27883, 34938, 340, 260, 1554, 284, 4502, 5521, 10387, 2087, 198, 260, 422, 539, 1554, 5058, 5396, 512, 310, 4502, 5521, 10387, 2087, 33599, 17522, 11, 3636, 11, 19076, 696, 415, 471, 721, 3055, 6363, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 5715, 264, 734, 430, 690, 1650, 279, 37257, 21331, 2087, 33599, 368, 1749, 198, 415, 449, 279, 2728, 5137, 13, 220, 578, 1121, 315, 420, 734, 649, 387, 5946, 439, 198, 415, 279, 330, 3758, 3607, 1, 311, 264, 9343, 46, 13283, 291, 34938, 4797, 382, 14711, 6075, 512, 755, 1304, 1502, 6363, 3607, 17522, 11, 3636, 11, 19076, 5980, 997, 415, 11712, 5715, 264, 734, 430, 690, 1650, 279, 37257, 21331, 2087, 33599, 368, 1749, 198, 415, 449, 279, 2728, 5137, 13, 220, 578, 1121, 315, 420, 734, 649, 387, 5946, 439, 198, 415, 279, 330, 3758, 3607, 1, 311, 264, 9343, 46, 13283, 291, 34938, 4797, 88785, 415, 711, 721, 3055, 6363, 7, 36112, 34938, 997, 260, 4502, 284, 37257, 14181, 2584, 446, 1898, 2584, 498, 27883, 34938, 340, 260, 1554, 284, 4502, 5521, 10387, 2087, 198, 260, 422, 539, 1554, 5058, 5396, 512, 310, 4502, 5521, 10387, 2087, 33599, 17522, 11, 3636, 11, 19076, 696, 415, 471, 721, 3055, 6363, 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 ]
apple/turicreate
src/unity/python/turicreate/toolkits/recommender/util.py
_Recommender.recommend
def recommend(self, users=None, k=10, exclude=None, items=None, new_observation_data=None, new_user_data=None, new_item_data=None, exclude_known=True, diversity=0, random_seed=None, verbose=True): """ Recommend the ``k`` highest scored items for each user. Parameters ---------- users : SArray, SFrame, or list, optional Users or observation queries for which to make recommendations. For list, SArray, and single-column inputs, this is simply a set of user IDs. By default, recommendations are returned for all users present when the model was trained. However, if the recommender model was created with additional features in the ``observation_data`` SFrame, then a corresponding SFrame of observation queries -- observation data without item or target columns -- can be passed to this method. For example, a model trained with user ID, item ID, time, and rating columns may be queried using an SFrame with user ID and time columns. In this case, the user ID column must be present, and all column names should match those in the ``observation_data`` SFrame passed to ``create.`` k : int, optional The number of recommendations to generate for each user. items : SArray, SFrame, or list, optional Restricts the items from which recommendations can be made. If ``items`` is an SArray, list, or SFrame with a single column, only items from the given set will be recommended. This can be used, for example, to restrict the recommendations to items within a particular category or genre. If ``items`` is an SFrame with user ID and item ID columns, then the item restriction is specialized to each user. For example, if ``items`` contains 3 rows with user U1 -- (U1, I1), (U1, I2), and (U1, I3) -- then the recommendations for user U1 are chosen from items I1, I2, and I3. By default, recommendations are made from all items present when the model was trained. new_observation_data : SFrame, optional ``new_observation_data`` gives additional observation data to the model, which may be used by the models to improve score and recommendation accuracy. Must be in the same format as the observation data passed to ``create``. How this data is used varies by model. new_user_data : SFrame, optional ``new_user_data`` may give additional user data to the model. If present, scoring is done with reference to this new information. If there is any overlap with the side information present at training time, then this new side data is preferred. Must be in the same format as the user data passed to ``create``. new_item_data : SFrame, optional ``new_item_data`` may give additional item data to the model. If present, scoring is done with reference to this new information. If there is any overlap with the side information present at training time, then this new side data is preferred. Must be in the same format as the item data passed to ``create``. exclude : SFrame, optional An :class:`~turicreate.SFrame` of user / item pairs. The column names must be equal to the user and item columns of the main data, and it provides the model with user/item pairs to exclude from the recommendations. These user-item-pairs are always excluded from the predictions, even if exclude_known is False. exclude_known : bool, optional By default, all user-item interactions previously seen in the training data, or in any new data provided using new_observation_data.., are excluded from the recommendations. Passing in ``exclude_known = False`` overrides this behavior. diversity : non-negative float, optional If given, then the recommend function attempts chooses a set of `k` items that are both highly scored and different from other items in that set. It does this by first retrieving ``k*(1+diversity)`` recommended items, then randomly choosing a diverse set from these items. Suggested values for diversity are between 1 and 3. random_seed : int, optional If diversity is larger than 0, then some randomness is used; this controls the random seed to use for randomization. If None, will be different each time. verbose : bool, optional If True, print the progress of generating recommendation. Returns ------- out : SFrame A SFrame with the top ranked items for each user. The columns are: ``user_id``, ``item_id``, *score*, and *rank*, where ``user_id`` and ``item_id`` match the user and item column names specified at training time. The rank column is between 1 and ``k`` and gives the relative score of that item. The value of score depends on the method used for recommendations. See Also -------- recommend_from_interactions predict evaluate """ from turicreate._cython.cy_server import QuietProgress assert type(k) == int column_types = self._get_data_schema() user_id = self.user_id item_id = self.item_id user_type = column_types[user_id] item_type = column_types[item_id] __null_sframe = _SFrame() if users is None: users = __null_sframe if exclude is None: exclude = __null_sframe if items is None: items = __null_sframe if new_observation_data is None: new_observation_data = __null_sframe if new_user_data is None: new_user_data = __null_sframe if new_item_data is None: new_item_data = __null_sframe if isinstance(users, list) or (_HAS_NUMPY and isinstance(users, _numpy.ndarray)): users = _SArray(users) # allow to take a list of dictionaries of the form [{'user_id':1,'time':10}] etc. if users.dtype == dict: users = users.unpack(column_name_prefix='') if isinstance(users, _SArray): users = _SFrame({user_id: users}) if isinstance(items, list) or (_HAS_NUMPY and isinstance(items, _numpy.ndarray)): items = _SArray(items, dtype = item_type) if isinstance(items, _SArray): items = _SFrame({item_id: items}) # Check type of incoming data. def check_type(arg, arg_name, required_type, allowed_types): if not isinstance(arg, required_type): raise TypeError("Parameter " + arg_name + " must be of type(s) " + (", ".join(allowed_types)) + "; Type '" + str(type(arg)) + "' not recognized.") check_type(users, "users", _SFrame, ["SArray", "list", "SFrame", "numpy.ndarray"]) check_type(exclude, "exclude", _SFrame, ["SFrame"]) check_type(items, "items", _SFrame, ["SFrame", "SArray", "list", "numpy.ndarray"]) check_type(new_observation_data, "new_observation_data", _SFrame, ["SFrame"]) check_type(new_user_data, "new_user_data", _SFrame, ["SFrame"]) check_type(new_item_data, "new_item_data", _SFrame, ["SFrame"]) # See if we are in the situation where there are no users # originally. In this case, the default type of the user # column is string, so we have to be mindful of that when # making recommendations and possibly cast it to string if # needed. # The only case where we need to deal with the user id is when # it's used to link with rated items in new_observation_data, # thus handle that case explicitly and error out in others. cast_user_to_string_type = False if self.num_users == 0: cast_user_to_string_type = True if users.num_rows() != 0: # In this case, the user column has actually been set to a # string type, so we need to make sure that we cast # everything back and forth to that to preserve type. if new_observation_data.num_rows() == 0: raise ValueError("When users are not specified with the model, " "new_observation_data must be set in order to make recommendations.") new_observation_data[user_id] = new_observation_data[user_id].astype(user_type) else: print("WARNING: No users specified to model at creation time, so " "calling recommend() for all users returns empty SFrame.") # Cast to the appropriate type if necessary. if users.num_rows() != 0: try: user_column = users[user_id] except RuntimeError: raise _ToolkitError("User column '%s' not present in input user data." % user_id) if cast_user_to_string_type: assert new_observation_data.num_rows() != 0 original_user_type = user_column.dtype users[user_id] = user_column.astype(str) user_type=str elif user_column.dtype != user_type: users[user_id] = user_column.astype(user_type) # Cast user specified in exclude to the appropriate type if necessary. if user_id in exclude.column_names() and exclude[user_id].dtype!=user_type: exclude[user_id] = exclude[user_id].astype(user_type) try: diversity = float(diversity) except Exception: raise TypeError("Parameter diversity must be a floating point value equal to or larger than 0.") if diversity < 0: raise TypeError("Parameter diversity must be a floating point value equal to or larger than 0.") if random_seed is None: random_seed = hash("%.20f" % _time.time()) else: try: random_seed = int(random_seed) except TypeError: raise TypeError("random_seed must be integer.") opt = {'model': self.__proxy__, 'query': users, 'top_k': k, 'exclude': exclude, 'restrictions': items, 'new_data': new_observation_data, 'new_user_data': new_user_data, 'new_item_data': new_item_data, 'exclude_known': exclude_known, 'diversity' : diversity, 'random_seed' : random_seed } with QuietProgress(verbose): recs = self.__proxy__.recommend(users, exclude, items, new_observation_data, new_user_data, new_item_data, exclude_known, k, diversity, random_seed) if cast_user_to_string_type: recs[user_id] = recs[user_id].astype(original_user_type) return recs
python
def recommend(self, users=None, k=10, exclude=None, items=None, new_observation_data=None, new_user_data=None, new_item_data=None, exclude_known=True, diversity=0, random_seed=None, verbose=True): """ Recommend the ``k`` highest scored items for each user. Parameters ---------- users : SArray, SFrame, or list, optional Users or observation queries for which to make recommendations. For list, SArray, and single-column inputs, this is simply a set of user IDs. By default, recommendations are returned for all users present when the model was trained. However, if the recommender model was created with additional features in the ``observation_data`` SFrame, then a corresponding SFrame of observation queries -- observation data without item or target columns -- can be passed to this method. For example, a model trained with user ID, item ID, time, and rating columns may be queried using an SFrame with user ID and time columns. In this case, the user ID column must be present, and all column names should match those in the ``observation_data`` SFrame passed to ``create.`` k : int, optional The number of recommendations to generate for each user. items : SArray, SFrame, or list, optional Restricts the items from which recommendations can be made. If ``items`` is an SArray, list, or SFrame with a single column, only items from the given set will be recommended. This can be used, for example, to restrict the recommendations to items within a particular category or genre. If ``items`` is an SFrame with user ID and item ID columns, then the item restriction is specialized to each user. For example, if ``items`` contains 3 rows with user U1 -- (U1, I1), (U1, I2), and (U1, I3) -- then the recommendations for user U1 are chosen from items I1, I2, and I3. By default, recommendations are made from all items present when the model was trained. new_observation_data : SFrame, optional ``new_observation_data`` gives additional observation data to the model, which may be used by the models to improve score and recommendation accuracy. Must be in the same format as the observation data passed to ``create``. How this data is used varies by model. new_user_data : SFrame, optional ``new_user_data`` may give additional user data to the model. If present, scoring is done with reference to this new information. If there is any overlap with the side information present at training time, then this new side data is preferred. Must be in the same format as the user data passed to ``create``. new_item_data : SFrame, optional ``new_item_data`` may give additional item data to the model. If present, scoring is done with reference to this new information. If there is any overlap with the side information present at training time, then this new side data is preferred. Must be in the same format as the item data passed to ``create``. exclude : SFrame, optional An :class:`~turicreate.SFrame` of user / item pairs. The column names must be equal to the user and item columns of the main data, and it provides the model with user/item pairs to exclude from the recommendations. These user-item-pairs are always excluded from the predictions, even if exclude_known is False. exclude_known : bool, optional By default, all user-item interactions previously seen in the training data, or in any new data provided using new_observation_data.., are excluded from the recommendations. Passing in ``exclude_known = False`` overrides this behavior. diversity : non-negative float, optional If given, then the recommend function attempts chooses a set of `k` items that are both highly scored and different from other items in that set. It does this by first retrieving ``k*(1+diversity)`` recommended items, then randomly choosing a diverse set from these items. Suggested values for diversity are between 1 and 3. random_seed : int, optional If diversity is larger than 0, then some randomness is used; this controls the random seed to use for randomization. If None, will be different each time. verbose : bool, optional If True, print the progress of generating recommendation. Returns ------- out : SFrame A SFrame with the top ranked items for each user. The columns are: ``user_id``, ``item_id``, *score*, and *rank*, where ``user_id`` and ``item_id`` match the user and item column names specified at training time. The rank column is between 1 and ``k`` and gives the relative score of that item. The value of score depends on the method used for recommendations. See Also -------- recommend_from_interactions predict evaluate """ from turicreate._cython.cy_server import QuietProgress assert type(k) == int column_types = self._get_data_schema() user_id = self.user_id item_id = self.item_id user_type = column_types[user_id] item_type = column_types[item_id] __null_sframe = _SFrame() if users is None: users = __null_sframe if exclude is None: exclude = __null_sframe if items is None: items = __null_sframe if new_observation_data is None: new_observation_data = __null_sframe if new_user_data is None: new_user_data = __null_sframe if new_item_data is None: new_item_data = __null_sframe if isinstance(users, list) or (_HAS_NUMPY and isinstance(users, _numpy.ndarray)): users = _SArray(users) # allow to take a list of dictionaries of the form [{'user_id':1,'time':10}] etc. if users.dtype == dict: users = users.unpack(column_name_prefix='') if isinstance(users, _SArray): users = _SFrame({user_id: users}) if isinstance(items, list) or (_HAS_NUMPY and isinstance(items, _numpy.ndarray)): items = _SArray(items, dtype = item_type) if isinstance(items, _SArray): items = _SFrame({item_id: items}) # Check type of incoming data. def check_type(arg, arg_name, required_type, allowed_types): if not isinstance(arg, required_type): raise TypeError("Parameter " + arg_name + " must be of type(s) " + (", ".join(allowed_types)) + "; Type '" + str(type(arg)) + "' not recognized.") check_type(users, "users", _SFrame, ["SArray", "list", "SFrame", "numpy.ndarray"]) check_type(exclude, "exclude", _SFrame, ["SFrame"]) check_type(items, "items", _SFrame, ["SFrame", "SArray", "list", "numpy.ndarray"]) check_type(new_observation_data, "new_observation_data", _SFrame, ["SFrame"]) check_type(new_user_data, "new_user_data", _SFrame, ["SFrame"]) check_type(new_item_data, "new_item_data", _SFrame, ["SFrame"]) # See if we are in the situation where there are no users # originally. In this case, the default type of the user # column is string, so we have to be mindful of that when # making recommendations and possibly cast it to string if # needed. # The only case where we need to deal with the user id is when # it's used to link with rated items in new_observation_data, # thus handle that case explicitly and error out in others. cast_user_to_string_type = False if self.num_users == 0: cast_user_to_string_type = True if users.num_rows() != 0: # In this case, the user column has actually been set to a # string type, so we need to make sure that we cast # everything back and forth to that to preserve type. if new_observation_data.num_rows() == 0: raise ValueError("When users are not specified with the model, " "new_observation_data must be set in order to make recommendations.") new_observation_data[user_id] = new_observation_data[user_id].astype(user_type) else: print("WARNING: No users specified to model at creation time, so " "calling recommend() for all users returns empty SFrame.") # Cast to the appropriate type if necessary. if users.num_rows() != 0: try: user_column = users[user_id] except RuntimeError: raise _ToolkitError("User column '%s' not present in input user data." % user_id) if cast_user_to_string_type: assert new_observation_data.num_rows() != 0 original_user_type = user_column.dtype users[user_id] = user_column.astype(str) user_type=str elif user_column.dtype != user_type: users[user_id] = user_column.astype(user_type) # Cast user specified in exclude to the appropriate type if necessary. if user_id in exclude.column_names() and exclude[user_id].dtype!=user_type: exclude[user_id] = exclude[user_id].astype(user_type) try: diversity = float(diversity) except Exception: raise TypeError("Parameter diversity must be a floating point value equal to or larger than 0.") if diversity < 0: raise TypeError("Parameter diversity must be a floating point value equal to or larger than 0.") if random_seed is None: random_seed = hash("%.20f" % _time.time()) else: try: random_seed = int(random_seed) except TypeError: raise TypeError("random_seed must be integer.") opt = {'model': self.__proxy__, 'query': users, 'top_k': k, 'exclude': exclude, 'restrictions': items, 'new_data': new_observation_data, 'new_user_data': new_user_data, 'new_item_data': new_item_data, 'exclude_known': exclude_known, 'diversity' : diversity, 'random_seed' : random_seed } with QuietProgress(verbose): recs = self.__proxy__.recommend(users, exclude, items, new_observation_data, new_user_data, new_item_data, exclude_known, k, diversity, random_seed) if cast_user_to_string_type: recs[user_id] = recs[user_id].astype(original_user_type) return recs
[ "def", "recommend", "(", "self", ",", "users", "=", "None", ",", "k", "=", "10", ",", "exclude", "=", "None", ",", "items", "=", "None", ",", "new_observation_data", "=", "None", ",", "new_user_data", "=", "None", ",", "new_item_data", "=", "None", ",", "exclude_known", "=", "True", ",", "diversity", "=", "0", ",", "random_seed", "=", "None", ",", "verbose", "=", "True", ")", ":", "from", "turicreate", ".", "_cython", ".", "cy_server", "import", "QuietProgress", "assert", "type", "(", "k", ")", "==", "int", "column_types", "=", "self", ".", "_get_data_schema", "(", ")", "user_id", "=", "self", ".", "user_id", "item_id", "=", "self", ".", "item_id", "user_type", "=", "column_types", "[", "user_id", "]", "item_type", "=", "column_types", "[", "item_id", "]", "__null_sframe", "=", "_SFrame", "(", ")", "if", "users", "is", "None", ":", "users", "=", "__null_sframe", "if", "exclude", "is", "None", ":", "exclude", "=", "__null_sframe", "if", "items", "is", "None", ":", "items", "=", "__null_sframe", "if", "new_observation_data", "is", "None", ":", "new_observation_data", "=", "__null_sframe", "if", "new_user_data", "is", "None", ":", "new_user_data", "=", "__null_sframe", "if", "new_item_data", "is", "None", ":", "new_item_data", "=", "__null_sframe", "if", "isinstance", "(", "users", ",", "list", ")", "or", "(", "_HAS_NUMPY", "and", "isinstance", "(", "users", ",", "_numpy", ".", "ndarray", ")", ")", ":", "users", "=", "_SArray", "(", "users", ")", "# allow to take a list of dictionaries of the form [{'user_id':1,'time':10}] etc.", "if", "users", ".", "dtype", "==", "dict", ":", "users", "=", "users", ".", "unpack", "(", "column_name_prefix", "=", "''", ")", "if", "isinstance", "(", "users", ",", "_SArray", ")", ":", "users", "=", "_SFrame", "(", "{", "user_id", ":", "users", "}", ")", "if", "isinstance", "(", "items", ",", "list", ")", "or", "(", "_HAS_NUMPY", "and", "isinstance", "(", "items", ",", "_numpy", ".", "ndarray", ")", ")", ":", "items", "=", "_SArray", "(", "items", ",", "dtype", "=", "item_type", ")", "if", "isinstance", "(", "items", ",", "_SArray", ")", ":", "items", "=", "_SFrame", "(", "{", "item_id", ":", "items", "}", ")", "# Check type of incoming data.", "def", "check_type", "(", "arg", ",", "arg_name", ",", "required_type", ",", "allowed_types", ")", ":", "if", "not", "isinstance", "(", "arg", ",", "required_type", ")", ":", "raise", "TypeError", "(", "\"Parameter \"", "+", "arg_name", "+", "\" must be of type(s) \"", "+", "(", "\", \"", ".", "join", "(", "allowed_types", ")", ")", "+", "\"; Type '\"", "+", "str", "(", "type", "(", "arg", ")", ")", "+", "\"' not recognized.\"", ")", "check_type", "(", "users", ",", "\"users\"", ",", "_SFrame", ",", "[", "\"SArray\"", ",", "\"list\"", ",", "\"SFrame\"", ",", "\"numpy.ndarray\"", "]", ")", "check_type", "(", "exclude", ",", "\"exclude\"", ",", "_SFrame", ",", "[", "\"SFrame\"", "]", ")", "check_type", "(", "items", ",", "\"items\"", ",", "_SFrame", ",", "[", "\"SFrame\"", ",", "\"SArray\"", ",", "\"list\"", ",", "\"numpy.ndarray\"", "]", ")", "check_type", "(", "new_observation_data", ",", "\"new_observation_data\"", ",", "_SFrame", ",", "[", "\"SFrame\"", "]", ")", "check_type", "(", "new_user_data", ",", "\"new_user_data\"", ",", "_SFrame", ",", "[", "\"SFrame\"", "]", ")", "check_type", "(", "new_item_data", ",", "\"new_item_data\"", ",", "_SFrame", ",", "[", "\"SFrame\"", "]", ")", "# See if we are in the situation where there are no users", "# originally. In this case, the default type of the user", "# column is string, so we have to be mindful of that when", "# making recommendations and possibly cast it to string if", "# needed.", "# The only case where we need to deal with the user id is when", "# it's used to link with rated items in new_observation_data,", "# thus handle that case explicitly and error out in others.", "cast_user_to_string_type", "=", "False", "if", "self", ".", "num_users", "==", "0", ":", "cast_user_to_string_type", "=", "True", "if", "users", ".", "num_rows", "(", ")", "!=", "0", ":", "# In this case, the user column has actually been set to a", "# string type, so we need to make sure that we cast", "# everything back and forth to that to preserve type.", "if", "new_observation_data", ".", "num_rows", "(", ")", "==", "0", ":", "raise", "ValueError", "(", "\"When users are not specified with the model, \"", "\"new_observation_data must be set in order to make recommendations.\"", ")", "new_observation_data", "[", "user_id", "]", "=", "new_observation_data", "[", "user_id", "]", ".", "astype", "(", "user_type", ")", "else", ":", "print", "(", "\"WARNING: No users specified to model at creation time, so \"", "\"calling recommend() for all users returns empty SFrame.\"", ")", "# Cast to the appropriate type if necessary.", "if", "users", ".", "num_rows", "(", ")", "!=", "0", ":", "try", ":", "user_column", "=", "users", "[", "user_id", "]", "except", "RuntimeError", ":", "raise", "_ToolkitError", "(", "\"User column '%s' not present in input user data.\"", "%", "user_id", ")", "if", "cast_user_to_string_type", ":", "assert", "new_observation_data", ".", "num_rows", "(", ")", "!=", "0", "original_user_type", "=", "user_column", ".", "dtype", "users", "[", "user_id", "]", "=", "user_column", ".", "astype", "(", "str", ")", "user_type", "=", "str", "elif", "user_column", ".", "dtype", "!=", "user_type", ":", "users", "[", "user_id", "]", "=", "user_column", ".", "astype", "(", "user_type", ")", "# Cast user specified in exclude to the appropriate type if necessary.", "if", "user_id", "in", "exclude", ".", "column_names", "(", ")", "and", "exclude", "[", "user_id", "]", ".", "dtype", "!=", "user_type", ":", "exclude", "[", "user_id", "]", "=", "exclude", "[", "user_id", "]", ".", "astype", "(", "user_type", ")", "try", ":", "diversity", "=", "float", "(", "diversity", ")", "except", "Exception", ":", "raise", "TypeError", "(", "\"Parameter diversity must be a floating point value equal to or larger than 0.\"", ")", "if", "diversity", "<", "0", ":", "raise", "TypeError", "(", "\"Parameter diversity must be a floating point value equal to or larger than 0.\"", ")", "if", "random_seed", "is", "None", ":", "random_seed", "=", "hash", "(", "\"%.20f\"", "%", "_time", ".", "time", "(", ")", ")", "else", ":", "try", ":", "random_seed", "=", "int", "(", "random_seed", ")", "except", "TypeError", ":", "raise", "TypeError", "(", "\"random_seed must be integer.\"", ")", "opt", "=", "{", "'model'", ":", "self", ".", "__proxy__", ",", "'query'", ":", "users", ",", "'top_k'", ":", "k", ",", "'exclude'", ":", "exclude", ",", "'restrictions'", ":", "items", ",", "'new_data'", ":", "new_observation_data", ",", "'new_user_data'", ":", "new_user_data", ",", "'new_item_data'", ":", "new_item_data", ",", "'exclude_known'", ":", "exclude_known", ",", "'diversity'", ":", "diversity", ",", "'random_seed'", ":", "random_seed", "}", "with", "QuietProgress", "(", "verbose", ")", ":", "recs", "=", "self", ".", "__proxy__", ".", "recommend", "(", "users", ",", "exclude", ",", "items", ",", "new_observation_data", ",", "new_user_data", ",", "new_item_data", ",", "exclude_known", ",", "k", ",", "diversity", ",", "random_seed", ")", "if", "cast_user_to_string_type", ":", "recs", "[", "user_id", "]", "=", "recs", "[", "user_id", "]", ".", "astype", "(", "original_user_type", ")", "return", "recs" ]
Recommend the ``k`` highest scored items for each user. Parameters ---------- users : SArray, SFrame, or list, optional Users or observation queries for which to make recommendations. For list, SArray, and single-column inputs, this is simply a set of user IDs. By default, recommendations are returned for all users present when the model was trained. However, if the recommender model was created with additional features in the ``observation_data`` SFrame, then a corresponding SFrame of observation queries -- observation data without item or target columns -- can be passed to this method. For example, a model trained with user ID, item ID, time, and rating columns may be queried using an SFrame with user ID and time columns. In this case, the user ID column must be present, and all column names should match those in the ``observation_data`` SFrame passed to ``create.`` k : int, optional The number of recommendations to generate for each user. items : SArray, SFrame, or list, optional Restricts the items from which recommendations can be made. If ``items`` is an SArray, list, or SFrame with a single column, only items from the given set will be recommended. This can be used, for example, to restrict the recommendations to items within a particular category or genre. If ``items`` is an SFrame with user ID and item ID columns, then the item restriction is specialized to each user. For example, if ``items`` contains 3 rows with user U1 -- (U1, I1), (U1, I2), and (U1, I3) -- then the recommendations for user U1 are chosen from items I1, I2, and I3. By default, recommendations are made from all items present when the model was trained. new_observation_data : SFrame, optional ``new_observation_data`` gives additional observation data to the model, which may be used by the models to improve score and recommendation accuracy. Must be in the same format as the observation data passed to ``create``. How this data is used varies by model. new_user_data : SFrame, optional ``new_user_data`` may give additional user data to the model. If present, scoring is done with reference to this new information. If there is any overlap with the side information present at training time, then this new side data is preferred. Must be in the same format as the user data passed to ``create``. new_item_data : SFrame, optional ``new_item_data`` may give additional item data to the model. If present, scoring is done with reference to this new information. If there is any overlap with the side information present at training time, then this new side data is preferred. Must be in the same format as the item data passed to ``create``. exclude : SFrame, optional An :class:`~turicreate.SFrame` of user / item pairs. The column names must be equal to the user and item columns of the main data, and it provides the model with user/item pairs to exclude from the recommendations. These user-item-pairs are always excluded from the predictions, even if exclude_known is False. exclude_known : bool, optional By default, all user-item interactions previously seen in the training data, or in any new data provided using new_observation_data.., are excluded from the recommendations. Passing in ``exclude_known = False`` overrides this behavior. diversity : non-negative float, optional If given, then the recommend function attempts chooses a set of `k` items that are both highly scored and different from other items in that set. It does this by first retrieving ``k*(1+diversity)`` recommended items, then randomly choosing a diverse set from these items. Suggested values for diversity are between 1 and 3. random_seed : int, optional If diversity is larger than 0, then some randomness is used; this controls the random seed to use for randomization. If None, will be different each time. verbose : bool, optional If True, print the progress of generating recommendation. Returns ------- out : SFrame A SFrame with the top ranked items for each user. The columns are: ``user_id``, ``item_id``, *score*, and *rank*, where ``user_id`` and ``item_id`` match the user and item column names specified at training time. The rank column is between 1 and ``k`` and gives the relative score of that item. The value of score depends on the method used for recommendations. See Also -------- recommend_from_interactions predict evaluate
[ "Recommend", "the", "k", "highest", "scored", "items", "for", "each", "user", "." ]
train
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/recommender/util.py#L1056-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: Recommend the ``k`` highest scored items for each user. Parameters ---------- users : SArray, SFrame, or list, optional Users or observation queries for which to make recommendations. For list, SArray, and single-column inputs, this is simply a set of user IDs. By default, recommendations are returned for all users present when the model was trained. However, if the recommender model was created with additional features in the ``observation_data`` SFrame, then a corresponding SFrame of observation queries -- observation data without item or target columns -- can be passed to this method. For example, a model trained with user ID, item ID, time, and rating columns may be queried using an SFrame with user ID and time columns. In this case, the user ID column must be present, and all column names should match those in the ``observation_data`` SFrame passed to ``create.`` k : int, optional The number of recommendations to generate for each user. items : SArray, SFrame, or list, optional Restricts the items from which recommendations can be made. If ``items`` is an SArray, list, or SFrame with a single column, only items from the given set will be recommended. This can be used, for example, to restrict the recommendations to items within a particular category or genre. If ``items`` is an SFrame with user ID and item ID columns, then the item restriction is specialized to each user. For example, if ``items`` contains 3 rows with user U1 -- (U1, I1), (U1, I2), and (U1, I3) -- then the recommendations for user U1 are chosen from items I1, I2, and I3. By default, recommendations are made from all items present when the model was trained. new_observation_data : SFrame, optional ``new_observation_data`` gives additional observation data to the model, which may be used by the models to improve score and recommendation accuracy. Must be in the same format as the observation data passed to ``create``. How this data is used varies by model. new_user_data : SFrame, optional ``new_user_data`` may give additional user data to the model. If present, scoring is done with reference to this new information. If there is any overlap with the side information present at training time, then this new side data is preferred. Must be in the same format as the user data passed to ``create``. new_item_data : SFrame, optional ``new_item_data`` may give additional item data to the model. If present, scoring is done with reference to this new information. If there is any overlap with the side information present at training time, then this new side data is preferred. Must be in the same format as the item data passed to ``create``. exclude : SFrame, optional An :class:`~turicreate.SFrame` of user / item pairs. The column names must be equal to the user and item columns of the main data, and it provides the model with user/item pairs to exclude from the recommendations. These user-item-pairs are always excluded from the predictions, even if exclude_known is False. exclude_known : bool, optional By default, all user-item interactions previously seen in the training data, or in any new data provided using new_observation_data.., are excluded from the recommendations. Passing in ``exclude_known = False`` overrides this behavior. diversity : non-negative float, optional If given, then the recommend function attempts chooses a set of `k` items that are both highly scored and different from other items in that set. It does this by first retrieving ``k*(1+diversity)`` recommended items, then randomly choosing a diverse set from these items. Suggested values for diversity are between 1 and 3. random_seed : int, optional If diversity is larger than 0, then some randomness is used; this controls the random seed to use for randomization. If None, will be different each time. verbose : bool, optional If True, print the progress of generating recommendation. Returns ------- out : SFrame A SFrame with the top ranked items for each user. The columns are: ``user_id``, ``item_id``, *score*, and *rank*, where ``user_id`` and ``item_id`` match the user and item column names specified at training time. The rank column is between 1 and ``k`` and gives the relative score of that item. The value of score depends on the method used for recommendations. See Also -------- recommend_from_interactions predict evaluate ### Response: def recommend(self, users=None, k=10, exclude=None, items=None, new_observation_data=None, new_user_data=None, new_item_data=None, exclude_known=True, diversity=0, random_seed=None, verbose=True): """ Recommend the ``k`` highest scored items for each user. Parameters ---------- users : SArray, SFrame, or list, optional Users or observation queries for which to make recommendations. For list, SArray, and single-column inputs, this is simply a set of user IDs. By default, recommendations are returned for all users present when the model was trained. However, if the recommender model was created with additional features in the ``observation_data`` SFrame, then a corresponding SFrame of observation queries -- observation data without item or target columns -- can be passed to this method. For example, a model trained with user ID, item ID, time, and rating columns may be queried using an SFrame with user ID and time columns. In this case, the user ID column must be present, and all column names should match those in the ``observation_data`` SFrame passed to ``create.`` k : int, optional The number of recommendations to generate for each user. items : SArray, SFrame, or list, optional Restricts the items from which recommendations can be made. If ``items`` is an SArray, list, or SFrame with a single column, only items from the given set will be recommended. This can be used, for example, to restrict the recommendations to items within a particular category or genre. If ``items`` is an SFrame with user ID and item ID columns, then the item restriction is specialized to each user. For example, if ``items`` contains 3 rows with user U1 -- (U1, I1), (U1, I2), and (U1, I3) -- then the recommendations for user U1 are chosen from items I1, I2, and I3. By default, recommendations are made from all items present when the model was trained. new_observation_data : SFrame, optional ``new_observation_data`` gives additional observation data to the model, which may be used by the models to improve score and recommendation accuracy. Must be in the same format as the observation data passed to ``create``. How this data is used varies by model. new_user_data : SFrame, optional ``new_user_data`` may give additional user data to the model. If present, scoring is done with reference to this new information. If there is any overlap with the side information present at training time, then this new side data is preferred. Must be in the same format as the user data passed to ``create``. new_item_data : SFrame, optional ``new_item_data`` may give additional item data to the model. If present, scoring is done with reference to this new information. If there is any overlap with the side information present at training time, then this new side data is preferred. Must be in the same format as the item data passed to ``create``. exclude : SFrame, optional An :class:`~turicreate.SFrame` of user / item pairs. The column names must be equal to the user and item columns of the main data, and it provides the model with user/item pairs to exclude from the recommendations. These user-item-pairs are always excluded from the predictions, even if exclude_known is False. exclude_known : bool, optional By default, all user-item interactions previously seen in the training data, or in any new data provided using new_observation_data.., are excluded from the recommendations. Passing in ``exclude_known = False`` overrides this behavior. diversity : non-negative float, optional If given, then the recommend function attempts chooses a set of `k` items that are both highly scored and different from other items in that set. It does this by first retrieving ``k*(1+diversity)`` recommended items, then randomly choosing a diverse set from these items. Suggested values for diversity are between 1 and 3. random_seed : int, optional If diversity is larger than 0, then some randomness is used; this controls the random seed to use for randomization. If None, will be different each time. verbose : bool, optional If True, print the progress of generating recommendation. Returns ------- out : SFrame A SFrame with the top ranked items for each user. The columns are: ``user_id``, ``item_id``, *score*, and *rank*, where ``user_id`` and ``item_id`` match the user and item column names specified at training time. The rank column is between 1 and ``k`` and gives the relative score of that item. The value of score depends on the method used for recommendations. See Also -------- recommend_from_interactions predict evaluate """ from turicreate._cython.cy_server import QuietProgress assert type(k) == int column_types = self._get_data_schema() user_id = self.user_id item_id = self.item_id user_type = column_types[user_id] item_type = column_types[item_id] __null_sframe = _SFrame() if users is None: users = __null_sframe if exclude is None: exclude = __null_sframe if items is None: items = __null_sframe if new_observation_data is None: new_observation_data = __null_sframe if new_user_data is None: new_user_data = __null_sframe if new_item_data is None: new_item_data = __null_sframe if isinstance(users, list) or (_HAS_NUMPY and isinstance(users, _numpy.ndarray)): users = _SArray(users) # allow to take a list of dictionaries of the form [{'user_id':1,'time':10}] etc. if users.dtype == dict: users = users.unpack(column_name_prefix='') if isinstance(users, _SArray): users = _SFrame({user_id: users}) if isinstance(items, list) or (_HAS_NUMPY and isinstance(items, _numpy.ndarray)): items = _SArray(items, dtype = item_type) if isinstance(items, _SArray): items = _SFrame({item_id: items}) # Check type of incoming data. def check_type(arg, arg_name, required_type, allowed_types): if not isinstance(arg, required_type): raise TypeError("Parameter " + arg_name + " must be of type(s) " + (", ".join(allowed_types)) + "; Type '" + str(type(arg)) + "' not recognized.") check_type(users, "users", _SFrame, ["SArray", "list", "SFrame", "numpy.ndarray"]) check_type(exclude, "exclude", _SFrame, ["SFrame"]) check_type(items, "items", _SFrame, ["SFrame", "SArray", "list", "numpy.ndarray"]) check_type(new_observation_data, "new_observation_data", _SFrame, ["SFrame"]) check_type(new_user_data, "new_user_data", _SFrame, ["SFrame"]) check_type(new_item_data, "new_item_data", _SFrame, ["SFrame"]) # See if we are in the situation where there are no users # originally. In this case, the default type of the user # column is string, so we have to be mindful of that when # making recommendations and possibly cast it to string if # needed. # The only case where we need to deal with the user id is when # it's used to link with rated items in new_observation_data, # thus handle that case explicitly and error out in others. cast_user_to_string_type = False if self.num_users == 0: cast_user_to_string_type = True if users.num_rows() != 0: # In this case, the user column has actually been set to a # string type, so we need to make sure that we cast # everything back and forth to that to preserve type. if new_observation_data.num_rows() == 0: raise ValueError("When users are not specified with the model, " "new_observation_data must be set in order to make recommendations.") new_observation_data[user_id] = new_observation_data[user_id].astype(user_type) else: print("WARNING: No users specified to model at creation time, so " "calling recommend() for all users returns empty SFrame.") # Cast to the appropriate type if necessary. if users.num_rows() != 0: try: user_column = users[user_id] except RuntimeError: raise _ToolkitError("User column '%s' not present in input user data." % user_id) if cast_user_to_string_type: assert new_observation_data.num_rows() != 0 original_user_type = user_column.dtype users[user_id] = user_column.astype(str) user_type=str elif user_column.dtype != user_type: users[user_id] = user_column.astype(user_type) # Cast user specified in exclude to the appropriate type if necessary. if user_id in exclude.column_names() and exclude[user_id].dtype!=user_type: exclude[user_id] = exclude[user_id].astype(user_type) try: diversity = float(diversity) except Exception: raise TypeError("Parameter diversity must be a floating point value equal to or larger than 0.") if diversity < 0: raise TypeError("Parameter diversity must be a floating point value equal to or larger than 0.") if random_seed is None: random_seed = hash("%.20f" % _time.time()) else: try: random_seed = int(random_seed) except TypeError: raise TypeError("random_seed must be integer.") opt = {'model': self.__proxy__, 'query': users, 'top_k': k, 'exclude': exclude, 'restrictions': items, 'new_data': new_observation_data, 'new_user_data': new_user_data, 'new_item_data': new_item_data, 'exclude_known': exclude_known, 'diversity' : diversity, 'random_seed' : random_seed } with QuietProgress(verbose): recs = self.__proxy__.recommend(users, exclude, items, new_observation_data, new_user_data, new_item_data, exclude_known, k, diversity, random_seed) if cast_user_to_string_type: recs[user_id] = recs[user_id].astype(original_user_type) return recs <|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, 68744, 279, 10103, 74, 14196, 8592, 16957, 3673, 369, 1855, 1217, 382, 286, 13831, 198, 286, 31423, 286, 3932, 551, 220, 328, 1895, 11, 328, 4467, 11, 477, 1160, 11, 10309, 198, 310, 14969, 477, 22695, 20126, 369, 902, 311, 1304, 19075, 627, 310, 1789, 1160, 11, 328, 1895, 11, 323, 3254, 26005, 11374, 11, 420, 374, 5042, 264, 743, 198, 310, 315, 1217, 29460, 13, 3296, 1670, 11, 19075, 527, 6052, 369, 682, 198, 310, 3932, 3118, 994, 279, 1646, 574, 16572, 13, 4452, 11, 422, 279, 198, 310, 4966, 1693, 1646, 574, 3549, 449, 5217, 4519, 304, 279, 198, 310, 10103, 79060, 1807, 14196, 328, 4467, 11, 1243, 264, 12435, 328, 4467, 315, 198, 310, 22695, 20126, 1198, 22695, 828, 2085, 1537, 477, 2218, 198, 310, 8310, 1198, 649, 387, 5946, 311, 420, 1749, 13, 1789, 3187, 11, 264, 1646, 198, 310, 16572, 449, 1217, 3110, 11, 1537, 3110, 11, 892, 11, 323, 10959, 8310, 1253, 387, 198, 310, 79002, 1701, 459, 328, 4467, 449, 1217, 3110, 323, 892, 8310, 13, 220, 763, 420, 198, 310, 1162, 11, 279, 1217, 3110, 3330, 2011, 387, 3118, 11, 323, 682, 3330, 5144, 198, 310, 1288, 2489, 1884, 304, 279, 10103, 79060, 1807, 14196, 328, 4467, 5946, 311, 198, 310, 10103, 3261, 13, 14196, 271, 286, 597, 551, 528, 11, 10309, 198, 310, 578, 1396, 315, 19075, 311, 7068, 369, 1855, 1217, 382, 286, 3673, 551, 328, 1895, 11, 328, 4467, 11, 477, 1160, 11, 10309, 198, 310, 42427, 31095, 279, 3673, 505, 902, 19075, 649, 387, 1903, 13, 1442, 198, 310, 10103, 3699, 14196, 374, 459, 328, 1895, 11, 1160, 11, 477, 328, 4467, 449, 264, 3254, 3330, 345, 310, 1193, 3673, 505, 279, 2728, 743, 690, 387, 11349, 13, 1115, 649, 387, 198, 310, 1511, 11, 369, 3187, 11, 311, 9067, 279, 19075, 311, 3673, 198, 310, 2949, 264, 4040, 5699, 477, 17779, 13, 1442, 10103, 3699, 14196, 374, 459, 198, 310, 328, 4467, 449, 1217, 3110, 323, 1537, 3110, 8310, 11, 1243, 279, 1537, 198, 310, 20020, 374, 28175, 311, 1855, 1217, 13, 1789, 3187, 11, 422, 198, 310, 10103, 3699, 14196, 5727, 220, 18, 7123, 449, 1217, 549, 16, 1198, 320, 52, 16, 11, 358, 16, 705, 320, 52, 16, 11, 358, 17, 1350, 310, 323, 320, 52, 16, 11, 358, 18, 8, 1198, 1243, 279, 19075, 369, 1217, 549, 16, 527, 198, 310, 12146, 505, 3673, 358, 16, 11, 358, 17, 11, 323, 358, 18, 13, 3296, 1670, 11, 19075, 198, 310, 527, 1903, 505, 682, 3673, 3118, 994, 279, 1646, 574, 16572, 382, 286, 502, 31505, 8943, 1807, 551, 328, 4467, 11, 10309, 198, 310, 10103, 943, 31505, 8943, 1807, 14196, 6835, 5217, 22695, 828, 198, 310, 311, 279, 1646, 11, 902, 1253, 387, 1511, 555, 279, 4211, 311, 7417, 198, 310, 5573, 323, 28782, 13708, 13, 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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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 68744, 279, 10103, 74, 14196, 8592, 16957, 3673, 369, 1855, 1217, 382, 286, 13831, 198, 286, 31423, 286, 3932, 551, 220, 328, 1895, 11, 328, 4467, 11, 477, 1160, 11, 10309, 198, 310, 14969, 477, 22695, 20126, 369, 902, 311, 1304, 19075, 627, 310, 1789, 1160, 11, 328, 1895, 11, 323, 3254, 26005, 11374, 11, 420, 374, 5042, 264, 743, 198, 310, 315, 1217, 29460, 13, 3296, 1670, 11, 19075, 527, 6052, 369, 682, 198, 310, 3932, 3118, 994, 279, 1646, 574, 16572, 13, 4452, 11, 422, 279, 198, 310, 4966, 1693, 1646, 574, 3549, 449, 5217, 4519, 304, 279, 198, 310, 10103, 79060, 1807, 14196, 328, 4467, 11, 1243, 264, 12435, 328, 4467, 315, 198, 310, 22695, 20126, 1198, 22695, 828, 2085, 1537, 477, 2218, 198, 310, 8310, 1198, 649, 387, 5946, 311, 420, 1749, 13, 1789, 3187, 11, 264, 1646, 198, 310, 16572, 449, 1217, 3110, 11, 1537, 3110, 11, 892, 11, 323, 10959, 8310, 1253, 387, 198, 310, 79002, 1701, 459, 328, 4467, 449, 1217, 3110, 323, 892, 8310, 13, 220, 763, 420, 198, 310, 1162, 11, 279, 1217, 3110, 3330, 2011, 387, 3118, 11, 323, 682, 3330, 5144, 198, 310, 1288, 2489, 1884, 304, 279, 10103, 79060, 1807, 14196, 328, 4467, 5946, 311, 198, 310, 10103, 3261, 13, 14196, 271, 286, 597, 551, 528, 11, 10309, 198, 310, 578, 1396, 315, 19075, 311, 7068, 369, 1855, 1217, 382, 286, 3673, 551, 328, 1895, 11, 328, 4467, 11, 477, 1160, 11, 10309, 198, 310, 42427, 31095, 279, 3673, 505, 902, 19075, 649, 387, 1903, 13, 1442, 198, 310, 10103, 3699, 14196, 374, 459, 328, 1895, 11, 1160, 11, 477, 328, 4467, 449, 264, 3254, 3330, 345, 310, 1193, 3673, 505, 279, 2728, 743, 690, 387, 11349, 13, 1115, 649, 387, 198, 310, 1511, 11, 369, 3187, 11, 311, 9067, 279, 19075, 311, 3673, 198, 310, 2949, 264, 4040, 5699, 477, 17779, 13, 1442, 10103, 3699, 14196, 374, 459, 198, 310, 328, 4467, 449, 1217, 3110, 323, 1537, 3110, 8310, 11, 1243, 279, 1537, 198, 310, 20020, 374, 28175, 311, 1855, 1217, 13, 1789, 3187, 11, 422, 198, 310, 10103, 3699, 14196, 5727, 220, 18, 7123, 449, 1217, 549, 16, 1198, 320, 52, 16, 11, 358, 16, 705, 320, 52, 16, 11, 358, 17, 1350, 310, 323, 320, 52, 16, 11, 358, 18, 8, 1198, 1243, 279, 19075, 369, 1217, 549, 16, 527, 198, 310, 12146, 505, 3673, 358, 16, 11, 358, 17, 11, 323, 358, 18, 13, 3296, 1670, 11, 19075, 198, 310, 527, 1903, 505, 682, 3673, 3118, 994, 279, 1646, 574, 16572, 382, 286, 502, 31505, 8943, 1807, 551, 328, 4467, 11, 10309, 198, 310, 10103, 943, 31505, 8943, 1807, 14196, 6835, 5217, 22695, 828, 198, 310, 311, 279, 1646, 11, 902, 1253, 387, 1511, 555, 279, 4211, 311, 7417, 198, 310, 5573, 323, 28782, 13708, 13, 220 ]
10gen/mongo-orchestration
mongo_orchestration/servers.py
Servers.remove
def remove(self, server_id): """remove server and data stuff Args: server_id - server identity """ server = self._storage.pop(server_id) server.stop() server.cleanup()
python
def remove(self, server_id): """remove server and data stuff Args: server_id - server identity """ server = self._storage.pop(server_id) server.stop() server.cleanup()
[ "def", "remove", "(", "self", ",", "server_id", ")", ":", "server", "=", "self", ".", "_storage", ".", "pop", "(", "server_id", ")", "server", ".", "stop", "(", ")", "server", ".", "cleanup", "(", ")" ]
remove server and data stuff Args: server_id - server identity
[ "remove", "server", "and", "data", "stuff", "Args", ":", "server_id", "-", "server", "identity" ]
train
https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/servers.py#L525-L532
<|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: remove server and data stuff Args: server_id - server identity ### Response: def remove(self, server_id): """remove server and data stuff Args: server_id - server identity """ server = self._storage.pop(server_id) server.stop() server.cleanup() <|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, 5514, 3622, 323, 828, 6392, 198, 286, 18161, 512, 310, 3622, 851, 482, 3622, 9764, 271, 14711, 6075, 512, 755, 4148, 1214, 11, 3622, 851, 997, 286, 4304, 5514, 3622, 323, 828, 6392, 198, 286, 18161, 512, 310, 3622, 851, 482, 3622, 9764, 198, 286, 3270, 286, 3622, 284, 659, 1462, 16568, 8452, 22136, 851, 340, 286, 3622, 13530, 746, 286, 3622, 88789, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 5514, 3622, 323, 828, 6392, 198, 286, 18161, 512, 310, 3622, 851, 482, 3622, 9764, 271, 14711, 6075, 512, 755, 4148, 1214, 11, 3622, 851, 997, 286, 4304, 5514, 3622, 323, 828, 6392, 198, 286, 18161, 512, 310, 3622, 851, 482, 3622, 9764, 198, 286, 3270, 286, 3622, 284, 659, 1462, 16568, 8452, 22136, 851, 340, 286, 3622, 13530, 746, 286, 3622, 88789, 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, 128009 ]
inasafe/inasafe
safe_extras/pydispatch/dispatcher.py
_removeOldBackRefs
def _removeOldBackRefs(senderkey, signal, receiver, receivers): """Kill old sendersBack references from receiver This guards against multiple registration of the same receiver for a given signal and sender leaking memory as old back reference records build up. Also removes old receiver instance from receivers """ try: index = receivers.index(receiver) # need to scan back references here and remove senderkey except ValueError: return False else: oldReceiver = receivers[index] del receivers[index] found = 0 signals = connections.get(signal) if signals is not None: for sig,recs in connections.get(signal,{}).items(): if sig != signal: for rec in recs: if rec is oldReceiver: found = 1 break if not found: _killBackref( oldReceiver, senderkey ) return True return False
python
def _removeOldBackRefs(senderkey, signal, receiver, receivers): """Kill old sendersBack references from receiver This guards against multiple registration of the same receiver for a given signal and sender leaking memory as old back reference records build up. Also removes old receiver instance from receivers """ try: index = receivers.index(receiver) # need to scan back references here and remove senderkey except ValueError: return False else: oldReceiver = receivers[index] del receivers[index] found = 0 signals = connections.get(signal) if signals is not None: for sig,recs in connections.get(signal,{}).items(): if sig != signal: for rec in recs: if rec is oldReceiver: found = 1 break if not found: _killBackref( oldReceiver, senderkey ) return True return False
[ "def", "_removeOldBackRefs", "(", "senderkey", ",", "signal", ",", "receiver", ",", "receivers", ")", ":", "try", ":", "index", "=", "receivers", ".", "index", "(", "receiver", ")", "# need to scan back references here and remove senderkey", "except", "ValueError", ":", "return", "False", "else", ":", "oldReceiver", "=", "receivers", "[", "index", "]", "del", "receivers", "[", "index", "]", "found", "=", "0", "signals", "=", "connections", ".", "get", "(", "signal", ")", "if", "signals", "is", "not", "None", ":", "for", "sig", ",", "recs", "in", "connections", ".", "get", "(", "signal", ",", "{", "}", ")", ".", "items", "(", ")", ":", "if", "sig", "!=", "signal", ":", "for", "rec", "in", "recs", ":", "if", "rec", "is", "oldReceiver", ":", "found", "=", "1", "break", "if", "not", "found", ":", "_killBackref", "(", "oldReceiver", ",", "senderkey", ")", "return", "True", "return", "False" ]
Kill old sendersBack references from receiver This guards against multiple registration of the same receiver for a given signal and sender leaking memory as old back reference records build up. Also removes old receiver instance from receivers
[ "Kill", "old", "sendersBack", "references", "from", "receiver" ]
train
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe_extras/pydispatch/dispatcher.py#L441-L470
<|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: Kill old sendersBack references from receiver This guards against multiple registration of the same receiver for a given signal and sender leaking memory as old back reference records build up. Also removes old receiver instance from receivers ### Response: def _removeOldBackRefs(senderkey, signal, receiver, receivers): """Kill old sendersBack references from receiver This guards against multiple registration of the same receiver for a given signal and sender leaking memory as old back reference records build up. Also removes old receiver instance from receivers """ try: index = receivers.index(receiver) # need to scan back references here and remove senderkey except ValueError: return False else: oldReceiver = receivers[index] del receivers[index] found = 0 signals = connections.get(signal) if signals is not None: for sig,recs in connections.get(signal,{}).items(): if sig != signal: for rec in recs: if rec is oldReceiver: found = 1 break if not found: _killBackref( oldReceiver, senderkey ) 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, 54834, 2362, 3708, 388, 3792, 15407, 505, 14291, 271, 262, 1115, 27270, 2403, 5361, 12506, 315, 279, 1890, 198, 262, 14291, 369, 264, 2728, 8450, 323, 4750, 52929, 5044, 198, 262, 439, 2362, 1203, 5905, 7576, 1977, 709, 382, 262, 7429, 29260, 2362, 14291, 2937, 505, 41006, 271, 14711, 6075, 512, 755, 721, 5514, 18788, 3792, 83907, 19939, 798, 11, 8450, 11, 14291, 11, 41006, 997, 262, 4304, 54834, 2362, 3708, 388, 3792, 15407, 505, 14291, 271, 262, 1115, 27270, 2403, 5361, 12506, 315, 279, 1890, 198, 262, 14291, 369, 264, 2728, 8450, 323, 4750, 52929, 5044, 198, 262, 439, 2362, 1203, 5905, 7576, 1977, 709, 382, 262, 7429, 29260, 2362, 14291, 2937, 505, 41006, 198, 262, 3270, 262, 1456, 512, 286, 1963, 284, 41006, 5265, 79226, 340, 286, 674, 1205, 311, 8737, 1203, 15407, 1618, 323, 4148, 4750, 798, 198, 262, 3734, 15764, 512, 286, 471, 3641, 198, 262, 775, 512, 286, 2362, 26512, 284, 41006, 6042, 933, 286, 1624, 41006, 6042, 933, 286, 1766, 284, 220, 15, 198, 286, 17738, 284, 13537, 673, 57882, 340, 286, 422, 17738, 374, 539, 2290, 512, 310, 369, 8531, 11, 2827, 82, 304, 13537, 673, 57882, 11, 6390, 570, 3699, 4019, 394, 422, 8531, 976, 8450, 512, 504, 369, 1421, 304, 1421, 82, 512, 667, 422, 1421, 374, 2362, 26512, 512, 1014, 1766, 284, 220, 16, 198, 1014, 1464, 198, 286, 422, 539, 1766, 512, 310, 721, 11088, 3792, 1116, 7, 2362, 26512, 11, 4750, 798, 1763, 310, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 54834, 2362, 3708, 388, 3792, 15407, 505, 14291, 271, 262, 1115, 27270, 2403, 5361, 12506, 315, 279, 1890, 198, 262, 14291, 369, 264, 2728, 8450, 323, 4750, 52929, 5044, 198, 262, 439, 2362, 1203, 5905, 7576, 1977, 709, 382, 262, 7429, 29260, 2362, 14291, 2937, 505, 41006, 271, 14711, 6075, 512, 755, 721, 5514, 18788, 3792, 83907, 19939, 798, 11, 8450, 11, 14291, 11, 41006, 997, 262, 4304, 54834, 2362, 3708, 388, 3792, 15407, 505, 14291, 271, 262, 1115, 27270, 2403, 5361, 12506, 315, 279, 1890, 198, 262, 14291, 369, 264, 2728, 8450, 323, 4750, 52929, 5044, 198, 262, 439, 2362, 1203, 5905, 7576, 1977, 709, 382, 262, 7429, 29260, 2362, 14291, 2937, 505, 41006, 198, 262, 3270, 262, 1456, 512, 286, 1963, 284, 41006, 5265, 79226, 340, 286, 674, 1205, 311, 8737, 1203, 15407, 1618, 323, 4148, 4750, 798, 198, 262, 3734, 15764, 512, 286, 471, 3641, 198, 262, 775, 512, 286, 2362, 26512, 284, 41006, 6042, 933, 286, 1624, 41006, 6042, 933, 286, 1766, 284, 220, 15, 198, 286, 17738, 284, 13537, 673, 57882, 340, 286, 422, 17738, 374, 539, 2290, 512, 310, 369, 8531, 11, 2827, 82, 304, 13537, 673, 57882, 11, 6390, 570, 3699, 4019, 394, 422, 8531, 976, 8450, 512, 504, 369, 1421, 304, 1421, 82, 512, 667, 422, 1421, 374, 2362, 26512, 512, 1014, 1766, 284, 220, 16, 198, 1014, 1464, 198, 286, 422, 539, 1766, 512, 310, 721, 11088, 3792, 1116, 7, 2362, 26512, 11, 4750, 798, 1763, 310, 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 ]
JukeboxPipeline/jukebox-core
src/jukeboxcore/release.py
Release.delete_releasefile
def delete_releasefile(self, release): """Delete the releasefile of the given release This is inteded to be used in a action unit. :param release: the release with the releasefile :type release: :class:`Release` :returns: an action status :rtype: :class:`ActionStatus` :raises: None """ fp = release._releasefile.get_fullpath() log.info("Deleting release file %s", fp) delete_file(release._releasefile) return ActionStatus(ActionStatus.SUCCESS, msg="Deleted %s" % fp)
python
def delete_releasefile(self, release): """Delete the releasefile of the given release This is inteded to be used in a action unit. :param release: the release with the releasefile :type release: :class:`Release` :returns: an action status :rtype: :class:`ActionStatus` :raises: None """ fp = release._releasefile.get_fullpath() log.info("Deleting release file %s", fp) delete_file(release._releasefile) return ActionStatus(ActionStatus.SUCCESS, msg="Deleted %s" % fp)
[ "def", "delete_releasefile", "(", "self", ",", "release", ")", ":", "fp", "=", "release", ".", "_releasefile", ".", "get_fullpath", "(", ")", "log", ".", "info", "(", "\"Deleting release file %s\"", ",", "fp", ")", "delete_file", "(", "release", ".", "_releasefile", ")", "return", "ActionStatus", "(", "ActionStatus", ".", "SUCCESS", ",", "msg", "=", "\"Deleted %s\"", "%", "fp", ")" ]
Delete the releasefile of the given release This is inteded to be used in a action unit. :param release: the release with the releasefile :type release: :class:`Release` :returns: an action status :rtype: :class:`ActionStatus` :raises: None
[ "Delete", "the", "releasefile", "of", "the", "given", "release" ]
train
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/release.py#L193-L208
<|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: Delete the releasefile of the given release This is inteded to be used in a action unit. :param release: the release with the releasefile :type release: :class:`Release` :returns: an action status :rtype: :class:`ActionStatus` :raises: None ### Response: def delete_releasefile(self, release): """Delete the releasefile of the given release This is inteded to be used in a action unit. :param release: the release with the releasefile :type release: :class:`Release` :returns: an action status :rtype: :class:`ActionStatus` :raises: None """ fp = release._releasefile.get_fullpath() log.info("Deleting release file %s", fp) delete_file(release._releasefile) return ActionStatus(ActionStatus.SUCCESS, msg="Deleted %s" % fp) <|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, 6571, 279, 4984, 1213, 315, 279, 2728, 4984, 271, 286, 1115, 374, 528, 31035, 311, 387, 1511, 304, 264, 1957, 5089, 382, 286, 551, 913, 4984, 25, 279, 4984, 449, 279, 4984, 1213, 198, 286, 551, 1337, 4984, 25, 551, 1058, 19258, 16464, 4077, 286, 551, 4310, 25, 459, 1957, 2704, 198, 286, 551, 33613, 25, 551, 1058, 19258, 2573, 2583, 4077, 286, 551, 33371, 25, 2290, 271, 14711, 6075, 512, 755, 3783, 25596, 1213, 1214, 11, 4984, 997, 286, 4304, 6571, 279, 4984, 1213, 315, 279, 2728, 4984, 271, 286, 1115, 374, 528, 31035, 311, 387, 1511, 304, 264, 1957, 5089, 382, 286, 551, 913, 4984, 25, 279, 4984, 449, 279, 4984, 1213, 198, 286, 551, 1337, 4984, 25, 551, 1058, 19258, 16464, 4077, 286, 551, 4310, 25, 459, 1957, 2704, 198, 286, 551, 33613, 25, 551, 1058, 19258, 2573, 2583, 4077, 286, 551, 33371, 25, 2290, 198, 286, 3270, 286, 12276, 284, 4984, 1462, 23859, 1213, 673, 16776, 2398, 746, 286, 1515, 5506, 446, 61575, 4984, 1052, 1034, 82, 498, 12276, 340, 286, 3783, 2517, 5921, 1655, 1462, 23859, 1213, 340, 286, 471, 5703, 2583, 22668, 2583, 45784, 345, 1014, 3835, 429, 27130, 1034, 82, 1, 1034, 12276, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 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, 6571, 279, 4984, 1213, 315, 279, 2728, 4984, 271, 286, 1115, 374, 528, 31035, 311, 387, 1511, 304, 264, 1957, 5089, 382, 286, 551, 913, 4984, 25, 279, 4984, 449, 279, 4984, 1213, 198, 286, 551, 1337, 4984, 25, 551, 1058, 19258, 16464, 4077, 286, 551, 4310, 25, 459, 1957, 2704, 198, 286, 551, 33613, 25, 551, 1058, 19258, 2573, 2583, 4077, 286, 551, 33371, 25, 2290, 271, 14711, 6075, 512, 755, 3783, 25596, 1213, 1214, 11, 4984, 997, 286, 4304, 6571, 279, 4984, 1213, 315, 279, 2728, 4984, 271, 286, 1115, 374, 528, 31035, 311, 387, 1511, 304, 264, 1957, 5089, 382, 286, 551, 913, 4984, 25, 279, 4984, 449, 279, 4984, 1213, 198, 286, 551, 1337, 4984, 25, 551, 1058, 19258, 16464, 4077, 286, 551, 4310, 25, 459, 1957, 2704, 198, 286, 551, 33613, 25, 551, 1058, 19258, 2573, 2583, 4077, 286, 551, 33371, 25, 2290, 198, 286, 3270, 286, 12276, 284, 4984, 1462, 23859, 1213, 673, 16776, 2398, 746, 286, 1515, 5506, 446, 61575, 4984, 1052, 1034, 82, 498, 12276, 340, 286, 3783, 2517, 5921, 1655, 1462, 23859, 1213, 340, 286, 471, 5703, 2583, 22668, 2583, 45784, 345, 1014, 3835, 429, 27130, 1034, 82, 1, 1034, 12276, 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 ]
quantmind/pulsar
pulsar/apps/http/stream.py
HttpStream.read
async def read(self, n=None): """Read all content """ if self._streamed: return b'' buffer = [] async for body in self: buffer.append(body) return b''.join(buffer)
python
async def read(self, n=None): """Read all content """ if self._streamed: return b'' buffer = [] async for body in self: buffer.append(body) return b''.join(buffer)
[ "async", "def", "read", "(", "self", ",", "n", "=", "None", ")", ":", "if", "self", ".", "_streamed", ":", "return", "b''", "buffer", "=", "[", "]", "async", "for", "body", "in", "self", ":", "buffer", ".", "append", "(", "body", ")", "return", "b''", ".", "join", "(", "buffer", ")" ]
Read all content
[ "Read", "all", "content" ]
train
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/http/stream.py#L27-L35
<|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: Read all content ### Response: async def read(self, n=None): """Read all content """ if self._streamed: return b'' buffer = [] async for body in self: buffer.append(body) return b''.join(buffer) <|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, 4518, 682, 2262, 271, 14711, 6075, 512, 7847, 711, 1373, 1214, 11, 308, 5980, 997, 286, 4304, 4518, 682, 2262, 198, 286, 3270, 286, 422, 659, 1462, 4116, 291, 512, 310, 471, 293, 72572, 286, 4240, 284, 4260, 286, 3393, 369, 2547, 304, 659, 512, 310, 4240, 2102, 15582, 340, 286, 471, 293, 98722, 6115, 12869, 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, 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, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 4518, 682, 2262, 271, 14711, 6075, 512, 7847, 711, 1373, 1214, 11, 308, 5980, 997, 286, 4304, 4518, 682, 2262, 198, 286, 3270, 286, 422, 659, 1462, 4116, 291, 512, 310, 471, 293, 72572, 286, 4240, 284, 4260, 286, 3393, 369, 2547, 304, 659, 512, 310, 4240, 2102, 15582, 340, 286, 471, 293, 98722, 6115, 12869, 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 ]
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.oauth_signup
def oauth_signup(self, provider, attrs, defaults, redirect_url=None): """Start the signup process after having logged in via oauth """ session["oauth_user_defaults"] = defaults session["oauth_user_attrs"] = dict(provider=provider, **attrs) if not redirect_url: redirect_url = request.args.get("next") return redirect(url_for('users.oauth_signup', next=redirect_url))
python
def oauth_signup(self, provider, attrs, defaults, redirect_url=None): """Start the signup process after having logged in via oauth """ session["oauth_user_defaults"] = defaults session["oauth_user_attrs"] = dict(provider=provider, **attrs) if not redirect_url: redirect_url = request.args.get("next") return redirect(url_for('users.oauth_signup', next=redirect_url))
[ "def", "oauth_signup", "(", "self", ",", "provider", ",", "attrs", ",", "defaults", ",", "redirect_url", "=", "None", ")", ":", "session", "[", "\"oauth_user_defaults\"", "]", "=", "defaults", "session", "[", "\"oauth_user_attrs\"", "]", "=", "dict", "(", "provider", "=", "provider", ",", "*", "*", "attrs", ")", "if", "not", "redirect_url", ":", "redirect_url", "=", "request", ".", "args", ".", "get", "(", "\"next\"", ")", "return", "redirect", "(", "url_for", "(", "'users.oauth_signup'", ",", "next", "=", "redirect_url", ")", ")" ]
Start the signup process after having logged in via oauth
[ "Start", "the", "signup", "process", "after", "having", "logged", "in", "via", "oauth" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L863-L870
<|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: Start the signup process after having logged in via oauth ### Response: def oauth_signup(self, provider, attrs, defaults, redirect_url=None): """Start the signup process after having logged in via oauth """ session["oauth_user_defaults"] = defaults session["oauth_user_attrs"] = dict(provider=provider, **attrs) if not redirect_url: redirect_url = request.args.get("next") return redirect(url_for('users.oauth_signup', next=redirect_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, 3563, 279, 41148, 1920, 1306, 3515, 14042, 304, 4669, 47515, 271, 14711, 6075, 512, 755, 47515, 83105, 1214, 11, 9287, 11, 16602, 11, 17088, 11, 6559, 2975, 5980, 997, 286, 4304, 3563, 279, 41148, 1920, 1306, 3515, 14042, 304, 4669, 47515, 198, 286, 3270, 286, 3882, 1204, 35463, 3398, 43390, 1365, 284, 17088, 198, 286, 3882, 1204, 35463, 3398, 40678, 1365, 284, 6587, 51986, 28, 20576, 11, 3146, 21101, 340, 286, 422, 539, 6559, 2975, 512, 310, 6559, 2975, 284, 1715, 16769, 673, 446, 3684, 1158, 286, 471, 6559, 6659, 5595, 493, 4312, 58873, 83105, 518, 1828, 28, 8280, 2975, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 3563, 279, 41148, 1920, 1306, 3515, 14042, 304, 4669, 47515, 271, 14711, 6075, 512, 755, 47515, 83105, 1214, 11, 9287, 11, 16602, 11, 17088, 11, 6559, 2975, 5980, 997, 286, 4304, 3563, 279, 41148, 1920, 1306, 3515, 14042, 304, 4669, 47515, 198, 286, 3270, 286, 3882, 1204, 35463, 3398, 43390, 1365, 284, 17088, 198, 286, 3882, 1204, 35463, 3398, 40678, 1365, 284, 6587, 51986, 28, 20576, 11, 3146, 21101, 340, 286, 422, 539, 6559, 2975, 512, 310, 6559, 2975, 284, 1715, 16769, 673, 446, 3684, 1158, 286, 471, 6559, 6659, 5595, 493, 4312, 58873, 83105, 518, 1828, 28, 8280, 2975, 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 ]
saltstack/salt
salt/modules/kernelpkg_linux_apt.py
cleanup
def cleanup(keep_latest=True): ''' Remove all unused kernel packages from the system. keep_latest : True In the event that the active kernel is not the latest one installed, setting this to True will retain the latest kernel package, in addition to the active one. If False, all kernel packages other than the active one will be removed. CLI Example: .. code-block:: bash salt '*' kernelpkg.cleanup ''' removed = [] # Loop over all installed kernel packages for kernel in list_installed(): # Keep the active kernel package if kernel == active(): continue # Optionally keep the latest kernel package if keep_latest and kernel == latest_installed(): continue # Remove the kernel package removed.extend(remove(kernel)['removed']) return {'removed': removed}
python
def cleanup(keep_latest=True): ''' Remove all unused kernel packages from the system. keep_latest : True In the event that the active kernel is not the latest one installed, setting this to True will retain the latest kernel package, in addition to the active one. If False, all kernel packages other than the active one will be removed. CLI Example: .. code-block:: bash salt '*' kernelpkg.cleanup ''' removed = [] # Loop over all installed kernel packages for kernel in list_installed(): # Keep the active kernel package if kernel == active(): continue # Optionally keep the latest kernel package if keep_latest and kernel == latest_installed(): continue # Remove the kernel package removed.extend(remove(kernel)['removed']) return {'removed': removed}
[ "def", "cleanup", "(", "keep_latest", "=", "True", ")", ":", "removed", "=", "[", "]", "# Loop over all installed kernel packages", "for", "kernel", "in", "list_installed", "(", ")", ":", "# Keep the active kernel package", "if", "kernel", "==", "active", "(", ")", ":", "continue", "# Optionally keep the latest kernel package", "if", "keep_latest", "and", "kernel", "==", "latest_installed", "(", ")", ":", "continue", "# Remove the kernel package", "removed", ".", "extend", "(", "remove", "(", "kernel", ")", "[", "'removed'", "]", ")", "return", "{", "'removed'", ":", "removed", "}" ]
Remove all unused kernel packages from the system. keep_latest : True In the event that the active kernel is not the latest one installed, setting this to True will retain the latest kernel package, in addition to the active one. If False, all kernel packages other than the active one will be removed. CLI Example: .. code-block:: bash salt '*' kernelpkg.cleanup
[ "Remove", "all", "unused", "kernel", "packages", "from", "the", "system", "." ]
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/kernelpkg_linux_apt.py#L231-L262
<|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: Remove all unused kernel packages from the system. keep_latest : True In the event that the active kernel is not the latest one installed, setting this to True will retain the latest kernel package, in addition to the active one. If False, all kernel packages other than the active one will be removed. CLI Example: .. code-block:: bash salt '*' kernelpkg.cleanup ### Response: def cleanup(keep_latest=True): ''' Remove all unused kernel packages from the system. keep_latest : True In the event that the active kernel is not the latest one installed, setting this to True will retain the latest kernel package, in addition to the active one. If False, all kernel packages other than the active one will be removed. CLI Example: .. code-block:: bash salt '*' kernelpkg.cleanup ''' removed = [] # Loop over all installed kernel packages for kernel in list_installed(): # Keep the active kernel package if kernel == active(): continue # Optionally keep the latest kernel package if keep_latest and kernel == latest_installed(): continue # Remove the kernel package removed.extend(remove(kernel)['removed']) return {'removed': removed} <|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, 13319, 682, 20604, 10206, 14519, 505, 279, 1887, 382, 262, 2567, 65980, 551, 3082, 198, 286, 763, 279, 1567, 430, 279, 4642, 10206, 374, 539, 279, 5652, 832, 10487, 11, 6376, 420, 311, 3082, 198, 286, 690, 14389, 279, 5652, 10206, 6462, 11, 304, 5369, 311, 279, 4642, 832, 13, 1442, 3641, 11, 682, 10206, 198, 286, 14519, 1023, 1109, 279, 4642, 832, 690, 387, 7108, 382, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 286, 12290, 31801, 83685, 1290, 7501, 88789, 271, 14711, 6075, 512, 755, 21993, 7, 13397, 65980, 3702, 997, 262, 11414, 262, 11016, 682, 20604, 10206, 14519, 505, 279, 1887, 382, 262, 2567, 65980, 551, 3082, 198, 286, 763, 279, 1567, 430, 279, 4642, 10206, 374, 539, 279, 5652, 832, 10487, 11, 6376, 420, 311, 3082, 198, 286, 690, 14389, 279, 5652, 10206, 6462, 11, 304, 5369, 311, 279, 4642, 832, 13, 1442, 3641, 11, 682, 10206, 198, 286, 14519, 1023, 1109, 279, 4642, 832, 690, 387, 7108, 382, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 286, 12290, 31801, 83685, 1290, 7501, 88789, 198, 262, 11414, 262, 7108, 284, 14941, 262, 674, 22070, 927, 682, 10487, 10206, 14519, 198, 262, 369, 10206, 304, 1160, 80165, 41074, 286, 674, 13969, 279, 4642, 10206, 6462, 198, 286, 422, 10206, 624, 4642, 4019, 310, 3136, 271, 286, 674, 97295, 2567, 279, 5652, 10206, 6462, 198, 286, 422, 2567, 65980, 323, 10206, 624, 5652, 80165, 4019, 310, 3136, 271, 286, 674, 11016, 279, 10206, 6462, 198, 286, 7108, 16209, 68809, 56257, 51610, 46856, 24287, 262, 471, 5473, 46856, 1232, 7108, 534, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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, 13319, 682, 20604, 10206, 14519, 505, 279, 1887, 382, 262, 2567, 65980, 551, 3082, 198, 286, 763, 279, 1567, 430, 279, 4642, 10206, 374, 539, 279, 5652, 832, 10487, 11, 6376, 420, 311, 3082, 198, 286, 690, 14389, 279, 5652, 10206, 6462, 11, 304, 5369, 311, 279, 4642, 832, 13, 1442, 3641, 11, 682, 10206, 198, 286, 14519, 1023, 1109, 279, 4642, 832, 690, 387, 7108, 382, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 286, 12290, 31801, 83685, 1290, 7501, 88789, 271, 14711, 6075, 512, 755, 21993, 7, 13397, 65980, 3702, 997, 262, 11414, 262, 11016, 682, 20604, 10206, 14519, 505, 279, 1887, 382, 262, 2567, 65980, 551, 3082, 198, 286, 763, 279, 1567, 430, 279, 4642, 10206, 374, 539, 279, 5652, 832, 10487, 11, 6376, 420, 311, 3082, 198, 286, 690, 14389, 279, 5652, 10206, 6462, 11, 304, 5369, 311, 279, 4642, 832, 13, 1442, 3641, 11, 682, 10206, 198, 286, 14519, 1023, 1109, 279, 4642, 832, 690, 387, 7108, 382, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 286, 12290, 31801, 83685, 1290, 7501, 88789, 198, 262, 11414, 262, 7108, 284, 14941, 262, 674, 22070, 927, 682, 10487, 10206, 14519, 198, 262, 369, 10206, 304, 1160, 80165, 41074, 286, 674, 13969, 279, 4642, 10206, 6462, 198, 286, 422, 10206, 624, 4642, 4019, 310, 3136, 271, 286, 674, 97295, 2567, 279, 5652, 10206, 6462, 198, 286, 422, 2567, 65980, 323, 10206, 624, 5652, 80165, 4019, 310, 3136, 271, 286, 674, 11016, 279, 10206, 6462, 198, 286, 7108, 16209, 68809, 56257, 51610, 46856, 24287, 262, 471, 5473, 46856, 1232, 7108, 534, 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 ]
icometrix/dicom2nifti
dicom2nifti/convert_philips.py
_singleframe_to_block
def _singleframe_to_block(grouped_dicoms): """ Generate a full datablock containing all timepoints """ # For each slice / mosaic create a data volume block data_blocks = [] for index in range(0, len(grouped_dicoms)): logger.info('Creating block %s of %s' % (index + 1, len(grouped_dicoms))) current_block = _stack_to_block(grouped_dicoms[index]) current_block = current_block[:, :, :, numpy.newaxis] data_blocks.append(current_block) try: full_block = numpy.concatenate(data_blocks, axis=3) except: traceback.print_exc() raise ConversionError("MISSING_DICOM_FILES") # Apply the rescaling if needed common.apply_scaling(full_block, grouped_dicoms[0][0]) return full_block
python
def _singleframe_to_block(grouped_dicoms): """ Generate a full datablock containing all timepoints """ # For each slice / mosaic create a data volume block data_blocks = [] for index in range(0, len(grouped_dicoms)): logger.info('Creating block %s of %s' % (index + 1, len(grouped_dicoms))) current_block = _stack_to_block(grouped_dicoms[index]) current_block = current_block[:, :, :, numpy.newaxis] data_blocks.append(current_block) try: full_block = numpy.concatenate(data_blocks, axis=3) except: traceback.print_exc() raise ConversionError("MISSING_DICOM_FILES") # Apply the rescaling if needed common.apply_scaling(full_block, grouped_dicoms[0][0]) return full_block
[ "def", "_singleframe_to_block", "(", "grouped_dicoms", ")", ":", "# For each slice / mosaic create a data volume block", "data_blocks", "=", "[", "]", "for", "index", "in", "range", "(", "0", ",", "len", "(", "grouped_dicoms", ")", ")", ":", "logger", ".", "info", "(", "'Creating block %s of %s'", "%", "(", "index", "+", "1", ",", "len", "(", "grouped_dicoms", ")", ")", ")", "current_block", "=", "_stack_to_block", "(", "grouped_dicoms", "[", "index", "]", ")", "current_block", "=", "current_block", "[", ":", ",", ":", ",", ":", ",", "numpy", ".", "newaxis", "]", "data_blocks", ".", "append", "(", "current_block", ")", "try", ":", "full_block", "=", "numpy", ".", "concatenate", "(", "data_blocks", ",", "axis", "=", "3", ")", "except", ":", "traceback", ".", "print_exc", "(", ")", "raise", "ConversionError", "(", "\"MISSING_DICOM_FILES\"", ")", "# Apply the rescaling if needed", "common", ".", "apply_scaling", "(", "full_block", ",", "grouped_dicoms", "[", "0", "]", "[", "0", "]", ")", "return", "full_block" ]
Generate a full datablock containing all timepoints
[ "Generate", "a", "full", "datablock", "containing", "all", "timepoints" ]
train
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/convert_philips.py#L325-L346
<|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 full datablock containing all timepoints ### Response: def _singleframe_to_block(grouped_dicoms): """ Generate a full datablock containing all timepoints """ # For each slice / mosaic create a data volume block data_blocks = [] for index in range(0, len(grouped_dicoms)): logger.info('Creating block %s of %s' % (index + 1, len(grouped_dicoms))) current_block = _stack_to_block(grouped_dicoms[index]) current_block = current_block[:, :, :, numpy.newaxis] data_blocks.append(current_block) try: full_block = numpy.concatenate(data_blocks, axis=3) except: traceback.print_exc() raise ConversionError("MISSING_DICOM_FILES") # Apply the rescaling if needed common.apply_scaling(full_block, grouped_dicoms[0][0]) return full_block <|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, 2539, 72340, 1039, 8649, 682, 892, 7862, 271, 14711, 6075, 512, 755, 721, 15698, 6906, 2401, 7258, 18158, 291, 40254, 7085, 997, 262, 3270, 262, 20400, 264, 2539, 72340, 1039, 8649, 682, 892, 7862, 198, 262, 3270, 262, 674, 1789, 1855, 16363, 611, 71624, 1893, 264, 828, 8286, 2565, 198, 262, 828, 26266, 284, 4260, 262, 369, 1963, 304, 2134, 7, 15, 11, 2479, 18158, 291, 40254, 7085, 10162, 286, 6050, 5506, 493, 26021, 2565, 1034, 82, 315, 1034, 82, 6, 1034, 320, 1275, 489, 220, 16, 11, 2479, 18158, 291, 40254, 7085, 6054, 286, 1510, 7258, 284, 721, 7848, 2401, 7258, 18158, 291, 40254, 7085, 6042, 2608, 286, 1510, 7258, 284, 1510, 7258, 9821, 28882, 28882, 8760, 77033, 933, 286, 828, 26266, 2102, 8937, 7258, 696, 262, 1456, 512, 286, 2539, 7258, 284, 8760, 39859, 2657, 26266, 11, 8183, 28, 18, 340, 262, 3734, 512, 286, 47158, 2263, 46747, 746, 286, 4933, 43609, 1480, 446, 80570, 1753, 1586, 1341, 1937, 49110, 5240, 262, 674, 21194, 279, 594, 82652, 422, 4460, 198, 262, 4279, 13344, 80316, 30007, 7258, 11, 41141, 40254, 7085, 58, 15, 1483, 15, 9801, 262, 471, 2539, 7258, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1039, 8649, 682, 892, 7862, 271, 14711, 6075, 512, 755, 721, 15698, 6906, 2401, 7258, 18158, 291, 40254, 7085, 997, 262, 3270, 262, 20400, 264, 2539, 72340, 1039, 8649, 682, 892, 7862, 198, 262, 3270, 262, 674, 1789, 1855, 16363, 611, 71624, 1893, 264, 828, 8286, 2565, 198, 262, 828, 26266, 284, 4260, 262, 369, 1963, 304, 2134, 7, 15, 11, 2479, 18158, 291, 40254, 7085, 10162, 286, 6050, 5506, 493, 26021, 2565, 1034, 82, 315, 1034, 82, 6, 1034, 320, 1275, 489, 220, 16, 11, 2479, 18158, 291, 40254, 7085, 6054, 286, 1510, 7258, 284, 721, 7848, 2401, 7258, 18158, 291, 40254, 7085, 6042, 2608, 286, 1510, 7258, 284, 1510, 7258, 9821, 28882, 28882, 8760, 77033, 933, 286, 828, 26266, 2102, 8937, 7258, 696, 262, 1456, 512, 286, 2539, 7258, 284, 8760, 39859, 2657, 26266, 11, 8183, 28, 18, 340, 262, 3734, 512, 286, 47158, 2263, 46747, 746, 286, 4933, 43609, 1480, 446, 80570, 1753, 1586, 1341, 1937, 49110, 5240, 262, 674, 21194, 279, 594, 82652, 422, 4460, 198, 262, 4279, 13344, 80316, 30007, 7258, 11, 41141, 40254, 7085, 58, 15, 1483, 15, 9801, 262, 471, 2539, 7258, 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 ]
python-cmd2/cmd2
examples/async_printing.py
AlerterApp._generate_alert_str
def _generate_alert_str(self) -> str: """ Combines alerts into one string that can be printed to the terminal :return: the alert string """ global ALERTS alert_str = '' alerts = self._get_alerts() longest_alert = max(ALERTS, key=len) num_asterisks = len(longest_alert) + 8 for i, cur_alert in enumerate(alerts): # Use padding to center the alert padding = ' ' * int((num_asterisks - len(cur_alert)) / 2) if i > 0: alert_str += '\n' alert_str += '*' * num_asterisks + '\n' alert_str += padding + cur_alert + padding + '\n' alert_str += '*' * num_asterisks + '\n' return alert_str
python
def _generate_alert_str(self) -> str: """ Combines alerts into one string that can be printed to the terminal :return: the alert string """ global ALERTS alert_str = '' alerts = self._get_alerts() longest_alert = max(ALERTS, key=len) num_asterisks = len(longest_alert) + 8 for i, cur_alert in enumerate(alerts): # Use padding to center the alert padding = ' ' * int((num_asterisks - len(cur_alert)) / 2) if i > 0: alert_str += '\n' alert_str += '*' * num_asterisks + '\n' alert_str += padding + cur_alert + padding + '\n' alert_str += '*' * num_asterisks + '\n' return alert_str
[ "def", "_generate_alert_str", "(", "self", ")", "->", "str", ":", "global", "ALERTS", "alert_str", "=", "''", "alerts", "=", "self", ".", "_get_alerts", "(", ")", "longest_alert", "=", "max", "(", "ALERTS", ",", "key", "=", "len", ")", "num_asterisks", "=", "len", "(", "longest_alert", ")", "+", "8", "for", "i", ",", "cur_alert", "in", "enumerate", "(", "alerts", ")", ":", "# Use padding to center the alert", "padding", "=", "' '", "*", "int", "(", "(", "num_asterisks", "-", "len", "(", "cur_alert", ")", ")", "/", "2", ")", "if", "i", ">", "0", ":", "alert_str", "+=", "'\\n'", "alert_str", "+=", "'*'", "*", "num_asterisks", "+", "'\\n'", "alert_str", "+=", "padding", "+", "cur_alert", "+", "padding", "+", "'\\n'", "alert_str", "+=", "'*'", "*", "num_asterisks", "+", "'\\n'", "return", "alert_str" ]
Combines alerts into one string that can be printed to the terminal :return: the alert string
[ "Combines", "alerts", "into", "one", "string", "that", "can", "be", "printed", "to", "the", "terminal", ":", "return", ":", "the", "alert", "string" ]
train
https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/examples/async_printing.py#L118-L141
<|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: Combines alerts into one string that can be printed to the terminal :return: the alert string ### Response: def _generate_alert_str(self) -> str: """ Combines alerts into one string that can be printed to the terminal :return: the alert string """ global ALERTS alert_str = '' alerts = self._get_alerts() longest_alert = max(ALERTS, key=len) num_asterisks = len(longest_alert) + 8 for i, cur_alert in enumerate(alerts): # Use padding to center the alert padding = ' ' * int((num_asterisks - len(cur_alert)) / 2) if i > 0: alert_str += '\n' alert_str += '*' * num_asterisks + '\n' alert_str += padding + cur_alert + padding + '\n' alert_str += '*' * num_asterisks + '\n' return alert_str <|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, 37292, 1572, 30350, 1139, 832, 925, 430, 649, 387, 17124, 311, 279, 15372, 198, 286, 551, 693, 25, 279, 5225, 925, 271, 14711, 6075, 512, 755, 721, 19927, 36817, 2966, 1214, 8, 1492, 610, 512, 286, 3270, 286, 23262, 1572, 30350, 1139, 832, 925, 430, 649, 387, 17124, 311, 279, 15372, 198, 286, 551, 693, 25, 279, 5225, 925, 198, 286, 3270, 286, 3728, 91648, 50, 271, 286, 5225, 2966, 284, 12038, 286, 30350, 284, 659, 1462, 456, 36817, 82, 2892, 286, 22807, 36817, 284, 1973, 47332, 3481, 50, 11, 1401, 46919, 340, 286, 1661, 62, 2352, 93934, 284, 2479, 12916, 478, 36817, 8, 489, 220, 23, 271, 286, 369, 602, 11, 2917, 36817, 304, 13555, 54537, 82, 997, 310, 674, 5560, 5413, 311, 4219, 279, 5225, 198, 310, 5413, 284, 364, 364, 353, 528, 1209, 2470, 62, 2352, 93934, 482, 2479, 18053, 36817, 595, 611, 220, 17, 696, 310, 422, 602, 871, 220, 15, 512, 394, 5225, 2966, 1447, 5307, 77, 1270, 310, 5225, 2966, 1447, 31801, 353, 1661, 62, 2352, 93934, 489, 5307, 77, 1270, 310, 5225, 2966, 1447, 5413, 489, 2917, 36817, 489, 5413, 489, 5307, 77, 1270, 310, 5225, 2966, 1447, 31801, 353, 1661, 62, 2352, 93934, 489, 5307, 77, 3961, 286, 471, 5225, 2966, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 37292, 1572, 30350, 1139, 832, 925, 430, 649, 387, 17124, 311, 279, 15372, 198, 286, 551, 693, 25, 279, 5225, 925, 271, 14711, 6075, 512, 755, 721, 19927, 36817, 2966, 1214, 8, 1492, 610, 512, 286, 3270, 286, 23262, 1572, 30350, 1139, 832, 925, 430, 649, 387, 17124, 311, 279, 15372, 198, 286, 551, 693, 25, 279, 5225, 925, 198, 286, 3270, 286, 3728, 91648, 50, 271, 286, 5225, 2966, 284, 12038, 286, 30350, 284, 659, 1462, 456, 36817, 82, 2892, 286, 22807, 36817, 284, 1973, 47332, 3481, 50, 11, 1401, 46919, 340, 286, 1661, 62, 2352, 93934, 284, 2479, 12916, 478, 36817, 8, 489, 220, 23, 271, 286, 369, 602, 11, 2917, 36817, 304, 13555, 54537, 82, 997, 310, 674, 5560, 5413, 311, 4219, 279, 5225, 198, 310, 5413, 284, 364, 364, 353, 528, 1209, 2470, 62, 2352, 93934, 482, 2479, 18053, 36817, 595, 611, 220, 17, 696, 310, 422, 602, 871, 220, 15, 512, 394, 5225, 2966, 1447, 5307, 77, 1270, 310, 5225, 2966, 1447, 31801, 353, 1661, 62, 2352, 93934, 489, 5307, 77, 1270, 310, 5225, 2966, 1447, 5413, 489, 2917, 36817, 489, 5413, 489, 5307, 77, 1270, 310, 5225, 2966, 1447, 31801, 353, 1661, 62, 2352, 93934, 489, 5307, 77, 3961, 286, 471, 5225, 2966, 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 ]
JoeVirtual/KonFoo
konfoo/core.py
Structure.index_fields
def index_fields(self, index=Index(), **options): """ Indexes all fields in the `Structure` starting with the given *index* and returns the :class:`Index` after the last :class:`Field` in the `Structure`. :param Index index: start :class:`Index` for the first :class:`Field` in the `Structure`. :keyword bool nested: if ``True`` all :class:`Pointer` fields of the `Structure` indexes their referenced :attr:`~Pointer.data` object fields as well (chained method call). """ for name, item in self.items(): # Container if is_container(item): index = item.index_fields(index, **options) # Pointer elif is_pointer(item) and get_nested(options): index = item.index_field(index) item.index_data() # Field elif is_field(item): index = item.index_field(index) else: raise MemberTypeError(self, item, name, index) return index
python
def index_fields(self, index=Index(), **options): """ Indexes all fields in the `Structure` starting with the given *index* and returns the :class:`Index` after the last :class:`Field` in the `Structure`. :param Index index: start :class:`Index` for the first :class:`Field` in the `Structure`. :keyword bool nested: if ``True`` all :class:`Pointer` fields of the `Structure` indexes their referenced :attr:`~Pointer.data` object fields as well (chained method call). """ for name, item in self.items(): # Container if is_container(item): index = item.index_fields(index, **options) # Pointer elif is_pointer(item) and get_nested(options): index = item.index_field(index) item.index_data() # Field elif is_field(item): index = item.index_field(index) else: raise MemberTypeError(self, item, name, index) return index
[ "def", "index_fields", "(", "self", ",", "index", "=", "Index", "(", ")", ",", "*", "*", "options", ")", ":", "for", "name", ",", "item", "in", "self", ".", "items", "(", ")", ":", "# Container", "if", "is_container", "(", "item", ")", ":", "index", "=", "item", ".", "index_fields", "(", "index", ",", "*", "*", "options", ")", "# Pointer", "elif", "is_pointer", "(", "item", ")", "and", "get_nested", "(", "options", ")", ":", "index", "=", "item", ".", "index_field", "(", "index", ")", "item", ".", "index_data", "(", ")", "# Field", "elif", "is_field", "(", "item", ")", ":", "index", "=", "item", ".", "index_field", "(", "index", ")", "else", ":", "raise", "MemberTypeError", "(", "self", ",", "item", ",", "name", ",", "index", ")", "return", "index" ]
Indexes all fields in the `Structure` starting with the given *index* and returns the :class:`Index` after the last :class:`Field` in the `Structure`. :param Index index: start :class:`Index` for the first :class:`Field` in the `Structure`. :keyword bool nested: if ``True`` all :class:`Pointer` fields of the `Structure` indexes their referenced :attr:`~Pointer.data` object fields as well (chained method call).
[ "Indexes", "all", "fields", "in", "the", "Structure", "starting", "with", "the", "given", "*", "index", "*", "and", "returns", "the", ":", "class", ":", "Index", "after", "the", "last", ":", "class", ":", "Field", "in", "the", "Structure", "." ]
train
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L738-L762
<|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: Indexes all fields in the `Structure` starting with the given *index* and returns the :class:`Index` after the last :class:`Field` in the `Structure`. :param Index index: start :class:`Index` for the first :class:`Field` in the `Structure`. :keyword bool nested: if ``True`` all :class:`Pointer` fields of the `Structure` indexes their referenced :attr:`~Pointer.data` object fields as well (chained method call). ### Response: def index_fields(self, index=Index(), **options): """ Indexes all fields in the `Structure` starting with the given *index* and returns the :class:`Index` after the last :class:`Field` in the `Structure`. :param Index index: start :class:`Index` for the first :class:`Field` in the `Structure`. :keyword bool nested: if ``True`` all :class:`Pointer` fields of the `Structure` indexes their referenced :attr:`~Pointer.data` object fields as well (chained method call). """ for name, item in self.items(): # Container if is_container(item): index = item.index_fields(index, **options) # Pointer elif is_pointer(item) and get_nested(options): index = item.index_field(index) item.index_data() # Field elif is_field(item): index = item.index_field(index) else: raise MemberTypeError(self, item, name, index) return index <|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, 63329, 682, 5151, 304, 279, 1595, 23807, 63, 6041, 449, 279, 2728, 198, 286, 353, 1275, 9, 323, 4780, 279, 551, 1058, 19258, 1581, 63, 1306, 279, 1566, 551, 1058, 19258, 1915, 4077, 286, 304, 279, 1595, 23807, 63438, 286, 551, 913, 8167, 1963, 25, 1212, 551, 1058, 19258, 1581, 63, 369, 279, 1176, 551, 1058, 19258, 1915, 4077, 310, 304, 279, 1595, 23807, 19154, 286, 551, 20454, 1845, 24997, 25, 422, 10103, 2575, 14196, 682, 551, 1058, 19258, 9261, 63, 5151, 315, 279, 198, 310, 1595, 23807, 63, 25998, 872, 25819, 551, 3064, 78902, 9261, 2245, 63, 1665, 198, 310, 5151, 439, 1664, 320, 331, 2692, 1749, 1650, 3677, 14711, 6075, 512, 755, 1963, 12406, 1214, 11, 1963, 28, 1581, 1535, 3146, 2945, 997, 286, 4304, 8167, 288, 682, 5151, 304, 279, 1595, 23807, 63, 6041, 449, 279, 2728, 198, 286, 353, 1275, 9, 323, 4780, 279, 551, 1058, 19258, 1581, 63, 1306, 279, 1566, 551, 1058, 19258, 1915, 4077, 286, 304, 279, 1595, 23807, 63438, 286, 551, 913, 8167, 1963, 25, 1212, 551, 1058, 19258, 1581, 63, 369, 279, 1176, 551, 1058, 19258, 1915, 4077, 310, 304, 279, 1595, 23807, 19154, 286, 551, 20454, 1845, 24997, 25, 422, 10103, 2575, 14196, 682, 551, 1058, 19258, 9261, 63, 5151, 315, 279, 198, 310, 1595, 23807, 63, 25998, 872, 25819, 551, 3064, 78902, 9261, 2245, 63, 1665, 198, 310, 5151, 439, 1664, 320, 331, 2692, 1749, 1650, 4390, 286, 3270, 286, 369, 836, 11, 1537, 304, 659, 9812, 4019, 310, 674, 9876, 198, 310, 422, 374, 16226, 5508, 997, 394, 1963, 284, 1537, 5265, 12406, 7343, 11, 3146, 2945, 340, 310, 674, 22366, 198, 310, 4508, 374, 22140, 5508, 8, 323, 636, 67379, 12349, 997, 394, 1963, 284, 1537, 5265, 5121, 7343, 340, 394, 1537, 5265, 1807, 746, 310, 674, 8771, 198, 310, 4508, 374, 5121, 5508, 997, 394, 1963, 284, 1537, 5265, 5121, 7343, 340, 310, 775, 512, 394, 4933, 12308, 81176, 1214, 11, 1537, 11, 836, 11, 1963, 340, 286, 471, 1963, 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,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 63329, 682, 5151, 304, 279, 1595, 23807, 63, 6041, 449, 279, 2728, 198, 286, 353, 1275, 9, 323, 4780, 279, 551, 1058, 19258, 1581, 63, 1306, 279, 1566, 551, 1058, 19258, 1915, 4077, 286, 304, 279, 1595, 23807, 63438, 286, 551, 913, 8167, 1963, 25, 1212, 551, 1058, 19258, 1581, 63, 369, 279, 1176, 551, 1058, 19258, 1915, 4077, 310, 304, 279, 1595, 23807, 19154, 286, 551, 20454, 1845, 24997, 25, 422, 10103, 2575, 14196, 682, 551, 1058, 19258, 9261, 63, 5151, 315, 279, 198, 310, 1595, 23807, 63, 25998, 872, 25819, 551, 3064, 78902, 9261, 2245, 63, 1665, 198, 310, 5151, 439, 1664, 320, 331, 2692, 1749, 1650, 3677, 14711, 6075, 512, 755, 1963, 12406, 1214, 11, 1963, 28, 1581, 1535, 3146, 2945, 997, 286, 4304, 8167, 288, 682, 5151, 304, 279, 1595, 23807, 63, 6041, 449, 279, 2728, 198, 286, 353, 1275, 9, 323, 4780, 279, 551, 1058, 19258, 1581, 63, 1306, 279, 1566, 551, 1058, 19258, 1915, 4077, 286, 304, 279, 1595, 23807, 63438, 286, 551, 913, 8167, 1963, 25, 1212, 551, 1058, 19258, 1581, 63, 369, 279, 1176, 551, 1058, 19258, 1915, 4077, 310, 304, 279, 1595, 23807, 19154, 286, 551, 20454, 1845, 24997, 25, 422, 10103, 2575, 14196, 682, 551, 1058, 19258, 9261, 63, 5151, 315, 279, 198, 310, 1595, 23807, 63, 25998, 872, 25819, 551, 3064, 78902, 9261, 2245, 63, 1665, 198, 310, 5151, 439, 1664, 320, 331, 2692, 1749, 1650, 4390, 286, 3270, 286, 369, 836, 11, 1537, 304, 659, 9812, 4019, 310, 674, 9876, 198, 310, 422, 374, 16226, 5508, 997, 394, 1963, 284, 1537, 5265, 12406, 7343, 11, 3146, 2945, 340, 310, 674, 22366, 198, 310, 4508, 374, 22140, 5508, 8, 323, 636, 67379, 12349, 997, 394, 1963, 284, 1537, 5265, 5121, 7343, 340, 394, 1537, 5265, 1807, 746, 310, 674, 8771, 198, 310, 4508, 374, 5121, 5508, 997, 394, 1963, 284, 1537, 5265, 5121, 7343, 340, 310, 775, 512, 394, 4933, 12308, 81176, 1214, 11, 1537, 11, 836, 11, 1963, 340, 286, 471, 1963, 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 ]
gwastro/pycbc
pycbc/workflow/datafind.py
setup_datafind_server_connection
def setup_datafind_server_connection(cp, tags=None): """ This function is resposible for setting up the connection with the datafind server. Parameters ----------- cp : pycbc.workflow.configuration.WorkflowConfigParser The memory representation of the ConfigParser Returns -------- connection The open connection to the datafind server. """ if tags is None: tags = [] if cp.has_option_tags("workflow-datafind", "datafind-ligo-datafind-server", tags): datafind_server = cp.get_opt_tags("workflow-datafind", "datafind-ligo-datafind-server", tags) else: datafind_server = None return datafind_connection(datafind_server)
python
def setup_datafind_server_connection(cp, tags=None): """ This function is resposible for setting up the connection with the datafind server. Parameters ----------- cp : pycbc.workflow.configuration.WorkflowConfigParser The memory representation of the ConfigParser Returns -------- connection The open connection to the datafind server. """ if tags is None: tags = [] if cp.has_option_tags("workflow-datafind", "datafind-ligo-datafind-server", tags): datafind_server = cp.get_opt_tags("workflow-datafind", "datafind-ligo-datafind-server", tags) else: datafind_server = None return datafind_connection(datafind_server)
[ "def", "setup_datafind_server_connection", "(", "cp", ",", "tags", "=", "None", ")", ":", "if", "tags", "is", "None", ":", "tags", "=", "[", "]", "if", "cp", ".", "has_option_tags", "(", "\"workflow-datafind\"", ",", "\"datafind-ligo-datafind-server\"", ",", "tags", ")", ":", "datafind_server", "=", "cp", ".", "get_opt_tags", "(", "\"workflow-datafind\"", ",", "\"datafind-ligo-datafind-server\"", ",", "tags", ")", "else", ":", "datafind_server", "=", "None", "return", "datafind_connection", "(", "datafind_server", ")" ]
This function is resposible for setting up the connection with the datafind server. Parameters ----------- cp : pycbc.workflow.configuration.WorkflowConfigParser The memory representation of the ConfigParser Returns -------- connection The open connection to the datafind server.
[ "This", "function", "is", "resposible", "for", "setting", "up", "the", "connection", "with", "the", "datafind", "server", "." ]
train
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/datafind.py#L809-L833
<|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 is resposible for setting up the connection with the datafind server. Parameters ----------- cp : pycbc.workflow.configuration.WorkflowConfigParser The memory representation of the ConfigParser Returns -------- connection The open connection to the datafind server. ### Response: def setup_datafind_server_connection(cp, tags=None): """ This function is resposible for setting up the connection with the datafind server. Parameters ----------- cp : pycbc.workflow.configuration.WorkflowConfigParser The memory representation of the ConfigParser Returns -------- connection The open connection to the datafind server. """ if tags is None: tags = [] if cp.has_option_tags("workflow-datafind", "datafind-ligo-datafind-server", tags): datafind_server = cp.get_opt_tags("workflow-datafind", "datafind-ligo-datafind-server", tags) else: datafind_server = None return datafind_connection(datafind_server) <|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, 374, 594, 981, 1260, 369, 6376, 709, 279, 3717, 449, 279, 828, 3990, 198, 262, 3622, 382, 262, 13831, 198, 262, 220, 26999, 262, 12773, 551, 281, 3418, 9081, 73874, 32553, 29848, 5072, 2714, 6707, 198, 286, 578, 5044, 13340, 315, 279, 5649, 6707, 198, 262, 5295, 198, 262, 90238, 262, 3717, 198, 286, 578, 1825, 3717, 311, 279, 828, 3990, 3622, 382, 14711, 6075, 512, 755, 6642, 1807, 3990, 12284, 16245, 45175, 11, 9681, 5980, 997, 262, 3270, 262, 1115, 734, 374, 594, 981, 1260, 369, 6376, 709, 279, 3717, 449, 279, 828, 3990, 198, 262, 3622, 382, 262, 13831, 198, 262, 220, 26999, 262, 12773, 551, 281, 3418, 9081, 73874, 32553, 29848, 5072, 2714, 6707, 198, 286, 578, 5044, 13340, 315, 279, 5649, 6707, 198, 262, 5295, 198, 262, 90238, 262, 3717, 198, 286, 578, 1825, 3717, 311, 279, 828, 3990, 3622, 627, 262, 3270, 262, 422, 9681, 374, 2290, 512, 286, 9681, 284, 14941, 262, 422, 12773, 7001, 9869, 16735, 446, 57349, 14271, 3990, 761, 3586, 330, 695, 3990, 2922, 7992, 14271, 3990, 27396, 498, 9681, 997, 286, 828, 3990, 12284, 284, 12773, 673, 15382, 16735, 446, 57349, 14271, 3990, 761, 2623, 330, 695, 3990, 2922, 7992, 14271, 3990, 27396, 498, 9681, 340, 262, 775, 512, 286, 828, 3990, 12284, 284, 2290, 271, 262, 471, 828, 3990, 16245, 2657, 3990, 12284, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 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, 374, 594, 981, 1260, 369, 6376, 709, 279, 3717, 449, 279, 828, 3990, 198, 262, 3622, 382, 262, 13831, 198, 262, 220, 26999, 262, 12773, 551, 281, 3418, 9081, 73874, 32553, 29848, 5072, 2714, 6707, 198, 286, 578, 5044, 13340, 315, 279, 5649, 6707, 198, 262, 5295, 198, 262, 90238, 262, 3717, 198, 286, 578, 1825, 3717, 311, 279, 828, 3990, 3622, 382, 14711, 6075, 512, 755, 6642, 1807, 3990, 12284, 16245, 45175, 11, 9681, 5980, 997, 262, 3270, 262, 1115, 734, 374, 594, 981, 1260, 369, 6376, 709, 279, 3717, 449, 279, 828, 3990, 198, 262, 3622, 382, 262, 13831, 198, 262, 220, 26999, 262, 12773, 551, 281, 3418, 9081, 73874, 32553, 29848, 5072, 2714, 6707, 198, 286, 578, 5044, 13340, 315, 279, 5649, 6707, 198, 262, 5295, 198, 262, 90238, 262, 3717, 198, 286, 578, 1825, 3717, 311, 279, 828, 3990, 3622, 627, 262, 3270, 262, 422, 9681, 374, 2290, 512, 286, 9681, 284, 14941, 262, 422, 12773, 7001, 9869, 16735, 446, 57349, 14271, 3990, 761, 3586, 330, 695, 3990, 2922, 7992, 14271, 3990, 27396, 498, 9681, 997, 286, 828, 3990, 12284, 284, 12773, 673, 15382, 16735, 446, 57349, 14271, 3990, 761, 2623, 330, 695, 3990, 2922, 7992, 14271, 3990, 27396, 498, 9681, 340, 262, 775, 512, 286, 828, 3990, 12284, 284, 2290, 271, 262, 471, 828, 3990, 16245, 2657, 3990, 12284, 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 ]
Bogdanp/dramatiq
dramatiq/rate_limits/rate_limiter.py
RateLimiter.acquire
def acquire(self, *, raise_on_failure=True): """Attempt to acquire a slot under this rate limiter. Parameters: raise_on_failure(bool): Whether or not failures should raise an exception. If this is false, the context manager will instead return a boolean value representing whether or not the rate limit slot was acquired. Returns: bool: Whether or not the slot could be acquired. """ acquired = False try: acquired = self._acquire() if raise_on_failure and not acquired: raise RateLimitExceeded("rate limit exceeded for key %(key)r" % vars(self)) yield acquired finally: if acquired: self._release()
python
def acquire(self, *, raise_on_failure=True): """Attempt to acquire a slot under this rate limiter. Parameters: raise_on_failure(bool): Whether or not failures should raise an exception. If this is false, the context manager will instead return a boolean value representing whether or not the rate limit slot was acquired. Returns: bool: Whether or not the slot could be acquired. """ acquired = False try: acquired = self._acquire() if raise_on_failure and not acquired: raise RateLimitExceeded("rate limit exceeded for key %(key)r" % vars(self)) yield acquired finally: if acquired: self._release()
[ "def", "acquire", "(", "self", ",", "*", ",", "raise_on_failure", "=", "True", ")", ":", "acquired", "=", "False", "try", ":", "acquired", "=", "self", ".", "_acquire", "(", ")", "if", "raise_on_failure", "and", "not", "acquired", ":", "raise", "RateLimitExceeded", "(", "\"rate limit exceeded for key %(key)r\"", "%", "vars", "(", "self", ")", ")", "yield", "acquired", "finally", ":", "if", "acquired", ":", "self", ".", "_release", "(", ")" ]
Attempt to acquire a slot under this rate limiter. Parameters: raise_on_failure(bool): Whether or not failures should raise an exception. If this is false, the context manager will instead return a boolean value representing whether or not the rate limit slot was acquired. Returns: bool: Whether or not the slot could be acquired.
[ "Attempt", "to", "acquire", "a", "slot", "under", "this", "rate", "limiter", "." ]
train
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/rate_limits/rate_limiter.py#L56-L78
<|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: Attempt to acquire a slot under this rate limiter. Parameters: raise_on_failure(bool): Whether or not failures should raise an exception. If this is false, the context manager will instead return a boolean value representing whether or not the rate limit slot was acquired. Returns: bool: Whether or not the slot could be acquired. ### Response: def acquire(self, *, raise_on_failure=True): """Attempt to acquire a slot under this rate limiter. Parameters: raise_on_failure(bool): Whether or not failures should raise an exception. If this is false, the context manager will instead return a boolean value representing whether or not the rate limit slot was acquired. Returns: bool: Whether or not the slot could be acquired. """ acquired = False try: acquired = self._acquire() if raise_on_failure and not acquired: raise RateLimitExceeded("rate limit exceeded for key %(key)r" % vars(self)) yield acquired finally: if acquired: self._release() <|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, 48152, 311, 21953, 264, 9633, 1234, 420, 4478, 4671, 2058, 382, 286, 13831, 512, 692, 4933, 4570, 44718, 9963, 1680, 13440, 477, 539, 28950, 1288, 4933, 459, 198, 310, 4788, 13, 220, 1442, 420, 374, 905, 11, 279, 2317, 6783, 690, 4619, 198, 310, 471, 264, 2777, 907, 14393, 3508, 477, 539, 279, 4478, 198, 310, 4017, 9633, 574, 19426, 382, 286, 5295, 512, 692, 1845, 25, 13440, 477, 539, 279, 9633, 1436, 387, 19426, 382, 14711, 6075, 512, 755, 21953, 1214, 11, 12039, 4933, 4570, 44718, 3702, 997, 286, 4304, 48152, 311, 21953, 264, 9633, 1234, 420, 4478, 4671, 2058, 382, 286, 13831, 512, 692, 4933, 4570, 44718, 9963, 1680, 13440, 477, 539, 28950, 1288, 4933, 459, 198, 310, 4788, 13, 220, 1442, 420, 374, 905, 11, 279, 2317, 6783, 690, 4619, 198, 310, 471, 264, 2777, 907, 14393, 3508, 477, 539, 279, 4478, 198, 310, 4017, 9633, 574, 19426, 382, 286, 5295, 512, 692, 1845, 25, 13440, 477, 539, 279, 9633, 1436, 387, 19426, 627, 286, 3270, 286, 19426, 284, 3641, 271, 286, 1456, 512, 310, 19426, 284, 659, 1462, 582, 999, 746, 310, 422, 4933, 4570, 44718, 323, 539, 19426, 512, 394, 4933, 20359, 16934, 849, 95306, 446, 7853, 4017, 34908, 369, 1401, 21921, 798, 94442, 1, 1034, 20537, 1214, 4489, 310, 7692, 19426, 198, 286, 5616, 512, 310, 422, 19426, 512, 394, 659, 1462, 23859, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 48152, 311, 21953, 264, 9633, 1234, 420, 4478, 4671, 2058, 382, 286, 13831, 512, 692, 4933, 4570, 44718, 9963, 1680, 13440, 477, 539, 28950, 1288, 4933, 459, 198, 310, 4788, 13, 220, 1442, 420, 374, 905, 11, 279, 2317, 6783, 690, 4619, 198, 310, 471, 264, 2777, 907, 14393, 3508, 477, 539, 279, 4478, 198, 310, 4017, 9633, 574, 19426, 382, 286, 5295, 512, 692, 1845, 25, 13440, 477, 539, 279, 9633, 1436, 387, 19426, 382, 14711, 6075, 512, 755, 21953, 1214, 11, 12039, 4933, 4570, 44718, 3702, 997, 286, 4304, 48152, 311, 21953, 264, 9633, 1234, 420, 4478, 4671, 2058, 382, 286, 13831, 512, 692, 4933, 4570, 44718, 9963, 1680, 13440, 477, 539, 28950, 1288, 4933, 459, 198, 310, 4788, 13, 220, 1442, 420, 374, 905, 11, 279, 2317, 6783, 690, 4619, 198, 310, 471, 264, 2777, 907, 14393, 3508, 477, 539, 279, 4478, 198, 310, 4017, 9633, 574, 19426, 382, 286, 5295, 512, 692, 1845, 25, 13440, 477, 539, 279, 9633, 1436, 387, 19426, 627, 286, 3270, 286, 19426, 284, 3641, 271, 286, 1456, 512, 310, 19426, 284, 659, 1462, 582, 999, 746, 310, 422, 4933, 4570, 44718, 323, 539, 19426, 512, 394, 4933, 20359, 16934, 849, 95306, 446, 7853, 4017, 34908, 369, 1401, 21921, 798, 94442, 1, 1034, 20537, 1214, 4489, 310, 7692, 19426, 198, 286, 5616, 512, 310, 422, 19426, 512, 394, 659, 1462, 23859, 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 ]
notpushkin/rock
rock_cli/cli/register.py
cmd_register
def cmd_register(phone): """ Войти в приложение с помощью SMS. """ if phone is None: phone = click.prompt("Номер телефона") r = rocket.devices.register.post(data={"phone": phone}) r = handle_error(r) id = r.json()["sms_verification"]["id"] code = click.prompt("Введите код из SMS", type=int) r = rocket.sms_verifications[id]["verify"].patch(data={"code": code}) r = handle_error(r) j = r.json() click.secho("Добро пожаловать, {}!".format(j["user"]["first_name"]), fg="green") config.email = j["user"]["email"] config.write()
python
def cmd_register(phone): """ Войти в приложение с помощью SMS. """ if phone is None: phone = click.prompt("Номер телефона") r = rocket.devices.register.post(data={"phone": phone}) r = handle_error(r) id = r.json()["sms_verification"]["id"] code = click.prompt("Введите код из SMS", type=int) r = rocket.sms_verifications[id]["verify"].patch(data={"code": code}) r = handle_error(r) j = r.json() click.secho("Добро пожаловать, {}!".format(j["user"]["first_name"]), fg="green") config.email = j["user"]["email"] config.write()
[ "def", "cmd_register", "(", "phone", ")", ":", "if", "phone", "is", "None", ":", "phone", "=", "click", ".", "prompt", "(", "\"Номер телефона\")", "", "r", "=", "rocket", ".", "devices", ".", "register", ".", "post", "(", "data", "=", "{", "\"phone\"", ":", "phone", "}", ")", "r", "=", "handle_error", "(", "r", ")", "id", "=", "r", ".", "json", "(", ")", "[", "\"sms_verification\"", "]", "[", "\"id\"", "]", "code", "=", "click", ".", "prompt", "(", "\"Введите код из SMS\", type=int)", "", "", "", "", "", "r", "=", "rocket", ".", "sms_verifications", "[", "id", "]", "[", "\"verify\"", "]", ".", "patch", "(", "data", "=", "{", "\"code\"", ":", "code", "}", ")", "r", "=", "handle_error", "(", "r", ")", "j", "=", "r", ".", "json", "(", ")", "click", ".", "secho", "(", "\"Добро пожаловать, {}!\".format(j[\"user", "\"", "][\"fir", "s", "t", "_", "name\"]", ")", ",", " fg=\"green\")", "", "", "", "", "", "", "", "config", ".", "email", "=", "j", "[", "\"user\"", "]", "[", "\"email\"", "]", "config", ".", "write", "(", ")" ]
Войти в приложение с помощью SMS.
[ "Войти", "в", "приложение", "с", "помощью", "SMS", "." ]
train
https://github.com/notpushkin/rock/blob/c1451a7604b462c19e4929f0eb171cbcf23e50ab/rock_cli/cli/register.py#L7-L27
<|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: Войти в приложение с помощью SMS. ### Response: def cmd_register(phone): """ Войти в приложение с помощью SMS. """ if phone is None: phone = click.prompt("Номер телефона") r = rocket.devices.register.post(data={"phone": phone}) r = handle_error(r) id = r.json()["sms_verification"]["id"] code = click.prompt("Введите код из SMS", type=int) r = rocket.sms_verifications[id]["verify"].patch(data={"code": code}) r = handle_error(r) j = r.json() click.secho("Добро пожаловать, {}!".format(j["user"]["first_name"]), fg="green") config.email = j["user"]["email"] config.write() <|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, 16604, 16742, 23311, 5927, 37405, 82941, 17618, 5524, 109344, 31009, 382, 14711, 6075, 512, 755, 5556, 14327, 50255, 997, 262, 3270, 262, 23784, 16742, 23311, 5927, 37405, 82941, 17618, 5524, 109344, 31009, 627, 262, 3270, 262, 422, 4641, 374, 2290, 512, 286, 4641, 284, 4299, 66499, 446, 20807, 50619, 114613, 74828, 5240, 262, 436, 284, 25294, 80014, 10131, 6679, 2657, 16160, 4949, 794, 4641, 3602, 262, 436, 284, 3790, 4188, 2666, 696, 262, 887, 284, 436, 4421, 65422, 42492, 85345, 11264, 307, 7171, 262, 2082, 284, 4299, 66499, 446, 55226, 69126, 23934, 31009, 498, 955, 16972, 696, 262, 436, 284, 25294, 95376, 27133, 7174, 14839, 10069, 12728, 5638, 3482, 2657, 16160, 1889, 794, 2082, 3602, 262, 436, 284, 3790, 4188, 2666, 340, 262, 503, 284, 436, 4421, 2892, 262, 4299, 4624, 971, 446, 25079, 14082, 100442, 107813, 16331, 103291, 11, 4792, 94093, 2293, 3406, 1204, 882, 11264, 3983, 1292, 64724, 30899, 429, 13553, 5240, 262, 2242, 10048, 284, 503, 1204, 882, 11264, 2386, 7171, 262, 2242, 3921, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 16604, 16742, 23311, 5927, 37405, 82941, 17618, 5524, 109344, 31009, 382, 14711, 6075, 512, 755, 5556, 14327, 50255, 997, 262, 3270, 262, 23784, 16742, 23311, 5927, 37405, 82941, 17618, 5524, 109344, 31009, 627, 262, 3270, 262, 422, 4641, 374, 2290, 512, 286, 4641, 284, 4299, 66499, 446, 20807, 50619, 114613, 74828, 5240, 262, 436, 284, 25294, 80014, 10131, 6679, 2657, 16160, 4949, 794, 4641, 3602, 262, 436, 284, 3790, 4188, 2666, 696, 262, 887, 284, 436, 4421, 65422, 42492, 85345, 11264, 307, 7171, 262, 2082, 284, 4299, 66499, 446, 55226, 69126, 23934, 31009, 498, 955, 16972, 696, 262, 436, 284, 25294, 95376, 27133, 7174, 14839, 10069, 12728, 5638, 3482, 2657, 16160, 1889, 794, 2082, 3602, 262, 436, 284, 3790, 4188, 2666, 340, 262, 503, 284, 436, 4421, 2892, 262, 4299, 4624, 971, 446, 25079, 14082, 100442, 107813, 16331, 103291, 11, 4792, 94093, 2293, 3406, 1204, 882, 11264, 3983, 1292, 64724, 30899, 429, 13553, 5240, 262, 2242, 10048, 284, 503, 1204, 882, 11264, 2386, 7171, 262, 2242, 3921, 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 ]
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.data64_send
def data64_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data64_encode(type, len, data), force_mavlink1=force_mavlink1)
python
def data64_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data64_encode(type, len, data), force_mavlink1=force_mavlink1)
[ "def", "data64_send", "(", "self", ",", "type", ",", "len", ",", "data", ",", "force_mavlink1", "=", "False", ")", ":", "return", "self", ".", "send", "(", "self", ".", "data64_encode", "(", "type", ",", "len", ",", "data", ")", ",", "force_mavlink1", "=", "force_mavlink1", ")" ]
Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t)
[ "Data", "packet", "size", "64" ]
train
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10273-L10282
<|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: Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ### Response: def data64_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ''' return self.send(self.data64_encode(type, len, data), force_mavlink1=force_mavlink1) <|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, 1061, 10361, 11, 1404, 220, 1227, 271, 394, 955, 2611, 551, 828, 955, 320, 2557, 23, 530, 340, 394, 2479, 5291, 551, 828, 3160, 320, 2557, 23, 530, 340, 394, 828, 2611, 551, 7257, 828, 320, 2557, 23, 530, 696, 14711, 6075, 512, 755, 828, 1227, 13877, 1214, 11, 955, 11, 2479, 11, 828, 11, 5457, 722, 402, 2125, 16, 5725, 997, 394, 11414, 394, 2956, 10361, 11, 1404, 220, 1227, 271, 394, 955, 2611, 551, 828, 955, 320, 2557, 23, 530, 340, 394, 2479, 5291, 551, 828, 3160, 320, 2557, 23, 530, 340, 394, 828, 2611, 551, 7257, 828, 320, 2557, 23, 530, 696, 394, 11414, 394, 471, 659, 5331, 1214, 2245, 1227, 11473, 5930, 11, 2479, 11, 828, 705, 5457, 722, 402, 2125, 16, 28, 9009, 722, 402, 2125, 16, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1061, 10361, 11, 1404, 220, 1227, 271, 394, 955, 2611, 551, 828, 955, 320, 2557, 23, 530, 340, 394, 2479, 5291, 551, 828, 3160, 320, 2557, 23, 530, 340, 394, 828, 2611, 551, 7257, 828, 320, 2557, 23, 530, 696, 14711, 6075, 512, 755, 828, 1227, 13877, 1214, 11, 955, 11, 2479, 11, 828, 11, 5457, 722, 402, 2125, 16, 5725, 997, 394, 11414, 394, 2956, 10361, 11, 1404, 220, 1227, 271, 394, 955, 2611, 551, 828, 955, 320, 2557, 23, 530, 340, 394, 2479, 5291, 551, 828, 3160, 320, 2557, 23, 530, 340, 394, 828, 2611, 551, 7257, 828, 320, 2557, 23, 530, 696, 394, 11414, 394, 471, 659, 5331, 1214, 2245, 1227, 11473, 5930, 11, 2479, 11, 828, 705, 5457, 722, 402, 2125, 16, 28, 9009, 722, 402, 2125, 16, 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 ]
pypa/pipenv
pipenv/patched/notpip/_internal/req/req_install.py
InstallRequirement.remove_temporary_source
def remove_temporary_source(self): # type: () -> None """Remove the source files from this requirement, if they are marked for deletion""" if self.source_dir and os.path.exists( os.path.join(self.source_dir, PIP_DELETE_MARKER_FILENAME)): logger.debug('Removing source in %s', self.source_dir) rmtree(self.source_dir) self.source_dir = None self._temp_build_dir.cleanup() self.build_env.cleanup()
python
def remove_temporary_source(self): # type: () -> None """Remove the source files from this requirement, if they are marked for deletion""" if self.source_dir and os.path.exists( os.path.join(self.source_dir, PIP_DELETE_MARKER_FILENAME)): logger.debug('Removing source in %s', self.source_dir) rmtree(self.source_dir) self.source_dir = None self._temp_build_dir.cleanup() self.build_env.cleanup()
[ "def", "remove_temporary_source", "(", "self", ")", ":", "# type: () -> None", "if", "self", ".", "source_dir", "and", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join", "(", "self", ".", "source_dir", ",", "PIP_DELETE_MARKER_FILENAME", ")", ")", ":", "logger", ".", "debug", "(", "'Removing source in %s'", ",", "self", ".", "source_dir", ")", "rmtree", "(", "self", ".", "source_dir", ")", "self", ".", "source_dir", "=", "None", "self", ".", "_temp_build_dir", ".", "cleanup", "(", ")", "self", ".", "build_env", ".", "cleanup", "(", ")" ]
Remove the source files from this requirement, if they are marked for deletion
[ "Remove", "the", "source", "files", "from", "this", "requirement", "if", "they", "are", "marked", "for", "deletion" ]
train
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_internal/req/req_install.py#L364-L374
<|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: Remove the source files from this requirement, if they are marked for deletion ### Response: def remove_temporary_source(self): # type: () -> None """Remove the source files from this requirement, if they are marked for deletion""" if self.source_dir and os.path.exists( os.path.join(self.source_dir, PIP_DELETE_MARKER_FILENAME)): logger.debug('Removing source in %s', self.source_dir) rmtree(self.source_dir) self.source_dir = None self._temp_build_dir.cleanup() self.build_env.cleanup() <|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, 13319, 279, 2592, 3626, 505, 420, 16686, 11, 422, 814, 527, 13160, 198, 286, 369, 37166, 271, 14711, 6075, 512, 755, 4148, 12033, 7746, 10561, 1214, 997, 286, 674, 955, 25, 1754, 1492, 2290, 198, 286, 4304, 13319, 279, 2592, 3626, 505, 420, 16686, 11, 422, 814, 527, 13160, 198, 286, 369, 37166, 7275, 286, 422, 659, 15040, 4432, 323, 2709, 3960, 12347, 1021, 394, 2709, 3960, 5563, 1214, 15040, 4432, 11, 393, 3378, 30023, 83789, 46105, 10162, 310, 6050, 8042, 493, 64719, 2592, 304, 1034, 82, 518, 659, 15040, 4432, 340, 310, 436, 71522, 1214, 15040, 4432, 340, 286, 659, 15040, 4432, 284, 2290, 198, 286, 659, 1462, 3975, 21465, 4432, 88789, 746, 286, 659, 13542, 16258, 88789, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 13319, 279, 2592, 3626, 505, 420, 16686, 11, 422, 814, 527, 13160, 198, 286, 369, 37166, 271, 14711, 6075, 512, 755, 4148, 12033, 7746, 10561, 1214, 997, 286, 674, 955, 25, 1754, 1492, 2290, 198, 286, 4304, 13319, 279, 2592, 3626, 505, 420, 16686, 11, 422, 814, 527, 13160, 198, 286, 369, 37166, 7275, 286, 422, 659, 15040, 4432, 323, 2709, 3960, 12347, 1021, 394, 2709, 3960, 5563, 1214, 15040, 4432, 11, 393, 3378, 30023, 83789, 46105, 10162, 310, 6050, 8042, 493, 64719, 2592, 304, 1034, 82, 518, 659, 15040, 4432, 340, 310, 436, 71522, 1214, 15040, 4432, 340, 286, 659, 15040, 4432, 284, 2290, 198, 286, 659, 1462, 3975, 21465, 4432, 88789, 746, 286, 659, 13542, 16258, 88789, 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 ]
idlesign/uwsgiconf
uwsgiconf/options/python.py
Python.set_app_args
def set_app_args(self, *args): """Sets ``sys.argv`` for python apps. Examples: * pyargv="one two three" will set ``sys.argv`` to ``('one', 'two', 'three')``. :param args: """ if args: self._set('pyargv', ' '.join(args)) return self._section
python
def set_app_args(self, *args): """Sets ``sys.argv`` for python apps. Examples: * pyargv="one two three" will set ``sys.argv`` to ``('one', 'two', 'three')``. :param args: """ if args: self._set('pyargv', ' '.join(args)) return self._section
[ "def", "set_app_args", "(", "self", ",", "*", "args", ")", ":", "if", "args", ":", "self", ".", "_set", "(", "'pyargv'", ",", "' '", ".", "join", "(", "args", ")", ")", "return", "self", ".", "_section" ]
Sets ``sys.argv`` for python apps. Examples: * pyargv="one two three" will set ``sys.argv`` to ``('one', 'two', 'three')``. :param args:
[ "Sets", "sys", ".", "argv", "for", "python", "apps", "." ]
train
https://github.com/idlesign/uwsgiconf/blob/475407acb44199edbf7e0a66261bfeb51de1afae/uwsgiconf/options/python.py#L98-L109
<|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: Sets ``sys.argv`` for python apps. Examples: * pyargv="one two three" will set ``sys.argv`` to ``('one', 'two', 'three')``. :param args: ### Response: def set_app_args(self, *args): """Sets ``sys.argv`` for python apps. Examples: * pyargv="one two three" will set ``sys.argv`` to ``('one', 'two', 'three')``. :param args: """ if args: self._set('pyargv', ' '.join(args)) return self._section <|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, 31275, 10103, 7947, 14629, 14196, 369, 10344, 10721, 382, 286, 26379, 512, 310, 353, 4611, 6645, 429, 606, 1403, 2380, 1, 690, 743, 10103, 7947, 14629, 14196, 311, 10103, 493, 606, 518, 364, 20375, 518, 364, 28956, 873, 14196, 382, 286, 551, 913, 2897, 1473, 14711, 6075, 512, 755, 743, 8354, 8550, 1214, 11, 353, 2164, 997, 286, 4304, 31275, 10103, 7947, 14629, 14196, 369, 10344, 10721, 382, 286, 26379, 512, 310, 353, 4611, 6645, 429, 606, 1403, 2380, 1, 690, 743, 10103, 7947, 14629, 14196, 311, 10103, 493, 606, 518, 364, 20375, 518, 364, 28956, 873, 14196, 382, 286, 551, 913, 2897, 512, 286, 3270, 286, 422, 2897, 512, 310, 659, 1462, 751, 493, 3368, 6645, 518, 364, 6389, 6115, 7506, 4489, 286, 471, 659, 1462, 2879, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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, 10103, 7947, 14629, 14196, 369, 10344, 10721, 382, 286, 26379, 512, 310, 353, 4611, 6645, 429, 606, 1403, 2380, 1, 690, 743, 10103, 7947, 14629, 14196, 311, 10103, 493, 606, 518, 364, 20375, 518, 364, 28956, 873, 14196, 382, 286, 551, 913, 2897, 1473, 14711, 6075, 512, 755, 743, 8354, 8550, 1214, 11, 353, 2164, 997, 286, 4304, 31275, 10103, 7947, 14629, 14196, 369, 10344, 10721, 382, 286, 26379, 512, 310, 353, 4611, 6645, 429, 606, 1403, 2380, 1, 690, 743, 10103, 7947, 14629, 14196, 311, 10103, 493, 606, 518, 364, 20375, 518, 364, 28956, 873, 14196, 382, 286, 551, 913, 2897, 512, 286, 3270, 286, 422, 2897, 512, 310, 659, 1462, 751, 493, 3368, 6645, 518, 364, 6389, 6115, 7506, 4489, 286, 471, 659, 1462, 2879, 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 ]
quokkaproject/flask-htmlbuilder
flask_htmlbuilder/htmlbuilder.py
render
def render(element, level=0): """Renders the HTML builder `element` and it's children to a string. Example:: >>> print( ... render( ... html.form(action='/search', name='f')( ... html.input(name='q'), ... html.input(name='search_button', type='submit') ... ) ... ) ... ) <form action="/search" name="f"> <input name="q" /> <input type="submit" name="search_button" /> </form> The :func:`render` function accepts the following arguments: :param element: element created through the `html` builder instance, a list of such elements, or just a string. :param level: indentation level of the rendered element with a step of two spaces. If `level` is `None`, the `element` will be rendered without indentation and new line transferring, passing the same rule to the child elements. """ if hasattr(element, 'render'): return element.render(level) elif isinstance(element, basestring): return _render_string(element, level) elif hasattr(element, '__iter__'): return _render_iteratable(element, level) elif element is None: return '' raise TypeError('Cannot render %r' % element)
python
def render(element, level=0): """Renders the HTML builder `element` and it's children to a string. Example:: >>> print( ... render( ... html.form(action='/search', name='f')( ... html.input(name='q'), ... html.input(name='search_button', type='submit') ... ) ... ) ... ) <form action="/search" name="f"> <input name="q" /> <input type="submit" name="search_button" /> </form> The :func:`render` function accepts the following arguments: :param element: element created through the `html` builder instance, a list of such elements, or just a string. :param level: indentation level of the rendered element with a step of two spaces. If `level` is `None`, the `element` will be rendered without indentation and new line transferring, passing the same rule to the child elements. """ if hasattr(element, 'render'): return element.render(level) elif isinstance(element, basestring): return _render_string(element, level) elif hasattr(element, '__iter__'): return _render_iteratable(element, level) elif element is None: return '' raise TypeError('Cannot render %r' % element)
[ "def", "render", "(", "element", ",", "level", "=", "0", ")", ":", "if", "hasattr", "(", "element", ",", "'render'", ")", ":", "return", "element", ".", "render", "(", "level", ")", "elif", "isinstance", "(", "element", ",", "basestring", ")", ":", "return", "_render_string", "(", "element", ",", "level", ")", "elif", "hasattr", "(", "element", ",", "'__iter__'", ")", ":", "return", "_render_iteratable", "(", "element", ",", "level", ")", "elif", "element", "is", "None", ":", "return", "''", "raise", "TypeError", "(", "'Cannot render %r'", "%", "element", ")" ]
Renders the HTML builder `element` and it's children to a string. Example:: >>> print( ... render( ... html.form(action='/search', name='f')( ... html.input(name='q'), ... html.input(name='search_button', type='submit') ... ) ... ) ... ) <form action="/search" name="f"> <input name="q" /> <input type="submit" name="search_button" /> </form> The :func:`render` function accepts the following arguments: :param element: element created through the `html` builder instance, a list of such elements, or just a string. :param level: indentation level of the rendered element with a step of two spaces. If `level` is `None`, the `element` will be rendered without indentation and new line transferring, passing the same rule to the child elements.
[ "Renders", "the", "HTML", "builder", "element", "and", "it", "s", "children", "to", "a", "string", ".", "Example", "::" ]
train
https://github.com/quokkaproject/flask-htmlbuilder/blob/ee8b1b5d495ba9335428bf5bc8e3bce6799cf9a2/flask_htmlbuilder/htmlbuilder.py#L114-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: Renders the HTML builder `element` and it's children to a string. Example:: >>> print( ... render( ... html.form(action='/search', name='f')( ... html.input(name='q'), ... html.input(name='search_button', type='submit') ... ) ... ) ... ) <form action="/search" name="f"> <input name="q" /> <input type="submit" name="search_button" /> </form> The :func:`render` function accepts the following arguments: :param element: element created through the `html` builder instance, a list of such elements, or just a string. :param level: indentation level of the rendered element with a step of two spaces. If `level` is `None`, the `element` will be rendered without indentation and new line transferring, passing the same rule to the child elements. ### Response: def render(element, level=0): """Renders the HTML builder `element` and it's children to a string. Example:: >>> print( ... render( ... html.form(action='/search', name='f')( ... html.input(name='q'), ... html.input(name='search_button', type='submit') ... ) ... ) ... ) <form action="/search" name="f"> <input name="q" /> <input type="submit" name="search_button" /> </form> The :func:`render` function accepts the following arguments: :param element: element created through the `html` builder instance, a list of such elements, or just a string. :param level: indentation level of the rendered element with a step of two spaces. If `level` is `None`, the `element` will be rendered without indentation and new line transferring, passing the same rule to the child elements. """ if hasattr(element, 'render'): return element.render(level) elif isinstance(element, basestring): return _render_string(element, level) elif hasattr(element, '__iter__'): return _render_iteratable(element, level) elif element is None: return '' raise TypeError('Cannot render %r' % element) <|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, 49, 14846, 279, 9492, 7514, 1595, 6229, 63, 323, 433, 596, 2911, 311, 264, 925, 627, 262, 13688, 66152, 286, 12382, 1194, 1021, 286, 2564, 257, 3219, 1021, 286, 2564, 260, 5385, 8726, 15665, 22007, 1874, 518, 836, 1151, 69, 873, 1021, 286, 2564, 1835, 5385, 10252, 3232, 1151, 80, 3379, 286, 2564, 1835, 5385, 10252, 3232, 1151, 1874, 8655, 518, 955, 1151, 6081, 1329, 286, 2564, 260, 1763, 286, 2564, 257, 1763, 286, 2564, 1763, 286, 366, 630, 1957, 6039, 1874, 1, 836, 429, 69, 891, 692, 366, 1379, 836, 429, 80, 1, 2662, 692, 366, 1379, 955, 429, 6081, 1, 836, 429, 1874, 8655, 1, 2662, 286, 694, 630, 1363, 262, 578, 551, 2900, 19258, 7472, 63, 734, 27441, 279, 2768, 6105, 1473, 262, 551, 913, 2449, 25, 2449, 3549, 1555, 279, 1595, 1580, 63, 7514, 2937, 11, 264, 1160, 198, 504, 315, 1778, 5540, 11, 477, 1120, 264, 925, 627, 262, 551, 913, 2237, 25, 70692, 2237, 315, 279, 23188, 2449, 449, 264, 3094, 315, 1403, 198, 1733, 12908, 13, 220, 1442, 1595, 3374, 63, 374, 1595, 4155, 7964, 279, 1595, 6229, 63, 690, 387, 23188, 198, 1733, 2085, 70692, 323, 502, 1584, 51051, 11, 12579, 279, 198, 1733, 1890, 6037, 311, 279, 1716, 5540, 382, 14711, 6075, 512, 755, 3219, 11747, 11, 2237, 28, 15, 997, 262, 4304, 49, 14846, 279, 9492, 7514, 1595, 6229, 63, 323, 433, 596, 2911, 311, 264, 925, 627, 262, 13688, 66152, 286, 12382, 1194, 1021, 286, 2564, 257, 3219, 1021, 286, 2564, 260, 5385, 8726, 15665, 22007, 1874, 518, 836, 1151, 69, 873, 1021, 286, 2564, 1835, 5385, 10252, 3232, 1151, 80, 3379, 286, 2564, 1835, 5385, 10252, 3232, 1151, 1874, 8655, 518, 955, 1151, 6081, 1329, 286, 2564, 260, 1763, 286, 2564, 257, 1763, 286, 2564, 1763, 286, 366, 630, 1957, 6039, 1874, 1, 836, 429, 69, 891, 692, 366, 1379, 836, 429, 80, 1, 2662, 692, 366, 1379, 955, 429, 6081, 1, 836, 429, 1874, 8655, 1, 2662, 286, 694, 630, 1363, 262, 578, 551, 2900, 19258, 7472, 63, 734, 27441, 279, 2768, 6105, 1473, 262, 551, 913, 2449, 25, 2449, 3549, 1555, 279, 1595, 1580, 63, 7514, 2937, 11, 264, 1160, 198, 504, 315, 1778, 5540, 11, 477, 1120, 264, 925, 627, 262, 551, 913, 2237, 25, 70692, 2237, 315, 279, 23188, 2449, 449, 264, 3094, 315, 1403, 198, 1733, 12908, 13, 220, 1442, 1595, 3374, 63, 374, 1595, 4155, 7964, 279, 1595, 6229, 63, 690, 387, 23188, 198, 1733, 2085, 70692, 323, 502, 1584, 51051, 11, 12579, 279, 198, 1733, 1890, 6037, 311, 279, 1716, 5540, 627, 262, 12713, 262, 422, 32156, 11747, 11, 364, 7472, 11290, 286, 471, 2449, 8914, 24593, 340, 262, 4508, 11656, 11747, 11, 3122, 66140, 997, 286, 471, 721, 7472, 3991, 11747, 11, 2237, 340, 262, 4508, 32156, 11747, 11, 12385, 2058, 565, 11290 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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, 49, 14846, 279, 9492, 7514, 1595, 6229, 63, 323, 433, 596, 2911, 311, 264, 925, 627, 262, 13688, 66152, 286, 12382, 1194, 1021, 286, 2564, 257, 3219, 1021, 286, 2564, 260, 5385, 8726, 15665, 22007, 1874, 518, 836, 1151, 69, 873, 1021, 286, 2564, 1835, 5385, 10252, 3232, 1151, 80, 3379, 286, 2564, 1835, 5385, 10252, 3232, 1151, 1874, 8655, 518, 955, 1151, 6081, 1329, 286, 2564, 260, 1763, 286, 2564, 257, 1763, 286, 2564, 1763, 286, 366, 630, 1957, 6039, 1874, 1, 836, 429, 69, 891, 692, 366, 1379, 836, 429, 80, 1, 2662, 692, 366, 1379, 955, 429, 6081, 1, 836, 429, 1874, 8655, 1, 2662, 286, 694, 630, 1363, 262, 578, 551, 2900, 19258, 7472, 63, 734, 27441, 279, 2768, 6105, 1473, 262, 551, 913, 2449, 25, 2449, 3549, 1555, 279, 1595, 1580, 63, 7514, 2937, 11, 264, 1160, 198, 504, 315, 1778, 5540, 11, 477, 1120, 264, 925, 627, 262, 551, 913, 2237, 25, 70692, 2237, 315, 279, 23188, 2449, 449, 264, 3094, 315, 1403, 198, 1733, 12908, 13, 220, 1442, 1595, 3374, 63, 374, 1595, 4155, 7964, 279, 1595, 6229, 63, 690, 387, 23188, 198, 1733, 2085, 70692, 323, 502, 1584, 51051, 11, 12579, 279, 198, 1733, 1890, 6037, 311, 279, 1716, 5540, 382, 14711, 6075, 512, 755, 3219, 11747, 11, 2237, 28, 15, 997, 262, 4304, 49, 14846, 279, 9492, 7514, 1595, 6229, 63, 323, 433, 596, 2911, 311, 264, 925, 627, 262, 13688, 66152, 286, 12382, 1194, 1021, 286, 2564, 257, 3219, 1021, 286, 2564, 260, 5385, 8726, 15665, 22007, 1874, 518, 836, 1151, 69, 873, 1021, 286, 2564, 1835, 5385, 10252, 3232, 1151, 80, 3379, 286, 2564, 1835, 5385, 10252, 3232, 1151, 1874, 8655, 518, 955, 1151, 6081, 1329, 286, 2564, 260, 1763, 286, 2564, 257, 1763, 286, 2564, 1763, 286, 366, 630, 1957, 6039, 1874, 1, 836, 429, 69, 891, 692, 366, 1379, 836, 429, 80, 1, 2662, 692, 366, 1379, 955, 429, 6081, 1, 836, 429, 1874, 8655, 1, 2662, 286, 694, 630, 1363, 262, 578, 551, 2900, 19258, 7472, 63, 734, 27441, 279, 2768, 6105, 1473, 262, 551, 913, 2449, 25, 2449, 3549, 1555, 279, 1595, 1580, 63, 7514, 2937, 11, 264, 1160, 198, 504, 315, 1778, 5540, 11, 477, 1120, 264, 925, 627, 262, 551, 913, 2237, 25, 70692, 2237, 315, 279, 23188, 2449, 449, 264, 3094, 315, 1403, 198, 1733, 12908, 13, 220, 1442, 1595, 3374, 63, 374, 1595, 4155, 7964, 279, 1595, 6229, 63, 690, 387, 23188, 198, 1733, 2085, 70692, 323, 502, 1584, 51051, 11, 12579, 279, 198, 1733, 1890, 6037, 311, 279, 1716, 5540, 627, 262, 12713, 262, 422, 32156, 11747, 11, 364, 7472, 11290, 286, 471, 2449, 8914, 24593, 340, 262, 4508, 11656, 11747, 11, 3122, 66140, 997, 286, 471, 721, 7472, 3991, 11747, 11, 2237, 340, 262, 4508, 32156, 11747, 11, 12385, 2058, 565, 11290 ]
dranjan/python-plyfile
plyfile.py
PlyProperty._read_bin
def _read_bin(self, stream, byte_order): ''' Read data from a binary stream. Raise StopIteration if the property could not be read. ''' try: return _read_array(stream, self.dtype(byte_order), 1)[0] except IndexError: raise StopIteration
python
def _read_bin(self, stream, byte_order): ''' Read data from a binary stream. Raise StopIteration if the property could not be read. ''' try: return _read_array(stream, self.dtype(byte_order), 1)[0] except IndexError: raise StopIteration
[ "def", "_read_bin", "(", "self", ",", "stream", ",", "byte_order", ")", ":", "try", ":", "return", "_read_array", "(", "stream", ",", "self", ".", "dtype", "(", "byte_order", ")", ",", "1", ")", "[", "0", "]", "except", "IndexError", ":", "raise", "StopIteration" ]
Read data from a binary stream. Raise StopIteration if the property could not be read.
[ "Read", "data", "from", "a", "binary", "stream", ".", "Raise", "StopIteration", "if", "the", "property", "could", "not", "be", "read", "." ]
train
https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L841-L850
<|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: Read data from a binary stream. Raise StopIteration if the property could not be read. ### Response: def _read_bin(self, stream, byte_order): ''' Read data from a binary stream. Raise StopIteration if the property could not be read. ''' try: return _read_array(stream, self.dtype(byte_order), 1)[0] except IndexError: raise StopIteration <|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, 4518, 828, 505, 264, 8026, 4365, 13, 220, 43646, 14549, 54201, 422, 279, 198, 286, 3424, 1436, 539, 387, 1373, 382, 14711, 6075, 512, 755, 721, 888, 22569, 1214, 11, 4365, 11, 5027, 8028, 997, 286, 11414, 286, 4557, 828, 505, 264, 8026, 4365, 13, 220, 43646, 14549, 54201, 422, 279, 198, 286, 3424, 1436, 539, 387, 1373, 382, 286, 11414, 286, 1456, 512, 310, 471, 721, 888, 3943, 21217, 11, 659, 46855, 20318, 8028, 705, 220, 16, 6758, 15, 933, 286, 3734, 61303, 512, 310, 4933, 14549, 54201, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 4518, 828, 505, 264, 8026, 4365, 13, 220, 43646, 14549, 54201, 422, 279, 198, 286, 3424, 1436, 539, 387, 1373, 382, 14711, 6075, 512, 755, 721, 888, 22569, 1214, 11, 4365, 11, 5027, 8028, 997, 286, 11414, 286, 4557, 828, 505, 264, 8026, 4365, 13, 220, 43646, 14549, 54201, 422, 279, 198, 286, 3424, 1436, 539, 387, 1373, 382, 286, 11414, 286, 1456, 512, 310, 471, 721, 888, 3943, 21217, 11, 659, 46855, 20318, 8028, 705, 220, 16, 6758, 15, 933, 286, 3734, 61303, 512, 310, 4933, 14549, 54201, 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 ]
upsight/doctor
doctor/schema.py
SchemaRefResolver._format_stack
def _format_stack(self, stack, current=None): """Prettifies a scope stack for use in error messages. :param list(str) stack: List of scopes. :param str current: The current scope. If specified, will be appended onto the stack before formatting. :returns: str """ if current is not None: stack = stack + [current] if len(stack) > 1: prefix = os.path.commonprefix(stack) if prefix.endswith('/'): prefix = prefix[:-1] stack = [scope[len(prefix):] for scope in stack] return ' => '.join(stack)
python
def _format_stack(self, stack, current=None): """Prettifies a scope stack for use in error messages. :param list(str) stack: List of scopes. :param str current: The current scope. If specified, will be appended onto the stack before formatting. :returns: str """ if current is not None: stack = stack + [current] if len(stack) > 1: prefix = os.path.commonprefix(stack) if prefix.endswith('/'): prefix = prefix[:-1] stack = [scope[len(prefix):] for scope in stack] return ' => '.join(stack)
[ "def", "_format_stack", "(", "self", ",", "stack", ",", "current", "=", "None", ")", ":", "if", "current", "is", "not", "None", ":", "stack", "=", "stack", "+", "[", "current", "]", "if", "len", "(", "stack", ")", ">", "1", ":", "prefix", "=", "os", ".", "path", ".", "commonprefix", "(", "stack", ")", "if", "prefix", ".", "endswith", "(", "'/'", ")", ":", "prefix", "=", "prefix", "[", ":", "-", "1", "]", "stack", "=", "[", "scope", "[", "len", "(", "prefix", ")", ":", "]", "for", "scope", "in", "stack", "]", "return", "' => '", ".", "join", "(", "stack", ")" ]
Prettifies a scope stack for use in error messages. :param list(str) stack: List of scopes. :param str current: The current scope. If specified, will be appended onto the stack before formatting. :returns: str
[ "Prettifies", "a", "scope", "stack", "for", "use", "in", "error", "messages", "." ]
train
https://github.com/upsight/doctor/blob/2cf1d433f6f1aa1355644b449a757c0660793cdd/doctor/schema.py#L20-L35
<|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: Prettifies a scope stack for use in error messages. :param list(str) stack: List of scopes. :param str current: The current scope. If specified, will be appended onto the stack before formatting. :returns: str ### Response: def _format_stack(self, stack, current=None): """Prettifies a scope stack for use in error messages. :param list(str) stack: List of scopes. :param str current: The current scope. If specified, will be appended onto the stack before formatting. :returns: str """ if current is not None: stack = stack + [current] if len(stack) > 1: prefix = os.path.commonprefix(stack) if prefix.endswith('/'): prefix = prefix[:-1] stack = [scope[len(prefix):] for scope in stack] return ' => '.join(stack) <|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, 17708, 9803, 264, 7036, 5729, 369, 1005, 304, 1493, 6743, 382, 286, 551, 913, 1160, 4293, 8, 5729, 25, 1796, 315, 51698, 627, 286, 551, 913, 610, 1510, 25, 578, 1510, 7036, 13, 1442, 5300, 11, 690, 387, 52287, 198, 310, 8800, 279, 5729, 1603, 37666, 627, 286, 551, 4310, 25, 610, 271, 14711, 6075, 512, 755, 721, 2293, 15897, 1214, 11, 5729, 11, 1510, 5980, 997, 286, 4304, 47, 17708, 9803, 264, 7036, 5729, 369, 1005, 304, 1493, 6743, 382, 286, 551, 913, 1160, 4293, 8, 5729, 25, 1796, 315, 51698, 627, 286, 551, 913, 610, 1510, 25, 578, 1510, 7036, 13, 1442, 5300, 11, 690, 387, 52287, 198, 310, 8800, 279, 5729, 1603, 37666, 627, 286, 551, 4310, 25, 610, 198, 286, 3270, 286, 422, 1510, 374, 539, 2290, 512, 310, 5729, 284, 5729, 489, 510, 3311, 933, 286, 422, 2479, 28538, 8, 871, 220, 16, 512, 310, 9436, 284, 2709, 3960, 6488, 12113, 28538, 340, 310, 422, 9436, 41215, 3478, 11290, 394, 9436, 284, 9436, 27141, 16, 933, 310, 5729, 284, 510, 4280, 25721, 30018, 1680, 60, 369, 7036, 304, 5729, 933, 286, 471, 364, 591, 6389, 6115, 28538, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 47, 17708, 9803, 264, 7036, 5729, 369, 1005, 304, 1493, 6743, 382, 286, 551, 913, 1160, 4293, 8, 5729, 25, 1796, 315, 51698, 627, 286, 551, 913, 610, 1510, 25, 578, 1510, 7036, 13, 1442, 5300, 11, 690, 387, 52287, 198, 310, 8800, 279, 5729, 1603, 37666, 627, 286, 551, 4310, 25, 610, 271, 14711, 6075, 512, 755, 721, 2293, 15897, 1214, 11, 5729, 11, 1510, 5980, 997, 286, 4304, 47, 17708, 9803, 264, 7036, 5729, 369, 1005, 304, 1493, 6743, 382, 286, 551, 913, 1160, 4293, 8, 5729, 25, 1796, 315, 51698, 627, 286, 551, 913, 610, 1510, 25, 578, 1510, 7036, 13, 1442, 5300, 11, 690, 387, 52287, 198, 310, 8800, 279, 5729, 1603, 37666, 627, 286, 551, 4310, 25, 610, 198, 286, 3270, 286, 422, 1510, 374, 539, 2290, 512, 310, 5729, 284, 5729, 489, 510, 3311, 933, 286, 422, 2479, 28538, 8, 871, 220, 16, 512, 310, 9436, 284, 2709, 3960, 6488, 12113, 28538, 340, 310, 422, 9436, 41215, 3478, 11290, 394, 9436, 284, 9436, 27141, 16, 933, 310, 5729, 284, 510, 4280, 25721, 30018, 1680, 60, 369, 7036, 304, 5729, 933, 286, 471, 364, 591, 6389, 6115, 28538, 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 ]
django-salesforce/django-salesforce
salesforce/auth.py
SalesforceAuth.dynamic_start
def dynamic_start(self, access_token, instance_url=None, **kw): """ Set the access token dynamically according to the current user. More parameters can be set. """ self.dynamic = {'access_token': str(access_token), 'instance_url': str(instance_url)} self.dynamic.update(kw)
python
def dynamic_start(self, access_token, instance_url=None, **kw): """ Set the access token dynamically according to the current user. More parameters can be set. """ self.dynamic = {'access_token': str(access_token), 'instance_url': str(instance_url)} self.dynamic.update(kw)
[ "def", "dynamic_start", "(", "self", ",", "access_token", ",", "instance_url", "=", "None", ",", "*", "*", "kw", ")", ":", "self", ".", "dynamic", "=", "{", "'access_token'", ":", "str", "(", "access_token", ")", ",", "'instance_url'", ":", "str", "(", "instance_url", ")", "}", "self", ".", "dynamic", ".", "update", "(", "kw", ")" ]
Set the access token dynamically according to the current user. More parameters can be set.
[ "Set", "the", "access", "token", "dynamically", "according", "to", "the", "current", "user", "." ]
train
https://github.com/django-salesforce/django-salesforce/blob/6fd5643dba69d49c5881de50875cf90204a8f808/salesforce/auth.py#L144-L151
<|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 the access token dynamically according to the current user. More parameters can be set. ### Response: def dynamic_start(self, access_token, instance_url=None, **kw): """ Set the access token dynamically according to the current user. More parameters can be set. """ self.dynamic = {'access_token': str(access_token), 'instance_url': str(instance_url)} self.dynamic.update(kw) <|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, 279, 2680, 4037, 43111, 4184, 311, 279, 1510, 1217, 382, 286, 4497, 5137, 649, 387, 743, 382, 14711, 6075, 512, 755, 8915, 5011, 1214, 11, 2680, 6594, 11, 2937, 2975, 5980, 11, 3146, 29700, 997, 286, 3270, 286, 2638, 279, 2680, 4037, 43111, 4184, 311, 279, 1510, 1217, 382, 286, 4497, 5137, 649, 387, 743, 627, 286, 3270, 286, 659, 60144, 284, 5473, 5323, 6594, 1232, 610, 56287, 6594, 705, 364, 4956, 2975, 1232, 610, 22384, 2975, 10792, 286, 659, 60144, 5430, 6097, 86, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 279, 2680, 4037, 43111, 4184, 311, 279, 1510, 1217, 382, 286, 4497, 5137, 649, 387, 743, 382, 14711, 6075, 512, 755, 8915, 5011, 1214, 11, 2680, 6594, 11, 2937, 2975, 5980, 11, 3146, 29700, 997, 286, 3270, 286, 2638, 279, 2680, 4037, 43111, 4184, 311, 279, 1510, 1217, 382, 286, 4497, 5137, 649, 387, 743, 627, 286, 3270, 286, 659, 60144, 284, 5473, 5323, 6594, 1232, 610, 56287, 6594, 705, 364, 4956, 2975, 1232, 610, 22384, 2975, 10792, 286, 659, 60144, 5430, 6097, 86, 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 ]
tBuLi/symfit
symfit/core/support.py
sympy_to_scipy
def sympy_to_scipy(func, vars, params): """ Convert a symbolic expression to one scipy digs. Not used by ``symfit`` any more. :param func: sympy expression :param vars: variables :param params: parameters :return: Scipy-style function to be used for numerical evaluation of the model. """ lambda_func = sympy_to_py(func, vars, params) def f(x, p): """ Scipy style function. :param x: list of arrays, NxM :param p: tuple of parameter values. """ x = np.atleast_2d(x) y = [x[i] for i in range(len(x))] if len(x[0]) else [] try: ans = lambda_func(*(y + list(p))) except TypeError: # Possibly this is a constant function in which case it only has Parameters. ans = lambda_func(*list(p))# * np.ones(x_shape) return ans return f
python
def sympy_to_scipy(func, vars, params): """ Convert a symbolic expression to one scipy digs. Not used by ``symfit`` any more. :param func: sympy expression :param vars: variables :param params: parameters :return: Scipy-style function to be used for numerical evaluation of the model. """ lambda_func = sympy_to_py(func, vars, params) def f(x, p): """ Scipy style function. :param x: list of arrays, NxM :param p: tuple of parameter values. """ x = np.atleast_2d(x) y = [x[i] for i in range(len(x))] if len(x[0]) else [] try: ans = lambda_func(*(y + list(p))) except TypeError: # Possibly this is a constant function in which case it only has Parameters. ans = lambda_func(*list(p))# * np.ones(x_shape) return ans return f
[ "def", "sympy_to_scipy", "(", "func", ",", "vars", ",", "params", ")", ":", "lambda_func", "=", "sympy_to_py", "(", "func", ",", "vars", ",", "params", ")", "def", "f", "(", "x", ",", "p", ")", ":", "\"\"\"\n Scipy style function.\n\n :param x: list of arrays, NxM\n :param p: tuple of parameter values.\n \"\"\"", "x", "=", "np", ".", "atleast_2d", "(", "x", ")", "y", "=", "[", "x", "[", "i", "]", "for", "i", "in", "range", "(", "len", "(", "x", ")", ")", "]", "if", "len", "(", "x", "[", "0", "]", ")", "else", "[", "]", "try", ":", "ans", "=", "lambda_func", "(", "*", "(", "y", "+", "list", "(", "p", ")", ")", ")", "except", "TypeError", ":", "# Possibly this is a constant function in which case it only has Parameters.", "ans", "=", "lambda_func", "(", "*", "list", "(", "p", ")", ")", "# * np.ones(x_shape)", "return", "ans", "return", "f" ]
Convert a symbolic expression to one scipy digs. Not used by ``symfit`` any more. :param func: sympy expression :param vars: variables :param params: parameters :return: Scipy-style function to be used for numerical evaluation of the model.
[ "Convert", "a", "symbolic", "expression", "to", "one", "scipy", "digs", ".", "Not", "used", "by", "symfit", "any", "more", "." ]
train
https://github.com/tBuLi/symfit/blob/759dd3d1d4270510d651f40b23dd26b1b10eee83/symfit/core/support.py#L162-L188
<|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 a symbolic expression to one scipy digs. Not used by ``symfit`` any more. :param func: sympy expression :param vars: variables :param params: parameters :return: Scipy-style function to be used for numerical evaluation of the model. ### Response: def sympy_to_scipy(func, vars, params): """ Convert a symbolic expression to one scipy digs. Not used by ``symfit`` any more. :param func: sympy expression :param vars: variables :param params: parameters :return: Scipy-style function to be used for numerical evaluation of the model. """ lambda_func = sympy_to_py(func, vars, params) def f(x, p): """ Scipy style function. :param x: list of arrays, NxM :param p: tuple of parameter values. """ x = np.atleast_2d(x) y = [x[i] for i in range(len(x))] if len(x[0]) else [] try: ans = lambda_func(*(y + list(p))) except TypeError: # Possibly this is a constant function in which case it only has Parameters. ans = lambda_func(*list(p))# * np.ones(x_shape) return ans return f <|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, 264, 36396, 7645, 311, 832, 29190, 90057, 13, 2876, 1511, 555, 10103, 24738, 6410, 14196, 904, 810, 382, 262, 551, 913, 2988, 25, 22176, 88, 7645, 198, 262, 551, 913, 20537, 25, 7482, 198, 262, 551, 913, 3712, 25, 5137, 198, 262, 551, 693, 25, 2522, 23799, 11549, 734, 311, 387, 1511, 369, 35876, 16865, 315, 279, 1646, 382, 14711, 6075, 512, 755, 22176, 88, 2401, 13473, 23799, 19062, 11, 20537, 11, 3712, 997, 262, 3270, 262, 7316, 264, 36396, 7645, 311, 832, 29190, 90057, 13, 2876, 1511, 555, 10103, 24738, 6410, 14196, 904, 810, 382, 262, 551, 913, 2988, 25, 22176, 88, 7645, 198, 262, 551, 913, 20537, 25, 7482, 198, 262, 551, 913, 3712, 25, 5137, 198, 262, 551, 693, 25, 2522, 23799, 11549, 734, 311, 387, 1511, 369, 35876, 16865, 315, 279, 1646, 627, 262, 3270, 262, 12741, 9791, 284, 22176, 88, 2401, 41391, 19062, 11, 20537, 11, 3712, 340, 262, 711, 282, 2120, 11, 281, 997, 286, 3270, 286, 2522, 23799, 1742, 734, 382, 286, 551, 913, 865, 25, 1160, 315, 18893, 11, 82147, 44, 198, 286, 551, 913, 281, 25, 14743, 315, 5852, 2819, 627, 286, 3270, 286, 865, 284, 2660, 6990, 56371, 62, 17, 67, 2120, 340, 286, 379, 284, 510, 87, 1004, 60, 369, 602, 304, 2134, 7046, 2120, 82494, 422, 2479, 2120, 58, 15, 2526, 775, 4260, 286, 1456, 512, 310, 8261, 284, 12741, 9791, 40603, 88, 489, 1160, 1319, 6054, 286, 3734, 26082, 512, 310, 674, 80291, 420, 374, 264, 6926, 734, 304, 902, 1162, 433, 1193, 706, 13831, 627, 310, 8261, 284, 12741, 9791, 4163, 1638, 1319, 595, 2, 353, 2660, 32890, 2120, 13911, 340, 286, 471, 8261, 271, 262, 471, 282, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 264, 36396, 7645, 311, 832, 29190, 90057, 13, 2876, 1511, 555, 10103, 24738, 6410, 14196, 904, 810, 382, 262, 551, 913, 2988, 25, 22176, 88, 7645, 198, 262, 551, 913, 20537, 25, 7482, 198, 262, 551, 913, 3712, 25, 5137, 198, 262, 551, 693, 25, 2522, 23799, 11549, 734, 311, 387, 1511, 369, 35876, 16865, 315, 279, 1646, 382, 14711, 6075, 512, 755, 22176, 88, 2401, 13473, 23799, 19062, 11, 20537, 11, 3712, 997, 262, 3270, 262, 7316, 264, 36396, 7645, 311, 832, 29190, 90057, 13, 2876, 1511, 555, 10103, 24738, 6410, 14196, 904, 810, 382, 262, 551, 913, 2988, 25, 22176, 88, 7645, 198, 262, 551, 913, 20537, 25, 7482, 198, 262, 551, 913, 3712, 25, 5137, 198, 262, 551, 693, 25, 2522, 23799, 11549, 734, 311, 387, 1511, 369, 35876, 16865, 315, 279, 1646, 627, 262, 3270, 262, 12741, 9791, 284, 22176, 88, 2401, 41391, 19062, 11, 20537, 11, 3712, 340, 262, 711, 282, 2120, 11, 281, 997, 286, 3270, 286, 2522, 23799, 1742, 734, 382, 286, 551, 913, 865, 25, 1160, 315, 18893, 11, 82147, 44, 198, 286, 551, 913, 281, 25, 14743, 315, 5852, 2819, 627, 286, 3270, 286, 865, 284, 2660, 6990, 56371, 62, 17, 67, 2120, 340, 286, 379, 284, 510, 87, 1004, 60, 369, 602, 304, 2134, 7046, 2120, 82494, 422, 2479, 2120, 58, 15, 2526, 775, 4260, 286, 1456, 512, 310, 8261, 284, 12741, 9791, 40603, 88, 489, 1160, 1319, 6054, 286, 3734, 26082, 512, 310, 674, 80291, 420, 374, 264, 6926, 734, 304, 902, 1162, 433, 1193, 706, 13831, 627, 310, 8261, 284, 12741, 9791, 4163, 1638, 1319, 595, 2, 353, 2660, 32890, 2120, 13911, 340, 286, 471, 8261, 271, 262, 471, 282, 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 ]
toumorokoshi/sprinter
sprinter/formula/base.py
FormulaBase.validate
def validate(self): """ validates the feature configuration, and returns a list of errors (empty list if no error) validate should: * required variables * warn on unused variables errors should either be reported via self._log_error(), or raise an exception """ if self.target: for k in self.target.keys(): if k in self.deprecated_options: self.logger.warn( self.deprecated_options[k].format(option=k, feature=self.feature_name)) elif (k not in self.valid_options and k not in self.required_options and '*' not in self.valid_options): self.logger.warn("Unused option %s in %s!" % (k, self.feature_name)) for k in self.required_options: if not self.target.has(k): self._log_error( "Required option %s not present in feature %s!" % (k, self.feature_name))
python
def validate(self): """ validates the feature configuration, and returns a list of errors (empty list if no error) validate should: * required variables * warn on unused variables errors should either be reported via self._log_error(), or raise an exception """ if self.target: for k in self.target.keys(): if k in self.deprecated_options: self.logger.warn( self.deprecated_options[k].format(option=k, feature=self.feature_name)) elif (k not in self.valid_options and k not in self.required_options and '*' not in self.valid_options): self.logger.warn("Unused option %s in %s!" % (k, self.feature_name)) for k in self.required_options: if not self.target.has(k): self._log_error( "Required option %s not present in feature %s!" % (k, self.feature_name))
[ "def", "validate", "(", "self", ")", ":", "if", "self", ".", "target", ":", "for", "k", "in", "self", ".", "target", ".", "keys", "(", ")", ":", "if", "k", "in", "self", ".", "deprecated_options", ":", "self", ".", "logger", ".", "warn", "(", "self", ".", "deprecated_options", "[", "k", "]", ".", "format", "(", "option", "=", "k", ",", "feature", "=", "self", ".", "feature_name", ")", ")", "elif", "(", "k", "not", "in", "self", ".", "valid_options", "and", "k", "not", "in", "self", ".", "required_options", "and", "'*'", "not", "in", "self", ".", "valid_options", ")", ":", "self", ".", "logger", ".", "warn", "(", "\"Unused option %s in %s!\"", "%", "(", "k", ",", "self", ".", "feature_name", ")", ")", "for", "k", "in", "self", ".", "required_options", ":", "if", "not", "self", ".", "target", ".", "has", "(", "k", ")", ":", "self", ".", "_log_error", "(", "\"Required option %s not present in feature %s!\"", "%", "(", "k", ",", "self", ".", "feature_name", ")", ")" ]
validates the feature configuration, and returns a list of errors (empty list if no error) validate should: * required variables * warn on unused variables errors should either be reported via self._log_error(), or raise an exception
[ "validates", "the", "feature", "configuration", "and", "returns", "a", "list", "of", "errors", "(", "empty", "list", "if", "no", "error", ")" ]
train
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/base.py#L141-L163
<|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: validates the feature configuration, and returns a list of errors (empty list if no error) validate should: * required variables * warn on unused variables errors should either be reported via self._log_error(), or raise an exception ### Response: def validate(self): """ validates the feature configuration, and returns a list of errors (empty list if no error) validate should: * required variables * warn on unused variables errors should either be reported via self._log_error(), or raise an exception """ if self.target: for k in self.target.keys(): if k in self.deprecated_options: self.logger.warn( self.deprecated_options[k].format(option=k, feature=self.feature_name)) elif (k not in self.valid_options and k not in self.required_options and '*' not in self.valid_options): self.logger.warn("Unused option %s in %s!" % (k, self.feature_name)) for k in self.required_options: if not self.target.has(k): self._log_error( "Required option %s not present in feature %s!" % (k, self.feature_name)) <|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, 1930, 988, 279, 4668, 6683, 11, 323, 4780, 264, 1160, 315, 6103, 320, 3274, 1160, 422, 912, 1493, 696, 286, 9788, 1288, 1473, 286, 353, 2631, 7482, 198, 286, 353, 8985, 389, 20604, 7482, 271, 286, 6103, 1288, 3060, 387, 5068, 4669, 659, 1462, 848, 4188, 1535, 477, 4933, 459, 4788, 271, 14711, 6075, 512, 755, 9788, 1214, 997, 286, 3270, 286, 27353, 279, 4668, 6683, 11, 323, 4780, 264, 1160, 315, 6103, 320, 3274, 1160, 422, 912, 1493, 696, 286, 9788, 1288, 1473, 286, 353, 2631, 7482, 198, 286, 353, 8985, 389, 20604, 7482, 271, 286, 6103, 1288, 3060, 387, 5068, 4669, 659, 1462, 848, 4188, 1535, 477, 4933, 459, 4788, 198, 286, 3270, 286, 422, 659, 6676, 512, 310, 369, 597, 304, 659, 6676, 9301, 4019, 394, 422, 597, 304, 659, 2337, 20483, 8917, 512, 504, 659, 16465, 22123, 1021, 667, 659, 2337, 20483, 8917, 6874, 948, 2293, 31731, 46257, 11, 4668, 7822, 30691, 1292, 1192, 394, 4508, 320, 74, 539, 304, 659, 21232, 8917, 323, 597, 539, 304, 659, 20664, 8917, 323, 198, 2611, 31801, 539, 304, 659, 21232, 8917, 997, 504, 659, 16465, 22123, 446, 95133, 3072, 1034, 82, 304, 1034, 82, 9135, 1034, 320, 74, 11, 659, 30691, 1292, 1192, 310, 369, 597, 304, 659, 20664, 8917, 512, 394, 422, 539, 659, 6676, 7001, 6097, 997, 504, 659, 1462, 848, 4188, 1021, 667, 330, 8327, 3072, 1034, 82, 539, 3118, 304, 4668, 1034, 82, 9135, 1034, 320, 74, 11, 659, 30691, 1292, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 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, 1930, 988, 279, 4668, 6683, 11, 323, 4780, 264, 1160, 315, 6103, 320, 3274, 1160, 422, 912, 1493, 696, 286, 9788, 1288, 1473, 286, 353, 2631, 7482, 198, 286, 353, 8985, 389, 20604, 7482, 271, 286, 6103, 1288, 3060, 387, 5068, 4669, 659, 1462, 848, 4188, 1535, 477, 4933, 459, 4788, 271, 14711, 6075, 512, 755, 9788, 1214, 997, 286, 3270, 286, 27353, 279, 4668, 6683, 11, 323, 4780, 264, 1160, 315, 6103, 320, 3274, 1160, 422, 912, 1493, 696, 286, 9788, 1288, 1473, 286, 353, 2631, 7482, 198, 286, 353, 8985, 389, 20604, 7482, 271, 286, 6103, 1288, 3060, 387, 5068, 4669, 659, 1462, 848, 4188, 1535, 477, 4933, 459, 4788, 198, 286, 3270, 286, 422, 659, 6676, 512, 310, 369, 597, 304, 659, 6676, 9301, 4019, 394, 422, 597, 304, 659, 2337, 20483, 8917, 512, 504, 659, 16465, 22123, 1021, 667, 659, 2337, 20483, 8917, 6874, 948, 2293, 31731, 46257, 11, 4668, 7822, 30691, 1292, 1192, 394, 4508, 320, 74, 539, 304, 659, 21232, 8917, 323, 597, 539, 304, 659, 20664, 8917, 323, 198, 2611, 31801, 539, 304, 659, 21232, 8917, 997, 504, 659, 16465, 22123, 446, 95133, 3072, 1034, 82, 304, 1034, 82, 9135, 1034, 320, 74, 11, 659, 30691, 1292, 1192, 310, 369, 597, 304, 659, 20664, 8917, 512, 394, 422, 539, 659, 6676, 7001, 6097, 997, 504, 659, 1462, 848, 4188, 1021, 667, 330, 8327, 3072, 1034, 82, 539, 3118, 304, 4668, 1034, 82, 9135, 1034, 320, 74, 11, 659, 30691, 1292, 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 ]
dossier/dossier.web
dossier/web/tags.py
v1_url_associations
def v1_url_associations(tags, url): '''Retrieve associations for a given URL. The associations returned have the exact same structure as defined in the ``v1_tag_associate`` route with one addition: a ``tag`` field contains the full tag name for the association. ''' url = urllib.unquote_plus(url.decode('utf-8')).strip() return {'associations': tags.assocs_by_url(url)}
python
def v1_url_associations(tags, url): '''Retrieve associations for a given URL. The associations returned have the exact same structure as defined in the ``v1_tag_associate`` route with one addition: a ``tag`` field contains the full tag name for the association. ''' url = urllib.unquote_plus(url.decode('utf-8')).strip() return {'associations': tags.assocs_by_url(url)}
[ "def", "v1_url_associations", "(", "tags", ",", "url", ")", ":", "url", "=", "urllib", ".", "unquote_plus", "(", "url", ".", "decode", "(", "'utf-8'", ")", ")", ".", "strip", "(", ")", "return", "{", "'associations'", ":", "tags", ".", "assocs_by_url", "(", "url", ")", "}" ]
Retrieve associations for a given URL. The associations returned have the exact same structure as defined in the ``v1_tag_associate`` route with one addition: a ``tag`` field contains the full tag name for the association.
[ "Retrieve", "associations", "for", "a", "given", "URL", "." ]
train
https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/tags.py#L140-L148
<|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 associations for a given URL. The associations returned have the exact same structure as defined in the ``v1_tag_associate`` route with one addition: a ``tag`` field contains the full tag name for the association. ### Response: def v1_url_associations(tags, url): '''Retrieve associations for a given URL. The associations returned have the exact same structure as defined in the ``v1_tag_associate`` route with one addition: a ``tag`` field contains the full tag name for the association. ''' url = urllib.unquote_plus(url.decode('utf-8')).strip() return {'associations': tags.assocs_by_url(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, 30257, 369, 264, 2728, 5665, 382, 262, 578, 30257, 6052, 617, 279, 4839, 1890, 6070, 439, 4613, 198, 262, 304, 279, 10103, 85, 16, 9556, 59765, 349, 14196, 6149, 449, 832, 5369, 25, 264, 10103, 4681, 85374, 262, 2115, 5727, 279, 2539, 4877, 836, 369, 279, 15360, 382, 14711, 6075, 512, 755, 348, 16, 2975, 59765, 811, 58313, 11, 2576, 997, 262, 11712, 88765, 30257, 369, 264, 2728, 5665, 382, 262, 578, 30257, 6052, 617, 279, 4839, 1890, 6070, 439, 4613, 198, 262, 304, 279, 10103, 85, 16, 9556, 59765, 349, 14196, 6149, 449, 832, 5369, 25, 264, 10103, 4681, 85374, 262, 2115, 5727, 279, 2539, 4877, 836, 369, 279, 15360, 627, 262, 11414, 262, 2576, 284, 25057, 6441, 3022, 29143, 6659, 16301, 493, 4867, 12, 23, 19449, 13406, 746, 262, 471, 5473, 25304, 811, 1232, 9681, 13, 395, 14460, 3795, 2975, 6659, 10792, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 30257, 369, 264, 2728, 5665, 382, 262, 578, 30257, 6052, 617, 279, 4839, 1890, 6070, 439, 4613, 198, 262, 304, 279, 10103, 85, 16, 9556, 59765, 349, 14196, 6149, 449, 832, 5369, 25, 264, 10103, 4681, 85374, 262, 2115, 5727, 279, 2539, 4877, 836, 369, 279, 15360, 382, 14711, 6075, 512, 755, 348, 16, 2975, 59765, 811, 58313, 11, 2576, 997, 262, 11712, 88765, 30257, 369, 264, 2728, 5665, 382, 262, 578, 30257, 6052, 617, 279, 4839, 1890, 6070, 439, 4613, 198, 262, 304, 279, 10103, 85, 16, 9556, 59765, 349, 14196, 6149, 449, 832, 5369, 25, 264, 10103, 4681, 85374, 262, 2115, 5727, 279, 2539, 4877, 836, 369, 279, 15360, 627, 262, 11414, 262, 2576, 284, 25057, 6441, 3022, 29143, 6659, 16301, 493, 4867, 12, 23, 19449, 13406, 746, 262, 471, 5473, 25304, 811, 1232, 9681, 13, 395, 14460, 3795, 2975, 6659, 10792, 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 ]
bitesofcode/projexui
projexui/widgets/xtreewidget/xtreewidget.py
XTreeWidget.restoreXml
def restoreXml(self, xml): """ Restores properties for this tree widget from the inputed XML. :param xml | <xml.etree.ElementTree.Element> :return <bool> success """ if xml is None: return False self.setUpdatesEnabled(False) self.blockSignals(True) # restore column data header = self.header() xcolumns = xml.find('columns') if xcolumns is not None: for xcolumn in xcolumns: name = xcolumn.get('name') index = self.column(name) vindex = int(xcolumn.get('visualIndex', index)) currvi = header.visualIndex(index) # restore from name if index == -1: continue if currvi != vindex: header.moveSection(currvi, vindex) self.setColumnHidden(index, xcolumn.get('hidden') == 'True') if not self.isColumnHidden(index): width = int(xcolumn.get('width', self.columnWidth(index))) self.setColumnWidth(index, width) # restore order data headerState = xml.get('headerState') if headerState is not None: state = QtCore.QByteArray.fromBase64(str(headerState)) self.header().restoreState(state) sortColumn = int(xml.get('sortColumn', 0)) sortingEnabled = xml.get('sortingEnabled') == 'True' sortOrder = QtCore.Qt.SortOrder(int(xml.get('sortOrder', 0))) if sortingEnabled: self.setSortingEnabled(sortingEnabled) self.sortByColumn(sortColumn, sortOrder) self.setUpdatesEnabled(True) self.blockSignals(False) return True
python
def restoreXml(self, xml): """ Restores properties for this tree widget from the inputed XML. :param xml | <xml.etree.ElementTree.Element> :return <bool> success """ if xml is None: return False self.setUpdatesEnabled(False) self.blockSignals(True) # restore column data header = self.header() xcolumns = xml.find('columns') if xcolumns is not None: for xcolumn in xcolumns: name = xcolumn.get('name') index = self.column(name) vindex = int(xcolumn.get('visualIndex', index)) currvi = header.visualIndex(index) # restore from name if index == -1: continue if currvi != vindex: header.moveSection(currvi, vindex) self.setColumnHidden(index, xcolumn.get('hidden') == 'True') if not self.isColumnHidden(index): width = int(xcolumn.get('width', self.columnWidth(index))) self.setColumnWidth(index, width) # restore order data headerState = xml.get('headerState') if headerState is not None: state = QtCore.QByteArray.fromBase64(str(headerState)) self.header().restoreState(state) sortColumn = int(xml.get('sortColumn', 0)) sortingEnabled = xml.get('sortingEnabled') == 'True' sortOrder = QtCore.Qt.SortOrder(int(xml.get('sortOrder', 0))) if sortingEnabled: self.setSortingEnabled(sortingEnabled) self.sortByColumn(sortColumn, sortOrder) self.setUpdatesEnabled(True) self.blockSignals(False) return True
[ "def", "restoreXml", "(", "self", ",", "xml", ")", ":", "if", "xml", "is", "None", ":", "return", "False", "self", ".", "setUpdatesEnabled", "(", "False", ")", "self", ".", "blockSignals", "(", "True", ")", "# restore column data\r", "header", "=", "self", ".", "header", "(", ")", "xcolumns", "=", "xml", ".", "find", "(", "'columns'", ")", "if", "xcolumns", "is", "not", "None", ":", "for", "xcolumn", "in", "xcolumns", ":", "name", "=", "xcolumn", ".", "get", "(", "'name'", ")", "index", "=", "self", ".", "column", "(", "name", ")", "vindex", "=", "int", "(", "xcolumn", ".", "get", "(", "'visualIndex'", ",", "index", ")", ")", "currvi", "=", "header", ".", "visualIndex", "(", "index", ")", "# restore from name\r", "if", "index", "==", "-", "1", ":", "continue", "if", "currvi", "!=", "vindex", ":", "header", ".", "moveSection", "(", "currvi", ",", "vindex", ")", "self", ".", "setColumnHidden", "(", "index", ",", "xcolumn", ".", "get", "(", "'hidden'", ")", "==", "'True'", ")", "if", "not", "self", ".", "isColumnHidden", "(", "index", ")", ":", "width", "=", "int", "(", "xcolumn", ".", "get", "(", "'width'", ",", "self", ".", "columnWidth", "(", "index", ")", ")", ")", "self", ".", "setColumnWidth", "(", "index", ",", "width", ")", "# restore order data\r", "headerState", "=", "xml", ".", "get", "(", "'headerState'", ")", "if", "headerState", "is", "not", "None", ":", "state", "=", "QtCore", ".", "QByteArray", ".", "fromBase64", "(", "str", "(", "headerState", ")", ")", "self", ".", "header", "(", ")", ".", "restoreState", "(", "state", ")", "sortColumn", "=", "int", "(", "xml", ".", "get", "(", "'sortColumn'", ",", "0", ")", ")", "sortingEnabled", "=", "xml", ".", "get", "(", "'sortingEnabled'", ")", "==", "'True'", "sortOrder", "=", "QtCore", ".", "Qt", ".", "SortOrder", "(", "int", "(", "xml", ".", "get", "(", "'sortOrder'", ",", "0", ")", ")", ")", "if", "sortingEnabled", ":", "self", ".", "setSortingEnabled", "(", "sortingEnabled", ")", "self", ".", "sortByColumn", "(", "sortColumn", ",", "sortOrder", ")", "self", ".", "setUpdatesEnabled", "(", "True", ")", "self", ".", "blockSignals", "(", "False", ")", "return", "True" ]
Restores properties for this tree widget from the inputed XML. :param xml | <xml.etree.ElementTree.Element> :return <bool> success
[ "Restores", "properties", "for", "this", "tree", "widget", "from", "the", "inputed", "XML", ".", ":", "param", "xml", "|", "<xml", ".", "etree", ".", "ElementTree", ".", "Element", ">", ":", "return", "<bool", ">", "success" ]
train
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtreewidget/xtreewidget.py#L1482-L1536
<|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: Restores properties for this tree widget from the inputed XML. :param xml | <xml.etree.ElementTree.Element> :return <bool> success ### Response: def restoreXml(self, xml): """ Restores properties for this tree widget from the inputed XML. :param xml | <xml.etree.ElementTree.Element> :return <bool> success """ if xml is None: return False self.setUpdatesEnabled(False) self.blockSignals(True) # restore column data header = self.header() xcolumns = xml.find('columns') if xcolumns is not None: for xcolumn in xcolumns: name = xcolumn.get('name') index = self.column(name) vindex = int(xcolumn.get('visualIndex', index)) currvi = header.visualIndex(index) # restore from name if index == -1: continue if currvi != vindex: header.moveSection(currvi, vindex) self.setColumnHidden(index, xcolumn.get('hidden') == 'True') if not self.isColumnHidden(index): width = int(xcolumn.get('width', self.columnWidth(index))) self.setColumnWidth(index, width) # restore order data headerState = xml.get('headerState') if headerState is not None: state = QtCore.QByteArray.fromBase64(str(headerState)) self.header().restoreState(state) sortColumn = int(xml.get('sortColumn', 0)) sortingEnabled = xml.get('sortingEnabled') == 'True' sortOrder = QtCore.Qt.SortOrder(int(xml.get('sortOrder', 0))) if sortingEnabled: self.setSortingEnabled(sortingEnabled) self.sortByColumn(sortColumn, sortOrder) self.setUpdatesEnabled(True) self.blockSignals(False) return 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, 12698, 4692, 6012, 369, 420, 5021, 9264, 505, 279, 1988, 291, 12138, 3304, 9175, 286, 551, 913, 415, 8562, 765, 366, 6591, 39932, 770, 20743, 6670, 20743, 1459, 9175, 286, 551, 693, 257, 366, 2707, 29, 2450, 271, 14711, 6075, 512, 755, 15301, 11854, 1214, 11, 8562, 5903, 286, 26547, 286, 9240, 4692, 6012, 369, 420, 5021, 9264, 505, 279, 1988, 291, 12138, 3304, 9175, 286, 551, 913, 415, 8562, 765, 366, 6591, 39932, 770, 20743, 6670, 20743, 1459, 9175, 286, 551, 693, 257, 366, 2707, 29, 2450, 319, 286, 26547, 286, 422, 8562, 374, 2290, 2904, 310, 471, 3641, 44105, 286, 659, 995, 38191, 5579, 23852, 1240, 286, 659, 16072, 97759, 23922, 1240, 9175, 286, 674, 15301, 3330, 828, 319, 286, 4342, 284, 659, 17531, 3652, 286, 865, 16773, 284, 8562, 2725, 493, 16773, 7849, 286, 422, 865, 16773, 374, 539, 2290, 2904, 310, 369, 865, 6361, 304, 865, 16773, 2904, 394, 836, 256, 284, 865, 6361, 673, 493, 609, 7849, 394, 1963, 220, 284, 659, 13159, 3232, 1240, 394, 348, 1275, 284, 528, 2120, 6361, 673, 493, 30318, 1581, 518, 1963, 5904, 394, 10004, 10176, 284, 4342, 53697, 1581, 7343, 1240, 28465, 394, 674, 15301, 505, 836, 319, 394, 422, 1963, 624, 482, 16, 2904, 504, 3136, 319, 28465, 394, 422, 10004, 10176, 976, 348, 1275, 2904, 504, 4342, 13949, 9817, 28001, 10176, 11, 348, 1275, 1240, 28465, 394, 659, 99403, 17964, 7343, 11, 865, 6361, 673, 493, 6397, 873, 624, 364, 2575, 7849, 28465, 394, 422, 539, 659, 2124, 3006, 17964, 7343, 5903, 504, 2430, 220, 284, 528, 2120, 6361, 673, 493, 3175, 518, 659, 13159, 3408, 7343, 37307, 504, 659, 99403, 3408, 7343, 11, 2430, 1240, 9175, 286, 674, 15301, 2015, 828, 319, 286, 4342, 1423, 284, 8562, 673, 493, 2775, 1423, 7849, 286, 422, 4342, 1423, 374, 539, 2290, 2904, 310, 1614, 284, 54447, 10208, 18901, 6521, 4066, 1227, 4293, 26615, 1423, 5904, 310, 659, 17531, 1020, 31904, 1423, 8556, 1240, 9175, 286, 3460, 3006, 284, 528, 31032, 673, 493, 7003, 3006, 518, 220, 15, 5904, 286, 29373, 5579, 284, 8562, 673, 493, 68139, 5579, 873, 624, 364, 2575, 9938, 286, 79751, 284, 54447, 38340, 37076, 4531, 1577, 31032, 673, 493, 7003, 4531, 518, 220, 15, 37307, 9175, 286, 422, 29373, 5579, 2904, 310, 659, 995, 72781, 5579, 48098, 287, 5579, 1240, 310, 659, 10838, 1383, 3006, 48098, 3006, 11, 79751, 1240, 9175, 286, 659, 995, 38191, 5579, 23922, 1240, 286, 659, 16072, 97759, 23852, 1240, 9175, 286, 471, 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 ]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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 12698, 4692, 6012, 369, 420, 5021, 9264, 505, 279, 1988, 291, 12138, 3304, 9175, 286, 551, 913, 415, 8562, 765, 366, 6591, 39932, 770, 20743, 6670, 20743, 1459, 9175, 286, 551, 693, 257, 366, 2707, 29, 2450, 271, 14711, 6075, 512, 755, 15301, 11854, 1214, 11, 8562, 5903, 286, 26547, 286, 9240, 4692, 6012, 369, 420, 5021, 9264, 505, 279, 1988, 291, 12138, 3304, 9175, 286, 551, 913, 415, 8562, 765, 366, 6591, 39932, 770, 20743, 6670, 20743, 1459, 9175, 286, 551, 693, 257, 366, 2707, 29, 2450, 319, 286, 26547, 286, 422, 8562, 374, 2290, 2904, 310, 471, 3641, 44105, 286, 659, 995, 38191, 5579, 23852, 1240, 286, 659, 16072, 97759, 23922, 1240, 9175, 286, 674, 15301, 3330, 828, 319, 286, 4342, 284, 659, 17531, 3652, 286, 865, 16773, 284, 8562, 2725, 493, 16773, 7849, 286, 422, 865, 16773, 374, 539, 2290, 2904, 310, 369, 865, 6361, 304, 865, 16773, 2904, 394, 836, 256, 284, 865, 6361, 673, 493, 609, 7849, 394, 1963, 220, 284, 659, 13159, 3232, 1240, 394, 348, 1275, 284, 528, 2120, 6361, 673, 493, 30318, 1581, 518, 1963, 5904, 394, 10004, 10176, 284, 4342, 53697, 1581, 7343, 1240, 28465, 394, 674, 15301, 505, 836, 319, 394, 422, 1963, 624, 482, 16, 2904, 504, 3136, 319, 28465, 394, 422, 10004, 10176, 976, 348, 1275, 2904, 504, 4342, 13949, 9817, 28001, 10176, 11, 348, 1275, 1240, 28465, 394, 659, 99403, 17964, 7343, 11, 865, 6361, 673, 493, 6397, 873, 624, 364, 2575, 7849, 28465, 394, 422, 539, 659, 2124, 3006, 17964, 7343, 5903, 504, 2430, 220, 284, 528, 2120, 6361, 673, 493, 3175, 518, 659, 13159, 3408, 7343, 37307, 504, 659, 99403, 3408, 7343, 11, 2430, 1240, 9175, 286, 674, 15301, 2015, 828, 319, 286, 4342, 1423, 284, 8562, 673, 493, 2775, 1423, 7849, 286, 422, 4342, 1423, 374, 539, 2290, 2904, 310, 1614, 284, 54447, 10208, 18901, 6521, 4066, 1227, 4293, 26615, 1423, 5904, 310, 659, 17531, 1020, 31904, 1423, 8556, 1240, 9175, 286, 3460, 3006, 284, 528, 31032, 673, 493, 7003, 3006, 518, 220, 15, 5904, 286, 29373, 5579, 284, 8562, 673, 493, 68139, 5579, 873, 624, 364, 2575, 9938, 286, 79751, 284, 54447, 38340, 37076, 4531, 1577, 31032, 673, 493, 7003, 4531, 518, 220, 15, 37307, 9175, 286, 422, 29373, 5579, 2904, 310, 659, 995, 72781, 5579, 48098, 287, 5579, 1240, 310, 659, 10838, 1383, 3006, 48098, 3006, 11, 79751, 1240, 9175, 286, 659, 995, 38191, 5579, 23922, 1240, 286, 659, 16072, 97759, 23852, 1240, 9175, 286, 471, 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 ]
crackinglandia/pype32
pype32/pype32.py
PE._parseExceptionDirectory
def _parseExceptionDirectory(self, rva, size, magic = consts.PE32): """ Parses the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_EXCEPTION_DIRECTORY} starts. @type size: int @param size: The size of the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type magic: int @param magic: (Optional) The type of PE. This value could be L{consts.PE32} or L{consts.PE64}. @rtype: str @return: The C{IMAGE_EXCEPTION_DIRECTORY} data. """ return self.getDataAtRva(rva, size)
python
def _parseExceptionDirectory(self, rva, size, magic = consts.PE32): """ Parses the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_EXCEPTION_DIRECTORY} starts. @type size: int @param size: The size of the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type magic: int @param magic: (Optional) The type of PE. This value could be L{consts.PE32} or L{consts.PE64}. @rtype: str @return: The C{IMAGE_EXCEPTION_DIRECTORY} data. """ return self.getDataAtRva(rva, size)
[ "def", "_parseExceptionDirectory", "(", "self", ",", "rva", ",", "size", ",", "magic", "=", "consts", ".", "PE32", ")", ":", "return", "self", ".", "getDataAtRva", "(", "rva", ",", "size", ")" ]
Parses the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_EXCEPTION_DIRECTORY} starts. @type size: int @param size: The size of the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type magic: int @param magic: (Optional) The type of PE. This value could be L{consts.PE32} or L{consts.PE64}. @rtype: str @return: The C{IMAGE_EXCEPTION_DIRECTORY} data.
[ "Parses", "the", "C", "{", "IMAGE_EXCEPTION_DIRECTORY", "}", "directory", "." ]
train
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L976-L992
<|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: Parses the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_EXCEPTION_DIRECTORY} starts. @type size: int @param size: The size of the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type magic: int @param magic: (Optional) The type of PE. This value could be L{consts.PE32} or L{consts.PE64}. @rtype: str @return: The C{IMAGE_EXCEPTION_DIRECTORY} data. ### Response: def _parseExceptionDirectory(self, rva, size, magic = consts.PE32): """ Parses the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type rva: int @param rva: The RVA where the C{IMAGE_EXCEPTION_DIRECTORY} starts. @type size: int @param size: The size of the C{IMAGE_EXCEPTION_DIRECTORY} directory. @type magic: int @param magic: (Optional) The type of PE. This value could be L{consts.PE32} or L{consts.PE64}. @rtype: str @return: The C{IMAGE_EXCEPTION_DIRECTORY} data. """ return self.getDataAtRva(rva, size) <|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, 1590, 288, 279, 356, 90, 31026, 28385, 44914, 92, 6352, 627, 1827, 286, 571, 1337, 436, 6723, 25, 528, 720, 286, 571, 913, 436, 6723, 25, 578, 45696, 1405, 279, 356, 90, 31026, 28385, 44914, 92, 8638, 627, 1827, 286, 571, 1337, 1404, 25, 528, 198, 286, 571, 913, 1404, 25, 578, 1404, 315, 279, 356, 90, 31026, 28385, 44914, 92, 6352, 627, 1827, 286, 571, 1337, 11204, 25, 528, 198, 286, 571, 913, 11204, 25, 320, 15669, 8, 578, 955, 315, 22557, 13, 1115, 907, 1436, 387, 445, 90, 96873, 1087, 36, 843, 92, 477, 445, 90, 96873, 1087, 36, 1227, 28374, 1827, 286, 571, 33613, 25, 610, 198, 286, 571, 693, 25, 578, 356, 90, 31026, 28385, 44914, 92, 828, 382, 14711, 6075, 512, 755, 721, 6534, 1378, 9494, 1214, 11, 436, 6723, 11, 1404, 11, 11204, 284, 96532, 1087, 36, 843, 997, 286, 3270, 286, 74530, 279, 356, 90, 31026, 28385, 44914, 92, 6352, 627, 1827, 286, 571, 1337, 436, 6723, 25, 528, 720, 286, 571, 913, 436, 6723, 25, 578, 45696, 1405, 279, 356, 90, 31026, 28385, 44914, 92, 8638, 627, 1827, 286, 571, 1337, 1404, 25, 528, 198, 286, 571, 913, 1404, 25, 578, 1404, 315, 279, 356, 90, 31026, 28385, 44914, 92, 6352, 627, 1827, 286, 571, 1337, 11204, 25, 528, 198, 286, 571, 913, 11204, 25, 320, 15669, 8, 578, 955, 315, 22557, 13, 1115, 907, 1436, 387, 445, 90, 96873, 1087, 36, 843, 92, 477, 445, 90, 96873, 1087, 36, 1227, 28374, 1827, 286, 571, 33613, 25, 610, 198, 286, 571, 693, 25, 578, 356, 90, 31026, 28385, 44914, 92, 828, 627, 286, 3270, 286, 471, 659, 21665, 1688, 49, 6723, 2666, 6723, 11, 1404, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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, 47, 1590, 288, 279, 356, 90, 31026, 28385, 44914, 92, 6352, 627, 1827, 286, 571, 1337, 436, 6723, 25, 528, 720, 286, 571, 913, 436, 6723, 25, 578, 45696, 1405, 279, 356, 90, 31026, 28385, 44914, 92, 8638, 627, 1827, 286, 571, 1337, 1404, 25, 528, 198, 286, 571, 913, 1404, 25, 578, 1404, 315, 279, 356, 90, 31026, 28385, 44914, 92, 6352, 627, 1827, 286, 571, 1337, 11204, 25, 528, 198, 286, 571, 913, 11204, 25, 320, 15669, 8, 578, 955, 315, 22557, 13, 1115, 907, 1436, 387, 445, 90, 96873, 1087, 36, 843, 92, 477, 445, 90, 96873, 1087, 36, 1227, 28374, 1827, 286, 571, 33613, 25, 610, 198, 286, 571, 693, 25, 578, 356, 90, 31026, 28385, 44914, 92, 828, 382, 14711, 6075, 512, 755, 721, 6534, 1378, 9494, 1214, 11, 436, 6723, 11, 1404, 11, 11204, 284, 96532, 1087, 36, 843, 997, 286, 3270, 286, 74530, 279, 356, 90, 31026, 28385, 44914, 92, 6352, 627, 1827, 286, 571, 1337, 436, 6723, 25, 528, 720, 286, 571, 913, 436, 6723, 25, 578, 45696, 1405, 279, 356, 90, 31026, 28385, 44914, 92, 8638, 627, 1827, 286, 571, 1337, 1404, 25, 528, 198, 286, 571, 913, 1404, 25, 578, 1404, 315, 279, 356, 90, 31026, 28385, 44914, 92, 6352, 627, 1827, 286, 571, 1337, 11204, 25, 528, 198, 286, 571, 913, 11204, 25, 320, 15669, 8, 578, 955, 315, 22557, 13, 1115, 907, 1436, 387, 445, 90, 96873, 1087, 36, 843, 92, 477, 445, 90, 96873, 1087, 36, 1227, 28374, 1827, 286, 571, 33613, 25, 610, 198, 286, 571, 693, 25, 578, 356, 90, 31026, 28385, 44914, 92, 828, 627, 286, 3270, 286, 471, 659, 21665, 1688, 49, 6723, 2666, 6723, 11, 1404, 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 ]
UCSBarchlab/PyRTL
pyrtl/corecircuits.py
signed_mult
def signed_mult(a, b): """ Return a*b where a and b are treated as signed values. """ a, b = as_wires(a), as_wires(b) final_len = len(a) + len(b) # sign extend both inputs to the final target length a, b = a.sign_extended(final_len), b.sign_extended(final_len) # the result is the multiplication of both, but truncated # TODO: this may make estimates based on the multiplication overly # pessimistic as half of the multiply result is thrown right away! return (a * b)[0:final_len]
python
def signed_mult(a, b): """ Return a*b where a and b are treated as signed values. """ a, b = as_wires(a), as_wires(b) final_len = len(a) + len(b) # sign extend both inputs to the final target length a, b = a.sign_extended(final_len), b.sign_extended(final_len) # the result is the multiplication of both, but truncated # TODO: this may make estimates based on the multiplication overly # pessimistic as half of the multiply result is thrown right away! return (a * b)[0:final_len]
[ "def", "signed_mult", "(", "a", ",", "b", ")", ":", "a", ",", "b", "=", "as_wires", "(", "a", ")", ",", "as_wires", "(", "b", ")", "final_len", "=", "len", "(", "a", ")", "+", "len", "(", "b", ")", "# sign extend both inputs to the final target length", "a", ",", "b", "=", "a", ".", "sign_extended", "(", "final_len", ")", ",", "b", ".", "sign_extended", "(", "final_len", ")", "# the result is the multiplication of both, but truncated", "# TODO: this may make estimates based on the multiplication overly", "# pessimistic as half of the multiply result is thrown right away!", "return", "(", "a", "*", "b", ")", "[", "0", ":", "final_len", "]" ]
Return a*b where a and b are treated as signed values.
[ "Return", "a", "*", "b", "where", "a", "and", "b", "are", "treated", "as", "signed", "values", "." ]
train
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/corecircuits.py#L184-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: Return a*b where a and b are treated as signed values. ### Response: def signed_mult(a, b): """ Return a*b where a and b are treated as signed values. """ a, b = as_wires(a), as_wires(b) final_len = len(a) + len(b) # sign extend both inputs to the final target length a, b = a.sign_extended(final_len), b.sign_extended(final_len) # the result is the multiplication of both, but truncated # TODO: this may make estimates based on the multiplication overly # pessimistic as half of the multiply result is thrown right away! return (a * b)[0:final_len] <|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, 34379, 1405, 264, 323, 293, 527, 12020, 439, 8667, 2819, 382, 14711, 6075, 512, 755, 8667, 27386, 2948, 11, 293, 997, 262, 4304, 3494, 264, 34379, 1405, 264, 323, 293, 527, 12020, 439, 8667, 2819, 13, 3270, 262, 264, 11, 293, 284, 439, 1704, 3946, 2948, 705, 439, 1704, 3946, 1921, 340, 262, 1620, 6171, 284, 2479, 2948, 8, 489, 2479, 1921, 340, 262, 674, 1879, 13334, 2225, 11374, 311, 279, 1620, 2218, 3160, 198, 262, 264, 11, 293, 284, 264, 15867, 62778, 10285, 6171, 705, 293, 15867, 62778, 10285, 6171, 340, 262, 674, 279, 1121, 374, 279, 47544, 315, 2225, 11, 719, 60856, 198, 262, 674, 5456, 25, 420, 1253, 1304, 17989, 3196, 389, 279, 47544, 39532, 198, 262, 674, 73623, 4633, 439, 4376, 315, 279, 31370, 1121, 374, 15338, 1314, 3201, 4999, 262, 471, 320, 64, 353, 293, 6758, 15, 25, 12085, 6171, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 34379, 1405, 264, 323, 293, 527, 12020, 439, 8667, 2819, 382, 14711, 6075, 512, 755, 8667, 27386, 2948, 11, 293, 997, 262, 4304, 3494, 264, 34379, 1405, 264, 323, 293, 527, 12020, 439, 8667, 2819, 13, 3270, 262, 264, 11, 293, 284, 439, 1704, 3946, 2948, 705, 439, 1704, 3946, 1921, 340, 262, 1620, 6171, 284, 2479, 2948, 8, 489, 2479, 1921, 340, 262, 674, 1879, 13334, 2225, 11374, 311, 279, 1620, 2218, 3160, 198, 262, 264, 11, 293, 284, 264, 15867, 62778, 10285, 6171, 705, 293, 15867, 62778, 10285, 6171, 340, 262, 674, 279, 1121, 374, 279, 47544, 315, 2225, 11, 719, 60856, 198, 262, 674, 5456, 25, 420, 1253, 1304, 17989, 3196, 389, 279, 47544, 39532, 198, 262, 674, 73623, 4633, 439, 4376, 315, 279, 31370, 1121, 374, 15338, 1314, 3201, 4999, 262, 471, 320, 64, 353, 293, 6758, 15, 25, 12085, 6171, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
JoseAntFer/pyny3d
pyny3d/geoms.py
Polygon.get_domain
def get_domain(self): """ :returns: opposite vertices of the bounding prism for this object. :rtype: ndarray([min], [max]) """ if self.domain is None: return np.array([self.points.min(axis=0), self.points.max(axis=0)]) return self.domain
python
def get_domain(self): """ :returns: opposite vertices of the bounding prism for this object. :rtype: ndarray([min], [max]) """ if self.domain is None: return np.array([self.points.min(axis=0), self.points.max(axis=0)]) return self.domain
[ "def", "get_domain", "(", "self", ")", ":", "if", "self", ".", "domain", "is", "None", ":", "return", "np", ".", "array", "(", "[", "self", ".", "points", ".", "min", "(", "axis", "=", "0", ")", ",", "self", ".", "points", ".", "max", "(", "axis", "=", "0", ")", "]", ")", "return", "self", ".", "domain" ]
:returns: opposite vertices of the bounding prism for this object. :rtype: ndarray([min], [max])
[ ":", "returns", ":", "opposite", "vertices", "of", "the", "bounding", "prism", "for", "this", "object", ".", ":", "rtype", ":", "ndarray", "(", "[", "min", "]", "[", "max", "]", ")" ]
train
https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/geoms.py#L415-L424
<|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: opposite vertices of the bounding prism for this object. :rtype: ndarray([min], [max]) ### Response: def get_domain(self): """ :returns: opposite vertices of the bounding prism for this object. :rtype: ndarray([min], [max]) """ if self.domain is None: return np.array([self.points.min(axis=0), self.points.max(axis=0)]) return self.domain <|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, 4310, 25, 14329, 17672, 315, 279, 31718, 94710, 369, 420, 2591, 310, 1665, 3304, 286, 551, 33613, 25, 67983, 2625, 1083, 1145, 510, 2880, 9801, 14711, 6075, 512, 755, 636, 20715, 1214, 5903, 286, 26547, 286, 551, 4310, 25, 14329, 17672, 315, 279, 31718, 94710, 369, 420, 2591, 310, 1665, 3304, 286, 551, 33613, 25, 67983, 2625, 1083, 1145, 510, 2880, 15364, 286, 26547, 286, 422, 659, 11248, 374, 2290, 2904, 310, 471, 2660, 7382, 2625, 726, 31896, 4456, 32984, 28, 15, 705, 2591, 6663, 659, 31896, 6817, 32984, 28, 15, 7400, 1240, 286, 471, 659, 11248, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 4310, 25, 14329, 17672, 315, 279, 31718, 94710, 369, 420, 2591, 310, 1665, 3304, 286, 551, 33613, 25, 67983, 2625, 1083, 1145, 510, 2880, 9801, 14711, 6075, 512, 755, 636, 20715, 1214, 5903, 286, 26547, 286, 551, 4310, 25, 14329, 17672, 315, 279, 31718, 94710, 369, 420, 2591, 310, 1665, 3304, 286, 551, 33613, 25, 67983, 2625, 1083, 1145, 510, 2880, 15364, 286, 26547, 286, 422, 659, 11248, 374, 2290, 2904, 310, 471, 2660, 7382, 2625, 726, 31896, 4456, 32984, 28, 15, 705, 2591, 6663, 659, 31896, 6817, 32984, 28, 15, 7400, 1240, 286, 471, 659, 11248, 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 ]
JarryShaw/PyPCAPKit
src/toolkit/default.py
ipv4_reassembly
def ipv4_reassembly(frame): """Make data for IPv4 reassembly.""" if 'IPv4' in frame: ipv4 = frame['IPv4'].info if ipv4.flags.df: # dismiss not fragmented frame return False, None data = dict( bufid=( ipv4.src, # source IP address ipv4.dst, # destination IP address ipv4.id, # identification ipv4.proto.name, # payload protocol type ), num=frame.info.number, # original packet range number fo=ipv4.frag_offset, # fragment offset ihl=ipv4.hdr_len, # internet header length mf=ipv4.flags.mf, # more fragment flag tl=ipv4.len, # total length, header includes header=bytearray(ipv4.packet.header), # raw bytearray type header payload=bytearray(ipv4.packet.payload or b''), # raw bytearray type payload ) return True, data return False, None
python
def ipv4_reassembly(frame): """Make data for IPv4 reassembly.""" if 'IPv4' in frame: ipv4 = frame['IPv4'].info if ipv4.flags.df: # dismiss not fragmented frame return False, None data = dict( bufid=( ipv4.src, # source IP address ipv4.dst, # destination IP address ipv4.id, # identification ipv4.proto.name, # payload protocol type ), num=frame.info.number, # original packet range number fo=ipv4.frag_offset, # fragment offset ihl=ipv4.hdr_len, # internet header length mf=ipv4.flags.mf, # more fragment flag tl=ipv4.len, # total length, header includes header=bytearray(ipv4.packet.header), # raw bytearray type header payload=bytearray(ipv4.packet.payload or b''), # raw bytearray type payload ) return True, data return False, None
[ "def", "ipv4_reassembly", "(", "frame", ")", ":", "if", "'IPv4'", "in", "frame", ":", "ipv4", "=", "frame", "[", "'IPv4'", "]", ".", "info", "if", "ipv4", ".", "flags", ".", "df", ":", "# dismiss not fragmented frame", "return", "False", ",", "None", "data", "=", "dict", "(", "bufid", "=", "(", "ipv4", ".", "src", ",", "# source IP address", "ipv4", ".", "dst", ",", "# destination IP address", "ipv4", ".", "id", ",", "# identification", "ipv4", ".", "proto", ".", "name", ",", "# payload protocol type", ")", ",", "num", "=", "frame", ".", "info", ".", "number", ",", "# original packet range number", "fo", "=", "ipv4", ".", "frag_offset", ",", "# fragment offset", "ihl", "=", "ipv4", ".", "hdr_len", ",", "# internet header length", "mf", "=", "ipv4", ".", "flags", ".", "mf", ",", "# more fragment flag", "tl", "=", "ipv4", ".", "len", ",", "# total length, header includes", "header", "=", "bytearray", "(", "ipv4", ".", "packet", ".", "header", ")", ",", "# raw bytearray type header", "payload", "=", "bytearray", "(", "ipv4", ".", "packet", ".", "payload", "or", "b''", ")", ",", "# raw bytearray type payload", ")", "return", "True", ",", "data", "return", "False", ",", "None" ]
Make data for IPv4 reassembly.
[ "Make", "data", "for", "IPv4", "reassembly", "." ]
train
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/toolkit/default.py#L12-L34
<|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 data for IPv4 reassembly. ### Response: def ipv4_reassembly(frame): """Make data for IPv4 reassembly.""" if 'IPv4' in frame: ipv4 = frame['IPv4'].info if ipv4.flags.df: # dismiss not fragmented frame return False, None data = dict( bufid=( ipv4.src, # source IP address ipv4.dst, # destination IP address ipv4.id, # identification ipv4.proto.name, # payload protocol type ), num=frame.info.number, # original packet range number fo=ipv4.frag_offset, # fragment offset ihl=ipv4.hdr_len, # internet header length mf=ipv4.flags.mf, # more fragment flag tl=ipv4.len, # total length, header includes header=bytearray(ipv4.packet.header), # raw bytearray type header payload=bytearray(ipv4.packet.payload or b''), # raw bytearray type payload ) return True, data return False, 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, 8238, 828, 369, 32660, 19, 312, 15343, 382, 14711, 6075, 512, 755, 46575, 19, 1311, 15343, 15396, 997, 262, 4304, 8238, 828, 369, 32660, 19, 312, 15343, 14781, 262, 422, 364, 59156, 19, 6, 304, 4124, 512, 286, 46575, 19, 284, 4124, 681, 59156, 19, 7352, 2801, 198, 286, 422, 46575, 19, 28302, 49478, 25, 996, 674, 13738, 539, 87195, 4124, 198, 310, 471, 3641, 11, 2290, 198, 286, 828, 284, 6587, 1021, 310, 6745, 307, 86368, 394, 46575, 19, 15023, 11, 9898, 674, 2592, 6933, 2686, 198, 394, 46575, 19, 57533, 11, 9898, 674, 9284, 6933, 2686, 198, 394, 46575, 19, 1801, 11, 1961, 674, 22654, 198, 394, 46575, 19, 58422, 2710, 11, 1014, 674, 7885, 11766, 955, 198, 310, 2907, 310, 1661, 28, 6906, 5506, 14678, 11, 3586, 674, 4113, 10361, 2134, 1396, 198, 310, 12018, 28, 43776, 19, 840, 4193, 7062, 11, 1014, 674, 12569, 4445, 198, 310, 13608, 75, 28, 43776, 19, 870, 3696, 6171, 11, 7714, 674, 7757, 4342, 3160, 198, 310, 45069, 28, 43776, 19, 28302, 749, 69, 11, 7714, 674, 810, 12569, 5292, 198, 310, 30896, 28, 43776, 19, 19970, 11, 1961, 674, 2860, 3160, 11, 4342, 5764, 198, 310, 4342, 28, 3867, 1686, 24338, 85, 19, 68239, 17531, 705, 1881, 674, 7257, 96703, 955, 4342, 198, 310, 7885, 28, 3867, 1686, 24338, 85, 19, 68239, 17950, 477, 293, 6, 4670, 220, 674, 7257, 96703, 955, 7885, 198, 286, 1763, 286, 471, 3082, 11, 828, 198, 262, 471, 3641, 11, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 828, 369, 32660, 19, 312, 15343, 382, 14711, 6075, 512, 755, 46575, 19, 1311, 15343, 15396, 997, 262, 4304, 8238, 828, 369, 32660, 19, 312, 15343, 14781, 262, 422, 364, 59156, 19, 6, 304, 4124, 512, 286, 46575, 19, 284, 4124, 681, 59156, 19, 7352, 2801, 198, 286, 422, 46575, 19, 28302, 49478, 25, 996, 674, 13738, 539, 87195, 4124, 198, 310, 471, 3641, 11, 2290, 198, 286, 828, 284, 6587, 1021, 310, 6745, 307, 86368, 394, 46575, 19, 15023, 11, 9898, 674, 2592, 6933, 2686, 198, 394, 46575, 19, 57533, 11, 9898, 674, 9284, 6933, 2686, 198, 394, 46575, 19, 1801, 11, 1961, 674, 22654, 198, 394, 46575, 19, 58422, 2710, 11, 1014, 674, 7885, 11766, 955, 198, 310, 2907, 310, 1661, 28, 6906, 5506, 14678, 11, 3586, 674, 4113, 10361, 2134, 1396, 198, 310, 12018, 28, 43776, 19, 840, 4193, 7062, 11, 1014, 674, 12569, 4445, 198, 310, 13608, 75, 28, 43776, 19, 870, 3696, 6171, 11, 7714, 674, 7757, 4342, 3160, 198, 310, 45069, 28, 43776, 19, 28302, 749, 69, 11, 7714, 674, 810, 12569, 5292, 198, 310, 30896, 28, 43776, 19, 19970, 11, 1961, 674, 2860, 3160, 11, 4342, 5764, 198, 310, 4342, 28, 3867, 1686, 24338, 85, 19, 68239, 17531, 705, 1881, 674, 7257, 96703, 955, 4342, 198, 310, 7885, 28, 3867, 1686, 24338, 85, 19, 68239, 17950, 477, 293, 6, 4670, 220, 674, 7257, 96703, 955, 7885, 198, 286, 1763, 286, 471, 3082, 11, 828, 198, 262, 471, 3641, 11, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
totalgood/nlpia
src/nlpia/book/examples/ch04_sklearn_pca_source.py
_fit_full
def _fit_full(self=self, X=X, n_components=6): """Fit the model by computing full SVD on X""" n_samples, n_features = X.shape # Center data self.mean_ = np.mean(X, axis=0) print(self.mean_) X -= self.mean_ print(X.round(2)) U, S, V = linalg.svd(X, full_matrices=False) print(V.round(2)) # flip eigenvectors' sign to enforce deterministic output U, V = svd_flip(U, V) components_ = V print(components_.round(2)) # Get variance explained by singular values explained_variance_ = (S ** 2) / (n_samples - 1) total_var = explained_variance_.sum() explained_variance_ratio_ = explained_variance_ / total_var singular_values_ = S.copy() # Store the singular values. # Postprocess the number of components required if n_components == 'mle': n_components = \ _infer_dimension_(explained_variance_, n_samples, n_features) elif 0 < n_components < 1.0: # number of components for which the cumulated explained # variance percentage is superior to the desired threshold ratio_cumsum = stable_cumsum(explained_variance_ratio_) n_components = np.searchsorted(ratio_cumsum, n_components) + 1 # Compute noise covariance using Probabilistic PCA model # The sigma2 maximum likelihood (cf. eq. 12.46) if n_components < min(n_features, n_samples): self.noise_variance_ = explained_variance_[n_components:].mean() else: self.noise_variance_ = 0. self.n_samples_, self.n_features_ = n_samples, n_features self.components_ = components_[:n_components] print(self.components_.round(2)) self.n_components_ = n_components self.explained_variance_ = explained_variance_[:n_components] self.explained_variance_ratio_ = \ explained_variance_ratio_[:n_components] self.singular_values_ = singular_values_[:n_components] return U, S, V
python
def _fit_full(self=self, X=X, n_components=6): """Fit the model by computing full SVD on X""" n_samples, n_features = X.shape # Center data self.mean_ = np.mean(X, axis=0) print(self.mean_) X -= self.mean_ print(X.round(2)) U, S, V = linalg.svd(X, full_matrices=False) print(V.round(2)) # flip eigenvectors' sign to enforce deterministic output U, V = svd_flip(U, V) components_ = V print(components_.round(2)) # Get variance explained by singular values explained_variance_ = (S ** 2) / (n_samples - 1) total_var = explained_variance_.sum() explained_variance_ratio_ = explained_variance_ / total_var singular_values_ = S.copy() # Store the singular values. # Postprocess the number of components required if n_components == 'mle': n_components = \ _infer_dimension_(explained_variance_, n_samples, n_features) elif 0 < n_components < 1.0: # number of components for which the cumulated explained # variance percentage is superior to the desired threshold ratio_cumsum = stable_cumsum(explained_variance_ratio_) n_components = np.searchsorted(ratio_cumsum, n_components) + 1 # Compute noise covariance using Probabilistic PCA model # The sigma2 maximum likelihood (cf. eq. 12.46) if n_components < min(n_features, n_samples): self.noise_variance_ = explained_variance_[n_components:].mean() else: self.noise_variance_ = 0. self.n_samples_, self.n_features_ = n_samples, n_features self.components_ = components_[:n_components] print(self.components_.round(2)) self.n_components_ = n_components self.explained_variance_ = explained_variance_[:n_components] self.explained_variance_ratio_ = \ explained_variance_ratio_[:n_components] self.singular_values_ = singular_values_[:n_components] return U, S, V
[ "def", "_fit_full", "(", "self", "=", "self", ",", "X", "=", "X", ",", "n_components", "=", "6", ")", ":", "n_samples", ",", "n_features", "=", "X", ".", "shape", "# Center data", "self", ".", "mean_", "=", "np", ".", "mean", "(", "X", ",", "axis", "=", "0", ")", "print", "(", "self", ".", "mean_", ")", "X", "-=", "self", ".", "mean_", "print", "(", "X", ".", "round", "(", "2", ")", ")", "U", ",", "S", ",", "V", "=", "linalg", ".", "svd", "(", "X", ",", "full_matrices", "=", "False", ")", "print", "(", "V", ".", "round", "(", "2", ")", ")", "# flip eigenvectors' sign to enforce deterministic output", "U", ",", "V", "=", "svd_flip", "(", "U", ",", "V", ")", "components_", "=", "V", "print", "(", "components_", ".", "round", "(", "2", ")", ")", "# Get variance explained by singular values", "explained_variance_", "=", "(", "S", "**", "2", ")", "/", "(", "n_samples", "-", "1", ")", "total_var", "=", "explained_variance_", ".", "sum", "(", ")", "explained_variance_ratio_", "=", "explained_variance_", "/", "total_var", "singular_values_", "=", "S", ".", "copy", "(", ")", "# Store the singular values.", "# Postprocess the number of components required", "if", "n_components", "==", "'mle'", ":", "n_components", "=", "_infer_dimension_", "(", "explained_variance_", ",", "n_samples", ",", "n_features", ")", "elif", "0", "<", "n_components", "<", "1.0", ":", "# number of components for which the cumulated explained", "# variance percentage is superior to the desired threshold", "ratio_cumsum", "=", "stable_cumsum", "(", "explained_variance_ratio_", ")", "n_components", "=", "np", ".", "searchsorted", "(", "ratio_cumsum", ",", "n_components", ")", "+", "1", "# Compute noise covariance using Probabilistic PCA model", "# The sigma2 maximum likelihood (cf. eq. 12.46)", "if", "n_components", "<", "min", "(", "n_features", ",", "n_samples", ")", ":", "self", ".", "noise_variance_", "=", "explained_variance_", "[", "n_components", ":", "]", ".", "mean", "(", ")", "else", ":", "self", ".", "noise_variance_", "=", "0.", "self", ".", "n_samples_", ",", "self", ".", "n_features_", "=", "n_samples", ",", "n_features", "self", ".", "components_", "=", "components_", "[", ":", "n_components", "]", "print", "(", "self", ".", "components_", ".", "round", "(", "2", ")", ")", "self", ".", "n_components_", "=", "n_components", "self", ".", "explained_variance_", "=", "explained_variance_", "[", ":", "n_components", "]", "self", ".", "explained_variance_ratio_", "=", "explained_variance_ratio_", "[", ":", "n_components", "]", "self", ".", "singular_values_", "=", "singular_values_", "[", ":", "n_components", "]", "return", "U", ",", "S", ",", "V" ]
Fit the model by computing full SVD on X
[ "Fit", "the", "model", "by", "computing", "full", "SVD", "on", "X" ]
train
https://github.com/totalgood/nlpia/blob/efa01126275e9cd3c3a5151a644f1c798a9ec53f/src/nlpia/book/examples/ch04_sklearn_pca_source.py#L136-L186
<|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: Fit the model by computing full SVD on X ### Response: def _fit_full(self=self, X=X, n_components=6): """Fit the model by computing full SVD on X""" n_samples, n_features = X.shape # Center data self.mean_ = np.mean(X, axis=0) print(self.mean_) X -= self.mean_ print(X.round(2)) U, S, V = linalg.svd(X, full_matrices=False) print(V.round(2)) # flip eigenvectors' sign to enforce deterministic output U, V = svd_flip(U, V) components_ = V print(components_.round(2)) # Get variance explained by singular values explained_variance_ = (S ** 2) / (n_samples - 1) total_var = explained_variance_.sum() explained_variance_ratio_ = explained_variance_ / total_var singular_values_ = S.copy() # Store the singular values. # Postprocess the number of components required if n_components == 'mle': n_components = \ _infer_dimension_(explained_variance_, n_samples, n_features) elif 0 < n_components < 1.0: # number of components for which the cumulated explained # variance percentage is superior to the desired threshold ratio_cumsum = stable_cumsum(explained_variance_ratio_) n_components = np.searchsorted(ratio_cumsum, n_components) + 1 # Compute noise covariance using Probabilistic PCA model # The sigma2 maximum likelihood (cf. eq. 12.46) if n_components < min(n_features, n_samples): self.noise_variance_ = explained_variance_[n_components:].mean() else: self.noise_variance_ = 0. self.n_samples_, self.n_features_ = n_samples, n_features self.components_ = components_[:n_components] print(self.components_.round(2)) self.n_components_ = n_components self.explained_variance_ = explained_variance_[:n_components] self.explained_variance_ratio_ = \ explained_variance_ratio_[:n_components] self.singular_values_ = singular_values_[:n_components] return U, S, V <|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, 24231, 279, 1646, 555, 25213, 2539, 328, 12757, 389, 1630, 271, 14711, 6075, 512, 755, 721, 6410, 16776, 1214, 7822, 11, 1630, 62445, 11, 308, 24139, 28, 21, 997, 262, 4304, 24231, 279, 1646, 555, 25213, 2539, 328, 12757, 389, 1630, 7275, 262, 308, 18801, 11, 308, 15314, 284, 1630, 7201, 271, 262, 674, 5955, 828, 198, 262, 659, 19231, 62, 284, 2660, 19231, 7799, 11, 8183, 28, 15, 340, 262, 1194, 1214, 19231, 24262, 262, 1630, 6110, 659, 19231, 13220, 262, 1194, 7799, 17180, 7, 17, 4489, 262, 549, 11, 328, 11, 650, 284, 326, 34331, 516, 17008, 7799, 11, 2539, 96290, 5725, 340, 262, 1194, 12692, 17180, 7, 17, 1192, 262, 674, 18791, 35834, 3239, 10829, 6, 1879, 311, 29262, 73449, 2612, 198, 262, 549, 11, 650, 284, 13871, 67, 57112, 12597, 11, 650, 696, 262, 6956, 62, 284, 650, 198, 262, 1194, 100157, 5056, 1067, 7, 17, 4489, 262, 674, 2175, 33373, 11497, 555, 35044, 2819, 198, 262, 11497, 78550, 62, 284, 320, 50, 3146, 220, 17, 8, 611, 320, 77, 18801, 482, 220, 16, 340, 262, 2860, 4715, 284, 11497, 78550, 5056, 1264, 746, 262, 11497, 78550, 20512, 62, 284, 11497, 78550, 62, 611, 2860, 4715, 198, 262, 35044, 9324, 62, 284, 328, 12511, 368, 220, 674, 9307, 279, 35044, 2819, 382, 262, 674, 3962, 4734, 279, 1396, 315, 6956, 2631, 198, 262, 422, 308, 24139, 624, 364, 76, 273, 3730, 286, 308, 24139, 284, 3120, 310, 721, 90659, 50719, 8526, 81950, 78550, 7022, 308, 18801, 11, 308, 15314, 340, 262, 4508, 220, 15, 366, 308, 24139, 366, 220, 16, 13, 15, 512, 286, 674, 1396, 315, 6956, 369, 902, 279, 12454, 7913, 11497, 198, 286, 674, 33373, 11668, 374, 16757, 311, 279, 12974, 12447, 198, 286, 11595, 92428, 1264, 284, 15528, 92428, 1264, 5580, 501, 2692, 78550, 20512, 24262, 286, 308, 24139, 284, 2660, 9472, 29398, 2666, 6400, 92428, 1264, 11, 308, 24139, 8, 489, 220, 16, 271, 262, 674, 23426, 12248, 60408, 1701, 26709, 13052, 4633, 62029, 1646, 198, 262, 674, 578, 20868, 17, 7340, 29736, 320, 9991, 13, 9116, 13, 220, 717, 13, 2790, 340, 262, 422, 308, 24139, 366, 1332, 1471, 15314, 11, 308, 18801, 997, 286, 659, 18847, 1082, 78550, 62, 284, 11497, 78550, 12147, 77, 24139, 73659, 14622, 746, 262, 775, 512, 286, 659, 18847, 1082, 78550, 62, 284, 220, 15, 382, 262, 659, 1276, 18801, 7022, 659, 1276, 15314, 62, 284, 308, 18801, 11, 308, 15314, 198, 262, 659, 20641, 62, 284, 6956, 62, 3530, 77, 24139, 933, 262, 1194, 1214, 20641, 5056, 1067, 7, 17, 1192, 262, 659, 1276, 24139, 62, 284, 308, 24139, 198, 262, 659, 2272, 501, 2692, 78550, 62, 284, 11497, 78550, 62, 3530, 77, 24139, 933, 262, 659, 2272, 501, 2692, 78550, 20512, 62, 284, 3120, 286, 11497, 78550, 20512, 62, 3530, 77, 24139, 933, 262, 659 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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 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, 24231, 279, 1646, 555, 25213, 2539, 328, 12757, 389, 1630, 271, 14711, 6075, 512, 755, 721, 6410, 16776, 1214, 7822, 11, 1630, 62445, 11, 308, 24139, 28, 21, 997, 262, 4304, 24231, 279, 1646, 555, 25213, 2539, 328, 12757, 389, 1630, 7275, 262, 308, 18801, 11, 308, 15314, 284, 1630, 7201, 271, 262, 674, 5955, 828, 198, 262, 659, 19231, 62, 284, 2660, 19231, 7799, 11, 8183, 28, 15, 340, 262, 1194, 1214, 19231, 24262, 262, 1630, 6110, 659, 19231, 13220, 262, 1194, 7799, 17180, 7, 17, 4489, 262, 549, 11, 328, 11, 650, 284, 326, 34331, 516, 17008, 7799, 11, 2539, 96290, 5725, 340, 262, 1194, 12692, 17180, 7, 17, 1192, 262, 674, 18791, 35834, 3239, 10829, 6, 1879, 311, 29262, 73449, 2612, 198, 262, 549, 11, 650, 284, 13871, 67, 57112, 12597, 11, 650, 696, 262, 6956, 62, 284, 650, 198, 262, 1194, 100157, 5056, 1067, 7, 17, 4489, 262, 674, 2175, 33373, 11497, 555, 35044, 2819, 198, 262, 11497, 78550, 62, 284, 320, 50, 3146, 220, 17, 8, 611, 320, 77, 18801, 482, 220, 16, 340, 262, 2860, 4715, 284, 11497, 78550, 5056, 1264, 746, 262, 11497, 78550, 20512, 62, 284, 11497, 78550, 62, 611, 2860, 4715, 198, 262, 35044, 9324, 62, 284, 328, 12511, 368, 220, 674, 9307, 279, 35044, 2819, 382, 262, 674, 3962, 4734, 279, 1396, 315, 6956, 2631, 198, 262, 422, 308, 24139, 624, 364, 76, 273, 3730, 286, 308, 24139, 284, 3120, 310, 721, 90659, 50719, 8526, 81950, 78550, 7022, 308, 18801, 11, 308, 15314, 340, 262, 4508, 220, 15, 366, 308, 24139, 366, 220, 16, 13, 15, 512, 286, 674, 1396, 315, 6956, 369, 902, 279, 12454, 7913, 11497, 198, 286, 674, 33373, 11668, 374, 16757, 311, 279, 12974, 12447, 198, 286, 11595, 92428, 1264, 284, 15528, 92428, 1264, 5580, 501, 2692, 78550, 20512, 24262, 286, 308, 24139, 284, 2660, 9472, 29398, 2666, 6400, 92428, 1264, 11, 308, 24139, 8, 489, 220, 16, 271, 262, 674, 23426, 12248, 60408, 1701, 26709, 13052, 4633, 62029, 1646, 198, 262, 674, 578, 20868, 17, 7340, 29736, 320, 9991, 13, 9116, 13, 220, 717, 13, 2790, 340, 262, 422, 308, 24139, 366, 1332, 1471, 15314, 11, 308, 18801, 997, 286, 659, 18847, 1082, 78550, 62, 284, 11497, 78550, 12147, 77, 24139, 73659, 14622, 746, 262, 775, 512, 286, 659, 18847, 1082, 78550, 62, 284, 220, 15, 382, 262, 659, 1276, 18801, 7022, 659, 1276, 15314, 62, 284, 308, 18801, 11, 308, 15314, 198, 262, 659, 20641, 62, 284, 6956, 62, 3530, 77, 24139, 933, 262, 1194, 1214, 20641, 5056, 1067, 7, 17, 1192, 262, 659, 1276, 24139, 62, 284, 308, 24139, 198, 262, 659, 2272, 501, 2692, 78550, 62, 284, 11497, 78550, 62, 3530, 77, 24139, 933, 262, 659, 2272, 501, 2692, 78550, 20512, 62, 284, 3120, 286, 11497, 78550, 20512, 62, 3530, 77, 24139, 933, 262, 659 ]
pypa/setuptools
setuptools/command/easy_install.py
ScriptWriter.best
def best(cls): """ Select the best ScriptWriter for this environment. """ if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'): return WindowsScriptWriter.best() else: return cls
python
def best(cls): """ Select the best ScriptWriter for this environment. """ if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'): return WindowsScriptWriter.best() else: return cls
[ "def", "best", "(", "cls", ")", ":", "if", "sys", ".", "platform", "==", "'win32'", "or", "(", "os", ".", "name", "==", "'java'", "and", "os", ".", "_name", "==", "'nt'", ")", ":", "return", "WindowsScriptWriter", ".", "best", "(", ")", "else", ":", "return", "cls" ]
Select the best ScriptWriter for this environment.
[ "Select", "the", "best", "ScriptWriter", "for", "this", "environment", "." ]
train
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2130-L2137
<|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: Select the best ScriptWriter for this environment. ### Response: def best(cls): """ Select the best ScriptWriter for this environment. """ if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'): return WindowsScriptWriter.best() else: return cls <|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, 3461, 279, 1888, 14025, 6628, 369, 420, 4676, 382, 14711, 6075, 512, 755, 1888, 21024, 997, 286, 3270, 286, 8593, 279, 1888, 14025, 6628, 369, 420, 4676, 627, 286, 3270, 286, 422, 5826, 25723, 624, 364, 7678, 843, 6, 477, 320, 437, 2710, 624, 364, 10248, 6, 323, 2709, 1462, 609, 624, 364, 406, 11290, 310, 471, 5632, 6035, 6628, 52376, 746, 286, 775, 512, 310, 471, 13082, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 3461, 279, 1888, 14025, 6628, 369, 420, 4676, 382, 14711, 6075, 512, 755, 1888, 21024, 997, 286, 3270, 286, 8593, 279, 1888, 14025, 6628, 369, 420, 4676, 627, 286, 3270, 286, 422, 5826, 25723, 624, 364, 7678, 843, 6, 477, 320, 437, 2710, 624, 364, 10248, 6, 323, 2709, 1462, 609, 624, 364, 406, 11290, 310, 471, 5632, 6035, 6628, 52376, 746, 286, 775, 512, 310, 471, 13082, 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 ]
fridiculous/django-estimators
estimators/models/base.py
HashableFileQuerySet.filter
def filter(self, *args, **kwargs): """filter lets django managers use `objects.filter` on a hashable object.""" obj = kwargs.pop(self.object_property_name, None) if obj is not None: kwargs['object_hash'] = self.model._compute_hash(obj) return super().filter(*args, **kwargs)
python
def filter(self, *args, **kwargs): """filter lets django managers use `objects.filter` on a hashable object.""" obj = kwargs.pop(self.object_property_name, None) if obj is not None: kwargs['object_hash'] = self.model._compute_hash(obj) return super().filter(*args, **kwargs)
[ "def", "filter", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "kwargs", ".", "pop", "(", "self", ".", "object_property_name", ",", "None", ")", "if", "obj", "is", "not", "None", ":", "kwargs", "[", "'object_hash'", "]", "=", "self", ".", "model", ".", "_compute_hash", "(", "obj", ")", "return", "super", "(", ")", ".", "filter", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
filter lets django managers use `objects.filter` on a hashable object.
[ "filter", "lets", "django", "managers", "use", "objects", ".", "filter", "on", "a", "hashable", "object", "." ]
train
https://github.com/fridiculous/django-estimators/blob/5dd72694dab6725335214543a59104c4de504037/estimators/models/base.py#L23-L28
<|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: filter lets django managers use `objects.filter` on a hashable object. ### Response: def filter(self, *args, **kwargs): """filter lets django managers use `objects.filter` on a hashable object.""" obj = kwargs.pop(self.object_property_name, None) if obj is not None: kwargs['object_hash'] = self.model._compute_hash(obj) return super().filter(*args, **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, 5428, 15714, 8426, 20258, 1005, 1595, 19761, 7081, 63, 389, 264, 5286, 481, 1665, 382, 14711, 6075, 512, 755, 4141, 1214, 11, 353, 2164, 11, 3146, 9872, 997, 286, 4304, 5428, 15714, 8426, 20258, 1005, 1595, 19761, 7081, 63, 389, 264, 5286, 481, 1665, 14781, 286, 2909, 284, 16901, 8452, 1214, 6163, 17050, 1292, 11, 2290, 340, 286, 422, 2909, 374, 539, 2290, 512, 310, 16901, 681, 1735, 9127, 663, 284, 659, 3272, 1462, 28806, 9127, 6922, 340, 286, 471, 2307, 1020, 5428, 4163, 2164, 11, 3146, 9872, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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,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, 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, 5428, 15714, 8426, 20258, 1005, 1595, 19761, 7081, 63, 389, 264, 5286, 481, 1665, 382, 14711, 6075, 512, 755, 4141, 1214, 11, 353, 2164, 11, 3146, 9872, 997, 286, 4304, 5428, 15714, 8426, 20258, 1005, 1595, 19761, 7081, 63, 389, 264, 5286, 481, 1665, 14781, 286, 2909, 284, 16901, 8452, 1214, 6163, 17050, 1292, 11, 2290, 340, 286, 422, 2909, 374, 539, 2290, 512, 310, 16901, 681, 1735, 9127, 663, 284, 659, 3272, 1462, 28806, 9127, 6922, 340, 286, 471, 2307, 1020, 5428, 4163, 2164, 11, 3146, 9872, 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 ]
rootpy/rootpy
rootpy/io/pickler.py
load
def load(root_file, use_proxy=True, key=None): """Load an object from a ROOT TFile. `root_file` may be an open ROOT file or directory, or a string path to an existing ROOT file. """ if isinstance(root_file, string_types): root_file = root_open(root_file) own_file = True else: own_file = False obj = Unpickler(root_file, use_proxy).load(key) if own_file: root_file.Close() return obj
python
def load(root_file, use_proxy=True, key=None): """Load an object from a ROOT TFile. `root_file` may be an open ROOT file or directory, or a string path to an existing ROOT file. """ if isinstance(root_file, string_types): root_file = root_open(root_file) own_file = True else: own_file = False obj = Unpickler(root_file, use_proxy).load(key) if own_file: root_file.Close() return obj
[ "def", "load", "(", "root_file", ",", "use_proxy", "=", "True", ",", "key", "=", "None", ")", ":", "if", "isinstance", "(", "root_file", ",", "string_types", ")", ":", "root_file", "=", "root_open", "(", "root_file", ")", "own_file", "=", "True", "else", ":", "own_file", "=", "False", "obj", "=", "Unpickler", "(", "root_file", ",", "use_proxy", ")", ".", "load", "(", "key", ")", "if", "own_file", ":", "root_file", ".", "Close", "(", ")", "return", "obj" ]
Load an object from a ROOT TFile. `root_file` may be an open ROOT file or directory, or a string path to an existing ROOT file.
[ "Load", "an", "object", "from", "a", "ROOT", "TFile", "." ]
train
https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/io/pickler.py#L361-L375
<|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 an object from a ROOT TFile. `root_file` may be an open ROOT file or directory, or a string path to an existing ROOT file. ### Response: def load(root_file, use_proxy=True, key=None): """Load an object from a ROOT TFile. `root_file` may be an open ROOT file or directory, or a string path to an existing ROOT file. """ if isinstance(root_file, string_types): root_file = root_open(root_file) own_file = True else: own_file = False obj = Unpickler(root_file, use_proxy).load(key) if own_file: root_file.Close() return 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, 6003, 459, 1665, 505, 264, 36836, 350, 1738, 382, 262, 1595, 2959, 2517, 63, 1253, 387, 459, 1825, 36836, 1052, 477, 6352, 11, 477, 264, 925, 1853, 311, 459, 198, 262, 6484, 36836, 1052, 382, 14711, 6075, 512, 755, 2865, 9387, 2517, 11, 1005, 30812, 3702, 11, 1401, 5980, 997, 262, 4304, 6003, 459, 1665, 505, 264, 36836, 350, 1738, 382, 262, 1595, 2959, 2517, 63, 1253, 387, 459, 1825, 36836, 1052, 477, 6352, 11, 477, 264, 925, 1853, 311, 459, 198, 262, 6484, 36836, 1052, 627, 262, 3270, 262, 422, 11656, 9387, 2517, 11, 925, 9962, 997, 286, 3789, 2517, 284, 3789, 11563, 9387, 2517, 340, 286, 1866, 2517, 284, 3082, 198, 262, 775, 512, 286, 1866, 2517, 284, 3641, 198, 262, 2909, 284, 1252, 30345, 1565, 9387, 2517, 11, 1005, 30812, 570, 1096, 4962, 340, 262, 422, 1866, 2517, 512, 286, 3789, 2517, 10638, 746, 262, 471, 2909, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 6003, 459, 1665, 505, 264, 36836, 350, 1738, 382, 262, 1595, 2959, 2517, 63, 1253, 387, 459, 1825, 36836, 1052, 477, 6352, 11, 477, 264, 925, 1853, 311, 459, 198, 262, 6484, 36836, 1052, 382, 14711, 6075, 512, 755, 2865, 9387, 2517, 11, 1005, 30812, 3702, 11, 1401, 5980, 997, 262, 4304, 6003, 459, 1665, 505, 264, 36836, 350, 1738, 382, 262, 1595, 2959, 2517, 63, 1253, 387, 459, 1825, 36836, 1052, 477, 6352, 11, 477, 264, 925, 1853, 311, 459, 198, 262, 6484, 36836, 1052, 627, 262, 3270, 262, 422, 11656, 9387, 2517, 11, 925, 9962, 997, 286, 3789, 2517, 284, 3789, 11563, 9387, 2517, 340, 286, 1866, 2517, 284, 3082, 198, 262, 775, 512, 286, 1866, 2517, 284, 3641, 198, 262, 2909, 284, 1252, 30345, 1565, 9387, 2517, 11, 1005, 30812, 570, 1096, 4962, 340, 262, 422, 1866, 2517, 512, 286, 3789, 2517, 10638, 746, 262, 471, 2909, 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 ]
PierreRust/apigpio
apigpio/apigpio.py
Pi.read
def read(self, gpio): """ Returns the GPIO level. gpio:= 0-53. ... yield from pi.set_mode(23, pigpio.INPUT) yield from pi.set_pull_up_down(23, pigpio.PUD_DOWN) print(yield from pi.read(23)) 0 yield from pi.set_pull_up_down(23, pigpio.PUD_UP) print(yield from pi.read(23)) 1 ... """ res = yield from self._pigpio_aio_command(_PI_CMD_READ, gpio, 0) return _u2i(res)
python
def read(self, gpio): """ Returns the GPIO level. gpio:= 0-53. ... yield from pi.set_mode(23, pigpio.INPUT) yield from pi.set_pull_up_down(23, pigpio.PUD_DOWN) print(yield from pi.read(23)) 0 yield from pi.set_pull_up_down(23, pigpio.PUD_UP) print(yield from pi.read(23)) 1 ... """ res = yield from self._pigpio_aio_command(_PI_CMD_READ, gpio, 0) return _u2i(res)
[ "def", "read", "(", "self", ",", "gpio", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_READ", ",", "gpio", ",", "0", ")", "return", "_u2i", "(", "res", ")" ]
Returns the GPIO level. gpio:= 0-53. ... yield from pi.set_mode(23, pigpio.INPUT) yield from pi.set_pull_up_down(23, pigpio.PUD_DOWN) print(yield from pi.read(23)) 0 yield from pi.set_pull_up_down(23, pigpio.PUD_UP) print(yield from pi.read(23)) 1 ...
[ "Returns", "the", "GPIO", "level", ".", "gpio", ":", "=", "0", "-", "53", ".", "...", "yield", "from", "pi", ".", "set_mode", "(", "23", "pigpio", ".", "INPUT", ")", "yield", "from", "pi", ".", "set_pull_up_down", "(", "23", "pigpio", ".", "PUD_DOWN", ")", "print", "(", "yield", "from", "pi", ".", "read", "(", "23", "))", "0", "yield", "from", "pi", ".", "set_pull_up_down", "(", "23", "pigpio", ".", "PUD_UP", ")", "print", "(", "yield", "from", "pi", ".", "read", "(", "23", "))", "1", "..." ]
train
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L871-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: Returns the GPIO level. gpio:= 0-53. ... yield from pi.set_mode(23, pigpio.INPUT) yield from pi.set_pull_up_down(23, pigpio.PUD_DOWN) print(yield from pi.read(23)) 0 yield from pi.set_pull_up_down(23, pigpio.PUD_UP) print(yield from pi.read(23)) 1 ... ### Response: def read(self, gpio): """ Returns the GPIO level. gpio:= 0-53. ... yield from pi.set_mode(23, pigpio.INPUT) yield from pi.set_pull_up_down(23, pigpio.PUD_DOWN) print(yield from pi.read(23)) 0 yield from pi.set_pull_up_down(23, pigpio.PUD_UP) print(yield from pi.read(23)) 1 ... """ res = yield from self._pigpio_aio_command(_PI_CMD_READ, gpio, 0) return _u2i(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, 16851, 279, 10933, 2237, 627, 286, 32722, 14543, 220, 15, 12, 4331, 627, 286, 12515, 286, 7692, 505, 9115, 995, 7450, 7, 1419, 11, 24623, 12183, 82914, 340, 286, 7692, 505, 9115, 995, 66793, 8401, 14325, 7, 1419, 11, 24623, 12183, 1087, 4760, 21842, 340, 286, 1194, 7166, 823, 505, 9115, 4217, 7, 1419, 1192, 286, 220, 15, 198, 286, 7692, 505, 9115, 995, 66793, 8401, 14325, 7, 1419, 11, 24623, 12183, 1087, 4760, 14384, 340, 286, 1194, 7166, 823, 505, 9115, 4217, 7, 1419, 1192, 286, 220, 16, 198, 286, 5585, 14711, 6075, 512, 755, 1373, 1214, 11, 32722, 997, 286, 3270, 286, 5295, 279, 10933, 2237, 627, 286, 32722, 14543, 220, 15, 12, 4331, 627, 286, 12515, 286, 7692, 505, 9115, 995, 7450, 7, 1419, 11, 24623, 12183, 82914, 340, 286, 7692, 505, 9115, 995, 66793, 8401, 14325, 7, 1419, 11, 24623, 12183, 1087, 4760, 21842, 340, 286, 1194, 7166, 823, 505, 9115, 4217, 7, 1419, 1192, 286, 220, 15, 198, 286, 7692, 505, 9115, 995, 66793, 8401, 14325, 7, 1419, 11, 24623, 12183, 1087, 4760, 14384, 340, 286, 1194, 7166, 823, 505, 9115, 4217, 7, 1419, 1192, 286, 220, 16, 198, 286, 12515, 286, 3270, 286, 594, 284, 7692, 505, 659, 1462, 90600, 12183, 4404, 822, 11045, 2551, 1932, 16748, 13418, 11, 32722, 11, 220, 15, 340, 286, 471, 721, 84, 17, 72, 4693, 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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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, 10933, 2237, 627, 286, 32722, 14543, 220, 15, 12, 4331, 627, 286, 12515, 286, 7692, 505, 9115, 995, 7450, 7, 1419, 11, 24623, 12183, 82914, 340, 286, 7692, 505, 9115, 995, 66793, 8401, 14325, 7, 1419, 11, 24623, 12183, 1087, 4760, 21842, 340, 286, 1194, 7166, 823, 505, 9115, 4217, 7, 1419, 1192, 286, 220, 15, 198, 286, 7692, 505, 9115, 995, 66793, 8401, 14325, 7, 1419, 11, 24623, 12183, 1087, 4760, 14384, 340, 286, 1194, 7166, 823, 505, 9115, 4217, 7, 1419, 1192, 286, 220, 16, 198, 286, 5585, 14711, 6075, 512, 755, 1373, 1214, 11, 32722, 997, 286, 3270, 286, 5295, 279, 10933, 2237, 627, 286, 32722, 14543, 220, 15, 12, 4331, 627, 286, 12515, 286, 7692, 505, 9115, 995, 7450, 7, 1419, 11, 24623, 12183, 82914, 340, 286, 7692, 505, 9115, 995, 66793, 8401, 14325, 7, 1419, 11, 24623, 12183, 1087, 4760, 21842, 340, 286, 1194, 7166, 823, 505, 9115, 4217, 7, 1419, 1192, 286, 220, 15, 198, 286, 7692, 505, 9115, 995, 66793, 8401, 14325, 7, 1419, 11, 24623, 12183, 1087, 4760, 14384, 340, 286, 1194, 7166, 823, 505, 9115, 4217, 7, 1419, 1192, 286, 220, 16, 198, 286, 12515, 286, 3270, 286, 594, 284, 7692, 505, 659, 1462, 90600, 12183, 4404, 822, 11045, 2551, 1932, 16748, 13418, 11, 32722, 11, 220, 15, 340, 286, 471, 721, 84, 17, 72, 4693, 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 ]
tensorflow/tensorboard
tensorboard/plugins/scalar/scalars_demo.py
run_all
def run_all(logdir, verbose=False): """Run simulations on a reasonable set of parameters. Arguments: logdir: the directory into which to store all the runs' data verbose: if true, print out each run's name as it begins """ for initial_temperature in [270.0, 310.0, 350.0]: for final_temperature in [270.0, 310.0, 350.0]: for heat_coefficient in [0.001, 0.005]: run_name = 'temperature:t0=%g,tA=%g,kH=%g' % ( initial_temperature, final_temperature, heat_coefficient) if verbose: print('--- Running: %s' % run_name) run(logdir, run_name, initial_temperature, final_temperature, heat_coefficient)
python
def run_all(logdir, verbose=False): """Run simulations on a reasonable set of parameters. Arguments: logdir: the directory into which to store all the runs' data verbose: if true, print out each run's name as it begins """ for initial_temperature in [270.0, 310.0, 350.0]: for final_temperature in [270.0, 310.0, 350.0]: for heat_coefficient in [0.001, 0.005]: run_name = 'temperature:t0=%g,tA=%g,kH=%g' % ( initial_temperature, final_temperature, heat_coefficient) if verbose: print('--- Running: %s' % run_name) run(logdir, run_name, initial_temperature, final_temperature, heat_coefficient)
[ "def", "run_all", "(", "logdir", ",", "verbose", "=", "False", ")", ":", "for", "initial_temperature", "in", "[", "270.0", ",", "310.0", ",", "350.0", "]", ":", "for", "final_temperature", "in", "[", "270.0", ",", "310.0", ",", "350.0", "]", ":", "for", "heat_coefficient", "in", "[", "0.001", ",", "0.005", "]", ":", "run_name", "=", "'temperature:t0=%g,tA=%g,kH=%g'", "%", "(", "initial_temperature", ",", "final_temperature", ",", "heat_coefficient", ")", "if", "verbose", ":", "print", "(", "'--- Running: %s'", "%", "run_name", ")", "run", "(", "logdir", ",", "run_name", ",", "initial_temperature", ",", "final_temperature", ",", "heat_coefficient", ")" ]
Run simulations on a reasonable set of parameters. Arguments: logdir: the directory into which to store all the runs' data verbose: if true, print out each run's name as it begins
[ "Run", "simulations", "on", "a", "reasonable", "set", "of", "parameters", "." ]
train
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/scalar/scalars_demo.py#L119-L134
<|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: Run simulations on a reasonable set of parameters. Arguments: logdir: the directory into which to store all the runs' data verbose: if true, print out each run's name as it begins ### Response: def run_all(logdir, verbose=False): """Run simulations on a reasonable set of parameters. Arguments: logdir: the directory into which to store all the runs' data verbose: if true, print out each run's name as it begins """ for initial_temperature in [270.0, 310.0, 350.0]: for final_temperature in [270.0, 310.0, 350.0]: for heat_coefficient in [0.001, 0.005]: run_name = 'temperature:t0=%g,tA=%g,kH=%g' % ( initial_temperature, final_temperature, heat_coefficient) if verbose: print('--- Running: %s' % run_name) run(logdir, run_name, initial_temperature, final_temperature, heat_coefficient) <|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, 6869, 47590, 389, 264, 13579, 743, 315, 5137, 382, 220, 28802, 512, 262, 1515, 3826, 25, 279, 6352, 1139, 902, 311, 3637, 682, 279, 8640, 6, 828, 198, 262, 14008, 25, 422, 837, 11, 1194, 704, 1855, 1629, 596, 836, 439, 433, 12302, 271, 14711, 6075, 512, 755, 1629, 5823, 12814, 3826, 11, 14008, 5725, 997, 220, 4304, 6869, 47590, 389, 264, 13579, 743, 315, 5137, 382, 220, 28802, 512, 262, 1515, 3826, 25, 279, 6352, 1139, 902, 311, 3637, 682, 279, 8640, 6, 828, 198, 262, 14008, 25, 422, 837, 11, 1194, 704, 1855, 1629, 596, 836, 439, 433, 12302, 198, 220, 3270, 220, 369, 2926, 54625, 304, 510, 10914, 13, 15, 11, 220, 12226, 13, 15, 11, 220, 8652, 13, 15, 10556, 262, 369, 1620, 54625, 304, 510, 10914, 13, 15, 11, 220, 12226, 13, 15, 11, 220, 8652, 13, 15, 10556, 415, 369, 8798, 33090, 5499, 304, 510, 15, 13, 4119, 11, 220, 15, 13, 8504, 10556, 286, 1629, 1292, 284, 364, 35658, 61877, 15, 8003, 70, 14287, 32, 8003, 70, 16539, 39, 8003, 70, 6, 1034, 2456, 310, 2926, 54625, 11, 1620, 54625, 11, 8798, 33090, 5499, 340, 286, 422, 14008, 512, 692, 1194, 493, 4521, 29125, 25, 1034, 82, 6, 1034, 1629, 1292, 340, 286, 1629, 12814, 3826, 11, 1629, 1292, 345, 310, 2926, 54625, 11, 1620, 54625, 11, 8798, 33090, 5499, 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,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 6869, 47590, 389, 264, 13579, 743, 315, 5137, 382, 220, 28802, 512, 262, 1515, 3826, 25, 279, 6352, 1139, 902, 311, 3637, 682, 279, 8640, 6, 828, 198, 262, 14008, 25, 422, 837, 11, 1194, 704, 1855, 1629, 596, 836, 439, 433, 12302, 271, 14711, 6075, 512, 755, 1629, 5823, 12814, 3826, 11, 14008, 5725, 997, 220, 4304, 6869, 47590, 389, 264, 13579, 743, 315, 5137, 382, 220, 28802, 512, 262, 1515, 3826, 25, 279, 6352, 1139, 902, 311, 3637, 682, 279, 8640, 6, 828, 198, 262, 14008, 25, 422, 837, 11, 1194, 704, 1855, 1629, 596, 836, 439, 433, 12302, 198, 220, 3270, 220, 369, 2926, 54625, 304, 510, 10914, 13, 15, 11, 220, 12226, 13, 15, 11, 220, 8652, 13, 15, 10556, 262, 369, 1620, 54625, 304, 510, 10914, 13, 15, 11, 220, 12226, 13, 15, 11, 220, 8652, 13, 15, 10556, 415, 369, 8798, 33090, 5499, 304, 510, 15, 13, 4119, 11, 220, 15, 13, 8504, 10556, 286, 1629, 1292, 284, 364, 35658, 61877, 15, 8003, 70, 14287, 32, 8003, 70, 16539, 39, 8003, 70, 6, 1034, 2456, 310, 2926, 54625, 11, 1620, 54625, 11, 8798, 33090, 5499, 340, 286, 422, 14008, 512, 692, 1194, 493, 4521, 29125, 25, 1034, 82, 6, 1034, 1629, 1292, 340, 286, 1629, 12814, 3826, 11, 1629, 1292, 345, 310, 2926, 54625, 11, 1620, 54625, 11, 8798, 33090, 5499, 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 ]
empymod/empymod
empymod/kernel.py
wavenumber
def wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval): r"""Calculate wavenumber domain solution. Return the wavenumber domain solutions ``PJ0``, ``PJ1``, and ``PJ0b``, which have to be transformed with a Hankel transform to the frequency domain. ``PJ0``/``PJ0b`` and ``PJ1`` have to be transformed with Bessel functions of order 0 (:math:`J_0`) and 1 (:math:`J_1`), respectively. This function corresponds loosely to equations 105--107, 111--116, 119--121, and 123--128 in [HuTS15]_, and equally loosely to the file ``kxwmod.c``. [HuTS15]_ uses Bessel functions of orders 0, 1, and 2 (:math:`J_0, J_1, J_2`). The implementations of the *Fast Hankel Transform* and the *Quadrature-with-Extrapolation* in ``transform`` are set-up with Bessel functions of order 0 and 1 only. This is achieved by applying the recurrence formula .. math:: J_2(kr) = \frac{2}{kr} J_1(kr) - J_0(kr) \ . .. note:: ``PJ0`` and ``PJ0b`` could theoretically be added here into one, and then be transformed in one go. However, ``PJ0b`` has to be multiplied by ``factAng`` later. This has to be done after the Hankel transform for methods which make use of spline interpolation, in order to work for offsets that are not in line with each other. This function is called from one of the Hankel functions in :mod:`transform`. Consult the modelling routines in :mod:`model` for a description of the input and output parameters. If you are solely interested in the wavenumber-domain solution you can call this function directly. However, you have to make sure all input arguments are correct, as no checks are carried out here. """ # ** CALCULATE GREEN'S FUNCTIONS # Shape of PTM, PTE: (nfreq, noffs, nfilt) PTM, PTE = greenfct(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval) # ** AB-SPECIFIC COLLECTION OF PJ0, PJ1, AND PJ0b # Pre-allocate output PJ0 = None PJ1 = None PJ0b = None # Calculate Ptot which is used in all cases Ptot = (PTM + PTE)/(4*np.pi) # If rec is magnetic switch sign (reciprocity MM/ME => EE/EM). if mrec: sign = -1 else: sign = 1 # Group into PJ0 and PJ1 for J0/J1 Hankel Transform if ab in [11, 12, 21, 22, 14, 24, 15, 25]: # Eqs 105, 106, 111, 112, # J2(kr) = 2/(kr)*J1(kr) - J0(kr) # 119, 120, 123, 124 if ab in [14, 22]: sign *= -1 PJ0b = sign/2*Ptot*lambd PJ1 = -sign*Ptot if ab in [11, 22, 24, 15]: if ab in [22, 24]: sign *= -1 PJ0 = sign*(PTM - PTE)/(8*np.pi)*lambd elif ab in [13, 23, 31, 32, 34, 35, 16, 26]: # Eqs 107, 113, 114, 115, PJ1 = sign*Ptot*lambd*lambd # . 121, 125, 126, 127 if ab in [34, 26]: PJ1 *= -1 elif ab in [33, ]: # Eq 116 PJ0 = sign*Ptot*lambd*lambd*lambd # Return PJ0, PJ1, PJ0b return PJ0, PJ1, PJ0b
python
def wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval): r"""Calculate wavenumber domain solution. Return the wavenumber domain solutions ``PJ0``, ``PJ1``, and ``PJ0b``, which have to be transformed with a Hankel transform to the frequency domain. ``PJ0``/``PJ0b`` and ``PJ1`` have to be transformed with Bessel functions of order 0 (:math:`J_0`) and 1 (:math:`J_1`), respectively. This function corresponds loosely to equations 105--107, 111--116, 119--121, and 123--128 in [HuTS15]_, and equally loosely to the file ``kxwmod.c``. [HuTS15]_ uses Bessel functions of orders 0, 1, and 2 (:math:`J_0, J_1, J_2`). The implementations of the *Fast Hankel Transform* and the *Quadrature-with-Extrapolation* in ``transform`` are set-up with Bessel functions of order 0 and 1 only. This is achieved by applying the recurrence formula .. math:: J_2(kr) = \frac{2}{kr} J_1(kr) - J_0(kr) \ . .. note:: ``PJ0`` and ``PJ0b`` could theoretically be added here into one, and then be transformed in one go. However, ``PJ0b`` has to be multiplied by ``factAng`` later. This has to be done after the Hankel transform for methods which make use of spline interpolation, in order to work for offsets that are not in line with each other. This function is called from one of the Hankel functions in :mod:`transform`. Consult the modelling routines in :mod:`model` for a description of the input and output parameters. If you are solely interested in the wavenumber-domain solution you can call this function directly. However, you have to make sure all input arguments are correct, as no checks are carried out here. """ # ** CALCULATE GREEN'S FUNCTIONS # Shape of PTM, PTE: (nfreq, noffs, nfilt) PTM, PTE = greenfct(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval) # ** AB-SPECIFIC COLLECTION OF PJ0, PJ1, AND PJ0b # Pre-allocate output PJ0 = None PJ1 = None PJ0b = None # Calculate Ptot which is used in all cases Ptot = (PTM + PTE)/(4*np.pi) # If rec is magnetic switch sign (reciprocity MM/ME => EE/EM). if mrec: sign = -1 else: sign = 1 # Group into PJ0 and PJ1 for J0/J1 Hankel Transform if ab in [11, 12, 21, 22, 14, 24, 15, 25]: # Eqs 105, 106, 111, 112, # J2(kr) = 2/(kr)*J1(kr) - J0(kr) # 119, 120, 123, 124 if ab in [14, 22]: sign *= -1 PJ0b = sign/2*Ptot*lambd PJ1 = -sign*Ptot if ab in [11, 22, 24, 15]: if ab in [22, 24]: sign *= -1 PJ0 = sign*(PTM - PTE)/(8*np.pi)*lambd elif ab in [13, 23, 31, 32, 34, 35, 16, 26]: # Eqs 107, 113, 114, 115, PJ1 = sign*Ptot*lambd*lambd # . 121, 125, 126, 127 if ab in [34, 26]: PJ1 *= -1 elif ab in [33, ]: # Eq 116 PJ0 = sign*Ptot*lambd*lambd*lambd # Return PJ0, PJ1, PJ0b return PJ0, PJ1, PJ0b
[ "def", "wavenumber", "(", "zsrc", ",", "zrec", ",", "lsrc", ",", "lrec", ",", "depth", ",", "etaH", ",", "etaV", ",", "zetaH", ",", "zetaV", ",", "lambd", ",", "ab", ",", "xdirect", ",", "msrc", ",", "mrec", ",", "use_ne_eval", ")", ":", "# ** CALCULATE GREEN'S FUNCTIONS", "# Shape of PTM, PTE: (nfreq, noffs, nfilt)", "PTM", ",", "PTE", "=", "greenfct", "(", "zsrc", ",", "zrec", ",", "lsrc", ",", "lrec", ",", "depth", ",", "etaH", ",", "etaV", ",", "zetaH", ",", "zetaV", ",", "lambd", ",", "ab", ",", "xdirect", ",", "msrc", ",", "mrec", ",", "use_ne_eval", ")", "# ** AB-SPECIFIC COLLECTION OF PJ0, PJ1, AND PJ0b", "# Pre-allocate output", "PJ0", "=", "None", "PJ1", "=", "None", "PJ0b", "=", "None", "# Calculate Ptot which is used in all cases", "Ptot", "=", "(", "PTM", "+", "PTE", ")", "/", "(", "4", "*", "np", ".", "pi", ")", "# If rec is magnetic switch sign (reciprocity MM/ME => EE/EM).", "if", "mrec", ":", "sign", "=", "-", "1", "else", ":", "sign", "=", "1", "# Group into PJ0 and PJ1 for J0/J1 Hankel Transform", "if", "ab", "in", "[", "11", ",", "12", ",", "21", ",", "22", ",", "14", ",", "24", ",", "15", ",", "25", "]", ":", "# Eqs 105, 106, 111, 112,", "# J2(kr) = 2/(kr)*J1(kr) - J0(kr) # 119, 120, 123, 124", "if", "ab", "in", "[", "14", ",", "22", "]", ":", "sign", "*=", "-", "1", "PJ0b", "=", "sign", "/", "2", "*", "Ptot", "*", "lambd", "PJ1", "=", "-", "sign", "*", "Ptot", "if", "ab", "in", "[", "11", ",", "22", ",", "24", ",", "15", "]", ":", "if", "ab", "in", "[", "22", ",", "24", "]", ":", "sign", "*=", "-", "1", "PJ0", "=", "sign", "*", "(", "PTM", "-", "PTE", ")", "/", "(", "8", "*", "np", ".", "pi", ")", "*", "lambd", "elif", "ab", "in", "[", "13", ",", "23", ",", "31", ",", "32", ",", "34", ",", "35", ",", "16", ",", "26", "]", ":", "# Eqs 107, 113, 114, 115,", "PJ1", "=", "sign", "*", "Ptot", "*", "lambd", "*", "lambd", "# . 121, 125, 126, 127", "if", "ab", "in", "[", "34", ",", "26", "]", ":", "PJ1", "*=", "-", "1", "elif", "ab", "in", "[", "33", ",", "]", ":", "# Eq 116", "PJ0", "=", "sign", "*", "Ptot", "*", "lambd", "*", "lambd", "*", "lambd", "# Return PJ0, PJ1, PJ0b", "return", "PJ0", ",", "PJ1", ",", "PJ0b" ]
r"""Calculate wavenumber domain solution. Return the wavenumber domain solutions ``PJ0``, ``PJ1``, and ``PJ0b``, which have to be transformed with a Hankel transform to the frequency domain. ``PJ0``/``PJ0b`` and ``PJ1`` have to be transformed with Bessel functions of order 0 (:math:`J_0`) and 1 (:math:`J_1`), respectively. This function corresponds loosely to equations 105--107, 111--116, 119--121, and 123--128 in [HuTS15]_, and equally loosely to the file ``kxwmod.c``. [HuTS15]_ uses Bessel functions of orders 0, 1, and 2 (:math:`J_0, J_1, J_2`). The implementations of the *Fast Hankel Transform* and the *Quadrature-with-Extrapolation* in ``transform`` are set-up with Bessel functions of order 0 and 1 only. This is achieved by applying the recurrence formula .. math:: J_2(kr) = \frac{2}{kr} J_1(kr) - J_0(kr) \ . .. note:: ``PJ0`` and ``PJ0b`` could theoretically be added here into one, and then be transformed in one go. However, ``PJ0b`` has to be multiplied by ``factAng`` later. This has to be done after the Hankel transform for methods which make use of spline interpolation, in order to work for offsets that are not in line with each other. This function is called from one of the Hankel functions in :mod:`transform`. Consult the modelling routines in :mod:`model` for a description of the input and output parameters. If you are solely interested in the wavenumber-domain solution you can call this function directly. However, you have to make sure all input arguments are correct, as no checks are carried out here.
[ "r", "Calculate", "wavenumber", "domain", "solution", "." ]
train
https://github.com/empymod/empymod/blob/4a78ca4191ed4b4d42d019ce715a9a3889dba1bc/empymod/kernel.py#L47-L129
<|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"""Calculate wavenumber domain solution. Return the wavenumber domain solutions ``PJ0``, ``PJ1``, and ``PJ0b``, which have to be transformed with a Hankel transform to the frequency domain. ``PJ0``/``PJ0b`` and ``PJ1`` have to be transformed with Bessel functions of order 0 (:math:`J_0`) and 1 (:math:`J_1`), respectively. This function corresponds loosely to equations 105--107, 111--116, 119--121, and 123--128 in [HuTS15]_, and equally loosely to the file ``kxwmod.c``. [HuTS15]_ uses Bessel functions of orders 0, 1, and 2 (:math:`J_0, J_1, J_2`). The implementations of the *Fast Hankel Transform* and the *Quadrature-with-Extrapolation* in ``transform`` are set-up with Bessel functions of order 0 and 1 only. This is achieved by applying the recurrence formula .. math:: J_2(kr) = \frac{2}{kr} J_1(kr) - J_0(kr) \ . .. note:: ``PJ0`` and ``PJ0b`` could theoretically be added here into one, and then be transformed in one go. However, ``PJ0b`` has to be multiplied by ``factAng`` later. This has to be done after the Hankel transform for methods which make use of spline interpolation, in order to work for offsets that are not in line with each other. This function is called from one of the Hankel functions in :mod:`transform`. Consult the modelling routines in :mod:`model` for a description of the input and output parameters. If you are solely interested in the wavenumber-domain solution you can call this function directly. However, you have to make sure all input arguments are correct, as no checks are carried out here. ### Response: def wavenumber(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval): r"""Calculate wavenumber domain solution. Return the wavenumber domain solutions ``PJ0``, ``PJ1``, and ``PJ0b``, which have to be transformed with a Hankel transform to the frequency domain. ``PJ0``/``PJ0b`` and ``PJ1`` have to be transformed with Bessel functions of order 0 (:math:`J_0`) and 1 (:math:`J_1`), respectively. This function corresponds loosely to equations 105--107, 111--116, 119--121, and 123--128 in [HuTS15]_, and equally loosely to the file ``kxwmod.c``. [HuTS15]_ uses Bessel functions of orders 0, 1, and 2 (:math:`J_0, J_1, J_2`). The implementations of the *Fast Hankel Transform* and the *Quadrature-with-Extrapolation* in ``transform`` are set-up with Bessel functions of order 0 and 1 only. This is achieved by applying the recurrence formula .. math:: J_2(kr) = \frac{2}{kr} J_1(kr) - J_0(kr) \ . .. note:: ``PJ0`` and ``PJ0b`` could theoretically be added here into one, and then be transformed in one go. However, ``PJ0b`` has to be multiplied by ``factAng`` later. This has to be done after the Hankel transform for methods which make use of spline interpolation, in order to work for offsets that are not in line with each other. This function is called from one of the Hankel functions in :mod:`transform`. Consult the modelling routines in :mod:`model` for a description of the input and output parameters. If you are solely interested in the wavenumber-domain solution you can call this function directly. However, you have to make sure all input arguments are correct, as no checks are carried out here. """ # ** CALCULATE GREEN'S FUNCTIONS # Shape of PTM, PTE: (nfreq, noffs, nfilt) PTM, PTE = greenfct(zsrc, zrec, lsrc, lrec, depth, etaH, etaV, zetaH, zetaV, lambd, ab, xdirect, msrc, mrec, use_ne_eval) # ** AB-SPECIFIC COLLECTION OF PJ0, PJ1, AND PJ0b # Pre-allocate output PJ0 = None PJ1 = None PJ0b = None # Calculate Ptot which is used in all cases Ptot = (PTM + PTE)/(4*np.pi) # If rec is magnetic switch sign (reciprocity MM/ME => EE/EM). if mrec: sign = -1 else: sign = 1 # Group into PJ0 and PJ1 for J0/J1 Hankel Transform if ab in [11, 12, 21, 22, 14, 24, 15, 25]: # Eqs 105, 106, 111, 112, # J2(kr) = 2/(kr)*J1(kr) - J0(kr) # 119, 120, 123, 124 if ab in [14, 22]: sign *= -1 PJ0b = sign/2*Ptot*lambd PJ1 = -sign*Ptot if ab in [11, 22, 24, 15]: if ab in [22, 24]: sign *= -1 PJ0 = sign*(PTM - PTE)/(8*np.pi)*lambd elif ab in [13, 23, 31, 32, 34, 35, 16, 26]: # Eqs 107, 113, 114, 115, PJ1 = sign*Ptot*lambd*lambd # . 121, 125, 126, 127 if ab in [34, 26]: PJ1 *= -1 elif ab in [33, ]: # Eq 116 PJ0 = sign*Ptot*lambd*lambd*lambd # Return PJ0, PJ1, PJ0b return PJ0, PJ1, PJ0b <|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, 48966, 289, 5389, 900, 8106, 6425, 382, 262, 3494, 279, 289, 5389, 900, 8106, 10105, 10103, 95335, 15, 91816, 10103, 95335, 16, 91816, 323, 10103, 95335, 15, 65, 63, 13188, 262, 902, 617, 311, 387, 24411, 449, 264, 55761, 301, 5276, 311, 279, 11900, 198, 262, 8106, 13, 10103, 95335, 15, 14196, 14, 14196, 95335, 15, 65, 14196, 323, 10103, 95335, 16, 14196, 617, 311, 387, 24411, 449, 426, 36648, 198, 262, 5865, 315, 2015, 220, 15, 30354, 10590, 19258, 41, 62, 15, 33981, 323, 220, 16, 30354, 10590, 19258, 41, 62, 16, 63, 705, 15947, 382, 262, 1115, 734, 34310, 63557, 311, 39006, 220, 6550, 313, 7699, 11, 220, 5037, 313, 8027, 345, 262, 220, 9079, 313, 7994, 11, 323, 220, 4513, 313, 4386, 304, 510, 82478, 10155, 868, 60, 7022, 323, 18813, 63557, 311, 279, 1052, 198, 262, 10103, 74, 87, 86, 2658, 522, 14196, 382, 262, 510, 82478, 10155, 868, 60, 62, 5829, 426, 36648, 5865, 315, 10373, 220, 15, 11, 220, 16, 11, 323, 220, 17, 30354, 10590, 19258, 41, 62, 15, 11, 622, 62, 16, 345, 262, 622, 62, 17, 60310, 578, 39437, 315, 279, 353, 33274, 55761, 301, 15583, 9, 323, 279, 198, 262, 353, 2232, 15008, 1598, 27281, 12, 849, 376, 17070, 367, 9, 304, 10103, 4806, 14196, 527, 743, 5352, 449, 426, 36648, 198, 262, 5865, 315, 2015, 220, 15, 323, 220, 16, 1193, 13, 1115, 374, 17427, 555, 19486, 279, 198, 262, 76293, 15150, 271, 262, 5354, 7033, 487, 622, 62, 17, 6097, 81, 8, 284, 1144, 38118, 90, 17, 15523, 10056, 92, 622, 62, 16, 6097, 81, 8, 482, 622, 62, 15, 6097, 81, 8, 1144, 220, 4286, 262, 5354, 5296, 66152, 286, 10103, 95335, 15, 14196, 323, 10103, 95335, 15, 65, 14196, 1436, 63234, 387, 3779, 1618, 1139, 832, 11, 323, 198, 286, 1243, 387, 24411, 304, 832, 733, 13, 220, 4452, 11, 10103, 95335, 15, 65, 14196, 706, 311, 387, 56016, 198, 286, 555, 10103, 34210, 10976, 14196, 3010, 13, 1115, 706, 311, 387, 2884, 1306, 279, 55761, 301, 5276, 198, 286, 369, 5528, 902, 1304, 1005, 315, 71186, 37587, 11, 304, 2015, 311, 990, 198, 286, 369, 36146, 430, 527, 539, 304, 1584, 449, 1855, 1023, 382, 262, 1115, 734, 374, 2663, 505, 832, 315, 279, 55761, 301, 5865, 304, 198, 262, 551, 2658, 19258, 4806, 29687, 220, 20556, 279, 61966, 30597, 304, 551, 2658, 19258, 2590, 63, 369, 264, 198, 262, 4096, 315, 279, 1988, 323, 2612, 5137, 382, 262, 1442, 499, 527, 21742, 8173, 304, 279, 289, 5389, 900, 73894, 6425, 499, 649, 1650, 198, 262, 420, 734, 6089, 13, 4452, 11, 499, 617, 311, 1304, 2771, 682, 1988, 6105, 198, 262, 527, 4495, 11, 439, 912, 12621, 527, 11953, 704, 1618, 382, 14711, 6075, 512, 755, 289, 5389, 900, 13476, 3632, 11, 1167, 2827, 11 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 48966, 289, 5389, 900, 8106, 6425, 382, 262, 3494, 279, 289, 5389, 900, 8106, 10105, 10103, 95335, 15, 91816, 10103, 95335, 16, 91816, 323, 10103, 95335, 15, 65, 63, 13188, 262, 902, 617, 311, 387, 24411, 449, 264, 55761, 301, 5276, 311, 279, 11900, 198, 262, 8106, 13, 10103, 95335, 15, 14196, 14, 14196, 95335, 15, 65, 14196, 323, 10103, 95335, 16, 14196, 617, 311, 387, 24411, 449, 426, 36648, 198, 262, 5865, 315, 2015, 220, 15, 30354, 10590, 19258, 41, 62, 15, 33981, 323, 220, 16, 30354, 10590, 19258, 41, 62, 16, 63, 705, 15947, 382, 262, 1115, 734, 34310, 63557, 311, 39006, 220, 6550, 313, 7699, 11, 220, 5037, 313, 8027, 345, 262, 220, 9079, 313, 7994, 11, 323, 220, 4513, 313, 4386, 304, 510, 82478, 10155, 868, 60, 7022, 323, 18813, 63557, 311, 279, 1052, 198, 262, 10103, 74, 87, 86, 2658, 522, 14196, 382, 262, 510, 82478, 10155, 868, 60, 62, 5829, 426, 36648, 5865, 315, 10373, 220, 15, 11, 220, 16, 11, 323, 220, 17, 30354, 10590, 19258, 41, 62, 15, 11, 622, 62, 16, 345, 262, 622, 62, 17, 60310, 578, 39437, 315, 279, 353, 33274, 55761, 301, 15583, 9, 323, 279, 198, 262, 353, 2232, 15008, 1598, 27281, 12, 849, 376, 17070, 367, 9, 304, 10103, 4806, 14196, 527, 743, 5352, 449, 426, 36648, 198, 262, 5865, 315, 2015, 220, 15, 323, 220, 16, 1193, 13, 1115, 374, 17427, 555, 19486, 279, 198, 262, 76293, 15150, 271, 262, 5354, 7033, 487, 622, 62, 17, 6097, 81, 8, 284, 1144, 38118, 90, 17, 15523, 10056, 92, 622, 62, 16, 6097, 81, 8, 482, 622, 62, 15, 6097, 81, 8, 1144, 220, 4286, 262, 5354, 5296, 66152, 286, 10103, 95335, 15, 14196, 323, 10103, 95335, 15, 65, 14196, 1436, 63234, 387, 3779, 1618, 1139, 832, 11, 323, 198, 286, 1243, 387, 24411, 304, 832, 733, 13, 220, 4452, 11, 10103, 95335, 15, 65, 14196, 706, 311, 387, 56016, 198, 286, 555, 10103, 34210, 10976, 14196, 3010, 13, 1115, 706, 311, 387, 2884, 1306, 279, 55761, 301, 5276, 198, 286, 369, 5528, 902, 1304, 1005, 315, 71186, 37587, 11, 304, 2015, 311, 990, 198, 286, 369, 36146, 430, 527, 539, 304, 1584, 449, 1855, 1023, 382, 262, 1115, 734, 374, 2663, 505, 832, 315, 279, 55761, 301, 5865, 304, 198, 262, 551, 2658, 19258, 4806, 29687, 220, 20556, 279, 61966, 30597, 304, 551, 2658, 19258, 2590, 63, 369, 264, 198, 262, 4096, 315, 279, 1988, 323, 2612, 5137, 382, 262, 1442, 499, 527, 21742, 8173, 304, 279, 289, 5389, 900, 73894, 6425, 499, 649, 1650, 198, 262, 420, 734, 6089, 13, 4452, 11, 499, 617, 311, 1304, 2771, 682, 1988, 6105, 198, 262, 527, 4495, 11, 439, 912, 12621, 527, 11953, 704, 1618, 382, 14711, 6075, 512, 755, 289, 5389, 900, 13476, 3632, 11, 1167, 2827, 11 ]
BYU-PCCL/holodeck
holodeck/holodeckclient.py
HolodeckClient.malloc
def malloc(self, key, shape, dtype): """Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): The numpy data type (e.g. np.float32). Returns: np.ndarray: The numpy array that is positioned on the shared memory. """ if key not in self._memory or self._memory[key].shape != shape or self._memory[key].dtype != dtype: self._memory[key] = Shmem(key, shape, dtype, self._uuid) return self._memory[key].np_array
python
def malloc(self, key, shape, dtype): """Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): The numpy data type (e.g. np.float32). Returns: np.ndarray: The numpy array that is positioned on the shared memory. """ if key not in self._memory or self._memory[key].shape != shape or self._memory[key].dtype != dtype: self._memory[key] = Shmem(key, shape, dtype, self._uuid) return self._memory[key].np_array
[ "def", "malloc", "(", "self", ",", "key", ",", "shape", ",", "dtype", ")", ":", "if", "key", "not", "in", "self", ".", "_memory", "or", "self", ".", "_memory", "[", "key", "]", ".", "shape", "!=", "shape", "or", "self", ".", "_memory", "[", "key", "]", ".", "dtype", "!=", "dtype", ":", "self", ".", "_memory", "[", "key", "]", "=", "Shmem", "(", "key", ",", "shape", ",", "dtype", ",", "self", ".", "_uuid", ")", "return", "self", ".", "_memory", "[", "key", "]", ".", "np_array" ]
Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): The numpy data type (e.g. np.float32). Returns: np.ndarray: The numpy array that is positioned on the shared memory.
[ "Allocates", "a", "block", "of", "shared", "memory", "and", "returns", "a", "numpy", "array", "whose", "data", "corresponds", "with", "that", "block", "." ]
train
https://github.com/BYU-PCCL/holodeck/blob/01acd4013f5acbd9f61fbc9caaafe19975e8b121/holodeck/holodeckclient.py#L88-L102
<|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: Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): The numpy data type (e.g. np.float32). Returns: np.ndarray: The numpy array that is positioned on the shared memory. ### Response: def malloc(self, key, shape, dtype): """Allocates a block of shared memory, and returns a numpy array whose data corresponds with that block. Args: key (str): The key to identify the block. shape (list of int): The shape of the numpy array to allocate. dtype (type): The numpy data type (e.g. np.float32). Returns: np.ndarray: The numpy array that is positioned on the shared memory. """ if key not in self._memory or self._memory[key].shape != shape or self._memory[key].dtype != dtype: self._memory[key] = Shmem(key, shape, dtype, self._uuid) return self._memory[key].np_array <|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, 26212, 988, 264, 2565, 315, 6222, 5044, 11, 323, 4780, 264, 8760, 1358, 6832, 828, 34310, 449, 430, 2565, 382, 286, 18161, 512, 310, 1401, 320, 496, 1680, 578, 1401, 311, 10765, 279, 2565, 627, 310, 6211, 320, 1638, 315, 528, 1680, 578, 6211, 315, 279, 8760, 1358, 311, 22864, 627, 310, 13534, 320, 1337, 1680, 578, 8760, 828, 955, 320, 68, 1326, 13, 2660, 16304, 843, 3677, 286, 5295, 512, 310, 2660, 36649, 25, 578, 8760, 1358, 430, 374, 35328, 389, 279, 6222, 5044, 382, 14711, 6075, 512, 755, 16108, 1214, 11, 1401, 11, 6211, 11, 13534, 997, 286, 4304, 26212, 988, 264, 2565, 315, 6222, 5044, 11, 323, 4780, 264, 8760, 1358, 6832, 828, 34310, 449, 430, 2565, 382, 286, 18161, 512, 310, 1401, 320, 496, 1680, 578, 1401, 311, 10765, 279, 2565, 627, 310, 6211, 320, 1638, 315, 528, 1680, 578, 6211, 315, 279, 8760, 1358, 311, 22864, 627, 310, 13534, 320, 1337, 1680, 578, 8760, 828, 955, 320, 68, 1326, 13, 2660, 16304, 843, 3677, 286, 5295, 512, 310, 2660, 36649, 25, 578, 8760, 1358, 430, 374, 35328, 389, 279, 6222, 5044, 627, 286, 3270, 286, 422, 1401, 539, 304, 659, 1462, 17717, 477, 659, 1462, 17717, 8320, 948, 12510, 976, 6211, 477, 659, 1462, 17717, 8320, 948, 48827, 976, 13534, 512, 310, 659, 1462, 17717, 8320, 60, 284, 1443, 10759, 4962, 11, 6211, 11, 13534, 11, 659, 1462, 17566, 696, 286, 471, 659, 1462, 17717, 8320, 948, 6331, 3943, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 26212, 988, 264, 2565, 315, 6222, 5044, 11, 323, 4780, 264, 8760, 1358, 6832, 828, 34310, 449, 430, 2565, 382, 286, 18161, 512, 310, 1401, 320, 496, 1680, 578, 1401, 311, 10765, 279, 2565, 627, 310, 6211, 320, 1638, 315, 528, 1680, 578, 6211, 315, 279, 8760, 1358, 311, 22864, 627, 310, 13534, 320, 1337, 1680, 578, 8760, 828, 955, 320, 68, 1326, 13, 2660, 16304, 843, 3677, 286, 5295, 512, 310, 2660, 36649, 25, 578, 8760, 1358, 430, 374, 35328, 389, 279, 6222, 5044, 382, 14711, 6075, 512, 755, 16108, 1214, 11, 1401, 11, 6211, 11, 13534, 997, 286, 4304, 26212, 988, 264, 2565, 315, 6222, 5044, 11, 323, 4780, 264, 8760, 1358, 6832, 828, 34310, 449, 430, 2565, 382, 286, 18161, 512, 310, 1401, 320, 496, 1680, 578, 1401, 311, 10765, 279, 2565, 627, 310, 6211, 320, 1638, 315, 528, 1680, 578, 6211, 315, 279, 8760, 1358, 311, 22864, 627, 310, 13534, 320, 1337, 1680, 578, 8760, 828, 955, 320, 68, 1326, 13, 2660, 16304, 843, 3677, 286, 5295, 512, 310, 2660, 36649, 25, 578, 8760, 1358, 430, 374, 35328, 389, 279, 6222, 5044, 627, 286, 3270, 286, 422, 1401, 539, 304, 659, 1462, 17717, 477, 659, 1462, 17717, 8320, 948, 12510, 976, 6211, 477, 659, 1462, 17717, 8320, 948, 48827, 976, 13534, 512, 310, 659, 1462, 17717, 8320, 60, 284, 1443, 10759, 4962, 11, 6211, 11, 13534, 11, 659, 1462, 17566, 696, 286, 471, 659, 1462, 17717, 8320, 948, 6331, 3943, 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 ]
timknip/pycsg
csg/core.py
CSG.cube
def cube(cls, center=[0,0,0], radius=[1,1,1]): """ Construct an axis-aligned solid cuboid. Optional parameters are `center` and `radius`, which default to `[0, 0, 0]` and `[1, 1, 1]`. The radius can be specified using a single number or a list of three numbers, one for each axis. Example code:: cube = CSG.cube( center=[0, 0, 0], radius=1 ) """ c = Vector(0, 0, 0) r = [1, 1, 1] if isinstance(center, list): c = Vector(center) if isinstance(radius, list): r = radius else: r = [radius, radius, radius] polygons = list(map( lambda v: Polygon( list(map(lambda i: Vertex( Vector( c.x + r[0] * (2 * bool(i & 1) - 1), c.y + r[1] * (2 * bool(i & 2) - 1), c.z + r[2] * (2 * bool(i & 4) - 1) ), None ), v[0]))), [ [[0, 4, 6, 2], [-1, 0, 0]], [[1, 3, 7, 5], [+1, 0, 0]], [[0, 1, 5, 4], [0, -1, 0]], [[2, 6, 7, 3], [0, +1, 0]], [[0, 2, 3, 1], [0, 0, -1]], [[4, 5, 7, 6], [0, 0, +1]] ])) return CSG.fromPolygons(polygons)
python
def cube(cls, center=[0,0,0], radius=[1,1,1]): """ Construct an axis-aligned solid cuboid. Optional parameters are `center` and `radius`, which default to `[0, 0, 0]` and `[1, 1, 1]`. The radius can be specified using a single number or a list of three numbers, one for each axis. Example code:: cube = CSG.cube( center=[0, 0, 0], radius=1 ) """ c = Vector(0, 0, 0) r = [1, 1, 1] if isinstance(center, list): c = Vector(center) if isinstance(radius, list): r = radius else: r = [radius, radius, radius] polygons = list(map( lambda v: Polygon( list(map(lambda i: Vertex( Vector( c.x + r[0] * (2 * bool(i & 1) - 1), c.y + r[1] * (2 * bool(i & 2) - 1), c.z + r[2] * (2 * bool(i & 4) - 1) ), None ), v[0]))), [ [[0, 4, 6, 2], [-1, 0, 0]], [[1, 3, 7, 5], [+1, 0, 0]], [[0, 1, 5, 4], [0, -1, 0]], [[2, 6, 7, 3], [0, +1, 0]], [[0, 2, 3, 1], [0, 0, -1]], [[4, 5, 7, 6], [0, 0, +1]] ])) return CSG.fromPolygons(polygons)
[ "def", "cube", "(", "cls", ",", "center", "=", "[", "0", ",", "0", ",", "0", "]", ",", "radius", "=", "[", "1", ",", "1", ",", "1", "]", ")", ":", "c", "=", "Vector", "(", "0", ",", "0", ",", "0", ")", "r", "=", "[", "1", ",", "1", ",", "1", "]", "if", "isinstance", "(", "center", ",", "list", ")", ":", "c", "=", "Vector", "(", "center", ")", "if", "isinstance", "(", "radius", ",", "list", ")", ":", "r", "=", "radius", "else", ":", "r", "=", "[", "radius", ",", "radius", ",", "radius", "]", "polygons", "=", "list", "(", "map", "(", "lambda", "v", ":", "Polygon", "(", "list", "(", "map", "(", "lambda", "i", ":", "Vertex", "(", "Vector", "(", "c", ".", "x", "+", "r", "[", "0", "]", "*", "(", "2", "*", "bool", "(", "i", "&", "1", ")", "-", "1", ")", ",", "c", ".", "y", "+", "r", "[", "1", "]", "*", "(", "2", "*", "bool", "(", "i", "&", "2", ")", "-", "1", ")", ",", "c", ".", "z", "+", "r", "[", "2", "]", "*", "(", "2", "*", "bool", "(", "i", "&", "4", ")", "-", "1", ")", ")", ",", "None", ")", ",", "v", "[", "0", "]", ")", ")", ")", ",", "[", "[", "[", "0", ",", "4", ",", "6", ",", "2", "]", ",", "[", "-", "1", ",", "0", ",", "0", "]", "]", ",", "[", "[", "1", ",", "3", ",", "7", ",", "5", "]", ",", "[", "+", "1", ",", "0", ",", "0", "]", "]", ",", "[", "[", "0", ",", "1", ",", "5", ",", "4", "]", ",", "[", "0", ",", "-", "1", ",", "0", "]", "]", ",", "[", "[", "2", ",", "6", ",", "7", ",", "3", "]", ",", "[", "0", ",", "+", "1", ",", "0", "]", "]", ",", "[", "[", "0", ",", "2", ",", "3", ",", "1", "]", ",", "[", "0", ",", "0", ",", "-", "1", "]", "]", ",", "[", "[", "4", ",", "5", ",", "7", ",", "6", "]", ",", "[", "0", ",", "0", ",", "+", "1", "]", "]", "]", ")", ")", "return", "CSG", ".", "fromPolygons", "(", "polygons", ")" ]
Construct an axis-aligned solid cuboid. Optional parameters are `center` and `radius`, which default to `[0, 0, 0]` and `[1, 1, 1]`. The radius can be specified using a single number or a list of three numbers, one for each axis. Example code:: cube = CSG.cube( center=[0, 0, 0], radius=1 )
[ "Construct", "an", "axis", "-", "aligned", "solid", "cuboid", ".", "Optional", "parameters", "are", "center", "and", "radius", "which", "default", "to", "[", "0", "0", "0", "]", "and", "[", "1", "1", "1", "]", ".", "The", "radius", "can", "be", "specified", "using", "a", "single", "number", "or", "a", "list", "of", "three", "numbers", "one", "for", "each", "axis", ".", "Example", "code", "::", "cube", "=", "CSG", ".", "cube", "(", "center", "=", "[", "0", "0", "0", "]", "radius", "=", "1", ")" ]
train
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/core.py#L318-L356
<|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 an axis-aligned solid cuboid. Optional parameters are `center` and `radius`, which default to `[0, 0, 0]` and `[1, 1, 1]`. The radius can be specified using a single number or a list of three numbers, one for each axis. Example code:: cube = CSG.cube( center=[0, 0, 0], radius=1 ) ### Response: def cube(cls, center=[0,0,0], radius=[1,1,1]): """ Construct an axis-aligned solid cuboid. Optional parameters are `center` and `radius`, which default to `[0, 0, 0]` and `[1, 1, 1]`. The radius can be specified using a single number or a list of three numbers, one for each axis. Example code:: cube = CSG.cube( center=[0, 0, 0], radius=1 ) """ c = Vector(0, 0, 0) r = [1, 1, 1] if isinstance(center, list): c = Vector(center) if isinstance(radius, list): r = radius else: r = [radius, radius, radius] polygons = list(map( lambda v: Polygon( list(map(lambda i: Vertex( Vector( c.x + r[0] * (2 * bool(i & 1) - 1), c.y + r[1] * (2 * bool(i & 2) - 1), c.z + r[2] * (2 * bool(i & 4) - 1) ), None ), v[0]))), [ [[0, 4, 6, 2], [-1, 0, 0]], [[1, 3, 7, 5], [+1, 0, 0]], [[0, 1, 5, 4], [0, -1, 0]], [[2, 6, 7, 3], [0, +1, 0]], [[0, 2, 3, 1], [0, 0, -1]], [[4, 5, 7, 6], [0, 0, +1]] ])) return CSG.fromPolygons(polygons) <|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, 459, 8183, 98551, 6573, 19250, 590, 13, 12536, 5137, 527, 1595, 3133, 63, 323, 198, 286, 1595, 27813, 7964, 902, 1670, 311, 78744, 15, 11, 220, 15, 11, 220, 15, 60, 63, 323, 78744, 16, 11, 220, 16, 11, 220, 16, 60, 29687, 578, 10801, 649, 387, 198, 286, 5300, 1701, 264, 3254, 1396, 477, 264, 1160, 315, 2380, 5219, 11, 832, 369, 1855, 8183, 627, 1827, 286, 13688, 2082, 50677, 1827, 310, 24671, 284, 356, 7939, 522, 3845, 1021, 1078, 4219, 5941, 15, 11, 220, 15, 11, 220, 15, 1282, 1078, 10801, 28, 16, 198, 310, 5235, 14711, 6075, 512, 755, 24671, 21024, 11, 4219, 5941, 15, 11, 15, 11, 15, 1145, 10801, 5941, 16, 11, 16, 11, 16, 22953, 286, 3270, 286, 19196, 459, 8183, 98551, 6573, 19250, 590, 13, 12536, 5137, 527, 1595, 3133, 63, 323, 198, 286, 1595, 27813, 7964, 902, 1670, 311, 78744, 15, 11, 220, 15, 11, 220, 15, 60, 63, 323, 78744, 16, 11, 220, 16, 11, 220, 16, 60, 29687, 578, 10801, 649, 387, 198, 286, 5300, 1701, 264, 3254, 1396, 477, 264, 1160, 315, 2380, 5219, 11, 832, 369, 1855, 8183, 627, 1827, 286, 13688, 2082, 50677, 1827, 310, 24671, 284, 356, 7939, 522, 3845, 1021, 1078, 4219, 5941, 15, 11, 220, 15, 11, 220, 15, 1282, 1078, 10801, 28, 16, 198, 310, 1763, 286, 3270, 286, 272, 284, 4290, 7, 15, 11, 220, 15, 11, 220, 15, 340, 286, 436, 284, 510, 16, 11, 220, 16, 11, 220, 16, 933, 286, 422, 11656, 42616, 11, 1160, 1680, 272, 284, 4290, 42616, 340, 286, 422, 11656, 62122, 11, 1160, 1680, 436, 284, 10801, 198, 286, 775, 25, 436, 284, 510, 27813, 11, 10801, 11, 10801, 2595, 286, 69259, 284, 1160, 9325, 1021, 310, 12741, 348, 25, 49259, 7, 720, 394, 1160, 9325, 18705, 602, 25, 720, 504, 24103, 1021, 667, 4290, 1021, 1014, 272, 2036, 489, 436, 58, 15, 60, 353, 320, 17, 353, 1845, 1998, 612, 220, 16, 8, 482, 220, 16, 1350, 1014, 272, 2441, 489, 436, 58, 16, 60, 353, 320, 17, 353, 1845, 1998, 612, 220, 17, 8, 482, 220, 16, 1350, 1014, 272, 4025, 489, 436, 58, 17, 60, 353, 320, 17, 353, 1845, 1998, 612, 220, 19, 8, 482, 220, 16, 340, 667, 7026, 720, 667, 2290, 198, 504, 7026, 348, 58, 15, 9549, 1350, 504, 2330, 667, 4416, 15, 11, 220, 19, 11, 220, 21, 11, 220, 17, 1145, 10261, 16, 11, 220, 15, 11, 220, 15, 19052, 667, 4416, 16, 11, 220, 18, 11, 220, 22, 11, 220, 20, 1145, 79901, 16, 11, 220, 15, 11, 220, 15, 19052, 667, 4416, 15, 11, 220, 16, 11, 220, 20, 11, 220, 19, 1145, 510, 15, 11, 482, 16, 11, 220, 15, 19052, 667, 4416, 17, 11, 220, 21, 11, 220, 22, 11, 220, 18, 1145, 510 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 29568, 459, 8183, 98551, 6573, 19250, 590, 13, 12536, 5137, 527, 1595, 3133, 63, 323, 198, 286, 1595, 27813, 7964, 902, 1670, 311, 78744, 15, 11, 220, 15, 11, 220, 15, 60, 63, 323, 78744, 16, 11, 220, 16, 11, 220, 16, 60, 29687, 578, 10801, 649, 387, 198, 286, 5300, 1701, 264, 3254, 1396, 477, 264, 1160, 315, 2380, 5219, 11, 832, 369, 1855, 8183, 627, 1827, 286, 13688, 2082, 50677, 1827, 310, 24671, 284, 356, 7939, 522, 3845, 1021, 1078, 4219, 5941, 15, 11, 220, 15, 11, 220, 15, 1282, 1078, 10801, 28, 16, 198, 310, 5235, 14711, 6075, 512, 755, 24671, 21024, 11, 4219, 5941, 15, 11, 15, 11, 15, 1145, 10801, 5941, 16, 11, 16, 11, 16, 22953, 286, 3270, 286, 19196, 459, 8183, 98551, 6573, 19250, 590, 13, 12536, 5137, 527, 1595, 3133, 63, 323, 198, 286, 1595, 27813, 7964, 902, 1670, 311, 78744, 15, 11, 220, 15, 11, 220, 15, 60, 63, 323, 78744, 16, 11, 220, 16, 11, 220, 16, 60, 29687, 578, 10801, 649, 387, 198, 286, 5300, 1701, 264, 3254, 1396, 477, 264, 1160, 315, 2380, 5219, 11, 832, 369, 1855, 8183, 627, 1827, 286, 13688, 2082, 50677, 1827, 310, 24671, 284, 356, 7939, 522, 3845, 1021, 1078, 4219, 5941, 15, 11, 220, 15, 11, 220, 15, 1282, 1078, 10801, 28, 16, 198, 310, 1763, 286, 3270, 286, 272, 284, 4290, 7, 15, 11, 220, 15, 11, 220, 15, 340, 286, 436, 284, 510, 16, 11, 220, 16, 11, 220, 16, 933, 286, 422, 11656, 42616, 11, 1160, 1680, 272, 284, 4290, 42616, 340, 286, 422, 11656, 62122, 11, 1160, 1680, 436, 284, 10801, 198, 286, 775, 25, 436, 284, 510, 27813, 11, 10801, 11, 10801, 2595, 286, 69259, 284, 1160, 9325, 1021, 310, 12741, 348, 25, 49259, 7, 720, 394, 1160, 9325, 18705, 602, 25, 720, 504, 24103, 1021, 667, 4290, 1021, 1014, 272, 2036, 489, 436, 58, 15, 60, 353, 320, 17, 353, 1845, 1998, 612, 220, 16, 8, 482, 220, 16, 1350, 1014, 272, 2441, 489, 436, 58, 16, 60, 353, 320, 17, 353, 1845, 1998, 612, 220, 17, 8, 482, 220, 16, 1350, 1014, 272, 4025, 489, 436, 58, 17, 60, 353, 320, 17, 353, 1845, 1998, 612, 220, 19, 8, 482, 220, 16, 340, 667, 7026, 720, 667, 2290, 198, 504, 7026, 348, 58, 15, 9549, 1350, 504, 2330, 667, 4416, 15, 11, 220, 19, 11, 220, 21, 11, 220, 17, 1145, 10261, 16, 11, 220, 15, 11, 220, 15, 19052, 667, 4416, 16, 11, 220, 18, 11, 220, 22, 11, 220, 20, 1145, 79901, 16, 11, 220, 15, 11, 220, 15, 19052, 667, 4416, 15, 11, 220, 16, 11, 220, 20, 11, 220, 19, 1145, 510, 15, 11, 482, 16, 11, 220, 15, 19052, 667, 4416, 17, 11, 220, 21, 11, 220, 22, 11, 220, 18, 1145, 510 ]
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxglobalworkflow.py
DXGlobalWorkflow.describe_underlying_workflow
def describe_underlying_workflow(self, region, describe_output=None): """ :param region: region name :type region: string :param describe_output: description of a global workflow :type describe_output: dict :returns: object description of a workflow :rtype: : dict Returns an object description of an underlying workflow from a given region. """ assert(describe_output is None or describe_output.get('class', '') == 'globalworkflow') if region is None: raise DXError( 'DXGlobalWorkflow: region must be provided to get an underlying workflow') # Perhaps we have cached it already if region in self._workflow_desc_by_region: return self._workflow_desc_by_region[region] if not describe_output: describe_output = self.describe() if region not in describe_output['regionalOptions'].keys(): raise DXError('DXGlobalWorkflow: the global workflow {} is not enabled in region {}'.format( self.get_id(), region)) underlying_workflow_id = describe_output['regionalOptions'][region]['workflow'] dxworkflow = dxpy.DXWorkflow(underlying_workflow_id) dxworkflow_desc = dxworkflow.describe() self._workflow_desc_by_region = dxworkflow_desc return dxworkflow_desc
python
def describe_underlying_workflow(self, region, describe_output=None): """ :param region: region name :type region: string :param describe_output: description of a global workflow :type describe_output: dict :returns: object description of a workflow :rtype: : dict Returns an object description of an underlying workflow from a given region. """ assert(describe_output is None or describe_output.get('class', '') == 'globalworkflow') if region is None: raise DXError( 'DXGlobalWorkflow: region must be provided to get an underlying workflow') # Perhaps we have cached it already if region in self._workflow_desc_by_region: return self._workflow_desc_by_region[region] if not describe_output: describe_output = self.describe() if region not in describe_output['regionalOptions'].keys(): raise DXError('DXGlobalWorkflow: the global workflow {} is not enabled in region {}'.format( self.get_id(), region)) underlying_workflow_id = describe_output['regionalOptions'][region]['workflow'] dxworkflow = dxpy.DXWorkflow(underlying_workflow_id) dxworkflow_desc = dxworkflow.describe() self._workflow_desc_by_region = dxworkflow_desc return dxworkflow_desc
[ "def", "describe_underlying_workflow", "(", "self", ",", "region", ",", "describe_output", "=", "None", ")", ":", "assert", "(", "describe_output", "is", "None", "or", "describe_output", ".", "get", "(", "'class'", ",", "''", ")", "==", "'globalworkflow'", ")", "if", "region", "is", "None", ":", "raise", "DXError", "(", "'DXGlobalWorkflow: region must be provided to get an underlying workflow'", ")", "# Perhaps we have cached it already", "if", "region", "in", "self", ".", "_workflow_desc_by_region", ":", "return", "self", ".", "_workflow_desc_by_region", "[", "region", "]", "if", "not", "describe_output", ":", "describe_output", "=", "self", ".", "describe", "(", ")", "if", "region", "not", "in", "describe_output", "[", "'regionalOptions'", "]", ".", "keys", "(", ")", ":", "raise", "DXError", "(", "'DXGlobalWorkflow: the global workflow {} is not enabled in region {}'", ".", "format", "(", "self", ".", "get_id", "(", ")", ",", "region", ")", ")", "underlying_workflow_id", "=", "describe_output", "[", "'regionalOptions'", "]", "[", "region", "]", "[", "'workflow'", "]", "dxworkflow", "=", "dxpy", ".", "DXWorkflow", "(", "underlying_workflow_id", ")", "dxworkflow_desc", "=", "dxworkflow", ".", "describe", "(", ")", "self", ".", "_workflow_desc_by_region", "=", "dxworkflow_desc", "return", "dxworkflow_desc" ]
:param region: region name :type region: string :param describe_output: description of a global workflow :type describe_output: dict :returns: object description of a workflow :rtype: : dict Returns an object description of an underlying workflow from a given region.
[ ":", "param", "region", ":", "region", "name", ":", "type", "region", ":", "string", ":", "param", "describe_output", ":", "description", "of", "a", "global", "workflow", ":", "type", "describe_output", ":", "dict", ":", "returns", ":", "object", "description", "of", "a", "workflow", ":", "rtype", ":", ":", "dict" ]
train
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxglobalworkflow.py#L163-L195
<|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 region: region name :type region: string :param describe_output: description of a global workflow :type describe_output: dict :returns: object description of a workflow :rtype: : dict Returns an object description of an underlying workflow from a given region. ### Response: def describe_underlying_workflow(self, region, describe_output=None): """ :param region: region name :type region: string :param describe_output: description of a global workflow :type describe_output: dict :returns: object description of a workflow :rtype: : dict Returns an object description of an underlying workflow from a given region. """ assert(describe_output is None or describe_output.get('class', '') == 'globalworkflow') if region is None: raise DXError( 'DXGlobalWorkflow: region must be provided to get an underlying workflow') # Perhaps we have cached it already if region in self._workflow_desc_by_region: return self._workflow_desc_by_region[region] if not describe_output: describe_output = self.describe() if region not in describe_output['regionalOptions'].keys(): raise DXError('DXGlobalWorkflow: the global workflow {} is not enabled in region {}'.format( self.get_id(), region)) underlying_workflow_id = describe_output['regionalOptions'][region]['workflow'] dxworkflow = dxpy.DXWorkflow(underlying_workflow_id) dxworkflow_desc = dxworkflow.describe() self._workflow_desc_by_region = dxworkflow_desc return dxworkflow_desc <|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, 68416, 5654, 25, 5654, 836, 198, 286, 551, 1337, 5654, 25, 925, 198, 286, 551, 913, 7664, 7800, 25, 4096, 315, 264, 3728, 29388, 198, 286, 551, 1337, 7664, 7800, 25, 6587, 198, 286, 551, 4310, 25, 1665, 4096, 315, 264, 29388, 198, 286, 551, 33613, 25, 551, 6587, 271, 286, 5295, 459, 1665, 4096, 315, 459, 16940, 29388, 505, 264, 2728, 5654, 382, 14711, 6075, 512, 755, 7664, 59328, 6852, 87518, 1214, 11, 5654, 11, 7664, 7800, 5980, 997, 286, 3270, 286, 551, 913, 5654, 25, 5654, 836, 198, 286, 551, 1337, 5654, 25, 925, 198, 286, 551, 913, 7664, 7800, 25, 4096, 315, 264, 3728, 29388, 198, 286, 551, 1337, 7664, 7800, 25, 6587, 198, 286, 551, 4310, 25, 1665, 4096, 315, 264, 29388, 198, 286, 551, 33613, 25, 551, 6587, 271, 286, 5295, 459, 1665, 4096, 315, 459, 16940, 29388, 505, 264, 2728, 5654, 627, 286, 3270, 286, 2105, 35690, 3191, 7800, 374, 2290, 477, 7664, 7800, 673, 493, 1058, 518, 13760, 624, 364, 9951, 57349, 4713, 286, 422, 5654, 374, 2290, 512, 310, 4933, 31908, 1480, 1021, 394, 364, 17001, 11907, 63868, 25, 5654, 2011, 387, 3984, 311, 636, 459, 16940, 29388, 4713, 286, 674, 19292, 584, 617, 21224, 433, 2736, 198, 286, 422, 5654, 304, 659, 1462, 57349, 11229, 3795, 21276, 512, 310, 471, 659, 1462, 57349, 11229, 3795, 21276, 58, 4030, 2595, 286, 422, 539, 7664, 7800, 512, 310, 7664, 7800, 284, 659, 43065, 2892, 286, 422, 5654, 539, 304, 7664, 7800, 681, 1610, 4001, 3883, 7352, 10786, 4019, 310, 4933, 31908, 1480, 493, 17001, 11907, 63868, 25, 279, 3728, 29388, 4792, 374, 539, 9147, 304, 5654, 26307, 2293, 1021, 394, 659, 673, 851, 1535, 5654, 4489, 286, 16940, 87518, 851, 284, 7664, 7800, 681, 1610, 4001, 3883, 10136, 4030, 5465, 57349, 4532, 286, 14142, 57349, 284, 14142, 3368, 920, 55, 63868, 7, 8154, 6852, 87518, 851, 340, 286, 14142, 57349, 11229, 284, 14142, 57349, 43065, 746, 286, 659, 1462, 57349, 11229, 3795, 21276, 284, 14142, 57349, 11229, 198, 286, 471, 14142, 57349, 11229, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 68416, 5654, 25, 5654, 836, 198, 286, 551, 1337, 5654, 25, 925, 198, 286, 551, 913, 7664, 7800, 25, 4096, 315, 264, 3728, 29388, 198, 286, 551, 1337, 7664, 7800, 25, 6587, 198, 286, 551, 4310, 25, 1665, 4096, 315, 264, 29388, 198, 286, 551, 33613, 25, 551, 6587, 271, 286, 5295, 459, 1665, 4096, 315, 459, 16940, 29388, 505, 264, 2728, 5654, 382, 14711, 6075, 512, 755, 7664, 59328, 6852, 87518, 1214, 11, 5654, 11, 7664, 7800, 5980, 997, 286, 3270, 286, 551, 913, 5654, 25, 5654, 836, 198, 286, 551, 1337, 5654, 25, 925, 198, 286, 551, 913, 7664, 7800, 25, 4096, 315, 264, 3728, 29388, 198, 286, 551, 1337, 7664, 7800, 25, 6587, 198, 286, 551, 4310, 25, 1665, 4096, 315, 264, 29388, 198, 286, 551, 33613, 25, 551, 6587, 271, 286, 5295, 459, 1665, 4096, 315, 459, 16940, 29388, 505, 264, 2728, 5654, 627, 286, 3270, 286, 2105, 35690, 3191, 7800, 374, 2290, 477, 7664, 7800, 673, 493, 1058, 518, 13760, 624, 364, 9951, 57349, 4713, 286, 422, 5654, 374, 2290, 512, 310, 4933, 31908, 1480, 1021, 394, 364, 17001, 11907, 63868, 25, 5654, 2011, 387, 3984, 311, 636, 459, 16940, 29388, 4713, 286, 674, 19292, 584, 617, 21224, 433, 2736, 198, 286, 422, 5654, 304, 659, 1462, 57349, 11229, 3795, 21276, 512, 310, 471, 659, 1462, 57349, 11229, 3795, 21276, 58, 4030, 2595, 286, 422, 539, 7664, 7800, 512, 310, 7664, 7800, 284, 659, 43065, 2892, 286, 422, 5654, 539, 304, 7664, 7800, 681, 1610, 4001, 3883, 7352, 10786, 4019, 310, 4933, 31908, 1480, 493, 17001, 11907, 63868, 25, 279, 3728, 29388, 4792, 374, 539, 9147, 304, 5654, 26307, 2293, 1021, 394, 659, 673, 851, 1535, 5654, 4489, 286, 16940, 87518, 851, 284, 7664, 7800, 681, 1610, 4001, 3883, 10136, 4030, 5465, 57349, 4532, 286, 14142, 57349, 284, 14142, 3368, 920, 55, 63868, 7, 8154, 6852, 87518, 851, 340, 286, 14142, 57349, 11229, 284, 14142, 57349, 43065, 746, 286, 659, 1462, 57349, 11229, 3795, 21276, 284, 14142, 57349, 11229, 198, 286, 471, 14142, 57349, 11229, 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 ]
saltstack/salt
salt/modules/boto_kms.py
decrypt
def decrypt(ciphertext_blob, encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) r = {} try: plaintext = conn.decrypt( ciphertext_blob, encryption_context=encryption_context, grant_tokens=grant_tokens ) r['plaintext'] = plaintext['Plaintext'] except boto.exception.BotoServerError as e: r['error'] = __utils__['boto.get_error'](e) return r
python
def decrypt(ciphertext_blob, encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) r = {} try: plaintext = conn.decrypt( ciphertext_blob, encryption_context=encryption_context, grant_tokens=grant_tokens ) r['plaintext'] = plaintext['Plaintext'] except boto.exception.BotoServerError as e: r['error'] = __utils__['boto.get_error'](e) return r
[ "def", "decrypt", "(", "ciphertext_blob", ",", "encryption_context", "=", "None", ",", "grant_tokens", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid", "=", "keyid", ",", "profile", "=", "profile", ")", "r", "=", "{", "}", "try", ":", "plaintext", "=", "conn", ".", "decrypt", "(", "ciphertext_blob", ",", "encryption_context", "=", "encryption_context", ",", "grant_tokens", "=", "grant_tokens", ")", "r", "[", "'plaintext'", "]", "=", "plaintext", "[", "'Plaintext'", "]", "except", "boto", ".", "exception", ".", "BotoServerError", "as", "e", ":", "r", "[", "'error'", "]", "=", "__utils__", "[", "'boto.get_error'", "]", "(", "e", ")", "return", "r" ]
Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext
[ "Decrypt", "ciphertext", "." ]
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L156-L177
<|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: Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext ### Response: def decrypt(ciphertext_blob, encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) r = {} try: plaintext = conn.decrypt( ciphertext_blob, encryption_context=encryption_context, grant_tokens=grant_tokens ) r['plaintext'] = plaintext['Plaintext'] except boto.exception.BotoServerError as e: r['error'] = __utils__['boto.get_error'](e) return r <|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, 90760, 70889, 382, 262, 40377, 3187, 66152, 286, 12290, 856, 1083, 290, 61879, 4803, 1026, 81415, 25461, 669, 46143, 271, 14711, 6075, 512, 755, 39226, 1361, 46143, 47008, 11, 26542, 8634, 5980, 11, 13500, 29938, 5980, 345, 310, 5654, 5980, 11, 1401, 5980, 11, 1401, 307, 5980, 11, 5643, 5980, 997, 262, 11414, 262, 90246, 70889, 382, 262, 40377, 3187, 66152, 286, 12290, 856, 1083, 290, 61879, 4803, 1026, 81415, 25461, 669, 46143, 198, 262, 11414, 262, 4635, 284, 721, 456, 17686, 49159, 28, 4030, 11, 1401, 87682, 11, 1401, 307, 87682, 307, 11, 5643, 28, 5478, 696, 262, 436, 284, 5731, 262, 1456, 512, 286, 61947, 284, 4635, 81415, 1021, 310, 70889, 47008, 345, 310, 26542, 8634, 28, 81037, 8634, 345, 310, 13500, 29938, 28, 52727, 29938, 198, 286, 1763, 286, 436, 681, 72323, 663, 284, 61947, 681, 2169, 1673, 428, 4532, 262, 3734, 61879, 14161, 1823, 2117, 39609, 439, 384, 512, 286, 436, 681, 850, 663, 284, 1328, 6159, 565, 681, 65, 2117, 673, 4188, 85433, 68, 340, 262, 471, 436, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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382, 262, 40377, 3187, 66152, 286, 12290, 856, 1083, 290, 61879, 4803, 1026, 81415, 25461, 669, 46143, 271, 14711, 6075, 512, 755, 39226, 1361, 46143, 47008, 11, 26542, 8634, 5980, 11, 13500, 29938, 5980, 345, 310, 5654, 5980, 11, 1401, 5980, 11, 1401, 307, 5980, 11, 5643, 5980, 997, 262, 11414, 262, 90246, 70889, 382, 262, 40377, 3187, 66152, 286, 12290, 856, 1083, 290, 61879, 4803, 1026, 81415, 25461, 669, 46143, 198, 262, 11414, 262, 4635, 284, 721, 456, 17686, 49159, 28, 4030, 11, 1401, 87682, 11, 1401, 307, 87682, 307, 11, 5643, 28, 5478, 696, 262, 436, 284, 5731, 262, 1456, 512, 286, 61947, 284, 4635, 81415, 1021, 310, 70889, 47008, 345, 310, 26542, 8634, 28, 81037, 8634, 345, 310, 13500, 29938, 28, 52727, 29938, 198, 286, 1763, 286, 436, 681, 72323, 663, 284, 61947, 681, 2169, 1673, 428, 4532, 262, 3734, 61879, 14161, 1823, 2117, 39609, 439, 384, 512, 286, 436, 681, 850, 663, 284, 1328, 6159, 565, 681, 65, 2117, 673, 4188, 85433, 68, 340, 262, 471, 436, 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 ]
gr33ndata/dysl
dysl/dyslib/lm.py
LM.add_doc
def add_doc(self, doc_id ='', doc_terms=[], doc_length=-1): ''' Add new document to our Language Model (training phase) doc_id is used here, so we build seperate LF for each doc_id I.e. if you call it more than once with same doc_id, then all terms given via doc_terms will contribute to same LM doc_terms: list of words in document to be added doc_length: the length of the document, you can provide it yourself, otherwise, we use len(doc_terms) instead. ''' if doc_length == -1: self.update_lengths(doc_id=doc_id, doc_length=len(doc_terms)) else: self.update_lengths(doc_id=doc_id, doc_length=int(doc_length)) for term in doc_terms: self.vocabulary.add(term) terms = self.lr_padding(doc_terms) ngrams = self.to_ngrams(terms) self.update_counts(doc_id, ngrams)
python
def add_doc(self, doc_id ='', doc_terms=[], doc_length=-1): ''' Add new document to our Language Model (training phase) doc_id is used here, so we build seperate LF for each doc_id I.e. if you call it more than once with same doc_id, then all terms given via doc_terms will contribute to same LM doc_terms: list of words in document to be added doc_length: the length of the document, you can provide it yourself, otherwise, we use len(doc_terms) instead. ''' if doc_length == -1: self.update_lengths(doc_id=doc_id, doc_length=len(doc_terms)) else: self.update_lengths(doc_id=doc_id, doc_length=int(doc_length)) for term in doc_terms: self.vocabulary.add(term) terms = self.lr_padding(doc_terms) ngrams = self.to_ngrams(terms) self.update_counts(doc_id, ngrams)
[ "def", "add_doc", "(", "self", ",", "doc_id", "=", "''", ",", "doc_terms", "=", "[", "]", ",", "doc_length", "=", "-", "1", ")", ":", "if", "doc_length", "==", "-", "1", ":", "self", ".", "update_lengths", "(", "doc_id", "=", "doc_id", ",", "doc_length", "=", "len", "(", "doc_terms", ")", ")", "else", ":", "self", ".", "update_lengths", "(", "doc_id", "=", "doc_id", ",", "doc_length", "=", "int", "(", "doc_length", ")", ")", "for", "term", "in", "doc_terms", ":", "self", ".", "vocabulary", ".", "add", "(", "term", ")", "terms", "=", "self", ".", "lr_padding", "(", "doc_terms", ")", "ngrams", "=", "self", ".", "to_ngrams", "(", "terms", ")", "self", ".", "update_counts", "(", "doc_id", ",", "ngrams", ")" ]
Add new document to our Language Model (training phase) doc_id is used here, so we build seperate LF for each doc_id I.e. if you call it more than once with same doc_id, then all terms given via doc_terms will contribute to same LM doc_terms: list of words in document to be added doc_length: the length of the document, you can provide it yourself, otherwise, we use len(doc_terms) instead.
[ "Add", "new", "document", "to", "our", "Language", "Model", "(", "training", "phase", ")", "doc_id", "is", "used", "here", "so", "we", "build", "seperate", "LF", "for", "each", "doc_id", "I", ".", "e", ".", "if", "you", "call", "it", "more", "than", "once", "with", "same", "doc_id", "then", "all", "terms", "given", "via", "doc_terms", "will", "contribute", "to", "same", "LM", "doc_terms", ":", "list", "of", "words", "in", "document", "to", "be", "added", "doc_length", ":", "the", "length", "of", "the", "document", "you", "can", "provide", "it", "yourself", "otherwise", "we", "use", "len", "(", "doc_terms", ")", "instead", "." ]
train
https://github.com/gr33ndata/dysl/blob/649c1d6a1761f47d49a9842e7389f6df52039155/dysl/dyslib/lm.py#L290-L308
<|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 new document to our Language Model (training phase) doc_id is used here, so we build seperate LF for each doc_id I.e. if you call it more than once with same doc_id, then all terms given via doc_terms will contribute to same LM doc_terms: list of words in document to be added doc_length: the length of the document, you can provide it yourself, otherwise, we use len(doc_terms) instead. ### Response: def add_doc(self, doc_id ='', doc_terms=[], doc_length=-1): ''' Add new document to our Language Model (training phase) doc_id is used here, so we build seperate LF for each doc_id I.e. if you call it more than once with same doc_id, then all terms given via doc_terms will contribute to same LM doc_terms: list of words in document to be added doc_length: the length of the document, you can provide it yourself, otherwise, we use len(doc_terms) instead. ''' if doc_length == -1: self.update_lengths(doc_id=doc_id, doc_length=len(doc_terms)) else: self.update_lengths(doc_id=doc_id, doc_length=int(doc_length)) for term in doc_terms: self.vocabulary.add(term) terms = self.lr_padding(doc_terms) ngrams = self.to_ngrams(terms) self.update_counts(doc_id, ngrams) <|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, 502, 2246, 311, 1057, 11688, 5008, 320, 31754, 10474, 340, 286, 4733, 851, 374, 1511, 1618, 11, 779, 584, 1977, 84983, 58236, 369, 1855, 4733, 851, 198, 286, 358, 1770, 13, 422, 499, 1650, 433, 810, 1109, 3131, 449, 1890, 4733, 851, 345, 286, 1243, 682, 3878, 2728, 4669, 4733, 38598, 690, 17210, 311, 1890, 47514, 198, 286, 4733, 38598, 25, 1160, 315, 4339, 304, 2246, 311, 387, 3779, 720, 286, 4733, 5228, 25, 279, 3160, 315, 279, 2246, 11, 499, 649, 3493, 433, 6261, 345, 504, 6062, 11, 584, 1005, 2479, 19702, 38598, 8, 4619, 382, 14711, 6075, 512, 755, 923, 19401, 1214, 11, 4733, 851, 27576, 518, 4733, 38598, 67321, 4733, 5228, 11065, 16, 997, 286, 11414, 286, 2758, 502, 2246, 311, 1057, 11688, 5008, 320, 31754, 10474, 340, 286, 4733, 851, 374, 1511, 1618, 11, 779, 584, 1977, 84983, 58236, 369, 1855, 4733, 851, 198, 286, 358, 1770, 13, 422, 499, 1650, 433, 810, 1109, 3131, 449, 1890, 4733, 851, 345, 286, 1243, 682, 3878, 2728, 4669, 4733, 38598, 690, 17210, 311, 1890, 47514, 198, 286, 4733, 38598, 25, 1160, 315, 4339, 304, 2246, 311, 387, 3779, 720, 286, 4733, 5228, 25, 279, 3160, 315, 279, 2246, 11, 499, 649, 3493, 433, 6261, 345, 504, 6062, 11, 584, 1005, 2479, 19702, 38598, 8, 4619, 627, 286, 11414, 286, 422, 4733, 5228, 624, 482, 16, 512, 310, 659, 5430, 55516, 19702, 851, 28, 5349, 851, 11, 4733, 5228, 46919, 19702, 38598, 1192, 286, 775, 512, 310, 659, 5430, 55516, 19702, 851, 28, 5349, 851, 11, 4733, 5228, 16972, 19702, 5228, 595, 720, 286, 369, 4751, 304, 4733, 38598, 25, 720, 310, 659, 3211, 44627, 1388, 45754, 340, 286, 3878, 284, 659, 64449, 41826, 19702, 38598, 340, 286, 308, 51870, 284, 659, 2446, 1107, 51870, 7, 18853, 8, 1084, 286, 659, 5430, 27067, 19702, 851, 11, 308, 51870, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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, 502, 2246, 311, 1057, 11688, 5008, 320, 31754, 10474, 340, 286, 4733, 851, 374, 1511, 1618, 11, 779, 584, 1977, 84983, 58236, 369, 1855, 4733, 851, 198, 286, 358, 1770, 13, 422, 499, 1650, 433, 810, 1109, 3131, 449, 1890, 4733, 851, 345, 286, 1243, 682, 3878, 2728, 4669, 4733, 38598, 690, 17210, 311, 1890, 47514, 198, 286, 4733, 38598, 25, 1160, 315, 4339, 304, 2246, 311, 387, 3779, 720, 286, 4733, 5228, 25, 279, 3160, 315, 279, 2246, 11, 499, 649, 3493, 433, 6261, 345, 504, 6062, 11, 584, 1005, 2479, 19702, 38598, 8, 4619, 382, 14711, 6075, 512, 755, 923, 19401, 1214, 11, 4733, 851, 27576, 518, 4733, 38598, 67321, 4733, 5228, 11065, 16, 997, 286, 11414, 286, 2758, 502, 2246, 311, 1057, 11688, 5008, 320, 31754, 10474, 340, 286, 4733, 851, 374, 1511, 1618, 11, 779, 584, 1977, 84983, 58236, 369, 1855, 4733, 851, 198, 286, 358, 1770, 13, 422, 499, 1650, 433, 810, 1109, 3131, 449, 1890, 4733, 851, 345, 286, 1243, 682, 3878, 2728, 4669, 4733, 38598, 690, 17210, 311, 1890, 47514, 198, 286, 4733, 38598, 25, 1160, 315, 4339, 304, 2246, 311, 387, 3779, 720, 286, 4733, 5228, 25, 279, 3160, 315, 279, 2246, 11, 499, 649, 3493, 433, 6261, 345, 504, 6062, 11, 584, 1005, 2479, 19702, 38598, 8, 4619, 627, 286, 11414, 286, 422, 4733, 5228, 624, 482, 16, 512, 310, 659, 5430, 55516, 19702, 851, 28, 5349, 851, 11, 4733, 5228, 46919, 19702, 38598, 1192, 286, 775, 512, 310, 659, 5430, 55516, 19702, 851, 28, 5349, 851, 11, 4733, 5228, 16972, 19702, 5228, 595, 720, 286, 369, 4751, 304, 4733, 38598, 25, 720, 310, 659, 3211, 44627, 1388, 45754, 340, 286, 3878, 284, 659, 64449, 41826, 19702, 38598, 340, 286, 308, 51870, 284, 659, 2446, 1107, 51870, 7, 18853, 8, 1084, 286, 659, 5430, 27067, 19702, 851, 11, 308, 51870, 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 ]
HDI-Project/BTB
btb/selection/pure.py
PureBestKVelocity.compute_rewards
def compute_rewards(self, scores): """ Compute the "velocity" of (average distance between) the k+1 best scores. Return a list with those k velocities padded out with zeros so that the count remains the same. """ # get the k + 1 best scores in descending order best_scores = sorted(scores, reverse=True)[:self.k + 1] velocities = [best_scores[i] - best_scores[i + 1] for i in range(len(best_scores) - 1)] # pad the list out with zeros to maintain the length of the list zeros = (len(scores) - self.k) * [0] return velocities + zeros
python
def compute_rewards(self, scores): """ Compute the "velocity" of (average distance between) the k+1 best scores. Return a list with those k velocities padded out with zeros so that the count remains the same. """ # get the k + 1 best scores in descending order best_scores = sorted(scores, reverse=True)[:self.k + 1] velocities = [best_scores[i] - best_scores[i + 1] for i in range(len(best_scores) - 1)] # pad the list out with zeros to maintain the length of the list zeros = (len(scores) - self.k) * [0] return velocities + zeros
[ "def", "compute_rewards", "(", "self", ",", "scores", ")", ":", "# get the k + 1 best scores in descending order", "best_scores", "=", "sorted", "(", "scores", ",", "reverse", "=", "True", ")", "[", ":", "self", ".", "k", "+", "1", "]", "velocities", "=", "[", "best_scores", "[", "i", "]", "-", "best_scores", "[", "i", "+", "1", "]", "for", "i", "in", "range", "(", "len", "(", "best_scores", ")", "-", "1", ")", "]", "# pad the list out with zeros to maintain the length of the list", "zeros", "=", "(", "len", "(", "scores", ")", "-", "self", ".", "k", ")", "*", "[", "0", "]", "return", "velocities", "+", "zeros" ]
Compute the "velocity" of (average distance between) the k+1 best scores. Return a list with those k velocities padded out with zeros so that the count remains the same.
[ "Compute", "the", "velocity", "of", "(", "average", "distance", "between", ")", "the", "k", "+", "1", "best", "scores", ".", "Return", "a", "list", "with", "those", "k", "velocities", "padded", "out", "with", "zeros", "so", "that", "the", "count", "remains", "the", "same", "." ]
train
https://github.com/HDI-Project/BTB/blob/7f489ebc5591bd0886652ef743098c022d7f7460/btb/selection/pure.py#L23-L36
<|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 the "velocity" of (average distance between) the k+1 best scores. Return a list with those k velocities padded out with zeros so that the count remains the same. ### Response: def compute_rewards(self, scores): """ Compute the "velocity" of (average distance between) the k+1 best scores. Return a list with those k velocities padded out with zeros so that the count remains the same. """ # get the k + 1 best scores in descending order best_scores = sorted(scores, reverse=True)[:self.k + 1] velocities = [best_scores[i] - best_scores[i + 1] for i in range(len(best_scores) - 1)] # pad the list out with zeros to maintain the length of the list zeros = (len(scores) - self.k) * [0] return velocities + zeros <|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, 279, 330, 14982, 1, 315, 320, 17645, 6138, 1990, 8, 279, 597, 10, 16, 1888, 198, 286, 12483, 13, 3494, 264, 1160, 449, 1884, 597, 75157, 44968, 704, 449, 17975, 779, 198, 286, 430, 279, 1797, 8625, 279, 1890, 382, 14711, 6075, 512, 755, 12849, 79097, 1214, 11, 12483, 997, 286, 3270, 286, 23426, 279, 330, 14982, 1, 315, 320, 17645, 6138, 1990, 8, 279, 597, 10, 16, 1888, 198, 286, 12483, 13, 3494, 264, 1160, 449, 1884, 597, 75157, 44968, 704, 449, 17975, 779, 198, 286, 430, 279, 1797, 8625, 279, 1890, 627, 286, 3270, 286, 674, 636, 279, 597, 489, 220, 16, 1888, 12483, 304, 44184, 2015, 198, 286, 1888, 28297, 284, 10839, 64219, 11, 10134, 3702, 85662, 726, 5314, 489, 220, 16, 933, 286, 75157, 284, 510, 16241, 28297, 1004, 60, 482, 1888, 28297, 1004, 489, 220, 16, 933, 2611, 369, 602, 304, 2134, 7046, 60523, 28297, 8, 482, 220, 16, 28871, 286, 674, 11262, 279, 1160, 704, 449, 17975, 311, 10519, 279, 3160, 315, 279, 1160, 198, 286, 17975, 284, 320, 2963, 64219, 8, 482, 659, 5314, 8, 353, 510, 15, 933, 286, 471, 75157, 489, 17975, 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,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 279, 330, 14982, 1, 315, 320, 17645, 6138, 1990, 8, 279, 597, 10, 16, 1888, 198, 286, 12483, 13, 3494, 264, 1160, 449, 1884, 597, 75157, 44968, 704, 449, 17975, 779, 198, 286, 430, 279, 1797, 8625, 279, 1890, 382, 14711, 6075, 512, 755, 12849, 79097, 1214, 11, 12483, 997, 286, 3270, 286, 23426, 279, 330, 14982, 1, 315, 320, 17645, 6138, 1990, 8, 279, 597, 10, 16, 1888, 198, 286, 12483, 13, 3494, 264, 1160, 449, 1884, 597, 75157, 44968, 704, 449, 17975, 779, 198, 286, 430, 279, 1797, 8625, 279, 1890, 627, 286, 3270, 286, 674, 636, 279, 597, 489, 220, 16, 1888, 12483, 304, 44184, 2015, 198, 286, 1888, 28297, 284, 10839, 64219, 11, 10134, 3702, 85662, 726, 5314, 489, 220, 16, 933, 286, 75157, 284, 510, 16241, 28297, 1004, 60, 482, 1888, 28297, 1004, 489, 220, 16, 933, 2611, 369, 602, 304, 2134, 7046, 60523, 28297, 8, 482, 220, 16, 28871, 286, 674, 11262, 279, 1160, 704, 449, 17975, 311, 10519, 279, 3160, 315, 279, 1160, 198, 286, 17975, 284, 320, 2963, 64219, 8, 482, 659, 5314, 8, 353, 510, 15, 933, 286, 471, 75157, 489, 17975, 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 ]
python-gitlab/python-gitlab
gitlab/mixins.py
UpdateMixin.update
def update(self, id=None, new_data={}, **kwargs): """Update an object on the server. Args: id: ID of the object to update (can be None if not required) new_data: the update data for the object **kwargs: Extra options to send to the server (e.g. sudo) Returns: dict: The new object data (*not* a RESTObject) Raises: GitlabAuthenticationError: If authentication is not correct GitlabUpdateError: If the server cannot perform the request """ if id is None: path = self.path else: path = '%s/%s' % (self.path, id) self._check_missing_update_attrs(new_data) files = {} # We get the attributes that need some special transformation types = getattr(self, '_types', {}) if types: # Duplicate data to avoid messing with what the user sent us new_data = new_data.copy() for attr_name, type_cls in types.items(): if attr_name in new_data.keys(): type_obj = type_cls(new_data[attr_name]) # if the type if FileAttribute we need to pass the data as # file if issubclass(type_cls, g_types.FileAttribute): k = type_obj.get_file_name(attr_name) files[attr_name] = (k, new_data.pop(attr_name)) else: new_data[attr_name] = type_obj.get_for_api() http_method = self._get_update_method() return http_method(path, post_data=new_data, files=files, **kwargs)
python
def update(self, id=None, new_data={}, **kwargs): """Update an object on the server. Args: id: ID of the object to update (can be None if not required) new_data: the update data for the object **kwargs: Extra options to send to the server (e.g. sudo) Returns: dict: The new object data (*not* a RESTObject) Raises: GitlabAuthenticationError: If authentication is not correct GitlabUpdateError: If the server cannot perform the request """ if id is None: path = self.path else: path = '%s/%s' % (self.path, id) self._check_missing_update_attrs(new_data) files = {} # We get the attributes that need some special transformation types = getattr(self, '_types', {}) if types: # Duplicate data to avoid messing with what the user sent us new_data = new_data.copy() for attr_name, type_cls in types.items(): if attr_name in new_data.keys(): type_obj = type_cls(new_data[attr_name]) # if the type if FileAttribute we need to pass the data as # file if issubclass(type_cls, g_types.FileAttribute): k = type_obj.get_file_name(attr_name) files[attr_name] = (k, new_data.pop(attr_name)) else: new_data[attr_name] = type_obj.get_for_api() http_method = self._get_update_method() return http_method(path, post_data=new_data, files=files, **kwargs)
[ "def", "update", "(", "self", ",", "id", "=", "None", ",", "new_data", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "if", "id", "is", "None", ":", "path", "=", "self", ".", "path", "else", ":", "path", "=", "'%s/%s'", "%", "(", "self", ".", "path", ",", "id", ")", "self", ".", "_check_missing_update_attrs", "(", "new_data", ")", "files", "=", "{", "}", "# We get the attributes that need some special transformation", "types", "=", "getattr", "(", "self", ",", "'_types'", ",", "{", "}", ")", "if", "types", ":", "# Duplicate data to avoid messing with what the user sent us", "new_data", "=", "new_data", ".", "copy", "(", ")", "for", "attr_name", ",", "type_cls", "in", "types", ".", "items", "(", ")", ":", "if", "attr_name", "in", "new_data", ".", "keys", "(", ")", ":", "type_obj", "=", "type_cls", "(", "new_data", "[", "attr_name", "]", ")", "# if the type if FileAttribute we need to pass the data as", "# file", "if", "issubclass", "(", "type_cls", ",", "g_types", ".", "FileAttribute", ")", ":", "k", "=", "type_obj", ".", "get_file_name", "(", "attr_name", ")", "files", "[", "attr_name", "]", "=", "(", "k", ",", "new_data", ".", "pop", "(", "attr_name", ")", ")", "else", ":", "new_data", "[", "attr_name", "]", "=", "type_obj", ".", "get_for_api", "(", ")", "http_method", "=", "self", ".", "_get_update_method", "(", ")", "return", "http_method", "(", "path", ",", "post_data", "=", "new_data", ",", "files", "=", "files", ",", "*", "*", "kwargs", ")" ]
Update an object on the server. Args: id: ID of the object to update (can be None if not required) new_data: the update data for the object **kwargs: Extra options to send to the server (e.g. sudo) Returns: dict: The new object data (*not* a RESTObject) Raises: GitlabAuthenticationError: If authentication is not correct GitlabUpdateError: If the server cannot perform the request
[ "Update", "an", "object", "on", "the", "server", "." ]
train
https://github.com/python-gitlab/python-gitlab/blob/16de1b03fde3dbbe8f851614dd1d8c09de102fe5/gitlab/mixins.py#L241-L283
<|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: Update an object on the server. Args: id: ID of the object to update (can be None if not required) new_data: the update data for the object **kwargs: Extra options to send to the server (e.g. sudo) Returns: dict: The new object data (*not* a RESTObject) Raises: GitlabAuthenticationError: If authentication is not correct GitlabUpdateError: If the server cannot perform the request ### Response: def update(self, id=None, new_data={}, **kwargs): """Update an object on the server. Args: id: ID of the object to update (can be None if not required) new_data: the update data for the object **kwargs: Extra options to send to the server (e.g. sudo) Returns: dict: The new object data (*not* a RESTObject) Raises: GitlabAuthenticationError: If authentication is not correct GitlabUpdateError: If the server cannot perform the request """ if id is None: path = self.path else: path = '%s/%s' % (self.path, id) self._check_missing_update_attrs(new_data) files = {} # We get the attributes that need some special transformation types = getattr(self, '_types', {}) if types: # Duplicate data to avoid messing with what the user sent us new_data = new_data.copy() for attr_name, type_cls in types.items(): if attr_name in new_data.keys(): type_obj = type_cls(new_data[attr_name]) # if the type if FileAttribute we need to pass the data as # file if issubclass(type_cls, g_types.FileAttribute): k = type_obj.get_file_name(attr_name) files[attr_name] = (k, new_data.pop(attr_name)) else: new_data[attr_name] = type_obj.get_for_api() http_method = self._get_update_method() return http_method(path, post_data=new_data, files=files, **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, 4387, 459, 1665, 389, 279, 3622, 382, 286, 18161, 512, 310, 887, 25, 3110, 315, 279, 1665, 311, 2713, 320, 4919, 387, 2290, 422, 539, 2631, 340, 310, 502, 1807, 25, 279, 2713, 828, 369, 279, 1665, 198, 310, 3146, 9872, 25, 26041, 2671, 311, 3708, 311, 279, 3622, 320, 68, 1326, 13, 26481, 696, 286, 5295, 512, 310, 6587, 25, 578, 502, 1665, 828, 4712, 1962, 9, 264, 26487, 1211, 696, 286, 61411, 512, 310, 21804, 14717, 19855, 1480, 25, 1442, 17066, 374, 539, 4495, 198, 310, 21804, 14717, 4387, 1480, 25, 1442, 279, 3622, 4250, 2804, 279, 1715, 271, 14711, 6075, 512, 755, 2713, 1214, 11, 887, 5980, 11, 502, 1807, 68525, 3146, 9872, 997, 286, 4304, 4387, 459, 1665, 389, 279, 3622, 382, 286, 18161, 512, 310, 887, 25, 3110, 315, 279, 1665, 311, 2713, 320, 4919, 387, 2290, 422, 539, 2631, 340, 310, 502, 1807, 25, 279, 2713, 828, 369, 279, 1665, 198, 310, 3146, 9872, 25, 26041, 2671, 311, 3708, 311, 279, 3622, 320, 68, 1326, 13, 26481, 696, 286, 5295, 512, 310, 6587, 25, 578, 502, 1665, 828, 4712, 1962, 9, 264, 26487, 1211, 696, 286, 61411, 512, 310, 21804, 14717, 19855, 1480, 25, 1442, 17066, 374, 539, 4495, 198, 310, 21804, 14717, 4387, 1480, 25, 1442, 279, 3622, 4250, 2804, 279, 1715, 198, 286, 12713, 286, 422, 887, 374, 2290, 512, 310, 1853, 284, 659, 3960, 198, 286, 775, 512, 310, 1853, 284, 7832, 82, 12915, 82, 6, 1034, 320, 726, 3960, 11, 887, 696, 286, 659, 1462, 2071, 41547, 9058, 40678, 1792, 1807, 340, 286, 3626, 284, 10294, 286, 674, 1226, 636, 279, 8365, 430, 1205, 1063, 3361, 18475, 198, 286, 4595, 284, 31097, 1214, 11, 9418, 9426, 518, 36348, 286, 422, 4595, 512, 310, 674, 72171, 828, 311, 5766, 76851, 449, 1148, 279, 1217, 3288, 603, 198, 310, 502, 1807, 284, 502, 1807, 12511, 746, 310, 369, 6510, 1292, 11, 955, 39756, 304, 4595, 9812, 4019, 394, 422, 6510, 1292, 304, 502, 1807, 9301, 4019, 504, 955, 7478, 284, 955, 39756, 1792, 1807, 67562, 1292, 9801, 504, 674, 422, 279, 955, 422, 2958, 3994, 584, 1205, 311, 1522, 279, 828, 439, 198, 504, 674, 1052, 198, 504, 422, 374, 100217, 5930, 39756, 11, 342, 9962, 8744, 3994, 997, 667, 597, 284, 955, 7478, 673, 2517, 1292, 33531, 1292, 340, 667, 3626, 67562, 1292, 60, 284, 320, 74, 11, 502, 1807, 8452, 33531, 1292, 1192, 504, 775, 512, 667, 502, 1807, 67562, 1292, 60, 284, 955, 7478, 673, 5595, 11959, 2892, 286, 1795, 9209, 284, 659, 1462, 456, 9058, 9209, 746, 286, 471, 1795, 9209, 5698, 11, 1772, 1807, 8507, 1807, 11, 3626, 28, 7346, 11, 3146, 9872, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1, 1, 1, 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 ]
[ 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, 459, 1665, 389, 279, 3622, 382, 286, 18161, 512, 310, 887, 25, 3110, 315, 279, 1665, 311, 2713, 320, 4919, 387, 2290, 422, 539, 2631, 340, 310, 502, 1807, 25, 279, 2713, 828, 369, 279, 1665, 198, 310, 3146, 9872, 25, 26041, 2671, 311, 3708, 311, 279, 3622, 320, 68, 1326, 13, 26481, 696, 286, 5295, 512, 310, 6587, 25, 578, 502, 1665, 828, 4712, 1962, 9, 264, 26487, 1211, 696, 286, 61411, 512, 310, 21804, 14717, 19855, 1480, 25, 1442, 17066, 374, 539, 4495, 198, 310, 21804, 14717, 4387, 1480, 25, 1442, 279, 3622, 4250, 2804, 279, 1715, 271, 14711, 6075, 512, 755, 2713, 1214, 11, 887, 5980, 11, 502, 1807, 68525, 3146, 9872, 997, 286, 4304, 4387, 459, 1665, 389, 279, 3622, 382, 286, 18161, 512, 310, 887, 25, 3110, 315, 279, 1665, 311, 2713, 320, 4919, 387, 2290, 422, 539, 2631, 340, 310, 502, 1807, 25, 279, 2713, 828, 369, 279, 1665, 198, 310, 3146, 9872, 25, 26041, 2671, 311, 3708, 311, 279, 3622, 320, 68, 1326, 13, 26481, 696, 286, 5295, 512, 310, 6587, 25, 578, 502, 1665, 828, 4712, 1962, 9, 264, 26487, 1211, 696, 286, 61411, 512, 310, 21804, 14717, 19855, 1480, 25, 1442, 17066, 374, 539, 4495, 198, 310, 21804, 14717, 4387, 1480, 25, 1442, 279, 3622, 4250, 2804, 279, 1715, 198, 286, 12713, 286, 422, 887, 374, 2290, 512, 310, 1853, 284, 659, 3960, 198, 286, 775, 512, 310, 1853, 284, 7832, 82, 12915, 82, 6, 1034, 320, 726, 3960, 11, 887, 696, 286, 659, 1462, 2071, 41547, 9058, 40678, 1792, 1807, 340, 286, 3626, 284, 10294, 286, 674, 1226, 636, 279, 8365, 430, 1205, 1063, 3361, 18475, 198, 286, 4595, 284, 31097, 1214, 11, 9418, 9426, 518, 36348, 286, 422, 4595, 512, 310, 674, 72171, 828, 311, 5766, 76851, 449, 1148, 279, 1217, 3288, 603, 198, 310, 502, 1807, 284, 502, 1807, 12511, 746, 310, 369, 6510, 1292, 11, 955, 39756, 304, 4595, 9812, 4019, 394, 422, 6510, 1292, 304, 502, 1807, 9301, 4019, 504, 955, 7478, 284, 955, 39756, 1792, 1807, 67562, 1292, 9801, 504, 674, 422, 279, 955, 422, 2958, 3994, 584, 1205, 311, 1522, 279, 828, 439, 198, 504, 674, 1052, 198, 504, 422, 374, 100217, 5930, 39756, 11, 342, 9962, 8744, 3994, 997, 667, 597, 284, 955, 7478, 673, 2517, 1292, 33531, 1292, 340, 667, 3626, 67562, 1292, 60, 284, 320, 74, 11, 502, 1807, 8452, 33531, 1292, 1192, 504, 775, 512, 667, 502, 1807, 67562, 1292, 60, 284, 955, 7478, 673, 5595, 11959, 2892, 286, 1795, 9209, 284, 659, 1462, 456, 9058, 9209, 746, 286, 471, 1795, 9209, 5698, 11, 1772, 1807, 8507, 1807, 11, 3626, 28, 7346, 11, 3146, 9872, 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 ]
saltstack/salt
salt/states/file.py
absent
def absent(name, **kwargs): ''' Make sure that the named file or directory is absent. If it exists, it will be deleted. This will work to reverse any of the functions in the file state module. If a directory is supplied, it will be recursively deleted. name The path which should be deleted ''' name = os.path.expanduser(name) ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} if not name: return _error(ret, 'Must provide name to file.absent') if not os.path.isabs(name): return _error( ret, 'Specified file {0} is not an absolute path'.format(name) ) if name == '/': return _error(ret, 'Refusing to make "/" absent') if os.path.isfile(name) or os.path.islink(name): if __opts__['test']: ret['result'] = None ret['changes']['removed'] = name ret['comment'] = 'File {0} is set for removal'.format(name) return ret try: __salt__['file.remove'](name, force=True) ret['comment'] = 'Removed file {0}'.format(name) ret['changes']['removed'] = name return ret except CommandExecutionError as exc: return _error(ret, '{0}'.format(exc)) elif os.path.isdir(name): if __opts__['test']: ret['result'] = None ret['changes']['removed'] = name ret['comment'] = 'Directory {0} is set for removal'.format(name) return ret try: __salt__['file.remove'](name, force=True) ret['comment'] = 'Removed directory {0}'.format(name) ret['changes']['removed'] = name return ret except (OSError, IOError): return _error(ret, 'Failed to remove directory {0}'.format(name)) ret['comment'] = 'File {0} is not present'.format(name) return ret
python
def absent(name, **kwargs): ''' Make sure that the named file or directory is absent. If it exists, it will be deleted. This will work to reverse any of the functions in the file state module. If a directory is supplied, it will be recursively deleted. name The path which should be deleted ''' name = os.path.expanduser(name) ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} if not name: return _error(ret, 'Must provide name to file.absent') if not os.path.isabs(name): return _error( ret, 'Specified file {0} is not an absolute path'.format(name) ) if name == '/': return _error(ret, 'Refusing to make "/" absent') if os.path.isfile(name) or os.path.islink(name): if __opts__['test']: ret['result'] = None ret['changes']['removed'] = name ret['comment'] = 'File {0} is set for removal'.format(name) return ret try: __salt__['file.remove'](name, force=True) ret['comment'] = 'Removed file {0}'.format(name) ret['changes']['removed'] = name return ret except CommandExecutionError as exc: return _error(ret, '{0}'.format(exc)) elif os.path.isdir(name): if __opts__['test']: ret['result'] = None ret['changes']['removed'] = name ret['comment'] = 'Directory {0} is set for removal'.format(name) return ret try: __salt__['file.remove'](name, force=True) ret['comment'] = 'Removed directory {0}'.format(name) ret['changes']['removed'] = name return ret except (OSError, IOError): return _error(ret, 'Failed to remove directory {0}'.format(name)) ret['comment'] = 'File {0} is not present'.format(name) return ret
[ "def", "absent", "(", "name", ",", "*", "*", "kwargs", ")", ":", "name", "=", "os", ".", "path", ".", "expanduser", "(", "name", ")", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", "}", "if", "not", "name", ":", "return", "_error", "(", "ret", ",", "'Must provide name to file.absent'", ")", "if", "not", "os", ".", "path", ".", "isabs", "(", "name", ")", ":", "return", "_error", "(", "ret", ",", "'Specified file {0} is not an absolute path'", ".", "format", "(", "name", ")", ")", "if", "name", "==", "'/'", ":", "return", "_error", "(", "ret", ",", "'Refusing to make \"/\" absent'", ")", "if", "os", ".", "path", ".", "isfile", "(", "name", ")", "or", "os", ".", "path", ".", "islink", "(", "name", ")", ":", "if", "__opts__", "[", "'test'", "]", ":", "ret", "[", "'result'", "]", "=", "None", "ret", "[", "'changes'", "]", "[", "'removed'", "]", "=", "name", "ret", "[", "'comment'", "]", "=", "'File {0} is set for removal'", ".", "format", "(", "name", ")", "return", "ret", "try", ":", "__salt__", "[", "'file.remove'", "]", "(", "name", ",", "force", "=", "True", ")", "ret", "[", "'comment'", "]", "=", "'Removed file {0}'", ".", "format", "(", "name", ")", "ret", "[", "'changes'", "]", "[", "'removed'", "]", "=", "name", "return", "ret", "except", "CommandExecutionError", "as", "exc", ":", "return", "_error", "(", "ret", ",", "'{0}'", ".", "format", "(", "exc", ")", ")", "elif", "os", ".", "path", ".", "isdir", "(", "name", ")", ":", "if", "__opts__", "[", "'test'", "]", ":", "ret", "[", "'result'", "]", "=", "None", "ret", "[", "'changes'", "]", "[", "'removed'", "]", "=", "name", "ret", "[", "'comment'", "]", "=", "'Directory {0} is set for removal'", ".", "format", "(", "name", ")", "return", "ret", "try", ":", "__salt__", "[", "'file.remove'", "]", "(", "name", ",", "force", "=", "True", ")", "ret", "[", "'comment'", "]", "=", "'Removed directory {0}'", ".", "format", "(", "name", ")", "ret", "[", "'changes'", "]", "[", "'removed'", "]", "=", "name", "return", "ret", "except", "(", "OSError", ",", "IOError", ")", ":", "return", "_error", "(", "ret", ",", "'Failed to remove directory {0}'", ".", "format", "(", "name", ")", ")", "ret", "[", "'comment'", "]", "=", "'File {0} is not present'", ".", "format", "(", "name", ")", "return", "ret" ]
Make sure that the named file or directory is absent. If it exists, it will be deleted. This will work to reverse any of the functions in the file state module. If a directory is supplied, it will be recursively deleted. name The path which should be deleted
[ "Make", "sure", "that", "the", "named", "file", "or", "directory", "is", "absent", ".", "If", "it", "exists", "it", "will", "be", "deleted", ".", "This", "will", "work", "to", "reverse", "any", "of", "the", "functions", "in", "the", "file", "state", "module", ".", "If", "a", "directory", "is", "supplied", "it", "will", "be", "recursively", "deleted", "." ]
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/file.py#L1717-L1770
<|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 sure that the named file or directory is absent. If it exists, it will be deleted. This will work to reverse any of the functions in the file state module. If a directory is supplied, it will be recursively deleted. name The path which should be deleted ### Response: def absent(name, **kwargs): ''' Make sure that the named file or directory is absent. If it exists, it will be deleted. This will work to reverse any of the functions in the file state module. If a directory is supplied, it will be recursively deleted. name The path which should be deleted ''' name = os.path.expanduser(name) ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} if not name: return _error(ret, 'Must provide name to file.absent') if not os.path.isabs(name): return _error( ret, 'Specified file {0} is not an absolute path'.format(name) ) if name == '/': return _error(ret, 'Refusing to make "/" absent') if os.path.isfile(name) or os.path.islink(name): if __opts__['test']: ret['result'] = None ret['changes']['removed'] = name ret['comment'] = 'File {0} is set for removal'.format(name) return ret try: __salt__['file.remove'](name, force=True) ret['comment'] = 'Removed file {0}'.format(name) ret['changes']['removed'] = name return ret except CommandExecutionError as exc: return _error(ret, '{0}'.format(exc)) elif os.path.isdir(name): if __opts__['test']: ret['result'] = None ret['changes']['removed'] = name ret['comment'] = 'Directory {0} is set for removal'.format(name) return ret try: __salt__['file.remove'](name, force=True) ret['comment'] = 'Removed directory {0}'.format(name) ret['changes']['removed'] = name return ret except (OSError, IOError): return _error(ret, 'Failed to remove directory {0}'.format(name)) ret['comment'] = 'File {0} is not present'.format(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, 8238, 2771, 430, 279, 7086, 1052, 477, 6352, 374, 28310, 13, 1442, 433, 6866, 11, 433, 690, 198, 262, 387, 11309, 13, 1115, 690, 990, 311, 10134, 904, 315, 279, 5865, 304, 279, 1052, 198, 262, 1614, 4793, 13, 1442, 264, 6352, 374, 17665, 11, 433, 690, 387, 53947, 11309, 382, 262, 836, 198, 286, 578, 1853, 902, 1288, 387, 11309, 271, 14711, 6075, 512, 755, 28310, 3232, 345, 1881, 3146, 9872, 997, 262, 11414, 262, 7557, 2771, 430, 279, 7086, 1052, 477, 6352, 374, 28310, 13, 1442, 433, 6866, 11, 433, 690, 198, 262, 387, 11309, 13, 1115, 690, 990, 311, 10134, 904, 315, 279, 5865, 304, 279, 1052, 198, 262, 1614, 4793, 13, 1442, 264, 6352, 374, 17665, 11, 433, 690, 387, 53947, 11309, 382, 262, 836, 198, 286, 578, 1853, 902, 1288, 387, 11309, 198, 262, 11414, 262, 836, 284, 2709, 3960, 28837, 882, 3232, 696, 262, 2160, 284, 5473, 609, 1232, 836, 345, 1881, 364, 19926, 1232, 14915, 1881, 364, 1407, 1232, 3082, 345, 1881, 364, 6313, 1232, 76452, 262, 422, 539, 836, 512, 286, 471, 721, 850, 16442, 11, 364, 32876, 3493, 836, 311, 1052, 14914, 306, 1329, 262, 422, 539, 2709, 3960, 2124, 3518, 3232, 997, 286, 471, 721, 850, 1021, 310, 2160, 11, 364, 8491, 1908, 1052, 314, 15, 92, 374, 539, 459, 10973, 1853, 4527, 2293, 3232, 340, 286, 1763, 262, 422, 836, 624, 3434, 3730, 286, 471, 721, 850, 16442, 11, 364, 4032, 985, 311, 1304, 17318, 28310, 1329, 262, 422, 2709, 3960, 40047, 3232, 8, 477, 2709, 3960, 2124, 2125, 3232, 997, 286, 422, 1328, 10740, 565, 681, 1985, 18888, 310, 2160, 681, 1407, 663, 284, 2290, 198, 310, 2160, 681, 19926, 4274, 46856, 663, 284, 836, 198, 310, 2160, 681, 6313, 663, 284, 364, 1738, 314, 15, 92, 374, 743, 369, 17065, 4527, 2293, 3232, 340, 310, 471, 2160, 198, 286, 1456, 512, 310, 1328, 43326, 565, 681, 1213, 4955, 85433, 609, 11, 5457, 3702, 340, 310, 2160, 681, 6313, 663, 284, 364, 43742, 1052, 314, 15, 24398, 2293, 3232, 340, 310, 2160, 681, 19926, 4274, 46856, 663, 284, 836, 198, 310, 471, 2160, 198, 286, 3734, 7498, 20912, 1480, 439, 3521, 512, 310, 471, 721, 850, 16442, 11, 11834, 15, 24398, 2293, 73955, 4489, 262, 4508, 2709, 3960, 49261, 3232, 997, 286, 422, 1328, 10740, 565, 681, 1985, 18888, 310, 2160, 681, 1407, 663, 284, 2290, 198, 310, 2160, 681, 19926, 4274, 46856, 663, 284, 836, 198, 310, 2160, 681, 6313, 663, 284, 364, 9494, 314, 15, 92, 374, 743, 369, 17065, 4527, 2293, 3232, 340, 310, 471, 2160, 198, 286, 1456, 512, 310, 1328, 43326, 565, 681, 1213, 4955, 85433, 609, 11, 5457, 3702, 340, 310, 2160, 681, 6313, 663, 284, 364, 43742, 6352, 314, 15, 24398, 2293, 3232, 340, 310, 2160, 681, 19926, 4274, 46856, 663, 284, 836, 198 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 8238, 2771, 430, 279, 7086, 1052, 477, 6352, 374, 28310, 13, 1442, 433, 6866, 11, 433, 690, 198, 262, 387, 11309, 13, 1115, 690, 990, 311, 10134, 904, 315, 279, 5865, 304, 279, 1052, 198, 262, 1614, 4793, 13, 1442, 264, 6352, 374, 17665, 11, 433, 690, 387, 53947, 11309, 382, 262, 836, 198, 286, 578, 1853, 902, 1288, 387, 11309, 271, 14711, 6075, 512, 755, 28310, 3232, 345, 1881, 3146, 9872, 997, 262, 11414, 262, 7557, 2771, 430, 279, 7086, 1052, 477, 6352, 374, 28310, 13, 1442, 433, 6866, 11, 433, 690, 198, 262, 387, 11309, 13, 1115, 690, 990, 311, 10134, 904, 315, 279, 5865, 304, 279, 1052, 198, 262, 1614, 4793, 13, 1442, 264, 6352, 374, 17665, 11, 433, 690, 387, 53947, 11309, 382, 262, 836, 198, 286, 578, 1853, 902, 1288, 387, 11309, 198, 262, 11414, 262, 836, 284, 2709, 3960, 28837, 882, 3232, 696, 262, 2160, 284, 5473, 609, 1232, 836, 345, 1881, 364, 19926, 1232, 14915, 1881, 364, 1407, 1232, 3082, 345, 1881, 364, 6313, 1232, 76452, 262, 422, 539, 836, 512, 286, 471, 721, 850, 16442, 11, 364, 32876, 3493, 836, 311, 1052, 14914, 306, 1329, 262, 422, 539, 2709, 3960, 2124, 3518, 3232, 997, 286, 471, 721, 850, 1021, 310, 2160, 11, 364, 8491, 1908, 1052, 314, 15, 92, 374, 539, 459, 10973, 1853, 4527, 2293, 3232, 340, 286, 1763, 262, 422, 836, 624, 3434, 3730, 286, 471, 721, 850, 16442, 11, 364, 4032, 985, 311, 1304, 17318, 28310, 1329, 262, 422, 2709, 3960, 40047, 3232, 8, 477, 2709, 3960, 2124, 2125, 3232, 997, 286, 422, 1328, 10740, 565, 681, 1985, 18888, 310, 2160, 681, 1407, 663, 284, 2290, 198, 310, 2160, 681, 19926, 4274, 46856, 663, 284, 836, 198, 310, 2160, 681, 6313, 663, 284, 364, 1738, 314, 15, 92, 374, 743, 369, 17065, 4527, 2293, 3232, 340, 310, 471, 2160, 198, 286, 1456, 512, 310, 1328, 43326, 565, 681, 1213, 4955, 85433, 609, 11, 5457, 3702, 340, 310, 2160, 681, 6313, 663, 284, 364, 43742, 1052, 314, 15, 24398, 2293, 3232, 340, 310, 2160, 681, 19926, 4274, 46856, 663, 284, 836, 198, 310, 471, 2160, 198, 286, 3734, 7498, 20912, 1480, 439, 3521, 512, 310, 471, 721, 850, 16442, 11, 11834, 15, 24398, 2293, 73955, 4489, 262, 4508, 2709, 3960, 49261, 3232, 997, 286, 422, 1328, 10740, 565, 681, 1985, 18888, 310, 2160, 681, 1407, 663, 284, 2290, 198, 310, 2160, 681, 19926, 4274, 46856, 663, 284, 836, 198, 310, 2160, 681, 6313, 663, 284, 364, 9494, 314, 15, 92, 374, 743, 369, 17065, 4527, 2293, 3232, 340, 310, 471, 2160, 198, 286, 1456, 512, 310, 1328, 43326, 565, 681, 1213, 4955, 85433, 609, 11, 5457, 3702, 340, 310, 2160, 681, 6313, 663, 284, 364, 43742, 6352, 314, 15, 24398, 2293, 3232, 340, 310, 2160, 681, 19926, 4274, 46856, 663, 284, 836, 198 ]
maoaiz/django-admin-conf-vars
django_admin_conf_vars/global_vars.py
VariablesManager.set
def set(self, name, default=0, editable=True, description=""): '''Define a variable in DB and in memory''' var, created = ConfigurationVariable.objects.get_or_create(name=name) if created: var.value = default if not editable: var.value = default var.editable = editable var.description = description var.save(reload=False) # ATTRIBUTES is accesible by any instance of VariablesManager self.ATTRIBUTES[var.name] = var.value
python
def set(self, name, default=0, editable=True, description=""): '''Define a variable in DB and in memory''' var, created = ConfigurationVariable.objects.get_or_create(name=name) if created: var.value = default if not editable: var.value = default var.editable = editable var.description = description var.save(reload=False) # ATTRIBUTES is accesible by any instance of VariablesManager self.ATTRIBUTES[var.name] = var.value
[ "def", "set", "(", "self", ",", "name", ",", "default", "=", "0", ",", "editable", "=", "True", ",", "description", "=", "\"\"", ")", ":", "var", ",", "created", "=", "ConfigurationVariable", ".", "objects", ".", "get_or_create", "(", "name", "=", "name", ")", "if", "created", ":", "var", ".", "value", "=", "default", "if", "not", "editable", ":", "var", ".", "value", "=", "default", "var", ".", "editable", "=", "editable", "var", ".", "description", "=", "description", "var", ".", "save", "(", "reload", "=", "False", ")", "# ATTRIBUTES is accesible by any instance of VariablesManager", "self", ".", "ATTRIBUTES", "[", "var", ".", "name", "]", "=", "var", ".", "value" ]
Define a variable in DB and in memory
[ "Define", "a", "variable", "in", "DB", "and", "in", "memory" ]
train
https://github.com/maoaiz/django-admin-conf-vars/blob/f18ddb62647719e3612ea87ee866fb27b901ac27/django_admin_conf_vars/global_vars.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: Define a variable in DB and in memory ### Response: def set(self, name, default=0, editable=True, description=""): '''Define a variable in DB and in memory''' var, created = ConfigurationVariable.objects.get_or_create(name=name) if created: var.value = default if not editable: var.value = default var.editable = editable var.description = description var.save(reload=False) # ATTRIBUTES is accesible by any instance of VariablesManager self.ATTRIBUTES[var.name] = var.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, 36438, 264, 3977, 304, 6078, 323, 304, 5044, 271, 14711, 6075, 512, 755, 743, 1214, 11, 836, 11, 1670, 28, 15, 11, 38509, 3702, 11, 4096, 429, 15497, 286, 11712, 36438, 264, 3977, 304, 6078, 323, 304, 5044, 34794, 286, 767, 11, 3549, 284, 12499, 7983, 8549, 673, 8908, 8827, 3232, 40341, 696, 286, 422, 3549, 512, 310, 767, 2894, 284, 1670, 271, 286, 422, 539, 38509, 512, 310, 767, 2894, 284, 1670, 271, 286, 767, 13007, 481, 284, 38509, 198, 286, 767, 13480, 284, 4096, 198, 286, 767, 5799, 5921, 1096, 5725, 696, 286, 674, 39018, 50246, 374, 85195, 1260, 555, 904, 2937, 315, 22134, 2087, 198, 286, 659, 13, 28980, 50246, 53837, 2710, 60, 284, 767, 2894, 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, 128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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 36438, 264, 3977, 304, 6078, 323, 304, 5044, 271, 14711, 6075, 512, 755, 743, 1214, 11, 836, 11, 1670, 28, 15, 11, 38509, 3702, 11, 4096, 429, 15497, 286, 11712, 36438, 264, 3977, 304, 6078, 323, 304, 5044, 34794, 286, 767, 11, 3549, 284, 12499, 7983, 8549, 673, 8908, 8827, 3232, 40341, 696, 286, 422, 3549, 512, 310, 767, 2894, 284, 1670, 271, 286, 422, 539, 38509, 512, 310, 767, 2894, 284, 1670, 271, 286, 767, 13007, 481, 284, 38509, 198, 286, 767, 13480, 284, 4096, 198, 286, 767, 5799, 5921, 1096, 5725, 696, 286, 674, 39018, 50246, 374, 85195, 1260, 555, 904, 2937, 315, 22134, 2087, 198, 286, 659, 13, 28980, 50246, 53837, 2710, 60, 284, 767, 2894, 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 ]
abilian/abilian-core
abilian/i18n.py
country_choices
def country_choices(first=None, default_country_first=True): """Return a list of (code, countries), alphabetically sorted on localized country name. :param first: Country code to be placed at the top :param default_country_first: :type default_country_first: bool """ locale = _get_locale() territories = [ (code, name) for code, name in locale.territories.items() if len(code) == 2 ] # skip 3-digit regions if first is None and default_country_first: first = default_country() def sortkey(item): if first is not None and item[0] == first: return "0" return to_lower_ascii(item[1]) territories.sort(key=sortkey) return territories
python
def country_choices(first=None, default_country_first=True): """Return a list of (code, countries), alphabetically sorted on localized country name. :param first: Country code to be placed at the top :param default_country_first: :type default_country_first: bool """ locale = _get_locale() territories = [ (code, name) for code, name in locale.territories.items() if len(code) == 2 ] # skip 3-digit regions if first is None and default_country_first: first = default_country() def sortkey(item): if first is not None and item[0] == first: return "0" return to_lower_ascii(item[1]) territories.sort(key=sortkey) return territories
[ "def", "country_choices", "(", "first", "=", "None", ",", "default_country_first", "=", "True", ")", ":", "locale", "=", "_get_locale", "(", ")", "territories", "=", "[", "(", "code", ",", "name", ")", "for", "code", ",", "name", "in", "locale", ".", "territories", ".", "items", "(", ")", "if", "len", "(", "code", ")", "==", "2", "]", "# skip 3-digit regions", "if", "first", "is", "None", "and", "default_country_first", ":", "first", "=", "default_country", "(", ")", "def", "sortkey", "(", "item", ")", ":", "if", "first", "is", "not", "None", "and", "item", "[", "0", "]", "==", "first", ":", "return", "\"0\"", "return", "to_lower_ascii", "(", "item", "[", "1", "]", ")", "territories", ".", "sort", "(", "key", "=", "sortkey", ")", "return", "territories" ]
Return a list of (code, countries), alphabetically sorted on localized country name. :param first: Country code to be placed at the top :param default_country_first: :type default_country_first: bool
[ "Return", "a", "list", "of", "(", "code", "countries", ")", "alphabetically", "sorted", "on", "localized", "country", "name", "." ]
train
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/i18n.py#L125-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: Return a list of (code, countries), alphabetically sorted on localized country name. :param first: Country code to be placed at the top :param default_country_first: :type default_country_first: bool ### Response: def country_choices(first=None, default_country_first=True): """Return a list of (code, countries), alphabetically sorted on localized country name. :param first: Country code to be placed at the top :param default_country_first: :type default_country_first: bool """ locale = _get_locale() territories = [ (code, name) for code, name in locale.territories.items() if len(code) == 2 ] # skip 3-digit regions if first is None and default_country_first: first = default_country() def sortkey(item): if first is not None and item[0] == first: return "0" return to_lower_ascii(item[1]) territories.sort(key=sortkey) return territories <|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, 1160, 315, 320, 1889, 11, 5961, 705, 28890, 2740, 10839, 389, 44589, 198, 262, 3224, 836, 382, 262, 551, 913, 1176, 25, 14438, 2082, 311, 387, 9277, 520, 279, 1948, 198, 262, 551, 913, 1670, 29206, 13275, 512, 262, 551, 1337, 1670, 29206, 13275, 25, 1845, 271, 14711, 6075, 512, 755, 3224, 63009, 18465, 5980, 11, 1670, 29206, 13275, 3702, 997, 262, 4304, 5715, 264, 1160, 315, 320, 1889, 11, 5961, 705, 28890, 2740, 10839, 389, 44589, 198, 262, 3224, 836, 382, 262, 551, 913, 1176, 25, 14438, 2082, 311, 387, 9277, 520, 279, 1948, 198, 262, 551, 913, 1670, 29206, 13275, 512, 262, 551, 1337, 1670, 29206, 13275, 25, 1845, 198, 262, 3270, 262, 19076, 284, 721, 456, 56618, 746, 262, 39543, 284, 2330, 286, 320, 1889, 11, 836, 8, 369, 2082, 11, 836, 304, 19076, 13, 96315, 2490, 9812, 368, 422, 2479, 16221, 8, 624, 220, 17, 198, 262, 2331, 220, 674, 10936, 220, 18, 49442, 13918, 271, 262, 422, 1176, 374, 2290, 323, 1670, 29206, 13275, 512, 286, 1176, 284, 1670, 29206, 2892, 262, 711, 3460, 798, 5508, 997, 286, 422, 1176, 374, 539, 2290, 323, 1537, 58, 15, 60, 624, 1176, 512, 310, 471, 330, 15, 702, 286, 471, 311, 31525, 51338, 5508, 58, 16, 9801, 262, 39543, 10838, 4962, 28, 7003, 798, 340, 262, 471, 39543, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1160, 315, 320, 1889, 11, 5961, 705, 28890, 2740, 10839, 389, 44589, 198, 262, 3224, 836, 382, 262, 551, 913, 1176, 25, 14438, 2082, 311, 387, 9277, 520, 279, 1948, 198, 262, 551, 913, 1670, 29206, 13275, 512, 262, 551, 1337, 1670, 29206, 13275, 25, 1845, 271, 14711, 6075, 512, 755, 3224, 63009, 18465, 5980, 11, 1670, 29206, 13275, 3702, 997, 262, 4304, 5715, 264, 1160, 315, 320, 1889, 11, 5961, 705, 28890, 2740, 10839, 389, 44589, 198, 262, 3224, 836, 382, 262, 551, 913, 1176, 25, 14438, 2082, 311, 387, 9277, 520, 279, 1948, 198, 262, 551, 913, 1670, 29206, 13275, 512, 262, 551, 1337, 1670, 29206, 13275, 25, 1845, 198, 262, 3270, 262, 19076, 284, 721, 456, 56618, 746, 262, 39543, 284, 2330, 286, 320, 1889, 11, 836, 8, 369, 2082, 11, 836, 304, 19076, 13, 96315, 2490, 9812, 368, 422, 2479, 16221, 8, 624, 220, 17, 198, 262, 2331, 220, 674, 10936, 220, 18, 49442, 13918, 271, 262, 422, 1176, 374, 2290, 323, 1670, 29206, 13275, 512, 286, 1176, 284, 1670, 29206, 2892, 262, 711, 3460, 798, 5508, 997, 286, 422, 1176, 374, 539, 2290, 323, 1537, 58, 15, 60, 624, 1176, 512, 310, 471, 330, 15, 702, 286, 471, 311, 31525, 51338, 5508, 58, 16, 9801, 262, 39543, 10838, 4962, 28, 7003, 798, 340, 262, 471, 39543, 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 ]
ChrisCummins/labm8
labtypes.py
dict_values
def dict_values(src): """ Recursively get values in dict. Unlike the builtin dict.values() function, this method will descend into nested dicts, returning all nested values. Arguments: src (dict): Source dict. Returns: list: List of values. """ for v in src.values(): if isinstance(v, dict): for v in dict_values(v): yield v else: yield v
python
def dict_values(src): """ Recursively get values in dict. Unlike the builtin dict.values() function, this method will descend into nested dicts, returning all nested values. Arguments: src (dict): Source dict. Returns: list: List of values. """ for v in src.values(): if isinstance(v, dict): for v in dict_values(v): yield v else: yield v
[ "def", "dict_values", "(", "src", ")", ":", "for", "v", "in", "src", ".", "values", "(", ")", ":", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "for", "v", "in", "dict_values", "(", "v", ")", ":", "yield", "v", "else", ":", "yield", "v" ]
Recursively get values in dict. Unlike the builtin dict.values() function, this method will descend into nested dicts, returning all nested values. Arguments: src (dict): Source dict. Returns: list: List of values.
[ "Recursively", "get", "values", "in", "dict", "." ]
train
https://github.com/ChrisCummins/labm8/blob/dd10d67a757aefb180cb508f86696f99440c94f5/labtypes.py#L85-L103
<|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: Recursively get values in dict. Unlike the builtin dict.values() function, this method will descend into nested dicts, returning all nested values. Arguments: src (dict): Source dict. Returns: list: List of values. ### Response: def dict_values(src): """ Recursively get values in dict. Unlike the builtin dict.values() function, this method will descend into nested dicts, returning all nested values. Arguments: src (dict): Source dict. Returns: list: List of values. """ for v in src.values(): if isinstance(v, dict): for v in dict_values(v): yield v else: yield v <|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, 3905, 80837, 636, 2819, 304, 6587, 382, 262, 27140, 279, 60726, 6587, 10883, 368, 734, 11, 420, 1749, 690, 55668, 1139, 198, 262, 24997, 98699, 11, 13758, 682, 24997, 2819, 382, 262, 28802, 512, 286, 2338, 320, 8644, 1680, 8922, 6587, 382, 262, 5295, 512, 286, 1160, 25, 1796, 315, 2819, 382, 14711, 6075, 512, 755, 6587, 9324, 15047, 997, 262, 3270, 262, 4158, 80837, 636, 2819, 304, 6587, 382, 262, 27140, 279, 60726, 6587, 10883, 368, 734, 11, 420, 1749, 690, 55668, 1139, 198, 262, 24997, 98699, 11, 13758, 682, 24997, 2819, 382, 262, 28802, 512, 286, 2338, 320, 8644, 1680, 8922, 6587, 382, 262, 5295, 512, 286, 1160, 25, 1796, 315, 2819, 627, 262, 3270, 262, 369, 348, 304, 2338, 10883, 4019, 286, 422, 11656, 3832, 11, 6587, 997, 310, 369, 348, 304, 6587, 9324, 3832, 997, 394, 7692, 348, 198, 286, 775, 512, 310, 7692, 348, 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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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 3905, 80837, 636, 2819, 304, 6587, 382, 262, 27140, 279, 60726, 6587, 10883, 368, 734, 11, 420, 1749, 690, 55668, 1139, 198, 262, 24997, 98699, 11, 13758, 682, 24997, 2819, 382, 262, 28802, 512, 286, 2338, 320, 8644, 1680, 8922, 6587, 382, 262, 5295, 512, 286, 1160, 25, 1796, 315, 2819, 382, 14711, 6075, 512, 755, 6587, 9324, 15047, 997, 262, 3270, 262, 4158, 80837, 636, 2819, 304, 6587, 382, 262, 27140, 279, 60726, 6587, 10883, 368, 734, 11, 420, 1749, 690, 55668, 1139, 198, 262, 24997, 98699, 11, 13758, 682, 24997, 2819, 382, 262, 28802, 512, 286, 2338, 320, 8644, 1680, 8922, 6587, 382, 262, 5295, 512, 286, 1160, 25, 1796, 315, 2819, 627, 262, 3270, 262, 369, 348, 304, 2338, 10883, 4019, 286, 422, 11656, 3832, 11, 6587, 997, 310, 369, 348, 304, 6587, 9324, 3832, 997, 394, 7692, 348, 198, 286, 775, 512, 310, 7692, 348, 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 ]
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_units
def parse_units(self, stream): """ UnitsExpression ::= UnitsStart WhiteSpace* UnitsValue WhiteSpace* UnitsEnd """ value = b'' self.expect(stream, self.begin_units) while not self.has_next(self.end_units, stream): if self.has_eof(stream): self.raise_unexpected_eof(stream) value += stream.read(1) self.expect(stream, self.end_units) return value.strip(b''.join(self.whitespace)).decode('utf-8')
python
def parse_units(self, stream): """ UnitsExpression ::= UnitsStart WhiteSpace* UnitsValue WhiteSpace* UnitsEnd """ value = b'' self.expect(stream, self.begin_units) while not self.has_next(self.end_units, stream): if self.has_eof(stream): self.raise_unexpected_eof(stream) value += stream.read(1) self.expect(stream, self.end_units) return value.strip(b''.join(self.whitespace)).decode('utf-8')
[ "def", "parse_units", "(", "self", ",", "stream", ")", ":", "value", "=", "b''", "self", ".", "expect", "(", "stream", ",", "self", ".", "begin_units", ")", "while", "not", "self", ".", "has_next", "(", "self", ".", "end_units", ",", "stream", ")", ":", "if", "self", ".", "has_eof", "(", "stream", ")", ":", "self", ".", "raise_unexpected_eof", "(", "stream", ")", "value", "+=", "stream", ".", "read", "(", "1", ")", "self", ".", "expect", "(", "stream", ",", "self", ".", "end_units", ")", "return", "value", ".", "strip", "(", "b''", ".", "join", "(", "self", ".", "whitespace", ")", ")", ".", "decode", "(", "'utf-8'", ")" ]
UnitsExpression ::= UnitsStart WhiteSpace* UnitsValue WhiteSpace* UnitsEnd
[ "UnitsExpression", "::", "=", "UnitsStart", "WhiteSpace", "*", "UnitsValue", "WhiteSpace", "*", "UnitsEnd" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L552-L566
<|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: UnitsExpression ::= UnitsStart WhiteSpace* UnitsValue WhiteSpace* UnitsEnd ### Response: def parse_units(self, stream): """ UnitsExpression ::= UnitsStart WhiteSpace* UnitsValue WhiteSpace* UnitsEnd """ value = b'' self.expect(stream, self.begin_units) while not self.has_next(self.end_units, stream): if self.has_eof(stream): self.raise_unexpected_eof(stream) value += stream.read(1) self.expect(stream, self.end_units) return value.strip(b''.join(self.whitespace)).decode('utf-8') <|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, 27411, 9790, 3588, 15092, 310, 36281, 3563, 5929, 10115, 9, 36281, 1150, 5929, 10115, 9, 36281, 3812, 271, 14711, 6075, 512, 755, 4820, 29445, 1214, 11, 4365, 997, 286, 3270, 286, 36281, 9790, 3588, 15092, 310, 36281, 3563, 5929, 10115, 9, 36281, 1150, 5929, 10115, 9, 36281, 3812, 198, 286, 3270, 286, 907, 284, 293, 72572, 286, 659, 27042, 21217, 11, 659, 6991, 29445, 696, 286, 1418, 539, 659, 7001, 11507, 1214, 5183, 29445, 11, 4365, 997, 310, 422, 659, 7001, 91892, 21217, 997, 394, 659, 68934, 5012, 7475, 91892, 21217, 340, 310, 907, 1447, 4365, 4217, 7, 16, 696, 286, 659, 27042, 21217, 11, 659, 5183, 29445, 340, 286, 471, 907, 17624, 1921, 98722, 6115, 1214, 47836, 37174, 4682, 18696, 493, 4867, 12, 23, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 27411, 9790, 3588, 15092, 310, 36281, 3563, 5929, 10115, 9, 36281, 1150, 5929, 10115, 9, 36281, 3812, 271, 14711, 6075, 512, 755, 4820, 29445, 1214, 11, 4365, 997, 286, 3270, 286, 36281, 9790, 3588, 15092, 310, 36281, 3563, 5929, 10115, 9, 36281, 1150, 5929, 10115, 9, 36281, 3812, 198, 286, 3270, 286, 907, 284, 293, 72572, 286, 659, 27042, 21217, 11, 659, 6991, 29445, 696, 286, 1418, 539, 659, 7001, 11507, 1214, 5183, 29445, 11, 4365, 997, 310, 422, 659, 7001, 91892, 21217, 997, 394, 659, 68934, 5012, 7475, 91892, 21217, 340, 310, 907, 1447, 4365, 4217, 7, 16, 696, 286, 659, 27042, 21217, 11, 659, 5183, 29445, 340, 286, 471, 907, 17624, 1921, 98722, 6115, 1214, 47836, 37174, 4682, 18696, 493, 4867, 12, 23, 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 ]
dropbox/stone
stone/backends/obj_c_client.py
ObjCBackend._get_deprecation_warning
def _get_deprecation_warning(self, route): """Returns a deprecation tag / message, if route is deprecated.""" result = '' if route.deprecated: msg = '{} is deprecated.'.format(fmt_route_func(route)) if route.deprecated.by: msg += ' Use {}.'.format(fmt_var(route.deprecated.by.name)) result = ' __deprecated_msg("{}")'.format(msg) return result
python
def _get_deprecation_warning(self, route): """Returns a deprecation tag / message, if route is deprecated.""" result = '' if route.deprecated: msg = '{} is deprecated.'.format(fmt_route_func(route)) if route.deprecated.by: msg += ' Use {}.'.format(fmt_var(route.deprecated.by.name)) result = ' __deprecated_msg("{}")'.format(msg) return result
[ "def", "_get_deprecation_warning", "(", "self", ",", "route", ")", ":", "result", "=", "''", "if", "route", ".", "deprecated", ":", "msg", "=", "'{} is deprecated.'", ".", "format", "(", "fmt_route_func", "(", "route", ")", ")", "if", "route", ".", "deprecated", ".", "by", ":", "msg", "+=", "' Use {}.'", ".", "format", "(", "fmt_var", "(", "route", ".", "deprecated", ".", "by", ".", "name", ")", ")", "result", "=", "' __deprecated_msg(\"{}\")'", ".", "format", "(", "msg", ")", "return", "result" ]
Returns a deprecation tag / message, if route is deprecated.
[ "Returns", "a", "deprecation", "tag", "/", "message", "if", "route", "is", "deprecated", "." ]
train
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backends/obj_c_client.py#L533-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: Returns a deprecation tag / message, if route is deprecated. ### Response: def _get_deprecation_warning(self, route): """Returns a deprecation tag / message, if route is deprecated.""" result = '' if route.deprecated: msg = '{} is deprecated.'.format(fmt_route_func(route)) if route.deprecated.by: msg += ' Use {}.'.format(fmt_var(route.deprecated.by.name)) result = ' __deprecated_msg("{}")'.format(msg) return result <|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, 409, 70693, 4877, 611, 1984, 11, 422, 6149, 374, 32690, 382, 14711, 6075, 512, 755, 721, 456, 2310, 70693, 39495, 1214, 11, 6149, 997, 286, 4304, 16851, 264, 409, 70693, 4877, 611, 1984, 11, 422, 6149, 374, 32690, 14781, 286, 1121, 284, 12038, 286, 422, 6149, 2337, 20483, 512, 310, 3835, 284, 34012, 374, 32690, 37049, 2293, 29297, 29209, 9791, 32536, 1192, 310, 422, 6149, 2337, 20483, 19544, 512, 394, 3835, 1447, 364, 5560, 4792, 37049, 2293, 29297, 4715, 32536, 2337, 20483, 19544, 2710, 1192, 310, 1121, 284, 364, 1328, 39289, 6619, 54530, 909, 4527, 2293, 8282, 340, 286, 471, 1121, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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,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000, 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, 409, 70693, 4877, 611, 1984, 11, 422, 6149, 374, 32690, 382, 14711, 6075, 512, 755, 721, 456, 2310, 70693, 39495, 1214, 11, 6149, 997, 286, 4304, 16851, 264, 409, 70693, 4877, 611, 1984, 11, 422, 6149, 374, 32690, 14781, 286, 1121, 284, 12038, 286, 422, 6149, 2337, 20483, 512, 310, 3835, 284, 34012, 374, 32690, 37049, 2293, 29297, 29209, 9791, 32536, 1192, 310, 422, 6149, 2337, 20483, 19544, 512, 394, 3835, 1447, 364, 5560, 4792, 37049, 2293, 29297, 4715, 32536, 2337, 20483, 19544, 2710, 1192, 310, 1121, 284, 364, 1328, 39289, 6619, 54530, 909, 4527, 2293, 8282, 340, 286, 471, 1121, 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 ]
androguard/androguard
androguard/decompiler/dad/control_flow.py
derived_sequence
def derived_sequence(graph): """ Compute the derived sequence of the graph G The intervals of G are collapsed into nodes, intervals of these nodes are built, and the process is repeated iteratively until we obtain a single node (if the graph is not irreducible) """ deriv_seq = [graph] deriv_interv = [] single_node = False while not single_node: interv_graph, interv_heads = intervals(graph) deriv_interv.append(interv_heads) single_node = len(interv_graph) == 1 if not single_node: deriv_seq.append(interv_graph) graph = interv_graph graph.compute_rpo() return deriv_seq, deriv_interv
python
def derived_sequence(graph): """ Compute the derived sequence of the graph G The intervals of G are collapsed into nodes, intervals of these nodes are built, and the process is repeated iteratively until we obtain a single node (if the graph is not irreducible) """ deriv_seq = [graph] deriv_interv = [] single_node = False while not single_node: interv_graph, interv_heads = intervals(graph) deriv_interv.append(interv_heads) single_node = len(interv_graph) == 1 if not single_node: deriv_seq.append(interv_graph) graph = interv_graph graph.compute_rpo() return deriv_seq, deriv_interv
[ "def", "derived_sequence", "(", "graph", ")", ":", "deriv_seq", "=", "[", "graph", "]", "deriv_interv", "=", "[", "]", "single_node", "=", "False", "while", "not", "single_node", ":", "interv_graph", ",", "interv_heads", "=", "intervals", "(", "graph", ")", "deriv_interv", ".", "append", "(", "interv_heads", ")", "single_node", "=", "len", "(", "interv_graph", ")", "==", "1", "if", "not", "single_node", ":", "deriv_seq", ".", "append", "(", "interv_graph", ")", "graph", "=", "interv_graph", "graph", ".", "compute_rpo", "(", ")", "return", "deriv_seq", ",", "deriv_interv" ]
Compute the derived sequence of the graph G The intervals of G are collapsed into nodes, intervals of these nodes are built, and the process is repeated iteratively until we obtain a single node (if the graph is not irreducible)
[ "Compute", "the", "derived", "sequence", "of", "the", "graph", "G", "The", "intervals", "of", "G", "are", "collapsed", "into", "nodes", "intervals", "of", "these", "nodes", "are", "built", "and", "the", "process", "is", "repeated", "iteratively", "until", "we", "obtain", "a", "single", "node", "(", "if", "the", "graph", "is", "not", "irreducible", ")" ]
train
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/decompiler/dad/control_flow.py#L86-L109
<|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 the derived sequence of the graph G The intervals of G are collapsed into nodes, intervals of these nodes are built, and the process is repeated iteratively until we obtain a single node (if the graph is not irreducible) ### Response: def derived_sequence(graph): """ Compute the derived sequence of the graph G The intervals of G are collapsed into nodes, intervals of these nodes are built, and the process is repeated iteratively until we obtain a single node (if the graph is not irreducible) """ deriv_seq = [graph] deriv_interv = [] single_node = False while not single_node: interv_graph, interv_heads = intervals(graph) deriv_interv.append(interv_heads) single_node = len(interv_graph) == 1 if not single_node: deriv_seq.append(interv_graph) graph = interv_graph graph.compute_rpo() return deriv_seq, deriv_interv <|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, 279, 14592, 8668, 315, 279, 4876, 480, 198, 262, 578, 28090, 315, 480, 527, 29368, 1139, 7954, 11, 28090, 315, 1521, 7954, 527, 198, 262, 5918, 11, 323, 279, 1920, 374, 11763, 5480, 8046, 3156, 584, 6994, 264, 3254, 198, 262, 2494, 320, 333, 279, 4876, 374, 539, 25912, 79385, 696, 14711, 6075, 512, 755, 14592, 24667, 25301, 997, 262, 3270, 262, 23426, 279, 14592, 8668, 315, 279, 4876, 480, 198, 262, 578, 28090, 315, 480, 527, 29368, 1139, 7954, 11, 28090, 315, 1521, 7954, 527, 198, 262, 5918, 11, 323, 279, 1920, 374, 11763, 5480, 8046, 3156, 584, 6994, 264, 3254, 198, 262, 2494, 320, 333, 279, 4876, 374, 539, 25912, 79385, 340, 262, 3270, 262, 19290, 14826, 284, 510, 4539, 933, 262, 19290, 4132, 651, 284, 4260, 262, 3254, 5194, 284, 3641, 271, 262, 1418, 539, 3254, 5194, 1473, 286, 86953, 15080, 11, 86953, 77420, 284, 28090, 25301, 340, 286, 19290, 4132, 651, 2102, 1577, 651, 77420, 696, 286, 3254, 5194, 284, 2479, 1577, 651, 15080, 8, 624, 220, 16, 198, 286, 422, 539, 3254, 5194, 512, 310, 19290, 14826, 2102, 1577, 651, 15080, 696, 286, 4876, 284, 86953, 15080, 198, 286, 4876, 36447, 1745, 5481, 2892, 262, 471, 19290, 14826, 11, 19290, 4132, 651, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 279, 14592, 8668, 315, 279, 4876, 480, 198, 262, 578, 28090, 315, 480, 527, 29368, 1139, 7954, 11, 28090, 315, 1521, 7954, 527, 198, 262, 5918, 11, 323, 279, 1920, 374, 11763, 5480, 8046, 3156, 584, 6994, 264, 3254, 198, 262, 2494, 320, 333, 279, 4876, 374, 539, 25912, 79385, 696, 14711, 6075, 512, 755, 14592, 24667, 25301, 997, 262, 3270, 262, 23426, 279, 14592, 8668, 315, 279, 4876, 480, 198, 262, 578, 28090, 315, 480, 527, 29368, 1139, 7954, 11, 28090, 315, 1521, 7954, 527, 198, 262, 5918, 11, 323, 279, 1920, 374, 11763, 5480, 8046, 3156, 584, 6994, 264, 3254, 198, 262, 2494, 320, 333, 279, 4876, 374, 539, 25912, 79385, 340, 262, 3270, 262, 19290, 14826, 284, 510, 4539, 933, 262, 19290, 4132, 651, 284, 4260, 262, 3254, 5194, 284, 3641, 271, 262, 1418, 539, 3254, 5194, 1473, 286, 86953, 15080, 11, 86953, 77420, 284, 28090, 25301, 340, 286, 19290, 4132, 651, 2102, 1577, 651, 77420, 696, 286, 3254, 5194, 284, 2479, 1577, 651, 15080, 8, 624, 220, 16, 198, 286, 422, 539, 3254, 5194, 512, 310, 19290, 14826, 2102, 1577, 651, 15080, 696, 286, 4876, 284, 86953, 15080, 198, 286, 4876, 36447, 1745, 5481, 2892, 262, 471, 19290, 14826, 11, 19290, 4132, 651, 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 ]
tensorpack/tensorpack
examples/basics/export-model.py
export_compact
def export_compact(model_path): """Export trained model to use it as a frozen and pruned inference graph in mobile applications. """ pred_config = PredictConfig( session_init=get_model_loader(model_path), model=Model(), input_names=['input_img'], output_names=['prediction_img']) ModelExporter(pred_config).export_compact('/tmp/compact_graph.pb')
python
def export_compact(model_path): """Export trained model to use it as a frozen and pruned inference graph in mobile applications. """ pred_config = PredictConfig( session_init=get_model_loader(model_path), model=Model(), input_names=['input_img'], output_names=['prediction_img']) ModelExporter(pred_config).export_compact('/tmp/compact_graph.pb')
[ "def", "export_compact", "(", "model_path", ")", ":", "pred_config", "=", "PredictConfig", "(", "session_init", "=", "get_model_loader", "(", "model_path", ")", ",", "model", "=", "Model", "(", ")", ",", "input_names", "=", "[", "'input_img'", "]", ",", "output_names", "=", "[", "'prediction_img'", "]", ")", "ModelExporter", "(", "pred_config", ")", ".", "export_compact", "(", "'/tmp/compact_graph.pb'", ")" ]
Export trained model to use it as a frozen and pruned inference graph in mobile applications.
[ "Export", "trained", "model", "to", "use", "it", "as", "a", "frozen", "and", "pruned", "inference", "graph", "in", "mobile", "applications", "." ]
train
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/basics/export-model.py#L116-L124
<|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: Export trained model to use it as a frozen and pruned inference graph in mobile applications. ### Response: def export_compact(model_path): """Export trained model to use it as a frozen and pruned inference graph in mobile applications. """ pred_config = PredictConfig( session_init=get_model_loader(model_path), model=Model(), input_names=['input_img'], output_names=['prediction_img']) ModelExporter(pred_config).export_compact('/tmp/compact_graph.pb') <|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, 17321, 16572, 1646, 311, 1005, 433, 439, 264, 20268, 323, 550, 49983, 45478, 4876, 304, 198, 996, 6505, 8522, 382, 14711, 6075, 512, 755, 7637, 18676, 533, 7790, 2703, 997, 262, 4304, 17321, 16572, 1646, 311, 1005, 433, 439, 264, 20268, 323, 550, 49983, 45478, 4876, 304, 198, 996, 6505, 8522, 13, 3270, 262, 4255, 5445, 284, 33810, 2714, 1021, 286, 3882, 6265, 29380, 5156, 22927, 7790, 2703, 1350, 286, 1646, 28, 1747, 3227, 286, 1988, 9366, 14314, 1379, 9095, 4479, 286, 2612, 9366, 14314, 70031, 9095, 7519, 262, 5008, 89125, 34089, 5445, 570, 1562, 18676, 533, 3478, 5284, 14, 40860, 15080, 39016, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 17321, 16572, 1646, 311, 1005, 433, 439, 264, 20268, 323, 550, 49983, 45478, 4876, 304, 198, 996, 6505, 8522, 382, 14711, 6075, 512, 755, 7637, 18676, 533, 7790, 2703, 997, 262, 4304, 17321, 16572, 1646, 311, 1005, 433, 439, 264, 20268, 323, 550, 49983, 45478, 4876, 304, 198, 996, 6505, 8522, 13, 3270, 262, 4255, 5445, 284, 33810, 2714, 1021, 286, 3882, 6265, 29380, 5156, 22927, 7790, 2703, 1350, 286, 1646, 28, 1747, 3227, 286, 1988, 9366, 14314, 1379, 9095, 4479, 286, 2612, 9366, 14314, 70031, 9095, 7519, 262, 5008, 89125, 34089, 5445, 570, 1562, 18676, 533, 3478, 5284, 14, 40860, 15080, 39016, 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 ]
PBR/MQ2
MQ2/mq2.py
cli_main
def cli_main(): # pragma: no cover """ Main function when running from CLI. """ if '--debug' in sys.argv: LOG.setLevel(logging.DEBUG) elif '--verbose' in sys.argv: LOG.setLevel(logging.INFO) args = _get_arguments() try: plugin, folder = get_plugin_and_folder( inputzip=args.inputzip, inputdir=args.inputdir, inputfile=args.inputfile) LOG.debug('Plugin: %s -- Folder: %s' % (plugin.name, folder)) run_mq2( plugin, folder, lod_threshold=args.lod, session=args.session) except MQ2Exception as err: print(err) return 1 return 0
python
def cli_main(): # pragma: no cover """ Main function when running from CLI. """ if '--debug' in sys.argv: LOG.setLevel(logging.DEBUG) elif '--verbose' in sys.argv: LOG.setLevel(logging.INFO) args = _get_arguments() try: plugin, folder = get_plugin_and_folder( inputzip=args.inputzip, inputdir=args.inputdir, inputfile=args.inputfile) LOG.debug('Plugin: %s -- Folder: %s' % (plugin.name, folder)) run_mq2( plugin, folder, lod_threshold=args.lod, session=args.session) except MQ2Exception as err: print(err) return 1 return 0
[ "def", "cli_main", "(", ")", ":", "# pragma: no cover", "if", "'--debug'", "in", "sys", ".", "argv", ":", "LOG", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "elif", "'--verbose'", "in", "sys", ".", "argv", ":", "LOG", ".", "setLevel", "(", "logging", ".", "INFO", ")", "args", "=", "_get_arguments", "(", ")", "try", ":", "plugin", ",", "folder", "=", "get_plugin_and_folder", "(", "inputzip", "=", "args", ".", "inputzip", ",", "inputdir", "=", "args", ".", "inputdir", ",", "inputfile", "=", "args", ".", "inputfile", ")", "LOG", ".", "debug", "(", "'Plugin: %s -- Folder: %s'", "%", "(", "plugin", ".", "name", ",", "folder", ")", ")", "run_mq2", "(", "plugin", ",", "folder", ",", "lod_threshold", "=", "args", ".", "lod", ",", "session", "=", "args", ".", "session", ")", "except", "MQ2Exception", "as", "err", ":", "print", "(", "err", ")", "return", "1", "return", "0" ]
Main function when running from CLI.
[ "Main", "function", "when", "running", "from", "CLI", "." ]
train
https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/mq2.py#L95-L114
<|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: Main function when running from CLI. ### Response: def cli_main(): # pragma: no cover """ Main function when running from CLI. """ if '--debug' in sys.argv: LOG.setLevel(logging.DEBUG) elif '--verbose' in sys.argv: LOG.setLevel(logging.INFO) args = _get_arguments() try: plugin, folder = get_plugin_and_folder( inputzip=args.inputzip, inputdir=args.inputdir, inputfile=args.inputfile) LOG.debug('Plugin: %s -- Folder: %s' % (plugin.name, folder)) run_mq2( plugin, folder, lod_threshold=args.lod, session=args.session) except MQ2Exception as err: print(err) return 1 return 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, 6334, 734, 994, 4401, 505, 40377, 382, 14711, 6075, 512, 755, 22059, 11273, 4658, 220, 674, 63220, 25, 912, 3504, 198, 262, 4304, 4802, 734, 994, 4401, 505, 40377, 13, 3270, 262, 422, 17753, 8514, 6, 304, 5826, 14629, 512, 286, 8241, 58479, 52787, 39236, 340, 262, 4508, 17753, 15228, 6, 304, 5826, 14629, 512, 286, 8241, 58479, 52787, 39417, 696, 262, 2897, 284, 721, 456, 44533, 746, 262, 1456, 512, 286, 9183, 11, 8695, 284, 636, 23982, 8543, 15626, 1021, 310, 1988, 10169, 32358, 10252, 10169, 345, 310, 1988, 3826, 32358, 10252, 3826, 345, 310, 1988, 1213, 32358, 10252, 1213, 340, 286, 8241, 8042, 493, 11807, 25, 1034, 82, 1198, 36943, 25, 1034, 82, 6, 1034, 320, 9316, 2710, 11, 8695, 1192, 286, 1629, 722, 80, 17, 1021, 310, 9183, 11, 8695, 11, 36132, 22616, 32358, 929, 347, 11, 3882, 32358, 10387, 340, 262, 3734, 44083, 17, 1378, 439, 1886, 512, 286, 1194, 4052, 340, 286, 471, 220, 16, 198, 262, 471, 220, 15, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 6334, 734, 994, 4401, 505, 40377, 382, 14711, 6075, 512, 755, 22059, 11273, 4658, 220, 674, 63220, 25, 912, 3504, 198, 262, 4304, 4802, 734, 994, 4401, 505, 40377, 13, 3270, 262, 422, 17753, 8514, 6, 304, 5826, 14629, 512, 286, 8241, 58479, 52787, 39236, 340, 262, 4508, 17753, 15228, 6, 304, 5826, 14629, 512, 286, 8241, 58479, 52787, 39417, 696, 262, 2897, 284, 721, 456, 44533, 746, 262, 1456, 512, 286, 9183, 11, 8695, 284, 636, 23982, 8543, 15626, 1021, 310, 1988, 10169, 32358, 10252, 10169, 345, 310, 1988, 3826, 32358, 10252, 3826, 345, 310, 1988, 1213, 32358, 10252, 1213, 340, 286, 8241, 8042, 493, 11807, 25, 1034, 82, 1198, 36943, 25, 1034, 82, 6, 1034, 320, 9316, 2710, 11, 8695, 1192, 286, 1629, 722, 80, 17, 1021, 310, 9183, 11, 8695, 11, 36132, 22616, 32358, 929, 347, 11, 3882, 32358, 10387, 340, 262, 3734, 44083, 17, 1378, 439, 1886, 512, 286, 1194, 4052, 340, 286, 471, 220, 16, 198, 262, 471, 220, 15, 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 ]
QUANTAXIS/QUANTAXIS
QUANTAXIS/QASU/main.py
QA_SU_save_stock_xdxr
def QA_SU_save_stock_xdxr(engine, client=DATABASE): """save stock_xdxr Arguments: engine {[type]} -- [description] Keyword Arguments: client {[type]} -- [description] (default: {DATABASE}) """ engine = select_save_engine(engine) engine.QA_SU_save_stock_xdxr(client=client)
python
def QA_SU_save_stock_xdxr(engine, client=DATABASE): """save stock_xdxr Arguments: engine {[type]} -- [description] Keyword Arguments: client {[type]} -- [description] (default: {DATABASE}) """ engine = select_save_engine(engine) engine.QA_SU_save_stock_xdxr(client=client)
[ "def", "QA_SU_save_stock_xdxr", "(", "engine", ",", "client", "=", "DATABASE", ")", ":", "engine", "=", "select_save_engine", "(", "engine", ")", "engine", ".", "QA_SU_save_stock_xdxr", "(", "client", "=", "client", ")" ]
save stock_xdxr Arguments: engine {[type]} -- [description] Keyword Arguments: client {[type]} -- [description] (default: {DATABASE})
[ "save", "stock_xdxr" ]
train
https://github.com/QUANTAXIS/QUANTAXIS/blob/bb1fe424e4108b62a1f712b81a05cf829297a5c0/QUANTAXIS/QASU/main.py#L315-L326
<|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: save stock_xdxr Arguments: engine {[type]} -- [description] Keyword Arguments: client {[type]} -- [description] (default: {DATABASE}) ### Response: def QA_SU_save_stock_xdxr(engine, client=DATABASE): """save stock_xdxr Arguments: engine {[type]} -- [description] Keyword Arguments: client {[type]} -- [description] (default: {DATABASE}) """ engine = select_save_engine(engine) engine.QA_SU_save_stock_xdxr(client=client) <|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, 6766, 5708, 3292, 13009, 81, 271, 262, 28802, 512, 286, 4817, 46691, 1337, 14316, 1198, 510, 4789, 2595, 262, 50070, 28802, 512, 286, 3016, 46691, 1337, 14316, 1198, 510, 4789, 60, 320, 2309, 25, 314, 47599, 9000, 14711, 6075, 512, 755, 67008, 57715, 15737, 31641, 3292, 13009, 81, 50074, 11, 3016, 28, 47599, 997, 262, 4304, 6766, 5708, 3292, 13009, 81, 271, 262, 28802, 512, 286, 4817, 46691, 1337, 14316, 1198, 510, 4789, 2595, 262, 50070, 28802, 512, 286, 3016, 46691, 1337, 14316, 1198, 510, 4789, 60, 320, 2309, 25, 314, 47599, 3602, 262, 12713, 262, 4817, 284, 3373, 15737, 25860, 50074, 340, 262, 4817, 10208, 32, 57715, 15737, 31641, 3292, 13009, 81, 13097, 28, 3045, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 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, 6766, 5708, 3292, 13009, 81, 271, 262, 28802, 512, 286, 4817, 46691, 1337, 14316, 1198, 510, 4789, 2595, 262, 50070, 28802, 512, 286, 3016, 46691, 1337, 14316, 1198, 510, 4789, 60, 320, 2309, 25, 314, 47599, 9000, 14711, 6075, 512, 755, 67008, 57715, 15737, 31641, 3292, 13009, 81, 50074, 11, 3016, 28, 47599, 997, 262, 4304, 6766, 5708, 3292, 13009, 81, 271, 262, 28802, 512, 286, 4817, 46691, 1337, 14316, 1198, 510, 4789, 2595, 262, 50070, 28802, 512, 286, 3016, 46691, 1337, 14316, 1198, 510, 4789, 60, 320, 2309, 25, 314, 47599, 3602, 262, 12713, 262, 4817, 284, 3373, 15737, 25860, 50074, 340, 262, 4817, 10208, 32, 57715, 15737, 31641, 3292, 13009, 81, 13097, 28, 3045, 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 ]
geographika/mappyfile
mappyfile/pprint.py
Quoter.escape_quotes
def escape_quotes(self, val): """ Escape any quotes in a value """ if self.is_string(val) and self._in_quotes(val, self.quote): # make sure any previously escaped quotes are not re-escaped middle = self.remove_quotes(val).replace("\\" + self.quote, self.quote) middle = middle.replace(self.quote, "\\" + self.quote) val = self.add_quotes(middle) return val
python
def escape_quotes(self, val): """ Escape any quotes in a value """ if self.is_string(val) and self._in_quotes(val, self.quote): # make sure any previously escaped quotes are not re-escaped middle = self.remove_quotes(val).replace("\\" + self.quote, self.quote) middle = middle.replace(self.quote, "\\" + self.quote) val = self.add_quotes(middle) return val
[ "def", "escape_quotes", "(", "self", ",", "val", ")", ":", "if", "self", ".", "is_string", "(", "val", ")", "and", "self", ".", "_in_quotes", "(", "val", ",", "self", ".", "quote", ")", ":", "# make sure any previously escaped quotes are not re-escaped", "middle", "=", "self", ".", "remove_quotes", "(", "val", ")", ".", "replace", "(", "\"\\\\\"", "+", "self", ".", "quote", ",", "self", ".", "quote", ")", "middle", "=", "middle", ".", "replace", "(", "self", ".", "quote", ",", "\"\\\\\"", "+", "self", ".", "quote", ")", "val", "=", "self", ".", "add_quotes", "(", "middle", ")", "return", "val" ]
Escape any quotes in a value
[ "Escape", "any", "quotes", "in", "a", "value" ]
train
https://github.com/geographika/mappyfile/blob/aecbc5e66ec06896bc4c5db41313503468829d00/mappyfile/pprint.py#L46-L56
<|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: Escape any quotes in a value ### Response: def escape_quotes(self, val): """ Escape any quotes in a value """ if self.is_string(val) and self._in_quotes(val, self.quote): # make sure any previously escaped quotes are not re-escaped middle = self.remove_quotes(val).replace("\\" + self.quote, self.quote) middle = middle.replace(self.quote, "\\" + self.quote) val = self.add_quotes(middle) return val <|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, 49224, 904, 17637, 304, 264, 907, 271, 14711, 6075, 512, 755, 12731, 76737, 1214, 11, 1062, 997, 286, 3270, 286, 46743, 904, 17637, 304, 264, 907, 198, 286, 3270, 286, 422, 659, 2124, 3991, 9276, 8, 323, 659, 1462, 258, 76737, 9276, 11, 659, 62665, 997, 310, 674, 1304, 2771, 904, 8767, 28883, 17637, 527, 539, 312, 12, 66926, 198, 310, 6278, 284, 659, 4955, 76737, 9276, 570, 8319, 5026, 2153, 489, 659, 62665, 11, 659, 62665, 340, 310, 6278, 284, 6278, 7125, 1214, 62665, 11, 70037, 489, 659, 62665, 340, 310, 1062, 284, 659, 1388, 76737, 1278, 3390, 696, 286, 471, 1062, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 49224, 904, 17637, 304, 264, 907, 271, 14711, 6075, 512, 755, 12731, 76737, 1214, 11, 1062, 997, 286, 3270, 286, 46743, 904, 17637, 304, 264, 907, 198, 286, 3270, 286, 422, 659, 2124, 3991, 9276, 8, 323, 659, 1462, 258, 76737, 9276, 11, 659, 62665, 997, 310, 674, 1304, 2771, 904, 8767, 28883, 17637, 527, 539, 312, 12, 66926, 198, 310, 6278, 284, 659, 4955, 76737, 9276, 570, 8319, 5026, 2153, 489, 659, 62665, 11, 659, 62665, 340, 310, 6278, 284, 6278, 7125, 1214, 62665, 11, 70037, 489, 659, 62665, 340, 310, 1062, 284, 659, 1388, 76737, 1278, 3390, 696, 286, 471, 1062, 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 ]
anjianshi/flask-restful-extend
flask_restful_extend/model_validates.py
_validate_handler
def _validate_handler(column_name, value, predicate_refs): """handle predicate's return value""" # only does validate when attribute value is not None # else, just return it, let sqlalchemy decide if the value was legal according to `nullable` argument's value if value is not None: for predicate_ref in predicate_refs: predicate, predicate_name, predicate_args = _decode_predicate_ref(predicate_ref) validate_result = predicate(value, *predicate_args) if isinstance(validate_result, dict) and 'value' in validate_result: value = validate_result['value'] elif type(validate_result) != bool: raise Exception( 'predicate (name={}) can only return bool or dict(value=new_value) value'.format(predicate_name)) elif not validate_result: raise ModelInvalid(u'db model validate failed: column={}, value={}, predicate={}, arguments={}'.format( column_name, value, predicate_name, ','.join(map(str, predicate_args)) )) return value
python
def _validate_handler(column_name, value, predicate_refs): """handle predicate's return value""" # only does validate when attribute value is not None # else, just return it, let sqlalchemy decide if the value was legal according to `nullable` argument's value if value is not None: for predicate_ref in predicate_refs: predicate, predicate_name, predicate_args = _decode_predicate_ref(predicate_ref) validate_result = predicate(value, *predicate_args) if isinstance(validate_result, dict) and 'value' in validate_result: value = validate_result['value'] elif type(validate_result) != bool: raise Exception( 'predicate (name={}) can only return bool or dict(value=new_value) value'.format(predicate_name)) elif not validate_result: raise ModelInvalid(u'db model validate failed: column={}, value={}, predicate={}, arguments={}'.format( column_name, value, predicate_name, ','.join(map(str, predicate_args)) )) return value
[ "def", "_validate_handler", "(", "column_name", ",", "value", ",", "predicate_refs", ")", ":", "# only does validate when attribute value is not None", "# else, just return it, let sqlalchemy decide if the value was legal according to `nullable` argument's value", "if", "value", "is", "not", "None", ":", "for", "predicate_ref", "in", "predicate_refs", ":", "predicate", ",", "predicate_name", ",", "predicate_args", "=", "_decode_predicate_ref", "(", "predicate_ref", ")", "validate_result", "=", "predicate", "(", "value", ",", "*", "predicate_args", ")", "if", "isinstance", "(", "validate_result", ",", "dict", ")", "and", "'value'", "in", "validate_result", ":", "value", "=", "validate_result", "[", "'value'", "]", "elif", "type", "(", "validate_result", ")", "!=", "bool", ":", "raise", "Exception", "(", "'predicate (name={}) can only return bool or dict(value=new_value) value'", ".", "format", "(", "predicate_name", ")", ")", "elif", "not", "validate_result", ":", "raise", "ModelInvalid", "(", "u'db model validate failed: column={}, value={}, predicate={}, arguments={}'", ".", "format", "(", "column_name", ",", "value", ",", "predicate_name", ",", "','", ".", "join", "(", "map", "(", "str", ",", "predicate_args", ")", ")", ")", ")", "return", "value" ]
handle predicate's return value
[ "handle", "predicate", "s", "return", "value" ]
train
https://github.com/anjianshi/flask-restful-extend/blob/cc168729bf341d4f9c0f6938be30463acbf770f1/flask_restful_extend/model_validates.py#L143-L162
<|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: handle predicate's return value ### Response: def _validate_handler(column_name, value, predicate_refs): """handle predicate's return value""" # only does validate when attribute value is not None # else, just return it, let sqlalchemy decide if the value was legal according to `nullable` argument's value if value is not None: for predicate_ref in predicate_refs: predicate, predicate_name, predicate_args = _decode_predicate_ref(predicate_ref) validate_result = predicate(value, *predicate_args) if isinstance(validate_result, dict) and 'value' in validate_result: value = validate_result['value'] elif type(validate_result) != bool: raise Exception( 'predicate (name={}) can only return bool or dict(value=new_value) value'.format(predicate_name)) elif not validate_result: raise ModelInvalid(u'db model validate failed: column={}, value={}, predicate={}, arguments={}'.format( column_name, value, predicate_name, ','.join(map(str, predicate_args)) )) 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, 8355, 25269, 596, 471, 907, 271, 14711, 6075, 512, 755, 721, 7212, 10393, 17725, 1292, 11, 907, 11, 25269, 61738, 997, 262, 4304, 8355, 25269, 596, 471, 907, 15425, 262, 674, 1193, 1587, 9788, 994, 7180, 907, 374, 539, 2290, 198, 262, 674, 775, 11, 1120, 471, 433, 11, 1095, 43275, 10491, 422, 279, 907, 574, 5897, 4184, 311, 1595, 13198, 63, 5811, 596, 907, 198, 262, 422, 907, 374, 539, 2290, 512, 286, 369, 25269, 7949, 304, 25269, 61738, 512, 310, 25269, 11, 25269, 1292, 11, 25269, 8550, 284, 721, 18696, 98574, 7949, 77272, 7949, 340, 310, 9788, 5400, 284, 25269, 3764, 11, 353, 62885, 8550, 696, 310, 422, 11656, 95344, 5400, 11, 6587, 8, 323, 364, 970, 6, 304, 9788, 5400, 512, 394, 907, 284, 9788, 5400, 681, 970, 4532, 310, 4508, 955, 95344, 5400, 8, 976, 1845, 512, 394, 4933, 4204, 1021, 504, 364, 62885, 320, 609, 1185, 5525, 649, 1193, 471, 1845, 477, 6587, 3764, 8507, 3220, 8, 907, 4527, 2293, 77272, 1292, 1192, 310, 4508, 539, 9788, 5400, 512, 394, 4933, 5008, 8087, 8317, 4265, 65, 1646, 9788, 4745, 25, 3330, 68525, 907, 68525, 25269, 68525, 6105, 1185, 24398, 2293, 1021, 504, 3330, 1292, 11, 907, 11, 25269, 1292, 11, 98780, 6115, 9325, 4293, 11, 25269, 8550, 1192, 394, 19800, 262, 471, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 8355, 25269, 596, 471, 907, 271, 14711, 6075, 512, 755, 721, 7212, 10393, 17725, 1292, 11, 907, 11, 25269, 61738, 997, 262, 4304, 8355, 25269, 596, 471, 907, 15425, 262, 674, 1193, 1587, 9788, 994, 7180, 907, 374, 539, 2290, 198, 262, 674, 775, 11, 1120, 471, 433, 11, 1095, 43275, 10491, 422, 279, 907, 574, 5897, 4184, 311, 1595, 13198, 63, 5811, 596, 907, 198, 262, 422, 907, 374, 539, 2290, 512, 286, 369, 25269, 7949, 304, 25269, 61738, 512, 310, 25269, 11, 25269, 1292, 11, 25269, 8550, 284, 721, 18696, 98574, 7949, 77272, 7949, 340, 310, 9788, 5400, 284, 25269, 3764, 11, 353, 62885, 8550, 696, 310, 422, 11656, 95344, 5400, 11, 6587, 8, 323, 364, 970, 6, 304, 9788, 5400, 512, 394, 907, 284, 9788, 5400, 681, 970, 4532, 310, 4508, 955, 95344, 5400, 8, 976, 1845, 512, 394, 4933, 4204, 1021, 504, 364, 62885, 320, 609, 1185, 5525, 649, 1193, 471, 1845, 477, 6587, 3764, 8507, 3220, 8, 907, 4527, 2293, 77272, 1292, 1192, 310, 4508, 539, 9788, 5400, 512, 394, 4933, 5008, 8087, 8317, 4265, 65, 1646, 9788, 4745, 25, 3330, 68525, 907, 68525, 25269, 68525, 6105, 1185, 24398, 2293, 1021, 504, 3330, 1292, 11, 907, 11, 25269, 1292, 11, 98780, 6115, 9325, 4293, 11, 25269, 8550, 1192, 394, 19800, 262, 471, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]