repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
blockstack/virtualchain | virtualchain/lib/blockchain/session.py | get_bitcoind_client | def get_bitcoind_client(config_path=None, bitcoind_opts=None):
"""
Connect to bitcoind
"""
if bitcoind_opts is None and config_path is None:
raise ValueError("Need bitcoind opts or config path")
bitcoind_opts = get_bitcoind_config(config_file=config_path)
log.debug("Connect to bitcoind ... | python | def get_bitcoind_client(config_path=None, bitcoind_opts=None):
"""
Connect to bitcoind
"""
if bitcoind_opts is None and config_path is None:
raise ValueError("Need bitcoind opts or config path")
bitcoind_opts = get_bitcoind_config(config_file=config_path)
log.debug("Connect to bitcoind ... | [
"def",
"get_bitcoind_client",
"(",
"config_path",
"=",
"None",
",",
"bitcoind_opts",
"=",
"None",
")",
":",
"if",
"bitcoind_opts",
"is",
"None",
"and",
"config_path",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Need bitcoind opts or config path\"",
")",
"bit... | Connect to bitcoind | [
"Connect",
"to",
"bitcoind"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/session.py#L181-L192 | train | 63,900 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | set_privkey_compressed | def set_privkey_compressed(privkey, compressed=True):
"""
Make sure the private key given is compressed or not compressed
"""
if len(privkey) != 64 and len(privkey) != 66:
raise ValueError("expected 32-byte private key as a hex string")
# compressed?
if compressed and len(privkey) == 64... | python | def set_privkey_compressed(privkey, compressed=True):
"""
Make sure the private key given is compressed or not compressed
"""
if len(privkey) != 64 and len(privkey) != 66:
raise ValueError("expected 32-byte private key as a hex string")
# compressed?
if compressed and len(privkey) == 64... | [
"def",
"set_privkey_compressed",
"(",
"privkey",
",",
"compressed",
"=",
"True",
")",
":",
"if",
"len",
"(",
"privkey",
")",
"!=",
"64",
"and",
"len",
"(",
"privkey",
")",
"!=",
"66",
":",
"raise",
"ValueError",
"(",
"\"expected 32-byte private key as a hex st... | Make sure the private key given is compressed or not compressed | [
"Make",
"sure",
"the",
"private",
"key",
"given",
"is",
"compressed",
"or",
"not",
"compressed"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L249-L266 | train | 63,901 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | get_pubkey_hex | def get_pubkey_hex( privatekey_hex ):
"""
Get the uncompressed hex form of a private key
"""
if not isinstance(privatekey_hex, (str, unicode)):
raise ValueError("private key is not a hex string but {}".format(str(type(privatekey_hex))))
# remove 'compressed' hint
if len(privatekey_hex) ... | python | def get_pubkey_hex( privatekey_hex ):
"""
Get the uncompressed hex form of a private key
"""
if not isinstance(privatekey_hex, (str, unicode)):
raise ValueError("private key is not a hex string but {}".format(str(type(privatekey_hex))))
# remove 'compressed' hint
if len(privatekey_hex) ... | [
"def",
"get_pubkey_hex",
"(",
"privatekey_hex",
")",
":",
"if",
"not",
"isinstance",
"(",
"privatekey_hex",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"private key is not a hex string but {}\"",
".",
"format",
"(",
"str",
"(",
... | Get the uncompressed hex form of a private key | [
"Get",
"the",
"uncompressed",
"hex",
"form",
"of",
"a",
"private",
"key"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L269-L291 | train | 63,902 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | decode_privkey_hex | def decode_privkey_hex(privkey_hex):
"""
Decode a private key for ecdsa signature
"""
if not isinstance(privkey_hex, (str, unicode)):
raise ValueError("private key is not a string")
# force uncompressed
priv = str(privkey_hex)
if len(priv) > 64:
if priv[-2:] != '01':
... | python | def decode_privkey_hex(privkey_hex):
"""
Decode a private key for ecdsa signature
"""
if not isinstance(privkey_hex, (str, unicode)):
raise ValueError("private key is not a string")
# force uncompressed
priv = str(privkey_hex)
if len(priv) > 64:
if priv[-2:] != '01':
... | [
"def",
"decode_privkey_hex",
"(",
"privkey_hex",
")",
":",
"if",
"not",
"isinstance",
"(",
"privkey_hex",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"private key is not a string\"",
")",
"# force uncompressed",
"priv",
"=",
"st... | Decode a private key for ecdsa signature | [
"Decode",
"a",
"private",
"key",
"for",
"ecdsa",
"signature"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L316-L332 | train | 63,903 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | decode_pubkey_hex | def decode_pubkey_hex(pubkey_hex):
"""
Decode a public key for ecdsa verification
"""
if not isinstance(pubkey_hex, (str, unicode)):
raise ValueError("public key is not a string")
pubk = keylib.key_formatting.decompress(str(pubkey_hex))
assert len(pubk) == 130
pubk_raw = pubk[2:]
... | python | def decode_pubkey_hex(pubkey_hex):
"""
Decode a public key for ecdsa verification
"""
if not isinstance(pubkey_hex, (str, unicode)):
raise ValueError("public key is not a string")
pubk = keylib.key_formatting.decompress(str(pubkey_hex))
assert len(pubk) == 130
pubk_raw = pubk[2:]
... | [
"def",
"decode_pubkey_hex",
"(",
"pubkey_hex",
")",
":",
"if",
"not",
"isinstance",
"(",
"pubkey_hex",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"public key is not a string\"",
")",
"pubk",
"=",
"keylib",
".",
"key_formattin... | Decode a public key for ecdsa verification | [
"Decode",
"a",
"public",
"key",
"for",
"ecdsa",
"verification"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L335-L347 | train | 63,904 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | encode_signature | def encode_signature(sig_r, sig_s):
"""
Encode an ECDSA signature, with low-s
"""
# enforce low-s
if sig_s * 2 >= SECP256k1_order:
log.debug("High-S to low-S")
sig_s = SECP256k1_order - sig_s
sig_bin = '{:064x}{:064x}'.format(sig_r, sig_s).decode('hex')
assert len(sig_bin) ... | python | def encode_signature(sig_r, sig_s):
"""
Encode an ECDSA signature, with low-s
"""
# enforce low-s
if sig_s * 2 >= SECP256k1_order:
log.debug("High-S to low-S")
sig_s = SECP256k1_order - sig_s
sig_bin = '{:064x}{:064x}'.format(sig_r, sig_s).decode('hex')
assert len(sig_bin) ... | [
"def",
"encode_signature",
"(",
"sig_r",
",",
"sig_s",
")",
":",
"# enforce low-s ",
"if",
"sig_s",
"*",
"2",
">=",
"SECP256k1_order",
":",
"log",
".",
"debug",
"(",
"\"High-S to low-S\"",
")",
"sig_s",
"=",
"SECP256k1_order",
"-",
"sig_s",
"sig_bin",
"=",
"... | Encode an ECDSA signature, with low-s | [
"Encode",
"an",
"ECDSA",
"signature",
"with",
"low",
"-",
"s"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L350-L363 | train | 63,905 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | decode_signature | def decode_signature(sigb64):
"""
Decode a signature into r, s
"""
sig_bin = base64.b64decode(sigb64)
if len(sig_bin) != 64:
raise ValueError("Invalid base64 signature")
sig_hex = sig_bin.encode('hex')
sig_r = int(sig_hex[:64], 16)
sig_s = int(sig_hex[64:], 16)
return sig_r,... | python | def decode_signature(sigb64):
"""
Decode a signature into r, s
"""
sig_bin = base64.b64decode(sigb64)
if len(sig_bin) != 64:
raise ValueError("Invalid base64 signature")
sig_hex = sig_bin.encode('hex')
sig_r = int(sig_hex[:64], 16)
sig_s = int(sig_hex[64:], 16)
return sig_r,... | [
"def",
"decode_signature",
"(",
"sigb64",
")",
":",
"sig_bin",
"=",
"base64",
".",
"b64decode",
"(",
"sigb64",
")",
"if",
"len",
"(",
"sig_bin",
")",
"!=",
"64",
":",
"raise",
"ValueError",
"(",
"\"Invalid base64 signature\"",
")",
"sig_hex",
"=",
"sig_bin",... | Decode a signature into r, s | [
"Decode",
"a",
"signature",
"into",
"r",
"s"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L366-L377 | train | 63,906 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | sign_raw_data | def sign_raw_data(raw_data, privatekey_hex):
"""
Sign a string of data.
Returns signature as a base64 string
"""
if not isinstance(raw_data, (str, unicode)):
raise ValueError("Data is not a string")
raw_data = str(raw_data)
si = ECSigner(privatekey_hex)
si.update(raw_data)
... | python | def sign_raw_data(raw_data, privatekey_hex):
"""
Sign a string of data.
Returns signature as a base64 string
"""
if not isinstance(raw_data, (str, unicode)):
raise ValueError("Data is not a string")
raw_data = str(raw_data)
si = ECSigner(privatekey_hex)
si.update(raw_data)
... | [
"def",
"sign_raw_data",
"(",
"raw_data",
",",
"privatekey_hex",
")",
":",
"if",
"not",
"isinstance",
"(",
"raw_data",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"Data is not a string\"",
")",
"raw_data",
"=",
"str",
"(",
... | Sign a string of data.
Returns signature as a base64 string | [
"Sign",
"a",
"string",
"of",
"data",
".",
"Returns",
"signature",
"as",
"a",
"base64",
"string"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L380-L392 | train | 63,907 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | verify_raw_data | def verify_raw_data(raw_data, pubkey_hex, sigb64):
"""
Verify the signature over a string, given the public key
and base64-encode signature.
Return True on success.
Return False on error.
"""
if not isinstance(raw_data, (str, unicode)):
raise ValueError("data is not a string")
r... | python | def verify_raw_data(raw_data, pubkey_hex, sigb64):
"""
Verify the signature over a string, given the public key
and base64-encode signature.
Return True on success.
Return False on error.
"""
if not isinstance(raw_data, (str, unicode)):
raise ValueError("data is not a string")
r... | [
"def",
"verify_raw_data",
"(",
"raw_data",
",",
"pubkey_hex",
",",
"sigb64",
")",
":",
"if",
"not",
"isinstance",
"(",
"raw_data",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"data is not a string\"",
")",
"raw_data",
"=",
... | Verify the signature over a string, given the public key
and base64-encode signature.
Return True on success.
Return False on error. | [
"Verify",
"the",
"signature",
"over",
"a",
"string",
"given",
"the",
"public",
"key",
"and",
"base64",
"-",
"encode",
"signature",
".",
"Return",
"True",
"on",
"success",
".",
"Return",
"False",
"on",
"error",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L395-L409 | train | 63,908 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | sign_digest | def sign_digest(hash_hex, privkey_hex, hashfunc=hashlib.sha256):
"""
Given a digest and a private key, sign it.
Return the base64-encoded signature
"""
if not isinstance(hash_hex, (str, unicode)):
raise ValueError("hash hex is not a string")
hash_hex = str(hash_hex)
pk_i = decode_p... | python | def sign_digest(hash_hex, privkey_hex, hashfunc=hashlib.sha256):
"""
Given a digest and a private key, sign it.
Return the base64-encoded signature
"""
if not isinstance(hash_hex, (str, unicode)):
raise ValueError("hash hex is not a string")
hash_hex = str(hash_hex)
pk_i = decode_p... | [
"def",
"sign_digest",
"(",
"hash_hex",
",",
"privkey_hex",
",",
"hashfunc",
"=",
"hashlib",
".",
"sha256",
")",
":",
"if",
"not",
"isinstance",
"(",
"hash_hex",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"hash hex is not ... | Given a digest and a private key, sign it.
Return the base64-encoded signature | [
"Given",
"a",
"digest",
"and",
"a",
"private",
"key",
"sign",
"it",
".",
"Return",
"the",
"base64",
"-",
"encoded",
"signature"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L412-L429 | train | 63,909 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | ECSigner.finalize | def finalize(self):
"""
Get the base64-encoded signature itself.
Can only be called once.
"""
signature = self.signer.finalize()
sig_r, sig_s = decode_dss_signature(signature)
sig_b64 = encode_signature(sig_r, sig_s)
return sig_b64 | python | def finalize(self):
"""
Get the base64-encoded signature itself.
Can only be called once.
"""
signature = self.signer.finalize()
sig_r, sig_s = decode_dss_signature(signature)
sig_b64 = encode_signature(sig_r, sig_s)
return sig_b64 | [
"def",
"finalize",
"(",
"self",
")",
":",
"signature",
"=",
"self",
".",
"signer",
".",
"finalize",
"(",
")",
"sig_r",
",",
"sig_s",
"=",
"decode_dss_signature",
"(",
"signature",
")",
"sig_b64",
"=",
"encode_signature",
"(",
"sig_r",
",",
"sig_s",
")",
... | Get the base64-encoded signature itself.
Can only be called once. | [
"Get",
"the",
"base64",
"-",
"encoded",
"signature",
"itself",
".",
"Can",
"only",
"be",
"called",
"once",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L65-L73 | train | 63,910 |
blockstack/virtualchain | virtualchain/lib/ecdsalib.py | ECVerifier.update | def update(self, data):
"""
Update the hash used to generate the signature
"""
try:
self.verifier.update(data)
except TypeError:
log.error("Invalid data: {} ({})".format(type(data), data))
raise | python | def update(self, data):
"""
Update the hash used to generate the signature
"""
try:
self.verifier.update(data)
except TypeError:
log.error("Invalid data: {} ({})".format(type(data), data))
raise | [
"def",
"update",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"self",
".",
"verifier",
".",
"update",
"(",
"data",
")",
"except",
"TypeError",
":",
"log",
".",
"error",
"(",
"\"Invalid data: {} ({})\"",
".",
"format",
"(",
"type",
"(",
"data",
")",
... | Update the hash used to generate the signature | [
"Update",
"the",
"hash",
"used",
"to",
"generate",
"the",
"signature"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/ecdsalib.py#L90-L98 | train | 63,911 |
mdickinson/bigfloat | examples/contfrac.py | semiconvergents | def semiconvergents(x):
"""Semiconvergents of continued fraction expansion of a Fraction x."""
(q, n), d = divmod(x.numerator, x.denominator), x.denominator
yield Fraction(q)
p0, q0, p1, q1 = 1, 0, q, 1
while n:
(q, n), d = divmod(d, n), n
for _ in range(q):
p0, q0 = p0+... | python | def semiconvergents(x):
"""Semiconvergents of continued fraction expansion of a Fraction x."""
(q, n), d = divmod(x.numerator, x.denominator), x.denominator
yield Fraction(q)
p0, q0, p1, q1 = 1, 0, q, 1
while n:
(q, n), d = divmod(d, n), n
for _ in range(q):
p0, q0 = p0+... | [
"def",
"semiconvergents",
"(",
"x",
")",
":",
"(",
"q",
",",
"n",
")",
",",
"d",
"=",
"divmod",
"(",
"x",
".",
"numerator",
",",
"x",
".",
"denominator",
")",
",",
"x",
".",
"denominator",
"yield",
"Fraction",
"(",
"q",
")",
"p0",
",",
"q0",
",... | Semiconvergents of continued fraction expansion of a Fraction x. | [
"Semiconvergents",
"of",
"continued",
"fraction",
"expansion",
"of",
"a",
"Fraction",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/examples/contfrac.py#L38-L49 | train | 63,912 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_pandas_wrapper.py | PandasWrapper.replace | def replace(self, to_replace=None, value=None, inplace=False,
limit=None, regex=False, method='pad', axis=None):
"""Replace values given in 'to_replace' with 'value'.
Wrapper around the :meth:`pandas.DataFrame.replace` method.
"""
if inplace:
self._frame.repl... | python | def replace(self, to_replace=None, value=None, inplace=False,
limit=None, regex=False, method='pad', axis=None):
"""Replace values given in 'to_replace' with 'value'.
Wrapper around the :meth:`pandas.DataFrame.replace` method.
"""
if inplace:
self._frame.repl... | [
"def",
"replace",
"(",
"self",
",",
"to_replace",
"=",
"None",
",",
"value",
"=",
"None",
",",
"inplace",
"=",
"False",
",",
"limit",
"=",
"None",
",",
"regex",
"=",
"False",
",",
"method",
"=",
"'pad'",
",",
"axis",
"=",
"None",
")",
":",
"if",
... | Replace values given in 'to_replace' with 'value'.
Wrapper around the :meth:`pandas.DataFrame.replace` method. | [
"Replace",
"values",
"given",
"in",
"to_replace",
"with",
"value",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_pandas_wrapper.py#L195-L211 | train | 63,913 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_pandas_wrapper.py | PandasWrapper.append | def append(self, other, ignore_index=False):
"""Append rows of `other` to the end of this frame, returning a new object.
Wrapper around the :meth:`pandas.DataFrame.append` method.
Args:
other (Cartesian):
ignore_index (sequence, bool, int): If it is a boolean, it
... | python | def append(self, other, ignore_index=False):
"""Append rows of `other` to the end of this frame, returning a new object.
Wrapper around the :meth:`pandas.DataFrame.append` method.
Args:
other (Cartesian):
ignore_index (sequence, bool, int): If it is a boolean, it
... | [
"def",
"append",
"(",
"self",
",",
"other",
",",
"ignore_index",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
":",
"raise",
"ValueError",
"(",
"'May only append instances of same type.'",
")",
"if",
"ty... | Append rows of `other` to the end of this frame, returning a new object.
Wrapper around the :meth:`pandas.DataFrame.append` method.
Args:
other (Cartesian):
ignore_index (sequence, bool, int): If it is a boolean, it
behaves like in the description of
... | [
"Append",
"rows",
"of",
"other",
"to",
"the",
"end",
"of",
"this",
"frame",
"returning",
"a",
"new",
"object",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_pandas_wrapper.py#L244-L277 | train | 63,914 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_pandas_wrapper.py | PandasWrapper.apply | def apply(self, *args, **kwargs):
"""Applies function along input axis of DataFrame.
Wrapper around the :meth:`pandas.DataFrame.apply` method.
"""
return self.__class__(self._frame.apply(*args, **kwargs),
metadata=self.metadata,
... | python | def apply(self, *args, **kwargs):
"""Applies function along input axis of DataFrame.
Wrapper around the :meth:`pandas.DataFrame.apply` method.
"""
return self.__class__(self._frame.apply(*args, **kwargs),
metadata=self.metadata,
... | [
"def",
"apply",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"self",
".",
"_frame",
".",
"apply",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
",",
"metadata",
"=",
"self",
".",
"... | Applies function along input axis of DataFrame.
Wrapper around the :meth:`pandas.DataFrame.apply` method. | [
"Applies",
"function",
"along",
"input",
"axis",
"of",
"DataFrame",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_pandas_wrapper.py#L291-L298 | train | 63,915 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_pandas_wrapper.py | PandasWrapper.applymap | def applymap(self, *args, **kwargs):
"""Applies function elementwise
Wrapper around the :meth:`pandas.DataFrame.applymap` method.
"""
return self.__class__(self._frame.applymap(*args, **kwargs),
metadata=self.metadata,
_metadat... | python | def applymap(self, *args, **kwargs):
"""Applies function elementwise
Wrapper around the :meth:`pandas.DataFrame.applymap` method.
"""
return self.__class__(self._frame.applymap(*args, **kwargs),
metadata=self.metadata,
_metadat... | [
"def",
"applymap",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"self",
".",
"_frame",
".",
"applymap",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
",",
"metadata",
"=",
"self",
".... | Applies function elementwise
Wrapper around the :meth:`pandas.DataFrame.applymap` method. | [
"Applies",
"function",
"elementwise"
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_pandas_wrapper.py#L300-L307 | train | 63,916 |
anjianshi/flask-restful-extend | flask_restful_extend/marshal.py | marshal_with_model | def marshal_with_model(model, excludes=None, only=None, extends=None):
"""With this decorator, you can return ORM model instance, or ORM query in view function directly.
We'll transform these objects to standard python data structures, like Flask-RESTFul's `marshal_with` decorator.
And, you don't need defin... | python | def marshal_with_model(model, excludes=None, only=None, extends=None):
"""With this decorator, you can return ORM model instance, or ORM query in view function directly.
We'll transform these objects to standard python data structures, like Flask-RESTFul's `marshal_with` decorator.
And, you don't need defin... | [
"def",
"marshal_with_model",
"(",
"model",
",",
"excludes",
"=",
"None",
",",
"only",
"=",
"None",
",",
"extends",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"excludes",
",",
"six",
".",
"string_types",
")",
":",
"excludes",
"=",
"[",
"excludes",
... | With this decorator, you can return ORM model instance, or ORM query in view function directly.
We'll transform these objects to standard python data structures, like Flask-RESTFul's `marshal_with` decorator.
And, you don't need define fields at all.
You can specific columns to be returned, by `excludes` o... | [
"With",
"this",
"decorator",
"you",
"can",
"return",
"ORM",
"model",
"instance",
"or",
"ORM",
"query",
"in",
"view",
"function",
"directly",
".",
"We",
"ll",
"transform",
"these",
"objects",
"to",
"standard",
"python",
"data",
"structures",
"like",
"Flask",
... | cc168729bf341d4f9c0f6938be30463acbf770f1 | https://github.com/anjianshi/flask-restful-extend/blob/cc168729bf341d4f9c0f6938be30463acbf770f1/flask_restful_extend/marshal.py#L8-L70 | train | 63,917 |
anjianshi/flask-restful-extend | flask_restful_extend/marshal.py | quick_marshal | def quick_marshal(*args, **kwargs):
"""In some case, one view functions may return different model in different situation.
Use `marshal_with_model` to handle this situation was tedious.
This function can simplify this process.
Usage:
quick_marshal(args_to_marshal_with_model)(db_instance_or_query)
... | python | def quick_marshal(*args, **kwargs):
"""In some case, one view functions may return different model in different situation.
Use `marshal_with_model` to handle this situation was tedious.
This function can simplify this process.
Usage:
quick_marshal(args_to_marshal_with_model)(db_instance_or_query)
... | [
"def",
"quick_marshal",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"@",
"marshal_with_model",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"def",
"fn",
"(",
"value",
")",
":",
"return",
"value",
"return",
"fn"
] | In some case, one view functions may return different model in different situation.
Use `marshal_with_model` to handle this situation was tedious.
This function can simplify this process.
Usage:
quick_marshal(args_to_marshal_with_model)(db_instance_or_query) | [
"In",
"some",
"case",
"one",
"view",
"functions",
"may",
"return",
"different",
"model",
"in",
"different",
"situation",
".",
"Use",
"marshal_with_model",
"to",
"handle",
"this",
"situation",
"was",
"tedious",
".",
"This",
"function",
"can",
"simplify",
"this",
... | cc168729bf341d4f9c0f6938be30463acbf770f1 | https://github.com/anjianshi/flask-restful-extend/blob/cc168729bf341d4f9c0f6938be30463acbf770f1/flask_restful_extend/marshal.py#L73-L84 | train | 63,918 |
anjianshi/flask-restful-extend | flask_restful_extend/marshal.py | _wrap_field | def _wrap_field(field):
"""Improve Flask-RESTFul's original field type"""
class WrappedField(field):
def output(self, key, obj):
value = _fields.get_value(key if self.attribute is None else self.attribute, obj)
# For all fields, when its value was null (None), return null direct... | python | def _wrap_field(field):
"""Improve Flask-RESTFul's original field type"""
class WrappedField(field):
def output(self, key, obj):
value = _fields.get_value(key if self.attribute is None else self.attribute, obj)
# For all fields, when its value was null (None), return null direct... | [
"def",
"_wrap_field",
"(",
"field",
")",
":",
"class",
"WrappedField",
"(",
"field",
")",
":",
"def",
"output",
"(",
"self",
",",
"key",
",",
"obj",
")",
":",
"value",
"=",
"_fields",
".",
"get_value",
"(",
"key",
"if",
"self",
".",
"attribute",
"is"... | Improve Flask-RESTFul's original field type | [
"Improve",
"Flask",
"-",
"RESTFul",
"s",
"original",
"field",
"type"
] | cc168729bf341d4f9c0f6938be30463acbf770f1 | https://github.com/anjianshi/flask-restful-extend/blob/cc168729bf341d4f9c0f6938be30463acbf770f1/flask_restful_extend/marshal.py#L87-L97 | train | 63,919 |
mcocdawc/chemcoord | src/chemcoord/configuration.py | write_configuration_file | def write_configuration_file(filepath=_give_default_file_path(),
overwrite=False):
"""Create a configuration file.
Writes the current state of settings into a configuration file.
.. note:: Since a file is permamently written, this function
is strictly speaking not side... | python | def write_configuration_file(filepath=_give_default_file_path(),
overwrite=False):
"""Create a configuration file.
Writes the current state of settings into a configuration file.
.. note:: Since a file is permamently written, this function
is strictly speaking not side... | [
"def",
"write_configuration_file",
"(",
"filepath",
"=",
"_give_default_file_path",
"(",
")",
",",
"overwrite",
"=",
"False",
")",
":",
"config",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"config",
".",
"read_dict",
"(",
"settings",
")",
"if",
"os",
... | Create a configuration file.
Writes the current state of settings into a configuration file.
.. note:: Since a file is permamently written, this function
is strictly speaking not sideeffect free.
Args:
filepath (str): Where to write the file.
The default is under both UNIX and... | [
"Create",
"a",
"configuration",
"file",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/configuration.py#L32-L59 | train | 63,920 |
emory-libraries/eulxml | eulxml/xmlmap/eadmap.py | Component.hasSubseries | def hasSubseries(self):
"""Check if this component has subseries or not.
Determined based on level of first subcomponent (series or subseries)
or if first component has subcomponents present.
:rtype: boolean
"""
if self.c and self.c[0] and ((self.c[0].level in... | python | def hasSubseries(self):
"""Check if this component has subseries or not.
Determined based on level of first subcomponent (series or subseries)
or if first component has subcomponents present.
:rtype: boolean
"""
if self.c and self.c[0] and ((self.c[0].level in... | [
"def",
"hasSubseries",
"(",
"self",
")",
":",
"if",
"self",
".",
"c",
"and",
"self",
".",
"c",
"[",
"0",
"]",
"and",
"(",
"(",
"self",
".",
"c",
"[",
"0",
"]",
".",
"level",
"in",
"(",
"'series'",
",",
"'subseries'",
")",
")",
"or",
"(",
"sel... | Check if this component has subseries or not.
Determined based on level of first subcomponent (series or subseries)
or if first component has subcomponents present.
:rtype: boolean | [
"Check",
"if",
"this",
"component",
"has",
"subseries",
"or",
"not",
"."
] | 17d71c7d98c0cebda9932b7f13e72093805e1fe2 | https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/eadmap.py#L274-L286 | train | 63,921 |
probcomp/crosscat | src/LocalEngine.py | LocalEngine.initialize | def initialize(
self, M_c, M_r, T, seed, initialization=b'from_the_prior',
row_initialization=-1, n_chains=1,
ROW_CRP_ALPHA_GRID=(), COLUMN_CRP_ALPHA_GRID=(),
S_GRID=(), MU_GRID=(), N_GRID=31,):
"""Sample a latent state from prior.
T, list of lists:
... | python | def initialize(
self, M_c, M_r, T, seed, initialization=b'from_the_prior',
row_initialization=-1, n_chains=1,
ROW_CRP_ALPHA_GRID=(), COLUMN_CRP_ALPHA_GRID=(),
S_GRID=(), MU_GRID=(), N_GRID=31,):
"""Sample a latent state from prior.
T, list of lists:
... | [
"def",
"initialize",
"(",
"self",
",",
"M_c",
",",
"M_r",
",",
"T",
",",
"seed",
",",
"initialization",
"=",
"b'from_the_prior'",
",",
"row_initialization",
"=",
"-",
"1",
",",
"n_chains",
"=",
"1",
",",
"ROW_CRP_ALPHA_GRID",
"=",
"(",
")",
",",
"COLUMN_... | Sample a latent state from prior.
T, list of lists:
The data table in mapped representation (all floats, generated
by data_utils.read_data_objects)
:returns: X_L, X_D -- the latent state | [
"Sample",
"a",
"latent",
"state",
"from",
"prior",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L77-L101 | train | 63,922 |
probcomp/crosscat | src/LocalEngine.py | LocalEngine.insert | def insert(
self, M_c, T, X_L_list, X_D_list, new_rows=None, N_GRID=31,
CT_KERNEL=0):
"""Insert mutates the data T."""
if new_rows is None:
raise ValueError("new_row must exist")
if not isinstance(new_rows, list):
raise TypeError('new_rows must be... | python | def insert(
self, M_c, T, X_L_list, X_D_list, new_rows=None, N_GRID=31,
CT_KERNEL=0):
"""Insert mutates the data T."""
if new_rows is None:
raise ValueError("new_row must exist")
if not isinstance(new_rows, list):
raise TypeError('new_rows must be... | [
"def",
"insert",
"(",
"self",
",",
"M_c",
",",
"T",
",",
"X_L_list",
",",
"X_D_list",
",",
"new_rows",
"=",
"None",
",",
"N_GRID",
"=",
"31",
",",
"CT_KERNEL",
"=",
"0",
")",
":",
"if",
"new_rows",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"... | Insert mutates the data T. | [
"Insert",
"mutates",
"the",
"data",
"T",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L117-L144 | train | 63,923 |
probcomp/crosscat | src/LocalEngine.py | LocalEngine.analyze | def analyze(self, M_c, T, X_L, X_D, seed, kernel_list=(), n_steps=1, c=(),
r=(),
max_iterations=-1, max_time=-1, do_diagnostics=False,
diagnostics_every_N=1,
ROW_CRP_ALPHA_GRID=(),
COLUMN_CRP_ALPHA_GRID=(),
S_GRID=(), MU_GRI... | python | def analyze(self, M_c, T, X_L, X_D, seed, kernel_list=(), n_steps=1, c=(),
r=(),
max_iterations=-1, max_time=-1, do_diagnostics=False,
diagnostics_every_N=1,
ROW_CRP_ALPHA_GRID=(),
COLUMN_CRP_ALPHA_GRID=(),
S_GRID=(), MU_GRI... | [
"def",
"analyze",
"(",
"self",
",",
"M_c",
",",
"T",
",",
"X_L",
",",
"X_D",
",",
"seed",
",",
"kernel_list",
"=",
"(",
")",
",",
"n_steps",
"=",
"1",
",",
"c",
"=",
"(",
")",
",",
"r",
"=",
"(",
")",
",",
"max_iterations",
"=",
"-",
"1",
"... | Evolve the latent state by running MCMC transition kernels.
:param seed: The random seed
:type seed: int
:param M_c: The column metadata
:type M_c: dict
:param T: The data table in mapped representation (all floats, generated
by data_utils.read_data_objects)
... | [
"Evolve",
"the",
"latent",
"state",
"by",
"running",
"MCMC",
"transition",
"kernels",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L177-L284 | train | 63,924 |
probcomp/crosscat | src/LocalEngine.py | LocalEngine.simple_predictive_sample | def simple_predictive_sample(self, M_c, X_L, X_D, Y, Q, seed, n=1):
"""Sample values from predictive distribution of the given latent state.
:param Y: A list of constraints to apply when sampling. Each constraint
is a triplet of (r, d, v): r is the row index, d is the column
in... | python | def simple_predictive_sample(self, M_c, X_L, X_D, Y, Q, seed, n=1):
"""Sample values from predictive distribution of the given latent state.
:param Y: A list of constraints to apply when sampling. Each constraint
is a triplet of (r, d, v): r is the row index, d is the column
in... | [
"def",
"simple_predictive_sample",
"(",
"self",
",",
"M_c",
",",
"X_L",
",",
"X_D",
",",
"Y",
",",
"Q",
",",
"seed",
",",
"n",
"=",
"1",
")",
":",
"get_next_seed",
"=",
"make_get_next_seed",
"(",
"seed",
")",
"samples",
"=",
"_do_simple_predictive_sample",... | Sample values from predictive distribution of the given latent state.
:param Y: A list of constraints to apply when sampling. Each constraint
is a triplet of (r, d, v): r is the row index, d is the column
index and v is the value of the constraint
:type Y: list of lists
... | [
"Sample",
"values",
"from",
"predictive",
"distribution",
"of",
"the",
"given",
"latent",
"state",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L322-L340 | train | 63,925 |
probcomp/crosscat | src/LocalEngine.py | LocalEngine.mutual_information | def mutual_information(
self, M_c, X_L_list, X_D_list, Q, seed, n_samples=1000):
"""Estimate mutual information for each pair of columns on Q given
the set of samples.
:param Q: List of tuples where each tuple contains the two column
indexes to compare
:type Q: l... | python | def mutual_information(
self, M_c, X_L_list, X_D_list, Q, seed, n_samples=1000):
"""Estimate mutual information for each pair of columns on Q given
the set of samples.
:param Q: List of tuples where each tuple contains the two column
indexes to compare
:type Q: l... | [
"def",
"mutual_information",
"(",
"self",
",",
"M_c",
",",
"X_L_list",
",",
"X_D_list",
",",
"Q",
",",
"seed",
",",
"n_samples",
"=",
"1000",
")",
":",
"get_next_seed",
"=",
"make_get_next_seed",
"(",
"seed",
")",
"return",
"iu",
".",
"mutual_information",
... | Estimate mutual information for each pair of columns on Q given
the set of samples.
:param Q: List of tuples where each tuple contains the two column
indexes to compare
:type Q: list of two-tuples of ints
:param n_samples: the number of simple predictive samples to use
... | [
"Estimate",
"mutual",
"information",
"for",
"each",
"pair",
"of",
"columns",
"on",
"Q",
"given",
"the",
"set",
"of",
"samples",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L417-L433 | train | 63,926 |
probcomp/crosscat | src/LocalEngine.py | LocalEngine.similarity | def similarity(
self, M_c, X_L_list, X_D_list, given_row_id, target_row_id,
target_columns=None):
"""Computes the similarity of the given row to the target row,
averaged over all the column indexes given by target_columns.
:param given_row_id: the id of one of the rows t... | python | def similarity(
self, M_c, X_L_list, X_D_list, given_row_id, target_row_id,
target_columns=None):
"""Computes the similarity of the given row to the target row,
averaged over all the column indexes given by target_columns.
:param given_row_id: the id of one of the rows t... | [
"def",
"similarity",
"(",
"self",
",",
"M_c",
",",
"X_L_list",
",",
"X_D_list",
",",
"given_row_id",
",",
"target_row_id",
",",
"target_columns",
"=",
"None",
")",
":",
"return",
"su",
".",
"similarity",
"(",
"M_c",
",",
"X_L_list",
",",
"X_D_list",
",",
... | Computes the similarity of the given row to the target row,
averaged over all the column indexes given by target_columns.
:param given_row_id: the id of one of the rows to measure similarity
between
:type given_row_id: int
:param target_row_id: the id of the other row to mea... | [
"Computes",
"the",
"similarity",
"of",
"the",
"given",
"row",
"to",
"the",
"target",
"row",
"averaged",
"over",
"all",
"the",
"column",
"indexes",
"given",
"by",
"target_columns",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L458-L478 | train | 63,927 |
probcomp/crosscat | src/LocalEngine.py | LocalEngine.impute | def impute(self, M_c, X_L, X_D, Y, Q, seed, n):
"""Impute values from predictive distribution of the given latent state.
:param Y: A list of constraints to apply when sampling. Each constraint
is a triplet of (r,d,v): r is the row index, d is the column
index and v is the value... | python | def impute(self, M_c, X_L, X_D, Y, Q, seed, n):
"""Impute values from predictive distribution of the given latent state.
:param Y: A list of constraints to apply when sampling. Each constraint
is a triplet of (r,d,v): r is the row index, d is the column
index and v is the value... | [
"def",
"impute",
"(",
"self",
",",
"M_c",
",",
"X_L",
",",
"X_D",
",",
"Y",
",",
"Q",
",",
"seed",
",",
"n",
")",
":",
"get_next_seed",
"=",
"make_get_next_seed",
"(",
"seed",
")",
"e",
"=",
"su",
".",
"impute",
"(",
"M_c",
",",
"X_L",
",",
"X_... | Impute values from predictive distribution of the given latent state.
:param Y: A list of constraints to apply when sampling. Each constraint
is a triplet of (r,d,v): r is the row index, d is the column
index and v is the value of the constraint
:type Y: list of lists
:... | [
"Impute",
"values",
"from",
"predictive",
"distribution",
"of",
"the",
"given",
"latent",
"state",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L481-L499 | train | 63,928 |
probcomp/crosscat | src/LocalEngine.py | LocalEngine.impute_and_confidence | def impute_and_confidence(self, M_c, X_L, X_D, Y, Q, seed, n):
"""Impute values and confidence of the value from the predictive
distribution of the given latent state.
:param Y: A list of constraints to apply when sampling. Each constraint
is a triplet of (r, d, v): r is the row in... | python | def impute_and_confidence(self, M_c, X_L, X_D, Y, Q, seed, n):
"""Impute values and confidence of the value from the predictive
distribution of the given latent state.
:param Y: A list of constraints to apply when sampling. Each constraint
is a triplet of (r, d, v): r is the row in... | [
"def",
"impute_and_confidence",
"(",
"self",
",",
"M_c",
",",
"X_L",
",",
"X_D",
",",
"Y",
",",
"Q",
",",
"seed",
",",
"n",
")",
":",
"get_next_seed",
"=",
"make_get_next_seed",
"(",
"seed",
")",
"if",
"isinstance",
"(",
"X_L",
",",
"(",
"list",
",",... | Impute values and confidence of the value from the predictive
distribution of the given latent state.
:param Y: A list of constraints to apply when sampling. Each constraint
is a triplet of (r, d, v): r is the row index, d is the column
index and v is the value of the constrain... | [
"Impute",
"values",
"and",
"confidence",
"of",
"the",
"value",
"from",
"the",
"predictive",
"distribution",
"of",
"the",
"given",
"latent",
"state",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L502-L530 | train | 63,929 |
probcomp/crosscat | src/LocalEngine.py | LocalEngine.ensure_col_dep_constraints | def ensure_col_dep_constraints(
self, M_c, M_r, T, X_L, X_D, dep_constraints,
seed, max_rejections=100):
"""Ensures dependencey or indepdendency between columns.
`dep_constraints` is a list of where each entry is an (int, int, bool)
tuple where the first two entries are ... | python | def ensure_col_dep_constraints(
self, M_c, M_r, T, X_L, X_D, dep_constraints,
seed, max_rejections=100):
"""Ensures dependencey or indepdendency between columns.
`dep_constraints` is a list of where each entry is an (int, int, bool)
tuple where the first two entries are ... | [
"def",
"ensure_col_dep_constraints",
"(",
"self",
",",
"M_c",
",",
"M_r",
",",
"T",
",",
"X_L",
",",
"X_D",
",",
"dep_constraints",
",",
"seed",
",",
"max_rejections",
"=",
"100",
")",
":",
"X_L_list",
",",
"X_D_list",
",",
"was_multistate",
"=",
"su",
"... | Ensures dependencey or indepdendency between columns.
`dep_constraints` is a list of where each entry is an (int, int, bool)
tuple where the first two entries are column indices and the third entry
describes whether the columns are to be dependent (True) or independent
(False).
... | [
"Ensures",
"dependencey",
"or",
"indepdendency",
"between",
"columns",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L533-L625 | train | 63,930 |
probcomp/crosscat | src/LocalEngine.py | LocalEngine.ensure_row_dep_constraint | def ensure_row_dep_constraint(
self, M_c, T, X_L, X_D, row1, row2, dependent=True, wrt=None,
max_iter=100, force=False):
"""Ensures dependencey or indepdendency between rows with respect to
columns."""
X_L_list, X_D_list, was_multistate = su.ensure_multistate(X_L, X_D)
... | python | def ensure_row_dep_constraint(
self, M_c, T, X_L, X_D, row1, row2, dependent=True, wrt=None,
max_iter=100, force=False):
"""Ensures dependencey or indepdendency between rows with respect to
columns."""
X_L_list, X_D_list, was_multistate = su.ensure_multistate(X_L, X_D)
... | [
"def",
"ensure_row_dep_constraint",
"(",
"self",
",",
"M_c",
",",
"T",
",",
"X_L",
",",
"X_D",
",",
"row1",
",",
"row2",
",",
"dependent",
"=",
"True",
",",
"wrt",
"=",
"None",
",",
"max_iter",
"=",
"100",
",",
"force",
"=",
"False",
")",
":",
"X_L... | Ensures dependencey or indepdendency between rows with respect to
columns. | [
"Ensures",
"dependencey",
"or",
"indepdendency",
"between",
"rows",
"with",
"respect",
"to",
"columns",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/LocalEngine.py#L628-L665 | train | 63,931 |
mdickinson/bigfloat | bigfloat/formatting.py | parse_format_specifier | def parse_format_specifier(specification):
"""
Parse the given format specification and return a dictionary
containing relevant values.
"""
m = _parse_format_specifier_regex.match(specification)
if m is None:
raise ValueError(
"Invalid format specifier: {!r}".format(specific... | python | def parse_format_specifier(specification):
"""
Parse the given format specification and return a dictionary
containing relevant values.
"""
m = _parse_format_specifier_regex.match(specification)
if m is None:
raise ValueError(
"Invalid format specifier: {!r}".format(specific... | [
"def",
"parse_format_specifier",
"(",
"specification",
")",
":",
"m",
"=",
"_parse_format_specifier_regex",
".",
"match",
"(",
"specification",
")",
"if",
"m",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Invalid format specifier: {!r}\"",
".",
"format",
"(",
... | Parse the given format specification and return a dictionary
containing relevant values. | [
"Parse",
"the",
"given",
"format",
"specification",
"and",
"return",
"a",
"dictionary",
"containing",
"relevant",
"values",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/formatting.py#L56-L105 | train | 63,932 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.get_bonds | def get_bonds(self,
self_bonding_allowed=False,
offset=3,
modified_properties=None,
use_lookup=False,
set_lookup=True,
atomic_radius_data=None
):
"""Return a dictionary representing the ... | python | def get_bonds(self,
self_bonding_allowed=False,
offset=3,
modified_properties=None,
use_lookup=False,
set_lookup=True,
atomic_radius_data=None
):
"""Return a dictionary representing the ... | [
"def",
"get_bonds",
"(",
"self",
",",
"self_bonding_allowed",
"=",
"False",
",",
"offset",
"=",
"3",
",",
"modified_properties",
"=",
"None",
",",
"use_lookup",
"=",
"False",
",",
"set_lookup",
"=",
"True",
",",
"atomic_radius_data",
"=",
"None",
")",
":",
... | Return a dictionary representing the bonds.
.. warning:: This function is **not sideeffect free**, since it
assigns the output to a variable ``self._metadata['bond_dict']`` if
``set_lookup`` is ``True`` (which is the default). This is
necessary for performance reasons.
... | [
"Return",
"a",
"dictionary",
"representing",
"the",
"bonds",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L382-L476 | train | 63,933 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.get_coordination_sphere | def get_coordination_sphere(
self, index_of_atom, n_sphere=1, give_only_index=False,
only_surface=True, exclude=None,
use_lookup=None):
"""Return a Cartesian of atoms in the n-th coordination sphere.
Connected means that a path along covalent bonds exists.
A... | python | def get_coordination_sphere(
self, index_of_atom, n_sphere=1, give_only_index=False,
only_surface=True, exclude=None,
use_lookup=None):
"""Return a Cartesian of atoms in the n-th coordination sphere.
Connected means that a path along covalent bonds exists.
A... | [
"def",
"get_coordination_sphere",
"(",
"self",
",",
"index_of_atom",
",",
"n_sphere",
"=",
"1",
",",
"give_only_index",
"=",
"False",
",",
"only_surface",
"=",
"True",
",",
"exclude",
"=",
"None",
",",
"use_lookup",
"=",
"None",
")",
":",
"if",
"use_lookup",... | Return a Cartesian of atoms in the n-th coordination sphere.
Connected means that a path along covalent bonds exists.
Args:
index_of_atom (int):
give_only_index (bool): If ``True`` a set of indices is
returned. Otherwise a new Cartesian instance.
n_s... | [
"Return",
"a",
"Cartesian",
"of",
"atoms",
"in",
"the",
"n",
"-",
"th",
"coordination",
"sphere",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L498-L555 | train | 63,934 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore._preserve_bonds | def _preserve_bonds(self, sliced_cartesian,
use_lookup=None):
"""Is called after cutting geometric shapes.
If you want to change the rules how bonds are preserved, when
applying e.g. :meth:`Cartesian.cut_sphere` this is the
function you have to modify.
... | python | def _preserve_bonds(self, sliced_cartesian,
use_lookup=None):
"""Is called after cutting geometric shapes.
If you want to change the rules how bonds are preserved, when
applying e.g. :meth:`Cartesian.cut_sphere` this is the
function you have to modify.
... | [
"def",
"_preserve_bonds",
"(",
"self",
",",
"sliced_cartesian",
",",
"use_lookup",
"=",
"None",
")",
":",
"if",
"use_lookup",
"is",
"None",
":",
"use_lookup",
"=",
"settings",
"[",
"'defaults'",
"]",
"[",
"'use_lookup'",
"]",
"included_atoms_set",
"=",
"set",
... | Is called after cutting geometric shapes.
If you want to change the rules how bonds are preserved, when
applying e.g. :meth:`Cartesian.cut_sphere` this is the
function you have to modify.
It is recommended to inherit from the Cartesian class to
tailor it for your pro... | [
"Is",
"called",
"after",
"cutting",
"geometric",
"shapes",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L557-L601 | train | 63,935 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.cut_sphere | def cut_sphere(
self,
radius=15.,
origin=None,
outside_sliced=True,
preserve_bonds=False):
"""Cut a sphere specified by origin and radius.
Args:
radius (float):
origin (list): Please note that you can also pass an
... | python | def cut_sphere(
self,
radius=15.,
origin=None,
outside_sliced=True,
preserve_bonds=False):
"""Cut a sphere specified by origin and radius.
Args:
radius (float):
origin (list): Please note that you can also pass an
... | [
"def",
"cut_sphere",
"(",
"self",
",",
"radius",
"=",
"15.",
",",
"origin",
"=",
"None",
",",
"outside_sliced",
"=",
"True",
",",
"preserve_bonds",
"=",
"False",
")",
":",
"if",
"origin",
"is",
"None",
":",
"origin",
"=",
"np",
".",
"zeros",
"(",
"3"... | Cut a sphere specified by origin and radius.
Args:
radius (float):
origin (list): Please note that you can also pass an
integer. In this case it is interpreted as the
index of the atom which is taken as origin.
outside_sliced (bool): Atoms out... | [
"Cut",
"a",
"sphere",
"specified",
"by",
"origin",
"and",
"radius",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L603-L639 | train | 63,936 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.cut_cuboid | def cut_cuboid(
self,
a=20,
b=None,
c=None,
origin=None,
outside_sliced=True,
preserve_bonds=False):
"""Cut a cuboid specified by edge and radius.
Args:
a (float): Value of the a edge.
b (float):... | python | def cut_cuboid(
self,
a=20,
b=None,
c=None,
origin=None,
outside_sliced=True,
preserve_bonds=False):
"""Cut a cuboid specified by edge and radius.
Args:
a (float): Value of the a edge.
b (float):... | [
"def",
"cut_cuboid",
"(",
"self",
",",
"a",
"=",
"20",
",",
"b",
"=",
"None",
",",
"c",
"=",
"None",
",",
"origin",
"=",
"None",
",",
"outside_sliced",
"=",
"True",
",",
"preserve_bonds",
"=",
"False",
")",
":",
"if",
"origin",
"is",
"None",
":",
... | Cut a cuboid specified by edge and radius.
Args:
a (float): Value of the a edge.
b (float): Value of the b edge. Takes value of a if None.
c (float): Value of the c edge. Takes value of a if None.
origin (list): Please note that you can also pass an
... | [
"Cut",
"a",
"cuboid",
"specified",
"by",
"edge",
"and",
"radius",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L641-L683 | train | 63,937 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.get_barycenter | def get_barycenter(self):
"""Return the mass weighted average location.
Args:
None
Returns:
:class:`numpy.ndarray`:
"""
try:
mass = self['mass'].values
except KeyError:
mass = self.add_data('mass')['mass'].values
p... | python | def get_barycenter(self):
"""Return the mass weighted average location.
Args:
None
Returns:
:class:`numpy.ndarray`:
"""
try:
mass = self['mass'].values
except KeyError:
mass = self.add_data('mass')['mass'].values
p... | [
"def",
"get_barycenter",
"(",
"self",
")",
":",
"try",
":",
"mass",
"=",
"self",
"[",
"'mass'",
"]",
".",
"values",
"except",
"KeyError",
":",
"mass",
"=",
"self",
".",
"add_data",
"(",
"'mass'",
")",
"[",
"'mass'",
"]",
".",
"values",
"pos",
"=",
... | Return the mass weighted average location.
Args:
None
Returns:
:class:`numpy.ndarray`: | [
"Return",
"the",
"mass",
"weighted",
"average",
"location",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L696-L710 | train | 63,938 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.get_bond_lengths | def get_bond_lengths(self, indices):
"""Return the distances between given atoms.
Calculates the distance between the atoms with
indices ``i`` and ``b``.
The indices can be given in three ways:
* As simple list ``[i, b]``
* As list of lists: ``[[i1, b1], [i2, b2]...]``
... | python | def get_bond_lengths(self, indices):
"""Return the distances between given atoms.
Calculates the distance between the atoms with
indices ``i`` and ``b``.
The indices can be given in three ways:
* As simple list ``[i, b]``
* As list of lists: ``[[i1, b1], [i2, b2]...]``
... | [
"def",
"get_bond_lengths",
"(",
"self",
",",
"indices",
")",
":",
"coords",
"=",
"[",
"'x'",
",",
"'y'",
",",
"'z'",
"]",
"if",
"isinstance",
"(",
"indices",
",",
"pd",
".",
"DataFrame",
")",
":",
"i_pos",
"=",
"self",
".",
"loc",
"[",
"indices",
"... | Return the distances between given atoms.
Calculates the distance between the atoms with
indices ``i`` and ``b``.
The indices can be given in three ways:
* As simple list ``[i, b]``
* As list of lists: ``[[i1, b1], [i2, b2]...]``
* As :class:`pd.DataFrame` where ``i`` i... | [
"Return",
"the",
"distances",
"between",
"given",
"atoms",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L712-L740 | train | 63,939 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.get_angle_degrees | def get_angle_degrees(self, indices):
"""Return the angles between given atoms.
Calculates the angle in degrees between the atoms with
indices ``i, b, a``.
The indices can be given in three ways:
* As simple list ``[i, b, a]``
* As list of lists: ``[[i1, b1, a1], [i2, b... | python | def get_angle_degrees(self, indices):
"""Return the angles between given atoms.
Calculates the angle in degrees between the atoms with
indices ``i, b, a``.
The indices can be given in three ways:
* As simple list ``[i, b, a]``
* As list of lists: ``[[i1, b1, a1], [i2, b... | [
"def",
"get_angle_degrees",
"(",
"self",
",",
"indices",
")",
":",
"coords",
"=",
"[",
"'x'",
",",
"'y'",
",",
"'z'",
"]",
"if",
"isinstance",
"(",
"indices",
",",
"pd",
".",
"DataFrame",
")",
":",
"i_pos",
"=",
"self",
".",
"loc",
"[",
"indices",
... | Return the angles between given atoms.
Calculates the angle in degrees between the atoms with
indices ``i, b, a``.
The indices can be given in three ways:
* As simple list ``[i, b, a]``
* As list of lists: ``[[i1, b1, a1], [i2, b2, a2]...]``
* As :class:`pd.DataFrame` w... | [
"Return",
"the",
"angles",
"between",
"given",
"atoms",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L742-L779 | train | 63,940 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.get_dihedral_degrees | def get_dihedral_degrees(self, indices, start_row=0):
"""Return the dihedrals between given atoms.
Calculates the dihedral angle in degrees between the atoms with
indices ``i, b, a, d``.
The indices can be given in three ways:
* As simple list ``[i, b, a, d]``
* As list... | python | def get_dihedral_degrees(self, indices, start_row=0):
"""Return the dihedrals between given atoms.
Calculates the dihedral angle in degrees between the atoms with
indices ``i, b, a, d``.
The indices can be given in three ways:
* As simple list ``[i, b, a, d]``
* As list... | [
"def",
"get_dihedral_degrees",
"(",
"self",
",",
"indices",
",",
"start_row",
"=",
"0",
")",
":",
"coords",
"=",
"[",
"'x'",
",",
"'y'",
",",
"'z'",
"]",
"if",
"isinstance",
"(",
"indices",
",",
"pd",
".",
"DataFrame",
")",
":",
"i_pos",
"=",
"self",... | Return the dihedrals between given atoms.
Calculates the dihedral angle in degrees between the atoms with
indices ``i, b, a, d``.
The indices can be given in three ways:
* As simple list ``[i, b, a, d]``
* As list of lists: ``[[i1, b1, a1, d1], [i2, b2, a2, d2]...]``
* ... | [
"Return",
"the",
"dihedrals",
"between",
"given",
"atoms",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L781-L840 | train | 63,941 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.fragmentate | def fragmentate(self, give_only_index=False,
use_lookup=None):
"""Get the indices of non bonded parts in the molecule.
Args:
give_only_index (bool): If ``True`` a set of indices is returned.
Otherwise a new Cartesian instance.
use_lookup (bool... | python | def fragmentate(self, give_only_index=False,
use_lookup=None):
"""Get the indices of non bonded parts in the molecule.
Args:
give_only_index (bool): If ``True`` a set of indices is returned.
Otherwise a new Cartesian instance.
use_lookup (bool... | [
"def",
"fragmentate",
"(",
"self",
",",
"give_only_index",
"=",
"False",
",",
"use_lookup",
"=",
"None",
")",
":",
"if",
"use_lookup",
"is",
"None",
":",
"use_lookup",
"=",
"settings",
"[",
"'defaults'",
"]",
"[",
"'use_lookup'",
"]",
"fragments",
"=",
"["... | Get the indices of non bonded parts in the molecule.
Args:
give_only_index (bool): If ``True`` a set of indices is returned.
Otherwise a new Cartesian instance.
use_lookup (bool): Use a lookup variable for
:meth:`~chemcoord.Cartesian.get_bonds`.
... | [
"Get",
"the",
"indices",
"of",
"non",
"bonded",
"parts",
"in",
"the",
"molecule",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L842-L883 | train | 63,942 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.restrict_bond_dict | def restrict_bond_dict(self, bond_dict):
"""Restrict a bond dictionary to self.
Args:
bond_dict (dict): Look into :meth:`~chemcoord.Cartesian.get_bonds`,
to see examples for a bond_dict.
Returns:
bond dictionary
"""
return {j: bond_dict[j... | python | def restrict_bond_dict(self, bond_dict):
"""Restrict a bond dictionary to self.
Args:
bond_dict (dict): Look into :meth:`~chemcoord.Cartesian.get_bonds`,
to see examples for a bond_dict.
Returns:
bond dictionary
"""
return {j: bond_dict[j... | [
"def",
"restrict_bond_dict",
"(",
"self",
",",
"bond_dict",
")",
":",
"return",
"{",
"j",
":",
"bond_dict",
"[",
"j",
"]",
"&",
"set",
"(",
"self",
".",
"index",
")",
"for",
"j",
"in",
"self",
".",
"index",
"}"
] | Restrict a bond dictionary to self.
Args:
bond_dict (dict): Look into :meth:`~chemcoord.Cartesian.get_bonds`,
to see examples for a bond_dict.
Returns:
bond dictionary | [
"Restrict",
"a",
"bond",
"dictionary",
"to",
"self",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L885-L895 | train | 63,943 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.get_fragment | def get_fragment(self, list_of_indextuples, give_only_index=False,
use_lookup=None):
"""Get the indices of the atoms in a fragment.
The list_of_indextuples contains all bondings from the
molecule to the fragment. ``[(1,3), (2,4)]`` means for example that the
fragmen... | python | def get_fragment(self, list_of_indextuples, give_only_index=False,
use_lookup=None):
"""Get the indices of the atoms in a fragment.
The list_of_indextuples contains all bondings from the
molecule to the fragment. ``[(1,3), (2,4)]`` means for example that the
fragmen... | [
"def",
"get_fragment",
"(",
"self",
",",
"list_of_indextuples",
",",
"give_only_index",
"=",
"False",
",",
"use_lookup",
"=",
"None",
")",
":",
"if",
"use_lookup",
"is",
"None",
":",
"use_lookup",
"=",
"settings",
"[",
"'defaults'",
"]",
"[",
"'use_lookup'",
... | Get the indices of the atoms in a fragment.
The list_of_indextuples contains all bondings from the
molecule to the fragment. ``[(1,3), (2,4)]`` means for example that the
fragment is connected over two bonds. The first bond is from atom 1 in
the molecule to atom 3 in the fragment. The s... | [
"Get",
"the",
"indices",
"of",
"the",
"atoms",
"in",
"a",
"fragment",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L897-L929 | train | 63,944 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.get_without | def get_without(self, fragments,
use_lookup=None):
"""Return self without the specified fragments.
Args:
fragments: Either a list of :class:`~chemcoord.Cartesian` or a
:class:`~chemcoord.Cartesian`.
use_lookup (bool): Use a lookup variable for... | python | def get_without(self, fragments,
use_lookup=None):
"""Return self without the specified fragments.
Args:
fragments: Either a list of :class:`~chemcoord.Cartesian` or a
:class:`~chemcoord.Cartesian`.
use_lookup (bool): Use a lookup variable for... | [
"def",
"get_without",
"(",
"self",
",",
"fragments",
",",
"use_lookup",
"=",
"None",
")",
":",
"if",
"use_lookup",
"is",
"None",
":",
"use_lookup",
"=",
"settings",
"[",
"'defaults'",
"]",
"[",
"'use_lookup'",
"]",
"if",
"pd",
".",
"api",
".",
"types",
... | Return self without the specified fragments.
Args:
fragments: Either a list of :class:`~chemcoord.Cartesian` or a
:class:`~chemcoord.Cartesian`.
use_lookup (bool): Use a lookup variable for
:meth:`~chemcoord.Cartesian.get_bonds`. The default is
... | [
"Return",
"self",
"without",
"the",
"specified",
"fragments",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L931-L958 | train | 63,945 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore._jit_pairwise_distances | def _jit_pairwise_distances(pos1, pos2):
"""Optimized function for calculating the distance between each pair
of points in positions1 and positions2.
Does use python mode as fallback, if a scalar and not an array is
given.
"""
n1 = pos1.shape[0]
n2 = pos2.shape[0... | python | def _jit_pairwise_distances(pos1, pos2):
"""Optimized function for calculating the distance between each pair
of points in positions1 and positions2.
Does use python mode as fallback, if a scalar and not an array is
given.
"""
n1 = pos1.shape[0]
n2 = pos2.shape[0... | [
"def",
"_jit_pairwise_distances",
"(",
"pos1",
",",
"pos2",
")",
":",
"n1",
"=",
"pos1",
".",
"shape",
"[",
"0",
"]",
"n2",
"=",
"pos2",
".",
"shape",
"[",
"0",
"]",
"D",
"=",
"np",
".",
"empty",
"(",
"(",
"n1",
",",
"n2",
")",
")",
"for",
"i... | Optimized function for calculating the distance between each pair
of points in positions1 and positions2.
Does use python mode as fallback, if a scalar and not an array is
given. | [
"Optimized",
"function",
"for",
"calculating",
"the",
"distance",
"between",
"each",
"pair",
"of",
"points",
"in",
"positions1",
"and",
"positions2",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L962-L976 | train | 63,946 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.get_inertia | def get_inertia(self):
"""Calculate the inertia tensor and transforms along
rotation axes.
This function calculates the inertia tensor and returns
a 4-tuple.
The unit is ``amu * length-unit-of-xyz-file**2``
Args:
None
Returns:
dict: The... | python | def get_inertia(self):
"""Calculate the inertia tensor and transforms along
rotation axes.
This function calculates the inertia tensor and returns
a 4-tuple.
The unit is ``amu * length-unit-of-xyz-file**2``
Args:
None
Returns:
dict: The... | [
"def",
"get_inertia",
"(",
"self",
")",
":",
"def",
"calculate_inertia_tensor",
"(",
"molecule",
")",
":",
"masses",
"=",
"molecule",
".",
"loc",
"[",
":",
",",
"'mass'",
"]",
".",
"values",
"pos",
"=",
"molecule",
".",
"loc",
"[",
":",
",",
"[",
"'x... | Calculate the inertia tensor and transforms along
rotation axes.
This function calculates the inertia tensor and returns
a 4-tuple.
The unit is ``amu * length-unit-of-xyz-file**2``
Args:
None
Returns:
dict: The returned dictionary has four poss... | [
"Calculate",
"the",
"inertia",
"tensor",
"and",
"transforms",
"along",
"rotation",
"axes",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1005-L1063 | train | 63,947 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.basistransform | def basistransform(self, new_basis, old_basis=None,
orthonormalize=True):
"""Transform the frame to a new basis.
This function transforms the cartesian coordinates from an
old basis to a new one. Please note that old_basis and
new_basis are supposed to have full R... | python | def basistransform(self, new_basis, old_basis=None,
orthonormalize=True):
"""Transform the frame to a new basis.
This function transforms the cartesian coordinates from an
old basis to a new one. Please note that old_basis and
new_basis are supposed to have full R... | [
"def",
"basistransform",
"(",
"self",
",",
"new_basis",
",",
"old_basis",
"=",
"None",
",",
"orthonormalize",
"=",
"True",
")",
":",
"if",
"old_basis",
"is",
"None",
":",
"old_basis",
"=",
"np",
".",
"identity",
"(",
"3",
")",
"is_rotation_matrix",
"=",
... | Transform the frame to a new basis.
This function transforms the cartesian coordinates from an
old basis to a new one. Please note that old_basis and
new_basis are supposed to have full Rank and consist of
three linear independent vectors. If rotate_only is True,
it is asserted,... | [
"Transform",
"the",
"frame",
"to",
"a",
"new",
"basis",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1065-L1098 | train | 63,948 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.get_distance_to | def get_distance_to(self, origin=None, other_atoms=None, sort=False):
"""Return a Cartesian with a column for the distance from origin.
"""
if origin is None:
origin = np.zeros(3)
elif pd.api.types.is_list_like(origin):
origin = np.array(origin, dtype='f8')
... | python | def get_distance_to(self, origin=None, other_atoms=None, sort=False):
"""Return a Cartesian with a column for the distance from origin.
"""
if origin is None:
origin = np.zeros(3)
elif pd.api.types.is_list_like(origin):
origin = np.array(origin, dtype='f8')
... | [
"def",
"get_distance_to",
"(",
"self",
",",
"origin",
"=",
"None",
",",
"other_atoms",
"=",
"None",
",",
"sort",
"=",
"False",
")",
":",
"if",
"origin",
"is",
"None",
":",
"origin",
"=",
"np",
".",
"zeros",
"(",
"3",
")",
"elif",
"pd",
".",
"api",
... | Return a Cartesian with a column for the distance from origin. | [
"Return",
"a",
"Cartesian",
"with",
"a",
"column",
"for",
"the",
"distance",
"from",
"origin",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1118-L1141 | train | 63,949 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.change_numbering | def change_numbering(self, rename_dict, inplace=False):
"""Return the reindexed version of Cartesian.
Args:
rename_dict (dict): A dictionary mapping integers on integers.
Returns:
Cartesian: A renamed copy according to the dictionary passed.
"""
output =... | python | def change_numbering(self, rename_dict, inplace=False):
"""Return the reindexed version of Cartesian.
Args:
rename_dict (dict): A dictionary mapping integers on integers.
Returns:
Cartesian: A renamed copy according to the dictionary passed.
"""
output =... | [
"def",
"change_numbering",
"(",
"self",
",",
"rename_dict",
",",
"inplace",
"=",
"False",
")",
":",
"output",
"=",
"self",
"if",
"inplace",
"else",
"self",
".",
"copy",
"(",
")",
"new_index",
"=",
"[",
"rename_dict",
".",
"get",
"(",
"key",
",",
"key",... | Return the reindexed version of Cartesian.
Args:
rename_dict (dict): A dictionary mapping integers on integers.
Returns:
Cartesian: A renamed copy according to the dictionary passed. | [
"Return",
"the",
"reindexed",
"version",
"of",
"Cartesian",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1143-L1156 | train | 63,950 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.partition_chem_env | def partition_chem_env(self, n_sphere=4,
use_lookup=None):
"""This function partitions the molecule into subsets of the
same chemical environment.
A chemical environment is specified by the number of
surrounding atoms of a certain kind around an atom with a
... | python | def partition_chem_env(self, n_sphere=4,
use_lookup=None):
"""This function partitions the molecule into subsets of the
same chemical environment.
A chemical environment is specified by the number of
surrounding atoms of a certain kind around an atom with a
... | [
"def",
"partition_chem_env",
"(",
"self",
",",
"n_sphere",
"=",
"4",
",",
"use_lookup",
"=",
"None",
")",
":",
"if",
"use_lookup",
"is",
"None",
":",
"use_lookup",
"=",
"settings",
"[",
"'defaults'",
"]",
"[",
"'use_lookup'",
"]",
"def",
"get_chem_env",
"(... | This function partitions the molecule into subsets of the
same chemical environment.
A chemical environment is specified by the number of
surrounding atoms of a certain kind around an atom with a
certain atomic number represented by a tuple of a string
and a frozenset of tuples.... | [
"This",
"function",
"partitions",
"the",
"molecule",
"into",
"subsets",
"of",
"the",
"same",
"chemical",
"environment",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1158-L1219 | train | 63,951 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.align | def align(self, other, indices=None, ignore_hydrogens=False):
"""Align two Cartesians.
Minimize the RMSD (root mean squared deviation) between
``self`` and ``other``.
Returns a tuple of copies of ``self`` and ``other`` where
both are centered around their centroid and
... | python | def align(self, other, indices=None, ignore_hydrogens=False):
"""Align two Cartesians.
Minimize the RMSD (root mean squared deviation) between
``self`` and ``other``.
Returns a tuple of copies of ``self`` and ``other`` where
both are centered around their centroid and
... | [
"def",
"align",
"(",
"self",
",",
"other",
",",
"indices",
"=",
"None",
",",
"ignore_hydrogens",
"=",
"False",
")",
":",
"m1",
"=",
"(",
"self",
"-",
"self",
".",
"get_centroid",
"(",
")",
")",
".",
"sort_index",
"(",
")",
"m2",
"=",
"(",
"other",
... | Align two Cartesians.
Minimize the RMSD (root mean squared deviation) between
``self`` and ``other``.
Returns a tuple of copies of ``self`` and ``other`` where
both are centered around their centroid and
``other`` is rotated unto ``self``.
The rotation minimises the di... | [
"Align",
"two",
"Cartesians",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1221-L1271 | train | 63,952 |
mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/_cartesian_class_core.py | CartesianCore.reindex_similar | def reindex_similar(self, other, n_sphere=4):
"""Reindex ``other`` to be similarly indexed as ``self``.
Returns a reindexed copy of ``other`` that minimizes the
distance for each atom to itself in the same chemical environemt
from ``self`` to ``other``.
Read more about the defin... | python | def reindex_similar(self, other, n_sphere=4):
"""Reindex ``other`` to be similarly indexed as ``self``.
Returns a reindexed copy of ``other`` that minimizes the
distance for each atom to itself in the same chemical environemt
from ``self`` to ``other``.
Read more about the defin... | [
"def",
"reindex_similar",
"(",
"self",
",",
"other",
",",
"n_sphere",
"=",
"4",
")",
":",
"def",
"make_subset_similar",
"(",
"m1",
",",
"subset1",
",",
"m2",
",",
"subset2",
",",
"index_dct",
")",
":",
"\"\"\"Changes index_dct INPLACE\"\"\"",
"coords",
"=",
... | Reindex ``other`` to be similarly indexed as ``self``.
Returns a reindexed copy of ``other`` that minimizes the
distance for each atom to itself in the same chemical environemt
from ``self`` to ``other``.
Read more about the definition of the chemical environment in
:func:`Carte... | [
"Reindex",
"other",
"to",
"be",
"similarly",
"indexed",
"as",
"self",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/_cartesian_class_core.py#L1273-L1342 | train | 63,953 |
petrjasek/eve-elastic | eve_elastic/elastic.py | parse_date | def parse_date(date_str):
"""Parse elastic datetime string."""
if not date_str:
return None
try:
date = ciso8601.parse_datetime(date_str)
if not date:
date = arrow.get(date_str).datetime
except TypeError:
date = arrow.get(date_str[0]).datetime
return date | python | def parse_date(date_str):
"""Parse elastic datetime string."""
if not date_str:
return None
try:
date = ciso8601.parse_datetime(date_str)
if not date:
date = arrow.get(date_str).datetime
except TypeError:
date = arrow.get(date_str[0]).datetime
return date | [
"def",
"parse_date",
"(",
"date_str",
")",
":",
"if",
"not",
"date_str",
":",
"return",
"None",
"try",
":",
"date",
"=",
"ciso8601",
".",
"parse_datetime",
"(",
"date_str",
")",
"if",
"not",
"date",
":",
"date",
"=",
"arrow",
".",
"get",
"(",
"date_str... | Parse elastic datetime string. | [
"Parse",
"elastic",
"datetime",
"string",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L25-L36 | train | 63,954 |
petrjasek/eve-elastic | eve_elastic/elastic.py | get_dates | def get_dates(schema):
"""Return list of datetime fields for given schema."""
dates = [config.LAST_UPDATED, config.DATE_CREATED]
for field, field_schema in schema.items():
if field_schema['type'] == 'datetime':
dates.append(field)
return dates | python | def get_dates(schema):
"""Return list of datetime fields for given schema."""
dates = [config.LAST_UPDATED, config.DATE_CREATED]
for field, field_schema in schema.items():
if field_schema['type'] == 'datetime':
dates.append(field)
return dates | [
"def",
"get_dates",
"(",
"schema",
")",
":",
"dates",
"=",
"[",
"config",
".",
"LAST_UPDATED",
",",
"config",
".",
"DATE_CREATED",
"]",
"for",
"field",
",",
"field_schema",
"in",
"schema",
".",
"items",
"(",
")",
":",
"if",
"field_schema",
"[",
"'type'",... | Return list of datetime fields for given schema. | [
"Return",
"list",
"of",
"datetime",
"fields",
"for",
"given",
"schema",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L39-L45 | train | 63,955 |
petrjasek/eve-elastic | eve_elastic/elastic.py | format_doc | def format_doc(hit, schema, dates):
"""Format given doc to match given schema."""
doc = hit.get('_source', {})
doc.setdefault(config.ID_FIELD, hit.get('_id'))
doc.setdefault('_type', hit.get('_type'))
if hit.get('highlight'):
doc['es_highlight'] = hit.get('highlight')
if hit.get('inner_... | python | def format_doc(hit, schema, dates):
"""Format given doc to match given schema."""
doc = hit.get('_source', {})
doc.setdefault(config.ID_FIELD, hit.get('_id'))
doc.setdefault('_type', hit.get('_type'))
if hit.get('highlight'):
doc['es_highlight'] = hit.get('highlight')
if hit.get('inner_... | [
"def",
"format_doc",
"(",
"hit",
",",
"schema",
",",
"dates",
")",
":",
"doc",
"=",
"hit",
".",
"get",
"(",
"'_source'",
",",
"{",
"}",
")",
"doc",
".",
"setdefault",
"(",
"config",
".",
"ID_FIELD",
",",
"hit",
".",
"get",
"(",
"'_id'",
")",
")",... | Format given doc to match given schema. | [
"Format",
"given",
"doc",
"to",
"match",
"given",
"schema",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L48-L67 | train | 63,956 |
petrjasek/eve-elastic | eve_elastic/elastic.py | set_filters | def set_filters(query, base_filters):
"""Put together all filters we have and set them as 'and' filter
within filtered query.
:param query: elastic query being constructed
:param base_filters: all filters set outside of query (eg. resource config, sub_resource_lookup)
"""
filters = [f for f in ... | python | def set_filters(query, base_filters):
"""Put together all filters we have and set them as 'and' filter
within filtered query.
:param query: elastic query being constructed
:param base_filters: all filters set outside of query (eg. resource config, sub_resource_lookup)
"""
filters = [f for f in ... | [
"def",
"set_filters",
"(",
"query",
",",
"base_filters",
")",
":",
"filters",
"=",
"[",
"f",
"for",
"f",
"in",
"base_filters",
"if",
"f",
"is",
"not",
"None",
"]",
"query_filter",
"=",
"query",
"[",
"'query'",
"]",
"[",
"'filtered'",
"]",
".",
"get",
... | Put together all filters we have and set them as 'and' filter
within filtered query.
:param query: elastic query being constructed
:param base_filters: all filters set outside of query (eg. resource config, sub_resource_lookup) | [
"Put",
"together",
"all",
"filters",
"we",
"have",
"and",
"set",
"them",
"as",
"and",
"filter",
"within",
"filtered",
"query",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L154-L169 | train | 63,957 |
petrjasek/eve-elastic | eve_elastic/elastic.py | get_es | def get_es(url, **kwargs):
"""Create elasticsearch client instance.
:param url: elasticsearch url
"""
urls = [url] if isinstance(url, str) else url
kwargs.setdefault('serializer', ElasticJSONSerializer())
es = elasticsearch.Elasticsearch(urls, **kwargs)
return es | python | def get_es(url, **kwargs):
"""Create elasticsearch client instance.
:param url: elasticsearch url
"""
urls = [url] if isinstance(url, str) else url
kwargs.setdefault('serializer', ElasticJSONSerializer())
es = elasticsearch.Elasticsearch(urls, **kwargs)
return es | [
"def",
"get_es",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"urls",
"=",
"[",
"url",
"]",
"if",
"isinstance",
"(",
"url",
",",
"str",
")",
"else",
"url",
"kwargs",
".",
"setdefault",
"(",
"'serializer'",
",",
"ElasticJSONSerializer",
"(",
")",
")... | Create elasticsearch client instance.
:param url: elasticsearch url | [
"Create",
"elasticsearch",
"client",
"instance",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L179-L187 | train | 63,958 |
petrjasek/eve-elastic | eve_elastic/elastic.py | build_elastic_query | def build_elastic_query(doc):
"""
Build a query which follows ElasticSearch syntax from doc.
1. Converts {"q":"cricket"} to the below elastic query::
{
"query": {
"filtered": {
"query": {
"query_string": {
... | python | def build_elastic_query(doc):
"""
Build a query which follows ElasticSearch syntax from doc.
1. Converts {"q":"cricket"} to the below elastic query::
{
"query": {
"filtered": {
"query": {
"query_string": {
... | [
"def",
"build_elastic_query",
"(",
"doc",
")",
":",
"elastic_query",
",",
"filters",
"=",
"{",
"\"query\"",
":",
"{",
"\"filtered\"",
":",
"{",
"}",
"}",
"}",
",",
"[",
"]",
"for",
"key",
"in",
"doc",
".",
"keys",
"(",
")",
":",
"if",
"key",
"==",
... | Build a query which follows ElasticSearch syntax from doc.
1. Converts {"q":"cricket"} to the below elastic query::
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "cricket",
... | [
"Build",
"a",
"query",
"which",
"follows",
"ElasticSearch",
"syntax",
"from",
"doc",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L832-L892 | train | 63,959 |
petrjasek/eve-elastic | eve_elastic/elastic.py | _build_query_string | def _build_query_string(q, default_field=None, default_operator='AND'):
"""
Build ``query_string`` object from ``q``.
:param q: q of type String
:param default_field: default_field
:return: dictionary object.
"""
def _is_phrase_search(query_string):
clean_query = query_string.strip(... | python | def _build_query_string(q, default_field=None, default_operator='AND'):
"""
Build ``query_string`` object from ``q``.
:param q: q of type String
:param default_field: default_field
:return: dictionary object.
"""
def _is_phrase_search(query_string):
clean_query = query_string.strip(... | [
"def",
"_build_query_string",
"(",
"q",
",",
"default_field",
"=",
"None",
",",
"default_operator",
"=",
"'AND'",
")",
":",
"def",
"_is_phrase_search",
"(",
"query_string",
")",
":",
"clean_query",
"=",
"query_string",
".",
"strip",
"(",
")",
"return",
"clean_... | Build ``query_string`` object from ``q``.
:param q: q of type String
:param default_field: default_field
:return: dictionary object. | [
"Build",
"query_string",
"object",
"from",
"q",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L895-L916 | train | 63,960 |
petrjasek/eve-elastic | eve_elastic/elastic.py | ElasticJSONSerializer.default | def default(self, value):
"""Convert mongo.ObjectId."""
if isinstance(value, ObjectId):
return str(value)
return super(ElasticJSONSerializer, self).default(value) | python | def default(self, value):
"""Convert mongo.ObjectId."""
if isinstance(value, ObjectId):
return str(value)
return super(ElasticJSONSerializer, self).default(value) | [
"def",
"default",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"ObjectId",
")",
":",
"return",
"str",
"(",
"value",
")",
"return",
"super",
"(",
"ElasticJSONSerializer",
",",
"self",
")",
".",
"default",
"(",
"value",
")"... | Convert mongo.ObjectId. | [
"Convert",
"mongo",
".",
"ObjectId",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L118-L122 | train | 63,961 |
petrjasek/eve-elastic | eve_elastic/elastic.py | ElasticCursor.extra | def extra(self, response):
"""Add extra info to response."""
if 'facets' in self.hits:
response['_facets'] = self.hits['facets']
if 'aggregations' in self.hits:
response['_aggregations'] = self.hits['aggregations'] | python | def extra(self, response):
"""Add extra info to response."""
if 'facets' in self.hits:
response['_facets'] = self.hits['facets']
if 'aggregations' in self.hits:
response['_aggregations'] = self.hits['aggregations'] | [
"def",
"extra",
"(",
"self",
",",
"response",
")",
":",
"if",
"'facets'",
"in",
"self",
".",
"hits",
":",
"response",
"[",
"'_facets'",
"]",
"=",
"self",
".",
"hits",
"[",
"'facets'",
"]",
"if",
"'aggregations'",
"in",
"self",
".",
"hits",
":",
"resp... | Add extra info to response. | [
"Add",
"extra",
"info",
"to",
"response",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L146-L151 | train | 63,962 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.init_index | def init_index(self, app=None):
"""Create indexes and put mapping."""
elasticindexes = self._get_indexes()
for index, settings in elasticindexes.items():
es = settings['resource']
if not es.indices.exists(index):
self.create_index(index, settings.get('ind... | python | def init_index(self, app=None):
"""Create indexes and put mapping."""
elasticindexes = self._get_indexes()
for index, settings in elasticindexes.items():
es = settings['resource']
if not es.indices.exists(index):
self.create_index(index, settings.get('ind... | [
"def",
"init_index",
"(",
"self",
",",
"app",
"=",
"None",
")",
":",
"elasticindexes",
"=",
"self",
".",
"_get_indexes",
"(",
")",
"for",
"index",
",",
"settings",
"in",
"elasticindexes",
".",
"items",
"(",
")",
":",
"es",
"=",
"settings",
"[",
"'resou... | Create indexes and put mapping. | [
"Create",
"indexes",
"and",
"put",
"mapping",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L221-L237 | train | 63,963 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic._get_indexes | def _get_indexes(self):
"""Based on the resource definition calculates the index definition"""
indexes = {}
for resource in self._get_elastic_resources():
try:
index = self._resource_index(resource)
except KeyError: # ignore missing
conti... | python | def _get_indexes(self):
"""Based on the resource definition calculates the index definition"""
indexes = {}
for resource in self._get_elastic_resources():
try:
index = self._resource_index(resource)
except KeyError: # ignore missing
conti... | [
"def",
"_get_indexes",
"(",
"self",
")",
":",
"indexes",
"=",
"{",
"}",
"for",
"resource",
"in",
"self",
".",
"_get_elastic_resources",
"(",
")",
":",
"try",
":",
"index",
"=",
"self",
".",
"_resource_index",
"(",
"resource",
")",
"except",
"KeyError",
"... | Based on the resource definition calculates the index definition | [
"Based",
"on",
"the",
"resource",
"definition",
"calculates",
"the",
"index",
"definition"
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L239-L268 | train | 63,964 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic._get_mapping | def _get_mapping(self, schema):
"""Get mapping for given resource or item schema.
:param schema: resource or dict/list type item schema
"""
properties = {}
for field, field_schema in schema.items():
field_mapping = self._get_field_mapping(field_schema)
if... | python | def _get_mapping(self, schema):
"""Get mapping for given resource or item schema.
:param schema: resource or dict/list type item schema
"""
properties = {}
for field, field_schema in schema.items():
field_mapping = self._get_field_mapping(field_schema)
if... | [
"def",
"_get_mapping",
"(",
"self",
",",
"schema",
")",
":",
"properties",
"=",
"{",
"}",
"for",
"field",
",",
"field_schema",
"in",
"schema",
".",
"items",
"(",
")",
":",
"field_mapping",
"=",
"self",
".",
"_get_field_mapping",
"(",
"field_schema",
")",
... | Get mapping for given resource or item schema.
:param schema: resource or dict/list type item schema | [
"Get",
"mapping",
"for",
"given",
"resource",
"or",
"item",
"schema",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L275-L285 | train | 63,965 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic._get_field_mapping | def _get_field_mapping(self, schema):
"""Get mapping for single field schema.
:param schema: field schema
"""
if 'mapping' in schema:
return schema['mapping']
elif schema['type'] == 'dict' and 'schema' in schema:
return self._get_mapping(schema['schema'])... | python | def _get_field_mapping(self, schema):
"""Get mapping for single field schema.
:param schema: field schema
"""
if 'mapping' in schema:
return schema['mapping']
elif schema['type'] == 'dict' and 'schema' in schema:
return self._get_mapping(schema['schema'])... | [
"def",
"_get_field_mapping",
"(",
"self",
",",
"schema",
")",
":",
"if",
"'mapping'",
"in",
"schema",
":",
"return",
"schema",
"[",
"'mapping'",
"]",
"elif",
"schema",
"[",
"'type'",
"]",
"==",
"'dict'",
"and",
"'schema'",
"in",
"schema",
":",
"return",
... | Get mapping for single field schema.
:param schema: field schema | [
"Get",
"mapping",
"for",
"single",
"field",
"schema",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L287-L301 | train | 63,966 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.create_index | def create_index(self, index=None, settings=None, es=None):
"""Create new index and ignore if it exists already."""
if index is None:
index = self.index
if es is None:
es = self.es
try:
alias = index
index = generate_index_name(alias)
... | python | def create_index(self, index=None, settings=None, es=None):
"""Create new index and ignore if it exists already."""
if index is None:
index = self.index
if es is None:
es = self.es
try:
alias = index
index = generate_index_name(alias)
... | [
"def",
"create_index",
"(",
"self",
",",
"index",
"=",
"None",
",",
"settings",
"=",
"None",
",",
"es",
"=",
"None",
")",
":",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"self",
".",
"index",
"if",
"es",
"is",
"None",
":",
"es",
"=",
"self",... | Create new index and ignore if it exists already. | [
"Create",
"new",
"index",
"and",
"ignore",
"if",
"it",
"exists",
"already",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L303-L321 | train | 63,967 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.put_mapping | def put_mapping(self, app, index=None):
"""Put mapping for elasticsearch for current schema.
It's not called automatically now, but rather left for user to call it whenever it makes sense.
"""
for resource, resource_config in self._get_elastic_resources().items():
datasource... | python | def put_mapping(self, app, index=None):
"""Put mapping for elasticsearch for current schema.
It's not called automatically now, but rather left for user to call it whenever it makes sense.
"""
for resource, resource_config in self._get_elastic_resources().items():
datasource... | [
"def",
"put_mapping",
"(",
"self",
",",
"app",
",",
"index",
"=",
"None",
")",
":",
"for",
"resource",
",",
"resource_config",
"in",
"self",
".",
"_get_elastic_resources",
"(",
")",
".",
"items",
"(",
")",
":",
"datasource",
"=",
"resource_config",
".",
... | Put mapping for elasticsearch for current schema.
It's not called automatically now, but rather left for user to call it whenever it makes sense. | [
"Put",
"mapping",
"for",
"elasticsearch",
"for",
"current",
"schema",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L375-L400 | train | 63,968 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.get_mapping | def get_mapping(self, index, doc_type=None):
"""Get mapping for index.
:param index: index name
"""
mapping = self.es.indices.get_mapping(index=index, doc_type=doc_type)
return next(iter(mapping.values())) | python | def get_mapping(self, index, doc_type=None):
"""Get mapping for index.
:param index: index name
"""
mapping = self.es.indices.get_mapping(index=index, doc_type=doc_type)
return next(iter(mapping.values())) | [
"def",
"get_mapping",
"(",
"self",
",",
"index",
",",
"doc_type",
"=",
"None",
")",
":",
"mapping",
"=",
"self",
".",
"es",
".",
"indices",
".",
"get_mapping",
"(",
"index",
"=",
"index",
",",
"doc_type",
"=",
"doc_type",
")",
"return",
"next",
"(",
... | Get mapping for index.
:param index: index name | [
"Get",
"mapping",
"for",
"index",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L402-L408 | train | 63,969 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.get_settings | def get_settings(self, index):
"""Get settings for index.
:param index: index name
"""
settings = self.es.indices.get_settings(index=index)
return next(iter(settings.values())) | python | def get_settings(self, index):
"""Get settings for index.
:param index: index name
"""
settings = self.es.indices.get_settings(index=index)
return next(iter(settings.values())) | [
"def",
"get_settings",
"(",
"self",
",",
"index",
")",
":",
"settings",
"=",
"self",
".",
"es",
".",
"indices",
".",
"get_settings",
"(",
"index",
"=",
"index",
")",
"return",
"next",
"(",
"iter",
"(",
"settings",
".",
"values",
"(",
")",
")",
")"
] | Get settings for index.
:param index: index name | [
"Get",
"settings",
"for",
"index",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L410-L416 | train | 63,970 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.get_index_by_alias | def get_index_by_alias(self, alias):
"""Get index name for given alias.
If there is no alias assume it's an index.
:param alias: alias name
"""
try:
info = self.es.indices.get_alias(name=alias)
return next(iter(info.keys()))
except elasticsearch.... | python | def get_index_by_alias(self, alias):
"""Get index name for given alias.
If there is no alias assume it's an index.
:param alias: alias name
"""
try:
info = self.es.indices.get_alias(name=alias)
return next(iter(info.keys()))
except elasticsearch.... | [
"def",
"get_index_by_alias",
"(",
"self",
",",
"alias",
")",
":",
"try",
":",
"info",
"=",
"self",
".",
"es",
".",
"indices",
".",
"get_alias",
"(",
"name",
"=",
"alias",
")",
"return",
"next",
"(",
"iter",
"(",
"info",
".",
"keys",
"(",
")",
")",
... | Get index name for given alias.
If there is no alias assume it's an index.
:param alias: alias name | [
"Get",
"index",
"name",
"for",
"given",
"alias",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L418-L429 | train | 63,971 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.should_aggregate | def should_aggregate(self, req):
"""Check the environment variable and the given argument parameter to decide if aggregations needed.
argument value is expected to be '0' or '1'
"""
try:
return self.app.config.get('ELASTICSEARCH_AUTO_AGGREGATIONS') or \
bo... | python | def should_aggregate(self, req):
"""Check the environment variable and the given argument parameter to decide if aggregations needed.
argument value is expected to be '0' or '1'
"""
try:
return self.app.config.get('ELASTICSEARCH_AUTO_AGGREGATIONS') or \
bo... | [
"def",
"should_aggregate",
"(",
"self",
",",
"req",
")",
":",
"try",
":",
"return",
"self",
".",
"app",
".",
"config",
".",
"get",
"(",
"'ELASTICSEARCH_AUTO_AGGREGATIONS'",
")",
"or",
"bool",
"(",
"req",
".",
"args",
"and",
"int",
"(",
"req",
".",
"arg... | Check the environment variable and the given argument parameter to decide if aggregations needed.
argument value is expected to be '0' or '1' | [
"Check",
"the",
"environment",
"variable",
"and",
"the",
"given",
"argument",
"parameter",
"to",
"decide",
"if",
"aggregations",
"needed",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L513-L522 | train | 63,972 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.should_highlight | def should_highlight(self, req):
"""
Check the given argument parameter to decide if highlights needed.
argument value is expected to be '0' or '1'
"""
try:
return bool(req.args and int(req.args.get('es_highlight', 0)))
except (AttributeError, TypeError):
... | python | def should_highlight(self, req):
"""
Check the given argument parameter to decide if highlights needed.
argument value is expected to be '0' or '1'
"""
try:
return bool(req.args and int(req.args.get('es_highlight', 0)))
except (AttributeError, TypeError):
... | [
"def",
"should_highlight",
"(",
"self",
",",
"req",
")",
":",
"try",
":",
"return",
"bool",
"(",
"req",
".",
"args",
"and",
"int",
"(",
"req",
".",
"args",
".",
"get",
"(",
"'es_highlight'",
",",
"0",
")",
")",
")",
"except",
"(",
"AttributeError",
... | Check the given argument parameter to decide if highlights needed.
argument value is expected to be '0' or '1' | [
"Check",
"the",
"given",
"argument",
"parameter",
"to",
"decide",
"if",
"highlights",
"needed",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L524-L533 | train | 63,973 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.should_project | def should_project(self, req):
"""
Check the given argument parameter to decide if projections needed.
argument value is expected to be a list of strings
"""
try:
return req.args and json.loads(req.args.get('projections', []))
except (AttributeError, TypeErro... | python | def should_project(self, req):
"""
Check the given argument parameter to decide if projections needed.
argument value is expected to be a list of strings
"""
try:
return req.args and json.loads(req.args.get('projections', []))
except (AttributeError, TypeErro... | [
"def",
"should_project",
"(",
"self",
",",
"req",
")",
":",
"try",
":",
"return",
"req",
".",
"args",
"and",
"json",
".",
"loads",
"(",
"req",
".",
"args",
".",
"get",
"(",
"'projections'",
",",
"[",
"]",
")",
")",
"except",
"(",
"AttributeError",
... | Check the given argument parameter to decide if projections needed.
argument value is expected to be a list of strings | [
"Check",
"the",
"given",
"argument",
"parameter",
"to",
"decide",
"if",
"projections",
"needed",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L535-L544 | train | 63,974 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.get_projected_fields | def get_projected_fields(self, req):
"""
Returns the projected fields from request.
"""
try:
args = getattr(req, 'args', {})
return ','.join(json.loads(args.get('projections')))
except (AttributeError, TypeError):
return None | python | def get_projected_fields(self, req):
"""
Returns the projected fields from request.
"""
try:
args = getattr(req, 'args', {})
return ','.join(json.loads(args.get('projections')))
except (AttributeError, TypeError):
return None | [
"def",
"get_projected_fields",
"(",
"self",
",",
"req",
")",
":",
"try",
":",
"args",
"=",
"getattr",
"(",
"req",
",",
"'args'",
",",
"{",
"}",
")",
"return",
"','",
".",
"join",
"(",
"json",
".",
"loads",
"(",
"args",
".",
"get",
"(",
"'projection... | Returns the projected fields from request. | [
"Returns",
"the",
"projected",
"fields",
"from",
"request",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L546-L555 | train | 63,975 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.find_one | def find_one(self, resource, req, **lookup):
"""Find single document, if there is _id in lookup use that, otherwise filter."""
if config.ID_FIELD in lookup:
return self._find_by_id(resource=resource, _id=lookup[config.ID_FIELD], parent=lookup.get('parent'))
else:
args = ... | python | def find_one(self, resource, req, **lookup):
"""Find single document, if there is _id in lookup use that, otherwise filter."""
if config.ID_FIELD in lookup:
return self._find_by_id(resource=resource, _id=lookup[config.ID_FIELD], parent=lookup.get('parent'))
else:
args = ... | [
"def",
"find_one",
"(",
"self",
",",
"resource",
",",
"req",
",",
"*",
"*",
"lookup",
")",
":",
"if",
"config",
".",
"ID_FIELD",
"in",
"lookup",
":",
"return",
"self",
".",
"_find_by_id",
"(",
"resource",
"=",
"resource",
",",
"_id",
"=",
"lookup",
"... | Find single document, if there is _id in lookup use that, otherwise filter. | [
"Find",
"single",
"document",
"if",
"there",
"is",
"_id",
"in",
"lookup",
"use",
"that",
"otherwise",
"filter",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L557-L573 | train | 63,976 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic._find_by_id | def _find_by_id(self, resource, _id, parent=None):
"""Find the document by Id. If parent is not provided then on
routing exception try to find using search.
"""
def is_found(hit):
if 'exists' in hit:
hit['found'] = hit['exists']
return hit.get('fou... | python | def _find_by_id(self, resource, _id, parent=None):
"""Find the document by Id. If parent is not provided then on
routing exception try to find using search.
"""
def is_found(hit):
if 'exists' in hit:
hit['found'] = hit['exists']
return hit.get('fou... | [
"def",
"_find_by_id",
"(",
"self",
",",
"resource",
",",
"_id",
",",
"parent",
"=",
"None",
")",
":",
"def",
"is_found",
"(",
"hit",
")",
":",
"if",
"'exists'",
"in",
"hit",
":",
"hit",
"[",
"'found'",
"]",
"=",
"hit",
"[",
"'exists'",
"]",
"return... | Find the document by Id. If parent is not provided then on
routing exception try to find using search. | [
"Find",
"the",
"document",
"by",
"Id",
".",
"If",
"parent",
"is",
"not",
"provided",
"then",
"on",
"routing",
"exception",
"try",
"to",
"find",
"using",
"search",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L575-L611 | train | 63,977 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.find_one_raw | def find_one_raw(self, resource, _id):
"""Find document by id."""
return self._find_by_id(resource=resource, _id=_id) | python | def find_one_raw(self, resource, _id):
"""Find document by id."""
return self._find_by_id(resource=resource, _id=_id) | [
"def",
"find_one_raw",
"(",
"self",
",",
"resource",
",",
"_id",
")",
":",
"return",
"self",
".",
"_find_by_id",
"(",
"resource",
"=",
"resource",
",",
"_id",
"=",
"_id",
")"
] | Find document by id. | [
"Find",
"document",
"by",
"id",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L613-L615 | train | 63,978 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.find_list_of_ids | def find_list_of_ids(self, resource, ids, client_projection=None):
"""Find documents by ids."""
args = self._es_args(resource)
return self._parse_hits(self.elastic(resource).mget(body={'ids': ids}, **args), resource) | python | def find_list_of_ids(self, resource, ids, client_projection=None):
"""Find documents by ids."""
args = self._es_args(resource)
return self._parse_hits(self.elastic(resource).mget(body={'ids': ids}, **args), resource) | [
"def",
"find_list_of_ids",
"(",
"self",
",",
"resource",
",",
"ids",
",",
"client_projection",
"=",
"None",
")",
":",
"args",
"=",
"self",
".",
"_es_args",
"(",
"resource",
")",
"return",
"self",
".",
"_parse_hits",
"(",
"self",
".",
"elastic",
"(",
"res... | Find documents by ids. | [
"Find",
"documents",
"by",
"ids",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L617-L620 | train | 63,979 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.insert | def insert(self, resource, doc_or_docs, **kwargs):
"""Insert document, it must be new if there is ``_id`` in it."""
ids = []
kwargs.update(self._es_args(resource))
for doc in doc_or_docs:
self._update_parent_args(resource, kwargs, doc)
_id = doc.pop('_id', None)
... | python | def insert(self, resource, doc_or_docs, **kwargs):
"""Insert document, it must be new if there is ``_id`` in it."""
ids = []
kwargs.update(self._es_args(resource))
for doc in doc_or_docs:
self._update_parent_args(resource, kwargs, doc)
_id = doc.pop('_id', None)
... | [
"def",
"insert",
"(",
"self",
",",
"resource",
",",
"doc_or_docs",
",",
"*",
"*",
"kwargs",
")",
":",
"ids",
"=",
"[",
"]",
"kwargs",
".",
"update",
"(",
"self",
".",
"_es_args",
"(",
"resource",
")",
")",
"for",
"doc",
"in",
"doc_or_docs",
":",
"s... | Insert document, it must be new if there is ``_id`` in it. | [
"Insert",
"document",
"it",
"must",
"be",
"new",
"if",
"there",
"is",
"_id",
"in",
"it",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L622-L633 | train | 63,980 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.bulk_insert | def bulk_insert(self, resource, docs, **kwargs):
"""Bulk insert documents."""
kwargs.update(self._es_args(resource))
parent_type = self._get_parent_type(resource)
if parent_type:
for doc in docs:
if doc.get(parent_type.get('field')):
doc['_... | python | def bulk_insert(self, resource, docs, **kwargs):
"""Bulk insert documents."""
kwargs.update(self._es_args(resource))
parent_type = self._get_parent_type(resource)
if parent_type:
for doc in docs:
if doc.get(parent_type.get('field')):
doc['_... | [
"def",
"bulk_insert",
"(",
"self",
",",
"resource",
",",
"docs",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"self",
".",
"_es_args",
"(",
"resource",
")",
")",
"parent_type",
"=",
"self",
".",
"_get_parent_type",
"(",
"resource",
... | Bulk insert documents. | [
"Bulk",
"insert",
"documents",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L635-L646 | train | 63,981 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.update | def update(self, resource, id_, updates):
"""Update document in index."""
args = self._es_args(resource, refresh=True)
if self._get_retry_on_conflict():
args['retry_on_conflict'] = self._get_retry_on_conflict()
updates.pop('_id', None)
updates.pop('_type', None)
... | python | def update(self, resource, id_, updates):
"""Update document in index."""
args = self._es_args(resource, refresh=True)
if self._get_retry_on_conflict():
args['retry_on_conflict'] = self._get_retry_on_conflict()
updates.pop('_id', None)
updates.pop('_type', None)
... | [
"def",
"update",
"(",
"self",
",",
"resource",
",",
"id_",
",",
"updates",
")",
":",
"args",
"=",
"self",
".",
"_es_args",
"(",
"resource",
",",
"refresh",
"=",
"True",
")",
"if",
"self",
".",
"_get_retry_on_conflict",
"(",
")",
":",
"args",
"[",
"'r... | Update document in index. | [
"Update",
"document",
"in",
"index",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L648-L657 | train | 63,982 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.replace | def replace(self, resource, id_, document):
"""Replace document in index."""
args = self._es_args(resource, refresh=True)
document.pop('_id', None)
document.pop('_type', None)
self._update_parent_args(resource, args, document)
return self.elastic(resource).index(body=docu... | python | def replace(self, resource, id_, document):
"""Replace document in index."""
args = self._es_args(resource, refresh=True)
document.pop('_id', None)
document.pop('_type', None)
self._update_parent_args(resource, args, document)
return self.elastic(resource).index(body=docu... | [
"def",
"replace",
"(",
"self",
",",
"resource",
",",
"id_",
",",
"document",
")",
":",
"args",
"=",
"self",
".",
"_es_args",
"(",
"resource",
",",
"refresh",
"=",
"True",
")",
"document",
".",
"pop",
"(",
"'_id'",
",",
"None",
")",
"document",
".",
... | Replace document in index. | [
"Replace",
"document",
"in",
"index",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L659-L665 | train | 63,983 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.remove | def remove(self, resource, lookup=None, parent=None, **kwargs):
"""Remove docs for resource.
:param resource: resource name
:param lookup: filter
:param parent: parent id
"""
kwargs.update(self._es_args(resource))
if parent:
kwargs['parent'] = parent
... | python | def remove(self, resource, lookup=None, parent=None, **kwargs):
"""Remove docs for resource.
:param resource: resource name
:param lookup: filter
:param parent: parent id
"""
kwargs.update(self._es_args(resource))
if parent:
kwargs['parent'] = parent
... | [
"def",
"remove",
"(",
"self",
",",
"resource",
",",
"lookup",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"self",
".",
"_es_args",
"(",
"resource",
")",
")",
"if",
"parent",
":",
"kwargs... | Remove docs for resource.
:param resource: resource name
:param lookup: filter
:param parent: parent id | [
"Remove",
"docs",
"for",
"resource",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L667-L684 | train | 63,984 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.is_empty | def is_empty(self, resource):
"""Test if there is no document for resource.
:param resource: resource name
"""
args = self._es_args(resource)
res = self.elastic(resource).count(body={'query': {'match_all': {}}}, **args)
return res.get('count', 0) == 0 | python | def is_empty(self, resource):
"""Test if there is no document for resource.
:param resource: resource name
"""
args = self._es_args(resource)
res = self.elastic(resource).count(body={'query': {'match_all': {}}}, **args)
return res.get('count', 0) == 0 | [
"def",
"is_empty",
"(",
"self",
",",
"resource",
")",
":",
"args",
"=",
"self",
".",
"_es_args",
"(",
"resource",
")",
"res",
"=",
"self",
".",
"elastic",
"(",
"resource",
")",
".",
"count",
"(",
"body",
"=",
"{",
"'query'",
":",
"{",
"'match_all'",
... | Test if there is no document for resource.
:param resource: resource name | [
"Test",
"if",
"there",
"is",
"no",
"document",
"for",
"resource",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L686-L693 | train | 63,985 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.put_settings | def put_settings(self, app=None, index=None, settings=None, es=None):
"""Modify index settings.
Index must exist already.
"""
if not index:
index = self.index
if not app:
app = self.app
if not es:
es = self.es
if not setting... | python | def put_settings(self, app=None, index=None, settings=None, es=None):
"""Modify index settings.
Index must exist already.
"""
if not index:
index = self.index
if not app:
app = self.app
if not es:
es = self.es
if not setting... | [
"def",
"put_settings",
"(",
"self",
",",
"app",
"=",
"None",
",",
"index",
"=",
"None",
",",
"settings",
"=",
"None",
",",
"es",
"=",
"None",
")",
":",
"if",
"not",
"index",
":",
"index",
"=",
"self",
".",
"index",
"if",
"not",
"app",
":",
"app",... | Modify index settings.
Index must exist already. | [
"Modify",
"index",
"settings",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L695-L721 | train | 63,986 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic._parse_hits | def _parse_hits(self, hits, resource):
"""Parse hits response into documents."""
datasource = self.get_datasource(resource)
schema = {}
schema.update(config.DOMAIN[datasource[0]].get('schema', {}))
schema.update(config.DOMAIN[resource].get('schema', {}))
dates = get_dates... | python | def _parse_hits(self, hits, resource):
"""Parse hits response into documents."""
datasource = self.get_datasource(resource)
schema = {}
schema.update(config.DOMAIN[datasource[0]].get('schema', {}))
schema.update(config.DOMAIN[resource].get('schema', {}))
dates = get_dates... | [
"def",
"_parse_hits",
"(",
"self",
",",
"hits",
",",
"resource",
")",
":",
"datasource",
"=",
"self",
".",
"get_datasource",
"(",
"resource",
")",
"schema",
"=",
"{",
"}",
"schema",
".",
"update",
"(",
"config",
".",
"DOMAIN",
"[",
"datasource",
"[",
"... | Parse hits response into documents. | [
"Parse",
"hits",
"response",
"into",
"documents",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L723-L733 | train | 63,987 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic._es_args | def _es_args(self, resource, refresh=None, source_projections=None):
"""Get index and doctype args."""
datasource = self.get_datasource(resource)
args = {
'index': self._resource_index(resource),
'doc_type': datasource[0],
}
if source_projections:
... | python | def _es_args(self, resource, refresh=None, source_projections=None):
"""Get index and doctype args."""
datasource = self.get_datasource(resource)
args = {
'index': self._resource_index(resource),
'doc_type': datasource[0],
}
if source_projections:
... | [
"def",
"_es_args",
"(",
"self",
",",
"resource",
",",
"refresh",
"=",
"None",
",",
"source_projections",
"=",
"None",
")",
":",
"datasource",
"=",
"self",
".",
"get_datasource",
"(",
"resource",
")",
"args",
"=",
"{",
"'index'",
":",
"self",
".",
"_resou... | Get index and doctype args. | [
"Get",
"index",
"and",
"doctype",
"args",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L735-L747 | train | 63,988 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.get_parent_id | def get_parent_id(self, resource, document):
"""Get the Parent Id of the document
:param resource: resource name
:param document: document containing the parent id
"""
parent_type = self._get_parent_type(resource)
if parent_type and document:
return document.... | python | def get_parent_id(self, resource, document):
"""Get the Parent Id of the document
:param resource: resource name
:param document: document containing the parent id
"""
parent_type = self._get_parent_type(resource)
if parent_type and document:
return document.... | [
"def",
"get_parent_id",
"(",
"self",
",",
"resource",
",",
"document",
")",
":",
"parent_type",
"=",
"self",
".",
"_get_parent_type",
"(",
"resource",
")",
"if",
"parent_type",
"and",
"document",
":",
"return",
"document",
".",
"get",
"(",
"parent_type",
"."... | Get the Parent Id of the document
:param resource: resource name
:param document: document containing the parent id | [
"Get",
"the",
"Parent",
"Id",
"of",
"the",
"document"
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L753-L763 | train | 63,989 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic._fields | def _fields(self, resource):
"""Get projection fields for given resource."""
datasource = self.get_datasource(resource)
keys = datasource[2].keys()
return ','.join(keys) + ','.join([config.LAST_UPDATED, config.DATE_CREATED]) | python | def _fields(self, resource):
"""Get projection fields for given resource."""
datasource = self.get_datasource(resource)
keys = datasource[2].keys()
return ','.join(keys) + ','.join([config.LAST_UPDATED, config.DATE_CREATED]) | [
"def",
"_fields",
"(",
"self",
",",
"resource",
")",
":",
"datasource",
"=",
"self",
".",
"get_datasource",
"(",
"resource",
")",
"keys",
"=",
"datasource",
"[",
"2",
"]",
".",
"keys",
"(",
")",
"return",
"','",
".",
"join",
"(",
"keys",
")",
"+",
... | Get projection fields for given resource. | [
"Get",
"projection",
"fields",
"for",
"given",
"resource",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L771-L775 | train | 63,990 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic._resource_index | def _resource_index(self, resource):
"""Get index for given resource.
by default it will be `self.index`, but it can be overriden via app.config
:param resource: resource name
"""
datasource = self.get_datasource(resource)
indexes = self._resource_config(resource, 'INDE... | python | def _resource_index(self, resource):
"""Get index for given resource.
by default it will be `self.index`, but it can be overriden via app.config
:param resource: resource name
"""
datasource = self.get_datasource(resource)
indexes = self._resource_config(resource, 'INDE... | [
"def",
"_resource_index",
"(",
"self",
",",
"resource",
")",
":",
"datasource",
"=",
"self",
".",
"get_datasource",
"(",
"resource",
")",
"indexes",
"=",
"self",
".",
"_resource_config",
"(",
"resource",
",",
"'INDEXES'",
")",
"or",
"{",
"}",
"default_index"... | Get index for given resource.
by default it will be `self.index`, but it can be overriden via app.config
:param resource: resource name | [
"Get",
"index",
"for",
"given",
"resource",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L781-L791 | train | 63,991 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic._refresh_resource_index | def _refresh_resource_index(self, resource):
"""Refresh index for given resource.
:param resource: resource name
"""
if self._resource_config(resource, 'FORCE_REFRESH', True):
self.elastic(resource).indices.refresh(self._resource_index(resource)) | python | def _refresh_resource_index(self, resource):
"""Refresh index for given resource.
:param resource: resource name
"""
if self._resource_config(resource, 'FORCE_REFRESH', True):
self.elastic(resource).indices.refresh(self._resource_index(resource)) | [
"def",
"_refresh_resource_index",
"(",
"self",
",",
"resource",
")",
":",
"if",
"self",
".",
"_resource_config",
"(",
"resource",
",",
"'FORCE_REFRESH'",
",",
"True",
")",
":",
"self",
".",
"elastic",
"(",
"resource",
")",
".",
"indices",
".",
"refresh",
"... | Refresh index for given resource.
:param resource: resource name | [
"Refresh",
"index",
"for",
"given",
"resource",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L793-L799 | train | 63,992 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic._resource_prefix | def _resource_prefix(self, resource=None):
"""Get elastic prefix for given resource.
Resource can specify ``elastic_prefix`` which behaves same like ``mongo_prefix``.
"""
px = 'ELASTICSEARCH'
if resource and config.DOMAIN[resource].get('elastic_prefix'):
px = config.... | python | def _resource_prefix(self, resource=None):
"""Get elastic prefix for given resource.
Resource can specify ``elastic_prefix`` which behaves same like ``mongo_prefix``.
"""
px = 'ELASTICSEARCH'
if resource and config.DOMAIN[resource].get('elastic_prefix'):
px = config.... | [
"def",
"_resource_prefix",
"(",
"self",
",",
"resource",
"=",
"None",
")",
":",
"px",
"=",
"'ELASTICSEARCH'",
"if",
"resource",
"and",
"config",
".",
"DOMAIN",
"[",
"resource",
"]",
".",
"get",
"(",
"'elastic_prefix'",
")",
":",
"px",
"=",
"config",
".",... | Get elastic prefix for given resource.
Resource can specify ``elastic_prefix`` which behaves same like ``mongo_prefix``. | [
"Get",
"elastic",
"prefix",
"for",
"given",
"resource",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L801-L809 | train | 63,993 |
petrjasek/eve-elastic | eve_elastic/elastic.py | Elastic.elastic | def elastic(self, resource=None):
"""Get ElasticSearch instance for given resource."""
px = self._resource_prefix(resource)
if px not in self.elastics:
url = self._resource_config(resource, 'URL')
assert url, 'no url for %s' % px
self.elastics[px] = get_es(ur... | python | def elastic(self, resource=None):
"""Get ElasticSearch instance for given resource."""
px = self._resource_prefix(resource)
if px not in self.elastics:
url = self._resource_config(resource, 'URL')
assert url, 'no url for %s' % px
self.elastics[px] = get_es(ur... | [
"def",
"elastic",
"(",
"self",
",",
"resource",
"=",
"None",
")",
":",
"px",
"=",
"self",
".",
"_resource_prefix",
"(",
"resource",
")",
"if",
"px",
"not",
"in",
"self",
".",
"elastics",
":",
"url",
"=",
"self",
".",
"_resource_config",
"(",
"resource"... | Get ElasticSearch instance for given resource. | [
"Get",
"ElasticSearch",
"instance",
"for",
"given",
"resource",
"."
] | f146f31b348d22ac5559cf78717b3bb02efcb2d7 | https://github.com/petrjasek/eve-elastic/blob/f146f31b348d22ac5559cf78717b3bb02efcb2d7/eve_elastic/elastic.py#L816-L825 | train | 63,994 |
gregreen/dustmaps | dustmaps/fetch_utils.py | get_md5sum | def get_md5sum(fname, chunk_size=1024):
"""
Returns the MD5 checksum of a file.
Args:
fname (str): Filename
chunk_size (Optional[int]): Size (in Bytes) of the chunks that should be
read in at once. Increasing chunk size reduces the number of reads
required, but incre... | python | def get_md5sum(fname, chunk_size=1024):
"""
Returns the MD5 checksum of a file.
Args:
fname (str): Filename
chunk_size (Optional[int]): Size (in Bytes) of the chunks that should be
read in at once. Increasing chunk size reduces the number of reads
required, but incre... | [
"def",
"get_md5sum",
"(",
"fname",
",",
"chunk_size",
"=",
"1024",
")",
":",
"def",
"iter_chunks",
"(",
"f",
")",
":",
"while",
"True",
":",
"chunk",
"=",
"f",
".",
"read",
"(",
"chunk_size",
")",
"if",
"not",
"chunk",
":",
"break",
"yield",
"chunk",... | Returns the MD5 checksum of a file.
Args:
fname (str): Filename
chunk_size (Optional[int]): Size (in Bytes) of the chunks that should be
read in at once. Increasing chunk size reduces the number of reads
required, but increases the memory usage. Defaults to 1024.
Return... | [
"Returns",
"the",
"MD5",
"checksum",
"of",
"a",
"file",
"."
] | c8f571a71da0d951bf8ea865621bee14492bdfd9 | https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/fetch_utils.py#L61-L91 | train | 63,995 |
gregreen/dustmaps | dustmaps/fetch_utils.py | download_and_verify | def download_and_verify(url, md5sum, fname=None,
chunk_size=1024, clobber=False,
verbose=True):
"""
Download a file and verify the MD5 sum.
Args:
url (str): The URL to download.
md5sum (str): The expected MD5 sum.
fname (Optional[str])... | python | def download_and_verify(url, md5sum, fname=None,
chunk_size=1024, clobber=False,
verbose=True):
"""
Download a file and verify the MD5 sum.
Args:
url (str): The URL to download.
md5sum (str): The expected MD5 sum.
fname (Optional[str])... | [
"def",
"download_and_verify",
"(",
"url",
",",
"md5sum",
",",
"fname",
"=",
"None",
",",
"chunk_size",
"=",
"1024",
",",
"clobber",
"=",
"False",
",",
"verbose",
"=",
"True",
")",
":",
"# Determine the filename",
"if",
"fname",
"is",
"None",
":",
"fname",
... | Download a file and verify the MD5 sum.
Args:
url (str): The URL to download.
md5sum (str): The expected MD5 sum.
fname (Optional[str]): The filename to store the downloaded file in.
If `None`, infer the filename from the URL. Defaults to `None`.
chunk_size (Optional[int... | [
"Download",
"a",
"file",
"and",
"verify",
"the",
"MD5",
"sum",
"."
] | c8f571a71da0d951bf8ea865621bee14492bdfd9 | https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/fetch_utils.py#L177-L285 | train | 63,996 |
gregreen/dustmaps | dustmaps/fetch_utils.py | download | def download(url, fname=None):
"""
Downloads a file.
Args:
url (str): The URL to download.
fname (Optional[str]): The filename to store the downloaded file in. If
`None`, take the filename from the URL. Defaults to `None`.
Returns:
The filename the URL was downloa... | python | def download(url, fname=None):
"""
Downloads a file.
Args:
url (str): The URL to download.
fname (Optional[str]): The filename to store the downloaded file in. If
`None`, take the filename from the URL. Defaults to `None`.
Returns:
The filename the URL was downloa... | [
"def",
"download",
"(",
"url",
",",
"fname",
"=",
"None",
")",
":",
"# Determine the filename",
"if",
"fname",
"is",
"None",
":",
"fname",
"=",
"url",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"# Stream the URL as a file, copying to local disk",
"wi... | Downloads a file.
Args:
url (str): The URL to download.
fname (Optional[str]): The filename to store the downloaded file in. If
`None`, take the filename from the URL. Defaults to `None`.
Returns:
The filename the URL was downloaded to.
Raises:
requests.excep... | [
"Downloads",
"a",
"file",
"."
] | c8f571a71da0d951bf8ea865621bee14492bdfd9 | https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/fetch_utils.py#L288-L320 | train | 63,997 |
gregreen/dustmaps | dustmaps/fetch_utils.py | dataverse_download_doi | def dataverse_download_doi(doi,
local_fname=None,
file_requirements={},
clobber=False):
"""
Downloads a file from the Dataverse, using a DOI and set of metadata
parameters to locate the file.
Args:
doi (str): Digit... | python | def dataverse_download_doi(doi,
local_fname=None,
file_requirements={},
clobber=False):
"""
Downloads a file from the Dataverse, using a DOI and set of metadata
parameters to locate the file.
Args:
doi (str): Digit... | [
"def",
"dataverse_download_doi",
"(",
"doi",
",",
"local_fname",
"=",
"None",
",",
"file_requirements",
"=",
"{",
"}",
",",
"clobber",
"=",
"False",
")",
":",
"metadata",
"=",
"dataverse_search_doi",
"(",
"doi",
")",
"def",
"requirements_match",
"(",
"metadata... | Downloads a file from the Dataverse, using a DOI and set of metadata
parameters to locate the file.
Args:
doi (str): Digital Object Identifier (DOI) containing the file.
local_fname (Optional[str]): Local filename to download the file to. If
`None`, then use the filename provided by... | [
"Downloads",
"a",
"file",
"from",
"the",
"Dataverse",
"using",
"a",
"DOI",
"and",
"set",
"of",
"metadata",
"parameters",
"to",
"locate",
"the",
"file",
"."
] | c8f571a71da0d951bf8ea865621bee14492bdfd9 | https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/fetch_utils.py#L355-L414 | train | 63,998 |
blockstack/virtualchain | virtualchain/lib/blockchain/address.py | address_reencode | def address_reencode(address, blockchain='bitcoin', **blockchain_opts):
"""
Reencode an address
"""
if blockchain == 'bitcoin':
return btc_address_reencode(address, **blockchain_opts)
else:
raise ValueError("Unknown blockchain '{}'".format(blockchain)) | python | def address_reencode(address, blockchain='bitcoin', **blockchain_opts):
"""
Reencode an address
"""
if blockchain == 'bitcoin':
return btc_address_reencode(address, **blockchain_opts)
else:
raise ValueError("Unknown blockchain '{}'".format(blockchain)) | [
"def",
"address_reencode",
"(",
"address",
",",
"blockchain",
"=",
"'bitcoin'",
",",
"*",
"*",
"blockchain_opts",
")",
":",
"if",
"blockchain",
"==",
"'bitcoin'",
":",
"return",
"btc_address_reencode",
"(",
"address",
",",
"*",
"*",
"blockchain_opts",
")",
"el... | Reencode an address | [
"Reencode",
"an",
"address"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/address.py#L25-L32 | train | 63,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.