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
test_no_feature_mapping
(feature_descriptions, nm_feature)
Testing if None is returned when the feature does not have corresponding mapping defined.
Testing if None is returned when the feature does not have corresponding mapping defined.
def test_no_feature_mapping(feature_descriptions, nm_feature): """Testing if None is returned when the feature does not have corresponding mapping defined.""" fd = FeatureDescriptor(feature_descriptions) assert fd.mapping(nm_feature) is None
[ "def", "test_no_feature_mapping", "(", "feature_descriptions", ",", "nm_feature", ")", ":", "fd", "=", "FeatureDescriptor", "(", "feature_descriptions", ")", "assert", "fd", ".", "mapping", "(", "nm_feature", ")", "is", "None" ]
[ 56, 0 ]
[ 59, 41 ]
python
en
['en', 'en', 'en']
True
test_no_feature_category
(feature_descriptions, nc_feature)
Testing if None is returned when the feature does not have corresponding category defined.
Testing if None is returned when the feature does not have corresponding category defined.
def test_no_feature_category(feature_descriptions, nc_feature): """Testing if None is returned when the feature does not have corresponding category defined.""" fd = FeatureDescriptor(feature_descriptions) assert fd.category(nc_feature) is None
[ "def", "test_no_feature_category", "(", "feature_descriptions", ",", "nc_feature", ")", ":", "fd", "=", "FeatureDescriptor", "(", "feature_descriptions", ")", "assert", "fd", ".", "category", "(", "nc_feature", ")", "is", "None" ]
[ 70, 0 ]
[ 73, 42 ]
python
en
['en', 'en', 'en']
True
TorchDecisionTreeClassifier.fit
(self, vectors, labels, criterion=None)
Function which must be used after the initialisation to fit the binary tree and build the successive :class:`Sklearn_PyTorch.decision_node.DecisionNode` to solve a specific classification problem. Args: vectors (:class:`torch.FloatTensor`): Vectors tensor used to fit the decision t...
Function which must be used after the initialisation to fit the binary tree and build the successive :class:`Sklearn_PyTorch.decision_node.DecisionNode` to solve a specific classification problem.
def fit(self, vectors, labels, criterion=None): """ Function which must be used after the initialisation to fit the binary tree and build the successive :class:`Sklearn_PyTorch.decision_node.DecisionNode` to solve a specific classification problem. Args: vectors (:class:`tor...
[ "def", "fit", "(", "self", ",", "vectors", ",", "labels", ",", "criterion", "=", "None", ")", ":", "if", "len", "(", "vectors", ")", "<", "1", ":", "raise", "ValueError", "(", "\"Not enough samples in the given dataset\"", ")", "if", "len", "(", "vectors",...
[ 23, 4 ]
[ 43, 86 ]
python
en
['en', 'error', 'th']
False
TorchDecisionTreeClassifier._build_tree
(self, vectors, labels, func, depth)
Private recursive function used to build the tree.
Private recursive function used to build the tree.
def _build_tree(self, vectors, labels, func, depth): """ Private recursive function used to build the tree. """ if len(vectors) == 0: return DecisionNode() if depth == 0: return DecisionNode(results=unique_counts(labels)) current_score = func(labe...
[ "def", "_build_tree", "(", "self", ",", "vectors", ",", "labels", ",", "func", ",", "depth", ")", ":", "if", "len", "(", "vectors", ")", "==", "0", ":", "return", "DecisionNode", "(", ")", "if", "depth", "==", "0", ":", "return", "DecisionNode", "(",...
[ 45, 4 ]
[ 81, 62 ]
python
en
['en', 'error', 'th']
False
TorchDecisionTreeClassifier.predict
(self, vector)
Function which must be used after the the fitting of the binary tree. It calls recursively the different :class:`Sklearn_PyTorch.decision_node.DecisionNode` to classify the vector. Args: vector(:class:`torch.FloatTensor`): Vectors tensor which must be classified. It represents the ...
Function which must be used after the the fitting of the binary tree. It calls recursively the different :class:`Sklearn_PyTorch.decision_node.DecisionNode` to classify the vector.
def predict(self, vector): """ Function which must be used after the the fitting of the binary tree. It calls recursively the different :class:`Sklearn_PyTorch.decision_node.DecisionNode` to classify the vector. Args: vector(:class:`torch.FloatTensor`): Vectors tensor which ...
[ "def", "predict", "(", "self", ",", "vector", ")", ":", "return", "self", ".", "_classify", "(", "vector", ",", "self", ".", "_root_node", ")" ]
[ 83, 4 ]
[ 96, 54 ]
python
en
['en', 'error', 'th']
False
TorchDecisionTreeClassifier._classify
(self, vector, node)
Private recursive function used to classify with the tree.
Private recursive function used to classify with the tree.
def _classify(self, vector, node): """ Private recursive function used to classify with the tree. """ if node.results is not None: return list(node.results.keys())[0] else: if split_function(vector, node.col, node.value): branch = node.tb ...
[ "def", "_classify", "(", "self", ",", "vector", ",", "node", ")", ":", "if", "node", ".", "results", "is", "not", "None", ":", "return", "list", "(", "node", ".", "results", ".", "keys", "(", ")", ")", "[", "0", "]", "else", ":", "if", "split_fun...
[ 98, 4 ]
[ 110, 49 ]
python
en
['en', 'error', 'th']
False
TorchDecisionTreeRegressor.fit
(self, vectors, values, criterion=None)
Function which must be used after the initialisation to fit the binary tree and build the successive :class:`Sklearn_PyTorch.decision_node.DecisionNode` to solve a specific regression problem. Args: vectors(:class:`torch.FloatTensor`): Vectors tensor used to fit the decision tree. ...
Function which must be used after the initialisation to fit the binary tree and build the successive :class:`Sklearn_PyTorch.decision_node.DecisionNode` to solve a specific regression problem.
def fit(self, vectors, values, criterion=None): """ Function which must be used after the initialisation to fit the binary tree and build the successive :class:`Sklearn_PyTorch.decision_node.DecisionNode` to solve a specific regression problem. Args: vectors(:class:`torch.Fl...
[ "def", "fit", "(", "self", ",", "vectors", ",", "values", ",", "criterion", "=", "None", ")", ":", "if", "len", "(", "vectors", ")", "<", "1", ":", "raise", "ValueError", "(", "\"Not enough samples in the given dataset\"", ")", "if", "len", "(", "vectors",...
[ 129, 4 ]
[ 150, 86 ]
python
en
['en', 'error', 'th']
False
TorchDecisionTreeRegressor._build_tree
(self, vectors, values, func, depth)
Private recursive function used to build the tree.
Private recursive function used to build the tree.
def _build_tree(self, vectors, values, func, depth): """ Private recursive function used to build the tree. """ if len(vectors) == 0: return DecisionNode() if depth == 0: return DecisionNode(results=mean(values)) current_score = func(values) ...
[ "def", "_build_tree", "(", "self", ",", "vectors", ",", "values", ",", "func", ",", "depth", ")", ":", "if", "len", "(", "vectors", ")", "==", "0", ":", "return", "DecisionNode", "(", ")", "if", "depth", "==", "0", ":", "return", "DecisionNode", "(",...
[ 152, 4 ]
[ 188, 53 ]
python
en
['en', 'error', 'th']
False
TorchDecisionTreeRegressor.predict
(self, vector)
Function which must be used after the the fitting of the binary tree. It calls recursively the different :class:`Sklearn_PyTorch.decision_node.DecisionNode` to regress the vector. Args: vector(:class:`torch.FloatTensor`): Vectors tensor which must be regressed. It represents the da...
Function which must be used after the the fitting of the binary tree. It calls recursively the different :class:`Sklearn_PyTorch.decision_node.DecisionNode` to regress the vector.
def predict(self, vector): """ Function which must be used after the the fitting of the binary tree. It calls recursively the different :class:`Sklearn_PyTorch.decision_node.DecisionNode` to regress the vector. Args: vector(:class:`torch.FloatTensor`): Vectors tensor which m...
[ "def", "predict", "(", "self", ",", "vector", ")", ":", "return", "self", ".", "_regress", "(", "vector", ",", "self", ".", "_root_node", ")" ]
[ 190, 4 ]
[ 203, 53 ]
python
en
['en', 'error', 'th']
False
TorchDecisionTreeRegressor._regress
(self, vector, node)
Private recursive function used to regress on the tree.
Private recursive function used to regress on the tree.
def _regress(self, vector, node): """ Private recursive function used to regress on the tree. """ if node.results is not None: return node.results else: if split_function(vector, node.col, node.value): branch = node.tb else: ...
[ "def", "_regress", "(", "self", ",", "vector", ",", "node", ")", ":", "if", "node", ".", "results", "is", "not", "None", ":", "return", "node", ".", "results", "else", ":", "if", "split_function", "(", "vector", ",", "node", ".", "col", ",", "node", ...
[ 205, 4 ]
[ 217, 48 ]
python
en
['en', 'error', 'th']
False
WorkflowView.get_initial
(self)
Returns initial data for the workflow. Defaults to using the GET parameters to allow pre-seeding of the workflow context values.
Returns initial data for the workflow.
def get_initial(self): """Returns initial data for the workflow. Defaults to using the GET parameters to allow pre-seeding of the workflow context values. """ return copy.copy(self.request.GET)
[ "def", "get_initial", "(", "self", ")", ":", "return", "copy", ".", "copy", "(", "self", ".", "request", ".", "GET", ")" ]
[ 68, 4 ]
[ 74, 42 ]
python
en
['en', 'en', 'en']
True
WorkflowView.get_workflow
(self)
Returns the instantiated workflow class.
Returns the instantiated workflow class.
def get_workflow(self): """Returns the instantiated workflow class.""" extra_context = self.get_initial() entry_point = self.request.GET.get("step", None) workflow = self.workflow_class(self.request, context_seed=extra_context, ...
[ "def", "get_workflow", "(", "self", ")", ":", "extra_context", "=", "self", ".", "get_initial", "(", ")", "entry_point", "=", "self", ".", "request", ".", "GET", ".", "get", "(", "\"step\"", ",", "None", ")", "workflow", "=", "self", ".", "workflow_class...
[ 76, 4 ]
[ 83, 23 ]
python
en
['en', 'en', 'en']
True
WorkflowView.get_context_data
(self, **kwargs)
Returns the template context, including the workflow class. This method should be overridden in subclasses to provide additional context data to the template.
Returns the template context, including the workflow class.
def get_context_data(self, **kwargs): """Returns the template context, including the workflow class. This method should be overridden in subclasses to provide additional context data to the template. """ context = super(WorkflowView, self).get_context_data(**kwargs) work...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "WorkflowView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "workflow", "=", "self", ".", "get_workflow", "(", ")", "w...
[ 85, 4 ]
[ 110, 22 ]
python
en
['en', 'en', 'en']
True
WorkflowView.get_layout
(self)
Returns classes for the workflow element in template. The returned classes are determied based on the workflow characteristics.
Returns classes for the workflow element in template.
def get_layout(self): """Returns classes for the workflow element in template. The returned classes are determied based on the workflow characteristics. """ if self.request.is_ajax(): layout = ['modal', ] else: layout = ['static_page', ] ...
[ "def", "get_layout", "(", "self", ")", ":", "if", "self", ".", "request", ".", "is_ajax", "(", ")", ":", "layout", "=", "[", "'modal'", ",", "]", "else", ":", "layout", "=", "[", "'static_page'", ",", "]", "if", "self", ".", "workflow_class", ".", ...
[ 112, 4 ]
[ 126, 21 ]
python
en
['en', 'en', 'en']
True
WorkflowView.get_template_names
(self)
Returns the template name to use for this request.
Returns the template name to use for this request.
def get_template_names(self): """Returns the template name to use for this request.""" if self.request.is_ajax(): template = self.ajax_template_name else: template = self.template_name return template
[ "def", "get_template_names", "(", "self", ")", ":", "if", "self", ".", "request", ".", "is_ajax", "(", ")", ":", "template", "=", "self", ".", "ajax_template_name", "else", ":", "template", "=", "self", ".", "template_name", "return", "template" ]
[ 128, 4 ]
[ 134, 23 ]
python
en
['en', 'en', 'en']
True
WorkflowView.get
(self, request, *args, **kwargs)
Handler for HTTP GET requests.
Handler for HTTP GET requests.
def get(self, request, *args, **kwargs): """Handler for HTTP GET requests.""" try: context = self.get_context_data(**kwargs) except exceptions.NotAvailable: exceptions.handle(request) self.set_workflow_step_errors(context) return self.render_to_response(co...
[ "def", "get", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "context", "=", "self", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "except", "exceptions", ".", "NotAvailable", ":", "exceptions", ...
[ 151, 4 ]
[ 158, 47 ]
python
en
['da', 'en', 'en']
True
WorkflowView.validate_steps
(self, request, workflow, start, end)
Validates the workflow steps from ``start`` to ``end``, inclusive. Returns a dict describing the validation state of the workflow.
Validates the workflow steps from ``start`` to ``end``, inclusive.
def validate_steps(self, request, workflow, start, end): """Validates the workflow steps from ``start`` to ``end``, inclusive. Returns a dict describing the validation state of the workflow. """ errors = {} for step in workflow.steps[start:end + 1]: if not step.actio...
[ "def", "validate_steps", "(", "self", ",", "request", ",", "workflow", ",", "start", ",", "end", ")", ":", "errors", "=", "{", "}", "for", "step", "in", "workflow", ".", "steps", "[", "start", ":", "end", "+", "1", "]", ":", "if", "not", "step", ...
[ 160, 4 ]
[ 175, 9 ]
python
en
['en', 'en', 'en']
True
WorkflowView.post
(self, request, *args, **kwargs)
Handler for HTTP POST requests.
Handler for HTTP POST requests.
def post(self, request, *args, **kwargs): """Handler for HTTP POST requests.""" context = self.get_context_data(**kwargs) workflow = context[self.context_object_name] try: # Check for the VALIDATE_STEP* headers, if they are present # and valid integers, return val...
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "context", "=", "self", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "workflow", "=", "context", "[", "self", ".", "context_object_name", "]", ...
[ 177, 4 ]
[ 226, 73 ]
python
en
['da', 'en', 'en']
True
MetadatadefinitionsPage.json_load_template
(self, namespace_template_name)
Read template for namespace creation :param namespace_template_name: Path to template :return = json data container
Read template for namespace creation
def json_load_template(self, namespace_template_name): """Read template for namespace creation :param namespace_template_name: Path to template :return = json data container """ try: with open(namespace_template_name, 'r') as template: json_template =...
[ "def", "json_load_template", "(", "self", ",", "namespace_template_name", ")", ":", "try", ":", "with", "open", "(", "namespace_template_name", ",", "'r'", ")", "as", "template", ":", "json_template", "=", "json", ".", "load", "(", "template", ")", "except", ...
[ 61, 4 ]
[ 73, 28 ]
python
en
['en', 'en', 'en']
True
UtilsTestCase.test_time_plus_minutes
(self)
Assert time_plus_minutes helper functions returns correct result of time + minutes calculation.
Assert time_plus_minutes helper functions returns correct result of time + minutes calculation.
def test_time_plus_minutes(self): """ Assert time_plus_minutes helper functions returns correct result of time + minutes calculation. """ time = dt.time() self.assertEqual(time, time_plus_minutes(time, 0)) self.assertEqual(time, dt.time()) time = dt.time(h...
[ "def", "test_time_plus_minutes", "(", "self", ")", ":", "time", "=", "dt", ".", "time", "(", ")", "self", ".", "assertEqual", "(", "time", ",", "time_plus_minutes", "(", "time", ",", "0", ")", ")", "self", ".", "assertEqual", "(", "time", ",", "dt", ...
[ 12, 4 ]
[ 22, 83 ]
python
en
['en', 'error', 'th']
False
StudentTestCase.test_student_id_validation
(self)
Assert that ValidationError is raised when student has incorrect student id number set.
Assert that ValidationError is raised when student has incorrect student id number set.
def test_student_id_validation(self): """ Assert that ValidationError is raised when student has incorrect student id number set. """ with self.assertRaises(ValidationError): student = Student.objects.create( account=self.student, student_id="1...
[ "def", "test_student_id_validation", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ValidationError", ")", ":", "student", "=", "Student", ".", "objects", ".", "create", "(", "account", "=", "self", ".", "student", ",", "student_id", "=", ...
[ 53, 4 ]
[ 89, 27 ]
python
en
['en', 'error', 'th']
False
StudentTestCase.test_student_user_type_validation
(self)
Assert that ValidationError is raised when Student account has user_type different than student.
Assert that ValidationError is raised when Student account has user_type different than student.
def test_student_user_type_validation(self): """ Assert that ValidationError is raised when Student account has user_type different than student. """ Student.objects.create( account=self.student, student_id="123456", ).clean() with self.ass...
[ "def", "test_student_user_type_validation", "(", "self", ")", ":", "Student", ".", "objects", ".", "create", "(", "account", "=", "self", ".", "student", ",", "student_id", "=", "\"123456\"", ",", ")", ".", "clean", "(", ")", "with", "self", ".", "assertRa...
[ 91, 4 ]
[ 109, 21 ]
python
en
['en', 'error', 'th']
False
LecturerTestCase.test_lecturer_account_validator
(self)
Assert that ValidationError is raised when Lecturer account has user_type different than teacher.
Assert that ValidationError is raised when Lecturer account has user_type different than teacher.
def test_lecturer_account_validator(self): """ Assert that ValidationError is raised when Lecturer account has user_type different than teacher. """ Lecturer.objects.create(account=self.teacher).clean() with self.assertRaises(ValidationError): Lecturer.objects...
[ "def", "test_lecturer_account_validator", "(", "self", ")", ":", "Lecturer", ".", "objects", ".", "create", "(", "account", "=", "self", ".", "teacher", ")", ".", "clean", "(", ")", "with", "self", ".", "assertRaises", "(", "ValidationError", ")", ":", "Le...
[ 116, 4 ]
[ 125, 65 ]
python
en
['en', 'error', 'th']
False
EnrollmentTestCase.test_student_typing
(self)
Assert that ValidationError is raised when Enrollment is linked to user other than student.
Assert that ValidationError is raised when Enrollment is linked to user other than student.
def test_student_typing(self): """ Assert that ValidationError is raised when Enrollment is linked to user other than student. """ Enrollment.objects.create( student=Student.objects.create(account=self.student, student_id="123456"), class_time=self.time, )...
[ "def", "test_student_typing", "(", "self", ")", ":", "Enrollment", ".", "objects", ".", "create", "(", "student", "=", "Student", ".", "objects", ".", "create", "(", "account", "=", "self", ".", "student", ",", "student_id", "=", "\"123456\"", ")", ",", ...
[ 139, 4 ]
[ 150, 89 ]
python
en
['en', 'error', 'th']
False
ClassTimeCase.test_end_property
(self)
Assert that ClassTime.end property returns correct end time (ClassTime.start + ClassTime.duration_minutes).
Assert that ClassTime.end property returns correct end time (ClassTime.start + ClassTime.duration_minutes).
def test_end_property(self): """ Assert that ClassTime.end property returns correct end time (ClassTime.start + ClassTime.duration_minutes). """ time = dt.time(hour=23, minute=59) duration = 10 ct = ClassTime.objects.create( day="1", freque...
[ "def", "test_end_property", "(", "self", ")", ":", "time", "=", "dt", ".", "time", "(", "hour", "=", "23", ",", "minute", "=", "59", ")", "duration", "=", "10", "ct", "=", "ClassTime", ".", "objects", ".", "create", "(", "day", "=", "\"1\"", ",", ...
[ 154, 4 ]
[ 168, 67 ]
python
en
['en', 'error', 'th']
False
AnsiToWin32.should_wrap
(self)
True if this class is actually needed. If false, then the output stream will not be affected, nor will win32 calls be issued, so wrapping stdout is not actually required. This will generally be False on non-Windows platforms, unless optional functionality like autoreset has been...
True if this class is actually needed. If false, then the output stream will not be affected, nor will win32 calls be issued, so wrapping stdout is not actually required. This will generally be False on non-Windows platforms, unless optional functionality like autoreset has been...
def should_wrap(self): ''' True if this class is actually needed. If false, then the output stream will not be affected, nor will win32 calls be issued, so wrapping stdout is not actually required. This will generally be False on non-Windows platforms, unless optional functionali...
[ "def", "should_wrap", "(", "self", ")", ":", "return", "self", ".", "convert", "or", "self", ".", "strip", "or", "self", ".", "autoreset" ]
[ 105, 4 ]
[ 113, 59 ]
python
en
['en', 'error', 'th']
False
AnsiToWin32.write_and_convert
(self, text)
Write the given text to our wrapped stream, stripping any ANSI sequences from the text, and optionally converting them into win32 calls.
Write the given text to our wrapped stream, stripping any ANSI sequences from the text, and optionally converting them into win32 calls.
def write_and_convert(self, text): ''' Write the given text to our wrapped stream, stripping any ANSI sequences from the text, and optionally converting them into win32 calls. ''' cursor = 0 text = self.convert_osc(text) for match in self.ANSI_CSI_RE.findi...
[ "def", "write_and_convert", "(", "self", ",", "text", ")", ":", "cursor", "=", "0", "text", "=", "self", ".", "convert_osc", "(", "text", ")", "for", "match", "in", "self", ".", "ANSI_CSI_RE", ".", "finditer", "(", "text", ")", ":", "start", ",", "en...
[ 176, 4 ]
[ 189, 54 ]
python
en
['en', 'error', 'th']
False
main
(args=None, plugins=None)
return exit code, after performing an in-process test run. :arg args: list of command line arguments. :arg plugins: list of plugin objects to be auto-registered during initialization.
return exit code, after performing an in-process test run.
def main(args=None, plugins=None): """ return exit code, after performing an in-process test run. :arg args: list of command line arguments. :arg plugins: list of plugin objects to be auto-registered during initialization. """ try: try: config = _prepareconfig...
[ "def", "main", "(", "args", "=", "None", ",", "plugins", "=", "None", ")", ":", "try", ":", "try", ":", "config", "=", "_prepareconfig", "(", "args", ",", "plugins", ")", "except", "ConftestImportFailure", "as", "e", ":", "tw", "=", "py", ".", "io", ...
[ 39, 0 ]
[ 65, 16 ]
python
en
['en', 'en', 'en']
True
filename_arg
(path, optname)
Argparse type validator for filename arguments. :path: path of filename :optname: name of the option
Argparse type validator for filename arguments.
def filename_arg(path, optname): """ Argparse type validator for filename arguments. :path: path of filename :optname: name of the option """ if os.path.isdir(path): raise UsageError("{0} must be a filename, given: {1}".format(optname, path)) return path
[ "def", "filename_arg", "(", "path", ",", "optname", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "raise", "UsageError", "(", "\"{0} must be a filename, given: {1}\"", ".", "format", "(", "optname", ",", "path", ")", ")", "return"...
[ 82, 0 ]
[ 90, 15 ]
python
da
['nb', 'da', 'en']
False
directory_arg
(path, optname)
Argparse type validator for directory arguments. :path: path of directory :optname: name of the option
Argparse type validator for directory arguments.
def directory_arg(path, optname): """Argparse type validator for directory arguments. :path: path of directory :optname: name of the option """ if not os.path.isdir(path): raise UsageError("{0} must be a directory, given: {1}".format(optname, path)) return path
[ "def", "directory_arg", "(", "path", ",", "optname", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "raise", "UsageError", "(", "\"{0} must be a directory, given: {1}\"", ".", "format", "(", "optname", ",", "path", ")", ")",...
[ 93, 0 ]
[ 101, 15 ]
python
en
['en', 'en', 'en']
True
get_plugin_manager
()
Obtain a new instance of the :py:class:`_pytest.config.PytestPluginManager`, with default plugins already loaded. This function can be used by integration with other tools, like hooking into pytest to run tests into an IDE.
Obtain a new instance of the :py:class:`_pytest.config.PytestPluginManager`, with default plugins already loaded.
def get_plugin_manager(): """ Obtain a new instance of the :py:class:`_pytest.config.PytestPluginManager`, with default plugins already loaded. This function can be used by integration with other tools, like hooking into pytest to run tests into an IDE. """ return get_config().pluginman...
[ "def", "get_plugin_manager", "(", ")", ":", "return", "get_config", "(", ")", ".", "pluginmanager" ]
[ 124, 0 ]
[ 133, 37 ]
python
en
['en', 'error', 'th']
False
_get_plugin_specs_as_list
(specs)
Parses a list of "plugin specs" and returns a list of plugin names. Plugin specs can be given as a list of strings separated by "," or already as a list/tuple in which case it is returned as a list. Specs can also be `None` in which case an empty list is returned.
Parses a list of "plugin specs" and returns a list of plugin names.
def _get_plugin_specs_as_list(specs): """ Parses a list of "plugin specs" and returns a list of plugin names. Plugin specs can be given as a list of strings separated by "," or already as a list/tuple in which case it is returned as a list. Specs can also be `None` in which case an empty list is re...
[ "def", "_get_plugin_specs_as_list", "(", "specs", ")", ":", "if", "specs", "is", "not", "None", ":", "if", "isinstance", "(", "specs", ",", "str", ")", ":", "specs", "=", "specs", ".", "split", "(", "','", ")", "if", "specs", "else", "[", "]", "if", ...
[ 447, 0 ]
[ 462, 13 ]
python
en
['en', 'error', 'th']
False
getcfg
(args, warnfunc=None)
Search the list of arguments for a valid ini-file for pytest, and return a tuple of (rootdir, inifile, cfg-dict). note: warnfunc is an optional function used to warn about ini-files that use deprecated features. This parameter should be removed when pytest adopts standard deprecati...
Search the list of arguments for a valid ini-file for pytest, and return a tuple of (rootdir, inifile, cfg-dict).
def getcfg(args, warnfunc=None): """ Search the list of arguments for a valid ini-file for pytest, and return a tuple of (rootdir, inifile, cfg-dict). note: warnfunc is an optional function used to warn about ini-files that use deprecated features. This parameter should be removed when ...
[ "def", "getcfg", "(", "args", ",", "warnfunc", "=", "None", ")", ":", "from", "_pytest", ".", "deprecated", "import", "SETUP_CFG_PYTEST", "inibasenames", "=", "[", "\"pytest.ini\"", ",", "\"tox.ini\"", ",", "\"setup.cfg\"", "]", "args", "=", "[", "x", "for",...
[ 1242, 0 ]
[ 1273, 27 ]
python
en
['en', 'error', 'th']
False
create_terminal_writer
(config, *args, **kwargs)
Create a TerminalWriter instance configured according to the options in the config object. Every code which requires a TerminalWriter object and has access to a config object should use this function.
Create a TerminalWriter instance configured according to the options in the config object. Every code which requires a TerminalWriter object and has access to a config object should use this function.
def create_terminal_writer(config, *args, **kwargs): """Create a TerminalWriter instance configured according to the options in the config object. Every code which requires a TerminalWriter object and has access to a config object should use this function. """ tw = py.io.TerminalWriter(*args, **kwar...
[ "def", "create_terminal_writer", "(", "config", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "tw", "=", "py", ".", "io", ".", "TerminalWriter", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "config", ".", "option", ".", "color", "==...
[ 1376, 0 ]
[ 1386, 13 ]
python
en
['en', 'en', 'en']
True
_strtobool
(val)
Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else. .. note:: copied from distutils.util
Convert a string representation of truth to true (1) or false (0).
def _strtobool(val): """Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else. .. note:: copied from distutils.util """ ...
[ "def", "_strtobool", "(", "val", ")", ":", "val", "=", "val", ".", "lower", "(", ")", "if", "val", "in", "(", "'y'", ",", "'yes'", ",", "'t'", ",", "'true'", ",", "'on'", ",", "'1'", ")", ":", "return", "1", "elif", "val", "in", "(", "'n'", "...
[ 1389, 0 ]
[ 1404, 59 ]
python
en
['en', 'pt', 'en']
True
PytestPluginManager.addhooks
(self, module_or_class)
.. deprecated:: 2.8 Use :py:meth:`pluggy.PluginManager.add_hookspecs <PluginManager.add_hookspecs>` instead.
.. deprecated:: 2.8
def addhooks(self, module_or_class): """ .. deprecated:: 2.8 Use :py:meth:`pluggy.PluginManager.add_hookspecs <PluginManager.add_hookspecs>` instead. """ warning = dict(code="I2", fslocation=_pytest._code.getfslineno(sys._getframe(1)), ...
[ "def", "addhooks", "(", "self", ",", "module_or_class", ")", ":", "warning", "=", "dict", "(", "code", "=", "\"I2\"", ",", "fslocation", "=", "_pytest", ".", "_code", ".", "getfslineno", "(", "sys", ".", "_getframe", "(", "1", ")", ")", ",", "nodeid", ...
[ 202, 4 ]
[ 215, 50 ]
python
en
['en', 'error', 'th']
False
PytestPluginManager.hasplugin
(self, name)
Return True if the plugin with the given name is registered.
Return True if the plugin with the given name is registered.
def hasplugin(self, name): """Return True if the plugin with the given name is registered.""" return bool(self.get_plugin(name))
[ "def", "hasplugin", "(", "self", ",", "name", ")", ":", "return", "bool", "(", "self", ".", "get_plugin", "(", "name", ")", ")" ]
[ 263, 4 ]
[ 265, 42 ]
python
en
['en', 'en', 'en']
True
PytestPluginManager._set_initial_conftests
(self, namespace)
load initial conftest files given a preparsed "namespace". As conftest files may add their own command line options which have arguments ('--my-opt somepath') we might get some false positives. All builtin and 3rd party plugins will have been loaded, however, so common ...
load initial conftest files given a preparsed "namespace". As conftest files may add their own command line options which have arguments ('--my-opt somepath') we might get some false positives. All builtin and 3rd party plugins will have been loaded, however, so common ...
def _set_initial_conftests(self, namespace): """ load initial conftest files given a preparsed "namespace". As conftest files may add their own command line options which have arguments ('--my-opt somepath') we might get some false positives. All builtin and 3rd party plugin...
[ "def", "_set_initial_conftests", "(", "self", ",", "namespace", ")", ":", "current", "=", "py", ".", "path", ".", "local", "(", ")", "self", ".", "_confcutdir", "=", "current", ".", "join", "(", "namespace", ".", "confcutdir", ",", "abs", "=", "True", ...
[ 289, 4 ]
[ 314, 44 ]
python
en
['en', 'en', 'en']
True
Parser.getgroup
(self, name, description="", after=None)
get (or create) a named option Group. :name: name of the option group. :description: long description for --help output. :after: name of other group, used for ordering --help output. The returned group object has an ``addoption`` method with the same signature as :py:func:`par...
get (or create) a named option Group.
def getgroup(self, name, description="", after=None): """ get (or create) a named option Group. :name: name of the option group. :description: long description for --help output. :after: name of other group, used for ordering --help output. The returned group object has an ``ad...
[ "def", "getgroup", "(", "self", ",", "name", ",", "description", "=", "\"\"", ",", "after", "=", "None", ")", ":", "for", "group", "in", "self", ".", "_groups", ":", "if", "group", ".", "name", "==", "name", ":", "return", "group", "group", "=", "O...
[ 486, 4 ]
[ 507, 20 ]
python
en
['en', 'en', 'en']
True
Parser.addoption
(self, *opts, **attrs)
register a command line option. :opts: option names, can be short or long options. :attrs: same attributes which the ``add_option()`` function of the `argparse library <http://docs.python.org/2/library/argparse.html>`_ accepts. After command line parsing optio...
register a command line option.
def addoption(self, *opts, **attrs): """ register a command line option. :opts: option names, can be short or long options. :attrs: same attributes which the ``add_option()`` function of the `argparse library <http://docs.python.org/2/library/argparse.html>`_ ac...
[ "def", "addoption", "(", "self", ",", "*", "opts", ",", "*", "*", "attrs", ")", ":", "self", ".", "_anonymous", ".", "addoption", "(", "*", "opts", ",", "*", "*", "attrs", ")" ]
[ 509, 4 ]
[ 523, 49 ]
python
en
['en', 'fr', 'en']
True
Parser.parse_known_args
(self, args, namespace=None)
parses and returns a namespace object with known arguments at this point.
parses and returns a namespace object with known arguments at this point.
def parse_known_args(self, args, namespace=None): """parses and returns a namespace object with known arguments at this point. """ return self.parse_known_and_unknown_args(args, namespace=namespace)[0]
[ "def", "parse_known_args", "(", "self", ",", "args", ",", "namespace", "=", "None", ")", ":", "return", "self", ".", "parse_known_and_unknown_args", "(", "args", ",", "namespace", "=", "namespace", ")", "[", "0", "]" ]
[ 553, 4 ]
[ 557, 78 ]
python
en
['en', 'en', 'en']
True
Parser.parse_known_and_unknown_args
(self, args, namespace=None)
parses and returns a namespace object with known arguments, and the remaining arguments unknown at this point.
parses and returns a namespace object with known arguments, and the remaining arguments unknown at this point.
def parse_known_and_unknown_args(self, args, namespace=None): """parses and returns a namespace object with known arguments, and the remaining arguments unknown at this point. """ optparser = self._getparser() args = [str(x) for x in args] return optparser.parse_known_arg...
[ "def", "parse_known_and_unknown_args", "(", "self", ",", "args", ",", "namespace", "=", "None", ")", ":", "optparser", "=", "self", ".", "_getparser", "(", ")", "args", "=", "[", "str", "(", "x", ")", "for", "x", "in", "args", "]", "return", "optparser...
[ 559, 4 ]
[ 565, 68 ]
python
en
['en', 'en', 'en']
True
Parser.addini
(self, name, help, type=None, default=None)
register an ini-file option. :name: name of the ini-variable :type: type of the variable, can be ``pathlist``, ``args``, ``linelist`` or ``bool``. :default: default value if no ini-file option exists but is queried. The value of ini-variables can be retrieved via a call...
register an ini-file option.
def addini(self, name, help, type=None, default=None): """ register an ini-file option. :name: name of the ini-variable :type: type of the variable, can be ``pathlist``, ``args``, ``linelist`` or ``bool``. :default: default value if no ini-file option exists but is querie...
[ "def", "addini", "(", "self", ",", "name", ",", "help", ",", "type", "=", "None", ",", "default", "=", "None", ")", ":", "assert", "type", "in", "(", "None", ",", "\"pathlist\"", ",", "\"args\"", ",", "\"linelist\"", ",", "\"bool\"", ")", "self", "."...
[ 567, 4 ]
[ 580, 35 ]
python
en
['en', 'no', 'en']
True
Argument.__init__
(self, *names, **attrs)
store parms in private vars for use in add_argument
store parms in private vars for use in add_argument
def __init__(self, *names, **attrs): """store parms in private vars for use in add_argument""" self._attrs = attrs self._short_opts = [] self._long_opts = [] self.dest = attrs.get('dest') if '%default' in (attrs.get('help') or ''): warnings.warn( ...
[ "def", "__init__", "(", "self", ",", "*", "names", ",", "*", "*", "attrs", ")", ":", "self", ".", "_attrs", "=", "attrs", "self", ".", "_short_opts", "=", "[", "]", "self", ".", "_long_opts", "=", "[", "]", "self", ".", "dest", "=", "attrs", ".",...
[ 614, 4 ]
[ 670, 60 ]
python
en
['en', 'en', 'en']
True
Argument._set_opt_strings
(self, opts)
directly from optparse might not be necessary as this is passed to argparse later on
directly from optparse
def _set_opt_strings(self, opts): """directly from optparse might not be necessary as this is passed to argparse later on""" for opt in opts: if len(opt) < 2: raise ArgumentError( "invalid option string %r: " "must be at least ...
[ "def", "_set_opt_strings", "(", "self", ",", "opts", ")", ":", "for", "opt", "in", "opts", ":", "if", "len", "(", "opt", ")", "<", "2", ":", "raise", "ArgumentError", "(", "\"invalid option string %r: \"", "\"must be at least two characters long\"", "%", "opt", ...
[ 692, 4 ]
[ 714, 43 ]
python
en
['en', 'en', 'en']
True
OptionGroup.addoption
(self, *optnames, **attrs)
add an option to this group. if a shortened version of a long option is specified it will be suppressed in the help. addoption('--twowords', '--two-words') results in help showing '--two-words' only, but --twowords gets accepted **and** the automatic destination is in args.twowords ...
add an option to this group.
def addoption(self, *optnames, **attrs): """ add an option to this group. if a shortened version of a long option is specified it will be suppressed in the help. addoption('--twowords', '--two-words') results in help showing '--two-words' only, but --twowords gets accepted **and...
[ "def", "addoption", "(", "self", ",", "*", "optnames", ",", "*", "*", "attrs", ")", ":", "conflict", "=", "set", "(", "optnames", ")", ".", "intersection", "(", "name", "for", "opt", "in", "self", ".", "options", "for", "name", "in", "opt", ".", "n...
[ 737, 4 ]
[ 750, 58 ]
python
en
['en', 'en', 'en']
True
MyOptionParser.parse_args
(self, args=None, namespace=None)
allow splitting of positional arguments
allow splitting of positional arguments
def parse_args(self, args=None, namespace=None): """allow splitting of positional arguments""" args, argv = self.parse_known_args(args, namespace) if argv: for arg in argv: if arg and arg[0] == '-': lines = ['unrecognized arguments: %s' % (' '.join...
[ "def", "parse_args", "(", "self", ",", "args", "=", "None", ",", "namespace", "=", "None", ")", ":", "args", ",", "argv", "=", "self", ".", "parse_known_args", "(", "args", ",", "namespace", ")", "if", "argv", ":", "for", "arg", "in", "argv", ":", ...
[ 777, 4 ]
[ 788, 19 ]
python
en
['en', 'en', 'en']
True
Config.add_cleanup
(self, func)
Add a function to be called when the config object gets out of use (usually coninciding with pytest_unconfigure).
Add a function to be called when the config object gets out of use (usually coninciding with pytest_unconfigure).
def add_cleanup(self, func): """ Add a function to be called when the config object gets out of use (usually coninciding with pytest_unconfigure).""" self._cleanup.append(func)
[ "def", "add_cleanup", "(", "self", ",", "func", ")", ":", "self", ".", "_cleanup", ".", "append", "(", "func", ")" ]
[ 913, 4 ]
[ 916, 34 ]
python
en
['en', 'en', 'en']
True
Config.warn
(self, code, message, fslocation=None, nodeid=None)
generate a warning for this test session.
generate a warning for this test session.
def warn(self, code, message, fslocation=None, nodeid=None): """ generate a warning for this test session. """ self.hook.pytest_logwarning.call_historic(kwargs=dict( code=code, message=message, fslocation=fslocation, nodeid=nodeid))
[ "def", "warn", "(", "self", ",", "code", ",", "message", ",", "fslocation", "=", "None", ",", "nodeid", "=", "None", ")", ":", "self", ".", "hook", ".", "pytest_logwarning", ".", "call_historic", "(", "kwargs", "=", "dict", "(", "code", "=", "code", ...
[ 932, 4 ]
[ 936, 50 ]
python
en
['en', 'en', 'en']
True
Config.fromdictargs
(cls, option_dict, args)
constructor useable for subprocesses.
constructor useable for subprocesses.
def fromdictargs(cls, option_dict, args): """ constructor useable for subprocesses. """ config = get_config() config.option.__dict__.update(option_dict) config.parse(args, addopts=False) for x in config.option.plugins: config.pluginmanager.consider_pluginarg(x) ...
[ "def", "fromdictargs", "(", "cls", ",", "option_dict", ",", "args", ")", ":", "config", "=", "get_config", "(", ")", "config", ".", "option", ".", "__dict__", ".", "update", "(", "option_dict", ")", "config", ".", "parse", "(", "args", ",", "addopts", ...
[ 970, 4 ]
[ 977, 21 ]
python
en
['en', 'en', 'en']
True
Config._consider_importhook
(self, args)
Install the PEP 302 import hook if using assertion rewriting. Needs to parse the --assert=<mode> option from the commandline and find all the installed plugins to mark them for rewriting by the importhook.
Install the PEP 302 import hook if using assertion rewriting.
def _consider_importhook(self, args): """Install the PEP 302 import hook if using assertion rewriting. Needs to parse the --assert=<mode> option from the commandline and find all the installed plugins to mark them for rewriting by the importhook. """ ns, unknown_args = s...
[ "def", "_consider_importhook", "(", "self", ",", "args", ")", ":", "ns", ",", "unknown_args", "=", "self", ".", "_parser", ".", "parse_known_and_unknown_args", "(", "args", ")", "mode", "=", "ns", ".", "assertmode", "if", "mode", "==", "'rewrite'", ":", "t...
[ 1002, 4 ]
[ 1018, 48 ]
python
en
['en', 'en', 'en']
True
Config._mark_plugins_for_rewrite
(self, hook)
Given an importhook, mark for rewrite any top-level modules or packages in the distribution package for all pytest plugins.
Given an importhook, mark for rewrite any top-level modules or packages in the distribution package for all pytest plugins.
def _mark_plugins_for_rewrite(self, hook): """ Given an importhook, mark for rewrite any top-level modules or packages in the distribution package for all pytest plugins. """ import pkg_resources self.pluginmanager.rewrite_hook = hook # 'RECORD' available...
[ "def", "_mark_plugins_for_rewrite", "(", "self", ",", "hook", ")", ":", "import", "pkg_resources", "self", ".", "pluginmanager", ".", "rewrite_hook", "=", "hook", "# 'RECORD' available for plugins installed normally (pip install)", "# 'SOURCES.txt' available for plugins installed...
[ 1020, 4 ]
[ 1043, 35 ]
python
en
['en', 'error', 'th']
False
Config.addinivalue_line
(self, name, line)
add a line to an ini-file option. The option must have been declared but might not yet be set in which case the line becomes the the first line in its value.
add a line to an ini-file option. The option must have been declared but might not yet be set in which case the line becomes the the first line in its value.
def addinivalue_line(self, name, line): """ add a line to an ini-file option. The option must have been declared but might not yet be set in which case the line becomes the the first line in its value. """ x = self.getini(name) assert isinstance(x, list) x.append(line)
[ "def", "addinivalue_line", "(", "self", ",", "name", ",", "line", ")", ":", "x", "=", "self", ".", "getini", "(", "name", ")", "assert", "isinstance", "(", "x", ",", "list", ")", "x", ".", "append", "(", "line", ")" ]
[ 1124, 4 ]
[ 1130, 22 ]
python
en
['en', 'en', 'en']
True
Config.getini
(self, name)
return configuration value from an :ref:`ini file <inifiles>`. If the specified name hasn't been registered through a prior :py:func:`parser.addini <_pytest.config.Parser.addini>` call (usually from a plugin), a ValueError is raised.
return configuration value from an :ref:`ini file <inifiles>`. If the specified name hasn't been registered through a prior :py:func:`parser.addini <_pytest.config.Parser.addini>` call (usually from a plugin), a ValueError is raised.
def getini(self, name): """ return configuration value from an :ref:`ini file <inifiles>`. If the specified name hasn't been registered through a prior :py:func:`parser.addini <_pytest.config.Parser.addini>` call (usually from a plugin), a ValueError is raised. """ try: ...
[ "def", "getini", "(", "self", ",", "name", ")", ":", "try", ":", "return", "self", ".", "_inicache", "[", "name", "]", "except", "KeyError", ":", "self", ".", "_inicache", "[", "name", "]", "=", "val", "=", "self", ".", "_getini", "(", "name", ")",...
[ 1132, 4 ]
[ 1141, 22 ]
python
en
['en', 'en', 'en']
True
Config.getoption
(self, name, default=notset, skip=False)
return command line option value. :arg name: name of the option. You may also specify the literal ``--OPT`` option instead of the "dest" option name. :arg default: default value if no option of that name exists. :arg skip: if True raise pytest.skip if option does not exists ...
return command line option value.
def getoption(self, name, default=notset, skip=False): """ return command line option value. :arg name: name of the option. You may also specify the literal ``--OPT`` option instead of the "dest" option name. :arg default: default value if no option of that name exists. :ar...
[ "def", "getoption", "(", "self", ",", "name", ",", "default", "=", "notset", ",", "skip", "=", "False", ")", ":", "name", "=", "self", ".", "_opt2dest", ".", "get", "(", "name", ",", "name", ")", "try", ":", "val", "=", "getattr", "(", "self", "....
[ 1203, 4 ]
[ 1224, 60 ]
python
en
['en', 'da', 'en']
True
Config.getvalue
(self, name, path=None)
(deprecated, use getoption())
(deprecated, use getoption())
def getvalue(self, name, path=None): """ (deprecated, use getoption()) """ return self.getoption(name)
[ "def", "getvalue", "(", "self", ",", "name", ",", "path", "=", "None", ")", ":", "return", "self", ".", "getoption", "(", "name", ")" ]
[ 1226, 4 ]
[ 1228, 35 ]
python
en
['en', 'zu', 'en']
True
Config.getvalueorskip
(self, name, path=None)
(deprecated, use getoption(skip=True))
(deprecated, use getoption(skip=True))
def getvalueorskip(self, name, path=None): """ (deprecated, use getoption(skip=True)) """ return self.getoption(name, skip=True)
[ "def", "getvalueorskip", "(", "self", ",", "name", ",", "path", "=", "None", ")", ":", "return", "self", ".", "getoption", "(", "name", ",", "skip", "=", "True", ")" ]
[ 1230, 4 ]
[ 1232, 46 ]
python
en
['en', 'bs', 'en']
True
glibc_version_string
()
Returns glibc version string, or None if not using glibc.
Returns glibc version string, or None if not using glibc.
def glibc_version_string(): # type: () -> Optional[str] "Returns glibc version string, or None if not using glibc." return glibc_version_string_confstr() or glibc_version_string_ctypes()
[ "def", "glibc_version_string", "(", ")", ":", "# type: () -> Optional[str]", "return", "glibc_version_string_confstr", "(", ")", "or", "glibc_version_string_ctypes", "(", ")" ]
[ 14, 0 ]
[ 17, 74 ]
python
en
['en', 'en', 'en']
True
glibc_version_string_confstr
()
Primary implementation of glibc_version_string using os.confstr.
Primary implementation of glibc_version_string using os.confstr.
def glibc_version_string_confstr(): # type: () -> Optional[str] "Primary implementation of glibc_version_string using os.confstr." # os.confstr is quite a bit faster than ctypes.DLL. It's also less likely # to be broken or missing. This strategy is used in the standard library # platform module: ...
[ "def", "glibc_version_string_confstr", "(", ")", ":", "# type: () -> Optional[str]", "# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely", "# to be broken or missing. This strategy is used in the standard library", "# platform module:", "# https://github.com/python/cpython/b...
[ 20, 0 ]
[ 35, 18 ]
python
en
['en', 'en', 'en']
True
glibc_version_string_ctypes
()
Fallback implementation of glibc_version_string using ctypes.
Fallback implementation of glibc_version_string using ctypes.
def glibc_version_string_ctypes(): # type: () -> Optional[str] "Fallback implementation of glibc_version_string using ctypes." try: import ctypes except ImportError: return None # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen # manpage says, "If filename is...
[ "def", "glibc_version_string_ctypes", "(", ")", ":", "# type: () -> Optional[str]", "try", ":", "import", "ctypes", "except", "ImportError", ":", "return", "None", "# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen", "# manpage says, \"If filename is NULL, then the...
[ 38, 0 ]
[ 66, 22 ]
python
en
['en', 'en', 'en']
True
libc_ver
()
Try to determine the glibc version Returns a tuple of strings (lib, version) which default to empty strings in case the lookup fails.
Try to determine the glibc version
def libc_ver(): # type: () -> Tuple[str, str] """Try to determine the glibc version Returns a tuple of strings (lib, version) which default to empty strings in case the lookup fails. """ glibc_version = glibc_version_string() if glibc_version is None: return ("", "") else: ...
[ "def", "libc_ver", "(", ")", ":", "# type: () -> Tuple[str, str]", "glibc_version", "=", "glibc_version_string", "(", ")", "if", "glibc_version", "is", "None", ":", "return", "(", "\"\"", ",", "\"\"", ")", "else", ":", "return", "(", "\"glibc\"", ",", "glibc_v...
[ 86, 0 ]
[ 97, 39 ]
python
en
['en', 'en', 'en']
True
AttrList.__init__
(self, attributes)
@param attributes: A list of attributes @type attributes: list
def __init__(self, attributes): """ @param attributes: A list of attributes @type attributes: list """ self.raw = attributes
[ "def", "__init__", "(", "self", ",", "attributes", ")", ":", "self", ".", "raw", "=", "attributes" ]
[ 33, 4 ]
[ 38, 29 ]
python
en
['en', 'error', 'th']
False
AttrList.real
(self)
Get list of I{real} attributes which exclude xs and xml attributes. @return: A list of I{real} attributes. @rtype: I{generator}
Get list of I{real} attributes which exclude xs and xml attributes.
def real(self): """ Get list of I{real} attributes which exclude xs and xml attributes. @return: A list of I{real} attributes. @rtype: I{generator} """ for a in self.raw: if self.skip(a): continue yield a
[ "def", "real", "(", "self", ")", ":", "for", "a", "in", "self", ".", "raw", ":", "if", "self", ".", "skip", "(", "a", ")", ":", "continue", "yield", "a" ]
[ 40, 4 ]
[ 48, 19 ]
python
en
['en', 'error', 'th']
False
AttrList.rlen
(self)
Get the number of I{real} attributes which exclude xs and xml attributes. @return: A count of I{real} attributes. @rtype: L{int}
Get the number of I{real} attributes which exclude xs and xml attributes.
def rlen(self): """ Get the number of I{real} attributes which exclude xs and xml attributes. @return: A count of I{real} attributes. @rtype: L{int} """ n = 0 for a in self.real(): n += 1 return n
[ "def", "rlen", "(", "self", ")", ":", "n", "=", "0", "for", "a", "in", "self", ".", "real", "(", ")", ":", "n", "+=", "1", "return", "n" ]
[ 50, 4 ]
[ 59, 16 ]
python
en
['en', 'error', 'th']
False
AttrList.lang
(self)
Get list of I{filtered} attributes which exclude xs. @return: A list of I{filtered} attributes. @rtype: I{generator}
Get list of I{filtered} attributes which exclude xs.
def lang(self): """ Get list of I{filtered} attributes which exclude xs. @return: A list of I{filtered} attributes. @rtype: I{generator} """ for a in self.raw: if a.qname() == 'xml:lang': return a.value return None
[ "def", "lang", "(", "self", ")", ":", "for", "a", "in", "self", ".", "raw", ":", "if", "a", ".", "qname", "(", ")", "==", "'xml:lang'", ":", "return", "a", ".", "value", "return", "None" ]
[ 61, 4 ]
[ 70, 23 ]
python
en
['en', 'error', 'th']
False
AttrList.skip
(self, attr)
Get whether to skip (filter-out) the specified attribute. @param attr: An attribute. @type attr: I{Attribute} @return: True if should be skipped. @rtype: bool
Get whether to skip (filter-out) the specified attribute.
def skip(self, attr): """ Get whether to skip (filter-out) the specified attribute. @param attr: An attribute. @type attr: I{Attribute} @return: True if should be skipped. @rtype: bool """ ns = attr.namespace() skip = ( Namespace.xmlns[...
[ "def", "skip", "(", "self", ",", "attr", ")", ":", "ns", "=", "attr", ".", "namespace", "(", ")", "skip", "=", "(", "Namespace", ".", "xmlns", "[", "1", "]", ",", "'http://schemas.xmlsoap.org/soap/encoding/'", ",", "'http://schemas.xmlsoap.org/soap/envelope/'", ...
[ 72, 4 ]
[ 87, 52 ]
python
en
['en', 'error', 'th']
False
SolanoHookTests.test_solano_message_001
(self)
Build notifications are generated by Solano Labs after build completes.
Build notifications are generated by Solano Labs after build completes.
def test_solano_message_001(self) -> None: """ Build notifications are generated by Solano Labs after build completes. """ expected_topic = "build update" expected_message = """ Build update (see [build log](https://ci.solanolabs.com:443/reports/3316175)): * **Author**: solano-ci...
[ "def", "test_solano_message_001", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"build update\"", "expected_message", "=", "\"\"\"\nBuild update (see [build log](https://ci.solanolabs.com:443/reports/3316175)):\n* **Author**: solano-ci[bot]@users.noreply.github.com\n* **Com...
[ 8, 4 ]
[ 25, 9 ]
python
en
['en', 'error', 'th']
False
SolanoHookTests.test_solano_message_002
(self)
Build notifications are generated by Solano Labs after build completes.
Build notifications are generated by Solano Labs after build completes.
def test_solano_message_002(self) -> None: """ Build notifications are generated by Solano Labs after build completes. """ expected_topic = "build update" expected_message = """ Build update (see [build log](https://ci.solanolabs.com:443/reports/3316723)): * **Author**: Unknown *...
[ "def", "test_solano_message_002", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"build update\"", "expected_message", "=", "\"\"\"\nBuild update (see [build log](https://ci.solanolabs.com:443/reports/3316723)):\n* **Author**: Unknown\n* **Commit**: [5d0b92e](bitbucket.org/f...
[ 27, 4 ]
[ 44, 9 ]
python
en
['en', 'error', 'th']
False
SolanoHookTests.test_solano_message_received
(self)
Build notifications are generated by Solano Labs after build completes.
Build notifications are generated by Solano Labs after build completes.
def test_solano_message_received(self) -> None: """ Build notifications are generated by Solano Labs after build completes. """ expected_topic = "build update" expected_message = """ Build update (see [build log](https://ci.solanolabs.com:443/reports/3317799)): * **Author**: sola...
[ "def", "test_solano_message_received", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"build update\"", "expected_message", "=", "\"\"\"\nBuild update (see [build log](https://ci.solanolabs.com:443/reports/3317799)):\n* **Author**: solano-ci[bot]@users.noreply.github.com\n* ...
[ 46, 4 ]
[ 63, 9 ]
python
en
['en', 'error', 'th']
False
K2KAuthPlugin.get_plugin
(self, service_provider=None, auth_url=None, plugins=None, **kwargs)
Authenticate using keystone to keystone federation. This plugin uses other v3 plugins to authenticate a user to a identity provider in order to authenticate the user to a service provider :param service_provider: service provider ID :param auth_url: Keystone auth url :p...
Authenticate using keystone to keystone federation.
def get_plugin(self, service_provider=None, auth_url=None, plugins=None, **kwargs): """Authenticate using keystone to keystone federation. This plugin uses other v3 plugins to authenticate a user to a identity provider in order to authenticate the user to a service pr...
[ "def", "get_plugin", "(", "self", ",", "service_provider", "=", "None", ",", "auth_url", "=", "None", ",", "plugins", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Avoid mutable default arg for plugins", "plugins", "=", "plugins", "or", "[", "]", "if", ...
[ 30, 4 ]
[ 87, 28 ]
python
en
['en', 'pl', 'en']
True
K2KAuthPlugin.get_access_info
(self, unscoped_auth)
Get the access info object We attempt to get the auth ref. If it fails and if the K2K auth plugin was being used then we will prepend a message saying that the error was on the service provider side. :param unscoped_auth: Keystone auth plugin for unscoped user :returns: keystone...
Get the access info object
def get_access_info(self, unscoped_auth): """Get the access info object We attempt to get the auth ref. If it fails and if the K2K auth plugin was being used then we will prepend a message saying that the error was on the service provider side. :param unscoped_auth: Keystone aut...
[ "def", "get_access_info", "(", "self", ",", "unscoped_auth", ")", ":", "try", ":", "unscoped_auth_ref", "=", "base", ".", "BasePlugin", ".", "get_access_info", "(", "self", ",", "unscoped_auth", ")", "except", "exceptions", ".", "KeystoneAuthException", "as", "e...
[ 89, 4 ]
[ 104, 32 ]
python
en
['en', 'en', 'en']
True
ScaledDotProductAttention.__init__
(self, d_model, d_k, d_v, h)
:param d_model: Output dimensionality of the model :param d_k: Dimensionality of queries and keys :param d_v: Dimensionality of values :param h: Number of heads
:param d_model: Output dimensionality of the model :param d_k: Dimensionality of queries and keys :param d_v: Dimensionality of values :param h: Number of heads
def __init__(self, d_model, d_k, d_v, h): ''' :param d_model: Output dimensionality of the model :param d_k: Dimensionality of queries and keys :param d_v: Dimensionality of values :param h: Number of heads ''' super(ScaledDotProductAttention, self).__init__() ...
[ "def", "__init__", "(", "self", ",", "d_model", ",", "d_k", ",", "d_v", ",", "h", ")", ":", "super", "(", "ScaledDotProductAttention", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "fc_q", "=", "nn", ".", "Linear", "(", "d_model", ",", ...
[ 17, 4 ]
[ 35, 27 ]
python
en
['en', 'error', 'th']
False
ScaledDotProductAttention.forward
(self, queries, keys, values, attention_mask=None, attention_weights=None)
Computes :param queries: Queries (b_s, nq, d_model) :param keys: Keys (b_s, nk, d_model) :param values: Values (b_s, nk, d_model) :param attention_mask: Mask over attention values (b_s, h, nq, nk). True indicates masking. :param attention_weights: Multiplicative weights ...
Computes :param queries: Queries (b_s, nq, d_model) :param keys: Keys (b_s, nk, d_model) :param values: Values (b_s, nk, d_model) :param attention_mask: Mask over attention values (b_s, h, nq, nk). True indicates masking. :param attention_weights: Multiplicative weights ...
def forward(self, queries, keys, values, attention_mask=None, attention_weights=None): ''' Computes :param queries: Queries (b_s, nq, d_model) :param keys: Keys (b_s, nk, d_model) :param values: Values (b_s, nk, d_model) :param attention_mask: Mask over attention values (...
[ "def", "forward", "(", "self", ",", "queries", ",", "keys", ",", "values", ",", "attention_mask", "=", "None", ",", "attention_weights", "=", "None", ")", ":", "b_s", ",", "nq", "=", "queries", ".", "shape", "[", ":", "2", "]", "nk", "=", "keys", "...
[ 47, 4 ]
[ 76, 18 ]
python
en
['en', 'error', 'th']
False
ScaledDotProductAttentionMemory.__init__
(self, d_model, d_k, d_v, h, m)
:param d_model: Output dimensionality of the model :param d_k: Dimensionality of queries and keys :param d_v: Dimensionality of values :param h: Number of heads :param m: Number of memory slots "extended the set of Keys and Values in Encoder with additional “slots” to ...
:param d_model: Output dimensionality of the model :param d_k: Dimensionality of queries and keys :param d_v: Dimensionality of values :param h: Number of heads :param m: Number of memory slots
def __init__(self, d_model, d_k, d_v, h, m): ''' :param d_model: Output dimensionality of the model :param d_k: Dimensionality of queries and keys :param d_v: Dimensionality of values :param h: Number of heads :param m: Number of memory slots "extended the set o...
[ "def", "__init__", "(", "self", ",", "d_model", ",", "d_k", ",", "d_v", ",", "h", ",", "m", ")", ":", "super", "(", "ScaledDotProductAttentionMemory", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "fc_q", "=", "nn", ".", "Linear", "(", ...
[ 84, 4 ]
[ 113, 27 ]
python
en
['en', 'error', 'th']
False
ScaledDotProductAttentionMemory.forward
(self, queries, keys, values, attention_mask=None, attention_weights=None)
Computes :param queries: Queries (b_s, nq, d_model) :param keys: Keys (b_s, nk, d_model) :param values: Values (b_s, nk, d_model) :param attention_mask: Mask over attention values (b_s, h, nq, nk). True indicates masking. :param attention_weights: Multiplicative weights ...
Computes :param queries: Queries (b_s, nq, d_model) :param keys: Keys (b_s, nk, d_model) :param values: Values (b_s, nk, d_model) :param attention_mask: Mask over attention values (b_s, h, nq, nk). True indicates masking. :param attention_weights: Multiplicative weights ...
def forward(self, queries, keys, values, attention_mask=None, attention_weights=None): ''' Computes :param queries: Queries (b_s, nq, d_model) :param keys: Keys (b_s, nk, d_model) :param values: Values (b_s, nk, d_model) :param attention_mask: Mask over attention values (...
[ "def", "forward", "(", "self", ",", "queries", ",", "keys", ",", "values", ",", "attention_mask", "=", "None", ",", "attention_weights", "=", "None", ")", ":", "b_s", ",", "nq", "=", "queries", ".", "shape", "[", ":", "2", "]", "nk", "=", "keys", "...
[ 127, 4 ]
[ 156, 18 ]
python
en
['en', 'error', 'th']
False
test_zipimport_hook
(testdir, tmpdir)
Test package loader is being used correctly (see #1837).
Test package loader is being used correctly (see #1837).
def test_zipimport_hook(testdir, tmpdir): """Test package loader is being used correctly (see #1837).""" zipapp = pytest.importorskip('zipapp') testdir.tmpdir.join('app').ensure(dir=1) testdir.makepyfile(**{ 'app/foo.py': """ import pytest def main(): pyte...
[ "def", "test_zipimport_hook", "(", "testdir", ",", "tmpdir", ")", ":", "zipapp", "=", "pytest", ".", "importorskip", "(", "'zipapp'", ")", "testdir", ".", "tmpdir", ".", "join", "(", "'app'", ")", ".", "ensure", "(", "dir", "=", "1", ")", "testdir", "....
[ 864, 0 ]
[ 880, 54 ]
python
en
['en', 'en', 'en']
True
test_deferred_hook_checking
(testdir)
Check hooks as late as possible (#1821).
Check hooks as late as possible (#1821).
def test_deferred_hook_checking(testdir): """ Check hooks as late as possible (#1821). """ testdir.syspathinsert() testdir.makepyfile(**{ 'plugin.py': """ class Hooks(object): def pytest_my_hook(self, config): pass def pytest_configure(config): ...
[ "def", "test_deferred_hook_checking", "(", "testdir", ")", ":", "testdir", ".", "syspathinsert", "(", ")", "testdir", ".", "makepyfile", "(", "*", "*", "{", "'plugin.py'", ":", "\"\"\"\n class Hooks(object):\n def pytest_my_hook(self, config):\n ...
[ 897, 0 ]
[ 922, 49 ]
python
en
['en', 'error', 'th']
False
test_fixture_values_leak
(testdir)
Ensure that fixture objects are properly destroyed by the garbage collector at the end of their expected life-times (#2981).
Ensure that fixture objects are properly destroyed by the garbage collector at the end of their expected life-times (#2981).
def test_fixture_values_leak(testdir): """Ensure that fixture objects are properly destroyed by the garbage collector at the end of their expected life-times (#2981). """ testdir.makepyfile(""" import attr import gc import pytest import weakref @attr.s cl...
[ "def", "test_fixture_values_leak", "(", "testdir", ")", ":", "testdir", ".", "makepyfile", "(", "\"\"\"\n import attr\n import gc\n import pytest\n import weakref\n\n @attr.s\n class SomeObj(object):\n name = attr.ib()\n\n fix_of_test1_...
[ 925, 0 ]
[ 965, 49 ]
python
en
['en', 'en', 'en']
True
TestGeneralUsage.test_namespace_import_doesnt_confuse_import_hook
(self, testdir)
Ref #383. Python 3.3's namespace package messed with our import hooks Importing a module that didn't exist, even if the ImportError was gracefully handled, would make our test crash. Use recwarn here to silence this warning in Python 2.7: ImportWarning: Not importing direct...
Ref #383. Python 3.3's namespace package messed with our import hooks Importing a module that didn't exist, even if the ImportError was gracefully handled, would make our test crash.
def test_namespace_import_doesnt_confuse_import_hook(self, testdir): """ Ref #383. Python 3.3's namespace package messed with our import hooks Importing a module that didn't exist, even if the ImportError was gracefully handled, would make our test crash. Use recwarn here to sil...
[ "def", "test_namespace_import_doesnt_confuse_import_hook", "(", "self", ",", "testdir", ")", ":", "testdir", ".", "mkdir", "(", "'not_a_package'", ")", "p", "=", "testdir", ".", "makepyfile", "(", "\"\"\"\n try:\n from not_a_package import doesnt_exi...
[ 343, 4 ]
[ 364, 27 ]
python
en
['en', 'error', 'th']
False
TestGeneralUsage.test_plugins_given_as_strings
(self, tmpdir, monkeypatch)
test that str values passed to main() as `plugins` arg are interpreted as module names to be imported and registered. #855.
test that str values passed to main() as `plugins` arg are interpreted as module names to be imported and registered. #855.
def test_plugins_given_as_strings(self, tmpdir, monkeypatch): """test that str values passed to main() as `plugins` arg are interpreted as module names to be imported and registered. #855. """ with pytest.raises(ImportError) as excinfo: pytest.main([str(tmpdir)], plug...
[ "def", "test_plugins_given_as_strings", "(", "self", ",", "tmpdir", ",", "monkeypatch", ")", ":", "with", "pytest", ".", "raises", "(", "ImportError", ")", "as", "excinfo", ":", "pytest", ".", "main", "(", "[", "str", "(", "tmpdir", ")", "]", ",", "plugi...
[ 390, 4 ]
[ 403, 73 ]
python
en
['en', 'en', 'en']
True
TestGeneralUsage.test_parametrized_with_null_bytes
(self, testdir)
Test parametrization with values that contain null bytes and unicode characters (#2644, #2957)
Test parametrization with values that contain null bytes and unicode characters (#2644, #2957)
def test_parametrized_with_null_bytes(self, testdir): """Test parametrization with values that contain null bytes and unicode characters (#2644, #2957)""" p = testdir.makepyfile(u""" # encoding: UTF-8 import pytest @pytest.mark.parametrize("data", [b"\\x00", "\\x00",...
[ "def", "test_parametrized_with_null_bytes", "(", "self", ",", "testdir", ")", ":", "p", "=", "testdir", ".", "makepyfile", "(", "u\"\"\"\n # encoding: UTF-8\n import pytest\n\n @pytest.mark.parametrize(\"data\", [b\"\\\\x00\", \"\\\\x00\", u'ação'])\n ...
[ 419, 4 ]
[ 430, 37 ]
python
en
['en', 'en', 'en']
True
TestInvocationVariants.test_cmdline_python_namespace_package
(self, testdir, monkeypatch)
test --pyargs option with namespace packages (#1567)
test --pyargs option with namespace packages (#1567)
def test_cmdline_python_namespace_package(self, testdir, monkeypatch): """ test --pyargs option with namespace packages (#1567) """ monkeypatch.delenv('PYTHONDONTWRITEBYTECODE', raising=False) search_path = [] for dirname in "hello", "world": d = testdir.mkdi...
[ "def", "test_cmdline_python_namespace_package", "(", "self", ",", "testdir", ",", "monkeypatch", ")", ":", "monkeypatch", ".", "delenv", "(", "'PYTHONDONTWRITEBYTECODE'", ",", "raising", "=", "False", ")", "search_path", "=", "[", "]", "for", "dirname", "in", "\...
[ 586, 4 ]
[ 648, 10 ]
python
en
['en', 'error', 'th']
False
TestInvocationVariants.test_cmdline_python_package_symlink
(self, testdir, monkeypatch)
test --pyargs option with packages with path containing symlink can have conftest.py in their package (#2985)
test --pyargs option with packages with path containing symlink can have conftest.py in their package (#2985)
def test_cmdline_python_package_symlink(self, testdir, monkeypatch): """ test --pyargs option with packages with path containing symlink can have conftest.py in their package (#2985) """ # dummy check that we can actually create symlinks: on Windows `os.symlink` is available, ...
[ "def", "test_cmdline_python_package_symlink", "(", "self", ",", "testdir", ",", "monkeypatch", ")", ":", "# dummy check that we can actually create symlinks: on Windows `os.symlink` is available,", "# but normal users require special admin privileges to create symlinks.", "if", "sys", "....
[ 651, 4 ]
[ 718, 10 ]
python
en
['en', 'error', 'th']
False
TestInvocationVariants.test_core_backward_compatibility
(self)
Test backward compatibility for get_plugin_manager function. See #787.
Test backward compatibility for get_plugin_manager function. See #787.
def test_core_backward_compatibility(self): """Test backward compatibility for get_plugin_manager function. See #787.""" import _pytest.config assert type(_pytest.config.get_plugin_manager()) is _pytest.config.PytestPluginManager
[ "def", "test_core_backward_compatibility", "(", "self", ")", ":", "import", "_pytest", ".", "config", "assert", "type", "(", "_pytest", ".", "config", ".", "get_plugin_manager", "(", ")", ")", "is", "_pytest", ".", "config", ".", "PytestPluginManager" ]
[ 759, 4 ]
[ 762, 94 ]
python
en
['en', 'en', 'en']
True
TestInvocationVariants.test_has_plugin
(self, request)
Test hasplugin function of the plugin manager (#932).
Test hasplugin function of the plugin manager (#932).
def test_has_plugin(self, request): """Test hasplugin function of the plugin manager (#932).""" assert request.config.pluginmanager.hasplugin('python')
[ "def", "test_has_plugin", "(", "self", ",", "request", ")", ":", "assert", "request", ".", "config", ".", "pluginmanager", ".", "hasplugin", "(", "'python'", ")" ]
[ 764, 4 ]
[ 766, 63 ]
python
en
['en', 'en', 'en']
True
start_new_thread
(function, args, kwargs={})
Dummy implementation of _thread.start_new_thread(). Compatibility is maintained by making sure that ``args`` is a tuple and ``kwargs`` is a dictionary. If an exception is raised and it is SystemExit (which can be done by _thread.exit()) it is caught and nothing is done; all other exceptions are printe...
Dummy implementation of _thread.start_new_thread().
def start_new_thread(function, args, kwargs={}): """Dummy implementation of _thread.start_new_thread(). Compatibility is maintained by making sure that ``args`` is a tuple and ``kwargs`` is a dictionary. If an exception is raised and it is SystemExit (which can be done by _thread.exit()) it is cau...
[ "def", "start_new_thread", "(", "function", ",", "args", ",", "kwargs", "=", "{", "}", ")", ":", "if", "type", "(", "args", ")", "!=", "type", "(", "tuple", "(", ")", ")", ":", "raise", "TypeError", "(", "\"2nd arg must be a tuple\"", ")", "if", "type"...
[ 28, 0 ]
[ 58, 31 ]
python
en
['en', 'de', 'en']
True
exit
()
Dummy implementation of _thread.exit().
Dummy implementation of _thread.exit().
def exit(): """Dummy implementation of _thread.exit().""" raise SystemExit
[ "def", "exit", "(", ")", ":", "raise", "SystemExit" ]
[ 60, 0 ]
[ 62, 20 ]
python
en
['en', 'en', 'en']
True
get_ident
()
Dummy implementation of _thread.get_ident(). Since this module should only be used when _threadmodule is not available, it is safe to assume that the current process is the only thread. Thus a constant can be safely returned.
Dummy implementation of _thread.get_ident().
def get_ident(): """Dummy implementation of _thread.get_ident(). Since this module should only be used when _threadmodule is not available, it is safe to assume that the current process is the only thread. Thus a constant can be safely returned. """ return -1
[ "def", "get_ident", "(", ")", ":", "return", "-", "1" ]
[ 64, 0 ]
[ 71, 13 ]
python
en
['en', 'en', 'en']
True
allocate_lock
()
Dummy implementation of _thread.allocate_lock().
Dummy implementation of _thread.allocate_lock().
def allocate_lock(): """Dummy implementation of _thread.allocate_lock().""" return LockType()
[ "def", "allocate_lock", "(", ")", ":", "return", "LockType", "(", ")" ]
[ 73, 0 ]
[ 75, 21 ]
python
en
['en', 'en', 'en']
True
stack_size
(size=None)
Dummy implementation of _thread.stack_size().
Dummy implementation of _thread.stack_size().
def stack_size(size=None): """Dummy implementation of _thread.stack_size().""" if size is not None: raise error("setting thread stack size not supported") return 0
[ "def", "stack_size", "(", "size", "=", "None", ")", ":", "if", "size", "is", "not", "None", ":", "raise", "error", "(", "\"setting thread stack size not supported\"", ")", "return", "0" ]
[ 77, 0 ]
[ 81, 12 ]
python
en
['en', 'en', 'en']
True
_set_sentinel
()
Dummy implementation of _thread._set_sentinel().
Dummy implementation of _thread._set_sentinel().
def _set_sentinel(): """Dummy implementation of _thread._set_sentinel().""" return LockType()
[ "def", "_set_sentinel", "(", ")", ":", "return", "LockType", "(", ")" ]
[ 83, 0 ]
[ 85, 21 ]
python
en
['en', 'de', 'en']
True
interrupt_main
()
Set _interrupt flag to True to have start_new_thread raise KeyboardInterrupt upon exiting.
Set _interrupt flag to True to have start_new_thread raise KeyboardInterrupt upon exiting.
def interrupt_main(): """Set _interrupt flag to True to have start_new_thread raise KeyboardInterrupt upon exiting.""" if _main: raise KeyboardInterrupt else: global _interrupt _interrupt = True
[ "def", "interrupt_main", "(", ")", ":", "if", "_main", ":", "raise", "KeyboardInterrupt", "else", ":", "global", "_interrupt", "_interrupt", "=", "True" ]
[ 155, 0 ]
[ 162, 25 ]
python
en
['en', 'de', 'en']
True
LockType.acquire
(self, waitflag=None, timeout=-1)
Dummy implementation of acquire(). For blocking calls, self.locked_status is automatically set to True and returned appropriately based on value of ``waitflag``. If it is non-blocking, then the value is actually checked and not set if it is already acquired. This is all done s...
Dummy implementation of acquire().
def acquire(self, waitflag=None, timeout=-1): """Dummy implementation of acquire(). For blocking calls, self.locked_status is automatically set to True and returned appropriately based on value of ``waitflag``. If it is non-blocking, then the value is actually checked and not s...
[ "def", "acquire", "(", "self", ",", "waitflag", "=", "None", ",", "timeout", "=", "-", "1", ")", ":", "if", "waitflag", "is", "None", "or", "waitflag", ":", "self", ".", "locked_status", "=", "True", "return", "True", "else", ":", "if", "not", "self"...
[ 101, 4 ]
[ 123, 28 ]
python
en
['en', 'en', 'en']
True
LockType.release
(self)
Release the dummy lock.
Release the dummy lock.
def release(self): """Release the dummy lock.""" # XXX Perhaps shouldn't actually bother to test? Could lead # to problems for complex, threaded code. if not self.locked_status: raise error self.locked_status = False return True
[ "def", "release", "(", "self", ")", ":", "# XXX Perhaps shouldn't actually bother to test? Could lead", "# to problems for complex, threaded code.", "if", "not", "self", ".", "locked_status", ":", "raise", "error", "self", ".", "locked_status", "=", "False", "return", ...
[ 130, 4 ]
[ 137, 19 ]
python
en
['en', 'en', 'en']
True
precook
(s, n=4)
Takes a string as input and returns an object that can be given to either cook_refs or cook_test. This is optional: cook_refs and cook_test can take string arguments as well. :param s: string : sentence to be converted into ngrams :param n: int : number of ngrams for which representation is calc...
Takes a string as input and returns an object that can be given to either cook_refs or cook_test. This is optional: cook_refs and cook_test can take string arguments as well. :param s: string : sentence to be converted into ngrams :param n: int : number of ngrams for which representation is calc...
def precook(s, n=4): """ Takes a string as input and returns an object that can be given to either cook_refs or cook_test. This is optional: cook_refs and cook_test can take string arguments as well. :param s: string : sentence to be converted into ngrams :param n: int : number of ngrams for ...
[ "def", "precook", "(", "s", ",", "n", "=", "4", ")", ":", "words", "=", "s", ".", "split", "(", ")", "counts", "=", "defaultdict", "(", "int", ")", "for", "k", "in", "range", "(", "1", ",", "n", "+", "1", ")", ":", "for", "i", "in", "range"...
[ 9, 0 ]
[ 24, 17 ]
python
en
['en', 'error', 'th']
False
cook_refs
(refs, n=4)
Takes a list of reference sentences for a single segment and returns an object that encapsulates everything that BLEU needs to know about them. :param refs: list of string : reference sentences for some image :param n: int : number of ngrams for which (ngram) representation is calculated :return: re...
Takes a list of reference sentences for a single segment and returns an object that encapsulates everything that BLEU needs to know about them. :param refs: list of string : reference sentences for some image :param n: int : number of ngrams for which (ngram) representation is calculated :return: re...
def cook_refs(refs, n=4): ## lhuang: oracle will call with "average" '''Takes a list of reference sentences for a single segment and returns an object that encapsulates everything that BLEU needs to know about them. :param refs: list of string : reference sentences for some image :param n: int : num...
[ "def", "cook_refs", "(", "refs", ",", "n", "=", "4", ")", ":", "## lhuang: oracle will call with \"average\"", "return", "[", "precook", "(", "ref", ",", "n", ")", "for", "ref", "in", "refs", "]" ]
[ 26, 0 ]
[ 34, 44 ]
python
en
['en', 'en', 'en']
True
cook_test
(test, n=4)
Takes a test sentence and returns an object that encapsulates everything that BLEU needs to know about it. :param test: list of string : hypothesis sentence for some image :param n: int : number of ngrams for which (ngram) representation is calculated :return: result (dict)
Takes a test sentence and returns an object that encapsulates everything that BLEU needs to know about it. :param test: list of string : hypothesis sentence for some image :param n: int : number of ngrams for which (ngram) representation is calculated :return: result (dict)
def cook_test(test, n=4): '''Takes a test sentence and returns an object that encapsulates everything that BLEU needs to know about it. :param test: list of string : hypothesis sentence for some image :param n: int : number of ngrams for which (ngram) representation is calculated :return: result (di...
[ "def", "cook_test", "(", "test", ",", "n", "=", "4", ")", ":", "return", "precook", "(", "test", ",", "n", ")" ]
[ 36, 0 ]
[ 43, 27 ]
python
en
['en', 'en', 'en']
True
CiderScorer.__init__
(self, refs, test=None, n=4, sigma=6.0, doc_frequency=None, ref_len=None)
singular instance
singular instance
def __init__(self, refs, test=None, n=4, sigma=6.0, doc_frequency=None, ref_len=None): ''' singular instance ''' self.n = n self.sigma = sigma self.crefs = [] self.ctest = [] self.doc_frequency = defaultdict(float) self.ref_len = None for k in refs.keys()...
[ "def", "__init__", "(", "self", ",", "refs", ",", "test", "=", "None", ",", "n", "=", "4", ",", "sigma", "=", "6.0", ",", "doc_frequency", "=", "None", ",", "ref_len", "=", "None", ")", ":", "self", ".", "n", "=", "n", "self", ".", "sigma", "="...
[ 49, 4 ]
[ 72, 34 ]
python
en
['en', 'de', 'en']
False
CiderScorer.compute_doc_freq
(self)
Compute term frequency for reference data. This will be used to compute idf (inverse document frequency later) The term frequency is stored in the object :return: None
Compute term frequency for reference data. This will be used to compute idf (inverse document frequency later) The term frequency is stored in the object :return: None
def compute_doc_freq(self): ''' Compute term frequency for reference data. This will be used to compute idf (inverse document frequency later) The term frequency is stored in the object :return: None ''' for refs in self.crefs: # refs, k ref captions o...
[ "def", "compute_doc_freq", "(", "self", ")", ":", "for", "refs", "in", "self", ".", "crefs", ":", "# refs, k ref captions of one image", "for", "ngram", "in", "set", "(", "[", "ngram", "for", "ref", "in", "refs", "for", "(", "ngram", ",", "count", ")", "...
[ 74, 4 ]
[ 84, 46 ]
python
en
['en', 'error', 'th']
False
_current_component
(view_func, dashboard=None, panel=None)
Sets the currently-active dashboard and/or panel on the request.
Sets the currently-active dashboard and/or panel on the request.
def _current_component(view_func, dashboard=None, panel=None): """Sets the currently-active dashboard and/or panel on the request.""" @functools.wraps(view_func, assigned=available_attrs(view_func)) def dec(request, *args, **kwargs): if dashboard: request.horizon['dashboard'] = dashboard...
[ "def", "_current_component", "(", "view_func", ",", "dashboard", "=", "None", ",", "panel", "=", "None", ")", ":", "@", "functools", ".", "wraps", "(", "view_func", ",", "assigned", "=", "available_attrs", "(", "view_func", ")", ")", "def", "dec", "(", "...
[ 27, 0 ]
[ 36, 14 ]
python
en
['en', 'en', 'en']
True