repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
dnephin/PyStaticConfiguration | staticconf/config.py | get_namespaces_from_names | def get_namespaces_from_names(name, all_names):
"""Return a generator which yields namespace objects."""
names = configuration_namespaces.keys() if all_names else [name]
for name in names:
yield get_namespace(name) | python | def get_namespaces_from_names(name, all_names):
"""Return a generator which yields namespace objects."""
names = configuration_namespaces.keys() if all_names else [name]
for name in names:
yield get_namespace(name) | [
"def",
"get_namespaces_from_names",
"(",
"name",
",",
"all_names",
")",
":",
"names",
"=",
"configuration_namespaces",
".",
"keys",
"(",
")",
"if",
"all_names",
"else",
"[",
"name",
"]",
"for",
"name",
"in",
"names",
":",
"yield",
"get_namespace",
"(",
"name... | Return a generator which yields namespace objects. | [
"Return",
"a",
"generator",
"which",
"yields",
"namespace",
"objects",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L181-L185 |
dnephin/PyStaticConfiguration | staticconf/config.py | get_namespace | def get_namespace(name):
"""Return a :class:`ConfigNamespace` by name, creating the
namespace if it does not exist.
"""
if name not in configuration_namespaces:
configuration_namespaces[name] = ConfigNamespace(name)
return configuration_namespaces[name] | python | def get_namespace(name):
"""Return a :class:`ConfigNamespace` by name, creating the
namespace if it does not exist.
"""
if name not in configuration_namespaces:
configuration_namespaces[name] = ConfigNamespace(name)
return configuration_namespaces[name] | [
"def",
"get_namespace",
"(",
"name",
")",
":",
"if",
"name",
"not",
"in",
"configuration_namespaces",
":",
"configuration_namespaces",
"[",
"name",
"]",
"=",
"ConfigNamespace",
"(",
"name",
")",
"return",
"configuration_namespaces",
"[",
"name",
"]"
] | Return a :class:`ConfigNamespace` by name, creating the
namespace if it does not exist. | [
"Return",
"a",
":",
"class",
":",
"ConfigNamespace",
"by",
"name",
"creating",
"the",
"namespace",
"if",
"it",
"does",
"not",
"exist",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L188-L194 |
dnephin/PyStaticConfiguration | staticconf/config.py | reload | def reload(name=DEFAULT, all_names=False):
"""Reload one or all :class:`ConfigNamespace`. Reload clears the cache of
:mod:`staticconf.schema` and :mod:`staticconf.getters`, allowing them to
pickup the latest values in the namespace.
Defaults to reloading just the DEFAULT namespace.
:param name: th... | python | def reload(name=DEFAULT, all_names=False):
"""Reload one or all :class:`ConfigNamespace`. Reload clears the cache of
:mod:`staticconf.schema` and :mod:`staticconf.getters`, allowing them to
pickup the latest values in the namespace.
Defaults to reloading just the DEFAULT namespace.
:param name: th... | [
"def",
"reload",
"(",
"name",
"=",
"DEFAULT",
",",
"all_names",
"=",
"False",
")",
":",
"for",
"namespace",
"in",
"get_namespaces_from_names",
"(",
"name",
",",
"all_names",
")",
":",
"for",
"value_proxy",
"in",
"namespace",
".",
"get_value_proxies",
"(",
")... | Reload one or all :class:`ConfigNamespace`. Reload clears the cache of
:mod:`staticconf.schema` and :mod:`staticconf.getters`, allowing them to
pickup the latest values in the namespace.
Defaults to reloading just the DEFAULT namespace.
:param name: the name of the :class:`ConfigNamespace` to reload
... | [
"Reload",
"one",
"or",
"all",
":",
"class",
":",
"ConfigNamespace",
".",
"Reload",
"clears",
"the",
"cache",
"of",
":",
"mod",
":",
"staticconf",
".",
"schema",
"and",
":",
"mod",
":",
"staticconf",
".",
"getters",
"allowing",
"them",
"to",
"pickup",
"th... | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L197-L209 |
dnephin/PyStaticConfiguration | staticconf/config.py | validate | def validate(name=DEFAULT, all_names=False):
"""Validate all registered keys after loading configuration.
Missing values or values which do not pass validation raise
:class:`staticconf.errors.ConfigurationError`. By default only validates
the `DEFAULT` namespace.
:param name: the namespace to vali... | python | def validate(name=DEFAULT, all_names=False):
"""Validate all registered keys after loading configuration.
Missing values or values which do not pass validation raise
:class:`staticconf.errors.ConfigurationError`. By default only validates
the `DEFAULT` namespace.
:param name: the namespace to vali... | [
"def",
"validate",
"(",
"name",
"=",
"DEFAULT",
",",
"all_names",
"=",
"False",
")",
":",
"for",
"namespace",
"in",
"get_namespaces_from_names",
"(",
"name",
",",
"all_names",
")",
":",
"all",
"(",
"value_proxy",
".",
"get_value",
"(",
")",
"for",
"value_p... | Validate all registered keys after loading configuration.
Missing values or values which do not pass validation raise
:class:`staticconf.errors.ConfigurationError`. By default only validates
the `DEFAULT` namespace.
:param name: the namespace to validate
:type name: string
:param all_names: i... | [
"Validate",
"all",
"registered",
"keys",
"after",
"loading",
"configuration",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L212-L225 |
dnephin/PyStaticConfiguration | staticconf/config.py | has_duplicate_keys | def has_duplicate_keys(config_data, base_conf, raise_error):
"""Compare two dictionaries for duplicate keys. if raise_error is True
then raise on exception, otherwise log return True."""
duplicate_keys = set(base_conf) & set(config_data)
if not duplicate_keys:
return
msg = "Duplicate keys in... | python | def has_duplicate_keys(config_data, base_conf, raise_error):
"""Compare two dictionaries for duplicate keys. if raise_error is True
then raise on exception, otherwise log return True."""
duplicate_keys = set(base_conf) & set(config_data)
if not duplicate_keys:
return
msg = "Duplicate keys in... | [
"def",
"has_duplicate_keys",
"(",
"config_data",
",",
"base_conf",
",",
"raise_error",
")",
":",
"duplicate_keys",
"=",
"set",
"(",
"base_conf",
")",
"&",
"set",
"(",
"config_data",
")",
"if",
"not",
"duplicate_keys",
":",
"return",
"msg",
"=",
"\"Duplicate ke... | Compare two dictionaries for duplicate keys. if raise_error is True
then raise on exception, otherwise log return True. | [
"Compare",
"two",
"dictionaries",
"for",
"duplicate",
"keys",
".",
"if",
"raise_error",
"is",
"True",
"then",
"raise",
"on",
"exception",
"otherwise",
"log",
"return",
"True",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L276-L286 |
dnephin/PyStaticConfiguration | staticconf/config.py | build_compare_func | def build_compare_func(err_logger=None):
"""Returns a compare_func that can be passed to MTimeComparator.
The returned compare_func first tries os.path.getmtime(filename),
then calls err_logger(filename) if that fails. If err_logger is None,
then it does nothing. err_logger is always called within the ... | python | def build_compare_func(err_logger=None):
"""Returns a compare_func that can be passed to MTimeComparator.
The returned compare_func first tries os.path.getmtime(filename),
then calls err_logger(filename) if that fails. If err_logger is None,
then it does nothing. err_logger is always called within the ... | [
"def",
"build_compare_func",
"(",
"err_logger",
"=",
"None",
")",
":",
"def",
"compare_func",
"(",
"filename",
")",
":",
"try",
":",
"return",
"os",
".",
"path",
".",
"getmtime",
"(",
"filename",
")",
"except",
"OSError",
":",
"if",
"err_logger",
"is",
"... | Returns a compare_func that can be passed to MTimeComparator.
The returned compare_func first tries os.path.getmtime(filename),
then calls err_logger(filename) if that fails. If err_logger is None,
then it does nothing. err_logger is always called within the context of
an OSError raised by os.path.getm... | [
"Returns",
"a",
"compare_func",
"that",
"can",
"be",
"passed",
"to",
"MTimeComparator",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L436-L451 |
dnephin/PyStaticConfiguration | staticconf/config.py | ConfigNamespace.get_config_dict | def get_config_dict(self):
"""Reconstruct the nested structure of this object's configuration
and return it as a dict.
"""
config_dict = {}
for dotted_key, value in self.get_config_values().items():
subkeys = dotted_key.split('.')
d = config_dict
... | python | def get_config_dict(self):
"""Reconstruct the nested structure of this object's configuration
and return it as a dict.
"""
config_dict = {}
for dotted_key, value in self.get_config_values().items():
subkeys = dotted_key.split('.')
d = config_dict
... | [
"def",
"get_config_dict",
"(",
"self",
")",
":",
"config_dict",
"=",
"{",
"}",
"for",
"dotted_key",
",",
"value",
"in",
"self",
".",
"get_config_values",
"(",
")",
".",
"items",
"(",
")",
":",
"subkeys",
"=",
"dotted_key",
".",
"split",
"(",
"'.'",
")"... | Reconstruct the nested structure of this object's configuration
and return it as a dict. | [
"Reconstruct",
"the",
"nested",
"structure",
"of",
"this",
"object",
"s",
"configuration",
"and",
"return",
"it",
"as",
"a",
"dict",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L114-L124 |
dnephin/PyStaticConfiguration | staticconf/config.py | ConfigHelp.view_help | def view_help(self):
"""Return a help message describing all the statically configured keys.
"""
def format_desc(desc):
return "%s (Type: %s, Default: %s)\n%s" % (
desc.name,
desc.validator.__name__.replace('validate_', ''),
... | python | def view_help(self):
"""Return a help message describing all the statically configured keys.
"""
def format_desc(desc):
return "%s (Type: %s, Default: %s)\n%s" % (
desc.name,
desc.validator.__name__.replace('validate_', ''),
... | [
"def",
"view_help",
"(",
"self",
")",
":",
"def",
"format_desc",
"(",
"desc",
")",
":",
"return",
"\"%s (Type: %s, Default: %s)\\n%s\"",
"%",
"(",
"desc",
".",
"name",
",",
"desc",
".",
"validator",
".",
"__name__",
".",
"replace",
"(",
"'validate_'",
",",
... | Return a help message describing all the statically configured keys. | [
"Return",
"a",
"help",
"message",
"describing",
"all",
"the",
"statically",
"configured",
"keys",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L238-L259 |
dnephin/PyStaticConfiguration | staticconf/config.py | ConfigurationWatcher.reload_if_changed | def reload_if_changed(self, force=False):
"""If the file(s) being watched by this object have changed,
their configuration will be loaded again using `config_loader`.
Otherwise this is a noop.
:param force: If True ignore the `min_interval` and proceed to
file modified compa... | python | def reload_if_changed(self, force=False):
"""If the file(s) being watched by this object have changed,
their configuration will be loaded again using `config_loader`.
Otherwise this is a noop.
:param force: If True ignore the `min_interval` and proceed to
file modified compa... | [
"def",
"reload_if_changed",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"if",
"(",
"force",
"or",
"self",
".",
"should_check",
")",
"and",
"self",
".",
"file_modified",
"(",
")",
":",
"return",
"self",
".",
"reload",
"(",
")"
] | If the file(s) being watched by this object have changed,
their configuration will be loaded again using `config_loader`.
Otherwise this is a noop.
:param force: If True ignore the `min_interval` and proceed to
file modified comparisons. To force a reload use
:func:`rel... | [
"If",
"the",
"file",
"(",
"s",
")",
"being",
"watched",
"by",
"this",
"object",
"have",
"changed",
"their",
"configuration",
"will",
"be",
"loaded",
"again",
"using",
"config_loader",
".",
"Otherwise",
"this",
"is",
"a",
"noop",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L369-L379 |
dnephin/PyStaticConfiguration | staticconf/config.py | ConfigFacade.load | def load(
cls,
filename,
namespace,
loader_func,
min_interval=0,
comparators=None,
):
"""Create a new :class:`ConfigurationWatcher` and load the initial
configuration by calling `loader_func`.
:param filename: a filenam... | python | def load(
cls,
filename,
namespace,
loader_func,
min_interval=0,
comparators=None,
):
"""Create a new :class:`ConfigurationWatcher` and load the initial
configuration by calling `loader_func`.
:param filename: a filenam... | [
"def",
"load",
"(",
"cls",
",",
"filename",
",",
"namespace",
",",
"loader_func",
",",
"min_interval",
"=",
"0",
",",
"comparators",
"=",
"None",
",",
")",
":",
"watcher",
"=",
"ConfigurationWatcher",
"(",
"build_loader_callable",
"(",
"loader_func",
",",
"f... | Create a new :class:`ConfigurationWatcher` and load the initial
configuration by calling `loader_func`.
:param filename: a filename or list of filenames to monitor for changes
:param namespace: the name of a namespace to use when loading
configuration. All config data ... | [
"Create",
"a",
"new",
":",
"class",
":",
"ConfigurationWatcher",
"and",
"load",
"the",
"initial",
"configuration",
"by",
"calling",
"loader_func",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L585-L620 |
dnephin/PyStaticConfiguration | staticconf/validation.py | _validate_iterable | def _validate_iterable(iterable_type, value):
"""Convert the iterable to iterable_type, or raise a Configuration
exception.
"""
if isinstance(value, six.string_types):
msg = "Invalid iterable of type(%s): %s"
raise ValidationError(msg % (type(value), value))
try:
return iter... | python | def _validate_iterable(iterable_type, value):
"""Convert the iterable to iterable_type, or raise a Configuration
exception.
"""
if isinstance(value, six.string_types):
msg = "Invalid iterable of type(%s): %s"
raise ValidationError(msg % (type(value), value))
try:
return iter... | [
"def",
"_validate_iterable",
"(",
"iterable_type",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"msg",
"=",
"\"Invalid iterable of type(%s): %s\"",
"raise",
"ValidationError",
"(",
"msg",
"%",
"(",
"type",
... | Convert the iterable to iterable_type, or raise a Configuration
exception. | [
"Convert",
"the",
"iterable",
"to",
"iterable_type",
"or",
"raise",
"a",
"Configuration",
"exception",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/validation.py#L90-L101 |
dnephin/PyStaticConfiguration | staticconf/validation.py | build_list_type_validator | def build_list_type_validator(item_validator):
"""Return a function which validates that the value is a list of items
which are validated using item_validator.
"""
def validate_list_of_type(value):
return [item_validator(item) for item in validate_list(value)]
return validate_list_of_type | python | def build_list_type_validator(item_validator):
"""Return a function which validates that the value is a list of items
which are validated using item_validator.
"""
def validate_list_of_type(value):
return [item_validator(item) for item in validate_list(value)]
return validate_list_of_type | [
"def",
"build_list_type_validator",
"(",
"item_validator",
")",
":",
"def",
"validate_list_of_type",
"(",
"value",
")",
":",
"return",
"[",
"item_validator",
"(",
"item",
")",
"for",
"item",
"in",
"validate_list",
"(",
"value",
")",
"]",
"return",
"validate_list... | Return a function which validates that the value is a list of items
which are validated using item_validator. | [
"Return",
"a",
"function",
"which",
"validates",
"that",
"the",
"value",
"is",
"a",
"list",
"of",
"items",
"which",
"are",
"validated",
"using",
"item_validator",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/validation.py#L123-L129 |
dnephin/PyStaticConfiguration | staticconf/validation.py | build_map_type_validator | def build_map_type_validator(item_validator):
"""Return a function which validates that the value is a mapping of
items. The function should return pairs of items that will be
passed to the `dict` constructor.
"""
def validate_mapping(value):
return dict(item_validator(item) for item in vali... | python | def build_map_type_validator(item_validator):
"""Return a function which validates that the value is a mapping of
items. The function should return pairs of items that will be
passed to the `dict` constructor.
"""
def validate_mapping(value):
return dict(item_validator(item) for item in vali... | [
"def",
"build_map_type_validator",
"(",
"item_validator",
")",
":",
"def",
"validate_mapping",
"(",
"value",
")",
":",
"return",
"dict",
"(",
"item_validator",
"(",
"item",
")",
"for",
"item",
"in",
"validate_list",
"(",
"value",
")",
")",
"return",
"validate_... | Return a function which validates that the value is a mapping of
items. The function should return pairs of items that will be
passed to the `dict` constructor. | [
"Return",
"a",
"function",
"which",
"validates",
"that",
"the",
"value",
"is",
"a",
"mapping",
"of",
"items",
".",
"The",
"function",
"should",
"return",
"pairs",
"of",
"items",
"that",
"will",
"be",
"passed",
"to",
"the",
"dict",
"constructor",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/validation.py#L132-L139 |
dnephin/PyStaticConfiguration | staticconf/getters.py | register_value_proxy | def register_value_proxy(namespace, value_proxy, help_text):
"""Register a value proxy with the namespace, and add the help_text."""
namespace.register_proxy(value_proxy)
config.config_help.add(
value_proxy.config_key, value_proxy.validator, value_proxy.default,
namespace.get_name(), help_te... | python | def register_value_proxy(namespace, value_proxy, help_text):
"""Register a value proxy with the namespace, and add the help_text."""
namespace.register_proxy(value_proxy)
config.config_help.add(
value_proxy.config_key, value_proxy.validator, value_proxy.default,
namespace.get_name(), help_te... | [
"def",
"register_value_proxy",
"(",
"namespace",
",",
"value_proxy",
",",
"help_text",
")",
":",
"namespace",
".",
"register_proxy",
"(",
"value_proxy",
")",
"config",
".",
"config_help",
".",
"add",
"(",
"value_proxy",
".",
"config_key",
",",
"value_proxy",
"."... | Register a value proxy with the namespace, and add the help_text. | [
"Register",
"a",
"value",
"proxy",
"with",
"the",
"namespace",
"and",
"add",
"the",
"help_text",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/getters.py#L68-L73 |
dnephin/PyStaticConfiguration | staticconf/getters.py | build_getter | def build_getter(validator, getter_namespace=None):
"""Create a getter function for retrieving values from the config cache.
Getters will default to the DEFAULT namespace.
"""
def proxy_register(key_name, default=UndefToken, help=None, namespace=None):
name = namespace or getter_namespace... | python | def build_getter(validator, getter_namespace=None):
"""Create a getter function for retrieving values from the config cache.
Getters will default to the DEFAULT namespace.
"""
def proxy_register(key_name, default=UndefToken, help=None, namespace=None):
name = namespace or getter_namespace... | [
"def",
"build_getter",
"(",
"validator",
",",
"getter_namespace",
"=",
"None",
")",
":",
"def",
"proxy_register",
"(",
"key_name",
",",
"default",
"=",
"UndefToken",
",",
"help",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"name",
"=",
"namespace... | Create a getter function for retrieving values from the config cache.
Getters will default to the DEFAULT namespace. | [
"Create",
"a",
"getter",
"function",
"for",
"retrieving",
"values",
"from",
"the",
"config",
"cache",
".",
"Getters",
"will",
"default",
"to",
"the",
"DEFAULT",
"namespace",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/getters.py#L101-L110 |
dnephin/PyStaticConfiguration | staticconf/getters.py | ProxyFactory.build | def build(self, validator, namespace, config_key, default, help):
"""Build or retrieve a ValueProxy from the attributes. Proxies are
keyed using a repr because default values can be mutable types.
"""
proxy_attrs = validator, namespace, config_key, default
proxy_key = repr(proxy_... | python | def build(self, validator, namespace, config_key, default, help):
"""Build or retrieve a ValueProxy from the attributes. Proxies are
keyed using a repr because default values can be mutable types.
"""
proxy_attrs = validator, namespace, config_key, default
proxy_key = repr(proxy_... | [
"def",
"build",
"(",
"self",
",",
"validator",
",",
"namespace",
",",
"config_key",
",",
"default",
",",
"help",
")",
":",
"proxy_attrs",
"=",
"validator",
",",
"namespace",
",",
"config_key",
",",
"default",
"proxy_key",
"=",
"repr",
"(",
"proxy_attrs",
"... | Build or retrieve a ValueProxy from the attributes. Proxies are
keyed using a repr because default values can be mutable types. | [
"Build",
"or",
"retrieve",
"a",
"ValueProxy",
"from",
"the",
"attributes",
".",
"Proxies",
"are",
"keyed",
"using",
"a",
"repr",
"because",
"default",
"values",
"can",
"be",
"mutable",
"types",
"."
] | train | https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/getters.py#L84-L95 |
andim/noisyopt | noisyopt/main.py | minimizeCompass | def minimizeCompass(func, x0, args=(),
bounds=None, scaling=None,
redfactor=2.0, deltainit=1.0, deltatol=1e-3, feps=1e-15,
errorcontrol=True, funcNinit=30, funcmultfactor=2.0,
paired=True, alpha=0.05, disp=False, callback=None, **kwargs):
"""
Minimization of an ob... | python | def minimizeCompass(func, x0, args=(),
bounds=None, scaling=None,
redfactor=2.0, deltainit=1.0, deltatol=1e-3, feps=1e-15,
errorcontrol=True, funcNinit=30, funcmultfactor=2.0,
paired=True, alpha=0.05, disp=False, callback=None, **kwargs):
"""
Minimization of an ob... | [
"def",
"minimizeCompass",
"(",
"func",
",",
"x0",
",",
"args",
"=",
"(",
")",
",",
"bounds",
"=",
"None",
",",
"scaling",
"=",
"None",
",",
"redfactor",
"=",
"2.0",
",",
"deltainit",
"=",
"1.0",
",",
"deltatol",
"=",
"1e-3",
",",
"feps",
"=",
"1e-1... | Minimization of an objective function by a pattern search.
The algorithm does a compass search along coordinate directions.
If `errorcontrol=True` then the function is called repeatedly to average
over the stochasticity in the function evaluation. The number of
evaluations over which to average is adap... | [
"Minimization",
"of",
"an",
"objective",
"function",
"by",
"a",
"pattern",
"search",
"."
] | train | https://github.com/andim/noisyopt/blob/91a748f59acc357622eb4feb58057f8414de7b90/noisyopt/main.py#L59-L256 |
andim/noisyopt | noisyopt/main.py | minimizeSPSA | def minimizeSPSA(func, x0, args=(), bounds=None, niter=100, paired=True,
a=1.0, alpha=0.602, c=1.0, gamma=0.101,
disp=False, callback=None):
"""
Minimization of an objective function by a simultaneous perturbation
stochastic approximation algorithm.
This algorithm appr... | python | def minimizeSPSA(func, x0, args=(), bounds=None, niter=100, paired=True,
a=1.0, alpha=0.602, c=1.0, gamma=0.101,
disp=False, callback=None):
"""
Minimization of an objective function by a simultaneous perturbation
stochastic approximation algorithm.
This algorithm appr... | [
"def",
"minimizeSPSA",
"(",
"func",
",",
"x0",
",",
"args",
"=",
"(",
")",
",",
"bounds",
"=",
"None",
",",
"niter",
"=",
"100",
",",
"paired",
"=",
"True",
",",
"a",
"=",
"1.0",
",",
"alpha",
"=",
"0.602",
",",
"c",
"=",
"1.0",
",",
"gamma",
... | Minimization of an objective function by a simultaneous perturbation
stochastic approximation algorithm.
This algorithm approximates the gradient of the function by finite differences
along stochastic directions Deltak. The elements of Deltak are drawn from
+- 1 with probability one half. The gradient ... | [
"Minimization",
"of",
"an",
"objective",
"function",
"by",
"a",
"simultaneous",
"perturbation",
"stochastic",
"approximation",
"algorithm",
"."
] | train | https://github.com/andim/noisyopt/blob/91a748f59acc357622eb4feb58057f8414de7b90/noisyopt/main.py#L264-L351 |
andim/noisyopt | noisyopt/main.py | bisect | def bisect(func, a, b, xtol=1e-6, errorcontrol=True,
testkwargs=dict(), outside='extrapolate',
ascending=None,
disp=False):
"""Find root by bysection search.
If the function evaluation is noisy then use `errorcontrol=True` for adaptive
sampling of the function during the bi... | python | def bisect(func, a, b, xtol=1e-6, errorcontrol=True,
testkwargs=dict(), outside='extrapolate',
ascending=None,
disp=False):
"""Find root by bysection search.
If the function evaluation is noisy then use `errorcontrol=True` for adaptive
sampling of the function during the bi... | [
"def",
"bisect",
"(",
"func",
",",
"a",
",",
"b",
",",
"xtol",
"=",
"1e-6",
",",
"errorcontrol",
"=",
"True",
",",
"testkwargs",
"=",
"dict",
"(",
")",
",",
"outside",
"=",
"'extrapolate'",
",",
"ascending",
"=",
"None",
",",
"disp",
"=",
"False",
... | Find root by bysection search.
If the function evaluation is noisy then use `errorcontrol=True` for adaptive
sampling of the function during the bisection search.
Parameters
----------
func: callable
Function of which the root should be found. If `errorcontrol=True`
then the functi... | [
"Find",
"root",
"by",
"bysection",
"search",
"."
] | train | https://github.com/andim/noisyopt/blob/91a748f59acc357622eb4feb58057f8414de7b90/noisyopt/main.py#L576-L657 |
andim/noisyopt | noisyopt/main.py | AveragedFunction.diffse | def diffse(self, x1, x2):
"""Standard error of the difference between the function values at x1 and x2"""
f1, f1se = self(x1)
f2, f2se = self(x2)
if self.paired:
fx1 = np.array(self.cache[tuple(x1)])
fx2 = np.array(self.cache[tuple(x2)])
diffse = np.s... | python | def diffse(self, x1, x2):
"""Standard error of the difference between the function values at x1 and x2"""
f1, f1se = self(x1)
f2, f2se = self(x2)
if self.paired:
fx1 = np.array(self.cache[tuple(x1)])
fx2 = np.array(self.cache[tuple(x2)])
diffse = np.s... | [
"def",
"diffse",
"(",
"self",
",",
"x1",
",",
"x2",
")",
":",
"f1",
",",
"f1se",
"=",
"self",
"(",
"x1",
")",
"f2",
",",
"f2se",
"=",
"self",
"(",
"x2",
")",
"if",
"self",
".",
"paired",
":",
"fx1",
"=",
"np",
".",
"array",
"(",
"self",
"."... | Standard error of the difference between the function values at x1 and x2 | [
"Standard",
"error",
"of",
"the",
"difference",
"between",
"the",
"function",
"values",
"at",
"x1",
"and",
"x2"
] | train | https://github.com/andim/noisyopt/blob/91a748f59acc357622eb4feb58057f8414de7b90/noisyopt/main.py#L466-L476 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_document_shorthand_with_fragments | def p_document_shorthand_with_fragments(self, p):
"""
document : selection_set fragment_list
"""
p[0] = Document(definitions=[Query(selections=p[1])] + p[2]) | python | def p_document_shorthand_with_fragments(self, p):
"""
document : selection_set fragment_list
"""
p[0] = Document(definitions=[Query(selections=p[1])] + p[2]) | [
"def",
"p_document_shorthand_with_fragments",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Document",
"(",
"definitions",
"=",
"[",
"Query",
"(",
"selections",
"=",
"p",
"[",
"1",
"]",
")",
"]",
"+",
"p",
"[",
"2",
"]",
")"
] | document : selection_set fragment_list | [
"document",
":",
"selection_set",
"fragment_list"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L52-L56 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_operation_definition1 | def p_operation_definition1(self, p):
"""
operation_definition : operation_type name variable_definitions directives selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[5],
name=p[2],
variable_definitions=p[3],
directives=p[4],
... | python | def p_operation_definition1(self, p):
"""
operation_definition : operation_type name variable_definitions directives selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[5],
name=p[2],
variable_definitions=p[3],
directives=p[4],
... | [
"def",
"p_operation_definition1",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"operation_cls",
"(",
"p",
"[",
"1",
"]",
")",
"(",
"selections",
"=",
"p",
"[",
"5",
"]",
",",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"va... | operation_definition : operation_type name variable_definitions directives selection_set | [
"operation_definition",
":",
"operation_type",
"name",
"variable_definitions",
"directives",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L95-L104 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_operation_definition2 | def p_operation_definition2(self, p):
"""
operation_definition : operation_type name variable_definitions selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[4],
name=p[2],
variable_definitions=p[3],
) | python | def p_operation_definition2(self, p):
"""
operation_definition : operation_type name variable_definitions selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[4],
name=p[2],
variable_definitions=p[3],
) | [
"def",
"p_operation_definition2",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"operation_cls",
"(",
"p",
"[",
"1",
"]",
")",
"(",
"selections",
"=",
"p",
"[",
"4",
"]",
",",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"va... | operation_definition : operation_type name variable_definitions selection_set | [
"operation_definition",
":",
"operation_type",
"name",
"variable_definitions",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L106-L114 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_operation_definition3 | def p_operation_definition3(self, p):
"""
operation_definition : operation_type name directives selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[4],
name=p[2],
directives=p[3],
) | python | def p_operation_definition3(self, p):
"""
operation_definition : operation_type name directives selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[4],
name=p[2],
directives=p[3],
) | [
"def",
"p_operation_definition3",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"operation_cls",
"(",
"p",
"[",
"1",
"]",
")",
"(",
"selections",
"=",
"p",
"[",
"4",
"]",
",",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"di... | operation_definition : operation_type name directives selection_set | [
"operation_definition",
":",
"operation_type",
"name",
"directives",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L116-L124 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_operation_definition4 | def p_operation_definition4(self, p):
"""
operation_definition : operation_type name selection_set
"""
p[0] = self.operation_cls(p[1])(selections=p[3], name=p[2]) | python | def p_operation_definition4(self, p):
"""
operation_definition : operation_type name selection_set
"""
p[0] = self.operation_cls(p[1])(selections=p[3], name=p[2]) | [
"def",
"p_operation_definition4",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"operation_cls",
"(",
"p",
"[",
"1",
"]",
")",
"(",
"selections",
"=",
"p",
"[",
"3",
"]",
",",
"name",
"=",
"p",
"[",
"2",
"]",
")"
] | operation_definition : operation_type name selection_set | [
"operation_definition",
":",
"operation_type",
"name",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L126-L130 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_operation_definition5 | def p_operation_definition5(self, p):
"""
operation_definition : operation_type variable_definitions directives selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[4],
variable_definitions=p[2],
directives=p[3],
) | python | def p_operation_definition5(self, p):
"""
operation_definition : operation_type variable_definitions directives selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[4],
variable_definitions=p[2],
directives=p[3],
) | [
"def",
"p_operation_definition5",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"operation_cls",
"(",
"p",
"[",
"1",
"]",
")",
"(",
"selections",
"=",
"p",
"[",
"4",
"]",
",",
"variable_definitions",
"=",
"p",
"[",
"2",
"... | operation_definition : operation_type variable_definitions directives selection_set | [
"operation_definition",
":",
"operation_type",
"variable_definitions",
"directives",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L132-L140 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_operation_definition6 | def p_operation_definition6(self, p):
"""
operation_definition : operation_type variable_definitions selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[3],
variable_definitions=p[2],
) | python | def p_operation_definition6(self, p):
"""
operation_definition : operation_type variable_definitions selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[3],
variable_definitions=p[2],
) | [
"def",
"p_operation_definition6",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"operation_cls",
"(",
"p",
"[",
"1",
"]",
")",
"(",
"selections",
"=",
"p",
"[",
"3",
"]",
",",
"variable_definitions",
"=",
"p",
"[",
"2",
"... | operation_definition : operation_type variable_definitions selection_set | [
"operation_definition",
":",
"operation_type",
"variable_definitions",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L142-L149 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_operation_definition7 | def p_operation_definition7(self, p):
"""
operation_definition : operation_type directives selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[3],
directives=p[2],
) | python | def p_operation_definition7(self, p):
"""
operation_definition : operation_type directives selection_set
"""
p[0] = self.operation_cls(p[1])(
selections=p[3],
directives=p[2],
) | [
"def",
"p_operation_definition7",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"operation_cls",
"(",
"p",
"[",
"1",
"]",
")",
"(",
"selections",
"=",
"p",
"[",
"3",
"]",
",",
"directives",
"=",
"p",
"[",
"2",
"]",
",",... | operation_definition : operation_type directives selection_set | [
"operation_definition",
":",
"operation_type",
"directives",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L151-L158 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_all | def p_field_all(self, p):
"""
field : alias name arguments directives selection_set
"""
p[0] = Field(name=p[2], alias=p[1], arguments=p[3], directives=p[4],
selections=p[5]) | python | def p_field_all(self, p):
"""
field : alias name arguments directives selection_set
"""
p[0] = Field(name=p[2], alias=p[1], arguments=p[3], directives=p[4],
selections=p[5]) | [
"def",
"p_field_all",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"alias",
"=",
"p",
"[",
"1",
"]",
",",
"arguments",
"=",
"p",
"[",
"3",
"]",
",",
"directives",
"=",
"p",
... | field : alias name arguments directives selection_set | [
"field",
":",
"alias",
"name",
"arguments",
"directives",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L199-L204 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_optional1_1 | def p_field_optional1_1(self, p):
"""
field : name arguments directives selection_set
"""
p[0] = Field(name=p[1], arguments=p[2], directives=p[3],
selections=p[5]) | python | def p_field_optional1_1(self, p):
"""
field : name arguments directives selection_set
"""
p[0] = Field(name=p[1], arguments=p[2], directives=p[3],
selections=p[5]) | [
"def",
"p_field_optional1_1",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"1",
"]",
",",
"arguments",
"=",
"p",
"[",
"2",
"]",
",",
"directives",
"=",
"p",
"[",
"3",
"]",
",",
"selections",
"... | field : name arguments directives selection_set | [
"field",
":",
"name",
"arguments",
"directives",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L206-L211 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_optional1_2 | def p_field_optional1_2(self, p):
"""
field : alias name directives selection_set
"""
p[0] = Field(name=p[2], alias=p[1], directives=p[3], selections=p[5]) | python | def p_field_optional1_2(self, p):
"""
field : alias name directives selection_set
"""
p[0] = Field(name=p[2], alias=p[1], directives=p[3], selections=p[5]) | [
"def",
"p_field_optional1_2",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"alias",
"=",
"p",
"[",
"1",
"]",
",",
"directives",
"=",
"p",
"[",
"3",
"]",
",",
"selections",
"=",
... | field : alias name directives selection_set | [
"field",
":",
"alias",
"name",
"directives",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L213-L217 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_optional1_3 | def p_field_optional1_3(self, p):
"""
field : alias name arguments selection_set
"""
p[0] = Field(name=p[2], alias=p[1], arguments=p[3], selections=p[4]) | python | def p_field_optional1_3(self, p):
"""
field : alias name arguments selection_set
"""
p[0] = Field(name=p[2], alias=p[1], arguments=p[3], selections=p[4]) | [
"def",
"p_field_optional1_3",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"alias",
"=",
"p",
"[",
"1",
"]",
",",
"arguments",
"=",
"p",
"[",
"3",
"]",
",",
"selections",
"=",
... | field : alias name arguments selection_set | [
"field",
":",
"alias",
"name",
"arguments",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L219-L223 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_optional1_4 | def p_field_optional1_4(self, p):
"""
field : alias name arguments directives
"""
p[0] = Field(name=p[2], alias=p[1], arguments=p[3], directives=p[4]) | python | def p_field_optional1_4(self, p):
"""
field : alias name arguments directives
"""
p[0] = Field(name=p[2], alias=p[1], arguments=p[3], directives=p[4]) | [
"def",
"p_field_optional1_4",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"alias",
"=",
"p",
"[",
"1",
"]",
",",
"arguments",
"=",
"p",
"[",
"3",
"]",
",",
"directives",
"=",
... | field : alias name arguments directives | [
"field",
":",
"alias",
"name",
"arguments",
"directives"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L225-L229 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_optional2_1 | def p_field_optional2_1(self, p):
"""
field : name directives selection_set
"""
p[0] = Field(name=p[1], directives=p[2], selections=p[3]) | python | def p_field_optional2_1(self, p):
"""
field : name directives selection_set
"""
p[0] = Field(name=p[1], directives=p[2], selections=p[3]) | [
"def",
"p_field_optional2_1",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"1",
"]",
",",
"directives",
"=",
"p",
"[",
"2",
"]",
",",
"selections",
"=",
"p",
"[",
"3",
"]",
")"
] | field : name directives selection_set | [
"field",
":",
"name",
"directives",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L231-L235 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_optional2_2 | def p_field_optional2_2(self, p):
"""
field : name arguments selection_set
"""
p[0] = Field(name=p[1], arguments=p[2], selections=p[3]) | python | def p_field_optional2_2(self, p):
"""
field : name arguments selection_set
"""
p[0] = Field(name=p[1], arguments=p[2], selections=p[3]) | [
"def",
"p_field_optional2_2",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"1",
"]",
",",
"arguments",
"=",
"p",
"[",
"2",
"]",
",",
"selections",
"=",
"p",
"[",
"3",
"]",
")"
] | field : name arguments selection_set | [
"field",
":",
"name",
"arguments",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L237-L241 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_optional2_3 | def p_field_optional2_3(self, p):
"""
field : name arguments directives
"""
p[0] = Field(name=p[1], arguments=p[2], directives=p[3]) | python | def p_field_optional2_3(self, p):
"""
field : name arguments directives
"""
p[0] = Field(name=p[1], arguments=p[2], directives=p[3]) | [
"def",
"p_field_optional2_3",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"1",
"]",
",",
"arguments",
"=",
"p",
"[",
"2",
"]",
",",
"directives",
"=",
"p",
"[",
"3",
"]",
")"
] | field : name arguments directives | [
"field",
":",
"name",
"arguments",
"directives"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L243-L247 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_optional2_4 | def p_field_optional2_4(self, p):
"""
field : alias name selection_set
"""
p[0] = Field(name=p[2], alias=p[1], selections=p[3]) | python | def p_field_optional2_4(self, p):
"""
field : alias name selection_set
"""
p[0] = Field(name=p[2], alias=p[1], selections=p[3]) | [
"def",
"p_field_optional2_4",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"alias",
"=",
"p",
"[",
"1",
"]",
",",
"selections",
"=",
"p",
"[",
"3",
"]",
")"
] | field : alias name selection_set | [
"field",
":",
"alias",
"name",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L249-L253 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_optional2_5 | def p_field_optional2_5(self, p):
"""
field : alias name directives
"""
p[0] = Field(name=p[2], alias=p[1], directives=p[3]) | python | def p_field_optional2_5(self, p):
"""
field : alias name directives
"""
p[0] = Field(name=p[2], alias=p[1], directives=p[3]) | [
"def",
"p_field_optional2_5",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"alias",
"=",
"p",
"[",
"1",
"]",
",",
"directives",
"=",
"p",
"[",
"3",
"]",
")"
] | field : alias name directives | [
"field",
":",
"alias",
"name",
"directives"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L255-L259 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_field_optional2_6 | def p_field_optional2_6(self, p):
"""
field : alias name arguments
"""
p[0] = Field(name=p[2], alias=p[1], arguments=p[3]) | python | def p_field_optional2_6(self, p):
"""
field : alias name arguments
"""
p[0] = Field(name=p[2], alias=p[1], arguments=p[3]) | [
"def",
"p_field_optional2_6",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"Field",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"alias",
"=",
"p",
"[",
"1",
"]",
",",
"arguments",
"=",
"p",
"[",
"3",
"]",
")"
] | field : alias name arguments | [
"field",
":",
"alias",
"name",
"arguments"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L261-L265 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_fragment_definition1 | def p_fragment_definition1(self, p):
"""
fragment_definition : FRAGMENT fragment_name ON type_condition directives selection_set
"""
p[0] = FragmentDefinition(name=p[2], type_condition=p[4],
selections=p[6], directives=p[5]) | python | def p_fragment_definition1(self, p):
"""
fragment_definition : FRAGMENT fragment_name ON type_condition directives selection_set
"""
p[0] = FragmentDefinition(name=p[2], type_condition=p[4],
selections=p[6], directives=p[5]) | [
"def",
"p_fragment_definition1",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"FragmentDefinition",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"type_condition",
"=",
"p",
"[",
"4",
"]",
",",
"selections",
"=",
"p",
"[",
"6",
"]",
","... | fragment_definition : FRAGMENT fragment_name ON type_condition directives selection_set | [
"fragment_definition",
":",
"FRAGMENT",
"fragment_name",
"ON",
"type_condition",
"directives",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L309-L314 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_fragment_definition2 | def p_fragment_definition2(self, p):
"""
fragment_definition : FRAGMENT fragment_name ON type_condition selection_set
"""
p[0] = FragmentDefinition(name=p[2], type_condition=p[4],
selections=p[5]) | python | def p_fragment_definition2(self, p):
"""
fragment_definition : FRAGMENT fragment_name ON type_condition selection_set
"""
p[0] = FragmentDefinition(name=p[2], type_condition=p[4],
selections=p[5]) | [
"def",
"p_fragment_definition2",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"FragmentDefinition",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"type_condition",
"=",
"p",
"[",
"4",
"]",
",",
"selections",
"=",
"p",
"[",
"5",
"]",
")"... | fragment_definition : FRAGMENT fragment_name ON type_condition selection_set | [
"fragment_definition",
":",
"FRAGMENT",
"fragment_name",
"ON",
"type_condition",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L316-L321 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_inline_fragment1 | def p_inline_fragment1(self, p):
"""
inline_fragment : SPREAD ON type_condition directives selection_set
"""
p[0] = InlineFragment(type_condition=p[3], selections=p[5],
directives=p[4]) | python | def p_inline_fragment1(self, p):
"""
inline_fragment : SPREAD ON type_condition directives selection_set
"""
p[0] = InlineFragment(type_condition=p[3], selections=p[5],
directives=p[4]) | [
"def",
"p_inline_fragment1",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"InlineFragment",
"(",
"type_condition",
"=",
"p",
"[",
"3",
"]",
",",
"selections",
"=",
"p",
"[",
"5",
"]",
",",
"directives",
"=",
"p",
"[",
"4",
"]",
")"
] | inline_fragment : SPREAD ON type_condition directives selection_set | [
"inline_fragment",
":",
"SPREAD",
"ON",
"type_condition",
"directives",
"selection_set"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L323-L328 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_directive | def p_directive(self, p):
"""
directive : AT name arguments
| AT name
"""
arguments = p[3] if len(p) == 4 else None
p[0] = Directive(name=p[2], arguments=arguments) | python | def p_directive(self, p):
"""
directive : AT name arguments
| AT name
"""
arguments = p[3] if len(p) == 4 else None
p[0] = Directive(name=p[2], arguments=arguments) | [
"def",
"p_directive",
"(",
"self",
",",
"p",
")",
":",
"arguments",
"=",
"p",
"[",
"3",
"]",
"if",
"len",
"(",
"p",
")",
"==",
"4",
"else",
"None",
"p",
"[",
"0",
"]",
"=",
"Directive",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"arguments",
... | directive : AT name arguments
| AT name | [
"directive",
":",
"AT",
"name",
"arguments",
"|",
"AT",
"name"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L372-L378 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_variable_definition1 | def p_variable_definition1(self, p):
"""
variable_definition : DOLLAR name COLON type default_value
"""
p[0] = VariableDefinition(name=p[2], type=p[4], default_value=p[5]) | python | def p_variable_definition1(self, p):
"""
variable_definition : DOLLAR name COLON type default_value
"""
p[0] = VariableDefinition(name=p[2], type=p[4], default_value=p[5]) | [
"def",
"p_variable_definition1",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"VariableDefinition",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"type",
"=",
"p",
"[",
"4",
"]",
",",
"default_value",
"=",
"p",
"[",
"5",
"]",
")"
] | variable_definition : DOLLAR name COLON type default_value | [
"variable_definition",
":",
"DOLLAR",
"name",
"COLON",
"type",
"default_value"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L422-L426 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_object_field_list | def p_object_field_list(self, p):
"""
object_field_list : object_field_list object_field
"""
obj = p[1].copy()
obj.update(p[2])
p[0] = obj | python | def p_object_field_list(self, p):
"""
object_field_list : object_field_list object_field
"""
obj = p[1].copy()
obj.update(p[2])
p[0] = obj | [
"def",
"p_object_field_list",
"(",
"self",
",",
"p",
")",
":",
"obj",
"=",
"p",
"[",
"1",
"]",
".",
"copy",
"(",
")",
"obj",
".",
"update",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"obj"
] | object_field_list : object_field_list object_field | [
"object_field_list",
":",
"object_field_list",
"object_field"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L560-L566 |
ivelum/graphql-py | graphql/parser.py | GraphQLParser.p_const_object_field_list | def p_const_object_field_list(self, p):
"""
const_object_field_list : const_object_field_list const_object_field
"""
obj = p[1].copy()
obj.update(p[2])
p[0] = obj | python | def p_const_object_field_list(self, p):
"""
const_object_field_list : const_object_field_list const_object_field
"""
obj = p[1].copy()
obj.update(p[2])
p[0] = obj | [
"def",
"p_const_object_field_list",
"(",
"self",
",",
"p",
")",
":",
"obj",
"=",
"p",
"[",
"1",
"]",
".",
"copy",
"(",
")",
"obj",
".",
"update",
"(",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"obj"
] | const_object_field_list : const_object_field_list const_object_field | [
"const_object_field_list",
":",
"const_object_field_list",
"const_object_field"
] | train | https://github.com/ivelum/graphql-py/blob/72baf16d838e82349ee5e8d8f8971ce11cfcedf9/graphql/parser.py#L587-L593 |
goodmami/penman | penman.py | alphanum_order | def alphanum_order(triples):
"""
Sort a list of triples by relation name.
Embedded integers are sorted numerically, but otherwise the sorting
is alphabetic.
"""
return sorted(
triples,
key=lambda t: [
int(t) if t.isdigit() else t
for t in re.split(r'([0-9... | python | def alphanum_order(triples):
"""
Sort a list of triples by relation name.
Embedded integers are sorted numerically, but otherwise the sorting
is alphabetic.
"""
return sorted(
triples,
key=lambda t: [
int(t) if t.isdigit() else t
for t in re.split(r'([0-9... | [
"def",
"alphanum_order",
"(",
"triples",
")",
":",
"return",
"sorted",
"(",
"triples",
",",
"key",
"=",
"lambda",
"t",
":",
"[",
"int",
"(",
"t",
")",
"if",
"t",
".",
"isdigit",
"(",
")",
"else",
"t",
"for",
"t",
"in",
"re",
".",
"split",
"(",
... | Sort a list of triples by relation name.
Embedded integers are sorted numerically, but otherwise the sorting
is alphabetic. | [
"Sort",
"a",
"list",
"of",
"triples",
"by",
"relation",
"name",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L95-L108 |
goodmami/penman | penman.py | decode | def decode(s, cls=PENMANCodec, **kwargs):
"""
Deserialize PENMAN-serialized *s* into its Graph object
Args:
s: a string containing a single PENMAN-serialized graph
cls: serialization codec class
kwargs: keyword arguments passed to the constructor of *cls*
Returns:
the Gr... | python | def decode(s, cls=PENMANCodec, **kwargs):
"""
Deserialize PENMAN-serialized *s* into its Graph object
Args:
s: a string containing a single PENMAN-serialized graph
cls: serialization codec class
kwargs: keyword arguments passed to the constructor of *cls*
Returns:
the Gr... | [
"def",
"decode",
"(",
"s",
",",
"cls",
"=",
"PENMANCodec",
",",
"*",
"*",
"kwargs",
")",
":",
"codec",
"=",
"cls",
"(",
"*",
"*",
"kwargs",
")",
"return",
"codec",
".",
"decode",
"(",
"s",
")"
] | Deserialize PENMAN-serialized *s* into its Graph object
Args:
s: a string containing a single PENMAN-serialized graph
cls: serialization codec class
kwargs: keyword arguments passed to the constructor of *cls*
Returns:
the Graph object described by *s*
Example:
>>> ... | [
"Deserialize",
"PENMAN",
"-",
"serialized",
"*",
"s",
"*",
"into",
"its",
"Graph",
"object"
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L793-L809 |
goodmami/penman | penman.py | encode | def encode(g, top=None, cls=PENMANCodec, **kwargs):
"""
Serialize the graph *g* from *top* to PENMAN notation.
Args:
g: the Graph object
top: the node identifier for the top of the serialized graph; if
unset, the original top of *g* is used
cls: serialization codec class... | python | def encode(g, top=None, cls=PENMANCodec, **kwargs):
"""
Serialize the graph *g* from *top* to PENMAN notation.
Args:
g: the Graph object
top: the node identifier for the top of the serialized graph; if
unset, the original top of *g* is used
cls: serialization codec class... | [
"def",
"encode",
"(",
"g",
",",
"top",
"=",
"None",
",",
"cls",
"=",
"PENMANCodec",
",",
"*",
"*",
"kwargs",
")",
":",
"codec",
"=",
"cls",
"(",
"*",
"*",
"kwargs",
")",
"return",
"codec",
".",
"encode",
"(",
"g",
",",
"top",
"=",
"top",
")"
] | Serialize the graph *g* from *top* to PENMAN notation.
Args:
g: the Graph object
top: the node identifier for the top of the serialized graph; if
unset, the original top of *g* is used
cls: serialization codec class
kwargs: keyword arguments passed to the constructor of ... | [
"Serialize",
"the",
"graph",
"*",
"g",
"*",
"from",
"*",
"top",
"*",
"to",
"PENMAN",
"notation",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L812-L830 |
goodmami/penman | penman.py | load | def load(source, triples=False, cls=PENMANCodec, **kwargs):
"""
Deserialize a list of PENMAN-encoded graphs from *source*.
Args:
source: a filename or file-like object to read from
triples: if True, read graphs as triples instead of as PENMAN
cls: serialization codec class
k... | python | def load(source, triples=False, cls=PENMANCodec, **kwargs):
"""
Deserialize a list of PENMAN-encoded graphs from *source*.
Args:
source: a filename or file-like object to read from
triples: if True, read graphs as triples instead of as PENMAN
cls: serialization codec class
k... | [
"def",
"load",
"(",
"source",
",",
"triples",
"=",
"False",
",",
"cls",
"=",
"PENMANCodec",
",",
"*",
"*",
"kwargs",
")",
":",
"decode",
"=",
"cls",
"(",
"*",
"*",
"kwargs",
")",
".",
"iterdecode",
"if",
"hasattr",
"(",
"source",
",",
"'read'",
")"... | Deserialize a list of PENMAN-encoded graphs from *source*.
Args:
source: a filename or file-like object to read from
triples: if True, read graphs as triples instead of as PENMAN
cls: serialization codec class
kwargs: keyword arguments passed to the constructor of *cls*
Returns:... | [
"Deserialize",
"a",
"list",
"of",
"PENMAN",
"-",
"encoded",
"graphs",
"from",
"*",
"source",
"*",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L833-L850 |
goodmami/penman | penman.py | loads | def loads(string, triples=False, cls=PENMANCodec, **kwargs):
"""
Deserialize a list of PENMAN-encoded graphs from *string*.
Args:
string: a string containing graph data
triples: if True, read graphs as triples instead of as PENMAN
cls: serialization codec class
kwargs: keywo... | python | def loads(string, triples=False, cls=PENMANCodec, **kwargs):
"""
Deserialize a list of PENMAN-encoded graphs from *string*.
Args:
string: a string containing graph data
triples: if True, read graphs as triples instead of as PENMAN
cls: serialization codec class
kwargs: keywo... | [
"def",
"loads",
"(",
"string",
",",
"triples",
"=",
"False",
",",
"cls",
"=",
"PENMANCodec",
",",
"*",
"*",
"kwargs",
")",
":",
"codec",
"=",
"cls",
"(",
"*",
"*",
"kwargs",
")",
"return",
"list",
"(",
"codec",
".",
"iterdecode",
"(",
"string",
","... | Deserialize a list of PENMAN-encoded graphs from *string*.
Args:
string: a string containing graph data
triples: if True, read graphs as triples instead of as PENMAN
cls: serialization codec class
kwargs: keyword arguments passed to the constructor of *cls*
Returns:
a li... | [
"Deserialize",
"a",
"list",
"of",
"PENMAN",
"-",
"encoded",
"graphs",
"from",
"*",
"string",
"*",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L853-L866 |
goodmami/penman | penman.py | dump | def dump(graphs, file, triples=False, cls=PENMANCodec, **kwargs):
"""
Serialize each graph in *graphs* to PENMAN and write to *file*.
Args:
graphs: an iterable of Graph objects
file: a filename or file-like object to write to
triples: if True, write graphs as triples instead of as P... | python | def dump(graphs, file, triples=False, cls=PENMANCodec, **kwargs):
"""
Serialize each graph in *graphs* to PENMAN and write to *file*.
Args:
graphs: an iterable of Graph objects
file: a filename or file-like object to write to
triples: if True, write graphs as triples instead of as P... | [
"def",
"dump",
"(",
"graphs",
",",
"file",
",",
"triples",
"=",
"False",
",",
"cls",
"=",
"PENMANCodec",
",",
"*",
"*",
"kwargs",
")",
":",
"text",
"=",
"dumps",
"(",
"graphs",
",",
"triples",
"=",
"triples",
",",
"cls",
"=",
"cls",
",",
"*",
"*"... | Serialize each graph in *graphs* to PENMAN and write to *file*.
Args:
graphs: an iterable of Graph objects
file: a filename or file-like object to write to
triples: if True, write graphs as triples instead of as PENMAN
cls: serialization codec class
kwargs: keyword arguments... | [
"Serialize",
"each",
"graph",
"in",
"*",
"graphs",
"*",
"to",
"PENMAN",
"and",
"write",
"to",
"*",
"file",
"*",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L869-L886 |
goodmami/penman | penman.py | dumps | def dumps(graphs, triples=False, cls=PENMANCodec, **kwargs):
"""
Serialize each graph in *graphs* to the PENMAN format.
Args:
graphs: an iterable of Graph objects
triples: if True, write graphs as triples instead of as PENMAN
Returns:
the string of serialized graphs
"""
... | python | def dumps(graphs, triples=False, cls=PENMANCodec, **kwargs):
"""
Serialize each graph in *graphs* to the PENMAN format.
Args:
graphs: an iterable of Graph objects
triples: if True, write graphs as triples instead of as PENMAN
Returns:
the string of serialized graphs
"""
... | [
"def",
"dumps",
"(",
"graphs",
",",
"triples",
"=",
"False",
",",
"cls",
"=",
"PENMANCodec",
",",
"*",
"*",
"kwargs",
")",
":",
"codec",
"=",
"cls",
"(",
"*",
"*",
"kwargs",
")",
"strings",
"=",
"[",
"codec",
".",
"encode",
"(",
"g",
",",
"triple... | Serialize each graph in *graphs* to the PENMAN format.
Args:
graphs: an iterable of Graph objects
triples: if True, write graphs as triples instead of as PENMAN
Returns:
the string of serialized graphs | [
"Serialize",
"each",
"graph",
"in",
"*",
"graphs",
"*",
"to",
"the",
"PENMAN",
"format",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L889-L901 |
goodmami/penman | penman.py | PENMANCodec.decode | def decode(self, s, triples=False):
"""
Deserialize PENMAN-notation string *s* into its Graph object.
Args:
s: a string containing a single PENMAN-serialized graph
triples: if True, treat *s* as a conjunction of logical triples
Returns:
the Graph obje... | python | def decode(self, s, triples=False):
"""
Deserialize PENMAN-notation string *s* into its Graph object.
Args:
s: a string containing a single PENMAN-serialized graph
triples: if True, treat *s* as a conjunction of logical triples
Returns:
the Graph obje... | [
"def",
"decode",
"(",
"self",
",",
"s",
",",
"triples",
"=",
"False",
")",
":",
"try",
":",
"if",
"triples",
":",
"span",
",",
"data",
"=",
"self",
".",
"_decode_triple_conjunction",
"(",
"s",
")",
"else",
":",
"span",
",",
"data",
"=",
"self",
"."... | Deserialize PENMAN-notation string *s* into its Graph object.
Args:
s: a string containing a single PENMAN-serialized graph
triples: if True, treat *s* as a conjunction of logical triples
Returns:
the Graph object described by *s*
Example:
>>> co... | [
"Deserialize",
"PENMAN",
"-",
"notation",
"string",
"*",
"s",
"*",
"into",
"its",
"Graph",
"object",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L148-L178 |
goodmami/penman | penman.py | PENMANCodec.iterdecode | def iterdecode(self, s, triples=False):
"""
Deserialize PENMAN-notation string *s* into its Graph objects.
Args:
s: a string containing zero or more PENMAN-serialized graphs
triples: if True, treat *s* as a conjunction of logical triples
Yields:
valid... | python | def iterdecode(self, s, triples=False):
"""
Deserialize PENMAN-notation string *s* into its Graph objects.
Args:
s: a string containing zero or more PENMAN-serialized graphs
triples: if True, treat *s* as a conjunction of logical triples
Yields:
valid... | [
"def",
"iterdecode",
"(",
"self",
",",
"s",
",",
"triples",
"=",
"False",
")",
":",
"pos",
",",
"strlen",
"=",
"0",
",",
"len",
"(",
"s",
")",
"while",
"pos",
"<",
"strlen",
":",
"if",
"s",
"[",
"pos",
"]",
"==",
"'#'",
":",
"while",
"pos",
"... | Deserialize PENMAN-notation string *s* into its Graph objects.
Args:
s: a string containing zero or more PENMAN-serialized graphs
triples: if True, treat *s* as a conjunction of logical triples
Yields:
valid Graph objects described by *s*
Example:
... | [
"Deserialize",
"PENMAN",
"-",
"notation",
"string",
"*",
"s",
"*",
"into",
"its",
"Graph",
"objects",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L180-L223 |
goodmami/penman | penman.py | PENMANCodec.encode | def encode(self, g, top=None, triples=False):
"""
Serialize the graph *g* from *top* to PENMAN notation.
Args:
g: the Graph object
top: the node identifier for the top of the serialized
graph; if unset, the original top of *g* is used
triples:... | python | def encode(self, g, top=None, triples=False):
"""
Serialize the graph *g* from *top* to PENMAN notation.
Args:
g: the Graph object
top: the node identifier for the top of the serialized
graph; if unset, the original top of *g* is used
triples:... | [
"def",
"encode",
"(",
"self",
",",
"g",
",",
"top",
"=",
"None",
",",
"triples",
"=",
"False",
")",
":",
"if",
"len",
"(",
"g",
".",
"triples",
"(",
")",
")",
"==",
"0",
":",
"raise",
"EncodeError",
"(",
"'Cannot encode empty graph.'",
")",
"if",
"... | Serialize the graph *g* from *top* to PENMAN notation.
Args:
g: the Graph object
top: the node identifier for the top of the serialized
graph; if unset, the original top of *g* is used
triples: if True, serialize as a conjunction of logical triples
Re... | [
"Serialize",
"the",
"graph",
"*",
"g",
"*",
"from",
"*",
"top",
"*",
"to",
"PENMAN",
"notation",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L225-L250 |
goodmami/penman | penman.py | PENMANCodec.handle_triple | def handle_triple(self, lhs, relation, rhs):
"""
Process triples before they are added to the graph.
Note that *lhs* and *rhs* are as they originally appeared, and
may be inverted. Inversions are detected by
is_relation_inverted() and de-inverted by invert_relation().
B... | python | def handle_triple(self, lhs, relation, rhs):
"""
Process triples before they are added to the graph.
Note that *lhs* and *rhs* are as they originally appeared, and
may be inverted. Inversions are detected by
is_relation_inverted() and de-inverted by invert_relation().
B... | [
"def",
"handle_triple",
"(",
"self",
",",
"lhs",
",",
"relation",
",",
"rhs",
")",
":",
"relation",
"=",
"relation",
".",
"replace",
"(",
"':'",
",",
"''",
",",
"1",
")",
"# remove leading :",
"if",
"self",
".",
"is_relation_inverted",
"(",
"relation",
"... | Process triples before they are added to the graph.
Note that *lhs* and *rhs* are as they originally appeared, and
may be inverted. Inversions are detected by
is_relation_inverted() and de-inverted by invert_relation().
By default, this function:
* removes initial colons on re... | [
"Process",
"triples",
"before",
"they",
"are",
"added",
"to",
"the",
"graph",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L267-L304 |
goodmami/penman | penman.py | PENMANCodec.triples_to_graph | def triples_to_graph(self, triples, top=None):
"""
Create a Graph from *triples* considering codec configuration.
The Graph class does not know about information in the codec,
so if Graph instantiation depends on special `TYPE_REL` or
`TOP_VAR` values, use this function instead ... | python | def triples_to_graph(self, triples, top=None):
"""
Create a Graph from *triples* considering codec configuration.
The Graph class does not know about information in the codec,
so if Graph instantiation depends on special `TYPE_REL` or
`TOP_VAR` values, use this function instead ... | [
"def",
"triples_to_graph",
"(",
"self",
",",
"triples",
",",
"top",
"=",
"None",
")",
":",
"inferred_top",
"=",
"triples",
"[",
"0",
"]",
"[",
"0",
"]",
"if",
"triples",
"else",
"None",
"ts",
"=",
"[",
"]",
"for",
"triple",
"in",
"triples",
":",
"i... | Create a Graph from *triples* considering codec configuration.
The Graph class does not know about information in the codec,
so if Graph instantiation depends on special `TYPE_REL` or
`TOP_VAR` values, use this function instead of instantiating
a Graph object directly. This is also wher... | [
"Create",
"a",
"Graph",
"from",
"*",
"triples",
"*",
"considering",
"codec",
"configuration",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L306-L331 |
goodmami/penman | penman.py | PENMANCodec._encode_penman | def _encode_penman(self, g, top=None):
"""
Walk graph g and find a spanning dag, then serialize the result.
First, depth-first traversal of preferred orientations (whether
true or inverted) to create graph p.
If any triples remain, select the first remaining triple whose
... | python | def _encode_penman(self, g, top=None):
"""
Walk graph g and find a spanning dag, then serialize the result.
First, depth-first traversal of preferred orientations (whether
true or inverted) to create graph p.
If any triples remain, select the first remaining triple whose
... | [
"def",
"_encode_penman",
"(",
"self",
",",
"g",
",",
"top",
"=",
"None",
")",
":",
"if",
"top",
"is",
"None",
":",
"top",
"=",
"g",
".",
"top",
"remaining",
"=",
"set",
"(",
"g",
".",
"triples",
"(",
")",
")",
"variables",
"=",
"g",
".",
"varia... | Walk graph g and find a spanning dag, then serialize the result.
First, depth-first traversal of preferred orientations (whether
true or inverted) to create graph p.
If any triples remain, select the first remaining triple whose
source in the dispreferred orientation exists in p, where... | [
"Walk",
"graph",
"g",
"and",
"find",
"a",
"spanning",
"dag",
"then",
"serialize",
"the",
"result",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L436-L499 |
goodmami/penman | penman.py | AMRCodec.is_relation_inverted | def is_relation_inverted(self, relation):
"""
Return True if *relation* is inverted.
"""
return (
relation in self._deinversions or
(relation.endswith('-of') and relation not in self._inversions)
) | python | def is_relation_inverted(self, relation):
"""
Return True if *relation* is inverted.
"""
return (
relation in self._deinversions or
(relation.endswith('-of') and relation not in self._inversions)
) | [
"def",
"is_relation_inverted",
"(",
"self",
",",
"relation",
")",
":",
"return",
"(",
"relation",
"in",
"self",
".",
"_deinversions",
"or",
"(",
"relation",
".",
"endswith",
"(",
"'-of'",
")",
"and",
"relation",
"not",
"in",
"self",
".",
"_inversions",
")"... | Return True if *relation* is inverted. | [
"Return",
"True",
"if",
"*",
"relation",
"*",
"is",
"inverted",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L571-L578 |
goodmami/penman | penman.py | AMRCodec.invert_relation | def invert_relation(self, relation):
"""
Invert or deinvert *relation*.
"""
if self.is_relation_inverted(relation):
rel = self._deinversions.get(relation, relation[:-3])
else:
rel = self._inversions.get(relation, relation + '-of')
if rel is None:
... | python | def invert_relation(self, relation):
"""
Invert or deinvert *relation*.
"""
if self.is_relation_inverted(relation):
rel = self._deinversions.get(relation, relation[:-3])
else:
rel = self._inversions.get(relation, relation + '-of')
if rel is None:
... | [
"def",
"invert_relation",
"(",
"self",
",",
"relation",
")",
":",
"if",
"self",
".",
"is_relation_inverted",
"(",
"relation",
")",
":",
"rel",
"=",
"self",
".",
"_deinversions",
".",
"get",
"(",
"relation",
",",
"relation",
"[",
":",
"-",
"3",
"]",
")"... | Invert or deinvert *relation*. | [
"Invert",
"or",
"deinvert",
"*",
"relation",
"*",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L580-L592 |
goodmami/penman | penman.py | Graph.triples | def triples(self, source=None, relation=None, target=None):
"""
Return triples filtered by their *source*, *relation*, or *target*.
"""
triplematch = lambda t: (
(source is None or source == t.source) and
(relation is None or relation == t.relation) and
... | python | def triples(self, source=None, relation=None, target=None):
"""
Return triples filtered by their *source*, *relation*, or *target*.
"""
triplematch = lambda t: (
(source is None or source == t.source) and
(relation is None or relation == t.relation) and
... | [
"def",
"triples",
"(",
"self",
",",
"source",
"=",
"None",
",",
"relation",
"=",
"None",
",",
"target",
"=",
"None",
")",
":",
"triplematch",
"=",
"lambda",
"t",
":",
"(",
"(",
"source",
"is",
"None",
"or",
"source",
"==",
"t",
".",
"source",
")",
... | Return triples filtered by their *source*, *relation*, or *target*. | [
"Return",
"triples",
"filtered",
"by",
"their",
"*",
"source",
"*",
"*",
"relation",
"*",
"or",
"*",
"target",
"*",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L680-L689 |
goodmami/penman | penman.py | Graph.edges | def edges(self, source=None, relation=None, target=None):
"""
Return edges filtered by their *source*, *relation*, or *target*.
Edges don't include terminal triples (node types or attributes).
"""
edgematch = lambda e: (
(source is None or source == e.source) and
... | python | def edges(self, source=None, relation=None, target=None):
"""
Return edges filtered by their *source*, *relation*, or *target*.
Edges don't include terminal triples (node types or attributes).
"""
edgematch = lambda e: (
(source is None or source == e.source) and
... | [
"def",
"edges",
"(",
"self",
",",
"source",
"=",
"None",
",",
"relation",
"=",
"None",
",",
"target",
"=",
"None",
")",
":",
"edgematch",
"=",
"lambda",
"e",
":",
"(",
"(",
"source",
"is",
"None",
"or",
"source",
"==",
"e",
".",
"source",
")",
"a... | Return edges filtered by their *source*, *relation*, or *target*.
Edges don't include terminal triples (node types or attributes). | [
"Return",
"edges",
"filtered",
"by",
"their",
"*",
"source",
"*",
"*",
"relation",
"*",
"or",
"*",
"target",
"*",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L691-L704 |
goodmami/penman | penman.py | Graph.attributes | def attributes(self, source=None, relation=None, target=None):
"""
Return attributes filtered by their *source*, *relation*, or *target*.
Attributes don't include triples where the target is a nonterminal.
"""
attrmatch = lambda a: (
(source is None or source == a.so... | python | def attributes(self, source=None, relation=None, target=None):
"""
Return attributes filtered by their *source*, *relation*, or *target*.
Attributes don't include triples where the target is a nonterminal.
"""
attrmatch = lambda a: (
(source is None or source == a.so... | [
"def",
"attributes",
"(",
"self",
",",
"source",
"=",
"None",
",",
"relation",
"=",
"None",
",",
"target",
"=",
"None",
")",
":",
"attrmatch",
"=",
"lambda",
"a",
":",
"(",
"(",
"source",
"is",
"None",
"or",
"source",
"==",
"a",
".",
"source",
")",... | Return attributes filtered by their *source*, *relation*, or *target*.
Attributes don't include triples where the target is a nonterminal. | [
"Return",
"attributes",
"filtered",
"by",
"their",
"*",
"source",
"*",
"*",
"relation",
"*",
"or",
"*",
"target",
"*",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L706-L719 |
goodmami/penman | penman.py | Graph.reentrancies | def reentrancies(self):
"""
Return a mapping of variables to their re-entrancy count.
A re-entrancy is when more than one edge selects a node as its
target. These graphs are rooted, so the top node always has an
implicit entrancy. Only nodes with re-entrancies are reported,
... | python | def reentrancies(self):
"""
Return a mapping of variables to their re-entrancy count.
A re-entrancy is when more than one edge selects a node as its
target. These graphs are rooted, so the top node always has an
implicit entrancy. Only nodes with re-entrancies are reported,
... | [
"def",
"reentrancies",
"(",
"self",
")",
":",
"entrancies",
"=",
"defaultdict",
"(",
"int",
")",
"entrancies",
"[",
"self",
".",
"top",
"]",
"+=",
"1",
"# implicit entrancy to top",
"for",
"t",
"in",
"self",
".",
"edges",
"(",
")",
":",
"entrancies",
"["... | Return a mapping of variables to their re-entrancy count.
A re-entrancy is when more than one edge selects a node as its
target. These graphs are rooted, so the top node always has an
implicit entrancy. Only nodes with re-entrancies are reported,
and the count is only for the entrant ed... | [
"Return",
"a",
"mapping",
"of",
"variables",
"to",
"their",
"re",
"-",
"entrancy",
"count",
"."
] | train | https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L721-L737 |
xgfs/NetLSD | netlsd/util.py | check_1d | def check_1d(inp):
"""
Check input to be a vector. Converts lists to np.ndarray.
Parameters
----------
inp : obj
Input vector
Returns
-------
numpy.ndarray or None
Input vector or None
Examples
--------
>>> check_1d([0, 1, 2, 3])
[0, 1, 2, 3]
>>> c... | python | def check_1d(inp):
"""
Check input to be a vector. Converts lists to np.ndarray.
Parameters
----------
inp : obj
Input vector
Returns
-------
numpy.ndarray or None
Input vector or None
Examples
--------
>>> check_1d([0, 1, 2, 3])
[0, 1, 2, 3]
>>> c... | [
"def",
"check_1d",
"(",
"inp",
")",
":",
"if",
"isinstance",
"(",
"inp",
",",
"list",
")",
":",
"return",
"check_1d",
"(",
"np",
".",
"array",
"(",
"inp",
")",
")",
"if",
"isinstance",
"(",
"inp",
",",
"np",
".",
"ndarray",
")",
":",
"if",
"inp",... | Check input to be a vector. Converts lists to np.ndarray.
Parameters
----------
inp : obj
Input vector
Returns
-------
numpy.ndarray or None
Input vector or None
Examples
--------
>>> check_1d([0, 1, 2, 3])
[0, 1, 2, 3]
>>> check_1d('test')
None | [
"Check",
"input",
"to",
"be",
"a",
"vector",
".",
"Converts",
"lists",
"to",
"np",
".",
"ndarray",
"."
] | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/util.py#L7-L34 |
xgfs/NetLSD | netlsd/util.py | check_2d | def check_2d(inp):
"""
Check input to be a matrix. Converts lists of lists to np.ndarray.
Also allows the input to be a scipy sparse matrix.
Parameters
----------
inp : obj
Input matrix
Returns
-------
numpy.ndarray, scipy.sparse or None
Input matrix or None
... | python | def check_2d(inp):
"""
Check input to be a matrix. Converts lists of lists to np.ndarray.
Also allows the input to be a scipy sparse matrix.
Parameters
----------
inp : obj
Input matrix
Returns
-------
numpy.ndarray, scipy.sparse or None
Input matrix or None
... | [
"def",
"check_2d",
"(",
"inp",
")",
":",
"if",
"isinstance",
"(",
"inp",
",",
"list",
")",
":",
"return",
"check_2d",
"(",
"np",
".",
"array",
"(",
"inp",
")",
")",
"if",
"isinstance",
"(",
"inp",
",",
"(",
"np",
".",
"ndarray",
",",
"np",
".",
... | Check input to be a matrix. Converts lists of lists to np.ndarray.
Also allows the input to be a scipy sparse matrix.
Parameters
----------
inp : obj
Input matrix
Returns
-------
numpy.ndarray, scipy.sparse or None
Input matrix or None
Examples
--------
>>... | [
"Check",
"input",
"to",
"be",
"a",
"matrix",
".",
"Converts",
"lists",
"of",
"lists",
"to",
"np",
".",
"ndarray",
"."
] | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/util.py#L37-L69 |
xgfs/NetLSD | netlsd/util.py | graph_to_laplacian | def graph_to_laplacian(G, normalized=True):
"""
Converts a graph from popular Python packages to Laplacian representation.
Currently support NetworkX, graph_tool and igraph.
Parameters
----------
G : obj
Input graph
normalized : bool
Whether to use normalized Laplacian.... | python | def graph_to_laplacian(G, normalized=True):
"""
Converts a graph from popular Python packages to Laplacian representation.
Currently support NetworkX, graph_tool and igraph.
Parameters
----------
G : obj
Input graph
normalized : bool
Whether to use normalized Laplacian.... | [
"def",
"graph_to_laplacian",
"(",
"G",
",",
"normalized",
"=",
"True",
")",
":",
"try",
":",
"import",
"networkx",
"as",
"nx",
"if",
"isinstance",
"(",
"G",
",",
"nx",
".",
"Graph",
")",
":",
"if",
"normalized",
":",
"return",
"nx",
".",
"normalized_la... | Converts a graph from popular Python packages to Laplacian representation.
Currently support NetworkX, graph_tool and igraph.
Parameters
----------
G : obj
Input graph
normalized : bool
Whether to use normalized Laplacian.
Normalized and unnormalized Laplacians capture ... | [
"Converts",
"a",
"graph",
"from",
"popular",
"Python",
"packages",
"to",
"Laplacian",
"representation",
"."
] | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/util.py#L72-L126 |
xgfs/NetLSD | netlsd/util.py | mat_to_laplacian | def mat_to_laplacian(mat, normalized):
"""
Converts a sparse or dence adjacency matrix to Laplacian.
Parameters
----------
mat : obj
Input adjacency matrix. If it is a Laplacian matrix already, return it.
normalized : bool
Whether to use normalized Laplacian.
Normali... | python | def mat_to_laplacian(mat, normalized):
"""
Converts a sparse or dence adjacency matrix to Laplacian.
Parameters
----------
mat : obj
Input adjacency matrix. If it is a Laplacian matrix already, return it.
normalized : bool
Whether to use normalized Laplacian.
Normali... | [
"def",
"mat_to_laplacian",
"(",
"mat",
",",
"normalized",
")",
":",
"if",
"sps",
".",
"issparse",
"(",
"mat",
")",
":",
"if",
"np",
".",
"all",
"(",
"mat",
".",
"diagonal",
"(",
")",
">=",
"0",
")",
":",
"# Check diagonal",
"if",
"np",
".",
"all",
... | Converts a sparse or dence adjacency matrix to Laplacian.
Parameters
----------
mat : obj
Input adjacency matrix. If it is a Laplacian matrix already, return it.
normalized : bool
Whether to use normalized Laplacian.
Normalized and unnormalized Laplacians capture different p... | [
"Converts",
"a",
"sparse",
"or",
"dence",
"adjacency",
"matrix",
"to",
"Laplacian",
".",
"Parameters",
"----------",
"mat",
":",
"obj",
"Input",
"adjacency",
"matrix",
".",
"If",
"it",
"is",
"a",
"Laplacian",
"matrix",
"already",
"return",
"it",
".",
"normal... | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/util.py#L129-L174 |
xgfs/NetLSD | netlsd/util.py | updown_linear_approx | def updown_linear_approx(eigvals_lower, eigvals_upper, nv):
"""
Approximates Laplacian spectrum using upper and lower parts of the eigenspectrum.
Parameters
----------
eigvals_lower : numpy.ndarray
Lower part of the spectrum, sorted
eigvals_upper : numpy.ndarray
Upper part o... | python | def updown_linear_approx(eigvals_lower, eigvals_upper, nv):
"""
Approximates Laplacian spectrum using upper and lower parts of the eigenspectrum.
Parameters
----------
eigvals_lower : numpy.ndarray
Lower part of the spectrum, sorted
eigvals_upper : numpy.ndarray
Upper part o... | [
"def",
"updown_linear_approx",
"(",
"eigvals_lower",
",",
"eigvals_upper",
",",
"nv",
")",
":",
"nal",
"=",
"len",
"(",
"eigvals_lower",
")",
"nau",
"=",
"len",
"(",
"eigvals_upper",
")",
"if",
"nv",
"<",
"nal",
"+",
"nau",
":",
"raise",
"ValueError",
"(... | Approximates Laplacian spectrum using upper and lower parts of the eigenspectrum.
Parameters
----------
eigvals_lower : numpy.ndarray
Lower part of the spectrum, sorted
eigvals_upper : numpy.ndarray
Upper part of the spectrum, sorted
nv : int
Total number of nodes (eigen... | [
"Approximates",
"Laplacian",
"spectrum",
"using",
"upper",
"and",
"lower",
"parts",
"of",
"the",
"eigenspectrum",
".",
"Parameters",
"----------",
"eigvals_lower",
":",
"numpy",
".",
"ndarray",
"Lower",
"part",
"of",
"the",
"spectrum",
"sorted",
"eigvals_upper",
"... | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/util.py#L177-L209 |
xgfs/NetLSD | netlsd/util.py | eigenvalues_auto | def eigenvalues_auto(mat, n_eivals='auto'):
"""
Automatically computes the spectrum of a given Laplacian matrix.
Parameters
----------
mat : numpy.ndarray or scipy.sparse
Laplacian matrix
n_eivals : string or int or tuple
Number of eigenvalues to compute / use for approximat... | python | def eigenvalues_auto(mat, n_eivals='auto'):
"""
Automatically computes the spectrum of a given Laplacian matrix.
Parameters
----------
mat : numpy.ndarray or scipy.sparse
Laplacian matrix
n_eivals : string or int or tuple
Number of eigenvalues to compute / use for approximat... | [
"def",
"eigenvalues_auto",
"(",
"mat",
",",
"n_eivals",
"=",
"'auto'",
")",
":",
"do_full",
"=",
"True",
"n_lower",
"=",
"150",
"n_upper",
"=",
"150",
"nv",
"=",
"mat",
".",
"shape",
"[",
"0",
"]",
"if",
"n_eivals",
"==",
"'auto'",
":",
"if",
"mat",
... | Automatically computes the spectrum of a given Laplacian matrix.
Parameters
----------
mat : numpy.ndarray or scipy.sparse
Laplacian matrix
n_eivals : string or int or tuple
Number of eigenvalues to compute / use for approximation.
If string, we expect either 'full' or 'auto... | [
"Automatically",
"computes",
"the",
"spectrum",
"of",
"a",
"given",
"Laplacian",
"matrix",
".",
"Parameters",
"----------",
"mat",
":",
"numpy",
".",
"ndarray",
"or",
"scipy",
".",
"sparse",
"Laplacian",
"matrix",
"n_eivals",
":",
"string",
"or",
"int",
"or",
... | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/util.py#L212-L268 |
xgfs/NetLSD | netlsd/kernels.py | netlsd | def netlsd(inp, timescales=np.logspace(-2, 2, 250), kernel='heat', eigenvalues='auto', normalization='empty', normalized_laplacian=True):
"""
Computes NetLSD signature from some given input, timescales, and normalization.
Accepts matrices, common Python graph libraries' graphs, or vectors of eigenvalues.
... | python | def netlsd(inp, timescales=np.logspace(-2, 2, 250), kernel='heat', eigenvalues='auto', normalization='empty', normalized_laplacian=True):
"""
Computes NetLSD signature from some given input, timescales, and normalization.
Accepts matrices, common Python graph libraries' graphs, or vectors of eigenvalues.
... | [
"def",
"netlsd",
"(",
"inp",
",",
"timescales",
"=",
"np",
".",
"logspace",
"(",
"-",
"2",
",",
"2",
",",
"250",
")",
",",
"kernel",
"=",
"'heat'",
",",
"eigenvalues",
"=",
"'auto'",
",",
"normalization",
"=",
"'empty'",
",",
"normalized_laplacian",
"=... | Computes NetLSD signature from some given input, timescales, and normalization.
Accepts matrices, common Python graph libraries' graphs, or vectors of eigenvalues.
For precise definition, please refer to "NetLSD: Hearing the Shape of a Graph" by A. Tsitsulin, D. Mottin, P. Karras, A. Bronstein, E. Müller. Pub... | [
"Computes",
"NetLSD",
"signature",
"from",
"some",
"given",
"input",
"timescales",
"and",
"normalization",
"."
] | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/kernels.py#L25-L91 |
xgfs/NetLSD | netlsd/kernels.py | heat | def heat(inp, timescales=np.logspace(-2, 2, 250), eigenvalues='auto', normalization='empty', normalized_laplacian=True):
"""
Computes heat kernel trace from some given input, timescales, and normalization.
Accepts matrices, common Python graph libraries' graphs, or vectors of eigenvalues.
For precise ... | python | def heat(inp, timescales=np.logspace(-2, 2, 250), eigenvalues='auto', normalization='empty', normalized_laplacian=True):
"""
Computes heat kernel trace from some given input, timescales, and normalization.
Accepts matrices, common Python graph libraries' graphs, or vectors of eigenvalues.
For precise ... | [
"def",
"heat",
"(",
"inp",
",",
"timescales",
"=",
"np",
".",
"logspace",
"(",
"-",
"2",
",",
"2",
",",
"250",
")",
",",
"eigenvalues",
"=",
"'auto'",
",",
"normalization",
"=",
"'empty'",
",",
"normalized_laplacian",
"=",
"True",
")",
":",
"return",
... | Computes heat kernel trace from some given input, timescales, and normalization.
Accepts matrices, common Python graph libraries' graphs, or vectors of eigenvalues.
For precise definition, please refer to "NetLSD: Hearing the Shape of a Graph" by A. Tsitsulin, D. Mottin, P. Karras, A. Bronstein, E. Müller. Pu... | [
"Computes",
"heat",
"kernel",
"trace",
"from",
"some",
"given",
"input",
"timescales",
"and",
"normalization",
"."
] | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/kernels.py#L94-L127 |
xgfs/NetLSD | netlsd/kernels.py | wave | def wave(inp, timescales=np.linspace(0, 2*np.pi, 250), eigenvalues='auto', normalization='empty', normalized_laplacian=True):
"""
Computes wave kernel trace from some given input, timescales, and normalization.
Accepts matrices, common Python graph libraries' graphs, or vectors of eigenvalues.
For pre... | python | def wave(inp, timescales=np.linspace(0, 2*np.pi, 250), eigenvalues='auto', normalization='empty', normalized_laplacian=True):
"""
Computes wave kernel trace from some given input, timescales, and normalization.
Accepts matrices, common Python graph libraries' graphs, or vectors of eigenvalues.
For pre... | [
"def",
"wave",
"(",
"inp",
",",
"timescales",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"2",
"*",
"np",
".",
"pi",
",",
"250",
")",
",",
"eigenvalues",
"=",
"'auto'",
",",
"normalization",
"=",
"'empty'",
",",
"normalized_laplacian",
"=",
"True",
")... | Computes wave kernel trace from some given input, timescales, and normalization.
Accepts matrices, common Python graph libraries' graphs, or vectors of eigenvalues.
For precise definition, please refer to "NetLSD: Hearing the Shape of a Graph" by A. Tsitsulin, D. Mottin, P. Karras, A. Bronstein, E. Müller. Pu... | [
"Computes",
"wave",
"kernel",
"trace",
"from",
"some",
"given",
"input",
"timescales",
"and",
"normalization",
"."
] | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/kernels.py#L130-L163 |
xgfs/NetLSD | netlsd/kernels.py | _hkt | def _hkt(eivals, timescales, normalization, normalized_laplacian):
"""
Computes heat kernel trace from given eigenvalues, timescales, and normalization.
For precise definition, please refer to "NetLSD: Hearing the Shape of a Graph" by A. Tsitsulin, D. Mottin, P. Karras, A. Bronstein, E. Müller. Published a... | python | def _hkt(eivals, timescales, normalization, normalized_laplacian):
"""
Computes heat kernel trace from given eigenvalues, timescales, and normalization.
For precise definition, please refer to "NetLSD: Hearing the Shape of a Graph" by A. Tsitsulin, D. Mottin, P. Karras, A. Bronstein, E. Müller. Published a... | [
"def",
"_hkt",
"(",
"eivals",
",",
"timescales",
",",
"normalization",
",",
"normalized_laplacian",
")",
":",
"nv",
"=",
"eivals",
".",
"shape",
"[",
"0",
"]",
"hkt",
"=",
"np",
".",
"zeros",
"(",
"timescales",
".",
"shape",
")",
"for",
"idx",
",",
"... | Computes heat kernel trace from given eigenvalues, timescales, and normalization.
For precise definition, please refer to "NetLSD: Hearing the Shape of a Graph" by A. Tsitsulin, D. Mottin, P. Karras, A. Bronstein, E. Müller. Published at KDD'18.
Parameters
----------
eivals : numpy.ndarray
... | [
"Computes",
"heat",
"kernel",
"trace",
"from",
"given",
"eigenvalues",
"timescales",
"and",
"normalization",
"."
] | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/kernels.py#L166-L205 |
xgfs/NetLSD | netlsd/kernels.py | _wkt | def _wkt(eivals, timescales, normalization, normalized_laplacian):
"""
Computes wave kernel trace from given eigenvalues, timescales, and normalization.
For precise definition, please refer to "NetLSD: Hearing the Shape of a Graph" by A. Tsitsulin, D. Mottin, P. Karras, A. Bronstein, E. Müller. Published a... | python | def _wkt(eivals, timescales, normalization, normalized_laplacian):
"""
Computes wave kernel trace from given eigenvalues, timescales, and normalization.
For precise definition, please refer to "NetLSD: Hearing the Shape of a Graph" by A. Tsitsulin, D. Mottin, P. Karras, A. Bronstein, E. Müller. Published a... | [
"def",
"_wkt",
"(",
"eivals",
",",
"timescales",
",",
"normalization",
",",
"normalized_laplacian",
")",
":",
"nv",
"=",
"eivals",
".",
"shape",
"[",
"0",
"]",
"wkt",
"=",
"np",
".",
"zeros",
"(",
"timescales",
".",
"shape",
")",
"for",
"idx",
",",
"... | Computes wave kernel trace from given eigenvalues, timescales, and normalization.
For precise definition, please refer to "NetLSD: Hearing the Shape of a Graph" by A. Tsitsulin, D. Mottin, P. Karras, A. Bronstein, E. Müller. Published at KDD'18.
Parameters
----------
eivals : numpy.ndarray
... | [
"Computes",
"wave",
"kernel",
"trace",
"from",
"given",
"eigenvalues",
"timescales",
"and",
"normalization",
"."
] | train | https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/kernels.py#L208-L247 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey.clear | def clear(self):
"""Remove all the elements from the list."""
self._len = 0
del self._maxes[:]
del self._lists[:]
del self._keys[:]
del self._index[:] | python | def clear(self):
"""Remove all the elements from the list."""
self._len = 0
del self._maxes[:]
del self._lists[:]
del self._keys[:]
del self._index[:] | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"_len",
"=",
"0",
"del",
"self",
".",
"_maxes",
"[",
":",
"]",
"del",
"self",
".",
"_lists",
"[",
":",
"]",
"del",
"self",
".",
"_keys",
"[",
":",
"]",
"del",
"self",
".",
"_index",
"[",
":"... | Remove all the elements from the list. | [
"Remove",
"all",
"the",
"elements",
"from",
"the",
"list",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L53-L59 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey.discard | def discard(self, val):
"""
Remove the first occurrence of *val*.
If *val* is not a member, does nothing.
"""
_maxes = self._maxes
if not _maxes:
return
key = self._key(val)
pos = bisect_left(_maxes, key)
if pos == len(_maxes):
... | python | def discard(self, val):
"""
Remove the first occurrence of *val*.
If *val* is not a member, does nothing.
"""
_maxes = self._maxes
if not _maxes:
return
key = self._key(val)
pos = bisect_left(_maxes, key)
if pos == len(_maxes):
... | [
"def",
"discard",
"(",
"self",
",",
"val",
")",
":",
"_maxes",
"=",
"self",
".",
"_maxes",
"if",
"not",
"_maxes",
":",
"return",
"key",
"=",
"self",
".",
"_key",
"(",
"val",
")",
"pos",
"=",
"bisect_left",
"(",
"_maxes",
",",
"key",
")",
"if",
"p... | Remove the first occurrence of *val*.
If *val* is not a member, does nothing. | [
"Remove",
"the",
"first",
"occurrence",
"of",
"*",
"val",
"*",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L178-L214 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey.remove | def remove(self, val):
"""
Remove first occurrence of *val*.
Raises ValueError if *val* is not present.
"""
_maxes = self._maxes
if not _maxes:
raise ValueError('{0} not in list'.format(repr(val)))
key = self._key(val)
pos = bisect_left(_max... | python | def remove(self, val):
"""
Remove first occurrence of *val*.
Raises ValueError if *val* is not present.
"""
_maxes = self._maxes
if not _maxes:
raise ValueError('{0} not in list'.format(repr(val)))
key = self._key(val)
pos = bisect_left(_max... | [
"def",
"remove",
"(",
"self",
",",
"val",
")",
":",
"_maxes",
"=",
"self",
".",
"_maxes",
"if",
"not",
"_maxes",
":",
"raise",
"ValueError",
"(",
"'{0} not in list'",
".",
"format",
"(",
"repr",
"(",
"val",
")",
")",
")",
"key",
"=",
"self",
".",
"... | Remove first occurrence of *val*.
Raises ValueError if *val* is not present. | [
"Remove",
"first",
"occurrence",
"of",
"*",
"val",
"*",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L216-L252 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey._delete | def _delete(self, pos, idx):
"""
Delete the item at the given (pos, idx).
Combines lists that are less than half the load level.
Updates the index when the sublist length is more than half the load
level. This requires decrementing the nodes in a traversal from the leaf
... | python | def _delete(self, pos, idx):
"""
Delete the item at the given (pos, idx).
Combines lists that are less than half the load level.
Updates the index when the sublist length is more than half the load
level. This requires decrementing the nodes in a traversal from the leaf
... | [
"def",
"_delete",
"(",
"self",
",",
"pos",
",",
"idx",
")",
":",
"_maxes",
",",
"_lists",
",",
"_keys",
",",
"_index",
"=",
"self",
".",
"_maxes",
",",
"self",
".",
"_lists",
",",
"self",
".",
"_keys",
",",
"self",
".",
"_index",
"keys_pos",
"=",
... | Delete the item at the given (pos, idx).
Combines lists that are less than half the load level.
Updates the index when the sublist length is more than half the load
level. This requires decrementing the nodes in a traversal from the leaf
node to the root. For an example traversal see s... | [
"Delete",
"the",
"item",
"at",
"the",
"given",
"(",
"pos",
"idx",
")",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L254-L312 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey._loc | def _loc(self, pos, idx):
"""Convert an index pair (alpha, beta) into a single index that corresponds to
the position of the value in the sorted list.
Most queries require the index be built. Details of the index are
described in self._build_index.
Indexing requires traversing ... | python | def _loc(self, pos, idx):
"""Convert an index pair (alpha, beta) into a single index that corresponds to
the position of the value in the sorted list.
Most queries require the index be built. Details of the index are
described in self._build_index.
Indexing requires traversing ... | [
"def",
"_loc",
"(",
"self",
",",
"pos",
",",
"idx",
")",
":",
"if",
"not",
"pos",
":",
"return",
"idx",
"_index",
"=",
"self",
".",
"_index",
"if",
"not",
"len",
"(",
"_index",
")",
":",
"self",
".",
"_build_index",
"(",
")",
"total",
"=",
"0",
... | Convert an index pair (alpha, beta) into a single index that corresponds to
the position of the value in the sorted list.
Most queries require the index be built. Details of the index are
described in self._build_index.
Indexing requires traversing the tree from a leaf node to the root... | [
"Convert",
"an",
"index",
"pair",
"(",
"alpha",
"beta",
")",
"into",
"a",
"single",
"index",
"that",
"corresponds",
"to",
"the",
"position",
"of",
"the",
"value",
"in",
"the",
"sorted",
"list",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L314-L386 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey.islice | def islice(self, start=None, stop=None, reverse=False):
"""
Returns an iterator that slices `self` from `start` to `stop` index,
inclusive and exclusive respectively.
When `reverse` is `True`, values are yielded from the iterator in
reverse order.
Both `start` and `stop... | python | def islice(self, start=None, stop=None, reverse=False):
"""
Returns an iterator that slices `self` from `start` to `stop` index,
inclusive and exclusive respectively.
When `reverse` is `True`, values are yielded from the iterator in
reverse order.
Both `start` and `stop... | [
"def",
"islice",
"(",
"self",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"_len",
"=",
"self",
".",
"_len",
"if",
"not",
"_len",
":",
"return",
"iter",
"(",
"(",
")",
")",
"start",
",",
"stop",
"... | Returns an iterator that slices `self` from `start` to `stop` index,
inclusive and exclusive respectively.
When `reverse` is `True`, values are yielded from the iterator in
reverse order.
Both `start` and `stop` default to `None` which is automatically
inclusive of the beginnin... | [
"Returns",
"an",
"iterator",
"that",
"slices",
"self",
"from",
"start",
"to",
"stop",
"index",
"inclusive",
"and",
"exclusive",
"respectively",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L836-L867 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey.irange | def irange(self, minimum=None, maximum=None, inclusive=(True, True),
reverse=False):
"""
Create an iterator of values between `minimum` and `maximum`.
`inclusive` is a pair of booleans that indicates whether the minimum
and maximum ought to be included in the range, respe... | python | def irange(self, minimum=None, maximum=None, inclusive=(True, True),
reverse=False):
"""
Create an iterator of values between `minimum` and `maximum`.
`inclusive` is a pair of booleans that indicates whether the minimum
and maximum ought to be included in the range, respe... | [
"def",
"irange",
"(",
"self",
",",
"minimum",
"=",
"None",
",",
"maximum",
"=",
"None",
",",
"inclusive",
"=",
"(",
"True",
",",
"True",
")",
",",
"reverse",
"=",
"False",
")",
":",
"minimum",
"=",
"self",
".",
"_key",
"(",
"minimum",
")",
"if",
... | Create an iterator of values between `minimum` and `maximum`.
`inclusive` is a pair of booleans that indicates whether the minimum
and maximum ought to be included in the range, respectively. The
default is (True, True) such that the range is inclusive of both
minimum and maximum.
... | [
"Create",
"an",
"iterator",
"of",
"values",
"between",
"minimum",
"and",
"maximum",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L908-L929 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey.copy | def copy(self):
"""Return a shallow copy of the sorted list."""
return self.__class__(self, key=self._key, load=self._load) | python | def copy(self):
"""Return a shallow copy of the sorted list."""
return self.__class__(self, key=self._key, load=self._load) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"self",
",",
"key",
"=",
"self",
".",
"_key",
",",
"load",
"=",
"self",
".",
"_load",
")"
] | Return a shallow copy of the sorted list. | [
"Return",
"a",
"shallow",
"copy",
"of",
"the",
"sorted",
"list",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L1100-L1102 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey.append | def append(self, val):
"""
Append the element *val* to the list. Raises a ValueError if the *val*
would violate the sort order.
"""
_maxes, _lists, _keys = self._maxes, self._lists, self._keys
key = self._key(val)
if not _maxes:
_maxes.append(key)
... | python | def append(self, val):
"""
Append the element *val* to the list. Raises a ValueError if the *val*
would violate the sort order.
"""
_maxes, _lists, _keys = self._maxes, self._lists, self._keys
key = self._key(val)
if not _maxes:
_maxes.append(key)
... | [
"def",
"append",
"(",
"self",
",",
"val",
")",
":",
"_maxes",
",",
"_lists",
",",
"_keys",
"=",
"self",
".",
"_maxes",
",",
"self",
".",
"_lists",
",",
"self",
".",
"_keys",
"key",
"=",
"self",
".",
"_key",
"(",
"val",
")",
"if",
"not",
"_maxes",... | Append the element *val* to the list. Raises a ValueError if the *val*
would violate the sort order. | [
"Append",
"the",
"element",
"*",
"val",
"*",
"to",
"the",
"list",
".",
"Raises",
"a",
"ValueError",
"if",
"the",
"*",
"val",
"*",
"would",
"violate",
"the",
"sort",
"order",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L1106-L1132 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey.extend | def extend(self, values):
"""
Extend the list by appending all elements from the *values*. Raises a
ValueError if the sort order would be violated.
"""
_maxes, _keys, _lists, _load = self._maxes, self._keys, self._lists, self._load
if not isinstance(values, list):
... | python | def extend(self, values):
"""
Extend the list by appending all elements from the *values*. Raises a
ValueError if the sort order would be violated.
"""
_maxes, _keys, _lists, _load = self._maxes, self._keys, self._lists, self._load
if not isinstance(values, list):
... | [
"def",
"extend",
"(",
"self",
",",
"values",
")",
":",
"_maxes",
",",
"_keys",
",",
"_lists",
",",
"_load",
"=",
"self",
".",
"_maxes",
",",
"self",
".",
"_keys",
",",
"self",
".",
"_lists",
",",
"self",
".",
"_load",
"if",
"not",
"isinstance",
"("... | Extend the list by appending all elements from the *values*. Raises a
ValueError if the sort order would be violated. | [
"Extend",
"the",
"list",
"by",
"appending",
"all",
"elements",
"from",
"the",
"*",
"values",
"*",
".",
"Raises",
"a",
"ValueError",
"if",
"the",
"sort",
"order",
"would",
"be",
"violated",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L1134-L1184 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py | SortedListWithKey.pop | def pop(self, idx=-1):
"""
Remove and return item at *idx* (default last). Raises IndexError if
list is empty or index is out of range. Negative indices are supported,
as for slice indices.
"""
if (idx < 0 and -idx > self._len) or (idx >= self._len):
raise I... | python | def pop(self, idx=-1):
"""
Remove and return item at *idx* (default last). Raises IndexError if
list is empty or index is out of range. Negative indices are supported,
as for slice indices.
"""
if (idx < 0 and -idx > self._len) or (idx >= self._len):
raise I... | [
"def",
"pop",
"(",
"self",
",",
"idx",
"=",
"-",
"1",
")",
":",
"if",
"(",
"idx",
"<",
"0",
"and",
"-",
"idx",
">",
"self",
".",
"_len",
")",
"or",
"(",
"idx",
">=",
"self",
".",
"_len",
")",
":",
"raise",
"IndexError",
"(",
"'pop index out of ... | Remove and return item at *idx* (default last). Raises IndexError if
list is empty or index is out of range. Negative indices are supported,
as for slice indices. | [
"Remove",
"and",
"return",
"item",
"at",
"*",
"idx",
"*",
"(",
"default",
"last",
")",
".",
"Raises",
"IndexError",
"if",
"list",
"is",
"empty",
"or",
"index",
"is",
"out",
"of",
"range",
".",
"Negative",
"indices",
"are",
"supported",
"as",
"for",
"sl... | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L1252-L1265 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sorteddict.py | not26 | def not26(func):
"""Function decorator for methods not implemented in Python 2.6."""
@wraps(func)
def errfunc(*args, **kwargs):
raise NotImplementedError
if hexversion < 0x02070000:
return errfunc
else:
return func | python | def not26(func):
"""Function decorator for methods not implemented in Python 2.6."""
@wraps(func)
def errfunc(*args, **kwargs):
raise NotImplementedError
if hexversion < 0x02070000:
return errfunc
else:
return func | [
"def",
"not26",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"errfunc",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"if",
"hexversion",
"<",
"0x02070000",
":",
"return",
"errfunc",
"else",
":",
... | Function decorator for methods not implemented in Python 2.6. | [
"Function",
"decorator",
"for",
"methods",
"not",
"implemented",
"in",
"Python",
"2",
".",
"6",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sorteddict.py#L17-L27 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sorteddict.py | SortedDict.copy | def copy(self):
"""Return a shallow copy of the sorted dictionary."""
return self.__class__(self._key, self._load, self._iteritems()) | python | def copy(self):
"""Return a shallow copy of the sorted dictionary."""
return self.__class__(self._key, self._load, self._iteritems()) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"self",
".",
"_key",
",",
"self",
".",
"_load",
",",
"self",
".",
"_iteritems",
"(",
")",
")"
] | Return a shallow copy of the sorted dictionary. | [
"Return",
"a",
"shallow",
"copy",
"of",
"the",
"sorted",
"dictionary",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sorteddict.py#L200-L202 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sorteddict.py | SortedDict.pop | def pop(self, key, default=_NotGiven):
"""
If *key* is in the dictionary, remove it and return its value,
else return *default*. If *default* is not given and *key* is not in
the dictionary, a KeyError is raised.
"""
if key in self:
self._list_remove(key)
... | python | def pop(self, key, default=_NotGiven):
"""
If *key* is in the dictionary, remove it and return its value,
else return *default*. If *default* is not given and *key* is not in
the dictionary, a KeyError is raised.
"""
if key in self:
self._list_remove(key)
... | [
"def",
"pop",
"(",
"self",
",",
"key",
",",
"default",
"=",
"_NotGiven",
")",
":",
"if",
"key",
"in",
"self",
":",
"self",
".",
"_list_remove",
"(",
"key",
")",
"return",
"self",
".",
"_pop",
"(",
"key",
")",
"else",
":",
"if",
"default",
"is",
"... | If *key* is in the dictionary, remove it and return its value,
else return *default*. If *default* is not given and *key* is not in
the dictionary, a KeyError is raised. | [
"If",
"*",
"key",
"*",
"is",
"in",
"the",
"dictionary",
"remove",
"it",
"and",
"return",
"its",
"value",
"else",
"return",
"*",
"default",
"*",
".",
"If",
"*",
"default",
"*",
"is",
"not",
"given",
"and",
"*",
"key",
"*",
"is",
"not",
"in",
"the",
... | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sorteddict.py#L285-L298 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sorteddict.py | SortedDict.popitem | def popitem(self, last=True):
"""
Remove and return a ``(key, value)`` pair from the dictionary. If
last=True (default) then remove the *greatest* `key` from the
diciontary. Else, remove the *least* key from the dictionary.
If the dictionary is empty, calling `popitem` raises a
... | python | def popitem(self, last=True):
"""
Remove and return a ``(key, value)`` pair from the dictionary. If
last=True (default) then remove the *greatest* `key` from the
diciontary. Else, remove the *least* key from the dictionary.
If the dictionary is empty, calling `popitem` raises a
... | [
"def",
"popitem",
"(",
"self",
",",
"last",
"=",
"True",
")",
":",
"if",
"not",
"len",
"(",
"self",
")",
":",
"raise",
"KeyError",
"(",
"'popitem(): dictionary is empty'",
")",
"key",
"=",
"self",
".",
"_list_pop",
"(",
"-",
"1",
"if",
"last",
"else",
... | Remove and return a ``(key, value)`` pair from the dictionary. If
last=True (default) then remove the *greatest* `key` from the
diciontary. Else, remove the *least* key from the dictionary.
If the dictionary is empty, calling `popitem` raises a
KeyError`. | [
"Remove",
"and",
"return",
"a",
"(",
"key",
"value",
")",
"pair",
"from",
"the",
"dictionary",
".",
"If",
"last",
"=",
"True",
"(",
"default",
")",
"then",
"remove",
"the",
"*",
"greatest",
"*",
"key",
"from",
"the",
"diciontary",
".",
"Else",
"remove"... | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sorteddict.py#L300-L315 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sorteddict.py | SortedDict.setdefault | def setdefault(self, key, default=None):
"""
If *key* is in the dictionary, return its value. If not, insert *key*
with a value of *default* and return *default*. *default* defaults to
``None``.
"""
if key in self:
return self[key]
else:
... | python | def setdefault(self, key, default=None):
"""
If *key* is in the dictionary, return its value. If not, insert *key*
with a value of *default* and return *default*. *default* defaults to
``None``.
"""
if key in self:
return self[key]
else:
... | [
"def",
"setdefault",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"if",
"key",
"in",
"self",
":",
"return",
"self",
"[",
"key",
"]",
"else",
":",
"self",
".",
"_setitem",
"(",
"key",
",",
"default",
")",
"self",
".",
"_list_add",... | If *key* is in the dictionary, return its value. If not, insert *key*
with a value of *default* and return *default*. *default* defaults to
``None``. | [
"If",
"*",
"key",
"*",
"is",
"in",
"the",
"dictionary",
"return",
"its",
"value",
".",
"If",
"not",
"insert",
"*",
"key",
"*",
"with",
"a",
"value",
"of",
"*",
"default",
"*",
"and",
"return",
"*",
"default",
"*",
".",
"*",
"default",
"*",
"default... | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sorteddict.py#L317-L328 |
lrq3000/pyFileFixity | pyFileFixity/lib/sortedcontainers/sorteddict.py | KeysView.index | def index(self, value, start=None, stop=None):
"""
Return the smallest *k* such that `keysview[k] == value` and `start <= k
< end`. Raises `KeyError` if *value* is not present. *stop* defaults
to the end of the set. *start* defaults to the beginning. Negative
indexes are supp... | python | def index(self, value, start=None, stop=None):
"""
Return the smallest *k* such that `keysview[k] == value` and `start <= k
< end`. Raises `KeyError` if *value* is not present. *stop* defaults
to the end of the set. *start* defaults to the beginning. Negative
indexes are supp... | [
"def",
"index",
"(",
"self",
",",
"value",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"return",
"self",
".",
"_list",
".",
"index",
"(",
"value",
",",
"start",
",",
"stop",
")"
] | Return the smallest *k* such that `keysview[k] == value` and `start <= k
< end`. Raises `KeyError` if *value* is not present. *stop* defaults
to the end of the set. *start* defaults to the beginning. Negative
indexes are supported, as for slice indices. | [
"Return",
"the",
"smallest",
"*",
"k",
"*",
"such",
"that",
"keysview",
"[",
"k",
"]",
"==",
"value",
"and",
"start",
"<",
"=",
"k",
"<",
"end",
".",
"Raises",
"KeyError",
"if",
"*",
"value",
"*",
"is",
"not",
"present",
".",
"*",
"stop",
"*",
"d... | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sorteddict.py#L462-L469 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/tracker.py | SummaryTracker.create_summary | def create_summary(self):
"""Return a summary.
See also the notes on ignore_self in the class as well as the
initializer documentation.
"""
if not self.ignore_self:
res = summary.summarize(muppy.get_objects())
else:
# If the user requested the da... | python | def create_summary(self):
"""Return a summary.
See also the notes on ignore_self in the class as well as the
initializer documentation.
"""
if not self.ignore_self:
res = summary.summarize(muppy.get_objects())
else:
# If the user requested the da... | [
"def",
"create_summary",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"ignore_self",
":",
"res",
"=",
"summary",
".",
"summarize",
"(",
"muppy",
".",
"get_objects",
"(",
")",
")",
"else",
":",
"# If the user requested the data required to store summaries to be... | Return a summary.
See also the notes on ignore_self in the class as well as the
initializer documentation. | [
"Return",
"a",
"summary",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/tracker.py#L47-L100 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/tracker.py | SummaryTracker.diff | def diff(self, summary1=None, summary2=None):
"""Compute diff between to summaries.
If no summary is provided, the diff from the last to the current
summary is used. If summary1 is provided the diff from summary1
to the current summary is used. If summary1 and summary2 are
provi... | python | def diff(self, summary1=None, summary2=None):
"""Compute diff between to summaries.
If no summary is provided, the diff from the last to the current
summary is used. If summary1 is provided the diff from summary1
to the current summary is used. If summary1 and summary2 are
provi... | [
"def",
"diff",
"(",
"self",
",",
"summary1",
"=",
"None",
",",
"summary2",
"=",
"None",
")",
":",
"res",
"=",
"None",
"if",
"summary2",
"is",
"None",
":",
"self",
".",
"s1",
"=",
"self",
".",
"create_summary",
"(",
")",
"if",
"summary1",
"is",
"Non... | Compute diff between to summaries.
If no summary is provided, the diff from the last to the current
summary is used. If summary1 is provided the diff from summary1
to the current summary is used. If summary1 and summary2 are
provided, the diff between these two is used. | [
"Compute",
"diff",
"between",
"to",
"summaries",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/tracker.py#L102-L124 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/tracker.py | SummaryTracker.print_diff | def print_diff(self, summary1=None, summary2=None):
"""Compute diff between to summaries and print it.
If no summary is provided, the diff from the last to the current
summary is used. If summary1 is provided the diff from summary1
to the current summary is used. If summary1 and summary... | python | def print_diff(self, summary1=None, summary2=None):
"""Compute diff between to summaries and print it.
If no summary is provided, the diff from the last to the current
summary is used. If summary1 is provided the diff from summary1
to the current summary is used. If summary1 and summary... | [
"def",
"print_diff",
"(",
"self",
",",
"summary1",
"=",
"None",
",",
"summary2",
"=",
"None",
")",
":",
"summary",
".",
"print_",
"(",
"self",
".",
"diff",
"(",
"summary1",
"=",
"summary1",
",",
"summary2",
"=",
"summary2",
")",
")"
] | Compute diff between to summaries and print it.
If no summary is provided, the diff from the last to the current
summary is used. If summary1 is provided the diff from summary1
to the current summary is used. If summary1 and summary2 are
provided, the diff between these two is used. | [
"Compute",
"diff",
"between",
"to",
"summaries",
"and",
"print",
"it",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/tracker.py#L126-L134 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/tracker.py | ObjectTracker._get_objects | def _get_objects(self, ignore=[]):
"""Get all currently existing objects.
XXX - ToDo: This method is a copy&paste from muppy.get_objects, but
some modifications are applied. Specifically, it allows to ignore
objects (which includes the current frame).
keyword arguments
... | python | def _get_objects(self, ignore=[]):
"""Get all currently existing objects.
XXX - ToDo: This method is a copy&paste from muppy.get_objects, but
some modifications are applied. Specifically, it allows to ignore
objects (which includes the current frame).
keyword arguments
... | [
"def",
"_get_objects",
"(",
"self",
",",
"ignore",
"=",
"[",
"]",
")",
":",
"def",
"remove_ignore",
"(",
"objects",
",",
"ignore",
"=",
"[",
"]",
")",
":",
"# remove all objects listed in the ignore list",
"res",
"=",
"[",
"]",
"for",
"o",
"in",
"objects",... | Get all currently existing objects.
XXX - ToDo: This method is a copy&paste from muppy.get_objects, but
some modifications are applied. Specifically, it allows to ignore
objects (which includes the current frame).
keyword arguments
ignore -- list of objects to ignore | [
"Get",
"all",
"currently",
"existing",
"objects",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/tracker.py#L169-L213 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/tracker.py | ObjectTracker.get_diff | def get_diff(self, ignore=[]):
"""Get the diff to the last time the state of objects was measured.
keyword arguments
ignore -- list of objects to ignore
"""
# ignore this and the caller frame
ignore.append(inspect.currentframe()) #PYCHOK change ignore
self.o1 = ... | python | def get_diff(self, ignore=[]):
"""Get the diff to the last time the state of objects was measured.
keyword arguments
ignore -- list of objects to ignore
"""
# ignore this and the caller frame
ignore.append(inspect.currentframe()) #PYCHOK change ignore
self.o1 = ... | [
"def",
"get_diff",
"(",
"self",
",",
"ignore",
"=",
"[",
"]",
")",
":",
"# ignore this and the caller frame",
"ignore",
".",
"append",
"(",
"inspect",
".",
"currentframe",
"(",
")",
")",
"#PYCHOK change ignore",
"self",
".",
"o1",
"=",
"self",
".",
"_get_obj... | Get the diff to the last time the state of objects was measured.
keyword arguments
ignore -- list of objects to ignore | [
"Get",
"the",
"diff",
"to",
"the",
"last",
"time",
"the",
"state",
"of",
"objects",
"was",
"measured",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/tracker.py#L215-L228 |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/tracker.py | ObjectTracker.print_diff | def print_diff(self, ignore=[]):
"""Print the diff to the last time the state of objects was measured.
keyword arguments
ignore -- list of objects to ignore
"""
# ignore this and the caller frame
ignore.append(inspect.currentframe()) #PYCHOK change ignore
diff = ... | python | def print_diff(self, ignore=[]):
"""Print the diff to the last time the state of objects was measured.
keyword arguments
ignore -- list of objects to ignore
"""
# ignore this and the caller frame
ignore.append(inspect.currentframe()) #PYCHOK change ignore
diff = ... | [
"def",
"print_diff",
"(",
"self",
",",
"ignore",
"=",
"[",
"]",
")",
":",
"# ignore this and the caller frame",
"ignore",
".",
"append",
"(",
"inspect",
".",
"currentframe",
"(",
")",
")",
"#PYCHOK change ignore",
"diff",
"=",
"self",
".",
"get_diff",
"(",
"... | Print the diff to the last time the state of objects was measured.
keyword arguments
ignore -- list of objects to ignore | [
"Print",
"the",
"diff",
"to",
"the",
"last",
"time",
"the",
"state",
"of",
"objects",
"was",
"measured",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/tracker.py#L230-L244 |
lrq3000/pyFileFixity | pyFileFixity/lib/distance/distance/_simpledists.py | hamming | def hamming(seq1, seq2, normalized=False):
"""Compute the Hamming distance between the two sequences `seq1` and `seq2`.
The Hamming distance is the number of differing items in two ordered
sequences of the same length. If the sequences submitted do not have the
same length, an error will be raised.
If `normalize... | python | def hamming(seq1, seq2, normalized=False):
"""Compute the Hamming distance between the two sequences `seq1` and `seq2`.
The Hamming distance is the number of differing items in two ordered
sequences of the same length. If the sequences submitted do not have the
same length, an error will be raised.
If `normalize... | [
"def",
"hamming",
"(",
"seq1",
",",
"seq2",
",",
"normalized",
"=",
"False",
")",
":",
"L",
"=",
"len",
"(",
"seq1",
")",
"if",
"L",
"!=",
"len",
"(",
"seq2",
")",
":",
"raise",
"ValueError",
"(",
"\"expected two strings of the same length\"",
")",
"if",... | Compute the Hamming distance between the two sequences `seq1` and `seq2`.
The Hamming distance is the number of differing items in two ordered
sequences of the same length. If the sequences submitted do not have the
same length, an error will be raised.
If `normalized` evaluates to `False`, the return value will ... | [
"Compute",
"the",
"Hamming",
"distance",
"between",
"the",
"two",
"sequences",
"seq1",
"and",
"seq2",
".",
"The",
"Hamming",
"distance",
"is",
"the",
"number",
"of",
"differing",
"items",
"in",
"two",
"ordered",
"sequences",
"of",
"the",
"same",
"length",
".... | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/distance/distance/_simpledists.py#L3-L25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.