repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
markchil/gptools | gptools/kernel/gibbs.py | cubic_bucket_warp | def cubic_bucket_warp(x, n, l1, l2, l3, x0, w1, w2, w3):
"""Warps the length scale with a piecewise cubic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first d... | python | def cubic_bucket_warp(x, n, l1, l2, l3, x0, w1, w2, w3):
"""Warps the length scale with a piecewise cubic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first d... | [
"def",
"cubic_bucket_warp",
"(",
"x",
",",
"n",
",",
"l1",
",",
"l2",
",",
"l3",
",",
"x0",
",",
"w1",
",",
"w2",
",",
"w3",
")",
":",
"x1",
"=",
"x0",
"-",
"w2",
"/",
"2.0",
"-",
"w1",
"/",
"2.0",
"x2",
"=",
"x0",
"+",
"w2",
"/",
"2.0",
... | Warps the length scale with a piecewise cubic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first derivatives are supported.
l1 : positive float
Length... | [
"Warps",
"the",
"length",
"scale",
"with",
"a",
"piecewise",
"cubic",
"bucket",
"shape",
".",
"Parameters",
"----------",
"x",
":",
"float",
"or",
"array",
"-",
"like",
"of",
"float",
"Locations",
"to",
"evaluate",
"length",
"scale",
"at",
".",
"n",
":",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L572-L620 |
markchil/gptools | gptools/kernel/gibbs.py | quintic_bucket_warp | def quintic_bucket_warp(x, n, l1, l2, l3, x0, w1, w2, w3):
"""Warps the length scale with a piecewise quintic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first d... | python | def quintic_bucket_warp(x, n, l1, l2, l3, x0, w1, w2, w3):
"""Warps the length scale with a piecewise quintic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first d... | [
"def",
"quintic_bucket_warp",
"(",
"x",
",",
"n",
",",
"l1",
",",
"l2",
",",
"l3",
",",
"x0",
",",
"w1",
",",
"w2",
",",
"w3",
")",
":",
"x1",
"=",
"x0",
"-",
"w2",
"/",
"2.0",
"-",
"w1",
"/",
"2.0",
"x2",
"=",
"x0",
"+",
"w2",
"/",
"2.0"... | Warps the length scale with a piecewise quintic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first derivatives are supported.
l1 : positive float
Length s... | [
"Warps",
"the",
"length",
"scale",
"with",
"a",
"piecewise",
"quintic",
"bucket",
"shape",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L660-L723 |
markchil/gptools | gptools/kernel/gibbs.py | exp_gauss_warp | def exp_gauss_warp(X, n, l0, *msb):
"""Length scale function which is an exponential of a sum of Gaussians.
The centers and widths of the Gaussians are free parameters.
The length scale function is given by
.. math::
l = l_0 \exp\left ( \sum_{i=1}^{N}\beta_i\exp\left ( -\... | python | def exp_gauss_warp(X, n, l0, *msb):
"""Length scale function which is an exponential of a sum of Gaussians.
The centers and widths of the Gaussians are free parameters.
The length scale function is given by
.. math::
l = l_0 \exp\left ( \sum_{i=1}^{N}\beta_i\exp\left ( -\... | [
"def",
"exp_gauss_warp",
"(",
"X",
",",
"n",
",",
"l0",
",",
"*",
"msb",
")",
":",
"X",
"=",
"scipy",
".",
"asarray",
"(",
"X",
",",
"dtype",
"=",
"float",
")",
"msb",
"=",
"scipy",
".",
"asarray",
"(",
"msb",
",",
"dtype",
"=",
"float",
")",
... | Length scale function which is an exponential of a sum of Gaussians.
The centers and widths of the Gaussians are free parameters.
The length scale function is given by
.. math::
l = l_0 \exp\left ( \sum_{i=1}^{N}\beta_i\exp\left ( -\frac{(x-\mu_i)^2}{2\sigma_i^2} \right ) \ri... | [
"Length",
"scale",
"function",
"which",
"is",
"an",
"exponential",
"of",
"a",
"sum",
"of",
"Gaussians",
".",
"The",
"centers",
"and",
"widths",
"of",
"the",
"Gaussians",
"are",
"free",
"parameters",
".",
"The",
"length",
"scale",
"function",
"is",
"given",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L763-L814 |
codenerix/django-codenerix | codenerix/djng/field_mixins.py | MultipleFieldMixin.get_multiple_choices_required | def get_multiple_choices_required(self):
"""
Add only the required message, but no 'ng-required' attribute to the input fields,
otherwise all Checkboxes of a MultipleChoiceField would require the property "checked".
"""
errors = []
if self.required:
for key, m... | python | def get_multiple_choices_required(self):
"""
Add only the required message, but no 'ng-required' attribute to the input fields,
otherwise all Checkboxes of a MultipleChoiceField would require the property "checked".
"""
errors = []
if self.required:
for key, m... | [
"def",
"get_multiple_choices_required",
"(",
"self",
")",
":",
"errors",
"=",
"[",
"]",
"if",
"self",
".",
"required",
":",
"for",
"key",
",",
"msg",
"in",
"self",
".",
"error_messages",
".",
"items",
"(",
")",
":",
"if",
"key",
"==",
"'required'",
":"... | Add only the required message, but no 'ng-required' attribute to the input fields,
otherwise all Checkboxes of a MultipleChoiceField would require the property "checked". | [
"Add",
"only",
"the",
"required",
"message",
"but",
"no",
"ng",
"-",
"required",
"attribute",
"to",
"the",
"input",
"fields",
"otherwise",
"all",
"Checkboxes",
"of",
"a",
"MultipleChoiceField",
"would",
"require",
"the",
"property",
"checked",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/djng/field_mixins.py#L177-L187 |
CTPUG/wafer | wafer/registration/sso.py | sso | def sso(user, desired_username, name, email, profile_fields=None):
"""
Create a user, if the provided `user` is None, from the parameters.
Then log the user in, and return it.
"""
if not user:
if not settings.REGISTRATION_OPEN:
raise SSOError('Account registration is closed')
... | python | def sso(user, desired_username, name, email, profile_fields=None):
"""
Create a user, if the provided `user` is None, from the parameters.
Then log the user in, and return it.
"""
if not user:
if not settings.REGISTRATION_OPEN:
raise SSOError('Account registration is closed')
... | [
"def",
"sso",
"(",
"user",
",",
"desired_username",
",",
"name",
",",
"email",
",",
"profile_fields",
"=",
"None",
")",
":",
"if",
"not",
"user",
":",
"if",
"not",
"settings",
".",
"REGISTRATION_OPEN",
":",
"raise",
"SSOError",
"(",
"'Account registration is... | Create a user, if the provided `user` is None, from the parameters.
Then log the user in, and return it. | [
"Create",
"a",
"user",
"if",
"the",
"provided",
"user",
"is",
"None",
"from",
"the",
"parameters",
".",
"Then",
"log",
"the",
"user",
"in",
"and",
"return",
"it",
"."
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/registration/sso.py#L24-L41 |
markchil/gptools | gptools/gp_utils.py | parallel_compute_ll_matrix | def parallel_compute_ll_matrix(gp, bounds, num_pts, num_proc=None):
"""Compute matrix of the log likelihood over the parameter space in parallel.
Parameters
----------
bounds : 2-tuple or list of 2-tuples with length equal to the number of free parameters
Bounds on the range to use for each... | python | def parallel_compute_ll_matrix(gp, bounds, num_pts, num_proc=None):
"""Compute matrix of the log likelihood over the parameter space in parallel.
Parameters
----------
bounds : 2-tuple or list of 2-tuples with length equal to the number of free parameters
Bounds on the range to use for each... | [
"def",
"parallel_compute_ll_matrix",
"(",
"gp",
",",
"bounds",
",",
"num_pts",
",",
"num_proc",
"=",
"None",
")",
":",
"if",
"num_proc",
"is",
"None",
":",
"num_proc",
"=",
"multiprocessing",
".",
"cpu_count",
"(",
")",
"present_free_params",
"=",
"gp",
".",... | Compute matrix of the log likelihood over the parameter space in parallel.
Parameters
----------
bounds : 2-tuple or list of 2-tuples with length equal to the number of free parameters
Bounds on the range to use for each of the parameters. If a single
2-tuple is given, it will be used f... | [
"Compute",
"matrix",
"of",
"the",
"log",
"likelihood",
"over",
"the",
"parameter",
"space",
"in",
"parallel",
".",
"Parameters",
"----------",
"bounds",
":",
"2",
"-",
"tuple",
"or",
"list",
"of",
"2",
"-",
"tuples",
"with",
"length",
"equal",
"to",
"the",... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gp_utils.py#L45-L117 |
markchil/gptools | gptools/gp_utils.py | slice_plot | def slice_plot(*args, **kwargs):
"""Constructs a plot that lets you look at slices through a multidimensional array.
Parameters
----------
vals : array, (`M`, `D`, `P`, ...)
Multidimensional array to visualize.
x_vals_1 : array, (`M`,)
Values along the first dimension.
x_val... | python | def slice_plot(*args, **kwargs):
"""Constructs a plot that lets you look at slices through a multidimensional array.
Parameters
----------
vals : array, (`M`, `D`, `P`, ...)
Multidimensional array to visualize.
x_vals_1 : array, (`M`,)
Values along the first dimension.
x_val... | [
"def",
"slice_plot",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"names",
"=",
"kwargs",
".",
"get",
"(",
"'names'",
",",
"None",
")",
"n",
"=",
"kwargs",
".",
"get",
"(",
"'n'",
",",
"100",
")",
"num_axes",
"=",
"len",
"(",
"args",
")... | Constructs a plot that lets you look at slices through a multidimensional array.
Parameters
----------
vals : array, (`M`, `D`, `P`, ...)
Multidimensional array to visualize.
x_vals_1 : array, (`M`,)
Values along the first dimension.
x_vals_2 : array, (`D`,)
Values along... | [
"Constructs",
"a",
"plot",
"that",
"lets",
"you",
"look",
"at",
"slices",
"through",
"a",
"multidimensional",
"array",
".",
"Parameters",
"----------",
"vals",
":",
"array",
"(",
"M",
"D",
"P",
"...",
")",
"Multidimensional",
"array",
"to",
"visualize",
".",... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gp_utils.py#L134-L236 |
markchil/gptools | gptools/gp_utils.py | arrow_respond | def arrow_respond(slider, event):
"""Event handler for arrow key events in plot windows.
Pass the slider object to update as a masked argument using a lambda function::
lambda evt: arrow_respond(my_slider, evt)
Parameters
----------
slider : Slider instance associated with... | python | def arrow_respond(slider, event):
"""Event handler for arrow key events in plot windows.
Pass the slider object to update as a masked argument using a lambda function::
lambda evt: arrow_respond(my_slider, evt)
Parameters
----------
slider : Slider instance associated with... | [
"def",
"arrow_respond",
"(",
"slider",
",",
"event",
")",
":",
"if",
"event",
".",
"key",
"==",
"'right'",
":",
"slider",
".",
"set_val",
"(",
"min",
"(",
"slider",
".",
"val",
"+",
"1",
",",
"slider",
".",
"valmax",
")",
")",
"elif",
"event",
".",... | Event handler for arrow key events in plot windows.
Pass the slider object to update as a masked argument using a lambda function::
lambda evt: arrow_respond(my_slider, evt)
Parameters
----------
slider : Slider instance associated with this handler.
event : Event to be ha... | [
"Event",
"handler",
"for",
"arrow",
"key",
"events",
"in",
"plot",
"windows",
".",
"Pass",
"the",
"slider",
"object",
"to",
"update",
"as",
"a",
"masked",
"argument",
"using",
"a",
"lambda",
"function",
"::",
"lambda",
"evt",
":",
"arrow_respond",
"(",
"my... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gp_utils.py#L238-L253 |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.debit | def debit(self, amount, credit_account, description, debit_memo="", credit_memo="", datetime=None):
""" Post a debit of 'amount' and a credit of -amount against this account and credit_account respectively.
note amount must be non-negative.
"""
assert amount >= 0
return self.po... | python | def debit(self, amount, credit_account, description, debit_memo="", credit_memo="", datetime=None):
""" Post a debit of 'amount' and a credit of -amount against this account and credit_account respectively.
note amount must be non-negative.
"""
assert amount >= 0
return self.po... | [
"def",
"debit",
"(",
"self",
",",
"amount",
",",
"credit_account",
",",
"description",
",",
"debit_memo",
"=",
"\"\"",
",",
"credit_memo",
"=",
"\"\"",
",",
"datetime",
"=",
"None",
")",
":",
"assert",
"amount",
">=",
"0",
"return",
"self",
".",
"post",
... | Post a debit of 'amount' and a credit of -amount against this account and credit_account respectively.
note amount must be non-negative. | [
"Post",
"a",
"debit",
"of",
"amount",
"and",
"a",
"credit",
"of",
"-",
"amount",
"against",
"this",
"account",
"and",
"credit_account",
"respectively",
"."
] | train | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L143-L150 |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.credit | def credit(self, amount, debit_account, description, debit_memo="", credit_memo="", datetime=None):
""" Post a credit of 'amount' and a debit of -amount against this account and credit_account respectively.
note amount must be non-negative.
"""
assert amount >= 0
return self.pos... | python | def credit(self, amount, debit_account, description, debit_memo="", credit_memo="", datetime=None):
""" Post a credit of 'amount' and a debit of -amount against this account and credit_account respectively.
note amount must be non-negative.
"""
assert amount >= 0
return self.pos... | [
"def",
"credit",
"(",
"self",
",",
"amount",
",",
"debit_account",
",",
"description",
",",
"debit_memo",
"=",
"\"\"",
",",
"credit_memo",
"=",
"\"\"",
",",
"datetime",
"=",
"None",
")",
":",
"assert",
"amount",
">=",
"0",
"return",
"self",
".",
"post",
... | Post a credit of 'amount' and a debit of -amount against this account and credit_account respectively.
note amount must be non-negative. | [
"Post",
"a",
"credit",
"of",
"amount",
"and",
"a",
"debit",
"of",
"-",
"amount",
"against",
"this",
"account",
"and",
"credit_account",
"respectively",
"."
] | train | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L152-L158 |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.post | def post(self, amount, other_account, description, self_memo="", other_memo="", datetime=None):
""" Post a transaction of 'amount' against this account and the negative amount against 'other_account'.
This will show as a debit or credit against this account when amount > 0 or amount < 0 respectively.
... | python | def post(self, amount, other_account, description, self_memo="", other_memo="", datetime=None):
""" Post a transaction of 'amount' against this account and the negative amount against 'other_account'.
This will show as a debit or credit against this account when amount > 0 or amount < 0 respectively.
... | [
"def",
"post",
"(",
"self",
",",
"amount",
",",
"other_account",
",",
"description",
",",
"self_memo",
"=",
"\"\"",
",",
"other_memo",
"=",
"\"\"",
",",
"datetime",
"=",
"None",
")",
":",
"#Note: debits are always positive, credits are always negative. They should be... | Post a transaction of 'amount' against this account and the negative amount against 'other_account'.
This will show as a debit or credit against this account when amount > 0 or amount < 0 respectively. | [
"Post",
"a",
"transaction",
"of",
"amount",
"against",
"this",
"account",
"and",
"the",
"negative",
"amount",
"against",
"other_account",
"."
] | train | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L161-L183 |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.balance | def balance(self, date=None):
""" returns the account balance as of 'date' (datetime stamp) or now(). """
qs = self._entries()
if date:
qs = qs.filter(transaction__t_stamp__lt=date)
r = qs.aggregate(b=Sum('amount'))
b = r['b']
flip = self._DEBIT_IN_DB()
... | python | def balance(self, date=None):
""" returns the account balance as of 'date' (datetime stamp) or now(). """
qs = self._entries()
if date:
qs = qs.filter(transaction__t_stamp__lt=date)
r = qs.aggregate(b=Sum('amount'))
b = r['b']
flip = self._DEBIT_IN_DB()
... | [
"def",
"balance",
"(",
"self",
",",
"date",
"=",
"None",
")",
":",
"qs",
"=",
"self",
".",
"_entries",
"(",
")",
"if",
"date",
":",
"qs",
"=",
"qs",
".",
"filter",
"(",
"transaction__t_stamp__lt",
"=",
"date",
")",
"r",
"=",
"qs",
".",
"aggregate",... | returns the account balance as of 'date' (datetime stamp) or now(). | [
"returns",
"the",
"account",
"balance",
"as",
"of",
"date",
"(",
"datetime",
"stamp",
")",
"or",
"now",
"()",
"."
] | train | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L185-L203 |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.totals | def totals(self, start=None, end=None):
"""Returns a Totals object containing the sum of all debits, credits
and net change over the period of time from start to end.
'start' is inclusive, 'end' is exclusive
"""
qs = self._entries_range(start=start, end=end)
qs_positive... | python | def totals(self, start=None, end=None):
"""Returns a Totals object containing the sum of all debits, credits
and net change over the period of time from start to end.
'start' is inclusive, 'end' is exclusive
"""
qs = self._entries_range(start=start, end=end)
qs_positive... | [
"def",
"totals",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"qs",
"=",
"self",
".",
"_entries_range",
"(",
"start",
"=",
"start",
",",
"end",
"=",
"end",
")",
"qs_positive",
"=",
"qs",
".",
"filter",
"(",
"amount__gt... | Returns a Totals object containing the sum of all debits, credits
and net change over the period of time from start to end.
'start' is inclusive, 'end' is exclusive | [
"Returns",
"a",
"Totals",
"object",
"containing",
"the",
"sum",
"of",
"all",
"debits",
"credits",
"and",
"net",
"change",
"over",
"the",
"period",
"of",
"time",
"from",
"start",
"to",
"end",
"."
] | train | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L220-L246 |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.ledger | def ledger(self, start=None, end=None):
"""Returns a list of entries for this account.
Ledger returns a sequence of LedgerEntry's matching the criteria
in chronological order. The returned sequence can be boolean-tested
(ie. test that nothing was returned).
If 'start' is given,... | python | def ledger(self, start=None, end=None):
"""Returns a list of entries for this account.
Ledger returns a sequence of LedgerEntry's matching the criteria
in chronological order. The returned sequence can be boolean-tested
(ie. test that nothing was returned).
If 'start' is given,... | [
"def",
"ledger",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"DEBIT_IN_DB",
"=",
"self",
".",
"_DEBIT_IN_DB",
"(",
")",
"flip",
"=",
"1",
"if",
"self",
".",
"_positive_credit",
"(",
")",
":",
"flip",
"*=",
"-",
"1",
... | Returns a list of entries for this account.
Ledger returns a sequence of LedgerEntry's matching the criteria
in chronological order. The returned sequence can be boolean-tested
(ie. test that nothing was returned).
If 'start' is given, only entries on or after that datetime are
... | [
"Returns",
"a",
"list",
"of",
"entries",
"for",
"this",
"account",
"."
] | train | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L248-L288 |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | BookSetBase.get_third_party | def get_third_party(self, third_party):
"""Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset."""
actual_account = third_party.get_account()
assert actual_account.get_bookset() == self
return ThirdPartySubAccount(actual_acco... | python | def get_third_party(self, third_party):
"""Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset."""
actual_account = third_party.get_account()
assert actual_account.get_bookset() == self
return ThirdPartySubAccount(actual_acco... | [
"def",
"get_third_party",
"(",
"self",
",",
"third_party",
")",
":",
"actual_account",
"=",
"third_party",
".",
"get_account",
"(",
")",
"assert",
"actual_account",
".",
"get_bookset",
"(",
")",
"==",
"self",
"return",
"ThirdPartySubAccount",
"(",
"actual_account"... | Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset. | [
"Return",
"the",
"account",
"for",
"the",
"given",
"third",
"-",
"party",
".",
"Raise",
"<something",
">",
"if",
"the",
"third",
"party",
"doesn",
"t",
"belong",
"to",
"this",
"bookset",
"."
] | train | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L371-L375 |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | ProjectBase.get_third_party | def get_third_party(self, third_party):
"""Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset."""
actual_account = third_party.get_account()
assert actual_account.get_bookset() == self.get_bookset()
return ProjectAccount(ac... | python | def get_third_party(self, third_party):
"""Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset."""
actual_account = third_party.get_account()
assert actual_account.get_bookset() == self.get_bookset()
return ProjectAccount(ac... | [
"def",
"get_third_party",
"(",
"self",
",",
"third_party",
")",
":",
"actual_account",
"=",
"third_party",
".",
"get_account",
"(",
")",
"assert",
"actual_account",
".",
"get_bookset",
"(",
")",
"==",
"self",
".",
"get_bookset",
"(",
")",
"return",
"ProjectAcc... | Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset. | [
"Return",
"the",
"account",
"for",
"the",
"given",
"third",
"-",
"party",
".",
"Raise",
"<something",
">",
"if",
"the",
"third",
"party",
"doesn",
"t",
"belong",
"to",
"this",
"bookset",
"."
] | train | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L392-L397 |
CTPUG/wafer | wafer/schedule/admin.py | find_overlapping_slots | def find_overlapping_slots(all_slots):
"""Find any slots that overlap"""
overlaps = set([])
for slot in all_slots:
# Because slots are ordered, we can be more efficient than this
# N^2 loop, but this is simple and, since the number of slots
# should be low, this should be "fast enoug... | python | def find_overlapping_slots(all_slots):
"""Find any slots that overlap"""
overlaps = set([])
for slot in all_slots:
# Because slots are ordered, we can be more efficient than this
# N^2 loop, but this is simple and, since the number of slots
# should be low, this should be "fast enoug... | [
"def",
"find_overlapping_slots",
"(",
"all_slots",
")",
":",
"overlaps",
"=",
"set",
"(",
"[",
"]",
")",
"for",
"slot",
"in",
"all_slots",
":",
"# Because slots are ordered, we can be more efficient than this",
"# N^2 loop, but this is simple and, since the number of slots",
... | Find any slots that overlap | [
"Find",
"any",
"slots",
"that",
"overlap"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L24-L51 |
CTPUG/wafer | wafer/schedule/admin.py | find_non_contiguous | def find_non_contiguous(all_items):
"""Find any items that have slots that aren't contiguous"""
non_contiguous = []
for item in all_items:
if item.slots.count() < 2:
# No point in checking
continue
last_slot = None
for slot in item.slots.all().order_by('end_ti... | python | def find_non_contiguous(all_items):
"""Find any items that have slots that aren't contiguous"""
non_contiguous = []
for item in all_items:
if item.slots.count() < 2:
# No point in checking
continue
last_slot = None
for slot in item.slots.all().order_by('end_ti... | [
"def",
"find_non_contiguous",
"(",
"all_items",
")",
":",
"non_contiguous",
"=",
"[",
"]",
"for",
"item",
"in",
"all_items",
":",
"if",
"item",
".",
"slots",
".",
"count",
"(",
")",
"<",
"2",
":",
"# No point in checking",
"continue",
"last_slot",
"=",
"No... | Find any items that have slots that aren't contiguous | [
"Find",
"any",
"items",
"that",
"have",
"slots",
"that",
"aren",
"t",
"contiguous"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L55-L69 |
CTPUG/wafer | wafer/schedule/admin.py | validate_items | def validate_items(all_items):
"""Find errors in the schedule. Check for:
- pending / rejected talks in the schedule
- items with both talks and pages assigned
- items with neither talks nor pages assigned
"""
validation = []
for item in all_items:
if item.talk is... | python | def validate_items(all_items):
"""Find errors in the schedule. Check for:
- pending / rejected talks in the schedule
- items with both talks and pages assigned
- items with neither talks nor pages assigned
"""
validation = []
for item in all_items:
if item.talk is... | [
"def",
"validate_items",
"(",
"all_items",
")",
":",
"validation",
"=",
"[",
"]",
"for",
"item",
"in",
"all_items",
":",
"if",
"item",
".",
"talk",
"is",
"not",
"None",
"and",
"item",
".",
"page",
"is",
"not",
"None",
":",
"validation",
".",
"append",
... | Find errors in the schedule. Check for:
- pending / rejected talks in the schedule
- items with both talks and pages assigned
- items with neither talks nor pages assigned | [
"Find",
"errors",
"in",
"the",
"schedule",
".",
"Check",
"for",
":",
"-",
"pending",
"/",
"rejected",
"talks",
"in",
"the",
"schedule",
"-",
"items",
"with",
"both",
"talks",
"and",
"pages",
"assigned",
"-",
"items",
"with",
"neither",
"talks",
"nor",
"p... | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L72-L86 |
CTPUG/wafer | wafer/schedule/admin.py | find_duplicate_schedule_items | def find_duplicate_schedule_items(all_items):
"""Find talks / pages assigned to mulitple schedule items"""
duplicates = []
seen_talks = {}
for item in all_items:
if item.talk and item.talk in seen_talks:
duplicates.append(item)
if seen_talks[item.talk] not in duplicates:
... | python | def find_duplicate_schedule_items(all_items):
"""Find talks / pages assigned to mulitple schedule items"""
duplicates = []
seen_talks = {}
for item in all_items:
if item.talk and item.talk in seen_talks:
duplicates.append(item)
if seen_talks[item.talk] not in duplicates:
... | [
"def",
"find_duplicate_schedule_items",
"(",
"all_items",
")",
":",
"duplicates",
"=",
"[",
"]",
"seen_talks",
"=",
"{",
"}",
"for",
"item",
"in",
"all_items",
":",
"if",
"item",
".",
"talk",
"and",
"item",
".",
"talk",
"in",
"seen_talks",
":",
"duplicates... | Find talks / pages assigned to mulitple schedule items | [
"Find",
"talks",
"/",
"pages",
"assigned",
"to",
"mulitple",
"schedule",
"items"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L89-L103 |
CTPUG/wafer | wafer/schedule/admin.py | find_clashes | def find_clashes(all_items):
"""Find schedule items which clash (common slot and venue)"""
clashes = {}
seen_venue_slots = {}
for item in all_items:
for slot in item.slots.all():
pos = (item.venue, slot)
if pos in seen_venue_slots:
if seen_venue_slots[pos]... | python | def find_clashes(all_items):
"""Find schedule items which clash (common slot and venue)"""
clashes = {}
seen_venue_slots = {}
for item in all_items:
for slot in item.slots.all():
pos = (item.venue, slot)
if pos in seen_venue_slots:
if seen_venue_slots[pos]... | [
"def",
"find_clashes",
"(",
"all_items",
")",
":",
"clashes",
"=",
"{",
"}",
"seen_venue_slots",
"=",
"{",
"}",
"for",
"item",
"in",
"all_items",
":",
"for",
"slot",
"in",
"item",
".",
"slots",
".",
"all",
"(",
")",
":",
"pos",
"=",
"(",
"item",
".... | Find schedule items which clash (common slot and venue) | [
"Find",
"schedule",
"items",
"which",
"clash",
"(",
"common",
"slot",
"and",
"venue",
")"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L106-L120 |
CTPUG/wafer | wafer/schedule/admin.py | find_invalid_venues | def find_invalid_venues(all_items):
"""Find venues assigned slots that aren't on the allowed list
of days."""
venues = {}
for item in all_items:
valid = False
item_days = list(item.venue.days.all())
for slot in item.slots.all():
for day in item_days:
... | python | def find_invalid_venues(all_items):
"""Find venues assigned slots that aren't on the allowed list
of days."""
venues = {}
for item in all_items:
valid = False
item_days = list(item.venue.days.all())
for slot in item.slots.all():
for day in item_days:
... | [
"def",
"find_invalid_venues",
"(",
"all_items",
")",
":",
"venues",
"=",
"{",
"}",
"for",
"item",
"in",
"all_items",
":",
"valid",
"=",
"False",
"item_days",
"=",
"list",
"(",
"item",
".",
"venue",
".",
"days",
".",
"all",
"(",
")",
")",
"for",
"slot... | Find venues assigned slots that aren't on the allowed list
of days. | [
"Find",
"venues",
"assigned",
"slots",
"that",
"aren",
"t",
"on",
"the",
"allowed",
"list",
"of",
"days",
"."
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L123-L138 |
CTPUG/wafer | wafer/schedule/admin.py | check_schedule | def check_schedule():
"""Helper routine to easily test if the schedule is valid"""
all_items = prefetch_schedule_items()
for validator, _type, _msg in SCHEDULE_ITEM_VALIDATORS:
if validator(all_items):
return False
all_slots = prefetch_slots()
for validator, _type, _msg in SLOT_... | python | def check_schedule():
"""Helper routine to easily test if the schedule is valid"""
all_items = prefetch_schedule_items()
for validator, _type, _msg in SCHEDULE_ITEM_VALIDATORS:
if validator(all_items):
return False
all_slots = prefetch_slots()
for validator, _type, _msg in SLOT_... | [
"def",
"check_schedule",
"(",
")",
":",
"all_items",
"=",
"prefetch_schedule_items",
"(",
")",
"for",
"validator",
",",
"_type",
",",
"_msg",
"in",
"SCHEDULE_ITEM_VALIDATORS",
":",
"if",
"validator",
"(",
"all_items",
")",
":",
"return",
"False",
"all_slots",
... | Helper routine to easily test if the schedule is valid | [
"Helper",
"routine",
"to",
"easily",
"test",
"if",
"the",
"schedule",
"is",
"valid"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L196-L207 |
CTPUG/wafer | wafer/schedule/admin.py | validate_schedule | def validate_schedule():
"""Helper routine to report issues with the schedule"""
all_items = prefetch_schedule_items()
errors = []
for validator, _type, msg in SCHEDULE_ITEM_VALIDATORS:
if validator(all_items):
errors.append(msg)
all_slots = prefetch_slots()
for validator, _... | python | def validate_schedule():
"""Helper routine to report issues with the schedule"""
all_items = prefetch_schedule_items()
errors = []
for validator, _type, msg in SCHEDULE_ITEM_VALIDATORS:
if validator(all_items):
errors.append(msg)
all_slots = prefetch_slots()
for validator, _... | [
"def",
"validate_schedule",
"(",
")",
":",
"all_items",
"=",
"prefetch_schedule_items",
"(",
")",
"errors",
"=",
"[",
"]",
"for",
"validator",
",",
"_type",
",",
"msg",
"in",
"SCHEDULE_ITEM_VALIDATORS",
":",
"if",
"validator",
"(",
"all_items",
")",
":",
"er... | Helper routine to report issues with the schedule | [
"Helper",
"routine",
"to",
"report",
"issues",
"with",
"the",
"schedule"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L210-L222 |
CTPUG/wafer | wafer/schedule/admin.py | SlotAdmin.get_form | def get_form(self, request, obj=None, **kwargs):
"""Change the form depending on whether we're adding or
editing the slot."""
if obj is None:
# Adding a new Slot
kwargs['form'] = SlotAdminAddForm
return super(SlotAdmin, self).get_form(request, obj, **kwargs) | python | def get_form(self, request, obj=None, **kwargs):
"""Change the form depending on whether we're adding or
editing the slot."""
if obj is None:
# Adding a new Slot
kwargs['form'] = SlotAdminAddForm
return super(SlotAdmin, self).get_form(request, obj, **kwargs) | [
"def",
"get_form",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"obj",
"is",
"None",
":",
"# Adding a new Slot",
"kwargs",
"[",
"'form'",
"]",
"=",
"SlotAdminAddForm",
"return",
"super",
"(",
"SlotAdmin",... | Change the form depending on whether we're adding or
editing the slot. | [
"Change",
"the",
"form",
"depending",
"on",
"whether",
"we",
"re",
"adding",
"or",
"editing",
"the",
"slot",
"."
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L457-L463 |
CTPUG/wafer | wafer/menu.py | get_cached_menus | def get_cached_menus():
"""Return the menus from the cache or generate them if needed."""
items = cache.get(CACHE_KEY)
if items is None:
menu = generate_menu()
cache.set(CACHE_KEY, menu.items)
else:
menu = Menu(items)
return menu | python | def get_cached_menus():
"""Return the menus from the cache or generate them if needed."""
items = cache.get(CACHE_KEY)
if items is None:
menu = generate_menu()
cache.set(CACHE_KEY, menu.items)
else:
menu = Menu(items)
return menu | [
"def",
"get_cached_menus",
"(",
")",
":",
"items",
"=",
"cache",
".",
"get",
"(",
"CACHE_KEY",
")",
"if",
"items",
"is",
"None",
":",
"menu",
"=",
"generate_menu",
"(",
")",
"cache",
".",
"set",
"(",
"CACHE_KEY",
",",
"menu",
".",
"items",
")",
"else... | Return the menus from the cache or generate them if needed. | [
"Return",
"the",
"menus",
"from",
"the",
"cache",
"or",
"generate",
"them",
"if",
"needed",
"."
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/menu.py#L12-L20 |
CTPUG/wafer | wafer/menu.py | maybe_obj | def maybe_obj(str_or_obj):
"""If argument is not a string, return it.
Otherwise import the dotted name and return that.
"""
if not isinstance(str_or_obj, six.string_types):
return str_or_obj
parts = str_or_obj.split(".")
mod, modname = None, None
for p in parts:
modname = p ... | python | def maybe_obj(str_or_obj):
"""If argument is not a string, return it.
Otherwise import the dotted name and return that.
"""
if not isinstance(str_or_obj, six.string_types):
return str_or_obj
parts = str_or_obj.split(".")
mod, modname = None, None
for p in parts:
modname = p ... | [
"def",
"maybe_obj",
"(",
"str_or_obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"str_or_obj",
",",
"six",
".",
"string_types",
")",
":",
"return",
"str_or_obj",
"parts",
"=",
"str_or_obj",
".",
"split",
"(",
"\".\"",
")",
"mod",
",",
"modname",
"=",
"No... | If argument is not a string, return it.
Otherwise import the dotted name and return that. | [
"If",
"argument",
"is",
"not",
"a",
"string",
"return",
"it",
"."
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/menu.py#L44-L64 |
CTPUG/wafer | wafer/menu.py | generate_menu | def generate_menu():
"""Generate a new list of menus."""
root_menu = Menu(list(copy.deepcopy(settings.WAFER_MENUS)))
for dynamic_menu_func in settings.WAFER_DYNAMIC_MENUS:
dynamic_menu_func = maybe_obj(dynamic_menu_func)
dynamic_menu_func(root_menu)
return root_menu | python | def generate_menu():
"""Generate a new list of menus."""
root_menu = Menu(list(copy.deepcopy(settings.WAFER_MENUS)))
for dynamic_menu_func in settings.WAFER_DYNAMIC_MENUS:
dynamic_menu_func = maybe_obj(dynamic_menu_func)
dynamic_menu_func(root_menu)
return root_menu | [
"def",
"generate_menu",
"(",
")",
":",
"root_menu",
"=",
"Menu",
"(",
"list",
"(",
"copy",
".",
"deepcopy",
"(",
"settings",
".",
"WAFER_MENUS",
")",
")",
")",
"for",
"dynamic_menu_func",
"in",
"settings",
".",
"WAFER_DYNAMIC_MENUS",
":",
"dynamic_menu_func",
... | Generate a new list of menus. | [
"Generate",
"a",
"new",
"list",
"of",
"menus",
"."
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/menu.py#L67-L73 |
codenerix/django-codenerix | codenerix/lib/pylock.py | pylock.lock | def lock(self):
'''
Try to get locked the file
- the function will wait until the file is unlocked if 'wait' was defined as locktype
- the funciton will raise AlreadyLocked exception if 'lock' was defined as locktype
'''
# Open file
self.__fd = open(self.__lockfi... | python | def lock(self):
'''
Try to get locked the file
- the function will wait until the file is unlocked if 'wait' was defined as locktype
- the funciton will raise AlreadyLocked exception if 'lock' was defined as locktype
'''
# Open file
self.__fd = open(self.__lockfi... | [
"def",
"lock",
"(",
"self",
")",
":",
"# Open file",
"self",
".",
"__fd",
"=",
"open",
"(",
"self",
".",
"__lockfile",
",",
"\"w\"",
")",
"# Get it locked",
"if",
"self",
".",
"__locktype",
"==",
"\"wait\"",
":",
"# Try to get it locked until ready",
"fcntl",
... | Try to get locked the file
- the function will wait until the file is unlocked if 'wait' was defined as locktype
- the funciton will raise AlreadyLocked exception if 'lock' was defined as locktype | [
"Try",
"to",
"get",
"locked",
"the",
"file",
"-",
"the",
"function",
"will",
"wait",
"until",
"the",
"file",
"is",
"unlocked",
"if",
"wait",
"was",
"defined",
"as",
"locktype",
"-",
"the",
"funciton",
"will",
"raise",
"AlreadyLocked",
"exception",
"if",
"l... | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/lib/pylock.py#L70-L89 |
coursera/courseraoauth2client | courseraoauth2client/oauth2.py | _make_handler | def _make_handler(state_token, done_function):
'''
Makes a a handler class to use inside the basic python HTTP server.
state_token is the expected state token.
done_function is a function that is called, with the code passed to it.
'''
class LocalServerHandler(BaseHTTPServer.BaseHTTPRequestHan... | python | def _make_handler(state_token, done_function):
'''
Makes a a handler class to use inside the basic python HTTP server.
state_token is the expected state token.
done_function is a function that is called, with the code passed to it.
'''
class LocalServerHandler(BaseHTTPServer.BaseHTTPRequestHan... | [
"def",
"_make_handler",
"(",
"state_token",
",",
"done_function",
")",
":",
"class",
"LocalServerHandler",
"(",
"BaseHTTPServer",
".",
"BaseHTTPRequestHandler",
")",
":",
"def",
"error_response",
"(",
"self",
",",
"msg",
")",
":",
"logging",
".",
"warn",
"(",
... | Makes a a handler class to use inside the basic python HTTP server.
state_token is the expected state token.
done_function is a function that is called, with the code passed to it. | [
"Makes",
"a",
"a",
"handler",
"class",
"to",
"use",
"inside",
"the",
"basic",
"python",
"HTTP",
"server",
"."
] | train | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L105-L151 |
coursera/courseraoauth2client | courseraoauth2client/oauth2.py | configuration | def configuration():
'Loads configuration from the file system.'
defaults = '''
[oauth2]
hostname = localhost
port = 9876
api_endpoint = https://api.coursera.org
auth_endpoint = https://accounts.coursera.org/oauth2/v1/auth
token_endpoint = https://accounts.coursera.org/oauth2/v1/token
verify_tls = True
token_ca... | python | def configuration():
'Loads configuration from the file system.'
defaults = '''
[oauth2]
hostname = localhost
port = 9876
api_endpoint = https://api.coursera.org
auth_endpoint = https://accounts.coursera.org/oauth2/v1/auth
token_endpoint = https://accounts.coursera.org/oauth2/v1/token
verify_tls = True
token_ca... | [
"def",
"configuration",
"(",
")",
":",
"defaults",
"=",
"'''\n[oauth2]\nhostname = localhost\nport = 9876\napi_endpoint = https://api.coursera.org\nauth_endpoint = https://accounts.coursera.org/oauth2/v1/auth\ntoken_endpoint = https://accounts.coursera.org/oauth2/v1/token\nverify_tls = True\ntoken_cac... | Loads configuration from the file system. | [
"Loads",
"configuration",
"from",
"the",
"file",
"system",
"."
] | train | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L522-L551 |
coursera/courseraoauth2client | courseraoauth2client/oauth2.py | CourseraOAuth2._load_token_cache | def _load_token_cache(self):
'Reads the local fs cache for pre-authorized access tokens'
try:
logging.debug('About to read from local file cache file %s',
self.token_cache_file)
with open(self.token_cache_file, 'rb') as f:
fs_cached = cPi... | python | def _load_token_cache(self):
'Reads the local fs cache for pre-authorized access tokens'
try:
logging.debug('About to read from local file cache file %s',
self.token_cache_file)
with open(self.token_cache_file, 'rb') as f:
fs_cached = cPi... | [
"def",
"_load_token_cache",
"(",
"self",
")",
":",
"try",
":",
"logging",
".",
"debug",
"(",
"'About to read from local file cache file %s'",
",",
"self",
".",
"token_cache_file",
")",
"with",
"open",
"(",
"self",
".",
"token_cache_file",
",",
"'rb'",
")",
"as",... | Reads the local fs cache for pre-authorized access tokens | [
"Reads",
"the",
"local",
"fs",
"cache",
"for",
"pre",
"-",
"authorized",
"access",
"tokens"
] | train | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L230-L253 |
coursera/courseraoauth2client | courseraoauth2client/oauth2.py | CourseraOAuth2._save_token_cache | def _save_token_cache(self, new_cache):
'Write out to the filesystem a cache of the OAuth2 information.'
logging.debug('Looking to write to local authentication cache...')
if not self._check_token_cache_type(new_cache):
logging.error('Attempt to save a bad value: %s', new_cache)
... | python | def _save_token_cache(self, new_cache):
'Write out to the filesystem a cache of the OAuth2 information.'
logging.debug('Looking to write to local authentication cache...')
if not self._check_token_cache_type(new_cache):
logging.error('Attempt to save a bad value: %s', new_cache)
... | [
"def",
"_save_token_cache",
"(",
"self",
",",
"new_cache",
")",
":",
"logging",
".",
"debug",
"(",
"'Looking to write to local authentication cache...'",
")",
"if",
"not",
"self",
".",
"_check_token_cache_type",
"(",
"new_cache",
")",
":",
"logging",
".",
"error",
... | Write out to the filesystem a cache of the OAuth2 information. | [
"Write",
"out",
"to",
"the",
"filesystem",
"a",
"cache",
"of",
"the",
"OAuth2",
"information",
"."
] | train | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L255-L270 |
coursera/courseraoauth2client | courseraoauth2client/oauth2.py | CourseraOAuth2._check_token_cache_type | def _check_token_cache_type(self, cache_value):
'''
Checks the cache_value for appropriate type correctness.
Pass strict=True for strict validation to ensure the latest types are
being written.
Returns true is correct type, False otherwise.
'''
def check_string_... | python | def _check_token_cache_type(self, cache_value):
'''
Checks the cache_value for appropriate type correctness.
Pass strict=True for strict validation to ensure the latest types are
being written.
Returns true is correct type, False otherwise.
'''
def check_string_... | [
"def",
"_check_token_cache_type",
"(",
"self",
",",
"cache_value",
")",
":",
"def",
"check_string_value",
"(",
"name",
")",
":",
"return",
"(",
"isinstance",
"(",
"cache_value",
"[",
"name",
"]",
",",
"str",
")",
"or",
"isinstance",
"(",
"cache_value",
"[",
... | Checks the cache_value for appropriate type correctness.
Pass strict=True for strict validation to ensure the latest types are
being written.
Returns true is correct type, False otherwise. | [
"Checks",
"the",
"cache_value",
"for",
"appropriate",
"type",
"correctness",
"."
] | train | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L272-L300 |
coursera/courseraoauth2client | courseraoauth2client/oauth2.py | CourseraOAuth2._authorize_new_tokens | def _authorize_new_tokens(self):
'''
Stands up a new localhost http server and retrieves new OAuth2 access
tokens from the Coursera OAuth2 server.
'''
logging.info('About to request new OAuth2 tokens from Coursera.')
# Attempt to request new tokens from Coursera via the b... | python | def _authorize_new_tokens(self):
'''
Stands up a new localhost http server and retrieves new OAuth2 access
tokens from the Coursera OAuth2 server.
'''
logging.info('About to request new OAuth2 tokens from Coursera.')
# Attempt to request new tokens from Coursera via the b... | [
"def",
"_authorize_new_tokens",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'About to request new OAuth2 tokens from Coursera.'",
")",
"# Attempt to request new tokens from Coursera via the browser.",
"state_token",
"=",
"uuid",
".",
"uuid4",
"(",
")",
".",
"hex",
... | Stands up a new localhost http server and retrieves new OAuth2 access
tokens from the Coursera OAuth2 server. | [
"Stands",
"up",
"a",
"new",
"localhost",
"http",
"server",
"and",
"retrieves",
"new",
"OAuth2",
"access",
"tokens",
"from",
"the",
"Coursera",
"OAuth2",
"server",
"."
] | train | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L369-L415 |
coursera/courseraoauth2client | courseraoauth2client/oauth2.py | CourseraOAuth2._exchange_refresh_tokens | def _exchange_refresh_tokens(self):
'Exchanges a refresh token for an access token'
if self.token_cache is not None and 'refresh' in self.token_cache:
# Attempt to use the refresh token to get a new access token.
refresh_form = {
'grant_type': 'refresh_token',
... | python | def _exchange_refresh_tokens(self):
'Exchanges a refresh token for an access token'
if self.token_cache is not None and 'refresh' in self.token_cache:
# Attempt to use the refresh token to get a new access token.
refresh_form = {
'grant_type': 'refresh_token',
... | [
"def",
"_exchange_refresh_tokens",
"(",
"self",
")",
":",
"if",
"self",
".",
"token_cache",
"is",
"not",
"None",
"and",
"'refresh'",
"in",
"self",
".",
"token_cache",
":",
"# Attempt to use the refresh token to get a new access token.",
"refresh_form",
"=",
"{",
"'gra... | Exchanges a refresh token for an access token | [
"Exchanges",
"a",
"refresh",
"token",
"for",
"an",
"access",
"token"
] | train | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L417-L434 |
codenerix/django-codenerix | codenerix/templatetags/codenerix_lists.py | foreignkey | def foreignkey(element, exceptions):
'''
function to determine if each select field needs a create button or not
'''
label = element.field.__dict__['label']
try:
label = unicode(label)
except NameError:
pass
if (not label) or (label in exceptions):
return False
el... | python | def foreignkey(element, exceptions):
'''
function to determine if each select field needs a create button or not
'''
label = element.field.__dict__['label']
try:
label = unicode(label)
except NameError:
pass
if (not label) or (label in exceptions):
return False
el... | [
"def",
"foreignkey",
"(",
"element",
",",
"exceptions",
")",
":",
"label",
"=",
"element",
".",
"field",
".",
"__dict__",
"[",
"'label'",
"]",
"try",
":",
"label",
"=",
"unicode",
"(",
"label",
")",
"except",
"NameError",
":",
"pass",
"if",
"(",
"not",... | function to determine if each select field needs a create button or not | [
"function",
"to",
"determine",
"if",
"each",
"select",
"field",
"needs",
"a",
"create",
"button",
"or",
"not"
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/templatetags/codenerix_lists.py#L218-L230 |
CTPUG/wafer | wafer/kv/utils.py | deserialize_by_field | def deserialize_by_field(value, field):
"""
Some types get serialized to JSON, as strings.
If we know what they are supposed to be, we can deserialize them
"""
if isinstance(field, forms.DateTimeField):
value = parse_datetime(value)
elif isinstance(field, forms.DateField):
value ... | python | def deserialize_by_field(value, field):
"""
Some types get serialized to JSON, as strings.
If we know what they are supposed to be, we can deserialize them
"""
if isinstance(field, forms.DateTimeField):
value = parse_datetime(value)
elif isinstance(field, forms.DateField):
value ... | [
"def",
"deserialize_by_field",
"(",
"value",
",",
"field",
")",
":",
"if",
"isinstance",
"(",
"field",
",",
"forms",
".",
"DateTimeField",
")",
":",
"value",
"=",
"parse_datetime",
"(",
"value",
")",
"elif",
"isinstance",
"(",
"field",
",",
"forms",
".",
... | Some types get serialized to JSON, as strings.
If we know what they are supposed to be, we can deserialize them | [
"Some",
"types",
"get",
"serialized",
"to",
"JSON",
"as",
"strings",
".",
"If",
"we",
"know",
"what",
"they",
"are",
"supposed",
"to",
"be",
"we",
"can",
"deserialize",
"them"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/kv/utils.py#L5-L16 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.hyperprior | def hyperprior(self):
"""Combined hyperprior for the kernel, noise kernel and (if present) mean function.
"""
hp = self.k.hyperprior * self.noise_k.hyperprior
if self.mu is not None:
hp *= self.mu.hyperprior
return hp | python | def hyperprior(self):
"""Combined hyperprior for the kernel, noise kernel and (if present) mean function.
"""
hp = self.k.hyperprior * self.noise_k.hyperprior
if self.mu is not None:
hp *= self.mu.hyperprior
return hp | [
"def",
"hyperprior",
"(",
"self",
")",
":",
"hp",
"=",
"self",
".",
"k",
".",
"hyperprior",
"*",
"self",
".",
"noise_k",
".",
"hyperprior",
"if",
"self",
".",
"mu",
"is",
"not",
"None",
":",
"hp",
"*=",
"self",
".",
"mu",
".",
"hyperprior",
"return... | Combined hyperprior for the kernel, noise kernel and (if present) mean function. | [
"Combined",
"hyperprior",
"for",
"the",
"kernel",
"noise",
"kernel",
"and",
"(",
"if",
"present",
")",
"mean",
"function",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L247-L253 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.fixed_params | def fixed_params(self):
"""Combined fixed hyperparameter flags for the kernel, noise kernel and (if present) mean function.
"""
fp = CombinedBounds(self.k.fixed_params, self.noise_k.fixed_params)
if self.mu is not None:
fp = CombinedBounds(fp, self.mu.fixed_params)
re... | python | def fixed_params(self):
"""Combined fixed hyperparameter flags for the kernel, noise kernel and (if present) mean function.
"""
fp = CombinedBounds(self.k.fixed_params, self.noise_k.fixed_params)
if self.mu is not None:
fp = CombinedBounds(fp, self.mu.fixed_params)
re... | [
"def",
"fixed_params",
"(",
"self",
")",
":",
"fp",
"=",
"CombinedBounds",
"(",
"self",
".",
"k",
".",
"fixed_params",
",",
"self",
".",
"noise_k",
".",
"fixed_params",
")",
"if",
"self",
".",
"mu",
"is",
"not",
"None",
":",
"fp",
"=",
"CombinedBounds"... | Combined fixed hyperparameter flags for the kernel, noise kernel and (if present) mean function. | [
"Combined",
"fixed",
"hyperparameter",
"flags",
"for",
"the",
"kernel",
"noise",
"kernel",
"and",
"(",
"if",
"present",
")",
"mean",
"function",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L261-L267 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.params | def params(self):
"""Combined hyperparameters for the kernel, noise kernel and (if present) mean function.
"""
p = CombinedBounds(self.k.params, self.noise_k.params)
if self.mu is not None:
p = CombinedBounds(p, self.mu.params)
return p | python | def params(self):
"""Combined hyperparameters for the kernel, noise kernel and (if present) mean function.
"""
p = CombinedBounds(self.k.params, self.noise_k.params)
if self.mu is not None:
p = CombinedBounds(p, self.mu.params)
return p | [
"def",
"params",
"(",
"self",
")",
":",
"p",
"=",
"CombinedBounds",
"(",
"self",
".",
"k",
".",
"params",
",",
"self",
".",
"noise_k",
".",
"params",
")",
"if",
"self",
".",
"mu",
"is",
"not",
"None",
":",
"p",
"=",
"CombinedBounds",
"(",
"p",
",... | Combined hyperparameters for the kernel, noise kernel and (if present) mean function. | [
"Combined",
"hyperparameters",
"for",
"the",
"kernel",
"noise",
"kernel",
"and",
"(",
"if",
"present",
")",
"mean",
"function",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L278-L284 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.param_names | def param_names(self):
"""Combined names for the hyperparameters for the kernel, noise kernel and (if present) mean function.
"""
pn = CombinedBounds(self.k.param_names, self.noise_k.param_names)
if self.mu is not None:
pn = CombinedBounds(pn, self.mu.param_names)
ret... | python | def param_names(self):
"""Combined names for the hyperparameters for the kernel, noise kernel and (if present) mean function.
"""
pn = CombinedBounds(self.k.param_names, self.noise_k.param_names)
if self.mu is not None:
pn = CombinedBounds(pn, self.mu.param_names)
ret... | [
"def",
"param_names",
"(",
"self",
")",
":",
"pn",
"=",
"CombinedBounds",
"(",
"self",
".",
"k",
".",
"param_names",
",",
"self",
".",
"noise_k",
".",
"param_names",
")",
"if",
"self",
".",
"mu",
"is",
"not",
"None",
":",
"pn",
"=",
"CombinedBounds",
... | Combined names for the hyperparameters for the kernel, noise kernel and (if present) mean function. | [
"Combined",
"names",
"for",
"the",
"hyperparameters",
"for",
"the",
"kernel",
"noise",
"kernel",
"and",
"(",
"if",
"present",
")",
"mean",
"function",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L306-L312 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.free_params | def free_params(self):
"""Combined free hyperparameters for the kernel, noise kernel and (if present) mean function.
"""
p = CombinedBounds(self.k.free_params, self.noise_k.free_params)
if self.mu is not None:
p = CombinedBounds(p, self.mu.free_params)
return p | python | def free_params(self):
"""Combined free hyperparameters for the kernel, noise kernel and (if present) mean function.
"""
p = CombinedBounds(self.k.free_params, self.noise_k.free_params)
if self.mu is not None:
p = CombinedBounds(p, self.mu.free_params)
return p | [
"def",
"free_params",
"(",
"self",
")",
":",
"p",
"=",
"CombinedBounds",
"(",
"self",
".",
"k",
".",
"free_params",
",",
"self",
".",
"noise_k",
".",
"free_params",
")",
"if",
"self",
".",
"mu",
"is",
"not",
"None",
":",
"p",
"=",
"CombinedBounds",
"... | Combined free hyperparameters for the kernel, noise kernel and (if present) mean function. | [
"Combined",
"free",
"hyperparameters",
"for",
"the",
"kernel",
"noise",
"kernel",
"and",
"(",
"if",
"present",
")",
"mean",
"function",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L322-L328 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.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.noise_k.free_params = value[self.k.num_free_p... | 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.noise_k.free_params = value[self.k.num_free_p... | [
"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",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L331-L339 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.free_param_bounds | def free_param_bounds(self):
"""Combined free hyperparameter bounds for the kernel, noise kernel and (if present) mean function.
"""
fpb = CombinedBounds(self.k.free_param_bounds, self.noise_k.free_param_bounds)
if self.mu is not None:
fpb = CombinedBounds(fpb, self.mu.free_p... | python | def free_param_bounds(self):
"""Combined free hyperparameter bounds for the kernel, noise kernel and (if present) mean function.
"""
fpb = CombinedBounds(self.k.free_param_bounds, self.noise_k.free_param_bounds)
if self.mu is not None:
fpb = CombinedBounds(fpb, self.mu.free_p... | [
"def",
"free_param_bounds",
"(",
"self",
")",
":",
"fpb",
"=",
"CombinedBounds",
"(",
"self",
".",
"k",
".",
"free_param_bounds",
",",
"self",
".",
"noise_k",
".",
"free_param_bounds",
")",
"if",
"self",
".",
"mu",
"is",
"not",
"None",
":",
"fpb",
"=",
... | Combined free hyperparameter bounds for the kernel, noise kernel and (if present) mean function. | [
"Combined",
"free",
"hyperparameter",
"bounds",
"for",
"the",
"kernel",
"noise",
"kernel",
"and",
"(",
"if",
"present",
")",
"mean",
"function",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L342-L348 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.free_param_names | def free_param_names(self):
"""Combined free hyperparameter names for the kernel, noise kernel and (if present) mean function.
"""
p = CombinedBounds(self.k.free_param_names, self.noise_k.free_param_names)
if self.mu is not None:
p = CombinedBounds(p, self.mu.free_param_names... | python | def free_param_names(self):
"""Combined free hyperparameter names for the kernel, noise kernel and (if present) mean function.
"""
p = CombinedBounds(self.k.free_param_names, self.noise_k.free_param_names)
if self.mu is not None:
p = CombinedBounds(p, self.mu.free_param_names... | [
"def",
"free_param_names",
"(",
"self",
")",
":",
"p",
"=",
"CombinedBounds",
"(",
"self",
".",
"k",
".",
"free_param_names",
",",
"self",
".",
"noise_k",
".",
"free_param_names",
")",
"if",
"self",
".",
"mu",
"is",
"not",
"None",
":",
"p",
"=",
"Combi... | Combined free hyperparameter names for the kernel, noise kernel and (if present) mean function. | [
"Combined",
"free",
"hyperparameter",
"names",
"for",
"the",
"kernel",
"noise",
"kernel",
"and",
"(",
"if",
"present",
")",
"mean",
"function",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L359-L365 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.add_data | def add_data(self, X, y, err_y=0, n=0, T=None):
"""Add data to the training data set of the GaussianProcess instance.
Parameters
----------
X : array, (`M`, `D`)
`M` input values of dimension `D`.
y : array, (`M`,)
`M` target values.
er... | python | def add_data(self, X, y, err_y=0, n=0, T=None):
"""Add data to the training data set of the GaussianProcess instance.
Parameters
----------
X : array, (`M`, `D`)
`M` input values of dimension `D`.
y : array, (`M`,)
`M` target values.
er... | [
"def",
"add_data",
"(",
"self",
",",
"X",
",",
"y",
",",
"err_y",
"=",
"0",
",",
"n",
"=",
"0",
",",
"T",
"=",
"None",
")",
":",
"# Verify y has only one non-trivial dimension:",
"y",
"=",
"scipy",
".",
"atleast_1d",
"(",
"scipy",
".",
"asarray",
"(",
... | Add data to the training data set of the GaussianProcess instance.
Parameters
----------
X : array, (`M`, `D`)
`M` input values of dimension `D`.
y : array, (`M`,)
`M` target values.
err_y : array, (`M`,) or scalar float, optional
Non-... | [
"Add",
"data",
"to",
"the",
"training",
"data",
"set",
"of",
"the",
"GaussianProcess",
"instance",
".",
"Parameters",
"----------",
"X",
":",
"array",
"(",
"M",
"D",
")",
"M",
"input",
"values",
"of",
"dimension",
"D",
".",
"y",
":",
"array",
"(",
"M",... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L376-L499 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.condense_duplicates | def condense_duplicates(self):
"""Condense duplicate points using a transformation matrix.
This is useful if you have multiple non-transformed points at the same
location or multiple transformed points that use the same quadrature
points.
Won't change the GP if ... | python | def condense_duplicates(self):
"""Condense duplicate points using a transformation matrix.
This is useful if you have multiple non-transformed points at the same
location or multiple transformed points that use the same quadrature
points.
Won't change the GP if ... | [
"def",
"condense_duplicates",
"(",
"self",
")",
":",
"unique",
",",
"inv",
"=",
"unique_rows",
"(",
"scipy",
".",
"hstack",
"(",
"(",
"self",
".",
"X",
",",
"self",
".",
"n",
")",
")",
",",
"return_inverse",
"=",
"True",
")",
"# Only proceed if there is ... | Condense duplicate points using a transformation matrix.
This is useful if you have multiple non-transformed points at the same
location or multiple transformed points that use the same quadrature
points.
Won't change the GP if all of the rows of [X, n] are unique. Will... | [
"Condense",
"duplicate",
"points",
"using",
"a",
"transformation",
"matrix",
".",
"This",
"is",
"useful",
"if",
"you",
"have",
"multiple",
"non",
"-",
"transformed",
"points",
"at",
"the",
"same",
"location",
"or",
"multiple",
"transformed",
"points",
"that",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L501-L537 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.remove_outliers | def remove_outliers(self, thresh=3, **predict_kwargs):
"""Remove outliers from the GP with very simplistic outlier detection.
Removes points that are more than `thresh` * `err_y` away from the GP
mean. Note that this is only very rough in that it ignores the
uncertainty in the G... | python | def remove_outliers(self, thresh=3, **predict_kwargs):
"""Remove outliers from the GP with very simplistic outlier detection.
Removes points that are more than `thresh` * `err_y` away from the GP
mean. Note that this is only very rough in that it ignores the
uncertainty in the G... | [
"def",
"remove_outliers",
"(",
"self",
",",
"thresh",
"=",
"3",
",",
"*",
"*",
"predict_kwargs",
")",
":",
"mean",
"=",
"self",
".",
"predict",
"(",
"self",
".",
"X",
",",
"n",
"=",
"self",
".",
"n",
",",
"noise",
"=",
"False",
",",
"return_std",
... | Remove outliers from the GP with very simplistic outlier detection.
Removes points that are more than `thresh` * `err_y` away from the GP
mean. Note that this is only very rough in that it ignores the
uncertainty in the GP mean at any given point. But you should only be
using th... | [
"Remove",
"outliers",
"from",
"the",
"GP",
"with",
"very",
"simplistic",
"outlier",
"detection",
".",
"Removes",
"points",
"that",
"are",
"more",
"than",
"thresh",
"*",
"err_y",
"away",
"from",
"the",
"GP",
"mean",
".",
"Note",
"that",
"this",
"is",
"only"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L539-L617 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.optimize_hyperparameters | def optimize_hyperparameters(self, method='SLSQP', opt_kwargs={},
verbose=False, random_starts=None,
num_proc=None, max_tries=1):
r"""Optimize the hyperparameters by maximizing the log-posterior.
Leaves the :py:class:`GaussianPro... | python | def optimize_hyperparameters(self, method='SLSQP', opt_kwargs={},
verbose=False, random_starts=None,
num_proc=None, max_tries=1):
r"""Optimize the hyperparameters by maximizing the log-posterior.
Leaves the :py:class:`GaussianPro... | [
"def",
"optimize_hyperparameters",
"(",
"self",
",",
"method",
"=",
"'SLSQP'",
",",
"opt_kwargs",
"=",
"{",
"}",
",",
"verbose",
"=",
"False",
",",
"random_starts",
"=",
"None",
",",
"num_proc",
"=",
"None",
",",
"max_tries",
"=",
"1",
")",
":",
"if",
... | r"""Optimize the hyperparameters by maximizing the log-posterior.
Leaves the :py:class:`GaussianProcess` instance in the optimized state.
If :py:func:`scipy.optimize.minimize` is not available (i.e., if your
:py:mod:`scipy` version is older than 0.11.0) then :py:func:`fmin_slsq... | [
"r",
"Optimize",
"the",
"hyperparameters",
"by",
"maximizing",
"the",
"log",
"-",
"posterior",
".",
"Leaves",
"the",
":",
"py",
":",
"class",
":",
"GaussianProcess",
"instance",
"in",
"the",
"optimized",
"state",
".",
"If",
":",
"py",
":",
"func",
":",
"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L619-L777 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.predict | def predict(self, Xstar, n=0, noise=False, return_std=True, return_cov=False,
full_output=False, return_samples=False, num_samples=1,
samp_kwargs={}, return_mean_func=False, use_MCMC=False,
full_MC=False, rejection_func=None, ddof=1, output_transform=None,
... | python | def predict(self, Xstar, n=0, noise=False, return_std=True, return_cov=False,
full_output=False, return_samples=False, num_samples=1,
samp_kwargs={}, return_mean_func=False, use_MCMC=False,
full_MC=False, rejection_func=None, ddof=1, output_transform=None,
... | [
"def",
"predict",
"(",
"self",
",",
"Xstar",
",",
"n",
"=",
"0",
",",
"noise",
"=",
"False",
",",
"return_std",
"=",
"True",
",",
"return_cov",
"=",
"False",
",",
"full_output",
"=",
"False",
",",
"return_samples",
"=",
"False",
",",
"num_samples",
"="... | Predict the mean and covariance at the inputs `Xstar`.
The order of the derivative is given by `n`. The keyword `noise` sets
whether or not noise is included in the prediction.
Parameters
----------
Xstar : array, (`M`, `D`)
`M` test input values of ... | [
"Predict",
"the",
"mean",
"and",
"covariance",
"at",
"the",
"inputs",
"Xstar",
".",
"The",
"order",
"of",
"the",
"derivative",
"is",
"given",
"by",
"n",
".",
"The",
"keyword",
"noise",
"sets",
"whether",
"or",
"not",
"noise",
"is",
"included",
"in",
"the... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L779-L1024 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.plot | def plot(self, X=None, n=0, ax=None, envelopes=[1, 3], base_alpha=0.375,
return_prediction=False, return_std=True, full_output=False,
plot_kwargs={}, **kwargs):
"""Plots the Gaussian process using the current hyperparameters. Only for num_dim <= 2.
Parameters
-... | python | def plot(self, X=None, n=0, ax=None, envelopes=[1, 3], base_alpha=0.375,
return_prediction=False, return_std=True, full_output=False,
plot_kwargs={}, **kwargs):
"""Plots the Gaussian process using the current hyperparameters. Only for num_dim <= 2.
Parameters
-... | [
"def",
"plot",
"(",
"self",
",",
"X",
"=",
"None",
",",
"n",
"=",
"0",
",",
"ax",
"=",
"None",
",",
"envelopes",
"=",
"[",
"1",
",",
"3",
"]",
",",
"base_alpha",
"=",
"0.375",
",",
"return_prediction",
"=",
"False",
",",
"return_std",
"=",
"True"... | Plots the Gaussian process using the current hyperparameters. Only for num_dim <= 2.
Parameters
----------
X : array-like (`M`,) or (`M`, `num_dim`), optional
The values to evaluate the Gaussian process at. If None, then 100
points between the minimum and maximum... | [
"Plots",
"the",
"Gaussian",
"process",
"using",
"the",
"current",
"hyperparameters",
".",
"Only",
"for",
"num_dim",
"<",
"=",
"2",
".",
"Parameters",
"----------",
"X",
":",
"array",
"-",
"like",
"(",
"M",
")",
"or",
"(",
"M",
"num_dim",
")",
"optional",... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L1026-L1143 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.draw_sample | def draw_sample(self, Xstar, n=0, num_samp=1, rand_vars=None,
rand_type='standard normal', diag_factor=1e3,
method='cholesky', num_eig=None, mean=None, cov=None,
modify_sign=None, **kwargs):
"""Draw a sample evaluated at the given points `Xstar`.
... | python | def draw_sample(self, Xstar, n=0, num_samp=1, rand_vars=None,
rand_type='standard normal', diag_factor=1e3,
method='cholesky', num_eig=None, mean=None, cov=None,
modify_sign=None, **kwargs):
"""Draw a sample evaluated at the given points `Xstar`.
... | [
"def",
"draw_sample",
"(",
"self",
",",
"Xstar",
",",
"n",
"=",
"0",
",",
"num_samp",
"=",
"1",
",",
"rand_vars",
"=",
"None",
",",
"rand_type",
"=",
"'standard normal'",
",",
"diag_factor",
"=",
"1e3",
",",
"method",
"=",
"'cholesky'",
",",
"num_eig",
... | Draw a sample evaluated at the given points `Xstar`.
Note that this function draws samples from the GP given the current
values for the hyperparameters (which may be in a nonsense state if you
just created the instance or called a method that performs MCMC sampling).
If you want... | [
"Draw",
"a",
"sample",
"evaluated",
"at",
"the",
"given",
"points",
"Xstar",
".",
"Note",
"that",
"this",
"function",
"draws",
"samples",
"from",
"the",
"GP",
"given",
"the",
"current",
"values",
"for",
"the",
"hyperparameters",
"(",
"which",
"may",
"be",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L1145-L1320 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.update_hyperparameters | def update_hyperparameters(self, new_params, hyper_deriv_handling='default', exit_on_bounds=True, inf_on_error=True):
r"""Update the kernel's hyperparameters to the new parameters.
This will call :py:meth:`compute_K_L_alpha_ll` to update the state
accordingly.
Note that... | python | def update_hyperparameters(self, new_params, hyper_deriv_handling='default', exit_on_bounds=True, inf_on_error=True):
r"""Update the kernel's hyperparameters to the new parameters.
This will call :py:meth:`compute_K_L_alpha_ll` to update the state
accordingly.
Note that... | [
"def",
"update_hyperparameters",
"(",
"self",
",",
"new_params",
",",
"hyper_deriv_handling",
"=",
"'default'",
",",
"exit_on_bounds",
"=",
"True",
",",
"inf_on_error",
"=",
"True",
")",
":",
"use_hyper_deriv",
"=",
"self",
".",
"use_hyper_deriv",
"if",
"hyper_der... | r"""Update the kernel's hyperparameters to the new parameters.
This will call :py:meth:`compute_K_L_alpha_ll` to update the state
accordingly.
Note that if this method crashes and the `hyper_deriv_handling` keyword
was used, it may leave :py:attr:`use_hyper_deriv` in th... | [
"r",
"Update",
"the",
"kernel",
"s",
"hyperparameters",
"to",
"the",
"new",
"parameters",
".",
"This",
"will",
"call",
":",
"py",
":",
"meth",
":",
"compute_K_L_alpha_ll",
"to",
"update",
"the",
"state",
"accordingly",
".",
"Note",
"that",
"if",
"this",
"m... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L1322-L1405 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.compute_K_L_alpha_ll | def compute_K_L_alpha_ll(self):
r"""Compute `K`, `L`, `alpha` and log-likelihood according to the first part of Algorithm 2.1 in R&W.
Computes `K` and the noise portion of `K` using :py:meth:`compute_Kij`,
computes `L` using :py:func:`scipy.linalg.cholesky`, then computes
`alpha... | python | def compute_K_L_alpha_ll(self):
r"""Compute `K`, `L`, `alpha` and log-likelihood according to the first part of Algorithm 2.1 in R&W.
Computes `K` and the noise portion of `K` using :py:meth:`compute_Kij`,
computes `L` using :py:func:`scipy.linalg.cholesky`, then computes
`alpha... | [
"def",
"compute_K_L_alpha_ll",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"K_up_to_date",
":",
"y",
"=",
"self",
".",
"y",
"err_y",
"=",
"self",
".",
"err_y",
"self",
".",
"K",
"=",
"self",
".",
"compute_Kij",
"(",
"self",
".",
"X",
",",
"Non... | r"""Compute `K`, `L`, `alpha` and log-likelihood according to the first part of Algorithm 2.1 in R&W.
Computes `K` and the noise portion of `K` using :py:meth:`compute_Kij`,
computes `L` using :py:func:`scipy.linalg.cholesky`, then computes
`alpha` as `L.T\\(L\\y)`.
Onl... | [
"r",
"Compute",
"K",
"L",
"alpha",
"and",
"log",
"-",
"likelihood",
"according",
"to",
"the",
"first",
"part",
"of",
"Algorithm",
"2",
".",
"1",
"in",
"R&W",
".",
"Computes",
"K",
"and",
"the",
"noise",
"portion",
"of",
"K",
"using",
":",
"py",
":",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L1407-L1511 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.compute_Kij | def compute_Kij(self, Xi, Xj, ni, nj, noise=False, hyper_deriv=None, k=None):
r"""Compute covariance matrix between datasets `Xi` and `Xj`.
Specify the orders of derivatives at each location with the `ni`, `nj`
arrays. The `include_noise` flag is passed to the covariance kernel to
... | python | def compute_Kij(self, Xi, Xj, ni, nj, noise=False, hyper_deriv=None, k=None):
r"""Compute covariance matrix between datasets `Xi` and `Xj`.
Specify the orders of derivatives at each location with the `ni`, `nj`
arrays. The `include_noise` flag is passed to the covariance kernel to
... | [
"def",
"compute_Kij",
"(",
"self",
",",
"Xi",
",",
"Xj",
",",
"ni",
",",
"nj",
",",
"noise",
"=",
"False",
",",
"hyper_deriv",
"=",
"None",
",",
"k",
"=",
"None",
")",
":",
"if",
"k",
"is",
"None",
":",
"if",
"not",
"noise",
":",
"k",
"=",
"s... | r"""Compute covariance matrix between datasets `Xi` and `Xj`.
Specify the orders of derivatives at each location with the `ni`, `nj`
arrays. The `include_noise` flag is passed to the covariance kernel to
indicate whether noise is to be included (i.e., for evaluation of
:math:`K+... | [
"r",
"Compute",
"covariance",
"matrix",
"between",
"datasets",
"Xi",
"and",
"Xj",
".",
"Specify",
"the",
"orders",
"of",
"derivatives",
"at",
"each",
"location",
"with",
"the",
"ni",
"nj",
"arrays",
".",
"The",
"include_noise",
"flag",
"is",
"passed",
"to",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L1524-L1594 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.compute_ll_matrix | def compute_ll_matrix(self, bounds, num_pts):
"""Compute the log likelihood over the (free) parameter space.
Parameters
----------
bounds : 2-tuple or list of 2-tuples with length equal to the number of free parameters
Bounds on the range to use for each of the param... | python | def compute_ll_matrix(self, bounds, num_pts):
"""Compute the log likelihood over the (free) parameter space.
Parameters
----------
bounds : 2-tuple or list of 2-tuples with length equal to the number of free parameters
Bounds on the range to use for each of the param... | [
"def",
"compute_ll_matrix",
"(",
"self",
",",
"bounds",
",",
"num_pts",
")",
":",
"present_free_params",
"=",
"self",
".",
"free_params",
"[",
":",
"]",
"bounds",
"=",
"scipy",
".",
"atleast_2d",
"(",
"scipy",
".",
"asarray",
"(",
"bounds",
",",
"dtype",
... | Compute the log likelihood over the (free) parameter space.
Parameters
----------
bounds : 2-tuple or list of 2-tuples with length equal to the number of free parameters
Bounds on the range to use for each of the parameters. If a single
2-tuple is given, it will ... | [
"Compute",
"the",
"log",
"likelihood",
"over",
"the",
"(",
"free",
")",
"parameter",
"space",
".",
"Parameters",
"----------",
"bounds",
":",
"2",
"-",
"tuple",
"or",
"list",
"of",
"2",
"-",
"tuples",
"with",
"length",
"equal",
"to",
"the",
"number",
"of... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L1596-L1642 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess._compute_ll_matrix | def _compute_ll_matrix(self, idx, param_vals, num_pts):
"""Recursive helper function for compute_ll_matrix.
Parameters
----------
idx : int
The index of the parameter for this layer of the recursion to
work on. `idx` == len(`num_pts`) is the base case tha... | python | def _compute_ll_matrix(self, idx, param_vals, num_pts):
"""Recursive helper function for compute_ll_matrix.
Parameters
----------
idx : int
The index of the parameter for this layer of the recursion to
work on. `idx` == len(`num_pts`) is the base case tha... | [
"def",
"_compute_ll_matrix",
"(",
"self",
",",
"idx",
",",
"param_vals",
",",
"num_pts",
")",
":",
"if",
"idx",
">=",
"len",
"(",
"num_pts",
")",
":",
"# Base case: All entries in param_vals should be scalars:",
"return",
"-",
"1.0",
"*",
"self",
".",
"update_hy... | Recursive helper function for compute_ll_matrix.
Parameters
----------
idx : int
The index of the parameter for this layer of the recursion to
work on. `idx` == len(`num_pts`) is the base case that terminates
the recursion.
param_vals : List o... | [
"Recursive",
"helper",
"function",
"for",
"compute_ll_matrix",
".",
"Parameters",
"----------",
"idx",
":",
"int",
"The",
"index",
"of",
"the",
"parameter",
"for",
"this",
"layer",
"of",
"the",
"recursion",
"to",
"work",
"on",
".",
"idx",
"==",
"len",
"(",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L1644-L1681 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.sample_hyperparameter_posterior | def sample_hyperparameter_posterior(self, nwalkers=200, nsamp=500, burn=0,
thin=1, num_proc=None, sampler=None,
plot_posterior=False,
plot_chains=False, sampler_type='ensemble',
... | python | def sample_hyperparameter_posterior(self, nwalkers=200, nsamp=500, burn=0,
thin=1, num_proc=None, sampler=None,
plot_posterior=False,
plot_chains=False, sampler_type='ensemble',
... | [
"def",
"sample_hyperparameter_posterior",
"(",
"self",
",",
"nwalkers",
"=",
"200",
",",
"nsamp",
"=",
"500",
",",
"burn",
"=",
"0",
",",
"thin",
"=",
"1",
",",
"num_proc",
"=",
"None",
",",
"sampler",
"=",
"None",
",",
"plot_posterior",
"=",
"False",
... | Produce samples from the posterior for the hyperparameters using MCMC.
Returns the sampler created, because storing it stops the GP from being
pickleable. To add more samples to a previous sampler, pass the sampler
instance in the `sampler` keyword.
Parameters
-... | [
"Produce",
"samples",
"from",
"the",
"posterior",
"for",
"the",
"hyperparameters",
"using",
"MCMC",
".",
"Returns",
"the",
"sampler",
"created",
"because",
"storing",
"it",
"stops",
"the",
"GP",
"from",
"being",
"pickleable",
".",
"To",
"add",
"more",
"samples... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L1683-L1827 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.compute_from_MCMC | def compute_from_MCMC(self, X, n=0, return_mean=True, return_std=True,
return_cov=False, return_samples=False,
return_mean_func=False, num_samples=1, noise=False,
samp_kwargs={}, sampler=None, flat_trace=None, burn=0,
... | python | def compute_from_MCMC(self, X, n=0, return_mean=True, return_std=True,
return_cov=False, return_samples=False,
return_mean_func=False, num_samples=1, noise=False,
samp_kwargs={}, sampler=None, flat_trace=None, burn=0,
... | [
"def",
"compute_from_MCMC",
"(",
"self",
",",
"X",
",",
"n",
"=",
"0",
",",
"return_mean",
"=",
"True",
",",
"return_std",
"=",
"True",
",",
"return_cov",
"=",
"False",
",",
"return_samples",
"=",
"False",
",",
"return_mean_func",
"=",
"False",
",",
"num... | Compute desired quantities from MCMC samples of the hyperparameter posterior.
The return will be a list with a number of rows equal to the number of
hyperparameter samples. The columns depend on the state of the boolean
flags, but will be some subset of (mean, stddev, cov, samples), in ... | [
"Compute",
"desired",
"quantities",
"from",
"MCMC",
"samples",
"of",
"the",
"hyperparameter",
"posterior",
".",
"The",
"return",
"will",
"be",
"a",
"list",
"with",
"a",
"number",
"of",
"rows",
"equal",
"to",
"the",
"number",
"of",
"hyperparameter",
"samples",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L1829-L1976 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.compute_l_from_MCMC | def compute_l_from_MCMC(self, X, n=0, sampler=None, flat_trace=None, burn=0, thin=1, **kwargs):
"""Compute desired quantities from MCMC samples of the hyperparameter posterior.
The return will be a list with a number of rows equal to the number of
hyperparameter samples. The columns wil... | python | def compute_l_from_MCMC(self, X, n=0, sampler=None, flat_trace=None, burn=0, thin=1, **kwargs):
"""Compute desired quantities from MCMC samples of the hyperparameter posterior.
The return will be a list with a number of rows equal to the number of
hyperparameter samples. The columns wil... | [
"def",
"compute_l_from_MCMC",
"(",
"self",
",",
"X",
",",
"n",
"=",
"0",
",",
"sampler",
"=",
"None",
",",
"flat_trace",
"=",
"None",
",",
"burn",
"=",
"0",
",",
"thin",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"flat_trace",
"is",
"None... | Compute desired quantities from MCMC samples of the hyperparameter posterior.
The return will be a list with a number of rows equal to the number of
hyperparameter samples. The columns will contain the covariance length
scale function.
Parameters
----------
... | [
"Compute",
"desired",
"quantities",
"from",
"MCMC",
"samples",
"of",
"the",
"hyperparameter",
"posterior",
".",
"The",
"return",
"will",
"be",
"a",
"list",
"with",
"a",
"number",
"of",
"rows",
"equal",
"to",
"the",
"number",
"of",
"hyperparameter",
"samples",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L1978-L2054 |
markchil/gptools | gptools/gaussian_process.py | GaussianProcess.predict_MCMC | def predict_MCMC(self, X, ddof=1, full_MC=False, rejection_func=None, **kwargs):
"""Make a prediction using MCMC samples.
This is essentially a convenient wrapper of :py:meth:`compute_from_MCMC`,
designed to act more or less interchangeably with :py:meth:`predict`.
Comp... | python | def predict_MCMC(self, X, ddof=1, full_MC=False, rejection_func=None, **kwargs):
"""Make a prediction using MCMC samples.
This is essentially a convenient wrapper of :py:meth:`compute_from_MCMC`,
designed to act more or less interchangeably with :py:meth:`predict`.
Comp... | [
"def",
"predict_MCMC",
"(",
"self",
",",
"X",
",",
"ddof",
"=",
"1",
",",
"full_MC",
"=",
"False",
",",
"rejection_func",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return_std",
"=",
"kwargs",
".",
"get",
"(",
"'return_std'",
",",
"True",
")",
... | Make a prediction using MCMC samples.
This is essentially a convenient wrapper of :py:meth:`compute_from_MCMC`,
designed to act more or less interchangeably with :py:meth:`predict`.
Computes the mean of the GP posterior marginalized over the
hyperparameters using iterat... | [
"Make",
"a",
"prediction",
"using",
"MCMC",
"samples",
".",
"This",
"is",
"essentially",
"a",
"convenient",
"wrapper",
"of",
":",
"py",
":",
"meth",
":",
"compute_from_MCMC",
"designed",
"to",
"act",
"more",
"or",
"less",
"interchangeably",
"with",
":",
"py"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L2133-L2243 |
coursera/courseraoauth2client | courseraoauth2client/main.py | build_parser | def build_parser():
"Build an argparse argument parser to parse the command line."
parser = argparse.ArgumentParser(
description="""Coursera OAuth2 client CLI. This tool
helps users of the Coursera App Platform to programmatically access
Coursera APIs.""",
epilog="""Please file ... | python | def build_parser():
"Build an argparse argument parser to parse the command line."
parser = argparse.ArgumentParser(
description="""Coursera OAuth2 client CLI. This tool
helps users of the Coursera App Platform to programmatically access
Coursera APIs.""",
epilog="""Please file ... | [
"def",
"build_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"\"\"Coursera OAuth2 client CLI. This tool\n helps users of the Coursera App Platform to programmatically access\n Coursera APIs.\"\"\"",
",",
"epilog",
"=... | Build an argparse argument parser to parse the command line. | [
"Build",
"an",
"argparse",
"argument",
"parser",
"to",
"parse",
"the",
"command",
"line",
"."
] | train | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/main.py#L30-L53 |
coursera/courseraoauth2client | courseraoauth2client/main.py | main | def main():
"Boots up the command line tool"
logging.captureWarnings(True)
args = build_parser().parse_args()
# Configure logging
args.setup_logging(args)
# Dispatch into the appropriate subcommand function.
try:
return args.func(args)
except SystemExit:
raise
except:... | python | def main():
"Boots up the command line tool"
logging.captureWarnings(True)
args = build_parser().parse_args()
# Configure logging
args.setup_logging(args)
# Dispatch into the appropriate subcommand function.
try:
return args.func(args)
except SystemExit:
raise
except:... | [
"def",
"main",
"(",
")",
":",
"logging",
".",
"captureWarnings",
"(",
"True",
")",
"args",
"=",
"build_parser",
"(",
")",
".",
"parse_args",
"(",
")",
"# Configure logging",
"args",
".",
"setup_logging",
"(",
"args",
")",
"# Dispatch into the appropriate subcomm... | Boots up the command line tool | [
"Boots",
"up",
"the",
"command",
"line",
"tool"
] | train | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/main.py#L56-L69 |
CTPUG/wafer | wafer/sponsors/models.py | sponsor_menu | def sponsor_menu(
root_menu, menu="sponsors", label=_("Sponsors"),
sponsors_item=_("Our sponsors"),
packages_item=_("Sponsorship packages")):
"""Add sponsor menu links."""
root_menu.add_menu(menu, label, items=[])
for sponsor in (
Sponsor.objects.all()
.order_... | python | def sponsor_menu(
root_menu, menu="sponsors", label=_("Sponsors"),
sponsors_item=_("Our sponsors"),
packages_item=_("Sponsorship packages")):
"""Add sponsor menu links."""
root_menu.add_menu(menu, label, items=[])
for sponsor in (
Sponsor.objects.all()
.order_... | [
"def",
"sponsor_menu",
"(",
"root_menu",
",",
"menu",
"=",
"\"sponsors\"",
",",
"label",
"=",
"_",
"(",
"\"Sponsors\"",
")",
",",
"sponsors_item",
"=",
"_",
"(",
"\"Our sponsors\"",
")",
",",
"packages_item",
"=",
"_",
"(",
"\"Sponsorship packages\"",
")",
"... | Add sponsor menu links. | [
"Add",
"sponsor",
"menu",
"links",
"."
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/sponsors/models.py#L115-L141 |
codenerix/django-codenerix | codenerix/templatetags/codenerix_common.py | objectatrib | def objectatrib(instance, atrib):
'''
this filter is going to be useful to execute an object method or get an
object attribute dynamically. this method is going to take into account
the atrib param can contains underscores
'''
atrib = atrib.replace("__", ".")
atribs = []
atribs = atrib.s... | python | def objectatrib(instance, atrib):
'''
this filter is going to be useful to execute an object method or get an
object attribute dynamically. this method is going to take into account
the atrib param can contains underscores
'''
atrib = atrib.replace("__", ".")
atribs = []
atribs = atrib.s... | [
"def",
"objectatrib",
"(",
"instance",
",",
"atrib",
")",
":",
"atrib",
"=",
"atrib",
".",
"replace",
"(",
"\"__\"",
",",
"\".\"",
")",
"atribs",
"=",
"[",
"]",
"atribs",
"=",
"atrib",
".",
"split",
"(",
"\".\"",
")",
"obj",
"=",
"instance",
"for",
... | this filter is going to be useful to execute an object method or get an
object attribute dynamically. this method is going to take into account
the atrib param can contains underscores | [
"this",
"filter",
"is",
"going",
"to",
"be",
"useful",
"to",
"execute",
"an",
"object",
"method",
"or",
"get",
"an",
"object",
"attribute",
"dynamically",
".",
"this",
"method",
"is",
"going",
"to",
"take",
"into",
"account",
"the",
"atrib",
"param",
"can"... | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/templatetags/codenerix_common.py#L241-L262 |
codenerix/django-codenerix | codenerix/djng/angular_base.py | NgBoundField.as_widget | def as_widget(self, widget=None, attrs=None, only_initial=False):
"""
Renders the field.
"""
attrs = attrs or {}
attrs.update(self.form.get_widget_attrs(self))
if hasattr(self.field, 'widget_css_classes'):
css_classes = self.field.widget_css_classes
el... | python | def as_widget(self, widget=None, attrs=None, only_initial=False):
"""
Renders the field.
"""
attrs = attrs or {}
attrs.update(self.form.get_widget_attrs(self))
if hasattr(self.field, 'widget_css_classes'):
css_classes = self.field.widget_css_classes
el... | [
"def",
"as_widget",
"(",
"self",
",",
"widget",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"only_initial",
"=",
"False",
")",
":",
"attrs",
"=",
"attrs",
"or",
"{",
"}",
"attrs",
".",
"update",
"(",
"self",
".",
"form",
".",
"get_widget_attrs",
"("... | Renders the field. | [
"Renders",
"the",
"field",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/djng/angular_base.py#L166-L184 |
codenerix/django-codenerix | codenerix/djng/angular_base.py | NgFormBaseMixin.convert_widgets | def convert_widgets(self):
"""
During form initialization, some widgets have to be replaced by a counterpart suitable to
be rendered the AngularJS way.
"""
for field in self.base_fields.values():
try:
new_widget = field.get_converted_widget()
... | python | def convert_widgets(self):
"""
During form initialization, some widgets have to be replaced by a counterpart suitable to
be rendered the AngularJS way.
"""
for field in self.base_fields.values():
try:
new_widget = field.get_converted_widget()
... | [
"def",
"convert_widgets",
"(",
"self",
")",
":",
"for",
"field",
"in",
"self",
".",
"base_fields",
".",
"values",
"(",
")",
":",
"try",
":",
"new_widget",
"=",
"field",
".",
"get_converted_widget",
"(",
")",
"except",
"AttributeError",
":",
"pass",
"else",... | During form initialization, some widgets have to be replaced by a counterpart suitable to
be rendered the AngularJS way. | [
"During",
"form",
"initialization",
"some",
"widgets",
"have",
"to",
"be",
"replaced",
"by",
"a",
"counterpart",
"suitable",
"to",
"be",
"rendered",
"the",
"AngularJS",
"way",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/djng/angular_base.py#L291-L303 |
codenerix/django-codenerix | codenerix/helpers.py | epochdate | def epochdate(timestamp):
'''
Convet an epoch date to a tuple in format ("yyyy-mm-dd","hh:mm:ss")
Example: "1023456427" -> ("2002-06-07","15:27:07")
Parameters:
- `timestamp`: date in epoch format
'''
dt = datetime.fromtimestamp(float(timestamp)).timetuple()
fecha = "{0:d}-{1:02d}-{2:0... | python | def epochdate(timestamp):
'''
Convet an epoch date to a tuple in format ("yyyy-mm-dd","hh:mm:ss")
Example: "1023456427" -> ("2002-06-07","15:27:07")
Parameters:
- `timestamp`: date in epoch format
'''
dt = datetime.fromtimestamp(float(timestamp)).timetuple()
fecha = "{0:d}-{1:02d}-{2:0... | [
"def",
"epochdate",
"(",
"timestamp",
")",
":",
"dt",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"float",
"(",
"timestamp",
")",
")",
".",
"timetuple",
"(",
")",
"fecha",
"=",
"\"{0:d}-{1:02d}-{2:02d}\"",
".",
"format",
"(",
"dt",
".",
"tm_year",
",",
"... | Convet an epoch date to a tuple in format ("yyyy-mm-dd","hh:mm:ss")
Example: "1023456427" -> ("2002-06-07","15:27:07")
Parameters:
- `timestamp`: date in epoch format | [
"Convet",
"an",
"epoch",
"date",
"to",
"a",
"tuple",
"in",
"format",
"(",
"yyyy",
"-",
"mm",
"-",
"dd",
"hh",
":",
"mm",
":",
"ss",
")",
"Example",
":",
"1023456427",
"-",
">",
"(",
"2002",
"-",
"06",
"-",
"07",
"15",
":",
"27",
":",
"07",
")... | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/helpers.py#L52-L64 |
codenerix/django-codenerix | codenerix/helpers.py | model_inspect | def model_inspect(obj):
'''
Analize itself looking for special information, right now it returns:
- Application name
- Model name
'''
# Prepare the information object
info = {}
if hasattr(obj, '_meta'):
info['verbose_name'] = getattr(obj._meta,... | python | def model_inspect(obj):
'''
Analize itself looking for special information, right now it returns:
- Application name
- Model name
'''
# Prepare the information object
info = {}
if hasattr(obj, '_meta'):
info['verbose_name'] = getattr(obj._meta,... | [
"def",
"model_inspect",
"(",
"obj",
")",
":",
"# Prepare the information object",
"info",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"obj",
",",
"'_meta'",
")",
":",
"info",
"[",
"'verbose_name'",
"]",
"=",
"getattr",
"(",
"obj",
".",
"_meta",
",",
"'verbose_nam... | Analize itself looking for special information, right now it returns:
- Application name
- Model name | [
"Analize",
"itself",
"looking",
"for",
"special",
"information",
"right",
"now",
"it",
"returns",
":",
"-",
"Application",
"name",
"-",
"Model",
"name"
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/helpers.py#L284-L312 |
codenerix/django-codenerix | codenerix/helpers.py | upload_path | def upload_path(instance, filename):
'''
This method is created to return the path to upload files. This path must be
different from any other to avoid problems.
'''
path_separator = "/"
date_separator = "-"
ext_separator = "."
empty_string = ""
# get the model name
model_name = ... | python | def upload_path(instance, filename):
'''
This method is created to return the path to upload files. This path must be
different from any other to avoid problems.
'''
path_separator = "/"
date_separator = "-"
ext_separator = "."
empty_string = ""
# get the model name
model_name = ... | [
"def",
"upload_path",
"(",
"instance",
",",
"filename",
")",
":",
"path_separator",
"=",
"\"/\"",
"date_separator",
"=",
"\"-\"",
"ext_separator",
"=",
"\".\"",
"empty_string",
"=",
"\"\"",
"# get the model name",
"model_name",
"=",
"model_inspect",
"(",
"instance",... | This method is created to return the path to upload files. This path must be
different from any other to avoid problems. | [
"This",
"method",
"is",
"created",
"to",
"return",
"the",
"path",
"to",
"upload",
"files",
".",
"This",
"path",
"must",
"be",
"different",
"from",
"any",
"other",
"to",
"avoid",
"problems",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/helpers.py#L315-L341 |
codenerix/django-codenerix | codenerix/helpers.py | remove_getdisplay | def remove_getdisplay(field_name):
'''
for string 'get_FIELD_NAME_display' return 'FIELD_NAME'
'''
str_ini = 'get_'
str_end = '_display'
if str_ini == field_name[0:len(str_ini)] and str_end == field_name[(-1) * len(str_end):]:
field_name = field_name[len(str_ini):(-1) * len(str_end)]
... | python | def remove_getdisplay(field_name):
'''
for string 'get_FIELD_NAME_display' return 'FIELD_NAME'
'''
str_ini = 'get_'
str_end = '_display'
if str_ini == field_name[0:len(str_ini)] and str_end == field_name[(-1) * len(str_end):]:
field_name = field_name[len(str_ini):(-1) * len(str_end)]
... | [
"def",
"remove_getdisplay",
"(",
"field_name",
")",
":",
"str_ini",
"=",
"'get_'",
"str_end",
"=",
"'_display'",
"if",
"str_ini",
"==",
"field_name",
"[",
"0",
":",
"len",
"(",
"str_ini",
")",
"]",
"and",
"str_end",
"==",
"field_name",
"[",
"(",
"-",
"1"... | for string 'get_FIELD_NAME_display' return 'FIELD_NAME' | [
"for",
"string",
"get_FIELD_NAME_display",
"return",
"FIELD_NAME"
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/helpers.py#L545-L553 |
codenerix/django-codenerix | codenerix/helpers.py | JSONEncoder_newdefault | def JSONEncoder_newdefault(kind=['uuid', 'datetime', 'time', 'decimal']):
'''
JSON Encoder newdfeault is a wrapper capable of encoding several kinds
Usage:
from codenerix.helpers import JSONEncoder_newdefault
JSONEncoder_newdefault()
'''
JSONEncoder_olddefault = json.JSONEncoder.defa... | python | def JSONEncoder_newdefault(kind=['uuid', 'datetime', 'time', 'decimal']):
'''
JSON Encoder newdfeault is a wrapper capable of encoding several kinds
Usage:
from codenerix.helpers import JSONEncoder_newdefault
JSONEncoder_newdefault()
'''
JSONEncoder_olddefault = json.JSONEncoder.defa... | [
"def",
"JSONEncoder_newdefault",
"(",
"kind",
"=",
"[",
"'uuid'",
",",
"'datetime'",
",",
"'time'",
",",
"'decimal'",
"]",
")",
":",
"JSONEncoder_olddefault",
"=",
"json",
".",
"JSONEncoder",
".",
"default",
"def",
"JSONEncoder_wrapped",
"(",
"self",
",",
"o",... | JSON Encoder newdfeault is a wrapper capable of encoding several kinds
Usage:
from codenerix.helpers import JSONEncoder_newdefault
JSONEncoder_newdefault() | [
"JSON",
"Encoder",
"newdfeault",
"is",
"a",
"wrapper",
"capable",
"of",
"encoding",
"several",
"kinds",
"Usage",
":",
"from",
"codenerix",
".",
"helpers",
"import",
"JSONEncoder_newdefault",
"JSONEncoder_newdefault",
"()"
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/helpers.py#L626-L648 |
codenerix/django-codenerix | codenerix/helpers.py | context_processors_update | def context_processors_update(context, request):
'''
Update context with context_processors from settings
Usage:
from codenerix.helpers import context_processors_update
context_processors_update(context, self.request)
'''
for template in settings.TEMPLATES:
for context_proces... | python | def context_processors_update(context, request):
'''
Update context with context_processors from settings
Usage:
from codenerix.helpers import context_processors_update
context_processors_update(context, self.request)
'''
for template in settings.TEMPLATES:
for context_proces... | [
"def",
"context_processors_update",
"(",
"context",
",",
"request",
")",
":",
"for",
"template",
"in",
"settings",
".",
"TEMPLATES",
":",
"for",
"context_processor",
"in",
"template",
"[",
"'OPTIONS'",
"]",
"[",
"'context_processors'",
"]",
":",
"path",
"=",
"... | Update context with context_processors from settings
Usage:
from codenerix.helpers import context_processors_update
context_processors_update(context, self.request) | [
"Update",
"context",
"with",
"context_processors",
"from",
"settings",
"Usage",
":",
"from",
"codenerix",
".",
"helpers",
"import",
"context_processors_update",
"context_processors_update",
"(",
"context",
"self",
".",
"request",
")"
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/helpers.py#L651-L665 |
codenerix/django-codenerix | codenerix/helpers.py | InMemoryZip.append | def append(self, filename_in_zip, file_contents):
'''
Appends a file with name filename_in_zip and contents of
file_contents to the in-memory zip.
'''
# Set the file pointer to the end of the file
self.in_memory_zip.seek(-1, io.SEEK_END)
# Get a handle to the in-... | python | def append(self, filename_in_zip, file_contents):
'''
Appends a file with name filename_in_zip and contents of
file_contents to the in-memory zip.
'''
# Set the file pointer to the end of the file
self.in_memory_zip.seek(-1, io.SEEK_END)
# Get a handle to the in-... | [
"def",
"append",
"(",
"self",
",",
"filename_in_zip",
",",
"file_contents",
")",
":",
"# Set the file pointer to the end of the file",
"self",
".",
"in_memory_zip",
".",
"seek",
"(",
"-",
"1",
",",
"io",
".",
"SEEK_END",
")",
"# Get a handle to the in-memory zip in ap... | Appends a file with name filename_in_zip and contents of
file_contents to the in-memory zip. | [
"Appends",
"a",
"file",
"with",
"name",
"filename_in_zip",
"and",
"contents",
"of",
"file_contents",
"to",
"the",
"in",
"-",
"memory",
"zip",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/helpers.py#L491-L516 |
codenerix/django-codenerix | codenerix/helpers.py | InMemoryZip.writetofile | def writetofile(self, filename):
'''Writes the in-memory zip to a file.'''
f = open(filename, "w")
f.write(self.read())
f.close() | python | def writetofile(self, filename):
'''Writes the in-memory zip to a file.'''
f = open(filename, "w")
f.write(self.read())
f.close() | [
"def",
"writetofile",
"(",
"self",
",",
"filename",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"\"w\"",
")",
"f",
".",
"write",
"(",
"self",
".",
"read",
"(",
")",
")",
"f",
".",
"close",
"(",
")"
] | Writes the in-memory zip to a file. | [
"Writes",
"the",
"in",
"-",
"memory",
"zip",
"to",
"a",
"file",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/helpers.py#L538-L542 |
CTPUG/wafer | wafer/sponsors/templatetags/sponsors.py | sponsor_image_url | def sponsor_image_url(sponsor, name):
"""Returns the corresponding url from the sponsors images"""
if sponsor.files.filter(name=name).exists():
# We avoid worrying about multiple matches by always
# returning the first one.
return sponsor.files.filter(name=name).first().item.url
retu... | python | def sponsor_image_url(sponsor, name):
"""Returns the corresponding url from the sponsors images"""
if sponsor.files.filter(name=name).exists():
# We avoid worrying about multiple matches by always
# returning the first one.
return sponsor.files.filter(name=name).first().item.url
retu... | [
"def",
"sponsor_image_url",
"(",
"sponsor",
",",
"name",
")",
":",
"if",
"sponsor",
".",
"files",
".",
"filter",
"(",
"name",
"=",
"name",
")",
".",
"exists",
"(",
")",
":",
"# We avoid worrying about multiple matches by always",
"# returning the first one.",
"ret... | Returns the corresponding url from the sponsors images | [
"Returns",
"the",
"corresponding",
"url",
"from",
"the",
"sponsors",
"images"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/sponsors/templatetags/sponsors.py#L25-L31 |
CTPUG/wafer | wafer/sponsors/templatetags/sponsors.py | sponsor_tagged_image | def sponsor_tagged_image(sponsor, tag):
"""returns the corresponding url from the tagged image list."""
if sponsor.files.filter(tag_name=tag).exists():
return sponsor.files.filter(tag_name=tag).first().tagged_file.item.url
return '' | python | def sponsor_tagged_image(sponsor, tag):
"""returns the corresponding url from the tagged image list."""
if sponsor.files.filter(tag_name=tag).exists():
return sponsor.files.filter(tag_name=tag).first().tagged_file.item.url
return '' | [
"def",
"sponsor_tagged_image",
"(",
"sponsor",
",",
"tag",
")",
":",
"if",
"sponsor",
".",
"files",
".",
"filter",
"(",
"tag_name",
"=",
"tag",
")",
".",
"exists",
"(",
")",
":",
"return",
"sponsor",
".",
"files",
".",
"filter",
"(",
"tag_name",
"=",
... | returns the corresponding url from the tagged image list. | [
"returns",
"the",
"corresponding",
"url",
"from",
"the",
"tagged",
"image",
"list",
"."
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/sponsors/templatetags/sponsors.py#L35-L39 |
codenerix/django-codenerix | codenerix/templatetags/codenerix_special.py | ifusergroup | def ifusergroup(parser, token):
""" Check to see if the currently logged in user belongs to a specific
group. Requires the Django authentication contrib app and middleware.
Usage: {% ifusergroup Admins %} ... {% endifusergroup %}, or
{% ifusergroup Admins Clients Sellers %} ... {% else %} ... {%... | python | def ifusergroup(parser, token):
""" Check to see if the currently logged in user belongs to a specific
group. Requires the Django authentication contrib app and middleware.
Usage: {% ifusergroup Admins %} ... {% endifusergroup %}, or
{% ifusergroup Admins Clients Sellers %} ... {% else %} ... {%... | [
"def",
"ifusergroup",
"(",
"parser",
",",
"token",
")",
":",
"try",
":",
"tokensp",
"=",
"token",
".",
"split_contents",
"(",
")",
"groups",
"=",
"[",
"]",
"groups",
"+=",
"tokensp",
"[",
"1",
":",
"]",
"except",
"ValueError",
":",
"raise",
"template",... | Check to see if the currently logged in user belongs to a specific
group. Requires the Django authentication contrib app and middleware.
Usage: {% ifusergroup Admins %} ... {% endifusergroup %}, or
{% ifusergroup Admins Clients Sellers %} ... {% else %} ... {% endifusergroup %} | [
"Check",
"to",
"see",
"if",
"the",
"currently",
"logged",
"in",
"user",
"belongs",
"to",
"a",
"specific",
"group",
".",
"Requires",
"the",
"Django",
"authentication",
"contrib",
"app",
"and",
"middleware",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/templatetags/codenerix_special.py#L63-L87 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.OpenHandle | def OpenHandle(self):
'''Gets a handle for use with other vSphere Guest API functions. The guest library
handle provides a context for accessing information about the virtual machine.
Virtual machine statistics and state data are associated with a particular guest library
handl... | python | def OpenHandle(self):
'''Gets a handle for use with other vSphere Guest API functions. The guest library
handle provides a context for accessing information about the virtual machine.
Virtual machine statistics and state data are associated with a particular guest library
handl... | [
"def",
"OpenHandle",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'handle'",
")",
":",
"return",
"self",
".",
"handle",
"else",
":",
"handle",
"=",
"c_void_p",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_OpenHandle",
"(",
"byref",
... | Gets a handle for use with other vSphere Guest API functions. The guest library
handle provides a context for accessing information about the virtual machine.
Virtual machine statistics and state data are associated with a particular guest library
handle, so using one handle does not a... | [
"Gets",
"a",
"handle",
"for",
"use",
"with",
"other",
"vSphere",
"Guest",
"API",
"functions",
".",
"The",
"guest",
"library",
"handle",
"provides",
"a",
"context",
"for",
"accessing",
"information",
"about",
"the",
"virtual",
"machine",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L114-L126 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.CloseHandle | def CloseHandle(self):
'''Releases a handle acquired with VMGuestLib_OpenHandle'''
if hasattr(self, 'handle'):
ret = vmGuestLib.VMGuestLib_CloseHandle(self.handle.value)
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
del(self.handle) | python | def CloseHandle(self):
'''Releases a handle acquired with VMGuestLib_OpenHandle'''
if hasattr(self, 'handle'):
ret = vmGuestLib.VMGuestLib_CloseHandle(self.handle.value)
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
del(self.handle) | [
"def",
"CloseHandle",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'handle'",
")",
":",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_CloseHandle",
"(",
"self",
".",
"handle",
".",
"value",
")",
"if",
"ret",
"!=",
"VMGUESTLIB_ERROR_SUCCESS",
":"... | Releases a handle acquired with VMGuestLib_OpenHandle | [
"Releases",
"a",
"handle",
"acquired",
"with",
"VMGuestLib_OpenHandle"
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L128-L133 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.UpdateInfo | def UpdateInfo(self):
'''Updates information about the virtual machine. This information is associated with
the VMGuestLibHandle.
VMGuestLib_UpdateInfo requires similar CPU resources to a system call and
therefore can affect performance. If you are concerned about performance, ... | python | def UpdateInfo(self):
'''Updates information about the virtual machine. This information is associated with
the VMGuestLibHandle.
VMGuestLib_UpdateInfo requires similar CPU resources to a system call and
therefore can affect performance. If you are concerned about performance, ... | [
"def",
"UpdateInfo",
"(",
"self",
")",
":",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_UpdateInfo",
"(",
"self",
".",
"handle",
".",
"value",
")",
"if",
"ret",
"!=",
"VMGUESTLIB_ERROR_SUCCESS",
":",
"raise",
"VMGuestLibException",
"(",
"ret",
")"
] | Updates information about the virtual machine. This information is associated with
the VMGuestLibHandle.
VMGuestLib_UpdateInfo requires similar CPU resources to a system call and
therefore can affect performance. If you are concerned about performance, minimize
the number of... | [
"Updates",
"information",
"about",
"the",
"virtual",
"machine",
".",
"This",
"information",
"is",
"associated",
"with",
"the",
"VMGuestLibHandle",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L135-L147 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetSessionId | def GetSessionId(self):
'''Retrieves the VMSessionID for the current session. Call this function after calling
VMGuestLib_UpdateInfo. If VMGuestLib_UpdateInfo has never been called,
VMGuestLib_GetSessionId returns VMGUESTLIB_ERROR_NO_INFO.'''
sid = c_void_p()
ret = vmGuestL... | python | def GetSessionId(self):
'''Retrieves the VMSessionID for the current session. Call this function after calling
VMGuestLib_UpdateInfo. If VMGuestLib_UpdateInfo has never been called,
VMGuestLib_GetSessionId returns VMGUESTLIB_ERROR_NO_INFO.'''
sid = c_void_p()
ret = vmGuestL... | [
"def",
"GetSessionId",
"(",
"self",
")",
":",
"sid",
"=",
"c_void_p",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetSessionId",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"sid",
")",
")",
"if",
"ret",
"!=",
"VMGUESTLIB_ERROR_S... | Retrieves the VMSessionID for the current session. Call this function after calling
VMGuestLib_UpdateInfo. If VMGuestLib_UpdateInfo has never been called,
VMGuestLib_GetSessionId returns VMGUESTLIB_ERROR_NO_INFO. | [
"Retrieves",
"the",
"VMSessionID",
"for",
"the",
"current",
"session",
".",
"Call",
"this",
"function",
"after",
"calling",
"VMGuestLib_UpdateInfo",
".",
"If",
"VMGuestLib_UpdateInfo",
"has",
"never",
"been",
"called",
"VMGuestLib_GetSessionId",
"returns",
"VMGUESTLIB_E... | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L149-L156 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetCpuLimitMHz | def GetCpuLimitMHz(self):
'''Retrieves the upperlimit of processor use in MHz available to the virtual
machine. For information about setting the CPU limit, see "Limits and
Reservations" on page 14.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetCpuLimitMHz(self.handl... | python | def GetCpuLimitMHz(self):
'''Retrieves the upperlimit of processor use in MHz available to the virtual
machine. For information about setting the CPU limit, see "Limits and
Reservations" on page 14.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetCpuLimitMHz(self.handl... | [
"def",
"GetCpuLimitMHz",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetCpuLimitMHz",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTL... | Retrieves the upperlimit of processor use in MHz available to the virtual
machine. For information about setting the CPU limit, see "Limits and
Reservations" on page 14. | [
"Retrieves",
"the",
"upperlimit",
"of",
"processor",
"use",
"in",
"MHz",
"available",
"to",
"the",
"virtual",
"machine",
".",
"For",
"information",
"about",
"setting",
"the",
"CPU",
"limit",
"see",
"Limits",
"and",
"Reservations",
"on",
"page",
"14",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L158-L165 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetCpuReservationMHz | def GetCpuReservationMHz(self):
'''Retrieves the minimum processing power in MHz reserved for the virtual
machine. For information about setting a CPU reservation, see "Limits and
Reservations" on page 14.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetCpuReservationM... | python | def GetCpuReservationMHz(self):
'''Retrieves the minimum processing power in MHz reserved for the virtual
machine. For information about setting a CPU reservation, see "Limits and
Reservations" on page 14.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetCpuReservationM... | [
"def",
"GetCpuReservationMHz",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetCpuReservationMHz",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",... | Retrieves the minimum processing power in MHz reserved for the virtual
machine. For information about setting a CPU reservation, see "Limits and
Reservations" on page 14. | [
"Retrieves",
"the",
"minimum",
"processing",
"power",
"in",
"MHz",
"reserved",
"for",
"the",
"virtual",
"machine",
".",
"For",
"information",
"about",
"setting",
"a",
"CPU",
"reservation",
"see",
"Limits",
"and",
"Reservations",
"on",
"page",
"14",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L167-L174 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetCpuShares | def GetCpuShares(self):
'''Retrieves the number of CPU shares allocated to the virtual machine. For
information about how an ESX server uses CPU shares to manage virtual
machine priority, see the vSphere Resource Management Guide.'''
counter = c_uint()
ret = vmGuestLib.VMGu... | python | def GetCpuShares(self):
'''Retrieves the number of CPU shares allocated to the virtual machine. For
information about how an ESX server uses CPU shares to manage virtual
machine priority, see the vSphere Resource Management Guide.'''
counter = c_uint()
ret = vmGuestLib.VMGu... | [
"def",
"GetCpuShares",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetCpuShares",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTLIB_E... | Retrieves the number of CPU shares allocated to the virtual machine. For
information about how an ESX server uses CPU shares to manage virtual
machine priority, see the vSphere Resource Management Guide. | [
"Retrieves",
"the",
"number",
"of",
"CPU",
"shares",
"allocated",
"to",
"the",
"virtual",
"machine",
".",
"For",
"information",
"about",
"how",
"an",
"ESX",
"server",
"uses",
"CPU",
"shares",
"to",
"manage",
"virtual",
"machine",
"priority",
"see",
"the",
"v... | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L176-L183 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetCpuStolenMs | def GetCpuStolenMs(self):
'''Retrieves the number of milliseconds that the virtual machine was in a
ready state (able to transition to a run state), but was not scheduled to run.'''
counter = c_uint64()
ret = vmGuestLib.VMGuestLib_GetCpuStolenMs(self.handle.value, byref(counter))
... | python | def GetCpuStolenMs(self):
'''Retrieves the number of milliseconds that the virtual machine was in a
ready state (able to transition to a run state), but was not scheduled to run.'''
counter = c_uint64()
ret = vmGuestLib.VMGuestLib_GetCpuStolenMs(self.handle.value, byref(counter))
... | [
"def",
"GetCpuStolenMs",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint64",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetCpuStolenMs",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUES... | Retrieves the number of milliseconds that the virtual machine was in a
ready state (able to transition to a run state), but was not scheduled to run. | [
"Retrieves",
"the",
"number",
"of",
"milliseconds",
"that",
"the",
"virtual",
"machine",
"was",
"in",
"a",
"ready",
"state",
"(",
"able",
"to",
"transition",
"to",
"a",
"run",
"state",
")",
"but",
"was",
"not",
"scheduled",
"to",
"run",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L185-L191 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetCpuUsedMs | def GetCpuUsedMs(self):
'''Retrieves the number of milliseconds during which the virtual machine
has used the CPU. This value includes the time used by the guest
operating system and the time used by virtualization code for tasks for this
virtual machine. You can combine this va... | python | def GetCpuUsedMs(self):
'''Retrieves the number of milliseconds during which the virtual machine
has used the CPU. This value includes the time used by the guest
operating system and the time used by virtualization code for tasks for this
virtual machine. You can combine this va... | [
"def",
"GetCpuUsedMs",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint64",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetCpuUsedMs",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTLIB... | Retrieves the number of milliseconds during which the virtual machine
has used the CPU. This value includes the time used by the guest
operating system and the time used by virtualization code for tasks for this
virtual machine. You can combine this value with the elapsed time
... | [
"Retrieves",
"the",
"number",
"of",
"milliseconds",
"during",
"which",
"the",
"virtual",
"machine",
"has",
"used",
"the",
"CPU",
".",
"This",
"value",
"includes",
"the",
"time",
"used",
"by",
"the",
"guest",
"operating",
"system",
"and",
"the",
"time",
"used... | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L193-L203 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetElapsedMs | def GetElapsedMs(self):
'''Retrieves the number of milliseconds that have passed in the virtual
machine since it last started running on the server. The count of elapsed
time restarts each time the virtual machine is powered on, resumed, or
migrated using VMotion. This value cou... | python | def GetElapsedMs(self):
'''Retrieves the number of milliseconds that have passed in the virtual
machine since it last started running on the server. The count of elapsed
time restarts each time the virtual machine is powered on, resumed, or
migrated using VMotion. This value cou... | [
"def",
"GetElapsedMs",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint64",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetElapsedMs",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTLIB... | Retrieves the number of milliseconds that have passed in the virtual
machine since it last started running on the server. The count of elapsed
time restarts each time the virtual machine is powered on, resumed, or
migrated using VMotion. This value counts milliseconds, regardless of
... | [
"Retrieves",
"the",
"number",
"of",
"milliseconds",
"that",
"have",
"passed",
"in",
"the",
"virtual",
"machine",
"since",
"it",
"last",
"started",
"running",
"on",
"the",
"server",
".",
"The",
"count",
"of",
"elapsed",
"time",
"restarts",
"each",
"time",
"th... | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L205-L218 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostCpuUsedMs | def GetHostCpuUsedMs(self):
'''Undocumented.'''
counter = c_uint64()
ret = vmGuestLib.VMGuestLib_GetHostCpuUsedMs(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetHostCpuUsedMs(self):
'''Undocumented.'''
counter = c_uint64()
ret = vmGuestLib.VMGuestLib_GetHostCpuUsedMs(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetHostCpuUsedMs",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint64",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostCpuUsedMs",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VM... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L221-L226 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostMemKernOvhdMB | def GetHostMemKernOvhdMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemKernOvhdMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetHostMemKernOvhdMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemKernOvhdMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetHostMemKernOvhdMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostMemKernOvhdMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L229-L234 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostMemMappedMB | def GetHostMemMappedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemMappedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetHostMemMappedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemMappedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetHostMemMappedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostMemMappedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L237-L242 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostMemPhysFreeMB | def GetHostMemPhysFreeMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemPhysFreeMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetHostMemPhysFreeMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemPhysFreeMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetHostMemPhysFreeMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostMemPhysFreeMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L245-L250 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostMemPhysMB | def GetHostMemPhysMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemPhysMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetHostMemPhysMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemPhysMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetHostMemPhysMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostMemPhysMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGU... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L253-L258 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostMemSharedMB | def GetHostMemSharedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemSharedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetHostMemSharedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemSharedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetHostMemSharedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostMemSharedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L261-L266 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostMemSwappedMB | def GetHostMemSwappedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemSwappedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetHostMemSwappedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemSwappedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetHostMemSwappedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostMemSwappedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L269-L274 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostMemUnmappedMB | def GetHostMemUnmappedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemUnmappedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetHostMemUnmappedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemUnmappedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetHostMemUnmappedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostMemUnmappedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L277-L282 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostMemUsedMB | def GetHostMemUsedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemUsedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetHostMemUsedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostMemUsedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetHostMemUsedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostMemUsedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGU... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L285-L290 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostNumCpuCores | def GetHostNumCpuCores(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostNumCpuCores(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetHostNumCpuCores(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostNumCpuCores(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetHostNumCpuCores",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostNumCpuCores",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L293-L298 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetHostProcessorSpeed | def GetHostProcessorSpeed(self):
'''Retrieves the speed of the ESX system's physical CPU in MHz.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostProcessorSpeed(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return co... | python | def GetHostProcessorSpeed(self):
'''Retrieves the speed of the ESX system's physical CPU in MHz.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetHostProcessorSpeed(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return co... | [
"def",
"GetHostProcessorSpeed",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetHostProcessorSpeed",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=... | Retrieves the speed of the ESX system's physical CPU in MHz. | [
"Retrieves",
"the",
"speed",
"of",
"the",
"ESX",
"system",
"s",
"physical",
"CPU",
"in",
"MHz",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L300-L305 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.