partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
MaternKernel._compute_y_wrapper
r"""Convert tau to :math:`y=\sqrt{2\nu\sum_i(\tau_i^2/l_i^2)}`. Takes `tau` as an argument list for compatibility with :py:func:`mpmath.diff`. Parameters ---------- tau[0] : scalar float First element of `tau`. tau[1] : And so on... ...
gptools/kernel/matern.py
def _compute_y_wrapper(self, *args): r"""Convert tau to :math:`y=\sqrt{2\nu\sum_i(\tau_i^2/l_i^2)}`. Takes `tau` as an argument list for compatibility with :py:func:`mpmath.diff`. Parameters ---------- tau[0] : scalar float First element of `tau`. ...
def _compute_y_wrapper(self, *args): r"""Convert tau to :math:`y=\sqrt{2\nu\sum_i(\tau_i^2/l_i^2)}`. Takes `tau` as an argument list for compatibility with :py:func:`mpmath.diff`. Parameters ---------- tau[0] : scalar float First element of `tau`. ...
[ "r", "Convert", "tau", "to", ":", "math", ":", "y", "=", "\\", "sqrt", "{", "2", "\\", "nu", "\\", "sum_i", "(", "\\", "tau_i^2", "/", "l_i^2", ")", "}", ".", "Takes", "tau", "as", "an", "argument", "list", "for", "compatibility", "with", ":", "p...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L339-L355
[ "def", "_compute_y_wrapper", "(", "self", ",", "*", "args", ")", ":", "return", "self", ".", "_compute_y", "(", "scipy", ".", "atleast_2d", "(", "scipy", ".", "asarray", "(", "args", ",", "dtype", "=", "float", ")", ")", ")" ]
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
MaternKernel._compute_dk_dy
r"""Evaluate the derivative of the outer form of the Matern kernel. Uses the general Leibniz rule to compute the n-th derivative of: .. math:: f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2}) Parameters ---------- y : :...
gptools/kernel/matern.py
def _compute_dk_dy(self, y, n): r"""Evaluate the derivative of the outer form of the Matern kernel. Uses the general Leibniz rule to compute the n-th derivative of: .. math:: f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2}) Par...
def _compute_dk_dy(self, y, n): r"""Evaluate the derivative of the outer form of the Matern kernel. Uses the general Leibniz rule to compute the n-th derivative of: .. math:: f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2}) Par...
[ "r", "Evaluate", "the", "derivative", "of", "the", "outer", "form", "of", "the", "Matern", "kernel", ".", "Uses", "the", "general", "Leibniz", "rule", "to", "compute", "the", "n", "-", "th", "derivative", "of", ":", "..", "math", "::", "f", "(", "y", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L357-L378
[ "def", "_compute_dk_dy", "(", "self", ",", "y", ",", "n", ")", ":", "return", "2.0", "**", "(", "1", "-", "self", ".", "nu", ")", "/", "(", "scipy", ".", "special", ".", "gamma", "(", "self", ".", "nu", ")", ")", "*", "yn2Kn2Der", "(", "self", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
MaternKernel._compute_dy_dtau
r"""Evaluate the derivative of the inner argument of the Matern kernel. Take the derivative of .. math:: y = 2 \nu \sum_i(\tau_i^2 / l_i^2) Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimen...
gptools/kernel/matern.py
def _compute_dy_dtau(self, tau, b, r2l2): r"""Evaluate the derivative of the inner argument of the Matern kernel. Take the derivative of .. math:: y = 2 \nu \sum_i(\tau_i^2 / l_i^2) Parameters ---------- tau : :py:class:`Mat...
def _compute_dy_dtau(self, tau, b, r2l2): r"""Evaluate the derivative of the inner argument of the Matern kernel. Take the derivative of .. math:: y = 2 \nu \sum_i(\tau_i^2 / l_i^2) Parameters ---------- tau : :py:class:`Mat...
[ "r", "Evaluate", "the", "derivative", "of", "the", "inner", "argument", "of", "the", "Matern", "kernel", ".", "Take", "the", "derivative", "of", "..", "math", "::", "y", "=", "2", "\\", "nu", "\\", "sum_i", "(", "\\", "tau_i^2", "/", "l_i^2", ")", "P...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L380-L410
[ "def", "_compute_dy_dtau", "(", "self", ",", "tau", ",", "b", ",", "r2l2", ")", ":", "if", "len", "(", "b", ")", "==", "0", ":", "return", "self", ".", "_compute_y", "(", "tau", ")", "elif", "len", "(", "b", ")", "==", "1", ":", "return", "4.0"...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
MaternKernel._compute_dk_dtau_on_partition
Evaluate the term inside the sum of Faa di Bruno's formula for the given partition. Overrides the version from :py:class:`gptools.kernel.core.ChainRuleKernel` in order to get the correct behavior at the origin. Parameters ---------- tau : :py:class:`Matrix`, (`M...
gptools/kernel/matern.py
def _compute_dk_dtau_on_partition(self, tau, p): """Evaluate the term inside the sum of Faa di Bruno's formula for the given partition. Overrides the version from :py:class:`gptools.kernel.core.ChainRuleKernel` in order to get the correct behavior at the origin. Paramet...
def _compute_dk_dtau_on_partition(self, tau, p): """Evaluate the term inside the sum of Faa di Bruno's formula for the given partition. Overrides the version from :py:class:`gptools.kernel.core.ChainRuleKernel` in order to get the correct behavior at the origin. Paramet...
[ "Evaluate", "the", "term", "inside", "the", "sum", "of", "Faa", "di", "Bruno", "s", "formula", "for", "the", "given", "partition", ".", "Overrides", "the", "version", "from", ":", "py", ":", "class", ":", "gptools", ".", "kernel", ".", "core", ".", "Ch...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L412-L459
[ "def", "_compute_dk_dtau_on_partition", "(", "self", ",", "tau", ",", "p", ")", ":", "# Find the derivative order:", "n", "=", "len", "(", "p", ")", "y", ",", "r2l2", "=", "self", ".", "_compute_y", "(", "tau", ",", "return_r2l2", "=", "True", ")", "# Ke...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
add_logging_parser
Build an argparse argument parser to parse the command line.
courseraoauth2client/utils.py
def add_logging_parser(main_parser): "Build an argparse argument parser to parse the command line." main_parser.set_defaults(setup_logging=set_logging_level) verbosity_group = main_parser.add_mutually_exclusive_group(required=False) verbosity_group.add_argument( '--verbose', '-v', ...
def add_logging_parser(main_parser): "Build an argparse argument parser to parse the command line." main_parser.set_defaults(setup_logging=set_logging_level) verbosity_group = main_parser.add_mutually_exclusive_group(required=False) verbosity_group.add_argument( '--verbose', '-v', ...
[ "Build", "an", "argparse", "argument", "parser", "to", "parse", "the", "command", "line", "." ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/utils.py#L28-L52
[ "def", "add_logging_parser", "(", "main_parser", ")", ":", "main_parser", ".", "set_defaults", "(", "setup_logging", "=", "set_logging_level", ")", "verbosity_group", "=", "main_parser", ".", "add_mutually_exclusive_group", "(", "required", "=", "False", ")", "verbosi...
4edd991defe26bfc768ab28a30368cace40baf44
train
set_logging_level
Computes and sets the logging level from the parsed arguments.
courseraoauth2client/utils.py
def set_logging_level(args): "Computes and sets the logging level from the parsed arguments." root_logger = logging.getLogger() level = logging.INFO logging.getLogger('requests.packages.urllib3').setLevel(logging.WARNING) if "verbose" in args and args.verbose is not None: logging.getLogger('...
def set_logging_level(args): "Computes and sets the logging level from the parsed arguments." root_logger = logging.getLogger() level = logging.INFO logging.getLogger('requests.packages.urllib3').setLevel(logging.WARNING) if "verbose" in args and args.verbose is not None: logging.getLogger('...
[ "Computes", "and", "sets", "the", "logging", "level", "from", "the", "parsed", "arguments", "." ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/utils.py#L55-L83
[ "def", "set_logging_level", "(", "args", ")", ":", "root_logger", "=", "logging", ".", "getLogger", "(", ")", "level", "=", "logging", ".", "INFO", "logging", ".", "getLogger", "(", "'requests.packages.urllib3'", ")", ".", "setLevel", "(", "logging", ".", "W...
4edd991defe26bfc768ab28a30368cace40baf44
train
check_auth
Check if the user should or shouldn't be inside the system: - If the user is staff or superuser: LOGIN GRANTED - If the user has a Person and it is not "disabled": LOGIN GRANTED - Elsewhere: LOGIN DENIED
codenerix/authbackend.py
def check_auth(user): ''' Check if the user should or shouldn't be inside the system: - If the user is staff or superuser: LOGIN GRANTED - If the user has a Person and it is not "disabled": LOGIN GRANTED - Elsewhere: LOGIN DENIED ''' # Initialize authentication auth = None person = ...
def check_auth(user): ''' Check if the user should or shouldn't be inside the system: - If the user is staff or superuser: LOGIN GRANTED - If the user has a Person and it is not "disabled": LOGIN GRANTED - Elsewhere: LOGIN DENIED ''' # Initialize authentication auth = None person = ...
[ "Check", "if", "the", "user", "should", "or", "shouldn", "t", "be", "inside", "the", "system", ":", "-", "If", "the", "user", "is", "staff", "or", "superuser", ":", "LOGIN", "GRANTED", "-", "If", "the", "user", "has", "a", "Person", "and", "it", "is"...
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L42-L77
[ "def", "check_auth", "(", "user", ")", ":", "# Initialize authentication", "auth", "=", "None", "person", "=", "None", "# Check if there is an user", "if", "user", ":", "# It means that Django accepted the user and it is active", "if", "user", ".", "is_staff", "or", "us...
1f5527b352141caaee902b37b2648791a06bd57d
train
ActiveDirectoryGroupMembershipSSLBackend.debug
Handle the debugging to a file
codenerix/authbackend.py
def debug(self, msg): ''' Handle the debugging to a file ''' # If debug is not disabled if self.__debug is not False: # If never was set, try to set it up if self.__debug is None: # Check what do we have inside settings de...
def debug(self, msg): ''' Handle the debugging to a file ''' # If debug is not disabled if self.__debug is not False: # If never was set, try to set it up if self.__debug is None: # Check what do we have inside settings de...
[ "Handle", "the", "debugging", "to", "a", "file" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L407-L429
[ "def", "debug", "(", "self", ",", "msg", ")", ":", "# If debug is not disabled", "if", "self", ".", "__debug", "is", "not", "False", ":", "# If never was set, try to set it up", "if", "self", ".", "__debug", "is", "None", ":", "# Check what do we have inside setting...
1f5527b352141caaee902b37b2648791a06bd57d
train
ActiveDirectoryGroupMembershipSSLBackend.authenticate
Authenticate the user agains LDAP
codenerix/authbackend.py
def authenticate(self, *args, **kwargs): ''' Authenticate the user agains LDAP ''' # Get config username = kwargs.get("username", None) password = kwargs.get("password", None) # Check user in Active Directory (authorization == None if can not connect to Active D...
def authenticate(self, *args, **kwargs): ''' Authenticate the user agains LDAP ''' # Get config username = kwargs.get("username", None) password = kwargs.get("password", None) # Check user in Active Directory (authorization == None if can not connect to Active D...
[ "Authenticate", "the", "user", "agains", "LDAP" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L493-L527
[ "def", "authenticate", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Get config", "username", "=", "kwargs", ".", "get", "(", "\"username\"", ",", "None", ")", "password", "=", "kwargs", ".", "get", "(", "\"password\"", ",", "Non...
1f5527b352141caaee902b37b2648791a06bd57d
train
ActiveDirectoryGroupMembershipSSLBackend.get_or_create_user
Get or create the given user
codenerix/authbackend.py
def get_or_create_user(self, username, password): ''' Get or create the given user ''' # Get the groups for this user info = self.get_ad_info(username, password) self.debug("INFO found: {}".format(info)) # Find the user try: user = User.objec...
def get_or_create_user(self, username, password): ''' Get or create the given user ''' # Get the groups for this user info = self.get_ad_info(username, password) self.debug("INFO found: {}".format(info)) # Find the user try: user = User.objec...
[ "Get", "or", "create", "the", "given", "user" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L633-L681
[ "def", "get_or_create_user", "(", "self", ",", "username", ",", "password", ")", ":", "# Get the groups for this user", "info", "=", "self", ".", "get_ad_info", "(", "username", ",", "password", ")", "self", ".", "debug", "(", "\"INFO found: {}\"", ".", "format"...
1f5527b352141caaee902b37b2648791a06bd57d
train
ActiveDirectoryGroupMembershipSSLBackend.synchronize
It tries to do a group synchronization if possible This methods should be redeclared by the developer
codenerix/authbackend.py
def synchronize(self, user, info): ''' It tries to do a group synchronization if possible This methods should be redeclared by the developer ''' self.debug("Synchronize!") # Remove all groups from this user user.groups.clear() # For all domains found fo...
def synchronize(self, user, info): ''' It tries to do a group synchronization if possible This methods should be redeclared by the developer ''' self.debug("Synchronize!") # Remove all groups from this user user.groups.clear() # For all domains found fo...
[ "It", "tries", "to", "do", "a", "group", "synchronization", "if", "possible", "This", "methods", "should", "be", "redeclared", "by", "the", "developer" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L698-L717
[ "def", "synchronize", "(", "self", ",", "user", ",", "info", ")", ":", "self", ".", "debug", "(", "\"Synchronize!\"", ")", "# Remove all groups from this user", "user", ".", "groups", ".", "clear", "(", ")", "# For all domains found for this user", "for", "domain"...
1f5527b352141caaee902b37b2648791a06bd57d
train
Kernel.set_hyperparams
Sets the free hyperparameters to the new parameter values in new_params. Parameters ---------- new_params : :py:class:`Array` or other Array-like, (len(:py:attr:`self.free_params`),) New parameter values, ordered as dictated by the docstring for the class.
gptools/kernel/core.py
def set_hyperparams(self, new_params): """Sets the free hyperparameters to the new parameter values in new_params. Parameters ---------- new_params : :py:class:`Array` or other Array-like, (len(:py:attr:`self.free_params`),) New parameter values, ordered as dictated ...
def set_hyperparams(self, new_params): """Sets the free hyperparameters to the new parameter values in new_params. Parameters ---------- new_params : :py:class:`Array` or other Array-like, (len(:py:attr:`self.free_params`),) New parameter values, ordered as dictated ...
[ "Sets", "the", "free", "hyperparameters", "to", "the", "new", "parameter", "values", "in", "new_params", ".", "Parameters", "----------", "new_params", ":", ":", "py", ":", "class", ":", "Array", "or", "other", "Array", "-", "like", "(", "len", "(", ":", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L236-L256
[ "def", "set_hyperparams", "(", "self", ",", "new_params", ")", ":", "new_params", "=", "scipy", ".", "asarray", "(", "new_params", ",", "dtype", "=", "float", ")", "if", "len", "(", "new_params", ")", "==", "len", "(", "self", ".", "free_params", ")", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
Kernel._compute_r2l2
r"""Compute the anisotropic :math:`r^2/l^2` term for the given `tau`. Here, :math:`\tau=X_i-X_j` is the difference vector. Computes .. math:: \frac{r^2}{l^2} = \sum_i\frac{\tau_i^2}{l_{i}^{2}} Assumes that the length parameters are the last `num_dim` el...
gptools/kernel/core.py
def _compute_r2l2(self, tau, return_l=False): r"""Compute the anisotropic :math:`r^2/l^2` term for the given `tau`. Here, :math:`\tau=X_i-X_j` is the difference vector. Computes .. math:: \frac{r^2}{l^2} = \sum_i\frac{\tau_i^2}{l_{i}^{2}} Assume...
def _compute_r2l2(self, tau, return_l=False): r"""Compute the anisotropic :math:`r^2/l^2` term for the given `tau`. Here, :math:`\tau=X_i-X_j` is the difference vector. Computes .. math:: \frac{r^2}{l^2} = \sum_i\frac{\tau_i^2}{l_{i}^{2}} Assume...
[ "r", "Compute", "the", "anisotropic", ":", "math", ":", "r^2", "/", "l^2", "term", "for", "the", "given", "tau", ".", "Here", ":", "math", ":", "\\", "tau", "=", "X_i", "-", "X_j", "is", "the", "difference", "vector", ".", "Computes", "..", "math", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L349-L386
[ "def", "_compute_r2l2", "(", "self", ",", "tau", ",", "return_l", "=", "False", ")", ":", "l_mat", "=", "scipy", ".", "tile", "(", "self", ".", "params", "[", "-", "self", ".", "num_dim", ":", "]", ",", "(", "tau", ".", "shape", "[", "0", "]", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
BinaryKernel.enforce_bounds
Set `enforce_bounds` for both of the kernels to a new value.
gptools/kernel/core.py
def enforce_bounds(self, v): """Set `enforce_bounds` for both of the kernels to a new value. """ self._enforce_bounds = v self.k1.enforce_bounds = v self.k2.enforce_bounds = v
def enforce_bounds(self, v): """Set `enforce_bounds` for both of the kernels to a new value. """ self._enforce_bounds = v self.k1.enforce_bounds = v self.k2.enforce_bounds = v
[ "Set", "enforce_bounds", "for", "both", "of", "the", "kernels", "to", "a", "new", "value", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L426-L431
[ "def", "enforce_bounds", "(", "self", ",", "v", ")", ":", "self", ".", "_enforce_bounds", "=", "v", "self", ".", "k1", ".", "enforce_bounds", "=", "v", "self", ".", "k2", ".", "enforce_bounds", "=", "v" ]
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
BinaryKernel.free_param_bounds
Returns the bounds of the free hyperparameters. Returns ------- free_param_bounds : :py:class:`Array` Array of the bounds of the free parameters, in order.
gptools/kernel/core.py
def free_param_bounds(self): """Returns the bounds of the free hyperparameters. Returns ------- free_param_bounds : :py:class:`Array` Array of the bounds of the free parameters, in order. """ return scipy.concatenate((self.k1.free_param_bounds, self.k...
def free_param_bounds(self): """Returns the bounds of the free hyperparameters. Returns ------- free_param_bounds : :py:class:`Array` Array of the bounds of the free parameters, in order. """ return scipy.concatenate((self.k1.free_param_bounds, self.k...
[ "Returns", "the", "bounds", "of", "the", "free", "hyperparameters", ".", "Returns", "-------", "free_param_bounds", ":", ":", "py", ":", "class", ":", "Array", "Array", "of", "the", "bounds", "of", "the", "free", "parameters", "in", "order", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L443-L451
[ "def", "free_param_bounds", "(", "self", ")", ":", "return", "scipy", ".", "concatenate", "(", "(", "self", ".", "k1", ".", "free_param_bounds", ",", "self", ".", "k2", ".", "free_param_bounds", ")", ")" ]
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
BinaryKernel.free_param_names
Returns the names of the free hyperparameters. Returns ------- free_param_names : :py:class:`Array` Array of the names of the free parameters, in order.
gptools/kernel/core.py
def free_param_names(self): """Returns the names of the free hyperparameters. Returns ------- free_param_names : :py:class:`Array` Array of the names of the free parameters, in order. """ return scipy.concatenate((self.k1.free_param_names, self.k2.fre...
def free_param_names(self): """Returns the names of the free hyperparameters. Returns ------- free_param_names : :py:class:`Array` Array of the names of the free parameters, in order. """ return scipy.concatenate((self.k1.free_param_names, self.k2.fre...
[ "Returns", "the", "names", "of", "the", "free", "hyperparameters", ".", "Returns", "-------", "free_param_names", ":", ":", "py", ":", "class", ":", "Array", "Array", "of", "the", "names", "of", "the", "free", "parameters", "in", "order", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L454-L462
[ "def", "free_param_names", "(", "self", ")", ":", "return", "scipy", ".", "concatenate", "(", "(", "self", ".", "k1", ".", "free_param_names", ",", "self", ".", "k2", ".", "free_param_names", ")", ")" ]
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
BinaryKernel.set_hyperparams
Set the (free) hyperparameters. Parameters ---------- new_params : :py:class:`Array` or other Array-like New values of the free parameters. Raises ------ ValueError If the length of `new_params` is not consistent with :py:attr:`se...
gptools/kernel/core.py
def set_hyperparams(self, new_params): """Set the (free) hyperparameters. Parameters ---------- new_params : :py:class:`Array` or other Array-like New values of the free parameters. Raises ------ ValueError If the length o...
def set_hyperparams(self, new_params): """Set the (free) hyperparameters. Parameters ---------- new_params : :py:class:`Array` or other Array-like New values of the free parameters. Raises ------ ValueError If the length o...
[ "Set", "the", "(", "free", ")", "hyperparameters", ".", "Parameters", "----------", "new_params", ":", ":", "py", ":", "class", ":", "Array", "or", "other", "Array", "-", "like", "New", "values", "of", "the", "free", "parameters", ".", "Raises", "------", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L473-L493
[ "def", "set_hyperparams", "(", "self", ",", "new_params", ")", ":", "new_params", "=", "scipy", ".", "asarray", "(", "new_params", ",", "dtype", "=", "float", ")", "if", "len", "(", "new_params", ")", "==", "len", "(", "self", ".", "free_params", ")", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
ChainRuleKernel._compute_dk_dtau
r"""Evaluate :math:`dk/d\tau` at the specified locations with the specified derivatives. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. n : :py:class:`Array`, (`D`,) Degree of derivative with respect to each dime...
gptools/kernel/core.py
def _compute_dk_dtau(self, tau, n): r"""Evaluate :math:`dk/d\tau` at the specified locations with the specified derivatives. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. n : :py:class:`Array`, (`D`,) De...
def _compute_dk_dtau(self, tau, n): r"""Evaluate :math:`dk/d\tau` at the specified locations with the specified derivatives. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. n : :py:class:`Array`, (`D`,) De...
[ "r", "Evaluate", ":", "math", ":", "dk", "/", "d", "\\", "tau", "at", "the", "specified", "locations", "with", "the", "specified", "derivatives", ".", "Parameters", "----------", "tau", ":", ":", "py", ":", "class", ":", "Matrix", "(", "M", "D", ")", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L671-L707
[ "def", "_compute_dk_dtau", "(", "self", ",", "tau", ",", "n", ")", ":", "# Construct the derivative pattern:", "# For each dimension, this will contain the index of the dimension", "# repeated a number of times equal to the order of derivative with", "# respect to that dimension.", "# Ex...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
ChainRuleKernel._compute_dk_dtau_on_partition
Evaluate the term inside the sum of Faa di Bruno's formula for the given partition. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. p : list of :py:class:`Array` Each element is a block of the partition representi...
gptools/kernel/core.py
def _compute_dk_dtau_on_partition(self, tau, p): """Evaluate the term inside the sum of Faa di Bruno's formula for the given partition. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. p : list of :py:class:`Array` ...
def _compute_dk_dtau_on_partition(self, tau, p): """Evaluate the term inside the sum of Faa di Bruno's formula for the given partition. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. p : list of :py:class:`Array` ...
[ "Evaluate", "the", "term", "inside", "the", "sum", "of", "Faa", "di", "Bruno", "s", "formula", "for", "the", "given", "partition", ".", "Parameters", "----------", "tau", ":", ":", "py", ":", "class", ":", "Matrix", "(", "M", "D", ")", "M", "inputs", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L709-L732
[ "def", "_compute_dk_dtau_on_partition", "(", "self", ",", "tau", ",", "p", ")", ":", "y", ",", "r2l2", "=", "self", ".", "_compute_y", "(", "tau", ",", "return_r2l2", "=", "True", ")", "# Compute the d^(|pi|)f/dy term:", "dk_dtau", "=", "self", ".", "_comput...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
ArbitraryKernel._mask_cov_func
Masks the covariance function into a form usable by :py:func:`mpmath.diff`. Parameters ---------- *args : `num_dim` * 2 floats The individual elements of Xi and Xj to be passed to :py:attr:`cov_func`.
gptools/kernel/core.py
def _mask_cov_func(self, *args): """Masks the covariance function into a form usable by :py:func:`mpmath.diff`. Parameters ---------- *args : `num_dim` * 2 floats The individual elements of Xi and Xj to be passed to :py:attr:`cov_func`. """ # Have to ...
def _mask_cov_func(self, *args): """Masks the covariance function into a form usable by :py:func:`mpmath.diff`. Parameters ---------- *args : `num_dim` * 2 floats The individual elements of Xi and Xj to be passed to :py:attr:`cov_func`. """ # Have to ...
[ "Masks", "the", "covariance", "function", "into", "a", "form", "usable", "by", ":", "py", ":", "func", ":", "mpmath", ".", "diff", ".", "Parameters", "----------", "*", "args", ":", "num_dim", "*", "2", "floats", "The", "individual", "elements", "of", "X...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L858-L870
[ "def", "_mask_cov_func", "(", "self", ",", "*", "args", ")", ":", "# Have to do it in two cases to get the 1d unwrapped properly:", "if", "self", ".", "num_dim", "==", "1", ":", "return", "self", ".", "cov_func", "(", "args", "[", "0", "]", ",", "args", "[", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
constant
Function implementing a constant mean suitable for use with :py:class:`MeanFunction`.
gptools/mean.py
def constant(X, n, mu, hyper_deriv=None): """Function implementing a constant mean suitable for use with :py:class:`MeanFunction`. """ if (n == 0).all(): if hyper_deriv is not None: return scipy.ones(X.shape[0]) else: return mu * scipy.ones(X.shape[0]) else: ...
def constant(X, n, mu, hyper_deriv=None): """Function implementing a constant mean suitable for use with :py:class:`MeanFunction`. """ if (n == 0).all(): if hyper_deriv is not None: return scipy.ones(X.shape[0]) else: return mu * scipy.ones(X.shape[0]) else: ...
[ "Function", "implementing", "a", "constant", "mean", "suitable", "for", "use", "with", ":", "py", ":", "class", ":", "MeanFunction", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/mean.py#L293-L302
[ "def", "constant", "(", "X", ",", "n", ",", "mu", ",", "hyper_deriv", "=", "None", ")", ":", "if", "(", "n", "==", "0", ")", ".", "all", "(", ")", ":", "if", "hyper_deriv", "is", "not", "None", ":", "return", "scipy", ".", "ones", "(", "X", "...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
mtanh
Modified hyperbolic tangent function mtanh(z; alpha). Parameters ---------- alpha : float The core slope of the mtanh. z : float or array The coordinate of the mtanh.
gptools/mean.py
def mtanh(alpha, z): """Modified hyperbolic tangent function mtanh(z; alpha). Parameters ---------- alpha : float The core slope of the mtanh. z : float or array The coordinate of the mtanh. """ z = scipy.asarray(z) ez = scipy.exp(z) enz = 1.0 / ez return ((1...
def mtanh(alpha, z): """Modified hyperbolic tangent function mtanh(z; alpha). Parameters ---------- alpha : float The core slope of the mtanh. z : float or array The coordinate of the mtanh. """ z = scipy.asarray(z) ez = scipy.exp(z) enz = 1.0 / ez return ((1...
[ "Modified", "hyperbolic", "tangent", "function", "mtanh", "(", "z", ";", "alpha", ")", ".", "Parameters", "----------", "alpha", ":", "float", "The", "core", "slope", "of", "the", "mtanh", ".", "z", ":", "float", "or", "array", "The", "coordinate", "of", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/mean.py#L321-L334
[ "def", "mtanh", "(", "alpha", ",", "z", ")", ":", "z", "=", "scipy", ".", "asarray", "(", "z", ")", "ez", "=", "scipy", ".", "exp", "(", "z", ")", "enz", "=", "1.0", "/", "ez", "return", "(", "(", "1", "+", "alpha", "*", "z", ")", "*", "e...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
mtanh_profile
Profile used with the mtanh function to fit profiles, suitable for use with :py:class:`MeanFunction`. Only supports univariate data! Parameters ---------- X : array, (`M`, 1) The points to evaluate at. n : array, (1,) The order of derivative to compute. Only up to first der...
gptools/mean.py
def mtanh_profile(X, n, x0, delta, alpha, h, b, hyper_deriv=None): """Profile used with the mtanh function to fit profiles, suitable for use with :py:class:`MeanFunction`. Only supports univariate data! Parameters ---------- X : array, (`M`, 1) The points to evaluate at. n : ar...
def mtanh_profile(X, n, x0, delta, alpha, h, b, hyper_deriv=None): """Profile used with the mtanh function to fit profiles, suitable for use with :py:class:`MeanFunction`. Only supports univariate data! Parameters ---------- X : array, (`M`, 1) The points to evaluate at. n : ar...
[ "Profile", "used", "with", "the", "mtanh", "function", "to", "fit", "profiles", "suitable", "for", "use", "with", ":", "py", ":", "class", ":", "MeanFunction", ".", "Only", "supports", "univariate", "data!", "Parameters", "----------", "X", ":", "array", "("...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/mean.py#L336-L419
[ "def", "mtanh_profile", "(", "X", ",", "n", ",", "x0", ",", "delta", ",", "alpha", ",", "h", ",", "b", ",", "hyper_deriv", "=", "None", ")", ":", "X", "=", "X", "[", ":", ",", "0", "]", "z", "=", "(", "x0", "-", "X", ")", "/", "delta", "i...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
linear
Linear mean function of arbitrary dimension, suitable for use with :py:class:`MeanFunction`. The form is :math:`m_0 * X[:, 0] + m_1 * X[:, 1] + \dots + b`. Parameters ---------- X : array, (`M`, `D`) The points to evaluate the model at. n : array of non-negative int, (`D`) ...
gptools/mean.py
def linear(X, n, *args, **kwargs): """Linear mean function of arbitrary dimension, suitable for use with :py:class:`MeanFunction`. The form is :math:`m_0 * X[:, 0] + m_1 * X[:, 1] + \dots + b`. Parameters ---------- X : array, (`M`, `D`) The points to evaluate the model at. n :...
def linear(X, n, *args, **kwargs): """Linear mean function of arbitrary dimension, suitable for use with :py:class:`MeanFunction`. The form is :math:`m_0 * X[:, 0] + m_1 * X[:, 1] + \dots + b`. Parameters ---------- X : array, (`M`, `D`) The points to evaluate the model at. n :...
[ "Linear", "mean", "function", "of", "arbitrary", "dimension", "suitable", "for", "use", "with", ":", "py", ":", "class", ":", "MeanFunction", ".", "The", "form", "is", ":", "math", ":", "m_0", "*", "X", "[", ":", "0", "]", "+", "m_1", "*", "X", "["...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/mean.py#L446-L484
[ "def", "linear", "(", "X", ",", "n", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "hyper_deriv", "=", "kwargs", ".", "pop", "(", "'hyper_deriv'", ",", "None", ")", "m", "=", "scipy", ".", "asarray", "(", "args", "[", ":", "-", "1", "]",...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
update_schedule_items
We save all the schedule items associated with this slot, so the last_update time is updated to reflect any changes to the timing of the slots
wafer/schedule/models.py
def update_schedule_items(*args, **kw): """We save all the schedule items associated with this slot, so the last_update time is updated to reflect any changes to the timing of the slots""" slot = kw.pop('instance', None) if not slot: return for item in slot.scheduleitem_set.all(): ...
def update_schedule_items(*args, **kw): """We save all the schedule items associated with this slot, so the last_update time is updated to reflect any changes to the timing of the slots""" slot = kw.pop('instance', None) if not slot: return for item in slot.scheduleitem_set.all(): ...
[ "We", "save", "all", "the", "schedule", "items", "associated", "with", "this", "slot", "so", "the", "last_update", "time", "is", "updated", "to", "reflect", "any", "changes", "to", "the", "timing", "of", "the", "slots" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/models.py#L287-L303
[ "def", "update_schedule_items", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "slot", "=", "kw", ".", "pop", "(", "'instance'", ",", "None", ")", "if", "not", "slot", ":", "return", "for", "item", "in", "slot", ".", "scheduleitem_set", ".", "all",...
a20af3c399267f76373dc342f4d542a9bc457c35
train
make_diff
Create the difference between the current revision and a previous version
wafer/compare/admin.py
def make_diff(current, revision): """Create the difference between the current revision and a previous version""" the_diff = [] dmp = diff_match_patch() for field in (set(current.field_dict.keys()) | set(revision.field_dict.keys())): # These exclusions really should be configurable if f...
def make_diff(current, revision): """Create the difference between the current revision and a previous version""" the_diff = [] dmp = diff_match_patch() for field in (set(current.field_dict.keys()) | set(revision.field_dict.keys())): # These exclusions really should be configurable if f...
[ "Create", "the", "difference", "between", "the", "current", "revision", "and", "a", "previous", "version" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/compare/admin.py#L61-L107
[ "def", "make_diff", "(", "current", ",", "revision", ")", ":", "the_diff", "=", "[", "]", "dmp", "=", "diff_match_patch", "(", ")", "for", "field", "in", "(", "set", "(", "current", ".", "field_dict", ".", "keys", "(", ")", ")", "|", "set", "(", "r...
a20af3c399267f76373dc342f4d542a9bc457c35
train
CompareVersionAdmin.compare_view
Actually compare two versions.
wafer/compare/admin.py
def compare_view(self, request, object_id, version_id, extra_context=None): """Actually compare two versions.""" opts = self.model._meta object_id = unquote(object_id) # get_for_object's ordering means this is always the latest revision. # The reversion we want to compare to ...
def compare_view(self, request, object_id, version_id, extra_context=None): """Actually compare two versions.""" opts = self.model._meta object_id = unquote(object_id) # get_for_object's ordering means this is always the latest revision. # The reversion we want to compare to ...
[ "Actually", "compare", "two", "versions", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/compare/admin.py#L129-L154
[ "def", "compare_view", "(", "self", ",", "request", ",", "object_id", ",", "version_id", ",", "extra_context", "=", "None", ")", ":", "opts", "=", "self", ".", "model", ".", "_meta", "object_id", "=", "unquote", "(", "object_id", ")", "# get_for_object's ord...
a20af3c399267f76373dc342f4d542a9bc457c35
train
CompareVersionAdmin.comparelist_view
Allow selecting versions to compare.
wafer/compare/admin.py
def comparelist_view(self, request, object_id, extra_context=None): """Allow selecting versions to compare.""" opts = self.model._meta object_id = unquote(object_id) current = get_object_or_404(self.model, pk=object_id) # As done by reversion's history_view action_list = ...
def comparelist_view(self, request, object_id, extra_context=None): """Allow selecting versions to compare.""" opts = self.model._meta object_id = unquote(object_id) current = get_object_or_404(self.model, pk=object_id) # As done by reversion's history_view action_list = ...
[ "Allow", "selecting", "versions", "to", "compare", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/compare/admin.py#L156-L177
[ "def", "comparelist_view", "(", "self", ",", "request", ",", "object_id", ",", "extra_context", "=", "None", ")", ":", "opts", "=", "self", ".", "model", ".", "_meta", "object_id", "=", "unquote", "(", "object_id", ")", "current", "=", "get_object_or_404", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
grv
This function helps to convert date information for showing proper filtering
codenerix/views.py
def grv(struct, position): ''' This function helps to convert date information for showing proper filtering ''' if position == 'year': size = 4 else: size = 2 if (struct[position][2]): rightnow = str(struct[position][0]).zfill(size) else: if position == 'year...
def grv(struct, position): ''' This function helps to convert date information for showing proper filtering ''' if position == 'year': size = 4 else: size = 2 if (struct[position][2]): rightnow = str(struct[position][0]).zfill(size) else: if position == 'year...
[ "This", "function", "helps", "to", "convert", "date", "information", "for", "showing", "proper", "filtering" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L96-L112
[ "def", "grv", "(", "struct", ",", "position", ")", ":", "if", "position", "==", "'year'", ":", "size", "=", "4", "else", ":", "size", "=", "2", "if", "(", "struct", "[", "position", "]", "[", "2", "]", ")", ":", "rightnow", "=", "str", "(", "st...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenBase._setup
Entry point for this class, here we decide basic stuff
codenerix/views.py
def _setup(self, request): ''' Entry point for this class, here we decide basic stuff ''' # Get details from self info = model_inspect(self) self._appname = getattr(self, 'appname', info['appname']) self._modelname = getattr(self, 'modelname', info['modelname']) ...
def _setup(self, request): ''' Entry point for this class, here we decide basic stuff ''' # Get details from self info = model_inspect(self) self._appname = getattr(self, 'appname', info['appname']) self._modelname = getattr(self, 'modelname', info['modelname']) ...
[ "Entry", "point", "for", "this", "class", "here", "we", "decide", "basic", "stuff" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L610-L631
[ "def", "_setup", "(", "self", ",", "request", ")", ":", "# Get details from self", "info", "=", "model_inspect", "(", "self", ")", "self", ".", "_appname", "=", "getattr", "(", "self", ",", "'appname'", ",", "info", "[", "'appname'", "]", ")", "self", "....
1f5527b352141caaee902b37b2648791a06bd57d
train
GenBase.get_template_names
Build the list of templates related to this user
codenerix/views.py
def get_template_names(self): ''' Build the list of templates related to this user ''' # Get user template template_model = getattr(self, 'template_model', "{0}/{1}_{2}".format(self._appname.lower(), self._modelname.lower(), self.get_template_names_key)) template_model_e...
def get_template_names(self): ''' Build the list of templates related to this user ''' # Get user template template_model = getattr(self, 'template_model', "{0}/{1}_{2}".format(self._appname.lower(), self._modelname.lower(), self.get_template_names_key)) template_model_e...
[ "Build", "the", "list", "of", "templates", "related", "to", "this", "user" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L633-L646
[ "def", "get_template_names", "(", "self", ")", ":", "# Get user template", "template_model", "=", "getattr", "(", "self", ",", "'template_model'", ",", "\"{0}/{1}_{2}\"", ".", "format", "(", "self", ".", "_appname", ".", "lower", "(", ")", ",", "self", ".", ...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenBase.get_context_data
Set a base context
codenerix/views.py
def get_context_data(self, **kwargs): ''' Set a base context ''' # Call the base implementation first to get a context context = super(GenBase, self).get_context_data(**kwargs) # Update general context with the stuff we already calculated if hasattr(self, 'html_...
def get_context_data(self, **kwargs): ''' Set a base context ''' # Call the base implementation first to get a context context = super(GenBase, self).get_context_data(**kwargs) # Update general context with the stuff we already calculated if hasattr(self, 'html_...
[ "Set", "a", "base", "context" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L648-L668
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Call the base implementation first to get a context", "context", "=", "super", "(", "GenBase", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "# Update general ...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenList.dispatch
Entry point for this class, here we decide basic stuff
codenerix/views.py
def dispatch(self, *args, **kwargs): ''' Entry point for this class, here we decide basic stuff ''' # Get if this class is working as only a base render and List funcionality shouldn't be enabled onlybase = getattr(self, "onlybase", False) # REST not available when only...
def dispatch(self, *args, **kwargs): ''' Entry point for this class, here we decide basic stuff ''' # Get if this class is working as only a base render and List funcionality shouldn't be enabled onlybase = getattr(self, "onlybase", False) # REST not available when only...
[ "Entry", "point", "for", "this", "class", "here", "we", "decide", "basic", "stuff" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L1180-L1287
[ "def", "dispatch", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Get if this class is working as only a base render and List funcionality shouldn't be enabled", "onlybase", "=", "getattr", "(", "self", ",", "\"onlybase\"", ",", "False", ")", "# ...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenList.get_queryset
raise Exception("FOUND: {} -- __foreignkeys: {} -- __columns: {} -- autorules_keys: {} -- \ query_select_related: {} -- query_renamed: {} -- query_optimizer: {} | use_extra: {}| -- \ query: {} -- meta.fields: {} -- fields_related_model: {} -- query_verifier: {}\ -- ??? {} == {}".form...
codenerix/views.py
def get_queryset(self, raw_query=False): # Call the base implementation if not self.haystack: queryset = super(GenList, self).get_queryset() else: queryset = SearchQuerySet().models(self.model) # Optional tweak methods Mfields = None MlimitQ = Non...
def get_queryset(self, raw_query=False): # Call the base implementation if not self.haystack: queryset = super(GenList, self).get_queryset() else: queryset = SearchQuerySet().models(self.model) # Optional tweak methods Mfields = None MlimitQ = Non...
[ "raise", "Exception", "(", "FOUND", ":", "{}", "--", "__foreignkeys", ":", "{}", "--", "__columns", ":", "{}", "--", "autorules_keys", ":", "{}", "--", "\\", "query_select_related", ":", "{}", "--", "query_renamed", ":", "{}", "--", "query_optimizer", ":", ...
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L1353-L2336
[ "def", "get_queryset", "(", "self", ",", "raw_query", "=", "False", ")", ":", "# Call the base implementation", "if", "not", "self", ".", "haystack", ":", "queryset", "=", "super", "(", "GenList", ",", "self", ")", ".", "get_queryset", "(", ")", "else", ":...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenList.get_context_data
Generic list view with validation included and object transfering support
codenerix/views.py
def get_context_data(self, **kwargs): ''' Generic list view with validation included and object transfering support ''' # Call the base implementation first to get a context context = super(GenList, self).get_context_data(**kwargs) # Update general context with the stuff...
def get_context_data(self, **kwargs): ''' Generic list view with validation included and object transfering support ''' # Call the base implementation first to get a context context = super(GenList, self).get_context_data(**kwargs) # Update general context with the stuff...
[ "Generic", "list", "view", "with", "validation", "included", "and", "object", "transfering", "support" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L2338-L2417
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Call the base implementation first to get a context", "context", "=", "super", "(", "GenList", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "# Update general ...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenList.get_context_json
Return a base answer for a json answer
codenerix/views.py
def get_context_json(self, context): ''' Return a base answer for a json answer ''' # Initialize answer answer = {} # Metadata builder answer['meta'] = self.__jcontext_metadata(context) # Filter builder answer['filter'] = self.__jcontext_filter(c...
def get_context_json(self, context): ''' Return a base answer for a json answer ''' # Initialize answer answer = {} # Metadata builder answer['meta'] = self.__jcontext_metadata(context) # Filter builder answer['filter'] = self.__jcontext_filter(c...
[ "Return", "a", "base", "answer", "for", "a", "json", "answer" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L2609-L2630
[ "def", "get_context_json", "(", "self", ",", "context", ")", ":", "# Initialize answer", "answer", "=", "{", "}", "# Metadata builder", "answer", "[", "'meta'", "]", "=", "self", ".", "__jcontext_metadata", "(", "context", ")", "# Filter builder", "answer", "[",...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenList.set_context_json
Get a json parameter and rebuild the context back to a dictionary (probably kwargs)
codenerix/views.py
def set_context_json(self, jsonquery): ''' Get a json parameter and rebuild the context back to a dictionary (probably kwargs) ''' # Make sure we are getting dicts if type(jsonquery) != dict: raise IOError("set_json_context() method can be called only with dictionari...
def set_context_json(self, jsonquery): ''' Get a json parameter and rebuild the context back to a dictionary (probably kwargs) ''' # Make sure we are getting dicts if type(jsonquery) != dict: raise IOError("set_json_context() method can be called only with dictionari...
[ "Get", "a", "json", "parameter", "and", "rebuild", "the", "context", "back", "to", "a", "dictionary", "(", "probably", "kwargs", ")" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L2632-L2682
[ "def", "set_context_json", "(", "self", ",", "jsonquery", ")", ":", "# Make sure we are getting dicts", "if", "type", "(", "jsonquery", ")", "!=", "dict", ":", "raise", "IOError", "(", "\"set_json_context() method can be called only with dictionaries, you gave me a '{}'\"", ...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenModify.dispatch
Entry point for this class, here we decide basic stuff
codenerix/views.py
def dispatch(self, request, **kwargs): ''' Entry point for this class, here we decide basic stuff ''' # Check if this is a webservice request self.json_worker = (bool(getattr(self.request, "authtoken", False))) or (self.json is True) self.__authtoken = (bool(getattr(self...
def dispatch(self, request, **kwargs): ''' Entry point for this class, here we decide basic stuff ''' # Check if this is a webservice request self.json_worker = (bool(getattr(self.request, "authtoken", False))) or (self.json is True) self.__authtoken = (bool(getattr(self...
[ "Entry", "point", "for", "this", "class", "here", "we", "decide", "basic", "stuff" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L3004-L3030
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "# Check if this is a webservice request", "self", ".", "json_worker", "=", "(", "bool", "(", "getattr", "(", "self", ".", "request", ",", "\"authtoken\"", ",", "False", ")", ...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenModify.get_form
Set form groups to the groups specified in the view if defined
codenerix/views.py
def get_form(self, form_class=None): ''' Set form groups to the groups specified in the view if defined ''' formobj = super(GenModify, self).get_form(form_class) # Set requested group to this form selfgroups = getattr(self, "form_groups", None) if selfgroups: ...
def get_form(self, form_class=None): ''' Set form groups to the groups specified in the view if defined ''' formobj = super(GenModify, self).get_form(form_class) # Set requested group to this form selfgroups = getattr(self, "form_groups", None) if selfgroups: ...
[ "Set", "form", "groups", "to", "the", "groups", "specified", "in", "the", "view", "if", "defined" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L3316-L3335
[ "def", "get_form", "(", "self", ",", "form_class", "=", "None", ")", ":", "formobj", "=", "super", "(", "GenModify", ",", "self", ")", ".", "get_form", "(", "form_class", ")", "# Set requested group to this form", "selfgroups", "=", "getattr", "(", "self", "...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenDelete.dispatch
Entry point for this class, here we decide basic stuff
codenerix/views.py
def dispatch(self, request, **kwargs): ''' Entry point for this class, here we decide basic stuff ''' # Delete method must happen with POST not with GET if request.method == 'POST': # Check if this is a webservice request self.__authtoken = (bool(getattr(...
def dispatch(self, request, **kwargs): ''' Entry point for this class, here we decide basic stuff ''' # Delete method must happen with POST not with GET if request.method == 'POST': # Check if this is a webservice request self.__authtoken = (bool(getattr(...
[ "Entry", "point", "for", "this", "class", "here", "we", "decide", "basic", "stuff" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L3415-L3432
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "# Delete method must happen with POST not with GET", "if", "request", ".", "method", "==", "'POST'", ":", "# Check if this is a webservice request", "self", ".", "__authtoken", "=", ...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenDetail.dispatch
Entry point for this class, here we decide basic stuff
codenerix/views.py
def dispatch(self, request, **kwargs): ''' Entry point for this class, here we decide basic stuff ''' # Check if this is a REST query to pusth the answer to responde in JSON if bool(self.request.META.get('HTTP_X_REST', False)): self.json = True # Check if th...
def dispatch(self, request, **kwargs): ''' Entry point for this class, here we decide basic stuff ''' # Check if this is a REST query to pusth the answer to responde in JSON if bool(self.request.META.get('HTTP_X_REST', False)): self.json = True # Check if th...
[ "Entry", "point", "for", "this", "class", "here", "we", "decide", "basic", "stuff" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L3490-L3530
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "# Check if this is a REST query to pusth the answer to responde in JSON", "if", "bool", "(", "self", ".", "request", ".", "META", ".", "get", "(", "'HTTP_X_REST'", ",", "False", ...
1f5527b352141caaee902b37b2648791a06bd57d
train
GenDetail.get_filled_structure
method in charged of filling an structure containing the object fields values taking into account the 'group' attribute from the corresponding form object, which is necesary to fill the details form as it is configured in the 'group' attribute
codenerix/views.py
def get_filled_structure(self, subgroup=None): ''' method in charged of filling an structure containing the object fields values taking into account the 'group' attribute from the corresponding form object, which is necesary to fill the details form as it is configured in the 'gr...
def get_filled_structure(self, subgroup=None): ''' method in charged of filling an structure containing the object fields values taking into account the 'group' attribute from the corresponding form object, which is necesary to fill the details form as it is configured in the 'gr...
[ "method", "in", "charged", "of", "filling", "an", "structure", "containing", "the", "object", "fields", "values", "taking", "into", "account", "the", "group", "attribute", "from", "the", "corresponding", "form", "object", "which", "is", "necesary", "to", "fill",...
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L3532-L3668
[ "def", "get_filled_structure", "(", "self", ",", "subgroup", "=", "None", ")", ":", "# initilize the result structure", "result", "=", "[", "]", "# the object corresponding model content is taken into a dictionary", "object_content", "=", "model_to_dict", "(", "self", ".", ...
1f5527b352141caaee902b37b2648791a06bd57d
train
flatatt
Pilfered from `django.forms.utils`: Convert a dictionary of attributes to a single string. The returned string will contain a leading space followed by key="value", XML-style pairs. In the case of a boolean value, the key will appear without a value. Otherwise, the value is formatted through its own dic...
codenerix/djng/widgets.py
def flatatt(attrs): """ Pilfered from `django.forms.utils`: Convert a dictionary of attributes to a single string. The returned string will contain a leading space followed by key="value", XML-style pairs. In the case of a boolean value, the key will appear without a value. Otherwise, the value ...
def flatatt(attrs): """ Pilfered from `django.forms.utils`: Convert a dictionary of attributes to a single string. The returned string will contain a leading space followed by key="value", XML-style pairs. In the case of a boolean value, the key will appear without a value. Otherwise, the value ...
[ "Pilfered", "from", "django", ".", "forms", ".", "utils", ":", "Convert", "a", "dictionary", "of", "attributes", "to", "a", "single", "string", ".", "The", "returned", "string", "will", "contain", "a", "leading", "space", "followed", "by", "key", "=", "val...
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/djng/widgets.py#L11-L41
[ "def", "flatatt", "(", "attrs", ")", ":", "key_value_attrs", "=", "[", "]", "boolean_attrs", "=", "[", "]", "for", "attr", ",", "value", "in", "attrs", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "if", "val...
1f5527b352141caaee902b37b2648791a06bd57d
train
RationalQuadraticKernel._compute_k
r"""Evaluate the kernel directly at the given values of `tau`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. Returns ------- k : :py:class:`Array`, (`M`,) :math:`k(\tau)` (less t...
gptools/kernel/rational_quadratic.py
def _compute_k(self, tau): r"""Evaluate the kernel directly at the given values of `tau`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. Returns ------- k : :py:class:`Array`, (`M`,) ...
def _compute_k(self, tau): r"""Evaluate the kernel directly at the given values of `tau`. Parameters ---------- tau : :py:class:`Matrix`, (`M`, `D`) `M` inputs with dimension `D`. Returns ------- k : :py:class:`Array`, (`M`,) ...
[ "r", "Evaluate", "the", "kernel", "directly", "at", "the", "given", "values", "of", "tau", ".", "Parameters", "----------", "tau", ":", ":", "py", ":", "class", ":", "Matrix", "(", "M", "D", ")", "M", "inputs", "with", "dimension", "D", ".", "Returns",...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/rational_quadratic.py#L74-L88
[ "def", "_compute_k", "(", "self", ",", "tau", ")", ":", "y", "=", "self", ".", "_compute_y", "(", "tau", ")", "return", "y", "**", "(", "-", "self", ".", "params", "[", "1", "]", ")" ]
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
RationalQuadraticKernel._compute_dk_dy
Evaluate the derivative of the outer form of the RQ kernel. Parameters ---------- y : :py:class:`Array`, (`M`,) `M` inputs to evaluate at. n : non-negative scalar int Order of derivative to compute. Returns ------- dk_dy :...
gptools/kernel/rational_quadratic.py
def _compute_dk_dy(self, y, n): """Evaluate the derivative of the outer form of the RQ kernel. Parameters ---------- y : :py:class:`Array`, (`M`,) `M` inputs to evaluate at. n : non-negative scalar int Order of derivative to compute. ...
def _compute_dk_dy(self, y, n): """Evaluate the derivative of the outer form of the RQ kernel. Parameters ---------- y : :py:class:`Array`, (`M`,) `M` inputs to evaluate at. n : non-negative scalar int Order of derivative to compute. ...
[ "Evaluate", "the", "derivative", "of", "the", "outer", "form", "of", "the", "RQ", "kernel", ".", "Parameters", "----------", "y", ":", ":", "py", ":", "class", ":", "Array", "(", "M", ")", "M", "inputs", "to", "evaluate", "at", ".", "n", ":", "non", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/rational_quadratic.py#L116-L132
[ "def", "_compute_dk_dy", "(", "self", ",", "y", ",", "n", ")", ":", "p", "=", "fixed_poch", "(", "1.0", "-", "self", ".", "params", "[", "1", "]", "-", "n", ",", "n", ")", "return", "p", "*", "y", "**", "(", "-", "self", ".", "params", "[", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
Command.get_parent
Given a directory name, return the Page representing it in the menu heirarchy.
wafer/pages/management/commands/load_pages.py
def get_parent(self, directory): """ Given a directory name, return the Page representing it in the menu heirarchy. """ assert settings.PAGE_DIR.startswith('/') assert settings.PAGE_DIR.endswith('/') parents = directory[len(settings.PAGE_DIR):] page = No...
def get_parent(self, directory): """ Given a directory name, return the Page representing it in the menu heirarchy. """ assert settings.PAGE_DIR.startswith('/') assert settings.PAGE_DIR.endswith('/') parents = directory[len(settings.PAGE_DIR):] page = No...
[ "Given", "a", "directory", "name", "return", "the", "Page", "representing", "it", "in", "the", "menu", "heirarchy", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/pages/management/commands/load_pages.py#L24-L38
[ "def", "get_parent", "(", "self", ",", "directory", ")", ":", "assert", "settings", ".", "PAGE_DIR", ".", "startswith", "(", "'/'", ")", "assert", "settings", ".", "PAGE_DIR", ".", "endswith", "(", "'/'", ")", "parents", "=", "directory", "[", "len", "("...
a20af3c399267f76373dc342f4d542a9bc457c35
train
wafer_sso_url
Return the correct URL to SSO with the given method.
wafer/registration/templatetags/wafer_sso.py
def wafer_sso_url(context, sso_method): ''' Return the correct URL to SSO with the given method. ''' request = context.request url = reverse(getattr(views, '%s_login' % sso_method)) if 'next' in request.GET: url += '?' + urlencode({'next': request.GET['next']}) return url
def wafer_sso_url(context, sso_method): ''' Return the correct URL to SSO with the given method. ''' request = context.request url = reverse(getattr(views, '%s_login' % sso_method)) if 'next' in request.GET: url += '?' + urlencode({'next': request.GET['next']}) return url
[ "Return", "the", "correct", "URL", "to", "SSO", "with", "the", "given", "method", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/registration/templatetags/wafer_sso.py#L11-L19
[ "def", "wafer_sso_url", "(", "context", ",", "sso_method", ")", ":", "request", "=", "context", ".", "request", "url", "=", "reverse", "(", "getattr", "(", "views", ",", "'%s_login'", "%", "sso_method", ")", ")", "if", "'next'", "in", "request", ".", "GE...
a20af3c399267f76373dc342f4d542a9bc457c35
train
authorize
Authorizes Coursera's OAuth2 client for using coursera.org API servers for a specific application
courseraoauth2client/commands/config.py
def authorize(args): """ Authorizes Coursera's OAuth2 client for using coursera.org API servers for a specific application """ oauth2_instance = oauth2.build_oauth2(args.app, args) oauth2_instance.build_authorizer() logging.info('Application "%s" authorized!', args.app)
def authorize(args): """ Authorizes Coursera's OAuth2 client for using coursera.org API servers for a specific application """ oauth2_instance = oauth2.build_oauth2(args.app, args) oauth2_instance.build_authorizer() logging.info('Application "%s" authorized!', args.app)
[ "Authorizes", "Coursera", "s", "OAuth2", "client", "for", "using", "coursera", ".", "org", "API", "servers", "for", "a", "specific", "application" ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/commands/config.py#L31-L38
[ "def", "authorize", "(", "args", ")", ":", "oauth2_instance", "=", "oauth2", ".", "build_oauth2", "(", "args", ".", "app", ",", "args", ")", "oauth2_instance", ".", "build_authorizer", "(", ")", "logging", ".", "info", "(", "'Application \"%s\" authorized!'", ...
4edd991defe26bfc768ab28a30368cace40baf44
train
check_auth
Checks courseraoauth2client's connectivity to the coursera.org API servers for a specific application
courseraoauth2client/commands/config.py
def check_auth(args): """ Checks courseraoauth2client's connectivity to the coursera.org API servers for a specific application """ oauth2_instance = oauth2.build_oauth2(args.app, args) auth = oauth2_instance.build_authorizer() my_profile_url = ( 'https://api.coursera.org/api/externa...
def check_auth(args): """ Checks courseraoauth2client's connectivity to the coursera.org API servers for a specific application """ oauth2_instance = oauth2.build_oauth2(args.app, args) auth = oauth2_instance.build_authorizer() my_profile_url = ( 'https://api.coursera.org/api/externa...
[ "Checks", "courseraoauth2client", "s", "connectivity", "to", "the", "coursera", ".", "org", "API", "servers", "for", "a", "specific", "application" ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/commands/config.py#L41-L79
[ "def", "check_auth", "(", "args", ")", ":", "oauth2_instance", "=", "oauth2", ".", "build_oauth2", "(", "args", ".", "app", ",", "args", ")", "auth", "=", "oauth2_instance", ".", "build_authorizer", "(", ")", "my_profile_url", "=", "(", "'https://api.coursera....
4edd991defe26bfc768ab28a30368cace40baf44
train
display_auth_cache
Writes to the screen the state of the authentication cache. (For debugging authentication issues.) BEWARE: DO NOT email the output of this command!!! You must keep the tokens secure. Treat them as passwords.
courseraoauth2client/commands/config.py
def display_auth_cache(args): ''' Writes to the screen the state of the authentication cache. (For debugging authentication issues.) BEWARE: DO NOT email the output of this command!!! You must keep the tokens secure. Treat them as passwords. ''' oauth2_instance = oauth2.build_oauth2(args.app, ar...
def display_auth_cache(args): ''' Writes to the screen the state of the authentication cache. (For debugging authentication issues.) BEWARE: DO NOT email the output of this command!!! You must keep the tokens secure. Treat them as passwords. ''' oauth2_instance = oauth2.build_oauth2(args.app, ar...
[ "Writes", "to", "the", "screen", "the", "state", "of", "the", "authentication", "cache", ".", "(", "For", "debugging", "authentication", "issues", ".", ")", "BEWARE", ":", "DO", "NOT", "email", "the", "output", "of", "this", "command!!!", "You", "must", "k...
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/commands/config.py#L82-L105
[ "def", "display_auth_cache", "(", "args", ")", ":", "oauth2_instance", "=", "oauth2", ".", "build_oauth2", "(", "args", ".", "app", ",", "args", ")", "if", "not", "args", ".", "quiet", ">", "0", ":", "token", "=", "oauth2_instance", ".", "token_cache", "...
4edd991defe26bfc768ab28a30368cace40baf44
train
tanh_warp_arb
r"""Warps the `X` coordinate with the tanh model .. math:: l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w} Parameters ---------- X : :py:class:`Array`, (`M`,) or scalar float `M` locations to evaluate length scale at. l1 : positive float Sma...
gptools/kernel/gibbs.py
def tanh_warp_arb(X, l1, l2, lw, x0): r"""Warps the `X` coordinate with the tanh model .. math:: l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w} Parameters ---------- X : :py:class:`Array`, (`M`,) or scalar float `M` locations to evaluate length sca...
def tanh_warp_arb(X, l1, l2, lw, x0): r"""Warps the `X` coordinate with the tanh model .. math:: l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w} Parameters ---------- X : :py:class:`Array`, (`M`,) or scalar float `M` locations to evaluate length sca...
[ "r", "Warps", "the", "X", "coordinate", "with", "the", "tanh", "model", "..", "math", "::", "l", "=", "\\", "frac", "{", "l_1", "+", "l_2", "}", "{", "2", "}", "-", "\\", "frac", "{", "l_1", "-", "l_2", "}", "{", "2", "}", "\\", "tanh", "\\",...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L37-L67
[ "def", "tanh_warp_arb", "(", "X", ",", "l1", ",", "l2", ",", "lw", ",", "x0", ")", ":", "if", "isinstance", "(", "X", ",", "scipy", ".", "ndarray", ")", ":", "if", "isinstance", "(", "X", ",", "scipy", ".", "matrix", ")", ":", "X", "=", "scipy"...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
gauss_warp_arb
r"""Warps the `X` coordinate with a Gaussian-shaped divot. .. math:: l = l_1 - (l_1 - l_2) \exp\left ( -4\ln 2\frac{(X-x_0)^2}{l_{w}^{2}} \right ) Parameters ---------- X : :py:class:`Array`, (`M`,) or scalar float `M` locations to evaluate length scale at. l1 : po...
gptools/kernel/gibbs.py
def gauss_warp_arb(X, l1, l2, lw, x0): r"""Warps the `X` coordinate with a Gaussian-shaped divot. .. math:: l = l_1 - (l_1 - l_2) \exp\left ( -4\ln 2\frac{(X-x_0)^2}{l_{w}^{2}} \right ) Parameters ---------- X : :py:class:`Array`, (`M`,) or scalar float `M` locatio...
def gauss_warp_arb(X, l1, l2, lw, x0): r"""Warps the `X` coordinate with a Gaussian-shaped divot. .. math:: l = l_1 - (l_1 - l_2) \exp\left ( -4\ln 2\frac{(X-x_0)^2}{l_{w}^{2}} \right ) Parameters ---------- X : :py:class:`Array`, (`M`,) or scalar float `M` locatio...
[ "r", "Warps", "the", "X", "coordinate", "with", "a", "Gaussian", "-", "shaped", "divot", ".", "..", "math", "::", "l", "=", "l_1", "-", "(", "l_1", "-", "l_2", ")", "\\", "exp", "\\", "left", "(", "-", "4", "\\", "ln", "2", "\\", "frac", "{", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L69-L99
[ "def", "gauss_warp_arb", "(", "X", ",", "l1", ",", "l2", ",", "lw", ",", "x0", ")", ":", "if", "isinstance", "(", "X", ",", "scipy", ".", "ndarray", ")", ":", "if", "isinstance", "(", "X", ",", "scipy", ".", "matrix", ")", ":", "X", "=", "scipy...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
tanh_warp
r"""Implements a tanh warping function and its derivative. .. math:: l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w} Parameters ---------- x : float or array of float Locations to evaluate the function at. n : int Derivative order to take. U...
gptools/kernel/gibbs.py
def tanh_warp(x, n, l1, l2, lw, x0): r"""Implements a tanh warping function and its derivative. .. math:: l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w} Parameters ---------- x : float or array of float Locations to evaluate the function at. n ...
def tanh_warp(x, n, l1, l2, lw, x0): r"""Implements a tanh warping function and its derivative. .. math:: l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w} Parameters ---------- x : float or array of float Locations to evaluate the function at. n ...
[ "r", "Implements", "a", "tanh", "warping", "function", "and", "its", "derivative", ".", "..", "math", "::", "l", "=", "\\", "frac", "{", "l_1", "+", "l_2", "}", "{", "2", "}", "-", "\\", "frac", "{", "l_1", "-", "l_2", "}", "{", "2", "}", "\\",...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L401-L438
[ "def", "tanh_warp", "(", "x", ",", "n", ",", "l1", ",", "l2", ",", "lw", ",", "x0", ")", ":", "if", "n", "==", "0", ":", "return", "(", "l1", "+", "l2", ")", "/", "2.0", "-", "(", "l1", "-", "l2", ")", "/", "2.0", "*", "scipy", ".", "ta...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
double_tanh_warp
r"""Implements a sum-of-tanh warping function and its derivative. .. math:: l = a\tanh\frac{x-x_a}{l_a} + b\tanh\frac{x-x_b}{l_b} Parameters ---------- x : float or array of float Locations to evaluate the function at. n : int Derivative order to take. Used for...
gptools/kernel/gibbs.py
def double_tanh_warp(x, n, lcore, lmid, ledge, la, lb, xa, xb): r"""Implements a sum-of-tanh warping function and its derivative. .. math:: l = a\tanh\frac{x-x_a}{l_a} + b\tanh\frac{x-x_b}{l_b} Parameters ---------- x : float or array of float Locations to evaluate the...
def double_tanh_warp(x, n, lcore, lmid, ledge, la, lb, xa, xb): r"""Implements a sum-of-tanh warping function and its derivative. .. math:: l = a\tanh\frac{x-x_a}{l_a} + b\tanh\frac{x-x_b}{l_b} Parameters ---------- x : float or array of float Locations to evaluate the...
[ "r", "Implements", "a", "sum", "-", "of", "-", "tanh", "warping", "function", "and", "its", "derivative", ".", "..", "math", "::", "l", "=", "a", "\\", "tanh", "\\", "frac", "{", "x", "-", "x_a", "}", "{", "l_a", "}", "+", "b", "\\", "tanh", "\...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L479-L528
[ "def", "double_tanh_warp", "(", "x", ",", "n", ",", "lcore", ",", "lmid", ",", "ledge", ",", "la", ",", "lb", ",", "xa", ",", "xb", ")", ":", "a", ",", "b", ",", "c", "=", "scipy", ".", "dot", "(", "[", "[", "-", "0.5", ",", "0", ",", "0....
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
cubic_bucket_warp
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...
gptools/kernel/gibbs.py
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): """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...
[ "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", ":", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L572-L620
[ "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", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
quintic_bucket_warp
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...
gptools/kernel/gibbs.py
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): """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...
[ "Warps", "the", "length", "scale", "with", "a", "piecewise", "quintic", "bucket", "shape", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L660-L723
[ "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"...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
exp_gauss_warp
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...
gptools/kernel/gibbs.py
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): """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 ( -\...
[ "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", ...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L763-L814
[ "def", "exp_gauss_warp", "(", "X", ",", "n", ",", "l0", ",", "*", "msb", ")", ":", "X", "=", "scipy", ".", "asarray", "(", "X", ",", "dtype", "=", "float", ")", "msb", "=", "scipy", ".", "asarray", "(", "msb", ",", "dtype", "=", "float", ")", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
MultipleFieldMixin.get_multiple_choices_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".
codenerix/djng/field_mixins.py
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): """ 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...
[ "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", "." ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/djng/field_mixins.py#L177-L187
[ "def", "get_multiple_choices_required", "(", "self", ")", ":", "errors", "=", "[", "]", "if", "self", ".", "required", ":", "for", "key", ",", "msg", "in", "self", ".", "error_messages", ".", "items", "(", ")", ":", "if", "key", "==", "'required'", ":"...
1f5527b352141caaee902b37b2648791a06bd57d
train
sso
Create a user, if the provided `user` is None, from the parameters. Then log the user in, and return it.
wafer/registration/sso.py
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): """ 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') ...
[ "Create", "a", "user", "if", "the", "provided", "user", "is", "None", "from", "the", "parameters", ".", "Then", "log", "the", "user", "in", "and", "return", "it", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/registration/sso.py#L24-L41
[ "def", "sso", "(", "user", ",", "desired_username", ",", "name", ",", "email", ",", "profile_fields", "=", "None", ")", ":", "if", "not", "user", ":", "if", "not", "settings", ".", "REGISTRATION_OPEN", ":", "raise", "SSOError", "(", "'Account registration is...
a20af3c399267f76373dc342f4d542a9bc457c35
train
parallel_compute_ll_matrix
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...
gptools/gp_utils.py
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): """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...
[ "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",...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gp_utils.py#L45-L117
[ "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", ".",...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
slice_plot
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...
gptools/gp_utils.py
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): """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...
[ "Constructs", "a", "plot", "that", "lets", "you", "look", "at", "slices", "through", "a", "multidimensional", "array", ".", "Parameters", "----------", "vals", ":", "array", "(", "M", "D", "P", "...", ")", "Multidimensional", "array", "to", "visualize", ".",...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gp_utils.py#L134-L236
[ "def", "slice_plot", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "names", "=", "kwargs", ".", "get", "(", "'names'", ",", "None", ")", "n", "=", "kwargs", ".", "get", "(", "'n'", ",", "100", ")", "num_axes", "=", "len", "(", "args", ")...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
arrow_respond
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...
gptools/gp_utils.py
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): """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...
[ "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...
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gp_utils.py#L238-L253
[ "def", "arrow_respond", "(", "slider", ",", "event", ")", ":", "if", "event", ".", "key", "==", "'right'", ":", "slider", ".", "set_val", "(", "min", "(", "slider", ".", "val", "+", "1", ",", "slider", ".", "valmax", ")", ")", "elif", "event", ".",...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
AccountBase.debit
Post a debit of 'amount' and a credit of -amount against this account and credit_account respectively. note amount must be non-negative.
swingtix/bookkeeper/account_api.py
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): """ 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...
[ "Post", "a", "debit", "of", "amount", "and", "a", "credit", "of", "-", "amount", "against", "this", "account", "and", "credit_account", "respectively", "." ]
SwingTix/bookkeeper
python
https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L143-L150
[ "def", "debit", "(", "self", ",", "amount", ",", "credit_account", ",", "description", ",", "debit_memo", "=", "\"\"", ",", "credit_memo", "=", "\"\"", ",", "datetime", "=", "None", ")", ":", "assert", "amount", ">=", "0", "return", "self", ".", "post", ...
2035099fd78b1d0906403ec836a4b7e7144a6bbc
train
AccountBase.credit
Post a credit of 'amount' and a debit of -amount against this account and credit_account respectively. note amount must be non-negative.
swingtix/bookkeeper/account_api.py
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): """ 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...
[ "Post", "a", "credit", "of", "amount", "and", "a", "debit", "of", "-", "amount", "against", "this", "account", "and", "credit_account", "respectively", "." ]
SwingTix/bookkeeper
python
https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L152-L158
[ "def", "credit", "(", "self", ",", "amount", ",", "debit_account", ",", "description", ",", "debit_memo", "=", "\"\"", ",", "credit_memo", "=", "\"\"", ",", "datetime", "=", "None", ")", ":", "assert", "amount", ">=", "0", "return", "self", ".", "post", ...
2035099fd78b1d0906403ec836a4b7e7144a6bbc
train
AccountBase.post
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.
swingtix/bookkeeper/account_api.py
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): """ 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", "." ]
SwingTix/bookkeeper
python
https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L161-L183
[ "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...
2035099fd78b1d0906403ec836a4b7e7144a6bbc
train
AccountBase.balance
returns the account balance as of 'date' (datetime stamp) or now().
swingtix/bookkeeper/account_api.py
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): """ 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() ...
[ "returns", "the", "account", "balance", "as", "of", "date", "(", "datetime", "stamp", ")", "or", "now", "()", "." ]
SwingTix/bookkeeper
python
https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L185-L203
[ "def", "balance", "(", "self", ",", "date", "=", "None", ")", ":", "qs", "=", "self", ".", "_entries", "(", ")", "if", "date", ":", "qs", "=", "qs", ".", "filter", "(", "transaction__t_stamp__lt", "=", "date", ")", "r", "=", "qs", ".", "aggregate",...
2035099fd78b1d0906403ec836a4b7e7144a6bbc
train
AccountBase.totals
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
swingtix/bookkeeper/account_api.py
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): """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...
[ "Returns", "a", "Totals", "object", "containing", "the", "sum", "of", "all", "debits", "credits", "and", "net", "change", "over", "the", "period", "of", "time", "from", "start", "to", "end", "." ]
SwingTix/bookkeeper
python
https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L220-L246
[ "def", "totals", "(", "self", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "qs", "=", "self", ".", "_entries_range", "(", "start", "=", "start", ",", "end", "=", "end", ")", "qs_positive", "=", "qs", ".", "filter", "(", "amount__gt...
2035099fd78b1d0906403ec836a4b7e7144a6bbc
train
AccountBase.ledger
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 ...
swingtix/bookkeeper/account_api.py
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): """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,...
[ "Returns", "a", "list", "of", "entries", "for", "this", "account", "." ]
SwingTix/bookkeeper
python
https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L248-L288
[ "def", "ledger", "(", "self", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "DEBIT_IN_DB", "=", "self", ".", "_DEBIT_IN_DB", "(", ")", "flip", "=", "1", "if", "self", ".", "_positive_credit", "(", ")", ":", "flip", "*=", "-", "1", ...
2035099fd78b1d0906403ec836a4b7e7144a6bbc
train
BookSetBase.get_third_party
Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset.
swingtix/bookkeeper/account_api.py
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): """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...
[ "Return", "the", "account", "for", "the", "given", "third", "-", "party", ".", "Raise", "<something", ">", "if", "the", "third", "party", "doesn", "t", "belong", "to", "this", "bookset", "." ]
SwingTix/bookkeeper
python
https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L371-L375
[ "def", "get_third_party", "(", "self", ",", "third_party", ")", ":", "actual_account", "=", "third_party", ".", "get_account", "(", ")", "assert", "actual_account", ".", "get_bookset", "(", ")", "==", "self", "return", "ThirdPartySubAccount", "(", "actual_account"...
2035099fd78b1d0906403ec836a4b7e7144a6bbc
train
ProjectBase.get_third_party
Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset.
swingtix/bookkeeper/account_api.py
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): """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...
[ "Return", "the", "account", "for", "the", "given", "third", "-", "party", ".", "Raise", "<something", ">", "if", "the", "third", "party", "doesn", "t", "belong", "to", "this", "bookset", "." ]
SwingTix/bookkeeper
python
https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L392-L397
[ "def", "get_third_party", "(", "self", ",", "third_party", ")", ":", "actual_account", "=", "third_party", ".", "get_account", "(", ")", "assert", "actual_account", ".", "get_bookset", "(", ")", "==", "self", ".", "get_bookset", "(", ")", "return", "ProjectAcc...
2035099fd78b1d0906403ec836a4b7e7144a6bbc
train
find_overlapping_slots
Find any slots that overlap
wafer/schedule/admin.py
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): """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...
[ "Find", "any", "slots", "that", "overlap" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L24-L51
[ "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", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
find_non_contiguous
Find any items that have slots that aren't contiguous
wafer/schedule/admin.py
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): """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...
[ "Find", "any", "items", "that", "have", "slots", "that", "aren", "t", "contiguous" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L55-L69
[ "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...
a20af3c399267f76373dc342f4d542a9bc457c35
train
validate_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
wafer/schedule/admin.py
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): """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...
[ "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...
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L72-L86
[ "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", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
find_duplicate_schedule_items
Find talks / pages assigned to mulitple schedule items
wafer/schedule/admin.py
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): """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: ...
[ "Find", "talks", "/", "pages", "assigned", "to", "mulitple", "schedule", "items" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L89-L103
[ "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...
a20af3c399267f76373dc342f4d542a9bc457c35
train
find_clashes
Find schedule items which clash (common slot and venue)
wafer/schedule/admin.py
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): """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]...
[ "Find", "schedule", "items", "which", "clash", "(", "common", "slot", "and", "venue", ")" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L106-L120
[ "def", "find_clashes", "(", "all_items", ")", ":", "clashes", "=", "{", "}", "seen_venue_slots", "=", "{", "}", "for", "item", "in", "all_items", ":", "for", "slot", "in", "item", ".", "slots", ".", "all", "(", ")", ":", "pos", "=", "(", "item", "....
a20af3c399267f76373dc342f4d542a9bc457c35
train
find_invalid_venues
Find venues assigned slots that aren't on the allowed list of days.
wafer/schedule/admin.py
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): """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: ...
[ "Find", "venues", "assigned", "slots", "that", "aren", "t", "on", "the", "allowed", "list", "of", "days", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L123-L138
[ "def", "find_invalid_venues", "(", "all_items", ")", ":", "venues", "=", "{", "}", "for", "item", "in", "all_items", ":", "valid", "=", "False", "item_days", "=", "list", "(", "item", ".", "venue", ".", "days", ".", "all", "(", ")", ")", "for", "slot...
a20af3c399267f76373dc342f4d542a9bc457c35
train
check_schedule
Helper routine to easily test if the schedule is valid
wafer/schedule/admin.py
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(): """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_...
[ "Helper", "routine", "to", "easily", "test", "if", "the", "schedule", "is", "valid" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L196-L207
[ "def", "check_schedule", "(", ")", ":", "all_items", "=", "prefetch_schedule_items", "(", ")", "for", "validator", ",", "_type", ",", "_msg", "in", "SCHEDULE_ITEM_VALIDATORS", ":", "if", "validator", "(", "all_items", ")", ":", "return", "False", "all_slots", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
validate_schedule
Helper routine to report issues with the schedule
wafer/schedule/admin.py
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(): """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, _...
[ "Helper", "routine", "to", "report", "issues", "with", "the", "schedule" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L210-L222
[ "def", "validate_schedule", "(", ")", ":", "all_items", "=", "prefetch_schedule_items", "(", ")", "errors", "=", "[", "]", "for", "validator", ",", "_type", ",", "msg", "in", "SCHEDULE_ITEM_VALIDATORS", ":", "if", "validator", "(", "all_items", ")", ":", "er...
a20af3c399267f76373dc342f4d542a9bc457c35
train
SlotAdmin.get_form
Change the form depending on whether we're adding or editing the slot.
wafer/schedule/admin.py
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): """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)
[ "Change", "the", "form", "depending", "on", "whether", "we", "re", "adding", "or", "editing", "the", "slot", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L457-L463
[ "def", "get_form", "(", "self", ",", "request", ",", "obj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "obj", "is", "None", ":", "# Adding a new Slot", "kwargs", "[", "'form'", "]", "=", "SlotAdminAddForm", "return", "super", "(", "SlotAdmin",...
a20af3c399267f76373dc342f4d542a9bc457c35
train
get_cached_menus
Return the menus from the cache or generate them if needed.
wafer/menu.py
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(): """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
[ "Return", "the", "menus", "from", "the", "cache", "or", "generate", "them", "if", "needed", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/menu.py#L12-L20
[ "def", "get_cached_menus", "(", ")", ":", "items", "=", "cache", ".", "get", "(", "CACHE_KEY", ")", "if", "items", "is", "None", ":", "menu", "=", "generate_menu", "(", ")", "cache", ".", "set", "(", "CACHE_KEY", ",", "menu", ".", "items", ")", "else...
a20af3c399267f76373dc342f4d542a9bc457c35
train
maybe_obj
If argument is not a string, return it. Otherwise import the dotted name and return that.
wafer/menu.py
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 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 ...
[ "If", "argument", "is", "not", "a", "string", "return", "it", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/menu.py#L44-L64
[ "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...
a20af3c399267f76373dc342f4d542a9bc457c35
train
generate_menu
Generate a new list of menus.
wafer/menu.py
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(): """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
[ "Generate", "a", "new", "list", "of", "menus", "." ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/menu.py#L67-L73
[ "def", "generate_menu", "(", ")", ":", "root_menu", "=", "Menu", "(", "list", "(", "copy", ".", "deepcopy", "(", "settings", ".", "WAFER_MENUS", ")", ")", ")", "for", "dynamic_menu_func", "in", "settings", ".", "WAFER_DYNAMIC_MENUS", ":", "dynamic_menu_func", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
pylock.lock
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
codenerix/lib/pylock.py
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): ''' 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...
[ "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...
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/lib/pylock.py#L70-L89
[ "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", ...
1f5527b352141caaee902b37b2648791a06bd57d
train
_make_handler
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.
courseraoauth2client/oauth2.py
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): ''' 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...
[ "Makes", "a", "a", "handler", "class", "to", "use", "inside", "the", "basic", "python", "HTTP", "server", "." ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L105-L151
[ "def", "_make_handler", "(", "state_token", ",", "done_function", ")", ":", "class", "LocalServerHandler", "(", "BaseHTTPServer", ".", "BaseHTTPRequestHandler", ")", ":", "def", "error_response", "(", "self", ",", "msg", ")", ":", "logging", ".", "warn", "(", ...
4edd991defe26bfc768ab28a30368cace40baf44
train
configuration
Loads configuration from the file system.
courseraoauth2client/oauth2.py
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(): '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...
[ "Loads", "configuration", "from", "the", "file", "system", "." ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L522-L551
[ "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...
4edd991defe26bfc768ab28a30368cace40baf44
train
CourseraOAuth2._load_token_cache
Reads the local fs cache for pre-authorized access tokens
courseraoauth2client/oauth2.py
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): '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...
[ "Reads", "the", "local", "fs", "cache", "for", "pre", "-", "authorized", "access", "tokens" ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L230-L253
[ "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",...
4edd991defe26bfc768ab28a30368cace40baf44
train
CourseraOAuth2._save_token_cache
Write out to the filesystem a cache of the OAuth2 information.
courseraoauth2client/oauth2.py
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): '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) ...
[ "Write", "out", "to", "the", "filesystem", "a", "cache", "of", "the", "OAuth2", "information", "." ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L255-L270
[ "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", ...
4edd991defe26bfc768ab28a30368cace40baf44
train
CourseraOAuth2._check_token_cache_type
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.
courseraoauth2client/oauth2.py
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): ''' 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_...
[ "Checks", "the", "cache_value", "for", "appropriate", "type", "correctness", "." ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L272-L300
[ "def", "_check_token_cache_type", "(", "self", ",", "cache_value", ")", ":", "def", "check_string_value", "(", "name", ")", ":", "return", "(", "isinstance", "(", "cache_value", "[", "name", "]", ",", "str", ")", "or", "isinstance", "(", "cache_value", "[", ...
4edd991defe26bfc768ab28a30368cace40baf44
train
CourseraOAuth2._authorize_new_tokens
Stands up a new localhost http server and retrieves new OAuth2 access tokens from the Coursera OAuth2 server.
courseraoauth2client/oauth2.py
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): ''' 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...
[ "Stands", "up", "a", "new", "localhost", "http", "server", "and", "retrieves", "new", "OAuth2", "access", "tokens", "from", "the", "Coursera", "OAuth2", "server", "." ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L369-L415
[ "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", ...
4edd991defe26bfc768ab28a30368cace40baf44
train
CourseraOAuth2._exchange_refresh_tokens
Exchanges a refresh token for an access token
courseraoauth2client/oauth2.py
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): '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', ...
[ "Exchanges", "a", "refresh", "token", "for", "an", "access", "token" ]
coursera/courseraoauth2client
python
https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/oauth2.py#L417-L434
[ "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...
4edd991defe26bfc768ab28a30368cace40baf44
train
foreignkey
function to determine if each select field needs a create button or not
codenerix/templatetags/codenerix_lists.py
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): ''' 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...
[ "function", "to", "determine", "if", "each", "select", "field", "needs", "a", "create", "button", "or", "not" ]
codenerix/django-codenerix
python
https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/templatetags/codenerix_lists.py#L218-L230
[ "def", "foreignkey", "(", "element", ",", "exceptions", ")", ":", "label", "=", "element", ".", "field", ".", "__dict__", "[", "'label'", "]", "try", ":", "label", "=", "unicode", "(", "label", ")", "except", "NameError", ":", "pass", "if", "(", "not",...
1f5527b352141caaee902b37b2648791a06bd57d
train
deserialize_by_field
Some types get serialized to JSON, as strings. If we know what they are supposed to be, we can deserialize them
wafer/kv/utils.py
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): """ 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 ...
[ "Some", "types", "get", "serialized", "to", "JSON", "as", "strings", ".", "If", "we", "know", "what", "they", "are", "supposed", "to", "be", "we", "can", "deserialize", "them" ]
CTPUG/wafer
python
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/kv/utils.py#L5-L16
[ "def", "deserialize_by_field", "(", "value", ",", "field", ")", ":", "if", "isinstance", "(", "field", ",", "forms", ".", "DateTimeField", ")", ":", "value", "=", "parse_datetime", "(", "value", ")", "elif", "isinstance", "(", "field", ",", "forms", ".", ...
a20af3c399267f76373dc342f4d542a9bc457c35
train
GaussianProcess.hyperprior
Combined hyperprior for the kernel, noise kernel and (if present) mean function.
gptools/gaussian_process.py
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): """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
[ "Combined", "hyperprior", "for", "the", "kernel", "noise", "kernel", "and", "(", "if", "present", ")", "mean", "function", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L247-L253
[ "def", "hyperprior", "(", "self", ")", ":", "hp", "=", "self", ".", "k", ".", "hyperprior", "*", "self", ".", "noise_k", ".", "hyperprior", "if", "self", ".", "mu", "is", "not", "None", ":", "hp", "*=", "self", ".", "mu", ".", "hyperprior", "return...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
GaussianProcess.fixed_params
Combined fixed hyperparameter flags for the kernel, noise kernel and (if present) mean function.
gptools/gaussian_process.py
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): """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...
[ "Combined", "fixed", "hyperparameter", "flags", "for", "the", "kernel", "noise", "kernel", "and", "(", "if", "present", ")", "mean", "function", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L261-L267
[ "def", "fixed_params", "(", "self", ")", ":", "fp", "=", "CombinedBounds", "(", "self", ".", "k", ".", "fixed_params", ",", "self", ".", "noise_k", ".", "fixed_params", ")", "if", "self", ".", "mu", "is", "not", "None", ":", "fp", "=", "CombinedBounds"...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
GaussianProcess.params
Combined hyperparameters for the kernel, noise kernel and (if present) mean function.
gptools/gaussian_process.py
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): """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
[ "Combined", "hyperparameters", "for", "the", "kernel", "noise", "kernel", "and", "(", "if", "present", ")", "mean", "function", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L278-L284
[ "def", "params", "(", "self", ")", ":", "p", "=", "CombinedBounds", "(", "self", ".", "k", ".", "params", ",", "self", ".", "noise_k", ".", "params", ")", "if", "self", ".", "mu", "is", "not", "None", ":", "p", "=", "CombinedBounds", "(", "p", ",...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
GaussianProcess.param_names
Combined names for the hyperparameters for the kernel, noise kernel and (if present) mean function.
gptools/gaussian_process.py
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): """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...
[ "Combined", "names", "for", "the", "hyperparameters", "for", "the", "kernel", "noise", "kernel", "and", "(", "if", "present", ")", "mean", "function", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L306-L312
[ "def", "param_names", "(", "self", ")", ":", "pn", "=", "CombinedBounds", "(", "self", ".", "k", ".", "param_names", ",", "self", ".", "noise_k", ".", "param_names", ")", "if", "self", ".", "mu", "is", "not", "None", ":", "pn", "=", "CombinedBounds", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
GaussianProcess.free_params
Combined free hyperparameters for the kernel, noise kernel and (if present) mean function.
gptools/gaussian_process.py
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): """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
[ "Combined", "free", "hyperparameters", "for", "the", "kernel", "noise", "kernel", "and", "(", "if", "present", ")", "mean", "function", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L322-L328
[ "def", "free_params", "(", "self", ")", ":", "p", "=", "CombinedBounds", "(", "self", ".", "k", ".", "free_params", ",", "self", ".", "noise_k", ".", "free_params", ")", "if", "self", ".", "mu", "is", "not", "None", ":", "p", "=", "CombinedBounds", "...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
GaussianProcess.free_params
Set the free parameters. Note that this bypasses enforce_bounds.
gptools/gaussian_process.py
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): """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...
[ "Set", "the", "free", "parameters", ".", "Note", "that", "this", "bypasses", "enforce_bounds", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L331-L339
[ "def", "free_params", "(", "self", ",", "value", ")", ":", "value", "=", "scipy", ".", "asarray", "(", "value", ",", "dtype", "=", "float", ")", "self", ".", "K_up_to_date", "=", "False", "self", ".", "k", ".", "free_params", "=", "value", "[", ":", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
GaussianProcess.free_param_bounds
Combined free hyperparameter bounds for the kernel, noise kernel and (if present) mean function.
gptools/gaussian_process.py
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): """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...
[ "Combined", "free", "hyperparameter", "bounds", "for", "the", "kernel", "noise", "kernel", "and", "(", "if", "present", ")", "mean", "function", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L342-L348
[ "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", "=", ...
225db52bfe6baef1516529ad22177aa2cf7b71e4
train
GaussianProcess.free_param_names
Combined free hyperparameter names for the kernel, noise kernel and (if present) mean function.
gptools/gaussian_process.py
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): """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...
[ "Combined", "free", "hyperparameter", "names", "for", "the", "kernel", "noise", "kernel", "and", "(", "if", "present", ")", "mean", "function", "." ]
markchil/gptools
python
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gaussian_process.py#L359-L365
[ "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...
225db52bfe6baef1516529ad22177aa2cf7b71e4