repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
CTPUG/wafer | wafer/registration/views.py | redirect_profile | def redirect_profile(request):
'''
The default destination from logging in, redirect to the actual profile URL
'''
if request.user.is_authenticated:
return HttpResponseRedirect(reverse('wafer_user_profile',
args=(request.user.username,)))
else:
... | python | def redirect_profile(request):
'''
The default destination from logging in, redirect to the actual profile URL
'''
if request.user.is_authenticated:
return HttpResponseRedirect(reverse('wafer_user_profile',
args=(request.user.username,)))
else:
... | [
"def",
"redirect_profile",
"(",
"request",
")",
":",
"if",
"request",
".",
"user",
".",
"is_authenticated",
":",
"return",
"HttpResponseRedirect",
"(",
"reverse",
"(",
"'wafer_user_profile'",
",",
"args",
"=",
"(",
"request",
".",
"user",
".",
"username",
",",... | The default destination from logging in, redirect to the actual profile URL | [
"The",
"default",
"destination",
"from",
"logging",
"in",
"redirect",
"to",
"the",
"actual",
"profile",
"URL"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/registration/views.py#L12-L20 | train |
CTPUG/wafer | wafer/talks/templatetags/review.py | reviewed_badge | def reviewed_badge(user, talk):
"""Returns a badge for the user's reviews of the talk"""
context = {
'reviewed': False,
}
review = None
if user and not user.is_anonymous():
review = talk.reviews.filter(reviewer=user).first()
if review:
context['reviewed'] = True
... | python | def reviewed_badge(user, talk):
"""Returns a badge for the user's reviews of the talk"""
context = {
'reviewed': False,
}
review = None
if user and not user.is_anonymous():
review = talk.reviews.filter(reviewer=user).first()
if review:
context['reviewed'] = True
... | [
"def",
"reviewed_badge",
"(",
"user",
",",
"talk",
")",
":",
"context",
"=",
"{",
"'reviewed'",
":",
"False",
",",
"}",
"review",
"=",
"None",
"if",
"user",
"and",
"not",
"user",
".",
"is_anonymous",
"(",
")",
":",
"review",
"=",
"talk",
".",
"review... | Returns a badge for the user's reviews of the talk | [
"Returns",
"a",
"badge",
"for",
"the",
"user",
"s",
"reviews",
"of",
"the",
"talk"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/talks/templatetags/review.py#L7-L21 | train |
markchil/gptools | gptools/kernel/warping.py | beta_cdf_warp | def beta_cdf_warp(X, d, n, *args):
r"""Warp inputs that are confined to the unit hypercube using the regularized incomplete beta function.
Applies separately to each dimension, designed for use with
:py:class:`WarpingFunction`.
Assumes that your inputs `X` lie entirely within the unit hypercub... | python | def beta_cdf_warp(X, d, n, *args):
r"""Warp inputs that are confined to the unit hypercube using the regularized incomplete beta function.
Applies separately to each dimension, designed for use with
:py:class:`WarpingFunction`.
Assumes that your inputs `X` lie entirely within the unit hypercub... | [
"def",
"beta_cdf_warp",
"(",
"X",
",",
"d",
",",
"n",
",",
"*",
"args",
")",
":",
"X",
"=",
"scipy",
".",
"asarray",
"(",
"X",
")",
"a",
"=",
"args",
"[",
"2",
"*",
"d",
"]",
"b",
"=",
"args",
"[",
"2",
"*",
"d",
"+",
"1",
"]",
"if",
"n... | r"""Warp inputs that are confined to the unit hypercube using the regularized incomplete beta function.
Applies separately to each dimension, designed for use with
:py:class:`WarpingFunction`.
Assumes that your inputs `X` lie entirely within the unit hypercube [0, 1].
Note that you may ex... | [
"r",
"Warp",
"inputs",
"that",
"are",
"confined",
"to",
"the",
"unit",
"hypercube",
"using",
"the",
"regularized",
"incomplete",
"beta",
"function",
".",
"Applies",
"separately",
"to",
"each",
"dimension",
"designed",
"for",
"use",
"with",
":",
"py",
":",
"c... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L315-L365 | train |
markchil/gptools | gptools/kernel/warping.py | linear_warp | def linear_warp(X, d, n, *args):
r"""Warp inputs with a linear transformation.
Applies the warping
.. math::
w(x) = \frac{x-a}{b-a}
to each dimension. If you set `a=min(X)` and `b=max(X)` then this is a
convenient way to map your inputs to the unit hypercube.
... | python | def linear_warp(X, d, n, *args):
r"""Warp inputs with a linear transformation.
Applies the warping
.. math::
w(x) = \frac{x-a}{b-a}
to each dimension. If you set `a=min(X)` and `b=max(X)` then this is a
convenient way to map your inputs to the unit hypercube.
... | [
"def",
"linear_warp",
"(",
"X",
",",
"d",
",",
"n",
",",
"*",
"args",
")",
":",
"X",
"=",
"scipy",
".",
"asarray",
"(",
"X",
",",
"dtype",
"=",
"float",
")",
"a",
"=",
"args",
"[",
"2",
"*",
"d",
"]",
"b",
"=",
"args",
"[",
"2",
"*",
"d",... | r"""Warp inputs with a linear transformation.
Applies the warping
.. math::
w(x) = \frac{x-a}{b-a}
to each dimension. If you set `a=min(X)` and `b=max(X)` then this is a
convenient way to map your inputs to the unit hypercube.
Parameters
----------
X : ar... | [
"r",
"Warp",
"inputs",
"with",
"a",
"linear",
"transformation",
".",
"Applies",
"the",
"warping",
"..",
"math",
"::",
"w",
"(",
"x",
")",
"=",
"\\",
"frac",
"{",
"x",
"-",
"a",
"}",
"{",
"b",
"-",
"a",
"}",
"to",
"each",
"dimension",
".",
"If",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L367-L402 | train |
markchil/gptools | gptools/kernel/warping.py | WarpedKernel.w_func | def w_func(self, X, d, n):
"""Evaluate the (possibly recursive) warping function and its derivatives.
Parameters
----------
X : array, (`M`,)
The points (from dimension `d`) to evaluate the warping function at.
d : int
The dimension to warp.
... | python | def w_func(self, X, d, n):
"""Evaluate the (possibly recursive) warping function and its derivatives.
Parameters
----------
X : array, (`M`,)
The points (from dimension `d`) to evaluate the warping function at.
d : int
The dimension to warp.
... | [
"def",
"w_func",
"(",
"self",
",",
"X",
",",
"d",
",",
"n",
")",
":",
"if",
"n",
"==",
"0",
":",
"wX",
"=",
"self",
".",
"w",
"(",
"X",
",",
"d",
",",
"0",
")",
"if",
"isinstance",
"(",
"self",
".",
"k",
",",
"WarpedKernel",
")",
":",
"wX... | Evaluate the (possibly recursive) warping function and its derivatives.
Parameters
----------
X : array, (`M`,)
The points (from dimension `d`) to evaluate the warping function at.
d : int
The dimension to warp.
n : int
The derivative ... | [
"Evaluate",
"the",
"(",
"possibly",
"recursive",
")",
"warping",
"function",
"and",
"its",
"derivatives",
".",
"Parameters",
"----------",
"X",
":",
"array",
"(",
"M",
")",
"The",
"points",
"(",
"from",
"dimension",
"d",
")",
"to",
"evaluate",
"the",
"warp... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L507-L531 | train |
markchil/gptools | gptools/kernel/warping.py | WarpedKernel.enforce_bounds | def enforce_bounds(self, v):
"""Set `enforce_bounds` for both of the kernels to a new value.
"""
self._enforce_bounds = v
self.k.enforce_bounds = v
self.w.enforce_bounds = v | python | def enforce_bounds(self, v):
"""Set `enforce_bounds` for both of the kernels to a new value.
"""
self._enforce_bounds = v
self.k.enforce_bounds = v
self.w.enforce_bounds = v | [
"def",
"enforce_bounds",
"(",
"self",
",",
"v",
")",
":",
"self",
".",
"_enforce_bounds",
"=",
"v",
"self",
".",
"k",
".",
"enforce_bounds",
"=",
"v",
"self",
".",
"w",
".",
"enforce_bounds",
"=",
"v"
] | Set `enforce_bounds` for both of the kernels to a new value. | [
"Set",
"enforce_bounds",
"for",
"both",
"of",
"the",
"kernels",
"to",
"a",
"new",
"value",
"."
] | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L540-L545 | train |
markchil/gptools | gptools/kernel/warping.py | WarpedKernel.free_params | def free_params(self, value):
"""Set the free parameters. Note that this bypasses enforce_bounds.
"""
value = scipy.asarray(value, dtype=float)
self.K_up_to_date = False
self.k.free_params = value[:self.k.num_free_params]
self.w.free_params = value[self.k.num_free_params:... | python | def free_params(self, value):
"""Set the free parameters. Note that this bypasses enforce_bounds.
"""
value = scipy.asarray(value, dtype=float)
self.K_up_to_date = False
self.k.free_params = value[:self.k.num_free_params]
self.w.free_params = value[self.k.num_free_params:... | [
"def",
"free_params",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"scipy",
".",
"asarray",
"(",
"value",
",",
"dtype",
"=",
"float",
")",
"self",
".",
"K_up_to_date",
"=",
"False",
"self",
".",
"k",
".",
"free_params",
"=",
"value",
"[",
":",
... | Set the free parameters. Note that this bypasses enforce_bounds. | [
"Set",
"the",
"free",
"parameters",
".",
"Note",
"that",
"this",
"bypasses",
"enforce_bounds",
"."
] | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L582-L588 | train |
markchil/gptools | gptools/kernel/warping.py | WarpedKernel.set_hyperparams | def set_hyperparams(self, new_params):
"""Set the (free) hyperparameters.
Parameters
----------
new_params : :py:class:`Array` or other Array-like
New values of the free parameters.
Raises
------
ValueError
If the length o... | python | def set_hyperparams(self, new_params):
"""Set the (free) hyperparameters.
Parameters
----------
new_params : :py:class:`Array` or other Array-like
New values of the free parameters.
Raises
------
ValueError
If the length o... | [
"def",
"set_hyperparams",
"(",
"self",
",",
"new_params",
")",
":",
"new_params",
"=",
"scipy",
".",
"asarray",
"(",
"new_params",
",",
"dtype",
"=",
"float",
")",
"if",
"len",
"(",
"new_params",
")",
"==",
"len",
"(",
"self",
".",
"free_params",
")",
... | Set the (free) hyperparameters.
Parameters
----------
new_params : :py:class:`Array` or other Array-like
New values of the free parameters.
Raises
------
ValueError
If the length of `new_params` is not consistent with :py:attr:`se... | [
"Set",
"the",
"(",
"free",
")",
"hyperparameters",
".",
"Parameters",
"----------",
"new_params",
":",
":",
"py",
":",
"class",
":",
"Array",
"or",
"other",
"Array",
"-",
"like",
"New",
"values",
"of",
"the",
"free",
"parameters",
".",
"Raises",
"------",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L611-L631 | train |
codenerix/django-codenerix | codenerix/multiforms.py | MultiForm.get | def get(self, request, *args, **kwargs):
"""
Handles GET requests and instantiates blank versions of the form and its inline formsets.
"""
# Prepare base
if 'pk' in kwargs:
self.object = self.get_object()
else:
self.object = None
form_clas... | python | def get(self, request, *args, **kwargs):
"""
Handles GET requests and instantiates blank versions of the form and its inline formsets.
"""
# Prepare base
if 'pk' in kwargs:
self.object = self.get_object()
else:
self.object = None
form_clas... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Prepare base",
"if",
"'pk'",
"in",
"kwargs",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"else",
":",
"self",
".",
"object"... | Handles GET requests and instantiates blank versions of the form and its inline formsets. | [
"Handles",
"GET",
"requests",
"and",
"instantiates",
"blank",
"versions",
"of",
"the",
"form",
"and",
"its",
"inline",
"formsets",
"."
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/multiforms.py#L51-L160 | train |
codenerix/django-codenerix | codenerix/multiforms.py | MultiForm.post | def post(self, request, *args, **kwargs):
"""
andles POST requests, instantiating a form instance and its inline formsets with the passed POST variables and then checking them for validity.
"""
# Prepare base
if 'pk' in kwargs:
self.object = self.get_object()
... | python | def post(self, request, *args, **kwargs):
"""
andles POST requests, instantiating a form instance and its inline formsets with the passed POST variables and then checking them for validity.
"""
# Prepare base
if 'pk' in kwargs:
self.object = self.get_object()
... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Prepare base",
"if",
"'pk'",
"in",
"kwargs",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"else",
":",
"self",
".",
"object... | andles POST requests, instantiating a form instance and its inline formsets with the passed POST variables and then checking them for validity. | [
"andles",
"POST",
"requests",
"instantiating",
"a",
"form",
"instance",
"and",
"its",
"inline",
"formsets",
"with",
"the",
"passed",
"POST",
"variables",
"and",
"then",
"checking",
"them",
"for",
"validity",
"."
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/multiforms.py#L162-L309 | train |
codenerix/django-codenerix | codenerix/multiforms.py | MultiForm.form_valid | def form_valid(self, form, forms):
"""
Called if all forms are valid. Creates a Recipe instance along with associated Ingredients and Instructions and then redirects to a success page.
"""
if self.object:
form.save()
for (formobj, linkerfield) in forms:
... | python | def form_valid(self, form, forms):
"""
Called if all forms are valid. Creates a Recipe instance along with associated Ingredients and Instructions and then redirects to a success page.
"""
if self.object:
form.save()
for (formobj, linkerfield) in forms:
... | [
"def",
"form_valid",
"(",
"self",
",",
"form",
",",
"forms",
")",
":",
"if",
"self",
".",
"object",
":",
"form",
".",
"save",
"(",
")",
"for",
"(",
"formobj",
",",
"linkerfield",
")",
"in",
"forms",
":",
"if",
"form",
"!=",
"formobj",
":",
"formobj... | Called if all forms are valid. Creates a Recipe instance along with associated Ingredients and Instructions and then redirects to a success page. | [
"Called",
"if",
"all",
"forms",
"are",
"valid",
".",
"Creates",
"a",
"Recipe",
"instance",
"along",
"with",
"associated",
"Ingredients",
"and",
"Instructions",
"and",
"then",
"redirects",
"to",
"a",
"success",
"page",
"."
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/multiforms.py#L312-L327 | train |
codenerix/django-codenerix | codenerix/multiforms.py | MultiForm.form_invalid | def form_invalid(self, form, forms, open_tabs, position_form_default):
"""
Called if a form is invalid. Re-renders the context data with the data-filled forms and errors.
"""
# return self.render_to_response( self.get_context_data( form = form, forms = forms ) )
return self.rende... | python | def form_invalid(self, form, forms, open_tabs, position_form_default):
"""
Called if a form is invalid. Re-renders the context data with the data-filled forms and errors.
"""
# return self.render_to_response( self.get_context_data( form = form, forms = forms ) )
return self.rende... | [
"def",
"form_invalid",
"(",
"self",
",",
"form",
",",
"forms",
",",
"open_tabs",
",",
"position_form_default",
")",
":",
"# return self.render_to_response( self.get_context_data( form = form, forms = forms ) )",
"return",
"self",
".",
"render_to_response",
"(",
"self",
".",... | Called if a form is invalid. Re-renders the context data with the data-filled forms and errors. | [
"Called",
"if",
"a",
"form",
"is",
"invalid",
".",
"Re",
"-",
"renders",
"the",
"context",
"data",
"with",
"the",
"data",
"-",
"filled",
"forms",
"and",
"errors",
"."
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/multiforms.py#L329-L334 | train |
markchil/gptools | gptools/utils.py | wrap_fmin_slsqp | def wrap_fmin_slsqp(fun, guess, opt_kwargs={}):
"""Wrapper for :py:func:`fmin_slsqp` to allow it to be called with :py:func:`minimize`-like syntax.
This is included to enable the code to run with :py:mod:`scipy` versions
older than 0.11.0.
Accepts `opt_kwargs` in the same format as used by
:py:fun... | python | def wrap_fmin_slsqp(fun, guess, opt_kwargs={}):
"""Wrapper for :py:func:`fmin_slsqp` to allow it to be called with :py:func:`minimize`-like syntax.
This is included to enable the code to run with :py:mod:`scipy` versions
older than 0.11.0.
Accepts `opt_kwargs` in the same format as used by
:py:fun... | [
"def",
"wrap_fmin_slsqp",
"(",
"fun",
",",
"guess",
",",
"opt_kwargs",
"=",
"{",
"}",
")",
":",
"opt_kwargs",
"=",
"dict",
"(",
"opt_kwargs",
")",
"opt_kwargs",
".",
"pop",
"(",
"'method'",
",",
"None",
")",
"eqcons",
"=",
"[",
"]",
"ieqcons",
"=",
"... | Wrapper for :py:func:`fmin_slsqp` to allow it to be called with :py:func:`minimize`-like syntax.
This is included to enable the code to run with :py:mod:`scipy` versions
older than 0.11.0.
Accepts `opt_kwargs` in the same format as used by
:py:func:`scipy.optimize.minimize`, with the additional precon... | [
"Wrapper",
"for",
":",
"py",
":",
"func",
":",
"fmin_slsqp",
"to",
"allow",
"it",
"to",
"be",
"called",
"with",
":",
"py",
":",
"func",
":",
"minimize",
"-",
"like",
"syntax",
"."
] | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1269-L1367 | train |
markchil/gptools | gptools/utils.py | fixed_poch | def fixed_poch(a, n):
"""Implementation of the Pochhammer symbol :math:`(a)_n` which handles negative integer arguments properly.
Need conditional statement because scipy's impelementation of the Pochhammer
symbol is wrong for negative integer arguments. This function uses the
definition from
h... | python | def fixed_poch(a, n):
"""Implementation of the Pochhammer symbol :math:`(a)_n` which handles negative integer arguments properly.
Need conditional statement because scipy's impelementation of the Pochhammer
symbol is wrong for negative integer arguments. This function uses the
definition from
h... | [
"def",
"fixed_poch",
"(",
"a",
",",
"n",
")",
":",
"# Old form, calls gamma function:",
"# if a < 0.0 and a % 1 == 0 and n <= -a:",
"# p = (-1.0)**n * scipy.misc.factorial(-a) / scipy.misc.factorial(-a - n)",
"# else:",
"# p = scipy.special.poch(a, n)",
"# return p",
"if",
"(",... | Implementation of the Pochhammer symbol :math:`(a)_n` which handles negative integer arguments properly.
Need conditional statement because scipy's impelementation of the Pochhammer
symbol is wrong for negative integer arguments. This function uses the
definition from
http://functions.wolfram.com/G... | [
"Implementation",
"of",
"the",
"Pochhammer",
"symbol",
":",
"math",
":",
"(",
"a",
")",
"_n",
"which",
"handles",
"negative",
"integer",
"arguments",
"properly",
".",
"Need",
"conditional",
"statement",
"because",
"scipy",
"s",
"impelementation",
"of",
"the",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1369-L1395 | train |
markchil/gptools | gptools/utils.py | Kn2Der | def Kn2Der(nu, y, n=0):
r"""Find the derivatives of :math:`K_\nu(y^{1/2})`.
Parameters
----------
nu : float
The order of the modified Bessel function of the second kind.
y : array of float
The values to evaluate at.
n : nonnegative int, optional
The order of derivat... | python | def Kn2Der(nu, y, n=0):
r"""Find the derivatives of :math:`K_\nu(y^{1/2})`.
Parameters
----------
nu : float
The order of the modified Bessel function of the second kind.
y : array of float
The values to evaluate at.
n : nonnegative int, optional
The order of derivat... | [
"def",
"Kn2Der",
"(",
"nu",
",",
"y",
",",
"n",
"=",
"0",
")",
":",
"n",
"=",
"int",
"(",
"n",
")",
"y",
"=",
"scipy",
".",
"asarray",
"(",
"y",
",",
"dtype",
"=",
"float",
")",
"sqrty",
"=",
"scipy",
".",
"sqrt",
"(",
"y",
")",
"if",
"n"... | r"""Find the derivatives of :math:`K_\nu(y^{1/2})`.
Parameters
----------
nu : float
The order of the modified Bessel function of the second kind.
y : array of float
The values to evaluate at.
n : nonnegative int, optional
The order of derivative to take. | [
"r",
"Find",
"the",
"derivatives",
"of",
":",
"math",
":",
"K_",
"\\",
"nu",
"(",
"y^",
"{",
"1",
"/",
"2",
"}",
")",
".",
"Parameters",
"----------",
"nu",
":",
"float",
"The",
"order",
"of",
"the",
"modified",
"Bessel",
"function",
"of",
"the",
"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1397-L1427 | train |
markchil/gptools | gptools/utils.py | yn2Kn2Der | def yn2Kn2Der(nu, y, n=0, tol=5e-4, nterms=1, nu_step=0.001):
r"""Computes the function :math:`y^{\nu/2} K_{\nu}(y^{1/2})` and its derivatives.
Care has been taken to handle the conditions at :math:`y=0`.
For `n=0`, uses a direct evaluation of the expression, replacing points
where `y=0` with ... | python | def yn2Kn2Der(nu, y, n=0, tol=5e-4, nterms=1, nu_step=0.001):
r"""Computes the function :math:`y^{\nu/2} K_{\nu}(y^{1/2})` and its derivatives.
Care has been taken to handle the conditions at :math:`y=0`.
For `n=0`, uses a direct evaluation of the expression, replacing points
where `y=0` with ... | [
"def",
"yn2Kn2Der",
"(",
"nu",
",",
"y",
",",
"n",
"=",
"0",
",",
"tol",
"=",
"5e-4",
",",
"nterms",
"=",
"1",
",",
"nu_step",
"=",
"0.001",
")",
":",
"n",
"=",
"int",
"(",
"n",
")",
"y",
"=",
"scipy",
".",
"asarray",
"(",
"y",
",",
"dtype"... | r"""Computes the function :math:`y^{\nu/2} K_{\nu}(y^{1/2})` and its derivatives.
Care has been taken to handle the conditions at :math:`y=0`.
For `n=0`, uses a direct evaluation of the expression, replacing points
where `y=0` with the appropriate value. For `n>0`, uses a general sum
expressio... | [
"r",
"Computes",
"the",
"function",
":",
"math",
":",
"y^",
"{",
"\\",
"nu",
"/",
"2",
"}",
"K_",
"{",
"\\",
"nu",
"}",
"(",
"y^",
"{",
"1",
"/",
"2",
"}",
")",
"and",
"its",
"derivatives",
".",
"Care",
"has",
"been",
"taken",
"to",
"handle",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1429-L1518 | train |
markchil/gptools | gptools/utils.py | incomplete_bell_poly | def incomplete_bell_poly(n, k, x):
r"""Recursive evaluation of the incomplete Bell polynomial :math:`B_{n, k}(x)`.
Evaluates the incomplete Bell polynomial :math:`B_{n, k}(x_1, x_2, \dots, x_{n-k+1})`,
also known as the partial Bell polynomial or the Bell polynomial of the
second kind. This polynom... | python | def incomplete_bell_poly(n, k, x):
r"""Recursive evaluation of the incomplete Bell polynomial :math:`B_{n, k}(x)`.
Evaluates the incomplete Bell polynomial :math:`B_{n, k}(x_1, x_2, \dots, x_{n-k+1})`,
also known as the partial Bell polynomial or the Bell polynomial of the
second kind. This polynom... | [
"def",
"incomplete_bell_poly",
"(",
"n",
",",
"k",
",",
"x",
")",
":",
"if",
"n",
"==",
"0",
"and",
"k",
"==",
"0",
":",
"return",
"scipy",
".",
"ones",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"float",
")",
"elif",
"k",
"=="... | r"""Recursive evaluation of the incomplete Bell polynomial :math:`B_{n, k}(x)`.
Evaluates the incomplete Bell polynomial :math:`B_{n, k}(x_1, x_2, \dots, x_{n-k+1})`,
also known as the partial Bell polynomial or the Bell polynomial of the
second kind. This polynomial is useful in the evaluation of (the... | [
"r",
"Recursive",
"evaluation",
"of",
"the",
"incomplete",
"Bell",
"polynomial",
":",
"math",
":",
"B_",
"{",
"n",
"k",
"}",
"(",
"x",
")",
".",
"Evaluates",
"the",
"incomplete",
"Bell",
"polynomial",
":",
"math",
":",
"B_",
"{",
"n",
"k",
"}",
"(",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1520-L1570 | train |
markchil/gptools | gptools/utils.py | generate_set_partition_strings | def generate_set_partition_strings(n):
"""Generate the restricted growth strings for all of the partitions of an `n`-member set.
Uses Algorithm H from page 416 of volume 4A of Knuth's `The Art of Computer
Programming`. Returns the partitions in lexicographical order.
Parameters
----------
... | python | def generate_set_partition_strings(n):
"""Generate the restricted growth strings for all of the partitions of an `n`-member set.
Uses Algorithm H from page 416 of volume 4A of Knuth's `The Art of Computer
Programming`. Returns the partitions in lexicographical order.
Parameters
----------
... | [
"def",
"generate_set_partition_strings",
"(",
"n",
")",
":",
"# Handle edge cases:",
"if",
"n",
"==",
"0",
":",
"return",
"[",
"]",
"elif",
"n",
"==",
"1",
":",
"return",
"[",
"scipy",
".",
"array",
"(",
"[",
"0",
"]",
")",
"]",
"partitions",
"=",
"[... | Generate the restricted growth strings for all of the partitions of an `n`-member set.
Uses Algorithm H from page 416 of volume 4A of Knuth's `The Art of Computer
Programming`. Returns the partitions in lexicographical order.
Parameters
----------
n : scalar int, non-negative
Numbe... | [
"Generate",
"the",
"restricted",
"growth",
"strings",
"for",
"all",
"of",
"the",
"partitions",
"of",
"an",
"n",
"-",
"member",
"set",
".",
"Uses",
"Algorithm",
"H",
"from",
"page",
"416",
"of",
"volume",
"4A",
"of",
"Knuth",
"s",
"The",
"Art",
"of",
"C... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1572-L1624 | train |
markchil/gptools | gptools/utils.py | generate_set_partitions | def generate_set_partitions(set_):
"""Generate all of the partitions of a set.
This is a helper function that utilizes the restricted growth strings from
:py:func:`generate_set_partition_strings`. The partitions are returned in
lexicographic order.
Parameters
----------
set_ : :py:... | python | def generate_set_partitions(set_):
"""Generate all of the partitions of a set.
This is a helper function that utilizes the restricted growth strings from
:py:func:`generate_set_partition_strings`. The partitions are returned in
lexicographic order.
Parameters
----------
set_ : :py:... | [
"def",
"generate_set_partitions",
"(",
"set_",
")",
":",
"set_",
"=",
"scipy",
".",
"asarray",
"(",
"set_",
")",
"strings",
"=",
"generate_set_partition_strings",
"(",
"len",
"(",
"set_",
")",
")",
"partitions",
"=",
"[",
"]",
"for",
"string",
"in",
"strin... | Generate all of the partitions of a set.
This is a helper function that utilizes the restricted growth strings from
:py:func:`generate_set_partition_strings`. The partitions are returned in
lexicographic order.
Parameters
----------
set_ : :py:class:`Array` or other Array-like, (`m`,)
... | [
"Generate",
"all",
"of",
"the",
"partitions",
"of",
"a",
"set",
".",
"This",
"is",
"a",
"helper",
"function",
"that",
"utilizes",
"the",
"restricted",
"growth",
"strings",
"from",
":",
"py",
":",
"func",
":",
"generate_set_partition_strings",
".",
"The",
"pa... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1626-L1656 | train |
markchil/gptools | gptools/utils.py | unique_rows | def unique_rows(arr, return_index=False, return_inverse=False):
"""Returns a copy of arr with duplicate rows removed.
From Stackoverflow "Find unique rows in numpy.array."
Parameters
----------
arr : :py:class:`Array`, (`m`, `n`)
The array to find the unique rows of.
return_ind... | python | def unique_rows(arr, return_index=False, return_inverse=False):
"""Returns a copy of arr with duplicate rows removed.
From Stackoverflow "Find unique rows in numpy.array."
Parameters
----------
arr : :py:class:`Array`, (`m`, `n`)
The array to find the unique rows of.
return_ind... | [
"def",
"unique_rows",
"(",
"arr",
",",
"return_index",
"=",
"False",
",",
"return_inverse",
"=",
"False",
")",
":",
"b",
"=",
"scipy",
".",
"ascontiguousarray",
"(",
"arr",
")",
".",
"view",
"(",
"scipy",
".",
"dtype",
"(",
"(",
"scipy",
".",
"void",
... | Returns a copy of arr with duplicate rows removed.
From Stackoverflow "Find unique rows in numpy.array."
Parameters
----------
arr : :py:class:`Array`, (`m`, `n`)
The array to find the unique rows of.
return_index : bool, optional
If True, the indices of the unique rows in ... | [
"Returns",
"a",
"copy",
"of",
"arr",
"with",
"duplicate",
"rows",
"removed",
".",
"From",
"Stackoverflow",
"Find",
"unique",
"rows",
"in",
"numpy",
".",
"array",
".",
"Parameters",
"----------",
"arr",
":",
":",
"py",
":",
"class",
":",
"Array",
"(",
"m"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1666-L1721 | train |
markchil/gptools | gptools/utils.py | compute_stats | def compute_stats(vals, check_nan=False, robust=False, axis=1, plot_QQ=False, bins=15, name=''):
"""Compute the average statistics (mean, std dev) for the given values.
Parameters
----------
vals : array-like, (`M`, `D`)
Values to compute the average statistics along the specified axis of.
... | python | def compute_stats(vals, check_nan=False, robust=False, axis=1, plot_QQ=False, bins=15, name=''):
"""Compute the average statistics (mean, std dev) for the given values.
Parameters
----------
vals : array-like, (`M`, `D`)
Values to compute the average statistics along the specified axis of.
... | [
"def",
"compute_stats",
"(",
"vals",
",",
"check_nan",
"=",
"False",
",",
"robust",
"=",
"False",
",",
"axis",
"=",
"1",
",",
"plot_QQ",
"=",
"False",
",",
"bins",
"=",
"15",
",",
"name",
"=",
"''",
")",
":",
"if",
"axis",
"!=",
"1",
"and",
"robu... | Compute the average statistics (mean, std dev) for the given values.
Parameters
----------
vals : array-like, (`M`, `D`)
Values to compute the average statistics along the specified axis of.
check_nan : bool, optional
Whether or not to check for (and exclude) NaN's. Default is False... | [
"Compute",
"the",
"average",
"statistics",
"(",
"mean",
"std",
"dev",
")",
"for",
"the",
"given",
"values",
".",
"Parameters",
"----------",
"vals",
":",
"array",
"-",
"like",
"(",
"M",
"D",
")",
"Values",
"to",
"compute",
"the",
"average",
"statistics",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1767-L1899 | train |
markchil/gptools | gptools/utils.py | univariate_envelope_plot | def univariate_envelope_plot(x, mean, std, ax=None, base_alpha=0.375, envelopes=[1, 3], lb=None, ub=None, expansion=10, **kwargs):
"""Make a plot of a mean curve with uncertainty envelopes.
"""
if ax is None:
f = plt.figure()
ax = f.add_subplot(1, 1, 1)
elif ax == 'gca':
ax = plt... | python | def univariate_envelope_plot(x, mean, std, ax=None, base_alpha=0.375, envelopes=[1, 3], lb=None, ub=None, expansion=10, **kwargs):
"""Make a plot of a mean curve with uncertainty envelopes.
"""
if ax is None:
f = plt.figure()
ax = f.add_subplot(1, 1, 1)
elif ax == 'gca':
ax = plt... | [
"def",
"univariate_envelope_plot",
"(",
"x",
",",
"mean",
",",
"std",
",",
"ax",
"=",
"None",
",",
"base_alpha",
"=",
"0.375",
",",
"envelopes",
"=",
"[",
"1",
",",
"3",
"]",
",",
"lb",
"=",
"None",
",",
"ub",
"=",
"None",
",",
"expansion",
"=",
... | Make a plot of a mean curve with uncertainty envelopes. | [
"Make",
"a",
"plot",
"of",
"a",
"mean",
"curve",
"with",
"uncertainty",
"envelopes",
"."
] | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1901-L1936 | train |
markchil/gptools | gptools/utils.py | summarize_sampler | def summarize_sampler(sampler, weights=None, burn=0, ci=0.95, chain_mask=None):
r"""Create summary statistics of the flattened chain of the sampler.
The confidence regions are computed from the quantiles of the data.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or arr... | python | def summarize_sampler(sampler, weights=None, burn=0, ci=0.95, chain_mask=None):
r"""Create summary statistics of the flattened chain of the sampler.
The confidence regions are computed from the quantiles of the data.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or arr... | [
"def",
"summarize_sampler",
"(",
"sampler",
",",
"weights",
"=",
"None",
",",
"burn",
"=",
"0",
",",
"ci",
"=",
"0.95",
",",
"chain_mask",
"=",
"None",
")",
":",
"try",
":",
"k",
"=",
"sampler",
".",
"flatchain",
".",
"shape",
"[",
"-",
"1",
"]",
... | r"""Create summary statistics of the flattened chain of the sampler.
The confidence regions are computed from the quantiles of the data.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or array, (`n_temps`, `n_chains`, `n_samp`, `n_dim`), (`n_chains`, `n_samp`, `n_dim`) or (... | [
"r",
"Create",
"summary",
"statistics",
"of",
"the",
"flattened",
"chain",
"of",
"the",
"sampler",
".",
"The",
"confidence",
"regions",
"are",
"computed",
"from",
"the",
"quantiles",
"of",
"the",
"data",
".",
"Parameters",
"----------",
"sampler",
":",
":",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1938-L2030 | train |
markchil/gptools | gptools/utils.py | plot_sampler | def plot_sampler(
sampler, suptitle=None, labels=None, bins=50,
plot_samples=False, plot_hist=True, plot_chains=True,
burn=0, chain_mask=None, temp_idx=0, weights=None, cutoff_weight=None,
cmap='gray_r', hist_color='k', chain_alpha=0.1,
points=None, covs=None, colors=None, ci=[0.... | python | def plot_sampler(
sampler, suptitle=None, labels=None, bins=50,
plot_samples=False, plot_hist=True, plot_chains=True,
burn=0, chain_mask=None, temp_idx=0, weights=None, cutoff_weight=None,
cmap='gray_r', hist_color='k', chain_alpha=0.1,
points=None, covs=None, colors=None, ci=[0.... | [
"def",
"plot_sampler",
"(",
"sampler",
",",
"suptitle",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"bins",
"=",
"50",
",",
"plot_samples",
"=",
"False",
",",
"plot_hist",
"=",
"True",
",",
"plot_chains",
"=",
"True",
",",
"burn",
"=",
"0",
",",
"c... | Plot the results of MCMC sampler (posterior and chains).
Loosely based on triangle.py. Provides extensive options to format the plot.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or array, (`n_temps`, `n_chains`, `n_samp`, `n_dim`), (`n_chains`, `n_samp`, `n_dim`) or (`n_... | [
"Plot",
"the",
"results",
"of",
"MCMC",
"sampler",
"(",
"posterior",
"and",
"chains",
")",
".",
"Loosely",
"based",
"on",
"triangle",
".",
"py",
".",
"Provides",
"extensive",
"options",
"to",
"format",
"the",
"plot",
".",
"Parameters",
"----------",
"sampler... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L2032-L2439 | train |
markchil/gptools | gptools/utils.py | plot_sampler_fingerprint | def plot_sampler_fingerprint(
sampler, hyperprior, weights=None, cutoff_weight=None, nbins=None,
labels=None, burn=0, chain_mask=None, temp_idx=0, points=None,
plot_samples=False, sample_color='k', point_color=None, point_lw=3,
title='', rot_x_labels=False, figsize=None
):
"""Mak... | python | def plot_sampler_fingerprint(
sampler, hyperprior, weights=None, cutoff_weight=None, nbins=None,
labels=None, burn=0, chain_mask=None, temp_idx=0, points=None,
plot_samples=False, sample_color='k', point_color=None, point_lw=3,
title='', rot_x_labels=False, figsize=None
):
"""Mak... | [
"def",
"plot_sampler_fingerprint",
"(",
"sampler",
",",
"hyperprior",
",",
"weights",
"=",
"None",
",",
"cutoff_weight",
"=",
"None",
",",
"nbins",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"burn",
"=",
"0",
",",
"chain_mask",
"=",
"None",
",",
"temp... | Make a plot of the sampler's "fingerprint": univariate marginal histograms for all hyperparameters.
The hyperparameters are mapped to [0, 1] using
:py:meth:`hyperprior.elementwise_cdf`, so this can only be used with prior
distributions which implement this function.
Returns the figure and axis... | [
"Make",
"a",
"plot",
"of",
"the",
"sampler",
"s",
"fingerprint",
":",
"univariate",
"marginal",
"histograms",
"for",
"all",
"hyperparameters",
".",
"The",
"hyperparameters",
"are",
"mapped",
"to",
"[",
"0",
"1",
"]",
"using",
":",
"py",
":",
"meth",
":",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L2441-L2614 | train |
markchil/gptools | gptools/utils.py | plot_sampler_cov | def plot_sampler_cov(
sampler, method='corr', weights=None, cutoff_weight=None, labels=None,
burn=0, chain_mask=None, temp_idx=0, cbar_label=None, title='',
rot_x_labels=False, figsize=None, xlabel_on_top=True
):
"""Make a plot of the sampler's correlation or covariance matrix.
... | python | def plot_sampler_cov(
sampler, method='corr', weights=None, cutoff_weight=None, labels=None,
burn=0, chain_mask=None, temp_idx=0, cbar_label=None, title='',
rot_x_labels=False, figsize=None, xlabel_on_top=True
):
"""Make a plot of the sampler's correlation or covariance matrix.
... | [
"def",
"plot_sampler_cov",
"(",
"sampler",
",",
"method",
"=",
"'corr'",
",",
"weights",
"=",
"None",
",",
"cutoff_weight",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"burn",
"=",
"0",
",",
"chain_mask",
"=",
"None",
",",
"temp_idx",
"=",
"0",
",",
... | Make a plot of the sampler's correlation or covariance matrix.
Returns the figure and axis created.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or array, (`n_temps`, `n_chains`, `n_samp`, `n_dim`), (`n_chains`, `n_samp`, `n_dim`) or (`n_samp`, `n_dim`)
The sample... | [
"Make",
"a",
"plot",
"of",
"the",
"sampler",
"s",
"correlation",
"or",
"covariance",
"matrix",
".",
"Returns",
"the",
"figure",
"and",
"axis",
"created",
".",
"Parameters",
"----------",
"sampler",
":",
":",
"py",
":",
"class",
":",
"emcee",
".",
"Sampler"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L2616-L2752 | train |
markchil/gptools | gptools/utils.py | ProductJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"p1_num_params",
"=",
"len",
"(",
"self",
".",
"p1",
".",
"bounds",
")",
"return",
"scipy",
".",
"concatenate",
"(",
"(",
"self",
".",
"p1",
".",
"sample_u",
"(",
"q",
"[",
":",
"p1_num_params",
"... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L285-L306 | train |
markchil/gptools | gptools/utils.py | ProductJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p1_num_params",
"=",
"len",
"(",
"self",
".",
"p1",
".",
"bounds",
")",
"return",
"scipy",
".",
"concatenate",
"(",
"(",
"self",
".",
"p1",
".",
"elementwise_cdf",
"(",
"p",
"[",
":",
"p1_nu... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L308-L330 | train |
markchil/gptools | gptools/utils.py | ProductJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
The outputs of the two priors are stacked vertically.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only o... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
The outputs of the two priors are stacked vertically.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only o... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"draw_1",
"=",
"self",
".",
"p1",
".",
"random_draw",
"(",
"size",
"=",
"size",
")",
"draw_2",
"=",
"self",
".",
"p2",
".",
"random_draw",
"(",
"size",
"=",
"size",
")",
"if",
... | Draw random samples of the hyperparameters.
The outputs of the two priors are stacked vertically.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is... | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"The",
"outputs",
"of",
"the",
"two",
"priors",
"are",
"stacked",
"vertically",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"num... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L332-L349 | train |
markchil/gptools | gptools/utils.py | UniformJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"bounds",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of ... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L392-L414 | train |
markchil/gptools | gptools/utils.py | UniformJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"bounds",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the num... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L416-L445 | train |
markchil/gptools | gptools/utils.py | UniformJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"numpy",
".",
"random",
".",
"uniform",
"(",
"low",
"=",
"b",
"[",
"0",
"]",
",",
"high",
"=",
"b",
"[",
"1",
"]",
",",
"size",
... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L447-L456 | train |
markchil/gptools | gptools/utils.py | CoreEdgeJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"1",
"single_val",
"=",
"True",
"else",
":",
"single_val",
"=",
"False",
"out_shape",
"=",
"[",
"len",
"(",
"self",
".",
"bounds",
... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L520-L554 | train |
markchil/gptools | gptools/utils.py | IndependentJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"univariate_priors",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L708-L730 | train |
markchil/gptools | gptools/utils.py | IndependentJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"univariate_priors",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must eq... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L732-L753 | train |
markchil/gptools | gptools/utils.py | IndependentJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"p",
".",
"rvs",
"(",
"size",
"=",
"size",
")",
"for",
"p",
"in",
"self",
".",
"univariate_priors",
"]",
")"
] | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L755-L764 | train |
markchil/gptools | gptools/utils.py | NormalJointPrior.bounds | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.norm.interval(self.i, loc=m, scale=s) for s, m in z... | python | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.norm.interval(self.i, loc=m, scale=s) for s, m in z... | [
"def",
"bounds",
"(",
"self",
")",
":",
"return",
"[",
"scipy",
".",
"stats",
".",
"norm",
".",
"interval",
"(",
"self",
".",
"i",
",",
"loc",
"=",
"m",
",",
"scale",
"=",
"s",
")",
"for",
"s",
",",
"m",
"in",
"zip",
"(",
"self",
".",
"sigma"... | The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful. | [
"The",
"bounds",
"of",
"the",
"random",
"variable",
".",
"Set",
"self",
".",
"i",
"=",
"0",
".",
"95",
"to",
"return",
"the",
"95%",
"interval",
"if",
"this",
"is",
"used",
"for",
"setting",
"bounds",
"on",
"optimizers",
"/",
"etc",
".",
"where",
"in... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L803-L809 | train |
markchil/gptools | gptools/utils.py | NormalJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of p... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L811-L833 | train |
markchil/gptools | gptools/utils.py | NormalJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the numb... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L835-L856 | train |
markchil/gptools | gptools/utils.py | NormalJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"scipy",
".",
"stats",
".",
"norm",
".",
"rvs",
"(",
"loc",
"=",
"m",
",",
"scale",
"=",
"s",
",",
"size",
"=",
"size",
")",
"fo... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L858-L867 | train |
markchil/gptools | gptools/utils.py | LogNormalJointPrior.bounds | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.lognorm.interval(self.i, s, loc=0, scale=em) for s,... | python | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.lognorm.interval(self.i, s, loc=0, scale=em) for s,... | [
"def",
"bounds",
"(",
"self",
")",
":",
"return",
"[",
"scipy",
".",
"stats",
".",
"lognorm",
".",
"interval",
"(",
"self",
".",
"i",
",",
"s",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"em",
")",
"for",
"s",
",",
"em",
"in",
"zip",
"(",
"self... | The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful. | [
"The",
"bounds",
"of",
"the",
"random",
"variable",
".",
"Set",
"self",
".",
"i",
"=",
"0",
".",
"95",
"to",
"return",
"the",
"95%",
"interval",
"if",
"this",
"is",
"used",
"for",
"setting",
"bounds",
"on",
"optimizers",
"/",
"etc",
".",
"where",
"in... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L909-L915 | train |
markchil/gptools | gptools/utils.py | LogNormalJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of p... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L917-L939 | train |
markchil/gptools | gptools/utils.py | LogNormalJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the numb... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L941-L962 | train |
markchil/gptools | gptools/utils.py | LogNormalJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"scipy",
".",
"stats",
".",
"lognorm",
".",
"rvs",
"(",
"s",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"em",
",",
"size",
"=",
"s... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L964-L973 | train |
markchil/gptools | gptools/utils.py | GammaJointPrior.bounds | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.gamma.interval(self.i, a, loc=0, scale=1.0 / b) for... | python | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.gamma.interval(self.i, a, loc=0, scale=1.0 / b) for... | [
"def",
"bounds",
"(",
"self",
")",
":",
"return",
"[",
"scipy",
".",
"stats",
".",
"gamma",
".",
"interval",
"(",
"self",
".",
"i",
",",
"a",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"1.0",
"/",
"b",
")",
"for",
"a",
",",
"b",
"in",
"zip",
... | The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful. | [
"The",
"bounds",
"of",
"the",
"random",
"variable",
".",
"Set",
"self",
".",
"i",
"=",
"0",
".",
"95",
"to",
"return",
"the",
"95%",
"interval",
"if",
"this",
"is",
"used",
"for",
"setting",
"bounds",
"on",
"optimizers",
"/",
"etc",
".",
"where",
"in... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1015-L1021 | train |
markchil/gptools | gptools/utils.py | GammaJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"a",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of param... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1023-L1045 | train |
markchil/gptools | gptools/utils.py | GammaJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"a",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the number o... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1047-L1068 | train |
markchil/gptools | gptools/utils.py | GammaJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"scipy",
".",
"stats",
".",
"gamma",
".",
"rvs",
"(",
"a",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"1.0",
"/",
"b",
",",
"size"... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1070-L1079 | train |
markchil/gptools | gptools/utils.py | SortedUniformJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"self",
".",
"num_var",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of parameters!\"",
")",... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1154-L1189 | train |
markchil/gptools | gptools/utils.py | SortedUniformJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"bounds",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the num... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1191-L1233 | train |
markchil/gptools | gptools/utils.py | SortedUniformJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"1",
"single_val",
"=",
"True",
"else",
":",
"single_val",
"=",
"False",
"out_shape",
"=",
"[",
"self",
".",
"num_var",
"]",
"try",
... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1235-L1267 | train |
CTPUG/wafer | wafer/tickets/views.py | zapier_cancel_hook | def zapier_cancel_hook(request):
'''
Zapier can post something like this when tickets are cancelled
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKET... | python | def zapier_cancel_hook(request):
'''
Zapier can post something like this when tickets are cancelled
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKET... | [
"def",
"zapier_cancel_hook",
"(",
"request",
")",
":",
"if",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_X_ZAPIER_SECRET'",
",",
"None",
")",
"!=",
"settings",
".",
"WAFER_TICKETS_SECRET",
":",
"raise",
"PermissionDenied",
"(",
"'Incorrect secret'",
")",
"# ... | Zapier can post something like this when tickets are cancelled
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
} | [
"Zapier",
"can",
"post",
"something",
"like",
"this",
"when",
"tickets",
"are",
"cancelled",
"{",
"ticket_type",
":",
"Individual",
"(",
"Regular",
")",
"barcode",
":",
"12345678",
"email",
":",
"demo"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/tickets/views.py#L55-L73 | train |
CTPUG/wafer | wafer/tickets/views.py | zapier_guest_hook | def zapier_guest_hook(request):
'''
Zapier can POST something like this when tickets are bought:
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKETS_... | python | def zapier_guest_hook(request):
'''
Zapier can POST something like this when tickets are bought:
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKETS_... | [
"def",
"zapier_guest_hook",
"(",
"request",
")",
":",
"if",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_X_ZAPIER_SECRET'",
",",
"None",
")",
"!=",
"settings",
".",
"WAFER_TICKETS_SECRET",
":",
"raise",
"PermissionDenied",
"(",
"'Incorrect secret'",
")",
"# T... | Zapier can POST something like this when tickets are bought:
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
} | [
"Zapier",
"can",
"POST",
"something",
"like",
"this",
"when",
"tickets",
"are",
"bought",
":",
"{"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/tickets/views.py#L81-L99 | train |
cocaine/cocaine-framework-python | cocaine/detail/secadaptor.py | TVM.fetch_token | def fetch_token(self):
"""Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header.
"""
grant_type = 'client_credentials'
channel = yield self._tvm.ticket_full(
self._client_id, self._client_secret, grant_type, {})
ticket... | python | def fetch_token(self):
"""Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header.
"""
grant_type = 'client_credentials'
channel = yield self._tvm.ticket_full(
self._client_id, self._client_secret, grant_type, {})
ticket... | [
"def",
"fetch_token",
"(",
"self",
")",
":",
"grant_type",
"=",
"'client_credentials'",
"channel",
"=",
"yield",
"self",
".",
"_tvm",
".",
"ticket_full",
"(",
"self",
".",
"_client_id",
",",
"self",
".",
"_client_secret",
",",
"grant_type",
",",
"{",
"}",
... | Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header. | [
"Gains",
"token",
"from",
"secure",
"backend",
"service",
"."
] | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/secadaptor.py#L54-L65 | train |
cocaine/cocaine-framework-python | cocaine/detail/secadaptor.py | SecureServiceFabric.make_secure_adaptor | def make_secure_adaptor(service, mod, client_id, client_secret, tok_update_sec=None):
"""
:param service: Service to wrap in.
:param mod: Name (type) of token refresh backend.
:param client_id: Client identifier.
:param client_secret: Client secret.
:param tok_update_sec:... | python | def make_secure_adaptor(service, mod, client_id, client_secret, tok_update_sec=None):
"""
:param service: Service to wrap in.
:param mod: Name (type) of token refresh backend.
:param client_id: Client identifier.
:param client_secret: Client secret.
:param tok_update_sec:... | [
"def",
"make_secure_adaptor",
"(",
"service",
",",
"mod",
",",
"client_id",
",",
"client_secret",
",",
"tok_update_sec",
"=",
"None",
")",
":",
"if",
"mod",
"==",
"'TVM'",
":",
"return",
"SecureServiceAdaptor",
"(",
"service",
",",
"TVM",
"(",
"client_id",
"... | :param service: Service to wrap in.
:param mod: Name (type) of token refresh backend.
:param client_id: Client identifier.
:param client_secret: Client secret.
:param tok_update_sec: Token update interval in seconds. | [
":",
"param",
"service",
":",
"Service",
"to",
"wrap",
"in",
".",
":",
"param",
"mod",
":",
"Name",
"(",
"type",
")",
"of",
"token",
"refresh",
"backend",
".",
":",
"param",
"client_id",
":",
"Client",
"identifier",
".",
":",
"param",
"client_secret",
... | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/secadaptor.py#L131-L142 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | process_summary | def process_summary(summaryfile, **kwargs):
"""Extracting information from an albacore summary file.
Only reads which have a >0 length are returned.
The fields below may or may not exist, depending on the type of sequencing performed.
Fields 1-14 are for 1D sequencing.
Fields 1-23 for 2D sequencin... | python | def process_summary(summaryfile, **kwargs):
"""Extracting information from an albacore summary file.
Only reads which have a >0 length are returned.
The fields below may or may not exist, depending on the type of sequencing performed.
Fields 1-14 are for 1D sequencing.
Fields 1-23 for 2D sequencin... | [
"def",
"process_summary",
"(",
"summaryfile",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Collecting metrics from summary file {} for {} sequencing\"",
".",
"format",
"(",
"summaryfile",
",",
"kwargs",
"[",
"\"readtype\"",
"]",
")",
"... | Extracting information from an albacore summary file.
Only reads which have a >0 length are returned.
The fields below may or may not exist, depending on the type of sequencing performed.
Fields 1-14 are for 1D sequencing.
Fields 1-23 for 2D sequencing.
Fields 24-27, 2-5, 22-23 for 1D^2 (1D2) sequ... | [
"Extracting",
"information",
"from",
"an",
"albacore",
"summary",
"file",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L12-L90 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | check_bam | def check_bam(bam, samtype="bam"):
"""Check if bam file is valid.
Bam file should:
- exists
- has an index (create if necessary)
- is sorted by coordinate
- has at least one mapped read
"""
ut.check_existance(bam)
samfile = pysam.AlignmentFile(bam, "rb")
if not samfile.has_index... | python | def check_bam(bam, samtype="bam"):
"""Check if bam file is valid.
Bam file should:
- exists
- has an index (create if necessary)
- is sorted by coordinate
- has at least one mapped read
"""
ut.check_existance(bam)
samfile = pysam.AlignmentFile(bam, "rb")
if not samfile.has_index... | [
"def",
"check_bam",
"(",
"bam",
",",
"samtype",
"=",
"\"bam\"",
")",
":",
"ut",
".",
"check_existance",
"(",
"bam",
")",
"samfile",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"bam",
",",
"\"rb\"",
")",
"if",
"not",
"samfile",
".",
"has_index",
"(",
")",
... | Check if bam file is valid.
Bam file should:
- exists
- has an index (create if necessary)
- is sorted by coordinate
- has at least one mapped read | [
"Check",
"if",
"bam",
"file",
"is",
"valid",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L93-L117 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | process_ubam | def process_ubam(bam, **kwargs):
"""Extracting metrics from unaligned bam format
Extracting lengths
"""
logging.info("Nanoget: Starting to collect statistics from ubam file {}.".format(bam))
samfile = pysam.AlignmentFile(bam, "rb", check_sq=False)
if not samfile.has_index():
pysam.index(... | python | def process_ubam(bam, **kwargs):
"""Extracting metrics from unaligned bam format
Extracting lengths
"""
logging.info("Nanoget: Starting to collect statistics from ubam file {}.".format(bam))
samfile = pysam.AlignmentFile(bam, "rb", check_sq=False)
if not samfile.has_index():
pysam.index(... | [
"def",
"process_ubam",
"(",
"bam",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from ubam file {}.\"",
".",
"format",
"(",
"bam",
")",
")",
"samfile",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"bam",
... | Extracting metrics from unaligned bam format
Extracting lengths | [
"Extracting",
"metrics",
"from",
"unaligned",
"bam",
"format",
"Extracting",
"lengths"
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L120-L139 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | process_bam | def process_bam(bam, **kwargs):
"""Combines metrics from bam after extraction.
Processing function: calls pool of worker functions
to extract from a bam file the following metrics:
-lengths
-aligned lengths
-qualities
-aligned qualities
-mapping qualities
-edit distances to the refe... | python | def process_bam(bam, **kwargs):
"""Combines metrics from bam after extraction.
Processing function: calls pool of worker functions
to extract from a bam file the following metrics:
-lengths
-aligned lengths
-qualities
-aligned qualities
-mapping qualities
-edit distances to the refe... | [
"def",
"process_bam",
"(",
"bam",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from bam file {}.\"",
".",
"format",
"(",
"bam",
")",
")",
"samfile",
"=",
"check_bam",
"(",
"bam",
")",
"chromosomes",
... | Combines metrics from bam after extraction.
Processing function: calls pool of worker functions
to extract from a bam file the following metrics:
-lengths
-aligned lengths
-qualities
-aligned qualities
-mapping qualities
-edit distances to the reference genome scaled by read length
... | [
"Combines",
"metrics",
"from",
"bam",
"after",
"extraction",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L142-L168 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | extract_from_bam | def extract_from_bam(params):
"""Extracts metrics from bam.
Worker function per chromosome
loop over a bam file and create list with tuples containing metrics:
-qualities
-aligned qualities
-lengths
-aligned lengths
-mapping qualities
-edit distances to the reference genome scaled b... | python | def extract_from_bam(params):
"""Extracts metrics from bam.
Worker function per chromosome
loop over a bam file and create list with tuples containing metrics:
-qualities
-aligned qualities
-lengths
-aligned lengths
-mapping qualities
-edit distances to the reference genome scaled b... | [
"def",
"extract_from_bam",
"(",
"params",
")",
":",
"bam",
",",
"chromosome",
"=",
"params",
"samfile",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"bam",
",",
"\"rb\"",
")",
"return",
"[",
"(",
"read",
".",
"query_name",
",",
"nanomath",
".",
"ave_qual",
"... | Extracts metrics from bam.
Worker function per chromosome
loop over a bam file and create list with tuples containing metrics:
-qualities
-aligned qualities
-lengths
-aligned lengths
-mapping qualities
-edit distances to the reference genome scaled by read length | [
"Extracts",
"metrics",
"from",
"bam",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L200-L223 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | get_pID | def get_pID(read):
"""Return the percent identity of a read.
based on the NM tag if present,
if not calculate from MD tag and CIGAR string
read.query_alignment_length can be zero in the case of ultra long reads aligned with minimap2 -L
"""
try:
return 100 * (1 - read.get_tag("NM") / re... | python | def get_pID(read):
"""Return the percent identity of a read.
based on the NM tag if present,
if not calculate from MD tag and CIGAR string
read.query_alignment_length can be zero in the case of ultra long reads aligned with minimap2 -L
"""
try:
return 100 * (1 - read.get_tag("NM") / re... | [
"def",
"get_pID",
"(",
"read",
")",
":",
"try",
":",
"return",
"100",
"*",
"(",
"1",
"-",
"read",
".",
"get_tag",
"(",
"\"NM\"",
")",
"/",
"read",
".",
"query_alignment_length",
")",
"except",
"KeyError",
":",
"try",
":",
"return",
"100",
"*",
"(",
... | Return the percent identity of a read.
based on the NM tag if present,
if not calculate from MD tag and CIGAR string
read.query_alignment_length can be zero in the case of ultra long reads aligned with minimap2 -L | [
"Return",
"the",
"percent",
"identity",
"of",
"a",
"read",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L226-L243 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | handle_compressed_input | def handle_compressed_input(inputfq, file_type="fastq"):
"""Return handles from compressed files according to extension.
Check for which fastq input is presented and open a handle accordingly
Can read from compressed files (gz, bz2, bgz) or uncompressed
Relies on file extensions to recognize compressio... | python | def handle_compressed_input(inputfq, file_type="fastq"):
"""Return handles from compressed files according to extension.
Check for which fastq input is presented and open a handle accordingly
Can read from compressed files (gz, bz2, bgz) or uncompressed
Relies on file extensions to recognize compressio... | [
"def",
"handle_compressed_input",
"(",
"inputfq",
",",
"file_type",
"=",
"\"fastq\"",
")",
":",
"ut",
".",
"check_existance",
"(",
"inputfq",
")",
"if",
"inputfq",
".",
"endswith",
"(",
"(",
"'.gz'",
",",
"'bgz'",
")",
")",
":",
"import",
"gzip",
"logging"... | Return handles from compressed files according to extension.
Check for which fastq input is presented and open a handle accordingly
Can read from compressed files (gz, bz2, bgz) or uncompressed
Relies on file extensions to recognize compression | [
"Return",
"handles",
"from",
"compressed",
"files",
"according",
"to",
"extension",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L256-L277 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | process_fasta | def process_fasta(fasta, **kwargs):
"""Combine metrics extracted from a fasta file."""
logging.info("Nanoget: Starting to collect statistics from a fasta file.")
inputfasta = handle_compressed_input(fasta, file_type="fasta")
return ut.reduce_memory_usage(pd.DataFrame(
data=[len(rec) for rec in S... | python | def process_fasta(fasta, **kwargs):
"""Combine metrics extracted from a fasta file."""
logging.info("Nanoget: Starting to collect statistics from a fasta file.")
inputfasta = handle_compressed_input(fasta, file_type="fasta")
return ut.reduce_memory_usage(pd.DataFrame(
data=[len(rec) for rec in S... | [
"def",
"process_fasta",
"(",
"fasta",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from a fasta file.\"",
")",
"inputfasta",
"=",
"handle_compressed_input",
"(",
"fasta",
",",
"file_type",
"=",
"\"fasta\"",... | Combine metrics extracted from a fasta file. | [
"Combine",
"metrics",
"extracted",
"from",
"a",
"fasta",
"file",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L280-L287 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | process_fastq_plain | def process_fastq_plain(fastq, **kwargs):
"""Combine metrics extracted from a fastq file."""
logging.info("Nanoget: Starting to collect statistics from plain fastq file.")
inputfastq = handle_compressed_input(fastq)
return ut.reduce_memory_usage(pd.DataFrame(
data=[res for res in extract_from_fa... | python | def process_fastq_plain(fastq, **kwargs):
"""Combine metrics extracted from a fastq file."""
logging.info("Nanoget: Starting to collect statistics from plain fastq file.")
inputfastq = handle_compressed_input(fastq)
return ut.reduce_memory_usage(pd.DataFrame(
data=[res for res in extract_from_fa... | [
"def",
"process_fastq_plain",
"(",
"fastq",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from plain fastq file.\"",
")",
"inputfastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"return",
"ut",
".",... | Combine metrics extracted from a fastq file. | [
"Combine",
"metrics",
"extracted",
"from",
"a",
"fastq",
"file",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L290-L297 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | extract_from_fastq | def extract_from_fastq(fq):
"""Extract metrics from a fastq file.
Return average quality and read length
"""
for rec in SeqIO.parse(fq, "fastq"):
yield nanomath.ave_qual(rec.letter_annotations["phred_quality"]), len(rec) | python | def extract_from_fastq(fq):
"""Extract metrics from a fastq file.
Return average quality and read length
"""
for rec in SeqIO.parse(fq, "fastq"):
yield nanomath.ave_qual(rec.letter_annotations["phred_quality"]), len(rec) | [
"def",
"extract_from_fastq",
"(",
"fq",
")",
":",
"for",
"rec",
"in",
"SeqIO",
".",
"parse",
"(",
"fq",
",",
"\"fastq\"",
")",
":",
"yield",
"nanomath",
".",
"ave_qual",
"(",
"rec",
".",
"letter_annotations",
"[",
"\"phred_quality\"",
"]",
")",
",",
"len... | Extract metrics from a fastq file.
Return average quality and read length | [
"Extract",
"metrics",
"from",
"a",
"fastq",
"file",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L300-L306 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | stream_fastq_full | def stream_fastq_full(fastq, threads):
"""Generator for returning metrics extracted from fastq.
Extract from a fastq file:
-readname
-average and median quality
-read_lenght
"""
logging.info("Nanoget: Starting to collect full metrics from plain fastq file.")
inputfastq = handle_compress... | python | def stream_fastq_full(fastq, threads):
"""Generator for returning metrics extracted from fastq.
Extract from a fastq file:
-readname
-average and median quality
-read_lenght
"""
logging.info("Nanoget: Starting to collect full metrics from plain fastq file.")
inputfastq = handle_compress... | [
"def",
"stream_fastq_full",
"(",
"fastq",
",",
"threads",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect full metrics from plain fastq file.\"",
")",
"inputfastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"with",
"cfutures",
".",
"Proce... | Generator for returning metrics extracted from fastq.
Extract from a fastq file:
-readname
-average and median quality
-read_lenght | [
"Generator",
"for",
"returning",
"metrics",
"extracted",
"from",
"fastq",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L309-L322 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | extract_all_from_fastq | def extract_all_from_fastq(rec):
"""Extract metrics from a fastq file.
Return identifier, read length, average quality and median quality
"""
return (rec.id,
len(rec),
nanomath.ave_qual(rec.letter_annotations["phred_quality"]),
nanomath.median_qual(rec.letter_annotat... | python | def extract_all_from_fastq(rec):
"""Extract metrics from a fastq file.
Return identifier, read length, average quality and median quality
"""
return (rec.id,
len(rec),
nanomath.ave_qual(rec.letter_annotations["phred_quality"]),
nanomath.median_qual(rec.letter_annotat... | [
"def",
"extract_all_from_fastq",
"(",
"rec",
")",
":",
"return",
"(",
"rec",
".",
"id",
",",
"len",
"(",
"rec",
")",
",",
"nanomath",
".",
"ave_qual",
"(",
"rec",
".",
"letter_annotations",
"[",
"\"phred_quality\"",
"]",
")",
",",
"nanomath",
".",
"media... | Extract metrics from a fastq file.
Return identifier, read length, average quality and median quality | [
"Extract",
"metrics",
"from",
"a",
"fastq",
"file",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L325-L333 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | process_fastq_rich | def process_fastq_rich(fastq, **kwargs):
"""Extract metrics from a richer fastq file.
Extract information from fastq files generated by albacore or MinKNOW,
containing richer information in the header (key-value pairs)
read=<int> [72]
ch=<int> [159]
start_time=<timestamp> [2016-07-15T14:23:22Z]... | python | def process_fastq_rich(fastq, **kwargs):
"""Extract metrics from a richer fastq file.
Extract information from fastq files generated by albacore or MinKNOW,
containing richer information in the header (key-value pairs)
read=<int> [72]
ch=<int> [159]
start_time=<timestamp> [2016-07-15T14:23:22Z]... | [
"def",
"process_fastq_rich",
"(",
"fastq",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from rich fastq file.\"",
")",
"inputfastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"res",
"=",
"[",
"]"... | Extract metrics from a richer fastq file.
Extract information from fastq files generated by albacore or MinKNOW,
containing richer information in the header (key-value pairs)
read=<int> [72]
ch=<int> [159]
start_time=<timestamp> [2016-07-15T14:23:22Z] # UTC ISO 8601 ISO 3339 timestamp
Z indica... | [
"Extract",
"metrics",
"from",
"a",
"richer",
"fastq",
"file",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L341-L374 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | readfq | def readfq(fp):
"""Generator function adapted from https://github.com/lh3/readfq."""
last = None # this is a buffer keeping the last unprocessed line
while True: # mimic closure; is it a bad idea?
if not last: # the first record or a record following a fastq
for l in fp: # search for... | python | def readfq(fp):
"""Generator function adapted from https://github.com/lh3/readfq."""
last = None # this is a buffer keeping the last unprocessed line
while True: # mimic closure; is it a bad idea?
if not last: # the first record or a record following a fastq
for l in fp: # search for... | [
"def",
"readfq",
"(",
"fp",
")",
":",
"last",
"=",
"None",
"# this is a buffer keeping the last unprocessed line",
"while",
"True",
":",
"# mimic closure; is it a bad idea?",
"if",
"not",
"last",
":",
"# the first record or a record following a fastq",
"for",
"l",
"in",
"... | Generator function adapted from https://github.com/lh3/readfq. | [
"Generator",
"function",
"adapted",
"from",
"https",
":",
"//",
"github",
".",
"com",
"/",
"lh3",
"/",
"readfq",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L377-L409 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | fq_minimal | def fq_minimal(fq):
"""Minimal fastq metrics extractor.
Quickly parse a fasta/fastq file - but makes expectations on the file format
There will be dragons if unexpected format is used
Expects a fastq_rich format, but extracts only timestamp and length
"""
try:
while True:
ti... | python | def fq_minimal(fq):
"""Minimal fastq metrics extractor.
Quickly parse a fasta/fastq file - but makes expectations on the file format
There will be dragons if unexpected format is used
Expects a fastq_rich format, but extracts only timestamp and length
"""
try:
while True:
ti... | [
"def",
"fq_minimal",
"(",
"fq",
")",
":",
"try",
":",
"while",
"True",
":",
"time",
"=",
"next",
"(",
"fq",
")",
"[",
"1",
":",
"]",
".",
"split",
"(",
"\" \"",
")",
"[",
"4",
"]",
"[",
"11",
":",
"-",
"1",
"]",
"length",
"=",
"len",
"(",
... | Minimal fastq metrics extractor.
Quickly parse a fasta/fastq file - but makes expectations on the file format
There will be dragons if unexpected format is used
Expects a fastq_rich format, but extracts only timestamp and length | [
"Minimal",
"fastq",
"metrics",
"extractor",
"."
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L412-L427 | train |
wdecoster/nanoget | nanoget/extraction_functions.py | process_fastq_minimal | def process_fastq_minimal(fastq, **kwargs):
"""Swiftly extract minimal features (length and timestamp) from a rich fastq file"""
infastq = handle_compressed_input(fastq)
try:
df = pd.DataFrame(
data=[rec for rec in fq_minimal(infastq) if rec],
columns=["timestamp", "lengths"]... | python | def process_fastq_minimal(fastq, **kwargs):
"""Swiftly extract minimal features (length and timestamp) from a rich fastq file"""
infastq = handle_compressed_input(fastq)
try:
df = pd.DataFrame(
data=[rec for rec in fq_minimal(infastq) if rec],
columns=["timestamp", "lengths"]... | [
"def",
"process_fastq_minimal",
"(",
"fastq",
",",
"*",
"*",
"kwargs",
")",
":",
"infastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"try",
":",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"data",
"=",
"[",
"rec",
"for",
"rec",
"in",
"fq_minimal",
... | Swiftly extract minimal features (length and timestamp) from a rich fastq file | [
"Swiftly",
"extract",
"minimal",
"features",
"(",
"length",
"and",
"timestamp",
")",
"from",
"a",
"rich",
"fastq",
"file"
] | fb7306220e261849b96785fab02dd2f35a0e3b60 | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L430-L441 | train |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | _get_piece | def _get_piece(string, index):
"""
Returns Piece subclass given index of piece.
:type: index: int
:type: loc Location
:raise: KeyError
"""
piece = string[index].strip()
piece = piece.upper()
piece_dict = {'R': Rook,
'P': Pawn,
'B': Bishop,
... | python | def _get_piece(string, index):
"""
Returns Piece subclass given index of piece.
:type: index: int
:type: loc Location
:raise: KeyError
"""
piece = string[index].strip()
piece = piece.upper()
piece_dict = {'R': Rook,
'P': Pawn,
'B': Bishop,
... | [
"def",
"_get_piece",
"(",
"string",
",",
"index",
")",
":",
"piece",
"=",
"string",
"[",
"index",
"]",
".",
"strip",
"(",
")",
"piece",
"=",
"piece",
".",
"upper",
"(",
")",
"piece_dict",
"=",
"{",
"'R'",
":",
"Rook",
",",
"'P'",
":",
"Pawn",
","... | Returns Piece subclass given index of piece.
:type: index: int
:type: loc Location
:raise: KeyError | [
"Returns",
"Piece",
"subclass",
"given",
"index",
"of",
"piece",
"."
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L24-L44 | train |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | incomplete_alg | def incomplete_alg(alg_str, input_color, position):
"""
Converts a string written in short algebraic form into an incomplete move.
These incomplete moves do not have the initial location specified and
therefore cannot be used to update the board. IN order to fully utilize
incomplete move, it must be... | python | def incomplete_alg(alg_str, input_color, position):
"""
Converts a string written in short algebraic form into an incomplete move.
These incomplete moves do not have the initial location specified and
therefore cannot be used to update the board. IN order to fully utilize
incomplete move, it must be... | [
"def",
"incomplete_alg",
"(",
"alg_str",
",",
"input_color",
",",
"position",
")",
":",
"edge_rank",
"=",
"0",
"if",
"input_color",
"==",
"color",
".",
"white",
"else",
"7",
"if",
"alg_str",
"is",
"None",
"or",
"len",
"(",
"alg_str",
")",
"<=",
"1",
":... | Converts a string written in short algebraic form into an incomplete move.
These incomplete moves do not have the initial location specified and
therefore cannot be used to update the board. IN order to fully utilize
incomplete move, it must be run through ``make_legal()`` with
the corresponding positio... | [
"Converts",
"a",
"string",
"written",
"in",
"short",
"algebraic",
"form",
"into",
"an",
"incomplete",
"move",
".",
"These",
"incomplete",
"moves",
"do",
"not",
"have",
"the",
"initial",
"location",
"specified",
"and",
"therefore",
"cannot",
"be",
"used",
"to",... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L105-L305 | train |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | make_legal | def make_legal(move, position):
"""
Converts an incomplete move (initial ``Location`` not specified)
and the corresponding position into the a complete move
with the most likely starting point specified. If no moves match, ``None``
is returned.
:type: move: Move
:type: position: Board
:... | python | def make_legal(move, position):
"""
Converts an incomplete move (initial ``Location`` not specified)
and the corresponding position into the a complete move
with the most likely starting point specified. If no moves match, ``None``
is returned.
:type: move: Move
:type: position: Board
:... | [
"def",
"make_legal",
"(",
"move",
",",
"position",
")",
":",
"assert",
"isinstance",
"(",
"move",
",",
"Move",
")",
"for",
"legal_move",
"in",
"position",
".",
"all_possible_moves",
"(",
"move",
".",
"color",
")",
":",
"if",
"move",
".",
"status",
"==",
... | Converts an incomplete move (initial ``Location`` not specified)
and the corresponding position into the a complete move
with the most likely starting point specified. If no moves match, ``None``
is returned.
:type: move: Move
:type: position: Board
:rtype: Move | [
"Converts",
"an",
"incomplete",
"move",
"(",
"initial",
"Location",
"not",
"specified",
")",
"and",
"the",
"corresponding",
"position",
"into",
"the",
"a",
"complete",
"move",
"with",
"the",
"most",
"likely",
"starting",
"point",
"specified",
".",
"If",
"no",
... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L308-L330 | train |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | short_alg | def short_alg(algebraic_string, input_color, position):
"""
Converts a string written in short algebraic form, the color
of the side whose turn it is, and the corresponding position
into a complete move that can be played. If no moves match,
None is returned.
Examples: e4, Nf3, exd5, Qxf3, 00, ... | python | def short_alg(algebraic_string, input_color, position):
"""
Converts a string written in short algebraic form, the color
of the side whose turn it is, and the corresponding position
into a complete move that can be played. If no moves match,
None is returned.
Examples: e4, Nf3, exd5, Qxf3, 00, ... | [
"def",
"short_alg",
"(",
"algebraic_string",
",",
"input_color",
",",
"position",
")",
":",
"return",
"make_legal",
"(",
"incomplete_alg",
"(",
"algebraic_string",
",",
"input_color",
",",
"position",
")",
",",
"position",
")"
] | Converts a string written in short algebraic form, the color
of the side whose turn it is, and the corresponding position
into a complete move that can be played. If no moves match,
None is returned.
Examples: e4, Nf3, exd5, Qxf3, 00, 000, e8=Q
:type: algebraic_string: str
:type: input_color: ... | [
"Converts",
"a",
"string",
"written",
"in",
"short",
"algebraic",
"form",
"the",
"color",
"of",
"the",
"side",
"whose",
"turn",
"it",
"is",
"and",
"the",
"corresponding",
"position",
"into",
"a",
"complete",
"move",
"that",
"can",
"be",
"played",
".",
"If"... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L333-L346 | train |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | long_alg | def long_alg(alg_str, position):
"""
Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move
... | python | def long_alg(alg_str, position):
"""
Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move
... | [
"def",
"long_alg",
"(",
"alg_str",
",",
"position",
")",
":",
"if",
"alg_str",
"is",
"None",
"or",
"len",
"(",
"alg_str",
")",
"<",
"4",
"or",
"len",
"(",
"alg_str",
")",
">",
"6",
":",
"raise",
"ValueError",
"(",
"\"Invalid string input {}\"",
".",
"f... | Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move | [
"Converts",
"a",
"string",
"written",
"in",
"long",
"algebraic",
"form",
"and",
"the",
"corresponding",
"position",
"into",
"a",
"complete",
"move",
"(",
"initial",
"location",
"specified",
")",
".",
"Used",
"primarily",
"for",
"UCI",
"but",
"can",
"be",
"us... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L349-L383 | train |
cimm-kzn/CGRtools | CGRtools/containers/molecule.py | MoleculeContainer.reset_query_marks | def reset_query_marks(self):
"""
set or reset hyb and neighbors marks to atoms.
"""
for i, atom in self.atoms():
neighbors = 0
hybridization = 1
# hybridization 1- sp3; 2- sp2; 3- sp1; 4- aromatic
for j, bond in self._adj[i].items():
... | python | def reset_query_marks(self):
"""
set or reset hyb and neighbors marks to atoms.
"""
for i, atom in self.atoms():
neighbors = 0
hybridization = 1
# hybridization 1- sp3; 2- sp2; 3- sp1; 4- aromatic
for j, bond in self._adj[i].items():
... | [
"def",
"reset_query_marks",
"(",
"self",
")",
":",
"for",
"i",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"neighbors",
"=",
"0",
"hybridization",
"=",
"1",
"# hybridization 1- sp3; 2- sp2; 3- sp1; 4- aromatic",
"for",
"j",
",",
"bond",
"in",
"se... | set or reset hyb and neighbors marks to atoms. | [
"set",
"or",
"reset",
"hyb",
"and",
"neighbors",
"marks",
"to",
"atoms",
"."
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L38-L65 | train |
cimm-kzn/CGRtools | CGRtools/containers/molecule.py | MoleculeContainer.implicify_hydrogens | def implicify_hydrogens(self):
"""
remove explicit hydrogen if possible
:return: number of removed hydrogens
"""
explicit = defaultdict(list)
c = 0
for n, atom in self.atoms():
if atom.element == 'H':
for m in self.neighbors(n):
... | python | def implicify_hydrogens(self):
"""
remove explicit hydrogen if possible
:return: number of removed hydrogens
"""
explicit = defaultdict(list)
c = 0
for n, atom in self.atoms():
if atom.element == 'H':
for m in self.neighbors(n):
... | [
"def",
"implicify_hydrogens",
"(",
"self",
")",
":",
"explicit",
"=",
"defaultdict",
"(",
"list",
")",
"c",
"=",
"0",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"if",
"atom",
".",
"element",
"==",
"'H'",
":",
"for",
"m",
... | remove explicit hydrogen if possible
:return: number of removed hydrogens | [
"remove",
"explicit",
"hydrogen",
"if",
"possible"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L67-L93 | train |
cimm-kzn/CGRtools | CGRtools/containers/molecule.py | MoleculeContainer.explicify_hydrogens | def explicify_hydrogens(self):
"""
add explicit hydrogens to atoms
:return: number of added atoms
"""
tmp = []
for n, atom in self.atoms():
if atom.element != 'H':
for _ in range(atom.get_implicit_h([x.order for x in self._adj[n].values()])):
... | python | def explicify_hydrogens(self):
"""
add explicit hydrogens to atoms
:return: number of added atoms
"""
tmp = []
for n, atom in self.atoms():
if atom.element != 'H':
for _ in range(atom.get_implicit_h([x.order for x in self._adj[n].values()])):
... | [
"def",
"explicify_hydrogens",
"(",
"self",
")",
":",
"tmp",
"=",
"[",
"]",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"if",
"atom",
".",
"element",
"!=",
"'H'",
":",
"for",
"_",
"in",
"range",
"(",
"atom",
".",
"get_impli... | add explicit hydrogens to atoms
:return: number of added atoms | [
"add",
"explicit",
"hydrogens",
"to",
"atoms"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L95-L110 | train |
cimm-kzn/CGRtools | CGRtools/containers/molecule.py | MoleculeContainer.substructure | def substructure(self, atoms, meta=False, as_view=True):
"""
create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view pr... | python | def substructure(self, atoms, meta=False, as_view=True):
"""
create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view pr... | [
"def",
"substructure",
"(",
"self",
",",
"atoms",
",",
"meta",
"=",
"False",
",",
"as_view",
"=",
"True",
")",
":",
"s",
"=",
"super",
"(",
")",
".",
"substructure",
"(",
"atoms",
",",
"meta",
",",
"as_view",
")",
"if",
"as_view",
":",
"s",
".",
... | create substructure containing atoms from nbunch list
:param atoms: list of atoms numbers of substructure
:param meta: if True metadata will be copied to substructure
:param as_view: If True, the returned graph-view provides a read-only view
of the original structure scaffold withou... | [
"create",
"substructure",
"containing",
"atoms",
"from",
"nbunch",
"list"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L112-L125 | train |
cimm-kzn/CGRtools | CGRtools/containers/molecule.py | MoleculeContainer.check_valence | def check_valence(self):
"""
check valences of all atoms
:return: list of invalid atoms
"""
return [x for x, atom in self.atoms() if not atom.check_valence(self.environment(x))] | python | def check_valence(self):
"""
check valences of all atoms
:return: list of invalid atoms
"""
return [x for x, atom in self.atoms() if not atom.check_valence(self.environment(x))] | [
"def",
"check_valence",
"(",
"self",
")",
":",
"return",
"[",
"x",
"for",
"x",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
"if",
"not",
"atom",
".",
"check_valence",
"(",
"self",
".",
"environment",
"(",
"x",
")",
")",
"]"
] | check valences of all atoms
:return: list of invalid atoms | [
"check",
"valences",
"of",
"all",
"atoms"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L139-L145 | train |
cimm-kzn/CGRtools | CGRtools/containers/molecule.py | MoleculeContainer._matcher | def _matcher(self, other):
"""
return VF2 GraphMatcher
MoleculeContainer < MoleculeContainer
MoleculeContainer < CGRContainer
"""
if isinstance(other, (self._get_subclass('CGRContainer'), MoleculeContainer)):
return GraphMatcher(other, self, lambda x, y: x ==... | python | def _matcher(self, other):
"""
return VF2 GraphMatcher
MoleculeContainer < MoleculeContainer
MoleculeContainer < CGRContainer
"""
if isinstance(other, (self._get_subclass('CGRContainer'), MoleculeContainer)):
return GraphMatcher(other, self, lambda x, y: x ==... | [
"def",
"_matcher",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"(",
"self",
".",
"_get_subclass",
"(",
"'CGRContainer'",
")",
",",
"MoleculeContainer",
")",
")",
":",
"return",
"GraphMatcher",
"(",
"other",
",",
"self",
",... | return VF2 GraphMatcher
MoleculeContainer < MoleculeContainer
MoleculeContainer < CGRContainer | [
"return",
"VF2",
"GraphMatcher"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L147-L156 | train |
rnwolf/jira-metrics-extract | jira_metrics_extract/query.py | to_datetime | def to_datetime(date):
"""Turn a date into a datetime at midnight.
"""
return datetime.datetime.combine(date, datetime.datetime.min.time()) | python | def to_datetime(date):
"""Turn a date into a datetime at midnight.
"""
return datetime.datetime.combine(date, datetime.datetime.min.time()) | [
"def",
"to_datetime",
"(",
"date",
")",
":",
"return",
"datetime",
".",
"datetime",
".",
"combine",
"(",
"date",
",",
"datetime",
".",
"datetime",
".",
"min",
".",
"time",
"(",
")",
")"
] | Turn a date into a datetime at midnight. | [
"Turn",
"a",
"date",
"into",
"a",
"datetime",
"at",
"midnight",
"."
] | 56443211b3e1200f3def79173a21e0232332ae17 | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/query.py#L9-L12 | train |
rnwolf/jira-metrics-extract | jira_metrics_extract/query.py | QueryManager.iter_size_changes | def iter_size_changes(self, issue):
"""Yield an IssueSnapshot for each time the issue size changed
"""
# Find the first size change, if any
try:
size_changes = list(filter(lambda h: h.field == 'Story Points',
itertools.chain.from_iterab... | python | def iter_size_changes(self, issue):
"""Yield an IssueSnapshot for each time the issue size changed
"""
# Find the first size change, if any
try:
size_changes = list(filter(lambda h: h.field == 'Story Points',
itertools.chain.from_iterab... | [
"def",
"iter_size_changes",
"(",
"self",
",",
"issue",
")",
":",
"# Find the first size change, if any",
"try",
":",
"size_changes",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"h",
":",
"h",
".",
"field",
"==",
"'Story Points'",
",",
"itertools",
".",
"chain",... | Yield an IssueSnapshot for each time the issue size changed | [
"Yield",
"an",
"IssueSnapshot",
"for",
"each",
"time",
"the",
"issue",
"size",
"changed"
] | 56443211b3e1200f3def79173a21e0232332ae17 | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/query.py#L139-L183 | train |
rnwolf/jira-metrics-extract | jira_metrics_extract/query.py | QueryManager.iter_changes | def iter_changes(self, issue, include_resolution_changes=True):
"""Yield an IssueSnapshot for each time the issue changed status or
resolution
"""
is_resolved = False
# Find the first status change, if any
try:
status_changes = list(filter(
l... | python | def iter_changes(self, issue, include_resolution_changes=True):
"""Yield an IssueSnapshot for each time the issue changed status or
resolution
"""
is_resolved = False
# Find the first status change, if any
try:
status_changes = list(filter(
l... | [
"def",
"iter_changes",
"(",
"self",
",",
"issue",
",",
"include_resolution_changes",
"=",
"True",
")",
":",
"is_resolved",
"=",
"False",
"# Find the first status change, if any",
"try",
":",
"status_changes",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"h",
":",
... | Yield an IssueSnapshot for each time the issue changed status or
resolution | [
"Yield",
"an",
"IssueSnapshot",
"for",
"each",
"time",
"the",
"issue",
"changed",
"status",
"or",
"resolution"
] | 56443211b3e1200f3def79173a21e0232332ae17 | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/query.py#L187-L242 | train |
rnwolf/jira-metrics-extract | jira_metrics_extract/query.py | QueryManager.find_issues | def find_issues(self, criteria={}, jql=None, order='KEY ASC', verbose=False, changelog=True):
"""Return a list of issues with changelog metadata.
Searches for the `issue_types`, `project`, `valid_resolutions` and
'jql_filter' set in the passed-in `criteria` object.
Pass a JQL string to... | python | def find_issues(self, criteria={}, jql=None, order='KEY ASC', verbose=False, changelog=True):
"""Return a list of issues with changelog metadata.
Searches for the `issue_types`, `project`, `valid_resolutions` and
'jql_filter' set in the passed-in `criteria` object.
Pass a JQL string to... | [
"def",
"find_issues",
"(",
"self",
",",
"criteria",
"=",
"{",
"}",
",",
"jql",
"=",
"None",
",",
"order",
"=",
"'KEY ASC'",
",",
"verbose",
"=",
"False",
",",
"changelog",
"=",
"True",
")",
":",
"query",
"=",
"[",
"]",
"if",
"criteria",
".",
"get",... | Return a list of issues with changelog metadata.
Searches for the `issue_types`, `project`, `valid_resolutions` and
'jql_filter' set in the passed-in `criteria` object.
Pass a JQL string to further qualify the query results. | [
"Return",
"a",
"list",
"of",
"issues",
"with",
"changelog",
"metadata",
"."
] | 56443211b3e1200f3def79173a21e0232332ae17 | https://github.com/rnwolf/jira-metrics-extract/blob/56443211b3e1200f3def79173a21e0232332ae17/jira_metrics_extract/query.py#L246-L300 | train |
zetaops/zengine | zengine/views/catalog_datas.py | CatalogDataView.list_catalogs | def list_catalogs(self):
"""
Lists existing catalogs respect to ui view template format
"""
_form = CatalogSelectForm(current=self.current)
_form.set_choices_of('catalog', [(i, i) for i in fixture_bucket.get_keys()])
self.form_out(_form) | python | def list_catalogs(self):
"""
Lists existing catalogs respect to ui view template format
"""
_form = CatalogSelectForm(current=self.current)
_form.set_choices_of('catalog', [(i, i) for i in fixture_bucket.get_keys()])
self.form_out(_form) | [
"def",
"list_catalogs",
"(",
"self",
")",
":",
"_form",
"=",
"CatalogSelectForm",
"(",
"current",
"=",
"self",
".",
"current",
")",
"_form",
".",
"set_choices_of",
"(",
"'catalog'",
",",
"[",
"(",
"i",
",",
"i",
")",
"for",
"i",
"in",
"fixture_bucket",
... | Lists existing catalogs respect to ui view template format | [
"Lists",
"existing",
"catalogs",
"respect",
"to",
"ui",
"view",
"template",
"format"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/catalog_datas.py#L63-L69 | train |
zetaops/zengine | zengine/views/catalog_datas.py | CatalogDataView.get_catalog | def get_catalog(self):
"""
Get existing catalog and fill the form with the model data.
If given key not found as catalog, it generates an empty catalog data form.
"""
catalog_data = fixture_bucket.get(self.input['form']['catalog'])
# define add or edit based on catalog ... | python | def get_catalog(self):
"""
Get existing catalog and fill the form with the model data.
If given key not found as catalog, it generates an empty catalog data form.
"""
catalog_data = fixture_bucket.get(self.input['form']['catalog'])
# define add or edit based on catalog ... | [
"def",
"get_catalog",
"(",
"self",
")",
":",
"catalog_data",
"=",
"fixture_bucket",
".",
"get",
"(",
"self",
".",
"input",
"[",
"'form'",
"]",
"[",
"'catalog'",
"]",
")",
"# define add or edit based on catalog data exists",
"add_or_edit",
"=",
"\"Edit\"",
"if",
... | Get existing catalog and fill the form with the model data.
If given key not found as catalog, it generates an empty catalog data form. | [
"Get",
"existing",
"catalog",
"and",
"fill",
"the",
"form",
"with",
"the",
"model",
"data",
".",
"If",
"given",
"key",
"not",
"found",
"as",
"catalog",
"it",
"generates",
"an",
"empty",
"catalog",
"data",
"form",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/catalog_datas.py#L71-L103 | train |
zetaops/zengine | zengine/views/catalog_datas.py | CatalogDataView.save_catalog | def save_catalog(self):
"""
Saves the catalog data to given key
Cancels if the cmd is cancel
Notifies user with the process.
"""
if self.input["cmd"] == 'save_catalog':
try:
edited_object = dict()
for i in self.input["form"]["Ca... | python | def save_catalog(self):
"""
Saves the catalog data to given key
Cancels if the cmd is cancel
Notifies user with the process.
"""
if self.input["cmd"] == 'save_catalog':
try:
edited_object = dict()
for i in self.input["form"]["Ca... | [
"def",
"save_catalog",
"(",
"self",
")",
":",
"if",
"self",
".",
"input",
"[",
"\"cmd\"",
"]",
"==",
"'save_catalog'",
":",
"try",
":",
"edited_object",
"=",
"dict",
"(",
")",
"for",
"i",
"in",
"self",
".",
"input",
"[",
"\"form\"",
"]",
"[",
"\"Cata... | Saves the catalog data to given key
Cancels if the cmd is cancel
Notifies user with the process. | [
"Saves",
"the",
"catalog",
"data",
"to",
"given",
"key",
"Cancels",
"if",
"the",
"cmd",
"is",
"cancel",
"Notifies",
"user",
"with",
"the",
"process",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/catalog_datas.py#L105-L127 | train |
zetaops/zengine | zengine/lib/utils.py | date_to_solr | def date_to_solr(d):
""" converts DD-MM-YYYY to YYYY-MM-DDT00:00:00Z"""
return "{y}-{m}-{day}T00:00:00Z".format(day=d[:2], m=d[3:5], y=d[6:]) if d else d | python | def date_to_solr(d):
""" converts DD-MM-YYYY to YYYY-MM-DDT00:00:00Z"""
return "{y}-{m}-{day}T00:00:00Z".format(day=d[:2], m=d[3:5], y=d[6:]) if d else d | [
"def",
"date_to_solr",
"(",
"d",
")",
":",
"return",
"\"{y}-{m}-{day}T00:00:00Z\"",
".",
"format",
"(",
"day",
"=",
"d",
"[",
":",
"2",
"]",
",",
"m",
"=",
"d",
"[",
"3",
":",
"5",
"]",
",",
"y",
"=",
"d",
"[",
"6",
":",
"]",
")",
"if",
"d",
... | converts DD-MM-YYYY to YYYY-MM-DDT00:00:00Z | [
"converts",
"DD",
"-",
"MM",
"-",
"YYYY",
"to",
"YYYY",
"-",
"MM",
"-",
"DDT00",
":",
"00",
":",
"00Z"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/utils.py#L19-L21 | train |
zetaops/zengine | zengine/lib/utils.py | solr_to_date | def solr_to_date(d):
""" converts YYYY-MM-DDT00:00:00Z to DD-MM-YYYY """
return "{day}:{m}:{y}".format(y=d[:4], m=d[5:7], day=d[8:10]) if d else d | python | def solr_to_date(d):
""" converts YYYY-MM-DDT00:00:00Z to DD-MM-YYYY """
return "{day}:{m}:{y}".format(y=d[:4], m=d[5:7], day=d[8:10]) if d else d | [
"def",
"solr_to_date",
"(",
"d",
")",
":",
"return",
"\"{day}:{m}:{y}\"",
".",
"format",
"(",
"y",
"=",
"d",
"[",
":",
"4",
"]",
",",
"m",
"=",
"d",
"[",
"5",
":",
"7",
"]",
",",
"day",
"=",
"d",
"[",
"8",
":",
"10",
"]",
")",
"if",
"d",
... | converts YYYY-MM-DDT00:00:00Z to DD-MM-YYYY | [
"converts",
"YYYY",
"-",
"MM",
"-",
"DDT00",
":",
"00",
":",
"00Z",
"to",
"DD",
"-",
"MM",
"-",
"YYYY"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/utils.py#L24-L26 | train |
zetaops/zengine | zengine/lib/utils.py | to_safe_str | def to_safe_str(s):
"""
converts some (tr) non-ascii chars to ascii counterparts,
then return the result as lowercase
"""
# TODO: This is insufficient as it doesn't do anything for other non-ascii chars
return re.sub(r'[^0-9a-zA-Z]+', '_', s.strip().replace(u'ğ', 'g').replace(u'ö', 'o').replace(... | python | def to_safe_str(s):
"""
converts some (tr) non-ascii chars to ascii counterparts,
then return the result as lowercase
"""
# TODO: This is insufficient as it doesn't do anything for other non-ascii chars
return re.sub(r'[^0-9a-zA-Z]+', '_', s.strip().replace(u'ğ', 'g').replace(u'ö', 'o').replace(... | [
"def",
"to_safe_str",
"(",
"s",
")",
":",
"# TODO: This is insufficient as it doesn't do anything for other non-ascii chars",
"return",
"re",
".",
"sub",
"(",
"r'[^0-9a-zA-Z]+'",
",",
"'_'",
",",
"s",
".",
"strip",
"(",
")",
".",
"replace",
"(",
"u'ğ',",
" ",
"g')... | converts some (tr) non-ascii chars to ascii counterparts,
then return the result as lowercase | [
"converts",
"some",
"(",
"tr",
")",
"non",
"-",
"ascii",
"chars",
"to",
"ascii",
"counterparts",
"then",
"return",
"the",
"result",
"as",
"lowercase"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/utils.py#L34-L43 | train |
zetaops/zengine | zengine/lib/utils.py | merge_truthy | def merge_truthy(*dicts):
"""Merge multiple dictionaries, keeping the truthy values in case of key collisions.
Accepts any number of dictionaries, or any other object that returns a 2-tuple of
key and value pairs when its `.items()` method is called.
If a key exists in multiple dictionaries passed to ... | python | def merge_truthy(*dicts):
"""Merge multiple dictionaries, keeping the truthy values in case of key collisions.
Accepts any number of dictionaries, or any other object that returns a 2-tuple of
key and value pairs when its `.items()` method is called.
If a key exists in multiple dictionaries passed to ... | [
"def",
"merge_truthy",
"(",
"*",
"dicts",
")",
":",
"merged",
"=",
"{",
"}",
"for",
"d",
"in",
"dicts",
":",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"merged",
"[",
"k",
"]",
"=",
"v",
"or",
"merged",
".",
"get",
"(",
"... | Merge multiple dictionaries, keeping the truthy values in case of key collisions.
Accepts any number of dictionaries, or any other object that returns a 2-tuple of
key and value pairs when its `.items()` method is called.
If a key exists in multiple dictionaries passed to this function, the values from th... | [
"Merge",
"multiple",
"dictionaries",
"keeping",
"the",
"truthy",
"values",
"in",
"case",
"of",
"key",
"collisions",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/utils.py#L46-L63 | train |
camptocamp/marabunta | marabunta/runner.py | VersionRunner.perform | def perform(self):
"""Perform the version upgrade on the database.
"""
db_versions = self.table.versions()
version = self.version
if (version.is_processed(db_versions) and
not self.config.force_version == self.version.number):
self.log(
... | python | def perform(self):
"""Perform the version upgrade on the database.
"""
db_versions = self.table.versions()
version = self.version
if (version.is_processed(db_versions) and
not self.config.force_version == self.version.number):
self.log(
... | [
"def",
"perform",
"(",
"self",
")",
":",
"db_versions",
"=",
"self",
".",
"table",
".",
"versions",
"(",
")",
"version",
"=",
"self",
".",
"version",
"if",
"(",
"version",
".",
"is_processed",
"(",
"db_versions",
")",
"and",
"not",
"self",
".",
"config... | Perform the version upgrade on the database. | [
"Perform",
"the",
"version",
"upgrade",
"on",
"the",
"database",
"."
] | ec3a7a725c7426d6ed642e0a80119b37880eb91e | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/runner.py#L154-L178 | train |
camptocamp/marabunta | marabunta/runner.py | VersionRunner._perform_version | def _perform_version(self, version):
"""Inner method for version upgrade.
Not intended for standalone use. This method performs the actual
version upgrade with all the pre, post operations and addons upgrades.
:param version: The migration version to upgrade to
:type version: I... | python | def _perform_version(self, version):
"""Inner method for version upgrade.
Not intended for standalone use. This method performs the actual
version upgrade with all the pre, post operations and addons upgrades.
:param version: The migration version to upgrade to
:type version: I... | [
"def",
"_perform_version",
"(",
"self",
",",
"version",
")",
":",
"if",
"version",
".",
"is_noop",
"(",
")",
":",
"self",
".",
"log",
"(",
"u'version {} is a noop'",
".",
"format",
"(",
"version",
".",
"number",
")",
")",
"else",
":",
"self",
".",
"log... | Inner method for version upgrade.
Not intended for standalone use. This method performs the actual
version upgrade with all the pre, post operations and addons upgrades.
:param version: The migration version to upgrade to
:type version: Instance of Version class | [
"Inner",
"method",
"for",
"version",
"upgrade",
"."
] | ec3a7a725c7426d6ed642e0a80119b37880eb91e | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/runner.py#L180-L208 | train |
zetaops/zengine | zengine/views/auth.py | logout | def logout(current):
"""
Log out view.
Simply deletes the session object.
For showing logout message:
'show_logout_message' field should be True in current.task_data,
Message should be sent in current.task_data with 'logout_message' field.
Message title should be sent in current.... | python | def logout(current):
"""
Log out view.
Simply deletes the session object.
For showing logout message:
'show_logout_message' field should be True in current.task_data,
Message should be sent in current.task_data with 'logout_message' field.
Message title should be sent in current.... | [
"def",
"logout",
"(",
"current",
")",
":",
"current",
".",
"user",
".",
"is_online",
"(",
"False",
")",
"current",
".",
"session",
".",
"delete",
"(",
")",
"current",
".",
"output",
"[",
"'cmd'",
"]",
"=",
"'logout'",
"if",
"current",
".",
"task_data",... | Log out view.
Simply deletes the session object.
For showing logout message:
'show_logout_message' field should be True in current.task_data,
Message should be sent in current.task_data with 'logout_message' field.
Message title should be sent in current.task_data with 'logout_title' fie... | [
"Log",
"out",
"view",
".",
"Simply",
"deletes",
"the",
"session",
"object",
".",
"For",
"showing",
"logout",
"message",
":",
"show_logout_message",
"field",
"should",
"be",
"True",
"in",
"current",
".",
"task_data",
"Message",
"should",
"be",
"sent",
"in",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/auth.py#L29-L50 | train |
zetaops/zengine | zengine/views/auth.py | Login._do_upgrade | def _do_upgrade(self):
""" open websocket connection """
self.current.output['cmd'] = 'upgrade'
self.current.output['user_id'] = self.current.user_id
self.terminate_existing_login()
self.current.user.bind_private_channel(self.current.session.sess_id)
user_sess = UserSessi... | python | def _do_upgrade(self):
""" open websocket connection """
self.current.output['cmd'] = 'upgrade'
self.current.output['user_id'] = self.current.user_id
self.terminate_existing_login()
self.current.user.bind_private_channel(self.current.session.sess_id)
user_sess = UserSessi... | [
"def",
"_do_upgrade",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"output",
"[",
"'cmd'",
"]",
"=",
"'upgrade'",
"self",
".",
"current",
".",
"output",
"[",
"'user_id'",
"]",
"=",
"self",
".",
"current",
".",
"user_id",
"self",
".",
"terminate_... | open websocket connection | [
"open",
"websocket",
"connection"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/auth.py#L73-L84 | train |
zetaops/zengine | zengine/views/auth.py | Login.do_view | def do_view(self):
"""
Authenticate user with given credentials.
Connects user's queue and exchange
"""
self.current.output['login_process'] = True
self.current.task_data['login_successful'] = False
if self.current.is_auth:
self._do_upgrade()
e... | python | def do_view(self):
"""
Authenticate user with given credentials.
Connects user's queue and exchange
"""
self.current.output['login_process'] = True
self.current.task_data['login_successful'] = False
if self.current.is_auth:
self._do_upgrade()
e... | [
"def",
"do_view",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"output",
"[",
"'login_process'",
"]",
"=",
"True",
"self",
".",
"current",
".",
"task_data",
"[",
"'login_successful'",
"]",
"=",
"False",
"if",
"self",
".",
"current",
".",
"is_auth"... | Authenticate user with given credentials.
Connects user's queue and exchange | [
"Authenticate",
"user",
"with",
"given",
"credentials",
".",
"Connects",
"user",
"s",
"queue",
"and",
"exchange"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/auth.py#L96-L121 | train |
zetaops/zengine | zengine/views/auth.py | Login.show_view | def show_view(self):
"""
Show :attr:`LoginForm` form.
"""
self.current.output['login_process'] = True
if self.current.is_auth:
self._do_upgrade()
else:
self.current.output['forms'] = LoginForm(current=self.current).serialize() | python | def show_view(self):
"""
Show :attr:`LoginForm` form.
"""
self.current.output['login_process'] = True
if self.current.is_auth:
self._do_upgrade()
else:
self.current.output['forms'] = LoginForm(current=self.current).serialize() | [
"def",
"show_view",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"output",
"[",
"'login_process'",
"]",
"=",
"True",
"if",
"self",
".",
"current",
".",
"is_auth",
":",
"self",
".",
"_do_upgrade",
"(",
")",
"else",
":",
"self",
".",
"current",
... | Show :attr:`LoginForm` form. | [
"Show",
":",
"attr",
":",
"LoginForm",
"form",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/auth.py#L123-L131 | train |
cimm-kzn/CGRtools | CGRtools/reactor.py | skip | def skip(mapping):
"""
:param mapping: generator
:return: filtered generator
"""
found = set()
for m in mapping:
matched_atoms = set(m.values())
if found.intersection(matched_atoms):
continue
found.update(matched_atoms)
yield m | python | def skip(mapping):
"""
:param mapping: generator
:return: filtered generator
"""
found = set()
for m in mapping:
matched_atoms = set(m.values())
if found.intersection(matched_atoms):
continue
found.update(matched_atoms)
yield m | [
"def",
"skip",
"(",
"mapping",
")",
":",
"found",
"=",
"set",
"(",
")",
"for",
"m",
"in",
"mapping",
":",
"matched_atoms",
"=",
"set",
"(",
"m",
".",
"values",
"(",
")",
")",
"if",
"found",
".",
"intersection",
"(",
"matched_atoms",
")",
":",
"cont... | :param mapping: generator
:return: filtered generator | [
":",
"param",
"mapping",
":",
"generator",
":",
"return",
":",
"filtered",
"generator"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/reactor.py#L333-L344 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.