Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
EventSequenceEncoderDecoder.events_to_input | (self, events, position) | Returns the input vector for the event at the given position.
Args:
events: A list-like sequence of events.
position: An integer event position in the sequence.
Returns:
An input vector, a self.input_size length list of floats.
| Returns the input vector for the event at the given position. | def events_to_input(self, events, position):
"""Returns the input vector for the event at the given position.
Args:
events: A list-like sequence of events.
position: An integer event position in the sequence.
Returns:
An input vector, a self.input_size length list of floats.
"""
... | [
"def",
"events_to_input",
"(",
"self",
",",
"events",
",",
"position",
")",
":",
"pass"
] | [
175,
2
] | [
185,
8
] | python | en | ['en', 'en', 'en'] | True |
EventSequenceEncoderDecoder.events_to_label | (self, events, position) | Returns the label for the event at the given position.
Args:
events: A list-like sequence of events.
position: An integer event position in the sequence.
Returns:
A label, an integer in the range [0, self.num_classes).
| Returns the label for the event at the given position. | def events_to_label(self, events, position):
"""Returns the label for the event at the given position.
Args:
events: A list-like sequence of events.
position: An integer event position in the sequence.
Returns:
A label, an integer in the range [0, self.num_classes).
"""
pass | [
"def",
"events_to_label",
"(",
"self",
",",
"events",
",",
"position",
")",
":",
"pass"
] | [
188,
2
] | [
198,
8
] | python | en | ['en', 'en', 'en'] | True |
EventSequenceEncoderDecoder.class_index_to_event | (self, class_index, events) | Returns the event for the given class index.
This is the reverse process of the self.events_to_label method.
Args:
class_index: An integer in the range [0, self.num_classes).
events: A list-like sequence of events.
Returns:
An event value.
| Returns the event for the given class index. | def class_index_to_event(self, class_index, events):
"""Returns the event for the given class index.
This is the reverse process of the self.events_to_label method.
Args:
class_index: An integer in the range [0, self.num_classes).
events: A list-like sequence of events.
Returns:
An ... | [
"def",
"class_index_to_event",
"(",
"self",
",",
"class_index",
",",
"events",
")",
":",
"pass"
] | [
201,
2
] | [
213,
8
] | python | en | ['en', 'en', 'en'] | True |
EventSequenceEncoderDecoder.labels_to_num_steps | (self, labels) | Returns the total number of time steps for a sequence of class labels.
This is used for normalization when computing metrics. Subclasses with
variable step size should override this method.
Args:
labels: A list-like sequence of integers in the range
[0, self.num_classes).
Returns:
... | Returns the total number of time steps for a sequence of class labels. | def labels_to_num_steps(self, labels):
"""Returns the total number of time steps for a sequence of class labels.
This is used for normalization when computing metrics. Subclasses with
variable step size should override this method.
Args:
labels: A list-like sequence of integers in the range
... | [
"def",
"labels_to_num_steps",
"(",
"self",
",",
"labels",
")",
":",
"return",
"len",
"(",
"labels",
")"
] | [
215,
2
] | [
229,
22
] | python | en | ['en', 'en', 'en'] | True |
EventSequenceEncoderDecoder.encode | (self, events) | Returns inputs and labels for the given event sequence.
Args:
events: A list-like sequence of events.
Returns:
The inputs and labels.
| Returns inputs and labels for the given event sequence. | def encode(self, events):
"""Returns inputs and labels for the given event sequence.
Args:
events: A list-like sequence of events.
Returns:
The inputs and labels.
"""
inputs = []
labels = []
for i in range(len(events) - 1):
inputs.append(self.events_to_input(events, i))
... | [
"def",
"encode",
"(",
"self",
",",
"events",
")",
":",
"inputs",
"=",
"[",
"]",
"labels",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"events",
")",
"-",
"1",
")",
":",
"inputs",
".",
"append",
"(",
"self",
".",
"events_to_input",
... | [
231,
2
] | [
245,
25
] | python | en | ['en', 'en', 'en'] | True |
EventSequenceEncoderDecoder.get_inputs_batch | (self, event_sequences, full_length=False) | Returns an inputs batch for the given event sequences.
Args:
event_sequences: A list of list-like event sequences.
full_length: If True, the inputs batch will be for the full length of
each event sequence. If False, the inputs batch will only be for the
last event of each event sequ... | Returns an inputs batch for the given event sequences. | def get_inputs_batch(self, event_sequences, full_length=False):
"""Returns an inputs batch for the given event sequences.
Args:
event_sequences: A list of list-like event sequences.
full_length: If True, the inputs batch will be for the full length of
each event sequence. If False, the in... | [
"def",
"get_inputs_batch",
"(",
"self",
",",
"event_sequences",
",",
"full_length",
"=",
"False",
")",
":",
"inputs_batch",
"=",
"[",
"]",
"for",
"events",
"in",
"event_sequences",
":",
"inputs",
"=",
"[",
"]",
"if",
"full_length",
":",
"for",
"i",
"in",
... | [
247,
2
] | [
274,
23
] | python | en | ['en', 'en', 'en'] | True |
EventSequenceEncoderDecoder.extend_event_sequences | (self, event_sequences, softmax) | Extends the event sequences by sampling the softmax probabilities.
Args:
event_sequences: A list of EventSequence objects.
softmax: A list of softmax probability vectors. The list of softmaxes
should be the same length as the list of event sequences.
Returns:
A Python list of chose... | Extends the event sequences by sampling the softmax probabilities. | def extend_event_sequences(self, event_sequences, softmax):
"""Extends the event sequences by sampling the softmax probabilities.
Args:
event_sequences: A list of EventSequence objects.
softmax: A list of softmax probability vectors. The list of softmaxes
should be the same length as the ... | [
"def",
"extend_event_sequences",
"(",
"self",
",",
"event_sequences",
",",
"softmax",
")",
":",
"chosen_classes",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"event_sequences",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
"softmax",
"[",
... | [
276,
2
] | [
306,
25
] | python | en | ['en', 'en', 'en'] | True |
EventSequenceEncoderDecoder.evaluate_log_likelihood | (self, event_sequences, softmax) | Evaluate the log likelihood of multiple event sequences.
Each event sequence is evaluated from the end. If the size of the
corresponding softmax vector is 1 less than the number of events, the entire
event sequence will be evaluated (other than the first event, whose
distribution is not modeled). If th... | Evaluate the log likelihood of multiple event sequences. | def evaluate_log_likelihood(self, event_sequences, softmax):
"""Evaluate the log likelihood of multiple event sequences.
Each event sequence is evaluated from the end. If the size of the
corresponding softmax vector is 1 less than the number of events, the entire
event sequence will be evaluated (other... | [
"def",
"evaluate_log_likelihood",
"(",
"self",
",",
"event_sequences",
",",
"softmax",
")",
":",
"all_loglik",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"event_sequences",
")",
")",
":",
"if",
"len",
"(",
"softmax",
"[",
"i",
"]",
")",... | [
308,
2
] | [
348,
21
] | python | en | ['en', 'en', 'en'] | True |
OneHotEventSequenceEncoderDecoder.__init__ | (self, one_hot_encoding) | Initialize a OneHotEventSequenceEncoderDecoder object.
Args:
one_hot_encoding: A OneHotEncoding object that transforms events to and
from integer indices.
| Initialize a OneHotEventSequenceEncoderDecoder object. | def __init__(self, one_hot_encoding):
"""Initialize a OneHotEventSequenceEncoderDecoder object.
Args:
one_hot_encoding: A OneHotEncoding object that transforms events to and
from integer indices.
"""
self._one_hot_encoding = one_hot_encoding | [
"def",
"__init__",
"(",
"self",
",",
"one_hot_encoding",
")",
":",
"self",
".",
"_one_hot_encoding",
"=",
"one_hot_encoding"
] | [
354,
2
] | [
361,
45
] | python | en | ['en', 'en', 'en'] | True |
OneHotEventSequenceEncoderDecoder.events_to_input | (self, events, position) | Returns the input vector for the given position in the event sequence.
Returns a one-hot vector for the given position in the event sequence, as
determined by the one hot encoding.
Args:
events: A list-like sequence of events.
position: An integer event position in the event sequence.
Ret... | Returns the input vector for the given position in the event sequence. | def events_to_input(self, events, position):
"""Returns the input vector for the given position in the event sequence.
Returns a one-hot vector for the given position in the event sequence, as
determined by the one hot encoding.
Args:
events: A list-like sequence of events.
position: An in... | [
"def",
"events_to_input",
"(",
"self",
",",
"events",
",",
"position",
")",
":",
"input_",
"=",
"[",
"0.0",
"]",
"*",
"self",
".",
"input_size",
"input_",
"[",
"self",
".",
"_one_hot_encoding",
".",
"encode_event",
"(",
"events",
"[",
"position",
"]",
")... | [
376,
2
] | [
391,
17
] | python | en | ['en', 'en', 'en'] | True |
OneHotEventSequenceEncoderDecoder.events_to_label | (self, events, position) | Returns the label for the given position in the event sequence.
Returns the zero-based index value for the given position in the event
sequence, as determined by the one hot encoding.
Args:
events: A list-like sequence of events.
position: An integer event position in the event sequence.
... | Returns the label for the given position in the event sequence. | def events_to_label(self, events, position):
"""Returns the label for the given position in the event sequence.
Returns the zero-based index value for the given position in the event
sequence, as determined by the one hot encoding.
Args:
events: A list-like sequence of events.
position: An... | [
"def",
"events_to_label",
"(",
"self",
",",
"events",
",",
"position",
")",
":",
"return",
"self",
".",
"_one_hot_encoding",
".",
"encode_event",
"(",
"events",
"[",
"position",
"]",
")"
] | [
393,
2
] | [
406,
64
] | python | en | ['en', 'en', 'en'] | True |
OneHotEventSequenceEncoderDecoder.class_index_to_event | (self, class_index, events) | Returns the event for the given class index.
This is the reverse process of the self.events_to_label method.
Args:
class_index: An integer in the range [0, self.num_classes).
events: A list-like sequence of events. This object is not used in this
implementation.
Returns:
An ev... | Returns the event for the given class index. | def class_index_to_event(self, class_index, events):
"""Returns the event for the given class index.
This is the reverse process of the self.events_to_label method.
Args:
class_index: An integer in the range [0, self.num_classes).
events: A list-like sequence of events. This object is not used... | [
"def",
"class_index_to_event",
"(",
"self",
",",
"class_index",
",",
"events",
")",
":",
"return",
"self",
".",
"_one_hot_encoding",
".",
"decode_event",
"(",
"class_index",
")"
] | [
408,
2
] | [
421,
59
] | python | en | ['en', 'en', 'en'] | True |
OneHotEventSequenceEncoderDecoder.labels_to_num_steps | (self, labels) | Returns the total number of time steps for a sequence of class labels.
Args:
labels: A list-like sequence of integers in the range
[0, self.num_classes).
Returns:
The total number of time steps for the label sequence, as determined by
the one-hot encoding.
| Returns the total number of time steps for a sequence of class labels. | def labels_to_num_steps(self, labels):
"""Returns the total number of time steps for a sequence of class labels.
Args:
labels: A list-like sequence of integers in the range
[0, self.num_classes).
Returns:
The total number of time steps for the label sequence, as determined by
t... | [
"def",
"labels_to_num_steps",
"(",
"self",
",",
"labels",
")",
":",
"events",
"=",
"[",
"]",
"for",
"label",
"in",
"labels",
":",
"events",
".",
"append",
"(",
"self",
".",
"class_index_to_event",
"(",
"label",
",",
"events",
")",
")",
"return",
"sum",
... | [
423,
2
] | [
438,
35
] | python | en | ['en', 'en', 'en'] | True |
OneHotIndexEventSequenceEncoderDecoder.events_to_input | (self, events, position) | Returns the one-hot index for the event at the given position.
Args:
events: A list-like sequence of events.
position: An integer event position in the event sequence.
Returns:
An integer input event index.
| Returns the one-hot index for the event at the given position. | def events_to_input(self, events, position):
"""Returns the one-hot index for the event at the given position.
Args:
events: A list-like sequence of events.
position: An integer event position in the event sequence.
Returns:
An integer input event index.
"""
return [self._one_hot... | [
"def",
"events_to_input",
"(",
"self",
",",
"events",
",",
"position",
")",
":",
"return",
"[",
"self",
".",
"_one_hot_encoding",
".",
"encode_event",
"(",
"events",
"[",
"position",
"]",
")",
"]"
] | [
452,
2
] | [
462,
66
] | python | en | ['en', 'en', 'en'] | True |
LookbackEventSequenceEncoderDecoder.__init__ | (self, one_hot_encoding, lookback_distances=None,
binary_counter_bits=5) | Initializes the LookbackEventSequenceEncoderDecoder.
Args:
one_hot_encoding: A OneHotEncoding object that transforms events to and
from integer indices.
lookback_distances: A list of step intervals to look back in history to
encode both the following event and whether the current step... | Initializes the LookbackEventSequenceEncoderDecoder. | def __init__(self, one_hot_encoding, lookback_distances=None,
binary_counter_bits=5):
"""Initializes the LookbackEventSequenceEncoderDecoder.
Args:
one_hot_encoding: A OneHotEncoding object that transforms events to and
from integer indices.
lookback_distances: A list of ste... | [
"def",
"__init__",
"(",
"self",
",",
"one_hot_encoding",
",",
"lookback_distances",
"=",
"None",
",",
"binary_counter_bits",
"=",
"5",
")",
":",
"self",
".",
"_one_hot_encoding",
"=",
"one_hot_encoding",
"if",
"lookback_distances",
"is",
"None",
":",
"self",
"."... | [
468,
2
] | [
486,
51
] | python | en | ['en', 'en', 'en'] | True |
LookbackEventSequenceEncoderDecoder.events_to_input | (self, events, position) | Returns the input vector for the given position in the event sequence.
Returns a self.input_size length list of floats. Assuming a one-hot
encoding with 38 classes, two lookback distances, and five binary counters,
self.input_size will = 121. Each index represents a different input signal
to the model.... | Returns the input vector for the given position in the event sequence. | def events_to_input(self, events, position):
"""Returns the input vector for the given position in the event sequence.
Returns a self.input_size length list of floats. Assuming a one-hot
encoding with 38 classes, two lookback distances, and five binary counters,
self.input_size will = 121. Each index r... | [
"def",
"events_to_input",
"(",
"self",
",",
"events",
",",
"position",
")",
":",
"input_",
"=",
"[",
"0.0",
"]",
"*",
"self",
".",
"input_size",
"offset",
"=",
"0",
"# Last event.",
"index",
"=",
"self",
".",
"_one_hot_encoding",
".",
"encode_event",
"(",
... | [
506,
2
] | [
568,
17
] | python | en | ['en', 'en', 'en'] | True |
LookbackEventSequenceEncoderDecoder.events_to_label | (self, events, position) | Returns the label for the given position in the event sequence.
Returns an integer in the range [0, self.num_classes). Indices in the range
[0, self._one_hot_encoding.num_classes) map to standard events. Indices
self._one_hot_encoding.num_classes and self._one_hot_encoding.num_classes +
1 are signals t... | Returns the label for the given position in the event sequence. | def events_to_label(self, events, position):
"""Returns the label for the given position in the event sequence.
Returns an integer in the range [0, self.num_classes). Indices in the range
[0, self._one_hot_encoding.num_classes) map to standard events. Indices
self._one_hot_encoding.num_classes and self... | [
"def",
"events_to_label",
"(",
"self",
",",
"events",
",",
"position",
")",
":",
"if",
"(",
"self",
".",
"_lookback_distances",
"and",
"position",
"<",
"self",
".",
"_lookback_distances",
"[",
"-",
"1",
"]",
"and",
"events",
"[",
"position",
"]",
"==",
"... | [
570,
2
] | [
612,
64
] | python | en | ['en', 'en', 'en'] | True |
LookbackEventSequenceEncoderDecoder.class_index_to_event | (self, class_index, events) | Returns the event for the given class index.
This is the reverse process of the self.events_to_label method.
Args:
class_index: An int in the range [0, self.num_classes).
events: The current event sequence.
Returns:
An event value.
| Returns the event for the given class index. | def class_index_to_event(self, class_index, events):
"""Returns the event for the given class index.
This is the reverse process of the self.events_to_label method.
Args:
class_index: An int in the range [0, self.num_classes).
events: The current event sequence.
Returns:
An event va... | [
"def",
"class_index_to_event",
"(",
"self",
",",
"class_index",
",",
"events",
")",
":",
"# Repeat N bar ago.",
"for",
"i",
",",
"lookback_distance",
"in",
"reversed",
"(",
"list",
"(",
"enumerate",
"(",
"self",
".",
"_lookback_distances",
")",
")",
")",
":",
... | [
614,
2
] | [
635,
59
] | python | en | ['en', 'en', 'en'] | True |
LookbackEventSequenceEncoderDecoder.labels_to_num_steps | (self, labels) | Returns the total number of time steps for a sequence of class labels.
This method assumes the event sequence begins with the event corresponding
to the first label, which is inconsistent with the `encode` method in
EventSequenceEncoderDecoder that uses the second event as the first label.
Therefore, i... | Returns the total number of time steps for a sequence of class labels. | def labels_to_num_steps(self, labels):
"""Returns the total number of time steps for a sequence of class labels.
This method assumes the event sequence begins with the event corresponding
to the first label, which is inconsistent with the `encode` method in
EventSequenceEncoderDecoder that uses the sec... | [
"def",
"labels_to_num_steps",
"(",
"self",
",",
"labels",
")",
":",
"events",
"=",
"[",
"]",
"for",
"label",
"in",
"labels",
":",
"events",
".",
"append",
"(",
"self",
".",
"class_index_to_event",
"(",
"label",
",",
"events",
")",
")",
"return",
"sum",
... | [
637,
2
] | [
659,
35
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.__init__ | (self, control_encoder_decoder, target_encoder_decoder) | Initialize a ConditionalEventSequenceEncoderDecoder object.
Args:
control_encoder_decoder: The EventSequenceEncoderDecoder to encode/decode
the control sequence.
target_encoder_decoder: The EventSequenceEncoderDecoder to encode/decode
the target sequence.
| Initialize a ConditionalEventSequenceEncoderDecoder object. | def __init__(self, control_encoder_decoder, target_encoder_decoder):
"""Initialize a ConditionalEventSequenceEncoderDecoder object.
Args:
control_encoder_decoder: The EventSequenceEncoderDecoder to encode/decode
the control sequence.
target_encoder_decoder: The EventSequenceEncoderDecoder... | [
"def",
"__init__",
"(",
"self",
",",
"control_encoder_decoder",
",",
"target_encoder_decoder",
")",
":",
"self",
".",
"_control_encoder_decoder",
"=",
"control_encoder_decoder",
"self",
".",
"_target_encoder_decoder",
"=",
"target_encoder_decoder"
] | [
685,
2
] | [
695,
57
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.input_size | (self) | The size of the concatenated control and target input vectors.
Returns:
An integer, the size of an input vector.
| The size of the concatenated control and target input vectors. | def input_size(self):
"""The size of the concatenated control and target input vectors.
Returns:
An integer, the size of an input vector.
"""
return (self._control_encoder_decoder.input_size +
self._target_encoder_decoder.input_size) | [
"def",
"input_size",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_control_encoder_decoder",
".",
"input_size",
"+",
"self",
".",
"_target_encoder_decoder",
".",
"input_size",
")"
] | [
698,
2
] | [
705,
52
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.num_classes | (self) | The range of target labels used by this model.
Returns:
An integer, the range of integers that can be returned by
self.events_to_label.
| The range of target labels used by this model. | def num_classes(self):
"""The range of target labels used by this model.
Returns:
An integer, the range of integers that can be returned by
self.events_to_label.
"""
return self._target_encoder_decoder.num_classes | [
"def",
"num_classes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_target_encoder_decoder",
".",
"num_classes"
] | [
708,
2
] | [
715,
51
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.default_event_label | (self) | The class label that represents a default target event.
Returns:
An integer, the class label that represents a default target event.
| The class label that represents a default target event. | def default_event_label(self):
"""The class label that represents a default target event.
Returns:
An integer, the class label that represents a default target event.
"""
return self._target_encoder_decoder.default_event_label | [
"def",
"default_event_label",
"(",
"self",
")",
":",
"return",
"self",
".",
"_target_encoder_decoder",
".",
"default_event_label"
] | [
718,
2
] | [
724,
59
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.events_to_input | (self, control_events, target_events, position) | Returns the input vector for the given position in the sequence pair.
Returns the vector formed by concatenating the input vector for the control
sequence and the input vector for the target sequence.
Args:
control_events: A list-like sequence of control events.
target_events: A list-like sequ... | Returns the input vector for the given position in the sequence pair. | def events_to_input(self, control_events, target_events, position):
"""Returns the input vector for the given position in the sequence pair.
Returns the vector formed by concatenating the input vector for the control
sequence and the input vector for the target sequence.
Args:
control_events: A ... | [
"def",
"events_to_input",
"(",
"self",
",",
"control_events",
",",
"target_events",
",",
"position",
")",
":",
"return",
"(",
"self",
".",
"_control_encoder_decoder",
".",
"events_to_input",
"(",
"control_events",
",",
"position",
"+",
"1",
")",
"+",
"self",
"... | [
726,
2
] | [
746,
78
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.events_to_label | (self, target_events, position) | Returns the label for the given position in the target event sequence.
Args:
target_events: A list-like sequence of target events.
position: An integer event position in the target event sequence.
Returns:
A label, an integer.
| Returns the label for the given position in the target event sequence. | def events_to_label(self, target_events, position):
"""Returns the label for the given position in the target event sequence.
Args:
target_events: A list-like sequence of target events.
position: An integer event position in the target event sequence.
Returns:
A label, an integer.
""... | [
"def",
"events_to_label",
"(",
"self",
",",
"target_events",
",",
"position",
")",
":",
"return",
"self",
".",
"_target_encoder_decoder",
".",
"events_to_label",
"(",
"target_events",
",",
"position",
")"
] | [
748,
2
] | [
758,
80
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.class_index_to_event | (self, class_index, target_events) | Returns the event for the given class index.
This is the reverse process of the self.events_to_label method.
Args:
class_index: An integer in the range [0, self.num_classes).
target_events: A list-like sequence of target events.
Returns:
A target event value.
| Returns the event for the given class index. | def class_index_to_event(self, class_index, target_events):
"""Returns the event for the given class index.
This is the reverse process of the self.events_to_label method.
Args:
class_index: An integer in the range [0, self.num_classes).
target_events: A list-like sequence of target events.
... | [
"def",
"class_index_to_event",
"(",
"self",
",",
"class_index",
",",
"target_events",
")",
":",
"return",
"self",
".",
"_target_encoder_decoder",
".",
"class_index_to_event",
"(",
"class_index",
",",
"target_events",
")"
] | [
760,
2
] | [
773,
35
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.labels_to_num_steps | (self, labels) | Returns the total number of time steps for a sequence of class labels.
Args:
labels: A list-like sequence of integers in the range
[0, self.num_classes).
Returns:
The total number of time steps for the label sequence, as determined by
the target encoder/decoder.
| Returns the total number of time steps for a sequence of class labels. | def labels_to_num_steps(self, labels):
"""Returns the total number of time steps for a sequence of class labels.
Args:
labels: A list-like sequence of integers in the range
[0, self.num_classes).
Returns:
The total number of time steps for the label sequence, as determined by
t... | [
"def",
"labels_to_num_steps",
"(",
"self",
",",
"labels",
")",
":",
"return",
"self",
".",
"_target_encoder_decoder",
".",
"labels_to_num_steps",
"(",
"labels",
")"
] | [
775,
2
] | [
786,
67
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.encode | (self, control_events, target_events) | Returns inputs and labels for the given event sequence pair.
Args:
control_events: A list-like sequence of control events.
target_events: A list-like sequence of target events, the same length as
`control_events`.
Returns:
Inputs and labels.
Raises:
ValueError: If the co... | Returns inputs and labels for the given event sequence pair. | def encode(self, control_events, target_events):
"""Returns inputs and labels for the given event sequence pair.
Args:
control_events: A list-like sequence of control events.
target_events: A list-like sequence of target events, the same length as
`control_events`.
Returns:
Inp... | [
"def",
"encode",
"(",
"self",
",",
"control_events",
",",
"target_events",
")",
":",
"if",
"len",
"(",
"control_events",
")",
"!=",
"len",
"(",
"target_events",
")",
":",
"raise",
"ValueError",
"(",
"'must have the same number of control and target events '",
"'(%d ... | [
788,
2
] | [
813,
25
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.get_inputs_batch | (self, control_event_sequences, target_event_sequences,
full_length=False) | Returns an inputs batch for the given control and target event sequences.
Args:
control_event_sequences: A list of list-like control event sequences.
target_event_sequences: A list of list-like target event sequences, the
same length as `control_event_sequences`. Each target event sequence
... | Returns an inputs batch for the given control and target event sequences. | def get_inputs_batch(self, control_event_sequences, target_event_sequences,
full_length=False):
"""Returns an inputs batch for the given control and target event sequences.
Args:
control_event_sequences: A list of list-like control event sequences.
target_event_sequences: A l... | [
"def",
"get_inputs_batch",
"(",
"self",
",",
"control_event_sequences",
",",
"target_event_sequences",
",",
"full_length",
"=",
"False",
")",
":",
"if",
"len",
"(",
"control_event_sequences",
")",
"!=",
"len",
"(",
"target_event_sequences",
")",
":",
"raise",
"Val... | [
815,
2
] | [
863,
23
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.extend_event_sequences | (self, target_event_sequences, softmax) | Extends the event sequences by sampling the softmax probabilities.
Args:
target_event_sequences: A list of target EventSequence objects.
softmax: A list of softmax probability vectors. The list of softmaxes
should be the same length as the list of event sequences.
Returns:
A Python... | Extends the event sequences by sampling the softmax probabilities. | def extend_event_sequences(self, target_event_sequences, softmax):
"""Extends the event sequences by sampling the softmax probabilities.
Args:
target_event_sequences: A list of target EventSequence objects.
softmax: A list of softmax probability vectors. The list of softmaxes
should be th... | [
"def",
"extend_event_sequences",
"(",
"self",
",",
"target_event_sequences",
",",
"softmax",
")",
":",
"return",
"self",
".",
"_target_encoder_decoder",
".",
"extend_event_sequences",
"(",
"target_event_sequences",
",",
"softmax",
")"
] | [
865,
2
] | [
877,
40
] | python | en | ['en', 'en', 'en'] | True |
ConditionalEventSequenceEncoderDecoder.evaluate_log_likelihood | (self, target_event_sequences, softmax) | Evaluate the log likelihood of multiple target event sequences.
Args:
target_event_sequences: A list of target EventSequence objects.
softmax: A list of softmax probability vectors. The list of softmaxes
should be the same length as the list of target event sequences. The
softmax ve... | Evaluate the log likelihood of multiple target event sequences. | def evaluate_log_likelihood(self, target_event_sequences, softmax):
"""Evaluate the log likelihood of multiple target event sequences.
Args:
target_event_sequences: A list of target EventSequence objects.
softmax: A list of softmax probability vectors. The list of softmaxes
should be the ... | [
"def",
"evaluate_log_likelihood",
"(",
"self",
",",
"target_event_sequences",
",",
"softmax",
")",
":",
"return",
"self",
".",
"_target_encoder_decoder",
".",
"evaluate_log_likelihood",
"(",
"target_event_sequences",
",",
"softmax",
")"
] | [
879,
2
] | [
893,
40
] | python | en | ['en', 'en', 'en'] | True |
OptionalEventSequenceEncoder.__init__ | (self, encoder) | Initialize an OptionalEventSequenceEncoder object.
Args:
encoder: The base EventSequenceEncoderDecoder to use.
| Initialize an OptionalEventSequenceEncoder object. | def __init__(self, encoder):
"""Initialize an OptionalEventSequenceEncoder object.
Args:
encoder: The base EventSequenceEncoderDecoder to use.
"""
self._encoder = encoder | [
"def",
"__init__",
"(",
"self",
",",
"encoder",
")",
":",
"self",
".",
"_encoder",
"=",
"encoder"
] | [
905,
2
] | [
911,
27
] | python | en | ['en', 'en', 'nl'] | True |
MultipleEventSequenceEncoder.__init__ | (self, encoders, encode_single_sequence=False) | Initialize a MultipleEventSequenceEncoder object.
Args:
encoders: A list of component EventSequenceEncoderDecoder objects whose
output will be concatenated.
encode_single_sequence: If True, at encoding time all of the encoders will
be applied to a single event sequence. If False, ea... | Initialize a MultipleEventSequenceEncoder object. | def __init__(self, encoders, encode_single_sequence=False):
"""Initialize a MultipleEventSequenceEncoder object.
Args:
encoders: A list of component EventSequenceEncoderDecoder objects whose
output will be concatenated.
encode_single_sequence: If True, at encoding time all of the encoders... | [
"def",
"__init__",
"(",
"self",
",",
"encoders",
",",
"encode_single_sequence",
"=",
"False",
")",
":",
"self",
".",
"_encoders",
"=",
"encoders",
"self",
".",
"_encode_single_sequence",
"=",
"encode_single_sequence"
] | [
952,
2
] | [
967,
57
] | python | en | ['en', 'en', 'it'] | True |
UserFilterAction.filter | (self, table, users, filter_string) | Naive case-insensitive search. | Naive case-insensitive search. | def filter(self, table, users, filter_string):
"""Naive case-insensitive search."""
q = filter_string.lower()
return [user for user in users
if (q in user.name.lower() or
q in (getattr(user, 'email', None) or '').lower())] | [
"def",
"filter",
"(",
"self",
",",
"table",
",",
"users",
",",
"filter_string",
")",
":",
"q",
"=",
"filter_string",
".",
"lower",
"(",
")",
"return",
"[",
"user",
"for",
"user",
"in",
"users",
"if",
"(",
"q",
"in",
"user",
".",
"name",
".",
"lower... | [
121,
4
] | [
126,
71
] | python | en | ['en', 'it', 'en'] | True |
tempdir | () | Create a temporary directory in a context manager. | Create a temporary directory in a context manager. | def tempdir():
"""Create a temporary directory in a context manager."""
td = tempfile.mkdtemp()
try:
yield td
finally:
shutil.rmtree(td) | [
"def",
"tempdir",
"(",
")",
":",
"td",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"try",
":",
"yield",
"td",
"finally",
":",
"shutil",
".",
"rmtree",
"(",
"td",
")"
] | [
10,
0
] | [
16,
25
] | python | en | ['en', 'en', 'en'] | True |
mkdir_p | (*args, **kwargs) | Like `mkdir`, but does not raise an exception if the
directory already exists.
| Like `mkdir`, but does not raise an exception if the
directory already exists.
| def mkdir_p(*args, **kwargs):
"""Like `mkdir`, but does not raise an exception if the
directory already exists.
"""
try:
return os.mkdir(*args, **kwargs)
except OSError as exc:
if exc.errno != errno.EEXIST:
raise | [
"def",
"mkdir_p",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"os",
".",
"mkdir",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"OSError",
"as",
"exc",
":",
"if",
"exc",
".",
"errno",
"!=",
"errno",
".... | [
19,
0
] | [
27,
17
] | python | en | ['en', 'en', 'en'] | True |
dir_to_zipfile | (root) | Construct an in-memory zip file for a directory. | Construct an in-memory zip file for a directory. | def dir_to_zipfile(root):
"""Construct an in-memory zip file for a directory."""
buffer = io.BytesIO()
zip_file = zipfile.ZipFile(buffer, 'w')
for root, dirs, files in os.walk(root):
for path in dirs:
fs_path = os.path.join(root, path)
rel_path = os.path.relpath(fs_path, ... | [
"def",
"dir_to_zipfile",
"(",
"root",
")",
":",
"buffer",
"=",
"io",
".",
"BytesIO",
"(",
")",
"zip_file",
"=",
"zipfile",
".",
"ZipFile",
"(",
"buffer",
",",
"'w'",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"root... | [
30,
0
] | [
43,
19
] | python | en | ['br', 'en', 'en'] | True |
TestFlavors.test_flavor_create | (self) | tests the flavor creation and deletion functionalities:
* creates a new flavor
* verifies the flavor appears in the flavors table
* deletes the newly created flavor
* verifies the flavor does not appear in the table after deletion
| tests the flavor creation and deletion functionalities: | def test_flavor_create(self):
"""tests the flavor creation and deletion functionalities:
* creates a new flavor
* verifies the flavor appears in the flavors table
* deletes the newly created flavor
* verifies the flavor does not appear in the table after deletion
"""
... | [
"def",
"test_flavor_create",
"(",
"self",
")",
":",
"self",
".",
"_create_flavor",
"(",
"self",
".",
"FLAVOR_NAME",
")",
"self",
".",
"_delete_flavor",
"(",
"self",
".",
"FLAVOR_NAME",
")"
] | [
69,
4
] | [
78,
45
] | python | en | ['en', 'en', 'en'] | True |
maybe_send_to_registration | (
request: HttpRequest,
email: str,
full_name: str = "",
mobile_flow_otp: Optional[str] = None,
desktop_flow_otp: Optional[str] = None,
is_signup: bool = False,
password_required: bool = True,
multiuse_object_key: str = "",
full_name_validated: bool = False,
) | Given a successful authentication for an email address (i.e. we've
confirmed the user controls the email address) that does not
currently have a Zulip account in the target realm, send them to
the registration flow or the "continue to registration" flow,
depending on is_signup, whether the email address... | Given a successful authentication for an email address (i.e. we've
confirmed the user controls the email address) that does not
currently have a Zulip account in the target realm, send them to
the registration flow or the "continue to registration" flow,
depending on is_signup, whether the email address... | def maybe_send_to_registration(
request: HttpRequest,
email: str,
full_name: str = "",
mobile_flow_otp: Optional[str] = None,
desktop_flow_otp: Optional[str] = None,
is_signup: bool = False,
password_required: bool = True,
multiuse_object_key: str = "",
full_name_validated: bool = Fa... | [
"def",
"maybe_send_to_registration",
"(",
"request",
":",
"HttpRequest",
",",
"email",
":",
"str",
",",
"full_name",
":",
"str",
"=",
"\"\"",
",",
"mobile_flow_otp",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"desktop_flow_otp",
":",
"Optional",
"["... | [
115,
0
] | [
232,
72
] | python | en | ['en', 'en', 'en'] | True |
login_or_register_remote_user | (request: HttpRequest, result: ExternalAuthResult) | Given a successful authentication showing the user controls given
email address (email) and potentially a UserProfile
object (if the user already has a Zulip account), redirect the
browser to the appropriate place:
* The logged-in app if the user already has a Zulip account and is
trying to log i... | Given a successful authentication showing the user controls given
email address (email) and potentially a UserProfile
object (if the user already has a Zulip account), redirect the
browser to the appropriate place: | def login_or_register_remote_user(request: HttpRequest, result: ExternalAuthResult) -> HttpResponse:
"""Given a successful authentication showing the user controls given
email address (email) and potentially a UserProfile
object (if the user already has a Zulip account), redirect the
browser to the appr... | [
"def",
"login_or_register_remote_user",
"(",
"request",
":",
"HttpRequest",
",",
"result",
":",
"ExternalAuthResult",
")",
"->",
"HttpResponse",
":",
"user_profile",
"=",
"result",
".",
"user_profile",
"if",
"user_profile",
"is",
"None",
"or",
"user_profile",
".",
... | [
249,
0
] | [
289,
44
] | python | en | ['en', 'en', 'en'] | True |
finish_desktop_flow | (request: HttpRequest, user_profile: UserProfile, otp: str) |
The desktop otp flow returns to the app (through the clipboard)
a token that allows obtaining (through log_into_subdomain) a logged in session
for the user account we authenticated in this flow.
The token can only be used once and within ExternalAuthResult.LOGIN_KEY_EXPIRATION_SECONDS
of being crea... |
The desktop otp flow returns to the app (through the clipboard)
a token that allows obtaining (through log_into_subdomain) a logged in session
for the user account we authenticated in this flow.
The token can only be used once and within ExternalAuthResult.LOGIN_KEY_EXPIRATION_SECONDS
of being crea... | def finish_desktop_flow(request: HttpRequest, user_profile: UserProfile, otp: str) -> HttpResponse:
"""
The desktop otp flow returns to the app (through the clipboard)
a token that allows obtaining (through log_into_subdomain) a logged in session
for the user account we authenticated in this flow.
T... | [
"def",
"finish_desktop_flow",
"(",
"request",
":",
"HttpRequest",
",",
"user_profile",
":",
"UserProfile",
",",
"otp",
":",
"str",
")",
"->",
"HttpResponse",
":",
"result",
"=",
"ExternalAuthResult",
"(",
"user_profile",
"=",
"user_profile",
")",
"token",
"=",
... | [
292,
0
] | [
311,
75
] | python | en | ['en', 'error', 'th'] | False |
start_remote_user_sso | (request: HttpRequest) |
The purpose of this endpoint is to provide an initial step in the flow
on which we can handle the special behavior for the desktop app.
/accounts/login/sso may have Apache intercepting requests to it
to do authentication, so we need this additional endpoint.
|
The purpose of this endpoint is to provide an initial step in the flow
on which we can handle the special behavior for the desktop app.
/accounts/login/sso may have Apache intercepting requests to it
to do authentication, so we need this additional endpoint.
| def start_remote_user_sso(request: HttpRequest) -> HttpResponse:
"""
The purpose of this endpoint is to provide an initial step in the flow
on which we can handle the special behavior for the desktop app.
/accounts/login/sso may have Apache intercepting requests to it
to do authentication, so we nee... | [
"def",
"start_remote_user_sso",
"(",
"request",
":",
"HttpRequest",
")",
"->",
"HttpResponse",
":",
"query",
"=",
"request",
".",
"META",
"[",
"\"QUERY_STRING\"",
"]",
"return",
"redirect",
"(",
"add_query_to_redirect_url",
"(",
"reverse",
"(",
"remote_user_sso",
... | [
518,
0
] | [
526,
79
] | python | en | ['en', 'error', 'th'] | False |
log_into_subdomain | (request: HttpRequest, token: str) | Given a valid authentication token (generated by
redirect_and_log_into_subdomain called on auth.zulip.example.com),
call login_or_register_remote_user, passing all the authentication
result data that has been stored in Redis, associated with this token.
| Given a valid authentication token (generated by
redirect_and_log_into_subdomain called on auth.zulip.example.com),
call login_or_register_remote_user, passing all the authentication
result data that has been stored in Redis, associated with this token.
| def log_into_subdomain(request: HttpRequest, token: str) -> HttpResponse:
"""Given a valid authentication token (generated by
redirect_and_log_into_subdomain called on auth.zulip.example.com),
call login_or_register_remote_user, passing all the authentication
result data that has been stored in Redis, a... | [
"def",
"log_into_subdomain",
"(",
"request",
":",
"HttpRequest",
",",
"token",
":",
"str",
")",
"->",
"HttpResponse",
":",
"# The tokens are intended to have the same format as API keys.",
"if",
"not",
"has_api_key_format",
"(",
"token",
")",
":",
"logging",
".",
"war... | [
590,
0
] | [
611,
57
] | python | en | ['en', 'en', 'en'] | True |
start_two_factor_auth | (
request: HttpRequest, extra_context: ExtraContext = None, **kwargs: Any
) |
This is how Django implements as_view(), so extra_context will be passed
to the __init__ method of TwoFactorLoginView.
def as_view(cls, **initkwargs):
def view(request, *args, **kwargs):
self = cls(**initkwargs)
...
return view
|
This is how Django implements as_view(), so extra_context will be passed
to the __init__ method of TwoFactorLoginView. | def start_two_factor_auth(
request: HttpRequest, extra_context: ExtraContext = None, **kwargs: Any
) -> HttpResponse:
two_fa_form_field = "two_factor_login_view-current_step"
if two_fa_form_field not in request.POST:
# Here we inject the 2FA step in the request context if it's missing to
# f... | [
"def",
"start_two_factor_auth",
"(",
"request",
":",
"HttpRequest",
",",
"extra_context",
":",
"ExtraContext",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"HttpResponse",
":",
"two_fa_form_field",
"=",
"\"two_factor_login_view-current_step\"",
"if",... | [
767,
0
] | [
795,
41
] | python | en | ['en', 'error', 'th'] | False |
get_auth_backends_data | (request: HttpRequest) | Returns which authentication methods are enabled on the server | Returns which authentication methods are enabled on the server | def get_auth_backends_data(request: HttpRequest) -> Dict[str, Any]:
"""Returns which authentication methods are enabled on the server"""
subdomain = get_subdomain(request)
try:
realm = Realm.objects.get(string_id=subdomain)
except Realm.DoesNotExist:
# If not the root subdomain, this is ... | [
"def",
"get_auth_backends_data",
"(",
"request",
":",
"HttpRequest",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"subdomain",
"=",
"get_subdomain",
"(",
"request",
")",
"try",
":",
"realm",
"=",
"Realm",
".",
"objects",
".",
"get",
"(",
"string_... | [
861,
0
] | [
884,
17
] | python | en | ['en', 'en', 'en'] | True |
saml_sp_metadata | (request: HttpRequest, **kwargs: Any) |
This is the view function for generating our SP metadata
for SAML authentication. It's meant for helping check the correctness
of the configuration when setting up SAML, or for obtaining the XML metadata
if the IdP requires it.
Taken from https://python-social-auth.readthedocs.io/en/latest/backends... |
This is the view function for generating our SP metadata
for SAML authentication. It's meant for helping check the correctness
of the configuration when setting up SAML, or for obtaining the XML metadata
if the IdP requires it.
Taken from https://python-social-auth.readthedocs.io/en/latest/backends... | def saml_sp_metadata(request: HttpRequest, **kwargs: Any) -> HttpResponse: # nocoverage
"""
This is the view function for generating our SP metadata
for SAML authentication. It's meant for helping check the correctness
of the configuration when setting up SAML, or for obtaining the XML metadata
if ... | [
"def",
"saml_sp_metadata",
"(",
"request",
":",
"HttpRequest",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"HttpResponse",
":",
"# nocoverage",
"if",
"not",
"saml_auth_enabled",
"(",
")",
":",
"return",
"config_error",
"(",
"request",
",",
"\"saml\"",
")... | [
957,
0
] | [
974,
61
] | python | en | ['en', 'error', 'th'] | False |
TwoFactorLoginView.done | (self, form_list: List[Form], **kwargs: Any) |
Log in the user and redirect to the desired page.
We need to override this function so that we can redirect to
realm.uri instead of '/'.
|
Log in the user and redirect to the desired page. | def done(self, form_list: List[Form], **kwargs: Any) -> HttpResponse:
"""
Log in the user and redirect to the desired page.
We need to override this function so that we can redirect to
realm.uri instead of '/'.
"""
realm_uri = self.get_user().realm.uri
# This moc... | [
"def",
"done",
"(",
"self",
",",
"form_list",
":",
"List",
"[",
"Form",
"]",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"HttpResponse",
":",
"realm_uri",
"=",
"self",
".",
"get_user",
"(",
")",
".",
"realm",
".",
"uri",
"# This mock.patch business... | [
679,
4
] | [
696,
52
] | python | en | ['en', 'error', 'th'] | False |
set_topic_mutes | (
user_profile: UserProfile,
muted_topics: List[List[str]],
date_muted: Optional[datetime.datetime] = None,
) |
This is only used in tests.
|
This is only used in tests.
| def set_topic_mutes(
user_profile: UserProfile,
muted_topics: List[List[str]],
date_muted: Optional[datetime.datetime] = None,
) -> None:
"""
This is only used in tests.
"""
MutedTopic.objects.filter(
user_profile=user_profile,
).delete()
if date_muted is None:
date... | [
"def",
"set_topic_mutes",
"(",
"user_profile",
":",
"UserProfile",
",",
"muted_topics",
":",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
",",
"date_muted",
":",
"Optional",
"[",
"datetime",
".",
"datetime",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
... | [
30,
0
] | [
55,
9
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy.key | (self) |
Возвращает уникальный идентификатор стратегии создания функции
|
Возвращает уникальный идентификатор стратегии создания функции
| def key(self) -> Optional[str]:
"""
Возвращает уникальный идентификатор стратегии создания функции
"""
return self._key | [
"def",
"key",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_key"
] | [
72,
4
] | [
76,
24
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy.title | (self) |
Возвращает название стратегии создания функции
|
Возвращает название стратегии создания функции
| def title(self) -> Optional[str]:
"""
Возвращает название стратегии создания функции
"""
return self._title | [
"def",
"title",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_title"
] | [
79,
4
] | [
83,
26
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy.function_template_name | (self) |
Возвращает наименование стратегии реализации функции
|
Возвращает наименование стратегии реализации функции
| def function_template_name(self) -> Optional[str]:
"""
Возвращает наименование стратегии реализации функции
"""
return self._function_template_name | [
"def",
"function_template_name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_function_template_name"
] | [
86,
4
] | [
90,
43
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_key | (self) |
Формирование уникального ключа стратегии создания функции
|
Формирование уникального ключа стратегии создания функции
| def _prepare_key(self) -> Optional[str]:
"""
Формирование уникального ключа стратегии создания функции
""" | [
"def",
"_prepare_key",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":"
] | [
249,
4
] | [
252,
11
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_title | (self) |
Формирование наименования стратегии создания функции
|
Формирование наименования стратегии создания функции
| def _prepare_title(self) -> Optional[str]:
"""
Формирование наименования стратегии создания функции
""" | [
"def",
"_prepare_title",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":"
] | [
255,
4
] | [
258,
11
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_function_template_name | (self) |
Формирование названия шаблона создания функции
|
Формирование названия шаблона создания функции
| def _prepare_function_template_name(self) -> Optional[str]:
"""
Формирование названия шаблона создания функции
""" | [
"def",
"_prepare_function_template_name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":"
] | [
260,
4
] | [
263,
11
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_manager_class | (self) |
Устанавливает класс менеджера
|
Устанавливает класс менеджера
| def _prepare_manager_class(self):
"""
Устанавливает класс менеджера
"""
self._manager_class = RunnerManager | [
"def",
"_prepare_manager_class",
"(",
"self",
")",
":",
"self",
".",
"_manager_class",
"=",
"RunnerManager"
] | [
265,
4
] | [
269,
43
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_runner_class | (self) |
Устанавливает класс пускателя
|
Устанавливает класс пускателя
| def _prepare_runner_class(self):
"""
Устанавливает класс пускателя
"""
self._runner_class = BaseRunner | [
"def",
"_prepare_runner_class",
"(",
"self",
")",
":",
"self",
".",
"_runner_class",
"=",
"BaseRunner"
] | [
271,
4
] | [
275,
39
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_function_class | (self) |
Устанавливает класс Функции
|
Устанавливает класс Функции
| def _prepare_function_class(self):
"""
Устанавливает класс Функции
"""
self._function_class = BaseFunction | [
"def",
"_prepare_function_class",
"(",
"self",
")",
":",
"self",
".",
"_function_class",
"=",
"BaseFunction"
] | [
277,
4
] | [
281,
43
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_runner_helper_class | (self) |
Устанавливает класс помощника пусковика
|
Устанавливает класс помощника пусковика
| def _prepare_runner_helper_class(self):
"""
Устанавливает класс помощника пусковика
"""
self._runner_helper_class = BaseRunnerHelper | [
"def",
"_prepare_runner_helper_class",
"(",
"self",
")",
":",
"self",
".",
"_runner_helper_class",
"=",
"BaseRunnerHelper"
] | [
283,
4
] | [
287,
52
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_function_helper_class | (self) |
Устанавливает класс помощника функции
|
Устанавливает класс помощника функции
| def _prepare_function_helper_class(self):
"""
Устанавливает класс помощника функции
"""
self._function_helper_class = BaseFunctionHelper | [
"def",
"_prepare_function_helper_class",
"(",
"self",
")",
":",
"self",
".",
"_function_helper_class",
"=",
"BaseFunctionHelper"
] | [
289,
4
] | [
293,
56
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_runner_validator_class | (self) |
Устанавливает класс валидатора пусковика
|
Устанавливает класс валидатора пусковика
| def _prepare_runner_validator_class(self):
"""
Устанавливает класс валидатора пусковика
"""
self._runner_validator_class = BaseValidator | [
"def",
"_prepare_runner_validator_class",
"(",
"self",
")",
":",
"self",
".",
"_runner_validator_class",
"=",
"BaseValidator"
] | [
295,
4
] | [
299,
52
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_function_validator_class | (self) |
Устанавливает класс валидатора Функции
|
Устанавливает класс валидатора Функции
| def _prepare_function_validator_class(self):
"""
Устанавливает класс валидатора Функции
"""
self._function_validator_class = BaseValidator | [
"def",
"_prepare_function_validator_class",
"(",
"self",
")",
":",
"self",
".",
"_function_validator_class",
"=",
"BaseValidator"
] | [
301,
4
] | [
305,
54
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_runner_cache_storage_class | (self) |
Устанавливает класс хранилища кешей пусковика
|
Устанавливает класс хранилища кешей пусковика
| def _prepare_runner_cache_storage_class(self):
"""
Устанавливает класс хранилища кешей пусковика
"""
self._runner_cache_storage_class = CacheStorage | [
"def",
"_prepare_runner_cache_storage_class",
"(",
"self",
")",
":",
"self",
".",
"_runner_cache_storage_class",
"=",
"CacheStorage"
] | [
307,
4
] | [
311,
55
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_function_cache_storage_class | (self) |
Устанавливает класс хранилища кешей Функции
|
Устанавливает класс хранилища кешей Функции
| def _prepare_function_cache_storage_class(self):
"""
Устанавливает класс хранилища кешей Функции
"""
self._function_cache_storage_class = CacheStorage | [
"def",
"_prepare_function_cache_storage_class",
"(",
"self",
")",
":",
"self",
".",
"_function_cache_storage_class",
"=",
"CacheStorage"
] | [
313,
4
] | [
317,
57
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_error_class | (self) |
Устанавливает класс ошибки
|
Устанавливает класс ошибки
| def _prepare_error_class(self):
"""
Устанавливает класс ошибки
"""
self._error_class = BaseError | [
"def",
"_prepare_error_class",
"(",
"self",
")",
":",
"self",
".",
"_error_class",
"=",
"BaseError"
] | [
319,
4
] | [
323,
37
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_runner_result_class | (self) |
Устанавливает класс результата
|
Устанавливает класс результата
| def _prepare_runner_result_class(self):
"""
Устанавливает класс результата
"""
self._runner_result_class = BaseRunnableResult | [
"def",
"_prepare_runner_result_class",
"(",
"self",
")",
":",
"self",
".",
"_runner_result_class",
"=",
"BaseRunnableResult"
] | [
325,
4
] | [
329,
54
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_function_result_class | (self) |
Устанавливает класс результата
|
Устанавливает класс результата
| def _prepare_function_result_class(self):
"""
Устанавливает класс результата
"""
self._function_result_class = BaseRunnableResult | [
"def",
"_prepare_function_result_class",
"(",
"self",
")",
":",
"self",
".",
"_function_result_class",
"=",
"BaseRunnableResult"
] | [
331,
4
] | [
335,
56
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare_result_presenter_class | (self) |
Устанавливает класс презентера результата
|
Устанавливает класс презентера результата
| def _prepare_result_presenter_class(self):
"""
Устанавливает класс презентера результата
"""
self._result_presenter_class = ResultPresenter | [
"def",
"_prepare_result_presenter_class",
"(",
"self",
")",
":",
"self",
".",
"_result_presenter_class",
"=",
"ResultPresenter"
] | [
337,
4
] | [
341,
54
] | python | en | ['en', 'error', 'th'] | False |
FunctionImplementationStrategy._prepare | (self) |
Подготовка компонентов реализации функции
|
Подготовка компонентов реализации функции
| def _prepare(self):
"""
Подготовка компонентов реализации функции
"""
self._prepare_manager_class()
self._prepare_runner_class()
self._prepare_function_class()
self._prepare_runner_helper_class()
self._prepare_function_helper_class()
self._prepare_... | [
"def",
"_prepare",
"(",
"self",
")",
":",
"self",
".",
"_prepare_manager_class",
"(",
")",
"self",
".",
"_prepare_runner_class",
"(",
")",
"self",
".",
"_prepare_function_class",
"(",
")",
"self",
".",
"_prepare_runner_helper_class",
"(",
")",
"self",
".",
"_p... | [
343,
4
] | [
359,
46
] | python | en | ['en', 'error', 'th'] | False |
SyncBaseRunnerBaseFunctionImplementationStrategy._prepare_key | (self) |
Возвращает уникальный идентификатор стратегии создания функции
|
Возвращает уникальный идентификатор стратегии создания функции
| def _prepare_key(self) -> str:
"""
Возвращает уникальный идентификатор стратегии создания функции
"""
return 'SYNC_BASE_FUNCTION' | [
"def",
"_prepare_key",
"(",
"self",
")",
"->",
"str",
":",
"return",
"'SYNC_BASE_FUNCTION'"
] | [
367,
4
] | [
371,
35
] | python | en | ['en', 'error', 'th'] | False |
SyncBaseRunnerBaseFunctionImplementationStrategy._prepare_title | (self) |
Возвращает название стратегии создания функции
|
Возвращает название стратегии создания функции
| def _prepare_title(self) -> str:
"""
Возвращает название стратегии создания функции
"""
return 'Реализация простой функции без отложенного сохранения' | [
"def",
"_prepare_title",
"(",
"self",
")",
"->",
"str",
":",
"return",
"'Реализация простой функции без отложенного сохранения'"
] | [
373,
4
] | [
377,
118
] | python | en | ['en', 'error', 'th'] | False |
SyncBaseRunnerBaseFunctionImplementationStrategy._prepare_function_template_name | (self) |
Формирование названия шаблона создания функции
|
Формирование названия шаблона создания функции
| def _prepare_function_template_name(self) -> Optional[str]:
"""
Формирование названия шаблона создания функции
"""
return 'm3_function_sync_template' | [
"def",
"_prepare_function_template_name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"'m3_function_sync_template'"
] | [
379,
4
] | [
383,
42
] | python | en | ['en', 'error', 'th'] | False |
SyncBaseRunnerLazySavingPredefinedQueueFunctionImplementationStrategy._prepare_key | (self) |
Возвращает уникальный идентификатор стратегии создания функции
|
Возвращает уникальный идентификатор стратегии создания функции
| def _prepare_key(self) -> str:
"""
Возвращает уникальный идентификатор стратегии создания функции
"""
return 'SYNC_LAZY_SAVING_FUNCTION' | [
"def",
"_prepare_key",
"(",
"self",
")",
"->",
"str",
":",
"return",
"'SYNC_LAZY_SAVING_FUNCTION'"
] | [
391,
4
] | [
395,
42
] | python | en | ['en', 'error', 'th'] | False |
SyncBaseRunnerLazySavingPredefinedQueueFunctionImplementationStrategy._prepare_title | (self) |
Возвращает название стратегии создания функции
|
Возвращает название стратегии создания функции
| def _prepare_title(self) -> str:
"""
Возвращает название стратегии создания функции
"""
return (
'Реализация функции с отложенным сохранением и предустановленной очередью объектов на сохранение. '
'Сохранение производится после удачной работы функции'
) | [
"def",
"_prepare_title",
"(",
"self",
")",
"->",
"str",
":",
"return",
"(",
"'Реализация функции с отложенным сохранением и предустановленной очередью объектов на сохранение. '",
"'Сохранение производится после удачной работы функции'",
")"
] | [
397,
4
] | [
404,
9
] | python | en | ['en', 'error', 'th'] | False |
SyncBaseRunnerLazySavingPredefinedQueueFunctionImplementationStrategy._prepare_function_template_name | (self) |
Формирование названия шаблона создания функции
|
Формирование названия шаблона создания функции
| def _prepare_function_template_name(self) -> Optional[str]:
"""
Формирование названия шаблона создания функции
"""
return 'm3_function_sync_template' | [
"def",
"_prepare_function_template_name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"'m3_function_sync_template'"
] | [
406,
4
] | [
410,
42
] | python | en | ['en', 'error', 'th'] | False |
SyncBaseRunnerLazySavingPredefinedQueueFunctionImplementationStrategy._prepare_function_class | (self) |
Устанавливает класс Функции
|
Устанавливает класс Функции
| def _prepare_function_class(self):
"""
Устанавливает класс Функции
"""
self._function_class = LazySavingPredefinedQueueFunction | [
"def",
"_prepare_function_class",
"(",
"self",
")",
":",
"self",
".",
"_function_class",
"=",
"LazySavingPredefinedQueueFunction"
] | [
412,
4
] | [
416,
64
] | python | en | ['en', 'error', 'th'] | False |
SyncLazySavingRunnerLazyDelegateSavingPredefinedQueueFunctionImplementationStrategy._prepare_key | (self) |
Возвращает уникальный идентификатор стратегии создания функции
|
Возвращает уникальный идентификатор стратегии создания функции
| def _prepare_key(self) -> str:
"""
Возвращает уникальный идентификатор стратегии создания функции
"""
return 'SYNC_LAZY_SAVING_RUNNER_FUNCTION' | [
"def",
"_prepare_key",
"(",
"self",
")",
"->",
"str",
":",
"return",
"'SYNC_LAZY_SAVING_RUNNER_FUNCTION'"
] | [
425,
4
] | [
429,
49
] | python | en | ['en', 'error', 'th'] | False |
SyncLazySavingRunnerLazyDelegateSavingPredefinedQueueFunctionImplementationStrategy._prepare_title | (self) |
Возвращает название стратегии создания функции
|
Возвращает название стратегии создания функции
| def _prepare_title(self) -> str:
"""
Возвращает название стратегии создания функции
"""
return (
'Реализация функции с отложенным сохранением его делегированием пускателю. Когда все функции отработают, '
'только после этого запускается сохранение объектов из очере... | [
"def",
"_prepare_title",
"(",
"self",
")",
"->",
"str",
":",
"return",
"(",
"'Реализация функции с отложенным сохранением его делегированием пускателю. Когда все функции отработают, '",
"'только после этого запускается сохранение объектов из очередей каждой функции'",
")"
] | [
431,
4
] | [
438,
9
] | python | en | ['en', 'error', 'th'] | False |
SyncLazySavingRunnerLazyDelegateSavingPredefinedQueueFunctionImplementationStrategy._prepare_function_template_name | (self) |
Формирование названия шаблона создания функции
|
Формирование названия шаблона создания функции
| def _prepare_function_template_name(self) -> Optional[str]:
"""
Формирование названия шаблона создания функции
"""
return 'm3_function_sync_template' | [
"def",
"_prepare_function_template_name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"'m3_function_sync_template'"
] | [
440,
4
] | [
444,
42
] | python | en | ['en', 'error', 'th'] | False |
SyncLazySavingRunnerLazyDelegateSavingPredefinedQueueFunctionImplementationStrategy._prepare_runner_class | (self) |
Устанавливает класс пусковика
|
Устанавливает класс пусковика
| def _prepare_runner_class(self):
"""
Устанавливает класс пусковика
"""
self._runner_class = LazySavingRunner | [
"def",
"_prepare_runner_class",
"(",
"self",
")",
":",
"self",
".",
"_runner_class",
"=",
"LazySavingRunner"
] | [
446,
4
] | [
450,
45
] | python | en | ['en', 'error', 'th'] | False |
SyncLazySavingRunnerLazyDelegateSavingPredefinedQueueFunctionImplementationStrategy._prepare_function_class | (self) |
Устанавливает класс Функции
|
Устанавливает класс Функции
| def _prepare_function_class(self):
"""
Устанавливает класс Функции
"""
self._function_class = LazyDelegateSavingPredefinedQueueFunction | [
"def",
"_prepare_function_class",
"(",
"self",
")",
":",
"self",
".",
"_function_class",
"=",
"LazyDelegateSavingPredefinedQueueFunction"
] | [
452,
4
] | [
456,
72
] | python | en | ['en', 'error', 'th'] | False |
FreshpingHookTests.test_freshping_check_test | (self) |
Tests if freshping check test is handled correctly
|
Tests if freshping check test is handled correctly
| def test_freshping_check_test(self) -> None:
"""
Tests if freshping check test is handled correctly
"""
expected_topic = "Freshping"
expected_message = "Freshping webhook has been successfully configured."
self.check_webhook("freshping_check_test", expected_topic, expecte... | [
"def",
"test_freshping_check_test",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Freshping\"",
"expected_message",
"=",
"\"Freshping webhook has been successfully configured.\"",
"self",
".",
"check_webhook",
"(",
"\"freshping_check_test\"",
",",
"expected_t... | [
8,
4
] | [
14,
84
] | python | en | ['en', 'error', 'th'] | False |
FreshpingHookTests.test_freshping_check_unreachable | (self) |
Tests if freshping check unreachable is handled correctly
|
Tests if freshping check unreachable is handled correctly
| def test_freshping_check_unreachable(self) -> None:
"""
Tests if freshping check unreachable is handled correctly
"""
expected_topic = "Test Check"
expected_message = """
https://example.com has just become unreachable.
Error code: 521.
""".strip()
self.check_webhook("fre... | [
"def",
"test_freshping_check_unreachable",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Test Check\"",
"expected_message",
"=",
"\"\"\"\nhttps://example.com has just become unreachable.\nError code: 521.\n\"\"\"",
".",
"strip",
"(",
")",
"self",
".",
"check_... | [
16,
4
] | [
25,
91
] | python | en | ['en', 'error', 'th'] | False |
FreshpingHookTests.test_freshping_check_reachable | (self) |
Tests if freshping check reachable is handled correctly
|
Tests if freshping check reachable is handled correctly
| def test_freshping_check_reachable(self) -> None:
"""
Tests if freshping check reachable is handled correctly
"""
expected_topic = "Test Check"
expected_message = "https://example.com is back up and no longer unreachable."
self.check_webhook("freshping_check_reachable", e... | [
"def",
"test_freshping_check_reachable",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Test Check\"",
"expected_message",
"=",
"\"https://example.com is back up and no longer unreachable.\"",
"self",
".",
"check_webhook",
"(",
"\"freshping_check_reachable\"",
"... | [
27,
4
] | [
33,
89
] | python | en | ['en', 'error', 'th'] | False |
format_explanation | (explanation) | This formats an explanation
Normally all embedded newlines are escaped, however there are
three exceptions: \n{, \n} and \n~. The first two are intended
cover nested explanations, see function and attribute explanations
for examples (.visit_Call(), visit_Attribute()). The last one is
for when one... | This formats an explanation | def format_explanation(explanation):
"""This formats an explanation
Normally all embedded newlines are escaped, however there are
three exceptions: \n{, \n} and \n~. The first two are intended
cover nested explanations, see function and attribute explanations
for examples (.visit_Call(), visit_Att... | [
"def",
"format_explanation",
"(",
"explanation",
")",
":",
"explanation",
"=",
"ecu",
"(",
"explanation",
")",
"lines",
"=",
"_split_explanation",
"(",
"explanation",
")",
"result",
"=",
"_format_lines",
"(",
"lines",
")",
"return",
"u",
"(",
"'\\n'",
")",
"... | [
27,
0
] | [
40,
31
] | python | en | ['en', 'en', 'en'] | True |
_split_explanation | (explanation) | Return a list of individual lines in the explanation
This will return a list of lines split on '\n{', '\n}' and '\n~'.
Any other newlines will be escaped and appear in the line as the
literal '\n' characters.
| Return a list of individual lines in the explanation | def _split_explanation(explanation):
"""Return a list of individual lines in the explanation
This will return a list of lines split on '\n{', '\n}' and '\n~'.
Any other newlines will be escaped and appear in the line as the
literal '\n' characters.
"""
raw_lines = (explanation or u('')).split('... | [
"def",
"_split_explanation",
"(",
"explanation",
")",
":",
"raw_lines",
"=",
"(",
"explanation",
"or",
"u",
"(",
"''",
")",
")",
".",
"split",
"(",
"'\\n'",
")",
"lines",
"=",
"[",
"raw_lines",
"[",
"0",
"]",
"]",
"for",
"values",
"in",
"raw_lines",
... | [
43,
0
] | [
57,
16
] | python | en | ['en', 'en', 'en'] | True |
_format_lines | (lines) | Format the individual lines
This will replace the '{', '}' and '~' characters of our mini
formatting language with the proper 'where ...', 'and ...' and ' +
...' text, taking care of indentation along the way.
Return a list of formatted lines.
| Format the individual lines | def _format_lines(lines):
"""Format the individual lines
This will replace the '{', '}' and '~' characters of our mini
formatting language with the proper 'where ...', 'and ...' and ' +
...' text, taking care of indentation along the way.
Return a list of formatted lines.
"""
result = line... | [
"def",
"_format_lines",
"(",
"lines",
")",
":",
"result",
"=",
"lines",
"[",
":",
"1",
"]",
"stack",
"=",
"[",
"0",
"]",
"stackcnt",
"=",
"[",
"0",
"]",
"for",
"line",
"in",
"lines",
"[",
"1",
":",
"]",
":",
"if",
"line",
".",
"startswith",
"("... | [
60,
0
] | [
92,
17
] | python | en | ['en', 'en', 'en'] | True |
assertrepr_compare | (config, op, left, right) | Return specialised explanations for some operators/operands | Return specialised explanations for some operators/operands | def assertrepr_compare(config, op, left, right):
"""Return specialised explanations for some operators/operands"""
width = 80 - 15 - len(op) - 2 # 15 chars indentation, 1 space around op
left_repr = py.io.saferepr(left, maxsize=int(width // 2))
right_repr = py.io.saferepr(right, maxsize=width - len(lef... | [
"def",
"assertrepr_compare",
"(",
"config",
",",
"op",
",",
"left",
",",
"right",
")",
":",
"width",
"=",
"80",
"-",
"15",
"-",
"len",
"(",
"op",
")",
"-",
"2",
"# 15 chars indentation, 1 space around op",
"left_repr",
"=",
"py",
".",
"io",
".",
"saferep... | [
102,
0
] | [
160,
34
] | python | en | ['en', 'en', 'en'] | True |
_diff_text | (left, right, verbose=False) | Return the explanation for the diff between text or bytes
Unless --verbose is used this will skip leading and trailing
characters which are identical to keep the diff minimal.
If the input are bytes they will be safely converted to text.
| Return the explanation for the diff between text or bytes | def _diff_text(left, right, verbose=False):
"""Return the explanation for the diff between text or bytes
Unless --verbose is used this will skip leading and trailing
characters which are identical to keep the diff minimal.
If the input are bytes they will be safely converted to text.
"""
from ... | [
"def",
"_diff_text",
"(",
"left",
",",
"right",
",",
"verbose",
"=",
"False",
")",
":",
"from",
"difflib",
"import",
"ndiff",
"explanation",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"left",
",",
"six",
".",
"binary_type",
")",
":",
"left",
"=",
"u",
"... | [
163,
0
] | [
202,
22
] | python | en | ['en', 'en', 'en'] | True |
JsonableError.msg_format | () | Override in subclasses. Gets the items in `data_fields` as format args.
This should return (a translation of) a string literal.
The reason it's not simply a class attribute is to allow
translation to work.
| Override in subclasses. Gets the items in `data_fields` as format args. | def msg_format() -> str:
"""Override in subclasses. Gets the items in `data_fields` as format args.
This should return (a translation of) a string literal.
The reason it's not simply a class attribute is to allow
translation to work.
"""
# Secretly this gets one more fo... | [
"def",
"msg_format",
"(",
")",
"->",
"str",
":",
"# Secretly this gets one more format arg not in `data_fields`: `_msg`.",
"# That's for the sake of the `JsonableError` base logic itself, for",
"# the simplest form of use where we just get a plain message string",
"# at construction time.",
"r... | [
106,
4
] | [
117,
23
] | python | en | ['en', 'en', 'en'] | True |
format_exception_only | (etype, value) | Format the exception part of a traceback.
The arguments are the exception type and value such as given by
sys.last_type and sys.last_value. The return value is a list of
strings, each ending in a newline.
Normally, the list contains a single string; however, for
SyntaxError exceptions, it contains... | Format the exception part of a traceback. | def format_exception_only(etype, value):
"""Format the exception part of a traceback.
The arguments are the exception type and value such as given by
sys.last_type and sys.last_value. The return value is a list of
strings, each ending in a newline.
Normally, the list contains a single string; howe... | [
"def",
"format_exception_only",
"(",
"etype",
",",
"value",
")",
":",
"# An instance should not have a meaningful value parameter, but",
"# sometimes does, particularly for string exceptions, such as",
"# >>> raise string1, string2 # deprecated",
"#",
"# Clear these out first because issubt... | [
8,
0
] | [
63,
16
] | python | en | ['en', 'en', 'en'] | True |
_format_final_exc_line | (etype, value) | Return a list of a single line -- normal case for format_exception_only | Return a list of a single line -- normal case for format_exception_only | def _format_final_exc_line(etype, value):
"""Return a list of a single line -- normal case for format_exception_only"""
valuestr = _some_str(value)
if value is None or not valuestr:
line = "%s\n" % etype
else:
line = "%s: %s\n" % (etype, valuestr)
return line | [
"def",
"_format_final_exc_line",
"(",
"etype",
",",
"value",
")",
":",
"valuestr",
"=",
"_some_str",
"(",
"value",
")",
"if",
"value",
"is",
"None",
"or",
"not",
"valuestr",
":",
"line",
"=",
"\"%s\\n\"",
"%",
"etype",
"else",
":",
"line",
"=",
"\"%s: %s... | [
66,
0
] | [
73,
15
] | python | en | ['en', 'en', 'en'] | True |
iterate_recursively | (d) |
Generator for a dictionary that can potentially include other dictionaries.
Yields tuples of (dict, key, value), where key, value are "leaf" elements of the "dict".
|
Generator for a dictionary that can potentially include other dictionaries.
Yields tuples of (dict, key, value), where key, value are "leaf" elements of the "dict". | def iterate_recursively(d):
"""
Generator for a dictionary that can potentially include other dictionaries.
Yields tuples of (dict, key, value), where key, value are "leaf" elements of the "dict".
"""
for k, v in d.items():
if isinstance(v, (dict, OrderedDict)):
yield from itera... | [
"def",
"iterate_recursively",
"(",
"d",
")",
":",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"(",
"dict",
",",
"OrderedDict",
")",
")",
":",
"yield",
"from",
"iterate_recursively",
"(",
"v",
")"... | [
45,
0
] | [
55,
25
] | python | en | ['en', 'error', 'th'] | False |
copy_dict_structure | (d) | Copy dictionary layout without copying the actual values (populated with Nones). | Copy dictionary layout without copying the actual values (populated with Nones). | def copy_dict_structure(d):
"""Copy dictionary layout without copying the actual values (populated with Nones)."""
d_copy = type(d)()
_copy_dict_structure_func(d, d_copy)
return d_copy | [
"def",
"copy_dict_structure",
"(",
"d",
")",
":",
"d_copy",
"=",
"type",
"(",
"d",
")",
"(",
")",
"_copy_dict_structure_func",
"(",
"d",
",",
"d_copy",
")",
"return",
"d_copy"
] | [
58,
0
] | [
62,
17
] | python | en | ['en', 'en', 'en'] | True |
iter_dicts_recursively | (d1, d2) | Assuming dicts have the exact same structure. | Assuming dicts have the exact same structure. | def iter_dicts_recursively(d1, d2):
"""Assuming dicts have the exact same structure."""
for k, v in d1.items():
assert k in d2
if isinstance(v, (dict, OrderedDict)):
yield from iter_dicts_recursively(d1[k], d2[k])
else:
yield d1, d2, k, d1[k], d2[k] | [
"def",
"iter_dicts_recursively",
"(",
"d1",
",",
"d2",
")",
":",
"for",
"k",
",",
"v",
"in",
"d1",
".",
"items",
"(",
")",
":",
"assert",
"k",
"in",
"d2",
"if",
"isinstance",
"(",
"v",
",",
"(",
"dict",
",",
"OrderedDict",
")",
")",
":",
"yield",... | [
74,
0
] | [
82,
41
] | python | en | ['en', 'en', 'en'] | True |
extend_array_by | (x, extra_len) | Assuming the array is currently not empty. | Assuming the array is currently not empty. | def extend_array_by(x, extra_len):
"""Assuming the array is currently not empty."""
if extra_len <= 0:
return x
last_elem = x[-1]
tail = [last_elem] * extra_len
tail = np.stack(tail)
return np.append(x, tail, axis=0) | [
"def",
"extend_array_by",
"(",
"x",
",",
"extra_len",
")",
":",
"if",
"extra_len",
"<=",
"0",
":",
"return",
"x",
"last_elem",
"=",
"x",
"[",
"-",
"1",
"]",
"tail",
"=",
"[",
"last_elem",
"]",
"*",
"extra_len",
"tail",
"=",
"np",
".",
"stack",
"(",... | [
98,
0
] | [
106,
37
] | python | en | ['en', 'en', 'en'] | True |
TensorBatcher.cat | (self, dict_of_tensor_arrays, macro_batch_size, use_pinned_memory, timing) |
Here 'macro_batch' is the overall size of experience per iteration.
Macro-batch = mini-batch * num_batches_per_iteration
|
Here 'macro_batch' is the overall size of experience per iteration.
Macro-batch = mini-batch * num_batches_per_iteration
| def cat(self, dict_of_tensor_arrays, macro_batch_size, use_pinned_memory, timing):
"""
Here 'macro_batch' is the overall size of experience per iteration.
Macro-batch = mini-batch * num_batches_per_iteration
"""
tensor_batch = self.batch_pool.get()
if tensor_batch is no... | [
"def",
"cat",
"(",
"self",
",",
"dict_of_tensor_arrays",
",",
"macro_batch_size",
",",
"use_pinned_memory",
",",
"timing",
")",
":",
"tensor_batch",
"=",
"self",
".",
"batch_pool",
".",
"get",
"(",
")",
"if",
"tensor_batch",
"is",
"not",
"None",
":",
"old_ba... | [
178,
4
] | [
212,
27
] | python | en | ['en', 'error', 'th'] | False |
BaseHorizonTests._reload_urls | (self) | Clears out the URL caches, and reloads the root urls module.
It re-triggers the autodiscovery mechanism for Horizon.
Allows URLs to be re-calculated after registering new dashboards.
Useful only for testing and should never be used on a live site.
| Clears out the URL caches, and reloads the root urls module. | def _reload_urls(self):
"""Clears out the URL caches, and reloads the root urls module.
It re-triggers the autodiscovery mechanism for Horizon.
Allows URLs to be re-calculated after registering new dashboards.
Useful only for testing and should never be used on a live site.
"""
... | [
"def",
"_reload_urls",
"(",
"self",
")",
":",
"urls",
".",
"clear_url_caches",
"(",
")",
"moves",
".",
"reload_module",
"(",
"import_module",
"(",
"settings",
".",
"ROOT_URLCONF",
")",
")",
"base",
".",
"Horizon",
".",
"_urls",
"(",
")"
] | [
120,
4
] | [
129,
28
] | python | en | ['en', 'en', 'en'] | True |
HorizonTests.test_registry | (self) | Verify registration and autodiscovery work correctly.
Please note that this implicitly tests that autodiscovery works
by virtue of the fact that the dashboards listed in
``settings.INSTALLED_APPS`` are loaded from the start.
| Verify registration and autodiscovery work correctly. | def test_registry(self):
"""Verify registration and autodiscovery work correctly.
Please note that this implicitly tests that autodiscovery works
by virtue of the fact that the dashboards listed in
``settings.INSTALLED_APPS`` are loaded from the start.
"""
# Registration... | [
"def",
"test_registry",
"(",
"self",
")",
":",
"# Registration",
"self",
".",
"assertEqual",
"(",
"2",
",",
"len",
"(",
"base",
".",
"Horizon",
".",
"_registry",
")",
")",
"horizon",
".",
"register",
"(",
"MyDash",
")",
"self",
".",
"assertEqual",
"(",
... | [
134,
4
] | [
167,
41
] | python | en | ['en', 'en', 'en'] | True |
HorizonTests.test_horizon_test_isolation_1 | (self) | Isolation Test Part 1: sets a value. | Isolation Test Part 1: sets a value. | def test_horizon_test_isolation_1(self):
"""Isolation Test Part 1: sets a value."""
cats = horizon.get_dashboard("cats")
cats.evil = True | [
"def",
"test_horizon_test_isolation_1",
"(",
"self",
")",
":",
"cats",
"=",
"horizon",
".",
"get_dashboard",
"(",
"\"cats\"",
")",
"cats",
".",
"evil",
"=",
"True"
] | [
240,
4
] | [
243,
24
] | python | en | ['en', 'en', 'en'] | True |
HorizonTests.test_horizon_test_isolation_2 | (self) | Isolation Test Part 2: The value set in part 1 should be gone. | Isolation Test Part 2: The value set in part 1 should be gone. | def test_horizon_test_isolation_2(self):
"""Isolation Test Part 2: The value set in part 1 should be gone."""
cats = horizon.get_dashboard("cats")
self.assertFalse(hasattr(cats, "evil")) | [
"def",
"test_horizon_test_isolation_2",
"(",
"self",
")",
":",
"cats",
"=",
"horizon",
".",
"get_dashboard",
"(",
"\"cats\"",
")",
"self",
".",
"assertFalse",
"(",
"hasattr",
"(",
"cats",
",",
"\"evil\"",
")",
")"
] | [
245,
4
] | [
248,
47
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.