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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9a10cb58e2a7df28a86f014d35ca80f33cf838be | JennySnyk/msticpy | msticpy/sectools/tiproviders/ti_provider_base.py | [
"MIT"
] | Python | supported_types | List[str] | def supported_types(self) -> List[str]:
"""
Return list of supported IoC types for this provider.
Returns
-------
List[str]
List of supported type names
"""
return [ioc.name for ioc in self._supported_types] |
Return list of supported IoC types for this provider.
Returns
-------
List[str]
List of supported type names
| Return list of supported IoC types for this provider.
Returns
List[str]
List of supported type names | [
"Return",
"list",
"of",
"supported",
"IoC",
"types",
"for",
"this",
"provider",
".",
"Returns",
"List",
"[",
"str",
"]",
"List",
"of",
"supported",
"type",
"names"
] | def supported_types(self) -> List[str]:
return [ioc.name for ioc in self._supported_types] | [
"def",
"supported_types",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"ioc",
".",
"name",
"for",
"ioc",
"in",
"self",
".",
"_supported_types",
"]"
] | Return list of supported IoC types for this provider. | [
"Return",
"list",
"of",
"supported",
"IoC",
"types",
"for",
"this",
"provider",
"."
] | [
"\"\"\"\n Return list of supported IoC types for this provider.\n\n Returns\n -------\n List[str]\n List of supported type names\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9a10cb58e2a7df28a86f014d35ca80f33cf838be | JennySnyk/msticpy | msticpy/sectools/tiproviders/ti_provider_base.py | [
"MIT"
] | Python | ioc_query_defs | Dict[str, Any] | def ioc_query_defs(self) -> Dict[str, Any]:
"""
Return current dictionary of IoC query/request definitions.
Returns
-------
Dict[str, Any]
IoC query/requist definitions keyed by IoCType
"""
return self._IOC_QUERIES |
Return current dictionary of IoC query/request definitions.
Returns
-------
Dict[str, Any]
IoC query/requist definitions keyed by IoCType
| Return current dictionary of IoC query/request definitions.
Returns
Dict[str, Any]
IoC query/requist definitions keyed by IoCType | [
"Return",
"current",
"dictionary",
"of",
"IoC",
"query",
"/",
"request",
"definitions",
".",
"Returns",
"Dict",
"[",
"str",
"Any",
"]",
"IoC",
"query",
"/",
"requist",
"definitions",
"keyed",
"by",
"IoCType"
] | def ioc_query_defs(self) -> Dict[str, Any]:
return self._IOC_QUERIES | [
"def",
"ioc_query_defs",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"self",
".",
"_IOC_QUERIES"
] | Return current dictionary of IoC query/request definitions. | [
"Return",
"current",
"dictionary",
"of",
"IoC",
"query",
"/",
"request",
"definitions",
"."
] | [
"\"\"\"\n Return current dictionary of IoC query/request definitions.\n\n Returns\n -------\n Dict[str, Any]\n IoC query/requist definitions keyed by IoCType\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9a10cb58e2a7df28a86f014d35ca80f33cf838be | JennySnyk/msticpy | msticpy/sectools/tiproviders/ti_provider_base.py | [
"MIT"
] | Python | preprocess_observable | SanitizedObservable | def preprocess_observable(
observable, ioc_type, require_url_encoding: bool = False
) -> SanitizedObservable:
"""
Preprocesses and checks validity of observable against declared IoC type.
:param observable: the value of the IoC
:param ioc_type: the IoC type
"""
observable = observab... |
Preprocesses and checks validity of observable against declared IoC type.
:param observable: the value of the IoC
:param ioc_type: the IoC type
| Preprocesses and checks validity of observable against declared IoC type.
:param observable: the value of the IoC
:param ioc_type: the IoC type | [
"Preprocesses",
"and",
"checks",
"validity",
"of",
"observable",
"against",
"declared",
"IoC",
"type",
".",
":",
"param",
"observable",
":",
"the",
"value",
"of",
"the",
"IoC",
":",
"param",
"ioc_type",
":",
"the",
"IoC",
"type"
] | def preprocess_observable(
observable, ioc_type, require_url_encoding: bool = False
) -> SanitizedObservable:
observable = observable.strip()
try:
validated = _IOC_EXTRACT.validate(observable, ioc_type)
except KeyError:
validated = False
if not validated:
return SanitizedObse... | [
"def",
"preprocess_observable",
"(",
"observable",
",",
"ioc_type",
",",
"require_url_encoding",
":",
"bool",
"=",
"False",
")",
"->",
"SanitizedObservable",
":",
"observable",
"=",
"observable",
".",
"strip",
"(",
")",
"try",
":",
"validated",
"=",
"_IOC_EXTRAC... | Preprocesses and checks validity of observable against declared IoC type. | [
"Preprocesses",
"and",
"checks",
"validity",
"of",
"observable",
"against",
"declared",
"IoC",
"type",
"."
] | [
"\"\"\"\n Preprocesses and checks validity of observable against declared IoC type.\n\n :param observable: the value of the IoC\n :param ioc_type: the IoC type\n \"\"\""
] | [
{
"param": "observable",
"type": null
},
{
"param": "ioc_type",
"type": null
},
{
"param": "require_url_encoding",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "observable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ioc_type",
"type": null,
"docstring": null,
"docstring_... |
9a10cb58e2a7df28a86f014d35ca80f33cf838be | JennySnyk/msticpy | msticpy/sectools/tiproviders/ti_provider_base.py | [
"MIT"
] | Python | _clean_url | Optional[str] | def _clean_url(url: str) -> Optional[str]:
"""
Clean URL to remove query params and fragments and any trailing stuff.
Parameters
----------
url : str
the URL to check
Returns
-------
Optional[str]
Cleaned URL or None if the input was not a valid URL
"""
# Try t... |
Clean URL to remove query params and fragments and any trailing stuff.
Parameters
----------
url : str
the URL to check
Returns
-------
Optional[str]
Cleaned URL or None if the input was not a valid URL
| Clean URL to remove query params and fragments and any trailing stuff.
Parameters
url : str
the URL to check
Returns
Optional[str]
Cleaned URL or None if the input was not a valid URL | [
"Clean",
"URL",
"to",
"remove",
"query",
"params",
"and",
"fragments",
"and",
"any",
"trailing",
"stuff",
".",
"Parameters",
"url",
":",
"str",
"the",
"URL",
"to",
"check",
"Returns",
"Optional",
"[",
"str",
"]",
"Cleaned",
"URL",
"or",
"None",
"if",
"th... | def _clean_url(url: str) -> Optional[str]:
match_url = _HTTP_STRICT_RGXC.search(url)
if (
not match_url
or match_url.groupdict()["protocol"] is None
or match_url.groupdict()["host"] is None
):
return None
clean_url = match_url.groupdict()["protocol"]
if match_url.grou... | [
"def",
"_clean_url",
"(",
"url",
":",
"str",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"match_url",
"=",
"_HTTP_STRICT_RGXC",
".",
"search",
"(",
"url",
")",
"if",
"(",
"not",
"match_url",
"or",
"match_url",
".",
"groupdict",
"(",
")",
"[",
"\"proto... | Clean URL to remove query params and fragments and any trailing stuff. | [
"Clean",
"URL",
"to",
"remove",
"query",
"params",
"and",
"fragments",
"and",
"any",
"trailing",
"stuff",
"."
] | [
"\"\"\"\n Clean URL to remove query params and fragments and any trailing stuff.\n\n Parameters\n ----------\n url : str\n the URL to check\n\n Returns\n -------\n Optional[str]\n Cleaned URL or None if the input was not a valid URL\n\n \"\"\"",
"# Try to clean URL and re-che... | [
{
"param": "url",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9a10cb58e2a7df28a86f014d35ca80f33cf838be | JennySnyk/msticpy | msticpy/sectools/tiproviders/ti_provider_base.py | [
"MIT"
] | Python | _preprocess_ip | <not_specific> | def _preprocess_ip(ipaddress: str, version=4):
"""Ensure Ip address is a valid public IPv4 address."""
try:
addr = ip_address(ipaddress)
except ValueError:
return SanitizedObservable(None, "IP address is invalid format")
if version == 4 and not isinstance(addr, IPv4Address):
ret... | Ensure Ip address is a valid public IPv4 address. | Ensure Ip address is a valid public IPv4 address. | [
"Ensure",
"Ip",
"address",
"is",
"a",
"valid",
"public",
"IPv4",
"address",
"."
] | def _preprocess_ip(ipaddress: str, version=4):
try:
addr = ip_address(ipaddress)
except ValueError:
return SanitizedObservable(None, "IP address is invalid format")
if version == 4 and not isinstance(addr, IPv4Address):
return SanitizedObservable(None, "Not an IPv4 address")
if v... | [
"def",
"_preprocess_ip",
"(",
"ipaddress",
":",
"str",
",",
"version",
"=",
"4",
")",
":",
"try",
":",
"addr",
"=",
"ip_address",
"(",
"ipaddress",
")",
"except",
"ValueError",
":",
"return",
"SanitizedObservable",
"(",
"None",
",",
"\"IP address is invalid fo... | Ensure Ip address is a valid public IPv4 address. | [
"Ensure",
"Ip",
"address",
"is",
"a",
"valid",
"public",
"IPv4",
"address",
"."
] | [
"\"\"\"Ensure Ip address is a valid public IPv4 address.\"\"\""
] | [
{
"param": "ipaddress",
"type": "str"
},
{
"param": "version",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ipaddress",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "version",
"type": null,
"docstring": null,
"docstring_t... |
9a10cb58e2a7df28a86f014d35ca80f33cf838be | JennySnyk/msticpy | msticpy/sectools/tiproviders/ti_provider_base.py | [
"MIT"
] | Python | _preprocess_dns | SanitizedObservable | def _preprocess_dns(domain: str) -> SanitizedObservable:
"""Ensure DNS is a valid-looking domain."""
if "." not in domain:
return SanitizedObservable(None, "Domain is unqualified domain name")
try:
addr = ip_address(domain)
del addr
return SanitizedObservable(None, "Domain is... | Ensure DNS is a valid-looking domain. | Ensure DNS is a valid-looking domain. | [
"Ensure",
"DNS",
"is",
"a",
"valid",
"-",
"looking",
"domain",
"."
] | def _preprocess_dns(domain: str) -> SanitizedObservable:
if "." not in domain:
return SanitizedObservable(None, "Domain is unqualified domain name")
try:
addr = ip_address(domain)
del addr
return SanitizedObservable(None, "Domain is an IP address")
except ValueError:
... | [
"def",
"_preprocess_dns",
"(",
"domain",
":",
"str",
")",
"->",
"SanitizedObservable",
":",
"if",
"\".\"",
"not",
"in",
"domain",
":",
"return",
"SanitizedObservable",
"(",
"None",
",",
"\"Domain is unqualified domain name\"",
")",
"try",
":",
"addr",
"=",
"ip_a... | Ensure DNS is a valid-looking domain. | [
"Ensure",
"DNS",
"is",
"a",
"valid",
"-",
"looking",
"domain",
"."
] | [
"\"\"\"Ensure DNS is a valid-looking domain.\"\"\""
] | [
{
"param": "domain",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "domain",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9a10cb58e2a7df28a86f014d35ca80f33cf838be | JennySnyk/msticpy | msticpy/sectools/tiproviders/ti_provider_base.py | [
"MIT"
] | Python | _preprocess_hash | SanitizedObservable | def _preprocess_hash(hash_str: str) -> SanitizedObservable:
"""Ensure Hash has minimum entropy (rather than a string of 'x')."""
str_entropy = entropy(hash_str)
if str_entropy < 3.0:
return SanitizedObservable(None, "String has too low an entropy to be a hash")
return SanitizedObservable(hash_st... | Ensure Hash has minimum entropy (rather than a string of 'x'). | Ensure Hash has minimum entropy (rather than a string of 'x'). | [
"Ensure",
"Hash",
"has",
"minimum",
"entropy",
"(",
"rather",
"than",
"a",
"string",
"of",
"'",
"x",
"'",
")",
"."
] | def _preprocess_hash(hash_str: str) -> SanitizedObservable:
str_entropy = entropy(hash_str)
if str_entropy < 3.0:
return SanitizedObservable(None, "String has too low an entropy to be a hash")
return SanitizedObservable(hash_str, "ok") | [
"def",
"_preprocess_hash",
"(",
"hash_str",
":",
"str",
")",
"->",
"SanitizedObservable",
":",
"str_entropy",
"=",
"entropy",
"(",
"hash_str",
")",
"if",
"str_entropy",
"<",
"3.0",
":",
"return",
"SanitizedObservable",
"(",
"None",
",",
"\"String has too low an en... | Ensure Hash has minimum entropy (rather than a string of 'x'). | [
"Ensure",
"Hash",
"has",
"minimum",
"entropy",
"(",
"rather",
"than",
"a",
"string",
"of",
"'",
"x",
"'",
")",
"."
] | [
"\"\"\"Ensure Hash has minimum entropy (rather than a string of 'x').\"\"\""
] | [
{
"param": "hash_str",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hash_str",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9a10cb58e2a7df28a86f014d35ca80f33cf838be | JennySnyk/msticpy | msticpy/sectools/tiproviders/ti_provider_base.py | [
"MIT"
] | Python | entropy | float | def entropy(input_str: str) -> float:
"""Compute entropy of input string."""
str_len = float(len(input_str))
return -sum(
map(
lambda a: (a / str_len) * math.log2(a / str_len),
Counter(input_str).values(),
)
) | Compute entropy of input string. | Compute entropy of input string. | [
"Compute",
"entropy",
"of",
"input",
"string",
"."
] | def entropy(input_str: str) -> float:
str_len = float(len(input_str))
return -sum(
map(
lambda a: (a / str_len) * math.log2(a / str_len),
Counter(input_str).values(),
)
) | [
"def",
"entropy",
"(",
"input_str",
":",
"str",
")",
"->",
"float",
":",
"str_len",
"=",
"float",
"(",
"len",
"(",
"input_str",
")",
")",
"return",
"-",
"sum",
"(",
"map",
"(",
"lambda",
"a",
":",
"(",
"a",
"/",
"str_len",
")",
"*",
"math",
".",
... | Compute entropy of input string. | [
"Compute",
"entropy",
"of",
"input",
"string",
"."
] | [
"\"\"\"Compute entropy of input string.\"\"\""
] | [
{
"param": "input_str",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_str",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5b3bf88ea440a5fca5a284c695816174a094aa3a | JennySnyk/msticpy | msticpy/nbtools/azure_ml_tools.py | [
"MIT"
] | Python | check_versions | <not_specific> | def check_versions(
min_py_ver: Union[str, Tuple] = MIN_PYTHON_VER_DEF,
min_mp_ver: Union[str, Tuple] = MSTICPY_REQ_VERSION,
extras: Optional[List[str]] = None,
mp_release: Optional[str] = None,
**kwargs,
):
"""
Check the current versions of the Python kernel and MSTICPy.
Parameters
... |
Check the current versions of the Python kernel and MSTICPy.
Parameters
----------
min_py_ver : Union[Tuple[int, int], str]
Minimum Python version
min_mp_ver : Union[Tuple[int, int], str]
Minimum MSTICPy version
extras : Optional[List[str]], optional
A list of extras re... | Check the current versions of the Python kernel and MSTICPy.
Parameters
Raises
RuntimeError
If the Python version does not support the notebook.
If the MSTICPy version does not support the notebook
and the user chose not to upgrade | [
"Check",
"the",
"current",
"versions",
"of",
"the",
"Python",
"kernel",
"and",
"MSTICPy",
".",
"Parameters",
"Raises",
"RuntimeError",
"If",
"the",
"Python",
"version",
"does",
"not",
"support",
"the",
"notebook",
".",
"If",
"the",
"MSTICPy",
"version",
"does"... | def check_versions(
min_py_ver: Union[str, Tuple] = MIN_PYTHON_VER_DEF,
min_mp_ver: Union[str, Tuple] = MSTICPY_REQ_VERSION,
extras: Optional[List[str]] = None,
mp_release: Optional[str] = None,
**kwargs,
):
del kwargs
_disp_html("<h4>Starting notebook pre-checks...</h4>")
if isinstance(... | [
"def",
"check_versions",
"(",
"min_py_ver",
":",
"Union",
"[",
"str",
",",
"Tuple",
"]",
"=",
"MIN_PYTHON_VER_DEF",
",",
"min_mp_ver",
":",
"Union",
"[",
"str",
",",
"Tuple",
"]",
"=",
"MSTICPY_REQ_VERSION",
",",
"extras",
":",
"Optional",
"[",
"List",
"["... | Check the current versions of the Python kernel and MSTICPy. | [
"Check",
"the",
"current",
"versions",
"of",
"the",
"Python",
"kernel",
"and",
"MSTICPy",
"."
] | [
"\"\"\"\n Check the current versions of the Python kernel and MSTICPy.\n\n Parameters\n ----------\n min_py_ver : Union[Tuple[int, int], str]\n Minimum Python version\n min_mp_ver : Union[Tuple[int, int], str]\n Minimum MSTICPy version\n extras : Optional[List[str]], optional\n ... | [
{
"param": "min_py_ver",
"type": "Union[str, Tuple]"
},
{
"param": "min_mp_ver",
"type": "Union[str, Tuple]"
},
{
"param": "extras",
"type": "Optional[List[str]]"
},
{
"param": "mp_release",
"type": "Optional[str]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "min_py_ver",
"type": "Union[str, Tuple]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "min_mp_ver",
"type": "Union[str, Tuple]",
"doc... |
5b3bf88ea440a5fca5a284c695816174a094aa3a | JennySnyk/msticpy | msticpy/nbtools/azure_ml_tools.py | [
"MIT"
] | Python | _check_mp_install | null | def _check_mp_install(
min_mp_ver: Union[str, Tuple],
mp_release: Optional[str],
extras: Optional[List[str]],
):
"""Check for and try to install required MSTICPy version."""
# Use the release ver specified in params, in the environment or
# the notebook default.
pkg_version = _get_pkg_versio... | Check for and try to install required MSTICPy version. | Check for and try to install required MSTICPy version. | [
"Check",
"for",
"and",
"try",
"to",
"install",
"required",
"MSTICPy",
"version",
"."
] | def _check_mp_install(
min_mp_ver: Union[str, Tuple],
mp_release: Optional[str],
extras: Optional[List[str]],
):
pkg_version = _get_pkg_version(min_mp_ver)
mp_install_version = mp_release or os.environ.get("MP_TEST_VER") or str(pkg_version)
check_mp_ver(min_msticpy_ver=mp_install_version, extras... | [
"def",
"_check_mp_install",
"(",
"min_mp_ver",
":",
"Union",
"[",
"str",
",",
"Tuple",
"]",
",",
"mp_release",
":",
"Optional",
"[",
"str",
"]",
",",
"extras",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
",",
")",
":",
"pkg_version",
"=",
"_g... | Check for and try to install required MSTICPy version. | [
"Check",
"for",
"and",
"try",
"to",
"install",
"required",
"MSTICPy",
"version",
"."
] | [
"\"\"\"Check for and try to install required MSTICPy version.\"\"\"",
"# Use the release ver specified in params, in the environment or",
"# the notebook default."
] | [
{
"param": "min_mp_ver",
"type": "Union[str, Tuple]"
},
{
"param": "mp_release",
"type": "Optional[str]"
},
{
"param": "extras",
"type": "Optional[List[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "min_mp_ver",
"type": "Union[str, Tuple]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mp_release",
"type": "Optional[str]",
"docstri... |
5b3bf88ea440a5fca5a284c695816174a094aa3a | JennySnyk/msticpy | msticpy/nbtools/azure_ml_tools.py | [
"MIT"
] | Python | check_mp_ver | null | def check_mp_ver(min_msticpy_ver: Union[str, Tuple], extras: Optional[List[str]]):
"""
Check and optionally update the current version of msticpy.
Parameters
----------
min_msticpy_ver : Tuple[int, int]
Minimum MSTICPy version
extras : Optional[List[str]], optional
A list of ext... |
Check and optionally update the current version of msticpy.
Parameters
----------
min_msticpy_ver : Tuple[int, int]
Minimum MSTICPy version
extras : Optional[List[str]], optional
A list of extras required for MSTICPy
Raises
------
ImportError
If MSTICPy version... | Check and optionally update the current version of msticpy.
Parameters
min_msticpy_ver : Tuple[int, int]
Minimum MSTICPy version
extras : Optional[List[str]], optional
A list of extras required for MSTICPy
Raises
ImportError
If MSTICPy version is insufficient and we need to upgrade | [
"Check",
"and",
"optionally",
"update",
"the",
"current",
"version",
"of",
"msticpy",
".",
"Parameters",
"min_msticpy_ver",
":",
"Tuple",
"[",
"int",
"int",
"]",
"Minimum",
"MSTICPy",
"version",
"extras",
":",
"Optional",
"[",
"List",
"[",
"str",
"]]",
"opti... | def check_mp_ver(min_msticpy_ver: Union[str, Tuple], extras: Optional[List[str]]):
mp_min_pkg_ver = _get_pkg_version(min_msticpy_ver)
_disp_html("Checking msticpy version...<br>")
inst_version = _get_pkg_version(__version__)
if inst_version < mp_min_pkg_ver:
_disp_html(
MISSING_PKG_E... | [
"def",
"check_mp_ver",
"(",
"min_msticpy_ver",
":",
"Union",
"[",
"str",
",",
"Tuple",
"]",
",",
"extras",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
")",
":",
"mp_min_pkg_ver",
"=",
"_get_pkg_version",
"(",
"min_msticpy_ver",
")",
"_disp_html",
"... | Check and optionally update the current version of msticpy. | [
"Check",
"and",
"optionally",
"update",
"the",
"current",
"version",
"of",
"msticpy",
"."
] | [
"\"\"\"\n Check and optionally update the current version of msticpy.\n\n Parameters\n ----------\n min_msticpy_ver : Tuple[int, int]\n Minimum MSTICPy version\n extras : Optional[List[str]], optional\n A list of extras required for MSTICPy\n\n Raises\n ------\n ImportError\n ... | [
{
"param": "min_msticpy_ver",
"type": "Union[str, Tuple]"
},
{
"param": "extras",
"type": "Optional[List[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "min_msticpy_ver",
"type": "Union[str, Tuple]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "extras",
"type": "Optional[List[str]]",
"... |
5b3bf88ea440a5fca5a284c695816174a094aa3a | JennySnyk/msticpy | msticpy/nbtools/azure_ml_tools.py | [
"MIT"
] | Python | _set_kql_env_vars | null | def _set_kql_env_vars(extras: Optional[List[str]]):
"""Set environment variables for Kqlmagic based on MP extras."""
jp_extended = ("azsentinel", "azuresentinel", "kql")
if extras and any(extra for extra in extras if extra in jp_extended):
os.environ["KQLMAGIC_EXTRAS_REQUIRE"] = "jupyter-extended"
... | Set environment variables for Kqlmagic based on MP extras. | Set environment variables for Kqlmagic based on MP extras. | [
"Set",
"environment",
"variables",
"for",
"Kqlmagic",
"based",
"on",
"MP",
"extras",
"."
] | def _set_kql_env_vars(extras: Optional[List[str]]):
jp_extended = ("azsentinel", "azuresentinel", "kql")
if extras and any(extra for extra in extras if extra in jp_extended):
os.environ["KQLMAGIC_EXTRAS_REQUIRE"] = "jupyter-extended"
else:
os.environ["KQLMAGIC_EXTRAS_REQUIRE"] = "jupyter-bas... | [
"def",
"_set_kql_env_vars",
"(",
"extras",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
")",
":",
"jp_extended",
"=",
"(",
"\"azsentinel\"",
",",
"\"azuresentinel\"",
",",
"\"kql\"",
")",
"if",
"extras",
"and",
"any",
"(",
"extra",
"for",
"extra",
... | Set environment variables for Kqlmagic based on MP extras. | [
"Set",
"environment",
"variables",
"for",
"Kqlmagic",
"based",
"on",
"MP",
"extras",
"."
] | [
"\"\"\"Set environment variables for Kqlmagic based on MP extras.\"\"\""
] | [
{
"param": "extras",
"type": "Optional[List[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "extras",
"type": "Optional[List[str]]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5b3bf88ea440a5fca5a284c695816174a094aa3a | JennySnyk/msticpy | msticpy/nbtools/azure_ml_tools.py | [
"MIT"
] | Python | _get_pkg_version | Any | def _get_pkg_version(version: Union[str, Tuple]) -> Any:
"""Return pkg_resources parsed version from string or tuple."""
if isinstance(version, str):
return parse_version(version)
if isinstance(version, tuple):
return parse_version(".".join(str(ver) for ver in version))
raise TypeError(f... | Return pkg_resources parsed version from string or tuple. | Return pkg_resources parsed version from string or tuple. | [
"Return",
"pkg_resources",
"parsed",
"version",
"from",
"string",
"or",
"tuple",
"."
] | def _get_pkg_version(version: Union[str, Tuple]) -> Any:
if isinstance(version, str):
return parse_version(version)
if isinstance(version, tuple):
return parse_version(".".join(str(ver) for ver in version))
raise TypeError(f"Unparseable type version {version}") | [
"def",
"_get_pkg_version",
"(",
"version",
":",
"Union",
"[",
"str",
",",
"Tuple",
"]",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
"version",
",",
"str",
")",
":",
"return",
"parse_version",
"(",
"version",
")",
"if",
"isinstance",
"(",
"version",
... | Return pkg_resources parsed version from string or tuple. | [
"Return",
"pkg_resources",
"parsed",
"version",
"from",
"string",
"or",
"tuple",
"."
] | [
"\"\"\"Return pkg_resources parsed version from string or tuple.\"\"\""
] | [
{
"param": "version",
"type": "Union[str, Tuple]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "version",
"type": "Union[str, Tuple]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5b3bf88ea440a5fca5a284c695816174a094aa3a | JennySnyk/msticpy | msticpy/nbtools/azure_ml_tools.py | [
"MIT"
] | Python | _set_mpconfig_var | <not_specific> | def _set_mpconfig_var():
"""Set MSTICPYCONFIG to file in user directory if no other found."""
mp_path_val = os.environ.get(MP_ENV_VAR)
if (
# If a valid MSTICPYCONFIG value is found - return
(mp_path_val and Path(mp_path_val).is_file())
# Or if there is a msticpconfig in the current ... | Set MSTICPYCONFIG to file in user directory if no other found. | Set MSTICPYCONFIG to file in user directory if no other found. | [
"Set",
"MSTICPYCONFIG",
"to",
"file",
"in",
"user",
"directory",
"if",
"no",
"other",
"found",
"."
] | def _set_mpconfig_var():
mp_path_val = os.environ.get(MP_ENV_VAR)
if (
(mp_path_val and Path(mp_path_val).is_file())
or Path(".").joinpath(MP_FILE).is_file()
):
return
user_dir = get_aml_user_folder()
mp_path = Path(user_dir).joinpath(MP_FILE)
if mp_path.is_file():
... | [
"def",
"_set_mpconfig_var",
"(",
")",
":",
"mp_path_val",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"MP_ENV_VAR",
")",
"if",
"(",
"(",
"mp_path_val",
"and",
"Path",
"(",
"mp_path_val",
")",
".",
"is_file",
"(",
")",
")",
"or",
"Path",
"(",
"\".\"",
... | Set MSTICPYCONFIG to file in user directory if no other found. | [
"Set",
"MSTICPYCONFIG",
"to",
"file",
"in",
"user",
"directory",
"if",
"no",
"other",
"found",
"."
] | [
"\"\"\"Set MSTICPYCONFIG to file in user directory if no other found.\"\"\"",
"# If a valid MSTICPYCONFIG value is found - return",
"# Or if there is a msticpconfig in the current folder.",
"# Otherwise check the user's root folder",
"# If there's a file there, set the env variable to that.",
"# Since we ... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5b3bf88ea440a5fca5a284c695816174a094aa3a | JennySnyk/msticpy | msticpy/nbtools/azure_ml_tools.py | [
"MIT"
] | Python | _get_vm_metadata | Mapping[str, Any] | def _get_vm_metadata() -> Mapping[str, Any]:
"""Use local request to get VM metadata."""
vm_uri = "http://169.254.169.254/metadata/instance?api-version=2017-08-01"
req = urllib.request.Request(vm_uri)
req.add_header("Metadata", "true")
# Bandit warning on urlopen - Fixed private URL
with urllib... | Use local request to get VM metadata. | Use local request to get VM metadata. | [
"Use",
"local",
"request",
"to",
"get",
"VM",
"metadata",
"."
] | def _get_vm_metadata() -> Mapping[str, Any]:
vm_uri = "http://169.254.169.254/metadata/instance?api-version=2017-08-01"
req = urllib.request.Request(vm_uri)
req.add_header("Metadata", "true")
with urllib.request.urlopen(req) as resp:
metadata = json.loads(resp.read())
return metadata if is... | [
"def",
"_get_vm_metadata",
"(",
")",
"->",
"Mapping",
"[",
"str",
",",
"Any",
"]",
":",
"vm_uri",
"=",
"\"http://169.254.169.254/metadata/instance?api-version=2017-08-01\"",
"req",
"=",
"urllib",
".",
"request",
".",
"Request",
"(",
"vm_uri",
")",
"req",
".",
"a... | Use local request to get VM metadata. | [
"Use",
"local",
"request",
"to",
"get",
"VM",
"metadata",
"."
] | [
"\"\"\"Use local request to get VM metadata.\"\"\"",
"# Bandit warning on urlopen - Fixed private URL",
"# nosec"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5b3bf88ea440a5fca5a284c695816174a094aa3a | JennySnyk/msticpy | msticpy/nbtools/azure_ml_tools.py | [
"MIT"
] | Python | _get_vm_fqdn | str | def _get_vm_fqdn() -> str:
"""Get the FQDN of the host."""
az_region = _get_vm_metadata().get("compute", {}).get("location")
return ".".join(
[
socket.gethostname(),
az_region,
"instances.azureml.ms",
]
if az_region
else ""
) | Get the FQDN of the host. | Get the FQDN of the host. | [
"Get",
"the",
"FQDN",
"of",
"the",
"host",
"."
] | def _get_vm_fqdn() -> str:
az_region = _get_vm_metadata().get("compute", {}).get("location")
return ".".join(
[
socket.gethostname(),
az_region,
"instances.azureml.ms",
]
if az_region
else ""
) | [
"def",
"_get_vm_fqdn",
"(",
")",
"->",
"str",
":",
"az_region",
"=",
"_get_vm_metadata",
"(",
")",
".",
"get",
"(",
"\"compute\"",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"location\"",
")",
"return",
"\".\"",
".",
"join",
"(",
"[",
"socket",
".",
"get... | Get the FQDN of the host. | [
"Get",
"the",
"FQDN",
"of",
"the",
"host",
"."
] | [
"\"\"\"Get the FQDN of the host.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5b3bf88ea440a5fca5a284c695816174a094aa3a | JennySnyk/msticpy | msticpy/nbtools/azure_ml_tools.py | [
"MIT"
] | Python | _check_kql_prereqs | <not_specific> | def _check_kql_prereqs():
"""
Check and install packages for Kqlmagic/msal_extensions.
Notes
-----
Kqlmagic may trigger warnings about a missing PyGObject package
and some system library dependencies. To fix this do the
following:<br>
From a notebook run:
%pip uninstall enum34
... |
Check and install packages for Kqlmagic/msal_extensions.
Notes
-----
Kqlmagic may trigger warnings about a missing PyGObject package
and some system library dependencies. To fix this do the
following:<br>
From a notebook run:
%pip uninstall enum34
!sudo apt-get --yes insta... | Check and install packages for Kqlmagic/msal_extensions.
Notes
Kqlmagic may trigger warnings about a missing PyGObject package
and some system library dependencies. To fix this do the
following:
From a notebook run.
You can also do this from a terminal - but ensure that you've
activated the environment correspondin... | [
"Check",
"and",
"install",
"packages",
"for",
"Kqlmagic",
"/",
"msal_extensions",
".",
"Notes",
"Kqlmagic",
"may",
"trigger",
"warnings",
"about",
"a",
"missing",
"PyGObject",
"package",
"and",
"some",
"system",
"library",
"dependencies",
".",
"To",
"fix",
"this... | def _check_kql_prereqs():
if not is_in_aml():
return
try:
import gi
del gi
except ImportError:
ip_shell = get_ipython()
if not ip_shell:
return
apt_list = ip_shell.run_line_magic("sx", "apt list")
apt_list = [apt.split("/", maxsplit=1)[0] f... | [
"def",
"_check_kql_prereqs",
"(",
")",
":",
"if",
"not",
"is_in_aml",
"(",
")",
":",
"return",
"try",
":",
"import",
"gi",
"del",
"gi",
"except",
"ImportError",
":",
"ip_shell",
"=",
"get_ipython",
"(",
")",
"if",
"not",
"ip_shell",
":",
"return",
"apt_l... | Check and install packages for Kqlmagic/msal_extensions. | [
"Check",
"and",
"install",
"packages",
"for",
"Kqlmagic",
"/",
"msal_extensions",
"."
] | [
"\"\"\"\n Check and install packages for Kqlmagic/msal_extensions.\n\n Notes\n -----\n Kqlmagic may trigger warnings about a missing PyGObject package\n and some system library dependencies. To fix this do the\n following:<br>\n From a notebook run:\n\n %pip uninstall enum34\n !su... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5b3bf88ea440a5fca5a284c695816174a094aa3a | JennySnyk/msticpy | msticpy/nbtools/azure_ml_tools.py | [
"MIT"
] | Python | _check_nb_check_ver | <not_specific> | def _check_nb_check_ver():
"""Check the version of nb_check and optionally update."""
nb_check_path = "utils/nb_check.py"
gh_file = ""
curr_file = ""
try:
# Bandit warning - fixed https URL
with request.urlopen(NB_CHECK_URI) as gh_fh: # nosec
gh_file = gh_fh.read().decod... | Check the version of nb_check and optionally update. | Check the version of nb_check and optionally update. | [
"Check",
"the",
"version",
"of",
"nb_check",
"and",
"optionally",
"update",
"."
] | def _check_nb_check_ver():
nb_check_path = "utils/nb_check.py"
gh_file = ""
curr_file = ""
try:
with request.urlopen(NB_CHECK_URI) as gh_fh:
gh_file = gh_fh.read().decode("utf-8")
except Exception:
_disp_html(f"Warning could not check version of {NB_CHECK_URI}")
... | [
"def",
"_check_nb_check_ver",
"(",
")",
":",
"nb_check_path",
"=",
"\"utils/nb_check.py\"",
"gh_file",
"=",
"\"\"",
"curr_file",
"=",
"\"\"",
"try",
":",
"with",
"request",
".",
"urlopen",
"(",
"NB_CHECK_URI",
")",
"as",
"gh_fh",
":",
"gh_file",
"=",
"gh_fh",
... | Check the version of nb_check and optionally update. | [
"Check",
"the",
"version",
"of",
"nb_check",
"and",
"optionally",
"update",
"."
] | [
"\"\"\"Check the version of nb_check and optionally update.\"\"\"",
"# Bandit warning - fixed https URL",
"# nosec"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
52e903855f834697cc7e226699406e85d364591c | JennySnyk/msticpy | msticpy/datamodel/pivot.py | [
"MIT"
] | Python | reload_pivots | null | def reload_pivots(
self,
namespace: Dict[str, Any] = None,
providers: Iterable[Any] = None,
clear_existing: bool = True,
):
"""
Load or reload Pivot functions from environment and/or providers list.
Parameters
----------
namespace : Dict[str, ... |
Load or reload Pivot functions from environment and/or providers list.
Parameters
----------
namespace : Dict[str, Any], optional
To search for and use any current providers, specify
`namespace=globals()`, by default None
providers : Iterable[Any], optio... | Load or reload Pivot functions from environment and/or providers list.
Parameters
namespace : Dict[str, Any], optional
To search for and use any current providers, specify
`namespace=globals()`, by default None
providers : Iterable[Any], optional
A list of query providers, TILookup or other providers to
use (these wil... | [
"Load",
"or",
"reload",
"Pivot",
"functions",
"from",
"environment",
"and",
"/",
"or",
"providers",
"list",
".",
"Parameters",
"namespace",
":",
"Dict",
"[",
"str",
"Any",
"]",
"optional",
"To",
"search",
"for",
"and",
"use",
"any",
"current",
"providers",
... | def reload_pivots(
self,
namespace: Dict[str, Any] = None,
providers: Iterable[Any] = None,
clear_existing: bool = True,
):
if clear_existing:
self.remove_pivot_funcs(entity="all")
self._get_all_providers(namespace, providers)
data_provs = (
... | [
"def",
"reload_pivots",
"(",
"self",
",",
"namespace",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"None",
",",
"providers",
":",
"Iterable",
"[",
"Any",
"]",
"=",
"None",
",",
"clear_existing",
":",
"bool",
"=",
"True",
",",
")",
":",
"if",
"cl... | Load or reload Pivot functions from environment and/or providers list. | [
"Load",
"or",
"reload",
"Pivot",
"functions",
"from",
"environment",
"and",
"/",
"or",
"providers",
"list",
"."
] | [
"\"\"\"\n Load or reload Pivot functions from environment and/or providers list.\n\n Parameters\n ----------\n namespace : Dict[str, Any], optional\n To search for and use any current providers, specify\n `namespace=globals()`, by default None\n providers : I... | [
{
"param": "self",
"type": null
},
{
"param": "namespace",
"type": "Dict[str, Any]"
},
{
"param": "providers",
"type": "Iterable[Any]"
},
{
"param": "clear_existing",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "namespace",
"type": "Dict[str, Any]",
"docstring": null,
"doc... |
52e903855f834697cc7e226699406e85d364591c | JennySnyk/msticpy | msticpy/datamodel/pivot.py | [
"MIT"
] | Python | remove_pivot_funcs | null | def remove_pivot_funcs(entity: str):
"""
Remove pivot functions from one or all entities.
Parameters
----------
entity : str
entity class name or "all" to remove all pivot functions.
Raises
------
ValueError
If entity is not a rec... |
Remove pivot functions from one or all entities.
Parameters
----------
entity : str
entity class name or "all" to remove all pivot functions.
Raises
------
ValueError
If entity is not a recognized entity class.
| Remove pivot functions from one or all entities.
Parameters
entity : str
entity class name or "all" to remove all pivot functions.
Raises
ValueError
If entity is not a recognized entity class. | [
"Remove",
"pivot",
"functions",
"from",
"one",
"or",
"all",
"entities",
".",
"Parameters",
"entity",
":",
"str",
"entity",
"class",
"name",
"or",
"\"",
"all",
"\"",
"to",
"remove",
"all",
"pivot",
"functions",
".",
"Raises",
"ValueError",
"If",
"entity",
"... | def remove_pivot_funcs(entity: str):
all_entities = dir(entities)
if entity != "all":
if entity not in all_entities:
raise ValueError(f"Entity name '{entity}' not found.")
entity_names = [entity]
else:
entity_names = all_entities
for en... | [
"def",
"remove_pivot_funcs",
"(",
"entity",
":",
"str",
")",
":",
"all_entities",
"=",
"dir",
"(",
"entities",
")",
"if",
"entity",
"!=",
"\"all\"",
":",
"if",
"entity",
"not",
"in",
"all_entities",
":",
"raise",
"ValueError",
"(",
"f\"Entity name '{entity}' n... | Remove pivot functions from one or all entities. | [
"Remove",
"pivot",
"functions",
"from",
"one",
"or",
"all",
"entities",
"."
] | [
"\"\"\"\n Remove pivot functions from one or all entities.\n\n Parameters\n ----------\n entity : str\n entity class name or \"all\" to remove all pivot functions.\n\n Raises\n ------\n ValueError\n If entity is not a recognized entity class.\n\... | [
{
"param": "entity",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entity",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e193a1fc675095ae865a04e401f4c427837872b4 | JennySnyk/msticpy | msticpy/data/drivers/mordor_driver.py | [
"MIT"
] | Python | query_with_results | Tuple[pd.DataFrame, Any] | def query_with_results(self, query: str, **kwargs) -> Tuple[pd.DataFrame, Any]:
"""
Execute query string and return DataFrame plus native results.
Parameters
----------
query : str
The query to execute
Returns
-------
Tuple[pd.DataFrame,Any]
... |
Execute query string and return DataFrame plus native results.
Parameters
----------
query : str
The query to execute
Returns
-------
Tuple[pd.DataFrame,Any]
A DataFrame and native results.
| Execute query string and return DataFrame plus native results.
Parameters
query : str
The query to execute
Returns
| [
"Execute",
"query",
"string",
"and",
"return",
"DataFrame",
"plus",
"native",
"results",
".",
"Parameters",
"query",
":",
"str",
"The",
"query",
"to",
"execute",
"Returns"
] | def query_with_results(self, query: str, **kwargs) -> Tuple[pd.DataFrame, Any]:
result = self.query(query, **kwargs)
if isinstance(result, pd.DataFrame):
return result, "OK"
return pd.DataFrame, result | [
"def",
"query_with_results",
"(",
"self",
",",
"query",
":",
"str",
",",
"**",
"kwargs",
")",
"->",
"Tuple",
"[",
"pd",
".",
"DataFrame",
",",
"Any",
"]",
":",
"result",
"=",
"self",
".",
"query",
"(",
"query",
",",
"**",
"kwargs",
")",
"if",
"isin... | Execute query string and return DataFrame plus native results. | [
"Execute",
"query",
"string",
"and",
"return",
"DataFrame",
"plus",
"native",
"results",
"."
] | [
"\"\"\"\n Execute query string and return DataFrame plus native results.\n\n Parameters\n ----------\n query : str\n The query to execute\n\n Returns\n -------\n Tuple[pd.DataFrame,Any]\n A DataFrame and native results.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": "str",
"docstring": null,
"docstring_tokens":... |
e193a1fc675095ae865a04e401f4c427837872b4 | JennySnyk/msticpy | msticpy/data/drivers/mordor_driver.py | [
"MIT"
] | Python | driver_queries | Iterable[Dict[str, Any]] | def driver_queries(self) -> Iterable[Dict[str, Any]]:
"""
Return generator of Mordor query definitions.
Yields
------
Iterable[Dict[str, Any]]
Iterable of Dictionaries containing query definitions.
"""
if not self._connected:
raise self._... |
Return generator of Mordor query definitions.
Yields
------
Iterable[Dict[str, Any]]
Iterable of Dictionaries containing query definitions.
| Return generator of Mordor query definitions.
Yields
Iterable[Dict[str, Any]]
Iterable of Dictionaries containing query definitions. | [
"Return",
"generator",
"of",
"Mordor",
"query",
"definitions",
".",
"Yields",
"Iterable",
"[",
"Dict",
"[",
"str",
"Any",
"]]",
"Iterable",
"of",
"Dictionaries",
"containing",
"query",
"definitions",
"."
] | def driver_queries(self) -> Iterable[Dict[str, Any]]:
if not self._connected:
raise self._create_not_connected_err()
if not self._driver_queries:
self._driver_queries = list(self._get_driver_queries())
return self._driver_queries | [
"def",
"driver_queries",
"(",
"self",
")",
"->",
"Iterable",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"if",
"not",
"self",
".",
"_connected",
":",
"raise",
"self",
".",
"_create_not_connected_err",
"(",
")",
"if",
"not",
"self",
".",
"_drive... | Return generator of Mordor query definitions. | [
"Return",
"generator",
"of",
"Mordor",
"query",
"definitions",
"."
] | [
"\"\"\"\n Return generator of Mordor query definitions.\n\n Yields\n ------\n Iterable[Dict[str, Any]]\n Iterable of Dictionaries containing query definitions.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e193a1fc675095ae865a04e401f4c427837872b4 | JennySnyk/msticpy | msticpy/data/drivers/mordor_driver.py | [
"MIT"
] | Python | _get_driver_queries | null | def _get_driver_queries(self):
"""Generate iterable of Mordor queries."""
for mdr_item in self.mordor_data.values():
for file_path in mdr_item.get_file_paths():
mitre_data = mdr_item.get_attacks()
techniques = ", ".join(
f"{att.technique}: ... | Generate iterable of Mordor queries. | Generate iterable of Mordor queries. | [
"Generate",
"iterable",
"of",
"Mordor",
"queries",
"."
] | def _get_driver_queries(self):
for mdr_item in self.mordor_data.values():
for file_path in mdr_item.get_file_paths():
mitre_data = mdr_item.get_attacks()
techniques = ", ".join(
f"{att.technique}: {att.technique_name}" for att in mitre_data
... | [
"def",
"_get_driver_queries",
"(",
"self",
")",
":",
"for",
"mdr_item",
"in",
"self",
".",
"mordor_data",
".",
"values",
"(",
")",
":",
"for",
"file_path",
"in",
"mdr_item",
".",
"get_file_paths",
"(",
")",
":",
"mitre_data",
"=",
"mdr_item",
".",
"get_att... | Generate iterable of Mordor queries. | [
"Generate",
"iterable",
"of",
"Mordor",
"queries",
"."
] | [
"\"\"\"Generate iterable of Mordor queries.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e193a1fc675095ae865a04e401f4c427837872b4 | JennySnyk/msticpy | msticpy/data/drivers/mordor_driver.py | [
"MIT"
] | Python | technique_name | Optional[str] | def technique_name(self) -> Optional[str]:
"""
Return Mitre Technique full name.
Returns
-------
Optional[str]
Name of the Mitre technique
"""
if not self._technique_name and self.technique in MITRE_TECHNIQUES.index:
self._technique_name ... |
Return Mitre Technique full name.
Returns
-------
Optional[str]
Name of the Mitre technique
| Return Mitre Technique full name.
Returns
Optional[str]
Name of the Mitre technique | [
"Return",
"Mitre",
"Technique",
"full",
"name",
".",
"Returns",
"Optional",
"[",
"str",
"]",
"Name",
"of",
"the",
"Mitre",
"technique"
] | def technique_name(self) -> Optional[str]:
if not self._technique_name and self.technique in MITRE_TECHNIQUES.index:
self._technique_name = MITRE_TECHNIQUES.loc[self.technique].Name
return self._technique_name | [
"def",
"technique_name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"not",
"self",
".",
"_technique_name",
"and",
"self",
".",
"technique",
"in",
"MITRE_TECHNIQUES",
".",
"index",
":",
"self",
".",
"_technique_name",
"=",
"MITRE_TECHNIQU... | Return Mitre Technique full name. | [
"Return",
"Mitre",
"Technique",
"full",
"name",
"."
] | [
"\"\"\"\n Return Mitre Technique full name.\n\n Returns\n -------\n Optional[str]\n Name of the Mitre technique\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e193a1fc675095ae865a04e401f4c427837872b4 | JennySnyk/msticpy | msticpy/data/drivers/mordor_driver.py | [
"MIT"
] | Python | technique_desc | Optional[str] | def technique_desc(self) -> Optional[str]:
"""
Return Mitre technique description.
Returns
-------
Optional[str]
Technique description
"""
if not self._technique_desc and self.technique in MITRE_TECHNIQUES.index:
self._technique_desc = MI... |
Return Mitre technique description.
Returns
-------
Optional[str]
Technique description
| Return Mitre technique description.
Returns
Optional[str]
Technique description | [
"Return",
"Mitre",
"technique",
"description",
".",
"Returns",
"Optional",
"[",
"str",
"]",
"Technique",
"description"
] | def technique_desc(self) -> Optional[str]:
if not self._technique_desc and self.technique in MITRE_TECHNIQUES.index:
self._technique_desc = MITRE_TECHNIQUES.loc[self.technique].Description
return self._technique_desc | [
"def",
"technique_desc",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"not",
"self",
".",
"_technique_desc",
"and",
"self",
".",
"technique",
"in",
"MITRE_TECHNIQUES",
".",
"index",
":",
"self",
".",
"_technique_desc",
"=",
"MITRE_TECHNIQU... | Return Mitre technique description. | [
"Return",
"Mitre",
"technique",
"description",
"."
] | [
"\"\"\"\n Return Mitre technique description.\n\n Returns\n -------\n Optional[str]\n Technique description\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e193a1fc675095ae865a04e401f4c427837872b4 | JennySnyk/msticpy | msticpy/data/drivers/mordor_driver.py | [
"MIT"
] | Python | _get_mdr_github_tree | <not_specific> | def _get_mdr_github_tree():
"""Closure to wrap fetching Mordor tree from GitHub."""
mordor_tree = None
def _get_mdr_tree(uri):
nonlocal mordor_tree
if mordor_tree is None:
resp = requests.get(uri)
mordor_tree = resp.json()
return mordor_tree
return _get_... | Closure to wrap fetching Mordor tree from GitHub. | Closure to wrap fetching Mordor tree from GitHub. | [
"Closure",
"to",
"wrap",
"fetching",
"Mordor",
"tree",
"from",
"GitHub",
"."
] | def _get_mdr_github_tree():
mordor_tree = None
def _get_mdr_tree(uri):
nonlocal mordor_tree
if mordor_tree is None:
resp = requests.get(uri)
mordor_tree = resp.json()
return mordor_tree
return _get_mdr_tree | [
"def",
"_get_mdr_github_tree",
"(",
")",
":",
"mordor_tree",
"=",
"None",
"def",
"_get_mdr_tree",
"(",
"uri",
")",
":",
"nonlocal",
"mordor_tree",
"if",
"mordor_tree",
"is",
"None",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"uri",
")",
"mordor_tree",
... | Closure to wrap fetching Mordor tree from GitHub. | [
"Closure",
"to",
"wrap",
"fetching",
"Mordor",
"tree",
"from",
"GitHub",
"."
] | [
"\"\"\"Closure to wrap fetching Mordor tree from GitHub.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
e193a1fc675095ae865a04e401f4c427837872b4 | JennySnyk/msticpy | msticpy/data/drivers/mordor_driver.py | [
"MIT"
] | Python | _get_mdr_file | <not_specific> | def _get_mdr_file(gh_file):
"""Fetch a file from Mordor repo."""
file_blob_uri = f"https://raw.githubusercontent.com/OTRF/mordor/master/{gh_file}"
file_resp = requests.get(file_blob_uri)
return file_resp.content | Fetch a file from Mordor repo. | Fetch a file from Mordor repo. | [
"Fetch",
"a",
"file",
"from",
"Mordor",
"repo",
"."
] | def _get_mdr_file(gh_file):
file_blob_uri = f"https://raw.githubusercontent.com/OTRF/mordor/master/{gh_file}"
file_resp = requests.get(file_blob_uri)
return file_resp.content | [
"def",
"_get_mdr_file",
"(",
"gh_file",
")",
":",
"file_blob_uri",
"=",
"f\"https://raw.githubusercontent.com/OTRF/mordor/master/{gh_file}\"",
"file_resp",
"=",
"requests",
".",
"get",
"(",
"file_blob_uri",
")",
"return",
"file_resp",
".",
"content"
] | Fetch a file from Mordor repo. | [
"Fetch",
"a",
"file",
"from",
"Mordor",
"repo",
"."
] | [
"\"\"\"Fetch a file from Mordor repo.\"\"\""
] | [
{
"param": "gh_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gh_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e193a1fc675095ae865a04e401f4c427837872b4 | JennySnyk/msticpy | msticpy/data/drivers/mordor_driver.py | [
"MIT"
] | Python | _fetch_mdr_metadata | Dict[str, MordorEntry] | def _fetch_mdr_metadata() -> Dict[str, MordorEntry]:
"""
Return full metadata for Mordor datasets.
Returns
-------
Dict[str, MordorEntry]:
Mordor data set metadata keyed by MordorID
"""
global MITRE_TECHNIQUES, MITRE_TACTICS
if MITRE_TECHNIQUES is None or MITRE_TACTICS is None... |
Return full metadata for Mordor datasets.
Returns
-------
Dict[str, MordorEntry]:
Mordor data set metadata keyed by MordorID
| Return full metadata for Mordor datasets.
Returns
Dict[str, MordorEntry]:
Mordor data set metadata keyed by MordorID | [
"Return",
"full",
"metadata",
"for",
"Mordor",
"datasets",
".",
"Returns",
"Dict",
"[",
"str",
"MordorEntry",
"]",
":",
"Mordor",
"data",
"set",
"metadata",
"keyed",
"by",
"MordorID"
] | def _fetch_mdr_metadata() -> Dict[str, MordorEntry]:
global MITRE_TECHNIQUES, MITRE_TACTICS
if MITRE_TECHNIQUES is None or MITRE_TACTICS is None:
MITRE_TECHNIQUES, MITRE_TACTICS = _get_mitre_categories()
md_metadata: Dict[str, MordorEntry] = {}
mdr_md_paths = list(get_mdr_data_paths("metadata"))... | [
"def",
"_fetch_mdr_metadata",
"(",
")",
"->",
"Dict",
"[",
"str",
",",
"MordorEntry",
"]",
":",
"global",
"MITRE_TECHNIQUES",
",",
"MITRE_TACTICS",
"if",
"MITRE_TECHNIQUES",
"is",
"None",
"or",
"MITRE_TACTICS",
"is",
"None",
":",
"MITRE_TECHNIQUES",
",",
"MITRE_... | Return full metadata for Mordor datasets. | [
"Return",
"full",
"metadata",
"for",
"Mordor",
"datasets",
"."
] | [
"\"\"\"\n Return full metadata for Mordor datasets.\n\n Returns\n -------\n Dict[str, MordorEntry]:\n Mordor data set metadata keyed by MordorID\n\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
144d987738423afc9e954ccc824b11988000eed8 | JennySnyk/msticpy | msticpy/sectools/tilookup.py | [
"MIT"
] | Python | configured_providers | List[str] | def configured_providers(self) -> List[str]:
"""
Return a list of avaliable providers that have configuration details present.
Returns
-------
List[str]
List of TI Provider classes.
"""
prim_conf = list(self._providers.keys())
sec_conf = list... |
Return a list of avaliable providers that have configuration details present.
Returns
-------
List[str]
List of TI Provider classes.
| Return a list of avaliable providers that have configuration details present.
Returns
List[str]
List of TI Provider classes. | [
"Return",
"a",
"list",
"of",
"avaliable",
"providers",
"that",
"have",
"configuration",
"details",
"present",
".",
"Returns",
"List",
"[",
"str",
"]",
"List",
"of",
"TI",
"Provider",
"classes",
"."
] | def configured_providers(self) -> List[str]:
prim_conf = list(self._providers.keys())
sec_conf = list(self._secondary_providers.keys())
return prim_conf + sec_conf | [
"def",
"configured_providers",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"prim_conf",
"=",
"list",
"(",
"self",
".",
"_providers",
".",
"keys",
"(",
")",
")",
"sec_conf",
"=",
"list",
"(",
"self",
".",
"_secondary_providers",
".",
"keys",
"... | Return a list of avaliable providers that have configuration details present. | [
"Return",
"a",
"list",
"of",
"avaliable",
"providers",
"that",
"have",
"configuration",
"details",
"present",
"."
] | [
"\"\"\"\n Return a list of avaliable providers that have configuration details present.\n\n Returns\n -------\n List[str]\n List of TI Provider classes.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
144d987738423afc9e954ccc824b11988000eed8 | JennySnyk/msticpy | msticpy/sectools/tilookup.py | [
"MIT"
] | Python | reload_provider_settings | null | def reload_provider_settings(cls):
"""Reload provider settings from config."""
reload_settings()
print(
"Settings reloaded. Use reload_providers to update settings",
"for loaded providers.",
) | Reload provider settings from config. | Reload provider settings from config. | [
"Reload",
"provider",
"settings",
"from",
"config",
"."
] | def reload_provider_settings(cls):
reload_settings()
print(
"Settings reloaded. Use reload_providers to update settings",
"for loaded providers.",
) | [
"def",
"reload_provider_settings",
"(",
"cls",
")",
":",
"reload_settings",
"(",
")",
"print",
"(",
"\"Settings reloaded. Use reload_providers to update settings\"",
",",
"\"for loaded providers.\"",
",",
")"
] | Reload provider settings from config. | [
"Reload",
"provider",
"settings",
"from",
"config",
"."
] | [
"\"\"\"Reload provider settings from config.\"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
144d987738423afc9e954ccc824b11988000eed8 | JennySnyk/msticpy | msticpy/sectools/tilookup.py | [
"MIT"
] | Python | reload_providers | null | def reload_providers(self):
"""
Reload providers based on current settings in config.
Parameters
----------
clear_keyring : bool, optional
Clears any secrets cached in keyring, by default False
"""
self.reload_provider_settings()
self._load_p... |
Reload providers based on current settings in config.
Parameters
----------
clear_keyring : bool, optional
Clears any secrets cached in keyring, by default False
| Reload providers based on current settings in config.
Parameters
clear_keyring : bool, optional
Clears any secrets cached in keyring, by default False | [
"Reload",
"providers",
"based",
"on",
"current",
"settings",
"in",
"config",
".",
"Parameters",
"clear_keyring",
":",
"bool",
"optional",
"Clears",
"any",
"secrets",
"cached",
"in",
"keyring",
"by",
"default",
"False"
] | def reload_providers(self):
self.reload_provider_settings()
self._load_providers() | [
"def",
"reload_providers",
"(",
"self",
")",
":",
"self",
".",
"reload_provider_settings",
"(",
")",
"self",
".",
"_load_providers",
"(",
")"
] | Reload providers based on current settings in config. | [
"Reload",
"providers",
"based",
"on",
"current",
"settings",
"in",
"config",
"."
] | [
"\"\"\"\n Reload providers based on current settings in config.\n\n Parameters\n ----------\n clear_keyring : bool, optional\n Clears any secrets cached in keyring, by default False\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
144d987738423afc9e954ccc824b11988000eed8 | JennySnyk/msticpy | msticpy/sectools/tilookup.py | [
"MIT"
] | Python | _load_providers | null | def _load_providers(self):
"""Load provider classes based on config."""
prov_settings = get_provider_settings()
for provider_entry, settings in prov_settings.items():
# Allow overriding provider name to use another class
provider_name = settings.provider or provider_entr... | Load provider classes based on config. | Load provider classes based on config. | [
"Load",
"provider",
"classes",
"based",
"on",
"config",
"."
] | def _load_providers(self):
prov_settings = get_provider_settings()
for provider_entry, settings in prov_settings.items():
provider_name = settings.provider or provider_entry
if self._providers_to_load and provider_name not in self._providers_to_load:
continue
... | [
"def",
"_load_providers",
"(",
"self",
")",
":",
"prov_settings",
"=",
"get_provider_settings",
"(",
")",
"for",
"provider_entry",
",",
"settings",
"in",
"prov_settings",
".",
"items",
"(",
")",
":",
"provider_name",
"=",
"settings",
".",
"provider",
"or",
"pr... | Load provider classes based on config. | [
"Load",
"provider",
"classes",
"based",
"on",
"config",
"."
] | [
"\"\"\"Load provider classes based on config.\"\"\"",
"# Allow overriding provider name to use another class",
"# instantiate class sending args from settings to init",
"# If the TI Provider didn't load, raise an exception",
"# set the description from settings, if one is provided, otherwise",
"# use clas... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
144d987738423afc9e954ccc824b11988000eed8 | JennySnyk/msticpy | msticpy/sectools/tilookup.py | [
"MIT"
] | Python | result_to_df | pd.DataFrame | def result_to_df(
ioc_lookup: Tuple[bool, List[Tuple[str, LookupResult]]]
) -> pd.DataFrame:
"""
Return DataFrame representation of IoC Lookup response.
Parameters
----------
ioc_lookup : Tuple[bool, List[Tuple[str, LookupResult]]]
Output from `lookup_ioc... |
Return DataFrame representation of IoC Lookup response.
Parameters
----------
ioc_lookup : Tuple[bool, List[Tuple[str, LookupResult]]]
Output from `lookup_ioc`
Returns
-------
pd.DataFrame
The response as a DataFrame with a row for each
... | Return DataFrame representation of IoC Lookup response.
Parameters
Returns
pd.DataFrame
The response as a DataFrame with a row for each
provider response. | [
"Return",
"DataFrame",
"representation",
"of",
"IoC",
"Lookup",
"response",
".",
"Parameters",
"Returns",
"pd",
".",
"DataFrame",
"The",
"response",
"as",
"a",
"DataFrame",
"with",
"a",
"row",
"for",
"each",
"provider",
"response",
"."
] | def result_to_df(
ioc_lookup: Tuple[bool, List[Tuple[str, LookupResult]]]
) -> pd.DataFrame:
return (
pd.DataFrame(
{
r_item[0]: pd.Series(attr.asdict(r_item[1]))
for r_item in ioc_lookup[1]
}
)
... | [
"def",
"result_to_df",
"(",
"ioc_lookup",
":",
"Tuple",
"[",
"bool",
",",
"List",
"[",
"Tuple",
"[",
"str",
",",
"LookupResult",
"]",
"]",
"]",
")",
"->",
"pd",
".",
"DataFrame",
":",
"return",
"(",
"pd",
".",
"DataFrame",
"(",
"{",
"r_item",
"[",
... | Return DataFrame representation of IoC Lookup response. | [
"Return",
"DataFrame",
"representation",
"of",
"IoC",
"Lookup",
"response",
"."
] | [
"\"\"\"\n Return DataFrame representation of IoC Lookup response.\n\n Parameters\n ----------\n ioc_lookup : Tuple[bool, List[Tuple[str, LookupResult]]]\n Output from `lookup_ioc`\n\n Returns\n -------\n pd.DataFrame\n The response as a DataFram... | [
{
"param": "ioc_lookup",
"type": "Tuple[bool, List[Tuple[str, LookupResult]]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ioc_lookup",
"type": "Tuple[bool, List[Tuple[str, LookupResult]]]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c9951dd31b400e1ecc33a1b4b116886562feca39 | JennySnyk/msticpy | msticpy/analysis/timeseries.py | [
"MIT"
] | Python | ts_anomalies_stl | pd.DataFrame | def ts_anomalies_stl(data: pd.DataFrame, **kwargs) -> pd.DataFrame:
"""
Return anomalies in Timeseries using STL.
Parameters
----------
data : pd.DataFrame
DataFrame as a time series data set retrived from data connector or
external data source. Dataframe must have 2 columns with ti... |
Return anomalies in Timeseries using STL.
Parameters
----------
data : pd.DataFrame
DataFrame as a time series data set retrived from data connector or
external data source. Dataframe must have 2 columns with time column
set as index and other numeric value.
Other Paramete... | Return anomalies in Timeseries using STL.
Parameters
data : pd.DataFrame
DataFrame as a time series data set retrived from data connector or
external data source. Dataframe must have 2 columns with time column
set as index and other numeric value.
Other Parameters
seasonal : int, optional
Seasonality period of the i... | [
"Return",
"anomalies",
"in",
"Timeseries",
"using",
"STL",
".",
"Parameters",
"data",
":",
"pd",
".",
"DataFrame",
"DataFrame",
"as",
"a",
"time",
"series",
"data",
"set",
"retrived",
"from",
"data",
"connector",
"or",
"external",
"data",
"source",
".",
"Dat... | def ts_anomalies_stl(data: pd.DataFrame, **kwargs) -> pd.DataFrame:
check_kwargs(kwargs, _DEFAULT_KWARGS)
seasonal: int = kwargs.get("seasonal", 7)
period: int = kwargs.get("period", 24)
score_threshold: float = kwargs.get("score_threshold", 3.0)
if not isinstance(data, pd.DataFrame):
raise ... | [
"def",
"ts_anomalies_stl",
"(",
"data",
":",
"pd",
".",
"DataFrame",
",",
"**",
"kwargs",
")",
"->",
"pd",
".",
"DataFrame",
":",
"check_kwargs",
"(",
"kwargs",
",",
"_DEFAULT_KWARGS",
")",
"seasonal",
":",
"int",
"=",
"kwargs",
".",
"get",
"(",
"\"seaso... | Return anomalies in Timeseries using STL. | [
"Return",
"anomalies",
"in",
"Timeseries",
"using",
"STL",
"."
] | [
"\"\"\"\n Return anomalies in Timeseries using STL.\n\n Parameters\n ----------\n data : pd.DataFrame\n DataFrame as a time series data set retrived from data connector or\n external data source. Dataframe must have 2 columns with time column\n set as index and other numeric value.\... | [
{
"param": "data",
"type": "pd.DataFrame"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": "pd.DataFrame",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
85387658298d2664abe1925bc125e825808a814d | JennySnyk/msticpy | msticpy/data/drivers/__init__.py | [
"MIT"
] | Python | import_driver | type | def import_driver(data_environment: DataEnvironment) -> type:
"""Import driver class for a data environment."""
mod_name, cls_name = _ENVIRONMENT_DRIVERS.get(data_environment, (None, None))
if not (mod_name and cls_name):
raise ValueError(
f"No driver available for environment {data_env... | Import driver class for a data environment. | Import driver class for a data environment. | [
"Import",
"driver",
"class",
"for",
"a",
"data",
"environment",
"."
] | def import_driver(data_environment: DataEnvironment) -> type:
mod_name, cls_name = _ENVIRONMENT_DRIVERS.get(data_environment, (None, None))
if not (mod_name and cls_name):
raise ValueError(
f"No driver available for environment {data_environment.name}.",
"Possible values are:",
... | [
"def",
"import_driver",
"(",
"data_environment",
":",
"DataEnvironment",
")",
"->",
"type",
":",
"mod_name",
",",
"cls_name",
"=",
"_ENVIRONMENT_DRIVERS",
".",
"get",
"(",
"data_environment",
",",
"(",
"None",
",",
"None",
")",
")",
"if",
"not",
"(",
"mod_na... | Import driver class for a data environment. | [
"Import",
"driver",
"class",
"for",
"a",
"data",
"environment",
"."
] | [
"\"\"\"Import driver class for a data environment.\"\"\""
] | [
{
"param": "data_environment",
"type": "DataEnvironment"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data_environment",
"type": "DataEnvironment",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
940b2628e4fa3d91ee3bcee6ba9eb990940b5cf6 | JennySnyk/msticpy | msticpy/datamodel/pivot_ti_provider.py | [
"MIT"
] | Python | create_ti_pivot_funcs | <not_specific> | def create_ti_pivot_funcs(ti_lookup: TILookup):
"""Create the TI Pivot functions."""
ioc_type_supp = _get_supported_ioc_types(ti_lookup)
ioc_queries: Dict[str, Dict[str, Callable[..., pd.DataFrame]]] = defaultdict(dict)
# Add functions for ioc types that will call all providers
# Non-IP types
i... | Create the TI Pivot functions. | Create the TI Pivot functions. | [
"Create",
"the",
"TI",
"Pivot",
"functions",
"."
] | def create_ti_pivot_funcs(ti_lookup: TILookup):
ioc_type_supp = _get_supported_ioc_types(ti_lookup)
ioc_queries: Dict[str, Dict[str, Callable[..., pd.DataFrame]]] = defaultdict(dict)
ioc_queries.update(_get_non_ip_functions(ioc_type_supp, ti_lookup))
ioc_queries.update(_get_ip_functions(ioc_type_supp, t... | [
"def",
"create_ti_pivot_funcs",
"(",
"ti_lookup",
":",
"TILookup",
")",
":",
"ioc_type_supp",
"=",
"_get_supported_ioc_types",
"(",
"ti_lookup",
")",
"ioc_queries",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Callable",
"[",
"...",
",",
"pd",
"."... | Create the TI Pivot functions. | [
"Create",
"the",
"TI",
"Pivot",
"functions",
"."
] | [
"\"\"\"Create the TI Pivot functions.\"\"\"",
"# Add functions for ioc types that will call all providers",
"# Non-IP types",
"# Special case for ipv4 and ipv6 - we want to merge these into \"ip\" if these are equivalent",
"# Add functions for provider-specific lookup function names",
"# These have a \"_p... | [
{
"param": "ti_lookup",
"type": "TILookup"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ti_lookup",
"type": "TILookup",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
940b2628e4fa3d91ee3bcee6ba9eb990940b5cf6 | JennySnyk/msticpy | msticpy/datamodel/pivot_ti_provider.py | [
"MIT"
] | Python | _get_non_ip_functions | <not_specific> | def _get_non_ip_functions(ioc_type_supp, ti_lookup):
"""Get functions for non-IP IoC types."""
ioc_queries = defaultdict(dict)
for ioc in IOC_TYPES - {"ipv4", "ipv6"}:
supporting_provs = [
prov for prov, supp_types in ioc_type_supp.items() if ioc in supp_types
]
_, func_n... | Get functions for non-IP IoC types. | Get functions for non-IP IoC types. | [
"Get",
"functions",
"for",
"non",
"-",
"IP",
"IoC",
"types",
"."
] | def _get_non_ip_functions(ioc_type_supp, ti_lookup):
ioc_queries = defaultdict(dict)
for ioc in IOC_TYPES - {"ipv4", "ipv6"}:
supporting_provs = [
prov for prov, supp_types in ioc_type_supp.items() if ioc in supp_types
]
_, func_name, func = _create_lookup_func(ti_lookup, ioc... | [
"def",
"_get_non_ip_functions",
"(",
"ioc_type_supp",
",",
"ti_lookup",
")",
":",
"ioc_queries",
"=",
"defaultdict",
"(",
"dict",
")",
"for",
"ioc",
"in",
"IOC_TYPES",
"-",
"{",
"\"ipv4\"",
",",
"\"ipv6\"",
"}",
":",
"supporting_provs",
"=",
"[",
"prov",
"fo... | Get functions for non-IP IoC types. | [
"Get",
"functions",
"for",
"non",
"-",
"IP",
"IoC",
"types",
"."
] | [
"\"\"\"Get functions for non-IP IoC types.\"\"\""
] | [
{
"param": "ioc_type_supp",
"type": null
},
{
"param": "ti_lookup",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ioc_type_supp",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ti_lookup",
"type": null,
"docstring": null,
"docstr... |
940b2628e4fa3d91ee3bcee6ba9eb990940b5cf6 | JennySnyk/msticpy | msticpy/datamodel/pivot_ti_provider.py | [
"MIT"
] | Python | _get_ip_functions | <not_specific> | def _get_ip_functions(ioc_type_supp, ti_lookup):
"""Get functions for IP IoC Types."""
# Special case for ipv4 and ipv6
# we want to merge these into "ip" if these are equivalent
ioc_queries = defaultdict(dict)
# Special case for ipv4 and ipv6 - we want to merge these into "ip" if these are equivale... | Get functions for IP IoC Types. | Get functions for IP IoC Types. | [
"Get",
"functions",
"for",
"IP",
"IoC",
"Types",
"."
] | def _get_ip_functions(ioc_type_supp, ti_lookup):
ioc_queries = defaultdict(dict)
- we want to merge these into "ip" if these are equivalent
ip_types = {"ipv4", "ipv6"}
ip_all_provs = [
prov for prov, supp_types in ioc_type_supp.items() if ip_types & supp_types
]
ip_gen_provs = [
... | [
"def",
"_get_ip_functions",
"(",
"ioc_type_supp",
",",
"ti_lookup",
")",
":",
"ioc_queries",
"=",
"defaultdict",
"(",
"dict",
")",
"ip_types",
"=",
"{",
"\"ipv4\"",
",",
"\"ipv6\"",
"}",
"ip_all_provs",
"=",
"[",
"prov",
"for",
"prov",
",",
"supp_types",
"in... | Get functions for IP IoC Types. | [
"Get",
"functions",
"for",
"IP",
"IoC",
"Types",
"."
] | [
"\"\"\"Get functions for IP IoC Types.\"\"\"",
"# Special case for ipv4 and ipv6",
"# we want to merge these into \"ip\" if these are equivalent",
"# Special case for ipv4 and ipv6 - we want to merge these into \"ip\" if these are equivalent",
"# Register providers where IP v4 and v6 are equivalent, or only... | [
{
"param": "ioc_type_supp",
"type": null
},
{
"param": "ti_lookup",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ioc_type_supp",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ti_lookup",
"type": null,
"docstring": null,
"docstr... |
7477ebb58d24c9e66901b1cf917fd56c181abb14 | JennySnyk/msticpy | msticpy/common/azure_auth_core.py | [
"MIT"
] | Python | az_connect_core | AzCredentials | def az_connect_core(
auth_methods: List[str] = None, silent: bool = False
) -> AzCredentials:
"""
Authenticate using multiple authentication sources.
Parameters
----------
auth_methods
List of authentication methods to try
Possible options are:
- "env" - to get authentic... |
Authenticate using multiple authentication sources.
Parameters
----------
auth_methods
List of authentication methods to try
Possible options are:
- "env" - to get authentication details from environment varibales
- "cli" - to use Azure CLI authentication details
... | Authenticate using multiple authentication sources.
Parameters
silent
Whether to display any output during auth process. Default is False.
Returns
AzCredentials
Named tuple of:
legacy (ADAL) credentials
modern (MSAL) credentials
Raises
CloudError
If chained token credential creation fails.
MsticpyAzureConnection... | [
"Authenticate",
"using",
"multiple",
"authentication",
"sources",
".",
"Parameters",
"silent",
"Whether",
"to",
"display",
"any",
"output",
"during",
"auth",
"process",
".",
"Default",
"is",
"False",
".",
"Returns",
"AzCredentials",
"Named",
"tuple",
"of",
":",
... | def az_connect_core(
auth_methods: List[str] = None, silent: bool = False
) -> AzCredentials:
if not auth_methods:
auth_methods = default_auth_methods()
try:
auths = [_AUTH_OPTIONS[meth] for meth in auth_methods]
except KeyError as err:
raise MsticpyAzureConnectionError(
... | [
"def",
"az_connect_core",
"(",
"auth_methods",
":",
"List",
"[",
"str",
"]",
"=",
"None",
",",
"silent",
":",
"bool",
"=",
"False",
")",
"->",
"AzCredentials",
":",
"if",
"not",
"auth_methods",
":",
"auth_methods",
"=",
"default_auth_methods",
"(",
")",
"t... | Authenticate using multiple authentication sources. | [
"Authenticate",
"using",
"multiple",
"authentication",
"sources",
"."
] | [
"\"\"\"\n Authenticate using multiple authentication sources.\n\n Parameters\n ----------\n auth_methods\n List of authentication methods to try\n Possible options are:\n - \"env\" - to get authentication details from environment varibales\n - \"cli\" - to use Azure CLI authe... | [
{
"param": "auth_methods",
"type": "List[str]"
},
{
"param": "silent",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "auth_methods",
"type": "List[str]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "silent",
"type": "bool",
"docstring": null,
"d... |
27cd0d52e0eda9867ecfe223f9a2f52c162dc87d | JennySnyk/msticpy | msticpy/nbtools/ti_browser.py | [
"MIT"
] | Python | _create_ti_agg_list | <not_specific> | def _create_ti_agg_list(
ti_data: pd.DataFrame, severities: Union[List[str], str, None] = None
):
"""Aggregate ti results on IoC for multiple providers."""
if not severities:
severities = ["warning", "high"]
if severities == "all":
severities = ["information", "warning", "high"]
ti_d... | Aggregate ti results on IoC for multiple providers. | Aggregate ti results on IoC for multiple providers. | [
"Aggregate",
"ti",
"results",
"on",
"IoC",
"for",
"multiple",
"providers",
"."
] | def _create_ti_agg_list(
ti_data: pd.DataFrame, severities: Union[List[str], str, None] = None
):
if not severities:
severities = ["warning", "high"]
if severities == "all":
severities = ["information", "warning", "high"]
ti_data["Details"] = ti_data.apply(lambda x: _label_col_dict(x, "D... | [
"def",
"_create_ti_agg_list",
"(",
"ti_data",
":",
"pd",
".",
"DataFrame",
",",
"severities",
":",
"Union",
"[",
"List",
"[",
"str",
"]",
",",
"str",
",",
"None",
"]",
"=",
"None",
")",
":",
"if",
"not",
"severities",
":",
"severities",
"=",
"[",
"\"... | Aggregate ti results on IoC for multiple providers. | [
"Aggregate",
"ti",
"results",
"on",
"IoC",
"for",
"multiple",
"providers",
"."
] | [
"\"\"\"Aggregate ti results on IoC for multiple providers.\"\"\""
] | [
{
"param": "ti_data",
"type": "pd.DataFrame"
},
{
"param": "severities",
"type": "Union[List[str], str, None]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ti_data",
"type": "pd.DataFrame",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "severities",
"type": "Union[List[str], str, None]",
"d... |
27cd0d52e0eda9867ecfe223f9a2f52c162dc87d | JennySnyk/msticpy | msticpy/nbtools/ti_browser.py | [
"MIT"
] | Python | _label_col_dict | <not_specific> | def _label_col_dict(row: pd.Series, column: str):
"""Add label from the Provider column to the details."""
if not isinstance(row[column], dict):
return row[column]
return (
{row.Provider: row[column]} if row.Provider not in row[column] else row[column]
) | Add label from the Provider column to the details. | Add label from the Provider column to the details. | [
"Add",
"label",
"from",
"the",
"Provider",
"column",
"to",
"the",
"details",
"."
] | def _label_col_dict(row: pd.Series, column: str):
if not isinstance(row[column], dict):
return row[column]
return (
{row.Provider: row[column]} if row.Provider not in row[column] else row[column]
) | [
"def",
"_label_col_dict",
"(",
"row",
":",
"pd",
".",
"Series",
",",
"column",
":",
"str",
")",
":",
"if",
"not",
"isinstance",
"(",
"row",
"[",
"column",
"]",
",",
"dict",
")",
":",
"return",
"row",
"[",
"column",
"]",
"return",
"(",
"{",
"row",
... | Add label from the Provider column to the details. | [
"Add",
"label",
"from",
"the",
"Provider",
"column",
"to",
"the",
"details",
"."
] | [
"\"\"\"Add label from the Provider column to the details.\"\"\""
] | [
{
"param": "row",
"type": "pd.Series"
},
{
"param": "column",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "row",
"type": "pd.Series",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "column",
"type": "str",
"docstring": null,
"docstring_t... |
27cd0d52e0eda9867ecfe223f9a2f52c162dc87d | JennySnyk/msticpy | msticpy/nbtools/ti_browser.py | [
"MIT"
] | Python | ti_details_display | <not_specific> | def ti_details_display(ti_data):
"""Return TI Details display function."""
def get_ti_details(ioc_prov):
"""Display TI records from individual TI entry."""
ioc, provs = ioc_prov
results = []
h2_style = "border: 1px solid;background-color: DarkGray; padding: 6px"
h3_style... | Return TI Details display function. | Return TI Details display function. | [
"Return",
"TI",
"Details",
"display",
"function",
"."
] | def ti_details_display(ti_data):
def get_ti_details(ioc_prov):
ioc, provs = ioc_prov
results = []
h2_style = "border: 1px solid;background-color: DarkGray; padding: 6px"
h3_style = "background-color: SteelBlue; padding: 6px"
results.append(f"<h2 style='{h2_style}'>{ioc}</h2>"... | [
"def",
"ti_details_display",
"(",
"ti_data",
")",
":",
"def",
"get_ti_details",
"(",
"ioc_prov",
")",
":",
"\"\"\"Display TI records from individual TI entry.\"\"\"",
"ioc",
",",
"provs",
"=",
"ioc_prov",
"results",
"=",
"[",
"]",
"h2_style",
"=",
"\"border: 1px solid... | Return TI Details display function. | [
"Return",
"TI",
"Details",
"display",
"function",
"."
] | [
"\"\"\"Return TI Details display function.\"\"\"",
"\"\"\"Display TI records from individual TI entry.\"\"\""
] | [
{
"param": "ti_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ti_data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
27cd0d52e0eda9867ecfe223f9a2f52c162dc87d | JennySnyk/msticpy | msticpy/nbtools/ti_browser.py | [
"MIT"
] | Python | raw_results | str | def raw_results(raw_result: str) -> str:
"""Create pre-formatted details for raw results."""
fmt_details = (
pprint.pformat(raw_result).replace("\n", "<br>").replace(" ", " ")
)
return f"""
<details>
<summary> <u>Raw results from provider...</u></summary>
<pre style... | Create pre-formatted details for raw results. | Create pre-formatted details for raw results. | [
"Create",
"pre",
"-",
"formatted",
"details",
"for",
"raw",
"results",
"."
] | def raw_results(raw_result: str) -> str:
fmt_details = (
pprint.pformat(raw_result).replace("\n", "<br>").replace(" ", " ")
)
return f"""
<details>
<summary> <u>Raw results from provider...</u></summary>
<pre style="font-size:11px">{fmt_details}</pre>
</details>... | [
"def",
"raw_results",
"(",
"raw_result",
":",
"str",
")",
"->",
"str",
":",
"fmt_details",
"=",
"(",
"pprint",
".",
"pformat",
"(",
"raw_result",
")",
".",
"replace",
"(",
"\"\\n\"",
",",
"\"<br>\"",
")",
".",
"replace",
"(",
"\" \"",
",",
"\" \"",
... | Create pre-formatted details for raw results. | [
"Create",
"pre",
"-",
"formatted",
"details",
"for",
"raw",
"results",
"."
] | [
"\"\"\"Create pre-formatted details for raw results.\"\"\""
] | [
{
"param": "raw_result",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "raw_result",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
27cd0d52e0eda9867ecfe223f9a2f52c162dc87d | JennySnyk/msticpy | msticpy/nbtools/ti_browser.py | [
"MIT"
] | Python | _ti_detail_table | str | def _ti_detail_table(detail_dict: dict) -> str:
"""Return table of ti details."""
return "".join(
[
_TI_TABLE_STYLE,
"<table class='tb_ti_res'>",
*_dict_to_html(detail_dict),
"</table>",
]
) | Return table of ti details. | Return table of ti details. | [
"Return",
"table",
"of",
"ti",
"details",
"."
] | def _ti_detail_table(detail_dict: dict) -> str:
return "".join(
[
_TI_TABLE_STYLE,
"<table class='tb_ti_res'>",
*_dict_to_html(detail_dict),
"</table>",
]
) | [
"def",
"_ti_detail_table",
"(",
"detail_dict",
":",
"dict",
")",
"->",
"str",
":",
"return",
"\"\"",
".",
"join",
"(",
"[",
"_TI_TABLE_STYLE",
",",
"\"<table class='tb_ti_res'>\"",
",",
"*",
"_dict_to_html",
"(",
"detail_dict",
")",
",",
"\"</table>\"",
",",
"... | Return table of ti details. | [
"Return",
"table",
"of",
"ti",
"details",
"."
] | [
"\"\"\"Return table of ti details.\"\"\""
] | [
{
"param": "detail_dict",
"type": "dict"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "detail_dict",
"type": "dict",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
787eb63eec89e10a5c8bc664ca16f1331d8cd1a3 | JennySnyk/msticpy | msticpy/data/drivers/local_data_driver.py | [
"MIT"
] | Python | _get_data_paths | Dict[str, str] | def _get_data_paths(self) -> Dict[str, str]:
"""Read files in data paths."""
data_files = {}
for path in self._paths:
for pattern in ["**/*.pkl", "**/*.csv"]:
found_files = list(Path(path).resolve().glob(pattern))
data_files.update(
... | Read files in data paths. | Read files in data paths. | [
"Read",
"files",
"in",
"data",
"paths",
"."
] | def _get_data_paths(self) -> Dict[str, str]:
data_files = {}
for path in self._paths:
for pattern in ["**/*.pkl", "**/*.csv"]:
found_files = list(Path(path).resolve().glob(pattern))
data_files.update(
{
str(file_path... | [
"def",
"_get_data_paths",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"data_files",
"=",
"{",
"}",
"for",
"path",
"in",
"self",
".",
"_paths",
":",
"for",
"pattern",
"in",
"[",
"\"**/*.pkl\"",
",",
"\"**/*.csv\"",
"]",
":",
"fou... | Read files in data paths. | [
"Read",
"files",
"in",
"data",
"paths",
"."
] | [
"\"\"\"Read files in data paths.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
787eb63eec89e10a5c8bc664ca16f1331d8cd1a3 | JennySnyk/msticpy | msticpy/data/drivers/local_data_driver.py | [
"MIT"
] | Python | connect | null | def connect(self, connection_str: Optional[str] = None, **kwargs):
"""
Connect to data source.
Parameters
----------
connection_str : str
Connect to a data source
"""
del connection_str
self._connected = True
print("Connected.") |
Connect to data source.
Parameters
----------
connection_str : str
Connect to a data source
| Connect to data source.
Parameters
connection_str : str
Connect to a data source | [
"Connect",
"to",
"data",
"source",
".",
"Parameters",
"connection_str",
":",
"str",
"Connect",
"to",
"a",
"data",
"source"
] | def connect(self, connection_str: Optional[str] = None, **kwargs):
del connection_str
self._connected = True
print("Connected.") | [
"def",
"connect",
"(",
"self",
",",
"connection_str",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"del",
"connection_str",
"self",
".",
"_connected",
"=",
"True",
"print",
"(",
"\"Connected.\"",
")"
] | Connect to data source. | [
"Connect",
"to",
"data",
"source",
"."
] | [
"\"\"\"\n Connect to data source.\n\n Parameters\n ----------\n connection_str : str\n Connect to a data source\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "connection_str",
"type": "Optional[str]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "connection_str",
"type": "Optional[str]",
"docstring": null,
... |
787eb63eec89e10a5c8bc664ca16f1331d8cd1a3 | JennySnyk/msticpy | msticpy/data/drivers/local_data_driver.py | [
"MIT"
] | Python | schema | Dict[str, Dict] | def schema(self) -> Dict[str, Dict]:
"""
Return current data schema of connection.
Returns
-------
Dict[str, Dict]
Data schema of current connection.
"""
if self._schema:
return self._schema
for df_fname in self.data_files:
... |
Return current data schema of connection.
Returns
-------
Dict[str, Dict]
Data schema of current connection.
| Return current data schema of connection.
Returns
Dict[str, Dict]
Data schema of current connection. | [
"Return",
"current",
"data",
"schema",
"of",
"connection",
".",
"Returns",
"Dict",
"[",
"str",
"Dict",
"]",
"Data",
"schema",
"of",
"current",
"connection",
"."
] | def schema(self) -> Dict[str, Dict]:
if self._schema:
return self._schema
for df_fname in self.data_files:
test_df = self.query(df_fname)
if not isinstance(test_df, pd.DataFrame):
continue
df_schema = test_df.dtypes
self._schema... | [
"def",
"schema",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Dict",
"]",
":",
"if",
"self",
".",
"_schema",
":",
"return",
"self",
".",
"_schema",
"for",
"df_fname",
"in",
"self",
".",
"data_files",
":",
"test_df",
"=",
"self",
".",
"query",
... | Return current data schema of connection. | [
"Return",
"current",
"data",
"schema",
"of",
"connection",
"."
] | [
"\"\"\"\n Return current data schema of connection.\n\n Returns\n -------\n Dict[str, Dict]\n Data schema of current connection.\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
787eb63eec89e10a5c8bc664ca16f1331d8cd1a3 | JennySnyk/msticpy | msticpy/data/drivers/local_data_driver.py | [
"MIT"
] | Python | query | Union[pd.DataFrame, Any] | def query(
self, query: str, query_source: QuerySource = None, **kwargs
) -> Union[pd.DataFrame, Any]:
"""
Execute query string and return DataFrame of results.
Parameters
----------
query : str
The query to execute
query_source : QuerySource
... |
Execute query string and return DataFrame of results.
Parameters
----------
query : str
The query to execute
query_source : QuerySource
The query definition object
Returns
-------
Union[pd.DataFrame, results.ResultSet]
... | Execute query string and return DataFrame of results.
Parameters
query : str
The query to execute
query_source : QuerySource
The query definition object
Returns
Union[pd.DataFrame, results.ResultSet]
A DataFrame (if successfull) or
the underlying provider result if an error. | [
"Execute",
"query",
"string",
"and",
"return",
"DataFrame",
"of",
"results",
".",
"Parameters",
"query",
":",
"str",
"The",
"query",
"to",
"execute",
"query_source",
":",
"QuerySource",
"The",
"query",
"definition",
"object",
"Returns",
"Union",
"[",
"pd",
"."... | def query(
self, query: str, query_source: QuerySource = None, **kwargs
) -> Union[pd.DataFrame, Any]:
del kwargs
query_name = query_source.name if query_source else query
file_path = self.data_files.get(query.casefold())
if not file_path:
raise FileNotFoundError(... | [
"def",
"query",
"(",
"self",
",",
"query",
":",
"str",
",",
"query_source",
":",
"QuerySource",
"=",
"None",
",",
"**",
"kwargs",
")",
"->",
"Union",
"[",
"pd",
".",
"DataFrame",
",",
"Any",
"]",
":",
"del",
"kwargs",
"query_name",
"=",
"query_source",... | Execute query string and return DataFrame of results. | [
"Execute",
"query",
"string",
"and",
"return",
"DataFrame",
"of",
"results",
"."
] | [
"\"\"\"\n Execute query string and return DataFrame of results.\n\n Parameters\n ----------\n query : str\n The query to execute\n query_source : QuerySource\n The query definition object\n\n Returns\n -------\n Union[pd.DataFrame, result... | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": "str"
},
{
"param": "query_source",
"type": "QuerySource"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": "str",
"docstring": null,
"docstring_tokens":... |
833b5d9f31d90f0b12c921d21c63dbb3687f6388 | JennySnyk/msticpy | msticpy/config/compound_ctrls.py | [
"MIT"
] | Python | _change_store | null | def _change_store(self, change):
"""Handle event for store type radio button."""
st_type = change.get("new")
self.txt_val.description = "Value" if st_type == STORE_TEXT else st_type
self._set_kv_visibility()
self.lbl_setting.value = st_type
if st_type == STORE_KEYVAULT an... | Handle event for store type radio button. | Handle event for store type radio button. | [
"Handle",
"event",
"for",
"store",
"type",
"radio",
"button",
"."
] | def _change_store(self, change):
st_type = change.get("new")
self.txt_val.description = "Value" if st_type == STORE_TEXT else st_type
self._set_kv_visibility()
self.lbl_setting.value = st_type
if st_type == STORE_KEYVAULT and not self.txt_val.value:
self.cb_kv_def.val... | [
"def",
"_change_store",
"(",
"self",
",",
"change",
")",
":",
"st_type",
"=",
"change",
".",
"get",
"(",
"\"new\"",
")",
"self",
".",
"txt_val",
".",
"description",
"=",
"\"Value\"",
"if",
"st_type",
"==",
"STORE_TEXT",
"else",
"st_type",
"self",
".",
"_... | Handle event for store type radio button. | [
"Handle",
"event",
"for",
"store",
"type",
"radio",
"button",
"."
] | [
"\"\"\"Handle event for store type radio button.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "change",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "change",
"type": null,
"docstring": null,
"docstring_tokens":... |
833b5d9f31d90f0b12c921d21c63dbb3687f6388 | JennySnyk/msticpy | msticpy/config/compound_ctrls.py | [
"MIT"
] | Python | _disable_txt | <not_specific> | def _disable_txt(self, change):
"""Disable the text field if KeyVault and kv_def_enabled."""
if self.rb_store_type.value != STORE_KEYVAULT:
return
kv_def_enabled = change.get("new")
if kv_def_enabled:
self.txt_val.value = ""
self.txt_val.disabled = kv_def_... | Disable the text field if KeyVault and kv_def_enabled. | Disable the text field if KeyVault and kv_def_enabled. | [
"Disable",
"the",
"text",
"field",
"if",
"KeyVault",
"and",
"kv_def_enabled",
"."
] | def _disable_txt(self, change):
if self.rb_store_type.value != STORE_KEYVAULT:
return
kv_def_enabled = change.get("new")
if kv_def_enabled:
self.txt_val.value = ""
self.txt_val.disabled = kv_def_enabled | [
"def",
"_disable_txt",
"(",
"self",
",",
"change",
")",
":",
"if",
"self",
".",
"rb_store_type",
".",
"value",
"!=",
"STORE_KEYVAULT",
":",
"return",
"kv_def_enabled",
"=",
"change",
".",
"get",
"(",
"\"new\"",
")",
"if",
"kv_def_enabled",
":",
"self",
"."... | Disable the text field if KeyVault and kv_def_enabled. | [
"Disable",
"the",
"text",
"field",
"if",
"KeyVault",
"and",
"kv_def_enabled",
"."
] | [
"\"\"\"Disable the text field if KeyVault and kv_def_enabled.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "change",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "change",
"type": null,
"docstring": null,
"docstring_tokens":... |
833b5d9f31d90f0b12c921d21c63dbb3687f6388 | JennySnyk/msticpy | msticpy/config/compound_ctrls.py | [
"MIT"
] | Python | _set_kv_visibility | null | def _set_kv_visibility(self):
"""Set the visibility of the keyvault-related controls."""
if self.rb_store_type.value == STORE_KEYVAULT:
self.cb_kv_def.layout.visibility = "visible"
self.btn_add_kv_secret.layout.visibility = "hidden"
else:
self.cb_kv_def.layout... | Set the visibility of the keyvault-related controls. | Set the visibility of the keyvault-related controls. | [
"Set",
"the",
"visibility",
"of",
"the",
"keyvault",
"-",
"related",
"controls",
"."
] | def _set_kv_visibility(self):
if self.rb_store_type.value == STORE_KEYVAULT:
self.cb_kv_def.layout.visibility = "visible"
self.btn_add_kv_secret.layout.visibility = "hidden"
else:
self.cb_kv_def.layout.visibility = "hidden"
self.btn_add_kv_secret.layout.vi... | [
"def",
"_set_kv_visibility",
"(",
"self",
")",
":",
"if",
"self",
".",
"rb_store_type",
".",
"value",
"==",
"STORE_KEYVAULT",
":",
"self",
".",
"cb_kv_def",
".",
"layout",
".",
"visibility",
"=",
"\"visible\"",
"self",
".",
"btn_add_kv_secret",
".",
"layout",
... | Set the visibility of the keyvault-related controls. | [
"Set",
"the",
"visibility",
"of",
"the",
"keyvault",
"-",
"related",
"controls",
"."
] | [
"\"\"\"Set the visibility of the keyvault-related controls.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
833b5d9f31d90f0b12c921d21c63dbb3687f6388 | JennySnyk/msticpy | msticpy/config/compound_ctrls.py | [
"MIT"
] | Python | _set_kv_secret | <not_specific> | def _set_kv_secret(self, btn):
"""Try to store the current value to key vault."""
del btn
if not self.setting_path:
self.set_status("No setting path to create KV secret name.")
return
sec_value = None
if self.rb_store_type.value == STORE_TEXT:
... | Try to store the current value to key vault. | Try to store the current value to key vault. | [
"Try",
"to",
"store",
"the",
"current",
"value",
"to",
"key",
"vault",
"."
] | def _set_kv_secret(self, btn):
del btn
if not self.setting_path:
self.set_status("No setting path to create KV secret name.")
return
sec_value = None
if self.rb_store_type.value == STORE_TEXT:
sec_value = self.txt_val.value
elif self.rb_store_t... | [
"def",
"_set_kv_secret",
"(",
"self",
",",
"btn",
")",
":",
"del",
"btn",
"if",
"not",
"self",
".",
"setting_path",
":",
"self",
".",
"set_status",
"(",
"\"No setting path to create KV secret name.\"",
")",
"return",
"sec_value",
"=",
"None",
"if",
"self",
"."... | Try to store the current value to key vault. | [
"Try",
"to",
"store",
"the",
"current",
"value",
"to",
"key",
"vault",
"."
] | [
"\"\"\"Try to store the current value to key vault.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "btn",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "btn",
"type": null,
"docstring": null,
"docstring_tokens": []... |
833b5d9f31d90f0b12c921d21c63dbb3687f6388 | JennySnyk/msticpy | msticpy/config/compound_ctrls.py | [
"MIT"
] | Python | _set_kv_secret_value | Tuple[bool, str, Any] | def _set_kv_secret_value(
setting_path: str,
item_name: str,
value: str,
kv_client: Any = None,
) -> Tuple[bool, str, Any]:
"""Return empty response function if Key Vault cannot be initialized."""
del setting_path, item_name, value, kv_client
return False, "Az... | Return empty response function if Key Vault cannot be initialized. | Return empty response function if Key Vault cannot be initialized. | [
"Return",
"empty",
"response",
"function",
"if",
"Key",
"Vault",
"cannot",
"be",
"initialized",
"."
] | def _set_kv_secret_value(
setting_path: str,
item_name: str,
value: str,
kv_client: Any = None,
) -> Tuple[bool, str, Any]:
del setting_path, item_name, value, kv_client
return False, "Azure keyvault libraries are not installed", None | [
"def",
"_set_kv_secret_value",
"(",
"setting_path",
":",
"str",
",",
"item_name",
":",
"str",
",",
"value",
":",
"str",
",",
"kv_client",
":",
"Any",
"=",
"None",
",",
")",
"->",
"Tuple",
"[",
"bool",
",",
"str",
",",
"Any",
"]",
":",
"del",
"setting... | Return empty response function if Key Vault cannot be initialized. | [
"Return",
"empty",
"response",
"function",
"if",
"Key",
"Vault",
"cannot",
"be",
"initialized",
"."
] | [
"\"\"\"Return empty response function if Key Vault cannot be initialized.\"\"\""
] | [
{
"param": "setting_path",
"type": "str"
},
{
"param": "item_name",
"type": "str"
},
{
"param": "value",
"type": "str"
},
{
"param": "kv_client",
"type": "Any"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "setting_path",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "item_name",
"type": "str",
"docstring": null,
"docst... |
833b5d9f31d90f0b12c921d21c63dbb3687f6388 | JennySnyk/msticpy | msticpy/config/compound_ctrls.py | [
"MIT"
] | Python | _set_prov_name | null | def _set_prov_name(self, prov_name):
"""
Set the provider name.
Notes
-----
The provider name can be a simple string or a compound,
dotted string (in the case of AzureSentinel it will be of the form
AzureSentinel.WorkspaceName)
"""
self.prov_name... |
Set the provider name.
Notes
-----
The provider name can be a simple string or a compound,
dotted string (in the case of AzureSentinel it will be of the form
AzureSentinel.WorkspaceName)
| Set the provider name.
Notes
The provider name can be a simple string or a compound,
dotted string (in the case of AzureSentinel it will be of the form
AzureSentinel.WorkspaceName) | [
"Set",
"the",
"provider",
"name",
".",
"Notes",
"The",
"provider",
"name",
"can",
"be",
"a",
"simple",
"string",
"or",
"a",
"compound",
"dotted",
"string",
"(",
"in",
"the",
"case",
"of",
"AzureSentinel",
"it",
"will",
"be",
"of",
"the",
"form",
"AzureSe... | def _set_prov_name(self, prov_name):
self.prov_name = prov_name
self.prov_type = "Workspace" if "." in prov_name else "Provider"
self.lbl_type = widgets.Label(
value=f"{self.prov_name} ({self.prov_type})",
layout=widgets.Layout(width="300px"),
) | [
"def",
"_set_prov_name",
"(",
"self",
",",
"prov_name",
")",
":",
"self",
".",
"prov_name",
"=",
"prov_name",
"self",
".",
"prov_type",
"=",
"\"Workspace\"",
"if",
"\".\"",
"in",
"prov_name",
"else",
"\"Provider\"",
"self",
".",
"lbl_type",
"=",
"widgets",
"... | Set the provider name. | [
"Set",
"the",
"provider",
"name",
"."
] | [
"\"\"\"\n Set the provider name.\n\n Notes\n -----\n The provider name can be a simple string or a compound,\n dotted string (in the case of AzureSentinel it will be of the form\n AzureSentinel.WorkspaceName)\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "prov_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prov_name",
"type": null,
"docstring": null,
"docstring_token... |
833b5d9f31d90f0b12c921d21c63dbb3687f6388 | JennySnyk/msticpy | msticpy/config/compound_ctrls.py | [
"MIT"
] | Python | value | Union[str, Dict[str, Optional[str]]] | def value(self) -> Union[str, Dict[str, Optional[str]]]:
"""
Return the current value of the control.
Returns
-------
Union[str, Dict[str, Optional[str]]]
The value dict.
In cases where optional 'alias' and 'connect' settings
are not used this... |
Return the current value of the control.
Returns
-------
Union[str, Dict[str, Optional[str]]]
The value dict.
In cases where optional 'alias' and 'connect' settings
are not used this will be an empty dictionary.
| Return the current value of the control.
Returns
| [
"Return",
"the",
"current",
"value",
"of",
"the",
"control",
".",
"Returns"
] | def value(self) -> Union[str, Dict[str, Optional[str]]]:
alias = {"alias": self.txt_alias.value} if self.txt_alias.value else {}
connect = (
{"connect": self.cb_connect.value} if not self.cb_connect.value else {}
)
return {**alias, **connect} | [
"def",
"value",
"(",
"self",
")",
"->",
"Union",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Optional",
"[",
"str",
"]",
"]",
"]",
":",
"alias",
"=",
"{",
"\"alias\"",
":",
"self",
".",
"txt_alias",
".",
"value",
"}",
"if",
"self",
".",
"txt_alias... | Return the current value of the control. | [
"Return",
"the",
"current",
"value",
"of",
"the",
"control",
"."
] | [
"\"\"\"\n Return the current value of the control.\n\n Returns\n -------\n Union[str, Dict[str, Optional[str]]]\n The value dict.\n In cases where optional 'alias' and 'connect' settings\n are not used this will be an empty dictionary.\n\n \"\"\""
... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
833b5d9f31d90f0b12c921d21c63dbb3687f6388 | JennySnyk/msticpy | msticpy/config/compound_ctrls.py | [
"MIT"
] | Python | _add_control_to_map | null | def _add_control_to_map(self, path, ctrl):
"""Set a value at dotted path location in self.control_map dict."""
ctrl_path = path.replace(f"{self.comp_path}.", "")
ctrl_map = self.control_map
for elem in ctrl_path.split("."):
if not isinstance(ctrl_map.get(elem), dict):
... | Set a value at dotted path location in self.control_map dict. | Set a value at dotted path location in self.control_map dict. | [
"Set",
"a",
"value",
"at",
"dotted",
"path",
"location",
"in",
"self",
".",
"control_map",
"dict",
"."
] | def _add_control_to_map(self, path, ctrl):
ctrl_path = path.replace(f"{self.comp_path}.", "")
ctrl_map = self.control_map
for elem in ctrl_path.split("."):
if not isinstance(ctrl_map.get(elem), dict):
ctrl_map[elem] = ctrl
break
ctrl_map = ... | [
"def",
"_add_control_to_map",
"(",
"self",
",",
"path",
",",
"ctrl",
")",
":",
"ctrl_path",
"=",
"path",
".",
"replace",
"(",
"f\"{self.comp_path}.\"",
",",
"\"\"",
")",
"ctrl_map",
"=",
"self",
".",
"control_map",
"for",
"elem",
"in",
"ctrl_path",
".",
"s... | Set a value at dotted path location in self.control_map dict. | [
"Set",
"a",
"value",
"at",
"dotted",
"path",
"location",
"in",
"self",
".",
"control_map",
"dict",
"."
] | [
"\"\"\"Set a value at dotted path location in self.control_map dict.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "ctrl",
"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": [... |
833b5d9f31d90f0b12c921d21c63dbb3687f6388 | JennySnyk/msticpy | msticpy/config/compound_ctrls.py | [
"MIT"
] | Python | _get_val_from_ctrl | <not_specific> | def _get_val_from_ctrl(self, val_dict):
"""Recursive get values from control dictionary."""
ctrl_val = {}
if not val_dict:
return val_dict
for name, value in val_dict.items():
if isinstance(value, widgets.Label):
continue
if isinstance(... | Recursive get values from control dictionary. | Recursive get values from control dictionary. | [
"Recursive",
"get",
"values",
"from",
"control",
"dictionary",
"."
] | def _get_val_from_ctrl(self, val_dict):
ctrl_val = {}
if not val_dict:
return val_dict
for name, value in val_dict.items():
if isinstance(value, widgets.Label):
continue
if isinstance(value, dict):
ctrl_val[name] = self._get_val... | [
"def",
"_get_val_from_ctrl",
"(",
"self",
",",
"val_dict",
")",
":",
"ctrl_val",
"=",
"{",
"}",
"if",
"not",
"val_dict",
":",
"return",
"val_dict",
"for",
"name",
",",
"value",
"in",
"val_dict",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"va... | Recursive get values from control dictionary. | [
"Recursive",
"get",
"values",
"from",
"control",
"dictionary",
"."
] | [
"\"\"\"Recursive get values from control dictionary.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "val_dict",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "val_dict",
"type": null,
"docstring": null,
"docstring_tokens... |
62c190dd3fc6f15275aa028bf7b29e6db401a661 | jhpenger/joint-ppo | sonic_on_ray/sonic_on_ray.py | [
"Apache-2.0"
] | Python | make | <not_specific> | def make(game, state, stack=True, scale_rew=True, monitordir='logs/', bk2dir='videos/'):
"""
Create an environment with some standard wrappers.
"""
env = retro.make(game, state)
if bk2dir:
env.auto_record('videos/')
if monitordir:
#env = Monitor(env, os.path.join(monitordir, 'mon... |
Create an environment with some standard wrappers.
| Create an environment with some standard wrappers. | [
"Create",
"an",
"environment",
"with",
"some",
"standard",
"wrappers",
"."
] | def make(game, state, stack=True, scale_rew=True, monitordir='logs/', bk2dir='videos/'):
env = retro.make(game, state)
if bk2dir:
env.auto_record('videos/')
if monitordir:
time_int = int(time.time())
env = Monitor(env, os.path.join('monitor_{}.csv'.format(time_int)), os.path.join('lo... | [
"def",
"make",
"(",
"game",
",",
"state",
",",
"stack",
"=",
"True",
",",
"scale_rew",
"=",
"True",
",",
"monitordir",
"=",
"'logs/'",
",",
"bk2dir",
"=",
"'videos/'",
")",
":",
"env",
"=",
"retro",
".",
"make",
"(",
"game",
",",
"state",
")",
"if"... | Create an environment with some standard wrappers. | [
"Create",
"an",
"environment",
"with",
"some",
"standard",
"wrappers",
"."
] | [
"\"\"\"\n Create an environment with some standard wrappers.\n \"\"\"",
"#env = Monitor(env, os.path.join(monitordir, 'monitor.csv'), os.path.join(monitordir, 'log.csv'))"
] | [
{
"param": "game",
"type": null
},
{
"param": "state",
"type": null
},
{
"param": "stack",
"type": null
},
{
"param": "scale_rew",
"type": null
},
{
"param": "monitordir",
"type": null
},
{
"param": "bk2dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "game",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "state",
"type": null,
"docstring": null,
"docstring_tokens": ... |
106e5d0569862a77a6b62fcecda2f6c5a1e1b411 | cadamswaite/reference-pots-app | main.py | [
"MIT"
] | Python | do_auth | <not_specific> | def do_auth(self):
''' Perform OAuth2 flow mostly on command-line and retrieve information of the
authorised user's current account information, rather than from joint account,
if present.
'''
print("Starting OAuth2 flow...")
token = input("If you already have a... | Perform OAuth2 flow mostly on command-line and retrieve information of the
authorised user's current account information, rather than from joint account,
if present.
| Perform OAuth2 flow mostly on command-line and retrieve information of the
authorised user's current account information, rather than from joint account,
if present. | [
"Perform",
"OAuth2",
"flow",
"mostly",
"on",
"command",
"-",
"line",
"and",
"retrieve",
"information",
"of",
"the",
"authorised",
"user",
"'",
"s",
"current",
"account",
"information",
"rather",
"than",
"from",
"joint",
"account",
"if",
"present",
"."
] | def do_auth(self):
print("Starting OAuth2 flow...")
token = input("If you already have a token, enter it now, otherwise press enter to continue")
if token == "":
self._api_client.start_auth()
else:
self._api_client.existing_access_token(token)
print("OAuth... | [
"def",
"do_auth",
"(",
"self",
")",
":",
"print",
"(",
"\"Starting OAuth2 flow...\"",
")",
"token",
"=",
"input",
"(",
"\"If you already have a token, enter it now, otherwise press enter to continue\"",
")",
"if",
"token",
"==",
"\"\"",
":",
"self",
".",
"_api_client",
... | Perform OAuth2 flow mostly on command-line and retrieve information of the
authorised user's current account information, rather than from joint account,
if present. | [
"Perform",
"OAuth2",
"flow",
"mostly",
"on",
"command",
"-",
"line",
"and",
"retrieve",
"information",
"of",
"the",
"authorised",
"user",
"'",
"s",
"current",
"account",
"information",
"rather",
"than",
"from",
"joint",
"account",
"if",
"present",
"."
] | [
"''' Perform OAuth2 flow mostly on command-line and retrieve information of the\n authorised user's current account information, rather than from joint account, \n if present.\n '''",
"# We will be operating on personal account only."
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b2e36202780db2ebdc701b7d00949dfbd17eb93 | dsh0416/qiskit-terra | qiskit/mapper/_mapping.py | [
"Apache-2.0"
] | Python | direction_mapper | <not_specific> | def direction_mapper(circuit_graph, coupling_graph):
"""Change the direction of CNOT gates to conform to CouplingGraph.
circuit_graph = input DAGCircuit
coupling_graph = corresponding CouplingGraph
Adds "h" to the circuit basis.
Returns a DAGCircuit object containing a circuit equivalent to
c... | Change the direction of CNOT gates to conform to CouplingGraph.
circuit_graph = input DAGCircuit
coupling_graph = corresponding CouplingGraph
Adds "h" to the circuit basis.
Returns a DAGCircuit object containing a circuit equivalent to
circuit_graph but with CNOT gate directions matching the edge... | Change the direction of CNOT gates to conform to CouplingGraph.
Adds "h" to the circuit basis.
Returns a DAGCircuit object containing a circuit equivalent to
circuit_graph but with CNOT gate directions matching the edges
of coupling_graph. Raises an exception if the circuit_graph
does not conform to the coupling_grap... | [
"Change",
"the",
"direction",
"of",
"CNOT",
"gates",
"to",
"conform",
"to",
"CouplingGraph",
".",
"Adds",
"\"",
"h",
"\"",
"to",
"the",
"circuit",
"basis",
".",
"Returns",
"a",
"DAGCircuit",
"object",
"containing",
"a",
"circuit",
"equivalent",
"to",
"circui... | def direction_mapper(circuit_graph, coupling_graph):
if "cx" not in circuit_graph.basis:
return circuit_graph
if circuit_graph.basis["cx"] != (2, 0, 0):
raise MapperError("cx gate has unexpected signature %s" %
circuit_graph.basis["cx"])
flipped_cx_circuit = DAGCirc... | [
"def",
"direction_mapper",
"(",
"circuit_graph",
",",
"coupling_graph",
")",
":",
"if",
"\"cx\"",
"not",
"in",
"circuit_graph",
".",
"basis",
":",
"return",
"circuit_graph",
"if",
"circuit_graph",
".",
"basis",
"[",
"\"cx\"",
"]",
"!=",
"(",
"2",
",",
"0",
... | Change the direction of CNOT gates to conform to CouplingGraph. | [
"Change",
"the",
"direction",
"of",
"CNOT",
"gates",
"to",
"conform",
"to",
"CouplingGraph",
"."
] | [
"\"\"\"Change the direction of CNOT gates to conform to CouplingGraph.\n\n circuit_graph = input DAGCircuit\n coupling_graph = corresponding CouplingGraph\n\n Adds \"h\" to the circuit basis.\n\n Returns a DAGCircuit object containing a circuit equivalent to\n circuit_graph but with CNOT gate directi... | [
{
"param": "circuit_graph",
"type": null
},
{
"param": "coupling_graph",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "circuit_graph",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "coupling_graph",
"type": null,
"docstring": null,
"d... |
6b2e36202780db2ebdc701b7d00949dfbd17eb93 | dsh0416/qiskit-terra | qiskit/mapper/_mapping.py | [
"Apache-2.0"
] | Python | swap_mapper_layer_update | <not_specific> | def swap_mapper_layer_update(i, first_layer, best_layout, best_d,
best_circ, layer_list):
"""Update the QASM string for an iteration of swap_mapper.
i = layer number
first_layer = True if this is the first layer with multi-qubit gates
best_layout = layout returned from swap... | Update the QASM string for an iteration of swap_mapper.
i = layer number
first_layer = True if this is the first layer with multi-qubit gates
best_layout = layout returned from swap algorithm
best_d = depth returned from swap algorithm
best_circ = swap circuit returned from swap algorithm
layer... | Update the QASM string for an iteration of swap_mapper.
Return DAGCircuit object to append to the output DAGCircuit. | [
"Update",
"the",
"QASM",
"string",
"for",
"an",
"iteration",
"of",
"swap_mapper",
".",
"Return",
"DAGCircuit",
"object",
"to",
"append",
"to",
"the",
"output",
"DAGCircuit",
"."
] | def swap_mapper_layer_update(i, first_layer, best_layout, best_d,
best_circ, layer_list):
layout = best_layout
layout_max_index = max(map(lambda x: x[1]+1, layout.values()))
dagcircuit_output = DAGCircuit()
dagcircuit_output.add_qreg("q", layout_max_index)
identity_wire_... | [
"def",
"swap_mapper_layer_update",
"(",
"i",
",",
"first_layer",
",",
"best_layout",
",",
"best_d",
",",
"best_circ",
",",
"layer_list",
")",
":",
"layout",
"=",
"best_layout",
"layout_max_index",
"=",
"max",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
"[",
... | Update the QASM string for an iteration of swap_mapper. | [
"Update",
"the",
"QASM",
"string",
"for",
"an",
"iteration",
"of",
"swap_mapper",
"."
] | [
"\"\"\"Update the QASM string for an iteration of swap_mapper.\n\n i = layer number\n first_layer = True if this is the first layer with multi-qubit gates\n best_layout = layout returned from swap algorithm\n best_d = depth returned from swap algorithm\n best_circ = swap circuit returned from swap al... | [
{
"param": "i",
"type": null
},
{
"param": "first_layer",
"type": null
},
{
"param": "best_layout",
"type": null
},
{
"param": "best_d",
"type": null
},
{
"param": "best_circ",
"type": null
},
{
"param": "layer_list",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "i",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "first_layer",
"type": null,
"docstring": null,
"docstring_tokens... |
6b2e36202780db2ebdc701b7d00949dfbd17eb93 | dsh0416/qiskit-terra | qiskit/mapper/_mapping.py | [
"Apache-2.0"
] | Python | swap_mapper | <not_specific> | def swap_mapper(circuit_graph, coupling_graph,
initial_layout=None,
basis="cx,u1,u2,u3,id", trials=20, seed=None):
"""Map a DAGCircuit onto a CouplingGraph using swap gates.
Args:
circuit_graph (DAGCircuit): input DAG circuit
coupling_graph (CouplingGraph): coupl... | Map a DAGCircuit onto a CouplingGraph using swap gates.
Args:
circuit_graph (DAGCircuit): input DAG circuit
coupling_graph (CouplingGraph): coupling graph to map onto
initial_layout (dict): dict from qubits of circuit_graph to qubits
of coupling_graph (optional)
basis (s... | Map a DAGCircuit onto a CouplingGraph using swap gates. | [
"Map",
"a",
"DAGCircuit",
"onto",
"a",
"CouplingGraph",
"using",
"swap",
"gates",
"."
] | def swap_mapper(circuit_graph, coupling_graph,
initial_layout=None,
basis="cx,u1,u2,u3,id", trials=20, seed=None):
if circuit_graph.width() > coupling_graph.size():
raise MapperError("Not enough qubits in CouplingGraph")
layerlist = list(circuit_graph.layers())
logger... | [
"def",
"swap_mapper",
"(",
"circuit_graph",
",",
"coupling_graph",
",",
"initial_layout",
"=",
"None",
",",
"basis",
"=",
"\"cx,u1,u2,u3,id\"",
",",
"trials",
"=",
"20",
",",
"seed",
"=",
"None",
")",
":",
"if",
"circuit_graph",
".",
"width",
"(",
")",
">"... | Map a DAGCircuit onto a CouplingGraph using swap gates. | [
"Map",
"a",
"DAGCircuit",
"onto",
"a",
"CouplingGraph",
"using",
"swap",
"gates",
"."
] | [
"\"\"\"Map a DAGCircuit onto a CouplingGraph using swap gates.\n\n Args:\n circuit_graph (DAGCircuit): input DAG circuit\n coupling_graph (CouplingGraph): coupling graph to map onto\n initial_layout (dict): dict from qubits of circuit_graph to qubits\n of coupling_graph (optional)... | [
{
"param": "circuit_graph",
"type": null
},
{
"param": "coupling_graph",
"type": null
},
{
"param": "initial_layout",
"type": null
},
{
"param": "basis",
"type": null
},
{
"param": "trials",
"type": null
},
{
"param": "seed",
"type": null
}
] | {
"returns": [
{
"docstring": "object containing a circuit equivalent to\ncircuit_graph that respects couplings in coupling_graph, and\na layout dict mapping qubits of circuit_graph into qubits\nof coupling_graph. The layout may differ from the initial_layout\nif the first layer of gates cannot be executed ... |
6b2e36202780db2ebdc701b7d00949dfbd17eb93 | dsh0416/qiskit-terra | qiskit/mapper/_mapping.py | [
"Apache-2.0"
] | Python | optimize_1q_gates | <not_specific> | def optimize_1q_gates(circuit):
"""Simplify runs of single qubit gates in the QX basis.
Return a new circuit that has been optimized.
"""
qx_basis = ["u1", "u2", "u3", "cx", "id"]
dag_unroller = DagUnroller(circuit, DAGBackend(qx_basis))
unrolled = dag_unroller.expand_gates()
runs = unroll... | Simplify runs of single qubit gates in the QX basis.
Return a new circuit that has been optimized.
| Simplify runs of single qubit gates in the QX basis.
Return a new circuit that has been optimized. | [
"Simplify",
"runs",
"of",
"single",
"qubit",
"gates",
"in",
"the",
"QX",
"basis",
".",
"Return",
"a",
"new",
"circuit",
"that",
"has",
"been",
"optimized",
"."
] | def optimize_1q_gates(circuit):
qx_basis = ["u1", "u2", "u3", "cx", "id"]
dag_unroller = DagUnroller(circuit, DAGBackend(qx_basis))
unrolled = dag_unroller.expand_gates()
runs = unrolled.collect_runs(["u1", "u2", "u3", "id"])
for run in runs:
qname = unrolled.multi_graph.node[run[0]]["qargs"... | [
"def",
"optimize_1q_gates",
"(",
"circuit",
")",
":",
"qx_basis",
"=",
"[",
"\"u1\"",
",",
"\"u2\"",
",",
"\"u3\"",
",",
"\"cx\"",
",",
"\"id\"",
"]",
"dag_unroller",
"=",
"DagUnroller",
"(",
"circuit",
",",
"DAGBackend",
"(",
"qx_basis",
")",
")",
"unroll... | Simplify runs of single qubit gates in the QX basis. | [
"Simplify",
"runs",
"of",
"single",
"qubit",
"gates",
"in",
"the",
"QX",
"basis",
"."
] | [
"\"\"\"Simplify runs of single qubit gates in the QX basis.\n\n Return a new circuit that has been optimized.\n \"\"\"",
"# (theta, phi, lambda)",
"# replace id with u1",
"# Compose gates",
"# u1(lambda1) * u1(lambda2) = u1(lambda1 + lambda2)",
"# u1(lambda1) * u2(phi2, lambda2) = u2(phi2 + lambda1,... | [
{
"param": "circuit",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "circuit",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b2e36202780db2ebdc701b7d00949dfbd17eb93 | dsh0416/qiskit-terra | qiskit/mapper/_mapping.py | [
"Apache-2.0"
] | Python | remove_last_measurements | <not_specific> | def remove_last_measurements(dag_circuit, perform_remove=True):
"""Removes all measurements that occur as the last operation
on a given qubit for a DAG circuit. Measurements that are followed by
additional gates are untouched.
This operation is done in-place on the input DAG circuit if perform_pop=Tru... | Removes all measurements that occur as the last operation
on a given qubit for a DAG circuit. Measurements that are followed by
additional gates are untouched.
This operation is done in-place on the input DAG circuit if perform_pop=True.
Parameters:
dag_circuit (qiskit.dagcircuit._dagcircuit.... | Removes all measurements that occur as the last operation
on a given qubit for a DAG circuit. Measurements that are followed by
additional gates are untouched.
This operation is done in-place on the input DAG circuit if perform_pop=True. | [
"Removes",
"all",
"measurements",
"that",
"occur",
"as",
"the",
"last",
"operation",
"on",
"a",
"given",
"qubit",
"for",
"a",
"DAG",
"circuit",
".",
"Measurements",
"that",
"are",
"followed",
"by",
"additional",
"gates",
"are",
"untouched",
".",
"This",
"ope... | def remove_last_measurements(dag_circuit, perform_remove=True):
removed_meas = []
try:
meas_nodes = dag_circuit.get_named_nodes('measure')
except DAGCircuitError:
return removed_meas
for idx in meas_nodes:
_, succ_map = dag_circuit._make_pred_succ_maps(idx)
if len(succ_ma... | [
"def",
"remove_last_measurements",
"(",
"dag_circuit",
",",
"perform_remove",
"=",
"True",
")",
":",
"removed_meas",
"=",
"[",
"]",
"try",
":",
"meas_nodes",
"=",
"dag_circuit",
".",
"get_named_nodes",
"(",
"'measure'",
")",
"except",
"DAGCircuitError",
":",
"re... | Removes all measurements that occur as the last operation
on a given qubit for a DAG circuit. | [
"Removes",
"all",
"measurements",
"that",
"occur",
"as",
"the",
"last",
"operation",
"on",
"a",
"given",
"qubit",
"for",
"a",
"DAG",
"circuit",
"."
] | [
"\"\"\"Removes all measurements that occur as the last operation\n on a given qubit for a DAG circuit. Measurements that are followed by\n additional gates are untouched.\n\n This operation is done in-place on the input DAG circuit if perform_pop=True.\n\n Parameters:\n dag_circuit (qiskit.dagci... | [
{
"param": "dag_circuit",
"type": null
},
{
"param": "perform_remove",
"type": null
}
] | {
"returns": [
{
"docstring": "List of all measurements that were removed.",
"docstring_tokens": [
"List",
"of",
"all",
"measurements",
"that",
"were",
"removed",
"."
],
"type": "list"
}
],
"raises": [],
"params": [
... |
6b2e36202780db2ebdc701b7d00949dfbd17eb93 | dsh0416/qiskit-terra | qiskit/mapper/_mapping.py | [
"Apache-2.0"
] | Python | return_last_measurements | null | def return_last_measurements(dag_circuit, removed_meas, final_layout):
"""Returns the measurements to a quantum circuit, removed by
`remove_last_measurements` after the swap mapper is finished.
This operation is done in-place on the input DAG circuit.
Parameters:
dag_circuit (qiskit.dagcircuit... | Returns the measurements to a quantum circuit, removed by
`remove_last_measurements` after the swap mapper is finished.
This operation is done in-place on the input DAG circuit.
Parameters:
dag_circuit (qiskit.dagcircuit._dagcircuit.DAGCircuit): DAG circuit.
removed_meas (list): List of me... | Returns the measurements to a quantum circuit, removed by
`remove_last_measurements` after the swap mapper is finished.
This operation is done in-place on the input DAG circuit. | [
"Returns",
"the",
"measurements",
"to",
"a",
"quantum",
"circuit",
"removed",
"by",
"`",
"remove_last_measurements",
"`",
"after",
"the",
"swap",
"mapper",
"is",
"finished",
".",
"This",
"operation",
"is",
"done",
"in",
"-",
"place",
"on",
"the",
"input",
"D... | def return_last_measurements(dag_circuit, removed_meas, final_layout):
if any(removed_meas) and 'measure' not in dag_circuit.basis.keys():
dag_circuit.add_basis_element("measure", 1, 1, 0)
for meas in removed_meas:
new_q_label = final_layout[meas['qargs'][0]]
dag_circuit.apply_operation_... | [
"def",
"return_last_measurements",
"(",
"dag_circuit",
",",
"removed_meas",
",",
"final_layout",
")",
":",
"if",
"any",
"(",
"removed_meas",
")",
"and",
"'measure'",
"not",
"in",
"dag_circuit",
".",
"basis",
".",
"keys",
"(",
")",
":",
"dag_circuit",
".",
"a... | Returns the measurements to a quantum circuit, removed by
`remove_last_measurements` after the swap mapper is finished. | [
"Returns",
"the",
"measurements",
"to",
"a",
"quantum",
"circuit",
"removed",
"by",
"`",
"remove_last_measurements",
"`",
"after",
"the",
"swap",
"mapper",
"is",
"finished",
"."
] | [
"\"\"\"Returns the measurements to a quantum circuit, removed by\n `remove_last_measurements` after the swap mapper is finished.\n\n This operation is done in-place on the input DAG circuit.\n\n Parameters:\n dag_circuit (qiskit.dagcircuit._dagcircuit.DAGCircuit): DAG circuit.\n removed_meas ... | [
{
"param": "dag_circuit",
"type": null
},
{
"param": "removed_meas",
"type": null
},
{
"param": "final_layout",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dag_circuit",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is_optional": false
},
{
"identifier": "removed_meas",
"type": null,
"docstri... |
d87b4f22864c527e12f4fd9fd24fadaaf3dbae4d | dsh0416/qiskit-terra | qiskit/_util.py | [
"Apache-2.0"
] | Python | _check_python_version | null | def _check_python_version():
"""Check for Python version 3.5+
"""
if sys.version_info < (3, 5):
raise Exception('QISKit requires Python version 3.5 or greater.') | Check for Python version 3.5+
| Check for Python version 3.5+ | [
"Check",
"for",
"Python",
"version",
"3",
".",
"5",
"+"
] | def _check_python_version():
if sys.version_info < (3, 5):
raise Exception('QISKit requires Python version 3.5 or greater.') | [
"def",
"_check_python_version",
"(",
")",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"5",
")",
":",
"raise",
"Exception",
"(",
"'QISKit requires Python version 3.5 or greater.'",
")"
] | Check for Python version 3.5+ | [
"Check",
"for",
"Python",
"version",
"3",
".",
"5",
"+"
] | [
"\"\"\"Check for Python version 3.5+\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d87b4f22864c527e12f4fd9fd24fadaaf3dbae4d | dsh0416/qiskit-terra | qiskit/_util.py | [
"Apache-2.0"
] | Python | _check_ibmqx_version | <not_specific> | def _check_ibmqx_version():
"""Check if the available IBMQuantumExperience version is the required one.
Check that the installed "IBMQuantumExperience" package version matches the
version required by the package, emitting a warning if it is not present.
Note:
The check is only performed when `... | Check if the available IBMQuantumExperience version is the required one.
Check that the installed "IBMQuantumExperience" package version matches the
version required by the package, emitting a warning if it is not present.
Note:
The check is only performed when `qiskit` is installed via `pip`
... | Check if the available IBMQuantumExperience version is the required one.
Check that the installed "IBMQuantumExperience" package version matches the
version required by the package, emitting a warning if it is not present.
| [
"Check",
"if",
"the",
"available",
"IBMQuantumExperience",
"version",
"is",
"the",
"required",
"one",
".",
"Check",
"that",
"the",
"installed",
"\"",
"IBMQuantumExperience",
"\"",
"package",
"version",
"matches",
"the",
"version",
"required",
"by",
"the",
"package... | def _check_ibmqx_version():
try:
import pkg_resources
working_set = pkg_resources.working_set
qiskit_pkg = working_set.by_key['qiskit']
except (ImportError, KeyError):
return
ibmqx_require = next(r for r in qiskit_pkg.requires() if
r.name == API_NAME)... | [
"def",
"_check_ibmqx_version",
"(",
")",
":",
"try",
":",
"import",
"pkg_resources",
"working_set",
"=",
"pkg_resources",
".",
"working_set",
"qiskit_pkg",
"=",
"working_set",
".",
"by_key",
"[",
"'qiskit'",
"]",
"except",
"(",
"ImportError",
",",
"KeyError",
")... | Check if the available IBMQuantumExperience version is the required one. | [
"Check",
"if",
"the",
"available",
"IBMQuantumExperience",
"version",
"is",
"the",
"required",
"one",
"."
] | [
"\"\"\"Check if the available IBMQuantumExperience version is the required one.\n\n Check that the installed \"IBMQuantumExperience\" package version matches the\n version required by the package, emitting a warning if it is not present.\n\n Note:\n The check is only performed when `qiskit` is insta... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d87b4f22864c527e12f4fd9fd24fadaaf3dbae4d | dsh0416/qiskit-terra | qiskit/_util.py | [
"Apache-2.0"
] | Python | _enable_deprecation_warnings | null | def _enable_deprecation_warnings():
"""
Force the `DeprecationWarning` warnings to be displayed for the qiskit
module, overriding the system configuration as they are ignored by default
[1] for end-users.
TODO: on Python 3.7, this might not be needed due to PEP-0565 [2].
[1] https://docs.pytho... |
Force the `DeprecationWarning` warnings to be displayed for the qiskit
module, overriding the system configuration as they are ignored by default
[1] for end-users.
TODO: on Python 3.7, this might not be needed due to PEP-0565 [2].
[1] https://docs.python.org/3/library/warnings.html#default-warni... | Force the `DeprecationWarning` warnings to be displayed for the qiskit
module, overriding the system configuration as they are ignored by default
[1] for end-users.
on Python 3.7, this might not be needed due to PEP-0565 [2].
| [
"Force",
"the",
"`",
"DeprecationWarning",
"`",
"warnings",
"to",
"be",
"displayed",
"for",
"the",
"qiskit",
"module",
"overriding",
"the",
"system",
"configuration",
"as",
"they",
"are",
"ignored",
"by",
"default",
"[",
"1",
"]",
"for",
"end",
"-",
"users",... | def _enable_deprecation_warnings():
deprecation_filter = ('always', None, DeprecationWarning,
re.compile(r'^qiskit\.*', re.UNICODE), 0)
try:
warnings._add_filter(*deprecation_filter, append=False)
except AttributeError:
pass | [
"def",
"_enable_deprecation_warnings",
"(",
")",
":",
"deprecation_filter",
"=",
"(",
"'always'",
",",
"None",
",",
"DeprecationWarning",
",",
"re",
".",
"compile",
"(",
"r'^qiskit\\.*'",
",",
"re",
".",
"UNICODE",
")",
",",
"0",
")",
"try",
":",
"warnings",... | Force the `DeprecationWarning` warnings to be displayed for the qiskit
module, overriding the system configuration as they are ignored by default
[1] for end-users. | [
"Force",
"the",
"`",
"DeprecationWarning",
"`",
"warnings",
"to",
"be",
"displayed",
"for",
"the",
"qiskit",
"module",
"overriding",
"the",
"system",
"configuration",
"as",
"they",
"are",
"ignored",
"by",
"default",
"[",
"1",
"]",
"for",
"end",
"-",
"users",... | [
"\"\"\"\n Force the `DeprecationWarning` warnings to be displayed for the qiskit\n module, overriding the system configuration as they are ignored by default\n [1] for end-users.\n\n TODO: on Python 3.7, this might not be needed due to PEP-0565 [2].\n\n [1] https://docs.python.org/3/library/warnings.... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d87b4f22864c527e12f4fd9fd24fadaaf3dbae4d | dsh0416/qiskit-terra | qiskit/_util.py | [
"Apache-2.0"
] | Python | _parse_ibmq_credentials | <not_specific> | def _parse_ibmq_credentials(url, hub=None, group=None, project=None):
"""Converts old Q network credentials to new url only
format, if needed.
"""
if any([hub, group, project]):
url = "https://q-console-api.mybluemix.net/api/" + \
"Hubs/{hub}/Groups/{group}/Projects/{project}"
... | Converts old Q network credentials to new url only
format, if needed.
| Converts old Q network credentials to new url only
format, if needed. | [
"Converts",
"old",
"Q",
"network",
"credentials",
"to",
"new",
"url",
"only",
"format",
"if",
"needed",
"."
] | def _parse_ibmq_credentials(url, hub=None, group=None, project=None):
if any([hub, group, project]):
url = "https://q-console-api.mybluemix.net/api/" + \
"Hubs/{hub}/Groups/{group}/Projects/{project}"
url = url.format(hub=hub, group=group, project=project)
warnings.warn(
... | [
"def",
"_parse_ibmq_credentials",
"(",
"url",
",",
"hub",
"=",
"None",
",",
"group",
"=",
"None",
",",
"project",
"=",
"None",
")",
":",
"if",
"any",
"(",
"[",
"hub",
",",
"group",
",",
"project",
"]",
")",
":",
"url",
"=",
"\"https://q-console-api.myb... | Converts old Q network credentials to new url only
format, if needed. | [
"Converts",
"old",
"Q",
"network",
"credentials",
"to",
"new",
"url",
"only",
"format",
"if",
"needed",
"."
] | [
"\"\"\"Converts old Q network credentials to new url only\n format, if needed.\n \"\"\""
] | [
{
"param": "url",
"type": null
},
{
"param": "hub",
"type": null
},
{
"param": "group",
"type": null
},
{
"param": "project",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hub",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
d87b4f22864c527e12f4fd9fd24fadaaf3dbae4d | dsh0416/qiskit-terra | qiskit/_util.py | [
"Apache-2.0"
] | Python | local_hardware_info | <not_specific> | def local_hardware_info():
"""Basic hardware information about the local machine.
Gives actual number of CPU's in the machine, even when hyperthreading is
turned on.
Returns:
dict: The hardware information.
"""
results = {'os': platform.system()}
results['memory'] = psutil.virtual... | Basic hardware information about the local machine.
Gives actual number of CPU's in the machine, even when hyperthreading is
turned on.
Returns:
dict: The hardware information.
| Basic hardware information about the local machine.
Gives actual number of CPU's in the machine, even when hyperthreading is
turned on. | [
"Basic",
"hardware",
"information",
"about",
"the",
"local",
"machine",
".",
"Gives",
"actual",
"number",
"of",
"CPU",
"'",
"s",
"in",
"the",
"machine",
"even",
"when",
"hyperthreading",
"is",
"turned",
"on",
"."
] | def local_hardware_info():
results = {'os': platform.system()}
results['memory'] = psutil.virtual_memory().total / (1024**3)
results['cpus'] = psutil.cpu_count(logical=False)
return results | [
"def",
"local_hardware_info",
"(",
")",
":",
"results",
"=",
"{",
"'os'",
":",
"platform",
".",
"system",
"(",
")",
"}",
"results",
"[",
"'memory'",
"]",
"=",
"psutil",
".",
"virtual_memory",
"(",
")",
".",
"total",
"/",
"(",
"1024",
"**",
"3",
")",
... | Basic hardware information about the local machine. | [
"Basic",
"hardware",
"information",
"about",
"the",
"local",
"machine",
"."
] | [
"\"\"\"Basic hardware information about the local machine.\n\n Gives actual number of CPU's in the machine, even when hyperthreading is\n turned on.\n\n Returns:\n dict: The hardware information.\n\n \"\"\""
] | [] | {
"returns": [
{
"docstring": "The hardware information.",
"docstring_tokens": [
"The",
"hardware",
"information",
"."
],
"type": "dict"
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d87b4f22864c527e12f4fd9fd24fadaaf3dbae4d | dsh0416/qiskit-terra | qiskit/_util.py | [
"Apache-2.0"
] | Python | _has_connection | <not_specific> | def _has_connection(hostname, port):
"""Checks to see if internet connection exists to host
via specified port
Args:
hostname (str): Hostname to connect to.
port (int): Port to connect to
Returns:
bool: Has connection or not
Raises:
gaierror: No connection establis... | Checks to see if internet connection exists to host
via specified port
Args:
hostname (str): Hostname to connect to.
port (int): Port to connect to
Returns:
bool: Has connection or not
Raises:
gaierror: No connection established.
| Checks to see if internet connection exists to host
via specified port | [
"Checks",
"to",
"see",
"if",
"internet",
"connection",
"exists",
"to",
"host",
"via",
"specified",
"port"
] | def _has_connection(hostname, port):
try:
host = socket.gethostbyname(hostname)
socket.create_connection((host, port), 2)
return True
except socket.gaierror:
pass
return False | [
"def",
"_has_connection",
"(",
"hostname",
",",
"port",
")",
":",
"try",
":",
"host",
"=",
"socket",
".",
"gethostbyname",
"(",
"hostname",
")",
"socket",
".",
"create_connection",
"(",
"(",
"host",
",",
"port",
")",
",",
"2",
")",
"return",
"True",
"e... | Checks to see if internet connection exists to host
via specified port | [
"Checks",
"to",
"see",
"if",
"internet",
"connection",
"exists",
"to",
"host",
"via",
"specified",
"port"
] | [
"\"\"\"Checks to see if internet connection exists to host\n via specified port\n\n Args:\n hostname (str): Hostname to connect to.\n port (int): Port to connect to\n\n Returns:\n bool: Has connection or not\n\n Raises:\n gaierror: No connection established.\n \"\"\""
] | [
{
"param": "hostname",
"type": null
},
{
"param": "port",
"type": null
}
] | {
"returns": [
{
"docstring": "Has connection or not",
"docstring_tokens": [
"Has",
"connection",
"or",
"not"
],
"type": "bool"
}
],
"raises": [
{
"docstring": "No connection established.",
"docstring_tokens": [
"No",
... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | SPSA_optimization | <not_specific> | def SPSA_optimization(obj_fun, initial_theta, SPSA_parameters, max_trials,
save_steps=1, last_avg=1):
"""Minimizes obj_fun(theta) with a simultaneous perturbation stochastic
approximation algorithm.
Args:
obj_fun (callable): the function to minimize
initial_theta (nump... | Minimizes obj_fun(theta) with a simultaneous perturbation stochastic
approximation algorithm.
Args:
obj_fun (callable): the function to minimize
initial_theta (numpy.array): initial value for the variables of
obj_fun
SPSA_parameters (list[float]) : the parameters of the SPS... | Minimizes obj_fun(theta) with a simultaneous perturbation stochastic
approximation algorithm. | [
"Minimizes",
"obj_fun",
"(",
"theta",
")",
"with",
"a",
"simultaneous",
"perturbation",
"stochastic",
"approximation",
"algorithm",
"."
] | def SPSA_optimization(obj_fun, initial_theta, SPSA_parameters, max_trials,
save_steps=1, last_avg=1):
theta_plus_save = []
theta_minus_save = []
cost_plus_save = []
cost_minus_save = []
theta = initial_theta
theta_best = np.zeros(initial_theta.shape)
circuits = []
f... | [
"def",
"SPSA_optimization",
"(",
"obj_fun",
",",
"initial_theta",
",",
"SPSA_parameters",
",",
"max_trials",
",",
"save_steps",
"=",
"1",
",",
"last_avg",
"=",
"1",
")",
":",
"theta_plus_save",
"=",
"[",
"]",
"theta_minus_save",
"=",
"[",
"]",
"cost_plus_save"... | Minimizes obj_fun(theta) with a simultaneous perturbation stochastic
approximation algorithm. | [
"Minimizes",
"obj_fun",
"(",
"theta",
")",
"with",
"a",
"simultaneous",
"perturbation",
"stochastic",
"approximation",
"algorithm",
"."
] | [
"\"\"\"Minimizes obj_fun(theta) with a simultaneous perturbation stochastic\n approximation algorithm.\n\n Args:\n obj_fun (callable): the function to minimize\n initial_theta (numpy.array): initial value for the variables of\n obj_fun\n SPSA_parameters (list[float]) : the par... | [
{
"param": "obj_fun",
"type": null
},
{
"param": "initial_theta",
"type": null
},
{
"param": "SPSA_parameters",
"type": null
},
{
"param": "max_trials",
"type": null
},
{
"param": "save_steps",
"type": null
},
{
"param": "last_avg",
"type": null
... | {
"returns": [
{
"docstring": "a list with the following elements:\ncost_final : final optimized value for obj_fun\ntheta_best : final values of the variables corresponding to\ncost_final\ncost_plus_save : array of stored values for obj_fun along the\noptimization in the + direction\ncost_minus_save : array... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | SPSA_calibration | <not_specific> | def SPSA_calibration(obj_fun, initial_theta, initial_c, target_update, stat):
"""Calibrates and returns the SPSA parameters.
Args:
obj_fun (callable): the function to minimize.
initial_theta (numpy.array): initial value for the variables of
obj_fun.
initial_c (float) : first... | Calibrates and returns the SPSA parameters.
Args:
obj_fun (callable): the function to minimize.
initial_theta (numpy.array): initial value for the variables of
obj_fun.
initial_c (float) : first perturbation of intitial_theta.
target_update (float) : the aimed update of ... | Calibrates and returns the SPSA parameters. | [
"Calibrates",
"and",
"returns",
"the",
"SPSA",
"parameters",
"."
] | def SPSA_calibration(obj_fun, initial_theta, initial_c, target_update, stat):
SPSA_parameters = np.zeros((5))
SPSA_parameters[1] = initial_c
SPSA_parameters[2] = 0.602
SPSA_parameters[3] = 0.101
SPSA_parameters[4] = 0
delta_obj = 0
circuits = []
for i in range(stat):
if i % 5 == ... | [
"def",
"SPSA_calibration",
"(",
"obj_fun",
",",
"initial_theta",
",",
"initial_c",
",",
"target_update",
",",
"stat",
")",
":",
"SPSA_parameters",
"=",
"np",
".",
"zeros",
"(",
"(",
"5",
")",
")",
"SPSA_parameters",
"[",
"1",
"]",
"=",
"initial_c",
"SPSA_p... | Calibrates and returns the SPSA parameters. | [
"Calibrates",
"and",
"returns",
"the",
"SPSA",
"parameters",
"."
] | [
"\"\"\"Calibrates and returns the SPSA parameters.\n\n Args:\n obj_fun (callable): the function to minimize.\n initial_theta (numpy.array): initial value for the variables of\n obj_fun.\n initial_c (float) : first perturbation of intitial_theta.\n target_update (float) : th... | [
{
"param": "obj_fun",
"type": null
},
{
"param": "initial_theta",
"type": null
},
{
"param": "initial_c",
"type": null
},
{
"param": "target_update",
"type": null
},
{
"param": "stat",
"type": null
}
] | {
"returns": [
{
"docstring": "An array of 5 SPSA_parameters to use in the optimization.\nlist[QuantumCircuit]: the circuits used in calibration",
"docstring_tokens": [
"An",
"array",
"of",
"5",
"SPSA_parameters",
"to",
"use",
"in",
... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | measure_pauli_z | <not_specific> | def measure_pauli_z(data, pauli):
"""Compute the expectation value of Z.
Z is represented by Z^v where v has lenght number of qubits and is 1
if Z is present and 0 otherwise.
Args:
data (dict): a dictionary of the form data = {'00000': 10}
pauli (Pauli): a Pauli object
Returns:
... | Compute the expectation value of Z.
Z is represented by Z^v where v has lenght number of qubits and is 1
if Z is present and 0 otherwise.
Args:
data (dict): a dictionary of the form data = {'00000': 10}
pauli (Pauli): a Pauli object
Returns:
float: Expected value of pauli given... | Compute the expectation value of Z.
Z is represented by Z^v where v has lenght number of qubits and is 1
if Z is present and 0 otherwise. | [
"Compute",
"the",
"expectation",
"value",
"of",
"Z",
".",
"Z",
"is",
"represented",
"by",
"Z^v",
"where",
"v",
"has",
"lenght",
"number",
"of",
"qubits",
"and",
"is",
"1",
"if",
"Z",
"is",
"present",
"and",
"0",
"otherwise",
"."
] | def measure_pauli_z(data, pauli):
observable = 0
tot = sum(data.values())
for key in data:
value = 1
for j in range(pauli.numberofqubits):
if ((pauli.v[j] == 1 or pauli.w[j] == 1) and
key[pauli.numberofqubits - j - 1] == '1'):
value = -value
... | [
"def",
"measure_pauli_z",
"(",
"data",
",",
"pauli",
")",
":",
"observable",
"=",
"0",
"tot",
"=",
"sum",
"(",
"data",
".",
"values",
"(",
")",
")",
"for",
"key",
"in",
"data",
":",
"value",
"=",
"1",
"for",
"j",
"in",
"range",
"(",
"pauli",
".",... | Compute the expectation value of Z. | [
"Compute",
"the",
"expectation",
"value",
"of",
"Z",
"."
] | [
"\"\"\"Compute the expectation value of Z.\n\n Z is represented by Z^v where v has lenght number of qubits and is 1\n if Z is present and 0 otherwise.\n\n Args:\n data (dict): a dictionary of the form data = {'00000': 10}\n pauli (Pauli): a Pauli object\n Returns:\n float: Expected ... | [
{
"param": "data",
"type": null
},
{
"param": "pauli",
"type": null
}
] | {
"returns": [
{
"docstring": "Expected value of pauli given data",
"docstring_tokens": [
"Expected",
"value",
"of",
"pauli",
"given",
"data"
],
"type": "float"
}
],
"raises": [],
"params": [
{
"identifier": "data",
... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | Energy_Estimate | <not_specific> | def Energy_Estimate(data, pauli_list):
"""Compute expectation value of a list of diagonal Paulis with
coefficients given measurement data. If somePaulis are non-diagonal
appropriate post-rotations had to be performed in the collection of data
Args:
data (dict): output of the execution of a quan... | Compute expectation value of a list of diagonal Paulis with
coefficients given measurement data. If somePaulis are non-diagonal
appropriate post-rotations had to be performed in the collection of data
Args:
data (dict): output of the execution of a quantum program
pauli_list (list): list of... | Compute expectation value of a list of diagonal Paulis with
coefficients given measurement data. If somePaulis are non-diagonal
appropriate post-rotations had to be performed in the collection of data | [
"Compute",
"expectation",
"value",
"of",
"a",
"list",
"of",
"diagonal",
"Paulis",
"with",
"coefficients",
"given",
"measurement",
"data",
".",
"If",
"somePaulis",
"are",
"non",
"-",
"diagonal",
"appropriate",
"post",
"-",
"rotations",
"had",
"to",
"be",
"perfo... | def Energy_Estimate(data, pauli_list):
energy = 0
if np.ndim(pauli_list) == 1:
energy = pauli_list[0] * measure_pauli_z(data, pauli_list[1])
else:
for p in pauli_list:
energy += p[0] * measure_pauli_z(data, p[1])
return energy | [
"def",
"Energy_Estimate",
"(",
"data",
",",
"pauli_list",
")",
":",
"energy",
"=",
"0",
"if",
"np",
".",
"ndim",
"(",
"pauli_list",
")",
"==",
"1",
":",
"energy",
"=",
"pauli_list",
"[",
"0",
"]",
"*",
"measure_pauli_z",
"(",
"data",
",",
"pauli_list",... | Compute expectation value of a list of diagonal Paulis with
coefficients given measurement data. | [
"Compute",
"expectation",
"value",
"of",
"a",
"list",
"of",
"diagonal",
"Paulis",
"with",
"coefficients",
"given",
"measurement",
"data",
"."
] | [
"\"\"\"Compute expectation value of a list of diagonal Paulis with\n coefficients given measurement data. If somePaulis are non-diagonal\n appropriate post-rotations had to be performed in the collection of data\n\n Args:\n data (dict): output of the execution of a quantum program\n pauli_lis... | [
{
"param": "data",
"type": null
},
{
"param": "pauli_list",
"type": null
}
] | {
"returns": [
{
"docstring": "The expectation value",
"docstring_tokens": [
"The",
"expectation",
"value"
],
"type": "float"
}
],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": "output of the execution o... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | index_2_bit | <not_specific> | def index_2_bit(state_index, num_bits):
"""Returns bit string corresponding to quantum state index
Args:
state_index (int): basis index of a quantum state
num_bits (int): the number of bits in the returned string
Returns:
numpy.array: A integer array with the binary representation o... | Returns bit string corresponding to quantum state index
Args:
state_index (int): basis index of a quantum state
num_bits (int): the number of bits in the returned string
Returns:
numpy.array: A integer array with the binary representation of
state_index
| Returns bit string corresponding to quantum state index | [
"Returns",
"bit",
"string",
"corresponding",
"to",
"quantum",
"state",
"index"
] | def index_2_bit(state_index, num_bits):
return np.array([int(c) for c
in np.binary_repr(state_index, num_bits)[::-1]],
dtype=np.uint8) | [
"def",
"index_2_bit",
"(",
"state_index",
",",
"num_bits",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"int",
"(",
"c",
")",
"for",
"c",
"in",
"np",
".",
"binary_repr",
"(",
"state_index",
",",
"num_bits",
")",
"[",
":",
":",
"-",
"1",
"]",
... | Returns bit string corresponding to quantum state index | [
"Returns",
"bit",
"string",
"corresponding",
"to",
"quantum",
"state",
"index"
] | [
"\"\"\"Returns bit string corresponding to quantum state index\n\n Args:\n state_index (int): basis index of a quantum state\n num_bits (int): the number of bits in the returned string\n Returns:\n numpy.array: A integer array with the binary representation of\n state_index\n ... | [
{
"param": "state_index",
"type": null
},
{
"param": "num_bits",
"type": null
}
] | {
"returns": [
{
"docstring": "A integer array with the binary representation of\nstate_index",
"docstring_tokens": [
"A",
"integer",
"array",
"with",
"the",
"binary",
"representation",
"of",
"state_index"
],
"type": "... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | group_paulis | <not_specific> | def group_paulis(pauli_list):
"""
Groups a list of (coeff,Pauli) tuples into tensor product basis (tpb) sets
Args:
pauli_list (list): a list of (coeff, Pauli object) tuples.
Returns:
list: A list of tpb sets, each one being a list of (coeff, Pauli
object) tuples.
"""
... |
Groups a list of (coeff,Pauli) tuples into tensor product basis (tpb) sets
Args:
pauli_list (list): a list of (coeff, Pauli object) tuples.
Returns:
list: A list of tpb sets, each one being a list of (coeff, Pauli
object) tuples.
| Groups a list of (coeff,Pauli) tuples into tensor product basis (tpb) sets | [
"Groups",
"a",
"list",
"of",
"(",
"coeff",
"Pauli",
")",
"tuples",
"into",
"tensor",
"product",
"basis",
"(",
"tpb",
")",
"sets"
] | def group_paulis(pauli_list):
n = len(pauli_list[0][1].v)
pauli_list_grouped = []
pauli_list_sorted = []
for p_1 in pauli_list:
if p_1 not in pauli_list_sorted:
pauli_list_temp = []
pauli_list_temp.append(list(p_1))
pauli_list_temp.append(copy.deepcopy(list(p_... | [
"def",
"group_paulis",
"(",
"pauli_list",
")",
":",
"n",
"=",
"len",
"(",
"pauli_list",
"[",
"0",
"]",
"[",
"1",
"]",
".",
"v",
")",
"pauli_list_grouped",
"=",
"[",
"]",
"pauli_list_sorted",
"=",
"[",
"]",
"for",
"p_1",
"in",
"pauli_list",
":",
"if",... | Groups a list of (coeff,Pauli) tuples into tensor product basis (tpb) sets | [
"Groups",
"a",
"list",
"of",
"(",
"coeff",
"Pauli",
")",
"tuples",
"into",
"tensor",
"product",
"basis",
"(",
"tpb",
")",
"sets"
] | [
"\"\"\"\n Groups a list of (coeff,Pauli) tuples into tensor product basis (tpb) sets\n\n Args:\n pauli_list (list): a list of (coeff, Pauli object) tuples.\n Returns:\n list: A list of tpb sets, each one being a list of (coeff, Pauli\n object) tuples.\n \"\"\"",
"# pauli_list_... | [
{
"param": "pauli_list",
"type": null
}
] | {
"returns": [
{
"docstring": "A list of tpb sets, each one being a list of (coeff, Pauli\nobject) tuples.",
"docstring_tokens": [
"A",
"list",
"of",
"tpb",
"sets",
"each",
"one",
"being",
"a",
"list",
"of",
... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | print_pauli_list_grouped | null | def print_pauli_list_grouped(pauli_list_grouped):
"""Print a list of Pauli operators which has been grouped into tensor
product basis (tpb) sets.
Args:
pauli_list_grouped (list of lists of (coeff, pauli) tuples): the
list of Pauli operators grouped into tpb sets
"""
for i, _ in ... | Print a list of Pauli operators which has been grouped into tensor
product basis (tpb) sets.
Args:
pauli_list_grouped (list of lists of (coeff, pauli) tuples): the
list of Pauli operators grouped into tpb sets
| Print a list of Pauli operators which has been grouped into tensor
product basis (tpb) sets. | [
"Print",
"a",
"list",
"of",
"Pauli",
"operators",
"which",
"has",
"been",
"grouped",
"into",
"tensor",
"product",
"basis",
"(",
"tpb",
")",
"sets",
"."
] | def print_pauli_list_grouped(pauli_list_grouped):
for i, _ in enumerate(pauli_list_grouped):
print('Post Rotations of TPB set ' + str(i) + ':')
print(pauli_list_grouped[i][0][1].to_label())
print(str(pauli_list_grouped[i][0][0]) + '\n')
for j in range((len(pauli_list_grouped[i]) - 1)... | [
"def",
"print_pauli_list_grouped",
"(",
"pauli_list_grouped",
")",
":",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"pauli_list_grouped",
")",
":",
"print",
"(",
"'Post Rotations of TPB set '",
"+",
"str",
"(",
"i",
")",
"+",
"':'",
")",
"print",
"(",
"pau... | Print a list of Pauli operators which has been grouped into tensor
product basis (tpb) sets. | [
"Print",
"a",
"list",
"of",
"Pauli",
"operators",
"which",
"has",
"been",
"grouped",
"into",
"tensor",
"product",
"basis",
"(",
"tpb",
")",
"sets",
"."
] | [
"\"\"\"Print a list of Pauli operators which has been grouped into tensor\n product basis (tpb) sets.\n\n Args:\n pauli_list_grouped (list of lists of (coeff, pauli) tuples): the\n list of Pauli operators grouped into tpb sets\n \"\"\""
] | [
{
"param": "pauli_list_grouped",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pauli_list_grouped",
"type": null,
"docstring": "the\nlist of Pauli operators grouped into tpb sets",
"docstring_tokens": [
"the",
"list",
"of",
"Pauli",
"operators",
"grouped",
... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | eval_hamiltonian | <not_specific> | def eval_hamiltonian(hamiltonian, input_circuit, shots, device):
"""Calculates the average value of a Hamiltonian on a state created by the
input circuit
Args:
hamiltonian (array or matrix or list): a representation of the
Hamiltonian or observables to be measured. If it is a list, it ... | Calculates the average value of a Hamiltonian on a state created by the
input circuit
Args:
hamiltonian (array or matrix or list): a representation of the
Hamiltonian or observables to be measured. If it is a list, it is
a list of Pauli operators grouped into tpb sets.
... | Calculates the average value of a Hamiltonian on a state created by the
input circuit | [
"Calculates",
"the",
"average",
"value",
"of",
"a",
"Hamiltonian",
"on",
"a",
"state",
"created",
"by",
"the",
"input",
"circuit"
] | def eval_hamiltonian(hamiltonian, input_circuit, shots, device):
energy = 0
circuits = []
if 'statevector' in device:
circuits.append(input_circuit)
if not isinstance(hamiltonian, list):
result = execute(circuits, device, shots=shots).result()
statevector = result.get... | [
"def",
"eval_hamiltonian",
"(",
"hamiltonian",
",",
"input_circuit",
",",
"shots",
",",
"device",
")",
":",
"energy",
"=",
"0",
"circuits",
"=",
"[",
"]",
"if",
"'statevector'",
"in",
"device",
":",
"circuits",
".",
"append",
"(",
"input_circuit",
")",
"if... | Calculates the average value of a Hamiltonian on a state created by the
input circuit | [
"Calculates",
"the",
"average",
"value",
"of",
"a",
"Hamiltonian",
"on",
"a",
"state",
"created",
"by",
"the",
"input",
"circuit"
] | [
"\"\"\"Calculates the average value of a Hamiltonian on a state created by the\n input circuit\n\n Args:\n hamiltonian (array or matrix or list): a representation of the\n Hamiltonian or observables to be measured. If it is a list, it is\n a list of Pauli operators grouped into t... | [
{
"param": "hamiltonian",
"type": null
},
{
"param": "input_circuit",
"type": null
},
{
"param": "shots",
"type": null
},
{
"param": "device",
"type": null
}
] | {
"returns": [
{
"docstring": "Average value of the Hamiltonian or observable.",
"docstring_tokens": [
"Average",
"value",
"of",
"the",
"Hamiltonian",
"or",
"observable",
"."
],
"type": "float"
}
],
"raises": [],
"pa... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | trial_circuit_ry | <not_specific> | def trial_circuit_ry(n, m, theta, entangler_map, meas_string=None,
measurement=True):
"""Creates a QuantumCircuit object ocnsisting in layers of
parametrized single-qubit Y rotations and CZ two-qubit gates
Args:
n (int): number of qubits
m (int): depth of the circuit
... | Creates a QuantumCircuit object ocnsisting in layers of
parametrized single-qubit Y rotations and CZ two-qubit gates
Args:
n (int): number of qubits
m (int): depth of the circuit
theta (array[float]): angles that parametrize the Y rotations
entangler_map (dict): CZ connectivity,... | Creates a QuantumCircuit object ocnsisting in layers of
parametrized single-qubit Y rotations and CZ two-qubit gates | [
"Creates",
"a",
"QuantumCircuit",
"object",
"ocnsisting",
"in",
"layers",
"of",
"parametrized",
"single",
"-",
"qubit",
"Y",
"rotations",
"and",
"CZ",
"two",
"-",
"qubit",
"gates"
] | def trial_circuit_ry(n, m, theta, entangler_map, meas_string=None,
measurement=True):
q = QuantumRegister(n, "q")
c = ClassicalRegister(n, "c")
trial_circuit = QuantumCircuit(q, c)
trial_circuit.h(q)
if meas_string is None:
meas_string = [None for x in range(n)]
for ... | [
"def",
"trial_circuit_ry",
"(",
"n",
",",
"m",
",",
"theta",
",",
"entangler_map",
",",
"meas_string",
"=",
"None",
",",
"measurement",
"=",
"True",
")",
":",
"q",
"=",
"QuantumRegister",
"(",
"n",
",",
"\"q\"",
")",
"c",
"=",
"ClassicalRegister",
"(",
... | Creates a QuantumCircuit object ocnsisting in layers of
parametrized single-qubit Y rotations and CZ two-qubit gates | [
"Creates",
"a",
"QuantumCircuit",
"object",
"ocnsisting",
"in",
"layers",
"of",
"parametrized",
"single",
"-",
"qubit",
"Y",
"rotations",
"and",
"CZ",
"two",
"-",
"qubit",
"gates"
] | [
"\"\"\"Creates a QuantumCircuit object ocnsisting in layers of\n parametrized single-qubit Y rotations and CZ two-qubit gates\n\n Args:\n n (int): number of qubits\n m (int): depth of the circuit\n theta (array[float]): angles that parametrize the Y rotations\n entangler_map (dict)... | [
{
"param": "n",
"type": null
},
{
"param": "m",
"type": null
},
{
"param": "theta",
"type": null
},
{
"param": "entangler_map",
"type": null
},
{
"param": "meas_string",
"type": null
},
{
"param": "measurement",
"type": null
}
] | {
"returns": [
{
"docstring": "A QuantumCircuit object",
"docstring_tokens": [
"A",
"QuantumCircuit",
"object"
],
"type": "QuantumCircuit"
}
],
"raises": [],
"params": [
{
"identifier": "n",
"type": null,
"docstring": "number of qubit... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | trial_circuit_ryrz | <not_specific> | def trial_circuit_ryrz(n, m, theta, entangler_map, meas_string=None,
measurement=True):
"""Creates a QuantumCircuit object consisting in layers of
parametrized single-qubit Y and Z rotations and CZ two-qubit gates
Args:
n (int): number of qubits
m (int): depth of the ... | Creates a QuantumCircuit object consisting in layers of
parametrized single-qubit Y and Z rotations and CZ two-qubit gates
Args:
n (int): number of qubits
m (int): depth of the circuit
theta (array[float]): angles that parametrize the Y and Z rotations
entangler_map (dict): CZ c... | Creates a QuantumCircuit object consisting in layers of
parametrized single-qubit Y and Z rotations and CZ two-qubit gates | [
"Creates",
"a",
"QuantumCircuit",
"object",
"consisting",
"in",
"layers",
"of",
"parametrized",
"single",
"-",
"qubit",
"Y",
"and",
"Z",
"rotations",
"and",
"CZ",
"two",
"-",
"qubit",
"gates"
] | def trial_circuit_ryrz(n, m, theta, entangler_map, meas_string=None,
measurement=True):
q = QuantumRegister(n, "q")
c = ClassicalRegister(n, "c")
trial_circuit = QuantumCircuit(q, c)
trial_circuit.h(q)
if meas_string is None:
meas_string = [None for x in range(n)]
... | [
"def",
"trial_circuit_ryrz",
"(",
"n",
",",
"m",
",",
"theta",
",",
"entangler_map",
",",
"meas_string",
"=",
"None",
",",
"measurement",
"=",
"True",
")",
":",
"q",
"=",
"QuantumRegister",
"(",
"n",
",",
"\"q\"",
")",
"c",
"=",
"ClassicalRegister",
"(",... | Creates a QuantumCircuit object consisting in layers of
parametrized single-qubit Y and Z rotations and CZ two-qubit gates | [
"Creates",
"a",
"QuantumCircuit",
"object",
"consisting",
"in",
"layers",
"of",
"parametrized",
"single",
"-",
"qubit",
"Y",
"and",
"Z",
"rotations",
"and",
"CZ",
"two",
"-",
"qubit",
"gates"
] | [
"\"\"\"Creates a QuantumCircuit object consisting in layers of\n parametrized single-qubit Y and Z rotations and CZ two-qubit gates\n\n Args:\n n (int): number of qubits\n m (int): depth of the circuit\n theta (array[float]): angles that parametrize the Y and Z rotations\n entangle... | [
{
"param": "n",
"type": null
},
{
"param": "m",
"type": null
},
{
"param": "theta",
"type": null
},
{
"param": "entangler_map",
"type": null
},
{
"param": "meas_string",
"type": null
},
{
"param": "measurement",
"type": null
}
] | {
"returns": [
{
"docstring": "A QuantumCircuit object",
"docstring_tokens": [
"A",
"QuantumCircuit",
"object"
],
"type": "QuantumCircuit"
}
],
"raises": [],
"params": [
{
"identifier": "n",
"type": null,
"docstring": "number of qubit... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | make_Hamiltonian | <not_specific> | def make_Hamiltonian(pauli_list):
"""Creates a matrix operator out of a list of Paulis.
Args:
pauli_list (list): list of list [coeff,Pauli]
Returns:
numpy.matrix: A matrix representing pauli_list
"""
Hamiltonian = 0
for p in pauli_list:
Hamiltonian += p[0] * p[1].to_matr... | Creates a matrix operator out of a list of Paulis.
Args:
pauli_list (list): list of list [coeff,Pauli]
Returns:
numpy.matrix: A matrix representing pauli_list
| Creates a matrix operator out of a list of Paulis. | [
"Creates",
"a",
"matrix",
"operator",
"out",
"of",
"a",
"list",
"of",
"Paulis",
"."
] | def make_Hamiltonian(pauli_list):
Hamiltonian = 0
for p in pauli_list:
Hamiltonian += p[0] * p[1].to_matrix()
return Hamiltonian | [
"def",
"make_Hamiltonian",
"(",
"pauli_list",
")",
":",
"Hamiltonian",
"=",
"0",
"for",
"p",
"in",
"pauli_list",
":",
"Hamiltonian",
"+=",
"p",
"[",
"0",
"]",
"*",
"p",
"[",
"1",
"]",
".",
"to_matrix",
"(",
")",
"return",
"Hamiltonian"
] | Creates a matrix operator out of a list of Paulis. | [
"Creates",
"a",
"matrix",
"operator",
"out",
"of",
"a",
"list",
"of",
"Paulis",
"."
] | [
"\"\"\"Creates a matrix operator out of a list of Paulis.\n\n Args:\n pauli_list (list): list of list [coeff,Pauli]\n Returns:\n numpy.matrix: A matrix representing pauli_list\n \"\"\""
] | [
{
"param": "pauli_list",
"type": null
}
] | {
"returns": [
{
"docstring": "A matrix representing pauli_list",
"docstring_tokens": [
"A",
"matrix",
"representing",
"pauli_list"
],
"type": "numpy.matrix"
}
],
"raises": [],
"params": [
{
"identifier": "pauli_list",
"type": null,... |
9ba762a3be4e067407755bd6370ce51a720c0bc7 | dsh0416/qiskit-terra | qiskit/tools/apps/optimization.py | [
"Apache-2.0"
] | Python | Hamiltonian_from_file | <not_specific> | def Hamiltonian_from_file(file_name):
"""Creates a matrix operator out of a file with a list
of Paulis.
Args:
file_name (str): a text file containing a list of Paulis and
coefficients.
Returns:
list: A matrix representing pauli_list
"""
with open(file_name, 'r+') as file... | Creates a matrix operator out of a file with a list
of Paulis.
Args:
file_name (str): a text file containing a list of Paulis and
coefficients.
Returns:
list: A matrix representing pauli_list
| Creates a matrix operator out of a file with a list
of Paulis.
file_name (str): a text file containing a list of Paulis and
coefficients.
Returns:
list: A matrix representing pauli_list | [
"Creates",
"a",
"matrix",
"operator",
"out",
"of",
"a",
"file",
"with",
"a",
"list",
"of",
"Paulis",
".",
"file_name",
"(",
"str",
")",
":",
"a",
"text",
"file",
"containing",
"a",
"list",
"of",
"Paulis",
"and",
"coefficients",
".",
"Returns",
":",
"li... | def Hamiltonian_from_file(file_name):
with open(file_name, 'r+') as file:
ham_array = file.readlines()
ham_array = [x.strip() for x in ham_array]
pauli_list = []
for i in range(len(ham_array) // 2):
pauli = label_to_pauli(ham_array[2 * i])
Numb = float(ham_array[2 * i + 1])
... | [
"def",
"Hamiltonian_from_file",
"(",
"file_name",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'r+'",
")",
"as",
"file",
":",
"ham_array",
"=",
"file",
".",
"readlines",
"(",
")",
"ham_array",
"=",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"... | Creates a matrix operator out of a file with a list
of Paulis. | [
"Creates",
"a",
"matrix",
"operator",
"out",
"of",
"a",
"file",
"with",
"a",
"list",
"of",
"Paulis",
"."
] | [
"\"\"\"Creates a matrix operator out of a file with a list\n of Paulis.\n\n Args:\n file_name (str): a text file containing a list of Paulis and\n coefficients.\n Returns:\n list: A matrix representing pauli_list\n \"\"\""
] | [
{
"param": "file_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f176992d00829e0b4d5b049371e0a595656081c6 | dsh0416/qiskit-terra | test/python/test_extensions_standard.py | [
"Apache-2.0"
] | Python | assertResult | null | def assertResult(self, type_, qasm_txt, qasm_txt_):
"""
Assert the single gate in self.circuit is of the type type_, the QASM
representation matches qasm_txt and the QASM representation of
inverse maches qasm_txt_.
Args:
type_ (type): a gate type.
qasm_tx... |
Assert the single gate in self.circuit is of the type type_, the QASM
representation matches qasm_txt and the QASM representation of
inverse maches qasm_txt_.
Args:
type_ (type): a gate type.
qasm_txt (str): QASM representation of the gate.
qasm_txt_... | Assert the single gate in self.circuit is of the type type_, the QASM
representation matches qasm_txt and the QASM representation of
inverse maches qasm_txt_. | [
"Assert",
"the",
"single",
"gate",
"in",
"self",
".",
"circuit",
"is",
"of",
"the",
"type",
"type_",
"the",
"QASM",
"representation",
"matches",
"qasm_txt",
"and",
"the",
"QASM",
"representation",
"of",
"inverse",
"maches",
"qasm_txt_",
"."
] | def assertResult(self, type_, qasm_txt, qasm_txt_):
circuit = self.circuit
self.assertEqual(type(circuit[0]), type_)
self.assertQasm(qasm_txt)
circuit[0].reapply(circuit)
self.assertQasm(qasm_txt + '\n' + qasm_txt)
self.assertEqual(circuit[0].inverse(), circuit[0])
... | [
"def",
"assertResult",
"(",
"self",
",",
"type_",
",",
"qasm_txt",
",",
"qasm_txt_",
")",
":",
"circuit",
"=",
"self",
".",
"circuit",
"self",
".",
"assertEqual",
"(",
"type",
"(",
"circuit",
"[",
"0",
"]",
")",
",",
"type_",
")",
"self",
".",
"asser... | Assert the single gate in self.circuit is of the type type_, the QASM
representation matches qasm_txt and the QASM representation of
inverse maches qasm_txt_. | [
"Assert",
"the",
"single",
"gate",
"in",
"self",
".",
"circuit",
"is",
"of",
"the",
"type",
"type_",
"the",
"QASM",
"representation",
"matches",
"qasm_txt",
"and",
"the",
"QASM",
"representation",
"of",
"inverse",
"maches",
"qasm_txt_",
"."
] | [
"\"\"\"\n Assert the single gate in self.circuit is of the type type_, the QASM\n representation matches qasm_txt and the QASM representation of\n inverse maches qasm_txt_.\n\n Args:\n type_ (type): a gate type.\n qasm_txt (str): QASM representation of the gate.\n ... | [
{
"param": "self",
"type": null
},
{
"param": "type_",
"type": null
},
{
"param": "qasm_txt",
"type": null
},
{
"param": "qasm_txt_",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "type_",
"type": null,
"docstring": "a gate type.",
"docstring... |
f176992d00829e0b4d5b049371e0a595656081c6 | dsh0416/qiskit-terra | test/python/test_extensions_standard.py | [
"Apache-2.0"
] | Python | assertStmtsType | null | def assertStmtsType(self, stmts, type_):
"""
Assert a list of statements stmts is of a type type_.
Args:
stmts (list): list of statements.
type_ (type): a gate type.
"""
for stmt in stmts:
self.assertEqual(type(stmt), type_) |
Assert a list of statements stmts is of a type type_.
Args:
stmts (list): list of statements.
type_ (type): a gate type.
| Assert a list of statements stmts is of a type type_. | [
"Assert",
"a",
"list",
"of",
"statements",
"stmts",
"is",
"of",
"a",
"type",
"type_",
"."
] | def assertStmtsType(self, stmts, type_):
for stmt in stmts:
self.assertEqual(type(stmt), type_) | [
"def",
"assertStmtsType",
"(",
"self",
",",
"stmts",
",",
"type_",
")",
":",
"for",
"stmt",
"in",
"stmts",
":",
"self",
".",
"assertEqual",
"(",
"type",
"(",
"stmt",
")",
",",
"type_",
")"
] | Assert a list of statements stmts is of a type type_. | [
"Assert",
"a",
"list",
"of",
"statements",
"stmts",
"is",
"of",
"a",
"type",
"type_",
"."
] | [
"\"\"\"\n Assert a list of statements stmts is of a type type_.\n\n Args:\n stmts (list): list of statements.\n type_ (type): a gate type.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "stmts",
"type": null
},
{
"param": "type_",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stmts",
"type": null,
"docstring": "list of statements.",
"do... |
f176992d00829e0b4d5b049371e0a595656081c6 | dsh0416/qiskit-terra | test/python/test_extensions_standard.py | [
"Apache-2.0"
] | Python | assertQasm | null | def assertQasm(self, qasm_txt, offset=1):
"""
Assert the QASM representation of the circuit self.circuit includes
the text qasm_txt in the right position (which can be adjusted by
offset)
Args:
qasm_txt (str): a string with QASM code
offset (int): the off... |
Assert the QASM representation of the circuit self.circuit includes
the text qasm_txt in the right position (which can be adjusted by
offset)
Args:
qasm_txt (str): a string with QASM code
offset (int): the offset in which qasm_txt should be found.
| Assert the QASM representation of the circuit self.circuit includes
the text qasm_txt in the right position (which can be adjusted by
offset) | [
"Assert",
"the",
"QASM",
"representation",
"of",
"the",
"circuit",
"self",
".",
"circuit",
"includes",
"the",
"text",
"qasm_txt",
"in",
"the",
"right",
"position",
"(",
"which",
"can",
"be",
"adjusted",
"by",
"offset",
")"
] | def assertQasm(self, qasm_txt, offset=1):
circuit = self.circuit
c_txt = len(qasm_txt)
self.assertIn('\n' + qasm_txt + '\n', circuit.qasm())
self.assertEqual(self.c_header + c_txt + offset, len(circuit.qasm())) | [
"def",
"assertQasm",
"(",
"self",
",",
"qasm_txt",
",",
"offset",
"=",
"1",
")",
":",
"circuit",
"=",
"self",
".",
"circuit",
"c_txt",
"=",
"len",
"(",
"qasm_txt",
")",
"self",
".",
"assertIn",
"(",
"'\\n'",
"+",
"qasm_txt",
"+",
"'\\n'",
",",
"circu... | Assert the QASM representation of the circuit self.circuit includes
the text qasm_txt in the right position (which can be adjusted by
offset) | [
"Assert",
"the",
"QASM",
"representation",
"of",
"the",
"circuit",
"self",
".",
"circuit",
"includes",
"the",
"text",
"qasm_txt",
"in",
"the",
"right",
"position",
"(",
"which",
"can",
"be",
"adjusted",
"by",
"offset",
")"
] | [
"\"\"\"\n Assert the QASM representation of the circuit self.circuit includes\n the text qasm_txt in the right position (which can be adjusted by\n offset)\n\n Args:\n qasm_txt (str): a string with QASM code\n offset (int): the offset in which qasm_txt should be fou... | [
{
"param": "self",
"type": null
},
{
"param": "qasm_txt",
"type": null
},
{
"param": "offset",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "qasm_txt",
"type": null,
"docstring": "a string with QASM code",
... |
a3062918483133f60dd8e6c7dec1caae0e09515f | dsh0416/qiskit-terra | qiskit/wrapper/_wrapper.py | [
"Apache-2.0"
] | Python | register | <not_specific> | def register(*args, provider_class=None, **kwargs):
"""
Authenticate against an online backend provider.
This is a factory method that returns the provider that gets registered.
Args:
args (tuple): positional arguments passed to provider class initialization
provider_class (BaseProvider... |
Authenticate against an online backend provider.
This is a factory method that returns the provider that gets registered.
Args:
args (tuple): positional arguments passed to provider class initialization
provider_class (BaseProvider): provider class
kwargs (dict): keyword arguments ... | Authenticate against an online backend provider.
This is a factory method that returns the provider that gets registered. | [
"Authenticate",
"against",
"an",
"online",
"backend",
"provider",
".",
"This",
"is",
"a",
"factory",
"method",
"that",
"returns",
"the",
"provider",
"that",
"gets",
"registered",
"."
] | def register(*args, provider_class=None, **kwargs):
if provider_class:
warnings.warn(
'The global registry of providers and register() is deprecated '
'since 0.6. Please instantiate "{}()" directly.'.format(provider_class),
DeprecationWarning)
return provider_clas... | [
"def",
"register",
"(",
"*",
"args",
",",
"provider_class",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"if",
"provider_class",
":",
"warnings",
".",
"warn",
"(",
"'The global registry of providers and register() is deprecated '",
"'since 0.6. Please instantiate \"{}()\" ... | Authenticate against an online backend provider. | [
"Authenticate",
"against",
"an",
"online",
"backend",
"provider",
"."
] | [
"\"\"\"\n Authenticate against an online backend provider.\n This is a factory method that returns the provider that gets registered.\n\n Args:\n args (tuple): positional arguments passed to provider class initialization\n provider_class (BaseProvider): provider class\n kwargs (dict): ... | [
{
"param": "provider_class",
"type": null
}
] | {
"returns": [
{
"docstring": "the provider instance that was just registered.",
"docstring_tokens": [
"the",
"provider",
"instance",
"that",
"was",
"just",
"registered",
"."
],
"type": "BaseProvider"
}
],
"raises": [
... |
a3062918483133f60dd8e6c7dec1caae0e09515f | dsh0416/qiskit-terra | qiskit/wrapper/_wrapper.py | [
"Apache-2.0"
] | Python | unregister | null | def unregister(provider):
"""
Removes a provider from list of registered providers.
Note:
If backend names from provider1 and provider2 were clashing,
`unregister(provider1)` removes the clash and makes the backends
from provider2 available.
Args:
provider (BaseProvider... |
Removes a provider from list of registered providers.
Note:
If backend names from provider1 and provider2 were clashing,
`unregister(provider1)` removes the clash and makes the backends
from provider2 available.
Args:
provider (BaseProvider): the provider instance to unreg... | Removes a provider from list of registered providers.
Note:
If backend names from provider1 and provider2 were clashing,
`unregister(provider1)` removes the clash and makes the backends
from provider2 available. | [
"Removes",
"a",
"provider",
"from",
"list",
"of",
"registered",
"providers",
".",
"Note",
":",
"If",
"backend",
"names",
"from",
"provider1",
"and",
"provider2",
"were",
"clashing",
"`",
"unregister",
"(",
"provider1",
")",
"`",
"removes",
"the",
"clash",
"a... | def unregister(provider):
warnings.warn('unregister() will be deprecated after 0.6. Please use the '
'qiskit.IBMQ.disable_account() method instead.',
DeprecationWarning) | [
"def",
"unregister",
"(",
"provider",
")",
":",
"warnings",
".",
"warn",
"(",
"'unregister() will be deprecated after 0.6. Please use the '",
"'qiskit.IBMQ.disable_account() method instead.'",
",",
"DeprecationWarning",
")"
] | Removes a provider from list of registered providers. | [
"Removes",
"a",
"provider",
"from",
"list",
"of",
"registered",
"providers",
"."
] | [
"\"\"\"\n Removes a provider from list of registered providers.\n\n Note:\n If backend names from provider1 and provider2 were clashing,\n `unregister(provider1)` removes the clash and makes the backends\n from provider2 available.\n\n Args:\n provider (BaseProvider): the provid... | [
{
"param": "provider",
"type": null
}
] | {
"returns": [],
"raises": [
{
"docstring": "if the provider instance is not registered",
"docstring_tokens": [
"if",
"the",
"provider",
"instance",
"is",
"not",
"registered"
],
"type": "QISKitError"
}
],
"params": [
{
... |
a3062918483133f60dd8e6c7dec1caae0e09515f | dsh0416/qiskit-terra | qiskit/wrapper/_wrapper.py | [
"Apache-2.0"
] | Python | registered_providers | <not_specific> | def registered_providers():
"""Return the currently registered providers.
.. deprecated:: 0.6+
After 0.6, this function is deprecated. Please use the methods in
`qiskit.IBMQ` instead (`active_accounts()`).
"""
warnings.warn('registered_providers() will be deprecated after 0.6. Please '
... | Return the currently registered providers.
.. deprecated:: 0.6+
After 0.6, this function is deprecated. Please use the methods in
`qiskit.IBMQ` instead (`active_accounts()`).
| Return the currently registered providers. | [
"Return",
"the",
"currently",
"registered",
"providers",
"."
] | def registered_providers():
warnings.warn('registered_providers() will be deprecated after 0.6. Please '
'use the qiskit.IBMQ.active_accounts() method instead.',
DeprecationWarning)
return IBMQ.active_accounts() | [
"def",
"registered_providers",
"(",
")",
":",
"warnings",
".",
"warn",
"(",
"'registered_providers() will be deprecated after 0.6. Please '",
"'use the qiskit.IBMQ.active_accounts() method instead.'",
",",
"DeprecationWarning",
")",
"return",
"IBMQ",
".",
"active_accounts",
"(",
... | Return the currently registered providers. | [
"Return",
"the",
"currently",
"registered",
"providers",
"."
] | [
"\"\"\"Return the currently registered providers.\n\n .. deprecated:: 0.6+\n After 0.6, this function is deprecated. Please use the methods in\n `qiskit.IBMQ` instead (`active_accounts()`).\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": [
{
"identifier": "deprecation",
"docstring": "After 0.6, this function is deprecated. Please use the methods in\n`qiskit.IBMQ` instead (`active_accounts()`).",
"docstring_tokens": [
"After",
"0"... |
a3062918483133f60dd8e6c7dec1caae0e09515f | dsh0416/qiskit-terra | qiskit/wrapper/_wrapper.py | [
"Apache-2.0"
] | Python | available_backends | <not_specific> | def available_backends(filters=None, compact=True):
"""
Return names of backends that are available in the SDK, optionally filtering
them based on their capabilities.
Note:
In order for this function to return online backends, a connection with
an online backend provider needs to be est... |
Return names of backends that are available in the SDK, optionally filtering
them based on their capabilities.
Note:
In order for this function to return online backends, a connection with
an online backend provider needs to be established by calling the
`register()` function.
... | Return names of backends that are available in the SDK, optionally filtering
them based on their capabilities.
In order for this function to return online backends, a connection with
an online backend provider needs to be established by calling the
`register()` function.
If two or more providers have backends with th... | [
"Return",
"names",
"of",
"backends",
"that",
"are",
"available",
"in",
"the",
"SDK",
"optionally",
"filtering",
"them",
"based",
"on",
"their",
"capabilities",
".",
"In",
"order",
"for",
"this",
"function",
"to",
"return",
"online",
"backends",
"a",
"connectio... | def available_backends(filters=None, compact=True):
warnings.warn('available_backends() will be deprecated after 0.6. Please '
'use the qiskit.IBMQ.backends() and qiskit.Aer.backends() '
'method instead.',
DeprecationWarning)
if isinstance(filters, dict):
... | [
"def",
"available_backends",
"(",
"filters",
"=",
"None",
",",
"compact",
"=",
"True",
")",
":",
"warnings",
".",
"warn",
"(",
"'available_backends() will be deprecated after 0.6. Please '",
"'use the qiskit.IBMQ.backends() and qiskit.Aer.backends() '",
"'method instead.'",
","... | Return names of backends that are available in the SDK, optionally filtering
them based on their capabilities. | [
"Return",
"names",
"of",
"backends",
"that",
"are",
"available",
"in",
"the",
"SDK",
"optionally",
"filtering",
"them",
"based",
"on",
"their",
"capabilities",
"."
] | [
"\"\"\"\n Return names of backends that are available in the SDK, optionally filtering\n them based on their capabilities.\n\n Note:\n In order for this function to return online backends, a connection with\n an online backend provider needs to be established by calling the\n `register... | [
{
"param": "filters",
"type": null
},
{
"param": "compact",
"type": null
}
] | {
"returns": [
{
"docstring": "the names of the available backends.",
"docstring_tokens": [
"the",
"names",
"of",
"the",
"available",
"backends",
"."
],
"type": "list[str]"
}
],
"raises": [],
"params": [
{
"identif... |
a3062918483133f60dd8e6c7dec1caae0e09515f | dsh0416/qiskit-terra | qiskit/wrapper/_wrapper.py | [
"Apache-2.0"
] | Python | least_busy | <not_specific> | def least_busy(names):
"""
Return the least busy available backend for those that
have a `pending_jobs` in their `status`. Backends such as
local backends that do not have this are not considered.
Args:
names (list[str]): backend names to choose from
(e.g. output of ``av... |
Return the least busy available backend for those that
have a `pending_jobs` in their `status`. Backends such as
local backends that do not have this are not considered.
Args:
names (list[str]): backend names to choose from
(e.g. output of ``available_backends()``)
Ret... | Return the least busy available backend for those that
have a `pending_jobs` in their `status`. Backends such as
local backends that do not have this are not considered. | [
"Return",
"the",
"least",
"busy",
"available",
"backend",
"for",
"those",
"that",
"have",
"a",
"`",
"pending_jobs",
"`",
"in",
"their",
"`",
"status",
"`",
".",
"Backends",
"such",
"as",
"local",
"backends",
"that",
"do",
"not",
"have",
"this",
"are",
"n... | def least_busy(names):
backends = [get_backend(name) for name in names]
warnings.warn('the global least_busy() will be deprecated after 0.6. Please '
'use least_busy() imported from qiskit.backends.ibmq',
DeprecationWarning)
return ibmq.least_busy(backends).name() | [
"def",
"least_busy",
"(",
"names",
")",
":",
"backends",
"=",
"[",
"get_backend",
"(",
"name",
")",
"for",
"name",
"in",
"names",
"]",
"warnings",
".",
"warn",
"(",
"'the global least_busy() will be deprecated after 0.6. Please '",
"'use least_busy() imported from qiski... | Return the least busy available backend for those that
have a `pending_jobs` in their `status`. | [
"Return",
"the",
"least",
"busy",
"available",
"backend",
"for",
"those",
"that",
"have",
"a",
"`",
"pending_jobs",
"`",
"in",
"their",
"`",
"status",
"`",
"."
] | [
"\"\"\"\n Return the least busy available backend for those that\n have a `pending_jobs` in their `status`. Backends such as\n local backends that do not have this are not considered.\n\n Args:\n names (list[str]): backend names to choose from\n (e.g. output of ``available_back... | [
{
"param": "names",
"type": null
}
] | {
"returns": [
{
"docstring": "the name of the least busy backend",
"docstring_tokens": [
"the",
"name",
"of",
"the",
"least",
"busy",
"backend"
],
"type": "str"
}
],
"raises": [
{
"docstring": "if passing a list of ... |
a3062918483133f60dd8e6c7dec1caae0e09515f | dsh0416/qiskit-terra | qiskit/wrapper/_wrapper.py | [
"Apache-2.0"
] | Python | compile | <not_specific> | def compile(circuits, backend,
config=None, basis_gates=None, coupling_map=None, initial_layout=None,
shots=1024, max_credits=10, seed=None, qobj_id=None, hpc=None,
skip_transpiler=False):
"""Compile a list of circuits into a qobj.
Args:
circuits (QuantumCircuit or l... | Compile a list of circuits into a qobj.
Args:
circuits (QuantumCircuit or list[QuantumCircuit]): circuits to compile
backend (BaseBackend or str): a backend to compile for
config (dict): dictionary of parameters (e.g. noise) used by runner
basis_gates (str): comma-separated basis ga... | Compile a list of circuits into a qobj. | [
"Compile",
"a",
"list",
"of",
"circuits",
"into",
"a",
"qobj",
"."
] | def compile(circuits, backend,
config=None, basis_gates=None, coupling_map=None, initial_layout=None,
shots=1024, max_credits=10, seed=None, qobj_id=None, hpc=None,
skip_transpiler=False):
if isinstance(backend, str):
warnings.warn('compile() no longer takes backend strin... | [
"def",
"compile",
"(",
"circuits",
",",
"backend",
",",
"config",
"=",
"None",
",",
"basis_gates",
"=",
"None",
",",
"coupling_map",
"=",
"None",
",",
"initial_layout",
"=",
"None",
",",
"shots",
"=",
"1024",
",",
"max_credits",
"=",
"10",
",",
"seed",
... | Compile a list of circuits into a qobj. | [
"Compile",
"a",
"list",
"of",
"circuits",
"into",
"a",
"qobj",
"."
] | [
"\"\"\"Compile a list of circuits into a qobj.\n\n Args:\n circuits (QuantumCircuit or list[QuantumCircuit]): circuits to compile\n backend (BaseBackend or str): a backend to compile for\n config (dict): dictionary of parameters (e.g. noise) used by runner\n basis_gates (str): comma-s... | [
{
"param": "circuits",
"type": null
},
{
"param": "backend",
"type": null
},
{
"param": "config",
"type": null
},
{
"param": "basis_gates",
"type": null
},
{
"param": "coupling_map",
"type": null
},
{
"param": "initial_layout",
"type": null
},
... | {
"returns": [
{
"docstring": "the qobj to be run on the backends",
"docstring_tokens": [
"the",
"qobj",
"to",
"be",
"run",
"on",
"the",
"backends"
],
"type": "Qobj"
}
],
"raises": [
{
"docstring": "in case o... |
a3062918483133f60dd8e6c7dec1caae0e09515f | dsh0416/qiskit-terra | qiskit/wrapper/_wrapper.py | [
"Apache-2.0"
] | Python | execute | <not_specific> | def execute(circuits, backend,
config=None, basis_gates=None, coupling_map=None, initial_layout=None,
shots=1024, max_credits=10, seed=None, qobj_id=None, hpc=None,
skip_transpiler=False):
"""Executes a set of circuits.
Args:
circuits (QuantumCircuit or list[QuantumC... | Executes a set of circuits.
Args:
circuits (QuantumCircuit or list[QuantumCircuit]): circuits to execute
backend (BaseBackend or str): a backend to execute the circuits on
config (dict): dictionary of parameters (e.g. noise) used by runner
basis_gates (str): comma-separated basis ga... | Executes a set of circuits. | [
"Executes",
"a",
"set",
"of",
"circuits",
"."
] | def execute(circuits, backend,
config=None, basis_gates=None, coupling_map=None, initial_layout=None,
shots=1024, max_credits=10, seed=None, qobj_id=None, hpc=None,
skip_transpiler=False):
if isinstance(backend, str):
warnings.warn('execute() no longer takes backend strin... | [
"def",
"execute",
"(",
"circuits",
",",
"backend",
",",
"config",
"=",
"None",
",",
"basis_gates",
"=",
"None",
",",
"coupling_map",
"=",
"None",
",",
"initial_layout",
"=",
"None",
",",
"shots",
"=",
"1024",
",",
"max_credits",
"=",
"10",
",",
"seed",
... | Executes a set of circuits. | [
"Executes",
"a",
"set",
"of",
"circuits",
"."
] | [
"\"\"\"Executes a set of circuits.\n\n Args:\n circuits (QuantumCircuit or list[QuantumCircuit]): circuits to execute\n backend (BaseBackend or str): a backend to execute the circuits on\n config (dict): dictionary of parameters (e.g. noise) used by runner\n basis_gates (str): comma-s... | [
{
"param": "circuits",
"type": null
},
{
"param": "backend",
"type": null
},
{
"param": "config",
"type": null
},
{
"param": "basis_gates",
"type": null
},
{
"param": "coupling_map",
"type": null
},
{
"param": "initial_layout",
"type": null
},
... | {
"returns": [
{
"docstring": "returns job instance derived from BaseJob",
"docstring_tokens": [
"returns",
"job",
"instance",
"derived",
"from",
"BaseJob"
],
"type": "BaseJob"
}
],
"raises": [],
"params": [
{
"identifier"... |
9db9802c2c14ca1ae4ec26fee9851c6dacfeb078 | dsh0416/qiskit-terra | qiskit/unroll/_printerbackend.py | [
"Apache-2.0"
] | Python | version | null | def version(self, version):
"""Print the version string.
v is a version number.
"""
print("OPENQASM %s;" % version) | Print the version string.
v is a version number.
| Print the version string.
v is a version number. | [
"Print",
"the",
"version",
"string",
".",
"v",
"is",
"a",
"version",
"number",
"."
] | def version(self, version):
print("OPENQASM %s;" % version) | [
"def",
"version",
"(",
"self",
",",
"version",
")",
":",
"print",
"(",
"\"OPENQASM %s;\"",
"%",
"version",
")"
] | Print the version string. | [
"Print",
"the",
"version",
"string",
"."
] | [
"\"\"\"Print the version string.\n\n v is a version number.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "version",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "version",
"type": null,
"docstring": null,
"docstring_tokens"... |
9db9802c2c14ca1ae4ec26fee9851c6dacfeb078 | dsh0416/qiskit-terra | qiskit/unroll/_printerbackend.py | [
"Apache-2.0"
] | Python | new_qreg | null | def new_qreg(self, name, size):
"""Create a new quantum register.
name = name of the register
sz = size of the register
"""
assert size >= 0, "invalid qreg size"
print("qreg %s[%d];" % (name, size)) | Create a new quantum register.
name = name of the register
sz = size of the register
| Create a new quantum register.
name = name of the register
sz = size of the register | [
"Create",
"a",
"new",
"quantum",
"register",
".",
"name",
"=",
"name",
"of",
"the",
"register",
"sz",
"=",
"size",
"of",
"the",
"register"
] | def new_qreg(self, name, size):
assert size >= 0, "invalid qreg size"
print("qreg %s[%d];" % (name, size)) | [
"def",
"new_qreg",
"(",
"self",
",",
"name",
",",
"size",
")",
":",
"assert",
"size",
">=",
"0",
",",
"\"invalid qreg size\"",
"print",
"(",
"\"qreg %s[%d];\"",
"%",
"(",
"name",
",",
"size",
")",
")"
] | Create a new quantum register. | [
"Create",
"a",
"new",
"quantum",
"register",
"."
] | [
"\"\"\"Create a new quantum register.\n\n name = name of the register\n sz = size of the register\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "size",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
9db9802c2c14ca1ae4ec26fee9851c6dacfeb078 | dsh0416/qiskit-terra | qiskit/unroll/_printerbackend.py | [
"Apache-2.0"
] | Python | new_creg | null | def new_creg(self, name, size):
"""Create a new classical register.
name = name of the register
sz = size of the register
"""
print("creg %s[%d];" % (name, size)) | Create a new classical register.
name = name of the register
sz = size of the register
| Create a new classical register.
name = name of the register
sz = size of the register | [
"Create",
"a",
"new",
"classical",
"register",
".",
"name",
"=",
"name",
"of",
"the",
"register",
"sz",
"=",
"size",
"of",
"the",
"register"
] | def new_creg(self, name, size):
print("creg %s[%d];" % (name, size)) | [
"def",
"new_creg",
"(",
"self",
",",
"name",
",",
"size",
")",
":",
"print",
"(",
"\"creg %s[%d];\"",
"%",
"(",
"name",
",",
"size",
")",
")"
] | Create a new classical register. | [
"Create",
"a",
"new",
"classical",
"register",
"."
] | [
"\"\"\"Create a new classical register.\n\n name = name of the register\n sz = size of the register\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "size",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
9db9802c2c14ca1ae4ec26fee9851c6dacfeb078 | dsh0416/qiskit-terra | qiskit/unroll/_printerbackend.py | [
"Apache-2.0"
] | Python | _gate_string | <not_specific> | def _gate_string(self, name):
"""Print OPENQASM for the named gate."""
out = ""
if self.gates[name]["opaque"]:
out = "opaque " + name
else:
out = "gate " + name
if self.gates[name]["n_args"] > 0:
out += "(" + ",".join(self.gates[name]["args"]) ... | Print OPENQASM for the named gate. | Print OPENQASM for the named gate. | [
"Print",
"OPENQASM",
"for",
"the",
"named",
"gate",
"."
] | def _gate_string(self, name):
out = ""
if self.gates[name]["opaque"]:
out = "opaque " + name
else:
out = "gate " + name
if self.gates[name]["n_args"] > 0:
out += "(" + ",".join(self.gates[name]["args"]) + ")"
out += " " + ",".join(self.gate... | [
"def",
"_gate_string",
"(",
"self",
",",
"name",
")",
":",
"out",
"=",
"\"\"",
"if",
"self",
".",
"gates",
"[",
"name",
"]",
"[",
"\"opaque\"",
"]",
":",
"out",
"=",
"\"opaque \"",
"+",
"name",
"else",
":",
"out",
"=",
"\"gate \"",
"+",
"name",
"if... | Print OPENQASM for the named gate. | [
"Print",
"OPENQASM",
"for",
"the",
"named",
"gate",
"."
] | [
"\"\"\"Print OPENQASM for the named gate.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
9db9802c2c14ca1ae4ec26fee9851c6dacfeb078 | dsh0416/qiskit-terra | qiskit/unroll/_printerbackend.py | [
"Apache-2.0"
] | Python | define_gate | null | def define_gate(self, name, gatedata):
"""Define a new quantum gate.
name is a string.
gatedata is the AST node for the gate.
"""
atomics = ["U", "CX", "measure", "reset", "barrier"]
self.gates[name] = gatedata
# Print out the gate definition if it is in self.bas... | Define a new quantum gate.
name is a string.
gatedata is the AST node for the gate.
| Define a new quantum gate.
name is a string.
gatedata is the AST node for the gate. | [
"Define",
"a",
"new",
"quantum",
"gate",
".",
"name",
"is",
"a",
"string",
".",
"gatedata",
"is",
"the",
"AST",
"node",
"for",
"the",
"gate",
"."
] | def define_gate(self, name, gatedata):
atomics = ["U", "CX", "measure", "reset", "barrier"]
self.gates[name] = gatedata
if name in self.basis and name not in atomics:
if not self.gates[name]["opaque"]:
calls = self.gates[name]["body"].calls()
for call ... | [
"def",
"define_gate",
"(",
"self",
",",
"name",
",",
"gatedata",
")",
":",
"atomics",
"=",
"[",
"\"U\"",
",",
"\"CX\"",
",",
"\"measure\"",
",",
"\"reset\"",
",",
"\"barrier\"",
"]",
"self",
".",
"gates",
"[",
"name",
"]",
"=",
"gatedata",
"if",
"name"... | Define a new quantum gate. | [
"Define",
"a",
"new",
"quantum",
"gate",
"."
] | [
"\"\"\"Define a new quantum gate.\n\n name is a string.\n gatedata is the AST node for the gate.\n \"\"\"",
"# Print out the gate definition if it is in self.basis",
"# Print the hierarchy of gates this gate calls",
"# Print the gate itself"
] | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "gatedata",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
9db9802c2c14ca1ae4ec26fee9851c6dacfeb078 | dsh0416/qiskit-terra | qiskit/unroll/_printerbackend.py | [
"Apache-2.0"
] | Python | u | null | def u(self, arg, qubit, nested_scope=None):
"""Fundamental single qubit gate.
arg is 3-tuple of Node expression objects.
qubit is (regname,idx) tuple.
nested_scope is a list of dictionaries mapping expression variables
to Node expression objects in order of increasing nesting de... | Fundamental single qubit gate.
arg is 3-tuple of Node expression objects.
qubit is (regname,idx) tuple.
nested_scope is a list of dictionaries mapping expression variables
to Node expression objects in order of increasing nesting depth.
| Fundamental single qubit gate.
arg is 3-tuple of Node expression objects.
qubit is (regname,idx) tuple.
nested_scope is a list of dictionaries mapping expression variables
to Node expression objects in order of increasing nesting depth. | [
"Fundamental",
"single",
"qubit",
"gate",
".",
"arg",
"is",
"3",
"-",
"tuple",
"of",
"Node",
"expression",
"objects",
".",
"qubit",
"is",
"(",
"regname",
"idx",
")",
"tuple",
".",
"nested_scope",
"is",
"a",
"list",
"of",
"dictionaries",
"mapping",
"express... | def u(self, arg, qubit, nested_scope=None):
if self.listen:
if "U" not in self.basis:
self.basis.append("U")
if self.creg is not None:
print("if(%s==%d) " % (self.creg, self.cval), end="")
print("U(%s,%s,%s) %s[%d];" % (arg[0].sym(nested_scope)... | [
"def",
"u",
"(",
"self",
",",
"arg",
",",
"qubit",
",",
"nested_scope",
"=",
"None",
")",
":",
"if",
"self",
".",
"listen",
":",
"if",
"\"U\"",
"not",
"in",
"self",
".",
"basis",
":",
"self",
".",
"basis",
".",
"append",
"(",
"\"U\"",
")",
"if",
... | Fundamental single qubit gate. | [
"Fundamental",
"single",
"qubit",
"gate",
"."
] | [
"\"\"\"Fundamental single qubit gate.\n\n arg is 3-tuple of Node expression objects.\n qubit is (regname,idx) tuple.\n nested_scope is a list of dictionaries mapping expression variables\n to Node expression objects in order of increasing nesting depth.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "arg",
"type": null
},
{
"param": "qubit",
"type": null
},
{
"param": "nested_scope",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "arg",
"type": null,
"docstring": null,
"docstring_tokens": []... |
9db9802c2c14ca1ae4ec26fee9851c6dacfeb078 | dsh0416/qiskit-terra | qiskit/unroll/_printerbackend.py | [
"Apache-2.0"
] | Python | cx | null | def cx(self, qubit0, qubit1):
"""Fundamental two qubit gate.
qubit0 is (regname,idx) tuple for the control qubit.
qubit1 is (regname,idx) tuple for the target qubit.
"""
if self.listen:
if "CX" not in self.basis:
self.basis.append("CX")
if... | Fundamental two qubit gate.
qubit0 is (regname,idx) tuple for the control qubit.
qubit1 is (regname,idx) tuple for the target qubit.
| Fundamental two qubit gate.
qubit0 is (regname,idx) tuple for the control qubit.
qubit1 is (regname,idx) tuple for the target qubit. | [
"Fundamental",
"two",
"qubit",
"gate",
".",
"qubit0",
"is",
"(",
"regname",
"idx",
")",
"tuple",
"for",
"the",
"control",
"qubit",
".",
"qubit1",
"is",
"(",
"regname",
"idx",
")",
"tuple",
"for",
"the",
"target",
"qubit",
"."
] | def cx(self, qubit0, qubit1):
if self.listen:
if "CX" not in self.basis:
self.basis.append("CX")
if self.creg is not None:
print("if(%s==%d) " % (self.creg, self.cval), end="")
print("CX %s[%d],%s[%d];" % (qubit0[0], qubit0[1],
... | [
"def",
"cx",
"(",
"self",
",",
"qubit0",
",",
"qubit1",
")",
":",
"if",
"self",
".",
"listen",
":",
"if",
"\"CX\"",
"not",
"in",
"self",
".",
"basis",
":",
"self",
".",
"basis",
".",
"append",
"(",
"\"CX\"",
")",
"if",
"self",
".",
"creg",
"is",
... | Fundamental two qubit gate. | [
"Fundamental",
"two",
"qubit",
"gate",
"."
] | [
"\"\"\"Fundamental two qubit gate.\n\n qubit0 is (regname,idx) tuple for the control qubit.\n qubit1 is (regname,idx) tuple for the target qubit.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "qubit0",
"type": null
},
{
"param": "qubit1",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "qubit0",
"type": null,
"docstring": null,
"docstring_tokens":... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.