body
stringlengths
26
98.2k
body_hash
int64
-9,222,864,604,528,158,000
9,221,803,474B
docstring
stringlengths
1
16.8k
path
stringlengths
5
230
name
stringlengths
1
96
repository_name
stringlengths
7
89
lang
stringclasses
1 value
body_without_docstring
stringlengths
20
98.2k
def __init__(self, event, device): 'Initialize the Axis event.' super().__init__(device) self.event = event self._attr_name = f'{device.name} {event.TYPE} {event.id}' self._attr_unique_id = f'{device.unique_id}-{event.topic}-{event.id}' self._attr_device_class = event.CLASS
6,711,343,000,170,600,000
Initialize the Axis event.
homeassistant/components/axis/axis_base.py
__init__
2004happy/core
python
def __init__(self, event, device): super().__init__(device) self.event = event self._attr_name = f'{device.name} {event.TYPE} {event.id}' self._attr_unique_id = f'{device.unique_id}-{event.topic}-{event.id}' self._attr_device_class = event.CLASS
async def async_added_to_hass(self) -> None: 'Subscribe sensors events.' self.event.register_callback(self.update_callback) (await super().async_added_to_hass())
5,140,606,662,706,622,000
Subscribe sensors events.
homeassistant/components/axis/axis_base.py
async_added_to_hass
2004happy/core
python
async def async_added_to_hass(self) -> None: self.event.register_callback(self.update_callback) (await super().async_added_to_hass())
async def async_will_remove_from_hass(self) -> None: 'Disconnect device object when removed.' self.event.remove_callback(self.update_callback)
-8,581,445,601,509,573,000
Disconnect device object when removed.
homeassistant/components/axis/axis_base.py
async_will_remove_from_hass
2004happy/core
python
async def async_will_remove_from_hass(self) -> None: self.event.remove_callback(self.update_callback)
def decode_prediction(prediction): '\n Decodes predictions and returns a result string.\n ' if (np.where((prediction == np.amax(prediction)))[1] == 2): prob_orange = round((prediction[0][2] * 100), 2) label = f'I am {prob_orange} % sure this is an orange 🍊!' if (np.where((prediction =...
992,678,582,589,011,700
Decodes predictions and returns a result string.
src/predict.py
decode_prediction
DariusTorabian/image-classifier
python
def decode_prediction(prediction): '\n \n ' if (np.where((prediction == np.amax(prediction)))[1] == 2): prob_orange = round((prediction[0][2] * 100), 2) label = f'I am {prob_orange} % sure this is an orange 🍊!' if (np.where((prediction == np.amax(prediction)))[1] == 1): prob_b...
def predict(frame): '\n Takes a frame as input, makes a prediction, decoodes it\n and returns a result string.\n ' img = cv2.resize(frame, (224, 224)) img = cv2.cvtColor(np.float32(img), cv2.COLOR_BGR2RGB) img = img.reshape(1, 224, 224, 3) prediction = model.predict(img) label = decode_...
-677,628,201,894,662,000
Takes a frame as input, makes a prediction, decoodes it and returns a result string.
src/predict.py
predict
DariusTorabian/image-classifier
python
def predict(frame): '\n Takes a frame as input, makes a prediction, decoodes it\n and returns a result string.\n ' img = cv2.resize(frame, (224, 224)) img = cv2.cvtColor(np.float32(img), cv2.COLOR_BGR2RGB) img = img.reshape(1, 224, 224, 3) prediction = model.predict(img) label = decode_...
def declare_types(**types): "\n Decorator to declare argument and result types for a function\n\n Usage is similar to `check_units` except that types must be one of ``{VALID_ARG_TYPES}``\n and the result type must be one of ``{VALID_RETURN_TYPES}``. Unspecified argument\n types are assumed to be ``'all'...
515,835,094,503,969,150
Decorator to declare argument and result types for a function Usage is similar to `check_units` except that types must be one of ``{VALID_ARG_TYPES}`` and the result type must be one of ``{VALID_RETURN_TYPES}``. Unspecified argument types are assumed to be ``'all'`` (i.e. anything is permitted), and an unspecified res...
brian2/core/functions.py
declare_types
Ziaeemehr/brian2
python
def declare_types(**types): "\n Decorator to declare argument and result types for a function\n\n Usage is similar to `check_units` except that types must be one of ``{VALID_ARG_TYPES}``\n and the result type must be one of ``{VALID_RETURN_TYPES}``. Unspecified argument\n types are assumed to be ``'all'...
def implementation(target, code=None, namespace=None, dependencies=None, discard_units=None, name=None, **compiler_kwds): '\n A simple decorator to extend user-written Python functions to work with code\n generation in other languages.\n\n Parameters\n ----------\n target : str\n Name of the c...
6,971,452,595,776,065,000
A simple decorator to extend user-written Python functions to work with code generation in other languages. Parameters ---------- target : str Name of the code generation target (e.g. ``'cython'``) for which to add an implementation. code : str or dict-like, optional What kind of code the target language e...
brian2/core/functions.py
implementation
Ziaeemehr/brian2
python
def implementation(target, code=None, namespace=None, dependencies=None, discard_units=None, name=None, **compiler_kwds): '\n A simple decorator to extend user-written Python functions to work with code\n generation in other languages.\n\n Parameters\n ----------\n target : str\n Name of the c...
def timestep(t, dt): '\n Converts a given time to an integer time step. This function slightly shifts\n the time before dividing it by ``dt`` to make sure that multiples of ``dt``\n do not end up in the preceding time step due to floating point issues. This\n function is used in the refractoriness calcu...
-7,115,279,182,672,181,000
Converts a given time to an integer time step. This function slightly shifts the time before dividing it by ``dt`` to make sure that multiples of ``dt`` do not end up in the preceding time step due to floating point issues. This function is used in the refractoriness calculation. .. versionadded:: 2.1.3 Parameters --...
brian2/core/functions.py
timestep
Ziaeemehr/brian2
python
def timestep(t, dt): '\n Converts a given time to an integer time step. This function slightly shifts\n the time before dividing it by ``dt`` to make sure that multiples of ``dt``\n do not end up in the preceding time step due to floating point issues. This\n function is used in the refractoriness calcu...
def is_locally_constant(self, dt): '\n Return whether this function (if interpreted as a function of time)\n should be considered constant over a timestep. This is most importantly\n used by `TimedArray` so that linear integration can be used. In its\n standard implementation, always ret...
-504,631,884,878,651,900
Return whether this function (if interpreted as a function of time) should be considered constant over a timestep. This is most importantly used by `TimedArray` so that linear integration can be used. In its standard implementation, always returns ``False``. Parameters ---------- dt : float The length of a timeste...
brian2/core/functions.py
is_locally_constant
Ziaeemehr/brian2
python
def is_locally_constant(self, dt): '\n Return whether this function (if interpreted as a function of time)\n should be considered constant over a timestep. This is most importantly\n used by `TimedArray` so that linear integration can be used. In its\n standard implementation, always ret...
def __getitem__(self, key): '\n Find an implementation for this function that can be used by the\n `CodeObject` given as `key`. Will find implementations registered\n for `key` itself (or one of its parents), or for the `CodeGenerator`\n class that `key` uses (or one of its parents). In ...
-7,995,967,572,741,398,000
Find an implementation for this function that can be used by the `CodeObject` given as `key`. Will find implementations registered for `key` itself (or one of its parents), or for the `CodeGenerator` class that `key` uses (or one of its parents). In all cases, implementations registered for the corresponding names qual...
brian2/core/functions.py
__getitem__
Ziaeemehr/brian2
python
def __getitem__(self, key): '\n Find an implementation for this function that can be used by the\n `CodeObject` given as `key`. Will find implementations registered\n for `key` itself (or one of its parents), or for the `CodeGenerator`\n class that `key` uses (or one of its parents). In ...
def add_numpy_implementation(self, wrapped_func, dependencies=None, discard_units=None, compiler_kwds=None): '\n Add a numpy implementation to a `Function`.\n\n Parameters\n ----------\n function : `Function`\n The function description for which an implementation should be add...
6,471,998,481,695,690,000
Add a numpy implementation to a `Function`. Parameters ---------- function : `Function` The function description for which an implementation should be added. wrapped_func : callable The original function (that will be used for the numpy implementation) dependencies : list of `Function`, optional A list of ...
brian2/core/functions.py
add_numpy_implementation
Ziaeemehr/brian2
python
def add_numpy_implementation(self, wrapped_func, dependencies=None, discard_units=None, compiler_kwds=None): '\n Add a numpy implementation to a `Function`.\n\n Parameters\n ----------\n function : `Function`\n The function description for which an implementation should be add...
def add_dynamic_implementation(self, target, code, namespace=None, dependencies=None, availability_check=None, name=None, compiler_kwds=None): '\n Adds an "dynamic implementation" for this function. `code` and `namespace`\n arguments are expected to be callables that will be called in\n `Networ...
502,401,531,114,870,500
Adds an "dynamic implementation" for this function. `code` and `namespace` arguments are expected to be callables that will be called in `Network.before_run` with the owner of the `CodeObject` as an argument. This allows to generate code that depends on details of the context it is run in, e.g. the ``dt`` of a clock.
brian2/core/functions.py
add_dynamic_implementation
Ziaeemehr/brian2
python
def add_dynamic_implementation(self, target, code, namespace=None, dependencies=None, availability_check=None, name=None, compiler_kwds=None): '\n Adds an "dynamic implementation" for this function. `code` and `namespace`\n arguments are expected to be callables that will be called in\n `Networ...
def fdiff(self, argindex=1): '\n Returns the first derivative of this function.\n ' if (argindex == 1): return (((sympy.exp(*self.args) * (self.args[0] - S.One)) + S.One) / (self.args[0] ** 2)) else: raise sympy.ArgumentIndexError(self, argindex)
1,287,340,907,368,516,400
Returns the first derivative of this function.
brian2/core/functions.py
fdiff
Ziaeemehr/brian2
python
def fdiff(self, argindex=1): '\n \n ' if (argindex == 1): return (((sympy.exp(*self.args) * (self.args[0] - S.One)) + S.One) / (self.args[0] ** 2)) else: raise sympy.ArgumentIndexError(self, argindex)
def get_sentiment(instances_content): 'Analyzing Sentiment in a String\n\n Args:\n text_content The text content to analyze\n ' scores = [] client = language_v1.LanguageServiceClient() encoding_type = enums.EncodingType.UTF8 language = 'en' type_ = enums.Document.Type.PLAIN_TEXT ...
6,303,273,581,906,286,000
Analyzing Sentiment in a String Args: text_content The text content to analyze
notebooks/samples/tensorflow/sentiment_analysis/dataflow/PubSubToBigQueryWithAPI.py
get_sentiment
dlminvestments/ai-platform-samples
python
def get_sentiment(instances_content): 'Analyzing Sentiment in a String\n\n Args:\n text_content The text content to analyze\n ' scores = [] client = language_v1.LanguageServiceClient() encoding_type = enums.EncodingType.UTF8 language = 'en' type_ = enums.Document.Type.PLAIN_TEXT ...
def prediction_helper(messages): 'Processes PubSub messages and calls AI Platform prediction.\n\n :param messages:\n :return:\n ' if (not isinstance(messages, list)): messages = [messages] instances = list(map((lambda message: json.loads(message)), messages)) scores = get_sentiment([ins...
-5,345,835,277,603,021,000
Processes PubSub messages and calls AI Platform prediction. :param messages: :return:
notebooks/samples/tensorflow/sentiment_analysis/dataflow/PubSubToBigQueryWithAPI.py
prediction_helper
dlminvestments/ai-platform-samples
python
def prediction_helper(messages): 'Processes PubSub messages and calls AI Platform prediction.\n\n :param messages:\n :return:\n ' if (not isinstance(messages, list)): messages = [messages] instances = list(map((lambda message: json.loads(message)), messages)) scores = get_sentiment([ins...
def run(args, pipeline_args=None): 'Executes Pipeline.\n\n :param args:\n :param pipeline_args:\n :return:\n ' 'Build and run the pipeline.' pipeline_options = PipelineOptions(pipeline_args, streaming=True, save_main_session=True) pipeline_options.view_as(StandardOptions).runner = args.runne...
-7,893,245,789,689,544,000
Executes Pipeline. :param args: :param pipeline_args: :return:
notebooks/samples/tensorflow/sentiment_analysis/dataflow/PubSubToBigQueryWithAPI.py
run
dlminvestments/ai-platform-samples
python
def run(args, pipeline_args=None): 'Executes Pipeline.\n\n :param args:\n :param pipeline_args:\n :return:\n ' 'Build and run the pipeline.' pipeline_options = PipelineOptions(pipeline_args, streaming=True, save_main_session=True) pipeline_options.view_as(StandardOptions).runner = args.runne...
@staticmethod def process(element, publish_time=beam.DoFn.TimestampParam): 'Processes each incoming windowed element by extracting the Pub/Sub\n message and its publish timestamp into a dictionary. `publish_time`\n defaults to the publish timestamp returned by the Pub/Sub server. It\n is bound ...
-394,851,617,096,089,500
Processes each incoming windowed element by extracting the Pub/Sub message and its publish timestamp into a dictionary. `publish_time` defaults to the publish timestamp returned by the Pub/Sub server. It is bound to each element by Beam at runtime.
notebooks/samples/tensorflow/sentiment_analysis/dataflow/PubSubToBigQueryWithAPI.py
process
dlminvestments/ai-platform-samples
python
@staticmethod def process(element, publish_time=beam.DoFn.TimestampParam): 'Processes each incoming windowed element by extracting the Pub/Sub\n message and its publish timestamp into a dictionary. `publish_time`\n defaults to the publish timestamp returned by the Pub/Sub server. It\n is bound ...
def logp_ab(value): ' prior density' return tt.log(tt.pow(tt.sum(value), ((- 5) / 2)))
-8,962,368,835,196,094,000
prior density
scripts/hbayes_binom_rats_pymc3.py
logp_ab
NamDinhRobotics/pyprobml
python
def logp_ab(value): ' ' return tt.log(tt.pow(tt.sum(value), ((- 5) / 2)))
def test_help(self): 'Does the help display without error?' run_nbgrader(['export', '--help-all'])
-8,138,394,947,637,915,000
Does the help display without error?
nbgrader/tests/apps/test_nbgrader_export.py
test_help
FrattisUC/nbgrader
python
def test_help(self): run_nbgrader(['export', '--help-all'])
def __init__(self, loc, scale, low, high, validate_args=False, allow_nan_stats=True, name='TruncatedCauchy'): "Construct a TruncatedCauchy.\n\n All parameters of the distribution will be broadcast to the same shape,\n so the resulting distribution will have a batch_shape of the broadcast\n shape of all par...
4,228,639,656,235,631,600
Construct a TruncatedCauchy. All parameters of the distribution will be broadcast to the same shape, so the resulting distribution will have a batch_shape of the broadcast shape of all parameters. Args: loc: Floating point tensor; the modes of the corresponding non-truncated Cauchy distribution(s). scale: Flo...
tensorflow_probability/python/distributions/truncated_cauchy.py
__init__
jeffpollock9/probability
python
def __init__(self, loc, scale, low, high, validate_args=False, allow_nan_stats=True, name='TruncatedCauchy'): "Construct a TruncatedCauchy.\n\n All parameters of the distribution will be broadcast to the same shape,\n so the resulting distribution will have a batch_shape of the broadcast\n shape of all par...
def _redefines_import(node): 'Detect that the given node (AssignName) is inside an\n exception handler and redefines an import from the tryexcept body.\n Returns True if the node redefines an import, False otherwise.\n ' current = node while (current and (not isinstance(current.parent, astroid.Exce...
-3,549,627,939,768,581,000
Detect that the given node (AssignName) is inside an exception handler and redefines an import from the tryexcept body. Returns True if the node redefines an import, False otherwise.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_redefines_import
DiegoSilvaHoffmann/Small-Ecommerce
python
def _redefines_import(node): 'Detect that the given node (AssignName) is inside an\n exception handler and redefines an import from the tryexcept body.\n Returns True if the node redefines an import, False otherwise.\n ' current = node while (current and (not isinstance(current.parent, astroid.Exce...
def in_loop(node): 'return True if the node is inside a kind of for loop' parent = node.parent while (parent is not None): if isinstance(parent, (astroid.For, astroid.ListComp, astroid.SetComp, astroid.DictComp, astroid.GeneratorExp)): return True parent = parent.parent retur...
-8,813,213,378,525,552,000
return True if the node is inside a kind of for loop
venv/lib/python3.8/site-packages/pylint/checkers/base.py
in_loop
DiegoSilvaHoffmann/Small-Ecommerce
python
def in_loop(node): parent = node.parent while (parent is not None): if isinstance(parent, (astroid.For, astroid.ListComp, astroid.SetComp, astroid.DictComp, astroid.GeneratorExp)): return True parent = parent.parent return False
def in_nested_list(nested_list, obj): 'return true if the object is an element of <nested_list> or of a nested\n list\n ' for elmt in nested_list: if isinstance(elmt, (list, tuple)): if in_nested_list(elmt, obj): return True elif (elmt == obj): retur...
7,580,033,024,259,611,000
return true if the object is an element of <nested_list> or of a nested list
venv/lib/python3.8/site-packages/pylint/checkers/base.py
in_nested_list
DiegoSilvaHoffmann/Small-Ecommerce
python
def in_nested_list(nested_list, obj): 'return true if the object is an element of <nested_list> or of a nested\n list\n ' for elmt in nested_list: if isinstance(elmt, (list, tuple)): if in_nested_list(elmt, obj): return True elif (elmt == obj): retur...
def _get_break_loop_node(break_node): '\n Returns the loop node that holds the break node in arguments.\n\n Args:\n break_node (astroid.Break): the break node of interest.\n\n Returns:\n astroid.For or astroid.While: the loop node holding the break node.\n ' loop_nodes = (astroid.For, ...
-3,874,634,519,098,343,400
Returns the loop node that holds the break node in arguments. Args: break_node (astroid.Break): the break node of interest. Returns: astroid.For or astroid.While: the loop node holding the break node.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_get_break_loop_node
DiegoSilvaHoffmann/Small-Ecommerce
python
def _get_break_loop_node(break_node): '\n Returns the loop node that holds the break node in arguments.\n\n Args:\n break_node (astroid.Break): the break node of interest.\n\n Returns:\n astroid.For or astroid.While: the loop node holding the break node.\n ' loop_nodes = (astroid.For, ...
def _loop_exits_early(loop): '\n Returns true if a loop may ends up in a break statement.\n\n Args:\n loop (astroid.For, astroid.While): the loop node inspected.\n\n Returns:\n bool: True if the loop may ends up in a break statement, False otherwise.\n ' loop_nodes = (astroid.For, astr...
-294,256,959,147,377,340
Returns true if a loop may ends up in a break statement. Args: loop (astroid.For, astroid.While): the loop node inspected. Returns: bool: True if the loop may ends up in a break statement, False otherwise.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_loop_exits_early
DiegoSilvaHoffmann/Small-Ecommerce
python
def _loop_exits_early(loop): '\n Returns true if a loop may ends up in a break statement.\n\n Args:\n loop (astroid.For, astroid.While): the loop node inspected.\n\n Returns:\n bool: True if the loop may ends up in a break statement, False otherwise.\n ' loop_nodes = (astroid.For, astr...
def _get_properties(config): "Returns a tuple of property classes and names.\n\n Property classes are fully qualified, such as 'abc.abstractproperty' and\n property names are the actual names, such as 'abstract_property'.\n " property_classes = {BUILTIN_PROPERTY} property_names = set() if (conf...
-2,447,406,039,172,952,600
Returns a tuple of property classes and names. Property classes are fully qualified, such as 'abc.abstractproperty' and property names are the actual names, such as 'abstract_property'.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_get_properties
DiegoSilvaHoffmann/Small-Ecommerce
python
def _get_properties(config): "Returns a tuple of property classes and names.\n\n Property classes are fully qualified, such as 'abc.abstractproperty' and\n property names are the actual names, such as 'abstract_property'.\n " property_classes = {BUILTIN_PROPERTY} property_names = set() if (conf...
def _determine_function_name_type(node: astroid.FunctionDef, config=None): "Determine the name type whose regex the a function's name should match.\n\n :param node: A function node.\n :param config: Configuration from which to pull additional property classes.\n :type config: :class:`optparse.Values`\n\n ...
4,250,182,075,832,558,600
Determine the name type whose regex the a function's name should match. :param node: A function node. :param config: Configuration from which to pull additional property classes. :type config: :class:`optparse.Values` :returns: One of ('function', 'method', 'attr') :rtype: str
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_determine_function_name_type
DiegoSilvaHoffmann/Small-Ecommerce
python
def _determine_function_name_type(node: astroid.FunctionDef, config=None): "Determine the name type whose regex the a function's name should match.\n\n :param node: A function node.\n :param config: Configuration from which to pull additional property classes.\n :type config: :class:`optparse.Values`\n\n ...
def _has_abstract_methods(node): '\n Determine if the given `node` has abstract methods.\n\n The methods should be made abstract by decorating them\n with `abc` decorators.\n ' return (len(utils.unimplemented_abstract_methods(node)) > 0)
3,715,557,256,578,693,600
Determine if the given `node` has abstract methods. The methods should be made abstract by decorating them with `abc` decorators.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_has_abstract_methods
DiegoSilvaHoffmann/Small-Ecommerce
python
def _has_abstract_methods(node): '\n Determine if the given `node` has abstract methods.\n\n The methods should be made abstract by decorating them\n with `abc` decorators.\n ' return (len(utils.unimplemented_abstract_methods(node)) > 0)
def report_by_type_stats(sect, stats, old_stats): 'make a report of\n\n * percentage of different types documented\n * percentage of different types with a bad name\n ' nice_stats = {} for node_type in ('module', 'class', 'method', 'function'): try: total = stats[node_type] ...
7,206,156,904,805,886,000
make a report of * percentage of different types documented * percentage of different types with a bad name
venv/lib/python3.8/site-packages/pylint/checkers/base.py
report_by_type_stats
DiegoSilvaHoffmann/Small-Ecommerce
python
def report_by_type_stats(sect, stats, old_stats): 'make a report of\n\n * percentage of different types documented\n * percentage of different types with a bad name\n ' nice_stats = {} for node_type in ('module', 'class', 'method', 'function'): try: total = stats[node_type] ...
def redefined_by_decorator(node): 'return True if the object is a method redefined via decorator.\n\n For example:\n @property\n def x(self): return self._x\n @x.setter\n def x(self, value): self._x = value\n ' if node.decorators: for decorator in node.decorators.nodes:...
1,408,302,441,557,557,800
return True if the object is a method redefined via decorator. For example: @property def x(self): return self._x @x.setter def x(self, value): self._x = value
venv/lib/python3.8/site-packages/pylint/checkers/base.py
redefined_by_decorator
DiegoSilvaHoffmann/Small-Ecommerce
python
def redefined_by_decorator(node): 'return True if the object is a method redefined via decorator.\n\n For example:\n @property\n def x(self): return self._x\n @x.setter\n def x(self, value): self._x = value\n ' if node.decorators: for decorator in node.decorators.nodes:...
def _is_one_arg_pos_call(call): 'Is this a call with exactly 1 argument,\n where that argument is positional?\n ' return (isinstance(call, astroid.Call) and (len(call.args) == 1) and (not call.keywords))
2,640,663,257,080,729,600
Is this a call with exactly 1 argument, where that argument is positional?
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_is_one_arg_pos_call
DiegoSilvaHoffmann/Small-Ecommerce
python
def _is_one_arg_pos_call(call): 'Is this a call with exactly 1 argument,\n where that argument is positional?\n ' return (isinstance(call, astroid.Call) and (len(call.args) == 1) and (not call.keywords))
def register(linter): 'required method to auto register this checker' linter.register_checker(BasicErrorChecker(linter)) linter.register_checker(BasicChecker(linter)) linter.register_checker(NameChecker(linter)) linter.register_checker(DocStringChecker(linter)) linter.register_checker(PassChecke...
4,990,916,917,822,871,000
required method to auto register this checker
venv/lib/python3.8/site-packages/pylint/checkers/base.py
register
DiegoSilvaHoffmann/Small-Ecommerce
python
def register(linter): linter.register_checker(BasicErrorChecker(linter)) linter.register_checker(BasicChecker(linter)) linter.register_checker(NameChecker(linter)) linter.register_checker(DocStringChecker(linter)) linter.register_checker(PassChecker(linter)) linter.register_checker(Comparis...
@utils.check_messages('star-needs-assignment-target') def visit_starred(self, node): 'Check that a Starred expression is used in an assignment target.' if isinstance(node.parent, astroid.Call): return if isinstance(node.parent, (astroid.List, astroid.Tuple, astroid.Set, astroid.Dict)): retur...
-4,635,363,187,658,599,000
Check that a Starred expression is used in an assignment target.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_starred
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('star-needs-assignment-target') def visit_starred(self, node): if isinstance(node.parent, astroid.Call): return if isinstance(node.parent, (astroid.List, astroid.Tuple, astroid.Set, astroid.Dict)): return stmt = node.statement() if (not isinstance(stmt, astroid...
def _check_nonlocal_and_global(self, node): 'Check that a name is both nonlocal and global.' def same_scope(current): return (current.scope() is node) from_iter = itertools.chain.from_iterable nonlocals = set(from_iter((child.names for child in node.nodes_of_class(astroid.Nonlocal) if same_scop...
6,190,297,754,518,350,000
Check that a name is both nonlocal and global.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_nonlocal_and_global
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_nonlocal_and_global(self, node): def same_scope(current): return (current.scope() is node) from_iter = itertools.chain.from_iterable nonlocals = set(from_iter((child.names for child in node.nodes_of_class(astroid.Nonlocal) if same_scope(child)))) if (not nonlocals): retu...
@utils.check_messages('nonexistent-operator') def visit_unaryop(self, node): 'check use of the non-existent ++ and -- operator operator' if ((node.op in '+-') and isinstance(node.operand, astroid.UnaryOp) and (node.operand.op == node.op)): self.add_message('nonexistent-operator', node=node, args=(node.o...
6,697,742,082,378,500,000
check use of the non-existent ++ and -- operator operator
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_unaryop
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('nonexistent-operator') def visit_unaryop(self, node): if ((node.op in '+-') and isinstance(node.operand, astroid.UnaryOp) and (node.operand.op == node.op)): self.add_message('nonexistent-operator', node=node, args=(node.op * 2))
@utils.check_messages('abstract-class-instantiated') def visit_call(self, node): 'Check instantiating abstract class with\n abc.ABCMeta as metaclass.\n ' try: for inferred in node.func.infer(): self._check_inferred_class_is_abstract(inferred, node) except astroid.InferenceE...
2,693,506,591,139,922,400
Check instantiating abstract class with abc.ABCMeta as metaclass.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_call
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('abstract-class-instantiated') def visit_call(self, node): 'Check instantiating abstract class with\n abc.ABCMeta as metaclass.\n ' try: for inferred in node.func.infer(): self._check_inferred_class_is_abstract(inferred, node) except astroid.InferenceE...
def _check_else_on_loop(self, node): 'Check that any loop with an else clause has a break statement.' if (node.orelse and (not _loop_exits_early(node))): self.add_message('useless-else-on-loop', node=node, line=(node.orelse[0].lineno - 1))
7,660,603,101,913,394,000
Check that any loop with an else clause has a break statement.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_else_on_loop
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_else_on_loop(self, node): if (node.orelse and (not _loop_exits_early(node))): self.add_message('useless-else-on-loop', node=node, line=(node.orelse[0].lineno - 1))
def _check_in_loop(self, node, node_name): 'check that a node is inside a for or while loop' _node = node.parent while _node: if isinstance(_node, (astroid.For, astroid.While)): if (node not in _node.orelse): return if isinstance(_node, (astroid.ClassDef, astroid....
-3,765,741,054,601,940,000
check that a node is inside a for or while loop
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_in_loop
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_in_loop(self, node, node_name): _node = node.parent while _node: if isinstance(_node, (astroid.For, astroid.While)): if (node not in _node.orelse): return if isinstance(_node, (astroid.ClassDef, astroid.FunctionDef)): break if (isin...
def _check_redefinition(self, redeftype, node): 'check for redefinition of a function / method / class name' parent_frame = node.parent.frame() redefinitions = parent_frame.locals[node.name] defined_self = next((local for local in redefinitions if (not utils.is_overload_stub(local))), node) if ((def...
-2,833,623,817,500,763,600
check for redefinition of a function / method / class name
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_redefinition
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_redefinition(self, redeftype, node): parent_frame = node.parent.frame() redefinitions = parent_frame.locals[node.name] defined_self = next((local for local in redefinitions if (not utils.is_overload_stub(local))), node) if ((defined_self is not node) and (not astroid.are_exclusive(node, ...
def open(self): 'initialize visit variables and statistics' self._tryfinallys = [] self.stats = self.linter.add_stats(module=0, function=0, method=0, class_=0)
-7,120,917,450,056,130,000
initialize visit variables and statistics
venv/lib/python3.8/site-packages/pylint/checkers/base.py
open
DiegoSilvaHoffmann/Small-Ecommerce
python
def open(self): self._tryfinallys = [] self.stats = self.linter.add_stats(module=0, function=0, method=0, class_=0)
def visit_module(self, _): 'check module name, docstring and required arguments' self.stats['module'] += 1
-3,172,526,212,306,251,000
check module name, docstring and required arguments
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_module
DiegoSilvaHoffmann/Small-Ecommerce
python
def visit_module(self, _): self.stats['module'] += 1
def visit_classdef(self, node): 'check module name, docstring and redefinition\n increment branch counter\n ' self.stats['class'] += 1
6,323,541,644,900,864,000
check module name, docstring and redefinition increment branch counter
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_classdef
DiegoSilvaHoffmann/Small-Ecommerce
python
def visit_classdef(self, node): 'check module name, docstring and redefinition\n increment branch counter\n ' self.stats['class'] += 1
@utils.check_messages('pointless-statement', 'pointless-string-statement', 'expression-not-assigned') def visit_expr(self, node): 'Check for various kind of statements without effect' expr = node.value if (isinstance(expr, astroid.Const) and isinstance(expr.value, str)): scope = expr.scope() ...
3,617,991,756,477,993,000
Check for various kind of statements without effect
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_expr
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('pointless-statement', 'pointless-string-statement', 'expression-not-assigned') def visit_expr(self, node): expr = node.value if (isinstance(expr, astroid.Const) and isinstance(expr.value, str)): scope = expr.scope() if isinstance(scope, (astroid.ClassDef, astroid.Modu...
@utils.check_messages('unnecessary-lambda') def visit_lambda(self, node): 'check whether or not the lambda is suspicious' if node.args.defaults: return call = node.body if (not isinstance(call, astroid.Call)): return if (isinstance(node.body.func, astroid.Attribute) and isinstance(no...
-7,762,045,850,180,491,000
check whether or not the lambda is suspicious
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_lambda
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('unnecessary-lambda') def visit_lambda(self, node): if node.args.defaults: return call = node.body if (not isinstance(call, astroid.Call)): return if (isinstance(node.body.func, astroid.Attribute) and isinstance(node.body.func.expr, astroid.Call)): retu...
@utils.check_messages('dangerous-default-value') def visit_functiondef(self, node): 'check function name, docstring, arguments, redefinition,\n variable names, max locals\n ' self.stats[('method' if node.is_method() else 'function')] += 1 self._check_dangerous_default(node)
-5,048,651,208,268,462,000
check function name, docstring, arguments, redefinition, variable names, max locals
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_functiondef
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('dangerous-default-value') def visit_functiondef(self, node): 'check function name, docstring, arguments, redefinition,\n variable names, max locals\n ' self.stats[('method' if node.is_method() else 'function')] += 1 self._check_dangerous_default(node)
def _check_dangerous_default(self, node): 'Check for dangerous default values as arguments.' def is_iterable(internal_node): return isinstance(internal_node, (astroid.List, astroid.Set, astroid.Dict)) defaults = (node.args.defaults or ([] + node.args.kw_defaults) or []) for default in defaults:...
8,315,180,032,150,322,000
Check for dangerous default values as arguments.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_dangerous_default
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_dangerous_default(self, node): def is_iterable(internal_node): return isinstance(internal_node, (astroid.List, astroid.Set, astroid.Dict)) defaults = (node.args.defaults or ([] + node.args.kw_defaults) or []) for default in defaults: if (not default): continue ...
@utils.check_messages('unreachable', 'lost-exception') def visit_return(self, node): "1 - check is the node has a right sibling (if so, that's some\n unreachable code)\n 2 - check is the node is inside the finally clause of a try...finally\n block\n " self._check_unreachable(node) ...
-3,677,153,586,974,532,600
1 - check is the node has a right sibling (if so, that's some unreachable code) 2 - check is the node is inside the finally clause of a try...finally block
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_return
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('unreachable', 'lost-exception') def visit_return(self, node): "1 - check is the node has a right sibling (if so, that's some\n unreachable code)\n 2 - check is the node is inside the finally clause of a try...finally\n block\n " self._check_unreachable(node) ...
@utils.check_messages('unreachable') def visit_continue(self, node): "check is the node has a right sibling (if so, that's some unreachable\n code)\n " self._check_unreachable(node)
-4,721,979,628,514,516,000
check is the node has a right sibling (if so, that's some unreachable code)
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_continue
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('unreachable') def visit_continue(self, node): "check is the node has a right sibling (if so, that's some unreachable\n code)\n " self._check_unreachable(node)
@utils.check_messages('unreachable', 'lost-exception') def visit_break(self, node): "1 - check is the node has a right sibling (if so, that's some\n unreachable code)\n 2 - check is the node is inside the finally clause of a try...finally\n block\n " self._check_unreachable(node) ...
-2,772,419,799,165,416,400
1 - check is the node has a right sibling (if so, that's some unreachable code) 2 - check is the node is inside the finally clause of a try...finally block
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_break
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('unreachable', 'lost-exception') def visit_break(self, node): "1 - check is the node has a right sibling (if so, that's some\n unreachable code)\n 2 - check is the node is inside the finally clause of a try...finally\n block\n " self._check_unreachable(node) ...
@utils.check_messages('unreachable') def visit_raise(self, node): "check if the node has a right sibling (if so, that's some unreachable\n code)\n " self._check_unreachable(node)
-6,611,969,601,107,533,000
check if the node has a right sibling (if so, that's some unreachable code)
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_raise
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('unreachable') def visit_raise(self, node): "check if the node has a right sibling (if so, that's some unreachable\n code)\n " self._check_unreachable(node)
@utils.check_messages('exec-used') def visit_exec(self, node): 'just print a warning on exec statements' self.add_message('exec-used', node=node)
-7,449,857,530,318,227,000
just print a warning on exec statements
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_exec
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('exec-used') def visit_exec(self, node): self.add_message('exec-used', node=node)
@utils.check_messages('eval-used', 'exec-used', 'bad-reversed-sequence', 'misplaced-format-function') def visit_call(self, node): 'visit a Call node -> check if this is not a disallowed builtin\n call and check for * or ** use\n ' self._check_misplaced_format_function(node) if isinstance(node....
-3,051,920,367,229,449,000
visit a Call node -> check if this is not a disallowed builtin call and check for * or ** use
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_call
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('eval-used', 'exec-used', 'bad-reversed-sequence', 'misplaced-format-function') def visit_call(self, node): 'visit a Call node -> check if this is not a disallowed builtin\n call and check for * or ** use\n ' self._check_misplaced_format_function(node) if isinstance(node....
@utils.check_messages('assert-on-tuple', 'assert-on-string-literal') def visit_assert(self, node): 'check whether assert is used on a tuple or string literal.' if ((node.fail is None) and isinstance(node.test, astroid.Tuple) and (len(node.test.elts) == 2)): self.add_message('assert-on-tuple', node=node)...
5,528,318,846,618,252,000
check whether assert is used on a tuple or string literal.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_assert
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('assert-on-tuple', 'assert-on-string-literal') def visit_assert(self, node): if ((node.fail is None) and isinstance(node.test, astroid.Tuple) and (len(node.test.elts) == 2)): self.add_message('assert-on-tuple', node=node) if (isinstance(node.test, astroid.Const) and isinstance...
@utils.check_messages('duplicate-key') def visit_dict(self, node): 'check duplicate key in dictionary' keys = set() for (k, _) in node.items: if isinstance(k, astroid.Const): key = k.value if (key in keys): self.add_message('duplicate-key', node=node, args=key...
7,305,081,576,754,378,000
check duplicate key in dictionary
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_dict
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('duplicate-key') def visit_dict(self, node): keys = set() for (k, _) in node.items: if isinstance(k, astroid.Const): key = k.value if (key in keys): self.add_message('duplicate-key', node=node, args=key) keys.add(key)
def visit_tryfinally(self, node): 'update try...finally flag' self._tryfinallys.append(node)
567,963,392,912,776,770
update try...finally flag
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_tryfinally
DiegoSilvaHoffmann/Small-Ecommerce
python
def visit_tryfinally(self, node): self._tryfinallys.append(node)
def leave_tryfinally(self, node): 'update try...finally flag' self._tryfinallys.pop()
3,084,186,197,470,985,000
update try...finally flag
venv/lib/python3.8/site-packages/pylint/checkers/base.py
leave_tryfinally
DiegoSilvaHoffmann/Small-Ecommerce
python
def leave_tryfinally(self, node): self._tryfinallys.pop()
def _check_unreachable(self, node): 'check unreachable code' unreach_stmt = node.next_sibling() if (unreach_stmt is not None): self.add_message('unreachable', node=unreach_stmt)
-4,818,121,943,211,807,000
check unreachable code
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_unreachable
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_unreachable(self, node): unreach_stmt = node.next_sibling() if (unreach_stmt is not None): self.add_message('unreachable', node=unreach_stmt)
def _check_not_in_finally(self, node, node_name, breaker_classes=()): 'check that a node is not inside a finally clause of a\n try...finally statement.\n If we found before a try...finally bloc a parent which its type is\n in breaker_classes, we skip the whole check.' if (not self._tryfinal...
6,710,553,124,971,190,000
check that a node is not inside a finally clause of a try...finally statement. If we found before a try...finally bloc a parent which its type is in breaker_classes, we skip the whole check.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_not_in_finally
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_not_in_finally(self, node, node_name, breaker_classes=()): 'check that a node is not inside a finally clause of a\n try...finally statement.\n If we found before a try...finally bloc a parent which its type is\n in breaker_classes, we skip the whole check.' if (not self._tryfinal...
def _check_reversed(self, node): 'check that the argument to `reversed` is a sequence' try: argument = utils.safe_infer(utils.get_argument_from_call(node, position=0)) except utils.NoSuchArgumentError: pass else: if (argument is astroid.Uninferable): return if...
-442,172,745,389,106,800
check that the argument to `reversed` is a sequence
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_reversed
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_reversed(self, node): try: argument = utils.safe_infer(utils.get_argument_from_call(node, position=0)) except utils.NoSuchArgumentError: pass else: if (argument is astroid.Uninferable): return if (argument is None): if isinstance(node.a...
@utils.check_messages('disallowed-name', 'invalid-name', 'assign-to-new-keyword', 'non-ascii-name') def visit_assignname(self, node): 'check module level assigned names' self._check_assign_to_new_keyword_violation(node.name, node) frame = node.frame() assign_type = node.assign_type() if isinstance(a...
-4,169,838,064,300,232,000
check module level assigned names
venv/lib/python3.8/site-packages/pylint/checkers/base.py
visit_assignname
DiegoSilvaHoffmann/Small-Ecommerce
python
@utils.check_messages('disallowed-name', 'invalid-name', 'assign-to-new-keyword', 'non-ascii-name') def visit_assignname(self, node): self._check_assign_to_new_keyword_violation(node.name, node) frame = node.frame() assign_type = node.assign_type() if isinstance(assign_type, astroid.Comprehension):...
def _recursive_check_names(self, args, node): 'check names in a possibly recursive list <arg>' for arg in args: if isinstance(arg, astroid.AssignName): self._check_name('argument', arg.name, node) else: self._recursive_check_names(arg.elts, node)
-4,889,120,403,578,327,000
check names in a possibly recursive list <arg>
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_recursive_check_names
DiegoSilvaHoffmann/Small-Ecommerce
python
def _recursive_check_names(self, args, node): for arg in args: if isinstance(arg, astroid.AssignName): self._check_name('argument', arg.name, node) else: self._recursive_check_names(arg.elts, node)
def _check_name(self, node_type, name, node, confidence=interfaces.HIGH): "check for a name using the type's regexp" non_ascii_match = self._non_ascii_rgx_compiled.match(name) if (non_ascii_match is not None): self._raise_name_warning(node, node_type, name, confidence, warning='non-ascii-name') ...
-4,220,091,793,548,102,700
check for a name using the type's regexp
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_name
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_name(self, node_type, name, node, confidence=interfaces.HIGH): non_ascii_match = self._non_ascii_rgx_compiled.match(name) if (non_ascii_match is not None): self._raise_name_warning(node, node_type, name, confidence, warning='non-ascii-name') def _should_exempt_from_invalid_name(node...
def _check_docstring(self, node_type, node, report_missing=True, confidence=interfaces.HIGH): 'check the node has a non empty docstring' docstring = node.doc if (docstring is None): docstring = _infer_dunder_doc_attribute(node) if (docstring is None): if (not report_missing): ...
691,359,148,964,642,600
check the node has a non empty docstring
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_docstring
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_docstring(self, node_type, node, report_missing=True, confidence=interfaces.HIGH): docstring = node.doc if (docstring is None): docstring = _infer_dunder_doc_attribute(node) if (docstring is None): if (not report_missing): return lines = (utils.get_node_la...
def _check_singleton_comparison(self, left_value, right_value, root_node, checking_for_absence: bool=False): 'Check if == or != is being used to compare a singleton value' singleton_values = (True, False, None) def _is_singleton_const(node) -> bool: return (isinstance(node, astroid.Const) and any((...
3,666,883,644,392,001,500
Check if == or != is being used to compare a singleton value
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_singleton_comparison
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_singleton_comparison(self, left_value, right_value, root_node, checking_for_absence: bool=False): singleton_values = (True, False, None) def _is_singleton_const(node) -> bool: return (isinstance(node, astroid.Const) and any(((node.value is value) for value in singleton_values))) if ...
def _check_literal_comparison(self, literal, node): 'Check if we compare to a literal, which is usually what we do not want to do.' nodes = (astroid.List, astroid.Tuple, astroid.Dict, astroid.Set) is_other_literal = isinstance(literal, nodes) is_const = False if isinstance(literal, astroid.Const): ...
-3,776,770,463,105,765,000
Check if we compare to a literal, which is usually what we do not want to do.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_literal_comparison
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_literal_comparison(self, literal, node): nodes = (astroid.List, astroid.Tuple, astroid.Dict, astroid.Set) is_other_literal = isinstance(literal, nodes) is_const = False if isinstance(literal, astroid.Const): if (isinstance(literal.value, bool) or (literal.value is None)): ...
def _check_logical_tautology(self, node): 'Check if identifier is compared against itself.\n :param node: Compare node\n :type node: astroid.node_classes.Compare\n :Example:\n val = 786\n if val == val: # [comparison-with-itself]\n pass\n ' left_operand = no...
6,435,169,647,564,362,000
Check if identifier is compared against itself. :param node: Compare node :type node: astroid.node_classes.Compare :Example: val = 786 if val == val: # [comparison-with-itself] pass
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_logical_tautology
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_logical_tautology(self, node): 'Check if identifier is compared against itself.\n :param node: Compare node\n :type node: astroid.node_classes.Compare\n :Example:\n val = 786\n if val == val: # [comparison-with-itself]\n pass\n ' left_operand = no...
def _check_type_x_is_y(self, node, left, operator, right): 'Check for expressions like type(x) == Y.' left_func = utils.safe_infer(left.func) if (not (isinstance(left_func, astroid.ClassDef) and (left_func.qname() == TYPE_QNAME))): return if ((operator in ('is', 'is not')) and _is_one_arg_pos_ca...
274,070,324,776,431,300
Check for expressions like type(x) == Y.
venv/lib/python3.8/site-packages/pylint/checkers/base.py
_check_type_x_is_y
DiegoSilvaHoffmann/Small-Ecommerce
python
def _check_type_x_is_y(self, node, left, operator, right): left_func = utils.safe_infer(left.func) if (not (isinstance(left_func, astroid.ClassDef) and (left_func.qname() == TYPE_QNAME))): return if ((operator in ('is', 'is not')) and _is_one_arg_pos_call(right)): right_func = utils.saf...
def send(self, inbox, data, **kwargs): 'Send the provided data to an inbox.' if (isinstance(data, dict) or isinstance(data, list)): self.__post_message(inbox, json.dumps(data), self.JSON_LD, **kwargs) elif isinstance(data, str): self.__post_message(inbox, data, self.JSON_LD, **kwargs) el...
3,203,947,373,159,349,000
Send the provided data to an inbox.
ldnlib/sender.py
send
trellis-ldp/py-ldn
python
def send(self, inbox, data, **kwargs): if (isinstance(data, dict) or isinstance(data, list)): self.__post_message(inbox, json.dumps(data), self.JSON_LD, **kwargs) elif isinstance(data, str): self.__post_message(inbox, data, self.JSON_LD, **kwargs) elif isinstance(data, Graph): c...
def __init__(self, username=None, password=None, sharedKey=None, certChain=None, privateKey=None, cryptoID=None, protocol=None, x509Fingerprint=None, x509TrustList=None, x509CommonName=None, settings=None): "\n For client authentication, use one of these argument\n combinations:\n - username, ...
-42,145,672,005,571,300
For client authentication, use one of these argument combinations: - username, password (SRP) - username, sharedKey (shared-key) - certChain, privateKey (certificate) For server authentication, you can either rely on the implicit mutual authentication performed by SRP or shared-keys, or you can do certificate-based...
third_party/tlslite/tlslite/integration/ClientHelper.py
__init__
1065672644894730302/Chromium
python
def __init__(self, username=None, password=None, sharedKey=None, certChain=None, privateKey=None, cryptoID=None, protocol=None, x509Fingerprint=None, x509TrustList=None, x509CommonName=None, settings=None): "\n For client authentication, use one of these argument\n combinations:\n - username, ...
def get_graph_embedding_args(graph_embedding_name): '\n It will build the template for ``GNNBase`` model.\n Parameters\n ----------\n graph_embedding_name: str\n The graph embedding name. Expected in ["gcn", "gat", "graphsage", "ggnn"].\n If it can\'t find the ``graph_embedding_name``,...
-8,607,500,043,819,556,000
It will build the template for ``GNNBase`` model. Parameters ---------- graph_embedding_name: str The graph embedding name. Expected in ["gcn", "gat", "graphsage", "ggnn"]. If it can't find the ``graph_embedding_name``, it will return ``{}``. Returns ------- template_dict: dict The template dict. The st...
graph4nlp/pytorch/modules/config/graph_embedding/__init__.py
get_graph_embedding_args
RyanWangZf/graph4nlp
python
def get_graph_embedding_args(graph_embedding_name): '\n It will build the template for ``GNNBase`` model.\n Parameters\n ----------\n graph_embedding_name: str\n The graph embedding name. Expected in ["gcn", "gat", "graphsage", "ggnn"].\n If it can\'t find the ``graph_embedding_name``,...
def select_lines(infile, contrast, lines, res_dict, fits_dict, wloc, outfil): '\n displays new window with image infile + start + \'fit\n a rectangle around the selected line can be selected with dragging the mouse\n :param infile: filebase of image\n :param contrast: brightness of image\n :param lin...
-2,950,692,695,651,559,000
displays new window with image infile + start + 'fit a rectangle around the selected line can be selected with dragging the mouse :param infile: filebase of image :param contrast: brightness of image :param lines: list of calibration wavelengths :param res_dict: dictionary :param fits_dict: " :param wloc: location of d...
myselect.py
select_lines
meteorspectroscopy/meteor-spectrum-calibration
python
def select_lines(infile, contrast, lines, res_dict, fits_dict, wloc, outfil): '\n displays new window with image infile + start + \'fit\n a rectangle around the selected line can be selected with dragging the mouse\n :param infile: filebase of image\n :param contrast: brightness of image\n :param lin...
def x(self, q): 'Apply X to q.' if isinstance(q, QuantumRegister): gs = InstructionSet() for j in range(q.size): gs.add(self.x((q, j))) return gs else: self._check_qubit(q) return self._attach(XGate(q, self))
8,371,005,246,915,321,000
Apply X to q.
qiskit/extensions/standard/x.py
x
NickyBar/QIP
python
def x(self, q): if isinstance(q, QuantumRegister): gs = InstructionSet() for j in range(q.size): gs.add(self.x((q, j))) return gs else: self._check_qubit(q) return self._attach(XGate(q, self))
def __init__(self, qubit, circ=None): 'Create new X gate.' super(XGate, self).__init__('x', [], [qubit], circ)
5,263,243,722,909,014,000
Create new X gate.
qiskit/extensions/standard/x.py
__init__
NickyBar/QIP
python
def __init__(self, qubit, circ=None): super(XGate, self).__init__('x', [], [qubit], circ)
def qasm(self): 'Return OPENQASM string.' qubit = self.arg[0] return self._qasmif(('x %s[%d];' % (qubit[0].name, qubit[1])))
-1,905,868,184,292,392,400
Return OPENQASM string.
qiskit/extensions/standard/x.py
qasm
NickyBar/QIP
python
def qasm(self): qubit = self.arg[0] return self._qasmif(('x %s[%d];' % (qubit[0].name, qubit[1])))
def inverse(self): 'Invert this gate.' return self
6,634,723,205,442,282,000
Invert this gate.
qiskit/extensions/standard/x.py
inverse
NickyBar/QIP
python
def inverse(self): return self
def reapply(self, circ): 'Reapply this gate to corresponding qubits in circ.' self._modifiers(circ.x(self.arg[0]))
3,164,904,002,953,134,600
Reapply this gate to corresponding qubits in circ.
qiskit/extensions/standard/x.py
reapply
NickyBar/QIP
python
def reapply(self, circ): self._modifiers(circ.x(self.arg[0]))
def __init__(self, **kwargs): '\n Initializes a new ScheduleSecretDeletionDetails object with values from keyword arguments.\n The following keyword arguments are supported (corresponding to the getters/setters of this class):\n\n :param time_of_deletion:\n The value to assign to the...
-6,563,169,429,261,355,000
Initializes a new ScheduleSecretDeletionDetails object with values from keyword arguments. The following keyword arguments are supported (corresponding to the getters/setters of this class): :param time_of_deletion: The value to assign to the time_of_deletion property of this ScheduleSecretDeletionDetails. :type t...
darling_ansible/python_venv/lib/python3.7/site-packages/oci/vault/models/schedule_secret_deletion_details.py
__init__
revnav/sandbox
python
def __init__(self, **kwargs): '\n Initializes a new ScheduleSecretDeletionDetails object with values from keyword arguments.\n The following keyword arguments are supported (corresponding to the getters/setters of this class):\n\n :param time_of_deletion:\n The value to assign to the...
@property def time_of_deletion(self): '\n Gets the time_of_deletion of this ScheduleSecretDeletionDetails.\n An optional property indicating when to delete the secret version, expressed in `RFC 3339`__ timestamp format.\n\n __ https://tools.ietf.org/html/rfc3339\n\n\n :return: The time_o...
-1,340,899,249,621,529,900
Gets the time_of_deletion of this ScheduleSecretDeletionDetails. An optional property indicating when to delete the secret version, expressed in `RFC 3339`__ timestamp format. __ https://tools.ietf.org/html/rfc3339 :return: The time_of_deletion of this ScheduleSecretDeletionDetails. :rtype: datetime
darling_ansible/python_venv/lib/python3.7/site-packages/oci/vault/models/schedule_secret_deletion_details.py
time_of_deletion
revnav/sandbox
python
@property def time_of_deletion(self): '\n Gets the time_of_deletion of this ScheduleSecretDeletionDetails.\n An optional property indicating when to delete the secret version, expressed in `RFC 3339`__ timestamp format.\n\n __ https://tools.ietf.org/html/rfc3339\n\n\n :return: The time_o...
@time_of_deletion.setter def time_of_deletion(self, time_of_deletion): '\n Sets the time_of_deletion of this ScheduleSecretDeletionDetails.\n An optional property indicating when to delete the secret version, expressed in `RFC 3339`__ timestamp format.\n\n __ https://tools.ietf.org/html/rfc3339...
5,927,719,153,223,761,000
Sets the time_of_deletion of this ScheduleSecretDeletionDetails. An optional property indicating when to delete the secret version, expressed in `RFC 3339`__ timestamp format. __ https://tools.ietf.org/html/rfc3339 :param time_of_deletion: The time_of_deletion of this ScheduleSecretDeletionDetails. :type: datetime
darling_ansible/python_venv/lib/python3.7/site-packages/oci/vault/models/schedule_secret_deletion_details.py
time_of_deletion
revnav/sandbox
python
@time_of_deletion.setter def time_of_deletion(self, time_of_deletion): '\n Sets the time_of_deletion of this ScheduleSecretDeletionDetails.\n An optional property indicating when to delete the secret version, expressed in `RFC 3339`__ timestamp format.\n\n __ https://tools.ietf.org/html/rfc3339...
def laplacian(csgraph, normed=False, return_diag=False): ' Return the Laplacian matrix of a directed graph.\n\n For non-symmetric graphs the out-degree is used in the computation.\n\n Parameters\n ----------\n csgraph : array_like or sparse matrix, 2 dimensions\n compressed-sparse graph, with sha...
-3,602,810,525,153,279,000
Return the Laplacian matrix of a directed graph. For non-symmetric graphs the out-degree is used in the computation. Parameters ---------- csgraph : array_like or sparse matrix, 2 dimensions compressed-sparse graph, with shape (N, N). normed : bool, optional If True, then compute normalized Laplacian. return_...
docker_version/resources/usr/local/lib/python2.7/dist-packages/scipy/sparse/csgraph/_laplacian.py
laplacian
animesh/parliament2
python
def laplacian(csgraph, normed=False, return_diag=False): ' Return the Laplacian matrix of a directed graph.\n\n For non-symmetric graphs the out-degree is used in the computation.\n\n Parameters\n ----------\n csgraph : array_like or sparse matrix, 2 dimensions\n compressed-sparse graph, with sha...
@classmethod def _dict_to_obj(cls, json_dict): 'Override dict_to_obj implementation' obj = cls._map_values_to_kwargs(json_dict) for key in obj.kwargs: obj.kwargs[key] = BandwidthInterface._dict_to_obj(obj.kwargs[key]) if obj.private: obj.private = BandwidthInterface._dict_to_obj(obj.priv...
3,527,210,701,742,197,000
Override dict_to_obj implementation
cloudcafe/events/models/compute/common.py
_dict_to_obj
kurhula/cloudcafe
python
@classmethod def _dict_to_obj(cls, json_dict): obj = cls._map_values_to_kwargs(json_dict) for key in obj.kwargs: obj.kwargs[key] = BandwidthInterface._dict_to_obj(obj.kwargs[key]) if obj.private: obj.private = BandwidthInterface._dict_to_obj(obj.private) if obj.public: obj.p...
def testNumber(self): 'Use a number.' self.assertEqual((i18n.twntranslate('de', 'test-plural', 0) % {'num': 0}), u'Bot: Ändere 0 Seiten.') self.assertEqual((i18n.twntranslate('de', 'test-plural', 1) % {'num': 1}), u'Bot: Ändere 1 Seite.') self.assertEqual((i18n.twntranslate('de', 'test-plural', 2) % {'n...
-6,116,252,089,283,957,000
Use a number.
tests/i18n_tests.py
testNumber
xZise/pywikibot-core
python
def testNumber(self): self.assertEqual((i18n.twntranslate('de', 'test-plural', 0) % {'num': 0}), u'Bot: Ändere 0 Seiten.') self.assertEqual((i18n.twntranslate('de', 'test-plural', 1) % {'num': 1}), u'Bot: Ändere 1 Seite.') self.assertEqual((i18n.twntranslate('de', 'test-plural', 2) % {'num': 2}), u'Bot...
def testString(self): 'Use a string.' self.assertEqual((i18n.twntranslate('en', 'test-plural', '1') % {'num': 'one'}), u'Bot: Changing one page.')
-9,027,707,513,875,948,000
Use a string.
tests/i18n_tests.py
testString
xZise/pywikibot-core
python
def testString(self): self.assertEqual((i18n.twntranslate('en', 'test-plural', '1') % {'num': 'one'}), u'Bot: Changing one page.')
def testDict(self): 'Use a dictionary.' self.assertEqual(i18n.twntranslate('en', 'test-plural', {'num': 2}), u'Bot: Changing 2 pages.')
3,638,274,504,369,245,700
Use a dictionary.
tests/i18n_tests.py
testDict
xZise/pywikibot-core
python
def testDict(self): self.assertEqual(i18n.twntranslate('en', 'test-plural', {'num': 2}), u'Bot: Changing 2 pages.')
def testExtended(self): 'Use additional format strings.' self.assertEqual(i18n.twntranslate('fr', 'test-plural', {'num': 1, 'descr': 'seulement'}), u'Robot: Changer seulement une page.')
8,598,923,295,161,366,000
Use additional format strings.
tests/i18n_tests.py
testExtended
xZise/pywikibot-core
python
def testExtended(self): self.assertEqual(i18n.twntranslate('fr', 'test-plural', {'num': 1, 'descr': 'seulement'}), u'Robot: Changer seulement une page.')
def testExtendedOutside(self): 'Use additional format strings also outside.' self.assertEqual((i18n.twntranslate('fr', 'test-plural', 1) % {'descr': 'seulement'}), u'Robot: Changer seulement une page.')
182,762,766,881,581,250
Use additional format strings also outside.
tests/i18n_tests.py
testExtendedOutside
xZise/pywikibot-core
python
def testExtendedOutside(self): self.assertEqual((i18n.twntranslate('fr', 'test-plural', 1) % {'descr': 'seulement'}), u'Robot: Changer seulement une page.')
def testMultipleWrongParameterLength(self): 'Test wrong parameter length.' with self.assertRaisesRegex(ValueError, 'Length of parameter does not match PLURAL occurrences'): self.assertEqual((i18n.twntranslate('de', 'test-multiple-plurals', (1, 2)) % {'action': u'Ändere', 'line': u'drei'}), u'Bot: Ändere...
3,387,738,654,253,292,000
Test wrong parameter length.
tests/i18n_tests.py
testMultipleWrongParameterLength
xZise/pywikibot-core
python
def testMultipleWrongParameterLength(self): with self.assertRaisesRegex(ValueError, 'Length of parameter does not match PLURAL occurrences'): self.assertEqual((i18n.twntranslate('de', 'test-multiple-plurals', (1, 2)) % {'action': u'Ändere', 'line': u'drei'}), u'Bot: Ändere drei Zeilen von mehreren Seit...
def testMultipleNonNumbers(self): 'Test error handling for multiple non-numbers.' with self.assertRaisesRegex(ValueError, "invalid literal for int\\(\\) with base 10: 'drei'"): self.assertEqual((i18n.twntranslate('de', 'test-multiple-plurals', ['drei', '1', 1]) % {'action': u'Ändere', 'line': u'drei'}),...
-1,921,360,065,697,760,500
Test error handling for multiple non-numbers.
tests/i18n_tests.py
testMultipleNonNumbers
xZise/pywikibot-core
python
def testMultipleNonNumbers(self): with self.assertRaisesRegex(ValueError, "invalid literal for int\\(\\) with base 10: 'drei'"): self.assertEqual((i18n.twntranslate('de', 'test-multiple-plurals', ['drei', '1', 1]) % {'action': u'Ändere', 'line': u'drei'}), u'Bot: Ändere drei Zeilen von einer Seite.') ...
def test_fallback_lang(self): "\n Test that twntranslate uses the translation's language.\n\n twntranslate calls _twtranslate which might return the translation for\n a different language and then the plural rules from that language need\n to be applied.\n " assert ('co' not i...
767,523,222,211,064,200
Test that twntranslate uses the translation's language. twntranslate calls _twtranslate which might return the translation for a different language and then the plural rules from that language need to be applied.
tests/i18n_tests.py
test_fallback_lang
xZise/pywikibot-core
python
def test_fallback_lang(self): "\n Test that twntranslate uses the translation's language.\n\n twntranslate calls _twtranslate which might return the translation for\n a different language and then the plural rules from that language need\n to be applied.\n " assert ('co' not i...
def test_basic(self): 'Verify that real messages are able to be loaded.' self.assertEqual(i18n.twntranslate('en', 'pywikibot-enter-new-text'), 'Please enter the new text:')
-1,621,876,870,489,097,700
Verify that real messages are able to be loaded.
tests/i18n_tests.py
test_basic
xZise/pywikibot-core
python
def test_basic(self): self.assertEqual(i18n.twntranslate('en', 'pywikibot-enter-new-text'), 'Please enter the new text:')
def test_missing(self): 'Test a missing message from a real message bundle.' self.assertRaises(i18n.TranslationError, i18n.twntranslate, 'en', 'pywikibot-missing-key')
5,642,107,501,364,760,000
Test a missing message from a real message bundle.
tests/i18n_tests.py
test_missing
xZise/pywikibot-core
python
def test_missing(self): self.assertRaises(i18n.TranslationError, i18n.twntranslate, 'en', 'pywikibot-missing-key')
def test_pagegen_i18n_input(self): 'Test i18n.input via .' result = self._execute(args=['listpages', '-cat'], data_in='non-existant-category\n', timeout=5) self.assertIn('Please enter the category name:', result['stderr'])
2,966,842,142,429,970,000
Test i18n.input via .
tests/i18n_tests.py
test_pagegen_i18n_input
xZise/pywikibot-core
python
def test_pagegen_i18n_input(self): result = self._execute(args=['listpages', '-cat'], data_in='non-existant-category\n', timeout=5) self.assertIn('Please enter the category name:', result['stderr'])
def test_pagegen_i18n_input(self): 'Test i18n.input falls back with missing message package.' rv = i18n.input('pywikibot-enter-category-name', fallback_prompt='dummy output') self.assertEqual(rv, 'dummy input') self.assertIn('dummy output: ', self.output_text)
1,770,211,232,122,889,700
Test i18n.input falls back with missing message package.
tests/i18n_tests.py
test_pagegen_i18n_input
xZise/pywikibot-core
python
def test_pagegen_i18n_input(self): rv = i18n.input('pywikibot-enter-category-name', fallback_prompt='dummy output') self.assertEqual(rv, 'dummy input') self.assertIn('dummy output: ', self.output_text)
def __init__(self, destination): '\n :param destination:\n ' self.__destination = destination
5,229,528,130,363,022,000
:param destination:
pv_simulator/CSVFileWriter.py
__init__
Shifuddin/PV-Simulator-Challenge
python
def __init__(self, destination): '\n \n ' self.__destination = destination
async def write(self, timestamp: datetime, meter_power_value: int, simulator_power_value: int, combined_power_value: int) -> None: '\n Writes values into a csv file\n :param timestamp:\n :param meter_power_value:\n :param simulator_power_value:\n :param combined_power_value:\n ...
5,507,098,978,224,734,000
Writes values into a csv file :param timestamp: :param meter_power_value: :param simulator_power_value: :param combined_power_value: :return:
pv_simulator/CSVFileWriter.py
write
Shifuddin/PV-Simulator-Challenge
python
async def write(self, timestamp: datetime, meter_power_value: int, simulator_power_value: int, combined_power_value: int) -> None: '\n Writes values into a csv file\n :param timestamp:\n :param meter_power_value:\n :param simulator_power_value:\n :param combined_power_value:\n ...
def print_path(path): 'Print path.' txt = path if os.path.isdir(path): txt += '/' if os.path.islink(path): txt += (' -> ' + os.readlink(path)) print(txt)
2,459,191,363,358,521,300
Print path.
tests/integration/test_data_finder.py
print_path
Peter9192/ESMValCore
python
def print_path(path): txt = path if os.path.isdir(path): txt += '/' if os.path.islink(path): txt += (' -> ' + os.readlink(path)) print(txt)
def tree(path): 'Print path, similar to the the `tree` command.' print_path(path) for (dirpath, dirnames, filenames) in os.walk(path): for dirname in dirnames: print_path(os.path.join(dirpath, dirname)) for filename in filenames: print_path(os.path.join(dirpath, filen...
-3,290,092,247,751,938,000
Print path, similar to the the `tree` command.
tests/integration/test_data_finder.py
tree
Peter9192/ESMValCore
python
def tree(path): print_path(path) for (dirpath, dirnames, filenames) in os.walk(path): for dirname in dirnames: print_path(os.path.join(dirpath, dirname)) for filename in filenames: print_path(os.path.join(dirpath, filename))
def create_file(filename): 'Create an empty file.' dirname = os.path.dirname(filename) if (not os.path.exists(dirname)): os.makedirs(dirname) with open(filename, 'a'): pass
5,985,060,040,766,657,000
Create an empty file.
tests/integration/test_data_finder.py
create_file
Peter9192/ESMValCore
python
def create_file(filename): dirname = os.path.dirname(filename) if (not os.path.exists(dirname)): os.makedirs(dirname) with open(filename, 'a'): pass
def create_tree(path, filenames=None, symlinks=None): 'Create directory structure and files.' for filename in (filenames or []): create_file(os.path.join(path, filename)) for symlink in (symlinks or []): link_name = os.path.join(path, symlink['link_name']) os.symlink(symlink['target'...
9,095,353,352,991,750,000
Create directory structure and files.
tests/integration/test_data_finder.py
create_tree
Peter9192/ESMValCore
python
def create_tree(path, filenames=None, symlinks=None): for filename in (filenames or []): create_file(os.path.join(path, filename)) for symlink in (symlinks or []): link_name = os.path.join(path, symlink['link_name']) os.symlink(symlink['target'], link_name)
@pytest.mark.parametrize('cfg', CONFIG['get_output_file']) def test_get_output_file(cfg): 'Test getting output name for preprocessed files.' output_file = get_output_file(cfg['variable'], cfg['preproc_dir']) assert (output_file == cfg['output_file'])
-7,210,884,641,818,079,000
Test getting output name for preprocessed files.
tests/integration/test_data_finder.py
test_get_output_file
Peter9192/ESMValCore
python
@pytest.mark.parametrize('cfg', CONFIG['get_output_file']) def test_get_output_file(cfg): output_file = get_output_file(cfg['variable'], cfg['preproc_dir']) assert (output_file == cfg['output_file'])