partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
SolidExecutionResult.transformed_values
Return dictionary of transformed results, with keys being output names. Returns None if execution result isn't a success. Reconstructs the pipeline context to materialize values.
python_modules/dagster/dagster/core/execution.py
def transformed_values(self): '''Return dictionary of transformed results, with keys being output names. Returns None if execution result isn't a success. Reconstructs the pipeline context to materialize values. ''' if self.success and self.transforms: with self.reco...
def transformed_values(self): '''Return dictionary of transformed results, with keys being output names. Returns None if execution result isn't a success. Reconstructs the pipeline context to materialize values. ''' if self.success and self.transforms: with self.reco...
[ "Return", "dictionary", "of", "transformed", "results", "with", "keys", "being", "output", "names", ".", "Returns", "None", "if", "execution", "result", "isn", "t", "a", "success", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/execution.py#L222-L239
[ "def", "transformed_values", "(", "self", ")", ":", "if", "self", ".", "success", "and", "self", ".", "transforms", ":", "with", "self", ".", "reconstruct_context", "(", ")", "as", "context", ":", "values", "=", "{", "result", ".", "step_output_data", ".",...
4119f8c773089de64831b1dfb9e168e353d401dc
test
SolidExecutionResult.transformed_value
Returns transformed value either for DEFAULT_OUTPUT or for the output given as output_name. Returns None if execution result isn't a success. Reconstructs the pipeline context to materialize value.
python_modules/dagster/dagster/core/execution.py
def transformed_value(self, output_name=DEFAULT_OUTPUT): '''Returns transformed value either for DEFAULT_OUTPUT or for the output given as output_name. Returns None if execution result isn't a success. Reconstructs the pipeline context to materialize value. ''' check.str_param(o...
def transformed_value(self, output_name=DEFAULT_OUTPUT): '''Returns transformed value either for DEFAULT_OUTPUT or for the output given as output_name. Returns None if execution result isn't a success. Reconstructs the pipeline context to materialize value. ''' check.str_param(o...
[ "Returns", "transformed", "value", "either", "for", "DEFAULT_OUTPUT", "or", "for", "the", "output", "given", "as", "output_name", ".", "Returns", "None", "if", "execution", "result", "isn", "t", "a", "success", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/execution.py#L241-L273
[ "def", "transformed_value", "(", "self", ",", "output_name", "=", "DEFAULT_OUTPUT", ")", ":", "check", ".", "str_param", "(", "output_name", ",", "'output_name'", ")", "if", "not", "self", ".", "solid", ".", "definition", ".", "has_output", "(", "output_name",...
4119f8c773089de64831b1dfb9e168e353d401dc
test
SolidExecutionResult.failure_data
Returns the failing step's data that happened during this solid's execution, if any
python_modules/dagster/dagster/core/execution.py
def failure_data(self): '''Returns the failing step's data that happened during this solid's execution, if any''' for result in itertools.chain( self.input_expectations, self.output_expectations, self.transforms ): if result.event_type == DagsterEventType.STEP_FAILURE: ...
def failure_data(self): '''Returns the failing step's data that happened during this solid's execution, if any''' for result in itertools.chain( self.input_expectations, self.output_expectations, self.transforms ): if result.event_type == DagsterEventType.STEP_FAILURE: ...
[ "Returns", "the", "failing", "step", "s", "data", "that", "happened", "during", "this", "solid", "s", "execution", "if", "any" ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/execution.py#L283-L289
[ "def", "failure_data", "(", "self", ")", ":", "for", "result", "in", "itertools", ".", "chain", "(", "self", ".", "input_expectations", ",", "self", ".", "output_expectations", ",", "self", ".", "transforms", ")", ":", "if", "result", ".", "event_type", "=...
4119f8c773089de64831b1dfb9e168e353d401dc
test
NamedDict
A :py:class:`Dict` with a name allowing it to be referenced by that name.
python_modules/dagster/dagster/core/types/field_utils.py
def NamedDict(name, fields, description=None, type_attributes=DEFAULT_TYPE_ATTRIBUTES): ''' A :py:class:`Dict` with a name allowing it to be referenced by that name. ''' check_user_facing_fields_dict(fields, 'NamedDict named "{}"'.format(name)) class _NamedDict(_ConfigComposite): def __init...
def NamedDict(name, fields, description=None, type_attributes=DEFAULT_TYPE_ATTRIBUTES): ''' A :py:class:`Dict` with a name allowing it to be referenced by that name. ''' check_user_facing_fields_dict(fields, 'NamedDict named "{}"'.format(name)) class _NamedDict(_ConfigComposite): def __init...
[ "A", ":", "py", ":", "class", ":", "Dict", "with", "a", "name", "allowing", "it", "to", "be", "referenced", "by", "that", "name", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/types/field_utils.py#L242-L258
[ "def", "NamedDict", "(", "name", ",", "fields", ",", "description", "=", "None", ",", "type_attributes", "=", "DEFAULT_TYPE_ATTRIBUTES", ")", ":", "check_user_facing_fields_dict", "(", "fields", ",", "'NamedDict named \"{}\"'", ".", "format", "(", "name", ")", ")"...
4119f8c773089de64831b1dfb9e168e353d401dc
test
Dict
Schema for configuration data with string keys and typed values via :py:class:`Field` . Args: fields (Dict[str, Field])
python_modules/dagster/dagster/core/types/field_utils.py
def Dict(fields): ''' Schema for configuration data with string keys and typed values via :py:class:`Field` . Args: fields (Dict[str, Field]) ''' check_user_facing_fields_dict(fields, 'Dict') class _Dict(_ConfigComposite): def __init__(self): key = 'Dict.' + str(Dic...
def Dict(fields): ''' Schema for configuration data with string keys and typed values via :py:class:`Field` . Args: fields (Dict[str, Field]) ''' check_user_facing_fields_dict(fields, 'Dict') class _Dict(_ConfigComposite): def __init__(self): key = 'Dict.' + str(Dic...
[ "Schema", "for", "configuration", "data", "with", "string", "keys", "and", "typed", "values", "via", ":", "py", ":", "class", ":", "Field", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/types/field_utils.py#L261-L281
[ "def", "Dict", "(", "fields", ")", ":", "check_user_facing_fields_dict", "(", "fields", ",", "'Dict'", ")", "class", "_Dict", "(", "_ConfigComposite", ")", ":", "def", "__init__", "(", "self", ")", ":", "key", "=", "'Dict.'", "+", "str", "(", "DictCounter"...
4119f8c773089de64831b1dfb9e168e353d401dc
test
PermissiveDict
A permissive dict will permit the user to partially specify the permitted fields. Any fields that are specified and passed in will be type checked. Other fields will be allowed, but will be ignored by the type checker.
python_modules/dagster/dagster/core/types/field_utils.py
def PermissiveDict(fields=None): '''A permissive dict will permit the user to partially specify the permitted fields. Any fields that are specified and passed in will be type checked. Other fields will be allowed, but will be ignored by the type checker. ''' if fields: check_user_facing_fie...
def PermissiveDict(fields=None): '''A permissive dict will permit the user to partially specify the permitted fields. Any fields that are specified and passed in will be type checked. Other fields will be allowed, but will be ignored by the type checker. ''' if fields: check_user_facing_fie...
[ "A", "permissive", "dict", "will", "permit", "the", "user", "to", "partially", "specify", "the", "permitted", "fields", ".", "Any", "fields", "that", "are", "specified", "and", "passed", "in", "will", "be", "type", "checked", ".", "Other", "fields", "will", ...
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/types/field_utils.py#L284-L308
[ "def", "PermissiveDict", "(", "fields", "=", "None", ")", ":", "if", "fields", ":", "check_user_facing_fields_dict", "(", "fields", ",", "'PermissiveDict'", ")", "class", "_PermissiveDict", "(", "_ConfigComposite", ")", ":", "def", "__init__", "(", "self", ")", ...
4119f8c773089de64831b1dfb9e168e353d401dc
test
Selector
Selectors are used when you want to be able present several different options to the user but force them to select one. For example, it would not make much sense to allow them to say that a single input should be sourced from a csv and a parquet file: They must choose. Note that in other type systems this ...
python_modules/dagster/dagster/core/types/field_utils.py
def Selector(fields): '''Selectors are used when you want to be able present several different options to the user but force them to select one. For example, it would not make much sense to allow them to say that a single input should be sourced from a csv and a parquet file: They must choose. Note tha...
def Selector(fields): '''Selectors are used when you want to be able present several different options to the user but force them to select one. For example, it would not make much sense to allow them to say that a single input should be sourced from a csv and a parquet file: They must choose. Note tha...
[ "Selectors", "are", "used", "when", "you", "want", "to", "be", "able", "present", "several", "different", "options", "to", "the", "user", "but", "force", "them", "to", "select", "one", ".", "For", "example", "it", "would", "not", "make", "much", "sense", ...
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/types/field_utils.py#L311-L335
[ "def", "Selector", "(", "fields", ")", ":", "check_user_facing_fields_dict", "(", "fields", ",", "'Selector'", ")", "class", "_Selector", "(", "_ConfigSelector", ")", ":", "def", "__init__", "(", "self", ")", ":", "key", "=", "'Selector.'", "+", "str", "(", ...
4119f8c773089de64831b1dfb9e168e353d401dc
test
NamedSelector
A :py:class`Selector` with a name, allowing it to be referenced by that name. Args: name (str): fields (Dict[str, Field])
python_modules/dagster/dagster/core/types/field_utils.py
def NamedSelector(name, fields, description=None, type_attributes=DEFAULT_TYPE_ATTRIBUTES): ''' A :py:class`Selector` with a name, allowing it to be referenced by that name. Args: name (str): fields (Dict[str, Field]) ''' check.str_param(name, 'name') check_user_facing_field...
def NamedSelector(name, fields, description=None, type_attributes=DEFAULT_TYPE_ATTRIBUTES): ''' A :py:class`Selector` with a name, allowing it to be referenced by that name. Args: name (str): fields (Dict[str, Field]) ''' check.str_param(name, 'name') check_user_facing_field...
[ "A", ":", "py", ":", "class", "Selector", "with", "a", "name", "allowing", "it", "to", "be", "referenced", "by", "that", "name", ".", "Args", ":", "name", "(", "str", ")", ":", "fields", "(", "Dict", "[", "str", "Field", "]", ")" ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/types/field_utils.py#L338-L359
[ "def", "NamedSelector", "(", "name", ",", "fields", ",", "description", "=", "None", ",", "type_attributes", "=", "DEFAULT_TYPE_ATTRIBUTES", ")", ":", "check", ".", "str_param", "(", "name", ",", "'name'", ")", "check_user_facing_fields_dict", "(", "fields", ","...
4119f8c773089de64831b1dfb9e168e353d401dc
test
_is_valid_dataset
Datasets must be of form "project.dataset" or "dataset"
python_modules/libraries/dagster-gcp/dagster_gcp/types.py
def _is_valid_dataset(config_value): '''Datasets must be of form "project.dataset" or "dataset" ''' return re.match( # regex matches: project.table -- OR -- table r'^' + RE_PROJECT + r'\.' + RE_DS_TABLE + r'$|^' + RE_DS_TABLE + r'$', config_value, )
def _is_valid_dataset(config_value): '''Datasets must be of form "project.dataset" or "dataset" ''' return re.match( # regex matches: project.table -- OR -- table r'^' + RE_PROJECT + r'\.' + RE_DS_TABLE + r'$|^' + RE_DS_TABLE + r'$', config_value, )
[ "Datasets", "must", "be", "of", "form", "project", ".", "dataset", "or", "dataset" ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/libraries/dagster-gcp/dagster_gcp/types.py#L86-L93
[ "def", "_is_valid_dataset", "(", "config_value", ")", ":", "return", "re", ".", "match", "(", "# regex matches: project.table -- OR -- table", "r'^'", "+", "RE_PROJECT", "+", "r'\\.'", "+", "RE_DS_TABLE", "+", "r'$|^'", "+", "RE_DS_TABLE", "+", "r'$'", ",", "confi...
4119f8c773089de64831b1dfb9e168e353d401dc
test
_is_valid_table
Tables must be of form "project.dataset.table" or "dataset.table"
python_modules/libraries/dagster-gcp/dagster_gcp/types.py
def _is_valid_table(config_value): '''Tables must be of form "project.dataset.table" or "dataset.table" ''' return re.match( r'^' + RE_PROJECT # project + r'\.' # . + RE_DS_TABLE # dataset + r'\.' # . + RE_DS_TABLE # table + r'$|^' #...
def _is_valid_table(config_value): '''Tables must be of form "project.dataset.table" or "dataset.table" ''' return re.match( r'^' + RE_PROJECT # project + r'\.' # . + RE_DS_TABLE # dataset + r'\.' # . + RE_DS_TABLE # table + r'$|^' #...
[ "Tables", "must", "be", "of", "form", "project", ".", "dataset", ".", "table", "or", "dataset", ".", "table" ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/libraries/dagster-gcp/dagster_gcp/types.py#L96-L112
[ "def", "_is_valid_table", "(", "config_value", ")", ":", "return", "re", ".", "match", "(", "r'^'", "+", "RE_PROJECT", "# project", "+", "r'\\.'", "# .", "+", "RE_DS_TABLE", "# dataset", "+", "r'\\.'", "# .", "+", "RE_DS_TABLE", "# table", "+", "r...
4119f8c773089de64831b1dfb9e168e353d401dc
test
_execute_core_transform
Execute the user-specified transform for the solid. Wrap in an error boundary and do all relevant logging and metrics tracking
python_modules/dagster/dagster/core/execution_plan/transform.py
def _execute_core_transform(transform_context, inputs): ''' Execute the user-specified transform for the solid. Wrap in an error boundary and do all relevant logging and metrics tracking ''' check.inst_param(transform_context, 'transform_context', SystemTransformExecutionContext) check.dict_para...
def _execute_core_transform(transform_context, inputs): ''' Execute the user-specified transform for the solid. Wrap in an error boundary and do all relevant logging and metrics tracking ''' check.inst_param(transform_context, 'transform_context', SystemTransformExecutionContext) check.dict_para...
[ "Execute", "the", "user", "-", "specified", "transform", "for", "the", "solid", ".", "Wrap", "in", "an", "error", "boundary", "and", "do", "all", "relevant", "logging", "and", "metrics", "tracking" ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/execution_plan/transform.py#L73-L102
[ "def", "_execute_core_transform", "(", "transform_context", ",", "inputs", ")", ":", "check", ".", "inst_param", "(", "transform_context", ",", "'transform_context'", ",", "SystemTransformExecutionContext", ")", "check", ".", "dict_param", "(", "inputs", ",", "'inputs...
4119f8c773089de64831b1dfb9e168e353d401dc
test
dagster_type
Decorator version of as_dagster_type. See documentation for :py:func:`as_dagster_type` .
python_modules/dagster/dagster/core/types/decorator.py
def dagster_type( name=None, description=None, input_schema=None, output_schema=None, serialization_strategy=None, storage_plugins=None, ): ''' Decorator version of as_dagster_type. See documentation for :py:func:`as_dagster_type` . ''' def _with_args(bare_cls): check.ty...
def dagster_type( name=None, description=None, input_schema=None, output_schema=None, serialization_strategy=None, storage_plugins=None, ): ''' Decorator version of as_dagster_type. See documentation for :py:func:`as_dagster_type` . ''' def _with_args(bare_cls): check.ty...
[ "Decorator", "version", "of", "as_dagster_type", ".", "See", "documentation", "for", ":", "py", ":", "func", ":", "as_dagster_type", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/types/decorator.py#L42-L76
[ "def", "dagster_type", "(", "name", "=", "None", ",", "description", "=", "None", ",", "input_schema", "=", "None", ",", "output_schema", "=", "None", ",", "serialization_strategy", "=", "None", ",", "storage_plugins", "=", "None", ",", ")", ":", "def", "_...
4119f8c773089de64831b1dfb9e168e353d401dc
test
as_dagster_type
Takes a python cls and creates a type for it in the Dagster domain. Args: existing_type (cls) The python type you want to project in to the Dagster type system. name (Optional[str]): description (Optiona[str]): input_schema (Optional[InputSchema]): An instanc...
python_modules/dagster/dagster/core/types/decorator.py
def as_dagster_type( existing_type, name=None, description=None, input_schema=None, output_schema=None, serialization_strategy=None, storage_plugins=None, ): ''' Takes a python cls and creates a type for it in the Dagster domain. Args: existing_type (cls) The...
def as_dagster_type( existing_type, name=None, description=None, input_schema=None, output_schema=None, serialization_strategy=None, storage_plugins=None, ): ''' Takes a python cls and creates a type for it in the Dagster domain. Args: existing_type (cls) The...
[ "Takes", "a", "python", "cls", "and", "creates", "a", "type", "for", "it", "in", "the", "Dagster", "domain", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/types/decorator.py#L98-L154
[ "def", "as_dagster_type", "(", "existing_type", ",", "name", "=", "None", ",", "description", "=", "None", ",", "input_schema", "=", "None", ",", "output_schema", "=", "None", ",", "serialization_strategy", "=", "None", ",", "storage_plugins", "=", "None", ","...
4119f8c773089de64831b1dfb9e168e353d401dc
test
resource
A decorator for creating a resource. The decorated function will be used as the resource_fn in a ResourceDefinition.
python_modules/dagster/dagster/core/definitions/resource.py
def resource(config_field=None, description=None): '''A decorator for creating a resource. The decorated function will be used as the resource_fn in a ResourceDefinition. ''' # This case is for when decorator is used bare, without arguments. # E.g. @resource versus @resource() if callable(conf...
def resource(config_field=None, description=None): '''A decorator for creating a resource. The decorated function will be used as the resource_fn in a ResourceDefinition. ''' # This case is for when decorator is used bare, without arguments. # E.g. @resource versus @resource() if callable(conf...
[ "A", "decorator", "for", "creating", "a", "resource", ".", "The", "decorated", "function", "will", "be", "used", "as", "the", "resource_fn", "in", "a", "ResourceDefinition", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/definitions/resource.py#L41-L54
[ "def", "resource", "(", "config_field", "=", "None", ",", "description", "=", "None", ")", ":", "# This case is for when decorator is used bare, without arguments.", "# E.g. @resource versus @resource()", "if", "callable", "(", "config_field", ")", ":", "return", "ResourceD...
4119f8c773089de64831b1dfb9e168e353d401dc
test
run_spark_subprocess
See https://bit.ly/2OpksJC for source of the subprocess stdout/stderr capture pattern in this function.
python_modules/libraries/dagster-spark/dagster_spark/utils.py
def run_spark_subprocess(cmd, logger): """See https://bit.ly/2OpksJC for source of the subprocess stdout/stderr capture pattern in this function. """ # Spark sometimes logs in log4j format. In those cases, we detect and parse. # Example log line from Spark that this is intended to match: # 2019...
def run_spark_subprocess(cmd, logger): """See https://bit.ly/2OpksJC for source of the subprocess stdout/stderr capture pattern in this function. """ # Spark sometimes logs in log4j format. In those cases, we detect and parse. # Example log line from Spark that this is intended to match: # 2019...
[ "See", "https", ":", "//", "bit", ".", "ly", "/", "2OpksJC", "for", "source", "of", "the", "subprocess", "stdout", "/", "stderr", "capture", "pattern", "in", "this", "function", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/libraries/dagster-spark/dagster_spark/utils.py#L9-L51
[ "def", "run_spark_subprocess", "(", "cmd", ",", "logger", ")", ":", "# Spark sometimes logs in log4j format. In those cases, we detect and parse.", "# Example log line from Spark that this is intended to match:", "# 2019-03-27 16:00:19 INFO ContextHandler:781 - Started o.s.j.s.ServletContextHan...
4119f8c773089de64831b1dfb9e168e353d401dc
test
parse_spark_config
For each key-value pair in spark conf, we need to pass to CLI in format: --conf "key=value"
python_modules/libraries/dagster-spark/dagster_spark/utils.py
def parse_spark_config(spark_conf): '''For each key-value pair in spark conf, we need to pass to CLI in format: --conf "key=value" ''' spark_conf_list = flatten_dict(spark_conf) return list( itertools.chain.from_iterable([('--conf', '{}={}'.format(*c)) for c in spark_conf_list]) )
def parse_spark_config(spark_conf): '''For each key-value pair in spark conf, we need to pass to CLI in format: --conf "key=value" ''' spark_conf_list = flatten_dict(spark_conf) return list( itertools.chain.from_iterable([('--conf', '{}={}'.format(*c)) for c in spark_conf_list]) )
[ "For", "each", "key", "-", "value", "pair", "in", "spark", "conf", "we", "need", "to", "pass", "to", "CLI", "in", "format", ":" ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/libraries/dagster-spark/dagster_spark/utils.py#L74-L83
[ "def", "parse_spark_config", "(", "spark_conf", ")", ":", "spark_conf_list", "=", "flatten_dict", "(", "spark_conf", ")", "return", "list", "(", "itertools", ".", "chain", ".", "from_iterable", "(", "[", "(", "'--conf'", ",", "'{}={}'", ".", "format", "(", "...
4119f8c773089de64831b1dfb9e168e353d401dc
test
SystemNamedDict
A SystemNamedDict object is simply a NamedDict intended for internal (dagster) use.
python_modules/dagster/dagster/core/definitions/environment_configs.py
def SystemNamedDict(name, fields, description=None): '''A SystemNamedDict object is simply a NamedDict intended for internal (dagster) use. ''' return NamedDict(name, fields, description, ConfigTypeAttributes(is_system_config=True))
def SystemNamedDict(name, fields, description=None): '''A SystemNamedDict object is simply a NamedDict intended for internal (dagster) use. ''' return NamedDict(name, fields, description, ConfigTypeAttributes(is_system_config=True))
[ "A", "SystemNamedDict", "object", "is", "simply", "a", "NamedDict", "intended", "for", "internal", "(", "dagster", ")", "use", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/definitions/environment_configs.py#L26-L29
[ "def", "SystemNamedDict", "(", "name", ",", "fields", ",", "description", "=", "None", ")", ":", "return", "NamedDict", "(", "name", ",", "fields", ",", "description", ",", "ConfigTypeAttributes", "(", "is_system_config", "=", "True", ")", ")" ]
4119f8c773089de64831b1dfb9e168e353d401dc
test
PagerDutyService.EventV2_create
Events API v2 enables you to add PagerDuty's advanced event and incident management functionality to any system that can make an outbound HTTP connection. Arguments: summary {string} -- A high-level, text summary message of the event. Will be used to construc...
python_modules/libraries/dagster-pagerduty/dagster_pagerduty/resources.py
def EventV2_create( self, summary, source, severity, event_action='trigger', dedup_key=None, timestamp=None, component=None, group=None, event_class=None, custom_details=None, ): '''Events API v2 enables you to add Pager...
def EventV2_create( self, summary, source, severity, event_action='trigger', dedup_key=None, timestamp=None, component=None, group=None, event_class=None, custom_details=None, ): '''Events API v2 enables you to add Pager...
[ "Events", "API", "v2", "enables", "you", "to", "add", "PagerDuty", "s", "advanced", "event", "and", "incident", "management", "functionality", "to", "any", "system", "that", "can", "make", "an", "outbound", "HTTP", "connection", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/libraries/dagster-pagerduty/dagster_pagerduty/resources.py#L21-L148
[ "def", "EventV2_create", "(", "self", ",", "summary", ",", "source", ",", "severity", ",", "event_action", "=", "'trigger'", ",", "dedup_key", "=", "None", ",", "timestamp", "=", "None", ",", "component", "=", "None", ",", "group", "=", "None", ",", "eve...
4119f8c773089de64831b1dfb9e168e353d401dc
test
coalesce_execution_steps
Groups execution steps by solid, in topological order of the solids.
python_modules/dagster-airflow/dagster_airflow/compile.py
def coalesce_execution_steps(execution_plan): '''Groups execution steps by solid, in topological order of the solids.''' solid_order = _coalesce_solid_order(execution_plan) steps = defaultdict(list) for solid_name, solid_steps in itertools.groupby( execution_plan.topological_steps(), lambda x...
def coalesce_execution_steps(execution_plan): '''Groups execution steps by solid, in topological order of the solids.''' solid_order = _coalesce_solid_order(execution_plan) steps = defaultdict(list) for solid_name, solid_steps in itertools.groupby( execution_plan.topological_steps(), lambda x...
[ "Groups", "execution", "steps", "by", "solid", "in", "topological", "order", "of", "the", "solids", "." ]
dagster-io/dagster
python
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster-airflow/dagster_airflow/compile.py#L16-L28
[ "def", "coalesce_execution_steps", "(", "execution_plan", ")", ":", "solid_order", "=", "_coalesce_solid_order", "(", "execution_plan", ")", "steps", "=", "defaultdict", "(", "list", ")", "for", "solid_name", ",", "solid_steps", "in", "itertools", ".", "groupby", ...
4119f8c773089de64831b1dfb9e168e353d401dc
test
DatabaseWrapper.get_connection_params
Default method to acquire database connection parameters. Sets connection parameters to match settings.py, and sets default values to blank fields.
djongo/base.py
def get_connection_params(self): """ Default method to acquire database connection parameters. Sets connection parameters to match settings.py, and sets default values to blank fields. """ valid_settings = { 'NAME': 'name', 'HOST': 'host', ...
def get_connection_params(self): """ Default method to acquire database connection parameters. Sets connection parameters to match settings.py, and sets default values to blank fields. """ valid_settings = { 'NAME': 'name', 'HOST': 'host', ...
[ "Default", "method", "to", "acquire", "database", "connection", "parameters", "." ]
nesdis/djongo
python
https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/base.py#L122-L157
[ "def", "get_connection_params", "(", "self", ")", ":", "valid_settings", "=", "{", "'NAME'", ":", "'name'", ",", "'HOST'", ":", "'host'", ",", "'PORT'", ":", "'port'", ",", "'USER'", ":", "'username'", ",", "'PASSWORD'", ":", "'password'", ",", "'AUTH_SOURCE...
7f9d79455cf030cb5eee0b822502c50a0d9d3abb
test
DatabaseWrapper.get_new_connection
Receives a dictionary connection_params to setup a connection to the database. Dictionary correct setup is made through the get_connection_params method. TODO: This needs to be made more generic to accept other MongoClient parameters.
djongo/base.py
def get_new_connection(self, connection_params): """ Receives a dictionary connection_params to setup a connection to the database. Dictionary correct setup is made through the get_connection_params method. TODO: This needs to be made more generic to accept othe...
def get_new_connection(self, connection_params): """ Receives a dictionary connection_params to setup a connection to the database. Dictionary correct setup is made through the get_connection_params method. TODO: This needs to be made more generic to accept othe...
[ "Receives", "a", "dictionary", "connection_params", "to", "setup", "a", "connection", "to", "the", "database", "." ]
nesdis/djongo
python
https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/base.py#L159-L185
[ "def", "get_new_connection", "(", "self", ",", "connection_params", ")", ":", "name", "=", "connection_params", ".", "pop", "(", "'name'", ")", "es", "=", "connection_params", ".", "pop", "(", "'enforce_schema'", ")", "connection_params", "[", "'document_class'", ...
7f9d79455cf030cb5eee0b822502c50a0d9d3abb
test
DatabaseWrapper.create_cursor
Returns an active connection cursor to the database.
djongo/base.py
def create_cursor(self, name=None): """ Returns an active connection cursor to the database. """ return Cursor(self.client_connection, self.connection, self.djongo_connection)
def create_cursor(self, name=None): """ Returns an active connection cursor to the database. """ return Cursor(self.client_connection, self.connection, self.djongo_connection)
[ "Returns", "an", "active", "connection", "cursor", "to", "the", "database", "." ]
nesdis/djongo
python
https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/base.py#L199-L203
[ "def", "create_cursor", "(", "self", ",", "name", "=", "None", ")", ":", "return", "Cursor", "(", "self", ".", "client_connection", ",", "self", ".", "connection", ",", "self", ".", "djongo_connection", ")" ]
7f9d79455cf030cb5eee0b822502c50a0d9d3abb
test
DatabaseWrapper._close
Closes the client connection to the database.
djongo/base.py
def _close(self): """ Closes the client connection to the database. """ if self.connection: with self.wrap_database_errors: self.connection.client.close()
def _close(self): """ Closes the client connection to the database. """ if self.connection: with self.wrap_database_errors: self.connection.client.close()
[ "Closes", "the", "client", "connection", "to", "the", "database", "." ]
nesdis/djongo
python
https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/base.py#L205-L211
[ "def", "_close", "(", "self", ")", ":", "if", "self", ".", "connection", ":", "with", "self", ".", "wrap_database_errors", ":", "self", ".", "connection", ".", "client", ".", "close", "(", ")" ]
7f9d79455cf030cb5eee0b822502c50a0d9d3abb
test
make_mdl
Builds an instance of model from the model_dict.
djongo/models/fields.py
def make_mdl(model, model_dict): """ Builds an instance of model from the model_dict. """ for field_name in model_dict: field = model._meta.get_field(field_name) model_dict[field_name] = field.to_python(model_dict[field_name]) return model(**model_dict)
def make_mdl(model, model_dict): """ Builds an instance of model from the model_dict. """ for field_name in model_dict: field = model._meta.get_field(field_name) model_dict[field_name] = field.to_python(model_dict[field_name]) return model(**model_dict)
[ "Builds", "an", "instance", "of", "model", "from", "the", "model_dict", "." ]
nesdis/djongo
python
https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/models/fields.py#L35-L43
[ "def", "make_mdl", "(", "model", ",", "model_dict", ")", ":", "for", "field_name", "in", "model_dict", ":", "field", "=", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", "model_dict", "[", "field_name", "]", "=", "field", ".", "to_python",...
7f9d79455cf030cb5eee0b822502c50a0d9d3abb
test
ArrayModelField.to_python
Overrides standard to_python method from django models to allow correct translation of Mongo array to a python list.
djongo/models/fields.py
def to_python(self, value): """ Overrides standard to_python method from django models to allow correct translation of Mongo array to a python list. """ if value is None: return value assert isinstance(value, list) ret = [] for mdl_d...
def to_python(self, value): """ Overrides standard to_python method from django models to allow correct translation of Mongo array to a python list. """ if value is None: return value assert isinstance(value, list) ret = [] for mdl_d...
[ "Overrides", "standard", "to_python", "method", "from", "django", "models", "to", "allow", "correct", "translation", "of", "Mongo", "array", "to", "a", "python", "list", "." ]
nesdis/djongo
python
https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/models/fields.py#L224-L241
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "value", "assert", "isinstance", "(", "value", ",", "list", ")", "ret", "=", "[", "]", "for", "mdl_dict", "in", "value", ":", "if", "isinstance", "("...
7f9d79455cf030cb5eee0b822502c50a0d9d3abb
test
ArrayModelField.formfield
Returns the formfield for the array.
djongo/models/fields.py
def formfield(self, **kwargs): """ Returns the formfield for the array. """ defaults = { 'form_class': ArrayFormField, 'model_container': self.model_container, 'model_form_class': self.model_form_class, 'name': self.attname, ...
def formfield(self, **kwargs): """ Returns the formfield for the array. """ defaults = { 'form_class': ArrayFormField, 'model_container': self.model_container, 'model_form_class': self.model_form_class, 'name': self.attname, ...
[ "Returns", "the", "formfield", "for", "the", "array", "." ]
nesdis/djongo
python
https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/models/fields.py#L243-L256
[ "def", "formfield", "(", "self", ",", "*", "*", "kwargs", ")", ":", "defaults", "=", "{", "'form_class'", ":", "ArrayFormField", ",", "'model_container'", ":", "self", ".", "model_container", ",", "'model_form_class'", ":", "self", ".", "model_form_class", ","...
7f9d79455cf030cb5eee0b822502c50a0d9d3abb
test
EmbeddedModelField.to_python
Overrides Django's default to_python to allow correct translation to instance.
djongo/models/fields.py
def to_python(self, value): """ Overrides Django's default to_python to allow correct translation to instance. """ if value is None or isinstance(value, self.model_container): return value assert isinstance(value, dict) instance = make_mdl(se...
def to_python(self, value): """ Overrides Django's default to_python to allow correct translation to instance. """ if value is None or isinstance(value, self.model_container): return value assert isinstance(value, dict) instance = make_mdl(se...
[ "Overrides", "Django", "s", "default", "to_python", "to", "allow", "correct", "translation", "to", "instance", "." ]
nesdis/djongo
python
https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/models/fields.py#L507-L517
[ "def", "to_python", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", "or", "isinstance", "(", "value", ",", "self", ".", "model_container", ")", ":", "return", "value", "assert", "isinstance", "(", "value", ",", "dict", ")", "instance", ...
7f9d79455cf030cb5eee0b822502c50a0d9d3abb
test
ArrayReferenceManagerMixin._apply_rel_filters
Filter the queryset for the instance this manager is bound to.
djongo/models/fields.py
def _apply_rel_filters(self, queryset): """ Filter the queryset for the instance this manager is bound to. """ queryset._add_hints(instance=self.instance) if self._db: queryset = queryset.using(self._db) queryset = queryset.filter(**self.core_filters) ...
def _apply_rel_filters(self, queryset): """ Filter the queryset for the instance this manager is bound to. """ queryset._add_hints(instance=self.instance) if self._db: queryset = queryset.using(self._db) queryset = queryset.filter(**self.core_filters) ...
[ "Filter", "the", "queryset", "for", "the", "instance", "this", "manager", "is", "bound", "to", "." ]
nesdis/djongo
python
https://github.com/nesdis/djongo/blob/7f9d79455cf030cb5eee0b822502c50a0d9d3abb/djongo/models/fields.py#L675-L684
[ "def", "_apply_rel_filters", "(", "self", ",", "queryset", ")", ":", "queryset", ".", "_add_hints", "(", "instance", "=", "self", ".", "instance", ")", "if", "self", ".", "_db", ":", "queryset", "=", "queryset", ".", "using", "(", "self", ".", "_db", "...
7f9d79455cf030cb5eee0b822502c50a0d9d3abb
test
_compute_nfp_uniform
Computes the expected number of false positives caused by using u to approximate set sizes in the interval [l, u], assuming uniform distribution of set sizes within the interval. Args: l: the lower bound on set sizes. u: the upper bound on set sizes. cum_counts: the complete cummula...
datasketch/lshensemble_partition.py
def _compute_nfp_uniform(l, u, cum_counts, sizes): """Computes the expected number of false positives caused by using u to approximate set sizes in the interval [l, u], assuming uniform distribution of set sizes within the interval. Args: l: the lower bound on set sizes. u: the upper bo...
def _compute_nfp_uniform(l, u, cum_counts, sizes): """Computes the expected number of false positives caused by using u to approximate set sizes in the interval [l, u], assuming uniform distribution of set sizes within the interval. Args: l: the lower bound on set sizes. u: the upper bo...
[ "Computes", "the", "expected", "number", "of", "false", "positives", "caused", "by", "using", "u", "to", "approximate", "set", "sizes", "in", "the", "interval", "[", "l", "u", "]", "assuming", "uniform", "distribution", "of", "set", "sizes", "within", "the",...
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble_partition.py#L13-L32
[ "def", "_compute_nfp_uniform", "(", "l", ",", "u", ",", "cum_counts", ",", "sizes", ")", ":", "if", "l", ">", "u", ":", "raise", "ValueError", "(", "\"l must be less or equal to u\"", ")", "if", "l", "==", "0", ":", "n", "=", "cum_counts", "[", "u", "]...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
_compute_nfps_uniform
Computes the matrix of expected false positives for all possible sub-intervals of the complete domain of set sizes, assuming uniform distribution of set_sizes within each sub-intervals. Args: cum_counts: the complete cummulative distribution of set sizes. sizes: the complete domain of set s...
datasketch/lshensemble_partition.py
def _compute_nfps_uniform(cum_counts, sizes): """Computes the matrix of expected false positives for all possible sub-intervals of the complete domain of set sizes, assuming uniform distribution of set_sizes within each sub-intervals. Args: cum_counts: the complete cummulative distribution of s...
def _compute_nfps_uniform(cum_counts, sizes): """Computes the matrix of expected false positives for all possible sub-intervals of the complete domain of set sizes, assuming uniform distribution of set_sizes within each sub-intervals. Args: cum_counts: the complete cummulative distribution of s...
[ "Computes", "the", "matrix", "of", "expected", "false", "positives", "for", "all", "possible", "sub", "-", "intervals", "of", "the", "complete", "domain", "of", "set", "sizes", "assuming", "uniform", "distribution", "of", "set_sizes", "within", "each", "sub", ...
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble_partition.py#L35-L54
[ "def", "_compute_nfps_uniform", "(", "cum_counts", ",", "sizes", ")", ":", "nfps", "=", "np", ".", "zeros", "(", "(", "len", "(", "sizes", ")", ",", "len", "(", "sizes", ")", ")", ")", "# All u an l are inclusive bounds for intervals.", "# Compute p = 1, the NFP...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
_compute_nfp_real
Computes the expected number of false positives caused by using u to approximate set sizes in the interval [l, u], using the real set size distribution. Args: l: the lower bound on set sizes. u: the upper bound on set sizes. counts: the complete distribution of set sizes. si...
datasketch/lshensemble_partition.py
def _compute_nfp_real(l, u, counts, sizes): """Computes the expected number of false positives caused by using u to approximate set sizes in the interval [l, u], using the real set size distribution. Args: l: the lower bound on set sizes. u: the upper bound on set sizes. counts:...
def _compute_nfp_real(l, u, counts, sizes): """Computes the expected number of false positives caused by using u to approximate set sizes in the interval [l, u], using the real set size distribution. Args: l: the lower bound on set sizes. u: the upper bound on set sizes. counts:...
[ "Computes", "the", "expected", "number", "of", "false", "positives", "caused", "by", "using", "u", "to", "approximate", "set", "sizes", "in", "the", "interval", "[", "l", "u", "]", "using", "the", "real", "set", "size", "distribution", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble_partition.py#L57-L72
[ "def", "_compute_nfp_real", "(", "l", ",", "u", ",", "counts", ",", "sizes", ")", ":", "if", "l", ">", "u", ":", "raise", "ValueError", "(", "\"l must be less or equal to u\"", ")", "return", "np", ".", "sum", "(", "(", "float", "(", "sizes", "[", "u",...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
_compute_nfps_real
Computes the matrix of expected false positives for all possible sub-intervals of the complete domain of set sizes. Args: counts: the complete distribution of set sizes. sizes: the complete domain of set sizes. Return (np.array): the 2-D array of expected number of false positives ...
datasketch/lshensemble_partition.py
def _compute_nfps_real(counts, sizes): """Computes the matrix of expected false positives for all possible sub-intervals of the complete domain of set sizes. Args: counts: the complete distribution of set sizes. sizes: the complete domain of set sizes. Return (np.array): the 2-D array ...
def _compute_nfps_real(counts, sizes): """Computes the matrix of expected false positives for all possible sub-intervals of the complete domain of set sizes. Args: counts: the complete distribution of set sizes. sizes: the complete domain of set sizes. Return (np.array): the 2-D array ...
[ "Computes", "the", "matrix", "of", "expected", "false", "positives", "for", "all", "possible", "sub", "-", "intervals", "of", "the", "complete", "domain", "of", "set", "sizes", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble_partition.py#L75-L93
[ "def", "_compute_nfps_real", "(", "counts", ",", "sizes", ")", ":", "nfps", "=", "np", ".", "zeros", "(", "(", "len", "(", "sizes", ")", ",", "len", "(", "sizes", ")", ")", ")", "# All u an l are inclusive bounds for intervals.", "# Compute p = 1, the NFPs", "...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
_compute_best_partitions
Computes the optimal partitions given the size distributions and computed number of expected false positives for all sub-intervals. Args: num_part (int): The number of partitions to create. sizes (numpy.array): The complete domain of set sizes in sorted order. nfps (numpy.array): The co...
datasketch/lshensemble_partition.py
def _compute_best_partitions(num_part, sizes, nfps): """Computes the optimal partitions given the size distributions and computed number of expected false positives for all sub-intervals. Args: num_part (int): The number of partitions to create. sizes (numpy.array): The complete domain of s...
def _compute_best_partitions(num_part, sizes, nfps): """Computes the optimal partitions given the size distributions and computed number of expected false positives for all sub-intervals. Args: num_part (int): The number of partitions to create. sizes (numpy.array): The complete domain of s...
[ "Computes", "the", "optimal", "partitions", "given", "the", "size", "distributions", "and", "computed", "number", "of", "expected", "false", "positives", "for", "all", "sub", "-", "intervals", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble_partition.py#L96-L168
[ "def", "_compute_best_partitions", "(", "num_part", ",", "sizes", ",", "nfps", ")", ":", "if", "num_part", "<", "2", ":", "raise", "ValueError", "(", "\"num_part cannot be less than 2\"", ")", "if", "num_part", ">", "len", "(", "sizes", ")", ":", "raise", "V...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
optimal_partitions
Compute the optimal partitions given a distribution of set sizes. Args: sizes (numpy.array): The complete domain of set sizes in ascending order. counts (numpy.array): The frequencies of all set sizes in the same order as `sizes`. num_part (int): The number of partit...
datasketch/lshensemble_partition.py
def optimal_partitions(sizes, counts, num_part): """Compute the optimal partitions given a distribution of set sizes. Args: sizes (numpy.array): The complete domain of set sizes in ascending order. counts (numpy.array): The frequencies of all set sizes in the same order ...
def optimal_partitions(sizes, counts, num_part): """Compute the optimal partitions given a distribution of set sizes. Args: sizes (numpy.array): The complete domain of set sizes in ascending order. counts (numpy.array): The frequencies of all set sizes in the same order ...
[ "Compute", "the", "optimal", "partitions", "given", "a", "distribution", "of", "set", "sizes", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble_partition.py#L172-L194
[ "def", "optimal_partitions", "(", "sizes", ",", "counts", ",", "num_part", ")", ":", "if", "num_part", "<", "2", ":", "return", "[", "(", "sizes", "[", "0", "]", ",", "sizes", "[", "-", "1", "]", ")", "]", "if", "num_part", ">=", "len", "(", "siz...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
bBitMinHash.jaccard
Estimate the Jaccard similarity (resemblance) between this b-bit MinHash and the other.
datasketch/b_bit_minhash.py
def jaccard(self, other): ''' Estimate the Jaccard similarity (resemblance) between this b-bit MinHash and the other. ''' if self.b != other.b: raise ValueError("Cannot compare two b-bit MinHashes with different\ b values") if self.seed != ...
def jaccard(self, other): ''' Estimate the Jaccard similarity (resemblance) between this b-bit MinHash and the other. ''' if self.b != other.b: raise ValueError("Cannot compare two b-bit MinHashes with different\ b values") if self.seed != ...
[ "Estimate", "the", "Jaccard", "similarity", "(", "resemblance", ")", "between", "this", "b", "-", "bit", "MinHash", "and", "the", "other", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/b_bit_minhash.py#L57-L73
[ "def", "jaccard", "(", "self", ",", "other", ")", ":", "if", "self", ".", "b", "!=", "other", ".", "b", ":", "raise", "ValueError", "(", "\"Cannot compare two b-bit MinHashes with different\\\n b values\"", ")", "if", "self", ".", "seed", "!=", ...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
bBitMinHash._calc_a
Compute the function A(r, b)
datasketch/b_bit_minhash.py
def _calc_a(self, r, b): ''' Compute the function A(r, b) ''' if r == 0.0: # Find the limit of A(r, b) as r -> 0. return 1.0 / (1 << b) return r * (1 - r) ** (2 ** b - 1) / (1 - (1 - r) ** (2 * b))
def _calc_a(self, r, b): ''' Compute the function A(r, b) ''' if r == 0.0: # Find the limit of A(r, b) as r -> 0. return 1.0 / (1 << b) return r * (1 - r) ** (2 ** b - 1) / (1 - (1 - r) ** (2 * b))
[ "Compute", "the", "function", "A", "(", "r", "b", ")" ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/b_bit_minhash.py#L129-L136
[ "def", "_calc_a", "(", "self", ",", "r", ",", "b", ")", ":", "if", "r", "==", "0.0", ":", "# Find the limit of A(r, b) as r -> 0.", "return", "1.0", "/", "(", "1", "<<", "b", ")", "return", "r", "*", "(", "1", "-", "r", ")", "**", "(", "2", "**",...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
bBitMinHash._calc_c
Compute the functions C1 and C2
datasketch/b_bit_minhash.py
def _calc_c(self, a1, a2, r1, r2): ''' Compute the functions C1 and C2 ''' if r1 == 0.0 and r2 == 0.0: # Find the limits of C1 and C2 as r1 -> 0 and r2 -> 0 # Since the b-value must be the same and r1 = r2, # we have A1(r1, b1) = A2(r2, b2) = A, ...
def _calc_c(self, a1, a2, r1, r2): ''' Compute the functions C1 and C2 ''' if r1 == 0.0 and r2 == 0.0: # Find the limits of C1 and C2 as r1 -> 0 and r2 -> 0 # Since the b-value must be the same and r1 = r2, # we have A1(r1, b1) = A2(r2, b2) = A, ...
[ "Compute", "the", "functions", "C1", "and", "C2" ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/b_bit_minhash.py#L138-L151
[ "def", "_calc_c", "(", "self", ",", "a1", ",", "a2", ",", "r1", ",", "r2", ")", ":", "if", "r1", "==", "0.0", "and", "r2", "==", "0.0", ":", "# Find the limits of C1 and C2 as r1 -> 0 and r2 -> 0", "# Since the b-value must be the same and r1 = r2,", "# we have A1(r...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
LeanMinHash._initialize_slots
Initialize the slots of the LeanMinHash. Args: seed (int): The random seed controls the set of random permutation functions generated for this LeanMinHash. hashvalues: The hash values is the internal state of the LeanMinHash.
datasketch/lean_minhash.py
def _initialize_slots(self, seed, hashvalues): '''Initialize the slots of the LeanMinHash. Args: seed (int): The random seed controls the set of random permutation functions generated for this LeanMinHash. hashvalues: The hash values is the internal state of the ...
def _initialize_slots(self, seed, hashvalues): '''Initialize the slots of the LeanMinHash. Args: seed (int): The random seed controls the set of random permutation functions generated for this LeanMinHash. hashvalues: The hash values is the internal state of the ...
[ "Initialize", "the", "slots", "of", "the", "LeanMinHash", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lean_minhash.py#L51-L60
[ "def", "_initialize_slots", "(", "self", ",", "seed", ",", "hashvalues", ")", ":", "self", ".", "seed", "=", "seed", "self", ".", "hashvalues", "=", "self", ".", "_parse_hashvalues", "(", "hashvalues", ")" ]
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
LeanMinHash.bytesize
Compute the byte size after serialization. Args: byteorder (str, optional): This is byte order of the serialized data. Use one of the `byte order characters <https://docs.python.org/3/library/struct.html#byte-order-size-and-alignment>`_: ``@``, ``=``,...
datasketch/lean_minhash.py
def bytesize(self, byteorder='@'): '''Compute the byte size after serialization. Args: byteorder (str, optional): This is byte order of the serialized data. Use one of the `byte order characters <https://docs.python.org/3/library/struct.html#byte-order-size-a...
def bytesize(self, byteorder='@'): '''Compute the byte size after serialization. Args: byteorder (str, optional): This is byte order of the serialized data. Use one of the `byte order characters <https://docs.python.org/3/library/struct.html#byte-order-size-a...
[ "Compute", "the", "byte", "size", "after", "serialization", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lean_minhash.py#L76-L95
[ "def", "bytesize", "(", "self", ",", "byteorder", "=", "'@'", ")", ":", "# Use 8 bytes to store the seed integer", "seed_size", "=", "struct", ".", "calcsize", "(", "byteorder", "+", "'q'", ")", "# Use 4 bytes to store the number of hash values", "length_size", "=", "...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
LeanMinHash.serialize
Serialize this lean MinHash and store the result in an allocated buffer. Args: buf (buffer): `buf` must implement the `buffer`_ interface. One such example is the built-in `bytearray`_ class. byteorder (str, optional): This is byte order of the serialized data. Use one ...
datasketch/lean_minhash.py
def serialize(self, buf, byteorder='@'): ''' Serialize this lean MinHash and store the result in an allocated buffer. Args: buf (buffer): `buf` must implement the `buffer`_ interface. One such example is the built-in `bytearray`_ class. byteorder (str, op...
def serialize(self, buf, byteorder='@'): ''' Serialize this lean MinHash and store the result in an allocated buffer. Args: buf (buffer): `buf` must implement the `buffer`_ interface. One such example is the built-in `bytearray`_ class. byteorder (str, op...
[ "Serialize", "this", "lean", "MinHash", "and", "store", "the", "result", "in", "an", "allocated", "buffer", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lean_minhash.py#L97-L145
[ "def", "serialize", "(", "self", ",", "buf", ",", "byteorder", "=", "'@'", ")", ":", "if", "len", "(", "buf", ")", "<", "self", ".", "bytesize", "(", ")", ":", "raise", "ValueError", "(", "\"The buffer does not have enough space\\\n for holdin...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
LeanMinHash.deserialize
Deserialize a lean MinHash from a buffer. Args: buf (buffer): `buf` must implement the `buffer`_ interface. One such example is the built-in `bytearray`_ class. byteorder (str. optional): This is byte order of the serialized data. Use one of the `byte ord...
datasketch/lean_minhash.py
def deserialize(cls, buf, byteorder='@'): ''' Deserialize a lean MinHash from a buffer. Args: buf (buffer): `buf` must implement the `buffer`_ interface. One such example is the built-in `bytearray`_ class. byteorder (str. optional): This is byte order of...
def deserialize(cls, buf, byteorder='@'): ''' Deserialize a lean MinHash from a buffer. Args: buf (buffer): `buf` must implement the `buffer`_ interface. One such example is the built-in `bytearray`_ class. byteorder (str. optional): This is byte order of...
[ "Deserialize", "a", "lean", "MinHash", "from", "a", "buffer", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lean_minhash.py#L148-L184
[ "def", "deserialize", "(", "cls", ",", "buf", ",", "byteorder", "=", "'@'", ")", ":", "fmt_seed_size", "=", "\"%sqi\"", "%", "byteorder", "fmt_hash", "=", "byteorder", "+", "\"%dI\"", "try", ":", "seed", ",", "num_perm", "=", "struct", ".", "unpack_from", ...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHash.update
Update this MinHash with a new value. The value will be hashed using the hash function specified by the `hashfunc` argument in the constructor. Args: b: The value to be hashed using the hash function specified. Example: To update with a new string value (using t...
datasketch/minhash.py
def update(self, b): '''Update this MinHash with a new value. The value will be hashed using the hash function specified by the `hashfunc` argument in the constructor. Args: b: The value to be hashed using the hash function specified. Example: To update ...
def update(self, b): '''Update this MinHash with a new value. The value will be hashed using the hash function specified by the `hashfunc` argument in the constructor. Args: b: The value to be hashed using the hash function specified. Example: To update ...
[ "Update", "this", "MinHash", "with", "a", "new", "value", ".", "The", "value", "will", "be", "hashed", "using", "the", "hash", "function", "specified", "by", "the", "hashfunc", "argument", "in", "the", "constructor", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/minhash.py#L105-L135
[ "def", "update", "(", "self", ",", "b", ")", ":", "hv", "=", "self", ".", "hashfunc", "(", "b", ")", "a", ",", "b", "=", "self", ".", "permutations", "phv", "=", "np", ".", "bitwise_and", "(", "(", "a", "*", "hv", "+", "b", ")", "%", "_mersen...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHash.jaccard
Estimate the `Jaccard similarity`_ (resemblance) between the sets represented by this MinHash and the other. Args: other (datasketch.MinHash): The other MinHash. Returns: float: The Jaccard similarity, which is between 0.0 and 1.0.
datasketch/minhash.py
def jaccard(self, other): '''Estimate the `Jaccard similarity`_ (resemblance) between the sets represented by this MinHash and the other. Args: other (datasketch.MinHash): The other MinHash. Returns: float: The Jaccard similarity, which is between 0.0 and 1.0. ...
def jaccard(self, other): '''Estimate the `Jaccard similarity`_ (resemblance) between the sets represented by this MinHash and the other. Args: other (datasketch.MinHash): The other MinHash. Returns: float: The Jaccard similarity, which is between 0.0 and 1.0. ...
[ "Estimate", "the", "Jaccard", "similarity", "_", "(", "resemblance", ")", "between", "the", "sets", "represented", "by", "this", "MinHash", "and", "the", "other", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/minhash.py#L137-L154
[ "def", "jaccard", "(", "self", ",", "other", ")", ":", "if", "other", ".", "seed", "!=", "self", ".", "seed", ":", "raise", "ValueError", "(", "\"Cannot compute Jaccard given MinHash with\\\n different seeds\"", ")", "if", "len", "(", "self", ")...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHash.count
Estimate the cardinality count based on the technique described in `this paper <http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=365694>`_. Returns: int: The estimated cardinality of the set represented by this MinHash.
datasketch/minhash.py
def count(self): '''Estimate the cardinality count based on the technique described in `this paper <http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=365694>`_. Returns: int: The estimated cardinality of the set represented by this MinHash. ''' k = len(self) ...
def count(self): '''Estimate the cardinality count based on the technique described in `this paper <http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=365694>`_. Returns: int: The estimated cardinality of the set represented by this MinHash. ''' k = len(self) ...
[ "Estimate", "the", "cardinality", "count", "based", "on", "the", "technique", "described", "in", "this", "paper", "<http", ":", "//", "ieeexplore", ".", "ieee", ".", "org", "/", "stamp", "/", "stamp", ".", "jsp?arnumber", "=", "365694", ">", "_", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/minhash.py#L156-L164
[ "def", "count", "(", "self", ")", ":", "k", "=", "len", "(", "self", ")", "return", "np", ".", "float", "(", "k", ")", "/", "np", ".", "sum", "(", "self", ".", "hashvalues", "/", "np", ".", "float", "(", "_max_hash", ")", ")", "-", "1.0" ]
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHash.merge
Merge the other MinHash with this one, making this one the union of both. Args: other (datasketch.MinHash): The other MinHash.
datasketch/minhash.py
def merge(self, other): '''Merge the other MinHash with this one, making this one the union of both. Args: other (datasketch.MinHash): The other MinHash. ''' if other.seed != self.seed: raise ValueError("Cannot merge MinHash with\ diff...
def merge(self, other): '''Merge the other MinHash with this one, making this one the union of both. Args: other (datasketch.MinHash): The other MinHash. ''' if other.seed != self.seed: raise ValueError("Cannot merge MinHash with\ diff...
[ "Merge", "the", "other", "MinHash", "with", "this", "one", "making", "this", "one", "the", "union", "of", "both", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/minhash.py#L166-L179
[ "def", "merge", "(", "self", ",", "other", ")", ":", "if", "other", ".", "seed", "!=", "self", ".", "seed", ":", "raise", "ValueError", "(", "\"Cannot merge MinHash with\\\n different seeds\"", ")", "if", "len", "(", "self", ")", "!=", "len"...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHash.copy
:returns: datasketch.MinHash -- A copy of this MinHash by exporting its state.
datasketch/minhash.py
def copy(self): ''' :returns: datasketch.MinHash -- A copy of this MinHash by exporting its state. ''' return MinHash(seed=self.seed, hashfunc=self.hashfunc, hashvalues=self.digest(), permutations=self.permutations)
def copy(self): ''' :returns: datasketch.MinHash -- A copy of this MinHash by exporting its state. ''' return MinHash(seed=self.seed, hashfunc=self.hashfunc, hashvalues=self.digest(), permutations=self.permutations)
[ ":", "returns", ":", "datasketch", ".", "MinHash", "--", "A", "copy", "of", "this", "MinHash", "by", "exporting", "its", "state", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/minhash.py#L207-L213
[ "def", "copy", "(", "self", ")", ":", "return", "MinHash", "(", "seed", "=", "self", ".", "seed", ",", "hashfunc", "=", "self", ".", "hashfunc", ",", "hashvalues", "=", "self", ".", "digest", "(", ")", ",", "permutations", "=", "self", ".", "permutat...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHash.union
Create a MinHash which is the union of the MinHash objects passed as arguments. Args: *mhs: The MinHash objects to be united. The argument list length is variable, but must be at least 2. Returns: datasketch.MinHash: A new union MinHash.
datasketch/minhash.py
def union(cls, *mhs): '''Create a MinHash which is the union of the MinHash objects passed as arguments. Args: *mhs: The MinHash objects to be united. The argument list length is variable, but must be at least 2. Returns: datasketch.MinHash: A new union ...
def union(cls, *mhs): '''Create a MinHash which is the union of the MinHash objects passed as arguments. Args: *mhs: The MinHash objects to be united. The argument list length is variable, but must be at least 2. Returns: datasketch.MinHash: A new union ...
[ "Create", "a", "MinHash", "which", "is", "the", "union", "of", "the", "MinHash", "objects", "passed", "as", "arguments", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/minhash.py#L230-L250
[ "def", "union", "(", "cls", ",", "*", "mhs", ")", ":", "if", "len", "(", "mhs", ")", "<", "2", ":", "raise", "ValueError", "(", "\"Cannot union less than 2 MinHash\"", ")", "num_perm", "=", "len", "(", "mhs", "[", "0", "]", ")", "seed", "=", "mhs", ...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
_false_positive_probability
Compute the false positive probability given the containment threshold. xq is the ratio of x/q.
datasketch/lshensemble.py
def _false_positive_probability(threshold, b, r, xq): ''' Compute the false positive probability given the containment threshold. xq is the ratio of x/q. ''' _probability = lambda t : 1 - (1 - (t/(1 + xq - t))**float(r))**float(b) if xq >= threshold: a, err = integrate(_probability, 0.0,...
def _false_positive_probability(threshold, b, r, xq): ''' Compute the false positive probability given the containment threshold. xq is the ratio of x/q. ''' _probability = lambda t : 1 - (1 - (t/(1 + xq - t))**float(r))**float(b) if xq >= threshold: a, err = integrate(_probability, 0.0,...
[ "Compute", "the", "false", "positive", "probability", "given", "the", "containment", "threshold", ".", "xq", "is", "the", "ratio", "of", "x", "/", "q", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble.py#L7-L17
[ "def", "_false_positive_probability", "(", "threshold", ",", "b", ",", "r", ",", "xq", ")", ":", "_probability", "=", "lambda", "t", ":", "1", "-", "(", "1", "-", "(", "t", "/", "(", "1", "+", "xq", "-", "t", ")", ")", "**", "float", "(", "r", ...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
_optimal_param
Compute the optimal parameters that minimizes the weighted sum of probabilities of false positive and false negative. xq is the ratio of x/q.
datasketch/lshensemble.py
def _optimal_param(threshold, num_perm, max_r, xq, false_positive_weight, false_negative_weight): ''' Compute the optimal parameters that minimizes the weighted sum of probabilities of false positive and false negative. xq is the ratio of x/q. ''' min_error = float("inf") opt = (0, 0...
def _optimal_param(threshold, num_perm, max_r, xq, false_positive_weight, false_negative_weight): ''' Compute the optimal parameters that minimizes the weighted sum of probabilities of false positive and false negative. xq is the ratio of x/q. ''' min_error = float("inf") opt = (0, 0...
[ "Compute", "the", "optimal", "parameters", "that", "minimizes", "the", "weighted", "sum", "of", "probabilities", "of", "false", "positive", "and", "false", "negative", ".", "xq", "is", "the", "ratio", "of", "x", "/", "q", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble.py#L34-L53
[ "def", "_optimal_param", "(", "threshold", ",", "num_perm", ",", "max_r", ",", "xq", ",", "false_positive_weight", ",", "false_negative_weight", ")", ":", "min_error", "=", "float", "(", "\"inf\"", ")", "opt", "=", "(", "0", ",", "0", ")", "for", "b", "i...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHashLSHEnsemble.index
Index all sets given their keys, MinHashes, and sizes. It can be called only once after the index is created. Args: entries (`iterable` of `tuple`): An iterable of tuples, each must be in the form of `(key, minhash, size)`, where `key` is the unique identifie...
datasketch/lshensemble.py
def index(self, entries): ''' Index all sets given their keys, MinHashes, and sizes. It can be called only once after the index is created. Args: entries (`iterable` of `tuple`): An iterable of tuples, each must be in the form of `(key, minhash, size)`, where...
def index(self, entries): ''' Index all sets given their keys, MinHashes, and sizes. It can be called only once after the index is created. Args: entries (`iterable` of `tuple`): An iterable of tuples, each must be in the form of `(key, minhash, size)`, where...
[ "Index", "all", "sets", "given", "their", "keys", "MinHashes", "and", "sizes", ".", "It", "can", "be", "called", "only", "once", "after", "the", "index", "is", "created", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble.py#L139-L177
[ "def", "index", "(", "self", ",", "entries", ")", ":", "if", "not", "self", ".", "is_empty", "(", ")", ":", "raise", "ValueError", "(", "\"Cannot call index again on a non-empty index\"", ")", "if", "not", "isinstance", "(", "entries", ",", "list", ")", ":",...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHashLSHEnsemble.query
Giving the MinHash and size of the query set, retrieve keys that references sets with containment with respect to the query set greater than the threshold. Args: minhash (datasketch.MinHash): The MinHash of the query set. size (int): The size (number of unique items) of ...
datasketch/lshensemble.py
def query(self, minhash, size): ''' Giving the MinHash and size of the query set, retrieve keys that references sets with containment with respect to the query set greater than the threshold. Args: minhash (datasketch.MinHash): The MinHash of the query set. ...
def query(self, minhash, size): ''' Giving the MinHash and size of the query set, retrieve keys that references sets with containment with respect to the query set greater than the threshold. Args: minhash (datasketch.MinHash): The MinHash of the query set. ...
[ "Giving", "the", "MinHash", "and", "size", "of", "the", "query", "set", "retrieve", "keys", "that", "references", "sets", "with", "containment", "with", "respect", "to", "the", "query", "set", "greater", "than", "the", "threshold", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble.py#L179-L198
[ "def", "query", "(", "self", ",", "minhash", ",", "size", ")", ":", "for", "i", ",", "index", "in", "enumerate", "(", "self", ".", "indexes", ")", ":", "u", "=", "self", ".", "uppers", "[", "i", "]", "if", "u", "is", "None", ":", "continue", "b...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHashLSHEnsemble.is_empty
Returns: bool: Check if the index is empty.
datasketch/lshensemble.py
def is_empty(self): ''' Returns: bool: Check if the index is empty. ''' return all(all(index[r].is_empty() for r in index) for index in self.indexes)
def is_empty(self): ''' Returns: bool: Check if the index is empty. ''' return all(all(index[r].is_empty() for r in index) for index in self.indexes)
[ "Returns", ":", "bool", ":", "Check", "if", "the", "index", "is", "empty", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshensemble.py#L211-L217
[ "def", "is_empty", "(", "self", ")", ":", "return", "all", "(", "all", "(", "index", "[", "r", "]", ".", "is_empty", "(", ")", "for", "r", "in", "index", ")", "for", "index", "in", "self", ".", "indexes", ")" ]
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
WeightedMinHash.jaccard
Estimate the `weighted Jaccard similarity`_ between the multi-sets represented by this weighted MinHash and the other. Args: other (datasketch.WeightedMinHash): The other weighted MinHash. Returns: float: The weighted Jaccard similarity between 0.0 and 1.0. ...
datasketch/weighted_minhash.py
def jaccard(self, other): '''Estimate the `weighted Jaccard similarity`_ between the multi-sets represented by this weighted MinHash and the other. Args: other (datasketch.WeightedMinHash): The other weighted MinHash. Returns: float: The weighted Jaccard...
def jaccard(self, other): '''Estimate the `weighted Jaccard similarity`_ between the multi-sets represented by this weighted MinHash and the other. Args: other (datasketch.WeightedMinHash): The other weighted MinHash. Returns: float: The weighted Jaccard...
[ "Estimate", "the", "weighted", "Jaccard", "similarity", "_", "between", "the", "multi", "-", "sets", "represented", "by", "this", "weighted", "MinHash", "and", "the", "other", ".", "Args", ":", "other", "(", "datasketch", ".", "WeightedMinHash", ")", ":", "T...
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/weighted_minhash.py#L22-L45
[ "def", "jaccard", "(", "self", ",", "other", ")", ":", "if", "other", ".", "seed", "!=", "self", ".", "seed", ":", "raise", "ValueError", "(", "\"Cannot compute Jaccard given WeightedMinHash objects with\\\n different seeds\"", ")", "if", "len", "("...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
WeightedMinHashGenerator.minhash
Create a new weighted MinHash given a weighted Jaccard vector. Each dimension is an integer frequency of the corresponding element in the multi-set represented by the vector. Args: v (numpy.array): The Jaccard vector.
datasketch/weighted_minhash.py
def minhash(self, v): '''Create a new weighted MinHash given a weighted Jaccard vector. Each dimension is an integer frequency of the corresponding element in the multi-set represented by the vector. Args: v (numpy.array): The Jaccard vector. ''' if...
def minhash(self, v): '''Create a new weighted MinHash given a weighted Jaccard vector. Each dimension is an integer frequency of the corresponding element in the multi-set represented by the vector. Args: v (numpy.array): The Jaccard vector. ''' if...
[ "Create", "a", "new", "weighted", "MinHash", "given", "a", "weighted", "Jaccard", "vector", ".", "Each", "dimension", "is", "an", "integer", "frequency", "of", "the", "corresponding", "element", "in", "the", "multi", "-", "set", "represented", "by", "the", "...
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/weighted_minhash.py#L107-L136
[ "def", "minhash", "(", "self", ",", "v", ")", ":", "if", "not", "isinstance", "(", "v", ",", "collections", ".", "Iterable", ")", ":", "raise", "TypeError", "(", "\"Input vector must be an iterable\"", ")", "if", "not", "len", "(", "v", ")", "==", "self"...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHashLSH.insert
Insert a key to the index, together with a MinHash (or weighted MinHash) of the set referenced by the key. :param str key: The identifier of the set. :param datasketch.MinHash minhash: The MinHash of the set. :param bool check_duplication: To avoid duplicate keys in the storage...
datasketch/lsh.py
def insert(self, key, minhash, check_duplication=True): ''' Insert a key to the index, together with a MinHash (or weighted MinHash) of the set referenced by the key. :param str key: The identifier of the set. :param datasketch.MinHash minhash: The MinHash of the set. ...
def insert(self, key, minhash, check_duplication=True): ''' Insert a key to the index, together with a MinHash (or weighted MinHash) of the set referenced by the key. :param str key: The identifier of the set. :param datasketch.MinHash minhash: The MinHash of the set. ...
[ "Insert", "a", "key", "to", "the", "index", "together", "with", "a", "MinHash", "(", "or", "weighted", "MinHash", ")", "of", "the", "set", "referenced", "by", "the", "key", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lsh.py#L136-L149
[ "def", "insert", "(", "self", ",", "key", ",", "minhash", ",", "check_duplication", "=", "True", ")", ":", "self", ".", "_insert", "(", "key", ",", "minhash", ",", "check_duplication", "=", "check_duplication", ",", "buffer", "=", "False", ")" ]
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHashLSH.remove
Remove the key from the index. Args: key (hashable): The unique identifier of a set.
datasketch/lsh.py
def remove(self, key): ''' Remove the key from the index. Args: key (hashable): The unique identifier of a set. ''' if self.prepickle: key = pickle.dumps(key) if key not in self.keys: raise ValueError("The given key does not exist") ...
def remove(self, key): ''' Remove the key from the index. Args: key (hashable): The unique identifier of a set. ''' if self.prepickle: key = pickle.dumps(key) if key not in self.keys: raise ValueError("The given key does not exist") ...
[ "Remove", "the", "key", "from", "the", "index", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lsh.py#L213-L229
[ "def", "remove", "(", "self", ",", "key", ")", ":", "if", "self", ".", "prepickle", ":", "key", "=", "pickle", ".", "dumps", "(", "key", ")", "if", "key", "not", "in", "self", ".", "keys", ":", "raise", "ValueError", "(", "\"The given key does not exis...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHashLSH.get_subset_counts
Returns the bucket allocation counts (see :func:`~datasketch.MinHashLSH.get_counts` above) restricted to the list of keys given. Args: keys (hashable) : the keys for which to get the bucket allocation counts
datasketch/lsh.py
def get_subset_counts(self, *keys): ''' Returns the bucket allocation counts (see :func:`~datasketch.MinHashLSH.get_counts` above) restricted to the list of keys given. Args: keys (hashable) : the keys for which to get the bucket allocation counts '''...
def get_subset_counts(self, *keys): ''' Returns the bucket allocation counts (see :func:`~datasketch.MinHashLSH.get_counts` above) restricted to the list of keys given. Args: keys (hashable) : the keys for which to get the bucket allocation counts '''...
[ "Returns", "the", "bucket", "allocation", "counts", "(", "see", ":", "func", ":", "~datasketch", ".", "MinHashLSH", ".", "get_counts", "above", ")", "restricted", "to", "the", "list", "of", "keys", "given", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lsh.py#L268-L287
[ "def", "get_subset_counts", "(", "self", ",", "*", "keys", ")", ":", "if", "self", ".", "prepickle", ":", "key_set", "=", "[", "pickle", ".", "dumps", "(", "key", ")", "for", "key", "in", "set", "(", "keys", ")", "]", "else", ":", "key_set", "=", ...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
HyperLogLog.update
Update the HyperLogLog with a new data value in bytes. The value will be hashed using the hash function specified by the `hashfunc` argument in the constructor. Args: b: The value to be hashed using the hash function specified. Example: To update with a new stri...
datasketch/hyperloglog.py
def update(self, b): ''' Update the HyperLogLog with a new data value in bytes. The value will be hashed using the hash function specified by the `hashfunc` argument in the constructor. Args: b: The value to be hashed using the hash function specified. Examp...
def update(self, b): ''' Update the HyperLogLog with a new data value in bytes. The value will be hashed using the hash function specified by the `hashfunc` argument in the constructor. Args: b: The value to be hashed using the hash function specified. Examp...
[ "Update", "the", "HyperLogLog", "with", "a", "new", "data", "value", "in", "bytes", ".", "The", "value", "will", "be", "hashed", "using", "the", "hash", "function", "specified", "by", "the", "hashfunc", "argument", "in", "the", "constructor", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/hyperloglog.py#L89-L124
[ "def", "update", "(", "self", ",", "b", ")", ":", "# Digest the hash object to get the hash value", "hv", "=", "self", ".", "hashfunc", "(", "b", ")", "# Get the index of the register using the first p bits of the hash", "reg_index", "=", "hv", "&", "(", "self", ".", ...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
HyperLogLog.count
Estimate the cardinality of the data values seen so far. Returns: int: The estimated cardinality.
datasketch/hyperloglog.py
def count(self): ''' Estimate the cardinality of the data values seen so far. Returns: int: The estimated cardinality. ''' # Use HyperLogLog estimation function e = self.alpha * float(self.m ** 2) / np.sum(2.0**(-self.reg)) # Small range correction ...
def count(self): ''' Estimate the cardinality of the data values seen so far. Returns: int: The estimated cardinality. ''' # Use HyperLogLog estimation function e = self.alpha * float(self.m ** 2) / np.sum(2.0**(-self.reg)) # Small range correction ...
[ "Estimate", "the", "cardinality", "of", "the", "data", "values", "seen", "so", "far", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/hyperloglog.py#L126-L143
[ "def", "count", "(", "self", ")", ":", "# Use HyperLogLog estimation function", "e", "=", "self", ".", "alpha", "*", "float", "(", "self", ".", "m", "**", "2", ")", "/", "np", ".", "sum", "(", "2.0", "**", "(", "-", "self", ".", "reg", ")", ")", ...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
HyperLogLog.merge
Merge the other HyperLogLog with this one, making this the union of the two. Args: other (datasketch.HyperLogLog):
datasketch/hyperloglog.py
def merge(self, other): ''' Merge the other HyperLogLog with this one, making this the union of the two. Args: other (datasketch.HyperLogLog): ''' if self.m != other.m or self.p != other.p: raise ValueError("Cannot merge HyperLogLog with different...
def merge(self, other): ''' Merge the other HyperLogLog with this one, making this the union of the two. Args: other (datasketch.HyperLogLog): ''' if self.m != other.m or self.p != other.p: raise ValueError("Cannot merge HyperLogLog with different...
[ "Merge", "the", "other", "HyperLogLog", "with", "this", "one", "making", "this", "the", "union", "of", "the", "two", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/hyperloglog.py#L145-L156
[ "def", "merge", "(", "self", ",", "other", ")", ":", "if", "self", ".", "m", "!=", "other", ".", "m", "or", "self", ".", "p", "!=", "other", ".", "p", ":", "raise", "ValueError", "(", "\"Cannot merge HyperLogLog with different\\\n precisions...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
HyperLogLog.clear
Reset the current HyperLogLog to empty.
datasketch/hyperloglog.py
def clear(self): ''' Reset the current HyperLogLog to empty. ''' self.reg = np.zeros((self.m,), dtype=np.int8)
def clear(self): ''' Reset the current HyperLogLog to empty. ''' self.reg = np.zeros((self.m,), dtype=np.int8)
[ "Reset", "the", "current", "HyperLogLog", "to", "empty", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/hyperloglog.py#L184-L188
[ "def", "clear", "(", "self", ")", ":", "self", ".", "reg", "=", "np", ".", "zeros", "(", "(", "self", ".", "m", ",", ")", ",", "dtype", "=", "np", ".", "int8", ")" ]
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
apk
Computes the average precision at k. This function computes the average prescision at k between two lists of items. Parameters ---------- actual : list A list of elements that are to be predicted (order doesn't matter) predicted : list A list of predicted elements ...
benchmark/average_precision.py
def apk(actual, predicted, k=10): """ Computes the average precision at k. This function computes the average prescision at k between two lists of items. Parameters ---------- actual : list A list of elements that are to be predicted (order doesn't matter) predicted : list...
def apk(actual, predicted, k=10): """ Computes the average precision at k. This function computes the average prescision at k between two lists of items. Parameters ---------- actual : list A list of elements that are to be predicted (order doesn't matter) predicted : list...
[ "Computes", "the", "average", "precision", "at", "k", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/benchmark/average_precision.py#L3-L39
[ "def", "apk", "(", "actual", ",", "predicted", ",", "k", "=", "10", ")", ":", "if", "len", "(", "predicted", ")", ">", "k", ":", "predicted", "=", "predicted", "[", ":", "k", "]", "score", "=", "0.0", "num_hits", "=", "0.0", "for", "i", ",", "p...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
mapk
Computes the mean average precision at k. This function computes the mean average prescision at k between two lists of lists of items. Parameters ---------- actual : list A list of lists of elements that are to be predicted (order doesn't matter in the lists) predict...
benchmark/average_precision.py
def mapk(actual, predicted, k=10): """ Computes the mean average precision at k. This function computes the mean average prescision at k between two lists of lists of items. Parameters ---------- actual : list A list of lists of elements that are to be predicted ...
def mapk(actual, predicted, k=10): """ Computes the mean average precision at k. This function computes the mean average prescision at k between two lists of lists of items. Parameters ---------- actual : list A list of lists of elements that are to be predicted ...
[ "Computes", "the", "mean", "average", "precision", "at", "k", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/benchmark/average_precision.py#L41-L65
[ "def", "mapk", "(", "actual", ",", "predicted", ",", "k", "=", "10", ")", ":", "return", "np", ".", "mean", "(", "[", "apk", "(", "a", ",", "p", ",", "k", ")", "for", "a", ",", "p", "in", "zip", "(", "actual", ",", "predicted", ")", "]", ")...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHashLSHForest.add
Add a unique key, together with a MinHash (or weighted MinHash) of the set referenced by the key. Note: The key won't be searchbale until the :func:`datasketch.MinHashLSHForest.index` method is called. Args: key (hashable): The unique identifier of the set. ...
datasketch/lshforest.py
def add(self, key, minhash): ''' Add a unique key, together with a MinHash (or weighted MinHash) of the set referenced by the key. Note: The key won't be searchbale until the :func:`datasketch.MinHashLSHForest.index` method is called. Args: k...
def add(self, key, minhash): ''' Add a unique key, together with a MinHash (or weighted MinHash) of the set referenced by the key. Note: The key won't be searchbale until the :func:`datasketch.MinHashLSHForest.index` method is called. Args: k...
[ "Add", "a", "unique", "key", "together", "with", "a", "MinHash", "(", "or", "weighted", "MinHash", ")", "of", "the", "set", "referenced", "by", "the", "key", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshforest.py#L40-L60
[ "def", "add", "(", "self", ",", "key", ",", "minhash", ")", ":", "if", "len", "(", "minhash", ")", "<", "self", ".", "k", "*", "self", ".", "l", ":", "raise", "ValueError", "(", "\"The num_perm of MinHash out of range\"", ")", "if", "key", "in", "self"...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHashLSHForest.index
Index all the keys added so far and make them searchable.
datasketch/lshforest.py
def index(self): ''' Index all the keys added so far and make them searchable. ''' for i, hashtable in enumerate(self.hashtables): self.sorted_hashtables[i] = [H for H in hashtable.keys()] self.sorted_hashtables[i].sort()
def index(self): ''' Index all the keys added so far and make them searchable. ''' for i, hashtable in enumerate(self.hashtables): self.sorted_hashtables[i] = [H for H in hashtable.keys()] self.sorted_hashtables[i].sort()
[ "Index", "all", "the", "keys", "added", "so", "far", "and", "make", "them", "searchable", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshforest.py#L62-L68
[ "def", "index", "(", "self", ")", ":", "for", "i", ",", "hashtable", "in", "enumerate", "(", "self", ".", "hashtables", ")", ":", "self", ".", "sorted_hashtables", "[", "i", "]", "=", "[", "H", "for", "H", "in", "hashtable", ".", "keys", "(", ")", ...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHashLSHForest.query
Return the approximate top-k keys that have the highest Jaccard similarities to the query set. Args: minhash (datasketch.MinHash): The MinHash of the query set. k (int): The maximum number of keys to return. Returns: `list` of at most k keys.
datasketch/lshforest.py
def query(self, minhash, k): ''' Return the approximate top-k keys that have the highest Jaccard similarities to the query set. Args: minhash (datasketch.MinHash): The MinHash of the query set. k (int): The maximum number of keys to return. Returns: ...
def query(self, minhash, k): ''' Return the approximate top-k keys that have the highest Jaccard similarities to the query set. Args: minhash (datasketch.MinHash): The MinHash of the query set. k (int): The maximum number of keys to return. Returns: ...
[ "Return", "the", "approximate", "top", "-", "k", "keys", "that", "have", "the", "highest", "Jaccard", "similarities", "to", "the", "query", "set", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshforest.py#L87-L111
[ "def", "query", "(", "self", ",", "minhash", ",", "k", ")", ":", "if", "k", "<=", "0", ":", "raise", "ValueError", "(", "\"k must be positive\"", ")", "if", "len", "(", "minhash", ")", "<", "self", ".", "k", "*", "self", ".", "l", ":", "raise", "...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
MinHashLSHForest._binary_search
https://golang.org/src/sort/search.go?s=2247:2287#L49
datasketch/lshforest.py
def _binary_search(self, n, func): ''' https://golang.org/src/sort/search.go?s=2247:2287#L49 ''' i, j = 0, n while i < j: h = int(i + (j - i) / 2) if not func(h): i = h + 1 else: j = h return i
def _binary_search(self, n, func): ''' https://golang.org/src/sort/search.go?s=2247:2287#L49 ''' i, j = 0, n while i < j: h = int(i + (j - i) / 2) if not func(h): i = h + 1 else: j = h return i
[ "https", ":", "//", "golang", ".", "org", "/", "src", "/", "sort", "/", "search", ".", "go?s", "=", "2247", ":", "2287#L49" ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/lshforest.py#L113-L124
[ "def", "_binary_search", "(", "self", ",", "n", ",", "func", ")", ":", "i", ",", "j", "=", "0", ",", "n", "while", "i", "<", "j", ":", "h", "=", "int", "(", "i", "+", "(", "j", "-", "i", ")", "/", "2", ")", "if", "not", "func", "(", "h"...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
AsyncMinHashLSH.close
Cleanup client resources and disconnect from AsyncMinHashLSH storage.
datasketch/experimental/aio/lsh.py
async def close(self): """ Cleanup client resources and disconnect from AsyncMinHashLSH storage. """ async with self._lock: for t in self.hashtables: await t.close() if self.keys is not None: await self.keys.close() se...
async def close(self): """ Cleanup client resources and disconnect from AsyncMinHashLSH storage. """ async with self._lock: for t in self.hashtables: await t.close() if self.keys is not None: await self.keys.close() se...
[ "Cleanup", "client", "resources", "and", "disconnect", "from", "AsyncMinHashLSH", "storage", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/experimental/aio/lsh.py#L167-L178
[ "async", "def", "close", "(", "self", ")", ":", "async", "with", "self", ".", "_lock", ":", "for", "t", "in", "self", ".", "hashtables", ":", "await", "t", ".", "close", "(", ")", "if", "self", ".", "keys", "is", "not", "None", ":", "await", "sel...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
AsyncMinHashLSH.query
see :class:`datasketch.MinHashLSH`.
datasketch/experimental/aio/lsh.py
async def query(self, minhash): """ see :class:`datasketch.MinHashLSH`. """ if len(minhash) != self.h: raise ValueError("Expecting minhash with length %d, " "got %d" % (self.h, len(minhash))) fs = (hashtable.get(self._H(minhash.hashvalues...
async def query(self, minhash): """ see :class:`datasketch.MinHashLSH`. """ if len(minhash) != self.h: raise ValueError("Expecting minhash with length %d, " "got %d" % (self.h, len(minhash))) fs = (hashtable.get(self._H(minhash.hashvalues...
[ "see", ":", "class", ":", "datasketch", ".", "MinHashLSH", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/experimental/aio/lsh.py#L275-L287
[ "async", "def", "query", "(", "self", ",", "minhash", ")", ":", "if", "len", "(", "minhash", ")", "!=", "self", ".", "h", ":", "raise", "ValueError", "(", "\"Expecting minhash with length %d, \"", "\"got %d\"", "%", "(", "self", ".", "h", ",", "len", "("...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
AsyncMinHashLSH.get_counts
see :class:`datasketch.MinHashLSH`.
datasketch/experimental/aio/lsh.py
async def get_counts(self): """ see :class:`datasketch.MinHashLSH`. """ fs = (hashtable.itemcounts() for hashtable in self.hashtables) return await asyncio.gather(*fs)
async def get_counts(self): """ see :class:`datasketch.MinHashLSH`. """ fs = (hashtable.itemcounts() for hashtable in self.hashtables) return await asyncio.gather(*fs)
[ "see", ":", "class", ":", "datasketch", ".", "MinHashLSH", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/experimental/aio/lsh.py#L341-L346
[ "async", "def", "get_counts", "(", "self", ")", ":", "fs", "=", "(", "hashtable", ".", "itemcounts", "(", ")", "for", "hashtable", "in", "self", ".", "hashtables", ")", "return", "await", "asyncio", ".", "gather", "(", "*", "fs", ")" ]
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
ordered_storage
Return ordered storage system based on the specified config. The canonical example of such a storage container is ``defaultdict(list)``. Thus, the return value of this method contains keys and values. The values are ordered lists with the last added item at the end. Args: config (dict): De...
datasketch/storage.py
def ordered_storage(config, name=None): '''Return ordered storage system based on the specified config. The canonical example of such a storage container is ``defaultdict(list)``. Thus, the return value of this method contains keys and values. The values are ordered lists with the last added item a...
def ordered_storage(config, name=None): '''Return ordered storage system based on the specified config. The canonical example of such a storage container is ``defaultdict(list)``. Thus, the return value of this method contains keys and values. The values are ordered lists with the last added item a...
[ "Return", "ordered", "storage", "system", "based", "on", "the", "specified", "config", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/storage.py#L13-L46
[ "def", "ordered_storage", "(", "config", ",", "name", "=", "None", ")", ":", "tp", "=", "config", "[", "'type'", "]", "if", "tp", "==", "'dict'", ":", "return", "DictListStorage", "(", "config", ")", "if", "tp", "==", "'redis'", ":", "return", "RedisLi...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
unordered_storage
Return an unordered storage system based on the specified config. The canonical example of such a storage container is ``defaultdict(set)``. Thus, the return value of this method contains keys and values. The values are unordered sets. Args: config (dict): Defines the configurations for the st...
datasketch/storage.py
def unordered_storage(config, name=None): '''Return an unordered storage system based on the specified config. The canonical example of such a storage container is ``defaultdict(set)``. Thus, the return value of this method contains keys and values. The values are unordered sets. Args: con...
def unordered_storage(config, name=None): '''Return an unordered storage system based on the specified config. The canonical example of such a storage container is ``defaultdict(set)``. Thus, the return value of this method contains keys and values. The values are unordered sets. Args: con...
[ "Return", "an", "unordered", "storage", "system", "based", "on", "the", "specified", "config", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/storage.py#L49-L81
[ "def", "unordered_storage", "(", "config", ",", "name", "=", "None", ")", ":", "tp", "=", "config", "[", "'type'", "]", "if", "tp", "==", "'dict'", ":", "return", "DictSetStorage", "(", "config", ")", "if", "tp", "==", "'redis'", ":", "return", "RedisS...
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
DictListStorage.itemcounts
Returns a dict where the keys are the keys of the container. The values are the *lengths* of the value sequences stored in this container.
datasketch/storage.py
def itemcounts(self, **kwargs): '''Returns a dict where the keys are the keys of the container. The values are the *lengths* of the value sequences stored in this container. ''' return {k: len(v) for k, v in self._dict.items()}
def itemcounts(self, **kwargs): '''Returns a dict where the keys are the keys of the container. The values are the *lengths* of the value sequences stored in this container. ''' return {k: len(v) for k, v in self._dict.items()}
[ "Returns", "a", "dict", "where", "the", "keys", "are", "the", "keys", "of", "the", "container", ".", "The", "values", "are", "the", "*", "lengths", "*", "of", "the", "value", "sequences", "stored", "in", "this", "container", "." ]
ekzhu/datasketch
python
https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/storage.py#L191-L196
[ "def", "itemcounts", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "{", "k", ":", "len", "(", "v", ")", "for", "k", ",", "v", "in", "self", ".", "_dict", ".", "items", "(", ")", "}" ]
b3e4129987890a2beb04f2c0b6dc618ae35f2e14
test
TwitterLoginSerializer.get_social_login
:param adapter: allauth.socialaccount Adapter subclass. Usually OAuthAdapter or Auth2Adapter :param app: `allauth.socialaccount.SocialApp` instance :param token: `allauth.socialaccount.SocialToken` instance :param response: Provider's response for OAuth1. Not used in the :ret...
rest_auth/social_serializers.py
def get_social_login(self, adapter, app, token, response): """ :param adapter: allauth.socialaccount Adapter subclass. Usually OAuthAdapter or Auth2Adapter :param app: `allauth.socialaccount.SocialApp` instance :param token: `allauth.socialaccount.SocialToken` instance ...
def get_social_login(self, adapter, app, token, response): """ :param adapter: allauth.socialaccount Adapter subclass. Usually OAuthAdapter or Auth2Adapter :param app: `allauth.socialaccount.SocialApp` instance :param token: `allauth.socialaccount.SocialToken` instance ...
[ ":", "param", "adapter", ":", "allauth", ".", "socialaccount", "Adapter", "subclass", ".", "Usually", "OAuthAdapter", "or", "Auth2Adapter", ":", "param", "app", ":", "allauth", ".", "socialaccount", ".", "SocialApp", "instance", ":", "param", "token", ":", "al...
Tivix/django-rest-auth
python
https://github.com/Tivix/django-rest-auth/blob/624ad01afbc86fa15b4e652406f3bdcd01f36e00/rest_auth/social_serializers.py#L24-L38
[ "def", "get_social_login", "(", "self", ",", "adapter", ",", "app", ",", "token", ",", "response", ")", ":", "request", "=", "self", ".", "_get_request", "(", ")", "social_login", "=", "adapter", ".", "complete_login", "(", "request", ",", "app", ",", "t...
624ad01afbc86fa15b4e652406f3bdcd01f36e00
test
JWTSerializer.get_user
Required to allow using custom USER_DETAILS_SERIALIZER in JWTSerializer. Defining it here to avoid circular imports
rest_auth/serializers.py
def get_user(self, obj): """ Required to allow using custom USER_DETAILS_SERIALIZER in JWTSerializer. Defining it here to avoid circular imports """ rest_auth_serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {}) JWTUserDetailsSerializer = import_callable( ...
def get_user(self, obj): """ Required to allow using custom USER_DETAILS_SERIALIZER in JWTSerializer. Defining it here to avoid circular imports """ rest_auth_serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {}) JWTUserDetailsSerializer = import_callable( ...
[ "Required", "to", "allow", "using", "custom", "USER_DETAILS_SERIALIZER", "in", "JWTSerializer", ".", "Defining", "it", "here", "to", "avoid", "circular", "imports" ]
Tivix/django-rest-auth
python
https://github.com/Tivix/django-rest-auth/blob/624ad01afbc86fa15b4e652406f3bdcd01f36e00/rest_auth/serializers.py#L143-L153
[ "def", "get_user", "(", "self", ",", "obj", ")", ":", "rest_auth_serializers", "=", "getattr", "(", "settings", ",", "'REST_AUTH_SERIALIZERS'", ",", "{", "}", ")", "JWTUserDetailsSerializer", "=", "import_callable", "(", "rest_auth_serializers", ".", "get", "(", ...
624ad01afbc86fa15b4e652406f3bdcd01f36e00
test
SocialConnectMixin.get_social_login
Set the social login process state to connect rather than login Refer to the implementation of get_social_login in base class and to the allauth.socialaccount.helpers module complete_social_login function.
rest_auth/registration/serializers.py
def get_social_login(self, *args, **kwargs): """ Set the social login process state to connect rather than login Refer to the implementation of get_social_login in base class and to the allauth.socialaccount.helpers module complete_social_login function. """ social_login ...
def get_social_login(self, *args, **kwargs): """ Set the social login process state to connect rather than login Refer to the implementation of get_social_login in base class and to the allauth.socialaccount.helpers module complete_social_login function. """ social_login ...
[ "Set", "the", "social", "login", "process", "state", "to", "connect", "rather", "than", "login", "Refer", "to", "the", "implementation", "of", "get_social_login", "in", "base", "class", "and", "to", "the", "allauth", ".", "socialaccount", ".", "helpers", "modu...
Tivix/django-rest-auth
python
https://github.com/Tivix/django-rest-auth/blob/624ad01afbc86fa15b4e652406f3bdcd01f36e00/rest_auth/registration/serializers.py#L151-L159
[ "def", "get_social_login", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "social_login", "=", "super", "(", "SocialConnectMixin", ",", "self", ")", ".", "get_social_login", "(", "*", "args", ",", "*", "*", "kwargs", ")", "social_login...
624ad01afbc86fa15b4e652406f3bdcd01f36e00
test
select_text
Select the correct text from the Japanese number, reading and alternatives
num2words/lang_JA.py
def select_text(text, reading=False, prefer=None): """Select the correct text from the Japanese number, reading and alternatives""" # select kanji number or kana reading if reading: text = text[1] else: text = text[0] # select the preferred one or the first one from multiple alt...
def select_text(text, reading=False, prefer=None): """Select the correct text from the Japanese number, reading and alternatives""" # select kanji number or kana reading if reading: text = text[1] else: text = text[0] # select the preferred one or the first one from multiple alt...
[ "Select", "the", "correct", "text", "from", "the", "Japanese", "number", "reading", "and", "alternatives" ]
savoirfairelinux/num2words
python
https://github.com/savoirfairelinux/num2words/blob/f4b2bac098ae8e4850cf2f185f6ff52a5979641f/num2words/lang_JA.py#L25-L42
[ "def", "select_text", "(", "text", ",", "reading", "=", "False", ",", "prefer", "=", "None", ")", ":", "# select kanji number or kana reading", "if", "reading", ":", "text", "=", "text", "[", "1", "]", "else", ":", "text", "=", "text", "[", "0", "]", "...
f4b2bac098ae8e4850cf2f185f6ff52a5979641f
test
rendaku_merge_pairs
Merge lpair < rpair while applying semi-irregular rendaku rules
num2words/lang_JA.py
def rendaku_merge_pairs(lpair, rpair): """Merge lpair < rpair while applying semi-irregular rendaku rules""" ltext, lnum = lpair rtext, rnum = rpair if lnum > rnum: raise ValueError if rpair == ("ひゃく", 100): if lpair == ("さん", 3): rtext = "びゃく" elif lpair == ("ろく...
def rendaku_merge_pairs(lpair, rpair): """Merge lpair < rpair while applying semi-irregular rendaku rules""" ltext, lnum = lpair rtext, rnum = rpair if lnum > rnum: raise ValueError if rpair == ("ひゃく", 100): if lpair == ("さん", 3): rtext = "びゃく" elif lpair == ("ろく...
[ "Merge", "lpair", "<", "rpair", "while", "applying", "semi", "-", "irregular", "rendaku", "rules" ]
savoirfairelinux/num2words
python
https://github.com/savoirfairelinux/num2words/blob/f4b2bac098ae8e4850cf2f185f6ff52a5979641f/num2words/lang_JA.py#L45-L85
[ "def", "rendaku_merge_pairs", "(", "lpair", ",", "rpair", ")", ":", "ltext", ",", "lnum", "=", "lpair", "rtext", ",", "rnum", "=", "rpair", "if", "lnum", ">", "rnum", ":", "raise", "ValueError", "if", "rpair", "==", "(", "\"ひゃく\", 100)", ":", "", "", ...
f4b2bac098ae8e4850cf2f185f6ff52a5979641f
test
Num2Word_ID.split_by_3
starting here, it groups the number by three from the tail '1234567' -> (('1',),('234',),('567',)) :param number:str :rtype:tuple
num2words/lang_ID.py
def split_by_3(self, number): """ starting here, it groups the number by three from the tail '1234567' -> (('1',),('234',),('567',)) :param number:str :rtype:tuple """ blocks = () length = len(number) if length < 3: blocks += ((number,...
def split_by_3(self, number): """ starting here, it groups the number by three from the tail '1234567' -> (('1',),('234',),('567',)) :param number:str :rtype:tuple """ blocks = () length = len(number) if length < 3: blocks += ((number,...
[ "starting", "here", "it", "groups", "the", "number", "by", "three", "from", "the", "tail", "1234567", "-", ">", "((", "1", ")", "(", "234", ")", "(", "567", "))", ":", "param", "number", ":", "str", ":", "rtype", ":", "tuple" ]
savoirfairelinux/num2words
python
https://github.com/savoirfairelinux/num2words/blob/f4b2bac098ae8e4850cf2f185f6ff52a5979641f/num2words/lang_ID.py#L53-L76
[ "def", "split_by_3", "(", "self", ",", "number", ")", ":", "blocks", "=", "(", ")", "length", "=", "len", "(", "number", ")", "if", "length", "<", "3", ":", "blocks", "+=", "(", "(", "number", ",", ")", ",", ")", "else", ":", "len_of_first_block", ...
f4b2bac098ae8e4850cf2f185f6ff52a5979641f
test
Num2Word_ID.spell
it adds the list of spelling to the blocks ( ('1',),('034',)) -> (('1',['satu']),('234',['tiga', 'puluh', 'empat']) ) :param blocks: tuple :rtype: tuple
num2words/lang_ID.py
def spell(self, blocks): """ it adds the list of spelling to the blocks ( ('1',),('034',)) -> (('1',['satu']),('234',['tiga', 'puluh', 'empat']) ) :param blocks: tuple :rtype: tuple """ word_blocks = () first_block = blocks[0] if le...
def spell(self, blocks): """ it adds the list of spelling to the blocks ( ('1',),('034',)) -> (('1',['satu']),('234',['tiga', 'puluh', 'empat']) ) :param blocks: tuple :rtype: tuple """ word_blocks = () first_block = blocks[0] if le...
[ "it", "adds", "the", "list", "of", "spelling", "to", "the", "blocks", "(", "(", "1", ")", "(", "034", "))", "-", ">", "((", "1", "[", "satu", "]", ")", "(", "234", "[", "tiga", "puluh", "empat", "]", ")", ")", ":", "param", "blocks", ":", "tu...
savoirfairelinux/num2words
python
https://github.com/savoirfairelinux/num2words/blob/f4b2bac098ae8e4850cf2f185f6ff52a5979641f/num2words/lang_ID.py#L78-L108
[ "def", "spell", "(", "self", ",", "blocks", ")", ":", "word_blocks", "=", "(", ")", "first_block", "=", "blocks", "[", "0", "]", "if", "len", "(", "first_block", "[", "0", "]", ")", "==", "1", ":", "if", "first_block", "[", "0", "]", "==", "'0'",...
f4b2bac098ae8e4850cf2f185f6ff52a5979641f
test
Num2Word_ID.join
join the words by first join lists in the tuple :param word_blocks: tuple :rtype: str
num2words/lang_ID.py
def join(self, word_blocks, float_part): """ join the words by first join lists in the tuple :param word_blocks: tuple :rtype: str """ word_list = [] length = len(word_blocks) - 1 first_block = word_blocks[0], start = 0 if length == 1 and ...
def join(self, word_blocks, float_part): """ join the words by first join lists in the tuple :param word_blocks: tuple :rtype: str """ word_list = [] length = len(word_blocks) - 1 first_block = word_blocks[0], start = 0 if length == 1 and ...
[ "join", "the", "words", "by", "first", "join", "lists", "in", "the", "tuple", ":", "param", "word_blocks", ":", "tuple", ":", "rtype", ":", "str" ]
savoirfairelinux/num2words
python
https://github.com/savoirfairelinux/num2words/blob/f4b2bac098ae8e4850cf2f185f6ff52a5979641f/num2words/lang_ID.py#L146-L169
[ "def", "join", "(", "self", ",", "word_blocks", ",", "float_part", ")", ":", "word_list", "=", "[", "]", "length", "=", "len", "(", "word_blocks", ")", "-", "1", "first_block", "=", "word_blocks", "[", "0", "]", ",", "start", "=", "0", "if", "length"...
f4b2bac098ae8e4850cf2f185f6ff52a5979641f
test
Num2Word_Base.to_currency
Args: val: Numeric value currency (str): Currency code cents (bool): Verbose cents separator (str): Cent separator adjective (bool): Prefix currency name with adjective Returns: str: Formatted string
num2words/base.py
def to_currency(self, val, currency='EUR', cents=True, separator=',', adjective=False): """ Args: val: Numeric value currency (str): Currency code cents (bool): Verbose cents separator (str): Cent separator adjective (bool):...
def to_currency(self, val, currency='EUR', cents=True, separator=',', adjective=False): """ Args: val: Numeric value currency (str): Currency code cents (bool): Verbose cents separator (str): Cent separator adjective (bool):...
[ "Args", ":", "val", ":", "Numeric", "value", "currency", "(", "str", ")", ":", "Currency", "code", "cents", "(", "bool", ")", ":", "Verbose", "cents", "separator", "(", "str", ")", ":", "Cent", "separator", "adjective", "(", "bool", ")", ":", "Prefix",...
savoirfairelinux/num2words
python
https://github.com/savoirfairelinux/num2words/blob/f4b2bac098ae8e4850cf2f185f6ff52a5979641f/num2words/base.py#L266-L303
[ "def", "to_currency", "(", "self", ",", "val", ",", "currency", "=", "'EUR'", ",", "cents", "=", "True", ",", "separator", "=", "','", ",", "adjective", "=", "False", ")", ":", "left", ",", "right", ",", "is_negative", "=", "parse_currency_parts", "(", ...
f4b2bac098ae8e4850cf2f185f6ff52a5979641f
test
parse_scoped_selector
Parse scoped selector.
gin/config_parser.py
def parse_scoped_selector(scoped_selector): """Parse scoped selector.""" # Conver Macro (%scope/name) to (scope/name/macro.value) if scoped_selector[0] == '%': if scoped_selector.endswith('.value'): err_str = '{} is invalid cannot use % and end with .value' raise ValueError(err_str.format(scoped_s...
def parse_scoped_selector(scoped_selector): """Parse scoped selector.""" # Conver Macro (%scope/name) to (scope/name/macro.value) if scoped_selector[0] == '%': if scoped_selector.endswith('.value'): err_str = '{} is invalid cannot use % and end with .value' raise ValueError(err_str.format(scoped_s...
[ "Parse", "scoped", "selector", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config_parser.py#L455-L466
[ "def", "parse_scoped_selector", "(", "scoped_selector", ")", ":", "# Conver Macro (%scope/name) to (scope/name/macro.value)", "if", "scoped_selector", "[", "0", "]", "==", "'%'", ":", "if", "scoped_selector", ".", "endswith", "(", "'.value'", ")", ":", "err_str", "=",...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
ConfigParser.parse_statement
Parse a single statement. Returns: Either a `BindingStatement`, `ImportStatement`, `IncludeStatement`, or `None` if no more statements can be parsed (EOF reached).
gin/config_parser.py
def parse_statement(self): """Parse a single statement. Returns: Either a `BindingStatement`, `ImportStatement`, `IncludeStatement`, or `None` if no more statements can be parsed (EOF reached). """ self._skip_whitespace_and_comments() if self._current_token.kind == tokenize.ENDMARKER: ...
def parse_statement(self): """Parse a single statement. Returns: Either a `BindingStatement`, `ImportStatement`, `IncludeStatement`, or `None` if no more statements can be parsed (EOF reached). """ self._skip_whitespace_and_comments() if self._current_token.kind == tokenize.ENDMARKER: ...
[ "Parse", "a", "single", "statement", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config_parser.py#L193-L234
[ "def", "parse_statement", "(", "self", ")", ":", "self", ".", "_skip_whitespace_and_comments", "(", ")", "if", "self", ".", "_current_token", ".", "kind", "==", "tokenize", ".", "ENDMARKER", ":", "return", "None", "# Save off location, but ignore char_num for any stat...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
ConfigParser.parse_value
Parse a single literal value. Returns: The parsed value.
gin/config_parser.py
def parse_value(self): """Parse a single literal value. Returns: The parsed value. """ parsers = [ self._maybe_parse_container, self._maybe_parse_basic_type, self._maybe_parse_configurable_reference, self._maybe_parse_macro ] for parser in parsers: success, value = p...
def parse_value(self): """Parse a single literal value. Returns: The parsed value. """ parsers = [ self._maybe_parse_container, self._maybe_parse_basic_type, self._maybe_parse_configurable_reference, self._maybe_parse_macro ] for parser in parsers: success, value = p...
[ "Parse", "a", "single", "literal", "value", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config_parser.py#L236-L250
[ "def", "parse_value", "(", "self", ")", ":", "parsers", "=", "[", "self", ".", "_maybe_parse_container", ",", "self", ".", "_maybe_parse_basic_type", ",", "self", ".", "_maybe_parse_configurable_reference", ",", "self", ".", "_maybe_parse_macro", "]", "for", "pars...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
ConfigParser.advance_one_line
Advances to next line.
gin/config_parser.py
def advance_one_line(self): """Advances to next line.""" current_line = self._current_token.line_number while current_line == self._current_token.line_number: self._current_token = ConfigParser.Token(*next(self._token_generator))
def advance_one_line(self): """Advances to next line.""" current_line = self._current_token.line_number while current_line == self._current_token.line_number: self._current_token = ConfigParser.Token(*next(self._token_generator))
[ "Advances", "to", "next", "line", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config_parser.py#L260-L265
[ "def", "advance_one_line", "(", "self", ")", ":", "current_line", "=", "self", ".", "_current_token", ".", "line_number", "while", "current_line", "==", "self", ".", "_current_token", ".", "line_number", ":", "self", ".", "_current_token", "=", "ConfigParser", "...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
ConfigParser._parse_selector
Parse a (possibly scoped) selector. A selector is a sequence of one or more valid Python-style identifiers separated by periods (see also `SelectorMap`). A scoped selector is a selector that may be preceded by scope names (separated by slashes). Args: scoped: Whether scopes are allowed. al...
gin/config_parser.py
def _parse_selector(self, scoped=True, allow_periods_in_scope=False): """Parse a (possibly scoped) selector. A selector is a sequence of one or more valid Python-style identifiers separated by periods (see also `SelectorMap`). A scoped selector is a selector that may be preceded by scope names (separat...
def _parse_selector(self, scoped=True, allow_periods_in_scope=False): """Parse a (possibly scoped) selector. A selector is a sequence of one or more valid Python-style identifiers separated by periods (see also `SelectorMap`). A scoped selector is a selector that may be preceded by scope names (separat...
[ "Parse", "a", "(", "possibly", "scoped", ")", "selector", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config_parser.py#L297-L354
[ "def", "_parse_selector", "(", "self", ",", "scoped", "=", "True", ",", "allow_periods_in_scope", "=", "False", ")", ":", "if", "self", ".", "_current_token", ".", "kind", "!=", "tokenize", ".", "NAME", ":", "self", ".", "_raise_syntax_error", "(", "'Unexpec...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
ConfigParser._maybe_parse_container
Try to parse a container type (dict, list, or tuple).
gin/config_parser.py
def _maybe_parse_container(self): """Try to parse a container type (dict, list, or tuple).""" bracket_types = { '{': ('}', dict, self._parse_dict_item), '(': (')', tuple, self.parse_value), '[': (']', list, self.parse_value) } if self._current_token.value in bracket_types: ...
def _maybe_parse_container(self): """Try to parse a container type (dict, list, or tuple).""" bracket_types = { '{': ('}', dict, self._parse_dict_item), '(': (')', tuple, self.parse_value), '[': (']', list, self.parse_value) } if self._current_token.value in bracket_types: ...
[ "Try", "to", "parse", "a", "container", "type", "(", "dict", "list", "or", "tuple", ")", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config_parser.py#L356-L386
[ "def", "_maybe_parse_container", "(", "self", ")", ":", "bracket_types", "=", "{", "'{'", ":", "(", "'}'", ",", "dict", ",", "self", ".", "_parse_dict_item", ")", ",", "'('", ":", "(", "')'", ",", "tuple", ",", "self", ".", "parse_value", ")", ",", "...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
ConfigParser._maybe_parse_basic_type
Try to parse a basic type (str, bool, number).
gin/config_parser.py
def _maybe_parse_basic_type(self): """Try to parse a basic type (str, bool, number).""" token_value = '' # Allow a leading dash to handle negative numbers. if self._current_token.value == '-': token_value += self._current_token.value self._advance() basic_type_tokens = [tokenize.NAME, t...
def _maybe_parse_basic_type(self): """Try to parse a basic type (str, bool, number).""" token_value = '' # Allow a leading dash to handle negative numbers. if self._current_token.value == '-': token_value += self._current_token.value self._advance() basic_type_tokens = [tokenize.NAME, t...
[ "Try", "to", "parse", "a", "basic", "type", "(", "str", "bool", "number", ")", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config_parser.py#L388-L415
[ "def", "_maybe_parse_basic_type", "(", "self", ")", ":", "token_value", "=", "''", "# Allow a leading dash to handle negative numbers.", "if", "self", ".", "_current_token", ".", "value", "==", "'-'", ":", "token_value", "+=", "self", ".", "_current_token", ".", "va...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
ConfigParser._maybe_parse_configurable_reference
Try to parse a configurable reference (@[scope/name/]fn_name[()]).
gin/config_parser.py
def _maybe_parse_configurable_reference(self): """Try to parse a configurable reference (@[scope/name/]fn_name[()]).""" if self._current_token.value != '@': return False, None location = self._current_location() self._advance_one_token() scoped_name = self._parse_selector(allow_periods_in_sco...
def _maybe_parse_configurable_reference(self): """Try to parse a configurable reference (@[scope/name/]fn_name[()]).""" if self._current_token.value != '@': return False, None location = self._current_location() self._advance_one_token() scoped_name = self._parse_selector(allow_periods_in_sco...
[ "Try", "to", "parse", "a", "configurable", "reference", "(" ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config_parser.py#L417-L438
[ "def", "_maybe_parse_configurable_reference", "(", "self", ")", ":", "if", "self", ".", "_current_token", ".", "value", "!=", "'@'", ":", "return", "False", ",", "None", "location", "=", "self", ".", "_current_location", "(", ")", "self", ".", "_advance_one_to...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
ConfigParser._maybe_parse_macro
Try to parse an macro (%scope/name).
gin/config_parser.py
def _maybe_parse_macro(self): """Try to parse an macro (%scope/name).""" if self._current_token.value != '%': return False, None location = self._current_location() self._advance_one_token() scoped_name = self._parse_selector(allow_periods_in_scope=True) with utils.try_with_location(loca...
def _maybe_parse_macro(self): """Try to parse an macro (%scope/name).""" if self._current_token.value != '%': return False, None location = self._current_location() self._advance_one_token() scoped_name = self._parse_selector(allow_periods_in_scope=True) with utils.try_with_location(loca...
[ "Try", "to", "parse", "an", "macro", "(", "%scope", "/", "name", ")", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config_parser.py#L440-L452
[ "def", "_maybe_parse_macro", "(", "self", ")", ":", "if", "self", ".", "_current_token", ".", "value", "!=", "'%'", ":", "return", "False", ",", "None", "location", "=", "self", ".", "_current_location", "(", ")", "self", ".", "_advance_one_token", "(", ")...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
augment_exception_message_and_reraise
Reraises `exception`, appending `message` to its string representation.
gin/utils.py
def augment_exception_message_and_reraise(exception, message): """Reraises `exception`, appending `message` to its string representation.""" class ExceptionProxy(type(exception)): """Acts as a proxy for an exception with an augmented message.""" __module__ = type(exception).__module__ def __init__(sel...
def augment_exception_message_and_reraise(exception, message): """Reraises `exception`, appending `message` to its string representation.""" class ExceptionProxy(type(exception)): """Acts as a proxy for an exception with an augmented message.""" __module__ = type(exception).__module__ def __init__(sel...
[ "Reraises", "exception", "appending", "message", "to", "its", "string", "representation", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/utils.py#L28-L51
[ "def", "augment_exception_message_and_reraise", "(", "exception", ",", "message", ")", ":", "class", "ExceptionProxy", "(", "type", "(", "exception", ")", ")", ":", "\"\"\"Acts as a proxy for an exception with an augmented message.\"\"\"", "__module__", "=", "type", "(", ...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
GinConfigSaverHook._markdownify_operative_config_str
Convert an operative config string to markdown format.
gin/tf/utils.py
def _markdownify_operative_config_str(self, string): """Convert an operative config string to markdown format.""" # TODO: Total hack below. Implement more principled formatting. def process(line): """Convert a single line to markdown format.""" if not line.startswith('#'): return ' '...
def _markdownify_operative_config_str(self, string): """Convert an operative config string to markdown format.""" # TODO: Total hack below. Implement more principled formatting. def process(line): """Convert a single line to markdown format.""" if not line.startswith('#'): return ' '...
[ "Convert", "an", "operative", "config", "string", "to", "markdown", "format", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/tf/utils.py#L82-L106
[ "def", "_markdownify_operative_config_str", "(", "self", ",", "string", ")", ":", "# TODO: Total hack below. Implement more principled formatting.", "def", "process", "(", "line", ")", ":", "\"\"\"Convert a single line to markdown format.\"\"\"", "if", "not", "line", ".", "st...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
GinConfigSaverHook.after_create_session
Writes out Gin's operative config, and maybe adds a summary of it.
gin/tf/utils.py
def after_create_session(self, session=None, coord=None): """Writes out Gin's operative config, and maybe adds a summary of it.""" config_str = config.operative_config_str() if not tf.gfile.IsDirectory(self._output_dir): tf.gfile.MakeDirs(self._output_dir) global_step_val = 0 if session is not...
def after_create_session(self, session=None, coord=None): """Writes out Gin's operative config, and maybe adds a summary of it.""" config_str = config.operative_config_str() if not tf.gfile.IsDirectory(self._output_dir): tf.gfile.MakeDirs(self._output_dir) global_step_val = 0 if session is not...
[ "Writes", "out", "Gin", "s", "operative", "config", "and", "maybe", "adds", "a", "summary", "of", "it", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/tf/utils.py#L108-L140
[ "def", "after_create_session", "(", "self", ",", "session", "=", "None", ",", "coord", "=", "None", ")", ":", "config_str", "=", "config", ".", "operative_config_str", "(", ")", "if", "not", "tf", ".", "gfile", ".", "IsDirectory", "(", "self", ".", "_out...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
_find_class_construction_fn
Find the first __init__ or __new__ method in the given class's MRO.
gin/config.py
def _find_class_construction_fn(cls): """Find the first __init__ or __new__ method in the given class's MRO.""" for base in type.mro(cls): if '__init__' in base.__dict__: return base.__init__ if '__new__' in base.__dict__: return base.__new__
def _find_class_construction_fn(cls): """Find the first __init__ or __new__ method in the given class's MRO.""" for base in type.mro(cls): if '__init__' in base.__dict__: return base.__init__ if '__new__' in base.__dict__: return base.__new__
[ "Find", "the", "first", "__init__", "or", "__new__", "method", "in", "the", "given", "class", "s", "MRO", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config.py#L155-L161
[ "def", "_find_class_construction_fn", "(", "cls", ")", ":", "for", "base", "in", "type", ".", "mro", "(", "cls", ")", ":", "if", "'__init__'", "in", "base", ".", "__dict__", ":", "return", "base", ".", "__init__", "if", "'__new__'", "in", "base", ".", ...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
_ensure_wrappability
Make sure `fn` can be wrapped cleanly by functools.wraps.
gin/config.py
def _ensure_wrappability(fn): """Make sure `fn` can be wrapped cleanly by functools.wraps.""" # Handle "wrapped_descriptor" and "method-wrapper" types. if isinstance(fn, (type(object.__init__), type(object.__call__))): # pylint: disable=unnecessary-lambda wrappable_fn = lambda *args, **kwargs: fn(*args, *...
def _ensure_wrappability(fn): """Make sure `fn` can be wrapped cleanly by functools.wraps.""" # Handle "wrapped_descriptor" and "method-wrapper" types. if isinstance(fn, (type(object.__init__), type(object.__call__))): # pylint: disable=unnecessary-lambda wrappable_fn = lambda *args, **kwargs: fn(*args, *...
[ "Make", "sure", "fn", "can", "be", "wrapped", "cleanly", "by", "functools", ".", "wraps", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config.py#L164-L177
[ "def", "_ensure_wrappability", "(", "fn", ")", ":", "# Handle \"wrapped_descriptor\" and \"method-wrapper\" types.", "if", "isinstance", "(", "fn", ",", "(", "type", "(", "object", ".", "__init__", ")", ",", "type", "(", "object", ".", "__call__", ")", ")", ")",...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
_decorate_fn_or_cls
Decorate a function or class with the given decorator. When `fn_or_cls` is a function, applies `decorator` to the function and returns the (decorated) result. When `fn_or_cls` is a class and the `subclass` parameter is `False`, this will replace `fn_or_cls.__init__` with the result of applying `decorator` to ...
gin/config.py
def _decorate_fn_or_cls(decorator, fn_or_cls, subclass=False): """Decorate a function or class with the given decorator. When `fn_or_cls` is a function, applies `decorator` to the function and returns the (decorated) result. When `fn_or_cls` is a class and the `subclass` parameter is `False`, this will repl...
def _decorate_fn_or_cls(decorator, fn_or_cls, subclass=False): """Decorate a function or class with the given decorator. When `fn_or_cls` is a function, applies `decorator` to the function and returns the (decorated) result. When `fn_or_cls` is a class and the `subclass` parameter is `False`, this will repl...
[ "Decorate", "a", "function", "or", "class", "with", "the", "given", "decorator", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config.py#L180-L226
[ "def", "_decorate_fn_or_cls", "(", "decorator", ",", "fn_or_cls", ",", "subclass", "=", "False", ")", ":", "if", "not", "inspect", ".", "isclass", "(", "fn_or_cls", ")", ":", "return", "decorator", "(", "_ensure_wrappability", "(", "fn_or_cls", ")", ")", "co...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
_should_skip
Checks whether `selector` should be skipped (if unknown).
gin/config.py
def _should_skip(selector, skip_unknown): """Checks whether `selector` should be skipped (if unknown).""" _validate_skip_unknown(skip_unknown) if _REGISTRY.matching_selectors(selector): return False # Never skip known configurables. if isinstance(skip_unknown, (list, tuple, set)): return selector in sk...
def _should_skip(selector, skip_unknown): """Checks whether `selector` should be skipped (if unknown).""" _validate_skip_unknown(skip_unknown) if _REGISTRY.matching_selectors(selector): return False # Never skip known configurables. if isinstance(skip_unknown, (list, tuple, set)): return selector in sk...
[ "Checks", "whether", "selector", "should", "be", "skipped", "(", "if", "unknown", ")", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config.py#L382-L389
[ "def", "_should_skip", "(", "selector", ",", "skip_unknown", ")", ":", "_validate_skip_unknown", "(", "skip_unknown", ")", "if", "_REGISTRY", ".", "matching_selectors", "(", "selector", ")", ":", "return", "False", "# Never skip known configurables.", "if", "isinstanc...
17a170e0a6711005d1c78e67cf493dc44674d44f
test
_format_value
Returns `value` in a format parseable by `parse_value`, or `None`. Simply put, This function ensures that when it returns a string value, the following will hold: parse_value(_format_value(value)) == value Args: value: The value to format. Returns: A string representation of `value` when `valu...
gin/config.py
def _format_value(value): """Returns `value` in a format parseable by `parse_value`, or `None`. Simply put, This function ensures that when it returns a string value, the following will hold: parse_value(_format_value(value)) == value Args: value: The value to format. Returns: A string repre...
def _format_value(value): """Returns `value` in a format parseable by `parse_value`, or `None`. Simply put, This function ensures that when it returns a string value, the following will hold: parse_value(_format_value(value)) == value Args: value: The value to format. Returns: A string repre...
[ "Returns", "value", "in", "a", "format", "parseable", "by", "parse_value", "or", "None", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config.py#L503-L524
[ "def", "_format_value", "(", "value", ")", ":", "literal", "=", "repr", "(", "value", ")", "try", ":", "if", "parse_value", "(", "literal", ")", "==", "value", ":", "return", "literal", "except", "SyntaxError", ":", "pass", "return", "None" ]
17a170e0a6711005d1c78e67cf493dc44674d44f
test
clear_config
Clears the global configuration. This clears any parameter values set by `bind_parameter` or `parse_config`, as well as the set of dynamically imported modules. It does not remove any configurable functions or classes from the registry of configurables. Args: clear_constants: Whether to clear constants cr...
gin/config.py
def clear_config(clear_constants=False): """Clears the global configuration. This clears any parameter values set by `bind_parameter` or `parse_config`, as well as the set of dynamically imported modules. It does not remove any configurable functions or classes from the registry of configurables. Args: ...
def clear_config(clear_constants=False): """Clears the global configuration. This clears any parameter values set by `bind_parameter` or `parse_config`, as well as the set of dynamically imported modules. It does not remove any configurable functions or classes from the registry of configurables. Args: ...
[ "Clears", "the", "global", "configuration", "." ]
google/gin-config
python
https://github.com/google/gin-config/blob/17a170e0a6711005d1c78e67cf493dc44674d44f/gin/config.py#L540-L562
[ "def", "clear_config", "(", "clear_constants", "=", "False", ")", ":", "_set_config_is_locked", "(", "False", ")", "_CONFIG", ".", "clear", "(", ")", "_SINGLETONS", ".", "clear", "(", ")", "if", "clear_constants", ":", "_CONSTANTS", ".", "clear", "(", ")", ...
17a170e0a6711005d1c78e67cf493dc44674d44f