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
225,400
pymc-devs/pymc
pymc/distributions.py
multivariate_hypergeometric_expval
def multivariate_hypergeometric_expval(n, m): """ Expected value of multivariate hypergeometric distribution. Parameters: - `n` : Number of draws. - `m` : Number of items in each categoy. """ m = np.asarray(m, float) return n * (m / m.sum())
python
def multivariate_hypergeometric_expval(n, m): """ Expected value of multivariate hypergeometric distribution. Parameters: - `n` : Number of draws. - `m` : Number of items in each categoy. """ m = np.asarray(m, float) return n * (m / m.sum())
[ "def", "multivariate_hypergeometric_expval", "(", "n", ",", "m", ")", ":", "m", "=", "np", ".", "asarray", "(", "m", ",", "float", ")", "return", "n", "*", "(", "m", "/", "m", ".", "sum", "(", ")", ")" ]
Expected value of multivariate hypergeometric distribution. Parameters: - `n` : Number of draws. - `m` : Number of items in each categoy.
[ "Expected", "value", "of", "multivariate", "hypergeometric", "distribution", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L1866-L1875
225,401
pymc-devs/pymc
pymc/distributions.py
mv_normal_like
def mv_normal_like(x, mu, tau): R""" Multivariate normal log-likelihood .. math:: f(x \mid \pi, T) = \frac{|T|^{1/2}}{(2\pi)^{1/2}} \exp\left\{ -\frac{1}{2} (x-\mu)^{\prime}T(x-\mu) \right\} :Parameters: - `x` : (n,k) - `mu` : (k) Location parameter sequence. - `Tau` : (k,k) ...
python
def mv_normal_like(x, mu, tau): R""" Multivariate normal log-likelihood .. math:: f(x \mid \pi, T) = \frac{|T|^{1/2}}{(2\pi)^{1/2}} \exp\left\{ -\frac{1}{2} (x-\mu)^{\prime}T(x-\mu) \right\} :Parameters: - `x` : (n,k) - `mu` : (k) Location parameter sequence. - `Tau` : (k,k) ...
[ "def", "mv_normal_like", "(", "x", ",", "mu", ",", "tau", ")", ":", "# TODO: Vectorize in Fortran", "if", "len", "(", "np", ".", "shape", "(", "x", ")", ")", ">", "1", ":", "return", "np", ".", "sum", "(", "[", "flib", ".", "prec_mvnorm", "(", "r",...
R""" Multivariate normal log-likelihood .. math:: f(x \mid \pi, T) = \frac{|T|^{1/2}}{(2\pi)^{1/2}} \exp\left\{ -\frac{1}{2} (x-\mu)^{\prime}T(x-\mu) \right\} :Parameters: - `x` : (n,k) - `mu` : (k) Location parameter sequence. - `Tau` : (k,k) Positive definite precision matrix. ...
[ "R", "Multivariate", "normal", "log", "-", "likelihood" ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L1939-L1958
225,402
pymc-devs/pymc
pymc/distributions.py
mv_normal_cov_like
def mv_normal_cov_like(x, mu, C): R""" Multivariate normal log-likelihood parameterized by a covariance matrix. .. math:: f(x \mid \pi, C) = \frac{1}{(2\pi|C|)^{1/2}} \exp\left\{ -\frac{1}{2} (x-\mu)^{\prime}C^{-1}(x-\mu) \right\} :Parameters: - `x` : (n,k) - `mu` : (k) Locatio...
python
def mv_normal_cov_like(x, mu, C): R""" Multivariate normal log-likelihood parameterized by a covariance matrix. .. math:: f(x \mid \pi, C) = \frac{1}{(2\pi|C|)^{1/2}} \exp\left\{ -\frac{1}{2} (x-\mu)^{\prime}C^{-1}(x-\mu) \right\} :Parameters: - `x` : (n,k) - `mu` : (k) Locatio...
[ "def", "mv_normal_cov_like", "(", "x", ",", "mu", ",", "C", ")", ":", "# TODO: Vectorize in Fortran", "if", "len", "(", "np", ".", "shape", "(", "x", ")", ")", ">", "1", ":", "return", "np", ".", "sum", "(", "[", "flib", ".", "cov_mvnorm", "(", "r"...
R""" Multivariate normal log-likelihood parameterized by a covariance matrix. .. math:: f(x \mid \pi, C) = \frac{1}{(2\pi|C|)^{1/2}} \exp\left\{ -\frac{1}{2} (x-\mu)^{\prime}C^{-1}(x-\mu) \right\} :Parameters: - `x` : (n,k) - `mu` : (k) Location parameter. - `C` : (k,k) Posit...
[ "R", "Multivariate", "normal", "log", "-", "likelihood", "parameterized", "by", "a", "covariance", "matrix", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L1982-L2002
225,403
pymc-devs/pymc
pymc/distributions.py
mv_normal_chol_like
def mv_normal_chol_like(x, mu, sig): R""" Multivariate normal log-likelihood. .. math:: f(x \mid \pi, \sigma) = \frac{1}{(2\pi)^{1/2}|\sigma|)} \exp\left\{ -\frac{1}{2} (x-\mu)^{\prime}(\sigma \sigma^{\prime})^{-1}(x-\mu) \right\} :Parameters: - `x` : (n,k) - `mu` : (k) Location pa...
python
def mv_normal_chol_like(x, mu, sig): R""" Multivariate normal log-likelihood. .. math:: f(x \mid \pi, \sigma) = \frac{1}{(2\pi)^{1/2}|\sigma|)} \exp\left\{ -\frac{1}{2} (x-\mu)^{\prime}(\sigma \sigma^{\prime})^{-1}(x-\mu) \right\} :Parameters: - `x` : (n,k) - `mu` : (k) Location pa...
[ "def", "mv_normal_chol_like", "(", "x", ",", "mu", ",", "sig", ")", ":", "# TODO: Vectorize in Fortran", "if", "len", "(", "np", ".", "shape", "(", "x", ")", ")", ">", "1", ":", "return", "np", ".", "sum", "(", "[", "flib", ".", "chol_mvnorm", "(", ...
R""" Multivariate normal log-likelihood. .. math:: f(x \mid \pi, \sigma) = \frac{1}{(2\pi)^{1/2}|\sigma|)} \exp\left\{ -\frac{1}{2} (x-\mu)^{\prime}(\sigma \sigma^{\prime})^{-1}(x-\mu) \right\} :Parameters: - `x` : (n,k) - `mu` : (k) Location parameter. - `sigma` : (k,k) Lower tr...
[ "R", "Multivariate", "normal", "log", "-", "likelihood", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2041-L2060
225,404
pymc-devs/pymc
pymc/distributions.py
rnegative_binomial
def rnegative_binomial(mu, alpha, size=None): """ Random negative binomial variates. """ # Using gamma-poisson mixture rather than numpy directly # because numpy apparently rounds mu = np.asarray(mu, dtype=float) pois_mu = np.random.gamma(alpha, mu / alpha, size) return np.random.poisson...
python
def rnegative_binomial(mu, alpha, size=None): """ Random negative binomial variates. """ # Using gamma-poisson mixture rather than numpy directly # because numpy apparently rounds mu = np.asarray(mu, dtype=float) pois_mu = np.random.gamma(alpha, mu / alpha, size) return np.random.poisson...
[ "def", "rnegative_binomial", "(", "mu", ",", "alpha", ",", "size", "=", "None", ")", ":", "# Using gamma-poisson mixture rather than numpy directly", "# because numpy apparently rounds", "mu", "=", "np", ".", "asarray", "(", "mu", ",", "dtype", "=", "float", ")", ...
Random negative binomial variates.
[ "Random", "negative", "binomial", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2065-L2073
225,405
pymc-devs/pymc
pymc/distributions.py
negative_binomial_like
def negative_binomial_like(x, mu, alpha): R""" Negative binomial log-likelihood. The negative binomial distribution describes a Poisson random variable whose rate parameter is gamma distributed. PyMC's chosen parameterization is based on this mixture interpretation. .. math:: f(x \...
python
def negative_binomial_like(x, mu, alpha): R""" Negative binomial log-likelihood. The negative binomial distribution describes a Poisson random variable whose rate parameter is gamma distributed. PyMC's chosen parameterization is based on this mixture interpretation. .. math:: f(x \...
[ "def", "negative_binomial_like", "(", "x", ",", "mu", ",", "alpha", ")", ":", "alpha", "=", "np", ".", "array", "(", "alpha", ")", "if", "(", "alpha", ">", "1e10", ")", ".", "any", "(", ")", ":", "if", "(", "alpha", ">", "1e10", ")", ".", "all"...
R""" Negative binomial log-likelihood. The negative binomial distribution describes a Poisson random variable whose rate parameter is gamma distributed. PyMC's chosen parameterization is based on this mixture interpretation. .. math:: f(x \mid \mu, \alpha) = \frac{\Gamma(x+\alpha)}{x! ...
[ "R", "Negative", "binomial", "log", "-", "likelihood", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2084-L2119
225,406
pymc-devs/pymc
pymc/distributions.py
rnormal
def rnormal(mu, tau, size=None): """ Random normal variates. """ return np.random.normal(mu, 1. / np.sqrt(tau), size)
python
def rnormal(mu, tau, size=None): """ Random normal variates. """ return np.random.normal(mu, 1. / np.sqrt(tau), size)
[ "def", "rnormal", "(", "mu", ",", "tau", ",", "size", "=", "None", ")", ":", "return", "np", ".", "random", ".", "normal", "(", "mu", ",", "1.", "/", "np", ".", "sqrt", "(", "tau", ")", ",", "size", ")" ]
Random normal variates.
[ "Random", "normal", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2128-L2132
225,407
pymc-devs/pymc
pymc/distributions.py
rvon_mises
def rvon_mises(mu, kappa, size=None): """ Random von Mises variates. """ # TODO: Just return straight from numpy after release 1.3 return (np.random.mtrand.vonmises( mu, kappa, size) + np.pi) % (2. * np.pi) - np.pi
python
def rvon_mises(mu, kappa, size=None): """ Random von Mises variates. """ # TODO: Just return straight from numpy after release 1.3 return (np.random.mtrand.vonmises( mu, kappa, size) + np.pi) % (2. * np.pi) - np.pi
[ "def", "rvon_mises", "(", "mu", ",", "kappa", ",", "size", "=", "None", ")", ":", "# TODO: Just return straight from numpy after release 1.3", "return", "(", "np", ".", "random", ".", "mtrand", ".", "vonmises", "(", "mu", ",", "kappa", ",", "size", ")", "+",...
Random von Mises variates.
[ "Random", "von", "Mises", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2191-L2197
225,408
pymc-devs/pymc
pymc/distributions.py
rtruncated_pareto
def rtruncated_pareto(alpha, m, b, size=None): """ Random bounded Pareto variates. """ u = random_number(size) return (-(u * b ** alpha - u * m ** alpha - b ** alpha) / (b ** alpha * m ** alpha)) ** (-1. / alpha)
python
def rtruncated_pareto(alpha, m, b, size=None): """ Random bounded Pareto variates. """ u = random_number(size) return (-(u * b ** alpha - u * m ** alpha - b ** alpha) / (b ** alpha * m ** alpha)) ** (-1. / alpha)
[ "def", "rtruncated_pareto", "(", "alpha", ",", "m", ",", "b", ",", "size", "=", "None", ")", ":", "u", "=", "random_number", "(", "size", ")", "return", "(", "-", "(", "u", "*", "b", "**", "alpha", "-", "u", "*", "m", "**", "alpha", "-", "b", ...
Random bounded Pareto variates.
[ "Random", "bounded", "Pareto", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2274-L2280
225,409
pymc-devs/pymc
pymc/distributions.py
truncated_pareto_expval
def truncated_pareto_expval(alpha, m, b): """ Expected value of truncated Pareto distribution. """ if alpha <= 1: return inf part1 = (m ** alpha) / (1. - (m / b) ** alpha) part2 = 1. * alpha / (alpha - 1) part3 = (1. / (m ** (alpha - 1)) - 1. / (b ** (alpha - 1.))) return part1 ...
python
def truncated_pareto_expval(alpha, m, b): """ Expected value of truncated Pareto distribution. """ if alpha <= 1: return inf part1 = (m ** alpha) / (1. - (m / b) ** alpha) part2 = 1. * alpha / (alpha - 1) part3 = (1. / (m ** (alpha - 1)) - 1. / (b ** (alpha - 1.))) return part1 ...
[ "def", "truncated_pareto_expval", "(", "alpha", ",", "m", ",", "b", ")", ":", "if", "alpha", "<=", "1", ":", "return", "inf", "part1", "=", "(", "m", "**", "alpha", ")", "/", "(", "1.", "-", "(", "m", "/", "b", ")", "**", "alpha", ")", "part2",...
Expected value of truncated Pareto distribution.
[ "Expected", "value", "of", "truncated", "Pareto", "distribution", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2283-L2293
225,410
pymc-devs/pymc
pymc/distributions.py
rtruncated_poisson
def rtruncated_poisson(mu, k, size=None): """ Random truncated Poisson variates with minimum value k, generated using rejection sampling. """ # Calculate m try: m = max(0, np.floor(k - mu)) except (TypeError, ValueError): # More than one mu return np.array([rtruncate...
python
def rtruncated_poisson(mu, k, size=None): """ Random truncated Poisson variates with minimum value k, generated using rejection sampling. """ # Calculate m try: m = max(0, np.floor(k - mu)) except (TypeError, ValueError): # More than one mu return np.array([rtruncate...
[ "def", "rtruncated_poisson", "(", "mu", ",", "k", ",", "size", "=", "None", ")", ":", "# Calculate m", "try", ":", "m", "=", "max", "(", "0", ",", "np", ".", "floor", "(", "k", "-", "mu", ")", ")", "except", "(", "TypeError", ",", "ValueError", "...
Random truncated Poisson variates with minimum value k, generated using rejection sampling.
[ "Random", "truncated", "Poisson", "variates", "with", "minimum", "value", "k", "generated", "using", "rejection", "sampling", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2365-L2404
225,411
pymc-devs/pymc
pymc/distributions.py
rtruncated_normal
def rtruncated_normal(mu, tau, a=-np.inf, b=np.inf, size=None): """ Random truncated normal variates. """ sigma = 1. / np.sqrt(tau) na = utils.normcdf((a - mu) / sigma) nb = utils.normcdf((b - mu) / sigma) # Use the inverse CDF generation method. U = np.random.mtrand.uniform(size=size)...
python
def rtruncated_normal(mu, tau, a=-np.inf, b=np.inf, size=None): """ Random truncated normal variates. """ sigma = 1. / np.sqrt(tau) na = utils.normcdf((a - mu) / sigma) nb = utils.normcdf((b - mu) / sigma) # Use the inverse CDF generation method. U = np.random.mtrand.uniform(size=size)...
[ "def", "rtruncated_normal", "(", "mu", ",", "tau", ",", "a", "=", "-", "np", ".", "inf", ",", "b", "=", "np", ".", "inf", ",", "size", "=", "None", ")", ":", "sigma", "=", "1.", "/", "np", ".", "sqrt", "(", "tau", ")", "na", "=", "utils", "...
Random truncated normal variates.
[ "Random", "truncated", "normal", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2447-L2462
225,412
pymc-devs/pymc
pymc/distributions.py
truncated_normal_expval
def truncated_normal_expval(mu, tau, a, b): """Expected value of the truncated normal distribution. .. math:: E(X) =\mu + \frac{\sigma(\varphi_1-\varphi_2)}{T} where .. math:: T & =\Phi\left(\frac{B-\mu}{\sigma}\right)-\Phi \left(\frac{A-\mu}{\sigma}\right)\text \\ \varph...
python
def truncated_normal_expval(mu, tau, a, b): """Expected value of the truncated normal distribution. .. math:: E(X) =\mu + \frac{\sigma(\varphi_1-\varphi_2)}{T} where .. math:: T & =\Phi\left(\frac{B-\mu}{\sigma}\right)-\Phi \left(\frac{A-\mu}{\sigma}\right)\text \\ \varph...
[ "def", "truncated_normal_expval", "(", "mu", ",", "tau", ",", "a", ",", "b", ")", ":", "phia", "=", "np", ".", "exp", "(", "normal_like", "(", "a", ",", "mu", ",", "tau", ")", ")", "phib", "=", "np", ".", "exp", "(", "normal_like", "(", "b", ",...
Expected value of the truncated normal distribution. .. math:: E(X) =\mu + \frac{\sigma(\varphi_1-\varphi_2)}{T} where .. math:: T & =\Phi\left(\frac{B-\mu}{\sigma}\right)-\Phi \left(\frac{A-\mu}{\sigma}\right)\text \\ \varphi_1 &= \varphi\left(\frac{A-\mu}{\sigma}\rig...
[ "Expected", "value", "of", "the", "truncated", "normal", "distribution", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2467-L2501
225,413
pymc-devs/pymc
pymc/distributions.py
truncated_normal_like
def truncated_normal_like(x, mu, tau, a=None, b=None): R""" Truncated normal log-likelihood. .. math:: f(x \mid \mu, \tau, a, b) = \frac{\phi(\frac{x-\mu}{\sigma})} {\Phi(\frac{b-\mu}{\sigma}) - \Phi(\frac{a-\mu}{\sigma})}, where :math:`\sigma^2=1/\tau`, `\phi` is the standard normal PDF and `...
python
def truncated_normal_like(x, mu, tau, a=None, b=None): R""" Truncated normal log-likelihood. .. math:: f(x \mid \mu, \tau, a, b) = \frac{\phi(\frac{x-\mu}{\sigma})} {\Phi(\frac{b-\mu}{\sigma}) - \Phi(\frac{a-\mu}{\sigma})}, where :math:`\sigma^2=1/\tau`, `\phi` is the standard normal PDF and `...
[ "def", "truncated_normal_like", "(", "x", ",", "mu", ",", "tau", ",", "a", "=", "None", ",", "b", "=", "None", ")", ":", "x", "=", "np", ".", "atleast_1d", "(", "x", ")", "if", "a", "is", "None", ":", "a", "=", "-", "np", ".", "inf", "a", "...
R""" Truncated normal log-likelihood. .. math:: f(x \mid \mu, \tau, a, b) = \frac{\phi(\frac{x-\mu}{\sigma})} {\Phi(\frac{b-\mu}{\sigma}) - \Phi(\frac{a-\mu}{\sigma})}, where :math:`\sigma^2=1/\tau`, `\phi` is the standard normal PDF and `\Phi` is the standard normal CDF. :Parameters: -...
[ "R", "Truncated", "normal", "log", "-", "likelihood", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2506-L2549
225,414
pymc-devs/pymc
pymc/distributions.py
rskew_normal
def rskew_normal(mu, tau, alpha, size=()): """ Skew-normal random variates. """ size_ = size or (1,) len_ = np.prod(size_) return flib.rskewnorm( len_, mu, tau, alpha, np.random.normal(size=2 * len_)).reshape(size)
python
def rskew_normal(mu, tau, alpha, size=()): """ Skew-normal random variates. """ size_ = size or (1,) len_ = np.prod(size_) return flib.rskewnorm( len_, mu, tau, alpha, np.random.normal(size=2 * len_)).reshape(size)
[ "def", "rskew_normal", "(", "mu", ",", "tau", ",", "alpha", ",", "size", "=", "(", ")", ")", ":", "size_", "=", "size", "or", "(", "1", ",", ")", "len_", "=", "np", ".", "prod", "(", "size_", ")", "return", "flib", ".", "rskewnorm", "(", "len_"...
Skew-normal random variates.
[ "Skew", "-", "normal", "random", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2557-L2564
225,415
pymc-devs/pymc
pymc/distributions.py
skew_normal_expval
def skew_normal_expval(mu, tau, alpha): """ Expectation of skew-normal random variables. """ delta = alpha / np.sqrt(1. + alpha ** 2) return mu + np.sqrt(2 / pi / tau) * delta
python
def skew_normal_expval(mu, tau, alpha): """ Expectation of skew-normal random variables. """ delta = alpha / np.sqrt(1. + alpha ** 2) return mu + np.sqrt(2 / pi / tau) * delta
[ "def", "skew_normal_expval", "(", "mu", ",", "tau", ",", "alpha", ")", ":", "delta", "=", "alpha", "/", "np", ".", "sqrt", "(", "1.", "+", "alpha", "**", "2", ")", "return", "mu", "+", "np", ".", "sqrt", "(", "2", "/", "pi", "/", "tau", ")", ...
Expectation of skew-normal random variables.
[ "Expectation", "of", "skew", "-", "normal", "random", "variables", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2567-L2572
225,416
pymc-devs/pymc
pymc/distributions.py
skew_normal_like
def skew_normal_like(x, mu, tau, alpha): R""" Azzalini's skew-normal log-likelihood .. math:: f(x \mid \mu, \tau, \alpha) = 2 \Phi((x-\mu)\sqrt{\tau}\alpha) \phi(x,\mu,\tau) where :math:\Phi is the normal CDF and :math: \phi is the normal PDF. :Parameters: - `x` : Input data. ...
python
def skew_normal_like(x, mu, tau, alpha): R""" Azzalini's skew-normal log-likelihood .. math:: f(x \mid \mu, \tau, \alpha) = 2 \Phi((x-\mu)\sqrt{\tau}\alpha) \phi(x,\mu,\tau) where :math:\Phi is the normal CDF and :math: \phi is the normal PDF. :Parameters: - `x` : Input data. ...
[ "def", "skew_normal_like", "(", "x", ",", "mu", ",", "tau", ",", "alpha", ")", ":", "return", "flib", ".", "sn_like", "(", "x", ",", "mu", ",", "tau", ",", "alpha", ")" ]
R""" Azzalini's skew-normal log-likelihood .. math:: f(x \mid \mu, \tau, \alpha) = 2 \Phi((x-\mu)\sqrt{\tau}\alpha) \phi(x,\mu,\tau) where :math:\Phi is the normal CDF and :math: \phi is the normal PDF. :Parameters: - `x` : Input data. - `mu` : Mean of the distribution. - `t...
[ "R", "Azzalini", "s", "skew", "-", "normal", "log", "-", "likelihood" ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2575-L2593
225,417
pymc-devs/pymc
pymc/distributions.py
rt
def rt(nu, size=None): """ Student's t random variates. """ return rnormal(0, 1, size) / np.sqrt(rchi2(nu, size) / nu)
python
def rt(nu, size=None): """ Student's t random variates. """ return rnormal(0, 1, size) / np.sqrt(rchi2(nu, size) / nu)
[ "def", "rt", "(", "nu", ",", "size", "=", "None", ")", ":", "return", "rnormal", "(", "0", ",", "1", ",", "size", ")", "/", "np", ".", "sqrt", "(", "rchi2", "(", "nu", ",", "size", ")", "/", "nu", ")" ]
Student's t random variates.
[ "Student", "s", "t", "random", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2598-L2602
225,418
pymc-devs/pymc
pymc/distributions.py
t_like
def t_like(x, nu): R""" Student's T log-likelihood. Describes a zero-mean normal variable whose precision is gamma distributed. Alternatively, describes the mean of several zero-mean normal random variables divided by their sample standard deviation. .. math:: f(x \mid \nu) = \frac...
python
def t_like(x, nu): R""" Student's T log-likelihood. Describes a zero-mean normal variable whose precision is gamma distributed. Alternatively, describes the mean of several zero-mean normal random variables divided by their sample standard deviation. .. math:: f(x \mid \nu) = \frac...
[ "def", "t_like", "(", "x", ",", "nu", ")", ":", "nu", "=", "np", ".", "asarray", "(", "nu", ")", "return", "flib", ".", "t", "(", "x", ",", "nu", ")" ]
R""" Student's T log-likelihood. Describes a zero-mean normal variable whose precision is gamma distributed. Alternatively, describes the mean of several zero-mean normal random variables divided by their sample standard deviation. .. math:: f(x \mid \nu) = \frac{\Gamma(\frac{\nu+1}{2}...
[ "R", "Student", "s", "T", "log", "-", "likelihood", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2612-L2630
225,419
pymc-devs/pymc
pymc/distributions.py
rnoncentral_t
def rnoncentral_t(mu, lam, nu, size=None): """ Non-central Student's t random variates. """ tau = rgamma(nu / 2., nu / (2. * lam), size) return rnormal(mu, tau)
python
def rnoncentral_t(mu, lam, nu, size=None): """ Non-central Student's t random variates. """ tau = rgamma(nu / 2., nu / (2. * lam), size) return rnormal(mu, tau)
[ "def", "rnoncentral_t", "(", "mu", ",", "lam", ",", "nu", ",", "size", "=", "None", ")", ":", "tau", "=", "rgamma", "(", "nu", "/", "2.", ",", "nu", "/", "(", "2.", "*", "lam", ")", ",", "size", ")", "return", "rnormal", "(", "mu", ",", "tau"...
Non-central Student's t random variates.
[ "Non", "-", "central", "Student", "s", "t", "random", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2636-L2641
225,420
pymc-devs/pymc
pymc/distributions.py
noncentral_t_like
def noncentral_t_like(x, mu, lam, nu): R""" Non-central Student's T log-likelihood. Describes a normal variable whose precision is gamma distributed. .. math:: f(x|\mu,\lambda,\nu) = \frac{\Gamma(\frac{\nu + 1}{2})}{\Gamma(\frac{\nu}{2})} \left(\frac{\lambda}{\pi\nu}\right)^{\f...
python
def noncentral_t_like(x, mu, lam, nu): R""" Non-central Student's T log-likelihood. Describes a normal variable whose precision is gamma distributed. .. math:: f(x|\mu,\lambda,\nu) = \frac{\Gamma(\frac{\nu + 1}{2})}{\Gamma(\frac{\nu}{2})} \left(\frac{\lambda}{\pi\nu}\right)^{\f...
[ "def", "noncentral_t_like", "(", "x", ",", "mu", ",", "lam", ",", "nu", ")", ":", "mu", "=", "np", ".", "asarray", "(", "mu", ")", "lam", "=", "np", ".", "asarray", "(", "lam", ")", "nu", "=", "np", ".", "asarray", "(", "nu", ")", "return", "...
R""" Non-central Student's T log-likelihood. Describes a normal variable whose precision is gamma distributed. .. math:: f(x|\mu,\lambda,\nu) = \frac{\Gamma(\frac{\nu + 1}{2})}{\Gamma(\frac{\nu}{2})} \left(\frac{\lambda}{\pi\nu}\right)^{\frac{1}{2}} \left[1+\frac{\lambda(x-...
[ "R", "Non", "-", "central", "Student", "s", "T", "log", "-", "likelihood", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2655-L2677
225,421
pymc-devs/pymc
pymc/distributions.py
rdiscrete_uniform
def rdiscrete_uniform(lower, upper, size=None): """ Random discrete_uniform variates. """ return np.random.randint(lower, upper + 1, size)
python
def rdiscrete_uniform(lower, upper, size=None): """ Random discrete_uniform variates. """ return np.random.randint(lower, upper + 1, size)
[ "def", "rdiscrete_uniform", "(", "lower", ",", "upper", ",", "size", "=", "None", ")", ":", "return", "np", ".", "random", ".", "randint", "(", "lower", ",", "upper", "+", "1", ",", "size", ")" ]
Random discrete_uniform variates.
[ "Random", "discrete_uniform", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2691-L2695
225,422
pymc-devs/pymc
pymc/distributions.py
runiform
def runiform(lower, upper, size=None): """ Random uniform variates. """ return np.random.uniform(lower, upper, size)
python
def runiform(lower, upper, size=None): """ Random uniform variates. """ return np.random.uniform(lower, upper, size)
[ "def", "runiform", "(", "lower", ",", "upper", ",", "size", "=", "None", ")", ":", "return", "np", ".", "random", ".", "uniform", "(", "lower", ",", "upper", ",", "size", ")" ]
Random uniform variates.
[ "Random", "uniform", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2723-L2727
225,423
pymc-devs/pymc
pymc/distributions.py
rweibull
def rweibull(alpha, beta, size=None): """ Weibull random variates. """ tmp = -np.log(runiform(0, 1, size)) return beta * (tmp ** (1. / alpha))
python
def rweibull(alpha, beta, size=None): """ Weibull random variates. """ tmp = -np.log(runiform(0, 1, size)) return beta * (tmp ** (1. / alpha))
[ "def", "rweibull", "(", "alpha", ",", "beta", ",", "size", "=", "None", ")", ":", "tmp", "=", "-", "np", ".", "log", "(", "runiform", "(", "0", ",", "1", ",", "size", ")", ")", "return", "beta", "*", "(", "tmp", "**", "(", "1.", "/", "alpha",...
Weibull random variates.
[ "Weibull", "random", "variates", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2761-L2766
225,424
pymc-devs/pymc
pymc/distributions.py
rwishart_cov
def rwishart_cov(n, C): """ Return a Wishart random matrix. :Parameters: n : int Degrees of freedom, > 0. C : matrix Symmetric and positive definite """ # return rwishart(n, np.linalg.inv(C)) p = np.shape(C)[0] # Need cholesky decomposition of precision matrix C...
python
def rwishart_cov(n, C): """ Return a Wishart random matrix. :Parameters: n : int Degrees of freedom, > 0. C : matrix Symmetric and positive definite """ # return rwishart(n, np.linalg.inv(C)) p = np.shape(C)[0] # Need cholesky decomposition of precision matrix C...
[ "def", "rwishart_cov", "(", "n", ",", "C", ")", ":", "# return rwishart(n, np.linalg.inv(C))", "p", "=", "np", ".", "shape", "(", "C", ")", "[", "0", "]", "# Need cholesky decomposition of precision matrix C^-1?", "sig", "=", "np", ".", "linalg", ".", "cholesky"...
Return a Wishart random matrix. :Parameters: n : int Degrees of freedom, > 0. C : matrix Symmetric and positive definite
[ "Return", "a", "Wishart", "random", "matrix", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2866-L2893
225,425
pymc-devs/pymc
pymc/distributions.py
valuewrapper
def valuewrapper(f, arguments=None): """Return a likelihood accepting value instead of x as a keyword argument. This is specifically intended for the instantiator above. """ def wrapper(**kwds): value = kwds.pop('value') return f(value, **kwds) if arguments is None: wrapper....
python
def valuewrapper(f, arguments=None): """Return a likelihood accepting value instead of x as a keyword argument. This is specifically intended for the instantiator above. """ def wrapper(**kwds): value = kwds.pop('value') return f(value, **kwds) if arguments is None: wrapper....
[ "def", "valuewrapper", "(", "f", ",", "arguments", "=", "None", ")", ":", "def", "wrapper", "(", "*", "*", "kwds", ")", ":", "value", "=", "kwds", ".", "pop", "(", "'value'", ")", "return", "f", "(", "value", ",", "*", "*", "kwds", ")", "if", "...
Return a likelihood accepting value instead of x as a keyword argument. This is specifically intended for the instantiator above.
[ "Return", "a", "likelihood", "accepting", "value", "instead", "of", "x", "as", "a", "keyword", "argument", ".", "This", "is", "specifically", "intended", "for", "the", "instantiator", "above", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2968-L2981
225,426
pymc-devs/pymc
pymc/distributions.py
local_decorated_likelihoods
def local_decorated_likelihoods(obj): """ New interface likelihoods """ for name, like in six.iteritems(likelihoods): obj[name + '_like'] = gofwrapper(like, snapshot)
python
def local_decorated_likelihoods(obj): """ New interface likelihoods """ for name, like in six.iteritems(likelihoods): obj[name + '_like'] = gofwrapper(like, snapshot)
[ "def", "local_decorated_likelihoods", "(", "obj", ")", ":", "for", "name", ",", "like", "in", "six", ".", "iteritems", "(", "likelihoods", ")", ":", "obj", "[", "name", "+", "'_like'", "]", "=", "gofwrapper", "(", "like", ",", "snapshot", ")" ]
New interface likelihoods
[ "New", "interface", "likelihoods" ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2994-L3000
225,427
pymc-devs/pymc
pymc/distributions.py
_inject_dist
def _inject_dist(distname, kwargs={}, ns=locals()): """ Reusable function to inject Stochastic subclasses into module namespace """ dist_logp, dist_random, grad_logp = name_to_funcs(distname, ns) classname = capitalize(distname) ns[classname] = stochastic_from_dist(distname, dist_logp, ...
python
def _inject_dist(distname, kwargs={}, ns=locals()): """ Reusable function to inject Stochastic subclasses into module namespace """ dist_logp, dist_random, grad_logp = name_to_funcs(distname, ns) classname = capitalize(distname) ns[classname] = stochastic_from_dist(distname, dist_logp, ...
[ "def", "_inject_dist", "(", "distname", ",", "kwargs", "=", "{", "}", ",", "ns", "=", "locals", "(", ")", ")", ":", "dist_logp", ",", "dist_random", ",", "grad_logp", "=", "name_to_funcs", "(", "distname", ",", "ns", ")", "classname", "=", "capitalize", ...
Reusable function to inject Stochastic subclasses into module namespace
[ "Reusable", "function", "to", "inject", "Stochastic", "subclasses", "into", "module", "namespace" ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L3009-L3019
225,428
pymc-devs/pymc
pymc/distributions.py
mod_categorical_expval
def mod_categorical_expval(p): """ Expected value of categorical distribution with parent p of length k-1. An implicit k'th category is assumed to exist with associated probability 1-sum(p). """ p = extend_dirichlet(p) return np.sum([p * i for i, p in enumerate(p)])
python
def mod_categorical_expval(p): """ Expected value of categorical distribution with parent p of length k-1. An implicit k'th category is assumed to exist with associated probability 1-sum(p). """ p = extend_dirichlet(p) return np.sum([p * i for i, p in enumerate(p)])
[ "def", "mod_categorical_expval", "(", "p", ")", ":", "p", "=", "extend_dirichlet", "(", "p", ")", "return", "np", ".", "sum", "(", "[", "p", "*", "i", "for", "i", ",", "p", "in", "enumerate", "(", "p", ")", "]", ")" ]
Expected value of categorical distribution with parent p of length k-1. An implicit k'th category is assumed to exist with associated probability 1-sum(p).
[ "Expected", "value", "of", "categorical", "distribution", "with", "parent", "p", "of", "length", "k", "-", "1", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L3104-L3112
225,429
pymc-devs/pymc
pymc/distributions.py
Impute
def Impute(name, dist_class, imputable, **parents): """ This function accomodates missing elements for the data of simple Stochastic distribution subclasses. The masked_values argument is an object of type numpy.ma.MaskedArray, which contains the raw data and a boolean mask indicating missing values...
python
def Impute(name, dist_class, imputable, **parents): """ This function accomodates missing elements for the data of simple Stochastic distribution subclasses. The masked_values argument is an object of type numpy.ma.MaskedArray, which contains the raw data and a boolean mask indicating missing values...
[ "def", "Impute", "(", "name", ",", "dist_class", ",", "imputable", ",", "*", "*", "parents", ")", ":", "dims", "=", "np", ".", "shape", "(", "imputable", ")", "masked_values", "=", "np", ".", "ravel", "(", "imputable", ")", "if", "not", "isinstance", ...
This function accomodates missing elements for the data of simple Stochastic distribution subclasses. The masked_values argument is an object of type numpy.ma.MaskedArray, which contains the raw data and a boolean mask indicating missing values. The resulting list contains a list of stochastics of type ...
[ "This", "function", "accomodates", "missing", "elements", "for", "the", "data", "of", "simple", "Stochastic", "distribution", "subclasses", ".", "The", "masked_values", "argument", "is", "an", "object", "of", "type", "numpy", ".", "ma", ".", "MaskedArray", "whic...
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L3269-L3335
225,430
pymc-devs/pymc
pymc/Node.py
logp_gradient_of_set
def logp_gradient_of_set(variable_set, calculation_set=None): """ Calculates the gradient of the joint log posterior with respect to all the variables in variable_set. Calculation of the log posterior is restricted to the variables in calculation_set. Returns a dictionary of the gradients. """ ...
python
def logp_gradient_of_set(variable_set, calculation_set=None): """ Calculates the gradient of the joint log posterior with respect to all the variables in variable_set. Calculation of the log posterior is restricted to the variables in calculation_set. Returns a dictionary of the gradients. """ ...
[ "def", "logp_gradient_of_set", "(", "variable_set", ",", "calculation_set", "=", "None", ")", ":", "logp_gradients", "=", "{", "}", "for", "variable", "in", "variable_set", ":", "logp_gradients", "[", "variable", "]", "=", "logp_gradient", "(", "variable", ",", ...
Calculates the gradient of the joint log posterior with respect to all the variables in variable_set. Calculation of the log posterior is restricted to the variables in calculation_set. Returns a dictionary of the gradients.
[ "Calculates", "the", "gradient", "of", "the", "joint", "log", "posterior", "with", "respect", "to", "all", "the", "variables", "in", "variable_set", ".", "Calculation", "of", "the", "log", "posterior", "is", "restricted", "to", "the", "variables", "in", "calcu...
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/Node.py#L42-L54
225,431
pymc-devs/pymc
pymc/Node.py
logp_gradient
def logp_gradient(variable, calculation_set=None): """ Calculates the gradient of the joint log posterior with respect to variable. Calculation of the log posterior is restricted to the variables in calculation_set. """ return variable.logp_partial_gradient(variable, calculation_set) + sum( ...
python
def logp_gradient(variable, calculation_set=None): """ Calculates the gradient of the joint log posterior with respect to variable. Calculation of the log posterior is restricted to the variables in calculation_set. """ return variable.logp_partial_gradient(variable, calculation_set) + sum( ...
[ "def", "logp_gradient", "(", "variable", ",", "calculation_set", "=", "None", ")", ":", "return", "variable", ".", "logp_partial_gradient", "(", "variable", ",", "calculation_set", ")", "+", "sum", "(", "[", "child", ".", "logp_partial_gradient", "(", "variable"...
Calculates the gradient of the joint log posterior with respect to variable. Calculation of the log posterior is restricted to the variables in calculation_set.
[ "Calculates", "the", "gradient", "of", "the", "joint", "log", "posterior", "with", "respect", "to", "variable", ".", "Calculation", "of", "the", "log", "posterior", "is", "restricted", "to", "the", "variables", "in", "calculation_set", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/Node.py#L57-L63
225,432
pymc-devs/pymc
pymc/Node.py
Variable.summary
def summary(self, alpha=0.05, start=0, batches=100, chain=None, roundto=3): """ Generate a pretty-printed summary of the node. :Parameters: alpha : float The alpha level for generating posterior intervals. Defaults to 0.05. start : int The starting...
python
def summary(self, alpha=0.05, start=0, batches=100, chain=None, roundto=3): """ Generate a pretty-printed summary of the node. :Parameters: alpha : float The alpha level for generating posterior intervals. Defaults to 0.05. start : int The starting...
[ "def", "summary", "(", "self", ",", "alpha", "=", "0.05", ",", "start", "=", "0", ",", "batches", "=", "100", ",", "chain", "=", "None", ",", "roundto", "=", "3", ")", ":", "# Calculate statistics for Node", "statdict", "=", "self", ".", "stats", "(", ...
Generate a pretty-printed summary of the node. :Parameters: alpha : float The alpha level for generating posterior intervals. Defaults to 0.05. start : int The starting index from which to summarize (each) chain. Defaults to zero. batches : int ...
[ "Generate", "a", "pretty", "-", "printed", "summary", "of", "the", "node", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/Node.py#L267-L358
225,433
pymc-devs/pymc
pymc/Container.py
file_items
def file_items(container, iterable): """ Files away objects into the appropriate attributes of the container. """ # container._value = copy(iterable) container.nodes = set() container.variables = set() container.deterministics = set() container.stochastics = set() container.potenti...
python
def file_items(container, iterable): """ Files away objects into the appropriate attributes of the container. """ # container._value = copy(iterable) container.nodes = set() container.variables = set() container.deterministics = set() container.stochastics = set() container.potenti...
[ "def", "file_items", "(", "container", ",", "iterable", ")", ":", "# container._value = copy(iterable)", "container", ".", "nodes", "=", "set", "(", ")", "container", ".", "variables", "=", "set", "(", ")", "container", ".", "deterministics", "=", "set", "(", ...
Files away objects into the appropriate attributes of the container.
[ "Files", "away", "objects", "into", "the", "appropriate", "attributes", "of", "the", "container", "." ]
c6e530210bff4c0d7189b35b2c971bc53f93f7cd
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/Container.py#L168-L248
225,434
ethereum/web3.py
web3/middleware/gas_price_strategy.py
gas_price_strategy_middleware
def gas_price_strategy_middleware(make_request, web3): """ Includes a gas price using the gas price strategy """ def middleware(method, params): if method == 'eth_sendTransaction': transaction = params[0] if 'gasPrice' not in transaction: generated_gas_pri...
python
def gas_price_strategy_middleware(make_request, web3): """ Includes a gas price using the gas price strategy """ def middleware(method, params): if method == 'eth_sendTransaction': transaction = params[0] if 'gasPrice' not in transaction: generated_gas_pri...
[ "def", "gas_price_strategy_middleware", "(", "make_request", ",", "web3", ")", ":", "def", "middleware", "(", "method", ",", "params", ")", ":", "if", "method", "==", "'eth_sendTransaction'", ":", "transaction", "=", "params", "[", "0", "]", "if", "'gasPrice'"...
Includes a gas price using the gas price strategy
[ "Includes", "a", "gas", "price", "using", "the", "gas", "price", "strategy" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/middleware/gas_price_strategy.py#L6-L19
225,435
ethereum/web3.py
web3/_utils/transactions.py
fill_transaction_defaults
def fill_transaction_defaults(web3, transaction): """ if web3 is None, fill as much as possible while offline """ defaults = {} for key, default_getter in TRANSACTION_DEFAULTS.items(): if key not in transaction: if callable(default_getter): if web3 is not None: ...
python
def fill_transaction_defaults(web3, transaction): """ if web3 is None, fill as much as possible while offline """ defaults = {} for key, default_getter in TRANSACTION_DEFAULTS.items(): if key not in transaction: if callable(default_getter): if web3 is not None: ...
[ "def", "fill_transaction_defaults", "(", "web3", ",", "transaction", ")", ":", "defaults", "=", "{", "}", "for", "key", ",", "default_getter", "in", "TRANSACTION_DEFAULTS", ".", "items", "(", ")", ":", "if", "key", "not", "in", "transaction", ":", "if", "c...
if web3 is None, fill as much as possible while offline
[ "if", "web3", "is", "None", "fill", "as", "much", "as", "possible", "while", "offline" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/transactions.py#L49-L64
225,436
ethereum/web3.py
web3/gas_strategies/time_based.py
_compute_probabilities
def _compute_probabilities(miner_data, wait_blocks, sample_size): """ Computes the probabilities that a txn will be accepted at each of the gas prices accepted by the miners. """ miner_data_by_price = tuple(sorted( miner_data, key=operator.attrgetter('low_percentile_gas_price'), ...
python
def _compute_probabilities(miner_data, wait_blocks, sample_size): """ Computes the probabilities that a txn will be accepted at each of the gas prices accepted by the miners. """ miner_data_by_price = tuple(sorted( miner_data, key=operator.attrgetter('low_percentile_gas_price'), ...
[ "def", "_compute_probabilities", "(", "miner_data", ",", "wait_blocks", ",", "sample_size", ")", ":", "miner_data_by_price", "=", "tuple", "(", "sorted", "(", "miner_data", ",", "key", "=", "operator", ".", "attrgetter", "(", "'low_percentile_gas_price'", ")", ","...
Computes the probabilities that a txn will be accepted at each of the gas prices accepted by the miners.
[ "Computes", "the", "probabilities", "that", "a", "txn", "will", "be", "accepted", "at", "each", "of", "the", "gas", "prices", "accepted", "by", "the", "miners", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/gas_strategies/time_based.py#L76-L91
225,437
ethereum/web3.py
web3/gas_strategies/time_based.py
_compute_gas_price
def _compute_gas_price(probabilities, desired_probability): """ Given a sorted range of ``Probability`` named-tuples returns a gas price computed based on where the ``desired_probability`` would fall within the range. :param probabilities: An iterable of `Probability` named-tuples sorted in reverse...
python
def _compute_gas_price(probabilities, desired_probability): """ Given a sorted range of ``Probability`` named-tuples returns a gas price computed based on where the ``desired_probability`` would fall within the range. :param probabilities: An iterable of `Probability` named-tuples sorted in reverse...
[ "def", "_compute_gas_price", "(", "probabilities", ",", "desired_probability", ")", ":", "first", "=", "probabilities", "[", "0", "]", "last", "=", "probabilities", "[", "-", "1", "]", "if", "desired_probability", ">=", "first", ".", "prob", ":", "return", "...
Given a sorted range of ``Probability`` named-tuples returns a gas price computed based on where the ``desired_probability`` would fall within the range. :param probabilities: An iterable of `Probability` named-tuples sorted in reverse order. :param desired_probability: An floating point representation...
[ "Given", "a", "sorted", "range", "of", "Probability", "named", "-", "tuples", "returns", "a", "gas", "price", "computed", "based", "on", "where", "the", "desired_probability", "would", "fall", "within", "the", "range", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/gas_strategies/time_based.py#L94-L136
225,438
ethereum/web3.py
web3/gas_strategies/time_based.py
construct_time_based_gas_price_strategy
def construct_time_based_gas_price_strategy(max_wait_seconds, sample_size=120, probability=98): """ A gas pricing strategy that uses recently mined block data to derive a gas price for which a transaction is likely to be...
python
def construct_time_based_gas_price_strategy(max_wait_seconds, sample_size=120, probability=98): """ A gas pricing strategy that uses recently mined block data to derive a gas price for which a transaction is likely to be...
[ "def", "construct_time_based_gas_price_strategy", "(", "max_wait_seconds", ",", "sample_size", "=", "120", ",", "probability", "=", "98", ")", ":", "def", "time_based_gas_price_strategy", "(", "web3", ",", "transaction_params", ")", ":", "avg_block_time", "=", "_get_a...
A gas pricing strategy that uses recently mined block data to derive a gas price for which a transaction is likely to be mined within X seconds with probability P. :param max_wait_seconds: The desired maxiumum number of seconds the transaction should take to mine. :param sample_size: The number...
[ "A", "gas", "pricing", "strategy", "that", "uses", "recently", "mined", "block", "data", "to", "derive", "a", "gas", "price", "for", "which", "a", "transaction", "is", "likely", "to", "be", "mined", "within", "X", "seconds", "with", "probability", "P", "."...
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/gas_strategies/time_based.py#L140-L170
225,439
ethereum/web3.py
web3/manager.py
RequestManager.default_middlewares
def default_middlewares(web3): """ List the default middlewares for the request manager. Leaving ens unspecified will prevent the middleware from resolving names. """ return [ (request_parameter_normalizer, 'request_param_normalizer'), (gas_price_strategy_...
python
def default_middlewares(web3): """ List the default middlewares for the request manager. Leaving ens unspecified will prevent the middleware from resolving names. """ return [ (request_parameter_normalizer, 'request_param_normalizer'), (gas_price_strategy_...
[ "def", "default_middlewares", "(", "web3", ")", ":", "return", "[", "(", "request_parameter_normalizer", ",", "'request_param_normalizer'", ")", ",", "(", "gas_price_strategy_middleware", ",", "'gas_price_strategy'", ")", ",", "(", "name_to_address_middleware", "(", "we...
List the default middlewares for the request manager. Leaving ens unspecified will prevent the middleware from resolving names.
[ "List", "the", "default", "middlewares", "for", "the", "request", "manager", ".", "Leaving", "ens", "unspecified", "will", "prevent", "the", "middleware", "from", "resolving", "names", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/manager.py#L57-L71
225,440
ethereum/web3.py
web3/manager.py
RequestManager.request_blocking
def request_blocking(self, method, params): """ Make a synchronous request using the provider """ response = self._make_request(method, params) if "error" in response: raise ValueError(response["error"]) return response['result']
python
def request_blocking(self, method, params): """ Make a synchronous request using the provider """ response = self._make_request(method, params) if "error" in response: raise ValueError(response["error"]) return response['result']
[ "def", "request_blocking", "(", "self", ",", "method", ",", "params", ")", ":", "response", "=", "self", ".", "_make_request", "(", "method", ",", "params", ")", "if", "\"error\"", "in", "response", ":", "raise", "ValueError", "(", "response", "[", "\"erro...
Make a synchronous request using the provider
[ "Make", "a", "synchronous", "request", "using", "the", "provider" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/manager.py#L90-L99
225,441
ethereum/web3.py
web3/manager.py
RequestManager.coro_request
async def coro_request(self, method, params): """ Couroutine for making a request using the provider """ response = await self._coro_make_request(method, params) if "error" in response: raise ValueError(response["error"]) if response['result'] is None: ...
python
async def coro_request(self, method, params): """ Couroutine for making a request using the provider """ response = await self._coro_make_request(method, params) if "error" in response: raise ValueError(response["error"]) if response['result'] is None: ...
[ "async", "def", "coro_request", "(", "self", ",", "method", ",", "params", ")", ":", "response", "=", "await", "self", ".", "_coro_make_request", "(", "method", ",", "params", ")", "if", "\"error\"", "in", "response", ":", "raise", "ValueError", "(", "resp...
Couroutine for making a request using the provider
[ "Couroutine", "for", "making", "a", "request", "using", "the", "provider" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/manager.py#L101-L113
225,442
ethereum/web3.py
web3/middleware/fixture.py
construct_fixture_middleware
def construct_fixture_middleware(fixtures): """ Constructs a middleware which returns a static response for any method which is found in the provided fixtures. """ def fixture_middleware(make_request, web3): def middleware(method, params): if method in fixtures: r...
python
def construct_fixture_middleware(fixtures): """ Constructs a middleware which returns a static response for any method which is found in the provided fixtures. """ def fixture_middleware(make_request, web3): def middleware(method, params): if method in fixtures: r...
[ "def", "construct_fixture_middleware", "(", "fixtures", ")", ":", "def", "fixture_middleware", "(", "make_request", ",", "web3", ")", ":", "def", "middleware", "(", "method", ",", "params", ")", ":", "if", "method", "in", "fixtures", ":", "result", "=", "fix...
Constructs a middleware which returns a static response for any method which is found in the provided fixtures.
[ "Constructs", "a", "middleware", "which", "returns", "a", "static", "response", "for", "any", "method", "which", "is", "found", "in", "the", "provided", "fixtures", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/middleware/fixture.py#L1-L14
225,443
ethereum/web3.py
web3/middleware/__init__.py
combine_middlewares
def combine_middlewares(middlewares, web3, provider_request_fn): """ Returns a callable function which will call the provider.provider_request function wrapped with all of the middlewares. """ return functools.reduce( lambda request_fn, middleware: middleware(request_fn, web3), rever...
python
def combine_middlewares(middlewares, web3, provider_request_fn): """ Returns a callable function which will call the provider.provider_request function wrapped with all of the middlewares. """ return functools.reduce( lambda request_fn, middleware: middleware(request_fn, web3), rever...
[ "def", "combine_middlewares", "(", "middlewares", ",", "web3", ",", "provider_request_fn", ")", ":", "return", "functools", ".", "reduce", "(", "lambda", "request_fn", ",", "middleware", ":", "middleware", "(", "request_fn", ",", "web3", ")", ",", "reversed", ...
Returns a callable function which will call the provider.provider_request function wrapped with all of the middlewares.
[ "Returns", "a", "callable", "function", "which", "will", "call", "the", "provider", ".", "provider_request", "function", "wrapped", "with", "all", "of", "the", "middlewares", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/middleware/__init__.py#L67-L76
225,444
ethereum/web3.py
web3/_utils/events.py
get_event_data
def get_event_data(event_abi, log_entry): """ Given an event ABI and a log entry for that event, return the decoded event data """ if event_abi['anonymous']: log_topics = log_entry['topics'] elif not log_entry['topics']: raise MismatchedABI("Expected non-anonymous event to have 1...
python
def get_event_data(event_abi, log_entry): """ Given an event ABI and a log entry for that event, return the decoded event data """ if event_abi['anonymous']: log_topics = log_entry['topics'] elif not log_entry['topics']: raise MismatchedABI("Expected non-anonymous event to have 1...
[ "def", "get_event_data", "(", "event_abi", ",", "log_entry", ")", ":", "if", "event_abi", "[", "'anonymous'", "]", ":", "log_topics", "=", "log_entry", "[", "'topics'", "]", "elif", "not", "log_entry", "[", "'topics'", "]", ":", "raise", "MismatchedABI", "("...
Given an event ABI and a log entry for that event, return the decoded event data
[ "Given", "an", "event", "ABI", "and", "a", "log", "entry", "for", "that", "event", "return", "the", "decoded", "event", "data" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/events.py#L159-L233
225,445
ethereum/web3.py
web3/middleware/exception_retry_request.py
exception_retry_middleware
def exception_retry_middleware(make_request, web3, errors, retries=5): """ Creates middleware that retries failed HTTP requests. Is a default middleware for HTTPProvider. """ def middleware(method, params): if check_if_retry_on_failure(method): for i in range(retries): ...
python
def exception_retry_middleware(make_request, web3, errors, retries=5): """ Creates middleware that retries failed HTTP requests. Is a default middleware for HTTPProvider. """ def middleware(method, params): if check_if_retry_on_failure(method): for i in range(retries): ...
[ "def", "exception_retry_middleware", "(", "make_request", ",", "web3", ",", "errors", ",", "retries", "=", "5", ")", ":", "def", "middleware", "(", "method", ",", "params", ")", ":", "if", "check_if_retry_on_failure", "(", "method", ")", ":", "for", "i", "...
Creates middleware that retries failed HTTP requests. Is a default middleware for HTTPProvider.
[ "Creates", "middleware", "that", "retries", "failed", "HTTP", "requests", ".", "Is", "a", "default", "middleware", "for", "HTTPProvider", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/middleware/exception_retry_request.py#L71-L88
225,446
ethereum/web3.py
web3/iban.py
mod9710
def mod9710(iban): """ Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064. @method mod9710 @param {String} iban @returns {Number} """ remainder = iban block = None while len(remainder) > 2: block = remainder[:9] remainder = str(int(block) % 97) + re...
python
def mod9710(iban): """ Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064. @method mod9710 @param {String} iban @returns {Number} """ remainder = iban block = None while len(remainder) > 2: block = remainder[:9] remainder = str(int(block) % 97) + re...
[ "def", "mod9710", "(", "iban", ")", ":", "remainder", "=", "iban", "block", "=", "None", "while", "len", "(", "remainder", ")", ">", "2", ":", "block", "=", "remainder", "[", ":", "9", "]", "remainder", "=", "str", "(", "int", "(", "block", ")", ...
Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064. @method mod9710 @param {String} iban @returns {Number}
[ "Calculates", "the", "MOD", "97", "10", "of", "the", "passed", "IBAN", "as", "specified", "in", "ISO7064", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/iban.py#L44-L59
225,447
ethereum/web3.py
web3/iban.py
baseN
def baseN(num, b, numerals="0123456789abcdefghijklmnopqrstuvwxyz"): """ This prototype should be used to create an iban object from iban correct string @param {String} iban """ return ((num == 0) and numerals[0]) or \ (baseN(num // b, b, numerals).lstrip(numerals[0]) + numerals[num % b]...
python
def baseN(num, b, numerals="0123456789abcdefghijklmnopqrstuvwxyz"): """ This prototype should be used to create an iban object from iban correct string @param {String} iban """ return ((num == 0) and numerals[0]) or \ (baseN(num // b, b, numerals).lstrip(numerals[0]) + numerals[num % b]...
[ "def", "baseN", "(", "num", ",", "b", ",", "numerals", "=", "\"0123456789abcdefghijklmnopqrstuvwxyz\"", ")", ":", "return", "(", "(", "num", "==", "0", ")", "and", "numerals", "[", "0", "]", ")", "or", "(", "baseN", "(", "num", "//", "b", ",", "b", ...
This prototype should be used to create an iban object from iban correct string @param {String} iban
[ "This", "prototype", "should", "be", "used", "to", "create", "an", "iban", "object", "from", "iban", "correct", "string" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/iban.py#L62-L70
225,448
ethereum/web3.py
web3/iban.py
Iban.fromAddress
def fromAddress(address): """ This method should be used to create an iban object from ethereum address @method fromAddress @param {String} address @return {Iban} the IBAN object """ validate_address(address) address_as_integer = int(address, 16) ...
python
def fromAddress(address): """ This method should be used to create an iban object from ethereum address @method fromAddress @param {String} address @return {Iban} the IBAN object """ validate_address(address) address_as_integer = int(address, 16) ...
[ "def", "fromAddress", "(", "address", ")", ":", "validate_address", "(", "address", ")", "address_as_integer", "=", "int", "(", "address", ",", "16", ")", "address_as_base36", "=", "baseN", "(", "address_as_integer", ",", "36", ")", "padded", "=", "pad_left_he...
This method should be used to create an iban object from ethereum address @method fromAddress @param {String} address @return {Iban} the IBAN object
[ "This", "method", "should", "be", "used", "to", "create", "an", "iban", "object", "from", "ethereum", "address" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/iban.py#L105-L118
225,449
ethereum/web3.py
web3/iban.py
Iban.address
def address(self): """ Should be called to get client direct address @method address @returns {String} client direct address """ if self.isDirect(): base36 = self._iban[4:] asInt = int(base36, 36) return to_checksum_address(pad_left_he...
python
def address(self): """ Should be called to get client direct address @method address @returns {String} client direct address """ if self.isDirect(): base36 = self._iban[4:] asInt = int(base36, 36) return to_checksum_address(pad_left_he...
[ "def", "address", "(", "self", ")", ":", "if", "self", ".", "isDirect", "(", ")", ":", "base36", "=", "self", ".", "_iban", "[", "4", ":", "]", "asInt", "=", "int", "(", "base36", ",", "36", ")", "return", "to_checksum_address", "(", "pad_left_hex", ...
Should be called to get client direct address @method address @returns {String} client direct address
[ "Should", "be", "called", "to", "get", "client", "direct", "address" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/iban.py#L207-L219
225,450
ethereum/web3.py
web3/middleware/filter.py
block_ranges
def block_ranges(start_block, last_block, step=5): """Returns 2-tuple ranges describing ranges of block from start_block to last_block Ranges do not overlap to facilitate use as ``toBlock``, ``fromBlock`` json-rpc arguments, which are both inclusive. """ if last_block is not None and start_b...
python
def block_ranges(start_block, last_block, step=5): """Returns 2-tuple ranges describing ranges of block from start_block to last_block Ranges do not overlap to facilitate use as ``toBlock``, ``fromBlock`` json-rpc arguments, which are both inclusive. """ if last_block is not None and start_b...
[ "def", "block_ranges", "(", "start_block", ",", "last_block", ",", "step", "=", "5", ")", ":", "if", "last_block", "is", "not", "None", "and", "start_block", ">", "last_block", ":", "raise", "TypeError", "(", "\"Incompatible start and stop arguments.\"", ",", "\...
Returns 2-tuple ranges describing ranges of block from start_block to last_block Ranges do not overlap to facilitate use as ``toBlock``, ``fromBlock`` json-rpc arguments, which are both inclusive.
[ "Returns", "2", "-", "tuple", "ranges", "describing", "ranges", "of", "block", "from", "start_block", "to", "last_block" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/middleware/filter.py#L68-L84
225,451
ethereum/web3.py
web3/middleware/filter.py
get_logs_multipart
def get_logs_multipart( w3, startBlock, stopBlock, address, topics, max_blocks): """Used to break up requests to ``eth_getLogs`` The getLog request is partitioned into multiple calls of the max number of blocks ``max_blocks``. """ _block_ranges = bloc...
python
def get_logs_multipart( w3, startBlock, stopBlock, address, topics, max_blocks): """Used to break up requests to ``eth_getLogs`` The getLog request is partitioned into multiple calls of the max number of blocks ``max_blocks``. """ _block_ranges = bloc...
[ "def", "get_logs_multipart", "(", "w3", ",", "startBlock", ",", "stopBlock", ",", "address", ",", "topics", ",", "max_blocks", ")", ":", "_block_ranges", "=", "block_ranges", "(", "startBlock", ",", "stopBlock", ",", "max_blocks", ")", "for", "from_block", ","...
Used to break up requests to ``eth_getLogs`` The getLog request is partitioned into multiple calls of the max number of blocks ``max_blocks``.
[ "Used", "to", "break", "up", "requests", "to", "eth_getLogs" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/middleware/filter.py#L158-L179
225,452
ethereum/web3.py
web3/method.py
Method.method_selector_fn
def method_selector_fn(self): """Gets the method selector from the config. """ if callable(self.json_rpc_method): return self.json_rpc_method elif isinstance(self.json_rpc_method, (str,)): return lambda *_: self.json_rpc_method raise ValueError("``json_rpc...
python
def method_selector_fn(self): """Gets the method selector from the config. """ if callable(self.json_rpc_method): return self.json_rpc_method elif isinstance(self.json_rpc_method, (str,)): return lambda *_: self.json_rpc_method raise ValueError("``json_rpc...
[ "def", "method_selector_fn", "(", "self", ")", ":", "if", "callable", "(", "self", ".", "json_rpc_method", ")", ":", "return", "self", ".", "json_rpc_method", "elif", "isinstance", "(", "self", ".", "json_rpc_method", ",", "(", "str", ",", ")", ")", ":", ...
Gets the method selector from the config.
[ "Gets", "the", "method", "selector", "from", "the", "config", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/method.py#L97-L104
225,453
ethereum/web3.py
web3/_utils/encoding.py
hex_encode_abi_type
def hex_encode_abi_type(abi_type, value, force_size=None): """ Encodes value into a hex string in format of abi_type """ validate_abi_type(abi_type) validate_abi_value(abi_type, value) data_size = force_size or size_of_type(abi_type) if is_array_type(abi_type): sub_type = sub_type_o...
python
def hex_encode_abi_type(abi_type, value, force_size=None): """ Encodes value into a hex string in format of abi_type """ validate_abi_type(abi_type) validate_abi_value(abi_type, value) data_size = force_size or size_of_type(abi_type) if is_array_type(abi_type): sub_type = sub_type_o...
[ "def", "hex_encode_abi_type", "(", "abi_type", ",", "value", ",", "force_size", "=", "None", ")", ":", "validate_abi_type", "(", "abi_type", ")", "validate_abi_value", "(", "abi_type", ",", "value", ")", "data_size", "=", "force_size", "or", "size_of_type", "(",...
Encodes value into a hex string in format of abi_type
[ "Encodes", "value", "into", "a", "hex", "string", "in", "format", "of", "abi_type" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/encoding.py#L50-L79
225,454
ethereum/web3.py
web3/_utils/encoding.py
to_hex_twos_compliment
def to_hex_twos_compliment(value, bit_size): """ Converts integer value to twos compliment hex representation with given bit_size """ if value >= 0: return to_hex_with_size(value, bit_size) value = (1 << bit_size) + value hex_value = hex(value) hex_value = hex_value.rstrip("L") ...
python
def to_hex_twos_compliment(value, bit_size): """ Converts integer value to twos compliment hex representation with given bit_size """ if value >= 0: return to_hex_with_size(value, bit_size) value = (1 << bit_size) + value hex_value = hex(value) hex_value = hex_value.rstrip("L") ...
[ "def", "to_hex_twos_compliment", "(", "value", ",", "bit_size", ")", ":", "if", "value", ">=", "0", ":", "return", "to_hex_with_size", "(", "value", ",", "bit_size", ")", "value", "=", "(", "1", "<<", "bit_size", ")", "+", "value", "hex_value", "=", "hex...
Converts integer value to twos compliment hex representation with given bit_size
[ "Converts", "integer", "value", "to", "twos", "compliment", "hex", "representation", "with", "given", "bit_size" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/encoding.py#L82-L92
225,455
ethereum/web3.py
web3/_utils/encoding.py
pad_hex
def pad_hex(value, bit_size): """ Pads a hex string up to the given bit_size """ value = remove_0x_prefix(value) return add_0x_prefix(value.zfill(int(bit_size / 4)))
python
def pad_hex(value, bit_size): """ Pads a hex string up to the given bit_size """ value = remove_0x_prefix(value) return add_0x_prefix(value.zfill(int(bit_size / 4)))
[ "def", "pad_hex", "(", "value", ",", "bit_size", ")", ":", "value", "=", "remove_0x_prefix", "(", "value", ")", "return", "add_0x_prefix", "(", "value", ".", "zfill", "(", "int", "(", "bit_size", "/", "4", ")", ")", ")" ]
Pads a hex string up to the given bit_size
[ "Pads", "a", "hex", "string", "up", "to", "the", "given", "bit_size" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/encoding.py#L102-L107
225,456
ethereum/web3.py
web3/_utils/encoding.py
to_int
def to_int(value=None, hexstr=None, text=None): """ Converts value to it's integer representation. Values are converted this way: * value: * bytes: big-endian integer * bool: True => 1, False => 0 * hexstr: interpret hex as integer * text: interpret as string of digits, like '...
python
def to_int(value=None, hexstr=None, text=None): """ Converts value to it's integer representation. Values are converted this way: * value: * bytes: big-endian integer * bool: True => 1, False => 0 * hexstr: interpret hex as integer * text: interpret as string of digits, like '...
[ "def", "to_int", "(", "value", "=", "None", ",", "hexstr", "=", "None", ",", "text", "=", "None", ")", ":", "assert_one_val", "(", "value", ",", "hexstr", "=", "hexstr", ",", "text", "=", "text", ")", "if", "hexstr", "is", "not", "None", ":", "retu...
Converts value to it's integer representation. Values are converted this way: * value: * bytes: big-endian integer * bool: True => 1, False => 0 * hexstr: interpret hex as integer * text: interpret as string of digits, like '12' => 12
[ "Converts", "value", "to", "it", "s", "integer", "representation", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/encoding.py#L118-L141
225,457
ethereum/web3.py
web3/pm.py
VyperReferenceRegistry.deploy_new_instance
def deploy_new_instance(cls, w3: Web3) -> "VyperReferenceRegistry": """ Returns a new instance of ```VyperReferenceRegistry`` representing a freshly deployed instance on the given ``web3`` instance of the Vyper Reference Registry implementation. """ manifest = get_vyper_registry_...
python
def deploy_new_instance(cls, w3: Web3) -> "VyperReferenceRegistry": """ Returns a new instance of ```VyperReferenceRegistry`` representing a freshly deployed instance on the given ``web3`` instance of the Vyper Reference Registry implementation. """ manifest = get_vyper_registry_...
[ "def", "deploy_new_instance", "(", "cls", ",", "w3", ":", "Web3", ")", "->", "\"VyperReferenceRegistry\"", ":", "manifest", "=", "get_vyper_registry_manifest", "(", ")", "registry_package", "=", "Package", "(", "manifest", ",", "w3", ")", "registry_factory", "=", ...
Returns a new instance of ```VyperReferenceRegistry`` representing a freshly deployed instance on the given ``web3`` instance of the Vyper Reference Registry implementation.
[ "Returns", "a", "new", "instance", "of", "VyperReferenceRegistry", "representing", "a", "freshly", "deployed", "instance", "on", "the", "given", "web3", "instance", "of", "the", "Vyper", "Reference", "Registry", "implementation", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/pm.py#L230-L241
225,458
ethereum/web3.py
web3/pm.py
VyperReferenceRegistry.transfer_owner
def transfer_owner(self, new_owner: Address) -> TxReceipt: """ Transfers ownership of this registry instance to the given ``new_owner``. Only the ``owner`` is allowed to transfer ownership. * Parameters: * ``new_owner``: The address of the new owner. """ tx_h...
python
def transfer_owner(self, new_owner: Address) -> TxReceipt: """ Transfers ownership of this registry instance to the given ``new_owner``. Only the ``owner`` is allowed to transfer ownership. * Parameters: * ``new_owner``: The address of the new owner. """ tx_h...
[ "def", "transfer_owner", "(", "self", ",", "new_owner", ":", "Address", ")", "->", "TxReceipt", ":", "tx_hash", "=", "self", ".", "registry", ".", "functions", ".", "transferOwner", "(", "new_owner", ")", ".", "transact", "(", ")", "return", "self", ".", ...
Transfers ownership of this registry instance to the given ``new_owner``. Only the ``owner`` is allowed to transfer ownership. * Parameters: * ``new_owner``: The address of the new owner.
[ "Transfers", "ownership", "of", "this", "registry", "instance", "to", "the", "given", "new_owner", ".", "Only", "the", "owner", "is", "allowed", "to", "transfer", "ownership", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/pm.py#L311-L320
225,459
ethereum/web3.py
web3/pm.py
PM.release_package
def release_package( self, package_name: str, version: str, manifest_uri: str ) -> bytes: """ Returns the release id generated by releasing a package on the current registry. Requires ``web3.PM`` to have a registry set. Requires ``web3.eth.defaultAccount`` to be the registry ...
python
def release_package( self, package_name: str, version: str, manifest_uri: str ) -> bytes: """ Returns the release id generated by releasing a package on the current registry. Requires ``web3.PM`` to have a registry set. Requires ``web3.eth.defaultAccount`` to be the registry ...
[ "def", "release_package", "(", "self", ",", "package_name", ":", "str", ",", "version", ":", "str", ",", "manifest_uri", ":", "str", ")", "->", "bytes", ":", "validate_is_supported_manifest_uri", "(", "manifest_uri", ")", "raw_manifest", "=", "to_text", "(", "...
Returns the release id generated by releasing a package on the current registry. Requires ``web3.PM`` to have a registry set. Requires ``web3.eth.defaultAccount`` to be the registry owner. * Parameters: * ``package_name``: Must be a valid package name, matching the given manifest. ...
[ "Returns", "the", "release", "id", "generated", "by", "releasing", "a", "package", "on", "the", "current", "registry", ".", "Requires", "web3", ".", "PM", "to", "have", "a", "registry", "set", ".", "Requires", "web3", ".", "eth", ".", "defaultAccount", "to...
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/pm.py#L471-L504
225,460
ethereum/web3.py
web3/pm.py
PM.get_all_package_names
def get_all_package_names(self) -> Iterable[str]: """ Returns a tuple containing all the package names available on the current registry. """ self._validate_set_registry() package_ids = self.registry._get_all_package_ids() for package_id in package_ids: yield ...
python
def get_all_package_names(self) -> Iterable[str]: """ Returns a tuple containing all the package names available on the current registry. """ self._validate_set_registry() package_ids = self.registry._get_all_package_ids() for package_id in package_ids: yield ...
[ "def", "get_all_package_names", "(", "self", ")", "->", "Iterable", "[", "str", "]", ":", "self", ".", "_validate_set_registry", "(", ")", "package_ids", "=", "self", ".", "registry", ".", "_get_all_package_ids", "(", ")", "for", "package_id", "in", "package_i...
Returns a tuple containing all the package names available on the current registry.
[ "Returns", "a", "tuple", "containing", "all", "the", "package", "names", "available", "on", "the", "current", "registry", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/pm.py#L507-L514
225,461
ethereum/web3.py
web3/pm.py
PM.get_release_count
def get_release_count(self, package_name: str) -> int: """ Returns the number of releases of the given package name available on the current registry. """ validate_package_name(package_name) self._validate_set_registry() return self.registry._num_release_ids(package_name)
python
def get_release_count(self, package_name: str) -> int: """ Returns the number of releases of the given package name available on the current registry. """ validate_package_name(package_name) self._validate_set_registry() return self.registry._num_release_ids(package_name)
[ "def", "get_release_count", "(", "self", ",", "package_name", ":", "str", ")", "->", "int", ":", "validate_package_name", "(", "package_name", ")", "self", ".", "_validate_set_registry", "(", ")", "return", "self", ".", "registry", ".", "_num_release_ids", "(", ...
Returns the number of releases of the given package name available on the current registry.
[ "Returns", "the", "number", "of", "releases", "of", "the", "given", "package", "name", "available", "on", "the", "current", "registry", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/pm.py#L523-L529
225,462
ethereum/web3.py
web3/pm.py
PM.get_release_id
def get_release_id(self, package_name: str, version: str) -> bytes: """ Returns the 32 byte identifier of a release for the given package name and version, if they are available on the current registry. """ validate_package_name(package_name) validate_package_version(vers...
python
def get_release_id(self, package_name: str, version: str) -> bytes: """ Returns the 32 byte identifier of a release for the given package name and version, if they are available on the current registry. """ validate_package_name(package_name) validate_package_version(vers...
[ "def", "get_release_id", "(", "self", ",", "package_name", ":", "str", ",", "version", ":", "str", ")", "->", "bytes", ":", "validate_package_name", "(", "package_name", ")", "validate_package_version", "(", "version", ")", "self", ".", "_validate_set_registry", ...
Returns the 32 byte identifier of a release for the given package name and version, if they are available on the current registry.
[ "Returns", "the", "32", "byte", "identifier", "of", "a", "release", "for", "the", "given", "package", "name", "and", "version", "if", "they", "are", "available", "on", "the", "current", "registry", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/pm.py#L531-L539
225,463
ethereum/web3.py
web3/pm.py
PM.get_package
def get_package(self, package_name: str, version: str) -> Package: """ Returns a ``Package`` instance, generated by the ``manifest_uri`` associated with the given package name and version, if they are published to the currently set registry. * Parameters: * ``name``: Must be...
python
def get_package(self, package_name: str, version: str) -> Package: """ Returns a ``Package`` instance, generated by the ``manifest_uri`` associated with the given package name and version, if they are published to the currently set registry. * Parameters: * ``name``: Must be...
[ "def", "get_package", "(", "self", ",", "package_name", ":", "str", ",", "version", ":", "str", ")", "->", "Package", ":", "validate_package_name", "(", "package_name", ")", "validate_package_version", "(", "version", ")", "self", ".", "_validate_set_registry", ...
Returns a ``Package`` instance, generated by the ``manifest_uri`` associated with the given package name and version, if they are published to the currently set registry. * Parameters: * ``name``: Must be a valid package name. * ``version``: Must be a valid package version.
[ "Returns", "a", "Package", "instance", "generated", "by", "the", "manifest_uri", "associated", "with", "the", "given", "package", "name", "and", "version", "if", "they", "are", "published", "to", "the", "currently", "set", "registry", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/pm.py#L580-L593
225,464
ethereum/web3.py
web3/_utils/filters.py
normalize_data_values
def normalize_data_values(type_string, data_value): """Decodes utf-8 bytes to strings for abi string values. eth-abi v1 returns utf-8 bytes for string values. This can be removed once eth-abi v2 is required. """ _type = parse_type_string(type_string) if _type.base == "string": if _type....
python
def normalize_data_values(type_string, data_value): """Decodes utf-8 bytes to strings for abi string values. eth-abi v1 returns utf-8 bytes for string values. This can be removed once eth-abi v2 is required. """ _type = parse_type_string(type_string) if _type.base == "string": if _type....
[ "def", "normalize_data_values", "(", "type_string", ",", "data_value", ")", ":", "_type", "=", "parse_type_string", "(", "type_string", ")", "if", "_type", ".", "base", "==", "\"string\"", ":", "if", "_type", ".", "arrlist", "is", "not", "None", ":", "return...
Decodes utf-8 bytes to strings for abi string values. eth-abi v1 returns utf-8 bytes for string values. This can be removed once eth-abi v2 is required.
[ "Decodes", "utf", "-", "8", "bytes", "to", "strings", "for", "abi", "string", "values", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/filters.py#L192-L204
225,465
ethereum/web3.py
web3/_utils/filters.py
match_fn
def match_fn(match_values_and_abi, data): """Match function used for filtering non-indexed event arguments. Values provided through the match_values_and_abi parameter are compared to the abi decoded log data. """ abi_types, all_match_values = zip(*match_values_and_abi) decoded_values = decode_a...
python
def match_fn(match_values_and_abi, data): """Match function used for filtering non-indexed event arguments. Values provided through the match_values_and_abi parameter are compared to the abi decoded log data. """ abi_types, all_match_values = zip(*match_values_and_abi) decoded_values = decode_a...
[ "def", "match_fn", "(", "match_values_and_abi", ",", "data", ")", ":", "abi_types", ",", "all_match_values", "=", "zip", "(", "*", "match_values_and_abi", ")", "decoded_values", "=", "decode_abi", "(", "abi_types", ",", "HexBytes", "(", "data", ")", ")", "for"...
Match function used for filtering non-indexed event arguments. Values provided through the match_values_and_abi parameter are compared to the abi decoded log data.
[ "Match", "function", "used", "for", "filtering", "non", "-", "indexed", "event", "arguments", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/filters.py#L208-L230
225,466
ethereum/web3.py
web3/middleware/attrdict.py
attrdict_middleware
def attrdict_middleware(make_request, web3): """ Converts any result which is a dictionary into an a """ def middleware(method, params): response = make_request(method, params) if 'result' in response: result = response['result'] if is_dict(result) and not isinst...
python
def attrdict_middleware(make_request, web3): """ Converts any result which is a dictionary into an a """ def middleware(method, params): response = make_request(method, params) if 'result' in response: result = response['result'] if is_dict(result) and not isinst...
[ "def", "attrdict_middleware", "(", "make_request", ",", "web3", ")", ":", "def", "middleware", "(", "method", ",", "params", ")", ":", "response", "=", "make_request", "(", "method", ",", "params", ")", "if", "'result'", "in", "response", ":", "result", "=...
Converts any result which is a dictionary into an a
[ "Converts", "any", "result", "which", "is", "a", "dictionary", "into", "an", "a" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/middleware/attrdict.py#L13-L28
225,467
ethereum/web3.py
ens/main.py
ENS.fromWeb3
def fromWeb3(cls, web3, addr=None): """ Generate an ENS instance with web3 :param `web3.Web3` web3: to infer connection information :param hex-string addr: the address of the ENS registry on-chain. If not provided, ENS.py will default to the mainnet ENS registry address. ...
python
def fromWeb3(cls, web3, addr=None): """ Generate an ENS instance with web3 :param `web3.Web3` web3: to infer connection information :param hex-string addr: the address of the ENS registry on-chain. If not provided, ENS.py will default to the mainnet ENS registry address. ...
[ "def", "fromWeb3", "(", "cls", ",", "web3", ",", "addr", "=", "None", ")", ":", "return", "cls", "(", "web3", ".", "manager", ".", "provider", ",", "addr", "=", "addr", ")" ]
Generate an ENS instance with web3 :param `web3.Web3` web3: to infer connection information :param hex-string addr: the address of the ENS registry on-chain. If not provided, ENS.py will default to the mainnet ENS registry address.
[ "Generate", "an", "ENS", "instance", "with", "web3" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/ens/main.py#L65-L73
225,468
ethereum/web3.py
ens/main.py
ENS.name
def name(self, address): """ Look up the name that the address points to, using a reverse lookup. Reverse lookup is opt-in for name owners. :param address: :type address: hex-string """ reversed_domain = address_to_reverse_domain(address) return self.reso...
python
def name(self, address): """ Look up the name that the address points to, using a reverse lookup. Reverse lookup is opt-in for name owners. :param address: :type address: hex-string """ reversed_domain = address_to_reverse_domain(address) return self.reso...
[ "def", "name", "(", "self", ",", "address", ")", ":", "reversed_domain", "=", "address_to_reverse_domain", "(", "address", ")", "return", "self", ".", "resolve", "(", "reversed_domain", ",", "get", "=", "'name'", ")" ]
Look up the name that the address points to, using a reverse lookup. Reverse lookup is opt-in for name owners. :param address: :type address: hex-string
[ "Look", "up", "the", "name", "that", "the", "address", "points", "to", "using", "a", "reverse", "lookup", ".", "Reverse", "lookup", "is", "opt", "-", "in", "for", "name", "owners", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/ens/main.py#L84-L93
225,469
ethereum/web3.py
ens/main.py
ENS.setup_address
def setup_address(self, name, address=default, transact={}): """ Set up the name to point to the supplied address. The sender of the transaction must own the name, or its parent name. Example: If the caller owns ``parentname.eth`` with no subdomains and calls this method...
python
def setup_address(self, name, address=default, transact={}): """ Set up the name to point to the supplied address. The sender of the transaction must own the name, or its parent name. Example: If the caller owns ``parentname.eth`` with no subdomains and calls this method...
[ "def", "setup_address", "(", "self", ",", "name", ",", "address", "=", "default", ",", "transact", "=", "{", "}", ")", ":", "owner", "=", "self", ".", "setup_owner", "(", "name", ",", "transact", "=", "transact", ")", "self", ".", "_assert_control", "(...
Set up the name to point to the supplied address. The sender of the transaction must own the name, or its parent name. Example: If the caller owns ``parentname.eth`` with no subdomains and calls this method with ``sub.parentname.eth``, then ``sub`` will be created as part of thi...
[ "Set", "up", "the", "name", "to", "point", "to", "the", "supplied", "address", ".", "The", "sender", "of", "the", "transaction", "must", "own", "the", "name", "or", "its", "parent", "name", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/ens/main.py#L96-L130
225,470
ethereum/web3.py
ens/main.py
ENS.setup_owner
def setup_owner(self, name, new_owner=default, transact={}): """ Set the owner of the supplied name to `new_owner`. For typical scenarios, you'll never need to call this method directly, simply call :meth:`setup_name` or :meth:`setup_address`. This method does *not* set up the n...
python
def setup_owner(self, name, new_owner=default, transact={}): """ Set the owner of the supplied name to `new_owner`. For typical scenarios, you'll never need to call this method directly, simply call :meth:`setup_name` or :meth:`setup_address`. This method does *not* set up the n...
[ "def", "setup_owner", "(", "self", ",", "name", ",", "new_owner", "=", "default", ",", "transact", "=", "{", "}", ")", ":", "(", "super_owner", ",", "unowned", ",", "owned", ")", "=", "self", ".", "_first_owner", "(", "name", ")", "if", "new_owner", ...
Set the owner of the supplied name to `new_owner`. For typical scenarios, you'll never need to call this method directly, simply call :meth:`setup_name` or :meth:`setup_address`. This method does *not* set up the name to point to an address. If `new_owner` is not supplied, then this wi...
[ "Set", "the", "owner", "of", "the", "supplied", "name", "to", "new_owner", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/ens/main.py#L213-L252
225,471
ethereum/web3.py
ens/main.py
ENS._first_owner
def _first_owner(self, name): """ Takes a name, and returns the owner of the deepest subdomain that has an owner :returns: (owner or None, list(unowned_subdomain_labels), first_owned_domain) """ owner = None unowned = [] pieces = normalize_name(name).split('.') ...
python
def _first_owner(self, name): """ Takes a name, and returns the owner of the deepest subdomain that has an owner :returns: (owner or None, list(unowned_subdomain_labels), first_owned_domain) """ owner = None unowned = [] pieces = normalize_name(name).split('.') ...
[ "def", "_first_owner", "(", "self", ",", "name", ")", ":", "owner", "=", "None", "unowned", "=", "[", "]", "pieces", "=", "normalize_name", "(", "name", ")", ".", "split", "(", "'.'", ")", "while", "pieces", "and", "is_none_or_zero_address", "(", "owner"...
Takes a name, and returns the owner of the deepest subdomain that has an owner :returns: (owner or None, list(unowned_subdomain_labels), first_owned_domain)
[ "Takes", "a", "name", "and", "returns", "the", "owner", "of", "the", "deepest", "subdomain", "that", "has", "an", "owner" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/ens/main.py#L262-L276
225,472
ethereum/web3.py
web3/contract.py
call_contract_function
def call_contract_function( web3, address, normalizers, function_identifier, transaction, block_id=None, contract_abi=None, fn_abi=None, *args, **kwargs): """ Helper function for interacting with a contract function using the `e...
python
def call_contract_function( web3, address, normalizers, function_identifier, transaction, block_id=None, contract_abi=None, fn_abi=None, *args, **kwargs): """ Helper function for interacting with a contract function using the `e...
[ "def", "call_contract_function", "(", "web3", ",", "address", ",", "normalizers", ",", "function_identifier", ",", "transaction", ",", "block_id", "=", "None", ",", "contract_abi", "=", "None", ",", "fn_abi", "=", "None", ",", "*", "args", ",", "*", "*", "...
Helper function for interacting with a contract function using the `eth_call` API.
[ "Helper", "function", "for", "interacting", "with", "a", "contract", "function", "using", "the", "eth_call", "API", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/contract.py#L1275-L1345
225,473
ethereum/web3.py
web3/contract.py
transact_with_contract_function
def transact_with_contract_function( address, web3, function_name=None, transaction=None, contract_abi=None, fn_abi=None, *args, **kwargs): """ Helper function for interacting with a contract function by sending a transaction. """ trans...
python
def transact_with_contract_function( address, web3, function_name=None, transaction=None, contract_abi=None, fn_abi=None, *args, **kwargs): """ Helper function for interacting with a contract function by sending a transaction. """ trans...
[ "def", "transact_with_contract_function", "(", "address", ",", "web3", ",", "function_name", "=", "None", ",", "transaction", "=", "None", ",", "contract_abi", "=", "None", ",", "fn_abi", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", ...
Helper function for interacting with a contract function by sending a transaction.
[ "Helper", "function", "for", "interacting", "with", "a", "contract", "function", "by", "sending", "a", "transaction", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/contract.py#L1370-L1395
225,474
ethereum/web3.py
web3/contract.py
estimate_gas_for_function
def estimate_gas_for_function( address, web3, fn_identifier=None, transaction=None, contract_abi=None, fn_abi=None, *args, **kwargs): """Estimates gas cost a function call would take. Don't call this directly, instead use :meth:`Contract.estimateG...
python
def estimate_gas_for_function( address, web3, fn_identifier=None, transaction=None, contract_abi=None, fn_abi=None, *args, **kwargs): """Estimates gas cost a function call would take. Don't call this directly, instead use :meth:`Contract.estimateG...
[ "def", "estimate_gas_for_function", "(", "address", ",", "web3", ",", "fn_identifier", "=", "None", ",", "transaction", "=", "None", ",", "contract_abi", "=", "None", ",", "fn_abi", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "estim...
Estimates gas cost a function call would take. Don't call this directly, instead use :meth:`Contract.estimateGas` on your contract instance.
[ "Estimates", "gas", "cost", "a", "function", "call", "would", "take", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/contract.py#L1398-L1424
225,475
ethereum/web3.py
web3/contract.py
build_transaction_for_function
def build_transaction_for_function( address, web3, function_name=None, transaction=None, contract_abi=None, fn_abi=None, *args, **kwargs): """Builds a dictionary with the fields required to make the given transaction Don't call this directly, inst...
python
def build_transaction_for_function( address, web3, function_name=None, transaction=None, contract_abi=None, fn_abi=None, *args, **kwargs): """Builds a dictionary with the fields required to make the given transaction Don't call this directly, inst...
[ "def", "build_transaction_for_function", "(", "address", ",", "web3", ",", "function_name", "=", "None", ",", "transaction", "=", "None", ",", "contract_abi", "=", "None", ",", "fn_abi", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "...
Builds a dictionary with the fields required to make the given transaction Don't call this directly, instead use :meth:`Contract.buildTransaction` on your contract instance.
[ "Builds", "a", "dictionary", "with", "the", "fields", "required", "to", "make", "the", "given", "transaction" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/contract.py#L1427-L1454
225,476
ethereum/web3.py
web3/contract.py
Contract.encodeABI
def encodeABI(cls, fn_name, args=None, kwargs=None, data=None): """ Encodes the arguments using the Ethereum ABI for the contract function that matches the given name and arguments.. :param data: defaults to function selector """ fn_abi, fn_selector, fn_arguments = get_f...
python
def encodeABI(cls, fn_name, args=None, kwargs=None, data=None): """ Encodes the arguments using the Ethereum ABI for the contract function that matches the given name and arguments.. :param data: defaults to function selector """ fn_abi, fn_selector, fn_arguments = get_f...
[ "def", "encodeABI", "(", "cls", ",", "fn_name", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "data", "=", "None", ")", ":", "fn_abi", ",", "fn_selector", ",", "fn_arguments", "=", "get_function_info", "(", "fn_name", ",", "contract_abi", "=...
Encodes the arguments using the Ethereum ABI for the contract function that matches the given name and arguments.. :param data: defaults to function selector
[ "Encodes", "the", "arguments", "using", "the", "Ethereum", "ABI", "for", "the", "contract", "function", "that", "matches", "the", "given", "name", "and", "arguments", ".." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/contract.py#L330-L344
225,477
ethereum/web3.py
web3/contract.py
ContractFunction.call
def call(self, transaction=None, block_identifier='latest'): """ Execute a contract function call using the `eth_call` interface. This method prepares a ``Caller`` object that exposes the contract functions and public variables as callable Python functions. Reading a public ``o...
python
def call(self, transaction=None, block_identifier='latest'): """ Execute a contract function call using the `eth_call` interface. This method prepares a ``Caller`` object that exposes the contract functions and public variables as callable Python functions. Reading a public ``o...
[ "def", "call", "(", "self", ",", "transaction", "=", "None", ",", "block_identifier", "=", "'latest'", ")", ":", "if", "transaction", "is", "None", ":", "call_transaction", "=", "{", "}", "else", ":", "call_transaction", "=", "dict", "(", "*", "*", "tran...
Execute a contract function call using the `eth_call` interface. This method prepares a ``Caller`` object that exposes the contract functions and public variables as callable Python functions. Reading a public ``owner`` address variable example: .. code-block:: python Con...
[ "Execute", "a", "contract", "function", "call", "using", "the", "eth_call", "interface", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/contract.py#L761-L824
225,478
ethereum/web3.py
web3/contract.py
ContractEvent.getLogs
def getLogs(self, argument_filters=None, fromBlock=None, toBlock=None, blockHash=None): """Get events for this contract instance using eth_getLogs API. This is a stateless method, as opposed to createFilter. It can be safely called...
python
def getLogs(self, argument_filters=None, fromBlock=None, toBlock=None, blockHash=None): """Get events for this contract instance using eth_getLogs API. This is a stateless method, as opposed to createFilter. It can be safely called...
[ "def", "getLogs", "(", "self", ",", "argument_filters", "=", "None", ",", "fromBlock", "=", "None", ",", "toBlock", "=", "None", ",", "blockHash", "=", "None", ")", ":", "if", "not", "self", ".", "address", ":", "raise", "TypeError", "(", "\"This method ...
Get events for this contract instance using eth_getLogs API. This is a stateless method, as opposed to createFilter. It can be safely called against nodes which do not provide eth_newFilter API, like Infura nodes. If there are many events, like ``Transfer`` events for a popular...
[ "Get", "events", "for", "this", "contract", "instance", "using", "eth_getLogs", "API", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/contract.py#L1065-L1161
225,479
ethereum/web3.py
ens/utils.py
dict_copy
def dict_copy(func): "copy dict keyword args, to avoid modifying caller's copy" @functools.wraps(func) def wrapper(*args, **kwargs): copied_kwargs = copy.deepcopy(kwargs) return func(*args, **copied_kwargs) return wrapper
python
def dict_copy(func): "copy dict keyword args, to avoid modifying caller's copy" @functools.wraps(func) def wrapper(*args, **kwargs): copied_kwargs = copy.deepcopy(kwargs) return func(*args, **copied_kwargs) return wrapper
[ "def", "dict_copy", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "copied_kwargs", "=", "copy", ".", "deepcopy", "(", "kwargs", ")", "return", "func", ...
copy dict keyword args, to avoid modifying caller's copy
[ "copy", "dict", "keyword", "args", "to", "avoid", "modifying", "caller", "s", "copy" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/ens/utils.py#L33-L39
225,480
ethereum/web3.py
ens/utils.py
dot_eth_label
def dot_eth_label(name): """ Convert from a name, like 'ethfinex.eth', to a label, like 'ethfinex' If name is already a label, this should be a noop, except for converting to a string and validating the name syntax. """ label = name_to_label(name, registrar='eth') if len(label) < MIN_ETH_LAB...
python
def dot_eth_label(name): """ Convert from a name, like 'ethfinex.eth', to a label, like 'ethfinex' If name is already a label, this should be a noop, except for converting to a string and validating the name syntax. """ label = name_to_label(name, registrar='eth') if len(label) < MIN_ETH_LAB...
[ "def", "dot_eth_label", "(", "name", ")", ":", "label", "=", "name_to_label", "(", "name", ",", "registrar", "=", "'eth'", ")", "if", "len", "(", "label", ")", "<", "MIN_ETH_LABEL_LENGTH", ":", "raise", "InvalidLabel", "(", "'name %r is too short'", "%", "la...
Convert from a name, like 'ethfinex.eth', to a label, like 'ethfinex' If name is already a label, this should be a noop, except for converting to a string and validating the name syntax.
[ "Convert", "from", "a", "name", "like", "ethfinex", ".", "eth", "to", "a", "label", "like", "ethfinex", "If", "name", "is", "already", "a", "label", "this", "should", "be", "a", "noop", "except", "for", "converting", "to", "a", "string", "and", "validati...
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/ens/utils.py#L125-L135
225,481
ethereum/web3.py
web3/_utils/formatters.py
map_collection
def map_collection(func, collection): """ Apply func to each element of a collection, or value of a dictionary. If the value is not a collection, return it unmodified """ datatype = type(collection) if isinstance(collection, Mapping): return datatype((key, func(val)) for key, val in coll...
python
def map_collection(func, collection): """ Apply func to each element of a collection, or value of a dictionary. If the value is not a collection, return it unmodified """ datatype = type(collection) if isinstance(collection, Mapping): return datatype((key, func(val)) for key, val in coll...
[ "def", "map_collection", "(", "func", ",", "collection", ")", ":", "datatype", "=", "type", "(", "collection", ")", "if", "isinstance", "(", "collection", ",", "Mapping", ")", ":", "return", "datatype", "(", "(", "key", ",", "func", "(", "val", ")", ")...
Apply func to each element of a collection, or value of a dictionary. If the value is not a collection, return it unmodified
[ "Apply", "func", "to", "each", "element", "of", "a", "collection", "or", "value", "of", "a", "dictionary", ".", "If", "the", "value", "is", "not", "a", "collection", "return", "it", "unmodified" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/formatters.py#L91-L104
225,482
ethereum/web3.py
web3/_utils/math.py
percentile
def percentile(values=None, percentile=None): """Calculates a simplified weighted average percentile """ if values in [None, tuple(), []] or len(values) < 1: raise InsufficientData( "Expected a sequence of at least 1 integers, got {0!r}".format(values)) if percentile is None: ...
python
def percentile(values=None, percentile=None): """Calculates a simplified weighted average percentile """ if values in [None, tuple(), []] or len(values) < 1: raise InsufficientData( "Expected a sequence of at least 1 integers, got {0!r}".format(values)) if percentile is None: ...
[ "def", "percentile", "(", "values", "=", "None", ",", "percentile", "=", "None", ")", ":", "if", "values", "in", "[", "None", ",", "tuple", "(", ")", ",", "[", "]", "]", "or", "len", "(", "values", ")", "<", "1", ":", "raise", "InsufficientData", ...
Calculates a simplified weighted average percentile
[ "Calculates", "a", "simplified", "weighted", "average", "percentile" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/math.py#L6-L32
225,483
ethereum/web3.py
web3/datastructures.py
ReadableAttributeDict._repr_pretty_
def _repr_pretty_(self, builder, cycle): """ Custom pretty output for the IPython console """ builder.text(self.__class__.__name__ + "(") if cycle: builder.text("<cycle>") else: builder.pretty(self.__dict__) builder.text(")")
python
def _repr_pretty_(self, builder, cycle): """ Custom pretty output for the IPython console """ builder.text(self.__class__.__name__ + "(") if cycle: builder.text("<cycle>") else: builder.pretty(self.__dict__) builder.text(")")
[ "def", "_repr_pretty_", "(", "self", ",", "builder", ",", "cycle", ")", ":", "builder", ".", "text", "(", "self", ".", "__class__", ".", "__name__", "+", "\"(\"", ")", "if", "cycle", ":", "builder", ".", "text", "(", "\"<cycle>\"", ")", "else", ":", ...
Custom pretty output for the IPython console
[ "Custom", "pretty", "output", "for", "the", "IPython", "console" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/datastructures.py#L45-L54
225,484
ethereum/web3.py
web3/datastructures.py
NamedElementOnion.inject
def inject(self, element, name=None, layer=None): """ Inject a named element to an arbitrary layer in the onion. The current implementation only supports insertion at the innermost layer, or at the outermost layer. Note that inserting to the outermost is equivalent to calling :m...
python
def inject(self, element, name=None, layer=None): """ Inject a named element to an arbitrary layer in the onion. The current implementation only supports insertion at the innermost layer, or at the outermost layer. Note that inserting to the outermost is equivalent to calling :m...
[ "def", "inject", "(", "self", ",", "element", ",", "name", "=", "None", ",", "layer", "=", "None", ")", ":", "if", "not", "is_integer", "(", "layer", ")", ":", "raise", "TypeError", "(", "\"The layer for insertion must be an int.\"", ")", "elif", "layer", ...
Inject a named element to an arbitrary layer in the onion. The current implementation only supports insertion at the innermost layer, or at the outermost layer. Note that inserting to the outermost is equivalent to calling :meth:`add` .
[ "Inject", "a", "named", "element", "to", "an", "arbitrary", "layer", "in", "the", "onion", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/datastructures.py#L127-L156
225,485
ethereum/web3.py
web3/middleware/signing.py
construct_sign_and_send_raw_middleware
def construct_sign_and_send_raw_middleware(private_key_or_account): """Capture transactions sign and send as raw transactions Keyword arguments: private_key_or_account -- A single private key or a tuple, list or set of private keys. Keys can be any of the following formats: - An eth_account.Loca...
python
def construct_sign_and_send_raw_middleware(private_key_or_account): """Capture transactions sign and send as raw transactions Keyword arguments: private_key_or_account -- A single private key or a tuple, list or set of private keys. Keys can be any of the following formats: - An eth_account.Loca...
[ "def", "construct_sign_and_send_raw_middleware", "(", "private_key_or_account", ")", ":", "accounts", "=", "gen_normalized_accounts", "(", "private_key_or_account", ")", "def", "sign_and_send_raw_middleware", "(", "make_request", ",", "w3", ")", ":", "format_and_fill_tx", "...
Capture transactions sign and send as raw transactions Keyword arguments: private_key_or_account -- A single private key or a tuple, list or set of private keys. Keys can be any of the following formats: - An eth_account.LocalAccount object - An eth_keys.PrivateKey object - A raw private...
[ "Capture", "transactions", "sign", "and", "send", "as", "raw", "transactions" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/middleware/signing.py#L95-L136
225,486
ethereum/web3.py
web3/_utils/validation.py
validate_abi
def validate_abi(abi): """ Helper function for validating an ABI """ if not is_list_like(abi): raise ValueError("'abi' is not a list") if not all(is_dict(e) for e in abi): raise ValueError("'abi' is not a list of dictionaries") functions = filter_by_type('function', abi) se...
python
def validate_abi(abi): """ Helper function for validating an ABI """ if not is_list_like(abi): raise ValueError("'abi' is not a list") if not all(is_dict(e) for e in abi): raise ValueError("'abi' is not a list of dictionaries") functions = filter_by_type('function', abi) se...
[ "def", "validate_abi", "(", "abi", ")", ":", "if", "not", "is_list_like", "(", "abi", ")", ":", "raise", "ValueError", "(", "\"'abi' is not a list\"", ")", "if", "not", "all", "(", "is_dict", "(", "e", ")", "for", "e", "in", "abi", ")", ":", "raise", ...
Helper function for validating an ABI
[ "Helper", "function", "for", "validating", "an", "ABI" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/validation.py#L55-L75
225,487
ethereum/web3.py
web3/_utils/validation.py
validate_address
def validate_address(value): """ Helper function for validating an address """ if is_bytes(value): if not is_binary_address(value): raise InvalidAddress("Address must be 20 bytes when input type is bytes", value) return if not isinstance(value, str): raise TypeEr...
python
def validate_address(value): """ Helper function for validating an address """ if is_bytes(value): if not is_binary_address(value): raise InvalidAddress("Address must be 20 bytes when input type is bytes", value) return if not isinstance(value, str): raise TypeEr...
[ "def", "validate_address", "(", "value", ")", ":", "if", "is_bytes", "(", "value", ")", ":", "if", "not", "is_binary_address", "(", "value", ")", ":", "raise", "InvalidAddress", "(", "\"Address must be 20 bytes when input type is bytes\"", ",", "value", ")", "retu...
Helper function for validating an address
[ "Helper", "function", "for", "validating", "an", "address" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/validation.py#L142-L170
225,488
ethereum/web3.py
web3/middleware/cache.py
construct_simple_cache_middleware
def construct_simple_cache_middleware( cache_class, rpc_whitelist=SIMPLE_CACHE_RPC_WHITELIST, should_cache_fn=_should_cache): """ Constructs a middleware which caches responses based on the request ``method`` and ``params`` :param cache: Any dictionary-like object :param rpc...
python
def construct_simple_cache_middleware( cache_class, rpc_whitelist=SIMPLE_CACHE_RPC_WHITELIST, should_cache_fn=_should_cache): """ Constructs a middleware which caches responses based on the request ``method`` and ``params`` :param cache: Any dictionary-like object :param rpc...
[ "def", "construct_simple_cache_middleware", "(", "cache_class", ",", "rpc_whitelist", "=", "SIMPLE_CACHE_RPC_WHITELIST", ",", "should_cache_fn", "=", "_should_cache", ")", ":", "def", "simple_cache_middleware", "(", "make_request", ",", "web3", ")", ":", "cache", "=", ...
Constructs a middleware which caches responses based on the request ``method`` and ``params`` :param cache: Any dictionary-like object :param rpc_whitelist: A set of RPC methods which may have their responses cached. :param should_cache_fn: A callable which accepts ``method`` ``params`` and ``r...
[ "Constructs", "a", "middleware", "which", "caches", "responses", "based", "on", "the", "request", "method", "and", "params" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/middleware/cache.py#L74-L110
225,489
ethereum/web3.py
web3/middleware/cache.py
construct_time_based_cache_middleware
def construct_time_based_cache_middleware( cache_class, cache_expire_seconds=15, rpc_whitelist=TIME_BASED_CACHE_RPC_WHITELIST, should_cache_fn=_should_cache): """ Constructs a middleware which caches responses based on the request ``method`` and ``params`` for a maximum amoun...
python
def construct_time_based_cache_middleware( cache_class, cache_expire_seconds=15, rpc_whitelist=TIME_BASED_CACHE_RPC_WHITELIST, should_cache_fn=_should_cache): """ Constructs a middleware which caches responses based on the request ``method`` and ``params`` for a maximum amoun...
[ "def", "construct_time_based_cache_middleware", "(", "cache_class", ",", "cache_expire_seconds", "=", "15", ",", "rpc_whitelist", "=", "TIME_BASED_CACHE_RPC_WHITELIST", ",", "should_cache_fn", "=", "_should_cache", ")", ":", "def", "time_based_cache_middleware", "(", "make_...
Constructs a middleware which caches responses based on the request ``method`` and ``params`` for a maximum amount of time as specified :param cache: Any dictionary-like object :param cache_expire_seconds: The number of seconds an item may be cached before it should expire. :param rpc_whitelist...
[ "Constructs", "a", "middleware", "which", "caches", "responses", "based", "on", "the", "request", "method", "and", "params", "for", "a", "maximum", "amount", "of", "time", "as", "specified" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/middleware/cache.py#L170-L220
225,490
ethereum/web3.py
web3/_utils/decorators.py
reject_recursive_repeats
def reject_recursive_repeats(to_wrap): """ Prevent simple cycles by returning None when called recursively with same instance """ to_wrap.__already_called = {} @functools.wraps(to_wrap) def wrapped(*args): arg_instances = tuple(map(id, args)) thread_id = threading.get_ident() ...
python
def reject_recursive_repeats(to_wrap): """ Prevent simple cycles by returning None when called recursively with same instance """ to_wrap.__already_called = {} @functools.wraps(to_wrap) def wrapped(*args): arg_instances = tuple(map(id, args)) thread_id = threading.get_ident() ...
[ "def", "reject_recursive_repeats", "(", "to_wrap", ")", ":", "to_wrap", ".", "__already_called", "=", "{", "}", "@", "functools", ".", "wraps", "(", "to_wrap", ")", "def", "wrapped", "(", "*", "args", ")", ":", "arg_instances", "=", "tuple", "(", "map", ...
Prevent simple cycles by returning None when called recursively with same instance
[ "Prevent", "simple", "cycles", "by", "returning", "None", "when", "called", "recursively", "with", "same", "instance" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/decorators.py#L20-L39
225,491
ethereum/web3.py
web3/_utils/abi.py
get_tuple_type_str_parts
def get_tuple_type_str_parts(s: str) -> Optional[Tuple[str, Optional[str]]]: """ Takes a JSON ABI type string. For tuple type strings, returns the separated prefix and array dimension parts. For all other strings, returns ``None``. """ match = TUPLE_TYPE_STR_RE.match(s) if match is not None: ...
python
def get_tuple_type_str_parts(s: str) -> Optional[Tuple[str, Optional[str]]]: """ Takes a JSON ABI type string. For tuple type strings, returns the separated prefix and array dimension parts. For all other strings, returns ``None``. """ match = TUPLE_TYPE_STR_RE.match(s) if match is not None: ...
[ "def", "get_tuple_type_str_parts", "(", "s", ":", "str", ")", "->", "Optional", "[", "Tuple", "[", "str", ",", "Optional", "[", "str", "]", "]", "]", ":", "match", "=", "TUPLE_TYPE_STR_RE", ".", "match", "(", "s", ")", "if", "match", "is", "not", "No...
Takes a JSON ABI type string. For tuple type strings, returns the separated prefix and array dimension parts. For all other strings, returns ``None``.
[ "Takes", "a", "JSON", "ABI", "type", "string", ".", "For", "tuple", "type", "strings", "returns", "the", "separated", "prefix", "and", "array", "dimension", "parts", ".", "For", "all", "other", "strings", "returns", "None", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/abi.py#L319-L332
225,492
ethereum/web3.py
web3/_utils/abi.py
_align_abi_input
def _align_abi_input(arg_abi, arg): """ Aligns the values of any mapping at any level of nesting in ``arg`` according to the layout of the corresponding abi spec. """ tuple_parts = get_tuple_type_str_parts(arg_abi['type']) if tuple_parts is None: # Arg is non-tuple. Just return value. ...
python
def _align_abi_input(arg_abi, arg): """ Aligns the values of any mapping at any level of nesting in ``arg`` according to the layout of the corresponding abi spec. """ tuple_parts = get_tuple_type_str_parts(arg_abi['type']) if tuple_parts is None: # Arg is non-tuple. Just return value. ...
[ "def", "_align_abi_input", "(", "arg_abi", ",", "arg", ")", ":", "tuple_parts", "=", "get_tuple_type_str_parts", "(", "arg_abi", "[", "'type'", "]", ")", "if", "tuple_parts", "is", "None", ":", "# Arg is non-tuple. Just return value.", "return", "arg", "tuple_prefi...
Aligns the values of any mapping at any level of nesting in ``arg`` according to the layout of the corresponding abi spec.
[ "Aligns", "the", "values", "of", "any", "mapping", "at", "any", "level", "of", "nesting", "in", "arg", "according", "to", "the", "layout", "of", "the", "corresponding", "abi", "spec", "." ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/abi.py#L335-L376
225,493
ethereum/web3.py
web3/_utils/abi.py
size_of_type
def size_of_type(abi_type): """ Returns size in bits of abi_type """ if 'string' in abi_type: return None if 'byte' in abi_type: return None if '[' in abi_type: return None if abi_type == 'bool': return 8 if abi_type == 'address': return 160 re...
python
def size_of_type(abi_type): """ Returns size in bits of abi_type """ if 'string' in abi_type: return None if 'byte' in abi_type: return None if '[' in abi_type: return None if abi_type == 'bool': return 8 if abi_type == 'address': return 160 re...
[ "def", "size_of_type", "(", "abi_type", ")", ":", "if", "'string'", "in", "abi_type", ":", "return", "None", "if", "'byte'", "in", "abi_type", ":", "return", "None", "if", "'['", "in", "abi_type", ":", "return", "None", "if", "abi_type", "==", "'bool'", ...
Returns size in bits of abi_type
[ "Returns", "size", "in", "bits", "of", "abi_type" ]
71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/abi.py#L485-L499
225,494
danielfrg/word2vec
word2vec/wordclusters.py
WordClusters.ix
def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0]
python
def ix(self, word): """ Returns the index on self.vocab and self.clusters for 'word' """ temp = np.where(self.vocab == word)[0] if temp.size == 0: raise KeyError("Word not in vocabulary") else: return temp[0]
[ "def", "ix", "(", "self", ",", "word", ")", ":", "temp", "=", "np", ".", "where", "(", "self", ".", "vocab", "==", "word", ")", "[", "0", "]", "if", "temp", ".", "size", "==", "0", ":", "raise", "KeyError", "(", "\"Word not in vocabulary\"", ")", ...
Returns the index on self.vocab and self.clusters for 'word'
[ "Returns", "the", "index", "on", "self", ".", "vocab", "and", "self", ".", "clusters", "for", "word" ]
762200acec2941a030abed69e946838af35eb2ae
https://github.com/danielfrg/word2vec/blob/762200acec2941a030abed69e946838af35eb2ae/word2vec/wordclusters.py#L10-L18
225,495
danielfrg/word2vec
word2vec/wordclusters.py
WordClusters.get_cluster
def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx]
python
def get_cluster(self, word): """ Returns the cluster number for a word in the vocabulary """ idx = self.ix(word) return self.clusters[idx]
[ "def", "get_cluster", "(", "self", ",", "word", ")", ":", "idx", "=", "self", ".", "ix", "(", "word", ")", "return", "self", ".", "clusters", "[", "idx", "]" ]
Returns the cluster number for a word in the vocabulary
[ "Returns", "the", "cluster", "number", "for", "a", "word", "in", "the", "vocabulary" ]
762200acec2941a030abed69e946838af35eb2ae
https://github.com/danielfrg/word2vec/blob/762200acec2941a030abed69e946838af35eb2ae/word2vec/wordclusters.py#L23-L28
225,496
danielfrg/word2vec
word2vec/wordvectors.py
WordVectors.closest
def closest(self, vector, n=10, metric="cosine"): """Returns the closest n words to a vector Parameters ------- vector : numpy.array n : int (default 10) Returns ------- Tuple of 2 numpy.array: 1. position in self.vocab 2. cosine ...
python
def closest(self, vector, n=10, metric="cosine"): """Returns the closest n words to a vector Parameters ------- vector : numpy.array n : int (default 10) Returns ------- Tuple of 2 numpy.array: 1. position in self.vocab 2. cosine ...
[ "def", "closest", "(", "self", ",", "vector", ",", "n", "=", "10", ",", "metric", "=", "\"cosine\"", ")", ":", "distances", "=", "distance", "(", "self", ".", "vectors", ",", "vector", ",", "metric", "=", "metric", ")", "best", "=", "np", ".", "arg...
Returns the closest n words to a vector Parameters ------- vector : numpy.array n : int (default 10) Returns ------- Tuple of 2 numpy.array: 1. position in self.vocab 2. cosine similarity
[ "Returns", "the", "closest", "n", "words", "to", "a", "vector" ]
762200acec2941a030abed69e946838af35eb2ae
https://github.com/danielfrg/word2vec/blob/762200acec2941a030abed69e946838af35eb2ae/word2vec/wordvectors.py#L90-L107
225,497
danielfrg/word2vec
word2vec/wordvectors.py
WordVectors.similar
def similar(self, word, n=10, metric="cosine"): """ Return similar words based on a metric Parameters ---------- word : string n : int (default 10) Returns ------- Tuple of 2 numpy.array: 1. position in self.vocab 2. cosin...
python
def similar(self, word, n=10, metric="cosine"): """ Return similar words based on a metric Parameters ---------- word : string n : int (default 10) Returns ------- Tuple of 2 numpy.array: 1. position in self.vocab 2. cosin...
[ "def", "similar", "(", "self", ",", "word", ",", "n", "=", "10", ",", "metric", "=", "\"cosine\"", ")", ":", "return", "self", ".", "closest", "(", "self", "[", "word", "]", ",", "n", "=", "n", ",", "metric", "=", "metric", ")" ]
Return similar words based on a metric Parameters ---------- word : string n : int (default 10) Returns ------- Tuple of 2 numpy.array: 1. position in self.vocab 2. cosine similarity
[ "Return", "similar", "words", "based", "on", "a", "metric" ]
762200acec2941a030abed69e946838af35eb2ae
https://github.com/danielfrg/word2vec/blob/762200acec2941a030abed69e946838af35eb2ae/word2vec/wordvectors.py#L109-L124
225,498
danielfrg/word2vec
word2vec/wordvectors.py
WordVectors.analogy
def analogy(self, pos, neg, n=10, metric="cosine"): """ Analogy similarity. Parameters ---------- pos : list neg : list Returns ------- Tuple of 2 numpy.array: 1. position in self.vocab 2. cosine similarity Exampl...
python
def analogy(self, pos, neg, n=10, metric="cosine"): """ Analogy similarity. Parameters ---------- pos : list neg : list Returns ------- Tuple of 2 numpy.array: 1. position in self.vocab 2. cosine similarity Exampl...
[ "def", "analogy", "(", "self", ",", "pos", ",", "neg", ",", "n", "=", "10", ",", "metric", "=", "\"cosine\"", ")", ":", "exclude", "=", "pos", "+", "neg", "pos", "=", "[", "(", "word", ",", "1.0", ")", "for", "word", "in", "pos", "]", "neg", ...
Analogy similarity. Parameters ---------- pos : list neg : list Returns ------- Tuple of 2 numpy.array: 1. position in self.vocab 2. cosine similarity Example ------- `king - man + woman = queen` will be: `pos...
[ "Analogy", "similarity", "." ]
762200acec2941a030abed69e946838af35eb2ae
https://github.com/danielfrg/word2vec/blob/762200acec2941a030abed69e946838af35eb2ae/word2vec/wordvectors.py#L126-L160
225,499
danielfrg/word2vec
word2vec/wordvectors.py
WordVectors.from_binary
def from_binary( cls, fname, vocab_unicode_size=78, desired_vocab=None, encoding="utf-8", new_lines=True, ): """ Create a WordVectors class based on a word2vec binary file Parameters ---------- fname : p...
python
def from_binary( cls, fname, vocab_unicode_size=78, desired_vocab=None, encoding="utf-8", new_lines=True, ): """ Create a WordVectors class based on a word2vec binary file Parameters ---------- fname : p...
[ "def", "from_binary", "(", "cls", ",", "fname", ",", "vocab_unicode_size", "=", "78", ",", "desired_vocab", "=", "None", ",", "encoding", "=", "\"utf-8\"", ",", "new_lines", "=", "True", ",", ")", ":", "with", "open", "(", "fname", ",", "\"rb\"", ")", ...
Create a WordVectors class based on a word2vec binary file Parameters ---------- fname : path to file vocabUnicodeSize: the maximum string length (78, by default) desired_vocab: if set any words that don't fall into this vocab will be droped Returns ------- ...
[ "Create", "a", "WordVectors", "class", "based", "on", "a", "word2vec", "binary", "file" ]
762200acec2941a030abed69e946838af35eb2ae
https://github.com/danielfrg/word2vec/blob/762200acec2941a030abed69e946838af35eb2ae/word2vec/wordvectors.py#L179-L230