repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
ff0000/scarlet
scarlet/cms/item.py
PreviewWrapper.get
def get(self, request, *args, **kwargs): """ Method for handling GET requests. Sets the renderer to be a RenderResponse instance that uses `default_template` as the template. The `preview_view` callable is called and passed to `render` method as the data keyword argument...
python
def get(self, request, *args, **kwargs): """ Method for handling GET requests. Sets the renderer to be a RenderResponse instance that uses `default_template` as the template. The `preview_view` callable is called and passed to `render` method as the data keyword argument...
[ "def", "get", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "renders", "=", "{", "'response'", ":", "renders", ".", "RenderResponse", "(", "template", "=", "self", ".", "default_template", ")", ",", "}...
Method for handling GET requests. Sets the renderer to be a RenderResponse instance that uses `default_template` as the template. The `preview_view` callable is called and passed to `render` method as the data keyword argument.
[ "Method", "for", "handling", "GET", "requests", ".", "Sets", "the", "renderer", "to", "be", "a", "RenderResponse", "instance", "that", "uses", "default_template", "as", "the", "template", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/item.py#L609-L624
ff0000/scarlet
scarlet/cms/item.py
VersionsList.get
def get(self, request, *args, **kwargs): """ Method for handling GET requests. Passes the following arguments to the context: * **versions** - The versions available for this object.\ These will be instances of the inner version class, and \ will not have access to the f...
python
def get(self, request, *args, **kwargs): """ Method for handling GET requests. Passes the following arguments to the context: * **versions** - The versions available for this object.\ These will be instances of the inner version class, and \ will not have access to the f...
[ "def", "get", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "versions", "=", "self", ".", "_get_versions", "(", ")", "return", "self", ".", "render", "(", "request", ",", "obj", "=", "self", ".", "object", ",", ...
Method for handling GET requests. Passes the following arguments to the context: * **versions** - The versions available for this object.\ These will be instances of the inner version class, and \ will not have access to the fields on the base model. * **done_url** - The result ...
[ "Method", "for", "handling", "GET", "requests", ".", "Passes", "the", "following", "arguments", "to", "the", "context", ":" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/item.py#L644-L656
ff0000/scarlet
scarlet/cms/item.py
VersionsList.revert
def revert(self, version, url): """ Set the given version to be the active draft. This is done by calling the object's `make_draft` method. Logs the revert as a 'save' and messages the user. """ message = "Draft replaced with %s version. This revert has not been published...
python
def revert(self, version, url): """ Set the given version to be the active draft. This is done by calling the object's `make_draft` method. Logs the revert as a 'save' and messages the user. """ message = "Draft replaced with %s version. This revert has not been published...
[ "def", "revert", "(", "self", ",", "version", ",", "url", ")", ":", "message", "=", "\"Draft replaced with %s version. This revert has not been published.\"", "%", "version", ".", "date_published", "version", ".", "make_draft", "(", ")", "# Log action as a save", "self"...
Set the given version to be the active draft. This is done by calling the object's `make_draft` method. Logs the revert as a 'save' and messages the user.
[ "Set", "the", "given", "version", "to", "be", "the", "active", "draft", ".", "This", "is", "done", "by", "calling", "the", "object", "s", "make_draft", "method", ".", "Logs", "the", "revert", "as", "a", "save", "and", "messages", "the", "user", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/item.py#L658-L669
ff0000/scarlet
scarlet/cms/item.py
VersionsList.delete
def delete(self, version): """ Deletes the given version, not the object itself. No log entry is generated but the user is notified with a message. """ # Shouldn't be able to delete live or draft version if version.state != version.DRAFT and \ ...
python
def delete(self, version): """ Deletes the given version, not the object itself. No log entry is generated but the user is notified with a message. """ # Shouldn't be able to delete live or draft version if version.state != version.DRAFT and \ ...
[ "def", "delete", "(", "self", ",", "version", ")", ":", "# Shouldn't be able to delete live or draft version", "if", "version", ".", "state", "!=", "version", ".", "DRAFT", "and", "version", ".", "state", "!=", "version", ".", "PUBLISHED", ":", "version", ".", ...
Deletes the given version, not the object itself. No log entry is generated but the user is notified with a message.
[ "Deletes", "the", "given", "version", "not", "the", "object", "itself", ".", "No", "log", "entry", "is", "generated", "but", "the", "user", "is", "notified", "with", "a", "message", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/item.py#L671-L682
ff0000/scarlet
scarlet/cms/item.py
VersionsList.post
def post(self, request, *args, **kwargs): """ Method for handling POST requests. Expects the 'vid' of the version to act on to be passed as in the POST variable 'version'. If a POST variable 'revert' is present this will call the revert method and then return a 'render ...
python
def post(self, request, *args, **kwargs): """ Method for handling POST requests. Expects the 'vid' of the version to act on to be passed as in the POST variable 'version'. If a POST variable 'revert' is present this will call the revert method and then return a 'render ...
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "versions", "=", "self", ".", "_get_versions", "(", ")", "url", "=", "self", ".", "get_done_url", "(", ")", "msg", "=", "None", "try", ":", "vid", "=...
Method for handling POST requests. Expects the 'vid' of the version to act on to be passed as in the POST variable 'version'. If a POST variable 'revert' is present this will call the revert method and then return a 'render redirect' to the result of the `get_done_url` method. ...
[ "Method", "for", "handling", "POST", "requests", ".", "Expects", "the", "vid", "of", "the", "version", "to", "act", "on", "to", "be", "passed", "as", "in", "the", "POST", "variable", "version", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/item.py#L684-L725
inveniosoftware/invenio-collections
invenio_collections/models.py
Collection.validate_parent_id
def validate_parent_id(self, key, parent_id): """Parent has to be different from itself.""" id_ = getattr(self, 'id', None) if id_ is not None and parent_id is not None: assert id_ != parent_id, 'Can not be attached to itself.' return parent_id
python
def validate_parent_id(self, key, parent_id): """Parent has to be different from itself.""" id_ = getattr(self, 'id', None) if id_ is not None and parent_id is not None: assert id_ != parent_id, 'Can not be attached to itself.' return parent_id
[ "def", "validate_parent_id", "(", "self", ",", "key", ",", "parent_id", ")", ":", "id_", "=", "getattr", "(", "self", ",", "'id'", ",", "None", ")", "if", "id_", "is", "not", "None", "and", "parent_id", "is", "not", "None", ":", "assert", "id_", "!="...
Parent has to be different from itself.
[ "Parent", "has", "to", "be", "different", "from", "itself", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/models.py#L50-L55
camsci/meteor-pi
src/pythonModules/meteorpi_client/meteorpi_client/__init__.py
_to_encoded_string
def _to_encoded_string(o): """ Build an encoded string suitable for use as a URL component. This includes double-escaping the string to avoid issues with escaped backslash characters being automatically converted by WSGI or, in some cases such as default Apache servers, blocked entirely. :param o: ...
python
def _to_encoded_string(o): """ Build an encoded string suitable for use as a URL component. This includes double-escaping the string to avoid issues with escaped backslash characters being automatically converted by WSGI or, in some cases such as default Apache servers, blocked entirely. :param o: ...
[ "def", "_to_encoded_string", "(", "o", ")", ":", "_dict", "=", "o", ".", "__dict__", "if", "o", ".", "as_dict", ":", "_dict", "=", "o", ".", "as_dict", "(", ")", "return", "urllib", ".", "quote_plus", "(", "urllib", ".", "quote_plus", "(", "json", "....
Build an encoded string suitable for use as a URL component. This includes double-escaping the string to avoid issues with escaped backslash characters being automatically converted by WSGI or, in some cases such as default Apache servers, blocked entirely. :param o: an object of any kind, if it has an as_...
[ "Build", "an", "encoded", "string", "suitable", "for", "use", "as", "a", "URL", "component", ".", "This", "includes", "double", "-", "escaping", "the", "string", "to", "avoid", "issues", "with", "escaped", "backslash", "characters", "being", "automatically", "...
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_client/meteorpi_client/__init__.py#L37-L50
camsci/meteor-pi
src/pythonModules/meteorpi_client/meteorpi_client/__init__.py
MeteorClient.list_observatories
def list_observatories(self): """ Get the IDs of all observatories with have stored observations on this server. :return: a sequence of strings containing observatories IDs """ response = requests.get(self.base_url + '/obstories').text return safe_load(response)
python
def list_observatories(self): """ Get the IDs of all observatories with have stored observations on this server. :return: a sequence of strings containing observatories IDs """ response = requests.get(self.base_url + '/obstories').text return safe_load(response)
[ "def", "list_observatories", "(", "self", ")", ":", "response", "=", "requests", ".", "get", "(", "self", ".", "base_url", "+", "'/obstories'", ")", ".", "text", "return", "safe_load", "(", "response", ")" ]
Get the IDs of all observatories with have stored observations on this server. :return: a sequence of strings containing observatories IDs
[ "Get", "the", "IDs", "of", "all", "observatories", "with", "have", "stored", "observations", "on", "this", "server", "." ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_client/meteorpi_client/__init__.py#L69-L76
camsci/meteor-pi
src/pythonModules/meteorpi_client/meteorpi_client/__init__.py
MeteorClient.get_observatory_status
def get_observatory_status(self, observatory_id, status_time=None): """ Get details of the specified camera's status :param string observatory_id: a observatory ID, as returned by list_observatories() :param float status_time: optional, if specified attempts to g...
python
def get_observatory_status(self, observatory_id, status_time=None): """ Get details of the specified camera's status :param string observatory_id: a observatory ID, as returned by list_observatories() :param float status_time: optional, if specified attempts to g...
[ "def", "get_observatory_status", "(", "self", ",", "observatory_id", ",", "status_time", "=", "None", ")", ":", "if", "status_time", "is", "None", ":", "response", "=", "requests", ".", "get", "(", "self", ".", "base_url", "+", "'/obstory/{0}/statusdict'", "."...
Get details of the specified camera's status :param string observatory_id: a observatory ID, as returned by list_observatories() :param float status_time: optional, if specified attempts to get the status for the given camera at a particular point in time specified a...
[ "Get", "details", "of", "the", "specified", "camera", "s", "status" ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_client/meteorpi_client/__init__.py#L78-L101
camsci/meteor-pi
src/pythonModules/meteorpi_client/meteorpi_client/__init__.py
MeteorClient.search_observations
def search_observations(self, search=None): """ Search for observations, returning an Observation object for each result. FileRecords within result Observations have two additional methods patched into them, get_url() and download_to(file_name), which will retrieve the URL for the file c...
python
def search_observations(self, search=None): """ Search for observations, returning an Observation object for each result. FileRecords within result Observations have two additional methods patched into them, get_url() and download_to(file_name), which will retrieve the URL for the file c...
[ "def", "search_observations", "(", "self", ",", "search", "=", "None", ")", ":", "if", "search", "is", "None", ":", "search", "=", "model", ".", "ObservationSearch", "(", ")", "search_string", "=", "_to_encoded_string", "(", "search", ")", "url", "=", "sel...
Search for observations, returning an Observation object for each result. FileRecords within result Observations have two additional methods patched into them, get_url() and download_to(file_name), which will retrieve the URL for the file content and download that content to a named file on disk, respec...
[ "Search", "for", "observations", "returning", "an", "Observation", "object", "for", "each", "result", ".", "FileRecords", "within", "result", "Observations", "have", "two", "additional", "methods", "patched", "into", "them", "get_url", "()", "and", "download_to", ...
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_client/meteorpi_client/__init__.py#L103-L131
camsci/meteor-pi
src/pythonModules/meteorpi_client/meteorpi_client/__init__.py
MeteorClient.search_files
def search_files(self, search=None): """ Search for files, returning a FileRecord for each result. FileRecords have two additional methods patched into them, get_url() and download_to(file_name), which will retrieve the URL for the file content and download that content to a named file o...
python
def search_files(self, search=None): """ Search for files, returning a FileRecord for each result. FileRecords have two additional methods patched into them, get_url() and download_to(file_name), which will retrieve the URL for the file content and download that content to a named file o...
[ "def", "search_files", "(", "self", ",", "search", "=", "None", ")", ":", "if", "search", "is", "None", ":", "search", "=", "model", ".", "FileRecordSearch", "(", ")", "search_string", "=", "_to_encoded_string", "(", "search", ")", "url", "=", "self", "....
Search for files, returning a FileRecord for each result. FileRecords have two additional methods patched into them, get_url() and download_to(file_name), which will retrieve the URL for the file content and download that content to a named file on disk, respectively. :param FileRecordSearch se...
[ "Search", "for", "files", "returning", "a", "FileRecord", "for", "each", "result", ".", "FileRecords", "have", "two", "additional", "methods", "patched", "into", "them", "get_url", "()", "and", "download_to", "(", "file_name", ")", "which", "will", "retrieve", ...
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_client/meteorpi_client/__init__.py#L133-L158
camsci/meteor-pi
src/pythonModules/meteorpi_client/meteorpi_client/__init__.py
MeteorClient._augment_file
def _augment_file(self, f): """ Augment a FileRecord with methods to get the data URL and to download, returning the updated file for use in generator functions :internal: """ def get_url(target): if target.file_size is None: return None ...
python
def _augment_file(self, f): """ Augment a FileRecord with methods to get the data URL and to download, returning the updated file for use in generator functions :internal: """ def get_url(target): if target.file_size is None: return None ...
[ "def", "_augment_file", "(", "self", ",", "f", ")", ":", "def", "get_url", "(", "target", ")", ":", "if", "target", ".", "file_size", "is", "None", ":", "return", "None", "if", "target", ".", "file_name", "is", "not", "None", ":", "return", "self", "...
Augment a FileRecord with methods to get the data URL and to download, returning the updated file for use in generator functions :internal:
[ "Augment", "a", "FileRecord", "with", "methods", "to", "get", "the", "data", "URL", "and", "to", "download", "returning", "the", "updated", "file", "for", "use", "in", "generator", "functions", ":", "internal", ":" ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_client/meteorpi_client/__init__.py#L160-L188
camsci/meteor-pi
src/pythonModules/meteorpi_client/meteorpi_client/__init__.py
MeteorClient._augment_observation_files
def _augment_observation_files(self, e): """ Augment all the file records in an event :internal: """ e.file_records = [self._augment_file(f) for f in e.file_records] return e
python
def _augment_observation_files(self, e): """ Augment all the file records in an event :internal: """ e.file_records = [self._augment_file(f) for f in e.file_records] return e
[ "def", "_augment_observation_files", "(", "self", ",", "e", ")", ":", "e", ".", "file_records", "=", "[", "self", ".", "_augment_file", "(", "f", ")", "for", "f", "in", "e", ".", "file_records", "]", "return", "e" ]
Augment all the file records in an event :internal:
[ "Augment", "all", "the", "file", "records", "in", "an", "event", ":", "internal", ":" ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_client/meteorpi_client/__init__.py#L190-L196
edaniszewski/bison
bison/scheme.py
Scheme.build_defaults
def build_defaults(self): """Build a dictionary of default values from the `Scheme`. Returns: dict: The default configurations as set by the `Scheme`. Raises: errors.InvalidSchemeError: The `Scheme` does not contain valid options. """ def...
python
def build_defaults(self): """Build a dictionary of default values from the `Scheme`. Returns: dict: The default configurations as set by the `Scheme`. Raises: errors.InvalidSchemeError: The `Scheme` does not contain valid options. """ def...
[ "def", "build_defaults", "(", "self", ")", ":", "defaults", "=", "{", "}", "for", "arg", "in", "self", ".", "args", ":", "if", "not", "isinstance", "(", "arg", ",", "_BaseOpt", ")", ":", "raise", "errors", ".", "InvalidSchemeError", "(", "'Unable to buil...
Build a dictionary of default values from the `Scheme`. Returns: dict: The default configurations as set by the `Scheme`. Raises: errors.InvalidSchemeError: The `Scheme` does not contain valid options.
[ "Build", "a", "dictionary", "of", "default", "values", "from", "the", "Scheme", "." ]
train
https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/scheme.py#L44-L70
edaniszewski/bison
bison/scheme.py
Scheme.flatten
def flatten(self): """Flatten the scheme into a dictionary where the keys are compound 'dot' notation keys, and the values are the corresponding options. Returns: dict: The flattened `Scheme`. """ if self._flat is None: flat = {} for a...
python
def flatten(self): """Flatten the scheme into a dictionary where the keys are compound 'dot' notation keys, and the values are the corresponding options. Returns: dict: The flattened `Scheme`. """ if self._flat is None: flat = {} for a...
[ "def", "flatten", "(", "self", ")", ":", "if", "self", ".", "_flat", "is", "None", ":", "flat", "=", "{", "}", "for", "arg", "in", "self", ".", "args", ":", "if", "isinstance", "(", "arg", ",", "Option", ")", ":", "flat", "[", "arg", ".", "name...
Flatten the scheme into a dictionary where the keys are compound 'dot' notation keys, and the values are the corresponding options. Returns: dict: The flattened `Scheme`.
[ "Flatten", "the", "scheme", "into", "a", "dictionary", "where", "the", "keys", "are", "compound", "dot", "notation", "keys", "and", "the", "values", "are", "the", "corresponding", "options", "." ]
train
https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/scheme.py#L72-L96
edaniszewski/bison
bison/scheme.py
Scheme.validate
def validate(self, config): """Validate the given config against the `Scheme`. Args: config (dict): The configuration to validate. Raises: errors.SchemeValidationError: The configuration fails validation against the `Schema`. """ if not i...
python
def validate(self, config): """Validate the given config against the `Scheme`. Args: config (dict): The configuration to validate. Raises: errors.SchemeValidationError: The configuration fails validation against the `Schema`. """ if not i...
[ "def", "validate", "(", "self", ",", "config", ")", ":", "if", "not", "isinstance", "(", "config", ",", "dict", ")", ":", "raise", "errors", ".", "SchemeValidationError", "(", "'Scheme can only validate a dictionary config, but was given '", "'{} (type: {})'", ".", ...
Validate the given config against the `Scheme`. Args: config (dict): The configuration to validate. Raises: errors.SchemeValidationError: The configuration fails validation against the `Schema`.
[ "Validate", "the", "given", "config", "against", "the", "Scheme", "." ]
train
https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/scheme.py#L98-L126
edaniszewski/bison
bison/scheme.py
Option.cast
def cast(self, value): """Cast a value to the type required by the option, if one is set. This is used to cast the string values gathered from environment variable into their required type. Args: value: The value to cast. Returns: The value casted to th...
python
def cast(self, value): """Cast a value to the type required by the option, if one is set. This is used to cast the string values gathered from environment variable into their required type. Args: value: The value to cast. Returns: The value casted to th...
[ "def", "cast", "(", "self", ",", "value", ")", ":", "# if there is no type set for the option, return the given", "# value unchanged.", "if", "self", ".", "type", "is", "None", ":", "return", "value", "# cast directly", "if", "self", ".", "type", "in", "(", "str",...
Cast a value to the type required by the option, if one is set. This is used to cast the string values gathered from environment variable into their required type. Args: value: The value to cast. Returns: The value casted to the expected type for the option.
[ "Cast", "a", "value", "to", "the", "type", "required", "by", "the", "option", "if", "one", "is", "set", "." ]
train
https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/scheme.py#L259-L292
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
geometricmean
def geometricmean(inlist): """ Calculates the geometric mean of the values in the passed list. That is: n-th root of (x1 * x2 * ... * xn). Assumes a '1D' list. Usage: lgeometricmean(inlist) """ mult = 1.0 one_over_n = 1.0 / len(inlist) for item in inlist: mult = mult * pow(item, one_over_n)...
python
def geometricmean(inlist): """ Calculates the geometric mean of the values in the passed list. That is: n-th root of (x1 * x2 * ... * xn). Assumes a '1D' list. Usage: lgeometricmean(inlist) """ mult = 1.0 one_over_n = 1.0 / len(inlist) for item in inlist: mult = mult * pow(item, one_over_n)...
[ "def", "geometricmean", "(", "inlist", ")", ":", "mult", "=", "1.0", "one_over_n", "=", "1.0", "/", "len", "(", "inlist", ")", "for", "item", "in", "inlist", ":", "mult", "=", "mult", "*", "pow", "(", "item", ",", "one_over_n", ")", "return", "mult" ...
Calculates the geometric mean of the values in the passed list. That is: n-th root of (x1 * x2 * ... * xn). Assumes a '1D' list. Usage: lgeometricmean(inlist)
[ "Calculates", "the", "geometric", "mean", "of", "the", "values", "in", "the", "passed", "list", ".", "That", "is", ":", "n", "-", "th", "root", "of", "(", "x1", "*", "x2", "*", "...", "*", "xn", ")", ".", "Assumes", "a", "1D", "list", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L244-L255
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
harmonicmean
def harmonicmean(inlist): """ Calculates the harmonic mean of the values in the passed list. That is: n / (1/x1 + 1/x2 + ... + 1/xn). Assumes a '1D' list. Usage: lharmonicmean(inlist) """ sum = 0 for item in inlist: sum = sum + 1.0 / item return len(inlist) / sum
python
def harmonicmean(inlist): """ Calculates the harmonic mean of the values in the passed list. That is: n / (1/x1 + 1/x2 + ... + 1/xn). Assumes a '1D' list. Usage: lharmonicmean(inlist) """ sum = 0 for item in inlist: sum = sum + 1.0 / item return len(inlist) / sum
[ "def", "harmonicmean", "(", "inlist", ")", ":", "sum", "=", "0", "for", "item", "in", "inlist", ":", "sum", "=", "sum", "+", "1.0", "/", "item", "return", "len", "(", "inlist", ")", "/", "sum" ]
Calculates the harmonic mean of the values in the passed list. That is: n / (1/x1 + 1/x2 + ... + 1/xn). Assumes a '1D' list. Usage: lharmonicmean(inlist)
[ "Calculates", "the", "harmonic", "mean", "of", "the", "values", "in", "the", "passed", "list", ".", "That", "is", ":", "n", "/", "(", "1", "/", "x1", "+", "1", "/", "x2", "+", "...", "+", "1", "/", "xn", ")", ".", "Assumes", "a", "1D", "list", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L258-L268
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
mean
def mean(inlist): """ Returns the arithematic mean of the values in the passed list. Assumes a '1D' list, but will function on the 1st dim of an array(!). Usage: lmean(inlist) """ sum = 0 for item in inlist: sum = sum + item return sum / float(len(inlist))
python
def mean(inlist): """ Returns the arithematic mean of the values in the passed list. Assumes a '1D' list, but will function on the 1st dim of an array(!). Usage: lmean(inlist) """ sum = 0 for item in inlist: sum = sum + item return sum / float(len(inlist))
[ "def", "mean", "(", "inlist", ")", ":", "sum", "=", "0", "for", "item", "in", "inlist", ":", "sum", "=", "sum", "+", "item", "return", "sum", "/", "float", "(", "len", "(", "inlist", ")", ")" ]
Returns the arithematic mean of the values in the passed list. Assumes a '1D' list, but will function on the 1st dim of an array(!). Usage: lmean(inlist)
[ "Returns", "the", "arithematic", "mean", "of", "the", "values", "in", "the", "passed", "list", ".", "Assumes", "a", "1D", "list", "but", "will", "function", "on", "the", "1st", "dim", "of", "an", "array", "(", "!", ")", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L271-L281
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
medianscore
def medianscore(inlist): """ Returns the 'middle' score of the passed list. If there is an even number of scores, the mean of the 2 middle scores is returned. Usage: lmedianscore(inlist) """ newlist = copy.deepcopy(inlist) newlist.sort() if len(newlist) % 2 == 0: # if even number of scores, avera...
python
def medianscore(inlist): """ Returns the 'middle' score of the passed list. If there is an even number of scores, the mean of the 2 middle scores is returned. Usage: lmedianscore(inlist) """ newlist = copy.deepcopy(inlist) newlist.sort() if len(newlist) % 2 == 0: # if even number of scores, avera...
[ "def", "medianscore", "(", "inlist", ")", ":", "newlist", "=", "copy", ".", "deepcopy", "(", "inlist", ")", "newlist", ".", "sort", "(", ")", "if", "len", "(", "newlist", ")", "%", "2", "==", "0", ":", "# if even number of scores, average middle 2", "index...
Returns the 'middle' score of the passed list. If there is an even number of scores, the mean of the 2 middle scores is returned. Usage: lmedianscore(inlist)
[ "Returns", "the", "middle", "score", "of", "the", "passed", "list", ".", "If", "there", "is", "an", "even", "number", "of", "scores", "the", "mean", "of", "the", "2", "middle", "scores", "is", "returned", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L306-L322
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
mode
def mode(inlist): """ Returns a list of the modal (most common) score(s) in the passed list. If there is more than one such score, all are returned. The bin-count for the mode(s) is also returned. Usage: lmode(inlist) Returns: bin-count for mode(s), a list of modal value(s) """ scores = pstat.unique(inlis...
python
def mode(inlist): """ Returns a list of the modal (most common) score(s) in the passed list. If there is more than one such score, all are returned. The bin-count for the mode(s) is also returned. Usage: lmode(inlist) Returns: bin-count for mode(s), a list of modal value(s) """ scores = pstat.unique(inlis...
[ "def", "mode", "(", "inlist", ")", ":", "scores", "=", "pstat", ".", "unique", "(", "inlist", ")", "scores", ".", "sort", "(", ")", "freq", "=", "[", "]", "for", "item", "in", "scores", ":", "freq", ".", "append", "(", "inlist", ".", "count", "("...
Returns a list of the modal (most common) score(s) in the passed list. If there is more than one such score, all are returned. The bin-count for the mode(s) is also returned. Usage: lmode(inlist) Returns: bin-count for mode(s), a list of modal value(s)
[ "Returns", "a", "list", "of", "the", "modal", "(", "most", "common", ")", "score", "(", "s", ")", "in", "the", "passed", "list", ".", "If", "there", "is", "more", "than", "one", "such", "score", "all", "are", "returned", ".", "The", "bin", "-", "co...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L325-L351
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
moment
def moment(inlist, moment=1): """ Calculates the nth moment about the mean for a sample (defaults to the 1st moment). Used to calculate coefficients of skewness and kurtosis. Usage: lmoment(inlist,moment=1) Returns: appropriate moment (r) from pyLibrary. 1/n * SUM((inlist(i)-mean)**r) """ if moment == 1: ...
python
def moment(inlist, moment=1): """ Calculates the nth moment about the mean for a sample (defaults to the 1st moment). Used to calculate coefficients of skewness and kurtosis. Usage: lmoment(inlist,moment=1) Returns: appropriate moment (r) from pyLibrary. 1/n * SUM((inlist(i)-mean)**r) """ if moment == 1: ...
[ "def", "moment", "(", "inlist", ",", "moment", "=", "1", ")", ":", "if", "moment", "==", "1", ":", "return", "0.0", "else", ":", "mn", "=", "mean", "(", "inlist", ")", "n", "=", "len", "(", "inlist", ")", "s", "=", "0", "for", "x", "in", "inl...
Calculates the nth moment about the mean for a sample (defaults to the 1st moment). Used to calculate coefficients of skewness and kurtosis. Usage: lmoment(inlist,moment=1) Returns: appropriate moment (r) from pyLibrary. 1/n * SUM((inlist(i)-mean)**r)
[ "Calculates", "the", "nth", "moment", "about", "the", "mean", "for", "a", "sample", "(", "defaults", "to", "the", "1st", "moment", ")", ".", "Used", "to", "calculate", "coefficients", "of", "skewness", "and", "kurtosis", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L358-L374
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
describe
def describe(inlist): """ Returns some descriptive statistics of the passed list (assumed to be 1D). Usage: ldescribe(inlist) Returns: n, mean, standard deviation, skew, kurtosis """ n = len(inlist) mm = (min(inlist), max(inlist)) m = mean(inlist) sd = stdev(inlist) sk = skew(inlist) kurt...
python
def describe(inlist): """ Returns some descriptive statistics of the passed list (assumed to be 1D). Usage: ldescribe(inlist) Returns: n, mean, standard deviation, skew, kurtosis """ n = len(inlist) mm = (min(inlist), max(inlist)) m = mean(inlist) sd = stdev(inlist) sk = skew(inlist) kurt...
[ "def", "describe", "(", "inlist", ")", ":", "n", "=", "len", "(", "inlist", ")", "mm", "=", "(", "min", "(", "inlist", ")", ",", "max", "(", "inlist", ")", ")", "m", "=", "mean", "(", "inlist", ")", "sd", "=", "stdev", "(", "inlist", ")", "sk...
Returns some descriptive statistics of the passed list (assumed to be 1D). Usage: ldescribe(inlist) Returns: n, mean, standard deviation, skew, kurtosis
[ "Returns", "some", "descriptive", "statistics", "of", "the", "passed", "list", "(", "assumed", "to", "be", "1D", ")", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L407-L420
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
itemfreq
def itemfreq(inlist): """ Returns a list of pairs. Each pair consists of one of the scores in inlist and it's frequency count. Assumes a 1D list is passed. Usage: litemfreq(inlist) Returns: a 2D frequency table (col [0:n-1]=scores, col n=frequencies) """ scores = pstat.unique(inlist) scores.sort() ...
python
def itemfreq(inlist): """ Returns a list of pairs. Each pair consists of one of the scores in inlist and it's frequency count. Assumes a 1D list is passed. Usage: litemfreq(inlist) Returns: a 2D frequency table (col [0:n-1]=scores, col n=frequencies) """ scores = pstat.unique(inlist) scores.sort() ...
[ "def", "itemfreq", "(", "inlist", ")", ":", "scores", "=", "pstat", ".", "unique", "(", "inlist", ")", "scores", ".", "sort", "(", ")", "freq", "=", "[", "]", "for", "item", "in", "scores", ":", "freq", ".", "append", "(", "inlist", ".", "count", ...
Returns a list of pairs. Each pair consists of one of the scores in inlist and it's frequency count. Assumes a 1D list is passed. Usage: litemfreq(inlist) Returns: a 2D frequency table (col [0:n-1]=scores, col n=frequencies)
[ "Returns", "a", "list", "of", "pairs", ".", "Each", "pair", "consists", "of", "one", "of", "the", "scores", "in", "inlist", "and", "it", "s", "frequency", "count", ".", "Assumes", "a", "1D", "list", "is", "passed", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L427-L440
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
scoreatpercentile
def scoreatpercentile(inlist, percent): """ Returns the score at a given percentile relative to the distribution given by inlist. Usage: lscoreatpercentile(inlist,percent) """ if percent > 1: print("\nDividing percent>1 by 100 in lscoreatpercentile().\n") percent = percent / 100.0 targetc...
python
def scoreatpercentile(inlist, percent): """ Returns the score at a given percentile relative to the distribution given by inlist. Usage: lscoreatpercentile(inlist,percent) """ if percent > 1: print("\nDividing percent>1 by 100 in lscoreatpercentile().\n") percent = percent / 100.0 targetc...
[ "def", "scoreatpercentile", "(", "inlist", ",", "percent", ")", ":", "if", "percent", ">", "1", ":", "print", "(", "\"\\nDividing percent>1 by 100 in lscoreatpercentile().\\n\"", ")", "percent", "=", "percent", "/", "100.0", "targetcf", "=", "percent", "*", "len",...
Returns the score at a given percentile relative to the distribution given by inlist. Usage: lscoreatpercentile(inlist,percent)
[ "Returns", "the", "score", "at", "a", "given", "percentile", "relative", "to", "the", "distribution", "given", "by", "inlist", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L443-L460
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
percentileofscore
def percentileofscore(inlist, score, histbins=10, defaultlimits=None): """ Returns the percentile value of a score relative to the distribution given by inlist. Formula depends on the values used to histogram the data(!). Usage: lpercentileofscore(inlist,score,histbins=10,defaultlimits=None) """ h, lrl, bi...
python
def percentileofscore(inlist, score, histbins=10, defaultlimits=None): """ Returns the percentile value of a score relative to the distribution given by inlist. Formula depends on the values used to histogram the data(!). Usage: lpercentileofscore(inlist,score,histbins=10,defaultlimits=None) """ h, lrl, bi...
[ "def", "percentileofscore", "(", "inlist", ",", "score", ",", "histbins", "=", "10", ",", "defaultlimits", "=", "None", ")", ":", "h", ",", "lrl", ",", "binsize", ",", "extras", "=", "histogram", "(", "inlist", ",", "histbins", ",", "defaultlimits", ")",...
Returns the percentile value of a score relative to the distribution given by inlist. Formula depends on the values used to histogram the data(!). Usage: lpercentileofscore(inlist,score,histbins=10,defaultlimits=None)
[ "Returns", "the", "percentile", "value", "of", "a", "score", "relative", "to", "the", "distribution", "given", "by", "inlist", ".", "Formula", "depends", "on", "the", "values", "used", "to", "histogram", "the", "data", "(", "!", ")", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L463-L475
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
histogram
def histogram(inlist, numbins=10, defaultreallimits=None, printextras=0): """ Returns (i) a list of histogram bin counts, (ii) the smallest value of the histogram binning, and (iii) the bin width (the last 2 are not necessarily integers). Default number of bins is 10. If no sequence object is given for defaultrea...
python
def histogram(inlist, numbins=10, defaultreallimits=None, printextras=0): """ Returns (i) a list of histogram bin counts, (ii) the smallest value of the histogram binning, and (iii) the bin width (the last 2 are not necessarily integers). Default number of bins is 10. If no sequence object is given for defaultrea...
[ "def", "histogram", "(", "inlist", ",", "numbins", "=", "10", ",", "defaultreallimits", "=", "None", ",", "printextras", "=", "0", ")", ":", "if", "(", "defaultreallimits", "!=", "None", ")", ":", "if", "type", "(", "defaultreallimits", ")", "not", "in",...
Returns (i) a list of histogram bin counts, (ii) the smallest value of the histogram binning, and (iii) the bin width (the last 2 are not necessarily integers). Default number of bins is 10. If no sequence object is given for defaultreallimits, the routine picks (usually non-pretty) bins spanning all the numbers in t...
[ "Returns", "(", "i", ")", "a", "list", "of", "histogram", "bin", "counts", "(", "ii", ")", "the", "smallest", "value", "of", "the", "histogram", "binning", "and", "(", "iii", ")", "the", "bin", "width", "(", "the", "last", "2", "are", "not", "necessa...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L478-L514
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
cumfreq
def cumfreq(inlist, numbins=10, defaultreallimits=None): """ Returns a cumulative frequency histogram, using the histogram function. Usage: lcumfreq(inlist,numbins=10,defaultreallimits=None) Returns: list of cumfreq bin values, lowerreallimit, binsize, extrapoints """ h, l, b, e = histogram(inlist, numbins, ...
python
def cumfreq(inlist, numbins=10, defaultreallimits=None): """ Returns a cumulative frequency histogram, using the histogram function. Usage: lcumfreq(inlist,numbins=10,defaultreallimits=None) Returns: list of cumfreq bin values, lowerreallimit, binsize, extrapoints """ h, l, b, e = histogram(inlist, numbins, ...
[ "def", "cumfreq", "(", "inlist", ",", "numbins", "=", "10", ",", "defaultreallimits", "=", "None", ")", ":", "h", ",", "l", ",", "b", ",", "e", "=", "histogram", "(", "inlist", ",", "numbins", ",", "defaultreallimits", ")", "cumhist", "=", "cumsum", ...
Returns a cumulative frequency histogram, using the histogram function. Usage: lcumfreq(inlist,numbins=10,defaultreallimits=None) Returns: list of cumfreq bin values, lowerreallimit, binsize, extrapoints
[ "Returns", "a", "cumulative", "frequency", "histogram", "using", "the", "histogram", "function", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L517-L526
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
relfreq
def relfreq(inlist, numbins=10, defaultreallimits=None): """ Returns a relative frequency histogram, using the histogram function. Usage: lrelfreq(inlist,numbins=10,defaultreallimits=None) Returns: list of cumfreq bin values, lowerreallimit, binsize, extrapoints """ h, l, b, e = histogram(inlist, numbins, de...
python
def relfreq(inlist, numbins=10, defaultreallimits=None): """ Returns a relative frequency histogram, using the histogram function. Usage: lrelfreq(inlist,numbins=10,defaultreallimits=None) Returns: list of cumfreq bin values, lowerreallimit, binsize, extrapoints """ h, l, b, e = histogram(inlist, numbins, de...
[ "def", "relfreq", "(", "inlist", ",", "numbins", "=", "10", ",", "defaultreallimits", "=", "None", ")", ":", "h", ",", "l", ",", "b", ",", "e", "=", "histogram", "(", "inlist", ",", "numbins", ",", "defaultreallimits", ")", "for", "i", "in", "range",...
Returns a relative frequency histogram, using the histogram function. Usage: lrelfreq(inlist,numbins=10,defaultreallimits=None) Returns: list of cumfreq bin values, lowerreallimit, binsize, extrapoints
[ "Returns", "a", "relative", "frequency", "histogram", "using", "the", "histogram", "function", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L529-L539
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
obrientransform
def obrientransform(*args): """ Computes a transform on input data (any number of columns). Used to test for homogeneity of variance prior to running one-way stats. From Maxwell and Delaney, p.112. Usage: lobrientransform(*args) Returns: transformed data for use in an ANOVA """ TINY = 1e-10 k = len(arg...
python
def obrientransform(*args): """ Computes a transform on input data (any number of columns). Used to test for homogeneity of variance prior to running one-way stats. From Maxwell and Delaney, p.112. Usage: lobrientransform(*args) Returns: transformed data for use in an ANOVA """ TINY = 1e-10 k = len(arg...
[ "def", "obrientransform", "(", "*", "args", ")", ":", "TINY", "=", "1e-10", "k", "=", "len", "(", "args", ")", "n", "=", "[", "0.0", "]", "*", "k", "v", "=", "[", "0.0", "]", "*", "k", "m", "=", "[", "0.0", "]", "*", "k", "nargs", "=", "[...
Computes a transform on input data (any number of columns). Used to test for homogeneity of variance prior to running one-way stats. From Maxwell and Delaney, p.112. Usage: lobrientransform(*args) Returns: transformed data for use in an ANOVA
[ "Computes", "a", "transform", "on", "input", "data", "(", "any", "number", "of", "columns", ")", ".", "Used", "to", "test", "for", "homogeneity", "of", "variance", "prior", "to", "running", "one", "-", "way", "stats", ".", "From", "Maxwell", "and", "Dela...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L546-L579
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
samplevar
def samplevar(inlist): """ Returns the variance of the values in the passed list using N for the denominator (i.e., DESCRIBES the sample variance only). Usage: lsamplevar(inlist) """ n = len(inlist) mn = mean(inlist) deviations = [] for item in inlist: deviations.append(item - mn) ret...
python
def samplevar(inlist): """ Returns the variance of the values in the passed list using N for the denominator (i.e., DESCRIBES the sample variance only). Usage: lsamplevar(inlist) """ n = len(inlist) mn = mean(inlist) deviations = [] for item in inlist: deviations.append(item - mn) ret...
[ "def", "samplevar", "(", "inlist", ")", ":", "n", "=", "len", "(", "inlist", ")", "mn", "=", "mean", "(", "inlist", ")", "deviations", "=", "[", "]", "for", "item", "in", "inlist", ":", "deviations", ".", "append", "(", "item", "-", "mn", ")", "r...
Returns the variance of the values in the passed list using N for the denominator (i.e., DESCRIBES the sample variance only). Usage: lsamplevar(inlist)
[ "Returns", "the", "variance", "of", "the", "values", "in", "the", "passed", "list", "using", "N", "for", "the", "denominator", "(", "i", ".", "e", ".", "DESCRIBES", "the", "sample", "variance", "only", ")", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L582-L594
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
cov
def cov(x, y, keepdims=0): """ Returns the estimated covariance of the values in the passed array (i.e., N-1). Dimension can equal None (ravel array first), an integer (the dimension over which to operate), or a sequence (operate over multiple dimensions). Set keepdims=1 to return an array with the same number of...
python
def cov(x, y, keepdims=0): """ Returns the estimated covariance of the values in the passed array (i.e., N-1). Dimension can equal None (ravel array first), an integer (the dimension over which to operate), or a sequence (operate over multiple dimensions). Set keepdims=1 to return an array with the same number of...
[ "def", "cov", "(", "x", ",", "y", ",", "keepdims", "=", "0", ")", ":", "n", "=", "len", "(", "x", ")", "xmn", "=", "mean", "(", "x", ")", "ymn", "=", "mean", "(", "y", ")", "xdeviations", "=", "[", "0", "]", "*", "len", "(", "x", ")", "...
Returns the estimated covariance of the values in the passed array (i.e., N-1). Dimension can equal None (ravel array first), an integer (the dimension over which to operate), or a sequence (operate over multiple dimensions). Set keepdims=1 to return an array with the same number of dimensions as inarray. Usage: l...
[ "Returns", "the", "estimated", "covariance", "of", "the", "values", "in", "the", "passed", "array", "(", "i", ".", "e", ".", "N", "-", "1", ")", ".", "Dimension", "can", "equal", "None", "(", "ravel", "array", "first", ")", "an", "integer", "(", "the...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L607-L629
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
var
def var(inlist): """ Returns the variance of the values in the passed list using N-1 for the denominator (i.e., for estimating population variance). Usage: lvar(inlist) """ n = len(inlist) mn = mean(inlist) deviations = [0] * len(inlist) for i in range(len(inlist)): deviations[i] = inlist...
python
def var(inlist): """ Returns the variance of the values in the passed list using N-1 for the denominator (i.e., for estimating population variance). Usage: lvar(inlist) """ n = len(inlist) mn = mean(inlist) deviations = [0] * len(inlist) for i in range(len(inlist)): deviations[i] = inlist...
[ "def", "var", "(", "inlist", ")", ":", "n", "=", "len", "(", "inlist", ")", "mn", "=", "mean", "(", "inlist", ")", "deviations", "=", "[", "0", "]", "*", "len", "(", "inlist", ")", "for", "i", "in", "range", "(", "len", "(", "inlist", ")", ")...
Returns the variance of the values in the passed list using N-1 for the denominator (i.e., for estimating population variance). Usage: lvar(inlist)
[ "Returns", "the", "variance", "of", "the", "values", "in", "the", "passed", "list", "using", "N", "-", "1", "for", "the", "denominator", "(", "i", ".", "e", ".", "for", "estimating", "population", "variance", ")", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L632-L644
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
sem
def sem(inlist): """ Returns the estimated standard error of the mean (sx-bar) of the values in the passed list. sem = stdev / sqrt(n) Usage: lsem(inlist) """ sd = stdev(inlist) n = len(inlist) return sd / math.sqrt(n)
python
def sem(inlist): """ Returns the estimated standard error of the mean (sx-bar) of the values in the passed list. sem = stdev / sqrt(n) Usage: lsem(inlist) """ sd = stdev(inlist) n = len(inlist) return sd / math.sqrt(n)
[ "def", "sem", "(", "inlist", ")", ":", "sd", "=", "stdev", "(", "inlist", ")", "n", "=", "len", "(", "inlist", ")", "return", "sd", "/", "math", ".", "sqrt", "(", "n", ")" ]
Returns the estimated standard error of the mean (sx-bar) of the values in the passed list. sem = stdev / sqrt(n) Usage: lsem(inlist)
[ "Returns", "the", "estimated", "standard", "error", "of", "the", "mean", "(", "sx", "-", "bar", ")", "of", "the", "values", "in", "the", "passed", "list", ".", "sem", "=", "stdev", "/", "sqrt", "(", "n", ")" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L667-L676
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
zs
def zs(inlist): """ Returns a list of z-scores, one for each score in the passed list. Usage: lzs(inlist) """ zscores = [] for item in inlist: zscores.append(z(inlist, item)) return zscores
python
def zs(inlist): """ Returns a list of z-scores, one for each score in the passed list. Usage: lzs(inlist) """ zscores = [] for item in inlist: zscores.append(z(inlist, item)) return zscores
[ "def", "zs", "(", "inlist", ")", ":", "zscores", "=", "[", "]", "for", "item", "in", "inlist", ":", "zscores", ".", "append", "(", "z", "(", "inlist", ",", "item", ")", ")", "return", "zscores" ]
Returns a list of z-scores, one for each score in the passed list. Usage: lzs(inlist)
[ "Returns", "a", "list", "of", "z", "-", "scores", "one", "for", "each", "score", "in", "the", "passed", "list", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L690-L699
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
trimboth
def trimboth(l, proportiontocut): """ Slices off the passed proportion of items from BOTH ends of the passed list (i.e., with proportiontocut=0.1, slices 'leftmost' 10% AND 'rightmost' 10% of scores. Assumes list is sorted by magnitude. Slices off LESS if proportion results in a non-integer slice index (i.e., con...
python
def trimboth(l, proportiontocut): """ Slices off the passed proportion of items from BOTH ends of the passed list (i.e., with proportiontocut=0.1, slices 'leftmost' 10% AND 'rightmost' 10% of scores. Assumes list is sorted by magnitude. Slices off LESS if proportion results in a non-integer slice index (i.e., con...
[ "def", "trimboth", "(", "l", ",", "proportiontocut", ")", ":", "lowercut", "=", "int", "(", "proportiontocut", "*", "len", "(", "l", ")", ")", "uppercut", "=", "len", "(", "l", ")", "-", "lowercut", "return", "l", "[", "lowercut", ":", "uppercut", "]...
Slices off the passed proportion of items from BOTH ends of the passed list (i.e., with proportiontocut=0.1, slices 'leftmost' 10% AND 'rightmost' 10% of scores. Assumes list is sorted by magnitude. Slices off LESS if proportion results in a non-integer slice index (i.e., conservatively slices off proportiontocut). ...
[ "Slices", "off", "the", "passed", "proportion", "of", "items", "from", "BOTH", "ends", "of", "the", "passed", "list", "(", "i", ".", "e", ".", "with", "proportiontocut", "=", "0", ".", "1", "slices", "leftmost", "10%", "AND", "rightmost", "10%", "of", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L706-L719
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
trim1
def trim1(l, proportiontocut, tail='right'): """ Slices off the passed proportion of items from ONE end of the passed list (i.e., if proportiontocut=0.1, slices off 'leftmost' or 'rightmost' 10% of scores). Slices off LESS if proportion results in a non-integer slice index (i.e., conservatively slices off proporti...
python
def trim1(l, proportiontocut, tail='right'): """ Slices off the passed proportion of items from ONE end of the passed list (i.e., if proportiontocut=0.1, slices off 'leftmost' or 'rightmost' 10% of scores). Slices off LESS if proportion results in a non-integer slice index (i.e., conservatively slices off proporti...
[ "def", "trim1", "(", "l", ",", "proportiontocut", ",", "tail", "=", "'right'", ")", ":", "if", "tail", "==", "'right'", ":", "lowercut", "=", "0", "uppercut", "=", "len", "(", "l", ")", "-", "int", "(", "proportiontocut", "*", "len", "(", "l", ")",...
Slices off the passed proportion of items from ONE end of the passed list (i.e., if proportiontocut=0.1, slices off 'leftmost' or 'rightmost' 10% of scores). Slices off LESS if proportion results in a non-integer slice index (i.e., conservatively slices off proportiontocut). Usage: ltrim1 (l,proportiontocut,tail='r...
[ "Slices", "off", "the", "passed", "proportion", "of", "items", "from", "ONE", "end", "of", "the", "passed", "list", "(", "i", ".", "e", ".", "if", "proportiontocut", "=", "0", ".", "1", "slices", "off", "leftmost", "or", "rightmost", "10%", "of", "scor...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L722-L738
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
paired
def paired(x, y): """ Interactively determines the type of data and then runs the appropriated statistic for paired group data. Usage: lpaired(x,y) Returns: appropriate statistic name, value, and probability """ samples = '' while samples not in ['i', 'r', 'I', 'R', 'c', 'C']: print('\nIndependen...
python
def paired(x, y): """ Interactively determines the type of data and then runs the appropriated statistic for paired group data. Usage: lpaired(x,y) Returns: appropriate statistic name, value, and probability """ samples = '' while samples not in ['i', 'r', 'I', 'R', 'c', 'C']: print('\nIndependen...
[ "def", "paired", "(", "x", ",", "y", ")", ":", "samples", "=", "''", "while", "samples", "not", "in", "[", "'i'", ",", "'r'", ",", "'I'", ",", "'R'", ",", "'c'", ",", "'C'", "]", ":", "print", "(", "'\\nIndependent or related samples, or correlation (i,r...
Interactively determines the type of data and then runs the appropriated statistic for paired group data. Usage: lpaired(x,y) Returns: appropriate statistic name, value, and probability
[ "Interactively", "determines", "the", "type", "of", "data", "and", "then", "runs", "the", "appropriated", "statistic", "for", "paired", "group", "data", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L745-L805
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
lincc
def lincc(x, y): """ Calculates Lin's concordance correlation coefficient. Usage: alincc(x,y) where x, y are equal-length arrays Returns: Lin's CC """ covar = cov(x, y) * (len(x) - 1) / float(len(x)) # correct denom to n xvar = var(x) * (len(x) - 1) / float(len(x)) # correct denom to n yvar = va...
python
def lincc(x, y): """ Calculates Lin's concordance correlation coefficient. Usage: alincc(x,y) where x, y are equal-length arrays Returns: Lin's CC """ covar = cov(x, y) * (len(x) - 1) / float(len(x)) # correct denom to n xvar = var(x) * (len(x) - 1) / float(len(x)) # correct denom to n yvar = va...
[ "def", "lincc", "(", "x", ",", "y", ")", ":", "covar", "=", "cov", "(", "x", ",", "y", ")", "*", "(", "len", "(", "x", ")", "-", "1", ")", "/", "float", "(", "len", "(", "x", ")", ")", "# correct denom to n", "xvar", "=", "var", "(", "x", ...
Calculates Lin's concordance correlation coefficient. Usage: alincc(x,y) where x, y are equal-length arrays Returns: Lin's CC
[ "Calculates", "Lin", "s", "concordance", "correlation", "coefficient", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L834-L845
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
pointbiserialr
def pointbiserialr(cats, vals): """ Calculates a point-biserial correlation coefficient and the associated probability value. Taken from Heiman's Basic Statistics for the Behav. Sci (1st), p.194. Usage: pointbiserialr(x,y) where x,y are equal-length lists Returns: Point-biserial r, two-tailed p-value """ ...
python
def pointbiserialr(cats, vals): """ Calculates a point-biserial correlation coefficient and the associated probability value. Taken from Heiman's Basic Statistics for the Behav. Sci (1st), p.194. Usage: pointbiserialr(x,y) where x,y are equal-length lists Returns: Point-biserial r, two-tailed p-value """ ...
[ "def", "pointbiserialr", "(", "cats", ",", "vals", ")", ":", "TINY", "=", "1e-30", "if", "len", "(", "cats", ")", "!=", "len", "(", "vals", ")", ":", "raise", "ValueError", "(", "'INPUT VALUES NOT PAIRED IN pointbiserialr. ABORTING.'", ")", "data", "=", "zi...
Calculates a point-biserial correlation coefficient and the associated probability value. Taken from Heiman's Basic Statistics for the Behav. Sci (1st), p.194. Usage: pointbiserialr(x,y) where x,y are equal-length lists Returns: Point-biserial r, two-tailed p-value
[ "Calculates", "a", "point", "-", "biserial", "correlation", "coefficient", "and", "the", "associated", "probability", "value", ".", "Taken", "from", "Heiman", "s", "Basic", "Statistics", "for", "the", "Behav", ".", "Sci", "(", "1st", ")", "p", ".", "194", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L872-L899
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
chisquare
def chisquare(f_obs, f_exp=None): """ Calculates a one-way chi square for list of observed frequencies and returns the result. If no expected frequencies are given, the total N is assumed to be equally distributed across all groups. Usage: lchisquare(f_obs, f_exp=None) f_obs = list of observed cell freq. Retu...
python
def chisquare(f_obs, f_exp=None): """ Calculates a one-way chi square for list of observed frequencies and returns the result. If no expected frequencies are given, the total N is assumed to be equally distributed across all groups. Usage: lchisquare(f_obs, f_exp=None) f_obs = list of observed cell freq. Retu...
[ "def", "chisquare", "(", "f_obs", ",", "f_exp", "=", "None", ")", ":", "k", "=", "len", "(", "f_obs", ")", "# number of groups", "if", "f_exp", "==", "None", ":", "f_exp", "=", "[", "sum", "(", "f_obs", ")", "/", "float", "(", "k", ")", "]", "*",...
Calculates a one-way chi square for list of observed frequencies and returns the result. If no expected frequencies are given, the total N is assumed to be equally distributed across all groups. Usage: lchisquare(f_obs, f_exp=None) f_obs = list of observed cell freq. Returns: chisquare-statistic, associated p-val...
[ "Calculates", "a", "one", "-", "way", "chi", "square", "for", "list", "of", "observed", "frequencies", "and", "returns", "the", "result", ".", "If", "no", "expected", "frequencies", "are", "given", "the", "total", "N", "is", "assumed", "to", "be", "equally...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1039-L1056
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
wilcoxont
def wilcoxont(x, y): """ Calculates the Wilcoxon T-test for related samples and returns the result. A non-parametric T-test. Usage: lwilcoxont(x,y) Returns: a t-statistic, two-tail probability estimate """ if len(x) != len(y): raise ValueError('Unequal N in wilcoxont. Aborting.') d = [] for...
python
def wilcoxont(x, y): """ Calculates the Wilcoxon T-test for related samples and returns the result. A non-parametric T-test. Usage: lwilcoxont(x,y) Returns: a t-statistic, two-tail probability estimate """ if len(x) != len(y): raise ValueError('Unequal N in wilcoxont. Aborting.') d = [] for...
[ "def", "wilcoxont", "(", "x", ",", "y", ")", ":", "if", "len", "(", "x", ")", "!=", "len", "(", "y", ")", ":", "raise", "ValueError", "(", "'Unequal N in wilcoxont. Aborting.'", ")", "d", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", ...
Calculates the Wilcoxon T-test for related samples and returns the result. A non-parametric T-test. Usage: lwilcoxont(x,y) Returns: a t-statistic, two-tail probability estimate
[ "Calculates", "the", "Wilcoxon", "T", "-", "test", "for", "related", "samples", "and", "returns", "the", "result", ".", "A", "non", "-", "parametric", "T", "-", "test", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1175-L1205
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
friedmanchisquare
def friedmanchisquare(*args): """ Friedman Chi-Square is a non-parametric, one-way within-subjects ANOVA. This function calculates the Friedman Chi-square test for repeated measures and returns the result, along with the associated probability value. It assumes 3 or more repeated measures. Only 3 levels requires...
python
def friedmanchisquare(*args): """ Friedman Chi-Square is a non-parametric, one-way within-subjects ANOVA. This function calculates the Friedman Chi-square test for repeated measures and returns the result, along with the associated probability value. It assumes 3 or more repeated measures. Only 3 levels requires...
[ "def", "friedmanchisquare", "(", "*", "args", ")", ":", "k", "=", "len", "(", "args", ")", "if", "k", "<", "3", ":", "raise", "ValueError", "(", "'Less than 3 levels. Friedman test not appropriate.'", ")", "n", "=", "len", "(", "args", "[", "0", "]", ")...
Friedman Chi-Square is a non-parametric, one-way within-subjects ANOVA. This function calculates the Friedman Chi-square test for repeated measures and returns the result, along with the associated probability value. It assumes 3 or more repeated measures. Only 3 levels requires a minimum of 10 subjects in the study...
[ "Friedman", "Chi", "-", "Square", "is", "a", "non", "-", "parametric", "one", "-", "way", "within", "-", "subjects", "ANOVA", ".", "This", "function", "calculates", "the", "Friedman", "Chi", "-", "square", "test", "for", "repeated", "measures", "and", "ret...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1243-L1266
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
erfcc
def erfcc(x): """ Returns the complementary error function erfc(x) with fractional error everywhere less than 1.2e-7. Adapted from Numerical Recipies. Usage: lerfcc(x) """ z = abs(x) t = 1.0 / (1.0 + 0.5 * z) ans = t * math.exp( -z * z - 1.26551223 + t * (1.00002368 + t * (0.37409196 + t * (...
python
def erfcc(x): """ Returns the complementary error function erfc(x) with fractional error everywhere less than 1.2e-7. Adapted from Numerical Recipies. Usage: lerfcc(x) """ z = abs(x) t = 1.0 / (1.0 + 0.5 * z) ans = t * math.exp( -z * z - 1.26551223 + t * (1.00002368 + t * (0.37409196 + t * (...
[ "def", "erfcc", "(", "x", ")", ":", "z", "=", "abs", "(", "x", ")", "t", "=", "1.0", "/", "(", "1.0", "+", "0.5", "*", "z", ")", "ans", "=", "t", "*", "math", ".", "exp", "(", "-", "z", "*", "z", "-", "1.26551223", "+", "t", "*", "(", ...
Returns the complementary error function erfc(x) with fractional error everywhere less than 1.2e-7. Adapted from Numerical Recipies. Usage: lerfcc(x)
[ "Returns", "the", "complementary", "error", "function", "erfc", "(", "x", ")", "with", "fractional", "error", "everywhere", "less", "than", "1", ".", "2e", "-", "7", ".", "Adapted", "from", "Numerical", "Recipies", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1334-L1348
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
fprob
def fprob(dfnum, dfden, F): """ Returns the (1-tailed) significance level (p-value) of an F statistic given the degrees of freedom for the numerator (dfR-dfF) and the degrees of freedom for the denominator (dfF). Usage: lfprob(dfnum, dfden, F) where usually dfnum=dfbn, dfden=dfwn """ p = betai(0.5 * dfden,...
python
def fprob(dfnum, dfden, F): """ Returns the (1-tailed) significance level (p-value) of an F statistic given the degrees of freedom for the numerator (dfR-dfF) and the degrees of freedom for the denominator (dfF). Usage: lfprob(dfnum, dfden, F) where usually dfnum=dfbn, dfden=dfwn """ p = betai(0.5 * dfden,...
[ "def", "fprob", "(", "dfnum", ",", "dfden", ",", "F", ")", ":", "p", "=", "betai", "(", "0.5", "*", "dfden", ",", "0.5", "*", "dfnum", ",", "dfden", "/", "float", "(", "dfden", "+", "dfnum", "*", "F", ")", ")", "return", "p" ]
Returns the (1-tailed) significance level (p-value) of an F statistic given the degrees of freedom for the numerator (dfR-dfF) and the degrees of freedom for the denominator (dfF). Usage: lfprob(dfnum, dfden, F) where usually dfnum=dfbn, dfden=dfwn
[ "Returns", "the", "(", "1", "-", "tailed", ")", "significance", "level", "(", "p", "-", "value", ")", "of", "an", "F", "statistic", "given", "the", "degrees", "of", "freedom", "for", "the", "numerator", "(", "dfR", "-", "dfF", ")", "and", "the", "deg...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1414-L1423
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
betacf
def betacf(a, b, x): """ This function evaluates the continued fraction form of the incomplete Beta function, betai. (Adapted from: Numerical Recipies in C.) Usage: lbetacf(a,b,x) """ ITMAX = 200 EPS = 3.0e-7 bm = az = am = 1.0 qab = a + b qap = a + 1.0 qam = a - 1.0 ...
python
def betacf(a, b, x): """ This function evaluates the continued fraction form of the incomplete Beta function, betai. (Adapted from: Numerical Recipies in C.) Usage: lbetacf(a,b,x) """ ITMAX = 200 EPS = 3.0e-7 bm = az = am = 1.0 qab = a + b qap = a + 1.0 qam = a - 1.0 ...
[ "def", "betacf", "(", "a", ",", "b", ",", "x", ")", ":", "ITMAX", "=", "200", "EPS", "=", "3.0e-7", "bm", "=", "az", "=", "am", "=", "1.0", "qab", "=", "a", "+", "b", "qap", "=", "a", "+", "1.0", "qam", "=", "a", "-", "1.0", "bz", "=", ...
This function evaluates the continued fraction form of the incomplete Beta function, betai. (Adapted from: Numerical Recipies in C.) Usage: lbetacf(a,b,x)
[ "This", "function", "evaluates", "the", "continued", "fraction", "form", "of", "the", "incomplete", "Beta", "function", "betai", ".", "(", "Adapted", "from", ":", "Numerical", "Recipies", "in", "C", ".", ")" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1426-L1457
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
F_oneway
def F_oneway(*lists): """ Performs a 1-way ANOVA, returning an F-value and probability given any number of groups. From Heiman, pp.394-7. Usage: F_oneway(*lists) where *lists is any number of lists, one per treatment group Returns: F value, one-tailed p-value """ a = len...
python
def F_oneway(*lists): """ Performs a 1-way ANOVA, returning an F-value and probability given any number of groups. From Heiman, pp.394-7. Usage: F_oneway(*lists) where *lists is any number of lists, one per treatment group Returns: F value, one-tailed p-value """ a = len...
[ "def", "F_oneway", "(", "*", "lists", ")", ":", "a", "=", "len", "(", "lists", ")", "# ANOVA on 'a' groups, each in it's own list", "means", "=", "[", "0", "]", "*", "a", "vars", "=", "[", "0", "]", "*", "a", "ns", "=", "[", "0", "]", "*", "a", "...
Performs a 1-way ANOVA, returning an F-value and probability given any number of groups. From Heiman, pp.394-7. Usage: F_oneway(*lists) where *lists is any number of lists, one per treatment group Returns: F value, one-tailed p-value
[ "Performs", "a", "1", "-", "way", "ANOVA", "returning", "an", "F", "-", "value", "and", "probability", "given", "any", "number", "of", "groups", ".", "From", "Heiman", "pp", ".", "394", "-", "7", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1509-L1542
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
F_value
def F_value(ER, EF, dfnum, dfden): """ Returns an F-statistic given the following: ER = error associated with the null hypothesis (the Restricted model) EF = error associated with the alternate hypothesis (the Full model) dfR-dfF = degrees of freedom of the numerator dfF = degrees ...
python
def F_value(ER, EF, dfnum, dfden): """ Returns an F-statistic given the following: ER = error associated with the null hypothesis (the Restricted model) EF = error associated with the alternate hypothesis (the Full model) dfR-dfF = degrees of freedom of the numerator dfF = degrees ...
[ "def", "F_value", "(", "ER", ",", "EF", ",", "dfnum", ",", "dfden", ")", ":", "return", "(", "(", "ER", "-", "EF", ")", "/", "float", "(", "dfnum", ")", "/", "(", "EF", "/", "float", "(", "dfden", ")", ")", ")" ]
Returns an F-statistic given the following: ER = error associated with the null hypothesis (the Restricted model) EF = error associated with the alternate hypothesis (the Full model) dfR-dfF = degrees of freedom of the numerator dfF = degrees of freedom associated with the denominator/...
[ "Returns", "an", "F", "-", "statistic", "given", "the", "following", ":", "ER", "=", "error", "associated", "with", "the", "null", "hypothesis", "(", "the", "Restricted", "model", ")", "EF", "=", "error", "associated", "with", "the", "alternate", "hypothesis...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1545-L1555
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
incr
def incr(l, cap): # to increment a list up to a max-list of 'cap' """ Simulate a counting system from an n-dimensional list. Usage: lincr(l,cap) l=list to increment, cap=max values for each list pos'n Returns: next set of values for list l, OR -1 (if overflow) """ l[0] = l[0] + 1 # e.g., [0,0,0]...
python
def incr(l, cap): # to increment a list up to a max-list of 'cap' """ Simulate a counting system from an n-dimensional list. Usage: lincr(l,cap) l=list to increment, cap=max values for each list pos'n Returns: next set of values for list l, OR -1 (if overflow) """ l[0] = l[0] + 1 # e.g., [0,0,0]...
[ "def", "incr", "(", "l", ",", "cap", ")", ":", "# to increment a list up to a max-list of 'cap'", "l", "[", "0", "]", "=", "l", "[", "0", "]", "+", "1", "# e.g., [0,0,0] --> [2,4,3] (=cap)", "for", "i", "in", "range", "(", "len", "(", "l", ")", ")", ":",...
Simulate a counting system from an n-dimensional list. Usage: lincr(l,cap) l=list to increment, cap=max values for each list pos'n Returns: next set of values for list l, OR -1 (if overflow)
[ "Simulate", "a", "counting", "system", "from", "an", "n", "-", "dimensional", "list", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1559-L1573
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
cumsum
def cumsum(inlist): """ Returns a list consisting of the cumulative sum of the items in the passed list. Usage: lcumsum(inlist) """ newlist = copy.deepcopy(inlist) for i in range(1, len(newlist)): newlist[i] = newlist[i] + newlist[i - 1] return newlist
python
def cumsum(inlist): """ Returns a list consisting of the cumulative sum of the items in the passed list. Usage: lcumsum(inlist) """ newlist = copy.deepcopy(inlist) for i in range(1, len(newlist)): newlist[i] = newlist[i] + newlist[i - 1] return newlist
[ "def", "cumsum", "(", "inlist", ")", ":", "newlist", "=", "copy", ".", "deepcopy", "(", "inlist", ")", "for", "i", "in", "range", "(", "1", ",", "len", "(", "newlist", ")", ")", ":", "newlist", "[", "i", "]", "=", "newlist", "[", "i", "]", "+",...
Returns a list consisting of the cumulative sum of the items in the passed list. Usage: lcumsum(inlist)
[ "Returns", "a", "list", "consisting", "of", "the", "cumulative", "sum", "of", "the", "items", "in", "the", "passed", "list", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1576-L1586
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
ss
def ss(inlist): """ Squares each value in the passed list, adds up these squares and returns the result. Usage: lss(inlist) """ ss = 0 for item in inlist: ss = ss + item * item return ss
python
def ss(inlist): """ Squares each value in the passed list, adds up these squares and returns the result. Usage: lss(inlist) """ ss = 0 for item in inlist: ss = ss + item * item return ss
[ "def", "ss", "(", "inlist", ")", ":", "ss", "=", "0", "for", "item", "in", "inlist", ":", "ss", "=", "ss", "+", "item", "*", "item", "return", "ss" ]
Squares each value in the passed list, adds up these squares and returns the result. Usage: lss(inlist)
[ "Squares", "each", "value", "in", "the", "passed", "list", "adds", "up", "these", "squares", "and", "returns", "the", "result", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1589-L1599
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
summult
def summult(list1, list2): """ Multiplies elements in list1 and list2, element by element, and returns the sum of all resulting multiplications. Must provide equal length lists. Usage: lsummult(list1,list2) """ if len(list1) != len(list2): raise ValueError("Lists not equal length in summult.") s...
python
def summult(list1, list2): """ Multiplies elements in list1 and list2, element by element, and returns the sum of all resulting multiplications. Must provide equal length lists. Usage: lsummult(list1,list2) """ if len(list1) != len(list2): raise ValueError("Lists not equal length in summult.") s...
[ "def", "summult", "(", "list1", ",", "list2", ")", ":", "if", "len", "(", "list1", ")", "!=", "len", "(", "list2", ")", ":", "raise", "ValueError", "(", "\"Lists not equal length in summult.\"", ")", "s", "=", "0", "for", "item1", ",", "item2", "in", "...
Multiplies elements in list1 and list2, element by element, and returns the sum of all resulting multiplications. Must provide equal length lists. Usage: lsummult(list1,list2)
[ "Multiplies", "elements", "in", "list1", "and", "list2", "element", "by", "element", "and", "returns", "the", "sum", "of", "all", "resulting", "multiplications", ".", "Must", "provide", "equal", "length", "lists", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1602-L1615
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
sumdiffsquared
def sumdiffsquared(x, y): """ Takes pairwise differences of the values in lists x and y, squares these differences, and returns the sum of these squares. Usage: lsumdiffsquared(x,y) Returns: sum[(x[i]-y[i])**2] """ sds = 0 for i in range(len(x)): sds = sds + (x[i] - y[i]) ** 2 return sds
python
def sumdiffsquared(x, y): """ Takes pairwise differences of the values in lists x and y, squares these differences, and returns the sum of these squares. Usage: lsumdiffsquared(x,y) Returns: sum[(x[i]-y[i])**2] """ sds = 0 for i in range(len(x)): sds = sds + (x[i] - y[i]) ** 2 return sds
[ "def", "sumdiffsquared", "(", "x", ",", "y", ")", ":", "sds", "=", "0", "for", "i", "in", "range", "(", "len", "(", "x", ")", ")", ":", "sds", "=", "sds", "+", "(", "x", "[", "i", "]", "-", "y", "[", "i", "]", ")", "**", "2", "return", ...
Takes pairwise differences of the values in lists x and y, squares these differences, and returns the sum of these squares. Usage: lsumdiffsquared(x,y) Returns: sum[(x[i]-y[i])**2]
[ "Takes", "pairwise", "differences", "of", "the", "values", "in", "lists", "x", "and", "y", "squares", "these", "differences", "and", "returns", "the", "sum", "of", "these", "squares", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1618-L1629
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
shellsort
def shellsort(inlist): """ Shellsort algorithm. Sorts a 1D-list. Usage: lshellsort(inlist) Returns: sorted-inlist, sorting-index-vector (for original list) """ n = len(inlist) svec = copy.deepcopy(inlist) ivec = range(n) gap = n / 2 # integer division needed while gap > 0: for i in...
python
def shellsort(inlist): """ Shellsort algorithm. Sorts a 1D-list. Usage: lshellsort(inlist) Returns: sorted-inlist, sorting-index-vector (for original list) """ n = len(inlist) svec = copy.deepcopy(inlist) ivec = range(n) gap = n / 2 # integer division needed while gap > 0: for i in...
[ "def", "shellsort", "(", "inlist", ")", ":", "n", "=", "len", "(", "inlist", ")", "svec", "=", "copy", ".", "deepcopy", "(", "inlist", ")", "ivec", "=", "range", "(", "n", ")", "gap", "=", "n", "/", "2", "# integer division needed", "while", "gap", ...
Shellsort algorithm. Sorts a 1D-list. Usage: lshellsort(inlist) Returns: sorted-inlist, sorting-index-vector (for original list)
[ "Shellsort", "algorithm", ".", "Sorts", "a", "1D", "-", "list", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1644-L1667
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
rankdata
def rankdata(inlist): """ Ranks the data in inlist, dealing with ties appropritely. Assumes a 1D inlist. Adapted from Gary Perlman's |Stat ranksort. Usage: rankdata(inlist) Returns: a list of length equal to inlist, containing rank scores """ n = len(inlist) svec, ivec = shellsort(inlist) sumranks ...
python
def rankdata(inlist): """ Ranks the data in inlist, dealing with ties appropritely. Assumes a 1D inlist. Adapted from Gary Perlman's |Stat ranksort. Usage: rankdata(inlist) Returns: a list of length equal to inlist, containing rank scores """ n = len(inlist) svec, ivec = shellsort(inlist) sumranks ...
[ "def", "rankdata", "(", "inlist", ")", ":", "n", "=", "len", "(", "inlist", ")", "svec", ",", "ivec", "=", "shellsort", "(", "inlist", ")", "sumranks", "=", "0", "dupcount", "=", "0", "newlist", "=", "[", "0", "]", "*", "n", "for", "i", "in", "...
Ranks the data in inlist, dealing with ties appropritely. Assumes a 1D inlist. Adapted from Gary Perlman's |Stat ranksort. Usage: rankdata(inlist) Returns: a list of length equal to inlist, containing rank scores
[ "Ranks", "the", "data", "in", "inlist", "dealing", "with", "ties", "appropritely", ".", "Assumes", "a", "1D", "inlist", ".", "Adapted", "from", "Gary", "Perlman", "s", "|Stat", "ranksort", "." ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1670-L1692
klahnakoski/pyLibrary
mo_math/vendor/strangman/stats.py
findwithin
def findwithin(data): """ Returns an integer representing a binary vector, where 1=within- subject factor, 0=between. Input equals the entire data 2D list (i.e., column 0=random factor, column -1=measured values (those two are skipped). Note: input data is in |Stat format ... a list of lists ("2D list") with one r...
python
def findwithin(data): """ Returns an integer representing a binary vector, where 1=within- subject factor, 0=between. Input equals the entire data 2D list (i.e., column 0=random factor, column -1=measured values (those two are skipped). Note: input data is in |Stat format ... a list of lists ("2D list") with one r...
[ "def", "findwithin", "(", "data", ")", ":", "numfact", "=", "len", "(", "data", "[", "0", "]", ")", "-", "1", "withinvec", "=", "0", "for", "col", "in", "range", "(", "1", ",", "numfact", ")", ":", "examplelevel", "=", "pstat", ".", "unique", "("...
Returns an integer representing a binary vector, where 1=within- subject factor, 0=between. Input equals the entire data 2D list (i.e., column 0=random factor, column -1=measured values (those two are skipped). Note: input data is in |Stat format ... a list of lists ("2D list") with one row per measured value, first c...
[ "Returns", "an", "integer", "representing", "a", "binary", "vector", "where", "1", "=", "within", "-", "subject", "factor", "0", "=", "between", ".", "Input", "equals", "the", "entire", "data", "2D", "list", "(", "i", ".", "e", ".", "column", "0", "=",...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/strangman/stats.py#L1695-L1717
ff0000/scarlet
scarlet/cms/sites.py
AdminSite.register_model
def register_model(self, model, bundle): """ Registers a bundle as the main bundle for a model. Used when we need to lookup urls by a model. """ if model in self._model_registry: raise AlreadyRegistered('The model %s is already registered' \ ...
python
def register_model(self, model, bundle): """ Registers a bundle as the main bundle for a model. Used when we need to lookup urls by a model. """ if model in self._model_registry: raise AlreadyRegistered('The model %s is already registered' \ ...
[ "def", "register_model", "(", "self", ",", "model", ",", "bundle", ")", ":", "if", "model", "in", "self", ".", "_model_registry", ":", "raise", "AlreadyRegistered", "(", "'The model %s is already registered'", "%", "model", ")", "if", "bundle", ".", "url_params"...
Registers a bundle as the main bundle for a model. Used when we need to lookup urls by a model.
[ "Registers", "a", "bundle", "as", "the", "main", "bundle", "for", "a", "model", ".", "Used", "when", "we", "need", "to", "lookup", "urls", "by", "a", "model", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L72-L86
ff0000/scarlet
scarlet/cms/sites.py
AdminSite.unregister_model
def unregister_model(self, model): """ Unregisters the given model. """ if model not in self._model_registry: raise NotRegistered('The model %s is not registered' % model) del self._model_registry[model]
python
def unregister_model(self, model): """ Unregisters the given model. """ if model not in self._model_registry: raise NotRegistered('The model %s is not registered' % model) del self._model_registry[model]
[ "def", "unregister_model", "(", "self", ",", "model", ")", ":", "if", "model", "not", "in", "self", ".", "_model_registry", ":", "raise", "NotRegistered", "(", "'The model %s is not registered'", "%", "model", ")", "del", "self", ".", "_model_registry", "[", "...
Unregisters the given model.
[ "Unregisters", "the", "given", "model", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L95-L102
ff0000/scarlet
scarlet/cms/sites.py
AdminSite.register
def register(self, slug, bundle, order=1, title=None): """ Registers the bundle for a certain slug. If a slug is already registered, this will raise AlreadyRegistered. :param slug: The slug to register. :param bundle: The bundle instance being registered. :param order: ...
python
def register(self, slug, bundle, order=1, title=None): """ Registers the bundle for a certain slug. If a slug is already registered, this will raise AlreadyRegistered. :param slug: The slug to register. :param bundle: The bundle instance being registered. :param order: ...
[ "def", "register", "(", "self", ",", "slug", ",", "bundle", ",", "order", "=", "1", ",", "title", "=", "None", ")", ":", "if", "slug", "in", "self", ".", "_registry", ":", "raise", "AlreadyRegistered", "(", "'The url %s is already registered'", "%", "slug"...
Registers the bundle for a certain slug. If a slug is already registered, this will raise AlreadyRegistered. :param slug: The slug to register. :param bundle: The bundle instance being registered. :param order: An integer that controls where this bundle's \ dashboard links appe...
[ "Registers", "the", "bundle", "for", "a", "certain", "slug", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L104-L124
ff0000/scarlet
scarlet/cms/sites.py
AdminSite.unregister
def unregister(self, slug): """ Unregisters the given url. If a slug isn't already registered, this will raise NotRegistered. """ if slug not in self._registry: raise NotRegistered('The slug %s is not registered' % slug) bundle = self._registry[slug] ...
python
def unregister(self, slug): """ Unregisters the given url. If a slug isn't already registered, this will raise NotRegistered. """ if slug not in self._registry: raise NotRegistered('The slug %s is not registered' % slug) bundle = self._registry[slug] ...
[ "def", "unregister", "(", "self", ",", "slug", ")", ":", "if", "slug", "not", "in", "self", ".", "_registry", ":", "raise", "NotRegistered", "(", "'The slug %s is not registered'", "%", "slug", ")", "bundle", "=", "self", ".", "_registry", "[", "slug", "]"...
Unregisters the given url. If a slug isn't already registered, this will raise NotRegistered.
[ "Unregisters", "the", "given", "url", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L126-L140
ff0000/scarlet
scarlet/cms/sites.py
AdminSite.password_change
def password_change(self, request): """ Handles the "change password" task -- both form display and validation. Uses the default auth views. """ from django.contrib.auth.views import password_change url = reverse('admin:cms_password_change_done') defaults = { ...
python
def password_change(self, request): """ Handles the "change password" task -- both form display and validation. Uses the default auth views. """ from django.contrib.auth.views import password_change url = reverse('admin:cms_password_change_done') defaults = { ...
[ "def", "password_change", "(", "self", ",", "request", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "views", "import", "password_change", "url", "=", "reverse", "(", "'admin:cms_password_change_done'", ")", "defaults", "=", "{", "'post_change_re...
Handles the "change password" task -- both form display and validation. Uses the default auth views.
[ "Handles", "the", "change", "password", "task", "--", "both", "form", "display", "and", "validation", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L205-L219
ff0000/scarlet
scarlet/cms/sites.py
AdminSite.password_change_done
def password_change_done(self, request, extra_context=None): """ Displays the "success" page after a password change. """ from django.contrib.auth.views import password_change_done defaults = { 'extra_context': extra_context or {}, 'template_name': 'cms/pa...
python
def password_change_done(self, request, extra_context=None): """ Displays the "success" page after a password change. """ from django.contrib.auth.views import password_change_done defaults = { 'extra_context': extra_context or {}, 'template_name': 'cms/pa...
[ "def", "password_change_done", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "views", "import", "password_change_done", "defaults", "=", "{", "'extra_context'", ":", "extra_context",...
Displays the "success" page after a password change.
[ "Displays", "the", "success", "page", "after", "a", "password", "change", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L221-L232
ff0000/scarlet
scarlet/cms/sites.py
AdminSite.logout
def logout(self, request, extra_context=None): """ Logs out the user for the given HttpRequest. This should *not* assume the user is already logged in. """ from django.contrib.auth.views import logout defaults = { 'extra_context': extra_context or {}, ...
python
def logout(self, request, extra_context=None): """ Logs out the user for the given HttpRequest. This should *not* assume the user is already logged in. """ from django.contrib.auth.views import logout defaults = { 'extra_context': extra_context or {}, ...
[ "def", "logout", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "views", "import", "logout", "defaults", "=", "{", "'extra_context'", ":", "extra_context", "or", "{", "}", ","...
Logs out the user for the given HttpRequest. This should *not* assume the user is already logged in.
[ "Logs", "out", "the", "user", "for", "the", "given", "HttpRequest", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L235-L248
ff0000/scarlet
scarlet/cms/sites.py
AdminSite.login
def login(self, request, extra_context=None): """ Displays the login form for the given HttpRequest. """ from django.contrib.auth.views import login context = { 'title': _('Log in'), 'app_path': request.get_full_path(), REDIRECT_FIELD_NAME: req...
python
def login(self, request, extra_context=None): """ Displays the login form for the given HttpRequest. """ from django.contrib.auth.views import login context = { 'title': _('Log in'), 'app_path': request.get_full_path(), REDIRECT_FIELD_NAME: req...
[ "def", "login", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "from", "django", ".", "contrib", ".", "auth", ".", "views", "import", "login", "context", "=", "{", "'title'", ":", "_", "(", "'Log in'", ")", ",", "'app_path'",...
Displays the login form for the given HttpRequest.
[ "Displays", "the", "login", "form", "for", "the", "given", "HttpRequest", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L251-L267
ff0000/scarlet
scarlet/cms/sites.py
AdminSite._get_allowed_sections
def _get_allowed_sections(self, dashboard): """ Get the sections to display based on dashboard """ allowed_titles = [x[0] for x in dashboard] allowed_sections = [x[2] for x in dashboard] return tuple(allowed_sections), tuple(allowed_titles)
python
def _get_allowed_sections(self, dashboard): """ Get the sections to display based on dashboard """ allowed_titles = [x[0] for x in dashboard] allowed_sections = [x[2] for x in dashboard] return tuple(allowed_sections), tuple(allowed_titles)
[ "def", "_get_allowed_sections", "(", "self", ",", "dashboard", ")", ":", "allowed_titles", "=", "[", "x", "[", "0", "]", "for", "x", "in", "dashboard", "]", "allowed_sections", "=", "[", "x", "[", "2", "]", "for", "x", "in", "dashboard", "]", "return",...
Get the sections to display based on dashboard
[ "Get", "the", "sections", "to", "display", "based", "on", "dashboard" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L289-L296
ff0000/scarlet
scarlet/cms/sites.py
AdminSite.index
def index(self, request, extra_context=None): """ Displays the dashboard. Includes the main navigation that the user has permission for as well as the cms log for those sections. The log list can be filtered by those same sections and is paginated. """ da...
python
def index(self, request, extra_context=None): """ Displays the dashboard. Includes the main navigation that the user has permission for as well as the cms log for those sections. The log list can be filtered by those same sections and is paginated. """ da...
[ "def", "index", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "dashboard", "=", "self", ".", "get_dashboard_urls", "(", "request", ")", "dash_blocks", "=", "self", ".", "get_dashboard_blocks", "(", "request", ")", "sections", ",",...
Displays the dashboard. Includes the main navigation that the user has permission for as well as the cms log for those sections. The log list can be filtered by those same sections and is paginated.
[ "Displays", "the", "dashboard", ".", "Includes", "the", "main", "navigation", "that", "the", "user", "has", "permission", "for", "as", "well", "as", "the", "cms", "log", "for", "those", "sections", ".", "The", "log", "list", "can", "be", "filtered", "by", ...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L299-L342
ff0000/scarlet
scarlet/cache/groups.py
CacheGroup.register_models
def register_models(self, *models, **kwargs): """ Register multiple models with the same arguments. Calls register for each argument passed along with all keyword arguments. """ for model in models: self.register(model, **kwargs)
python
def register_models(self, *models, **kwargs): """ Register multiple models with the same arguments. Calls register for each argument passed along with all keyword arguments. """ for model in models: self.register(model, **kwargs)
[ "def", "register_models", "(", "self", ",", "*", "models", ",", "*", "*", "kwargs", ")", ":", "for", "model", "in", "models", ":", "self", ".", "register", "(", "model", ",", "*", "*", "kwargs", ")" ]
Register multiple models with the same arguments. Calls register for each argument passed along with all keyword arguments.
[ "Register", "multiple", "models", "with", "the", "same", "arguments", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cache/groups.py#L50-L60
ff0000/scarlet
scarlet/cache/groups.py
CacheGroup.register
def register(self, model, values=None, instance_values=None): """ Registers a model with this group. :param values: A list of values that should be incremented \ whenever invalidate_cache is called for a instance or class \ of this type. :param instance_values: A list o...
python
def register(self, model, values=None, instance_values=None): """ Registers a model with this group. :param values: A list of values that should be incremented \ whenever invalidate_cache is called for a instance or class \ of this type. :param instance_values: A list o...
[ "def", "register", "(", "self", ",", "model", ",", "values", "=", "None", ",", "instance_values", "=", "None", ")", ":", "if", "model", "in", "self", ".", "_models", ":", "raise", "Exception", "(", "\"%s is already registered\"", "%", "model", ")", "self",...
Registers a model with this group. :param values: A list of values that should be incremented \ whenever invalidate_cache is called for a instance or class \ of this type. :param instance_values: A list of attribute names that will \ be looked up on the instance of this model t...
[ "Registers", "a", "model", "with", "this", "group", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cache/groups.py#L62-L79
ff0000/scarlet
scarlet/cache/groups.py
CacheGroup.invalidate_cache
def invalidate_cache(self, klass, instance=None, extra=None, force_all=False): """ Use this method to invalidate keys related to a particular model or instance. Invalidating a cache is really just incrementing the version for the right key(s). :param kla...
python
def invalidate_cache(self, klass, instance=None, extra=None, force_all=False): """ Use this method to invalidate keys related to a particular model or instance. Invalidating a cache is really just incrementing the version for the right key(s). :param kla...
[ "def", "invalidate_cache", "(", "self", ",", "klass", ",", "instance", "=", "None", ",", "extra", "=", "None", ",", "force_all", "=", "False", ")", ":", "values", "=", "self", ".", "_get_cache_extras", "(", "klass", ",", "instance", "=", "instance", ",",...
Use this method to invalidate keys related to a particular model or instance. Invalidating a cache is really just incrementing the version for the right key(s). :param klass: The model class you are invalidating. If the given \ class was not registered with this group no action will be ...
[ "Use", "this", "method", "to", "invalidate", "keys", "related", "to", "a", "particular", "model", "or", "instance", ".", "Invalidating", "a", "cache", "is", "really", "just", "incrementing", "the", "version", "for", "the", "right", "key", "(", "s", ")", "....
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cache/groups.py#L109-L137
ff0000/scarlet
scarlet/cache/groups.py
CacheGroup.get_version
def get_version(self, extra=None): """ This will return a string that can be used as a prefix for django's cache key. Something like key.1 or key.1.2 If a version was not found '1' will be stored and returned as the number for that key. If extra is given a version will ...
python
def get_version(self, extra=None): """ This will return a string that can be used as a prefix for django's cache key. Something like key.1 or key.1.2 If a version was not found '1' will be stored and returned as the number for that key. If extra is given a version will ...
[ "def", "get_version", "(", "self", ",", "extra", "=", "None", ")", ":", "if", "extra", ":", "key", "=", "self", ".", "_get_extra_key", "(", "extra", ")", "else", ":", "key", "=", "self", ".", "key", "v", "=", "self", ".", "_get_cache", "(", "key", ...
This will return a string that can be used as a prefix for django's cache key. Something like key.1 or key.1.2 If a version was not found '1' will be stored and returned as the number for that key. If extra is given a version will be returned for that value. Otherwise the major...
[ "This", "will", "return", "a", "string", "that", "can", "be", "used", "as", "a", "prefix", "for", "django", "s", "cache", "key", ".", "Something", "like", "key", ".", "1", "or", "key", ".", "1", ".", "2" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cache/groups.py#L152-L175
camsci/meteor-pi
src/pythonModules/meteorpi_server/meteorpi_server/query_api.py
add_routes
def add_routes(meteor_app, url_path=''): """ Adds search and retrieval routes to a :class:`meteorpi_server.MeteorServer` instance :param MeteorApp meteor_app: The :class:`meteorpi_server.MeteorApp` to which routes should be added :param string url_path: The base path used for the query ...
python
def add_routes(meteor_app, url_path=''): """ Adds search and retrieval routes to a :class:`meteorpi_server.MeteorServer` instance :param MeteorApp meteor_app: The :class:`meteorpi_server.MeteorApp` to which routes should be added :param string url_path: The base path used for the query ...
[ "def", "add_routes", "(", "meteor_app", ",", "url_path", "=", "''", ")", ":", "from", "meteorpi_server", "import", "MeteorApp", "app", "=", "meteor_app", ".", "app", "@", "app", ".", "after_request", "def", "after_request", "(", "response", ")", ":", "respon...
Adds search and retrieval routes to a :class:`meteorpi_server.MeteorServer` instance :param MeteorApp meteor_app: The :class:`meteorpi_server.MeteorApp` to which routes should be added :param string url_path: The base path used for the query routes, defaults to ''
[ "Adds", "search", "and", "retrieval", "routes", "to", "a", ":", "class", ":", "meteorpi_server", ".", "MeteorServer", "instance" ]
train
https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_server/meteorpi_server/query_api.py#L35-L263
klahnakoski/pyLibrary
jx_elasticsearch/es52/util.py
es_query_template
def es_query_template(path): """ RETURN TEMPLATE AND PATH-TO-FILTER AS A 2-TUPLE :param path: THE NESTED PATH (NOT INCLUDING TABLE NAME) :return: (es_query, es_filters) TUPLE """ if not is_text(path): Log.error("expecting path to be a string") if path != ".": f0 = {} ...
python
def es_query_template(path): """ RETURN TEMPLATE AND PATH-TO-FILTER AS A 2-TUPLE :param path: THE NESTED PATH (NOT INCLUDING TABLE NAME) :return: (es_query, es_filters) TUPLE """ if not is_text(path): Log.error("expecting path to be a string") if path != ".": f0 = {} ...
[ "def", "es_query_template", "(", "path", ")", ":", "if", "not", "is_text", "(", "path", ")", ":", "Log", ".", "error", "(", "\"expecting path to be a string\"", ")", "if", "path", "!=", "\".\"", ":", "f0", "=", "{", "}", "f1", "=", "{", "}", "output", ...
RETURN TEMPLATE AND PATH-TO-FILTER AS A 2-TUPLE :param path: THE NESTED PATH (NOT INCLUDING TABLE NAME) :return: (es_query, es_filters) TUPLE
[ "RETURN", "TEMPLATE", "AND", "PATH", "-", "TO", "-", "FILTER", "AS", "A", "2", "-", "TUPLE", ":", "param", "path", ":", "THE", "NESTED", "PATH", "(", "NOT", "INCLUDING", "TABLE", "NAME", ")", ":", "return", ":", "(", "es_query", "es_filters", ")", "T...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/es52/util.py#L21-L56
inveniosoftware/invenio-collections
invenio_collections/receivers.py
_ancestors
def _ancestors(collection): """Get the ancestors of the collection.""" for index, c in enumerate(collection.path_to_root()): if index > 0 and c.dbquery is not None: raise StopIteration yield c.name raise StopIteration
python
def _ancestors(collection): """Get the ancestors of the collection.""" for index, c in enumerate(collection.path_to_root()): if index > 0 and c.dbquery is not None: raise StopIteration yield c.name raise StopIteration
[ "def", "_ancestors", "(", "collection", ")", ":", "for", "index", ",", "c", "in", "enumerate", "(", "collection", ".", "path_to_root", "(", ")", ")", ":", "if", "index", ">", "0", "and", "c", ".", "dbquery", "is", "not", "None", ":", "raise", "StopIt...
Get the ancestors of the collection.
[ "Get", "the", "ancestors", "of", "the", "collection", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/receivers.py#L35-L41
inveniosoftware/invenio-collections
invenio_collections/receivers.py
_build_cache
def _build_cache(): """Preprocess collection queries.""" query = current_app.config['COLLECTIONS_DELETED_RECORDS'] for collection in Collection.query.filter( Collection.dbquery.isnot(None)).all(): yield collection.name, dict( query=query.format(dbquery=collection.dbquery), ...
python
def _build_cache(): """Preprocess collection queries.""" query = current_app.config['COLLECTIONS_DELETED_RECORDS'] for collection in Collection.query.filter( Collection.dbquery.isnot(None)).all(): yield collection.name, dict( query=query.format(dbquery=collection.dbquery), ...
[ "def", "_build_cache", "(", ")", ":", "query", "=", "current_app", ".", "config", "[", "'COLLECTIONS_DELETED_RECORDS'", "]", "for", "collection", "in", "Collection", ".", "query", ".", "filter", "(", "Collection", ".", "dbquery", ".", "isnot", "(", "None", "...
Preprocess collection queries.
[ "Preprocess", "collection", "queries", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/receivers.py#L50-L59
inveniosoftware/invenio-collections
invenio_collections/receivers.py
_find_matching_collections_internally
def _find_matching_collections_internally(collections, record): """Find matching collections with internal engine. :param collections: set of collections where search :param record: record to match """ for name, data in iteritems(collections): if _build_query(data['query']).match(record): ...
python
def _find_matching_collections_internally(collections, record): """Find matching collections with internal engine. :param collections: set of collections where search :param record: record to match """ for name, data in iteritems(collections): if _build_query(data['query']).match(record): ...
[ "def", "_find_matching_collections_internally", "(", "collections", ",", "record", ")", ":", "for", "name", ",", "data", "in", "iteritems", "(", "collections", ")", ":", "if", "_build_query", "(", "data", "[", "'query'", "]", ")", ".", "match", "(", "record"...
Find matching collections with internal engine. :param collections: set of collections where search :param record: record to match
[ "Find", "matching", "collections", "with", "internal", "engine", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/receivers.py#L62-L71
inveniosoftware/invenio-collections
invenio_collections/receivers.py
get_record_collections
def get_record_collections(record, matcher): """Return list of collections to which record belongs to. :param record: Record instance. :param matcher: Function used to check if a record belongs to a collection. :return: list of collection names. """ collections = current_collections.collections...
python
def get_record_collections(record, matcher): """Return list of collections to which record belongs to. :param record: Record instance. :param matcher: Function used to check if a record belongs to a collection. :return: list of collection names. """ collections = current_collections.collections...
[ "def", "get_record_collections", "(", "record", ",", "matcher", ")", ":", "collections", "=", "current_collections", ".", "collections", "if", "collections", "is", "None", ":", "# build collections cache", "collections", "=", "current_collections", ".", "collections", ...
Return list of collections to which record belongs to. :param record: Record instance. :param matcher: Function used to check if a record belongs to a collection. :return: list of collection names.
[ "Return", "list", "of", "collections", "to", "which", "record", "belongs", "to", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/receivers.py#L74-L91
klahnakoski/pyLibrary
mo_graphs/algorithms.py
dfs
def dfs(graph, func, head, reverse=None): """ DEPTH FIRST SEARCH IF func RETURNS FALSE, THEN PATH IS NO LONGER TAKEN IT'S EXPECTED func TAKES 3 ARGUMENTS node - THE CURRENT NODE IN THE path - PATH FROM head TO node graph - THE WHOLE GRAPH """ todo = deque() todo.append(head) ...
python
def dfs(graph, func, head, reverse=None): """ DEPTH FIRST SEARCH IF func RETURNS FALSE, THEN PATH IS NO LONGER TAKEN IT'S EXPECTED func TAKES 3 ARGUMENTS node - THE CURRENT NODE IN THE path - PATH FROM head TO node graph - THE WHOLE GRAPH """ todo = deque() todo.append(head) ...
[ "def", "dfs", "(", "graph", ",", "func", ",", "head", ",", "reverse", "=", "None", ")", ":", "todo", "=", "deque", "(", ")", "todo", ".", "append", "(", "head", ")", "path", "=", "deque", "(", ")", "done", "=", "set", "(", ")", "while", "todo",...
DEPTH FIRST SEARCH IF func RETURNS FALSE, THEN PATH IS NO LONGER TAKEN IT'S EXPECTED func TAKES 3 ARGUMENTS node - THE CURRENT NODE IN THE path - PATH FROM head TO node graph - THE WHOLE GRAPH
[ "DEPTH", "FIRST", "SEARCH" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_graphs/algorithms.py#L26-L55
klahnakoski/pyLibrary
mo_graphs/algorithms.py
bfs
def bfs(graph, func, head, reverse=None): """ BREADTH FIRST SEARCH IF func RETURNS FALSE, THEN NO MORE PATHS DOWN THE BRANCH ARE TAKEN IT'S EXPECTED func TAKES THESE ARGUMENTS: node - THE CURRENT NODE IN THE path - PATH FROM head TO node graph - THE WHOLE GRAPH todo - WHAT'S IN THE QUE...
python
def bfs(graph, func, head, reverse=None): """ BREADTH FIRST SEARCH IF func RETURNS FALSE, THEN NO MORE PATHS DOWN THE BRANCH ARE TAKEN IT'S EXPECTED func TAKES THESE ARGUMENTS: node - THE CURRENT NODE IN THE path - PATH FROM head TO node graph - THE WHOLE GRAPH todo - WHAT'S IN THE QUE...
[ "def", "bfs", "(", "graph", ",", "func", ",", "head", ",", "reverse", "=", "None", ")", ":", "todo", "=", "deque", "(", ")", "# LIST OF PATHS", "todo", ".", "append", "(", "Step", "(", "None", ",", "head", ")", ")", "while", "todo", ":", "path", ...
BREADTH FIRST SEARCH IF func RETURNS FALSE, THEN NO MORE PATHS DOWN THE BRANCH ARE TAKEN IT'S EXPECTED func TAKES THESE ARGUMENTS: node - THE CURRENT NODE IN THE path - PATH FROM head TO node graph - THE WHOLE GRAPH todo - WHAT'S IN THE QUEUE TO BE DONE
[ "BREADTH", "FIRST", "SEARCH" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_graphs/algorithms.py#L58-L78
klahnakoski/pyLibrary
mo_graphs/algorithms.py
dominator_tree
def dominator_tree(graph): """ RETURN DOMINATOR FOREST THERE ARE TWO TREES, "ROOTS" and "LOOPS" ROOTS HAVE NO PARENTS LOOPS ARE NODES THAT ARE A MEMBER OF A CYCLE THAT HAS NO EXTRNAL PARENT roots = dominator_tree(graph).get_children(ROOTS) """ todo = Queue() done = set() dominat...
python
def dominator_tree(graph): """ RETURN DOMINATOR FOREST THERE ARE TWO TREES, "ROOTS" and "LOOPS" ROOTS HAVE NO PARENTS LOOPS ARE NODES THAT ARE A MEMBER OF A CYCLE THAT HAS NO EXTRNAL PARENT roots = dominator_tree(graph).get_children(ROOTS) """ todo = Queue() done = set() dominat...
[ "def", "dominator_tree", "(", "graph", ")", ":", "todo", "=", "Queue", "(", ")", "done", "=", "set", "(", ")", "dominator", "=", "Tree", "(", "None", ")", "nodes", "=", "list", "(", "graph", ".", "nodes", ")", "while", "True", ":", "# FIGURE OUT NET ...
RETURN DOMINATOR FOREST THERE ARE TWO TREES, "ROOTS" and "LOOPS" ROOTS HAVE NO PARENTS LOOPS ARE NODES THAT ARE A MEMBER OF A CYCLE THAT HAS NO EXTRNAL PARENT roots = dominator_tree(graph).get_children(ROOTS)
[ "RETURN", "DOMINATOR", "FOREST", "THERE", "ARE", "TWO", "TREES", "ROOTS", "and", "LOOPS", "ROOTS", "HAVE", "NO", "PARENTS", "LOOPS", "ARE", "NODES", "THAT", "ARE", "A", "MEMBER", "OF", "A", "CYCLE", "THAT", "HAS", "NO", "EXTRNAL", "PARENT" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_graphs/algorithms.py#L115-L202
klahnakoski/pyLibrary
jx_python/meta.py
get_schema_from_list
def get_schema_from_list(table_name, frum): """ SCAN THE LIST FOR COLUMN TYPES """ columns = UniqueIndex(keys=("name",)) _get_schema_from_list(frum, ".", parent=".", nested_path=ROOT_PATH, columns=columns) return Schema(table_name=table_name, columns=list(columns))
python
def get_schema_from_list(table_name, frum): """ SCAN THE LIST FOR COLUMN TYPES """ columns = UniqueIndex(keys=("name",)) _get_schema_from_list(frum, ".", parent=".", nested_path=ROOT_PATH, columns=columns) return Schema(table_name=table_name, columns=list(columns))
[ "def", "get_schema_from_list", "(", "table_name", ",", "frum", ")", ":", "columns", "=", "UniqueIndex", "(", "keys", "=", "(", "\"name\"", ",", ")", ")", "_get_schema_from_list", "(", "frum", ",", "\".\"", ",", "parent", "=", "\".\"", ",", "nested_path", "...
SCAN THE LIST FOR COLUMN TYPES
[ "SCAN", "THE", "LIST", "FOR", "COLUMN", "TYPES" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/meta.py#L537-L543
klahnakoski/pyLibrary
jx_python/meta.py
_get_schema_from_list
def _get_schema_from_list(frum, table_name, parent, nested_path, columns): """ :param frum: The list :param table_name: Name of the table this list holds records for :param parent: parent path :param nested_path: each nested array, in reverse order :param columns: map from full name to column de...
python
def _get_schema_from_list(frum, table_name, parent, nested_path, columns): """ :param frum: The list :param table_name: Name of the table this list holds records for :param parent: parent path :param nested_path: each nested array, in reverse order :param columns: map from full name to column de...
[ "def", "_get_schema_from_list", "(", "frum", ",", "table_name", ",", "parent", ",", "nested_path", ",", "columns", ")", ":", "for", "d", "in", "frum", ":", "row_type", "=", "python_type_to_json_type", "[", "d", ".", "__class__", "]", "if", "row_type", "!=", ...
:param frum: The list :param table_name: Name of the table this list holds records for :param parent: parent path :param nested_path: each nested array, in reverse order :param columns: map from full name to column definition :return:
[ ":", "param", "frum", ":", "The", "list", ":", "param", "table_name", ":", "Name", "of", "the", "table", "this", "list", "holds", "records", "for", ":", "param", "parent", ":", "parent", "path", ":", "param", "nested_path", ":", "each", "nested", "array"...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/meta.py#L546-L615
klahnakoski/pyLibrary
jx_python/meta.py
ColumnList._add
def _add(self, column): """ :param column: ANY COLUMN OBJECT :return: None IF column IS canonical ALREADY (NET-ZERO EFFECT) """ columns_for_table = self.data.setdefault(column.es_index, {}) existing_columns = columns_for_table.setdefault(column.name, []) for can...
python
def _add(self, column): """ :param column: ANY COLUMN OBJECT :return: None IF column IS canonical ALREADY (NET-ZERO EFFECT) """ columns_for_table = self.data.setdefault(column.es_index, {}) existing_columns = columns_for_table.setdefault(column.name, []) for can...
[ "def", "_add", "(", "self", ",", "column", ")", ":", "columns_for_table", "=", "self", ".", "data", ".", "setdefault", "(", "column", ".", "es_index", ",", "{", "}", ")", "existing_columns", "=", "columns_for_table", ".", "setdefault", "(", "column", ".", ...
:param column: ANY COLUMN OBJECT :return: None IF column IS canonical ALREADY (NET-ZERO EFFECT)
[ ":", "param", "column", ":", "ANY", "COLUMN", "OBJECT", ":", "return", ":", "None", "IF", "column", "IS", "canonical", "ALREADY", "(", "NET", "-", "ZERO", "EFFECT", ")" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/meta.py#L300-L324
klahnakoski/pyLibrary
jx_python/meta.py
ColumnList.denormalized
def denormalized(self): """ THE INTERNAL STRUCTURE FOR THE COLUMN METADATA IS VERY DIFFERENT FROM THE DENORMALIZED PERSPECITVE. THIS PROVIDES THAT PERSPECTIVE FOR QUERIES """ with self.locker: self._update_meta() output = [ { ...
python
def denormalized(self): """ THE INTERNAL STRUCTURE FOR THE COLUMN METADATA IS VERY DIFFERENT FROM THE DENORMALIZED PERSPECITVE. THIS PROVIDES THAT PERSPECTIVE FOR QUERIES """ with self.locker: self._update_meta() output = [ { ...
[ "def", "denormalized", "(", "self", ")", ":", "with", "self", ".", "locker", ":", "self", ".", "_update_meta", "(", ")", "output", "=", "[", "{", "\"table\"", ":", "c", ".", "es_index", ",", "\"name\"", ":", "untype_path", "(", "c", ".", "name", ")",...
THE INTERNAL STRUCTURE FOR THE COLUMN METADATA IS VERY DIFFERENT FROM THE DENORMALIZED PERSPECITVE. THIS PROVIDES THAT PERSPECTIVE FOR QUERIES
[ "THE", "INTERNAL", "STRUCTURE", "FOR", "THE", "COLUMN", "METADATA", "IS", "VERY", "DIFFERENT", "FROM", "THE", "DENORMALIZED", "PERSPECITVE", ".", "THIS", "PROVIDES", "THAT", "PERSPECTIVE", "FOR", "QUERIES" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/meta.py#L502-L534
klahnakoski/pyLibrary
jx_python/namespace/normal.py
normalize_sort
def normalize_sort(sort=None): """ CONVERT SORT PARAMETERS TO A NORMAL FORM SO EASIER TO USE """ if not sort: return Null output = FlatList() for s in listwrap(sort): if is_text(s) or mo_math.is_integer(s): output.append({"value": s, "sort": 1}) elif not s.f...
python
def normalize_sort(sort=None): """ CONVERT SORT PARAMETERS TO A NORMAL FORM SO EASIER TO USE """ if not sort: return Null output = FlatList() for s in listwrap(sort): if is_text(s) or mo_math.is_integer(s): output.append({"value": s, "sort": 1}) elif not s.f...
[ "def", "normalize_sort", "(", "sort", "=", "None", ")", ":", "if", "not", "sort", ":", "return", "Null", "output", "=", "FlatList", "(", ")", "for", "s", "in", "listwrap", "(", "sort", ")", ":", "if", "is_text", "(", "s", ")", "or", "mo_math", ".",...
CONVERT SORT PARAMETERS TO A NORMAL FORM SO EASIER TO USE
[ "CONVERT", "SORT", "PARAMETERS", "TO", "A", "NORMAL", "FORM", "SO", "EASIER", "TO", "USE" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/namespace/normal.py#L225-L243
Galarzaa90/tibia.py
tibiapy/utils.py
parse_tibia_datetime
def parse_tibia_datetime(datetime_str) -> Optional[datetime.datetime]: """Parses date and time from the format used in Tibia.com Accepted format: - ``MMM DD YYYY, HH:mm:ss ZZZ``, e.g. ``Dec 10 2018, 21:53:37 CET``. Parameters ------------- datetime_str: :class:`str` The date and time ...
python
def parse_tibia_datetime(datetime_str) -> Optional[datetime.datetime]: """Parses date and time from the format used in Tibia.com Accepted format: - ``MMM DD YYYY, HH:mm:ss ZZZ``, e.g. ``Dec 10 2018, 21:53:37 CET``. Parameters ------------- datetime_str: :class:`str` The date and time ...
[ "def", "parse_tibia_datetime", "(", "datetime_str", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "try", ":", "datetime_str", "=", "datetime_str", ".", "replace", "(", "\",\"", ",", "\"\"", ")", ".", "replace", "(", "\"&#160;\"", ",", ...
Parses date and time from the format used in Tibia.com Accepted format: - ``MMM DD YYYY, HH:mm:ss ZZZ``, e.g. ``Dec 10 2018, 21:53:37 CET``. Parameters ------------- datetime_str: :class:`str` The date and time as represented in Tibia.com Returns ----------- :class:`datetime....
[ "Parses", "date", "and", "time", "from", "the", "format", "used", "in", "Tibia", ".", "com" ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/utils.py#L10-L47
Galarzaa90/tibia.py
tibiapy/utils.py
parse_tibia_date
def parse_tibia_date(date_str) -> Optional[datetime.date]: """Parses a date from the format used in Tibia.com Accepted format: - ``MMM DD YYYY``, e.g. ``Jul 23 2015`` Parameters ----------- date_str: :class:`str` The date as represented in Tibia.com Returns ----------- :c...
python
def parse_tibia_date(date_str) -> Optional[datetime.date]: """Parses a date from the format used in Tibia.com Accepted format: - ``MMM DD YYYY``, e.g. ``Jul 23 2015`` Parameters ----------- date_str: :class:`str` The date as represented in Tibia.com Returns ----------- :c...
[ "def", "parse_tibia_date", "(", "date_str", ")", "->", "Optional", "[", "datetime", ".", "date", "]", ":", "try", ":", "t", "=", "datetime", ".", "datetime", ".", "strptime", "(", "date_str", ".", "strip", "(", ")", ",", "\"%b %d %Y\"", ")", "return", ...
Parses a date from the format used in Tibia.com Accepted format: - ``MMM DD YYYY``, e.g. ``Jul 23 2015`` Parameters ----------- date_str: :class:`str` The date as represented in Tibia.com Returns ----------- :class:`datetime.date`, optional The represented date.
[ "Parses", "a", "date", "from", "the", "format", "used", "in", "Tibia", ".", "com" ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/utils.py#L50-L70
Galarzaa90/tibia.py
tibiapy/utils.py
parse_tibiadata_datetime
def parse_tibiadata_datetime(date_dict) -> Optional[datetime.datetime]: """Parses time objects from the TibiaData API. Time objects are made of a dictionary with three keys: date: contains a string representation of the time timezone: a string representation of the timezone the date time is bas...
python
def parse_tibiadata_datetime(date_dict) -> Optional[datetime.datetime]: """Parses time objects from the TibiaData API. Time objects are made of a dictionary with three keys: date: contains a string representation of the time timezone: a string representation of the timezone the date time is bas...
[ "def", "parse_tibiadata_datetime", "(", "date_dict", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "try", ":", "t", "=", "datetime", ".", "datetime", ".", "strptime", "(", "date_dict", "[", "\"date\"", "]", ",", "\"%Y-%m-%d %H:%M:%S.%f\"",...
Parses time objects from the TibiaData API. Time objects are made of a dictionary with three keys: date: contains a string representation of the time timezone: a string representation of the timezone the date time is based on timezone_type: the type of representation used in the timezone ke...
[ "Parses", "time", "objects", "from", "the", "TibiaData", "API", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/utils.py#L97-L129
Galarzaa90/tibia.py
tibiapy/utils.py
try_datetime
def try_datetime(obj) -> Optional[datetime.datetime]: """Attempts to convert an object into a datetime. If the date format is known, it's recommended to use the corresponding function This is meant to be used in constructors. Parameters ---------- obj: :class:`str`, :class:`dict`, :class:`date...
python
def try_datetime(obj) -> Optional[datetime.datetime]: """Attempts to convert an object into a datetime. If the date format is known, it's recommended to use the corresponding function This is meant to be used in constructors. Parameters ---------- obj: :class:`str`, :class:`dict`, :class:`date...
[ "def", "try_datetime", "(", "obj", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "if", "obj", "is", "None", ":", "return", "None", "if", "isinstance", "(", "obj", ",", "datetime", ".", "datetime", ")", ":", "return", "obj", "res", ...
Attempts to convert an object into a datetime. If the date format is known, it's recommended to use the corresponding function This is meant to be used in constructors. Parameters ---------- obj: :class:`str`, :class:`dict`, :class:`datetime.datetime` The object to convert. Returns ...
[ "Attempts", "to", "convert", "an", "object", "into", "a", "datetime", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/utils.py#L183-L207
Galarzaa90/tibia.py
tibiapy/utils.py
try_date
def try_date(obj) -> Optional[datetime.date]: """Attempts to convert an object into a date. If the date format is known, it's recommended to use the corresponding function This is meant to be used in constructors. Parameters ---------- obj: :class:`str`, :class:`datetime.datetime`, :class:`dat...
python
def try_date(obj) -> Optional[datetime.date]: """Attempts to convert an object into a date. If the date format is known, it's recommended to use the corresponding function This is meant to be used in constructors. Parameters ---------- obj: :class:`str`, :class:`datetime.datetime`, :class:`dat...
[ "def", "try_date", "(", "obj", ")", "->", "Optional", "[", "datetime", ".", "date", "]", ":", "if", "obj", "is", "None", ":", "return", "None", "if", "isinstance", "(", "obj", ",", "datetime", ".", "datetime", ")", ":", "return", "obj", ".", "date", ...
Attempts to convert an object into a date. If the date format is known, it's recommended to use the corresponding function This is meant to be used in constructors. Parameters ---------- obj: :class:`str`, :class:`datetime.datetime`, :class:`datetime.date` The object to convert. Retur...
[ "Attempts", "to", "convert", "an", "object", "into", "a", "date", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/utils.py#L210-L239
Galarzaa90/tibia.py
tibiapy/utils.py
parse_tibiacom_content
def parse_tibiacom_content(content, *, html_class="BoxContent", tag="div", builder="lxml"): """Parses HTML content from Tibia.com into a BeautifulSoup object. Parameters ---------- content: :class:`str` The raw HTML content from Tibia.com html_class: :class:`str` The HTML class of t...
python
def parse_tibiacom_content(content, *, html_class="BoxContent", tag="div", builder="lxml"): """Parses HTML content from Tibia.com into a BeautifulSoup object. Parameters ---------- content: :class:`str` The raw HTML content from Tibia.com html_class: :class:`str` The HTML class of t...
[ "def", "parse_tibiacom_content", "(", "content", ",", "*", ",", "html_class", "=", "\"BoxContent\"", ",", "tag", "=", "\"div\"", ",", "builder", "=", "\"lxml\"", ")", ":", "return", "bs4", ".", "BeautifulSoup", "(", "content", ".", "replace", "(", "'ISO-8859...
Parses HTML content from Tibia.com into a BeautifulSoup object. Parameters ---------- content: :class:`str` The raw HTML content from Tibia.com html_class: :class:`str` The HTML class of the parsed element. The default value is ``BoxContent``. tag: :class:`str` The HTML tag ...
[ "Parses", "HTML", "content", "from", "Tibia", ".", "com", "into", "a", "BeautifulSoup", "object", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/utils.py#L242-L262
Galarzaa90/tibia.py
tibiapy/utils.py
try_enum
def try_enum(cls: Type[T], val, default: D = None) -> Union[T, D]: """Attempts to convert a value into their enum value Parameters ---------- cls: :class:`Enum` The enum to convert to. val: The value to try to convert to Enum default: optional The value to return if no e...
python
def try_enum(cls: Type[T], val, default: D = None) -> Union[T, D]: """Attempts to convert a value into their enum value Parameters ---------- cls: :class:`Enum` The enum to convert to. val: The value to try to convert to Enum default: optional The value to return if no e...
[ "def", "try_enum", "(", "cls", ":", "Type", "[", "T", "]", ",", "val", ",", "default", ":", "D", "=", "None", ")", "->", "Union", "[", "T", ",", "D", "]", ":", "if", "isinstance", "(", "val", ",", "cls", ")", ":", "return", "val", "try", ":",...
Attempts to convert a value into their enum value Parameters ---------- cls: :class:`Enum` The enum to convert to. val: The value to try to convert to Enum default: optional The value to return if no enum value is found. Returns ------- obj: The enum val...
[ "Attempts", "to", "convert", "a", "value", "into", "their", "enum", "value" ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/utils.py#L269-L291
Galarzaa90/tibia.py
tibiapy/utils.py
parse_json
def parse_json(content): """Tries to parse a string into a json object. This also performs a trim of all values, recursively removing leading and trailing whitespace. Parameters ---------- content: A JSON format string. Returns ------- obj: The object represented by the json s...
python
def parse_json(content): """Tries to parse a string into a json object. This also performs a trim of all values, recursively removing leading and trailing whitespace. Parameters ---------- content: A JSON format string. Returns ------- obj: The object represented by the json s...
[ "def", "parse_json", "(", "content", ")", ":", "try", ":", "json_content", "=", "json", ".", "loads", "(", "content", ")", "return", "_recursive_strip", "(", "json_content", ")", "except", "json", ".", "JSONDecodeError", ":", "raise", "InvalidContent", "(", ...
Tries to parse a string into a json object. This also performs a trim of all values, recursively removing leading and trailing whitespace. Parameters ---------- content: A JSON format string. Returns ------- obj: The object represented by the json string. Raises ------ ...
[ "Tries", "to", "parse", "a", "string", "into", "a", "json", "object", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/utils.py#L294-L317
ninapavlich/django-share-me-share-me
share_me_share_me/templatetags/share_me_share_me_tags.py
get_social_share_link
def get_social_share_link(context, share_link, object_url, object_title): """ Construct the social share link for the request object. """ request = context['request'] url = unicode(object_url) if 'http' not in object_url.lower(): full_path = ''.join(('http', ('', 's')[request.is_secure...
python
def get_social_share_link(context, share_link, object_url, object_title): """ Construct the social share link for the request object. """ request = context['request'] url = unicode(object_url) if 'http' not in object_url.lower(): full_path = ''.join(('http', ('', 's')[request.is_secure...
[ "def", "get_social_share_link", "(", "context", ",", "share_link", ",", "object_url", ",", "object_title", ")", ":", "request", "=", "context", "[", "'request'", "]", "url", "=", "unicode", "(", "object_url", ")", "if", "'http'", "not", "in", "object_url", "...
Construct the social share link for the request object.
[ "Construct", "the", "social", "share", "link", "for", "the", "request", "object", "." ]
train
https://github.com/ninapavlich/django-share-me-share-me/blob/367cf7d3a66e518191ba9b4c7693ce8118c55496/share_me_share_me/templatetags/share_me_share_me_tags.py#L20-L33
klahnakoski/pyLibrary
mo_graphs/naive_graph.py
NaiveGraph.get_family
def get_family(self, node): """ RETURN ALL ADJACENT NODES """ return set(p if c == node else c for p, c in self.get_edges(node))
python
def get_family(self, node): """ RETURN ALL ADJACENT NODES """ return set(p if c == node else c for p, c in self.get_edges(node))
[ "def", "get_family", "(", "self", ",", "node", ")", ":", "return", "set", "(", "p", "if", "c", "==", "node", "else", "c", "for", "p", ",", "c", "in", "self", ".", "get_edges", "(", "node", ")", ")" ]
RETURN ALL ADJACENT NODES
[ "RETURN", "ALL", "ADJACENT", "NODES" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_graphs/naive_graph.py#L51-L55
oblalex/django-candv-choices
candv_x/django/choices/admin.py
ChoicesFieldListFilter.choices
def choices(self, cl): """ Take choices from field's 'choices' attribute for 'ChoicesField' and use 'flatchoices' as usual for other fields. """ #: Just tidy up standard implementation for the sake of DRY principle. def _choice_item(is_selected, query_string, title): ...
python
def choices(self, cl): """ Take choices from field's 'choices' attribute for 'ChoicesField' and use 'flatchoices' as usual for other fields. """ #: Just tidy up standard implementation for the sake of DRY principle. def _choice_item(is_selected, query_string, title): ...
[ "def", "choices", "(", "self", ",", "cl", ")", ":", "#: Just tidy up standard implementation for the sake of DRY principle.", "def", "_choice_item", "(", "is_selected", ",", "query_string", ",", "title", ")", ":", "return", "{", "'selected'", ":", "is_selected", ",", ...
Take choices from field's 'choices' attribute for 'ChoicesField' and use 'flatchoices' as usual for other fields.
[ "Take", "choices", "from", "field", "s", "choices", "attribute", "for", "ChoicesField", "and", "use", "flatchoices", "as", "usual", "for", "other", "fields", "." ]
train
https://github.com/oblalex/django-candv-choices/blob/a299cefceebc2fb23e223dfcc63700dff572b6a0/candv_x/django/choices/admin.py#L17-L43
uralbash/pyramid_pages
pyramid_pages/routes.py
page_factory
def page_factory(request): """ Page factory. Config models example: .. code-block:: python models = { '': [WebPage, CatalogResource], 'catalogue': CatalogResource, 'news': NewsResource, } """ prefix = request.matchdict['prefix'] # /{prefix}/pag...
python
def page_factory(request): """ Page factory. Config models example: .. code-block:: python models = { '': [WebPage, CatalogResource], 'catalogue': CatalogResource, 'news': NewsResource, } """ prefix = request.matchdict['prefix'] # /{prefix}/pag...
[ "def", "page_factory", "(", "request", ")", ":", "prefix", "=", "request", ".", "matchdict", "[", "'prefix'", "]", "# /{prefix}/page1/page2/page3...", "settings", "=", "request", ".", "registry", ".", "settings", "dbsession", "=", "settings", "[", "CONFIG_DBSESSIO...
Page factory. Config models example: .. code-block:: python models = { '': [WebPage, CatalogResource], 'catalogue': CatalogResource, 'news': NewsResource, }
[ "Page", "factory", "." ]
train
https://github.com/uralbash/pyramid_pages/blob/545b1ecb2e5dee5742135ba2a689b9635dd4efa1/pyramid_pages/routes.py#L31-L92
uralbash/pyramid_pages
pyramid_pages/routes.py
register_views
def register_views(*args): """ Registration view for each resource from config. """ config = args[0] settings = config.get_settings() pages_config = settings[CONFIG_MODELS] resources = resources_of_config(pages_config) for resource in resources: if hasattr(resource, '__table__')\ ...
python
def register_views(*args): """ Registration view for each resource from config. """ config = args[0] settings = config.get_settings() pages_config = settings[CONFIG_MODELS] resources = resources_of_config(pages_config) for resource in resources: if hasattr(resource, '__table__')\ ...
[ "def", "register_views", "(", "*", "args", ")", ":", "config", "=", "args", "[", "0", "]", "settings", "=", "config", ".", "get_settings", "(", ")", "pages_config", "=", "settings", "[", "CONFIG_MODELS", "]", "resources", "=", "resources_of_config", "(", "...
Registration view for each resource from config.
[ "Registration", "view", "for", "each", "resource", "from", "config", "." ]
train
https://github.com/uralbash/pyramid_pages/blob/545b1ecb2e5dee5742135ba2a689b9635dd4efa1/pyramid_pages/routes.py#L110-L127
klahnakoski/pyLibrary
jx_elasticsearch/es52/setop.py
accumulate_nested_doc
def accumulate_nested_doc(nested_path, expr=IDENTITY): """ :param nested_path: THE PATH USED TO EXTRACT THE NESTED RECORDS :param expr: FUNCTION USED ON THE NESTED OBJECT TO GET SPECIFIC VALUE :return: THE DE_TYPED NESTED OBJECT ARRAY """ name = literal_field(nested_path) def output(doc): ...
python
def accumulate_nested_doc(nested_path, expr=IDENTITY): """ :param nested_path: THE PATH USED TO EXTRACT THE NESTED RECORDS :param expr: FUNCTION USED ON THE NESTED OBJECT TO GET SPECIFIC VALUE :return: THE DE_TYPED NESTED OBJECT ARRAY """ name = literal_field(nested_path) def output(doc): ...
[ "def", "accumulate_nested_doc", "(", "nested_path", ",", "expr", "=", "IDENTITY", ")", ":", "name", "=", "literal_field", "(", "nested_path", ")", "def", "output", "(", "doc", ")", ":", "acc", "=", "[", "]", "for", "h", "in", "doc", ".", "inner_hits", ...
:param nested_path: THE PATH USED TO EXTRACT THE NESTED RECORDS :param expr: FUNCTION USED ON THE NESTED OBJECT TO GET SPECIFIC VALUE :return: THE DE_TYPED NESTED OBJECT ARRAY
[ ":", "param", "nested_path", ":", "THE", "PATH", "USED", "TO", "EXTRACT", "THE", "NESTED", "RECORDS", ":", "param", "expr", ":", "FUNCTION", "USED", "ON", "THE", "NESTED", "OBJECT", "TO", "GET", "SPECIFIC", "VALUE", ":", "return", ":", "THE", "DE_TYPED", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/es52/setop.py#L224-L244
klahnakoski/pyLibrary
jx_elasticsearch/es52/setop.py
es_query_proto
def es_query_proto(path, selects, wheres, schema): """ RETURN TEMPLATE AND PATH-TO-FILTER AS A 2-TUPLE :param path: THE NESTED PATH (NOT INCLUDING TABLE NAME) :param wheres: MAP FROM path TO LIST OF WHERE CONDITIONS :return: (es_query, filters_map) TUPLE """ output = None last_where = MA...
python
def es_query_proto(path, selects, wheres, schema): """ RETURN TEMPLATE AND PATH-TO-FILTER AS A 2-TUPLE :param path: THE NESTED PATH (NOT INCLUDING TABLE NAME) :param wheres: MAP FROM path TO LIST OF WHERE CONDITIONS :return: (es_query, filters_map) TUPLE """ output = None last_where = MA...
[ "def", "es_query_proto", "(", "path", ",", "selects", ",", "wheres", ",", "schema", ")", ":", "output", "=", "None", "last_where", "=", "MATCH_ALL", "for", "p", "in", "reversed", "(", "sorted", "(", "wheres", ".", "keys", "(", ")", "|", "set", "(", "...
RETURN TEMPLATE AND PATH-TO-FILTER AS A 2-TUPLE :param path: THE NESTED PATH (NOT INCLUDING TABLE NAME) :param wheres: MAP FROM path TO LIST OF WHERE CONDITIONS :return: (es_query, filters_map) TUPLE
[ "RETURN", "TEMPLATE", "AND", "PATH", "-", "TO", "-", "FILTER", "AS", "A", "2", "-", "TUPLE", ":", "param", "path", ":", "THE", "NESTED", "PATH", "(", "NOT", "INCLUDING", "TABLE", "NAME", ")", ":", "param", "wheres", ":", "MAP", "FROM", "path", "TO", ...
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/es52/setop.py#L409-L453