id int32 0 252k | 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 list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
46,900 | mdickinson/bigfloat | bigfloat/core.py | lgamma | def lgamma(x, context=None):
"""
Return the logarithm of the absolute value of the Gamma function at x.
"""
return _apply_function_in_current_context(
BigFloat,
lambda rop, op, rnd: mpfr.mpfr_lgamma(rop, op, rnd)[0],
(BigFloat._implicit_convert(x),),
context,
) | python | def lgamma(x, context=None):
"""
Return the logarithm of the absolute value of the Gamma function at x.
"""
return _apply_function_in_current_context(
BigFloat,
lambda rop, op, rnd: mpfr.mpfr_lgamma(rop, op, rnd)[0],
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"lgamma",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"lambda",
"rop",
",",
"op",
",",
"rnd",
":",
"mpfr",
".",
"mpfr_lgamma",
"(",
"rop",
",",
"op",
",",
"rnd",
")",
"["... | Return the logarithm of the absolute value of the Gamma function at x. | [
"Return",
"the",
"logarithm",
"of",
"the",
"absolute",
"value",
"of",
"the",
"Gamma",
"function",
"at",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2013-L2023 |
46,901 | mdickinson/bigfloat | bigfloat/core.py | zeta | def zeta(x, context=None):
"""
Return the value of the Riemann zeta function on x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_zeta,
(BigFloat._implicit_convert(x),),
context,
) | python | def zeta(x, context=None):
"""
Return the value of the Riemann zeta function on x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_zeta,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"zeta",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_zeta",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
... | Return the value of the Riemann zeta function on x. | [
"Return",
"the",
"value",
"of",
"the",
"Riemann",
"zeta",
"function",
"on",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2039-L2049 |
46,902 | mdickinson/bigfloat | bigfloat/core.py | erf | def erf(x, context=None):
"""
Return the value of the error function at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_erf,
(BigFloat._implicit_convert(x),),
context,
) | python | def erf(x, context=None):
"""
Return the value of the error function at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_erf,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"erf",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_erf",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
")... | Return the value of the error function at x. | [
"Return",
"the",
"value",
"of",
"the",
"error",
"function",
"at",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2065-L2075 |
46,903 | mdickinson/bigfloat | bigfloat/core.py | erfc | def erfc(x, context=None):
"""
Return the value of the complementary error function at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_erfc,
(BigFloat._implicit_convert(x),),
context,
) | python | def erfc(x, context=None):
"""
Return the value of the complementary error function at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_erfc,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"erfc",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_erfc",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
... | Return the value of the complementary error function at x. | [
"Return",
"the",
"value",
"of",
"the",
"complementary",
"error",
"function",
"at",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2078-L2088 |
46,904 | mdickinson/bigfloat | bigfloat/core.py | j0 | def j0(x, context=None):
"""
Return the value of the first kind Bessel function of order 0 at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_j0,
(BigFloat._implicit_convert(x),),
context,
) | python | def j0(x, context=None):
"""
Return the value of the first kind Bessel function of order 0 at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_j0,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"j0",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_j0",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
")"
... | Return the value of the first kind Bessel function of order 0 at x. | [
"Return",
"the",
"value",
"of",
"the",
"first",
"kind",
"Bessel",
"function",
"of",
"order",
"0",
"at",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2091-L2101 |
46,905 | mdickinson/bigfloat | bigfloat/core.py | j1 | def j1(x, context=None):
"""
Return the value of the first kind Bessel function of order 1 at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_j1,
(BigFloat._implicit_convert(x),),
context,
) | python | def j1(x, context=None):
"""
Return the value of the first kind Bessel function of order 1 at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_j1,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"j1",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_j1",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
")"
... | Return the value of the first kind Bessel function of order 1 at x. | [
"Return",
"the",
"value",
"of",
"the",
"first",
"kind",
"Bessel",
"function",
"of",
"order",
"1",
"at",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2104-L2114 |
46,906 | mdickinson/bigfloat | bigfloat/core.py | jn | def jn(n, x, context=None):
"""
Return the value of the first kind Bessel function of order ``n`` at ``x``.
``n`` should be a Python integer.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_jn,
(n, BigFloat._implicit_convert(x)),
context,
) | python | def jn(n, x, context=None):
"""
Return the value of the first kind Bessel function of order ``n`` at ``x``.
``n`` should be a Python integer.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_jn,
(n, BigFloat._implicit_convert(x)),
context,
) | [
"def",
"jn",
"(",
"n",
",",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_jn",
",",
"(",
"n",
",",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
")",
",",
"co... | Return the value of the first kind Bessel function of order ``n`` at ``x``.
``n`` should be a Python integer. | [
"Return",
"the",
"value",
"of",
"the",
"first",
"kind",
"Bessel",
"function",
"of",
"order",
"n",
"at",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2117-L2129 |
46,907 | mdickinson/bigfloat | bigfloat/core.py | y0 | def y0(x, context=None):
"""
Return the value of the second kind Bessel function of order 0 at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_y0,
(BigFloat._implicit_convert(x),),
context,
) | python | def y0(x, context=None):
"""
Return the value of the second kind Bessel function of order 0 at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_y0,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"y0",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_y0",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
")"
... | Return the value of the second kind Bessel function of order 0 at x. | [
"Return",
"the",
"value",
"of",
"the",
"second",
"kind",
"Bessel",
"function",
"of",
"order",
"0",
"at",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2132-L2142 |
46,908 | mdickinson/bigfloat | bigfloat/core.py | y1 | def y1(x, context=None):
"""
Return the value of the second kind Bessel function of order 1 at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_y1,
(BigFloat._implicit_convert(x),),
context,
) | python | def y1(x, context=None):
"""
Return the value of the second kind Bessel function of order 1 at x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_y1,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"y1",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_y1",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
")"
... | Return the value of the second kind Bessel function of order 1 at x. | [
"Return",
"the",
"value",
"of",
"the",
"second",
"kind",
"Bessel",
"function",
"of",
"order",
"1",
"at",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2145-L2155 |
46,909 | mdickinson/bigfloat | bigfloat/core.py | yn | def yn(n, x, context=None):
"""
Return the value of the second kind Bessel function of order ``n`` at
``x``.
``n`` should be a Python integer.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_yn,
(n, BigFloat._implicit_convert(x)),
context,
... | python | def yn(n, x, context=None):
"""
Return the value of the second kind Bessel function of order ``n`` at
``x``.
``n`` should be a Python integer.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_yn,
(n, BigFloat._implicit_convert(x)),
context,
... | [
"def",
"yn",
"(",
"n",
",",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_yn",
",",
"(",
"n",
",",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
")",
",",
"co... | Return the value of the second kind Bessel function of order ``n`` at
``x``.
``n`` should be a Python integer. | [
"Return",
"the",
"value",
"of",
"the",
"second",
"kind",
"Bessel",
"function",
"of",
"order",
"n",
"at",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2158-L2171 |
46,910 | mdickinson/bigfloat | bigfloat/core.py | agm | def agm(x, y, context=None):
"""
Return the arithmetic geometric mean of x and y.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_agm,
(
BigFloat._implicit_convert(x),
BigFloat._implicit_convert(y),
),
context,
) | python | def agm(x, y, context=None):
"""
Return the arithmetic geometric mean of x and y.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_agm,
(
BigFloat._implicit_convert(x),
BigFloat._implicit_convert(y),
),
context,
) | [
"def",
"agm",
"(",
"x",
",",
"y",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_agm",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
"BigFloat",
".",
"... | Return the arithmetic geometric mean of x and y. | [
"Return",
"the",
"arithmetic",
"geometric",
"mean",
"of",
"x",
"and",
"y",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2210-L2223 |
46,911 | mdickinson/bigfloat | bigfloat/core.py | hypot | def hypot(x, y, context=None):
"""
Return the Euclidean norm of x and y, i.e., the square root of the sum of
the squares of x and y.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_hypot,
(
BigFloat._implicit_convert(x),
BigFloat._i... | python | def hypot(x, y, context=None):
"""
Return the Euclidean norm of x and y, i.e., the square root of the sum of
the squares of x and y.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_hypot,
(
BigFloat._implicit_convert(x),
BigFloat._i... | [
"def",
"hypot",
"(",
"x",
",",
"y",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_hypot",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
"BigFloat",
".",... | Return the Euclidean norm of x and y, i.e., the square root of the sum of
the squares of x and y. | [
"Return",
"the",
"Euclidean",
"norm",
"of",
"x",
"and",
"y",
"i",
".",
"e",
".",
"the",
"square",
"root",
"of",
"the",
"sum",
"of",
"the",
"squares",
"of",
"x",
"and",
"y",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2226-L2240 |
46,912 | mdickinson/bigfloat | bigfloat/core.py | ai | def ai(x, context=None):
"""
Return the Airy function of x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_ai,
(BigFloat._implicit_convert(x),),
context,
) | python | def ai(x, context=None):
"""
Return the Airy function of x.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_ai,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"ai",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_ai",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
")"
... | Return the Airy function of x. | [
"Return",
"the",
"Airy",
"function",
"of",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2243-L2253 |
46,913 | mdickinson/bigfloat | bigfloat/core.py | ceil | def ceil(x, context=None):
"""
Return the next higher or equal integer to x.
If the result is not exactly representable, it will be rounded according to
the current context. Note that the rounding step means that it's possible
for the result to be smaller than ``x``. For example::
>>> x ... | python | def ceil(x, context=None):
"""
Return the next higher or equal integer to x.
If the result is not exactly representable, it will be rounded according to
the current context. Note that the rounding step means that it's possible
for the result to be smaller than ``x``. For example::
>>> x ... | [
"def",
"ceil",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_rint_ceil",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",... | Return the next higher or equal integer to x.
If the result is not exactly representable, it will be rounded according to
the current context. Note that the rounding step means that it's possible
for the result to be smaller than ``x``. For example::
>>> x = 2**100 + 1
>>> ceil(2**100 + ... | [
"Return",
"the",
"next",
"higher",
"or",
"equal",
"integer",
"to",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2328-L2363 |
46,914 | mdickinson/bigfloat | bigfloat/core.py | floor | def floor(x, context=None):
"""
Return the next lower or equal integer to x.
If the result is not exactly representable, it will be rounded according to
the current context.
Note that it's possible for the result to be larger than ``x``. See the
documentation of the :func:`ceil` function for ... | python | def floor(x, context=None):
"""
Return the next lower or equal integer to x.
If the result is not exactly representable, it will be rounded according to
the current context.
Note that it's possible for the result to be larger than ``x``. See the
documentation of the :func:`ceil` function for ... | [
"def",
"floor",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_rint_floor",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
... | Return the next lower or equal integer to x.
If the result is not exactly representable, it will be rounded according to
the current context.
Note that it's possible for the result to be larger than ``x``. See the
documentation of the :func:`ceil` function for more information.
.. note::
... | [
"Return",
"the",
"next",
"lower",
"or",
"equal",
"integer",
"to",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2366-L2387 |
46,915 | mdickinson/bigfloat | bigfloat/core.py | trunc | def trunc(x, context=None):
"""
Return the next integer towards zero.
If the result is not exactly representable, it will be rounded according to
the current context.
.. note::
This function corresponds to the MPFR function ``mpfr_rint_trunc``,
not to ``mpfr_trunc``.
"""
re... | python | def trunc(x, context=None):
"""
Return the next integer towards zero.
If the result is not exactly representable, it will be rounded according to
the current context.
.. note::
This function corresponds to the MPFR function ``mpfr_rint_trunc``,
not to ``mpfr_trunc``.
"""
re... | [
"def",
"trunc",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_rint_trunc",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
... | Return the next integer towards zero.
If the result is not exactly representable, it will be rounded according to
the current context.
.. note::
This function corresponds to the MPFR function ``mpfr_rint_trunc``,
not to ``mpfr_trunc``. | [
"Return",
"the",
"next",
"integer",
"towards",
"zero",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2411-L2429 |
46,916 | mdickinson/bigfloat | bigfloat/core.py | frac | def frac(x, context=None):
"""
Return the fractional part of ``x``.
The result has the same sign as ``x``.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_frac,
(BigFloat._implicit_convert(x),),
context,
) | python | def frac(x, context=None):
"""
Return the fractional part of ``x``.
The result has the same sign as ``x``.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_frac,
(BigFloat._implicit_convert(x),),
context,
) | [
"def",
"frac",
"(",
"x",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_frac",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
")",
",",
"context",
",",
... | Return the fractional part of ``x``.
The result has the same sign as ``x``. | [
"Return",
"the",
"fractional",
"part",
"of",
"x",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2432-L2444 |
46,917 | mdickinson/bigfloat | bigfloat/core.py | min | def min(x, y, context=None):
"""
Return the minimum of x and y.
If x and y are both NaN, return NaN. If exactly one of x and y is NaN,
return the non-NaN value. If x and y are zeros of different signs, return
−0.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr... | python | def min(x, y, context=None):
"""
Return the minimum of x and y.
If x and y are both NaN, return NaN. If exactly one of x and y is NaN,
return the non-NaN value. If x and y are zeros of different signs, return
−0.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr... | [
"def",
"min",
"(",
"x",
",",
"y",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_min",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
"BigFloat",
".",
"... | Return the minimum of x and y.
If x and y are both NaN, return NaN. If exactly one of x and y is NaN,
return the non-NaN value. If x and y are zeros of different signs, return
−0. | [
"Return",
"the",
"minimum",
"of",
"x",
"and",
"y",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2506-L2523 |
46,918 | mdickinson/bigfloat | bigfloat/core.py | max | def max(x, y, context=None):
"""
Return the maximum of x and y.
If x and y are both NaN, return NaN. If exactly one of x and y is NaN,
return the non-NaN value. If x and y are zeros of different signs, return
+0.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr... | python | def max(x, y, context=None):
"""
Return the maximum of x and y.
If x and y are both NaN, return NaN. If exactly one of x and y is NaN,
return the non-NaN value. If x and y are zeros of different signs, return
+0.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr... | [
"def",
"max",
"(",
"x",
",",
"y",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_max",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
"BigFloat",
".",
"... | Return the maximum of x and y.
If x and y are both NaN, return NaN. If exactly one of x and y is NaN,
return the non-NaN value. If x and y are zeros of different signs, return
+0. | [
"Return",
"the",
"maximum",
"of",
"x",
"and",
"y",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2526-L2543 |
46,919 | mdickinson/bigfloat | bigfloat/core.py | copysign | def copysign(x, y, context=None):
"""
Return a new BigFloat object with the magnitude of x but the sign of y.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_copysign,
(
BigFloat._implicit_convert(x),
BigFloat._implicit_convert(y),
... | python | def copysign(x, y, context=None):
"""
Return a new BigFloat object with the magnitude of x but the sign of y.
"""
return _apply_function_in_current_context(
BigFloat,
mpfr.mpfr_copysign,
(
BigFloat._implicit_convert(x),
BigFloat._implicit_convert(y),
... | [
"def",
"copysign",
"(",
"x",
",",
"y",
",",
"context",
"=",
"None",
")",
":",
"return",
"_apply_function_in_current_context",
"(",
"BigFloat",
",",
"mpfr",
".",
"mpfr_copysign",
",",
"(",
"BigFloat",
".",
"_implicit_convert",
"(",
"x",
")",
",",
"BigFloat",
... | Return a new BigFloat object with the magnitude of x but the sign of y. | [
"Return",
"a",
"new",
"BigFloat",
"object",
"with",
"the",
"magnitude",
"of",
"x",
"but",
"the",
"sign",
"of",
"y",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L2556-L2569 |
46,920 | mdickinson/bigfloat | bigfloat/core.py | BigFloat.exact | def exact(cls, value, precision=None):
"""Convert an integer, float or BigFloat with no loss of precision.
Also convert a string with given precision.
This constructor makes no use of the current context.
"""
# figure out precision to use
if isinstance(value, six.string_... | python | def exact(cls, value, precision=None):
"""Convert an integer, float or BigFloat with no loss of precision.
Also convert a string with given precision.
This constructor makes no use of the current context.
"""
# figure out precision to use
if isinstance(value, six.string_... | [
"def",
"exact",
"(",
"cls",
",",
"value",
",",
"precision",
"=",
"None",
")",
":",
"# figure out precision to use",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"if",
"precision",
"is",
"None",
":",
"raise",
"TypeError",
"("... | Convert an integer, float or BigFloat with no loss of precision.
Also convert a string with given precision.
This constructor makes no use of the current context. | [
"Convert",
"an",
"integer",
"float",
"or",
"BigFloat",
"with",
"no",
"loss",
"of",
"precision",
".",
"Also",
"convert",
"a",
"string",
"with",
"given",
"precision",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L310-L357 |
46,921 | mdickinson/bigfloat | bigfloat/core.py | BigFloat._significand | def _significand(self):
"""Return the significand of self, as a BigFloat.
If self is a nonzero finite number, return a BigFloat m
with the same precision as self, such that
0.5 <= m < 1. and
self = +/-m * 2**e
for some exponent e.
If self is zero, infinity... | python | def _significand(self):
"""Return the significand of self, as a BigFloat.
If self is a nonzero finite number, return a BigFloat m
with the same precision as self, such that
0.5 <= m < 1. and
self = +/-m * 2**e
for some exponent e.
If self is zero, infinity... | [
"def",
"_significand",
"(",
"self",
")",
":",
"m",
"=",
"self",
".",
"copy",
"(",
")",
"if",
"self",
"and",
"is_finite",
"(",
"self",
")",
":",
"mpfr",
".",
"mpfr_set_exp",
"(",
"m",
",",
"0",
")",
"mpfr",
".",
"mpfr_setsign",
"(",
"m",
",",
"m",... | Return the significand of self, as a BigFloat.
If self is a nonzero finite number, return a BigFloat m
with the same precision as self, such that
0.5 <= m < 1. and
self = +/-m * 2**e
for some exponent e.
If self is zero, infinity or nan, return a copy of self with... | [
"Return",
"the",
"significand",
"of",
"self",
"as",
"a",
"BigFloat",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L457-L476 |
46,922 | mdickinson/bigfloat | bigfloat/core.py | BigFloat._exponent | def _exponent(self):
"""Return the exponent of self, as an integer.
The exponent is defined as the unique integer k such that
2**(k-1) <= abs(self) < 2**k.
If self is not finite and nonzero, return a string: one
of '0', 'inf' or 'nan'.
"""
if self and is_finit... | python | def _exponent(self):
"""Return the exponent of self, as an integer.
The exponent is defined as the unique integer k such that
2**(k-1) <= abs(self) < 2**k.
If self is not finite and nonzero, return a string: one
of '0', 'inf' or 'nan'.
"""
if self and is_finit... | [
"def",
"_exponent",
"(",
"self",
")",
":",
"if",
"self",
"and",
"is_finite",
"(",
"self",
")",
":",
"return",
"mpfr",
".",
"mpfr_get_exp",
"(",
"self",
")",
"if",
"not",
"self",
":",
"return",
"'0'",
"elif",
"is_inf",
"(",
"self",
")",
":",
"return",... | Return the exponent of self, as an integer.
The exponent is defined as the unique integer k such that
2**(k-1) <= abs(self) < 2**k.
If self is not finite and nonzero, return a string: one
of '0', 'inf' or 'nan'. | [
"Return",
"the",
"exponent",
"of",
"self",
"as",
"an",
"integer",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L478-L498 |
46,923 | mdickinson/bigfloat | bigfloat/core.py | BigFloat.copy_neg | def copy_neg(self):
""" Return a copy of self with the opposite sign bit.
Unlike -self, this does not make use of the context: the result
has the same precision as the original.
"""
result = mpfr.Mpfr_t.__new__(BigFloat)
mpfr.mpfr_init2(result, self.precision)
... | python | def copy_neg(self):
""" Return a copy of self with the opposite sign bit.
Unlike -self, this does not make use of the context: the result
has the same precision as the original.
"""
result = mpfr.Mpfr_t.__new__(BigFloat)
mpfr.mpfr_init2(result, self.precision)
... | [
"def",
"copy_neg",
"(",
"self",
")",
":",
"result",
"=",
"mpfr",
".",
"Mpfr_t",
".",
"__new__",
"(",
"BigFloat",
")",
"mpfr",
".",
"mpfr_init2",
"(",
"result",
",",
"self",
".",
"precision",
")",
"new_sign",
"=",
"not",
"self",
".",
"_sign",
"(",
")"... | Return a copy of self with the opposite sign bit.
Unlike -self, this does not make use of the context: the result
has the same precision as the original. | [
"Return",
"a",
"copy",
"of",
"self",
"with",
"the",
"opposite",
"sign",
"bit",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L512-L523 |
46,924 | mdickinson/bigfloat | bigfloat/core.py | BigFloat.copy_abs | def copy_abs(self):
""" Return a copy of self with the sign bit unset.
Unlike abs(self), this does not make use of the context: the result
has the same precision as the original.
"""
result = mpfr.Mpfr_t.__new__(BigFloat)
mpfr.mpfr_init2(result, self.precision)
... | python | def copy_abs(self):
""" Return a copy of self with the sign bit unset.
Unlike abs(self), this does not make use of the context: the result
has the same precision as the original.
"""
result = mpfr.Mpfr_t.__new__(BigFloat)
mpfr.mpfr_init2(result, self.precision)
... | [
"def",
"copy_abs",
"(",
"self",
")",
":",
"result",
"=",
"mpfr",
".",
"Mpfr_t",
".",
"__new__",
"(",
"BigFloat",
")",
"mpfr",
".",
"mpfr_init2",
"(",
"result",
",",
"self",
".",
"precision",
")",
"mpfr",
".",
"mpfr_setsign",
"(",
"result",
",",
"self",... | Return a copy of self with the sign bit unset.
Unlike abs(self), this does not make use of the context: the result
has the same precision as the original. | [
"Return",
"a",
"copy",
"of",
"self",
"with",
"the",
"sign",
"bit",
"unset",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L525-L535 |
46,925 | mdickinson/bigfloat | bigfloat/core.py | BigFloat.hex | def hex(self):
"""Return a hexadecimal representation of a BigFloat."""
sign = '-' if self._sign() else ''
e = self._exponent()
if isinstance(e, six.string_types):
return sign + e
m = self._significand()
_, digits, _ = _mpfr_get_str2(
16,
... | python | def hex(self):
"""Return a hexadecimal representation of a BigFloat."""
sign = '-' if self._sign() else ''
e = self._exponent()
if isinstance(e, six.string_types):
return sign + e
m = self._significand()
_, digits, _ = _mpfr_get_str2(
16,
... | [
"def",
"hex",
"(",
"self",
")",
":",
"sign",
"=",
"'-'",
"if",
"self",
".",
"_sign",
"(",
")",
"else",
"''",
"e",
"=",
"self",
".",
"_exponent",
"(",
")",
"if",
"isinstance",
"(",
"e",
",",
"six",
".",
"string_types",
")",
":",
"return",
"sign",
... | Return a hexadecimal representation of a BigFloat. | [
"Return",
"a",
"hexadecimal",
"representation",
"of",
"a",
"BigFloat",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L537-L556 |
46,926 | mdickinson/bigfloat | bigfloat/core.py | BigFloat._format_to_floating_precision | def _format_to_floating_precision(self, precision):
""" Format a nonzero finite BigFloat instance to a given number of
significant digits.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string gi... | python | def _format_to_floating_precision(self, precision):
""" Format a nonzero finite BigFloat instance to a given number of
significant digits.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string gi... | [
"def",
"_format_to_floating_precision",
"(",
"self",
",",
"precision",
")",
":",
"if",
"precision",
"<=",
"0",
":",
"raise",
"ValueError",
"(",
"\"precision argument should be at least 1\"",
")",
"sign",
",",
"digits",
",",
"exp",
"=",
"_mpfr_get_str2",
"(",
"10",... | Format a nonzero finite BigFloat instance to a given number of
significant digits.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string giving the digits of the output
- exp represents the exp... | [
"Format",
"a",
"nonzero",
"finite",
"BigFloat",
"instance",
"to",
"a",
"given",
"number",
"of",
"significant",
"digits",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L616-L641 |
46,927 | mdickinson/bigfloat | bigfloat/core.py | BigFloat._format_to_fixed_precision | def _format_to_fixed_precision(self, precision):
""" Format 'self' to a given number of digits after the decimal point.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string giving the digits of the outp... | python | def _format_to_fixed_precision(self, precision):
""" Format 'self' to a given number of digits after the decimal point.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string giving the digits of the outp... | [
"def",
"_format_to_fixed_precision",
"(",
"self",
",",
"precision",
")",
":",
"# MPFR only provides functions to format to a given number of",
"# significant digits. So we must:",
"#",
"# (1) Identify an e such that 10**(e-1) <= abs(x) < 10**e.",
"#",
"# (2) Determine the number of si... | Format 'self' to a given number of digits after the decimal point.
Returns a triple (negative, digits, exp) where:
- negative is a boolean, True for a negative number, else False
- digits is a string giving the digits of the output
- exp represents the exponent of the output
... | [
"Format",
"self",
"to",
"a",
"given",
"number",
"of",
"digits",
"after",
"the",
"decimal",
"point",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L643-L724 |
46,928 | mdickinson/bigfloat | bigfloat/core.py | BigFloat._implicit_convert | def _implicit_convert(cls, arg):
"""Implicit conversion used for binary operations, comparisons,
functions, etc. Return value should be an instance of
BigFloat."""
# ints, long and floats mix freely with BigFloats, and are
# converted exactly.
if isinstance(arg, six.int... | python | def _implicit_convert(cls, arg):
"""Implicit conversion used for binary operations, comparisons,
functions, etc. Return value should be an instance of
BigFloat."""
# ints, long and floats mix freely with BigFloats, and are
# converted exactly.
if isinstance(arg, six.int... | [
"def",
"_implicit_convert",
"(",
"cls",
",",
"arg",
")",
":",
"# ints, long and floats mix freely with BigFloats, and are",
"# converted exactly.",
"if",
"isinstance",
"(",
"arg",
",",
"six",
".",
"integer_types",
")",
"or",
"isinstance",
"(",
"arg",
",",
"float",
"... | Implicit conversion used for binary operations, comparisons,
functions, etc. Return value should be an instance of
BigFloat. | [
"Implicit",
"conversion",
"used",
"for",
"binary",
"operations",
"comparisons",
"functions",
"etc",
".",
"Return",
"value",
"should",
"be",
"an",
"instance",
"of",
"BigFloat",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/core.py#L858-L871 |
46,929 | blockstack/virtualchain | virtualchain/lib/merkle.py | calculate_merkle_pairs | def calculate_merkle_pairs(bin_hashes, hash_function=bin_double_sha256):
"""
Calculate the parents of a row of a merkle tree.
Takes in a list of binary hashes, returns a binary hash.
The returned parents list is such that parents[i] == hash(bin_hashes[2*i] + bin_hashes[2*i+1]).
"""
hashes = lis... | python | def calculate_merkle_pairs(bin_hashes, hash_function=bin_double_sha256):
"""
Calculate the parents of a row of a merkle tree.
Takes in a list of binary hashes, returns a binary hash.
The returned parents list is such that parents[i] == hash(bin_hashes[2*i] + bin_hashes[2*i+1]).
"""
hashes = lis... | [
"def",
"calculate_merkle_pairs",
"(",
"bin_hashes",
",",
"hash_function",
"=",
"bin_double_sha256",
")",
":",
"hashes",
"=",
"list",
"(",
"bin_hashes",
")",
"# if there are an odd number of hashes, double up the last one",
"if",
"len",
"(",
"hashes",
")",
"%",
"2",
"=... | Calculate the parents of a row of a merkle tree.
Takes in a list of binary hashes, returns a binary hash.
The returned parents list is such that parents[i] == hash(bin_hashes[2*i] + bin_hashes[2*i+1]). | [
"Calculate",
"the",
"parents",
"of",
"a",
"row",
"of",
"a",
"merkle",
"tree",
".",
"Takes",
"in",
"a",
"list",
"of",
"binary",
"hashes",
"returns",
"a",
"binary",
"hash",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/merkle.py#L26-L43 |
46,930 | blockstack/virtualchain | virtualchain/lib/merkle.py | verify_merkle_path | def verify_merkle_path(merkle_root_hex, serialized_path, leaf_hash_hex, hash_function=bin_double_sha256):
"""
Verify a merkle path. The given path is the path from two leaf nodes to the root itself.
merkle_root_hex is a little-endian, hex-encoded hash.
serialized_path is the serialized merkle path
... | python | def verify_merkle_path(merkle_root_hex, serialized_path, leaf_hash_hex, hash_function=bin_double_sha256):
"""
Verify a merkle path. The given path is the path from two leaf nodes to the root itself.
merkle_root_hex is a little-endian, hex-encoded hash.
serialized_path is the serialized merkle path
... | [
"def",
"verify_merkle_path",
"(",
"merkle_root_hex",
",",
"serialized_path",
",",
"leaf_hash_hex",
",",
"hash_function",
"=",
"bin_double_sha256",
")",
":",
"merkle_root",
"=",
"hex_to_bin_reversed",
"(",
"merkle_root_hex",
")",
"leaf_hash",
"=",
"hex_to_bin_reversed",
... | Verify a merkle path. The given path is the path from two leaf nodes to the root itself.
merkle_root_hex is a little-endian, hex-encoded hash.
serialized_path is the serialized merkle path
path_hex is a list of little-endian, hex-encoded hashes.
Return True if the path is consistent with the merkle r... | [
"Verify",
"a",
"merkle",
"path",
".",
"The",
"given",
"path",
"is",
"the",
"path",
"from",
"two",
"leaf",
"nodes",
"to",
"the",
"root",
"itself",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/merkle.py#L46-L80 |
46,931 | gregreen/dustmaps | dustmaps/unstructured_map.py | UnstructuredDustMap._coords2idx | def _coords2idx(self, coords):
"""
Converts from sky coordinates to pixel indices.
Args:
coords (:obj:`astropy.coordinates.SkyCoord`): Sky coordinates.
Returns:
Pixel indices of the coordinates, with the same shape as the input
coordinates. Pixels wh... | python | def _coords2idx(self, coords):
"""
Converts from sky coordinates to pixel indices.
Args:
coords (:obj:`astropy.coordinates.SkyCoord`): Sky coordinates.
Returns:
Pixel indices of the coordinates, with the same shape as the input
coordinates. Pixels wh... | [
"def",
"_coords2idx",
"(",
"self",
",",
"coords",
")",
":",
"x",
"=",
"self",
".",
"_coords2vec",
"(",
"coords",
")",
"idx",
"=",
"self",
".",
"_kd",
".",
"query",
"(",
"x",
",",
"p",
"=",
"self",
".",
"_metric_p",
",",
"distance_upper_bound",
"=",
... | Converts from sky coordinates to pixel indices.
Args:
coords (:obj:`astropy.coordinates.SkyCoord`): Sky coordinates.
Returns:
Pixel indices of the coordinates, with the same shape as the input
coordinates. Pixels which are outside the map are given an index
... | [
"Converts",
"from",
"sky",
"coordinates",
"to",
"pixel",
"indices",
"."
] | c8f571a71da0d951bf8ea865621bee14492bdfd9 | https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/unstructured_map.py#L105-L121 |
46,932 | gregreen/dustmaps | dustmaps/marshall.py | MarshallQuery._gal2idx | def _gal2idx(self, gal):
"""
Converts from Galactic coordinates to pixel indices.
Args:
gal (:obj:`astropy.coordinates.SkyCoord`): Galactic coordinates. Must
store an array of coordinates (i.e., not be scalar).
Returns:
``j, k, mask`` - Pixel ind... | python | def _gal2idx(self, gal):
"""
Converts from Galactic coordinates to pixel indices.
Args:
gal (:obj:`astropy.coordinates.SkyCoord`): Galactic coordinates. Must
store an array of coordinates (i.e., not be scalar).
Returns:
``j, k, mask`` - Pixel ind... | [
"def",
"_gal2idx",
"(",
"self",
",",
"gal",
")",
":",
"# Make sure that l is in domain [-180 deg, 180 deg)",
"l",
"=",
"coordinates",
".",
"Longitude",
"(",
"gal",
".",
"l",
",",
"wrap_angle",
"=",
"180.",
"*",
"units",
".",
"deg",
")",
"j",
"=",
"(",
"sel... | Converts from Galactic coordinates to pixel indices.
Args:
gal (:obj:`astropy.coordinates.SkyCoord`): Galactic coordinates. Must
store an array of coordinates (i.e., not be scalar).
Returns:
``j, k, mask`` - Pixel indices of the coordinates, as well as a mask
... | [
"Converts",
"from",
"Galactic",
"coordinates",
"to",
"pixel",
"indices",
"."
] | c8f571a71da0d951bf8ea865621bee14492bdfd9 | https://github.com/gregreen/dustmaps/blob/c8f571a71da0d951bf8ea865621bee14492bdfd9/dustmaps/marshall.py#L79-L105 |
46,933 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | GetHeaders.add_block_hash | def add_block_hash( self, block_hash ):
"""
Append up to 2000 block hashes for which to get headers.
"""
if len(self.block_hashes) > 2000:
raise Exception("A getheaders request cannot have over 2000 block hashes")
hash_num = int("0x" + block_hash, 16)
... | python | def add_block_hash( self, block_hash ):
"""
Append up to 2000 block hashes for which to get headers.
"""
if len(self.block_hashes) > 2000:
raise Exception("A getheaders request cannot have over 2000 block hashes")
hash_num = int("0x" + block_hash, 16)
... | [
"def",
"add_block_hash",
"(",
"self",
",",
"block_hash",
")",
":",
"if",
"len",
"(",
"self",
".",
"block_hashes",
")",
">",
"2000",
":",
"raise",
"Exception",
"(",
"\"A getheaders request cannot have over 2000 block hashes\"",
")",
"hash_num",
"=",
"int",
"(",
"... | Append up to 2000 block hashes for which to get headers. | [
"Append",
"up",
"to",
"2000",
"block",
"hashes",
"for",
"which",
"to",
"get",
"headers",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L144-L157 |
46,934 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | BlockHeaderClient.run | def run( self ):
"""
Interact with the blockchain peer,
until we get a socket error or we
exit the loop explicitly.
Return True on success
Raise on error
"""
self.handshake()
try:
self.loop()
except socket.error, se:
... | python | def run( self ):
"""
Interact with the blockchain peer,
until we get a socket error or we
exit the loop explicitly.
Return True on success
Raise on error
"""
self.handshake()
try:
self.loop()
except socket.error, se:
... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"handshake",
"(",
")",
"try",
":",
"self",
".",
"loop",
"(",
")",
"except",
"socket",
".",
"error",
",",
"se",
":",
"if",
"self",
".",
"finished",
":",
"return",
"True",
"else",
":",
"raise"
] | Interact with the blockchain peer,
until we get a socket error or we
exit the loop explicitly.
Return True on success
Raise on error | [
"Interact",
"with",
"the",
"blockchain",
"peer",
"until",
"we",
"get",
"a",
"socket",
"error",
"or",
"we",
"exit",
"the",
"loop",
"explicitly",
".",
"Return",
"True",
"on",
"success",
"Raise",
"on",
"error"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L221-L238 |
46,935 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | BlockHeaderClient.handle_ping | def handle_ping(self, message_header, message):
"""
This method will handle the Ping message and then
will answer every Ping message with a Pong message
using the nonce received.
:param message_header: The header of the Ping message
:param message: The Ping message
... | python | def handle_ping(self, message_header, message):
"""
This method will handle the Ping message and then
will answer every Ping message with a Pong message
using the nonce received.
:param message_header: The header of the Ping message
:param message: The Ping message
... | [
"def",
"handle_ping",
"(",
"self",
",",
"message_header",
",",
"message",
")",
":",
"log",
".",
"debug",
"(",
"\"handle ping\"",
")",
"pong",
"=",
"Pong",
"(",
")",
"pong",
".",
"nonce",
"=",
"message",
".",
"nonce",
"log",
".",
"debug",
"(",
"\"send p... | This method will handle the Ping message and then
will answer every Ping message with a Pong message
using the nonce received.
:param message_header: The header of the Ping message
:param message: The Ping message | [
"This",
"method",
"will",
"handle",
"the",
"Ping",
"message",
"and",
"then",
"will",
"answer",
"every",
"Ping",
"message",
"with",
"a",
"Pong",
"message",
"using",
"the",
"nonce",
"received",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L395-L408 |
46,936 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | SPVClient.init | def init(cls, path):
"""
Set up an SPV client.
If the locally-stored headers do not exist, then
create a stub headers file with the genesis block information.
"""
if not os.path.exists( path ):
block_header_serializer = BlockHeaderSerializer()
ge... | python | def init(cls, path):
"""
Set up an SPV client.
If the locally-stored headers do not exist, then
create a stub headers file with the genesis block information.
"""
if not os.path.exists( path ):
block_header_serializer = BlockHeaderSerializer()
ge... | [
"def",
"init",
"(",
"cls",
",",
"path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"block_header_serializer",
"=",
"BlockHeaderSerializer",
"(",
")",
"genesis_block_header",
"=",
"BlockHeader",
"(",
")",
"if",
"USE_MAIN... | Set up an SPV client.
If the locally-stored headers do not exist, then
create a stub headers file with the genesis block information. | [
"Set",
"up",
"an",
"SPV",
"client",
".",
"If",
"the",
"locally",
"-",
"stored",
"headers",
"do",
"not",
"exist",
"then",
"create",
"a",
"stub",
"headers",
"file",
"with",
"the",
"genesis",
"block",
"information",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L423-L447 |
46,937 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | SPVClient.height | def height(cls, path):
"""
Get the locally-stored block height
"""
if os.path.exists( path ):
sb = os.stat( path )
h = (sb.st_size / BLOCK_HEADER_SIZE) - 1
return h
else:
return None | python | def height(cls, path):
"""
Get the locally-stored block height
"""
if os.path.exists( path ):
sb = os.stat( path )
h = (sb.st_size / BLOCK_HEADER_SIZE) - 1
return h
else:
return None | [
"def",
"height",
"(",
"cls",
",",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"sb",
"=",
"os",
".",
"stat",
"(",
"path",
")",
"h",
"=",
"(",
"sb",
".",
"st_size",
"/",
"BLOCK_HEADER_SIZE",
")",
"-",
"1",
"... | Get the locally-stored block height | [
"Get",
"the",
"locally",
"-",
"stored",
"block",
"height"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L451-L460 |
46,938 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | SPVClient.read_header | def read_header(cls, headers_path, block_height, allow_none=False):
"""
Get a block header at a particular height from disk.
Return the header if found
Return None if not.
"""
if os.path.exists(headers_path):
header_parser = BlockHeaderSerializer()
... | python | def read_header(cls, headers_path, block_height, allow_none=False):
"""
Get a block header at a particular height from disk.
Return the header if found
Return None if not.
"""
if os.path.exists(headers_path):
header_parser = BlockHeaderSerializer()
... | [
"def",
"read_header",
"(",
"cls",
",",
"headers_path",
",",
"block_height",
",",
"allow_none",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"headers_path",
")",
":",
"header_parser",
"=",
"BlockHeaderSerializer",
"(",
")",
"sb",
"="... | Get a block header at a particular height from disk.
Return the header if found
Return None if not. | [
"Get",
"a",
"block",
"header",
"at",
"a",
"particular",
"height",
"from",
"disk",
".",
"Return",
"the",
"header",
"if",
"found",
"Return",
"None",
"if",
"not",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L512-L538 |
46,939 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | SPVClient.block_header_verify | def block_header_verify( cls, headers_path, block_id, block_hash, block_header ):
"""
Given the block's numeric ID, its hash, and the bitcoind-returned block_data,
use the SPV header chain to verify the block's integrity.
block_header must be a dict with the following structure:
... | python | def block_header_verify( cls, headers_path, block_id, block_hash, block_header ):
"""
Given the block's numeric ID, its hash, and the bitcoind-returned block_data,
use the SPV header chain to verify the block's integrity.
block_header must be a dict with the following structure:
... | [
"def",
"block_header_verify",
"(",
"cls",
",",
"headers_path",
",",
"block_id",
",",
"block_hash",
",",
"block_header",
")",
":",
"prev_header",
"=",
"cls",
".",
"read_header",
"(",
"headers_path",
",",
"block_id",
"-",
"1",
")",
"prev_hash",
"=",
"prev_header... | Given the block's numeric ID, its hash, and the bitcoind-returned block_data,
use the SPV header chain to verify the block's integrity.
block_header must be a dict with the following structure:
* version: protocol version (int)
* prevhash: previous block hash (hex str)
* merkler... | [
"Given",
"the",
"block",
"s",
"numeric",
"ID",
"its",
"hash",
"and",
"the",
"bitcoind",
"-",
"returned",
"block_data",
"use",
"the",
"SPV",
"header",
"chain",
"to",
"verify",
"the",
"block",
"s",
"integrity",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L594-L614 |
46,940 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | SPVClient.tx_hash | def tx_hash( cls, tx ):
"""
Calculate the hash of a transction structure given by bitcoind
"""
tx_hex = bits.btc_bitcoind_tx_serialize( tx )
tx_hash = hashing.bin_double_sha256(tx_hex.decode('hex'))[::-1].encode('hex')
return tx_hash | python | def tx_hash( cls, tx ):
"""
Calculate the hash of a transction structure given by bitcoind
"""
tx_hex = bits.btc_bitcoind_tx_serialize( tx )
tx_hash = hashing.bin_double_sha256(tx_hex.decode('hex'))[::-1].encode('hex')
return tx_hash | [
"def",
"tx_hash",
"(",
"cls",
",",
"tx",
")",
":",
"tx_hex",
"=",
"bits",
".",
"btc_bitcoind_tx_serialize",
"(",
"tx",
")",
"tx_hash",
"=",
"hashing",
".",
"bin_double_sha256",
"(",
"tx_hex",
".",
"decode",
"(",
"'hex'",
")",
")",
"[",
":",
":",
"-",
... | Calculate the hash of a transction structure given by bitcoind | [
"Calculate",
"the",
"hash",
"of",
"a",
"transction",
"structure",
"given",
"by",
"bitcoind"
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L636-L642 |
46,941 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | SPVClient.tx_verify | def tx_verify( cls, verified_block_txids, tx ):
"""
Given the block's verified block txids, verify that a transaction is legit.
@tx must be a dict with the following fields:
* locktime: int
* version: int
* vin: list of dicts with:
* vout: int,
* has... | python | def tx_verify( cls, verified_block_txids, tx ):
"""
Given the block's verified block txids, verify that a transaction is legit.
@tx must be a dict with the following fields:
* locktime: int
* version: int
* vin: list of dicts with:
* vout: int,
* has... | [
"def",
"tx_verify",
"(",
"cls",
",",
"verified_block_txids",
",",
"tx",
")",
":",
"tx_hash",
"=",
"cls",
".",
"tx_hash",
"(",
"tx",
")",
"return",
"tx_hash",
"in",
"verified_block_txids"
] | Given the block's verified block txids, verify that a transaction is legit.
@tx must be a dict with the following fields:
* locktime: int
* version: int
* vin: list of dicts with:
* vout: int,
* hash: hex str
* sequence: int (optional)
* script... | [
"Given",
"the",
"block",
"s",
"verified",
"block",
"txids",
"verify",
"that",
"a",
"transaction",
"is",
"legit",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L646-L664 |
46,942 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | SPVClient.verify_header_chain | def verify_header_chain(cls, path, chain=None):
"""
Verify that a given chain of block headers
has sufficient proof of work.
"""
if chain is None:
chain = SPVClient.load_header_chain( path )
prev_header = chain[0]
for i in xrange(1, len(chain... | python | def verify_header_chain(cls, path, chain=None):
"""
Verify that a given chain of block headers
has sufficient proof of work.
"""
if chain is None:
chain = SPVClient.load_header_chain( path )
prev_header = chain[0]
for i in xrange(1, len(chain... | [
"def",
"verify_header_chain",
"(",
"cls",
",",
"path",
",",
"chain",
"=",
"None",
")",
":",
"if",
"chain",
"is",
"None",
":",
"chain",
"=",
"SPVClient",
".",
"load_header_chain",
"(",
"path",
")",
"prev_header",
"=",
"chain",
"[",
"0",
"]",
"for",
"i",... | Verify that a given chain of block headers
has sufficient proof of work. | [
"Verify",
"that",
"a",
"given",
"chain",
"of",
"block",
"headers",
"has",
"sufficient",
"proof",
"of",
"work",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L699-L729 |
46,943 | blockstack/virtualchain | virtualchain/lib/blockchain/bitcoin_blockchain/spv.py | SPVClient.sync_header_chain | def sync_header_chain(cls, path, bitcoind_server, last_block_id ):
"""
Synchronize our local block headers up to the last block ID given.
@last_block_id is *inclusive*
@bitcoind_server is host:port or just host
"""
current_block_id = SPVClient.height( path )
if cu... | python | def sync_header_chain(cls, path, bitcoind_server, last_block_id ):
"""
Synchronize our local block headers up to the last block ID given.
@last_block_id is *inclusive*
@bitcoind_server is host:port or just host
"""
current_block_id = SPVClient.height( path )
if cu... | [
"def",
"sync_header_chain",
"(",
"cls",
",",
"path",
",",
"bitcoind_server",
",",
"last_block_id",
")",
":",
"current_block_id",
"=",
"SPVClient",
".",
"height",
"(",
"path",
")",
"if",
"current_block_id",
"is",
"None",
":",
"assert",
"USE_TESTNET",
"current_blo... | Synchronize our local block headers up to the last block ID given.
@last_block_id is *inclusive*
@bitcoind_server is host:port or just host | [
"Synchronize",
"our",
"local",
"block",
"headers",
"up",
"to",
"the",
"last",
"block",
"ID",
"given",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/bitcoin_blockchain/spv.py#L733-L793 |
46,944 | mdickinson/bigfloat | bigfloat/ieee.py | IEEEContext | def IEEEContext(bitwidth):
"""
Return IEEE 754-2008 context for a given bit width.
The IEEE 754 standard specifies binary interchange formats with bitwidths
16, 32, 64, 128, and all multiples of 32 greater than 128. This function
returns the context corresponding to the interchange format for the ... | python | def IEEEContext(bitwidth):
"""
Return IEEE 754-2008 context for a given bit width.
The IEEE 754 standard specifies binary interchange formats with bitwidths
16, 32, 64, 128, and all multiples of 32 greater than 128. This function
returns the context corresponding to the interchange format for the ... | [
"def",
"IEEEContext",
"(",
"bitwidth",
")",
":",
"try",
":",
"precision",
"=",
"{",
"16",
":",
"11",
",",
"32",
":",
"24",
",",
"64",
":",
"53",
",",
"128",
":",
"113",
"}",
"[",
"bitwidth",
"]",
"except",
"KeyError",
":",
"if",
"not",
"(",
"bi... | Return IEEE 754-2008 context for a given bit width.
The IEEE 754 standard specifies binary interchange formats with bitwidths
16, 32, 64, 128, and all multiples of 32 greater than 128. This function
returns the context corresponding to the interchange format for the given
bitwidth.
See section 3.... | [
"Return",
"IEEE",
"754",
"-",
"2008",
"context",
"for",
"a",
"given",
"bit",
"width",
"."
] | e5fdd1048615191ed32a2b7460e14b3b3ff24662 | https://github.com/mdickinson/bigfloat/blob/e5fdd1048615191ed32a2b7460e14b3b3ff24662/bigfloat/ieee.py#L22-L58 |
46,945 | mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/xyz_functions.py | view | def view(molecule, viewer=settings['defaults']['viewer'], use_curr_dir=False):
"""View your molecule or list of molecules.
.. note:: This function writes a temporary file and opens it with
an external viewer.
If you modify your molecule afterwards you have to recall view
in order to see... | python | def view(molecule, viewer=settings['defaults']['viewer'], use_curr_dir=False):
"""View your molecule or list of molecules.
.. note:: This function writes a temporary file and opens it with
an external viewer.
If you modify your molecule afterwards you have to recall view
in order to see... | [
"def",
"view",
"(",
"molecule",
",",
"viewer",
"=",
"settings",
"[",
"'defaults'",
"]",
"[",
"'viewer'",
"]",
",",
"use_curr_dir",
"=",
"False",
")",
":",
"try",
":",
"molecule",
".",
"view",
"(",
"viewer",
"=",
"viewer",
",",
"use_curr_dir",
"=",
"use... | View your molecule or list of molecules.
.. note:: This function writes a temporary file and opens it with
an external viewer.
If you modify your molecule afterwards you have to recall view
in order to see the changes.
Args:
molecule: Can be a cartesian, or a list of cartesians... | [
"View",
"your",
"molecule",
"or",
"list",
"of",
"molecules",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/xyz_functions.py#L21-L73 |
46,946 | mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/xyz_functions.py | to_molden | def to_molden(cartesian_list, buf=None, sort_index=True,
overwrite=True, float_format='{:.6f}'.format):
"""Write a list of Cartesians into a molden file.
.. note:: Since it permamently writes a file, this function
is strictly speaking **not sideeffect free**.
The list to be writte... | python | def to_molden(cartesian_list, buf=None, sort_index=True,
overwrite=True, float_format='{:.6f}'.format):
"""Write a list of Cartesians into a molden file.
.. note:: Since it permamently writes a file, this function
is strictly speaking **not sideeffect free**.
The list to be writte... | [
"def",
"to_molden",
"(",
"cartesian_list",
",",
"buf",
"=",
"None",
",",
"sort_index",
"=",
"True",
",",
"overwrite",
"=",
"True",
",",
"float_format",
"=",
"'{:.6f}'",
".",
"format",
")",
":",
"if",
"sort_index",
":",
"cartesian_list",
"=",
"[",
"molecule... | Write a list of Cartesians into a molden file.
.. note:: Since it permamently writes a file, this function
is strictly speaking **not sideeffect free**.
The list to be written is of course not changed.
Args:
cartesian_list (list):
buf (str): StringIO-like, optional buffer to wr... | [
"Write",
"a",
"list",
"of",
"Cartesians",
"into",
"a",
"molden",
"file",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/xyz_functions.py#L76-L127 |
46,947 | mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/xyz_functions.py | read_molden | def read_molden(inputfile, start_index=0, get_bonds=True):
"""Read a molden file.
Args:
inputfile (str):
start_index (int):
Returns:
list: A list containing :class:`~chemcoord.Cartesian` is returned.
"""
from chemcoord.cartesian_coordinates.cartesian_class_main import Carte... | python | def read_molden(inputfile, start_index=0, get_bonds=True):
"""Read a molden file.
Args:
inputfile (str):
start_index (int):
Returns:
list: A list containing :class:`~chemcoord.Cartesian` is returned.
"""
from chemcoord.cartesian_coordinates.cartesian_class_main import Carte... | [
"def",
"read_molden",
"(",
"inputfile",
",",
"start_index",
"=",
"0",
",",
"get_bonds",
"=",
"True",
")",
":",
"from",
"chemcoord",
".",
"cartesian_coordinates",
".",
"cartesian_class_main",
"import",
"Cartesian",
"with",
"open",
"(",
"inputfile",
",",
"'r'",
... | Read a molden file.
Args:
inputfile (str):
start_index (int):
Returns:
list: A list containing :class:`~chemcoord.Cartesian` is returned. | [
"Read",
"a",
"molden",
"file",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/xyz_functions.py#L140-L184 |
46,948 | mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/xyz_functions.py | concat | def concat(cartesians, ignore_index=False, keys=None):
"""Join list of cartesians into one molecule.
Wrapper around the :func:`pandas.concat` function.
Default values are the same as in the pandas function except for
``verify_integrity`` which is set to true in case of this library.
Args:
... | python | def concat(cartesians, ignore_index=False, keys=None):
"""Join list of cartesians into one molecule.
Wrapper around the :func:`pandas.concat` function.
Default values are the same as in the pandas function except for
``verify_integrity`` which is set to true in case of this library.
Args:
... | [
"def",
"concat",
"(",
"cartesians",
",",
"ignore_index",
"=",
"False",
",",
"keys",
"=",
"None",
")",
":",
"frames",
"=",
"[",
"molecule",
".",
"_frame",
"for",
"molecule",
"in",
"cartesians",
"]",
"new",
"=",
"pd",
".",
"concat",
"(",
"frames",
",",
... | Join list of cartesians into one molecule.
Wrapper around the :func:`pandas.concat` function.
Default values are the same as in the pandas function except for
``verify_integrity`` which is set to true in case of this library.
Args:
ignore_index (sequence, bool, int): If it is a boolean, it
... | [
"Join",
"list",
"of",
"cartesians",
"into",
"one",
"molecule",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/xyz_functions.py#L240-L277 |
46,949 | mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/xyz_functions.py | dot | def dot(A, B):
"""Matrix multiplication between A and B
This function is equivalent to ``A @ B``, which is unfortunately
not possible under python 2.x.
Args:
A (sequence):
B (sequence):
Returns:
sequence:
"""
try:
result = A.__matmul__(B)
if result ... | python | def dot(A, B):
"""Matrix multiplication between A and B
This function is equivalent to ``A @ B``, which is unfortunately
not possible under python 2.x.
Args:
A (sequence):
B (sequence):
Returns:
sequence:
"""
try:
result = A.__matmul__(B)
if result ... | [
"def",
"dot",
"(",
"A",
",",
"B",
")",
":",
"try",
":",
"result",
"=",
"A",
".",
"__matmul__",
"(",
"B",
")",
"if",
"result",
"is",
"NotImplemented",
":",
"result",
"=",
"B",
".",
"__rmatmul__",
"(",
"A",
")",
"except",
"AttributeError",
":",
"resu... | Matrix multiplication between A and B
This function is equivalent to ``A @ B``, which is unfortunately
not possible under python 2.x.
Args:
A (sequence):
B (sequence):
Returns:
sequence: | [
"Matrix",
"multiplication",
"between",
"A",
"and",
"B"
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/xyz_functions.py#L280-L299 |
46,950 | mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/xyz_functions.py | orthonormalize_righthanded | def orthonormalize_righthanded(basis):
"""Orthonormalizes righthandedly a given 3D basis.
This functions returns a right handed orthonormalize_righthandedd basis.
Since only the first two vectors in the basis are used, it does not matter
if you give two or three vectors.
Right handed means, that:
... | python | def orthonormalize_righthanded(basis):
"""Orthonormalizes righthandedly a given 3D basis.
This functions returns a right handed orthonormalize_righthandedd basis.
Since only the first two vectors in the basis are used, it does not matter
if you give two or three vectors.
Right handed means, that:
... | [
"def",
"orthonormalize_righthanded",
"(",
"basis",
")",
":",
"v1",
",",
"v2",
"=",
"basis",
"[",
":",
",",
"0",
"]",
",",
"basis",
"[",
":",
",",
"1",
"]",
"e1",
"=",
"normalize",
"(",
"v1",
")",
"e3",
"=",
"normalize",
"(",
"np",
".",
"cross",
... | Orthonormalizes righthandedly a given 3D basis.
This functions returns a right handed orthonormalize_righthandedd basis.
Since only the first two vectors in the basis are used, it does not matter
if you give two or three vectors.
Right handed means, that:
.. math::
\\vec{e_1} \\times \\v... | [
"Orthonormalizes",
"righthandedly",
"a",
"given",
"3D",
"basis",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/xyz_functions.py#L393-L418 |
46,951 | mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/xyz_functions.py | get_kabsch_rotation | def get_kabsch_rotation(Q, P):
"""Calculate the optimal rotation from ``P`` unto ``Q``.
Using the Kabsch algorithm the optimal rotation matrix
for the rotation of ``other`` unto ``self`` is calculated.
The algorithm is described very well in
`wikipedia <http://en.wikipedia.org/wiki/Kabsch_algorithm... | python | def get_kabsch_rotation(Q, P):
"""Calculate the optimal rotation from ``P`` unto ``Q``.
Using the Kabsch algorithm the optimal rotation matrix
for the rotation of ``other`` unto ``self`` is calculated.
The algorithm is described very well in
`wikipedia <http://en.wikipedia.org/wiki/Kabsch_algorithm... | [
"def",
"get_kabsch_rotation",
"(",
"Q",
",",
"P",
")",
":",
"# Naming of variables follows the wikipedia article:",
"# http://en.wikipedia.org/wiki/Kabsch_algorithm",
"A",
"=",
"np",
".",
"dot",
"(",
"np",
".",
"transpose",
"(",
"P",
")",
",",
"Q",
")",
"# One can't... | Calculate the optimal rotation from ``P`` unto ``Q``.
Using the Kabsch algorithm the optimal rotation matrix
for the rotation of ``other`` unto ``self`` is calculated.
The algorithm is described very well in
`wikipedia <http://en.wikipedia.org/wiki/Kabsch_algorithm>`_.
Args:
other (Cartesi... | [
"Calculate",
"the",
"optimal",
"rotation",
"from",
"P",
"unto",
"Q",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/xyz_functions.py#L421-L442 |
46,952 | mcocdawc/chemcoord | src/chemcoord/cartesian_coordinates/xyz_functions.py | apply_grad_zmat_tensor | def apply_grad_zmat_tensor(grad_C, construction_table, cart_dist):
"""Apply the gradient for transformation to Zmatrix space onto cart_dist.
Args:
grad_C (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array.
The mathematical details of the index layout is explained in
:meth:`~chem... | python | def apply_grad_zmat_tensor(grad_C, construction_table, cart_dist):
"""Apply the gradient for transformation to Zmatrix space onto cart_dist.
Args:
grad_C (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array.
The mathematical details of the index layout is explained in
:meth:`~chem... | [
"def",
"apply_grad_zmat_tensor",
"(",
"grad_C",
",",
"construction_table",
",",
"cart_dist",
")",
":",
"if",
"(",
"construction_table",
".",
"index",
"!=",
"cart_dist",
".",
"index",
")",
".",
"any",
"(",
")",
":",
"message",
"=",
"\"construction_table and cart_... | Apply the gradient for transformation to Zmatrix space onto cart_dist.
Args:
grad_C (:class:`numpy.ndarray`): A ``(3, n, n, 3)`` array.
The mathematical details of the index layout is explained in
:meth:`~chemcoord.Cartesian.get_grad_zmat()`.
construction_table (pandas.DataF... | [
"Apply",
"the",
"gradient",
"for",
"transformation",
"to",
"Zmatrix",
"space",
"onto",
"cart_dist",
"."
] | 95561ce387c142227c38fb14a1d182179aef8f5f | https://github.com/mcocdawc/chemcoord/blob/95561ce387c142227c38fb14a1d182179aef8f5f/src/chemcoord/cartesian_coordinates/xyz_functions.py#L445-L481 |
46,953 | emory-libraries/eulxml | eulxml/xmlmap/fields.py | _remove_child_node | def _remove_child_node(node, context, xast, if_empty=False):
'''Remove a child node based on the specified xpath.
:param node: lxml element relative to which the xpath will be
interpreted
:param context: any context required for the xpath (e.g.,
namespace definitions)
:param xast: parsed xpat... | python | def _remove_child_node(node, context, xast, if_empty=False):
'''Remove a child node based on the specified xpath.
:param node: lxml element relative to which the xpath will be
interpreted
:param context: any context required for the xpath (e.g.,
namespace definitions)
:param xast: parsed xpat... | [
"def",
"_remove_child_node",
"(",
"node",
",",
"context",
",",
"xast",
",",
"if_empty",
"=",
"False",
")",
":",
"xpath",
"=",
"serialize",
"(",
"xast",
")",
"child",
"=",
"_find_xml_node",
"(",
"xpath",
",",
"node",
",",
"context",
")",
"if",
"child",
... | Remove a child node based on the specified xpath.
:param node: lxml element relative to which the xpath will be
interpreted
:param context: any context required for the xpath (e.g.,
namespace definitions)
:param xast: parsed xpath (xpath abstract syntax tree) from
:mod:`eulxml.xpath`
:param ... | [
"Remove",
"a",
"child",
"node",
"based",
"on",
"the",
"specified",
"xpath",
"."
] | 17d71c7d98c0cebda9932b7f13e72093805e1fe2 | https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/fields.py#L483-L506 |
46,954 | emory-libraries/eulxml | eulxml/xmlmap/fields.py | _remove_predicates | def _remove_predicates(xast, node, context):
'''Remove any constructible predicates specified in the xpath
relative to the specified node.
:param xast: parsed xpath (xpath abstract syntax tree) from
:mod:`eulxml.xpath`
:param node: lxml element which predicates will be removed from
:param context:... | python | def _remove_predicates(xast, node, context):
'''Remove any constructible predicates specified in the xpath
relative to the specified node.
:param xast: parsed xpath (xpath abstract syntax tree) from
:mod:`eulxml.xpath`
:param node: lxml element which predicates will be removed from
:param context:... | [
"def",
"_remove_predicates",
"(",
"xast",
",",
"node",
",",
"context",
")",
":",
"# work from a copy since it may be modified",
"xast_c",
"=",
"deepcopy",
"(",
"xast",
")",
"# check if predicates are constructable",
"for",
"pred",
"in",
"list",
"(",
"xast_c",
".",
"... | Remove any constructible predicates specified in the xpath
relative to the specified node.
:param xast: parsed xpath (xpath abstract syntax tree) from
:mod:`eulxml.xpath`
:param node: lxml element which predicates will be removed from
:param context: any context required for the xpath (e.g.,
name... | [
"Remove",
"any",
"constructible",
"predicates",
"specified",
"in",
"the",
"xpath",
"relative",
"to",
"the",
"specified",
"node",
"."
] | 17d71c7d98c0cebda9932b7f13e72093805e1fe2 | https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/fields.py#L513-L559 |
46,955 | emory-libraries/eulxml | eulxml/xmlmap/fields.py | NodeList.pop | def pop(self, i=None):
"""Remove the item at the given position in the list, and return it.
If no index is specified, removes and returns the last item in the list."""
if i is None:
i = len(self) - 1
val = self[i]
del(self[i])
return val | python | def pop(self, i=None):
"""Remove the item at the given position in the list, and return it.
If no index is specified, removes and returns the last item in the list."""
if i is None:
i = len(self) - 1
val = self[i]
del(self[i])
return val | [
"def",
"pop",
"(",
"self",
",",
"i",
"=",
"None",
")",
":",
"if",
"i",
"is",
"None",
":",
"i",
"=",
"len",
"(",
"self",
")",
"-",
"1",
"val",
"=",
"self",
"[",
"i",
"]",
"del",
"(",
"self",
"[",
"i",
"]",
")",
"return",
"val"
] | Remove the item at the given position in the list, and return it.
If no index is specified, removes and returns the last item in the list. | [
"Remove",
"the",
"item",
"at",
"the",
"given",
"position",
"in",
"the",
"list",
"and",
"return",
"it",
".",
"If",
"no",
"index",
"is",
"specified",
"removes",
"and",
"returns",
"the",
"last",
"item",
"in",
"the",
"list",
"."
] | 17d71c7d98c0cebda9932b7f13e72093805e1fe2 | https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/xmlmap/fields.py#L800-L807 |
46,956 | probcomp/crosscat | src/utils/general_utils.py | get_scc_from_tuples | def get_scc_from_tuples(constraints):
"""Given set of equivalences, return map of transitive equivalence classes.
>> constraints = [(1,2), (2,3)]
>> get_scc_from_tuples(constraints)
{
1: (1, 2, 3),
2: (1, 2, 3),
3: (1, 2, 3),
}
"""
classes = unionfind.classes(constra... | python | def get_scc_from_tuples(constraints):
"""Given set of equivalences, return map of transitive equivalence classes.
>> constraints = [(1,2), (2,3)]
>> get_scc_from_tuples(constraints)
{
1: (1, 2, 3),
2: (1, 2, 3),
3: (1, 2, 3),
}
"""
classes = unionfind.classes(constra... | [
"def",
"get_scc_from_tuples",
"(",
"constraints",
")",
":",
"classes",
"=",
"unionfind",
".",
"classes",
"(",
"constraints",
")",
"return",
"dict",
"(",
"(",
"x",
",",
"tuple",
"(",
"c",
")",
")",
"for",
"x",
",",
"c",
"in",
"classes",
".",
"iteritems"... | Given set of equivalences, return map of transitive equivalence classes.
>> constraints = [(1,2), (2,3)]
>> get_scc_from_tuples(constraints)
{
1: (1, 2, 3),
2: (1, 2, 3),
3: (1, 2, 3),
} | [
"Given",
"set",
"of",
"equivalences",
"return",
"map",
"of",
"transitive",
"equivalence",
"classes",
"."
] | 4a05bddb06a45f3b7b3e05e095720f16257d1535 | https://github.com/probcomp/crosscat/blob/4a05bddb06a45f3b7b3e05e095720f16257d1535/src/utils/general_utils.py#L206-L218 |
46,957 | emory-libraries/eulxml | eulxml/forms/xmlobject.py | _parse_field_list | def _parse_field_list(fieldnames, include_parents=False):
"""
Parse a list of field names, possibly including dot-separated subform
fields, into an internal ParsedFieldList object representing the base
fields and subform listed.
:param fieldnames: a list of field names as strings. dot-separated nam... | python | def _parse_field_list(fieldnames, include_parents=False):
"""
Parse a list of field names, possibly including dot-separated subform
fields, into an internal ParsedFieldList object representing the base
fields and subform listed.
:param fieldnames: a list of field names as strings. dot-separated nam... | [
"def",
"_parse_field_list",
"(",
"fieldnames",
",",
"include_parents",
"=",
"False",
")",
":",
"field_parts",
"=",
"(",
"name",
".",
"split",
"(",
"'.'",
")",
"for",
"name",
"in",
"fieldnames",
")",
"return",
"_collect_fields",
"(",
"field_parts",
",",
"incl... | Parse a list of field names, possibly including dot-separated subform
fields, into an internal ParsedFieldList object representing the base
fields and subform listed.
:param fieldnames: a list of field names as strings. dot-separated names
are interpreted as subform fields.
:param include_paren... | [
"Parse",
"a",
"list",
"of",
"field",
"names",
"possibly",
"including",
"dot",
"-",
"separated",
"subform",
"fields",
"into",
"an",
"internal",
"ParsedFieldList",
"object",
"representing",
"the",
"base",
"fields",
"and",
"subform",
"listed",
"."
] | 17d71c7d98c0cebda9932b7f13e72093805e1fe2 | https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/forms/xmlobject.py#L44-L57 |
46,958 | emory-libraries/eulxml | eulxml/forms/xmlobject.py | xmlobject_to_dict | def xmlobject_to_dict(instance, fields=None, exclude=None, prefix=''):
"""
Generate a dictionary based on the data in an XmlObject instance to pass as
a Form's ``initial`` keyword argument.
:param instance: instance of :class:`~eulxml.xmlmap.XmlObject`
:param fields: optional list of fields - if sp... | python | def xmlobject_to_dict(instance, fields=None, exclude=None, prefix=''):
"""
Generate a dictionary based on the data in an XmlObject instance to pass as
a Form's ``initial`` keyword argument.
:param instance: instance of :class:`~eulxml.xmlmap.XmlObject`
:param fields: optional list of fields - if sp... | [
"def",
"xmlobject_to_dict",
"(",
"instance",
",",
"fields",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"prefix",
"=",
"''",
")",
":",
"data",
"=",
"{",
"}",
"# convert prefix to combining form for convenience",
"if",
"prefix",
":",
"prefix",
"=",
"'%s-'",
... | Generate a dictionary based on the data in an XmlObject instance to pass as
a Form's ``initial`` keyword argument.
:param instance: instance of :class:`~eulxml.xmlmap.XmlObject`
:param fields: optional list of fields - if specified, only the named fields
will be included in the data returned
... | [
"Generate",
"a",
"dictionary",
"based",
"on",
"the",
"data",
"in",
"an",
"XmlObject",
"instance",
"to",
"pass",
"as",
"a",
"Form",
"s",
"initial",
"keyword",
"argument",
"."
] | 17d71c7d98c0cebda9932b7f13e72093805e1fe2 | https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/forms/xmlobject.py#L317-L354 |
46,959 | emory-libraries/eulxml | eulxml/forms/xmlobject.py | XmlObjectForm.update_instance | def update_instance(self):
"""Save bound form data into the XmlObject model instance and return the
updated instance."""
# NOTE: django model form has a save method - not applicable here,
# since an XmlObject by itself is not expected to have a save method
# (only likely to be s... | python | def update_instance(self):
"""Save bound form data into the XmlObject model instance and return the
updated instance."""
# NOTE: django model form has a save method - not applicable here,
# since an XmlObject by itself is not expected to have a save method
# (only likely to be s... | [
"def",
"update_instance",
"(",
"self",
")",
":",
"# NOTE: django model form has a save method - not applicable here,",
"# since an XmlObject by itself is not expected to have a save method",
"# (only likely to be saved in context of a fedora or exist object)",
"if",
"hasattr",
"(",
"self",
... | Save bound form data into the XmlObject model instance and return the
updated instance. | [
"Save",
"bound",
"form",
"data",
"into",
"the",
"XmlObject",
"model",
"instance",
"and",
"return",
"the",
"updated",
"instance",
"."
] | 17d71c7d98c0cebda9932b7f13e72093805e1fe2 | https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/forms/xmlobject.py#L546-L593 |
46,960 | emory-libraries/eulxml | eulxml/forms/xmlobject.py | XmlObjectForm._update_subinstance | def _update_subinstance(self, name, subform):
"""Save bound data for a single subform into the XmlObject model
instance."""
old_subinstance = getattr(self.instance, name)
new_subinstance = subform.update_instance()
# if our instance previously had no node for the subform AND the... | python | def _update_subinstance(self, name, subform):
"""Save bound data for a single subform into the XmlObject model
instance."""
old_subinstance = getattr(self.instance, name)
new_subinstance = subform.update_instance()
# if our instance previously had no node for the subform AND the... | [
"def",
"_update_subinstance",
"(",
"self",
",",
"name",
",",
"subform",
")",
":",
"old_subinstance",
"=",
"getattr",
"(",
"self",
".",
"instance",
",",
"name",
")",
"new_subinstance",
"=",
"subform",
".",
"update_instance",
"(",
")",
"# if our instance previousl... | Save bound data for a single subform into the XmlObject model
instance. | [
"Save",
"bound",
"data",
"for",
"a",
"single",
"subform",
"into",
"the",
"XmlObject",
"model",
"instance",
"."
] | 17d71c7d98c0cebda9932b7f13e72093805e1fe2 | https://github.com/emory-libraries/eulxml/blob/17d71c7d98c0cebda9932b7f13e72093805e1fe2/eulxml/forms/xmlobject.py#L595-L609 |
46,961 | blockstack/virtualchain | virtualchain/lib/blockchain/session.py | create_bitcoind_connection | def create_bitcoind_connection( rpc_username, rpc_password, server, port, use_https, timeout ):
"""
Creates an RPC client to a bitcoind instance.
It will have ".opts" defined as a member, which will be a dict that stores the above connection options.
"""
from .bitcoin_blockchain import AuthServ... | python | def create_bitcoind_connection( rpc_username, rpc_password, server, port, use_https, timeout ):
"""
Creates an RPC client to a bitcoind instance.
It will have ".opts" defined as a member, which will be a dict that stores the above connection options.
"""
from .bitcoin_blockchain import AuthServ... | [
"def",
"create_bitcoind_connection",
"(",
"rpc_username",
",",
"rpc_password",
",",
"server",
",",
"port",
",",
"use_https",
",",
"timeout",
")",
":",
"from",
".",
"bitcoin_blockchain",
"import",
"AuthServiceProxy",
"global",
"do_wrap_socket",
",",
"create_ssl_authpro... | Creates an RPC client to a bitcoind instance.
It will have ".opts" defined as a member, which will be a dict that stores the above connection options. | [
"Creates",
"an",
"RPC",
"client",
"to",
"a",
"bitcoind",
"instance",
".",
"It",
"will",
"have",
".",
"opts",
"defined",
"as",
"a",
"member",
"which",
"will",
"be",
"a",
"dict",
"that",
"stores",
"the",
"above",
"connection",
"options",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/session.py#L94-L148 |
46,962 | blockstack/virtualchain | virtualchain/lib/blockchain/session.py | connect_bitcoind_impl | def connect_bitcoind_impl( bitcoind_opts ):
"""
Create a connection to bitcoind, using a dict of config options.
"""
if 'bitcoind_port' not in bitcoind_opts.keys() or bitcoind_opts['bitcoind_port'] is None:
log.error("No port given")
raise ValueError("No RPC port given (bitcoind_port)")... | python | def connect_bitcoind_impl( bitcoind_opts ):
"""
Create a connection to bitcoind, using a dict of config options.
"""
if 'bitcoind_port' not in bitcoind_opts.keys() or bitcoind_opts['bitcoind_port'] is None:
log.error("No port given")
raise ValueError("No RPC port given (bitcoind_port)")... | [
"def",
"connect_bitcoind_impl",
"(",
"bitcoind_opts",
")",
":",
"if",
"'bitcoind_port'",
"not",
"in",
"bitcoind_opts",
".",
"keys",
"(",
")",
"or",
"bitcoind_opts",
"[",
"'bitcoind_port'",
"]",
"is",
"None",
":",
"log",
".",
"error",
"(",
"\"No port given\"",
... | Create a connection to bitcoind, using a dict of config options. | [
"Create",
"a",
"connection",
"to",
"bitcoind",
"using",
"a",
"dict",
"of",
"config",
"options",
"."
] | fcfc970064ca7dfcab26ebd3ab955870a763ea39 | https://github.com/blockstack/virtualchain/blob/fcfc970064ca7dfcab26ebd3ab955870a763ea39/virtualchain/lib/blockchain/session.py#L151-L178 |
46,963 | 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 |
46,964 | 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 |
46,965 | 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 |
46,966 | 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 |
46,967 | 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 |
46,968 | 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 |
46,969 | 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 |
46,970 | 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 |
46,971 | 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 |
46,972 | 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 |
46,973 | 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 |
46,974 | 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 |
46,975 | 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 |
46,976 | 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 |
46,977 | 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 |
46,978 | 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 |
46,979 | 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 |
46,980 | 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 |
46,981 | 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 |
46,982 | 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 |
46,983 | 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 |
46,984 | 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 |
46,985 | 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 |
46,986 | 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 |
46,987 | 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 |
46,988 | 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 |
46,989 | 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 |
46,990 | 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 |
46,991 | 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 |
46,992 | 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 |
46,993 | 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 |
46,994 | 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 |
46,995 | 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 |
46,996 | 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 |
46,997 | 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 |
46,998 | 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 |
46,999 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.