hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2dd49fdb9ceb04e59434271ded35ecefdc4f074e | devmichaelgirgis/android-perf-testing | run_perf_tests.py | [
"Apache-2.0"
] | Python | enable_dump_permission | null | def enable_dump_permission(sdk_path, device_id, dest_dir, package_name):
"""Enable the DUMP permission on the specified and installed Android
app.
"""
print 'Starting dump permission grant'
perm_command = [os.path.join(sdk_path, 'platform-tools', 'adb'),
'-s', device_id,
... | Enable the DUMP permission on the specified and installed Android
app.
| Enable the DUMP permission on the specified and installed Android
app. | [
"Enable",
"the",
"DUMP",
"permission",
"on",
"the",
"specified",
"and",
"installed",
"Android",
"app",
"."
] | def enable_dump_permission(sdk_path, device_id, dest_dir, package_name):
print 'Starting dump permission grant'
perm_command = [os.path.join(sdk_path, 'platform-tools', 'adb'),
'-s', device_id,
'shell',
'pm', 'grant', package_name,
... | [
"def",
"enable_dump_permission",
"(",
"sdk_path",
",",
"device_id",
",",
"dest_dir",
",",
"package_name",
")",
":",
"print",
"'Starting dump permission grant'",
"perm_command",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"sdk_path",
",",
"'platform-tools'",
","... | Enable the DUMP permission on the specified and installed Android
app. | [
"Enable",
"the",
"DUMP",
"permission",
"on",
"the",
"specified",
"and",
"installed",
"Android",
"app",
"."
] | [
"\"\"\"Enable the DUMP permission on the specified and installed Android\n app.\n \"\"\""
] | [
{
"param": "sdk_path",
"type": null
},
{
"param": "device_id",
"type": null
},
{
"param": "dest_dir",
"type": null
},
{
"param": "package_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sdk_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "device_id",
"type": null,
"docstring": null,
"docstring_t... |
2dd49fdb9ceb04e59434271ded35ecefdc4f074e | devmichaelgirgis/android-perf-testing | run_perf_tests.py | [
"Apache-2.0"
] | Python | enable_storage_permission | null | def enable_storage_permission(sdk_path, device_id, dest_dir, package_name):
"""Enable the WRITE_EXTERNAL_STORAGE permission on the specified and
installed Android app.
"""
print 'Starting storage permission grant'
perm_command = [os.path.join(sdk_path, 'platform-tools',
... | Enable the WRITE_EXTERNAL_STORAGE permission on the specified and
installed Android app.
| Enable the WRITE_EXTERNAL_STORAGE permission on the specified and
installed Android app. | [
"Enable",
"the",
"WRITE_EXTERNAL_STORAGE",
"permission",
"on",
"the",
"specified",
"and",
"installed",
"Android",
"app",
"."
] | def enable_storage_permission(sdk_path, device_id, dest_dir, package_name):
print 'Starting storage permission grant'
perm_command = [os.path.join(sdk_path, 'platform-tools',
'adb'),
'-s', device_id,
'shell',
'pm', 'gra... | [
"def",
"enable_storage_permission",
"(",
"sdk_path",
",",
"device_id",
",",
"dest_dir",
",",
"package_name",
")",
":",
"print",
"'Starting storage permission grant'",
"perm_command",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"sdk_path",
",",
"'platform-tools'",... | Enable the WRITE_EXTERNAL_STORAGE permission on the specified and
installed Android app. | [
"Enable",
"the",
"WRITE_EXTERNAL_STORAGE",
"permission",
"on",
"the",
"specified",
"and",
"installed",
"Android",
"app",
"."
] | [
"\"\"\"Enable the WRITE_EXTERNAL_STORAGE permission on the specified and\n installed Android app.\n \"\"\""
] | [
{
"param": "sdk_path",
"type": null
},
{
"param": "device_id",
"type": null
},
{
"param": "dest_dir",
"type": null
},
{
"param": "package_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sdk_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "device_id",
"type": null,
"docstring": null,
"docstring_t... |
2dd49fdb9ceb04e59434271ded35ecefdc4f074e | devmichaelgirgis/android-perf-testing | run_perf_tests.py | [
"Apache-2.0"
] | Python | pull_device_data_files | null | def pull_device_data_files(sdk_path, device_id, source_dir, dest_dir, package_name, log_suffix):
"""Extrace test files from a device after a test run."""
print 'Starting adb pull for test files'
test_data_location = (source_dir + package_name +
'/files/testdata')
pull_test_dat... | Extrace test files from a device after a test run. | Extrace test files from a device after a test run. | [
"Extrace",
"test",
"files",
"from",
"a",
"device",
"after",
"a",
"test",
"run",
"."
] | def pull_device_data_files(sdk_path, device_id, source_dir, dest_dir, package_name, log_suffix):
print 'Starting adb pull for test files'
test_data_location = (source_dir + package_name +
'/files/testdata')
pull_test_data_command = [os.path.join(sdk_path, 'platform-tools',
... | [
"def",
"pull_device_data_files",
"(",
"sdk_path",
",",
"device_id",
",",
"source_dir",
",",
"dest_dir",
",",
"package_name",
",",
"log_suffix",
")",
":",
"print",
"'Starting adb pull for test files'",
"test_data_location",
"=",
"(",
"source_dir",
"+",
"package_name",
... | Extrace test files from a device after a test run. | [
"Extrace",
"test",
"files",
"from",
"a",
"device",
"after",
"a",
"test",
"run",
"."
] | [
"\"\"\"Extrace test files from a device after a test run.\"\"\""
] | [
{
"param": "sdk_path",
"type": null
},
{
"param": "device_id",
"type": null
},
{
"param": "source_dir",
"type": null
},
{
"param": "dest_dir",
"type": null
},
{
"param": "package_name",
"type": null
},
{
"param": "log_suffix",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sdk_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "device_id",
"type": null,
"docstring": null,
"docstring_t... |
2dd49fdb9ceb04e59434271ded35ecefdc4f074e | devmichaelgirgis/android-perf-testing | run_perf_tests.py | [
"Apache-2.0"
] | Python | open_app | null | def open_app(device, package_name):
"""Open the specified app on the device."""
device.shell('am start -n ' + package_name + '/' + package_name +
'.MainActivity') | Open the specified app on the device. | Open the specified app on the device. | [
"Open",
"the",
"specified",
"app",
"on",
"the",
"device",
"."
] | def open_app(device, package_name):
device.shell('am start -n ' + package_name + '/' + package_name +
'.MainActivity') | [
"def",
"open_app",
"(",
"device",
",",
"package_name",
")",
":",
"device",
".",
"shell",
"(",
"'am start -n '",
"+",
"package_name",
"+",
"'/'",
"+",
"package_name",
"+",
"'.MainActivity'",
")"
] | Open the specified app on the device. | [
"Open",
"the",
"specified",
"app",
"on",
"the",
"device",
"."
] | [
"\"\"\"Open the specified app on the device.\"\"\""
] | [
{
"param": "device",
"type": null
},
{
"param": "package_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "device",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "package_name",
"type": null,
"docstring": null,
"docstring_... |
2dd49fdb9ceb04e59434271ded35ecefdc4f074e | devmichaelgirgis/android-perf-testing | run_perf_tests.py | [
"Apache-2.0"
] | Python | analyze_data_files | <not_specific> | def analyze_data_files(dest_dir):
"""Analyze data files for issues that indicate a test failure."""
overall_passed = True
test_data_dir = os.path.join(dest_dir, 'testdata')
for dir_name, sub_dir_list, file_list in os.walk(test_data_dir):
if dir_name == os.path.join(dest_dir, 'testdata'):
... | Analyze data files for issues that indicate a test failure. | Analyze data files for issues that indicate a test failure. | [
"Analyze",
"data",
"files",
"for",
"issues",
"that",
"indicate",
"a",
"test",
"failure",
"."
] | def analyze_data_files(dest_dir):
overall_passed = True
test_data_dir = os.path.join(dest_dir, 'testdata')
for dir_name, sub_dir_list, file_list in os.walk(test_data_dir):
if dir_name == os.path.join(dest_dir, 'testdata'):
for fname in file_list:
if fname == 'batterystats... | [
"def",
"analyze_data_files",
"(",
"dest_dir",
")",
":",
"overall_passed",
"=",
"True",
"test_data_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dest_dir",
",",
"'testdata'",
")",
"for",
"dir_name",
",",
"sub_dir_list",
",",
"file_list",
"in",
"os",
".",
... | Analyze data files for issues that indicate a test failure. | [
"Analyze",
"data",
"files",
"for",
"issues",
"that",
"indicate",
"a",
"test",
"failure",
"."
] | [
"\"\"\"Analyze data files for issues that indicate a test failure.\"\"\"",
"# in the root folder",
"# pylint: disable=fixme",
"# TODO(developer): process battery data.",
"# pylint: disable=fixme",
"# TODO(developer): process location requests information.",
"# in a test folder",
"# process gfxinfo for... | [
{
"param": "dest_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dest_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
12ad8c1672cbe18ad0d945b53600534e4a3e00c1 | greyblue9/justuse | src/use/use.py | [
"MIT"
] | Python | cleanup | null | def cleanup(self):
"""Bring registry and downloaded packages in sync.
First all packages are removed that don't have a matching registry entry, then all registry entries that don't have a matching pkg.
"""
def delete_folder(path):
for sub in path.iterdir():
... | Bring registry and downloaded packages in sync.
First all packages are removed that don't have a matching registry entry, then all registry entries that don't have a matching pkg.
| Bring registry and downloaded packages in sync.
First all packages are removed that don't have a matching registry entry, then all registry entries that don't have a matching pkg. | [
"Bring",
"registry",
"and",
"downloaded",
"packages",
"in",
"sync",
".",
"First",
"all",
"packages",
"are",
"removed",
"that",
"don",
"'",
"t",
"have",
"a",
"matching",
"registry",
"entry",
"then",
"all",
"registry",
"entries",
"that",
"don",
"'",
"t",
"ha... | def cleanup(self):
def delete_folder(path):
for sub in path.iterdir():
if sub.is_dir():
delete_folder(sub)
else:
sub.unlink()
path.rmdir()
for name, version, artifact_path, installation_path in self.registry.... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"def",
"delete_folder",
"(",
"path",
")",
":",
"for",
"sub",
"in",
"path",
".",
"iterdir",
"(",
")",
":",
"if",
"sub",
".",
"is_dir",
"(",
")",
":",
"delete_folder",
"(",
"sub",
")",
"else",
":",
"sub",
".... | Bring registry and downloaded packages in sync. | [
"Bring",
"registry",
"and",
"downloaded",
"packages",
"in",
"sync",
"."
] | [
"\"\"\"Bring registry and downloaded packages in sync.\n\n First all packages are removed that don't have a matching registry entry, then all registry entries that don't have a matching pkg.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
12ad8c1672cbe18ad0d945b53600534e4a3e00c1 | greyblue9/justuse | src/use/use.py | [
"MIT"
] | Python | _use_path | ProxyModule | def _use_path(
self,
path,
/,
*,
initial_globals=None,
as_import: str = None,
default=mode.fastfail,
modes=0,
) -> ProxyModule:
"""Import a module from a path.
https://github.com/amogorkon/justuse/wiki/Use-Path
Args:
... | Import a module from a path.
https://github.com/amogorkon/justuse/wiki/Use-Path
Args:
path ([type]): must be a pathlib.Path
initial_globals ([type], optional): dict that should be globally available to the module before executing it. Defaults to None.
default ([type... | Import a module from a path. | [
"Import",
"a",
"module",
"from",
"a",
"path",
"."
] | def _use_path(
self,
path,
/,
*,
initial_globals=None,
as_import: str = None,
default=mode.fastfail,
modes=0,
) -> ProxyModule:
log.debug(f"use-path: {path}")
initial_globals = initial_globals or {}
reloading = bool(Use.reloadin... | [
"def",
"_use_path",
"(",
"self",
",",
"path",
",",
"/",
",",
"*",
",",
"initial_globals",
"=",
"None",
",",
"as_import",
":",
"str",
"=",
"None",
",",
"default",
"=",
"mode",
".",
"fastfail",
",",
"modes",
"=",
"0",
",",
")",
"->",
"ProxyModule",
"... | Import a module from a path. | [
"Import",
"a",
"module",
"from",
"a",
"path",
"."
] | [
"\"\"\"Import a module from a path.\n\n https://github.com/amogorkon/justuse/wiki/Use-Path\n\n Args:\n path ([type]): must be a pathlib.Path\n initial_globals ([type], optional): dict that should be globally available to the module before executing it. Defaults to None.\n ... | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "initial_globals",
"type": null
},
{
"param": "as_import",
"type": "str"
},
{
"param": "default",
"type": null
},
{
"param": "modes",
"type": null
}
] | {
"returns": [
{
"docstring": "The module if it was imported, otherwise whatever was specified as default.",
"docstring_tokens": [
"The",
"module",
"if",
"it",
"was",
"imported",
"otherwise",
"whatever",
"was",
"specified"... |
12ad8c1672cbe18ad0d945b53600534e4a3e00c1 | greyblue9/justuse | src/use/use.py | [
"MIT"
] | Python | _use_str | ProxyModule | def _use_str(
self,
name: str,
/,
*,
version: str = None,
hash_algo=Hash.sha256,
hashes: Optional[Union[str, list[str]]] = None,
default=mode.fastfail,
modes: int = 0,
) -> ProxyModule:
"""
Import a pkg by name.
https:/... |
Import a pkg by name.
https://github.com/amogorkon/justuse/wiki/Use-String
Args:
name (str): The name of the pkg to import.
version (str or Version, optional): The version of the pkg to import. Defaults to None.
hash_algo (member of Use.Hash, optional): For... | Import a pkg by name. | [
"Import",
"a",
"pkg",
"by",
"name",
"."
] | def _use_str(
self,
name: str,
/,
*,
version: str = None,
hash_algo=Hash.sha256,
hashes: Optional[Union[str, list[str]]] = None,
default=mode.fastfail,
modes: int = 0,
) -> ProxyModule:
package_name, module_name = _parse_name(name)
... | [
"def",
"_use_str",
"(",
"self",
",",
"name",
":",
"str",
",",
"/",
",",
"*",
",",
"version",
":",
"str",
"=",
"None",
",",
"hash_algo",
"=",
"Hash",
".",
"sha256",
",",
"hashes",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"list",
"[",
"str",... | Import a pkg by name. | [
"Import",
"a",
"pkg",
"by",
"name",
"."
] | [
"\"\"\"\n Import a pkg by name.\n\n https://github.com/amogorkon/justuse/wiki/Use-String\n\n Args:\n name (str): The name of the pkg to import.\n version (str or Version, optional): The version of the pkg to import. Defaults to None.\n hash_algo (member of Use.H... | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": "str"
},
{
"param": "version",
"type": "str"
},
{
"param": "hash_algo",
"type": null
},
{
"param": "hashes",
"type": "Optional[Union[str, list[str]]]"
},
{
"param": "default",
"type": nu... | {
"returns": [
{
"docstring": "Module if successful, default as specified otherwise.",
"docstring_tokens": [
"Module",
"if",
"successful",
"default",
"as",
"specified",
"otherwise",
"."
],
"type": "Optional[ModuleType]"
}
... |
12ad8c1672cbe18ad0d945b53600534e4a3e00c1 | greyblue9/justuse | src/use/use.py | [
"MIT"
] | Python | decorator_log_calling_function_and_args | <not_specific> | def decorator_log_calling_function_and_args(func, *args):
"""
Decorator to log the calling function and its arguments.
Args:
func (function): The function to decorate.
*args: The arguments to pass to the function.
Returns:
function: The decorated function.
"""
def wrap... |
Decorator to log the calling function and its arguments.
Args:
func (function): The function to decorate.
*args: The arguments to pass to the function.
Returns:
function: The decorated function.
| Decorator to log the calling function and its arguments. | [
"Decorator",
"to",
"log",
"the",
"calling",
"function",
"and",
"its",
"arguments",
"."
] | def decorator_log_calling_function_and_args(func, *args):
def wrapper(*args, **kwargs):
log.debug(f"{func.__name__}({args}, {kwargs})")
return func(*args, **kwargs)
return wrapper | [
"def",
"decorator_log_calling_function_and_args",
"(",
"func",
",",
"*",
"args",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"log",
".",
"debug",
"(",
"f\"{func.__name__}({args}, {kwargs})\"",
")",
"return",
"func",
"(",
"*",
... | Decorator to log the calling function and its arguments. | [
"Decorator",
"to",
"log",
"the",
"calling",
"function",
"and",
"its",
"arguments",
"."
] | [
"\"\"\"\n Decorator to log the calling function and its arguments.\n\n Args:\n func (function): The function to decorate.\n *args: The arguments to pass to the function.\n\n Returns:\n function: The decorated function.\n \"\"\""
] | [
{
"param": "func",
"type": null
}
] | {
"returns": [
{
"docstring": "The decorated function.",
"docstring_tokens": [
"The",
"decorated",
"function",
"."
],
"type": "function"
}
],
"raises": [],
"params": [
{
"identifier": "func",
"type": null,
"docstring": "The fu... |
606e4e79c7433991ea39e2116b1d582a6b6a4463 | greyblue9/justuse | src/use/modules/install_utils.py | [
"MIT"
] | Python | _is_version_satisfied | bool | def _is_version_satisfied(specifier: str, sys_version) -> bool:
"""
SpecifierSet("") matches anything, no need to artificially
lock down versions at this point
@see https://warehouse.readthedocs.io/api-reference/json.html
@see https://packaging.pypa.io/en/latest/specifiers.html
"""
specifie... |
SpecifierSet("") matches anything, no need to artificially
lock down versions at this point
@see https://warehouse.readthedocs.io/api-reference/json.html
@see https://packaging.pypa.io/en/latest/specifiers.html
| SpecifierSet("") matches anything, no need to artificially
lock down versions at this point | [
"SpecifierSet",
"(",
"\"",
"\"",
")",
"matches",
"anything",
"no",
"need",
"to",
"artificially",
"lock",
"down",
"versions",
"at",
"this",
"point"
] | def _is_version_satisfied(specifier: str, sys_version) -> bool:
specifiers = SpecifierSet(specifier or "")
is_match = sys_version in specifiers
log.debug(f"is_version_satisfied(info=i){sys_version} in {specifiers}")
return is_match | [
"def",
"_is_version_satisfied",
"(",
"specifier",
":",
"str",
",",
"sys_version",
")",
"->",
"bool",
":",
"specifiers",
"=",
"SpecifierSet",
"(",
"specifier",
"or",
"\"\"",
")",
"is_match",
"=",
"sys_version",
"in",
"specifiers",
"log",
".",
"debug",
"(",
"f... | SpecifierSet("") matches anything, no need to artificially
lock down versions at this point | [
"SpecifierSet",
"(",
"\"",
"\"",
")",
"matches",
"anything",
"no",
"need",
"to",
"artificially",
"lock",
"down",
"versions",
"at",
"this",
"point"
] | [
"\"\"\"\n SpecifierSet(\"\") matches anything, no need to artificially\n lock down versions at this point\n\n @see https://warehouse.readthedocs.io/api-reference/json.html\n @see https://packaging.pypa.io/en/latest/specifiers.html\n \"\"\""
] | [
{
"param": "specifier",
"type": "str"
},
{
"param": "sys_version",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "specifier",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sys_version",
"type": null,
"docstring": null,
"docstri... |
606e4e79c7433991ea39e2116b1d582a6b6a4463 | greyblue9/justuse | src/use/modules/install_utils.py | [
"MIT"
] | Python | _is_compatible | bool | def _is_compatible(
info: PyPI_Release, sys_version, platform_tags, include_sdist=None
) -> bool:
"""Return true if the artifact described by 'info'
is compatible with the current or specified system."""
specifier = info.requires_python
return (
(not specifier or _is_version_satisfied(speci... | Return true if the artifact described by 'info'
is compatible with the current or specified system. | Return true if the artifact described by 'info'
is compatible with the current or specified system. | [
"Return",
"true",
"if",
"the",
"artifact",
"described",
"by",
"'",
"info",
"'",
"is",
"compatible",
"with",
"the",
"current",
"or",
"specified",
"system",
"."
] | def _is_compatible(
info: PyPI_Release, sys_version, platform_tags, include_sdist=None
) -> bool:
specifier = info.requires_python
return (
(not specifier or _is_version_satisfied(specifier, sys_version))
and _is_platform_compatible(info, platform_tags, include_sdist)
and not info.ya... | [
"def",
"_is_compatible",
"(",
"info",
":",
"PyPI_Release",
",",
"sys_version",
",",
"platform_tags",
",",
"include_sdist",
"=",
"None",
")",
"->",
"bool",
":",
"specifier",
"=",
"info",
".",
"requires_python",
"return",
"(",
"(",
"not",
"specifier",
"or",
"_... | Return true if the artifact described by 'info'
is compatible with the current or specified system. | [
"Return",
"true",
"if",
"the",
"artifact",
"described",
"by",
"'",
"info",
"'",
"is",
"compatible",
"with",
"the",
"current",
"or",
"specified",
"system",
"."
] | [
"\"\"\"Return true if the artifact described by 'info'\n is compatible with the current or specified system.\"\"\""
] | [
{
"param": "info",
"type": "PyPI_Release"
},
{
"param": "sys_version",
"type": null
},
{
"param": "platform_tags",
"type": null
},
{
"param": "include_sdist",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "info",
"type": "PyPI_Release",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sys_version",
"type": null,
"docstring": null,
"doc... |
606e4e79c7433991ea39e2116b1d582a6b6a4463 | greyblue9/justuse | src/use/modules/install_utils.py | [
"MIT"
] | Python | _apply_aspect | Any | def _apply_aspect(
thing,
check,
pattern,
decorator: Callable[[Callable[..., Any]], Any],
aspectize_dunders=False,
) -> Any:
"""Apply the aspect as a side-effect, no copy is created."""
for name, obj in thing.__dict__.items():
if not aspectize_dunders and name.startswith("__") and na... | Apply the aspect as a side-effect, no copy is created. | Apply the aspect as a side-effect, no copy is created. | [
"Apply",
"the",
"aspect",
"as",
"a",
"side",
"-",
"effect",
"no",
"copy",
"is",
"created",
"."
] | def _apply_aspect(
thing,
check,
pattern,
decorator: Callable[[Callable[..., Any]], Any],
aspectize_dunders=False,
) -> Any:
for name, obj in thing.__dict__.items():
if not aspectize_dunders and name.startswith("__") and name.endswith("__"):
continue
if check(obj) and... | [
"def",
"_apply_aspect",
"(",
"thing",
",",
"check",
",",
"pattern",
",",
"decorator",
":",
"Callable",
"[",
"[",
"Callable",
"[",
"...",
",",
"Any",
"]",
"]",
",",
"Any",
"]",
",",
"aspectize_dunders",
"=",
"False",
",",
")",
"->",
"Any",
":",
"for",... | Apply the aspect as a side-effect, no copy is created. | [
"Apply",
"the",
"aspect",
"as",
"a",
"side",
"-",
"effect",
"no",
"copy",
"is",
"created",
"."
] | [
"\"\"\"Apply the aspect as a side-effect, no copy is created.\"\"\""
] | [
{
"param": "thing",
"type": null
},
{
"param": "check",
"type": null
},
{
"param": "pattern",
"type": null
},
{
"param": "decorator",
"type": "Callable[[Callable[..., Any]], Any]"
},
{
"param": "aspectize_dunders",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "thing",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "check",
"type": null,
"docstring": null,
"docstring_tokens":... |
a8fa6cf51b426d26f0506a4d8e2e62e10ebe1459 | 4ybaka/py-nrf24 | src/nrf24/nrf24.py | [
"MIT"
] | Python | _nrf_write_reg | null | def _nrf_write_reg(self, reg, arg):
"""
Write arg (which may be one or more bytes) to reg.
This function is only permitted in a powerdown or
standby mode.
"""
if type(arg) is not list:
arg = [arg]
self._nrf_xfer([self.W_REGISTER | reg] + arg) |
Write arg (which may be one or more bytes) to reg.
This function is only permitted in a powerdown or
standby mode.
| Write arg (which may be one or more bytes) to reg.
This function is only permitted in a powerdown or
standby mode. | [
"Write",
"arg",
"(",
"which",
"may",
"be",
"one",
"or",
"more",
"bytes",
")",
"to",
"reg",
".",
"This",
"function",
"is",
"only",
"permitted",
"in",
"a",
"powerdown",
"or",
"standby",
"mode",
"."
] | def _nrf_write_reg(self, reg, arg):
if type(arg) is not list:
arg = [arg]
self._nrf_xfer([self.W_REGISTER | reg] + arg) | [
"def",
"_nrf_write_reg",
"(",
"self",
",",
"reg",
",",
"arg",
")",
":",
"if",
"type",
"(",
"arg",
")",
"is",
"not",
"list",
":",
"arg",
"=",
"[",
"arg",
"]",
"self",
".",
"_nrf_xfer",
"(",
"[",
"self",
".",
"W_REGISTER",
"|",
"reg",
"]",
"+",
"... | Write arg (which may be one or more bytes) to reg. | [
"Write",
"arg",
"(",
"which",
"may",
"be",
"one",
"or",
"more",
"bytes",
")",
"to",
"reg",
"."
] | [
"\"\"\"\n Write arg (which may be one or more bytes) to reg.\n\n This function is only permitted in a powerdown or\n standby mode.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "reg",
"type": null
},
{
"param": "arg",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reg",
"type": null,
"docstring": null,
"docstring_tokens": []... |
05aee19dea92386a1b5585f0cece6f8677e1372e | thesamesam/gpyutils | gpyutils/packages.py | [
"BSD-2-Clause"
] | Python | find_redundant | null | def find_redundant(pkgs):
"""
Find redundant packages in the group, i.e. those that have newer
versions with a superset of keywords and implementations.
"""
max_keywords = {}
max_impls = set()
for p in reversed(pkgs):
redundant = True
# live ebuilds are never redundant
... |
Find redundant packages in the group, i.e. those that have newer
versions with a superset of keywords and implementations.
| Find redundant packages in the group, i.e. those that have newer
versions with a superset of keywords and implementations. | [
"Find",
"redundant",
"packages",
"in",
"the",
"group",
"i",
".",
"e",
".",
"those",
"that",
"have",
"newer",
"versions",
"with",
"a",
"superset",
"of",
"keywords",
"and",
"implementations",
"."
] | def find_redundant(pkgs):
max_keywords = {}
max_impls = set()
for p in reversed(pkgs):
redundant = True
if not p.keywords:
redundant = False
for k in p.keywords:
if k.startswith('~'):
v = 1
k = k[1:]
else:
... | [
"def",
"find_redundant",
"(",
"pkgs",
")",
":",
"max_keywords",
"=",
"{",
"}",
"max_impls",
"=",
"set",
"(",
")",
"for",
"p",
"in",
"reversed",
"(",
"pkgs",
")",
":",
"redundant",
"=",
"True",
"if",
"not",
"p",
".",
"keywords",
":",
"redundant",
"=",... | Find redundant packages in the group, i.e. | [
"Find",
"redundant",
"packages",
"in",
"the",
"group",
"i",
".",
"e",
"."
] | [
"\"\"\"\n Find redundant packages in the group, i.e. those that have newer\n versions with a superset of keywords and implementations.\n \"\"\"",
"# live ebuilds are never redundant",
"# first, determine non-redundancy via keywords",
"# stable",
"# then determine non-redundancy via impls"
] | [
{
"param": "pkgs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pkgs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6ea8b59d06ab1432ae262cfd8e38102fa8f9cd07 | thesamesam/gpyutils | gpyutils/eclasses.py | [
"BSD-2-Clause"
] | Python | has_python_in_deptree | <not_specific> | def has_python_in_deptree(dep):
""" Check whether dev-lang/python is in dependency tree. """
for d in dep:
if isinstance(d, PMAtom):
if d.key == 'dev-lang/python':
return True
else:
if has_python_in_deptree(d):
return True
return Fals... | Check whether dev-lang/python is in dependency tree. | Check whether dev-lang/python is in dependency tree. | [
"Check",
"whether",
"dev",
"-",
"lang",
"/",
"python",
"is",
"in",
"dependency",
"tree",
"."
] | def has_python_in_deptree(dep):
for d in dep:
if isinstance(d, PMAtom):
if d.key == 'dev-lang/python':
return True
else:
if has_python_in_deptree(d):
return True
return False | [
"def",
"has_python_in_deptree",
"(",
"dep",
")",
":",
"for",
"d",
"in",
"dep",
":",
"if",
"isinstance",
"(",
"d",
",",
"PMAtom",
")",
":",
"if",
"d",
".",
"key",
"==",
"'dev-lang/python'",
":",
"return",
"True",
"else",
":",
"if",
"has_python_in_deptree"... | Check whether dev-lang/python is in dependency tree. | [
"Check",
"whether",
"dev",
"-",
"lang",
"/",
"python",
"is",
"in",
"dependency",
"tree",
"."
] | [
"\"\"\" Check whether dev-lang/python is in dependency tree. \"\"\""
] | [
{
"param": "dep",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dep",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c784da951a64a35d9f14008d8311525ba0713653 | mugifly/homeassistant-leafeemag | custom_components/leafeemag/binary_sensor.py | [
"MIT"
] | Python | device_state_attributes | dict | def device_state_attributes(self) -> dict:
"""Return the attributes of this sensor."""
return {
"mac_address": self._mac_address,
"battery_level": self._battery_level
} | Return the attributes of this sensor. | Return the attributes of this sensor. | [
"Return",
"the",
"attributes",
"of",
"this",
"sensor",
"."
] | def device_state_attributes(self) -> dict:
return {
"mac_address": self._mac_address,
"battery_level": self._battery_level
} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"\"mac_address\"",
":",
"self",
".",
"_mac_address",
",",
"\"battery_level\"",
":",
"self",
".",
"_battery_level",
"}"
] | Return the attributes of this sensor. | [
"Return",
"the",
"attributes",
"of",
"this",
"sensor",
"."
] | [
"\"\"\"Return the attributes of this sensor.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c784da951a64a35d9f14008d8311525ba0713653 | mugifly/homeassistant-leafeemag | custom_components/leafeemag/binary_sensor.py | [
"MIT"
] | Python | update | None | def update(self) -> None:
"""Not update the state in here, because the state will be updated by notification from the Mag."""
if self._mag_device == None and self._last_connected_at == 0:
# This device has not made a first connection yet
return
if self._mag_device == No... | Not update the state in here, because the state will be updated by notification from the Mag. | Not update the state in here, because the state will be updated by notification from the Mag. | [
"Not",
"update",
"the",
"state",
"in",
"here",
"because",
"the",
"state",
"will",
"be",
"updated",
"by",
"notification",
"from",
"the",
"Mag",
"."
] | def update(self) -> None:
if self._mag_device == None and self._last_connected_at == 0:
return
if self._mag_device == None and CONNECT_ERROR_RETRY_INTERVAL_SEC < (time.time() - self._last_connected_at):
self._connect_and_subscribe()
elif self._mag_device != None and PERIO... | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_mag_device",
"==",
"None",
"and",
"self",
".",
"_last_connected_at",
"==",
"0",
":",
"return",
"if",
"self",
".",
"_mag_device",
"==",
"None",
"and",
"CONNECT_ERROR_RETRY_INTERVAL_SEC... | Not update the state in here, because the state will be updated by notification from the Mag. | [
"Not",
"update",
"the",
"state",
"in",
"here",
"because",
"the",
"state",
"will",
"be",
"updated",
"by",
"notification",
"from",
"the",
"Mag",
"."
] | [
"\"\"\"Not update the state in here, because the state will be updated by notification from the Mag.\"\"\"",
"# This device has not made a first connection yet",
"# First or Retry connection",
"# Periodic Reconnect after long time has passed (to keep reliability of connection)"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c784da951a64a35d9f14008d8311525ba0713653 | mugifly/homeassistant-leafeemag | custom_components/leafeemag/binary_sensor.py | [
"MIT"
] | Python | _connect_and_subscribe | bool | def _connect_and_subscribe(self) -> bool:
"""Connect to Mag and Subscribe the notification service."""
# Update time
self._last_connected_at = time.time()
# Disconnect from device if necessary
self._disconnect();
# Initialize BLE adapter
_LOGGER.debug('Initiali... | Connect to Mag and Subscribe the notification service. | Connect to Mag and Subscribe the notification service. | [
"Connect",
"to",
"Mag",
"and",
"Subscribe",
"the",
"notification",
"service",
"."
] | def _connect_and_subscribe(self) -> bool:
self._last_connected_at = time.time()
self._disconnect();
_LOGGER.debug('Initializing BLE adapter...')
try:
self._ble_adapter.start(False)
except Exception as error:
_LOGGER.debug('Error occurred during initializin... | [
"def",
"_connect_and_subscribe",
"(",
"self",
")",
"->",
"bool",
":",
"self",
".",
"_last_connected_at",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"_disconnect",
"(",
")",
";",
"_LOGGER",
".",
"debug",
"(",
"'Initializing BLE adapter...'",
")",
"try",... | Connect to Mag and Subscribe the notification service. | [
"Connect",
"to",
"Mag",
"and",
"Subscribe",
"the",
"notification",
"service",
"."
] | [
"\"\"\"Connect to Mag and Subscribe the notification service.\"\"\"",
"# Update time",
"# Disconnect from device if necessary",
"# Initialize BLE adapter",
"# Connect to device",
"# Get latest state",
"# Get battery level",
"# Subscribe to notifications for state changes",
"# Done"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c784da951a64a35d9f14008d8311525ba0713653 | mugifly/homeassistant-leafeemag | custom_components/leafeemag/binary_sensor.py | [
"MIT"
] | Python | _set_state_by_received_bytearray | None | def _set_state_by_received_bytearray (self, received_bytearray) -> None:
"""Set state of this sensor by received sensor value."""
is_open = None;
if received_bytearray.decode() == '\x00': # Opened
is_open = True
else: # Closed
is_open = False
_LOGGER.deb... | Set state of this sensor by received sensor value. | Set state of this sensor by received sensor value. | [
"Set",
"state",
"of",
"this",
"sensor",
"by",
"received",
"sensor",
"value",
"."
] | def _set_state_by_received_bytearray (self, received_bytearray) -> None:
is_open = None;
if received_bytearray.decode() == '\x00':
is_open = True
else:
is_open = False
_LOGGER.debug('State of Mag %s has been changed to %s', self._name, is_open)
self._sta... | [
"def",
"_set_state_by_received_bytearray",
"(",
"self",
",",
"received_bytearray",
")",
"->",
"None",
":",
"is_open",
"=",
"None",
";",
"if",
"received_bytearray",
".",
"decode",
"(",
")",
"==",
"'\\x00'",
":",
"is_open",
"=",
"True",
"else",
":",
"is_open",
... | Set state of this sensor by received sensor value. | [
"Set",
"state",
"of",
"this",
"sensor",
"by",
"received",
"sensor",
"value",
"."
] | [
"\"\"\"Set state of this sensor by received sensor value.\"\"\"",
"# Opened",
"# Closed",
"# Set state",
"# Update time"
] | [
{
"param": "self",
"type": null
},
{
"param": "received_bytearray",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "received_bytearray",
"type": null,
"docstring": null,
"docstr... |
ab23022d3b271ef35852d123c608bccba1106a72 | pFernbach/crocoddyl | unittest/python/crocoddyl/action.py | [
"BSD-3-Clause"
] | Python | createData | <not_specific> | def createData(self):
""" Create the action data.
Each action model (AM) has its own data that needs to be allocated.
This function returns the allocated data for a predefined AM. Note that
you need to defined the ActionDataType inside your AM.
:return AM data.
"""
... | Create the action data.
Each action model (AM) has its own data that needs to be allocated.
This function returns the allocated data for a predefined AM. Note that
you need to defined the ActionDataType inside your AM.
:return AM data.
| Create the action data.
Each action model (AM) has its own data that needs to be allocated.
This function returns the allocated data for a predefined AM. Note that
you need to defined the ActionDataType inside your AM.
:return AM data. | [
"Create",
"the",
"action",
"data",
".",
"Each",
"action",
"model",
"(",
"AM",
")",
"has",
"its",
"own",
"data",
"that",
"needs",
"to",
"be",
"allocated",
".",
"This",
"function",
"returns",
"the",
"allocated",
"data",
"for",
"a",
"predefined",
"AM",
".",... | def createData(self):
return self.ActionDataType(self) | [
"def",
"createData",
"(",
"self",
")",
":",
"return",
"self",
".",
"ActionDataType",
"(",
"self",
")"
] | Create the action data. | [
"Create",
"the",
"action",
"data",
"."
] | [
"\"\"\" Create the action data.\n\n Each action model (AM) has its own data that needs to be allocated.\n This function returns the allocated data for a predefined AM. Note that\n you need to defined the ActionDataType inside your AM.\n :return AM data.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ab23022d3b271ef35852d123c608bccba1106a72 | pFernbach/crocoddyl | unittest/python/crocoddyl/action.py | [
"BSD-3-Clause"
] | Python | calcDiff | null | def calcDiff(model, data, x, u=None, recalc=True):
""" Compute the derivatives of the dynamics and cost functions.
It computes the partial derivatives of the dynamical system and the
cost function. If recalc == True, it first updates the state evolution
and cost value. This function bui... | Compute the derivatives of the dynamics and cost functions.
It computes the partial derivatives of the dynamical system and the
cost function. If recalc == True, it first updates the state evolution
and cost value. This function builds a quadratic approximation of the
action model (i.e... | Compute the derivatives of the dynamics and cost functions.
It computes the partial derivatives of the dynamical system and the
cost function. If recalc == True, it first updates the state evolution
and cost value. This function builds a quadratic approximation of the
action model . | [
"Compute",
"the",
"derivatives",
"of",
"the",
"dynamics",
"and",
"cost",
"functions",
".",
"It",
"computes",
"the",
"partial",
"derivatives",
"of",
"the",
"dynamical",
"system",
"and",
"the",
"cost",
"function",
".",
"If",
"recalc",
"==",
"True",
"it",
"firs... | def calcDiff(model, data, x, u=None, recalc=True):
raise NotImplementedError("Not implemented yet.") | [
"def",
"calcDiff",
"(",
"model",
",",
"data",
",",
"x",
",",
"u",
"=",
"None",
",",
"recalc",
"=",
"True",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Not implemented yet.\"",
")"
] | Compute the derivatives of the dynamics and cost functions. | [
"Compute",
"the",
"derivatives",
"of",
"the",
"dynamics",
"and",
"cost",
"functions",
"."
] | [
"\"\"\" Compute the derivatives of the dynamics and cost functions.\n\n It computes the partial derivatives of the dynamical system and the\n cost function. If recalc == True, it first updates the state evolution\n and cost value. This function builds a quadratic approximation of the\n a... | [
{
"param": "model",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "u",
"type": null
},
{
"param": "recalc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": ... |
ab23022d3b271ef35852d123c608bccba1106a72 | pFernbach/crocoddyl | unittest/python/crocoddyl/action.py | [
"BSD-3-Clause"
] | Python | calc | <not_specific> | def calc(model, data, x, u=None):
""" Update the next state and the cost function.
:param model: action model
:params data: action data
:params x: time-discrete state vector
:params u: time-discrete control vector
:returns the next state and cost value
"""
... | Update the next state and the cost function.
:param model: action model
:params data: action data
:params x: time-discrete state vector
:params u: time-discrete control vector
:returns the next state and cost value
| Update the next state and the cost function. | [
"Update",
"the",
"next",
"state",
"and",
"the",
"cost",
"function",
"."
] | def calc(model, data, x, u=None):
if u is None:
u = model.unone
data.xnext[:] = np.dot(model.Fx, x) + np.dot(model.Fu, u) + model.f0
data.cost = 0.5 * np.dot(x, np.dot(model.Lxx, x)) + 0.5 * np.dot(u, np.dot(model.Luu, u))
data.cost += np.dot(x, np.dot(model.Lxu, u)) + np.dot... | [
"def",
"calc",
"(",
"model",
",",
"data",
",",
"x",
",",
"u",
"=",
"None",
")",
":",
"if",
"u",
"is",
"None",
":",
"u",
"=",
"model",
".",
"unone",
"data",
".",
"xnext",
"[",
":",
"]",
"=",
"np",
".",
"dot",
"(",
"model",
".",
"Fx",
",",
... | Update the next state and the cost function. | [
"Update",
"the",
"next",
"state",
"and",
"the",
"cost",
"function",
"."
] | [
"\"\"\" Update the next state and the cost function.\n\n :param model: action model\n :params data: action data\n :params x: time-discrete state vector\n :params u: time-discrete control vector\n :returns the next state and cost value\n \"\"\""
] | [
{
"param": "model",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "u",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": ... |
ab23022d3b271ef35852d123c608bccba1106a72 | pFernbach/crocoddyl | unittest/python/crocoddyl/action.py | [
"BSD-3-Clause"
] | Python | calcDiff | <not_specific> | def calcDiff(model, data, x, u=None, recalc=True):
""" Update the derivatives of the dynamics and cost.
:param model: action model
:params data: action data
:params x: time-discrete state vector
:params u: time-discrete control vector
:returns the next state and cost val... | Update the derivatives of the dynamics and cost.
:param model: action model
:params data: action data
:params x: time-discrete state vector
:params u: time-discrete control vector
:returns the next state and cost value
| Update the derivatives of the dynamics and cost. | [
"Update",
"the",
"derivatives",
"of",
"the",
"dynamics",
"and",
"cost",
"."
] | def calcDiff(model, data, x, u=None, recalc=True):
if u is None:
u = model.unone
if recalc:
xnext, cost = model.calc(data, x, u)
data.Lx[:] = model.lx + np.dot(model.Lxx, x) + np.dot(model.Lxu, u)
data.Lu[:] = model.lu + np.dot(model.Lxu.T, x) + np.dot(model.Luu, ... | [
"def",
"calcDiff",
"(",
"model",
",",
"data",
",",
"x",
",",
"u",
"=",
"None",
",",
"recalc",
"=",
"True",
")",
":",
"if",
"u",
"is",
"None",
":",
"u",
"=",
"model",
".",
"unone",
"if",
"recalc",
":",
"xnext",
",",
"cost",
"=",
"model",
".",
... | Update the derivatives of the dynamics and cost. | [
"Update",
"the",
"derivatives",
"of",
"the",
"dynamics",
"and",
"cost",
"."
] | [
"\"\"\" Update the derivatives of the dynamics and cost.\n\n :param model: action model\n :params data: action data\n :params x: time-discrete state vector\n :params u: time-discrete control vector\n :returns the next state and cost value\n \"\"\""
] | [
{
"param": "model",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "u",
"type": null
},
{
"param": "recalc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": ... |
ab23022d3b271ef35852d123c608bccba1106a72 | pFernbach/crocoddyl | unittest/python/crocoddyl/action.py | [
"BSD-3-Clause"
] | Python | _assertStableStateFD | null | def _assertStableStateFD(model, x):
""" Make sure that when we finite difference the Action Model, the user does
not face unknown behaviour because of the finite differencing of a quaternion around pi.
This behaviour might occur if CostModelState and FloatingInContact differential model are used... | Make sure that when we finite difference the Action Model, the user does
not face unknown behaviour because of the finite differencing of a quaternion around pi.
This behaviour might occur if CostModelState and FloatingInContact differential model are used
together.
For full discussion... | Make sure that when we finite difference the Action Model, the user does
not face unknown behaviour because of the finite differencing of a quaternion around pi.
This behaviour might occur if CostModelState and FloatingInContact differential model are used
together.
| [
"Make",
"sure",
"that",
"when",
"we",
"finite",
"difference",
"the",
"Action",
"Model",
"the",
"user",
"does",
"not",
"face",
"unknown",
"behaviour",
"because",
"of",
"the",
"finite",
"differencing",
"of",
"a",
"quaternion",
"around",
"pi",
".",
"This",
"beh... | def _assertStableStateFD(model, x):
if hasattr(model.model0, "differential"):
md = model.model0.differential
if isinstance(md, DifferentialActionModelFloatingInContact):
if hasattr(md, "costs"):
mc = md.costs
if isinstance(mc, CostM... | [
"def",
"_assertStableStateFD",
"(",
"model",
",",
"x",
")",
":",
"if",
"hasattr",
"(",
"model",
".",
"model0",
",",
"\"differential\"",
")",
":",
"md",
"=",
"model",
".",
"model0",
".",
"differential",
"if",
"isinstance",
"(",
"md",
",",
"DifferentialActio... | Make sure that when we finite difference the Action Model, the user does
not face unknown behaviour because of the finite differencing of a quaternion around pi. | [
"Make",
"sure",
"that",
"when",
"we",
"finite",
"difference",
"the",
"Action",
"Model",
"the",
"user",
"does",
"not",
"face",
"unknown",
"behaviour",
"because",
"of",
"the",
"finite",
"differencing",
"of",
"a",
"quaternion",
"around",
"pi",
"."
] | [
"\"\"\" Make sure that when we finite difference the Action Model, the user does\n not face unknown behaviour because of the finite differencing of a quaternion around pi.\n This behaviour might occur if CostModelState and FloatingInContact differential model are used\n together.\n\n For... | [
{
"param": "model",
"type": null
},
{
"param": "x",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
80891b63c0970417b87d7b5cd2226c1ce8ee62b6 | pFernbach/crocoddyl | unittest/python/crocoddyl/activation.py | [
"BSD-3-Clause"
] | Python | calc | null | def calc(model, data, r):
""" Compute and return the activation value.
:param model: activation model
:param data: activation data
:param r: residual vector
:return the activation value
"""
raise NotImplementedError("Not implemented yet.") | Compute and return the activation value.
:param model: activation model
:param data: activation data
:param r: residual vector
:return the activation value
| Compute and return the activation value. | [
"Compute",
"and",
"return",
"the",
"activation",
"value",
"."
] | def calc(model, data, r):
raise NotImplementedError("Not implemented yet.") | [
"def",
"calc",
"(",
"model",
",",
"data",
",",
"r",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Not implemented yet.\"",
")"
] | Compute and return the activation value. | [
"Compute",
"and",
"return",
"the",
"activation",
"value",
"."
] | [
"\"\"\" Compute and return the activation value.\n\n :param model: activation model\n :param data: activation data\n :param r: residual vector\n :return the activation value\n \"\"\""
] | [
{
"param": "model",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "r",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": ... |
2a25bde0067d5ad089499628996a93cffd7ad8a4 | pFernbach/crocoddyl | unittest/python/test_armature.py | [
"BSD-3-Clause"
] | Python | runningModel | <not_specific> | def runningModel(contactIds, effectors, com=None, integrationStep=1e-2):
'''
Creating the action model for floating-base systems. A walker system
is by default a floating-base system.
contactIds is a list of frame Ids of points that should be in contact.
effectors is a dict of key frame ids and SE3 ... |
Creating the action model for floating-base systems. A walker system
is by default a floating-base system.
contactIds is a list of frame Ids of points that should be in contact.
effectors is a dict of key frame ids and SE3 values of effector references.
| Creating the action model for floating-base systems. A walker system
is by default a floating-base system.
contactIds is a list of frame Ids of points that should be in contact.
effectors is a dict of key frame ids and SE3 values of effector references. | [
"Creating",
"the",
"action",
"model",
"for",
"floating",
"-",
"base",
"systems",
".",
"A",
"walker",
"system",
"is",
"by",
"default",
"a",
"floating",
"-",
"base",
"system",
".",
"contactIds",
"is",
"a",
"list",
"of",
"frame",
"Ids",
"of",
"points",
"tha... | def runningModel(contactIds, effectors, com=None, integrationStep=1e-2):
actModel = ActuationModelFreeFloating(rmodel)
State = StatePinocchio(rmodel)
contactModel = ContactModelMultiple(rmodel)
for cid in contactIds:
contactModel.addContact('contact%d' % cid, ContactModel6D(rmodel, cid, ref=None... | [
"def",
"runningModel",
"(",
"contactIds",
",",
"effectors",
",",
"com",
"=",
"None",
",",
"integrationStep",
"=",
"1e-2",
")",
":",
"actModel",
"=",
"ActuationModelFreeFloating",
"(",
"rmodel",
")",
"State",
"=",
"StatePinocchio",
"(",
"rmodel",
")",
"contactM... | Creating the action model for floating-base systems. | [
"Creating",
"the",
"action",
"model",
"for",
"floating",
"-",
"base",
"systems",
"."
] | [
"'''\n Creating the action model for floating-base systems. A walker system\n is by default a floating-base system.\n contactIds is a list of frame Ids of points that should be in contact.\n effectors is a dict of key frame ids and SE3 values of effector references.\n '''",
"# Creating a 6D multi-c... | [
{
"param": "contactIds",
"type": null
},
{
"param": "effectors",
"type": null
},
{
"param": "com",
"type": null
},
{
"param": "integrationStep",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "contactIds",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "effectors",
"type": null,
"docstring": null,
"docstring... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | diff | null | def diff(self, x1, x2):
r""" Operator that differentiates the two state points.
It returns the value of x1 [-] x2 operation. Note tha x1 and x2 are
points in the state manifold (\in M). Instead the operator result lies
in the tangent-space of M.
:param x1: current state
... | r""" Operator that differentiates the two state points.
It returns the value of x1 [-] x2 operation. Note tha x1 and x2 are
points in the state manifold (\in M). Instead the operator result lies
in the tangent-space of M.
:param x1: current state
:param x2: next state
:r... | r""" Operator that differentiates the two state points.
It returns the value of x1 [-] x2 operation. Note tha x1 and x2 are
points in the state manifold (\in M). Instead the operator result lies
in the tangent-space of M. | [
"r",
"\"",
"\"",
"\"",
"Operator",
"that",
"differentiates",
"the",
"two",
"state",
"points",
".",
"It",
"returns",
"the",
"value",
"of",
"x1",
"[",
"-",
"]",
"x2",
"operation",
".",
"Note",
"tha",
"x1",
"and",
"x2",
"are",
"points",
"in",
"the",
"st... | def diff(self, x1, x2):
raise NotImplementedError("Not implemented yet.") | [
"def",
"diff",
"(",
"self",
",",
"x1",
",",
"x2",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Not implemented yet.\"",
")"
] | r""" Operator that differentiates the two state points. | [
"r",
"\"",
"\"",
"\"",
"Operator",
"that",
"differentiates",
"the",
"two",
"state",
"points",
"."
] | [
"r\"\"\" Operator that differentiates the two state points.\n\n It returns the value of x1 [-] x2 operation. Note tha x1 and x2 are\n points in the state manifold (\\in M). Instead the operator result lies\n in the tangent-space of M.\n :param x1: current state\n :param x2: next s... | [
{
"param": "self",
"type": null
},
{
"param": "x1",
"type": null
},
{
"param": "x2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | integrate | null | def integrate(self, x, dx):
r""" Operator that integrates the current state.
It returns the value of x [+] dx operation. Note tha x and dx are
points in the state manifold (\in M) and its tangent, respectively.
Note that the operator result lies on M too.
:param x: current state... | r""" Operator that integrates the current state.
It returns the value of x [+] dx operation. Note tha x and dx are
points in the state manifold (\in M) and its tangent, respectively.
Note that the operator result lies on M too.
:param x: current state
:param dx: displacement of ... | r""" Operator that integrates the current state.
It returns the value of x [+] dx operation. Note tha x and dx are
points in the state manifold (\in M) and its tangent, respectively.
Note that the operator result lies on M too. | [
"r",
"\"",
"\"",
"\"",
"Operator",
"that",
"integrates",
"the",
"current",
"state",
".",
"It",
"returns",
"the",
"value",
"of",
"x",
"[",
"+",
"]",
"dx",
"operation",
".",
"Note",
"tha",
"x",
"and",
"dx",
"are",
"points",
"in",
"the",
"state",
"manif... | def integrate(self, x, dx):
raise NotImplementedError("Not implemented yet.") | [
"def",
"integrate",
"(",
"self",
",",
"x",
",",
"dx",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Not implemented yet.\"",
")"
] | r""" Operator that integrates the current state. | [
"r",
"\"",
"\"",
"\"",
"Operator",
"that",
"integrates",
"the",
"current",
"state",
"."
] | [
"r\"\"\" Operator that integrates the current state.\n\n It returns the value of x [+] dx operation. Note tha x and dx are\n points in the state manifold (\\in M) and its tangent, respectively.\n Note that the operator result lies on M too.\n :param x: current state\n :param dx: d... | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "dx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | diff | <not_specific> | def diff(self, x1, x2):
""" Difference between x2 and x1.
:param x1: current state
:param x2: next state
:return x2 - x1 value
"""
return x2 - x1 | Difference between x2 and x1.
:param x1: current state
:param x2: next state
:return x2 - x1 value
| Difference between x2 and x1. | [
"Difference",
"between",
"x2",
"and",
"x1",
"."
] | def diff(self, x1, x2):
return x2 - x1 | [
"def",
"diff",
"(",
"self",
",",
"x1",
",",
"x2",
")",
":",
"return",
"x2",
"-",
"x1"
] | Difference between x2 and x1. | [
"Difference",
"between",
"x2",
"and",
"x1",
"."
] | [
"\"\"\" Difference between x2 and x1.\n\n :param x1: current state\n :param x2: next state\n :return x2 - x1 value\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x1",
"type": null
},
{
"param": "x2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | integrate | <not_specific> | def integrate(self, x1, dx):
""" Integration of x + dx.
Note that there is no timestep here. Set dx = v dt if you're integrating
a velocity v during an interval dt.
:param x: current state
:param dx: displacement of the state
:return x [+] dx value
"""
re... | Integration of x + dx.
Note that there is no timestep here. Set dx = v dt if you're integrating
a velocity v during an interval dt.
:param x: current state
:param dx: displacement of the state
:return x [+] dx value
| Integration of x + dx.
Note that there is no timestep here. Set dx = v dt if you're integrating
a velocity v during an interval dt. | [
"Integration",
"of",
"x",
"+",
"dx",
".",
"Note",
"that",
"there",
"is",
"no",
"timestep",
"here",
".",
"Set",
"dx",
"=",
"v",
"dt",
"if",
"you",
"'",
"re",
"integrating",
"a",
"velocity",
"v",
"during",
"an",
"interval",
"dt",
"."
] | def integrate(self, x1, dx):
return x1 + dx | [
"def",
"integrate",
"(",
"self",
",",
"x1",
",",
"dx",
")",
":",
"return",
"x1",
"+",
"dx"
] | Integration of x + dx. | [
"Integration",
"of",
"x",
"+",
"dx",
"."
] | [
"\"\"\" Integration of x + dx.\n\n Note that there is no timestep here. Set dx = v dt if you're integrating\n a velocity v during an interval dt.\n :param x: current state\n :param dx: displacement of the state\n :return x [+] dx value\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x1",
"type": null
},
{
"param": "dx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | Jdiff | <not_specific> | def Jdiff(self, x1, x2, firstsecond='both'):
""" Jacobians for the x2 - x1.
:param x1: current state
:param x2: next state
:param firstsecond: desired partial derivative
:return the partial derivative(s) of the diff(x1,x2) function
"""
assert (firstsecond in ['fi... | Jacobians for the x2 - x1.
:param x1: current state
:param x2: next state
:param firstsecond: desired partial derivative
:return the partial derivative(s) of the diff(x1,x2) function
| Jacobians for the x2 - x1. | [
"Jacobians",
"for",
"the",
"x2",
"-",
"x1",
"."
] | def Jdiff(self, x1, x2, firstsecond='both'):
assert (firstsecond in ['first', 'second', 'both'])
if firstsecond == 'both':
return [self.Jdiff(x1, x2, 'first'), self.Jdiff(x1, x2, 'second')]
J = np.zeros([self.ndx, self.ndx])
if firstsecond == 'first':
J[:, :] = -n... | [
"def",
"Jdiff",
"(",
"self",
",",
"x1",
",",
"x2",
",",
"firstsecond",
"=",
"'both'",
")",
":",
"assert",
"(",
"firstsecond",
"in",
"[",
"'first'",
",",
"'second'",
",",
"'both'",
"]",
")",
"if",
"firstsecond",
"==",
"'both'",
":",
"return",
"[",
"se... | Jacobians for the x2 - x1. | [
"Jacobians",
"for",
"the",
"x2",
"-",
"x1",
"."
] | [
"\"\"\" Jacobians for the x2 - x1.\n\n :param x1: current state\n :param x2: next state\n :param firstsecond: desired partial derivative\n :return the partial derivative(s) of the diff(x1,x2) function\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x1",
"type": null
},
{
"param": "x2",
"type": null
},
{
"param": "firstsecond",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | diff | <not_specific> | def diff(self, x1, x2):
""" Run the differentiate operator defined in State.
:param x1: current state
:param x2: next state
:return x2 [-] x1 value
"""
return self.State.diff(x1, x2) | Run the differentiate operator defined in State.
:param x1: current state
:param x2: next state
:return x2 [-] x1 value
| Run the differentiate operator defined in State. | [
"Run",
"the",
"differentiate",
"operator",
"defined",
"in",
"State",
"."
] | def diff(self, x1, x2):
return self.State.diff(x1, x2) | [
"def",
"diff",
"(",
"self",
",",
"x1",
",",
"x2",
")",
":",
"return",
"self",
".",
"State",
".",
"diff",
"(",
"x1",
",",
"x2",
")"
] | Run the differentiate operator defined in State. | [
"Run",
"the",
"differentiate",
"operator",
"defined",
"in",
"State",
"."
] | [
"\"\"\" Run the differentiate operator defined in State.\n\n :param x1: current state\n :param x2: next state\n :return x2 [-] x1 value\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x1",
"type": null
},
{
"param": "x2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | integrate | <not_specific> | def integrate(self, x, dx):
""" Run the integrate operator defined in State.
:param x: current state
:param dx: displacement of the state
:return x [+] dx value
"""
return self.State.integrate(x, dx) | Run the integrate operator defined in State.
:param x: current state
:param dx: displacement of the state
:return x [+] dx value
| Run the integrate operator defined in State. | [
"Run",
"the",
"integrate",
"operator",
"defined",
"in",
"State",
"."
] | def integrate(self, x, dx):
return self.State.integrate(x, dx) | [
"def",
"integrate",
"(",
"self",
",",
"x",
",",
"dx",
")",
":",
"return",
"self",
".",
"State",
".",
"integrate",
"(",
"x",
",",
"dx",
")"
] | Run the integrate operator defined in State. | [
"Run",
"the",
"integrate",
"operator",
"defined",
"in",
"State",
"."
] | [
"\"\"\" Run the integrate operator defined in State.\n\n :param x: current state\n :param dx: displacement of the state\n :return x [+] dx value\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "dx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | Jdiff | <not_specific> | def Jdiff(self, x1, x2, firstsecond='both'):
""" Compute the partial derivatives for diff operator using NumDiff.
:param x1: current state
:param x2: next state
:param firstsecond: desired partial derivative
:return the partial derivative(s) of the diff(x1,x2) function
"... | Compute the partial derivatives for diff operator using NumDiff.
:param x1: current state
:param x2: next state
:param firstsecond: desired partial derivative
:return the partial derivative(s) of the diff(x1,x2) function
| Compute the partial derivatives for diff operator using NumDiff. | [
"Compute",
"the",
"partial",
"derivatives",
"for",
"diff",
"operator",
"using",
"NumDiff",
"."
] | def Jdiff(self, x1, x2, firstsecond='both'):
assert (firstsecond in ['first', 'second', 'both'])
if firstsecond == 'both':
return [self.Jdiff(x1, x2, 'first'), self.Jdiff(x1, x2, 'second')]
dx = np.zeros(self.ndx)
h = self.disturbance
J = np.zeros([self.ndx, self.ndx]... | [
"def",
"Jdiff",
"(",
"self",
",",
"x1",
",",
"x2",
",",
"firstsecond",
"=",
"'both'",
")",
":",
"assert",
"(",
"firstsecond",
"in",
"[",
"'first'",
",",
"'second'",
",",
"'both'",
"]",
")",
"if",
"firstsecond",
"==",
"'both'",
":",
"return",
"[",
"se... | Compute the partial derivatives for diff operator using NumDiff. | [
"Compute",
"the",
"partial",
"derivatives",
"for",
"diff",
"operator",
"using",
"NumDiff",
"."
] | [
"\"\"\" Compute the partial derivatives for diff operator using NumDiff.\n\n :param x1: current state\n :param x2: next state\n :param firstsecond: desired partial derivative\n :return the partial derivative(s) of the diff(x1,x2) function\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x1",
"type": null
},
{
"param": "x2",
"type": null
},
{
"param": "firstsecond",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | Jintegrate | <not_specific> | def Jintegrate(self, x, dx, firstsecond='both'):
""" Compute the partial derivatives for integrate operator using NumDiff.
:param x: current state
:param dx: displacement of the state
:param firstsecond: desired partial derivative
:return the partial derivative(s) of the integra... | Compute the partial derivatives for integrate operator using NumDiff.
:param x: current state
:param dx: displacement of the state
:param firstsecond: desired partial derivative
:return the partial derivative(s) of the integrate(x,dx) function
| Compute the partial derivatives for integrate operator using NumDiff. | [
"Compute",
"the",
"partial",
"derivatives",
"for",
"integrate",
"operator",
"using",
"NumDiff",
"."
] | def Jintegrate(self, x, dx, firstsecond='both'):
assert (firstsecond in ['first', 'second', 'both'])
if firstsecond == 'both':
return [self.Jintegrate(x, dx, 'first'), self.Jintegrate(x, dx, 'second')]
Dx = np.zeros(self.ndx)
h = self.disturbance
J = np.zeros([self.nd... | [
"def",
"Jintegrate",
"(",
"self",
",",
"x",
",",
"dx",
",",
"firstsecond",
"=",
"'both'",
")",
":",
"assert",
"(",
"firstsecond",
"in",
"[",
"'first'",
",",
"'second'",
",",
"'both'",
"]",
")",
"if",
"firstsecond",
"==",
"'both'",
":",
"return",
"[",
... | Compute the partial derivatives for integrate operator using NumDiff. | [
"Compute",
"the",
"partial",
"derivatives",
"for",
"integrate",
"operator",
"using",
"NumDiff",
"."
] | [
"\"\"\" Compute the partial derivatives for integrate operator using NumDiff.\n\n :param x: current state\n :param dx: displacement of the state\n :param firstsecond: desired partial derivative\n :return the partial derivative(s) of the integrate(x,dx) function\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "dx",
"type": null
},
{
"param": "firstsecond",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | zero | <not_specific> | def zero(self):
""" Return the neutral robot configuration with zero velocity.
"""
q = pinocchio.neutral(self.model)
v = np.zeros(self.model.nv)
return np.concatenate([q.flat, v]) | Return the neutral robot configuration with zero velocity.
| Return the neutral robot configuration with zero velocity. | [
"Return",
"the",
"neutral",
"robot",
"configuration",
"with",
"zero",
"velocity",
"."
] | def zero(self):
q = pinocchio.neutral(self.model)
v = np.zeros(self.model.nv)
return np.concatenate([q.flat, v]) | [
"def",
"zero",
"(",
"self",
")",
":",
"q",
"=",
"pinocchio",
".",
"neutral",
"(",
"self",
".",
"model",
")",
"v",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"model",
".",
"nv",
")",
"return",
"np",
".",
"concatenate",
"(",
"[",
"q",
".",
"flat"... | Return the neutral robot configuration with zero velocity. | [
"Return",
"the",
"neutral",
"robot",
"configuration",
"with",
"zero",
"velocity",
"."
] | [
"\"\"\" Return the neutral robot configuration with zero velocity.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | diff | <not_specific> | def diff(self, x0, x1):
""" Difference between the robot's states x2 and x1.
:param x1: current state
:param x2: next state
:return x2 [-] x1 value
"""
nq, nv, nx = self.model.nq, self.model.nv, self.nx
assert (x0.shape == (nx, ) and x1.shape == (nx, ))
q... | Difference between the robot's states x2 and x1.
:param x1: current state
:param x2: next state
:return x2 [-] x1 value
| Difference between the robot's states x2 and x1. | [
"Difference",
"between",
"the",
"robot",
"'",
"s",
"states",
"x2",
"and",
"x1",
"."
] | def diff(self, x0, x1):
nq, nv, nx = self.model.nq, self.model.nv, self.nx
assert (x0.shape == (nx, ) and x1.shape == (nx, ))
q0 = x0[:nq]
q1 = x1[:nq]
v0 = x0[-nv:]
v1 = x1[-nv:]
dq = pinocchio.difference(self.model, a2m(q0), a2m(q1))
return np.concatenat... | [
"def",
"diff",
"(",
"self",
",",
"x0",
",",
"x1",
")",
":",
"nq",
",",
"nv",
",",
"nx",
"=",
"self",
".",
"model",
".",
"nq",
",",
"self",
".",
"model",
".",
"nv",
",",
"self",
".",
"nx",
"assert",
"(",
"x0",
".",
"shape",
"==",
"(",
"nx",
... | Difference between the robot's states x2 and x1. | [
"Difference",
"between",
"the",
"robot",
"'",
"s",
"states",
"x2",
"and",
"x1",
"."
] | [
"\"\"\" Difference between the robot's states x2 and x1.\n\n :param x1: current state\n :param x2: next state\n :return x2 [-] x1 value\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x0",
"type": null
},
{
"param": "x1",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x0",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | integrate | <not_specific> | def integrate(self, x, dx):
""" Integrate the current robot's state.
:param x: current state
:param dx: displacement of the state
:return x [+] dx value
"""
nq, nv, nx, ndx = self.model.nq, self.model.nv, self.nx, self.ndx
assert (x.shape == (nx, ) and dx.shape =... | Integrate the current robot's state.
:param x: current state
:param dx: displacement of the state
:return x [+] dx value
| Integrate the current robot's state. | [
"Integrate",
"the",
"current",
"robot",
"'",
"s",
"state",
"."
] | def integrate(self, x, dx):
nq, nv, nx, ndx = self.model.nq, self.model.nv, self.nx, self.ndx
assert (x.shape == (nx, ) and dx.shape == (ndx, ))
q = x[:nq]
v = x[-nv:]
dq = dx[:nv]
dv = dx[-nv:]
qn = pinocchio.integrate(self.model, a2m(q), a2m(dq))
return ... | [
"def",
"integrate",
"(",
"self",
",",
"x",
",",
"dx",
")",
":",
"nq",
",",
"nv",
",",
"nx",
",",
"ndx",
"=",
"self",
".",
"model",
".",
"nq",
",",
"self",
".",
"model",
".",
"nv",
",",
"self",
".",
"nx",
",",
"self",
".",
"ndx",
"assert",
"... | Integrate the current robot's state. | [
"Integrate",
"the",
"current",
"robot",
"'",
"s",
"state",
"."
] | [
"\"\"\" Integrate the current robot's state.\n\n :param x: current state\n :param dx: displacement of the state\n :return x [+] dx value\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "dx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | Jdiff | <not_specific> | def Jdiff(self, x1, x2, firstsecond='both'):
""" Compute the partial derivatives for diff operator using Pinocchio.
:param x1: current state
:param x2: next state
:param firstsecond: desired partial derivative
:return the partial derivative(s) of the diff(x1,x2) function
... | Compute the partial derivatives for diff operator using Pinocchio.
:param x1: current state
:param x2: next state
:param firstsecond: desired partial derivative
:return the partial derivative(s) of the diff(x1,x2) function
| Compute the partial derivatives for diff operator using Pinocchio. | [
"Compute",
"the",
"partial",
"derivatives",
"for",
"diff",
"operator",
"using",
"Pinocchio",
"."
] | def Jdiff(self, x1, x2, firstsecond='both'):
assert (firstsecond in ['first', 'second', 'both'])
if firstsecond == 'both':
return [self.Jdiff(x1, x2, 'first'), self.Jdiff(x1, x2, 'second')]
if firstsecond == 'second':
dx = self.diff(x1, x2)
q = a2m(x1[:self.mo... | [
"def",
"Jdiff",
"(",
"self",
",",
"x1",
",",
"x2",
",",
"firstsecond",
"=",
"'both'",
")",
":",
"assert",
"(",
"firstsecond",
"in",
"[",
"'first'",
",",
"'second'",
",",
"'both'",
"]",
")",
"if",
"firstsecond",
"==",
"'both'",
":",
"return",
"[",
"se... | Compute the partial derivatives for diff operator using Pinocchio. | [
"Compute",
"the",
"partial",
"derivatives",
"for",
"diff",
"operator",
"using",
"Pinocchio",
"."
] | [
"\"\"\" Compute the partial derivatives for diff operator using Pinocchio.\n\n :param x1: current state\n :param x2: next state\n :param firstsecond: desired partial derivative\n :return the partial derivative(s) of the diff(x1,x2) function\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x1",
"type": null
},
{
"param": "x2",
"type": null
},
{
"param": "firstsecond",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
becf34c415de0c9bc321b16e1aca1f79bbf8cc6f | pFernbach/crocoddyl | unittest/python/crocoddyl/state.py | [
"BSD-3-Clause"
] | Python | Jintegrate | <not_specific> | def Jintegrate(self, x, dx, firstsecond='both'):
""" Compute the partial derivatives for integrate operator using Pinocchio.
:param x: current state
:param dx: displacement of the state
:param firstsecond: desired partial derivative
:return the partial derivative(s) of the integ... | Compute the partial derivatives for integrate operator using Pinocchio.
:param x: current state
:param dx: displacement of the state
:param firstsecond: desired partial derivative
:return the partial derivative(s) of the integrate(x,dx) function
| Compute the partial derivatives for integrate operator using Pinocchio. | [
"Compute",
"the",
"partial",
"derivatives",
"for",
"integrate",
"operator",
"using",
"Pinocchio",
"."
] | def Jintegrate(self, x, dx, firstsecond='both'):
assert (firstsecond in ['first', 'second', 'both'])
assert (x.shape == (self.nx, ) and dx.shape == (self.ndx, ))
if firstsecond == 'both':
return [self.Jintegrate(x, dx, 'first'), self.Jintegrate(x, dx, 'second')]
q = a2m(x[:se... | [
"def",
"Jintegrate",
"(",
"self",
",",
"x",
",",
"dx",
",",
"firstsecond",
"=",
"'both'",
")",
":",
"assert",
"(",
"firstsecond",
"in",
"[",
"'first'",
",",
"'second'",
",",
"'both'",
"]",
")",
"assert",
"(",
"x",
".",
"shape",
"==",
"(",
"self",
"... | Compute the partial derivatives for integrate operator using Pinocchio. | [
"Compute",
"the",
"partial",
"derivatives",
"for",
"integrate",
"operator",
"using",
"Pinocchio",
"."
] | [
"\"\"\" Compute the partial derivatives for integrate operator using Pinocchio.\n\n :param x: current state\n :param dx: displacement of the state\n :param firstsecond: desired partial derivative\n :return the partial derivative(s) of the integrate(x,dx) function\n \"\"\"",
"# D... | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "dx",
"type": null
},
{
"param": "firstsecond",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
fa83b485ef158c98694f588b9f83bde47aa02bad | pFernbach/crocoddyl | unittest/python/crocoddyl/differential_action.py | [
"BSD-3-Clause"
] | Python | createData | <not_specific> | def createData(self):
""" Create the differential action data.
Each differential action model has its own data that needs to be
allocated. This function returns the allocated data for a predefined
DAM. Note that you need to defined the DifferentialActionDataType inside
your DAM.... | Create the differential action data.
Each differential action model has its own data that needs to be
allocated. This function returns the allocated data for a predefined
DAM. Note that you need to defined the DifferentialActionDataType inside
your DAM.
:return DAM data.
... | Create the differential action data.
Each differential action model has its own data that needs to be
allocated. This function returns the allocated data for a predefined
DAM. Note that you need to defined the DifferentialActionDataType inside
your DAM.
:return DAM data. | [
"Create",
"the",
"differential",
"action",
"data",
".",
"Each",
"differential",
"action",
"model",
"has",
"its",
"own",
"data",
"that",
"needs",
"to",
"be",
"allocated",
".",
"This",
"function",
"returns",
"the",
"allocated",
"data",
"for",
"a",
"predefined",
... | def createData(self):
return self.DifferentialActionDataType(self) | [
"def",
"createData",
"(",
"self",
")",
":",
"return",
"self",
".",
"DifferentialActionDataType",
"(",
"self",
")"
] | Create the differential action data. | [
"Create",
"the",
"differential",
"action",
"data",
"."
] | [
"\"\"\" Create the differential action data.\n\n Each differential action model has its own data that needs to be\n allocated. This function returns the allocated data for a predefined\n DAM. Note that you need to defined the DifferentialActionDataType inside\n your DAM.\n :return... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fa83b485ef158c98694f588b9f83bde47aa02bad | pFernbach/crocoddyl | unittest/python/crocoddyl/differential_action.py | [
"BSD-3-Clause"
] | Python | calc | null | def calc(self, data, x, u=None):
""" Compute the state evolution and cost value.
First, it describes the time-continuous evolution of our dynamical system
in which along predefined integrated action self we might obtain the
next discrete state. Indeed it computes the time derivatives of... | Compute the state evolution and cost value.
First, it describes the time-continuous evolution of our dynamical system
in which along predefined integrated action self we might obtain the
next discrete state. Indeed it computes the time derivatives of the
state from a predefined dynamic... | Compute the state evolution and cost value.
First, it describes the time-continuous evolution of our dynamical system
in which along predefined integrated action self we might obtain the
next discrete state. Indeed it computes the time derivatives of the
state from a predefined dynamical system. Additionally it compute... | [
"Compute",
"the",
"state",
"evolution",
"and",
"cost",
"value",
".",
"First",
"it",
"describes",
"the",
"time",
"-",
"continuous",
"evolution",
"of",
"our",
"dynamical",
"system",
"in",
"which",
"along",
"predefined",
"integrated",
"action",
"self",
"we",
"mig... | def calc(self, data, x, u=None):
raise NotImplementedError("Not implemented yet.") | [
"def",
"calc",
"(",
"self",
",",
"data",
",",
"x",
",",
"u",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Not implemented yet.\"",
")"
] | Compute the state evolution and cost value. | [
"Compute",
"the",
"state",
"evolution",
"and",
"cost",
"value",
"."
] | [
"\"\"\" Compute the state evolution and cost value.\n\n First, it describes the time-continuous evolution of our dynamical system\n in which along predefined integrated action self we might obtain the\n next discrete state. Indeed it computes the time derivatives of the\n state from a pr... | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "u",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": "differential action model",
"docstring_tokens": [
"differential",
"action",
"model"
],
"default": null,
"is_optional": null
},
{
"ident... |
fa83b485ef158c98694f588b9f83bde47aa02bad | pFernbach/crocoddyl | unittest/python/crocoddyl/differential_action.py | [
"BSD-3-Clause"
] | Python | calcDiff | null | def calcDiff(self, data, x, u=None, recalc=True):
""" Compute the derivatives of the dynamics and cost functions.
It computes the partial derivatives of the dynamical system and the cost
function. If recalc == True, it first updates the state evolution and
cost value. This function buil... | Compute the derivatives of the dynamics and cost functions.
It computes the partial derivatives of the dynamical system and the cost
function. If recalc == True, it first updates the state evolution and
cost value. This function builds a quadratic approximation of the
time-continuous a... | Compute the derivatives of the dynamics and cost functions.
It computes the partial derivatives of the dynamical system and the cost
function. If recalc == True, it first updates the state evolution and
cost value. This function builds a quadratic approximation of the
time-continuous action model . | [
"Compute",
"the",
"derivatives",
"of",
"the",
"dynamics",
"and",
"cost",
"functions",
".",
"It",
"computes",
"the",
"partial",
"derivatives",
"of",
"the",
"dynamical",
"system",
"and",
"the",
"cost",
"function",
".",
"If",
"recalc",
"==",
"True",
"it",
"firs... | def calcDiff(self, data, x, u=None, recalc=True):
raise NotImplementedError("Not implemented yet.") | [
"def",
"calcDiff",
"(",
"self",
",",
"data",
",",
"x",
",",
"u",
"=",
"None",
",",
"recalc",
"=",
"True",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Not implemented yet.\"",
")"
] | Compute the derivatives of the dynamics and cost functions. | [
"Compute",
"the",
"derivatives",
"of",
"the",
"dynamics",
"and",
"cost",
"functions",
"."
] | [
"\"\"\" Compute the derivatives of the dynamics and cost functions.\n\n It computes the partial derivatives of the dynamical system and the cost\n function. If recalc == True, it first updates the state evolution and\n cost value. This function builds a quadratic approximation of the\n t... | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "x",
"type": null
},
{
"param": "u",
"type": null
},
{
"param": "recalc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": "differential action data",
... |
8bbb57c16e722e3f9369a5b548c0a68c2ae53d4c | pFernbach/crocoddyl | unittest/python/crocoddyl/shooting.py | [
"BSD-3-Clause"
] | Python | calc | <not_specific> | def calc(self, xs, us):
""" Compute the cost and the next states.
"""
return sum([m.calc(d, x, u)[1] for m, d, x, u in zip(self.runningModels, self.runningDatas, xs[:-1], us)
]) + self.terminalModel.calc(self.terminalData, xs[-1])[1] | Compute the cost and the next states.
| Compute the cost and the next states. | [
"Compute",
"the",
"cost",
"and",
"the",
"next",
"states",
"."
] | def calc(self, xs, us):
return sum([m.calc(d, x, u)[1] for m, d, x, u in zip(self.runningModels, self.runningDatas, xs[:-1], us)
]) + self.terminalModel.calc(self.terminalData, xs[-1])[1] | [
"def",
"calc",
"(",
"self",
",",
"xs",
",",
"us",
")",
":",
"return",
"sum",
"(",
"[",
"m",
".",
"calc",
"(",
"d",
",",
"x",
",",
"u",
")",
"[",
"1",
"]",
"for",
"m",
",",
"d",
",",
"x",
",",
"u",
"in",
"zip",
"(",
"self",
".",
"running... | Compute the cost and the next states. | [
"Compute",
"the",
"cost",
"and",
"the",
"next",
"states",
"."
] | [
"\"\"\" Compute the cost and the next states.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "xs",
"type": null
},
{
"param": "us",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "xs",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
8bbb57c16e722e3f9369a5b548c0a68c2ae53d4c | pFernbach/crocoddyl | unittest/python/crocoddyl/shooting.py | [
"BSD-3-Clause"
] | Python | calcDiff | <not_specific> | def calcDiff(self, xs, us):
""" Compute the cost-and-dynamics derivatives.
These quantities are computed along a given pair of trajectories xs
(states) and us (controls).
:param xs: state trajectory
:param us: control trajectory
"""
assert (len(xs) == self.T + 1)... | Compute the cost-and-dynamics derivatives.
These quantities are computed along a given pair of trajectories xs
(states) and us (controls).
:param xs: state trajectory
:param us: control trajectory
| Compute the cost-and-dynamics derivatives.
These quantities are computed along a given pair of trajectories xs
(states) and us (controls). | [
"Compute",
"the",
"cost",
"-",
"and",
"-",
"dynamics",
"derivatives",
".",
"These",
"quantities",
"are",
"computed",
"along",
"a",
"given",
"pair",
"of",
"trajectories",
"xs",
"(",
"states",
")",
"and",
"us",
"(",
"controls",
")",
"."
] | def calcDiff(self, xs, us):
assert (len(xs) == self.T + 1)
assert (len(us) == self.T)
for m, d, x, u in zip(self.runningModels, self.runningDatas, xs[:-1], us):
m.calcDiff(d, x, u)
self.terminalModel.calcDiff(self.terminalData, xs[-1])
return sum([d.cost for d in self... | [
"def",
"calcDiff",
"(",
"self",
",",
"xs",
",",
"us",
")",
":",
"assert",
"(",
"len",
"(",
"xs",
")",
"==",
"self",
".",
"T",
"+",
"1",
")",
"assert",
"(",
"len",
"(",
"us",
")",
"==",
"self",
".",
"T",
")",
"for",
"m",
",",
"d",
",",
"x"... | Compute the cost-and-dynamics derivatives. | [
"Compute",
"the",
"cost",
"-",
"and",
"-",
"dynamics",
"derivatives",
"."
] | [
"\"\"\" Compute the cost-and-dynamics derivatives.\n\n These quantities are computed along a given pair of trajectories xs\n (states) and us (controls).\n :param xs: state trajectory\n :param us: control trajectory\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "xs",
"type": null
},
{
"param": "us",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "xs",
"type": null,
"docstring": null,
"docstring_tokens": [
... |
8bbb57c16e722e3f9369a5b548c0a68c2ae53d4c | pFernbach/crocoddyl | unittest/python/crocoddyl/shooting.py | [
"BSD-3-Clause"
] | Python | rollout | <not_specific> | def rollout(self, us):
""" Integrate the dynamics given a control sequence.
:param us: control sequence
"""
xs = [self.initialState]
for m, d, u in zip(self.runningModels, self.runningDatas, us):
xs.append(m.calc(d, xs[-1], u)[0].copy())
return xs | Integrate the dynamics given a control sequence.
:param us: control sequence
| Integrate the dynamics given a control sequence. | [
"Integrate",
"the",
"dynamics",
"given",
"a",
"control",
"sequence",
"."
] | def rollout(self, us):
xs = [self.initialState]
for m, d, u in zip(self.runningModels, self.runningDatas, us):
xs.append(m.calc(d, xs[-1], u)[0].copy())
return xs | [
"def",
"rollout",
"(",
"self",
",",
"us",
")",
":",
"xs",
"=",
"[",
"self",
".",
"initialState",
"]",
"for",
"m",
",",
"d",
",",
"u",
"in",
"zip",
"(",
"self",
".",
"runningModels",
",",
"self",
".",
"runningDatas",
",",
"us",
")",
":",
"xs",
"... | Integrate the dynamics given a control sequence. | [
"Integrate",
"the",
"dynamics",
"given",
"a",
"control",
"sequence",
"."
] | [
"\"\"\" Integrate the dynamics given a control sequence.\n\n :param us: control sequence\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "us",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "us",
"type": null,
"docstring": null,
"docstring_tokens": [
... |
6fe9fe180dbb0cd492b0eb7ce9874d79b95a45b2 | pFernbach/crocoddyl | unittest/python/crocoddyl/locomotion/spline_utils.py | [
"BSD-3-Clause"
] | Python | polyfitND | <not_specific> | def polyfitND(x, y, deg, eps, rcond=None, full=False, w=None, cov=False):
""" Return the polynomial fitting (and its derivative)
for a set of points x, y where y=p(x).
This is a wrapper of np.polyfit for more than one dimensions.
:params x: Points where polynomial is being computed. e.g. on a timeline.
:pa... | Return the polynomial fitting (and its derivative)
for a set of points x, y where y=p(x).
This is a wrapper of np.polyfit for more than one dimensions.
:params x: Points where polynomial is being computed. e.g. on a timeline.
:params y: value of the curve at x, y=p(x). each row corresponds to a point.
:para... | Return the polynomial fitting (and its derivative)
for a set of points x, y where y=p(x).
This is a wrapper of np.polyfit for more than one dimensions.
:params x: Points where polynomial is being computed.
:returns array p where each row corresponds to the coeffs of a dimension in format np.poly1d | [
"Return",
"the",
"polynomial",
"fitting",
"(",
"and",
"its",
"derivative",
")",
"for",
"a",
"set",
"of",
"points",
"x",
"y",
"where",
"y",
"=",
"p",
"(",
"x",
")",
".",
"This",
"is",
"a",
"wrapper",
"of",
"np",
".",
"polyfit",
"for",
"more",
"than"... | def polyfitND(x, y, deg, eps, rcond=None, full=False, w=None, cov=False):
assert len(x.shape) == 1
p = np.array([
None,
] * y.shape[1])
dp = np.array([
None,
] * y.shape[1])
for i, y_a in enumerate(y.T):
p_a, residual, _, _, _ = np.polyfit(x, np.asarray(y_a).squeeze(), de... | [
"def",
"polyfitND",
"(",
"x",
",",
"y",
",",
"deg",
",",
"eps",
",",
"rcond",
"=",
"None",
",",
"full",
"=",
"False",
",",
"w",
"=",
"None",
",",
"cov",
"=",
"False",
")",
":",
"assert",
"len",
"(",
"x",
".",
"shape",
")",
"==",
"1",
"p",
"... | Return the polynomial fitting (and its derivative)
for a set of points x, y where y=p(x). | [
"Return",
"the",
"polynomial",
"fitting",
"(",
"and",
"its",
"derivative",
")",
"for",
"a",
"set",
"of",
"points",
"x",
"y",
"where",
"y",
"=",
"p",
"(",
"x",
")",
"."
] | [
"\"\"\" Return the polynomial fitting (and its derivative)\n for a set of points x, y where y=p(x).\n This is a wrapper of np.polyfit for more than one dimensions.\n\n :params x: Points where polynomial is being computed. e.g. on a timeline.\n :params y: value of the curve at x, y=p(x). each row corresponds to ... | [
{
"param": "x",
"type": null
},
{
"param": "y",
"type": null
},
{
"param": "deg",
"type": null
},
{
"param": "eps",
"type": null
},
{
"param": "rcond",
"type": null
},
{
"param": "full",
"type": null
},
{
"param": "w",
"type": null
},... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
6fe9fe180dbb0cd492b0eb7ce9874d79b95a45b2 | pFernbach/crocoddyl | unittest/python/crocoddyl/locomotion/spline_utils.py | [
"BSD-3-Clause"
] | Python | findDuplicates | <not_specific> | def findDuplicates(arr, tol=1e-8):
""" Takes a sorted array and returns the index of duplicated valuesinside the array
:params arr: np.array. e.g., a timeline
:params tol. optional. criterion to know if values are being duplicated.
:returns list of duplicated indices
"""
duplicates = []
for... | Takes a sorted array and returns the index of duplicated valuesinside the array
:params arr: np.array. e.g., a timeline
:params tol. optional. criterion to know if values are being duplicated.
:returns list of duplicated indices
| Takes a sorted array and returns the index of duplicated valuesinside the array
:params arr: np.array. e.g., a timeline
:params tol. optional. criterion to know if values are being duplicated.
:returns list of duplicated indices | [
"Takes",
"a",
"sorted",
"array",
"and",
"returns",
"the",
"index",
"of",
"duplicated",
"valuesinside",
"the",
"array",
":",
"params",
"arr",
":",
"np",
".",
"array",
".",
"e",
".",
"g",
".",
"a",
"timeline",
":",
"params",
"tol",
".",
"optional",
".",
... | def findDuplicates(arr, tol=1e-8):
duplicates = []
for i, a in enumerate(arr):
if i == 0:
pass
else:
if abs(a - arr[i - 1]) < tol:
duplicates.append(i)
return duplicates | [
"def",
"findDuplicates",
"(",
"arr",
",",
"tol",
"=",
"1e-8",
")",
":",
"duplicates",
"=",
"[",
"]",
"for",
"i",
",",
"a",
"in",
"enumerate",
"(",
"arr",
")",
":",
"if",
"i",
"==",
"0",
":",
"pass",
"else",
":",
"if",
"abs",
"(",
"a",
"-",
"a... | Takes a sorted array and returns the index of duplicated valuesinside the array
:params arr: np.array. | [
"Takes",
"a",
"sorted",
"array",
"and",
"returns",
"the",
"index",
"of",
"duplicated",
"valuesinside",
"the",
"array",
":",
"params",
"arr",
":",
"np",
".",
"array",
"."
] | [
"\"\"\" Takes a sorted array and returns the index of duplicated valuesinside the array\n\n :params arr: np.array. e.g., a timeline\n :params tol. optional. criterion to know if values are being duplicated.\n :returns list of duplicated indices\n \"\"\""
] | [
{
"param": "arr",
"type": null
},
{
"param": "tol",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arr",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tol",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
6fe9fe180dbb0cd492b0eb7ce9874d79b95a45b2 | pFernbach/crocoddyl | unittest/python/crocoddyl/locomotion/spline_utils.py | [
"BSD-3-Clause"
] | Python | removeDuplicates | <not_specific> | def removeDuplicates(arr, indices):
""" Takes an arr and a sorted list of indices.
Removes arr[i] for i in indices and returns a new array.
if arr is 2D, removes the i^{th} row for i in indices.
:params arr: np.array. e.g., a timeline
:params indices: sorted list of indices to remove.
:returns ... | Takes an arr and a sorted list of indices.
Removes arr[i] for i in indices and returns a new array.
if arr is 2D, removes the i^{th} row for i in indices.
:params arr: np.array. e.g., a timeline
:params indices: sorted list of indices to remove.
:returns new_arr: np.array
| Takes an arr and a sorted list of indices.
Removes arr[i] for i in indices and returns a new array.
if arr is 2D, removes the i^{th} row for i in indices. | [
"Takes",
"an",
"arr",
"and",
"a",
"sorted",
"list",
"of",
"indices",
".",
"Removes",
"arr",
"[",
"i",
"]",
"for",
"i",
"in",
"indices",
"and",
"returns",
"a",
"new",
"array",
".",
"if",
"arr",
"is",
"2D",
"removes",
"the",
"i^",
"{",
"th",
"}",
"... | def removeDuplicates(arr, indices):
for i in indices[::-1]:
if len(arr.shape) == 1:
arr = np.delete(arr, i)
elif len(arr.shape) == 2:
arr = np.delete(arr, i, axis=0)
return arr | [
"def",
"removeDuplicates",
"(",
"arr",
",",
"indices",
")",
":",
"for",
"i",
"in",
"indices",
"[",
":",
":",
"-",
"1",
"]",
":",
"if",
"len",
"(",
"arr",
".",
"shape",
")",
"==",
"1",
":",
"arr",
"=",
"np",
".",
"delete",
"(",
"arr",
",",
"i"... | Takes an arr and a sorted list of indices. | [
"Takes",
"an",
"arr",
"and",
"a",
"sorted",
"list",
"of",
"indices",
"."
] | [
"\"\"\" Takes an arr and a sorted list of indices.\n Removes arr[i] for i in indices and returns a new array.\n if arr is 2D, removes the i^{th} row for i in indices.\n\n :params arr: np.array. e.g., a timeline\n :params indices: sorted list of indices to remove.\n :returns new_arr: np.array\n \"\... | [
{
"param": "arr",
"type": null
},
{
"param": "indices",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "new_arr"
}
],
"raises": [],
"params": [
{
"identifier": "arr",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": nul... |
049e22b503d5aa687ba87c5f17f2b511a63adc8b | pFernbach/crocoddyl | unittest/python/crocoddyl/box_ddp.py | [
"BSD-3-Clause"
] | Python | forwardPass | <not_specific> | def forwardPass(self, stepLength, warning='ignore'):
""" Run the forward-pass of the DDP algorithm.
The forward-pass basically applies a new policy and then rollout the
system. After this rollouts, it's checked if this policy provides a
reasonable improvement. For that we use Armijo con... | Run the forward-pass of the DDP algorithm.
The forward-pass basically applies a new policy and then rollout the
system. After this rollouts, it's checked if this policy provides a
reasonable improvement. For that we use Armijo condition to evaluated the
chosen step length.
:par... | Run the forward-pass of the DDP algorithm.
The forward-pass basically applies a new policy and then rollout the
system. After this rollouts, it's checked if this policy provides a
reasonable improvement. For that we use Armijo condition to evaluated the
chosen step length. | [
"Run",
"the",
"forward",
"-",
"pass",
"of",
"the",
"DDP",
"algorithm",
".",
"The",
"forward",
"-",
"pass",
"basically",
"applies",
"a",
"new",
"policy",
"and",
"then",
"rollout",
"the",
"system",
".",
"After",
"this",
"rollouts",
"it",
"'",
"s",
"checked... | def forwardPass(self, stepLength, warning='ignore'):
uu = self.uu
ul = self.ul
xs, us = self.xs, self.us
xtry = [self.problem.initialState] + [np.nan] * self.problem.T
utry = [np.nan] * self.problem.T
ctry = 0
for t, (m, d) in enumerate(zip(self.problem.runningMod... | [
"def",
"forwardPass",
"(",
"self",
",",
"stepLength",
",",
"warning",
"=",
"'ignore'",
")",
":",
"uu",
"=",
"self",
".",
"uu",
"ul",
"=",
"self",
".",
"ul",
"xs",
",",
"us",
"=",
"self",
".",
"xs",
",",
"self",
".",
"us",
"xtry",
"=",
"[",
"sel... | Run the forward-pass of the DDP algorithm. | [
"Run",
"the",
"forward",
"-",
"pass",
"of",
"the",
"DDP",
"algorithm",
"."
] | [
"\"\"\" Run the forward-pass of the DDP algorithm.\n\n The forward-pass basically applies a new policy and then rollout the\n system. After this rollouts, it's checked if this policy provides a\n reasonable improvement. For that we use Armijo condition to evaluated the\n chosen step leng... | [
{
"param": "self",
"type": null
},
{
"param": "stepLength",
"type": null
},
{
"param": "warning",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stepLength",
"type": null,
"docstring": null,
"docstring_toke... |
01ca3a8e0901cfecf262c34df93b39eb7782a758 | pFernbach/crocoddyl | unittest/python/crocoddyl/diagnostic.py | [
"BSD-3-Clause"
] | Python | displayTrajectory | <not_specific> | def displayTrajectory(robot, xs, dt=0.1, rate=-1, cameraTF=None):
""" Display a robot trajectory xs using Gepetto-viewer gui.
:param robot: Robot wrapper
:param xs: state trajectory
:param dt: step duration
:param rate: visualization rate
:param cameraTF: camera transform
"""
if not ha... | Display a robot trajectory xs using Gepetto-viewer gui.
:param robot: Robot wrapper
:param xs: state trajectory
:param dt: step duration
:param rate: visualization rate
:param cameraTF: camera transform
| Display a robot trajectory xs using Gepetto-viewer gui. | [
"Display",
"a",
"robot",
"trajectory",
"xs",
"using",
"Gepetto",
"-",
"viewer",
"gui",
"."
] | def displayTrajectory(robot, xs, dt=0.1, rate=-1, cameraTF=None):
if not hasattr(robot, 'viewer'):
robot.initDisplay(loadModel=True)
if cameraTF is not None:
robot.viewer.gui.setCameraTransform(0, cameraTF)
import numpy as np
def a2m(a):
return np.matrix(a).T
import time
... | [
"def",
"displayTrajectory",
"(",
"robot",
",",
"xs",
",",
"dt",
"=",
"0.1",
",",
"rate",
"=",
"-",
"1",
",",
"cameraTF",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"robot",
",",
"'viewer'",
")",
":",
"robot",
".",
"initDisplay",
"(",
"load... | Display a robot trajectory xs using Gepetto-viewer gui. | [
"Display",
"a",
"robot",
"trajectory",
"xs",
"using",
"Gepetto",
"-",
"viewer",
"gui",
"."
] | [
"\"\"\" Display a robot trajectory xs using Gepetto-viewer gui.\n\n :param robot: Robot wrapper\n :param xs: state trajectory\n :param dt: step duration\n :param rate: visualization rate\n :param cameraTF: camera transform\n \"\"\""
] | [
{
"param": "robot",
"type": null
},
{
"param": "xs",
"type": null
},
{
"param": "dt",
"type": null
},
{
"param": "rate",
"type": null
},
{
"param": "cameraTF",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "robot",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is_optional": null
},
{
"identifier": "xs",
"type": null,
"docstring": null,
... |
7be4aee5d0bf8d3b26ec292aed67a74538448341 | pFernbach/crocoddyl | unittest/python/crocoddyl/qpsolvers.py | [
"BSD-3-Clause"
] | Python | quadprogWrapper | <not_specific> | def quadprogWrapper(H, g, C=None, d=None, A=None, b=None, initvals=None):
"""
Quadprog <https://pypi.python.org/pypi/quadprog/>.
The quadprog solver only considers the lower entries of `H`, therefore it
will use a wrong cost function if a non-symmetric matrix is provided.
"""
assert (allclose(H,... |
Quadprog <https://pypi.python.org/pypi/quadprog/>.
The quadprog solver only considers the lower entries of `H`, therefore it
will use a wrong cost function if a non-symmetric matrix is provided.
| Quadprog .
The quadprog solver only considers the lower entries of `H`, therefore it
will use a wrong cost function if a non-symmetric matrix is provided. | [
"Quadprog",
".",
"The",
"quadprog",
"solver",
"only",
"considers",
"the",
"lower",
"entries",
"of",
"`",
"H",
"`",
"therefore",
"it",
"will",
"use",
"a",
"wrong",
"cost",
"function",
"if",
"a",
"non",
"-",
"symmetric",
"matrix",
"is",
"provided",
"."
] | def quadprogWrapper(H, g, C=None, d=None, A=None, b=None, initvals=None):
assert (allclose(H, H.T, atol=1e-10))
if initvals is not None:
print("quadprog: note that warm-start values ignored by wrapper")
if A is not None and C is not None:
qp_C = -vstack([A, C]).T
qp_b = -hstack([b, d... | [
"def",
"quadprogWrapper",
"(",
"H",
",",
"g",
",",
"C",
"=",
"None",
",",
"d",
"=",
"None",
",",
"A",
"=",
"None",
",",
"b",
"=",
"None",
",",
"initvals",
"=",
"None",
")",
":",
"assert",
"(",
"allclose",
"(",
"H",
",",
"H",
".",
"T",
",",
... | Quadprog <https://pypi.python.org/pypi/quadprog/>. | [
"Quadprog",
"<https",
":",
"//",
"pypi",
".",
"python",
".",
"org",
"/",
"pypi",
"/",
"quadprog",
"/",
">",
"."
] | [
"\"\"\"\n Quadprog <https://pypi.python.org/pypi/quadprog/>.\n The quadprog solver only considers the lower entries of `H`, therefore it\n will use a wrong cost function if a non-symmetric matrix is provided.\n \"\"\"",
"# no equality constraint",
"# if A is None and C is None:",
"\"\"\"\n Quad... | [
{
"param": "H",
"type": null
},
{
"param": "g",
"type": null
},
{
"param": "C",
"type": null
},
{
"param": "d",
"type": null
},
{
"param": "A",
"type": null
},
{
"param": "b",
"type": null
},
{
"param": "initvals",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "H",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "g",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
d571e4b9db9f1915837d77568f1f092e1a7f4875 | pFernbach/crocoddyl | unittest/python/crocoddyl/kkt.py | [
"BSD-3-Clause"
] | Python | calc | <not_specific> | def calc(self):
'''
For a given pair of candidate state and control trajectories,
compute the KKT system.
isFeasible should be set True if F(xs,us) = 0 (xs obtained from rollout).
'''
xs, us = self.xs, self.us
problem = self.problem
self.cost = problem.cal... |
For a given pair of candidate state and control trajectories,
compute the KKT system.
isFeasible should be set True if F(xs,us) = 0 (xs obtained from rollout).
| For a given pair of candidate state and control trajectories,
compute the KKT system.
isFeasible should be set True if F(xs,us) = 0 (xs obtained from rollout). | [
"For",
"a",
"given",
"pair",
"of",
"candidate",
"state",
"and",
"control",
"trajectories",
"compute",
"the",
"KKT",
"system",
".",
"isFeasible",
"should",
"be",
"set",
"True",
"if",
"F",
"(",
"xs",
"us",
")",
"=",
"0",
"(",
"xs",
"obtained",
"from",
"r... | def calc(self):
xs, us = self.xs, self.us
problem = self.problem
self.cost = problem.calcDiff(xs, us)
ix = 0
iu = 0
cx0 = problem.runningModels[0].ndx
np.fill_diagonal(self.Fx, 1)
for model, data, xguess in zip(problem.runningModels, problem.runningDatas... | [
"def",
"calc",
"(",
"self",
")",
":",
"xs",
",",
"us",
"=",
"self",
".",
"xs",
",",
"self",
".",
"us",
"problem",
"=",
"self",
".",
"problem",
"self",
".",
"cost",
"=",
"problem",
".",
"calcDiff",
"(",
"xs",
",",
"us",
")",
"ix",
"=",
"0",
"i... | For a given pair of candidate state and control trajectories,
compute the KKT system. | [
"For",
"a",
"given",
"pair",
"of",
"candidate",
"state",
"and",
"control",
"trajectories",
"compute",
"the",
"KKT",
"system",
"."
] | [
"'''\n For a given pair of candidate state and control trajectories,\n compute the KKT system.\n isFeasible should be set True if F(xs,us) = 0 (xs obtained from rollout).\n '''",
"# offset on constraint xnext = f(x,u) due to x0 = ref.",
"# constraint value = xnext_guess - f(x_guess,u... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d571e4b9db9f1915837d77568f1f092e1a7f4875 | pFernbach/crocoddyl | unittest/python/crocoddyl/kkt.py | [
"BSD-3-Clause"
] | Python | computeDirection | <not_specific> | def computeDirection(self, recalc=True):
'''
Compute the direction of descent for the current guess xs,us.
if recalc is True, run self.calc() before hand. self.setCandidate
must have been called before.
'''
if recalc:
self.calc()
self.computePrimalDual... |
Compute the direction of descent for the current guess xs,us.
if recalc is True, run self.calc() before hand. self.setCandidate
must have been called before.
| Compute the direction of descent for the current guess xs,us.
if recalc is True, run self.calc() before hand. self.setCandidate
must have been called before. | [
"Compute",
"the",
"direction",
"of",
"descent",
"for",
"the",
"current",
"guess",
"xs",
"us",
".",
"if",
"recalc",
"is",
"True",
"run",
"self",
".",
"calc",
"()",
"before",
"hand",
".",
"self",
".",
"setCandidate",
"must",
"have",
"been",
"called",
"befo... | def computeDirection(self, recalc=True):
if recalc:
self.calc()
self.computePrimalDual()
p_x = self.primaldual[:self.ndx]
p_u = self.primaldual[self.ndx:self.ndx + self.nu]
ix = 0
iu = 0
dxs = []
dus = []
lambdas = []
for model,... | [
"def",
"computeDirection",
"(",
"self",
",",
"recalc",
"=",
"True",
")",
":",
"if",
"recalc",
":",
"self",
".",
"calc",
"(",
")",
"self",
".",
"computePrimalDual",
"(",
")",
"p_x",
"=",
"self",
".",
"primaldual",
"[",
":",
"self",
".",
"ndx",
"]",
... | Compute the direction of descent for the current guess xs,us. | [
"Compute",
"the",
"direction",
"of",
"descent",
"for",
"the",
"current",
"guess",
"xs",
"us",
"."
] | [
"'''\n Compute the direction of descent for the current guess xs,us.\n if recalc is True, run self.calc() before hand. self.setCandidate\n must have been called before.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "recalc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "recalc",
"type": null,
"docstring": null,
"docstring_tokens":... |
d571e4b9db9f1915837d77568f1f092e1a7f4875 | pFernbach/crocoddyl | unittest/python/crocoddyl/kkt.py | [
"BSD-3-Clause"
] | Python | solve | <not_specific> | def solve(self, maxiter=100, init_xs=None, init_us=None, isFeasible=False, verbose=False):
'''
From an initial guess init_xs,init_us (feasible or not),
iterate over computeDirection and tryStep until stoppingCriteria is below threshold.
'''
self.setCandidate(init_xs, init_us, isF... |
From an initial guess init_xs,init_us (feasible or not),
iterate over computeDirection and tryStep until stoppingCriteria is below threshold.
| From an initial guess init_xs,init_us (feasible or not),
iterate over computeDirection and tryStep until stoppingCriteria is below threshold. | [
"From",
"an",
"initial",
"guess",
"init_xs",
"init_us",
"(",
"feasible",
"or",
"not",
")",
"iterate",
"over",
"computeDirection",
"and",
"tryStep",
"until",
"stoppingCriteria",
"is",
"below",
"threshold",
"."
] | def solve(self, maxiter=100, init_xs=None, init_us=None, isFeasible=False, verbose=False):
self.setCandidate(init_xs, init_us, isFeasible)
for i in range(maxiter):
self.computeDirection()
d1, d2 = self.expectedImprovement()
for a in self.alphas:
dV = s... | [
"def",
"solve",
"(",
"self",
",",
"maxiter",
"=",
"100",
",",
"init_xs",
"=",
"None",
",",
"init_us",
"=",
"None",
",",
"isFeasible",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"self",
".",
"setCandidate",
"(",
"init_xs",
",",
"init_us",
"... | From an initial guess init_xs,init_us (feasible or not),
iterate over computeDirection and tryStep until stoppingCriteria is below threshold. | [
"From",
"an",
"initial",
"guess",
"init_xs",
"init_us",
"(",
"feasible",
"or",
"not",
")",
"iterate",
"over",
"computeDirection",
"and",
"tryStep",
"until",
"stoppingCriteria",
"is",
"below",
"threshold",
"."
] | [
"'''\n From an initial guess init_xs,init_us (feasible or not),\n iterate over computeDirection and tryStep until stoppingCriteria is below threshold.\n '''",
"# Accept step",
"# if d1<self.th_grad:",
"# return self.xs,self.us,False",
"# Warning: no convergence in max iterations"
] | [
{
"param": "self",
"type": null
},
{
"param": "maxiter",
"type": null
},
{
"param": "init_xs",
"type": null
},
{
"param": "init_us",
"type": null
},
{
"param": "isFeasible",
"type": null
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "maxiter",
"type": null,
"docstring": null,
"docstring_tokens"... |
aad6490840d594236e05187f0155726a1e5178f2 | NoctuaNivalis/planer | planer/experimenting/quicksync.py | [
"MIT"
] | Python | main | null | def main():
"""Shows basic usage of the Google Calendar API.
Creates a Google Calendar API service object and outputs a list of the next
10 events on the user's calendar.
"""
credentials = get_credentials()
service = build('calendar', 'v3', http=credentials.authorize(Http()))
token = get_s... | Shows basic usage of the Google Calendar API.
Creates a Google Calendar API service object and outputs a list of the next
10 events on the user's calendar.
| Shows basic usage of the Google Calendar API.
Creates a Google Calendar API service object and outputs a list of the next
10 events on the user's calendar. | [
"Shows",
"basic",
"usage",
"of",
"the",
"Google",
"Calendar",
"API",
".",
"Creates",
"a",
"Google",
"Calendar",
"API",
"service",
"object",
"and",
"outputs",
"a",
"list",
"of",
"the",
"next",
"10",
"events",
"on",
"the",
"user",
"'",
"s",
"calendar",
"."... | def main():
credentials = get_credentials()
service = build('calendar', 'v3', http=credentials.authorize(Http()))
token = get_synctoken()
if token:
request = service.events().list(
calendarId='primary',
syncToken=token)
else:
request = service.events()... | [
"def",
"main",
"(",
")",
":",
"credentials",
"=",
"get_credentials",
"(",
")",
"service",
"=",
"build",
"(",
"'calendar'",
",",
"'v3'",
",",
"http",
"=",
"credentials",
".",
"authorize",
"(",
"Http",
"(",
")",
")",
")",
"token",
"=",
"get_synctoken",
"... | Shows basic usage of the Google Calendar API. | [
"Shows",
"basic",
"usage",
"of",
"the",
"Google",
"Calendar",
"API",
"."
] | [
"\"\"\"Shows basic usage of the Google Calendar API.\n\n Creates a Google Calendar API service object and outputs a list of the next\n 10 events on the user's calendar.\n \"\"\"",
"# 'Z' indicates UTC time"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
dc194700cf111d339d475a6a52e601230436059b | NoctuaNivalis/planer | planer/experimenting/quickstart.py | [
"MIT"
] | Python | main | null | def main():
"""Shows basic usage of the Google Calendar API.
Creates a Google Calendar API service object and outputs a list of the next
10 events on the user's calendar.
"""
credentials = get_credentials()
service = build('calendar', 'v3', http=credentials.authorize(Http()))
now = datetim... | Shows basic usage of the Google Calendar API.
Creates a Google Calendar API service object and outputs a list of the next
10 events on the user's calendar.
| Shows basic usage of the Google Calendar API.
Creates a Google Calendar API service object and outputs a list of the next
10 events on the user's calendar. | [
"Shows",
"basic",
"usage",
"of",
"the",
"Google",
"Calendar",
"API",
".",
"Creates",
"a",
"Google",
"Calendar",
"API",
"service",
"object",
"and",
"outputs",
"a",
"list",
"of",
"the",
"next",
"10",
"events",
"on",
"the",
"user",
"'",
"s",
"calendar",
"."... | def main():
credentials = get_credentials()
service = build('calendar', 'v3', http=credentials.authorize(Http()))
now = datetime.utcnow().isoformat() + 'Z'
print('Getting the upcoming 10 events')
eventsResult = service.events().list(
calendarId='primary', timeMin=now, maxResults=10, singleE... | [
"def",
"main",
"(",
")",
":",
"credentials",
"=",
"get_credentials",
"(",
")",
"service",
"=",
"build",
"(",
"'calendar'",
",",
"'v3'",
",",
"http",
"=",
"credentials",
".",
"authorize",
"(",
"Http",
"(",
")",
")",
")",
"now",
"=",
"datetime",
".",
"... | Shows basic usage of the Google Calendar API. | [
"Shows",
"basic",
"usage",
"of",
"the",
"Google",
"Calendar",
"API",
"."
] | [
"\"\"\"Shows basic usage of the Google Calendar API.\n\n Creates a Google Calendar API service object and outputs a list of the next\n 10 events on the user's calendar.\n \"\"\"",
"# 'Z' indicates UTC time",
"#start = event['start'].get('dateTime', event['start'].get('date'))",
"#print(start, event['... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
fefac8310f34179a341777e1fe7068275ee1bdde | NoctuaNivalis/planer | planer/remote/__init__.py | [
"MIT"
] | Python | send | <not_specific> | async def send(loop, message):
"Send the keyword arguments as a JSON to the server."
reader, writer = await asyncio.open_connection(
config['daemon']['host'],
config['daemon']['port'],
loop=loop)
writer.write("{}\n".format(json.dumps(message)).encode())
await writer.... | Send the keyword arguments as a JSON to the server. | Send the keyword arguments as a JSON to the server. | [
"Send",
"the",
"keyword",
"arguments",
"as",
"a",
"JSON",
"to",
"the",
"server",
"."
] | async def send(loop, message):
reader, writer = await asyncio.open_connection(
config['daemon']['host'],
config['daemon']['port'],
loop=loop)
writer.write("{}\n".format(json.dumps(message)).encode())
await writer.drain()
received = await reader.readline()
writer.c... | [
"async",
"def",
"send",
"(",
"loop",
",",
"message",
")",
":",
"reader",
",",
"writer",
"=",
"await",
"asyncio",
".",
"open_connection",
"(",
"config",
"[",
"'daemon'",
"]",
"[",
"'host'",
"]",
",",
"config",
"[",
"'daemon'",
"]",
"[",
"'port'",
"]",
... | Send the keyword arguments as a JSON to the server. | [
"Send",
"the",
"keyword",
"arguments",
"as",
"a",
"JSON",
"to",
"the",
"server",
"."
] | [
"\"Send the keyword arguments as a JSON to the server.\""
] | [
{
"param": "loop",
"type": null
},
{
"param": "message",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "message",
"type": null,
"docstring": null,
"docstring_tokens"... |
95f031628b6b57dee04f73b171db5ab144560e2a | jgkawell/feedback_cclfd | src/visualizations/path_display.py | [
"MIT"
] | Python | add_Pose_arr | null | def add_Pose_arr(self, msg):
""" Add the path to the list of paths """
nuPath = []
for pose in msg.poses:
posn, ornt = unpack_ROS_pose(pose)
nuPath.append(posn)
self.add_path(nuPath, _BLUE) | Add the path to the list of paths | Add the path to the list of paths | [
"Add",
"the",
"path",
"to",
"the",
"list",
"of",
"paths"
] | def add_Pose_arr(self, msg):
nuPath = []
for pose in msg.poses:
posn, ornt = unpack_ROS_pose(pose)
nuPath.append(posn)
self.add_path(nuPath, _BLUE) | [
"def",
"add_Pose_arr",
"(",
"self",
",",
"msg",
")",
":",
"nuPath",
"=",
"[",
"]",
"for",
"pose",
"in",
"msg",
".",
"poses",
":",
"posn",
",",
"ornt",
"=",
"unpack_ROS_pose",
"(",
"pose",
")",
"nuPath",
".",
"append",
"(",
"posn",
")",
"self",
".",... | Add the path to the list of paths | [
"Add",
"the",
"path",
"to",
"the",
"list",
"of",
"paths"
] | [
"\"\"\" Add the path to the list of paths \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "msg",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "msg",
"type": null,
"docstring": null,
"docstring_tokens": []... |
95f031628b6b57dee04f73b171db5ab144560e2a | jgkawell/feedback_cclfd | src/visualizations/path_display.py | [
"MIT"
] | Python | update_history | null | def update_history(self, msg):
""" Update the mug with the new xform --> pose """
# Get the position from the message
posn, ornt = unpack_ROS_xform(msg)
dist = vec_dif_mag(posn, self.pathList[0][-1])
# If the next point is sufficient distance from the last
if dist >= _DIS... | Update the mug with the new xform --> pose | Update the mug with the new xform --> pose | [
"Update",
"the",
"mug",
"with",
"the",
"new",
"xform",
"--",
">",
"pose"
] | def update_history(self, msg):
posn, ornt = unpack_ROS_xform(msg)
dist = vec_dif_mag(posn, self.pathList[0][-1])
if dist >= _DISTMARGIN:
self.pathList[0].append(posn) | [
"def",
"update_history",
"(",
"self",
",",
"msg",
")",
":",
"posn",
",",
"ornt",
"=",
"unpack_ROS_xform",
"(",
"msg",
")",
"dist",
"=",
"vec_dif_mag",
"(",
"posn",
",",
"self",
".",
"pathList",
"[",
"0",
"]",
"[",
"-",
"1",
"]",
")",
"if",
"dist",
... | Update the mug with the new xform --> pose | [
"Update",
"the",
"mug",
"with",
"the",
"new",
"xform",
"--",
">",
"pose"
] | [
"\"\"\" Update the mug with the new xform --> pose \"\"\"",
"# Get the position from the message",
"# If the next point is sufficient distance from the last"
] | [
{
"param": "self",
"type": null
},
{
"param": "msg",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "msg",
"type": null,
"docstring": null,
"docstring_tokens": []... |
95f031628b6b57dee04f73b171db5ab144560e2a | jgkawell/feedback_cclfd | src/visualizations/path_display.py | [
"MIT"
] | Python | add_path | null | def add_path(self, path, color=_GREEN):
""" Add a list of points to the list of paths """
# Add the path and the color
self.pathList.append(path)
self.colrList.append(color)
# If the number of paths have been exceeded
# then erase the first static path (index 1)
i... | Add a list of points to the list of paths | Add a list of points to the list of paths | [
"Add",
"a",
"list",
"of",
"points",
"to",
"the",
"list",
"of",
"paths"
] | def add_path(self, path, color=_GREEN):
self.pathList.append(path)
self.colrList.append(color)
if (len(self.pathList) - 1) > _PATHNUMLIMIT:
self.pathList.pop(1)
self.colrList.pop(1) | [
"def",
"add_path",
"(",
"self",
",",
"path",
",",
"color",
"=",
"_GREEN",
")",
":",
"self",
".",
"pathList",
".",
"append",
"(",
"path",
")",
"self",
".",
"colrList",
".",
"append",
"(",
"color",
")",
"if",
"(",
"len",
"(",
"self",
".",
"pathList",... | Add a list of points to the list of paths | [
"Add",
"a",
"list",
"of",
"points",
"to",
"the",
"list",
"of",
"paths"
] | [
"\"\"\" Add a list of points to the list of paths \"\"\"",
"# Add the path and the color",
"# If the number of paths have been exceeded",
"# then erase the first static path (index 1)"
] | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "color",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [... |
95f031628b6b57dee04f73b171db5ab144560e2a | jgkawell/feedback_cclfd | src/visualizations/path_display.py | [
"MIT"
] | Python | del_path | null | def del_path(self, index):
""" Remove path from list and the marker array
NOTE: Static path indices begin at 1 """
if index > 0:
self.pathList.pop(index)
self.colrList.pop(index) | Remove path from list and the marker array
NOTE: Static path indices begin at 1 | Remove path from list and the marker array
NOTE: Static path indices begin at 1 | [
"Remove",
"path",
"from",
"list",
"and",
"the",
"marker",
"array",
"NOTE",
":",
"Static",
"path",
"indices",
"begin",
"at",
"1"
] | def del_path(self, index):
if index > 0:
self.pathList.pop(index)
self.colrList.pop(index) | [
"def",
"del_path",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
">",
"0",
":",
"self",
".",
"pathList",
".",
"pop",
"(",
"index",
")",
"self",
".",
"colrList",
".",
"pop",
"(",
"index",
")"
] | Remove path from list and the marker array
NOTE: Static path indices begin at 1 | [
"Remove",
"path",
"from",
"list",
"and",
"the",
"marker",
"array",
"NOTE",
":",
"Static",
"path",
"indices",
"begin",
"at",
"1"
] | [
"\"\"\" Remove path from list and the marker array\n NOTE: Static path indices begin at 1 \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "index",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": null,
"docstring": null,
"docstring_tokens": ... |
95f031628b6b57dee04f73b171db5ab144560e2a | jgkawell/feedback_cclfd | src/visualizations/path_display.py | [
"MIT"
] | Python | create_line_marker | <not_specific> | def create_line_marker(self, ptsList,
scale=_DEFAULTSCALE, color=_GREEN,
mrkrNS=_NAMESPACE):
""" Return a marker composed of the points """
# Create marker
trace = Marker()
# Populate header
trace.header.stamp = rospy.Time.now... | Return a marker composed of the points | Return a marker composed of the points | [
"Return",
"a",
"marker",
"composed",
"of",
"the",
"points"
] | def create_line_marker(self, ptsList,
scale=_DEFAULTSCALE, color=_GREEN,
mrkrNS=_NAMESPACE):
trace = Marker()
trace.header.stamp = rospy.Time.now()
trace.header.frame_id = "base"
trace.ns = mrkrNS
trace.action = trace.ADD
... | [
"def",
"create_line_marker",
"(",
"self",
",",
"ptsList",
",",
"scale",
"=",
"_DEFAULTSCALE",
",",
"color",
"=",
"_GREEN",
",",
"mrkrNS",
"=",
"_NAMESPACE",
")",
":",
"trace",
"=",
"Marker",
"(",
")",
"trace",
".",
"header",
".",
"stamp",
"=",
"rospy",
... | Return a marker composed of the points | [
"Return",
"a",
"marker",
"composed",
"of",
"the",
"points"
] | [
"\"\"\" Return a marker composed of the points \"\"\"",
"# Create marker",
"# Populate header",
"# Set marker info for a persistent marker",
"# How long the object should last before being automatically deleted.",
"# 0 means forever",
"# Set marker size",
"# Line strips: Only scale.x is used and it co... | [
{
"param": "self",
"type": null
},
{
"param": "ptsList",
"type": null
},
{
"param": "scale",
"type": null
},
{
"param": "color",
"type": null
},
{
"param": "mrkrNS",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ptsList",
"type": null,
"docstring": null,
"docstring_tokens"... |
95f031628b6b57dee04f73b171db5ab144560e2a | jgkawell/feedback_cclfd | src/visualizations/path_display.py | [
"MIT"
] | Python | run | null | def run(self):
""" Publish all of the currently stored paths """
# While ROS is running
while (not rospy.is_shutdown()):
if 0 and (not self.hasRun):
self.test_lines()
self.hasRun = True
self.publish_all()
# Wait until the nod... | Publish all of the currently stored paths | Publish all of the currently stored paths | [
"Publish",
"all",
"of",
"the",
"currently",
"stored",
"paths"
] | def run(self):
while (not rospy.is_shutdown()):
if 0 and (not self.hasRun):
self.test_lines()
self.hasRun = True
self.publish_all()
self.idle.sleep()
else:
rospy.loginfo("Node Shutdown after %d seconds.",
... | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"(",
"not",
"rospy",
".",
"is_shutdown",
"(",
")",
")",
":",
"if",
"0",
"and",
"(",
"not",
"self",
".",
"hasRun",
")",
":",
"self",
".",
"test_lines",
"(",
")",
"self",
".",
"hasRun",
"=",
"True",
"... | Publish all of the currently stored paths | [
"Publish",
"all",
"of",
"the",
"currently",
"stored",
"paths"
] | [
"\"\"\" Publish all of the currently stored paths \"\"\"",
"# While ROS is running",
"# Wait until the node is supposed to fire next",
"# Post-shutdown activities"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
97f58487cf9e361fc4cbacc9cad1f7946d8fa8bb | jgkawell/feedback_cclfd | src/planners/query_strategy.py | [
"MIT"
] | Python | query_algorithm_interface | <not_specific> | def query_algorithm_interface(self, timestamp):
"""
This method for the main algorithms uses the states
from synthesizer to generate boolean queries map to constraints
:return: dictionary of keyframes mapped to constrains
and their truth value
"""
# states to ... |
This method for the main algorithms uses the states
from synthesizer to generate boolean queries map to constraints
:return: dictionary of keyframes mapped to constrains
and their truth value
| This method for the main algorithms uses the states
from synthesizer to generate boolean queries map to constraints | [
"This",
"method",
"for",
"the",
"main",
"algorithms",
"uses",
"the",
"states",
"from",
"synthesizer",
"to",
"generate",
"boolean",
"queries",
"map",
"to",
"constraints"
] | def query_algorithm_interface(self, timestamp):
key_frames = self.get_keyframes(self._states_of_interest)
for key_frame in key_frames:
self._queries[key_frame] = self.get_constraints(key_frame)
query_question = "Should I have oriented the cup upwards?"
return query_question | [
"def",
"query_algorithm_interface",
"(",
"self",
",",
"timestamp",
")",
":",
"key_frames",
"=",
"self",
".",
"get_keyframes",
"(",
"self",
".",
"_states_of_interest",
")",
"for",
"key_frame",
"in",
"key_frames",
":",
"self",
".",
"_queries",
"[",
"key_frame",
... | This method for the main algorithms uses the states
from synthesizer to generate boolean queries map to constraints | [
"This",
"method",
"for",
"the",
"main",
"algorithms",
"uses",
"the",
"states",
"from",
"synthesizer",
"to",
"generate",
"boolean",
"queries",
"map",
"to",
"constraints"
] | [
"\"\"\"\n This method for the main algorithms uses the states\n from synthesizer to generate boolean queries map to constraints\n :return: dictionary of keyframes mapped to constrains\n and their truth value\n \"\"\"",
"# states to keyframe transformation",
"# TODO: Genera... | [
{
"param": "self",
"type": null
},
{
"param": "timestamp",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary of keyframes mapped to constrains\nand their truth value",
"docstring_tokens": [
"dictionary",
"of",
"keyframes",
"mapped",
"to",
"constrains",
"and",
"their",
"truth",
"value"
... |
929bd1ff2ec68c64c4cf05f06710c87c5a5a018f | jgkawell/feedback_cclfd | src/visualizations/rospy_helpers.py | [
"MIT"
] | Python | load_pos_into_pose | null | def load_pos_into_pose(posArr, poseMsg):
""" Populate a ROS pose with an R3 list , in place """
poseMsg.x = posArr[0]
poseMsg.y = posArr[1]
poseMsg.z = posArr[2] | Populate a ROS pose with an R3 list , in place | Populate a ROS pose with an R3 list , in place | [
"Populate",
"a",
"ROS",
"pose",
"with",
"an",
"R3",
"list",
"in",
"place"
] | def load_pos_into_pose(posArr, poseMsg):
poseMsg.x = posArr[0]
poseMsg.y = posArr[1]
poseMsg.z = posArr[2] | [
"def",
"load_pos_into_pose",
"(",
"posArr",
",",
"poseMsg",
")",
":",
"poseMsg",
".",
"x",
"=",
"posArr",
"[",
"0",
"]",
"poseMsg",
".",
"y",
"=",
"posArr",
"[",
"1",
"]",
"poseMsg",
".",
"z",
"=",
"posArr",
"[",
"2",
"]"
] | Populate a ROS pose with an R3 list , in place | [
"Populate",
"a",
"ROS",
"pose",
"with",
"an",
"R3",
"list",
"in",
"place"
] | [
"\"\"\" Populate a ROS pose with an R3 list , in place \"\"\""
] | [
{
"param": "posArr",
"type": null
},
{
"param": "poseMsg",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "posArr",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "poseMsg",
"type": null,
"docstring": null,
"docstring_token... |
929bd1ff2ec68c64c4cf05f06710c87c5a5a018f | jgkawell/feedback_cclfd | src/visualizations/rospy_helpers.py | [
"MIT"
] | Python | vec3d_rand_corners | <not_specific> | def vec3d_rand_corners(corner1, corner2):
""" Sample one R3 point from the AABB
defined by 'corner1' and 'corner2' """
span = np.subtract(corner2, corner1)
sample = vec_random(3)
return [corner1[0]+span[0]*sample[0],
corner1[1]+span[1]*sample[1],
corner1[2]+span[2]*sample... | Sample one R3 point from the AABB
defined by 'corner1' and 'corner2' | Sample one R3 point from the AABB
defined by 'corner1' and 'corner2' | [
"Sample",
"one",
"R3",
"point",
"from",
"the",
"AABB",
"defined",
"by",
"'",
"corner1",
"'",
"and",
"'",
"corner2",
"'"
] | def vec3d_rand_corners(corner1, corner2):
span = np.subtract(corner2, corner1)
sample = vec_random(3)
return [corner1[0]+span[0]*sample[0],
corner1[1]+span[1]*sample[1],
corner1[2]+span[2]*sample[2]] | [
"def",
"vec3d_rand_corners",
"(",
"corner1",
",",
"corner2",
")",
":",
"span",
"=",
"np",
".",
"subtract",
"(",
"corner2",
",",
"corner1",
")",
"sample",
"=",
"vec_random",
"(",
"3",
")",
"return",
"[",
"corner1",
"[",
"0",
"]",
"+",
"span",
"[",
"0"... | Sample one R3 point from the AABB
defined by 'corner1' and 'corner2' | [
"Sample",
"one",
"R3",
"point",
"from",
"the",
"AABB",
"defined",
"by",
"'",
"corner1",
"'",
"and",
"'",
"corner2",
"'"
] | [
"\"\"\" Sample one R3 point from the AABB\n defined by 'corner1' and 'corner2' \"\"\""
] | [
{
"param": "corner1",
"type": null
},
{
"param": "corner2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "corner1",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "corner2",
"type": null,
"docstring": null,
"docstring_toke... |
929bd1ff2ec68c64c4cf05f06710c87c5a5a018f | jgkawell/feedback_cclfd | src/visualizations/rospy_helpers.py | [
"MIT"
] | Python | unpack_ROS_xform | <not_specific> | def unpack_ROS_xform(xform):
""" Unpack the ROS transform message into position and orientation """
posn = [xform.transform.translation.x,
xform.transform.translation.y, xform.transform.translation.z]
ornt = [xform.transform.rotation.x, xform.transform.rotation.y,
xform.transform.rot... | Unpack the ROS transform message into position and orientation | Unpack the ROS transform message into position and orientation | [
"Unpack",
"the",
"ROS",
"transform",
"message",
"into",
"position",
"and",
"orientation"
] | def unpack_ROS_xform(xform):
posn = [xform.transform.translation.x,
xform.transform.translation.y, xform.transform.translation.z]
ornt = [xform.transform.rotation.x, xform.transform.rotation.y,
xform.transform.rotation.z, xform.transform.rotation.w]
return posn, ornt | [
"def",
"unpack_ROS_xform",
"(",
"xform",
")",
":",
"posn",
"=",
"[",
"xform",
".",
"transform",
".",
"translation",
".",
"x",
",",
"xform",
".",
"transform",
".",
"translation",
".",
"y",
",",
"xform",
".",
"transform",
".",
"translation",
".",
"z",
"]... | Unpack the ROS transform message into position and orientation | [
"Unpack",
"the",
"ROS",
"transform",
"message",
"into",
"position",
"and",
"orientation"
] | [
"\"\"\" Unpack the ROS transform message into position and orientation \"\"\""
] | [
{
"param": "xform",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "xform",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
929bd1ff2ec68c64c4cf05f06710c87c5a5a018f | jgkawell/feedback_cclfd | src/visualizations/rospy_helpers.py | [
"MIT"
] | Python | unpack_ROS_pose | <not_specific> | def unpack_ROS_pose(pose):
""" Unpack the ROS transform message into position and orientation """
posn = [pose.position.x, pose.position.y, pose.position.z]
ornt = [pose.orientation.x, pose.orientation.y,
pose.orientation.z, pose.orientation.w]
return posn, ornt | Unpack the ROS transform message into position and orientation | Unpack the ROS transform message into position and orientation | [
"Unpack",
"the",
"ROS",
"transform",
"message",
"into",
"position",
"and",
"orientation"
] | def unpack_ROS_pose(pose):
posn = [pose.position.x, pose.position.y, pose.position.z]
ornt = [pose.orientation.x, pose.orientation.y,
pose.orientation.z, pose.orientation.w]
return posn, ornt | [
"def",
"unpack_ROS_pose",
"(",
"pose",
")",
":",
"posn",
"=",
"[",
"pose",
".",
"position",
".",
"x",
",",
"pose",
".",
"position",
".",
"y",
",",
"pose",
".",
"position",
".",
"z",
"]",
"ornt",
"=",
"[",
"pose",
".",
"orientation",
".",
"x",
","... | Unpack the ROS transform message into position and orientation | [
"Unpack",
"the",
"ROS",
"transform",
"message",
"into",
"position",
"and",
"orientation"
] | [
"\"\"\" Unpack the ROS transform message into position and orientation \"\"\""
] | [
{
"param": "pose",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pose",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
929bd1ff2ec68c64c4cf05f06710c87c5a5a018f | jgkawell/feedback_cclfd | src/visualizations/rospy_helpers.py | [
"MIT"
] | Python | load_xform_into_pose | null | def load_xform_into_pose(xform, pose):
""" Transfer frame data from transform to a pose """
# Load translation --> position
pose.position.x = xform.translation.x
pose.position.y = xform.translation.y
pose.position.z = xform.translation.z
# Load rotation --> orientation
pose.orientation.w = x... | Transfer frame data from transform to a pose | Transfer frame data from transform to a pose | [
"Transfer",
"frame",
"data",
"from",
"transform",
"to",
"a",
"pose"
] | def load_xform_into_pose(xform, pose):
pose.position.x = xform.translation.x
pose.position.y = xform.translation.y
pose.position.z = xform.translation.z
pose.orientation.w = xform.rotation.w
pose.orientation.x = xform.rotation.x
pose.orientation.y = xform.rotation.y
pose.orientation.z = xfor... | [
"def",
"load_xform_into_pose",
"(",
"xform",
",",
"pose",
")",
":",
"pose",
".",
"position",
".",
"x",
"=",
"xform",
".",
"translation",
".",
"x",
"pose",
".",
"position",
".",
"y",
"=",
"xform",
".",
"translation",
".",
"y",
"pose",
".",
"position",
... | Transfer frame data from transform to a pose | [
"Transfer",
"frame",
"data",
"from",
"transform",
"to",
"a",
"pose"
] | [
"\"\"\" Transfer frame data from transform to a pose \"\"\"",
"# Load translation --> position",
"# Load rotation --> orientation"
] | [
{
"param": "xform",
"type": null
},
{
"param": "pose",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "xform",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pose",
"type": null,
"docstring": null,
"docstring_tokens": ... |
18d231c8d86eaf15feca259bc5cea53778ba18fa | mathemusician/AudioTranscription | consolidate.py | [
"MIT"
] | Python | time_decoder | List[int] | def time_decoder(decoded: str, batch_decoded: List) -> List[int]:
"""
This is a function that takes in two arguments:
decoded: A string of decoded text
batch_decoded: A list of strings of decoded text
It returns a list of integers, which are the indices of the start
of each word in the decoded ... |
This is a function that takes in two arguments:
decoded: A string of decoded text
batch_decoded: A list of strings of decoded text
It returns a list of integers, which are the indices of the start
of each word in the decoded string.
This is done by iterating through the characters in the deco... | This is a function that takes in two arguments:
decoded: A string of decoded text
batch_decoded: A list of strings of decoded text
It returns a list of integers, which are the indices of the start
of each word in the decoded string.
This is done by iterating through the characters in the decoded
string, and comparing... | [
"This",
"is",
"a",
"function",
"that",
"takes",
"in",
"two",
"arguments",
":",
"decoded",
":",
"A",
"string",
"of",
"decoded",
"text",
"batch_decoded",
":",
"A",
"list",
"of",
"strings",
"of",
"decoded",
"text",
"It",
"returns",
"a",
"list",
"of",
"integ... | def time_decoder(decoded: str, batch_decoded: List) -> List[int]:
gen_decoded = char_gen(decoded)
decoded_index = 0
char = next(gen_decoded)
add_char = True
start_list = []
end_list = []
for index, token in tenumerate(batch_decoded):
if token == char:
if add_char == True:... | [
"def",
"time_decoder",
"(",
"decoded",
":",
"str",
",",
"batch_decoded",
":",
"List",
")",
"->",
"List",
"[",
"int",
"]",
":",
"gen_decoded",
"=",
"char_gen",
"(",
"decoded",
")",
"decoded_index",
"=",
"0",
"char",
"=",
"next",
"(",
"gen_decoded",
")",
... | This is a function that takes in two arguments:
decoded: A string of decoded text
batch_decoded: A list of strings of decoded text | [
"This",
"is",
"a",
"function",
"that",
"takes",
"in",
"two",
"arguments",
":",
"decoded",
":",
"A",
"string",
"of",
"decoded",
"text",
"batch_decoded",
":",
"A",
"list",
"of",
"strings",
"of",
"decoded",
"text"
] | [
"\"\"\"\n This is a function that takes in two arguments:\n decoded: A string of decoded text\n batch_decoded: A list of strings of decoded text\n\n It returns a list of integers, which are the indices of the start\n of each word in the decoded string.\n\n This is done by iterating through the cha... | [
{
"param": "decoded",
"type": "str"
},
{
"param": "batch_decoded",
"type": "List"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "decoded",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "batch_decoded",
"type": "List",
"docstring": null,
"docst... |
f01d09d0082885e96da512b8636499c5fdbed386 | mathemusician/AudioTranscription | make_xml.py | [
"MIT"
] | Python | make_xml_from_words | str | def make_xml_from_words(
word_start: List[int],
word_list: List[str],
wcps: Union[float, int],
word_end: List[int],
) -> str:
"""
makes a fcpxml file from word chunks
"""
# sanity checks
assert len(word_start) == len(word_list)
assert len(word_start) == len(word_end)
start_ge... |
makes a fcpxml file from word chunks
| makes a fcpxml file from word chunks | [
"makes",
"a",
"fcpxml",
"file",
"from",
"word",
"chunks"
] | def make_xml_from_words(
word_start: List[int],
word_list: List[str],
wcps: Union[float, int],
word_end: List[int],
) -> str:
assert len(word_start) == len(word_list)
assert len(word_start) == len(word_end)
start_gen = number_generator(word_start)
end_gen = number_generator(word_end)
... | [
"def",
"make_xml_from_words",
"(",
"word_start",
":",
"List",
"[",
"int",
"]",
",",
"word_list",
":",
"List",
"[",
"str",
"]",
",",
"wcps",
":",
"Union",
"[",
"float",
",",
"int",
"]",
",",
"word_end",
":",
"List",
"[",
"int",
"]",
",",
")",
"->",
... | makes a fcpxml file from word chunks | [
"makes",
"a",
"fcpxml",
"file",
"from",
"word",
"chunks"
] | [
"\"\"\"\n makes a fcpxml file from word chunks\n \"\"\"",
"# sanity checks",
"# convert starting chunks to fps",
"# make duration list",
"# beginning always starts at 3600 seconds"
] | [
{
"param": "word_start",
"type": "List[int]"
},
{
"param": "word_list",
"type": "List[str]"
},
{
"param": "wcps",
"type": "Union[float, int]"
},
{
"param": "word_end",
"type": "List[int]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "word_start",
"type": "List[int]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "word_list",
"type": "List[str]",
"docstring": null,
... |
4ad181bb8fbc9e752be82f7494c3c88390e5cfba | kienpt/site_discovery_public | plotting/plot_website_ranking_results/plot_ranking.py | [
"Apache-1.1"
] | Python | plot_ranking_evaluation_linechart | null | def plot_ranking_evaluation_linechart(score_file):
'''
Plot the ranking results using line chart
'''
mpl.rcParams['xtick.labelsize'] = 17
mpl.rcParams['ytick.labelsize'] = 17
#all_markers = ['+', 'o', "*", "s", "x", "h", "d", "<", ">"]
ranks = []
methods = []
ids = []
with open(s... |
Plot the ranking results using line chart
| Plot the ranking results using line chart | [
"Plot",
"the",
"ranking",
"results",
"using",
"line",
"chart"
] | def plot_ranking_evaluation_linechart(score_file):
mpl.rcParams['xtick.labelsize'] = 17
mpl.rcParams['ytick.labelsize'] = 17
ranks = []
methods = []
ids = []
with open(score_file) as lines:
for line in lines:
values = line.strip().split(",")
if values[1]=="random"... | [
"def",
"plot_ranking_evaluation_linechart",
"(",
"score_file",
")",
":",
"mpl",
".",
"rcParams",
"[",
"'xtick.labelsize'",
"]",
"=",
"17",
"mpl",
".",
"rcParams",
"[",
"'ytick.labelsize'",
"]",
"=",
"17",
"ranks",
"=",
"[",
"]",
"methods",
"=",
"[",
"]",
"... | Plot the ranking results using line chart | [
"Plot",
"the",
"ranking",
"results",
"using",
"line",
"chart"
] | [
"'''\n Plot the ranking results using line chart\n '''",
"#all_markers = ['+', 'o', \"*\", \"s\", \"x\", \"h\", \"d\", \"<\", \">\"]",
"#plt.ylim(ymin=0)",
"#plt.plot(ids[i], ranklist, marker=all_markers[i])",
"#plt.legend(names, loc='upper center', bbox_to_anchor=(0.5, 1.1), ncol=4, fancybox=True)",
... | [
{
"param": "score_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "score_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4ad181bb8fbc9e752be82f7494c3c88390e5cfba | kienpt/site_discovery_public | plotting/plot_website_ranking_results/plot_ranking.py | [
"Apache-1.1"
] | Python | plot_ranking_evaluation_barchart | null | def plot_ranking_evaluation_barchart(score_file):
"""
Plot the ranking results using bar chart
"""
data = pd.read_csv(score_file) |
Plot the ranking results using bar chart
| Plot the ranking results using bar chart | [
"Plot",
"the",
"ranking",
"results",
"using",
"bar",
"chart"
] | def plot_ranking_evaluation_barchart(score_file):
data = pd.read_csv(score_file) | [
"def",
"plot_ranking_evaluation_barchart",
"(",
"score_file",
")",
":",
"data",
"=",
"pd",
".",
"read_csv",
"(",
"score_file",
")"
] | Plot the ranking results using bar chart | [
"Plot",
"the",
"ranking",
"results",
"using",
"bar",
"chart"
] | [
"\"\"\"\n Plot the ranking results using bar chart\n \"\"\""
] | [
{
"param": "score_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "score_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8ef751dd8bc3c40d306592128c1538d0531bcf0 | kienpt/site_discovery_public | discovery/site_discovery.py | [
"Apache-1.1"
] | Python | run | null | def run(self, ranking, selection=None, online=True, max_results=50, seed_keyword="gun", searchop="kw", iters=5, representation='body', negative_file=None):
"""
seed_sites: urls that are used for search
selected_urls: urls that were used for search
Only top-ranked urls will become seed u... |
seed_sites: urls that are used for search
selected_urls: urls that were used for search
Only top-ranked urls will become seed urls
Important Args:
ranking: a ranking method
max_results: Maximum number of results to return in related and keyword search
| urls that are used for search
selected_urls: urls that were used for search
Only top-ranked urls will become seed urls
Important Args:
ranking: a ranking method
max_results: Maximum number of results to return in related and keyword search | [
"urls",
"that",
"are",
"used",
"for",
"search",
"selected_urls",
":",
"urls",
"that",
"were",
"used",
"for",
"search",
"Only",
"top",
"-",
"ranked",
"urls",
"will",
"become",
"seed",
"urls",
"Important",
"Args",
":",
"ranking",
":",
"a",
"ranking",
"method... | def run(self, ranking, selection=None, online=True, max_results=50, seed_keyword="gun", searchop="kw", iters=5, representation='body', negative_file=None):
max_pages = 1
train_sites = self.fetcher.fetch_sites(self.train_urls, max_pages, selection, online)
if negative_file:
neg_urls... | [
"def",
"run",
"(",
"self",
",",
"ranking",
",",
"selection",
"=",
"None",
",",
"online",
"=",
"True",
",",
"max_results",
"=",
"50",
",",
"seed_keyword",
"=",
"\"gun\"",
",",
"searchop",
"=",
"\"kw\"",
",",
"iters",
"=",
"5",
",",
"representation",
"="... | seed_sites: urls that are used for search
selected_urls: urls that were used for search | [
"seed_sites",
":",
"urls",
"that",
"are",
"used",
"for",
"search",
"selected_urls",
":",
"urls",
"that",
"were",
"used",
"for",
"search"
] | [
"\"\"\"\n seed_sites: urls that are used for search\n selected_urls: urls that were used for search\n\n Only top-ranked urls will become seed urls\n\n Important Args:\n ranking: a ranking method\n max_results: Maximum number of results to return in related and keywo... | [
{
"param": "self",
"type": null
},
{
"param": "ranking",
"type": null
},
{
"param": "selection",
"type": null
},
{
"param": "online",
"type": null
},
{
"param": "max_results",
"type": null
},
{
"param": "seed_keyword",
"type": null
},
{
"pa... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ranking",
"type": null,
"docstring": null,
"docstring_tokens"... |
f8ef751dd8bc3c40d306592128c1538d0531bcf0 | kienpt/site_discovery_public | discovery/site_discovery.py | [
"Apache-1.1"
] | Python | run_mix_search | null | def run_mix_search(self, ranking, selection=None, online=True, max_results=50, seed_keyword="gun", search="kw", iters=5, representation='body', negative_file=None):
"""
seed_sites: urls that are used for search
selected_urls: urls that were used for search
Only top-ranked urls will beco... |
seed_sites: urls that are used for search
selected_urls: urls that were used for search
Only top-ranked urls will become seed urls
Important Args:
ranking: a ranking method
max_results: Maximum number of results to return in related and keyword search
| urls that are used for search
selected_urls: urls that were used for search
Only top-ranked urls will become seed urls
Important Args:
ranking: a ranking method
max_results: Maximum number of results to return in related and keyword search | [
"urls",
"that",
"are",
"used",
"for",
"search",
"selected_urls",
":",
"urls",
"that",
"were",
"used",
"for",
"search",
"Only",
"top",
"-",
"ranked",
"urls",
"will",
"become",
"seed",
"urls",
"Important",
"Args",
":",
"ranking",
":",
"a",
"ranking",
"method... | def run_mix_search(self, ranking, selection=None, online=True, max_results=50, seed_keyword="gun", search="kw", iters=5, representation='body', negative_file=None):
max_pages = 1
train_sites = self.fetcher.fetch_sites(self.train_urls, max_pages, selection, online)
if negative_file:
... | [
"def",
"run_mix_search",
"(",
"self",
",",
"ranking",
",",
"selection",
"=",
"None",
",",
"online",
"=",
"True",
",",
"max_results",
"=",
"50",
",",
"seed_keyword",
"=",
"\"gun\"",
",",
"search",
"=",
"\"kw\"",
",",
"iters",
"=",
"5",
",",
"representatio... | seed_sites: urls that are used for search
selected_urls: urls that were used for search | [
"seed_sites",
":",
"urls",
"that",
"are",
"used",
"for",
"search",
"selected_urls",
":",
"urls",
"that",
"were",
"used",
"for",
"search"
] | [
"\"\"\"\n seed_sites: urls that are used for search\n selected_urls: urls that were used for search\n\n Only top-ranked urls will become seed urls\n\n Important Args:\n ranking: a ranking method\n max_results: Maximum number of results to return in related and keywo... | [
{
"param": "self",
"type": null
},
{
"param": "ranking",
"type": null
},
{
"param": "selection",
"type": null
},
{
"param": "online",
"type": null
},
{
"param": "max_results",
"type": null
},
{
"param": "seed_keyword",
"type": null
},
{
"pa... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ranking",
"type": null,
"docstring": null,
"docstring_tokens"... |
f8ef751dd8bc3c40d306592128c1538d0531bcf0 | kienpt/site_discovery_public | discovery/site_discovery.py | [
"Apache-1.1"
] | Python | make_name | <not_specific> | def make_name(args):
"""
Create name for output file
- Names are distinct from different runs
- Names are descriptive
"""
domain = args.seedfile.split('/')[-2]
name = 'result_' + domain + '_' + args.rank + '_search-' + str(args.search) + '_count-' + str(args.count) + '_' + str(time.time()) +... |
Create name for output file
- Names are distinct from different runs
- Names are descriptive
| Create name for output file
Names are distinct from different runs
Names are descriptive | [
"Create",
"name",
"for",
"output",
"file",
"Names",
"are",
"distinct",
"from",
"different",
"runs",
"Names",
"are",
"descriptive"
] | def make_name(args):
domain = args.seedfile.split('/')[-2]
name = 'result_' + domain + '_' + args.rank + '_search-' + str(args.search) + '_count-' + str(args.count) + '_' + str(time.time()) + '.csv'
return name | [
"def",
"make_name",
"(",
"args",
")",
":",
"domain",
"=",
"args",
".",
"seedfile",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"2",
"]",
"name",
"=",
"'result_'",
"+",
"domain",
"+",
"'_'",
"+",
"args",
".",
"rank",
"+",
"'_search-'",
"+",
"str",
"(... | Create name for output file
Names are distinct from different runs
Names are descriptive | [
"Create",
"name",
"for",
"output",
"file",
"Names",
"are",
"distinct",
"from",
"different",
"runs",
"Names",
"are",
"descriptive"
] | [
"\"\"\"\n Create name for output file\n - Names are distinct from different runs\n - Names are descriptive\n \"\"\""
] | [
{
"param": "args",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "args",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dbdbbd0005113e54a50f57a334dc262b05b4d789 | kienpt/site_discovery_public | ranking/cosine_similarity.py | [
"Apache-1.1"
] | Python | _reduce_dim | <not_specific> | def _reduce_dim(self, T, X):
"""
Use decomposition method to reduce dimension of the two vectors T and X.
Concatenate T and X before running NMF.
"""
TX = np.concatenate((T, X), axis=0)
print "Transforming"
transformed_X = self.model.fit_transform(TX)
pri... |
Use decomposition method to reduce dimension of the two vectors T and X.
Concatenate T and X before running NMF.
| Use decomposition method to reduce dimension of the two vectors T and X.
Concatenate T and X before running NMF. | [
"Use",
"decomposition",
"method",
"to",
"reduce",
"dimension",
"of",
"the",
"two",
"vectors",
"T",
"and",
"X",
".",
"Concatenate",
"T",
"and",
"X",
"before",
"running",
"NMF",
"."
] | def _reduce_dim(self, T, X):
TX = np.concatenate((T, X), axis=0)
print "Transforming"
transformed_X = self.model.fit_transform(TX)
print "Done transform"
split = T.shape[0]
new_T, _, new_X = np.vsplit(transformed_X, (split, split))
return new_T, new_X | [
"def",
"_reduce_dim",
"(",
"self",
",",
"T",
",",
"X",
")",
":",
"TX",
"=",
"np",
".",
"concatenate",
"(",
"(",
"T",
",",
"X",
")",
",",
"axis",
"=",
"0",
")",
"print",
"\"Transforming\"",
"transformed_X",
"=",
"self",
".",
"model",
".",
"fit_trans... | Use decomposition method to reduce dimension of the two vectors T and X.
Concatenate T and X before running NMF. | [
"Use",
"decomposition",
"method",
"to",
"reduce",
"dimension",
"of",
"the",
"two",
"vectors",
"T",
"and",
"X",
".",
"Concatenate",
"T",
"and",
"X",
"before",
"running",
"NMF",
"."
] | [
"\"\"\"\n Use decomposition method to reduce dimension of the two vectors T and X.\n Concatenate T and X before running NMF.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "T",
"type": null
},
{
"param": "X",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "T",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
dbdbbd0005113e54a50f57a334dc262b05b4d789 | kienpt/site_discovery_public | ranking/cosine_similarity.py | [
"Apache-1.1"
] | Python | _smd | <not_specific> | def _smd(self, w1, w2):
'''
Use Sum of Minimum Distance method (SMD) to compute the similarity between two sites
'''
docs1 = np.array([p.get_vsm(self.vectorizer, self.text_type) for p in w1])
docs2 = np.array([p.get_vsm(self.vectorizer, self.text_type) for p in w2])
score... |
Use Sum of Minimum Distance method (SMD) to compute the similarity between two sites
| Use Sum of Minimum Distance method (SMD) to compute the similarity between two sites | [
"Use",
"Sum",
"of",
"Minimum",
"Distance",
"method",
"(",
"SMD",
")",
"to",
"compute",
"the",
"similarity",
"between",
"two",
"sites"
] | def _smd(self, w1, w2):
docs1 = np.array([p.get_vsm(self.vectorizer, self.text_type) for p in w1])
docs2 = np.array([p.get_vsm(self.vectorizer, self.text_type) for p in w2])
scores = cosine_similarity(docs1, docs2)
max_scores1 = [0]*len(docs1)
max_scores2 = [0]*len(docs2)
... | [
"def",
"_smd",
"(",
"self",
",",
"w1",
",",
"w2",
")",
":",
"docs1",
"=",
"np",
".",
"array",
"(",
"[",
"p",
".",
"get_vsm",
"(",
"self",
".",
"vectorizer",
",",
"self",
".",
"text_type",
")",
"for",
"p",
"in",
"w1",
"]",
")",
"docs2",
"=",
"... | Use Sum of Minimum Distance method (SMD) to compute the similarity between two sites | [
"Use",
"Sum",
"of",
"Minimum",
"Distance",
"method",
"(",
"SMD",
")",
"to",
"compute",
"the",
"similarity",
"between",
"two",
"sites"
] | [
"'''\n Use Sum of Minimum Distance method (SMD) to compute the similarity between two sites\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "w1",
"type": null
},
{
"param": "w2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "w1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
9b930f68343a84588b376c99434db6201e9acf89 | kienpt/site_discovery_public | utils/website.py | [
"Apache-1.1"
] | Python | to_vector | <not_specific> | def to_vector(self, vectorizer, text_type):
"""
Transform website to a vector representation
Returns:
--------
List of real numbers as a vector
"""
if not self.pages:
return []
# Use a random page as website representation
text = self.... |
Transform website to a vector representation
Returns:
--------
List of real numbers as a vector
| Transform website to a vector representation | [
"Transform",
"website",
"to",
"a",
"vector",
"representation"
] | def to_vector(self, vectorizer, text_type):
if not self.pages:
return []
text = self.pages[0].get_text(text_type)
vsm_list = vectorizer.transform([text]).todense()
return vsm_list.tolist()[0] | [
"def",
"to_vector",
"(",
"self",
",",
"vectorizer",
",",
"text_type",
")",
":",
"if",
"not",
"self",
".",
"pages",
":",
"return",
"[",
"]",
"text",
"=",
"self",
".",
"pages",
"[",
"0",
"]",
".",
"get_text",
"(",
"text_type",
")",
"vsm_list",
"=",
"... | Transform website to a vector representation | [
"Transform",
"website",
"to",
"a",
"vector",
"representation"
] | [
"\"\"\"\n Transform website to a vector representation\n\n Returns:\n --------\n List of real numbers as a vector\n \"\"\"",
"# Use a random page as website representation"
] | [
{
"param": "self",
"type": null
},
{
"param": "vectorizer",
"type": null
},
{
"param": "text_type",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
9b930f68343a84588b376c99434db6201e9acf89 | kienpt/site_discovery_public | utils/website.py | [
"Apache-1.1"
] | Python | load_from_json | null | def load_from_json(self, json_obj):
"""
Populate data from a json object, which contains list of pages
Returns
-------
None
"""
for json_page in json_obj:
page = Page(json_page['url'])
page.load_from_json(json_page)
if not pag... |
Populate data from a json object, which contains list of pages
Returns
-------
None
| Populate data from a json object, which contains list of pages
Returns
None | [
"Populate",
"data",
"from",
"a",
"json",
"object",
"which",
"contains",
"list",
"of",
"pages",
"Returns",
"None"
] | def load_from_json(self, json_obj):
for json_page in json_obj:
page = Page(json_page['url'])
page.load_from_json(json_page)
if not page.is_empty():
self.pages.append(page) | [
"def",
"load_from_json",
"(",
"self",
",",
"json_obj",
")",
":",
"for",
"json_page",
"in",
"json_obj",
":",
"page",
"=",
"Page",
"(",
"json_page",
"[",
"'url'",
"]",
")",
"page",
".",
"load_from_json",
"(",
"json_page",
")",
"if",
"not",
"page",
".",
"... | Populate data from a json object, which contains list of pages
Returns | [
"Populate",
"data",
"from",
"a",
"json",
"object",
"which",
"contains",
"list",
"of",
"pages",
"Returns"
] | [
"\"\"\"\n Populate data from a json object, which contains list of pages\n\n Returns \n -------\n None\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "json_obj",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "json_obj",
"type": null,
"docstring": null,
"docstring_tokens... |
9b930f68343a84588b376c99434db6201e9acf89 | kienpt/site_discovery_public | utils/website.py | [
"Apache-1.1"
] | Python | is_empty | <not_specific> | def is_empty(self):
"""
Return True if the website does not have any page
"""
return False if self.pages else True |
Return True if the website does not have any page
| Return True if the website does not have any page | [
"Return",
"True",
"if",
"the",
"website",
"does",
"not",
"have",
"any",
"page"
] | def is_empty(self):
return False if self.pages else True | [
"def",
"is_empty",
"(",
"self",
")",
":",
"return",
"False",
"if",
"self",
".",
"pages",
"else",
"True"
] | Return True if the website does not have any page | [
"Return",
"True",
"if",
"the",
"website",
"does",
"not",
"have",
"any",
"page"
] | [
"\"\"\"\n Return True if the website does not have any page\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c643ffcd151ef5d94267f33ffbd64575ba51f3bb | kienpt/site_discovery_public | evaluation/evaluate.py | [
"Apache-1.1"
] | Python | evaluate_recall | null | def evaluate_recall(result_file, test_file):
""" Count number of urls in test found"""
test_host = set()
with open(test_file) as lines:
for line in lines:
url = line.strip()
#url = url_normalize(url)
host = URLUtility.get_tld(url)
test_host.add(host) ... | Count number of urls in test found | Count number of urls in test found | [
"Count",
"number",
"of",
"urls",
"in",
"test",
"found"
] | def evaluate_recall(result_file, test_file):
test_host = set()
with open(test_file) as lines:
for line in lines:
url = line.strip()
host = URLUtility.get_tld(url)
test_host.add(host)
found_host = set()
with open(result_file) as lines:
for line in lin... | [
"def",
"evaluate_recall",
"(",
"result_file",
",",
"test_file",
")",
":",
"test_host",
"=",
"set",
"(",
")",
"with",
"open",
"(",
"test_file",
")",
"as",
"lines",
":",
"for",
"line",
"in",
"lines",
":",
"url",
"=",
"line",
".",
"strip",
"(",
")",
"ho... | Count number of urls in test found | [
"Count",
"number",
"of",
"urls",
"in",
"test",
"found"
] | [
"\"\"\" Count number of urls in test found\"\"\"",
"#url = url_normalize(url)",
"#url = url_normalize(url)"
] | [
{
"param": "result_file",
"type": null
},
{
"param": "test_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "result_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "test_file",
"type": null,
"docstring": null,
"docstrin... |
c643ffcd151ef5d94267f33ffbd64575ba51f3bb | kienpt/site_discovery_public | evaluation/evaluate.py | [
"Apache-1.1"
] | Python | compute_prec | <not_specific> | def compute_prec(scores):
"""
Compute the precision at k, where k is in the range of [1,max_k]
"""
precs = []
max_k = len(scores)
for k in xrange(max_k):
prec_at_k = round(len([s for s in scores if s<=k])/float(k+1), 4)*100
precs.append(prec_at_k)
return precs |
Compute the precision at k, where k is in the range of [1,max_k]
| Compute the precision at k, where k is in the range of [1,max_k] | [
"Compute",
"the",
"precision",
"at",
"k",
"where",
"k",
"is",
"in",
"the",
"range",
"of",
"[",
"1",
"max_k",
"]"
] | def compute_prec(scores):
precs = []
max_k = len(scores)
for k in xrange(max_k):
prec_at_k = round(len([s for s in scores if s<=k])/float(k+1), 4)*100
precs.append(prec_at_k)
return precs | [
"def",
"compute_prec",
"(",
"scores",
")",
":",
"precs",
"=",
"[",
"]",
"max_k",
"=",
"len",
"(",
"scores",
")",
"for",
"k",
"in",
"xrange",
"(",
"max_k",
")",
":",
"prec_at_k",
"=",
"round",
"(",
"len",
"(",
"[",
"s",
"for",
"s",
"in",
"scores",... | Compute the precision at k, where k is in the range of [1,max_k] | [
"Compute",
"the",
"precision",
"at",
"k",
"where",
"k",
"is",
"in",
"the",
"range",
"of",
"[",
"1",
"max_k",
"]"
] | [
"\"\"\"\n Compute the precision at k, where k is in the range of [1,max_k]\n \"\"\""
] | [
{
"param": "scores",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scores",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31ff197b7db2c325054053456686d73e45bcf2e6 | kienpt/site_discovery_public | ranking/ranking.py | [
"Apache-1.1"
] | Python | update_seeds | null | def update_seeds(self, seed_urls):
'''Update seed urls in the current seed list.
Fetch the seed urls'''
new_seed_urls = []
for url in seed_urls:
host = URLUtility.get_tld(url)
if host not in self.host:
self.host.add(host)
new_seed_u... | Update seed urls in the current seed list.
Fetch the seed urls | Update seed urls in the current seed list.
Fetch the seed urls | [
"Update",
"seed",
"urls",
"in",
"the",
"current",
"seed",
"list",
".",
"Fetch",
"the",
"seed",
"urls"
] | def update_seeds(self, seed_urls):
new_seed_urls = []
for url in seed_urls:
host = URLUtility.get_tld(url)
if host not in self.host:
self.host.add(host)
new_seed_urls.append(url)
urls, text = self.fetcher.fetch_urls(new_seed_urls)
s... | [
"def",
"update_seeds",
"(",
"self",
",",
"seed_urls",
")",
":",
"new_seed_urls",
"=",
"[",
"]",
"for",
"url",
"in",
"seed_urls",
":",
"host",
"=",
"URLUtility",
".",
"get_tld",
"(",
"url",
")",
"if",
"host",
"not",
"in",
"self",
".",
"host",
":",
"se... | Update seed urls in the current seed list. | [
"Update",
"seed",
"urls",
"in",
"the",
"current",
"seed",
"list",
"."
] | [
"'''Update seed urls in the current seed list.\n Fetch the seed urls'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "seed_urls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "seed_urls",
"type": null,
"docstring": null,
"docstring_token... |
31ff197b7db2c325054053456686d73e45bcf2e6 | kienpt/site_discovery_public | ranking/ranking.py | [
"Apache-1.1"
] | Python | rank | <not_specific> | def rank(self, urls):
''' Rank the urls with respect to the seeds
Return the sorted ranking scores together with the urls'''
# Fetch the urls
urls, text = self.fetcher.fetch_urls(urls)
# Rank
knn_scores = []
scores = self.similarity.compute_similarity(text)
... | Rank the urls with respect to the seeds
Return the sorted ranking scores together with the urls | Rank the urls with respect to the seeds
Return the sorted ranking scores together with the urls | [
"Rank",
"the",
"urls",
"with",
"respect",
"to",
"the",
"seeds",
"Return",
"the",
"sorted",
"ranking",
"scores",
"together",
"with",
"the",
"urls"
] | def rank(self, urls):
urls, text = self.fetcher.fetch_urls(urls)
knn_scores = []
scores = self.similarity.compute_similarity(text)
for i in xrange(len(urls)):
sorted_scores = sorted(scores[i], reverse=True)
knn_score = sum(sorted_scores[:self.K])/float(min(self.K... | [
"def",
"rank",
"(",
"self",
",",
"urls",
")",
":",
"urls",
",",
"text",
"=",
"self",
".",
"fetcher",
".",
"fetch_urls",
"(",
"urls",
")",
"knn_scores",
"=",
"[",
"]",
"scores",
"=",
"self",
".",
"similarity",
".",
"compute_similarity",
"(",
"text",
"... | Rank the urls with respect to the seeds
Return the sorted ranking scores together with the urls | [
"Rank",
"the",
"urls",
"with",
"respect",
"to",
"the",
"seeds",
"Return",
"the",
"sorted",
"ranking",
"scores",
"together",
"with",
"the",
"urls"
] | [
"''' Rank the urls with respect to the seeds\n Return the sorted ranking scores together with the urls'''",
"# Fetch the urls",
"# Rank"
] | [
{
"param": "self",
"type": null
},
{
"param": "urls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "urls",
"type": null,
"docstring": null,
"docstring_tokens": [... |
a26947c76a606b5538b1eb91ca9fd6f5dac15cd8 | kienpt/site_discovery_public | search_apis/google_search.py | [
"Apache-1.1"
] | Python | search_site | <not_specific> | def search_site(self, keyword, url, k):
"""
Search inside a given website using the search command: "keyword site:url"
Return list of urls
"""
keyword = keyword + " site:" + url
return self.search(keyword, k) |
Search inside a given website using the search command: "keyword site:url"
Return list of urls
| Search inside a given website using the search command: "keyword site:url"
Return list of urls | [
"Search",
"inside",
"a",
"given",
"website",
"using",
"the",
"search",
"command",
":",
"\"",
"keyword",
"site",
":",
"url",
"\"",
"Return",
"list",
"of",
"urls"
] | def search_site(self, keyword, url, k):
keyword = keyword + " site:" + url
return self.search(keyword, k) | [
"def",
"search_site",
"(",
"self",
",",
"keyword",
",",
"url",
",",
"k",
")",
":",
"keyword",
"=",
"keyword",
"+",
"\" site:\"",
"+",
"url",
"return",
"self",
".",
"search",
"(",
"keyword",
",",
"k",
")"
] | Search inside a given website using the search command: "keyword site:url"
Return list of urls | [
"Search",
"inside",
"a",
"given",
"website",
"using",
"the",
"search",
"command",
":",
"\"",
"keyword",
"site",
":",
"url",
"\"",
"Return",
"list",
"of",
"urls"
] | [
"\"\"\"\n Search inside a given website using the search command: \"keyword site:url\"\n Return list of urls\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "keyword",
"type": null
},
{
"param": "url",
"type": null
},
{
"param": "k",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "keyword",
"type": null,
"docstring": null,
"docstring_tokens"... |
54c6eff86a51339f0ec550c16a85a608afef6450 | kienpt/site_discovery_public | plotting/plot_coverage/prepare_data.py | [
"Apache-1.1"
] | Python | _read_result_file | <not_specific> | def _read_result_file(result_file, max_pages):
"""
Load all sites from the result file of wdt tool
"""
sites = set()
count = 0
with open(result_file) as lines:
for line in lines:
count += 1
values = line.strip().split(",")
url = values[0]
u... |
Load all sites from the result file of wdt tool
| Load all sites from the result file of wdt tool | [
"Load",
"all",
"sites",
"from",
"the",
"result",
"file",
"of",
"wdt",
"tool"
] | def _read_result_file(result_file, max_pages):
sites = set()
count = 0
with open(result_file) as lines:
for line in lines:
count += 1
values = line.strip().split(",")
url = values[0]
url = URLUtility.normalize(url)
site = URLUtility.get_hos... | [
"def",
"_read_result_file",
"(",
"result_file",
",",
"max_pages",
")",
":",
"sites",
"=",
"set",
"(",
")",
"count",
"=",
"0",
"with",
"open",
"(",
"result_file",
")",
"as",
"lines",
":",
"for",
"line",
"in",
"lines",
":",
"count",
"+=",
"1",
"values",
... | Load all sites from the result file of wdt tool | [
"Load",
"all",
"sites",
"from",
"the",
"result",
"file",
"of",
"wdt",
"tool"
] | [
"\"\"\"\n Load all sites from the result file of wdt tool\n \"\"\""
] | [
{
"param": "result_file",
"type": null
},
{
"param": "max_pages",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "result_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max_pages",
"type": null,
"docstring": null,
"docstrin... |
54c6eff86a51339f0ec550c16a85a608afef6450 | kienpt/site_discovery_public | plotting/plot_coverage/prepare_data.py | [
"Apache-1.1"
] | Python | _read_sf_result_file | <not_specific> | def _read_sf_result_file(result_file, max_pages):
"""
Load all sites from the result file of SEEDFINDER
"""
sites = set()
count = 0
with open(result_file) as lines:
for line in lines:
count += 1
values = line.strip().split(', ')
url = values[-1]
... |
Load all sites from the result file of SEEDFINDER
| Load all sites from the result file of SEEDFINDER | [
"Load",
"all",
"sites",
"from",
"the",
"result",
"file",
"of",
"SEEDFINDER"
] | def _read_sf_result_file(result_file, max_pages):
sites = set()
count = 0
with open(result_file) as lines:
for line in lines:
count += 1
values = line.strip().split(', ')
url = values[-1]
url = URLUtility.normalize(url)
site = URLUtility.g... | [
"def",
"_read_sf_result_file",
"(",
"result_file",
",",
"max_pages",
")",
":",
"sites",
"=",
"set",
"(",
")",
"count",
"=",
"0",
"with",
"open",
"(",
"result_file",
")",
"as",
"lines",
":",
"for",
"line",
"in",
"lines",
":",
"count",
"+=",
"1",
"values... | Load all sites from the result file of SEEDFINDER | [
"Load",
"all",
"sites",
"from",
"the",
"result",
"file",
"of",
"SEEDFINDER"
] | [
"\"\"\"\n Load all sites from the result file of SEEDFINDER \n \"\"\""
] | [
{
"param": "result_file",
"type": null
},
{
"param": "max_pages",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "result_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max_pages",
"type": null,
"docstring": null,
"docstrin... |
54c6eff86a51339f0ec550c16a85a608afef6450 | kienpt/site_discovery_public | plotting/plot_coverage/prepare_data.py | [
"Apache-1.1"
] | Python | _read_ac_result_file | <not_specific> | def _read_ac_result_file(result_file, max_pages):
"""
Load all sites from the result file of ACHE
"""
count = 0
sites = set()
with open(result_file) as lines:
for line in lines:
count += 1
url = line.split()[0]
url = URLUtility.normalize(url)
... |
Load all sites from the result file of ACHE
| Load all sites from the result file of ACHE | [
"Load",
"all",
"sites",
"from",
"the",
"result",
"file",
"of",
"ACHE"
] | def _read_ac_result_file(result_file, max_pages):
count = 0
sites = set()
with open(result_file) as lines:
for line in lines:
count += 1
url = line.split()[0]
url = URLUtility.normalize(url)
site = URLUtility.get_host(url)
sites.add(site)... | [
"def",
"_read_ac_result_file",
"(",
"result_file",
",",
"max_pages",
")",
":",
"count",
"=",
"0",
"sites",
"=",
"set",
"(",
")",
"with",
"open",
"(",
"result_file",
")",
"as",
"lines",
":",
"for",
"line",
"in",
"lines",
":",
"count",
"+=",
"1",
"url",
... | Load all sites from the result file of ACHE | [
"Load",
"all",
"sites",
"from",
"the",
"result",
"file",
"of",
"ACHE"
] | [
"\"\"\"\n Load all sites from the result file of ACHE \n \"\"\""
] | [
{
"param": "result_file",
"type": null
},
{
"param": "max_pages",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "result_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max_pages",
"type": null,
"docstring": null,
"docstrin... |
54c6eff86a51339f0ec550c16a85a608afef6450 | kienpt/site_discovery_public | plotting/plot_coverage/prepare_data.py | [
"Apache-1.1"
] | Python | _read_relev_file | <not_specific> | def _read_relev_file(clf_file):
"""
Load all sites from the classification file
Note that all classification files from different discovery tools have the same format
"""
sites = set()
with open(clf_file) as lines:
for line in lines:
try:
values = line.strip()... |
Load all sites from the classification file
Note that all classification files from different discovery tools have the same format
| Load all sites from the classification file
Note that all classification files from different discovery tools have the same format | [
"Load",
"all",
"sites",
"from",
"the",
"classification",
"file",
"Note",
"that",
"all",
"classification",
"files",
"from",
"different",
"discovery",
"tools",
"have",
"the",
"same",
"format"
] | def _read_relev_file(clf_file):
sites = set()
with open(clf_file) as lines:
for line in lines:
try:
values = line.strip().split(",")
url = ''.join(values[:-1])
label = int(values[-1])
url = URLUtility.normalize(url)
... | [
"def",
"_read_relev_file",
"(",
"clf_file",
")",
":",
"sites",
"=",
"set",
"(",
")",
"with",
"open",
"(",
"clf_file",
")",
"as",
"lines",
":",
"for",
"line",
"in",
"lines",
":",
"try",
":",
"values",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split... | Load all sites from the classification file
Note that all classification files from different discovery tools have the same format | [
"Load",
"all",
"sites",
"from",
"the",
"classification",
"file",
"Note",
"that",
"all",
"classification",
"files",
"from",
"different",
"discovery",
"tools",
"have",
"the",
"same",
"format"
] | [
"\"\"\"\n Load all sites from the classification file\n Note that all classification files from different discovery tools have the same format\n \"\"\""
] | [
{
"param": "clf_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "clf_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
be539409c29d10dd5902176f15b88cd7e298c415 | kienpt/site_discovery_public | ranking/jaccard_similarity.py | [
"Apache-1.1"
] | Python | _smd | <not_specific> | def _smd(self, w1, w2):
"""
Use Sum of Minimum Distance method (SMD) to compute the similarity between two sites
"""
max_scores1 = [0]*len(w1.pages)
max_scores2 = [0]*len(w2.pages)
for i, page1 in enumerate(w1):
for j, page2 in enumerate(w2):
s... |
Use Sum of Minimum Distance method (SMD) to compute the similarity between two sites
| Use Sum of Minimum Distance method (SMD) to compute the similarity between two sites | [
"Use",
"Sum",
"of",
"Minimum",
"Distance",
"method",
"(",
"SMD",
")",
"to",
"compute",
"the",
"similarity",
"between",
"two",
"sites"
] | def _smd(self, w1, w2):
max_scores1 = [0]*len(w1.pages)
max_scores2 = [0]*len(w2.pages)
for i, page1 in enumerate(w1):
for j, page2 in enumerate(w2):
score = self._jaccard(page1.get_word_set(self.text_type), page2.get_word_set(self.text_type))
max_scor... | [
"def",
"_smd",
"(",
"self",
",",
"w1",
",",
"w2",
")",
":",
"max_scores1",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"w1",
".",
"pages",
")",
"max_scores2",
"=",
"[",
"0",
"]",
"*",
"len",
"(",
"w2",
".",
"pages",
")",
"for",
"i",
",",
"page1",
... | Use Sum of Minimum Distance method (SMD) to compute the similarity between two sites | [
"Use",
"Sum",
"of",
"Minimum",
"Distance",
"method",
"(",
"SMD",
")",
"to",
"compute",
"the",
"similarity",
"between",
"two",
"sites"
] | [
"\"\"\"\n Use Sum of Minimum Distance method (SMD) to compute the similarity between two sites\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "w1",
"type": null
},
{
"param": "w2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "w1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
be539409c29d10dd5902176f15b88cd7e298c415 | kienpt/site_discovery_public | ranking/jaccard_similarity.py | [
"Apache-1.1"
] | Python | _union | <not_specific> | def _union(self, w1, w2):
"""
Union all pages to create representation of a website
"""
score = self._jaccard(w1.get_word_set(self.text_type), w2.get_word_set(self.text_type))
return score |
Union all pages to create representation of a website
| Union all pages to create representation of a website | [
"Union",
"all",
"pages",
"to",
"create",
"representation",
"of",
"a",
"website"
] | def _union(self, w1, w2):
score = self._jaccard(w1.get_word_set(self.text_type), w2.get_word_set(self.text_type))
return score | [
"def",
"_union",
"(",
"self",
",",
"w1",
",",
"w2",
")",
":",
"score",
"=",
"self",
".",
"_jaccard",
"(",
"w1",
".",
"get_word_set",
"(",
"self",
".",
"text_type",
")",
",",
"w2",
".",
"get_word_set",
"(",
"self",
".",
"text_type",
")",
")",
"retur... | Union all pages to create representation of a website | [
"Union",
"all",
"pages",
"to",
"create",
"representation",
"of",
"a",
"website"
] | [
"\"\"\"\n Union all pages to create representation of a website\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "w1",
"type": null
},
{
"param": "w2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "w1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
be539409c29d10dd5902176f15b88cd7e298c415 | kienpt/site_discovery_public | ranking/jaccard_similarity.py | [
"Apache-1.1"
] | Python | _jaccard | <not_specific> | def _jaccard(self, s1, s2):
"""
Compute jaccard similarity between two sets
"""
if (not s1) and (not s2):
#print "Warning: two sets are empty"
return 0
return len(s1.intersection(s2))/float(len(s1.union(s2))) |
Compute jaccard similarity between two sets
| Compute jaccard similarity between two sets | [
"Compute",
"jaccard",
"similarity",
"between",
"two",
"sets"
] | def _jaccard(self, s1, s2):
if (not s1) and (not s2):
return 0
return len(s1.intersection(s2))/float(len(s1.union(s2))) | [
"def",
"_jaccard",
"(",
"self",
",",
"s1",
",",
"s2",
")",
":",
"if",
"(",
"not",
"s1",
")",
"and",
"(",
"not",
"s2",
")",
":",
"return",
"0",
"return",
"len",
"(",
"s1",
".",
"intersection",
"(",
"s2",
")",
")",
"/",
"float",
"(",
"len",
"("... | Compute jaccard similarity between two sets | [
"Compute",
"jaccard",
"similarity",
"between",
"two",
"sets"
] | [
"\"\"\"\n Compute jaccard similarity between two sets\n \"\"\"",
"#print \"Warning: two sets are empty\""
] | [
{
"param": "self",
"type": null
},
{
"param": "s1",
"type": null
},
{
"param": "s2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "s1",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
4490d8d10342bbbba711b919dad03fc6224cda9f | kienpt/site_discovery_public | extraction/text_extractor.py | [
"Apache-1.1"
] | Python | extract_body_with_boilerpipe | <not_specific> | def extract_body_with_boilerpipe(html):
"""
Extractor types:
DefaultExtractor
ArticleExtractor
ArticleSentencesExtractor
KeepEverythingExtractor
KeepEverythingWithMinKWordsExtractor
LargestContentExtractor
... |
Extractor types:
DefaultExtractor
ArticleExtractor
ArticleSentencesExtractor
KeepEverythingExtractor
KeepEverythingWithMinKWordsExtractor
LargestContentExtractor
NumWordsRulesExtractor
... |
Returns
extracted body text. Return empty string if extraction fails | [
"Returns",
"extracted",
"body",
"text",
".",
"Return",
"empty",
"string",
"if",
"extraction",
"fails"
] | def extract_body_with_boilerpipe(html):
try:
extractor = Extractor(extractor='KeepEverythingExtractor', html=html)
extracted_text = extractor.getText()
except:
print "Failed to extract text with boilerpipe"
extracted_text = ""
return extracted_text | [
"def",
"extract_body_with_boilerpipe",
"(",
"html",
")",
":",
"try",
":",
"extractor",
"=",
"Extractor",
"(",
"extractor",
"=",
"'KeepEverythingExtractor'",
",",
"html",
"=",
"html",
")",
"extracted_text",
"=",
"extractor",
".",
"getText",
"(",
")",
"except",
... | Extractor types:
DefaultExtractor
ArticleExtractor
ArticleSentencesExtractor
KeepEverythingExtractor
KeepEverythingWithMinKWordsExtractor
LargestContentExtractor
NumWordsRulesExtractor
CanolaExtractor
Reference: https://github.com/misja/python-boilerpipe
Note: set JAVA_HOME if import fails | [
"Extractor",
"types",
":",
"DefaultExtractor",
"ArticleExtractor",
"ArticleSentencesExtractor",
"KeepEverythingExtractor",
"KeepEverythingWithMinKWordsExtractor",
"LargestContentExtractor",
"NumWordsRulesExtractor",
"CanolaExtractor",
"Reference",
":",
"https",
":",
"//",
"github",
... | [
"\"\"\"\n Extractor types:\n DefaultExtractor\n ArticleExtractor\n ArticleSentencesExtractor\n KeepEverythingExtractor\n KeepEverythingWithMinKWordsExtractor\n LargestContentExtractor\n NumWordsRulesExtra... | [
{
"param": "html",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "html",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b2717266348b82a994dfb86d1575cabcd5636620 | kienpt/site_discovery_public | ranking/pu_learning.py | [
"Apache-1.1"
] | Python | score | <not_specific> | def score(self, websites):
"""
Note: Use all unlabelled websites as negatives but no more than 20x the positives """
"""
neg = np.array([w.get_vsm(self.vectorizer, self.text_type) for w in websites])
neg = self._convert_to_svmlight(neg, -1)
if not self.model:
... |
Note: Use all unlabelled websites as negatives but no more than 20x the positives | Use all unlabelled websites as negatives but no more than 20x the positives | [
"Use",
"all",
"unlabelled",
"websites",
"as",
"negatives",
"but",
"no",
"more",
"than",
"20x",
"the",
"positives"
] | def score(self, websites):
print "Scoring..."
if not self.clf:
print "Error. Classifier must be trained"
test = np.array([w.get_vsm(self.vectorizer, self.text_type) for w in websites])
test = self._convert_to_svmlight(test, -1)
predicts = svmlight.classify(self.clf,... | [
"def",
"score",
"(",
"self",
",",
"websites",
")",
":",
"\"\"\"\n neg = np.array([w.get_vsm(self.vectorizer, self.text_type) for w in websites])\n neg = self._convert_to_svmlight(neg, -1)\n\n if not self.model:\n max_neg = min(20*len(self.pos), len(neg))\n ... | Note: Use all unlabelled websites as negatives but no more than 20x the positives | [
"Note",
":",
"Use",
"all",
"unlabelled",
"websites",
"as",
"negatives",
"but",
"no",
"more",
"than",
"20x",
"the",
"positives"
] | [
"\"\"\"\n Note: Use all unlabelled websites as negatives but no more than 20x the positives \"\"\"",
"\"\"\"\n neg = np.array([w.get_vsm(self.vectorizer, self.text_type) for w in websites])\n neg = self._convert_to_svmlight(neg, -1)\n\n if not self.model:\n max_neg = min(20*... | [
{
"param": "self",
"type": null
},
{
"param": "websites",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "websites",
"type": null,
"docstring": null,
"docstring_tokens... |
176003f2f5a9e533cb93909d292b4e24b4916eee | kienpt/site_discovery_public | data/candidates/dmoz/sampling/sample_urls.py | [
"Apache-1.1"
] | Python | filter_duplicate_sites | null | def filter_duplicate_sites():
"""
Read urls from infile and output one url for each site
"""
infile = sys.argv[1]
outfile = sys.argv[2]
out = open(outfile, "w")
sites = set()
with open(infile) as lines:
for line in lines:
url = line.strip()
s = URLUti... |
Read urls from infile and output one url for each site
| Read urls from infile and output one url for each site | [
"Read",
"urls",
"from",
"infile",
"and",
"output",
"one",
"url",
"for",
"each",
"site"
] | def filter_duplicate_sites():
infile = sys.argv[1]
outfile = sys.argv[2]
out = open(outfile, "w")
sites = set()
with open(infile) as lines:
for line in lines:
url = line.strip()
s = URLUtility.get_host(url)
if s not in sites:
out.write(s + ... | [
"def",
"filter_duplicate_sites",
"(",
")",
":",
"infile",
"=",
"sys",
".",
"argv",
"[",
"1",
"]",
"outfile",
"=",
"sys",
".",
"argv",
"[",
"2",
"]",
"out",
"=",
"open",
"(",
"outfile",
",",
"\"w\"",
")",
"sites",
"=",
"set",
"(",
")",
"with",
"op... | Read urls from infile and output one url for each site | [
"Read",
"urls",
"from",
"infile",
"and",
"output",
"one",
"url",
"for",
"each",
"site"
] | [
"\"\"\"\n Read urls from infile and output one url for each site\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
90fa62ff733bed285df5de1e2d26a3d6b5b9d613 | kienpt/site_discovery_public | utils/fetcher.py | [
"Apache-1.1"
] | Python | fetch | null | def fetch(self, urls, out_file, extraction=True):
"""
Parameters:
-----------
urls: list of url. Each url represents a website
Returns:
--------
list<website>: list of fetched websites
"""
if os.path.exists(out_file):
fetched_urls = []... |
Parameters:
-----------
urls: list of url. Each url represents a website
Returns:
--------
list<website>: list of fetched websites
| list of url. Each url represents a website
list: list of fetched websites | [
"list",
"of",
"url",
".",
"Each",
"url",
"represents",
"a",
"website",
"list",
":",
"list",
"of",
"fetched",
"websites"
] | def fetch(self, urls, out_file, extraction=True):
if os.path.exists(out_file):
fetched_urls = []
with open(out_file) as lines:
for line in lines:
try:
jsobj = json.loads(line)
fetched_urls.append(jsobj['u... | [
"def",
"fetch",
"(",
"self",
",",
"urls",
",",
"out_file",
",",
"extraction",
"=",
"True",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"out_file",
")",
":",
"fetched_urls",
"=",
"[",
"]",
"with",
"open",
"(",
"out_file",
")",
"as",
"line... | Parameters:
urls: list of url. | [
"Parameters",
":",
"urls",
":",
"list",
"of",
"url",
"."
] | [
"\"\"\"\n Parameters:\n -----------\n urls: list of url. Each url represents a website\n\n Returns:\n --------\n list<website>: list of fetched websites\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "urls",
"type": null
},
{
"param": "out_file",
"type": null
},
{
"param": "extraction",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "urls",
"type": null,
"docstring": null,
"docstring_tokens": [... |
55275da2a7746c84f25db9f8f6354682fe8101e5 | kienpt/site_discovery_public | discovery/discovery.py | [
"Apache-1.1"
] | Python | discover_with_backlink_search | null | def discover_with_backlink_search(self):
'''url discovery using moz backlink search'''
next_urls = [(-1.0, url) for url in self.seed_urls] # negate the scores to turn minheap into maxheap
heapq.heapify(next_urls) # make next_urls be priority queue
new_discovered_urls = [] # urls with r... | url discovery using moz backlink search | url discovery using moz backlink search | [
"url",
"discovery",
"using",
"moz",
"backlink",
"search"
] | def discover_with_backlink_search(self):
next_urls = [(-1.0, url) for url in self.seed_urls]
heapq.heapify(next_urls)
new_discovered_urls = []
ranked_urls = []
while next_urls:
seed = heapq.heappop(next_urls)[1]
results = self.searcher.search_related... | [
"def",
"discover_with_backlink_search",
"(",
"self",
")",
":",
"next_urls",
"=",
"[",
"(",
"-",
"1.0",
",",
"url",
")",
"for",
"url",
"in",
"self",
".",
"seed_urls",
"]",
"heapq",
".",
"heapify",
"(",
"next_urls",
")",
"new_discovered_urls",
"=",
"[",
"]... | url discovery using moz backlink search | [
"url",
"discovery",
"using",
"moz",
"backlink",
"search"
] | [
"'''url discovery using moz backlink search'''",
"# negate the scores to turn minheap into maxheap",
"# make next_urls be priority queue",
"# urls with relevant scores",
"# discovered urls with ranking scores",
"# Rank the discovered urls"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
55275da2a7746c84f25db9f8f6354682fe8101e5 | kienpt/site_discovery_public | discovery/discovery.py | [
"Apache-1.1"
] | Python | discover_with_related_search | null | def discover_with_related_search(self):
'''url discovery using google related search'''
next_urls = [(-1.0, url) for url in self.seed_urls] # negate the scores to turn minheap into maxheap
heapq.heapify(next_urls) # make next_urls be priority queue
new_discovered_urls = [] # urls with ... | url discovery using google related search | url discovery using google related search | [
"url",
"discovery",
"using",
"google",
"related",
"search"
] | def discover_with_related_search(self):
next_urls = [(-1.0, url) for url in self.seed_urls]
heapq.heapify(next_urls)
new_discovered_urls = []
ranked_urls = []
while next_urls:
seed = heapq.heappop(next_urls)[1]
results = self.searcher.search_related(... | [
"def",
"discover_with_related_search",
"(",
"self",
")",
":",
"next_urls",
"=",
"[",
"(",
"-",
"1.0",
",",
"url",
")",
"for",
"url",
"in",
"self",
".",
"seed_urls",
"]",
"heapq",
".",
"heapify",
"(",
"next_urls",
")",
"new_discovered_urls",
"=",
"[",
"]"... | url discovery using google related search | [
"url",
"discovery",
"using",
"google",
"related",
"search"
] | [
"'''url discovery using google related search'''",
"# negate the scores to turn minheap into maxheap",
"# make next_urls be priority queue",
"# urls with relevant scores",
"# discovered urls with ranking scores",
"# Rank the discovered urls"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.