repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
thorgate/tg-react | tg_react/language.py | DjangoLocaleData.get_catalog | def get_catalog(self, locale):
"""Create Django translation catalogue for `locale`."""
with translation.override(locale):
translation_engine = DjangoTranslation(locale, domain=self.domain, localedirs=self.paths)
trans_cat = translation_engine._catalog
trans_fallback_... | python | def get_catalog(self, locale):
"""Create Django translation catalogue for `locale`."""
with translation.override(locale):
translation_engine = DjangoTranslation(locale, domain=self.domain, localedirs=self.paths)
trans_cat = translation_engine._catalog
trans_fallback_... | [
"def",
"get_catalog",
"(",
"self",
",",
"locale",
")",
":",
"with",
"translation",
".",
"override",
"(",
"locale",
")",
":",
"translation_engine",
"=",
"DjangoTranslation",
"(",
"locale",
",",
"domain",
"=",
"self",
".",
"domain",
",",
"localedirs",
"=",
"... | Create Django translation catalogue for `locale`. | [
"Create",
"Django",
"translation",
"catalogue",
"for",
"locale",
"."
] | train | https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L28-L36 |
thorgate/tg-react | tg_react/language.py | DjangoLocaleData.get_paths | def get_paths(cls, packages):
"""Create list of matching packages for translation engine."""
allowable_packages = dict((app_config.name, app_config) for app_config in apps.get_app_configs())
app_configs = [allowable_packages[p] for p in packages if p in allowable_packages]
# paths of req... | python | def get_paths(cls, packages):
"""Create list of matching packages for translation engine."""
allowable_packages = dict((app_config.name, app_config) for app_config in apps.get_app_configs())
app_configs = [allowable_packages[p] for p in packages if p in allowable_packages]
# paths of req... | [
"def",
"get_paths",
"(",
"cls",
",",
"packages",
")",
":",
"allowable_packages",
"=",
"dict",
"(",
"(",
"app_config",
".",
"name",
",",
"app_config",
")",
"for",
"app_config",
"in",
"apps",
".",
"get_app_configs",
"(",
")",
")",
"app_configs",
"=",
"[",
... | Create list of matching packages for translation engine. | [
"Create",
"list",
"of",
"matching",
"packages",
"for",
"translation",
"engine",
"."
] | train | https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L39-L44 |
thorgate/tg-react | tg_react/language.py | DjangoLocaleData.get_catalogue_header_value | def get_catalogue_header_value(cls, catalog, key):
"""Get `.po` header value."""
header_value = None
if '' in catalog:
for line in catalog[''].split('\n'):
if line.startswith('%s:' % key):
header_value = line.split(':', 1)[1].strip()
retur... | python | def get_catalogue_header_value(cls, catalog, key):
"""Get `.po` header value."""
header_value = None
if '' in catalog:
for line in catalog[''].split('\n'):
if line.startswith('%s:' % key):
header_value = line.split(':', 1)[1].strip()
retur... | [
"def",
"get_catalogue_header_value",
"(",
"cls",
",",
"catalog",
",",
"key",
")",
":",
"header_value",
"=",
"None",
"if",
"''",
"in",
"catalog",
":",
"for",
"line",
"in",
"catalog",
"[",
"''",
"]",
".",
"split",
"(",
"'\\n'",
")",
":",
"if",
"line",
... | Get `.po` header value. | [
"Get",
".",
"po",
"header",
"value",
"."
] | train | https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L47-L55 |
thorgate/tg-react | tg_react/language.py | DjangoLocaleData._num_plurals | def _num_plurals(self, catalogue):
"""
Return the number of plurals for this catalog language, or 2 if no
plural string is available.
"""
match = re.search(r'nplurals=\s*(\d+)', self.get_plural(catalogue) or '')
if match:
return int(match.groups()[0])
... | python | def _num_plurals(self, catalogue):
"""
Return the number of plurals for this catalog language, or 2 if no
plural string is available.
"""
match = re.search(r'nplurals=\s*(\d+)', self.get_plural(catalogue) or '')
if match:
return int(match.groups()[0])
... | [
"def",
"_num_plurals",
"(",
"self",
",",
"catalogue",
")",
":",
"match",
"=",
"re",
".",
"search",
"(",
"r'nplurals=\\s*(\\d+)'",
",",
"self",
".",
"get_plural",
"(",
"catalogue",
")",
"or",
"''",
")",
"if",
"match",
":",
"return",
"int",
"(",
"match",
... | Return the number of plurals for this catalog language, or 2 if no
plural string is available. | [
"Return",
"the",
"number",
"of",
"plurals",
"for",
"this",
"catalog",
"language",
"or",
"2",
"if",
"no",
"plural",
"string",
"is",
"available",
"."
] | train | https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L57-L65 |
thorgate/tg-react | tg_react/language.py | DjangoLocaleData.make_header | def make_header(self, locale, catalog):
"""Populate header with correct data from top-most locale file."""
return {
"po-revision-date": self.get_catalogue_header_value(catalog, 'PO-Revision-Date'),
"mime-version": self.get_catalogue_header_value(catalog, 'MIME-Version'),
... | python | def make_header(self, locale, catalog):
"""Populate header with correct data from top-most locale file."""
return {
"po-revision-date": self.get_catalogue_header_value(catalog, 'PO-Revision-Date'),
"mime-version": self.get_catalogue_header_value(catalog, 'MIME-Version'),
... | [
"def",
"make_header",
"(",
"self",
",",
"locale",
",",
"catalog",
")",
":",
"return",
"{",
"\"po-revision-date\"",
":",
"self",
".",
"get_catalogue_header_value",
"(",
"catalog",
",",
"'PO-Revision-Date'",
")",
",",
"\"mime-version\"",
":",
"self",
".",
"get_cat... | Populate header with correct data from top-most locale file. | [
"Populate",
"header",
"with",
"correct",
"data",
"from",
"top",
"-",
"most",
"locale",
"file",
"."
] | train | https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L72-L89 |
thorgate/tg-react | tg_react/language.py | DjangoLocaleData.collect_translations | def collect_translations(self):
"""Collect all `domain` translations and return `Tuple[languages, locale_data]`"""
languages = {}
locale_data = {}
for language_code, label in settings.LANGUAGES:
languages[language_code] = '%s' % label
# Create django translation... | python | def collect_translations(self):
"""Collect all `domain` translations and return `Tuple[languages, locale_data]`"""
languages = {}
locale_data = {}
for language_code, label in settings.LANGUAGES:
languages[language_code] = '%s' % label
# Create django translation... | [
"def",
"collect_translations",
"(",
"self",
")",
":",
"languages",
"=",
"{",
"}",
"locale_data",
"=",
"{",
"}",
"for",
"language_code",
",",
"label",
"in",
"settings",
".",
"LANGUAGES",
":",
"languages",
"[",
"language_code",
"]",
"=",
"'%s'",
"%",
"label"... | Collect all `domain` translations and return `Tuple[languages, locale_data]` | [
"Collect",
"all",
"domain",
"translations",
"and",
"return",
"Tuple",
"[",
"languages",
"locale_data",
"]"
] | train | https://github.com/thorgate/tg-react/blob/5a6e83d5a5c883f1a5ee4fda2226e81a468bdee3/tg_react/language.py#L91-L132 |
mieubrisse/wunderpy2 | wunderpy2/endpoint_helpers.py | get_endpoint_obj | def get_endpoint_obj(client, endpoint, object_id):
''' Tiny helper function that gets used all over the place to join the object ID to the endpoint and run a GET request, returning the result '''
endpoint = '/'.join([endpoint, str(object_id)])
return client.authenticated_request(endpoint).json() | python | def get_endpoint_obj(client, endpoint, object_id):
''' Tiny helper function that gets used all over the place to join the object ID to the endpoint and run a GET request, returning the result '''
endpoint = '/'.join([endpoint, str(object_id)])
return client.authenticated_request(endpoint).json() | [
"def",
"get_endpoint_obj",
"(",
"client",
",",
"endpoint",
",",
"object_id",
")",
":",
"endpoint",
"=",
"'/'",
".",
"join",
"(",
"[",
"endpoint",
",",
"str",
"(",
"object_id",
")",
"]",
")",
"return",
"client",
".",
"authenticated_request",
"(",
"endpoint"... | Tiny helper function that gets used all over the place to join the object ID to the endpoint and run a GET request, returning the result | [
"Tiny",
"helper",
"function",
"that",
"gets",
"used",
"all",
"over",
"the",
"place",
"to",
"join",
"the",
"object",
"ID",
"to",
"the",
"endpoint",
"and",
"run",
"a",
"GET",
"request",
"returning",
"the",
"result"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/endpoint_helpers.py#L1-L4 |
mieubrisse/wunderpy2 | wunderpy2/endpoint_helpers.py | update_endpoint_obj | def update_endpoint_obj(client, endpoint, object_id, revision, data):
'''
Helper method to ease the repetitiveness of updating an... SO VERY DRY
(That's a doubly-effective pun becuase my predecessor - https://github.com/bsmt/wunderpy - found maintaing a Python Wunderlist API to be "as tedious and bor... | python | def update_endpoint_obj(client, endpoint, object_id, revision, data):
'''
Helper method to ease the repetitiveness of updating an... SO VERY DRY
(That's a doubly-effective pun becuase my predecessor - https://github.com/bsmt/wunderpy - found maintaing a Python Wunderlist API to be "as tedious and bor... | [
"def",
"update_endpoint_obj",
"(",
"client",
",",
"endpoint",
",",
"object_id",
",",
"revision",
",",
"data",
")",
":",
"data",
"[",
"'revision'",
"]",
"=",
"int",
"(",
"revision",
")",
"endpoint",
"=",
"'/'",
".",
"join",
"(",
"[",
"endpoint",
",",
"s... | Helper method to ease the repetitiveness of updating an... SO VERY DRY
(That's a doubly-effective pun becuase my predecessor - https://github.com/bsmt/wunderpy - found maintaing a Python Wunderlist API to be "as tedious and boring as a liberal arts school poetry slam") | [
"Helper",
"method",
"to",
"ease",
"the",
"repetitiveness",
"of",
"updating",
"an",
"...",
"SO",
"VERY",
"DRY",
"(",
"That",
"s",
"a",
"doubly",
"-",
"effective",
"pun",
"becuase",
"my",
"predecessor",
"-",
"https",
":",
"//",
"github",
".",
"com",
"/",
... | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/endpoint_helpers.py#L6-L14 |
mieubrisse/wunderpy2 | wunderpy2/wunderapi.py | WunderApi._validate_response | def _validate_response(self, method, response):
''' Helper method to validate the given to a Wunderlist API request is as expected '''
# TODO Fill this out using the error codes here: https://developer.wunderlist.com/documentation/concepts/formats
# The expected results can change based on API v... | python | def _validate_response(self, method, response):
''' Helper method to validate the given to a Wunderlist API request is as expected '''
# TODO Fill this out using the error codes here: https://developer.wunderlist.com/documentation/concepts/formats
# The expected results can change based on API v... | [
"def",
"_validate_response",
"(",
"self",
",",
"method",
",",
"response",
")",
":",
"# TODO Fill this out using the error codes here: https://developer.wunderlist.com/documentation/concepts/formats",
"# The expected results can change based on API version, so validate this here",
"if",
"se... | Helper method to validate the given to a Wunderlist API request is as expected | [
"Helper",
"method",
"to",
"validate",
"the",
"given",
"to",
"a",
"Wunderlist",
"API",
"request",
"is",
"as",
"expected"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderapi.py#L34-L48 |
mieubrisse/wunderpy2 | wunderpy2/wunderapi.py | WunderApi.request | def request(self, endpoint, method='GET', headers=None, params=None, data=None):
'''
Send a request to the given Wunderlist API endpoint
Params:
endpoint -- API endpoint to send request to
Keyword Args:
headers -- headers to add to the request
method -- GET, PUT... | python | def request(self, endpoint, method='GET', headers=None, params=None, data=None):
'''
Send a request to the given Wunderlist API endpoint
Params:
endpoint -- API endpoint to send request to
Keyword Args:
headers -- headers to add to the request
method -- GET, PUT... | [
"def",
"request",
"(",
"self",
",",
"endpoint",
",",
"method",
"=",
"'GET'",
",",
"headers",
"=",
"None",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"if",
"not",
"headers",
":",
"headers",
"=",
"{",
"}",
"if",
"method",
"in",
... | Send a request to the given Wunderlist API endpoint
Params:
endpoint -- API endpoint to send request to
Keyword Args:
headers -- headers to add to the request
method -- GET, PUT, PATCH, DELETE, etc.
params -- parameters to encode in the request
data -- data to s... | [
"Send",
"a",
"request",
"to",
"the",
"given",
"Wunderlist",
"API",
"endpoint"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderapi.py#L50-L77 |
mieubrisse/wunderpy2 | wunderpy2/wunderapi.py | WunderApi.get_access_token | def get_access_token(self, code, client_id, client_secret):
'''
Exchange a temporary code for an access token allowing access to a user's account
See https://developer.wunderlist.com/documentation/concepts/authorization for more info
'''
headers = {
'Content-Typ... | python | def get_access_token(self, code, client_id, client_secret):
'''
Exchange a temporary code for an access token allowing access to a user's account
See https://developer.wunderlist.com/documentation/concepts/authorization for more info
'''
headers = {
'Content-Typ... | [
"def",
"get_access_token",
"(",
"self",
",",
"code",
",",
"client_id",
",",
"client_secret",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
"}",
"data",
"=",
"{",
"'client_id'",
":",
"client_id",
",",
"'client_secret'",
":",
"clien... | Exchange a temporary code for an access token allowing access to a user's account
See https://developer.wunderlist.com/documentation/concepts/authorization for more info | [
"Exchange",
"a",
"temporary",
"code",
"for",
"an",
"access",
"token",
"allowing",
"access",
"to",
"a",
"user",
"s",
"account"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderapi.py#L79-L98 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.authenticated_request | def authenticated_request(self, endpoint, method='GET', params=None, data=None):
'''
Send a request to the given Wunderlist API with 'X-Access-Token' and 'X-Client-ID' headers and ensure the response code is as expected given the request type
Params:
endpoint -- API endpoint to send req... | python | def authenticated_request(self, endpoint, method='GET', params=None, data=None):
'''
Send a request to the given Wunderlist API with 'X-Access-Token' and 'X-Client-ID' headers and ensure the response code is as expected given the request type
Params:
endpoint -- API endpoint to send req... | [
"def",
"authenticated_request",
"(",
"self",
",",
"endpoint",
",",
"method",
"=",
"'GET'",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"headers",
"=",
"{",
"'X-Access-Token'",
":",
"self",
".",
"access_token",
",",
"'X-Client-ID'",
":",... | Send a request to the given Wunderlist API with 'X-Access-Token' and 'X-Client-ID' headers and ensure the response code is as expected given the request type
Params:
endpoint -- API endpoint to send request to
Keyword Args:
method -- GET, PUT, PATCH, DELETE, etc.
params -- para... | [
"Send",
"a",
"request",
"to",
"the",
"given",
"Wunderlist",
"API",
"with",
"X",
"-",
"Access",
"-",
"Token",
"and",
"X",
"-",
"Client",
"-",
"ID",
"headers",
"and",
"ensure",
"the",
"response",
"code",
"is",
"as",
"expected",
"given",
"the",
"request",
... | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L29-L45 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.update_list | def update_list(self, list_id, revision, title=None, public=None):
''' Updates the list with the given ID to have the given title and public flag '''
return lists_endpoint.update_list(self, list_id, revision, title=title, public=public) | python | def update_list(self, list_id, revision, title=None, public=None):
''' Updates the list with the given ID to have the given title and public flag '''
return lists_endpoint.update_list(self, list_id, revision, title=title, public=public) | [
"def",
"update_list",
"(",
"self",
",",
"list_id",
",",
"revision",
",",
"title",
"=",
"None",
",",
"public",
"=",
"None",
")",
":",
"return",
"lists_endpoint",
".",
"update_list",
"(",
"self",
",",
"list_id",
",",
"revision",
",",
"title",
"=",
"title",... | Updates the list with the given ID to have the given title and public flag | [
"Updates",
"the",
"list",
"with",
"the",
"given",
"ID",
"to",
"have",
"the",
"given",
"title",
"and",
"public",
"flag"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L59-L61 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.get_tasks | def get_tasks(self, list_id, completed=False):
''' Gets tasks for the list with the given ID, filtered by the given completion flag '''
return tasks_endpoint.get_tasks(self, list_id, completed=completed) | python | def get_tasks(self, list_id, completed=False):
''' Gets tasks for the list with the given ID, filtered by the given completion flag '''
return tasks_endpoint.get_tasks(self, list_id, completed=completed) | [
"def",
"get_tasks",
"(",
"self",
",",
"list_id",
",",
"completed",
"=",
"False",
")",
":",
"return",
"tasks_endpoint",
".",
"get_tasks",
"(",
"self",
",",
"list_id",
",",
"completed",
"=",
"completed",
")"
] | Gets tasks for the list with the given ID, filtered by the given completion flag | [
"Gets",
"tasks",
"for",
"the",
"list",
"with",
"the",
"given",
"ID",
"filtered",
"by",
"the",
"given",
"completion",
"flag"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L67-L69 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.create_task | def create_task(self, list_id, title, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None):
''' Creates a new task with the given information in the list with the given ID '''
return tasks_endpoint.create_task(self, list_id, title, assignee_id=assig... | python | def create_task(self, list_id, title, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None):
''' Creates a new task with the given information in the list with the given ID '''
return tasks_endpoint.create_task(self, list_id, title, assignee_id=assig... | [
"def",
"create_task",
"(",
"self",
",",
"list_id",
",",
"title",
",",
"assignee_id",
"=",
"None",
",",
"completed",
"=",
"None",
",",
"recurrence_type",
"=",
"None",
",",
"recurrence_count",
"=",
"None",
",",
"due_date",
"=",
"None",
",",
"starred",
"=",
... | Creates a new task with the given information in the list with the given ID | [
"Creates",
"a",
"new",
"task",
"with",
"the",
"given",
"information",
"in",
"the",
"list",
"with",
"the",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L75-L77 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.update_task | def update_task(self, task_id, revision, title=None, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None, remove=None):
'''
Updates the task with the given ID to have the given information
NOTE: The 'remove' parameter is an option... | python | def update_task(self, task_id, revision, title=None, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None, remove=None):
'''
Updates the task with the given ID to have the given information
NOTE: The 'remove' parameter is an option... | [
"def",
"update_task",
"(",
"self",
",",
"task_id",
",",
"revision",
",",
"title",
"=",
"None",
",",
"assignee_id",
"=",
"None",
",",
"completed",
"=",
"None",
",",
"recurrence_type",
"=",
"None",
",",
"recurrence_count",
"=",
"None",
",",
"due_date",
"=",
... | Updates the task with the given ID to have the given information
NOTE: The 'remove' parameter is an optional list of parameters to remove from the given task, e.g. ['due_date'] | [
"Updates",
"the",
"task",
"with",
"the",
"given",
"ID",
"to",
"have",
"the",
"given",
"information",
"NOTE",
":",
"The",
"remove",
"parameter",
"is",
"an",
"optional",
"list",
"of",
"parameters",
"to",
"remove",
"from",
"the",
"given",
"task",
"e",
".",
... | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L79-L85 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.update_note | def update_note(self, note_id, revision, content):
''' Updates the note with the given ID to have the given content '''
return notes_endpoint.update_note(self, note_id, revision, content) | python | def update_note(self, note_id, revision, content):
''' Updates the note with the given ID to have the given content '''
return notes_endpoint.update_note(self, note_id, revision, content) | [
"def",
"update_note",
"(",
"self",
",",
"note_id",
",",
"revision",
",",
"content",
")",
":",
"return",
"notes_endpoint",
".",
"update_note",
"(",
"self",
",",
"note_id",
",",
"revision",
",",
"content",
")"
] | Updates the note with the given ID to have the given content | [
"Updates",
"the",
"note",
"with",
"the",
"given",
"ID",
"to",
"have",
"the",
"given",
"content"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L116-L118 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.get_task_subtasks | def get_task_subtasks(self, task_id, completed=False):
''' Gets subtasks for task with given ID '''
return subtasks_endpoint.get_task_subtasks(self, task_id, completed=completed) | python | def get_task_subtasks(self, task_id, completed=False):
''' Gets subtasks for task with given ID '''
return subtasks_endpoint.get_task_subtasks(self, task_id, completed=completed) | [
"def",
"get_task_subtasks",
"(",
"self",
",",
"task_id",
",",
"completed",
"=",
"False",
")",
":",
"return",
"subtasks_endpoint",
".",
"get_task_subtasks",
"(",
"self",
",",
"task_id",
",",
"completed",
"=",
"completed",
")"
] | Gets subtasks for task with given ID | [
"Gets",
"subtasks",
"for",
"task",
"with",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L130-L132 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.get_list_subtasks | def get_list_subtasks(self, list_id, completed=False):
''' Gets subtasks for the list with given ID '''
return subtasks_endpoint.get_list_subtasks(self, list_id, completed=completed) | python | def get_list_subtasks(self, list_id, completed=False):
''' Gets subtasks for the list with given ID '''
return subtasks_endpoint.get_list_subtasks(self, list_id, completed=completed) | [
"def",
"get_list_subtasks",
"(",
"self",
",",
"list_id",
",",
"completed",
"=",
"False",
")",
":",
"return",
"subtasks_endpoint",
".",
"get_list_subtasks",
"(",
"self",
",",
"list_id",
",",
"completed",
"=",
"completed",
")"
] | Gets subtasks for the list with given ID | [
"Gets",
"subtasks",
"for",
"the",
"list",
"with",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L134-L136 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.create_subtask | def create_subtask(self, task_id, title, completed=False):
'''
Creates a subtask with the given title under the task with the given ID
Return:
Newly-created subtask
'''
return subtasks_endpoint.create_subtask(self, task_id, title, completed=completed) | python | def create_subtask(self, task_id, title, completed=False):
'''
Creates a subtask with the given title under the task with the given ID
Return:
Newly-created subtask
'''
return subtasks_endpoint.create_subtask(self, task_id, title, completed=completed) | [
"def",
"create_subtask",
"(",
"self",
",",
"task_id",
",",
"title",
",",
"completed",
"=",
"False",
")",
":",
"return",
"subtasks_endpoint",
".",
"create_subtask",
"(",
"self",
",",
"task_id",
",",
"title",
",",
"completed",
"=",
"completed",
")"
] | Creates a subtask with the given title under the task with the given ID
Return:
Newly-created subtask | [
"Creates",
"a",
"subtask",
"with",
"the",
"given",
"title",
"under",
"the",
"task",
"with",
"the",
"given",
"ID",
"Return",
":",
"Newly",
"-",
"created",
"subtask"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L142-L149 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.update_subtask | def update_subtask(self, subtask_id, revision, title=None, completed=None):
'''
Updates the subtask with the given ID
See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information
Returns:
Subtask with given ID with properties and revis... | python | def update_subtask(self, subtask_id, revision, title=None, completed=None):
'''
Updates the subtask with the given ID
See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information
Returns:
Subtask with given ID with properties and revis... | [
"def",
"update_subtask",
"(",
"self",
",",
"subtask_id",
",",
"revision",
",",
"title",
"=",
"None",
",",
"completed",
"=",
"None",
")",
":",
"return",
"subtasks_endpoint",
".",
"update_subtask",
"(",
"self",
",",
"subtask_id",
",",
"revision",
",",
"title",... | Updates the subtask with the given ID
See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information
Returns:
Subtask with given ID with properties and revision updated | [
"Updates",
"the",
"subtask",
"with",
"the",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L151-L160 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.update_list_positions_obj | def update_list_positions_obj(self, positions_obj_id, revision, values):
'''
Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out.
See https://developer.wunderlist.com/documentation/endpoints/positions... | python | def update_list_positions_obj(self, positions_obj_id, revision, values):
'''
Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out.
See https://developer.wunderlist.com/documentation/endpoints/positions... | [
"def",
"update_list_positions_obj",
"(",
"self",
",",
"positions_obj_id",
",",
"revision",
",",
"values",
")",
":",
"return",
"positions_endpoints",
".",
"update_list_positions_obj",
"(",
"self",
",",
"positions_obj_id",
",",
"revision",
",",
"values",
")"
] | Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
The updated ListPositionsObj-mapped object defining t... | [
"Updates",
"the",
"ordering",
"of",
"lists",
"to",
"have",
"the",
"given",
"value",
".",
"The",
"given",
"ID",
"and",
"revision",
"should",
"match",
"the",
"singleton",
"object",
"defining",
"how",
"lists",
"are",
"laid",
"out",
"."
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L188-L197 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.update_task_positions_obj | def update_task_positions_obj(self, positions_obj_id, revision, values):
'''
Updates the ordering of tasks in the positions object with the given ID to the ordering in the given values.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
... | python | def update_task_positions_obj(self, positions_obj_id, revision, values):
'''
Updates the ordering of tasks in the positions object with the given ID to the ordering in the given values.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
... | [
"def",
"update_task_positions_obj",
"(",
"self",
",",
"positions_obj_id",
",",
"revision",
",",
"values",
")",
":",
"return",
"positions_endpoints",
".",
"update_task_positions_obj",
"(",
"self",
",",
"positions_obj_id",
",",
"revision",
",",
"values",
")"
] | Updates the ordering of tasks in the positions object with the given ID to the ordering in the given values.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
The updated TaskPositionsObj-mapped object defining the order of list layout | [
"Updates",
"the",
"ordering",
"of",
"tasks",
"in",
"the",
"positions",
"object",
"with",
"the",
"given",
"ID",
"to",
"the",
"ordering",
"in",
"the",
"given",
"values",
"."
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L221-L230 |
mieubrisse/wunderpy2 | wunderpy2/wunderclient.py | WunderClient.update_subtask_positions_obj | def update_subtask_positions_obj(self, positions_obj_id, revision, values):
'''
Updates the ordering of subtasks in the positions object with the given ID to the ordering in the given values.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
... | python | def update_subtask_positions_obj(self, positions_obj_id, revision, values):
'''
Updates the ordering of subtasks in the positions object with the given ID to the ordering in the given values.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
... | [
"def",
"update_subtask_positions_obj",
"(",
"self",
",",
"positions_obj_id",
",",
"revision",
",",
"values",
")",
":",
"return",
"positions_endpoints",
".",
"update_subtask_positions_obj",
"(",
"self",
",",
"positions_obj_id",
",",
"revision",
",",
"values",
")"
] | Updates the ordering of subtasks in the positions object with the given ID to the ordering in the given values.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
The updated SubtaskPositionsObj-mapped object defining the order of list layout | [
"Updates",
"the",
"ordering",
"of",
"subtasks",
"in",
"the",
"positions",
"object",
"with",
"the",
"given",
"ID",
"to",
"the",
"ordering",
"in",
"the",
"given",
"values",
"."
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/wunderclient.py#L263-L272 |
mieubrisse/wunderpy2 | wunderpy2/tasks_endpoint.py | _check_date_format | def _check_date_format(date, api):
''' Checks that the given date string conforms to the given API's date format specification '''
try:
datetime.datetime.strptime(date, api.DATE_FORMAT)
except ValueError:
raise ValueError("Date '{}' does not conform to API format: {}".format(date, api.DATE_F... | python | def _check_date_format(date, api):
''' Checks that the given date string conforms to the given API's date format specification '''
try:
datetime.datetime.strptime(date, api.DATE_FORMAT)
except ValueError:
raise ValueError("Date '{}' does not conform to API format: {}".format(date, api.DATE_F... | [
"def",
"_check_date_format",
"(",
"date",
",",
"api",
")",
":",
"try",
":",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"date",
",",
"api",
".",
"DATE_FORMAT",
")",
"except",
"ValueError",
":",
"raise",
"ValueError",
"(",
"\"Date '{}' does not conform t... | Checks that the given date string conforms to the given API's date format specification | [
"Checks",
"that",
"the",
"given",
"date",
"string",
"conforms",
"to",
"the",
"given",
"API",
"s",
"date",
"format",
"specification"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L11-L16 |
mieubrisse/wunderpy2 | wunderpy2/tasks_endpoint.py | get_tasks | def get_tasks(client, list_id, completed=False):
''' Gets un/completed tasks for the given list ID '''
params = {
'list_id' : str(list_id),
'completed' : completed
}
response = client.authenticated_request(client.api.Endpoints.TASKS, params=params)
return response.... | python | def get_tasks(client, list_id, completed=False):
''' Gets un/completed tasks for the given list ID '''
params = {
'list_id' : str(list_id),
'completed' : completed
}
response = client.authenticated_request(client.api.Endpoints.TASKS, params=params)
return response.... | [
"def",
"get_tasks",
"(",
"client",
",",
"list_id",
",",
"completed",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'list_id'",
":",
"str",
"(",
"list_id",
")",
",",
"'completed'",
":",
"completed",
"}",
"response",
"=",
"client",
".",
"authenticated_request... | Gets un/completed tasks for the given list ID | [
"Gets",
"un",
"/",
"completed",
"tasks",
"for",
"the",
"given",
"list",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L18-L25 |
mieubrisse/wunderpy2 | wunderpy2/tasks_endpoint.py | get_task | def get_task(client, task_id):
''' Gets task information for the given ID '''
endpoint = '/'.join([client.api.Endpoints.TASKS, str(task_id)])
response = client.authenticated_request(endpoint)
return response.json() | python | def get_task(client, task_id):
''' Gets task information for the given ID '''
endpoint = '/'.join([client.api.Endpoints.TASKS, str(task_id)])
response = client.authenticated_request(endpoint)
return response.json() | [
"def",
"get_task",
"(",
"client",
",",
"task_id",
")",
":",
"endpoint",
"=",
"'/'",
".",
"join",
"(",
"[",
"client",
".",
"api",
".",
"Endpoints",
".",
"TASKS",
",",
"str",
"(",
"task_id",
")",
"]",
")",
"response",
"=",
"client",
".",
"authenticated... | Gets task information for the given ID | [
"Gets",
"task",
"information",
"for",
"the",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L27-L31 |
mieubrisse/wunderpy2 | wunderpy2/tasks_endpoint.py | create_task | def create_task(client, list_id, title, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None):
'''
Creates a task in the given list
See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter information
'''
_check... | python | def create_task(client, list_id, title, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None):
'''
Creates a task in the given list
See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter information
'''
_check... | [
"def",
"create_task",
"(",
"client",
",",
"list_id",
",",
"title",
",",
"assignee_id",
"=",
"None",
",",
"completed",
"=",
"None",
",",
"recurrence_type",
"=",
"None",
",",
"recurrence_count",
"=",
"None",
",",
"due_date",
"=",
"None",
",",
"starred",
"=",... | Creates a task in the given list
See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter information | [
"Creates",
"a",
"task",
"in",
"the",
"given",
"list"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L33-L56 |
mieubrisse/wunderpy2 | wunderpy2/tasks_endpoint.py | update_task | def update_task(client, task_id, revision, title=None, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None, remove=None):
'''
Updates the task with the given ID
See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter in... | python | def update_task(client, task_id, revision, title=None, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None, remove=None):
'''
Updates the task with the given ID
See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter in... | [
"def",
"update_task",
"(",
"client",
",",
"task_id",
",",
"revision",
",",
"title",
"=",
"None",
",",
"assignee_id",
"=",
"None",
",",
"completed",
"=",
"None",
",",
"recurrence_type",
"=",
"None",
",",
"recurrence_count",
"=",
"None",
",",
"due_date",
"="... | Updates the task with the given ID
See https://developer.wunderlist.com/documentation/endpoints/task for detailed parameter information | [
"Updates",
"the",
"task",
"with",
"the",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/tasks_endpoint.py#L58-L84 |
mieubrisse/wunderpy2 | wunderpy2/lists_endpoint.py | _check_title_length | def _check_title_length(title, api):
''' Checks the given title against the given API specifications to ensure it's short enough '''
if len(title) > api.MAX_LIST_TITLE_LENGTH:
raise ValueError("Title cannot be longer than {} characters".format(api.MAX_TASK_TITLE_LENGTH)) | python | def _check_title_length(title, api):
''' Checks the given title against the given API specifications to ensure it's short enough '''
if len(title) > api.MAX_LIST_TITLE_LENGTH:
raise ValueError("Title cannot be longer than {} characters".format(api.MAX_TASK_TITLE_LENGTH)) | [
"def",
"_check_title_length",
"(",
"title",
",",
"api",
")",
":",
"if",
"len",
"(",
"title",
")",
">",
"api",
".",
"MAX_LIST_TITLE_LENGTH",
":",
"raise",
"ValueError",
"(",
"\"Title cannot be longer than {} characters\"",
".",
"format",
"(",
"api",
".",
"MAX_TAS... | Checks the given title against the given API specifications to ensure it's short enough | [
"Checks",
"the",
"given",
"title",
"against",
"the",
"given",
"API",
"specifications",
"to",
"ensure",
"it",
"s",
"short",
"enough"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/lists_endpoint.py#L4-L7 |
mieubrisse/wunderpy2 | wunderpy2/lists_endpoint.py | get_lists | def get_lists(client):
''' Gets all the client's lists '''
response = client.authenticated_request(client.api.Endpoints.LISTS)
return response.json() | python | def get_lists(client):
''' Gets all the client's lists '''
response = client.authenticated_request(client.api.Endpoints.LISTS)
return response.json() | [
"def",
"get_lists",
"(",
"client",
")",
":",
"response",
"=",
"client",
".",
"authenticated_request",
"(",
"client",
".",
"api",
".",
"Endpoints",
".",
"LISTS",
")",
"return",
"response",
".",
"json",
"(",
")"
] | Gets all the client's lists | [
"Gets",
"all",
"the",
"client",
"s",
"lists"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/lists_endpoint.py#L9-L12 |
mieubrisse/wunderpy2 | wunderpy2/lists_endpoint.py | get_list | def get_list(client, list_id):
''' Gets the given list '''
endpoint = '/'.join([client.api.Endpoints.LISTS, str(list_id)])
response = client.authenticated_request(endpoint)
return response.json() | python | def get_list(client, list_id):
''' Gets the given list '''
endpoint = '/'.join([client.api.Endpoints.LISTS, str(list_id)])
response = client.authenticated_request(endpoint)
return response.json() | [
"def",
"get_list",
"(",
"client",
",",
"list_id",
")",
":",
"endpoint",
"=",
"'/'",
".",
"join",
"(",
"[",
"client",
".",
"api",
".",
"Endpoints",
".",
"LISTS",
",",
"str",
"(",
"list_id",
")",
"]",
")",
"response",
"=",
"client",
".",
"authenticated... | Gets the given list | [
"Gets",
"the",
"given",
"list"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/lists_endpoint.py#L14-L18 |
mieubrisse/wunderpy2 | wunderpy2/lists_endpoint.py | create_list | def create_list(client, title):
''' Creates a new list with the given title '''
_check_title_length(title, client.api)
data = {
'title' : title,
}
response = client.authenticated_request(client.api.Endpoints.LISTS, method='POST', data=data)
return response.json() | python | def create_list(client, title):
''' Creates a new list with the given title '''
_check_title_length(title, client.api)
data = {
'title' : title,
}
response = client.authenticated_request(client.api.Endpoints.LISTS, method='POST', data=data)
return response.json() | [
"def",
"create_list",
"(",
"client",
",",
"title",
")",
":",
"_check_title_length",
"(",
"title",
",",
"client",
".",
"api",
")",
"data",
"=",
"{",
"'title'",
":",
"title",
",",
"}",
"response",
"=",
"client",
".",
"authenticated_request",
"(",
"client",
... | Creates a new list with the given title | [
"Creates",
"a",
"new",
"list",
"with",
"the",
"given",
"title"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/lists_endpoint.py#L20-L27 |
mieubrisse/wunderpy2 | wunderpy2/lists_endpoint.py | update_list | def update_list(client, list_id, revision, title=None, public=None):
'''
Updates the list with the given ID to have the given properties
See https://developer.wunderlist.com/documentation/endpoints/list for detailed parameter information
'''
if title is not None:
_check_title_length(title, ... | python | def update_list(client, list_id, revision, title=None, public=None):
'''
Updates the list with the given ID to have the given properties
See https://developer.wunderlist.com/documentation/endpoints/list for detailed parameter information
'''
if title is not None:
_check_title_length(title, ... | [
"def",
"update_list",
"(",
"client",
",",
"list_id",
",",
"revision",
",",
"title",
"=",
"None",
",",
"public",
"=",
"None",
")",
":",
"if",
"title",
"is",
"not",
"None",
":",
"_check_title_length",
"(",
"title",
",",
"client",
".",
"api",
")",
"data",... | Updates the list with the given ID to have the given properties
See https://developer.wunderlist.com/documentation/endpoints/list for detailed parameter information | [
"Updates",
"the",
"list",
"with",
"the",
"given",
"ID",
"to",
"have",
"the",
"given",
"properties"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/lists_endpoint.py#L29-L45 |
mieubrisse/wunderpy2 | wunderpy2/positions_endpoints.py | get_list_positions_obj | def get_list_positions_obj(client, positions_obj_id):
'''
Gets the object that defines how lists are ordered (there will always be only one of these)
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
A ListPositionsObj-mapped object defining the order of ... | python | def get_list_positions_obj(client, positions_obj_id):
'''
Gets the object that defines how lists are ordered (there will always be only one of these)
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
A ListPositionsObj-mapped object defining the order of ... | [
"def",
"get_list_positions_obj",
"(",
"client",
",",
"positions_obj_id",
")",
":",
"return",
"endpoint_helpers",
".",
"get_endpoint_obj",
"(",
"client",
",",
"client",
".",
"api",
".",
"Endpoints",
".",
"LIST_POSITIONS",
",",
"positions_obj_id",
")"
] | Gets the object that defines how lists are ordered (there will always be only one of these)
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
A ListPositionsObj-mapped object defining the order of list layout | [
"Gets",
"the",
"object",
"that",
"defines",
"how",
"lists",
"are",
"ordered",
"(",
"there",
"will",
"always",
"be",
"only",
"one",
"of",
"these",
")"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/positions_endpoints.py#L27-L36 |
mieubrisse/wunderpy2 | wunderpy2/positions_endpoints.py | update_list_positions_obj | def update_list_positions_obj(client, positions_obj_id, revision, values):
'''
Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out.
See https://developer.wunderlist.com/documentation/endpoints/positions for more ... | python | def update_list_positions_obj(client, positions_obj_id, revision, values):
'''
Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out.
See https://developer.wunderlist.com/documentation/endpoints/positions for more ... | [
"def",
"update_list_positions_obj",
"(",
"client",
",",
"positions_obj_id",
",",
"revision",
",",
"values",
")",
":",
"return",
"_update_positions_obj",
"(",
"client",
",",
"client",
".",
"api",
".",
"Endpoints",
".",
"LIST_POSITIONS",
",",
"positions_obj_id",
","... | Updates the ordering of lists to have the given value. The given ID and revision should match the singleton object defining how lists are laid out.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
The updated ListPositionsObj-mapped object defining the order of ... | [
"Updates",
"the",
"ordering",
"of",
"lists",
"to",
"have",
"the",
"given",
"value",
".",
"The",
"given",
"ID",
"and",
"revision",
"should",
"match",
"the",
"singleton",
"object",
"defining",
"how",
"lists",
"are",
"laid",
"out",
"."
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/positions_endpoints.py#L39-L48 |
mieubrisse/wunderpy2 | wunderpy2/positions_endpoints.py | get_task_positions_objs | def get_task_positions_objs(client, list_id):
'''
Gets a list containing the object that encapsulates information about the order lists are laid out in. This list will always contain exactly one object.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
A ... | python | def get_task_positions_objs(client, list_id):
'''
Gets a list containing the object that encapsulates information about the order lists are laid out in. This list will always contain exactly one object.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
A ... | [
"def",
"get_task_positions_objs",
"(",
"client",
",",
"list_id",
")",
":",
"params",
"=",
"{",
"'list_id'",
":",
"int",
"(",
"list_id",
")",
"}",
"response",
"=",
"client",
".",
"authenticated_request",
"(",
"client",
".",
"api",
".",
"Endpoints",
".",
"TA... | Gets a list containing the object that encapsulates information about the order lists are laid out in. This list will always contain exactly one object.
See https://developer.wunderlist.com/documentation/endpoints/positions for more info
Return:
A list containing a single ListPositionsObj-mapped object | [
"Gets",
"a",
"list",
"containing",
"the",
"object",
"that",
"encapsulates",
"information",
"about",
"the",
"order",
"lists",
"are",
"laid",
"out",
"in",
".",
"This",
"list",
"will",
"always",
"contain",
"exactly",
"one",
"object",
"."
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/positions_endpoints.py#L50-L63 |
mieubrisse/wunderpy2 | wunderpy2/positions_endpoints.py | get_task_subtask_positions_objs | def get_task_subtask_positions_objs(client, task_id):
'''
Gets a list of the positions of a single task's subtasks
Each task should (will?) only have one positions object defining how its subtasks are laid out
'''
params = {
'task_id' : int(task_id)
}
response = client.a... | python | def get_task_subtask_positions_objs(client, task_id):
'''
Gets a list of the positions of a single task's subtasks
Each task should (will?) only have one positions object defining how its subtasks are laid out
'''
params = {
'task_id' : int(task_id)
}
response = client.a... | [
"def",
"get_task_subtask_positions_objs",
"(",
"client",
",",
"task_id",
")",
":",
"params",
"=",
"{",
"'task_id'",
":",
"int",
"(",
"task_id",
")",
"}",
"response",
"=",
"client",
".",
"authenticated_request",
"(",
"client",
".",
"api",
".",
"Endpoints",
".... | Gets a list of the positions of a single task's subtasks
Each task should (will?) only have one positions object defining how its subtasks are laid out | [
"Gets",
"a",
"list",
"of",
"the",
"positions",
"of",
"a",
"single",
"task",
"s",
"subtasks"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/positions_endpoints.py#L71-L81 |
mieubrisse/wunderpy2 | wunderpy2/positions_endpoints.py | get_list_subtask_positions_objs | def get_list_subtask_positions_objs(client, list_id):
'''
Gets all subtask positions objects for the tasks within a given list. This is a convenience method so you don't have to get all the list's tasks before getting subtasks, though I can't fathom how mass subtask reordering is useful.
Returns:
List ... | python | def get_list_subtask_positions_objs(client, list_id):
'''
Gets all subtask positions objects for the tasks within a given list. This is a convenience method so you don't have to get all the list's tasks before getting subtasks, though I can't fathom how mass subtask reordering is useful.
Returns:
List ... | [
"def",
"get_list_subtask_positions_objs",
"(",
"client",
",",
"list_id",
")",
":",
"params",
"=",
"{",
"'list_id'",
":",
"int",
"(",
"list_id",
")",
"}",
"response",
"=",
"client",
".",
"authenticated_request",
"(",
"client",
".",
"api",
".",
"Endpoints",
".... | Gets all subtask positions objects for the tasks within a given list. This is a convenience method so you don't have to get all the list's tasks before getting subtasks, though I can't fathom how mass subtask reordering is useful.
Returns:
List of SubtaskPositionsObj-mapped objects representing the order of su... | [
"Gets",
"all",
"subtask",
"positions",
"objects",
"for",
"the",
"tasks",
"within",
"a",
"given",
"list",
".",
"This",
"is",
"a",
"convenience",
"method",
"so",
"you",
"don",
"t",
"have",
"to",
"get",
"all",
"the",
"list",
"s",
"tasks",
"before",
"getting... | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/positions_endpoints.py#L84-L95 |
mieubrisse/wunderpy2 | wunderpy2/subtasks_endpoint.py | _check_title_length | def _check_title_length(title, api):
''' Checks the given title against the given API specifications to ensure it's short enough '''
if len(title) > api.MAX_SUBTASK_TITLE_LENGTH:
raise ValueError("Title cannot be longer than {} characters".format(api.MAX_SUBTASK_TITLE_LENGTH)) | python | def _check_title_length(title, api):
''' Checks the given title against the given API specifications to ensure it's short enough '''
if len(title) > api.MAX_SUBTASK_TITLE_LENGTH:
raise ValueError("Title cannot be longer than {} characters".format(api.MAX_SUBTASK_TITLE_LENGTH)) | [
"def",
"_check_title_length",
"(",
"title",
",",
"api",
")",
":",
"if",
"len",
"(",
"title",
")",
">",
"api",
".",
"MAX_SUBTASK_TITLE_LENGTH",
":",
"raise",
"ValueError",
"(",
"\"Title cannot be longer than {} characters\"",
".",
"format",
"(",
"api",
".",
"MAX_... | Checks the given title against the given API specifications to ensure it's short enough | [
"Checks",
"the",
"given",
"title",
"against",
"the",
"given",
"API",
"specifications",
"to",
"ensure",
"it",
"s",
"short",
"enough"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L5-L8 |
mieubrisse/wunderpy2 | wunderpy2/subtasks_endpoint.py | get_task_subtasks | def get_task_subtasks(client, task_id, completed=False):
''' Gets subtasks for task with given ID '''
params = {
'task_id' : int(task_id),
'completed' : completed,
}
response = client.authenticated_request(client.api.Endpoints.SUBTASKS, params=params)
return response.... | python | def get_task_subtasks(client, task_id, completed=False):
''' Gets subtasks for task with given ID '''
params = {
'task_id' : int(task_id),
'completed' : completed,
}
response = client.authenticated_request(client.api.Endpoints.SUBTASKS, params=params)
return response.... | [
"def",
"get_task_subtasks",
"(",
"client",
",",
"task_id",
",",
"completed",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'task_id'",
":",
"int",
"(",
"task_id",
")",
",",
"'completed'",
":",
"completed",
",",
"}",
"response",
"=",
"client",
".",
"authen... | Gets subtasks for task with given ID | [
"Gets",
"subtasks",
"for",
"task",
"with",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L10-L17 |
mieubrisse/wunderpy2 | wunderpy2/subtasks_endpoint.py | get_list_subtasks | def get_list_subtasks(client, list_id, completed=False):
''' Gets subtasks for the list with given ID '''
params = {
'list_id' : int(list_id),
'completed' : completed,
}
response = client.authenticated_request(client.api.Endpoints.SUBTASKS, params=params)
return respo... | python | def get_list_subtasks(client, list_id, completed=False):
''' Gets subtasks for the list with given ID '''
params = {
'list_id' : int(list_id),
'completed' : completed,
}
response = client.authenticated_request(client.api.Endpoints.SUBTASKS, params=params)
return respo... | [
"def",
"get_list_subtasks",
"(",
"client",
",",
"list_id",
",",
"completed",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'list_id'",
":",
"int",
"(",
"list_id",
")",
",",
"'completed'",
":",
"completed",
",",
"}",
"response",
"=",
"client",
".",
"authen... | Gets subtasks for the list with given ID | [
"Gets",
"subtasks",
"for",
"the",
"list",
"with",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L19-L26 |
mieubrisse/wunderpy2 | wunderpy2/subtasks_endpoint.py | get_subtask | def get_subtask(client, subtask_id):
''' Gets the subtask with the given ID '''
endpoint = '/'.join([client.api.Endpoints.SUBTASKS, str(subtask_id)])
response = client.authenticated_request(endpoint)
return response.json() | python | def get_subtask(client, subtask_id):
''' Gets the subtask with the given ID '''
endpoint = '/'.join([client.api.Endpoints.SUBTASKS, str(subtask_id)])
response = client.authenticated_request(endpoint)
return response.json() | [
"def",
"get_subtask",
"(",
"client",
",",
"subtask_id",
")",
":",
"endpoint",
"=",
"'/'",
".",
"join",
"(",
"[",
"client",
".",
"api",
".",
"Endpoints",
".",
"SUBTASKS",
",",
"str",
"(",
"subtask_id",
")",
"]",
")",
"response",
"=",
"client",
".",
"a... | Gets the subtask with the given ID | [
"Gets",
"the",
"subtask",
"with",
"the",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L28-L32 |
mieubrisse/wunderpy2 | wunderpy2/subtasks_endpoint.py | create_subtask | def create_subtask(client, task_id, title, completed=False):
''' Creates a subtask with the given title under the task with the given ID '''
_check_title_length(title, client.api)
data = {
'task_id' : int(task_id) if task_id else None,
'title' : title,
'completed' : compl... | python | def create_subtask(client, task_id, title, completed=False):
''' Creates a subtask with the given title under the task with the given ID '''
_check_title_length(title, client.api)
data = {
'task_id' : int(task_id) if task_id else None,
'title' : title,
'completed' : compl... | [
"def",
"create_subtask",
"(",
"client",
",",
"task_id",
",",
"title",
",",
"completed",
"=",
"False",
")",
":",
"_check_title_length",
"(",
"title",
",",
"client",
".",
"api",
")",
"data",
"=",
"{",
"'task_id'",
":",
"int",
"(",
"task_id",
")",
"if",
"... | Creates a subtask with the given title under the task with the given ID | [
"Creates",
"a",
"subtask",
"with",
"the",
"given",
"title",
"under",
"the",
"task",
"with",
"the",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L34-L44 |
mieubrisse/wunderpy2 | wunderpy2/subtasks_endpoint.py | update_subtask | def update_subtask(client, subtask_id, revision, title=None, completed=None):
'''
Updates the subtask with the given ID
See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information
'''
if title is not None:
_check_title_length(title, client.api)
... | python | def update_subtask(client, subtask_id, revision, title=None, completed=None):
'''
Updates the subtask with the given ID
See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information
'''
if title is not None:
_check_title_length(title, client.api)
... | [
"def",
"update_subtask",
"(",
"client",
",",
"subtask_id",
",",
"revision",
",",
"title",
"=",
"None",
",",
"completed",
"=",
"None",
")",
":",
"if",
"title",
"is",
"not",
"None",
":",
"_check_title_length",
"(",
"title",
",",
"client",
".",
"api",
")",
... | Updates the subtask with the given ID
See https://developer.wunderlist.com/documentation/endpoints/subtask for detailed parameter information | [
"Updates",
"the",
"subtask",
"with",
"the",
"given",
"ID"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L46-L62 |
mieubrisse/wunderpy2 | wunderpy2/subtasks_endpoint.py | delete_subtask | def delete_subtask(client, subtask_id, revision):
''' Deletes the subtask with the given ID provided the given revision equals the revision the server has '''
params = {
'revision' : int(revision),
}
endpoint = '/'.join([client.api.Endpoints.SUBTASKS, str(subtask_id)])
client.aut... | python | def delete_subtask(client, subtask_id, revision):
''' Deletes the subtask with the given ID provided the given revision equals the revision the server has '''
params = {
'revision' : int(revision),
}
endpoint = '/'.join([client.api.Endpoints.SUBTASKS, str(subtask_id)])
client.aut... | [
"def",
"delete_subtask",
"(",
"client",
",",
"subtask_id",
",",
"revision",
")",
":",
"params",
"=",
"{",
"'revision'",
":",
"int",
"(",
"revision",
")",
",",
"}",
"endpoint",
"=",
"'/'",
".",
"join",
"(",
"[",
"client",
".",
"api",
".",
"Endpoints",
... | Deletes the subtask with the given ID provided the given revision equals the revision the server has | [
"Deletes",
"the",
"subtask",
"with",
"the",
"given",
"ID",
"provided",
"the",
"given",
"revision",
"equals",
"the",
"revision",
"the",
"server",
"has"
] | train | https://github.com/mieubrisse/wunderpy2/blob/7106b6c13ca45ef4d56f805753c93258d5b822c2/wunderpy2/subtasks_endpoint.py#L64-L70 |
bprinty/animation | animation/decorators.py | wait | def wait(animation='elipses', text='', speed=0.2):
"""
Decorator for adding wait animation to long running
functions.
Args:
animation (str, tuple): String reference to animation or tuple
with custom animation.
speed (float): Number of seconds each cycle of animation.
Ex... | python | def wait(animation='elipses', text='', speed=0.2):
"""
Decorator for adding wait animation to long running
functions.
Args:
animation (str, tuple): String reference to animation or tuple
with custom animation.
speed (float): Number of seconds each cycle of animation.
Ex... | [
"def",
"wait",
"(",
"animation",
"=",
"'elipses'",
",",
"text",
"=",
"''",
",",
"speed",
"=",
"0.2",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"func",
".",
"animation",
"=",
"animation",
"func",
".",
"speed",
"=",
"speed",
"func",
".",
"... | Decorator for adding wait animation to long running
functions.
Args:
animation (str, tuple): String reference to animation or tuple
with custom animation.
speed (float): Number of seconds each cycle of animation.
Examples:
>>> @animation.wait('bar')
>>> def long... | [
"Decorator",
"for",
"adding",
"wait",
"animation",
"to",
"long",
"running",
"functions",
"."
] | train | https://github.com/bprinty/animation/blob/e5c87bf593de1f04e5ce341496b8dff7ce5296ee/animation/decorators.py#L105-L143 |
bprinty/animation | animation/decorators.py | simple_wait | def simple_wait(func):
"""
Decorator for adding simple text wait animation to
long running functions.
Examples:
>>> @animation.simple_wait
>>> def long_running_function():
>>> ... 5 seconds later ...
>>> return
"""
@wraps(func)
def wrapper(*args, **kw... | python | def simple_wait(func):
"""
Decorator for adding simple text wait animation to
long running functions.
Examples:
>>> @animation.simple_wait
>>> def long_running_function():
>>> ... 5 seconds later ...
>>> return
"""
@wraps(func)
def wrapper(*args, **kw... | [
"def",
"simple_wait",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"wait",
"=",
"Wait",
"(",
")",
"wait",
".",
"start",
"(",
")",
"try",
":",
"ret",
"=",
"func",
... | Decorator for adding simple text wait animation to
long running functions.
Examples:
>>> @animation.simple_wait
>>> def long_running_function():
>>> ... 5 seconds later ...
>>> return | [
"Decorator",
"for",
"adding",
"simple",
"text",
"wait",
"animation",
"to",
"long",
"running",
"functions",
"."
] | train | https://github.com/bprinty/animation/blob/e5c87bf593de1f04e5ce341496b8dff7ce5296ee/animation/decorators.py#L146-L167 |
bprinty/animation | animation/decorators.py | Wait.start | def start(self):
"""
Start animation thread.
"""
self.thread = threading.Thread(target=self._animate)
self.thread.start()
return | python | def start(self):
"""
Start animation thread.
"""
self.thread = threading.Thread(target=self._animate)
self.thread.start()
return | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"_animate",
")",
"self",
".",
"thread",
".",
"start",
"(",
")",
"return"
] | Start animation thread. | [
"Start",
"animation",
"thread",
"."
] | train | https://github.com/bprinty/animation/blob/e5c87bf593de1f04e5ce341496b8dff7ce5296ee/animation/decorators.py#L84-L90 |
bprinty/animation | animation/decorators.py | Wait.stop | def stop(self):
"""
Stop animation thread.
"""
time.sleep(self.speed)
self._count = -9999
sys.stdout.write(self.reverser + '\r\033[K\033[A')
sys.stdout.flush()
return | python | def stop(self):
"""
Stop animation thread.
"""
time.sleep(self.speed)
self._count = -9999
sys.stdout.write(self.reverser + '\r\033[K\033[A')
sys.stdout.flush()
return | [
"def",
"stop",
"(",
"self",
")",
":",
"time",
".",
"sleep",
"(",
"self",
".",
"speed",
")",
"self",
".",
"_count",
"=",
"-",
"9999",
"sys",
".",
"stdout",
".",
"write",
"(",
"self",
".",
"reverser",
"+",
"'\\r\\033[K\\033[A'",
")",
"sys",
".",
"std... | Stop animation thread. | [
"Stop",
"animation",
"thread",
"."
] | train | https://github.com/bprinty/animation/blob/e5c87bf593de1f04e5ce341496b8dff7ce5296ee/animation/decorators.py#L92-L100 |
mattja/nsim | nsim/timeseries.py | merge | def merge(tup):
"""Merge several timeseries
Arguments:
tup: sequence of Timeseries, with the same shape except for axis 0
Returns:
Resulting merged timeseries which can have duplicate time points.
"""
if not all(tuple(ts.shape[1:] == tup[0].shape[1:] for ts in tup[1:])):
raise V... | python | def merge(tup):
"""Merge several timeseries
Arguments:
tup: sequence of Timeseries, with the same shape except for axis 0
Returns:
Resulting merged timeseries which can have duplicate time points.
"""
if not all(tuple(ts.shape[1:] == tup[0].shape[1:] for ts in tup[1:])):
raise V... | [
"def",
"merge",
"(",
"tup",
")",
":",
"if",
"not",
"all",
"(",
"tuple",
"(",
"ts",
".",
"shape",
"[",
"1",
":",
"]",
"==",
"tup",
"[",
"0",
"]",
".",
"shape",
"[",
"1",
":",
"]",
"for",
"ts",
"in",
"tup",
"[",
"1",
":",
"]",
")",
")",
"... | Merge several timeseries
Arguments:
tup: sequence of Timeseries, with the same shape except for axis 0
Returns:
Resulting merged timeseries which can have duplicate time points. | [
"Merge",
"several",
"timeseries",
"Arguments",
":",
"tup",
":",
"sequence",
"of",
"Timeseries",
"with",
"the",
"same",
"shape",
"except",
"for",
"axis",
"0",
"Returns",
":",
"Resulting",
"merged",
"timeseries",
"which",
"can",
"have",
"duplicate",
"time",
"poi... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L865-L875 |
mattja/nsim | nsim/timeseries.py | Timeseries.add_analyses | def add_analyses(cls, source):
"""Dynamically add new analysis methods to the Timeseries class.
Args:
source: Can be a function, module or the filename of a python file.
If a filename or a module is given, then all functions defined
inside not starting with _ will be a... | python | def add_analyses(cls, source):
"""Dynamically add new analysis methods to the Timeseries class.
Args:
source: Can be a function, module or the filename of a python file.
If a filename or a module is given, then all functions defined
inside not starting with _ will be a... | [
"def",
"add_analyses",
"(",
"cls",
",",
"source",
")",
":",
"if",
"isinstance",
"(",
"source",
",",
"types",
".",
"FunctionType",
")",
":",
"_add_single_method",
"(",
"source",
".",
"__name__",
",",
"source",
")",
"else",
":",
"if",
"isinstance",
"(",
"s... | Dynamically add new analysis methods to the Timeseries class.
Args:
source: Can be a function, module or the filename of a python file.
If a filename or a module is given, then all functions defined
inside not starting with _ will be added as methods.
The only restric... | [
"Dynamically",
"add",
"new",
"analysis",
"methods",
"to",
"the",
"Timeseries",
"class",
".",
"Args",
":",
"source",
":",
"Can",
"be",
"a",
"function",
"module",
"or",
"the",
"filename",
"of",
"a",
"python",
"file",
".",
"If",
"a",
"filename",
"or",
"a",
... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L119-L155 |
mattja/nsim | nsim/timeseries.py | Timeseries.absolute | def absolute(self):
"""Calculate the absolute value element-wise.
Returns:
absolute (Timeseries):
Absolute value. For complex input (a + b*j) gives sqrt(a**a + b**2)
"""
return Timeseries(np.absolute(self), self.tspan, self.labels) | python | def absolute(self):
"""Calculate the absolute value element-wise.
Returns:
absolute (Timeseries):
Absolute value. For complex input (a + b*j) gives sqrt(a**a + b**2)
"""
return Timeseries(np.absolute(self), self.tspan, self.labels) | [
"def",
"absolute",
"(",
"self",
")",
":",
"return",
"Timeseries",
"(",
"np",
".",
"absolute",
"(",
"self",
")",
",",
"self",
".",
"tspan",
",",
"self",
".",
"labels",
")"
] | Calculate the absolute value element-wise.
Returns:
absolute (Timeseries):
Absolute value. For complex input (a + b*j) gives sqrt(a**a + b**2) | [
"Calculate",
"the",
"absolute",
"value",
"element",
"-",
"wise",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L448-L455 |
mattja/nsim | nsim/timeseries.py | Timeseries.angle | def angle(self, deg=False):
"""Return the angle of the complex argument.
Args:
deg (bool, optional):
Return angle in degrees if True, radians if False (default).
Returns:
angle (Timeseries):
The counterclockwise angle from the positive real axis on
... | python | def angle(self, deg=False):
"""Return the angle of the complex argument.
Args:
deg (bool, optional):
Return angle in degrees if True, radians if False (default).
Returns:
angle (Timeseries):
The counterclockwise angle from the positive real axis on
... | [
"def",
"angle",
"(",
"self",
",",
"deg",
"=",
"False",
")",
":",
"if",
"self",
".",
"dtype",
".",
"str",
"[",
"1",
"]",
"!=",
"'c'",
":",
"warnings",
".",
"warn",
"(",
"'angle() is intended for complex-valued timeseries'",
",",
"RuntimeWarning",
",",
"1",
... | Return the angle of the complex argument.
Args:
deg (bool, optional):
Return angle in degrees if True, radians if False (default).
Returns:
angle (Timeseries):
The counterclockwise angle from the positive real axis on
the complex plane, with dtyp... | [
"Return",
"the",
"angle",
"of",
"the",
"complex",
"argument",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L461-L476 |
mattja/nsim | nsim/timeseries.py | Timeseries.swapaxes | def swapaxes(self, axis1, axis2):
"""Interchange two axes of a Timeseries."""
if self.ndim <=1 or axis1 == axis2:
return self
ar = np.asarray(self).swapaxes(axis1, axis2)
if axis1 != 0 and axis2 != 0:
# then axis 0 is unaffected by the swap
labels = se... | python | def swapaxes(self, axis1, axis2):
"""Interchange two axes of a Timeseries."""
if self.ndim <=1 or axis1 == axis2:
return self
ar = np.asarray(self).swapaxes(axis1, axis2)
if axis1 != 0 and axis2 != 0:
# then axis 0 is unaffected by the swap
labels = se... | [
"def",
"swapaxes",
"(",
"self",
",",
"axis1",
",",
"axis2",
")",
":",
"if",
"self",
".",
"ndim",
"<=",
"1",
"or",
"axis1",
"==",
"axis2",
":",
"return",
"self",
"ar",
"=",
"np",
".",
"asarray",
"(",
"self",
")",
".",
"swapaxes",
"(",
"axis1",
","... | Interchange two axes of a Timeseries. | [
"Interchange",
"two",
"axes",
"of",
"a",
"Timeseries",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L487-L497 |
mattja/nsim | nsim/timeseries.py | Timeseries.transpose | def transpose(self, *axes):
"""Permute the dimensions of a Timeseries."""
if self.ndim <= 1:
return self
ar = np.asarray(self).transpose(*axes)
if axes[0] != 0:
# then axis 0 is unaffected by the transposition
newlabels = [self.labels[ax] for ax in axe... | python | def transpose(self, *axes):
"""Permute the dimensions of a Timeseries."""
if self.ndim <= 1:
return self
ar = np.asarray(self).transpose(*axes)
if axes[0] != 0:
# then axis 0 is unaffected by the transposition
newlabels = [self.labels[ax] for ax in axe... | [
"def",
"transpose",
"(",
"self",
",",
"*",
"axes",
")",
":",
"if",
"self",
".",
"ndim",
"<=",
"1",
":",
"return",
"self",
"ar",
"=",
"np",
".",
"asarray",
"(",
"self",
")",
".",
"transpose",
"(",
"*",
"axes",
")",
"if",
"axes",
"[",
"0",
"]",
... | Permute the dimensions of a Timeseries. | [
"Permute",
"the",
"dimensions",
"of",
"a",
"Timeseries",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L499-L509 |
mattja/nsim | nsim/timeseries.py | Timeseries.reshape | def reshape(self, newshape, order='C'):
"""If axis 0 is unaffected by the reshape, then returns a Timeseries,
otherwise returns an ndarray. Preserves labels of axis j only if all
axes<=j are unaffected by the reshape.
See ``numpy.ndarray.reshape()`` for more information
"""
... | python | def reshape(self, newshape, order='C'):
"""If axis 0 is unaffected by the reshape, then returns a Timeseries,
otherwise returns an ndarray. Preserves labels of axis j only if all
axes<=j are unaffected by the reshape.
See ``numpy.ndarray.reshape()`` for more information
"""
... | [
"def",
"reshape",
"(",
"self",
",",
"newshape",
",",
"order",
"=",
"'C'",
")",
":",
"oldshape",
"=",
"self",
".",
"shape",
"ar",
"=",
"np",
".",
"asarray",
"(",
"self",
")",
".",
"reshape",
"(",
"newshape",
",",
"order",
"=",
"order",
")",
"if",
... | If axis 0 is unaffected by the reshape, then returns a Timeseries,
otherwise returns an ndarray. Preserves labels of axis j only if all
axes<=j are unaffected by the reshape.
See ``numpy.ndarray.reshape()`` for more information | [
"If",
"axis",
"0",
"is",
"unaffected",
"by",
"the",
"reshape",
"then",
"returns",
"a",
"Timeseries",
"otherwise",
"returns",
"an",
"ndarray",
".",
"Preserves",
"labels",
"of",
"axis",
"j",
"only",
"if",
"all",
"axes<",
"=",
"j",
"are",
"unaffected",
"by",
... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L517-L540 |
mattja/nsim | nsim/timeseries.py | Timeseries.merge | def merge(self, ts):
"""Merge another timeseries with this one
Arguments:
ts (Timeseries): The two timeseries being merged must have the
same shape except for axis 0.
Returns:
Resulting merged timeseries which can have duplicate time points.
"""
i... | python | def merge(self, ts):
"""Merge another timeseries with this one
Arguments:
ts (Timeseries): The two timeseries being merged must have the
same shape except for axis 0.
Returns:
Resulting merged timeseries which can have duplicate time points.
"""
i... | [
"def",
"merge",
"(",
"self",
",",
"ts",
")",
":",
"if",
"ts",
".",
"shape",
"[",
"1",
":",
"]",
"!=",
"self",
".",
"shape",
"[",
"1",
":",
"]",
":",
"raise",
"ValueError",
"(",
"'Timeseries to merge must have compatible shapes'",
")",
"indices",
"=",
"... | Merge another timeseries with this one
Arguments:
ts (Timeseries): The two timeseries being merged must have the
same shape except for axis 0.
Returns:
Resulting merged timeseries which can have duplicate time points. | [
"Merge",
"another",
"timeseries",
"with",
"this",
"one",
"Arguments",
":",
"ts",
"(",
"Timeseries",
")",
":",
"The",
"two",
"timeseries",
"being",
"merged",
"must",
"have",
"the",
"same",
"shape",
"except",
"for",
"axis",
"0",
".",
"Returns",
":",
"Resulti... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L651-L662 |
mattja/nsim | nsim/timeseries.py | Timeseries.expand_dims | def expand_dims(self, axis):
"""Insert a new axis, at a given position in the array shape
Args:
axis (int): Position (amongst axes) where new axis is to be inserted.
"""
if axis == -1:
axis = self.ndim
array = np.expand_dims(self, axis)
if axis == 0:... | python | def expand_dims(self, axis):
"""Insert a new axis, at a given position in the array shape
Args:
axis (int): Position (amongst axes) where new axis is to be inserted.
"""
if axis == -1:
axis = self.ndim
array = np.expand_dims(self, axis)
if axis == 0:... | [
"def",
"expand_dims",
"(",
"self",
",",
"axis",
")",
":",
"if",
"axis",
"==",
"-",
"1",
":",
"axis",
"=",
"self",
".",
"ndim",
"array",
"=",
"np",
".",
"expand_dims",
"(",
"self",
",",
"axis",
")",
"if",
"axis",
"==",
"0",
":",
"# prepended an axis... | Insert a new axis, at a given position in the array shape
Args:
axis (int): Position (amongst axes) where new axis is to be inserted. | [
"Insert",
"a",
"new",
"axis",
"at",
"a",
"given",
"position",
"in",
"the",
"array",
"shape",
"Args",
":",
"axis",
"(",
"int",
")",
":",
"Position",
"(",
"amongst",
"axes",
")",
"where",
"new",
"axis",
"is",
"to",
"be",
"inserted",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L664-L677 |
mattja/nsim | nsim/timeseries.py | Timeseries.concatenate | def concatenate(self, tup, axis=0):
"""Join a sequence of Timeseries to this one
Args:
tup (sequence of Timeseries): timeseries to be joined with this one.
They must have the same shape as this Timeseries, except in the
dimension corresponding to `axis`.
axis... | python | def concatenate(self, tup, axis=0):
"""Join a sequence of Timeseries to this one
Args:
tup (sequence of Timeseries): timeseries to be joined with this one.
They must have the same shape as this Timeseries, except in the
dimension corresponding to `axis`.
axis... | [
"def",
"concatenate",
"(",
"self",
",",
"tup",
",",
"axis",
"=",
"0",
")",
":",
"if",
"not",
"isinstance",
"(",
"tup",
",",
"Sequence",
")",
":",
"tup",
"=",
"(",
"tup",
",",
")",
"if",
"tup",
"is",
"(",
"None",
",",
")",
"or",
"len",
"(",
"t... | Join a sequence of Timeseries to this one
Args:
tup (sequence of Timeseries): timeseries to be joined with this one.
They must have the same shape as this Timeseries, except in the
dimension corresponding to `axis`.
axis (int, optional): The axis along which timeseri... | [
"Join",
"a",
"sequence",
"of",
"Timeseries",
"to",
"this",
"one",
"Args",
":",
"tup",
"(",
"sequence",
"of",
"Timeseries",
")",
":",
"timeseries",
"to",
"be",
"joined",
"with",
"this",
"one",
".",
"They",
"must",
"have",
"the",
"same",
"shape",
"as",
"... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L679-L728 |
mattja/nsim | nsim/timeseries.py | Timeseries.split | def split(self, indices_or_sections, axis=0):
"""Split a timeseries into multiple sub-timeseries"""
if not isinstance(indices_or_sections, numbers.Integral):
raise Error('splitting by array of indices is not yet implemented')
n = indices_or_sections
if self.shape[axis] % n !=... | python | def split(self, indices_or_sections, axis=0):
"""Split a timeseries into multiple sub-timeseries"""
if not isinstance(indices_or_sections, numbers.Integral):
raise Error('splitting by array of indices is not yet implemented')
n = indices_or_sections
if self.shape[axis] % n !=... | [
"def",
"split",
"(",
"self",
",",
"indices_or_sections",
",",
"axis",
"=",
"0",
")",
":",
"if",
"not",
"isinstance",
"(",
"indices_or_sections",
",",
"numbers",
".",
"Integral",
")",
":",
"raise",
"Error",
"(",
"'splitting by array of indices is not yet implemente... | Split a timeseries into multiple sub-timeseries | [
"Split",
"a",
"timeseries",
"into",
"multiple",
"sub",
"-",
"timeseries"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/timeseries.py#L730-L747 |
mattja/nsim | nsim/analysesN/plots.py | plot | def plot(dts, title=None, points=None, show=True):
"""Plot a distributed timeseries
Args:
dts (DistTimeseries)
title (str, optional)
points (int, optional): Limit the number of time points plotted.
If specified, will downsample to use this total number of time points,
and on... | python | def plot(dts, title=None, points=None, show=True):
"""Plot a distributed timeseries
Args:
dts (DistTimeseries)
title (str, optional)
points (int, optional): Limit the number of time points plotted.
If specified, will downsample to use this total number of time points,
and on... | [
"def",
"plot",
"(",
"dts",
",",
"title",
"=",
"None",
",",
"points",
"=",
"None",
",",
"show",
"=",
"True",
")",
":",
"if",
"points",
"is",
"not",
"None",
"and",
"len",
"(",
"dts",
".",
"tspan",
")",
">",
"points",
":",
"# then downsample (TODO: use... | Plot a distributed timeseries
Args:
dts (DistTimeseries)
title (str, optional)
points (int, optional): Limit the number of time points plotted.
If specified, will downsample to use this total number of time points,
and only fetch back the necessary points to the client for plott... | [
"Plot",
"a",
"distributed",
"timeseries",
"Args",
":",
"dts",
"(",
"DistTimeseries",
")",
"title",
"(",
"str",
"optional",
")",
"points",
"(",
"int",
"optional",
")",
":",
"Limit",
"the",
"number",
"of",
"time",
"points",
"plotted",
".",
"If",
"specified",... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/plots.py#L20-L36 |
mattja/nsim | nsim/analysesN/plots.py | phase_histogram | def phase_histogram(dts, times=None, nbins=30, colormap=mpl.cm.Blues):
"""Plot a polar histogram of a phase variable's probability distribution
Args:
dts: DistTimeseries with axis 2 ranging over separate instances of an
oscillator (time series values are assumed to represent an angle)
times ... | python | def phase_histogram(dts, times=None, nbins=30, colormap=mpl.cm.Blues):
"""Plot a polar histogram of a phase variable's probability distribution
Args:
dts: DistTimeseries with axis 2 ranging over separate instances of an
oscillator (time series values are assumed to represent an angle)
times ... | [
"def",
"phase_histogram",
"(",
"dts",
",",
"times",
"=",
"None",
",",
"nbins",
"=",
"30",
",",
"colormap",
"=",
"mpl",
".",
"cm",
".",
"Blues",
")",
":",
"if",
"times",
"is",
"None",
":",
"times",
"=",
"np",
".",
"linspace",
"(",
"dts",
".",
"tsp... | Plot a polar histogram of a phase variable's probability distribution
Args:
dts: DistTimeseries with axis 2 ranging over separate instances of an
oscillator (time series values are assumed to represent an angle)
times (float or sequence of floats): The target times at which
to plot the ... | [
"Plot",
"a",
"polar",
"histogram",
"of",
"a",
"phase",
"variable",
"s",
"probability",
"distribution",
"Args",
":",
"dts",
":",
"DistTimeseries",
"with",
"axis",
"2",
"ranging",
"over",
"separate",
"instances",
"of",
"an",
"oscillator",
"(",
"time",
"series",
... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/plots.py#L39-L81 |
mattja/nsim | nsim/analyses1/freq.py | psd | def psd(ts, nperseg=1500, noverlap=1200, plot=True):
"""plot Welch estimate of power spectral density, using nperseg samples per
segment, with noverlap samples overlap and Hamming window."""
ts = ts.squeeze()
if ts.ndim is 1:
ts = ts.reshape((-1, 1))
fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts... | python | def psd(ts, nperseg=1500, noverlap=1200, plot=True):
"""plot Welch estimate of power spectral density, using nperseg samples per
segment, with noverlap samples overlap and Hamming window."""
ts = ts.squeeze()
if ts.ndim is 1:
ts = ts.reshape((-1, 1))
fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts... | [
"def",
"psd",
"(",
"ts",
",",
"nperseg",
"=",
"1500",
",",
"noverlap",
"=",
"1200",
",",
"plot",
"=",
"True",
")",
":",
"ts",
"=",
"ts",
".",
"squeeze",
"(",
")",
"if",
"ts",
".",
"ndim",
"is",
"1",
":",
"ts",
"=",
"ts",
".",
"reshape",
"(",
... | plot Welch estimate of power spectral density, using nperseg samples per
segment, with noverlap samples overlap and Hamming window. | [
"plot",
"Welch",
"estimate",
"of",
"power",
"spectral",
"density",
"using",
"nperseg",
"samples",
"per",
"segment",
"with",
"noverlap",
"samples",
"overlap",
"and",
"Hamming",
"window",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L31-L53 |
mattja/nsim | nsim/analyses1/freq.py | lowpass | def lowpass(ts, cutoff_hz, order=3):
"""forward-backward butterworth low-pass filter"""
orig_ndim = ts.ndim
if ts.ndim is 1:
ts = ts[:, np.newaxis]
channels = ts.shape[1]
fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0])
nyq = 0.5 * fs
cutoff = cutoff_hz/nyq
b, a = signal.butte... | python | def lowpass(ts, cutoff_hz, order=3):
"""forward-backward butterworth low-pass filter"""
orig_ndim = ts.ndim
if ts.ndim is 1:
ts = ts[:, np.newaxis]
channels = ts.shape[1]
fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0])
nyq = 0.5 * fs
cutoff = cutoff_hz/nyq
b, a = signal.butte... | [
"def",
"lowpass",
"(",
"ts",
",",
"cutoff_hz",
",",
"order",
"=",
"3",
")",
":",
"orig_ndim",
"=",
"ts",
".",
"ndim",
"if",
"ts",
".",
"ndim",
"is",
"1",
":",
"ts",
"=",
"ts",
"[",
":",
",",
"np",
".",
"newaxis",
"]",
"channels",
"=",
"ts",
"... | forward-backward butterworth low-pass filter | [
"forward",
"-",
"backward",
"butterworth",
"low",
"-",
"pass",
"filter"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L98-L116 |
mattja/nsim | nsim/analyses1/freq.py | bandpass | def bandpass(ts, low_hz, high_hz, order=3):
"""forward-backward butterworth band-pass filter"""
orig_ndim = ts.ndim
if ts.ndim is 1:
ts = ts[:, np.newaxis]
channels = ts.shape[1]
fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0])
nyq = 0.5 * fs
low = low_hz/nyq
high = high_hz/ny... | python | def bandpass(ts, low_hz, high_hz, order=3):
"""forward-backward butterworth band-pass filter"""
orig_ndim = ts.ndim
if ts.ndim is 1:
ts = ts[:, np.newaxis]
channels = ts.shape[1]
fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0])
nyq = 0.5 * fs
low = low_hz/nyq
high = high_hz/ny... | [
"def",
"bandpass",
"(",
"ts",
",",
"low_hz",
",",
"high_hz",
",",
"order",
"=",
"3",
")",
":",
"orig_ndim",
"=",
"ts",
".",
"ndim",
"if",
"ts",
".",
"ndim",
"is",
"1",
":",
"ts",
"=",
"ts",
"[",
":",
",",
"np",
".",
"newaxis",
"]",
"channels",
... | forward-backward butterworth band-pass filter | [
"forward",
"-",
"backward",
"butterworth",
"band",
"-",
"pass",
"filter"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L140-L159 |
mattja/nsim | nsim/analyses1/freq.py | notch | def notch(ts, freq_hz, bandwidth_hz=1.0):
"""notch filter to remove remove a particular frequency
Adapted from code by Sturla Molden
"""
orig_ndim = ts.ndim
if ts.ndim is 1:
ts = ts[:, np.newaxis]
channels = ts.shape[1]
fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0])
nyq = 0.... | python | def notch(ts, freq_hz, bandwidth_hz=1.0):
"""notch filter to remove remove a particular frequency
Adapted from code by Sturla Molden
"""
orig_ndim = ts.ndim
if ts.ndim is 1:
ts = ts[:, np.newaxis]
channels = ts.shape[1]
fs = (len(ts) - 1.0) / (ts.tspan[-1] - ts.tspan[0])
nyq = 0.... | [
"def",
"notch",
"(",
"ts",
",",
"freq_hz",
",",
"bandwidth_hz",
"=",
"1.0",
")",
":",
"orig_ndim",
"=",
"ts",
".",
"ndim",
"if",
"ts",
".",
"ndim",
"is",
"1",
":",
"ts",
"=",
"ts",
"[",
":",
",",
"np",
".",
"newaxis",
"]",
"channels",
"=",
"ts"... | notch filter to remove remove a particular frequency
Adapted from code by Sturla Molden | [
"notch",
"filter",
"to",
"remove",
"remove",
"a",
"particular",
"frequency",
"Adapted",
"from",
"code",
"by",
"Sturla",
"Molden"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L162-L192 |
mattja/nsim | nsim/analyses1/freq.py | hilbert | def hilbert(ts):
"""Analytic signal, using the Hilbert transform"""
output = signal.hilbert(signal.detrend(ts, axis=0), axis=0)
return Timeseries(output, ts.tspan, labels=ts.labels) | python | def hilbert(ts):
"""Analytic signal, using the Hilbert transform"""
output = signal.hilbert(signal.detrend(ts, axis=0), axis=0)
return Timeseries(output, ts.tspan, labels=ts.labels) | [
"def",
"hilbert",
"(",
"ts",
")",
":",
"output",
"=",
"signal",
".",
"hilbert",
"(",
"signal",
".",
"detrend",
"(",
"ts",
",",
"axis",
"=",
"0",
")",
",",
"axis",
"=",
"0",
")",
"return",
"Timeseries",
"(",
"output",
",",
"ts",
".",
"tspan",
",",... | Analytic signal, using the Hilbert transform | [
"Analytic",
"signal",
"using",
"the",
"Hilbert",
"transform"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L195-L198 |
mattja/nsim | nsim/analyses1/freq.py | hilbert_amplitude | def hilbert_amplitude(ts):
"""Amplitude of the analytic signal, using the Hilbert transform"""
output = np.abs(signal.hilbert(signal.detrend(ts, axis=0), axis=0))
return Timeseries(output, ts.tspan, labels=ts.labels) | python | def hilbert_amplitude(ts):
"""Amplitude of the analytic signal, using the Hilbert transform"""
output = np.abs(signal.hilbert(signal.detrend(ts, axis=0), axis=0))
return Timeseries(output, ts.tspan, labels=ts.labels) | [
"def",
"hilbert_amplitude",
"(",
"ts",
")",
":",
"output",
"=",
"np",
".",
"abs",
"(",
"signal",
".",
"hilbert",
"(",
"signal",
".",
"detrend",
"(",
"ts",
",",
"axis",
"=",
"0",
")",
",",
"axis",
"=",
"0",
")",
")",
"return",
"Timeseries",
"(",
"... | Amplitude of the analytic signal, using the Hilbert transform | [
"Amplitude",
"of",
"the",
"analytic",
"signal",
"using",
"the",
"Hilbert",
"transform"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L201-L204 |
mattja/nsim | nsim/analyses1/freq.py | hilbert_phase | def hilbert_phase(ts):
"""Phase of the analytic signal, using the Hilbert transform"""
output = np.angle(signal.hilbert(signal.detrend(ts, axis=0), axis=0))
return Timeseries(output, ts.tspan, labels=ts.labels) | python | def hilbert_phase(ts):
"""Phase of the analytic signal, using the Hilbert transform"""
output = np.angle(signal.hilbert(signal.detrend(ts, axis=0), axis=0))
return Timeseries(output, ts.tspan, labels=ts.labels) | [
"def",
"hilbert_phase",
"(",
"ts",
")",
":",
"output",
"=",
"np",
".",
"angle",
"(",
"signal",
".",
"hilbert",
"(",
"signal",
".",
"detrend",
"(",
"ts",
",",
"axis",
"=",
"0",
")",
",",
"axis",
"=",
"0",
")",
")",
"return",
"Timeseries",
"(",
"ou... | Phase of the analytic signal, using the Hilbert transform | [
"Phase",
"of",
"the",
"analytic",
"signal",
"using",
"the",
"Hilbert",
"transform"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L207-L210 |
mattja/nsim | nsim/analyses1/freq.py | cwt | def cwt(ts, freqs=np.logspace(0, 2), wavelet=cwtmorlet, plot=True):
"""Continuous wavelet transform
Note the full results can use a huge amount of memory at 64-bit precision
Args:
ts: Timeseries of m variables, shape (n, m). Assumed constant timestep.
freqs: list of frequencies (in Hz) to use f... | python | def cwt(ts, freqs=np.logspace(0, 2), wavelet=cwtmorlet, plot=True):
"""Continuous wavelet transform
Note the full results can use a huge amount of memory at 64-bit precision
Args:
ts: Timeseries of m variables, shape (n, m). Assumed constant timestep.
freqs: list of frequencies (in Hz) to use f... | [
"def",
"cwt",
"(",
"ts",
",",
"freqs",
"=",
"np",
".",
"logspace",
"(",
"0",
",",
"2",
")",
",",
"wavelet",
"=",
"cwtmorlet",
",",
"plot",
"=",
"True",
")",
":",
"orig_ndim",
"=",
"ts",
".",
"ndim",
"if",
"ts",
".",
"ndim",
"is",
"1",
":",
"t... | Continuous wavelet transform
Note the full results can use a huge amount of memory at 64-bit precision
Args:
ts: Timeseries of m variables, shape (n, m). Assumed constant timestep.
freqs: list of frequencies (in Hz) to use for the tranform.
(default is 50 frequency bins logarithmic from 1H... | [
"Continuous",
"wavelet",
"transform",
"Note",
"the",
"full",
"results",
"can",
"use",
"a",
"huge",
"amount",
"of",
"memory",
"at",
"64",
"-",
"bit",
"precision"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L213-L241 |
mattja/nsim | nsim/analyses1/freq.py | cwt_distributed | def cwt_distributed(ts, freqs=np.logspace(0, 2), wavelet=cwtmorlet, plot=True):
"""Continuous wavelet transform using distributed computation.
(Currently just splits the data by channel. TODO split it further.)
Note: this function requires an IPython cluster to be started first.
Args:
ts: Timeser... | python | def cwt_distributed(ts, freqs=np.logspace(0, 2), wavelet=cwtmorlet, plot=True):
"""Continuous wavelet transform using distributed computation.
(Currently just splits the data by channel. TODO split it further.)
Note: this function requires an IPython cluster to be started first.
Args:
ts: Timeser... | [
"def",
"cwt_distributed",
"(",
"ts",
",",
"freqs",
"=",
"np",
".",
"logspace",
"(",
"0",
",",
"2",
")",
",",
"wavelet",
"=",
"cwtmorlet",
",",
"plot",
"=",
"True",
")",
":",
"if",
"ts",
".",
"ndim",
"is",
"1",
"or",
"ts",
".",
"shape",
"[",
"1"... | Continuous wavelet transform using distributed computation.
(Currently just splits the data by channel. TODO split it further.)
Note: this function requires an IPython cluster to be started first.
Args:
ts: Timeseries of m variables, shape (n, m). Assumed constant timestep.
freqs: list of frequ... | [
"Continuous",
"wavelet",
"transform",
"using",
"distributed",
"computation",
".",
"(",
"Currently",
"just",
"splits",
"the",
"data",
"by",
"channel",
".",
"TODO",
"split",
"it",
"further",
".",
")",
"Note",
":",
"this",
"function",
"requires",
"an",
"IPython",... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L244-L266 |
mattja/nsim | nsim/analyses1/freq.py | _plot_cwt | def _plot_cwt(ts, coefs, freqs, tsize=1024, fsize=512):
"""Plot time resolved power spectral density from cwt results
Args:
ts: the original Timeseries
coefs: continuous wavelet transform coefficients as calculated by cwt()
freqs: list of frequencies (in Hz) corresponding to coefs.
tsiz... | python | def _plot_cwt(ts, coefs, freqs, tsize=1024, fsize=512):
"""Plot time resolved power spectral density from cwt results
Args:
ts: the original Timeseries
coefs: continuous wavelet transform coefficients as calculated by cwt()
freqs: list of frequencies (in Hz) corresponding to coefs.
tsiz... | [
"def",
"_plot_cwt",
"(",
"ts",
",",
"coefs",
",",
"freqs",
",",
"tsize",
"=",
"1024",
",",
"fsize",
"=",
"512",
")",
":",
"import",
"matplotlib",
".",
"style",
"import",
"matplotlib",
"as",
"mpl",
"mpl",
".",
"style",
".",
"use",
"(",
"'classic'",
")... | Plot time resolved power spectral density from cwt results
Args:
ts: the original Timeseries
coefs: continuous wavelet transform coefficients as calculated by cwt()
freqs: list of frequencies (in Hz) corresponding to coefs.
tsize, fsize: size of the plot (time axis and frequency axis, in pi... | [
"Plot",
"time",
"resolved",
"power",
"spectral",
"density",
"from",
"cwt",
"results",
"Args",
":",
"ts",
":",
"the",
"original",
"Timeseries",
"coefs",
":",
"continuous",
"wavelet",
"transform",
"coefficients",
"as",
"calculated",
"by",
"cwt",
"()",
"freqs",
"... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/freq.py#L269-L299 |
mattja/nsim | nsim/analysesN/misc.py | first_return_times | def first_return_times(dts, c=None, d=0.0):
"""For an ensemble of time series, return the set of all time intervals
between successive returns to value c for all instances in the ensemble.
If c is not given, the default is the mean across all times and across all
time series in the ensemble.
Args:
... | python | def first_return_times(dts, c=None, d=0.0):
"""For an ensemble of time series, return the set of all time intervals
between successive returns to value c for all instances in the ensemble.
If c is not given, the default is the mean across all times and across all
time series in the ensemble.
Args:
... | [
"def",
"first_return_times",
"(",
"dts",
",",
"c",
"=",
"None",
",",
"d",
"=",
"0.0",
")",
":",
"if",
"c",
"is",
"None",
":",
"c",
"=",
"dts",
".",
"mean",
"(",
")",
"vmrt",
"=",
"distob",
".",
"vectorize",
"(",
"analyses1",
".",
"first_return_time... | For an ensemble of time series, return the set of all time intervals
between successive returns to value c for all instances in the ensemble.
If c is not given, the default is the mean across all times and across all
time series in the ensemble.
Args:
dts (DistTimeseries)
c (float): Option... | [
"For",
"an",
"ensemble",
"of",
"time",
"series",
"return",
"the",
"set",
"of",
"all",
"time",
"intervals",
"between",
"successive",
"returns",
"to",
"value",
"c",
"for",
"all",
"instances",
"in",
"the",
"ensemble",
".",
"If",
"c",
"is",
"not",
"given",
"... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/misc.py#L16-L40 |
mattja/nsim | nsim/analysesN/epochs.py | variability_fp | def variability_fp(ts, freqs=None, ncycles=6, plot=True):
"""Example variability function.
Gives two continuous, time-resolved measures of the variability of a
time series, ranging between -1 and 1.
The two measures are based on variance of the centroid frequency and
variance of the height of the ... | python | def variability_fp(ts, freqs=None, ncycles=6, plot=True):
"""Example variability function.
Gives two continuous, time-resolved measures of the variability of a
time series, ranging between -1 and 1.
The two measures are based on variance of the centroid frequency and
variance of the height of the ... | [
"def",
"variability_fp",
"(",
"ts",
",",
"freqs",
"=",
"None",
",",
"ncycles",
"=",
"6",
",",
"plot",
"=",
"True",
")",
":",
"if",
"ts",
".",
"ndim",
"<=",
"2",
":",
"return",
"analyses1",
".",
"variability_fp",
"(",
"ts",
",",
"freqs",
",",
"ncycl... | Example variability function.
Gives two continuous, time-resolved measures of the variability of a
time series, ranging between -1 and 1.
The two measures are based on variance of the centroid frequency and
variance of the height of the spectral peak, respectively.
(Centroid frequency meaning the ... | [
"Example",
"variability",
"function",
".",
"Gives",
"two",
"continuous",
"time",
"-",
"resolved",
"measures",
"of",
"the",
"variability",
"of",
"a",
"time",
"series",
"ranging",
"between",
"-",
"1",
"and",
"1",
".",
"The",
"two",
"measures",
"are",
"based",
... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/epochs.py#L29-L57 |
mattja/nsim | nsim/analysesN/epochs.py | epochs | def epochs(ts, variability=None, threshold=0.0, minlength=1.0, plot=True):
"""Identify "stationary" epochs within a time series, based on a
continuous measure of variability.
Epochs are defined to contain the points of minimal variability, and to
extend as wide as possible with variability not exceedi... | python | def epochs(ts, variability=None, threshold=0.0, minlength=1.0, plot=True):
"""Identify "stationary" epochs within a time series, based on a
continuous measure of variability.
Epochs are defined to contain the points of minimal variability, and to
extend as wide as possible with variability not exceedi... | [
"def",
"epochs",
"(",
"ts",
",",
"variability",
"=",
"None",
",",
"threshold",
"=",
"0.0",
",",
"minlength",
"=",
"1.0",
",",
"plot",
"=",
"True",
")",
":",
"if",
"ts",
".",
"ndim",
"<=",
"2",
":",
"return",
"analyses1",
".",
"epochs_distributed",
"(... | Identify "stationary" epochs within a time series, based on a
continuous measure of variability.
Epochs are defined to contain the points of minimal variability, and to
extend as wide as possible with variability not exceeding the threshold.
Args:
ts Timeseries of m variables, shape (n, m).
... | [
"Identify",
"stationary",
"epochs",
"within",
"a",
"time",
"series",
"based",
"on",
"a",
"continuous",
"measure",
"of",
"variability",
".",
"Epochs",
"are",
"defined",
"to",
"contain",
"the",
"points",
"of",
"minimal",
"variability",
"and",
"to",
"extend",
"as... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/epochs.py#L60-L88 |
mattja/nsim | nsim/analysesN/epochs.py | epochs_joint | def epochs_joint(ts, variability=None, threshold=0.0, minlength=1.0,
proportion=0.75, plot=True):
"""Identify epochs within a multivariate time series where at least a
certain proportion of channels are "stationary", based on a previously
computed variability measure.
(Note: This req... | python | def epochs_joint(ts, variability=None, threshold=0.0, minlength=1.0,
proportion=0.75, plot=True):
"""Identify epochs within a multivariate time series where at least a
certain proportion of channels are "stationary", based on a previously
computed variability measure.
(Note: This req... | [
"def",
"epochs_joint",
"(",
"ts",
",",
"variability",
"=",
"None",
",",
"threshold",
"=",
"0.0",
",",
"minlength",
"=",
"1.0",
",",
"proportion",
"=",
"0.75",
",",
"plot",
"=",
"True",
")",
":",
"if",
"ts",
".",
"ndim",
"<=",
"2",
":",
"return",
"a... | Identify epochs within a multivariate time series where at least a
certain proportion of channels are "stationary", based on a previously
computed variability measure.
(Note: This requires an IPython cluster to be started first,
e.g. on a workstation type 'ipcluster start')
Args:
ts Tim... | [
"Identify",
"epochs",
"within",
"a",
"multivariate",
"time",
"series",
"where",
"at",
"least",
"a",
"certain",
"proportion",
"of",
"channels",
"are",
"stationary",
"based",
"on",
"a",
"previously",
"computed",
"variability",
"measure",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/epochs.py#L128-L158 |
mattja/nsim | nsim/analysesN/phase.py | periods | def periods(dts, phi=0.0):
"""For an ensemble of oscillators, return the set of periods lengths of
all successive oscillations of all oscillators.
An individual oscillation is defined to start and end when the phase
passes phi (by default zero) after completing a full cycle.
If the timeseries of... | python | def periods(dts, phi=0.0):
"""For an ensemble of oscillators, return the set of periods lengths of
all successive oscillations of all oscillators.
An individual oscillation is defined to start and end when the phase
passes phi (by default zero) after completing a full cycle.
If the timeseries of... | [
"def",
"periods",
"(",
"dts",
",",
"phi",
"=",
"0.0",
")",
":",
"vperiods",
"=",
"distob",
".",
"vectorize",
"(",
"analyses1",
".",
"periods",
")",
"all_periods",
"=",
"vperiods",
"(",
"dts",
",",
"phi",
")",
"if",
"hasattr",
"(",
"type",
"(",
"all_p... | For an ensemble of oscillators, return the set of periods lengths of
all successive oscillations of all oscillators.
An individual oscillation is defined to start and end when the phase
passes phi (by default zero) after completing a full cycle.
If the timeseries of an oscillator phase begins (or en... | [
"For",
"an",
"ensemble",
"of",
"oscillators",
"return",
"the",
"set",
"of",
"periods",
"lengths",
"of",
"all",
"successive",
"oscillations",
"of",
"all",
"oscillators",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/phase.py#L16-L39 |
mattja/nsim | nsim/analysesN/phase.py | circmean | def circmean(dts, axis=2):
"""Circular mean phase"""
return np.exp(1.0j * dts).mean(axis=axis).angle() | python | def circmean(dts, axis=2):
"""Circular mean phase"""
return np.exp(1.0j * dts).mean(axis=axis).angle() | [
"def",
"circmean",
"(",
"dts",
",",
"axis",
"=",
"2",
")",
":",
"return",
"np",
".",
"exp",
"(",
"1.0j",
"*",
"dts",
")",
".",
"mean",
"(",
"axis",
"=",
"axis",
")",
".",
"angle",
"(",
")"
] | Circular mean phase | [
"Circular",
"mean",
"phase"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/phase.py#L42-L44 |
mattja/nsim | nsim/analysesN/phase.py | order_param | def order_param(dts, axis=2):
"""Order parameter of phase synchronization"""
return np.abs(np.exp(1.0j * dts).mean(axis=axis)) | python | def order_param(dts, axis=2):
"""Order parameter of phase synchronization"""
return np.abs(np.exp(1.0j * dts).mean(axis=axis)) | [
"def",
"order_param",
"(",
"dts",
",",
"axis",
"=",
"2",
")",
":",
"return",
"np",
".",
"abs",
"(",
"np",
".",
"exp",
"(",
"1.0j",
"*",
"dts",
")",
".",
"mean",
"(",
"axis",
"=",
"axis",
")",
")"
] | Order parameter of phase synchronization | [
"Order",
"parameter",
"of",
"phase",
"synchronization"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/phase.py#L47-L49 |
mattja/nsim | nsim/analysesN/phase.py | circstd | def circstd(dts, axis=2):
"""Circular standard deviation"""
R = np.abs(np.exp(1.0j * dts).mean(axis=axis))
return np.sqrt(-2.0 * np.log(R)) | python | def circstd(dts, axis=2):
"""Circular standard deviation"""
R = np.abs(np.exp(1.0j * dts).mean(axis=axis))
return np.sqrt(-2.0 * np.log(R)) | [
"def",
"circstd",
"(",
"dts",
",",
"axis",
"=",
"2",
")",
":",
"R",
"=",
"np",
".",
"abs",
"(",
"np",
".",
"exp",
"(",
"1.0j",
"*",
"dts",
")",
".",
"mean",
"(",
"axis",
"=",
"axis",
")",
")",
"return",
"np",
".",
"sqrt",
"(",
"-",
"2.0",
... | Circular standard deviation | [
"Circular",
"standard",
"deviation"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/phase.py#L52-L55 |
mattja/nsim | nsim/models/neural_mass.py | JansenRit.f | def f(self, v, t):
"""Aburn2012 equations right hand side, noise free term
Args:
v: (8,) array
state vector
t: number
scalar time
Returns:
(8,) array
"""
ret = np.zeros(8)
ret[0] = v[4]
ret[4] = (self.He1*s... | python | def f(self, v, t):
"""Aburn2012 equations right hand side, noise free term
Args:
v: (8,) array
state vector
t: number
scalar time
Returns:
(8,) array
"""
ret = np.zeros(8)
ret[0] = v[4]
ret[4] = (self.He1*s... | [
"def",
"f",
"(",
"self",
",",
"v",
",",
"t",
")",
":",
"ret",
"=",
"np",
".",
"zeros",
"(",
"8",
")",
"ret",
"[",
"0",
"]",
"=",
"v",
"[",
"4",
"]",
"ret",
"[",
"4",
"]",
"=",
"(",
"self",
".",
"He1",
"*",
"self",
".",
"ke1",
"*",
"("... | Aburn2012 equations right hand side, noise free term
Args:
v: (8,) array
state vector
t: number
scalar time
Returns:
(8,) array | [
"Aburn2012",
"equations",
"right",
"hand",
"side",
"noise",
"free",
"term",
"Args",
":",
"v",
":",
"(",
"8",
")",
"array",
"state",
"vector",
"t",
":",
"number",
"scalar",
"time",
"Returns",
":",
"(",
"8",
")",
"array"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/models/neural_mass.py#L79-L105 |
mattja/nsim | nsim/models/neural_mass.py | JansenRit.G | def G(self, v, t):
"""Aburn2012 equations right hand side, noise term
Args:
v: (8,) array
state vector
t: number
scalar time
Returns:
(8,1) array
Only one matrix column, meaning that in this example we are modelling
th... | python | def G(self, v, t):
"""Aburn2012 equations right hand side, noise term
Args:
v: (8,) array
state vector
t: number
scalar time
Returns:
(8,1) array
Only one matrix column, meaning that in this example we are modelling
th... | [
"def",
"G",
"(",
"self",
",",
"v",
",",
"t",
")",
":",
"ret",
"=",
"np",
".",
"zeros",
"(",
"(",
"8",
",",
"1",
")",
")",
"ret",
"[",
"4",
",",
"0",
"]",
"=",
"self",
".",
"ke1",
"*",
"self",
".",
"He1",
"*",
"self",
".",
"u_sdev",
"ret... | Aburn2012 equations right hand side, noise term
Args:
v: (8,) array
state vector
t: number
scalar time
Returns:
(8,1) array
Only one matrix column, meaning that in this example we are modelling
the noise input to pyramidal and... | [
"Aburn2012",
"equations",
"right",
"hand",
"side",
"noise",
"term",
"Args",
":",
"v",
":",
"(",
"8",
")",
"array",
"state",
"vector",
"t",
":",
"number",
"scalar",
"time",
"Returns",
":",
"(",
"8",
"1",
")",
"array",
"Only",
"one",
"matrix",
"column",
... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/models/neural_mass.py#L107-L124 |
mattja/nsim | nsim/models/neural_mass.py | JansenRit.coupling | def coupling(self, source_y, target_y, weight):
"""How to couple the output of one node to the input of another.
Args:
source_y (array of shape (8,)): state of the source node
target_y (array of shape (8,)): state of the target node
weight (float): the connection strength
... | python | def coupling(self, source_y, target_y, weight):
"""How to couple the output of one node to the input of another.
Args:
source_y (array of shape (8,)): state of the source node
target_y (array of shape (8,)): state of the target node
weight (float): the connection strength
... | [
"def",
"coupling",
"(",
"self",
",",
"source_y",
",",
"target_y",
",",
"weight",
")",
":",
"v_pyramidal",
"=",
"source_y",
"[",
"1",
"]",
"-",
"source_y",
"[",
"2",
"]",
"return",
"(",
"np",
".",
"array",
"(",
"[",
"0",
",",
"0",
",",
"0",
",",
... | How to couple the output of one node to the input of another.
Args:
source_y (array of shape (8,)): state of the source node
target_y (array of shape (8,)): state of the target node
weight (float): the connection strength
Returns:
input (array of shape (8,)): valu... | [
"How",
"to",
"couple",
"the",
"output",
"of",
"one",
"node",
"to",
"the",
"input",
"of",
"another",
".",
"Args",
":",
"source_y",
"(",
"array",
"of",
"shape",
"(",
"8",
"))",
":",
"state",
"of",
"the",
"source",
"node",
"target_y",
"(",
"array",
"of"... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/models/neural_mass.py#L126-L138 |
mattja/nsim | nsim/analyses1/pyeeg.py | hurst | def hurst(X):
""" Compute the Hurst exponent of X. If the output H=0.5,the behavior
of the time-series is similar to random walk. If H<0.5, the time-series
cover less "distance" than a random walk, vice verse.
Parameters
----------
X
list
a time series
Returns
------... | python | def hurst(X):
""" Compute the Hurst exponent of X. If the output H=0.5,the behavior
of the time-series is similar to random walk. If H<0.5, the time-series
cover less "distance" than a random walk, vice verse.
Parameters
----------
X
list
a time series
Returns
------... | [
"def",
"hurst",
"(",
"X",
")",
":",
"X",
"=",
"numpy",
".",
"array",
"(",
"X",
")",
"N",
"=",
"X",
".",
"size",
"T",
"=",
"numpy",
".",
"arange",
"(",
"1",
",",
"N",
"+",
"1",
")",
"Y",
"=",
"numpy",
".",
"cumsum",
"(",
"X",
")",
"Ave_T",... | Compute the Hurst exponent of X. If the output H=0.5,the behavior
of the time-series is similar to random walk. If H<0.5, the time-series
cover less "distance" than a random walk, vice verse.
Parameters
----------
X
list
a time series
Returns
-------
H
float... | [
"Compute",
"the",
"Hurst",
"exponent",
"of",
"X",
".",
"If",
"the",
"output",
"H",
"=",
"0",
".",
"5",
"the",
"behavior",
"of",
"the",
"time",
"-",
"series",
"is",
"similar",
"to",
"random",
"walk",
".",
"If",
"H<0",
".",
"5",
"the",
"time",
"-",
... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L40-L96 |
mattja/nsim | nsim/analyses1/pyeeg.py | embed_seq | def embed_seq(X, Tau, D):
"""Build a set of embedding sequences from given time series X with lag Tau
and embedding dimension DE. Let X = [x(1), x(2), ... , x(N)], then for each
i such that 1 < i < N - (D - 1) * Tau, we build an embedding sequence,
Y(i) = [x(i), x(i + Tau), ... , x(i + (D - 1) * Tau)].... | python | def embed_seq(X, Tau, D):
"""Build a set of embedding sequences from given time series X with lag Tau
and embedding dimension DE. Let X = [x(1), x(2), ... , x(N)], then for each
i such that 1 < i < N - (D - 1) * Tau, we build an embedding sequence,
Y(i) = [x(i), x(i + Tau), ... , x(i + (D - 1) * Tau)].... | [
"def",
"embed_seq",
"(",
"X",
",",
"Tau",
",",
"D",
")",
":",
"shape",
"=",
"(",
"X",
".",
"size",
"-",
"Tau",
"*",
"(",
"D",
"-",
"1",
")",
",",
"D",
")",
"strides",
"=",
"(",
"X",
".",
"itemsize",
",",
"Tau",
"*",
"X",
".",
"itemsize",
... | Build a set of embedding sequences from given time series X with lag Tau
and embedding dimension DE. Let X = [x(1), x(2), ... , x(N)], then for each
i such that 1 < i < N - (D - 1) * Tau, we build an embedding sequence,
Y(i) = [x(i), x(i + Tau), ... , x(i + (D - 1) * Tau)]. All embedding
sequence are p... | [
"Build",
"a",
"set",
"of",
"embedding",
"sequences",
"from",
"given",
"time",
"series",
"X",
"with",
"lag",
"Tau",
"and",
"embedding",
"dimension",
"DE",
".",
"Let",
"X",
"=",
"[",
"x",
"(",
"1",
")",
"x",
"(",
"2",
")",
"...",
"x",
"(",
"N",
")"... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L99-L163 |
mattja/nsim | nsim/analyses1/pyeeg.py | bin_power | def bin_power(X, Band, Fs):
"""Compute power in each frequency bin specified by Band from FFT result of
X. By default, X is a real signal.
Note
-----
A real signal can be synthesized, thus not real.
Parameters
-----------
Band
list
boundary frequencies (in Hz) of bins... | python | def bin_power(X, Band, Fs):
"""Compute power in each frequency bin specified by Band from FFT result of
X. By default, X is a real signal.
Note
-----
A real signal can be synthesized, thus not real.
Parameters
-----------
Band
list
boundary frequencies (in Hz) of bins... | [
"def",
"bin_power",
"(",
"X",
",",
"Band",
",",
"Fs",
")",
":",
"C",
"=",
"numpy",
".",
"fft",
".",
"fft",
"(",
"X",
")",
"C",
"=",
"abs",
"(",
"C",
")",
"Power",
"=",
"numpy",
".",
"zeros",
"(",
"len",
"(",
"Band",
")",
"-",
"1",
")",
"f... | Compute power in each frequency bin specified by Band from FFT result of
X. By default, X is a real signal.
Note
-----
A real signal can be synthesized, thus not real.
Parameters
-----------
Band
list
boundary frequencies (in Hz) of bins. They can be unequal bins, e.g.
... | [
"Compute",
"power",
"in",
"each",
"frequency",
"bin",
"specified",
"by",
"Band",
"from",
"FFT",
"result",
"of",
"X",
".",
"By",
"default",
"X",
"is",
"a",
"real",
"signal",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L166-L226 |
mattja/nsim | nsim/analyses1/pyeeg.py | pfd | def pfd(X, D=None):
"""Compute Petrosian Fractal Dimension of a time series from either two
cases below:
1. X, the time series of type list (default)
2. D, the first order differential sequence of X (if D is provided,
recommended to speed up)
In case 1, D is computed using Numpy'... | python | def pfd(X, D=None):
"""Compute Petrosian Fractal Dimension of a time series from either two
cases below:
1. X, the time series of type list (default)
2. D, the first order differential sequence of X (if D is provided,
recommended to speed up)
In case 1, D is computed using Numpy'... | [
"def",
"pfd",
"(",
"X",
",",
"D",
"=",
"None",
")",
":",
"if",
"D",
"is",
"None",
":",
"D",
"=",
"numpy",
".",
"diff",
"(",
"X",
")",
"D",
"=",
"D",
".",
"tolist",
"(",
")",
"N_delta",
"=",
"0",
"# number of sign changes in derivative of the signal",... | Compute Petrosian Fractal Dimension of a time series from either two
cases below:
1. X, the time series of type list (default)
2. D, the first order differential sequence of X (if D is provided,
recommended to speed up)
In case 1, D is computed using Numpy's difference function.
... | [
"Compute",
"Petrosian",
"Fractal",
"Dimension",
"of",
"a",
"time",
"series",
"from",
"either",
"two",
"cases",
"below",
":",
"1",
".",
"X",
"the",
"time",
"series",
"of",
"type",
"list",
"(",
"default",
")",
"2",
".",
"D",
"the",
"first",
"order",
"dif... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L229-L252 |
mattja/nsim | nsim/analyses1/pyeeg.py | hfd | def hfd(X, Kmax):
""" Compute Hjorth Fractal Dimension of a time series X, kmax
is an HFD parameter
"""
L = []
x = []
N = len(X)
for k in range(1, Kmax):
Lk = []
for m in range(0, k):
Lmk = 0
for i in range(1, int(numpy.floor((N - m) / k))):
... | python | def hfd(X, Kmax):
""" Compute Hjorth Fractal Dimension of a time series X, kmax
is an HFD parameter
"""
L = []
x = []
N = len(X)
for k in range(1, Kmax):
Lk = []
for m in range(0, k):
Lmk = 0
for i in range(1, int(numpy.floor((N - m) / k))):
... | [
"def",
"hfd",
"(",
"X",
",",
"Kmax",
")",
":",
"L",
"=",
"[",
"]",
"x",
"=",
"[",
"]",
"N",
"=",
"len",
"(",
"X",
")",
"for",
"k",
"in",
"range",
"(",
"1",
",",
"Kmax",
")",
":",
"Lk",
"=",
"[",
"]",
"for",
"m",
"in",
"range",
"(",
"0... | Compute Hjorth Fractal Dimension of a time series X, kmax
is an HFD parameter | [
"Compute",
"Hjorth",
"Fractal",
"Dimension",
"of",
"a",
"time",
"series",
"X",
"kmax",
"is",
"an",
"HFD",
"parameter"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L255-L274 |
mattja/nsim | nsim/analyses1/pyeeg.py | hjorth | def hjorth(X, D=None):
""" Compute Hjorth mobility and complexity of a time series from either two
cases below:
1. X, the time series of type list (default)
2. D, a first order differential sequence of X (if D is provided,
recommended to speed up)
In case 1, D is computed using N... | python | def hjorth(X, D=None):
""" Compute Hjorth mobility and complexity of a time series from either two
cases below:
1. X, the time series of type list (default)
2. D, a first order differential sequence of X (if D is provided,
recommended to speed up)
In case 1, D is computed using N... | [
"def",
"hjorth",
"(",
"X",
",",
"D",
"=",
"None",
")",
":",
"if",
"D",
"is",
"None",
":",
"D",
"=",
"numpy",
".",
"diff",
"(",
"X",
")",
"D",
"=",
"D",
".",
"tolist",
"(",
")",
"D",
".",
"insert",
"(",
"0",
",",
"X",
"[",
"0",
"]",
")",... | Compute Hjorth mobility and complexity of a time series from either two
cases below:
1. X, the time series of type list (default)
2. D, a first order differential sequence of X (if D is provided,
recommended to speed up)
In case 1, D is computed using Numpy's Difference function.
... | [
"Compute",
"Hjorth",
"mobility",
"and",
"complexity",
"of",
"a",
"time",
"series",
"from",
"either",
"two",
"cases",
"below",
":",
"1",
".",
"X",
"the",
"time",
"series",
"of",
"type",
"list",
"(",
"default",
")",
"2",
".",
"D",
"a",
"first",
"order",
... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L277-L332 |
mattja/nsim | nsim/analyses1/pyeeg.py | spectral_entropy | def spectral_entropy(X, Band, Fs, Power_Ratio=None):
"""Compute spectral entropy of a time series from either two cases below:
1. X, the time series (default)
2. Power_Ratio, a list of normalized signal power in a set of frequency
bins defined in Band (if Power_Ratio is provided, recommended to speed up... | python | def spectral_entropy(X, Band, Fs, Power_Ratio=None):
"""Compute spectral entropy of a time series from either two cases below:
1. X, the time series (default)
2. Power_Ratio, a list of normalized signal power in a set of frequency
bins defined in Band (if Power_Ratio is provided, recommended to speed up... | [
"def",
"spectral_entropy",
"(",
"X",
",",
"Band",
",",
"Fs",
",",
"Power_Ratio",
"=",
"None",
")",
":",
"if",
"Power_Ratio",
"is",
"None",
":",
"Power",
",",
"Power_Ratio",
"=",
"bin_power",
"(",
"X",
",",
"Band",
",",
"Fs",
")",
"Spectral_Entropy",
"=... | Compute spectral entropy of a time series from either two cases below:
1. X, the time series (default)
2. Power_Ratio, a list of normalized signal power in a set of frequency
bins defined in Band (if Power_Ratio is provided, recommended to speed up)
In case 1, Power_Ratio is computed by bin_power() fun... | [
"Compute",
"spectral",
"entropy",
"of",
"a",
"time",
"series",
"from",
"either",
"two",
"cases",
"below",
":",
"1",
".",
"X",
"the",
"time",
"series",
"(",
"default",
")",
"2",
".",
"Power_Ratio",
"a",
"list",
"of",
"normalized",
"signal",
"power",
"in",... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L335-L393 |
mattja/nsim | nsim/analyses1/pyeeg.py | svd_entropy | def svd_entropy(X, Tau, DE, W=None):
"""Compute SVD Entropy from either two cases below:
1. a time series X, with lag tau and embedding dimension dE (default)
2. a list, W, of normalized singular values of a matrix (if W is provided,
recommend to speed up.)
If W is None, the function will do as fol... | python | def svd_entropy(X, Tau, DE, W=None):
"""Compute SVD Entropy from either two cases below:
1. a time series X, with lag tau and embedding dimension dE (default)
2. a list, W, of normalized singular values of a matrix (if W is provided,
recommend to speed up.)
If W is None, the function will do as fol... | [
"def",
"svd_entropy",
"(",
"X",
",",
"Tau",
",",
"DE",
",",
"W",
"=",
"None",
")",
":",
"if",
"W",
"is",
"None",
":",
"Y",
"=",
"embed_seq",
"(",
"X",
",",
"Tau",
",",
"DE",
")",
"W",
"=",
"numpy",
".",
"linalg",
".",
"svd",
"(",
"Y",
",",
... | Compute SVD Entropy from either two cases below:
1. a time series X, with lag tau and embedding dimension dE (default)
2. a list, W, of normalized singular values of a matrix (if W is provided,
recommend to speed up.)
If W is None, the function will do as follows to prepare singular spectrum:
... | [
"Compute",
"SVD",
"Entropy",
"from",
"either",
"two",
"cases",
"below",
":",
"1",
".",
"a",
"time",
"series",
"X",
"with",
"lag",
"tau",
"and",
"embedding",
"dimension",
"dE",
"(",
"default",
")",
"2",
".",
"a",
"list",
"W",
"of",
"normalized",
"singul... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L396-L428 |
mattja/nsim | nsim/analyses1/pyeeg.py | ap_entropy | def ap_entropy(X, M, R):
"""Computer approximate entropy (ApEN) of series X, specified by M and R.
Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build
embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of
Em is x(i),x(i+1), ... , x(i+M-1). Hence, the embedding ... | python | def ap_entropy(X, M, R):
"""Computer approximate entropy (ApEN) of series X, specified by M and R.
Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build
embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of
Em is x(i),x(i+1), ... , x(i+M-1). Hence, the embedding ... | [
"def",
"ap_entropy",
"(",
"X",
",",
"M",
",",
"R",
")",
":",
"N",
"=",
"len",
"(",
"X",
")",
"Em",
"=",
"embed_seq",
"(",
"X",
",",
"1",
",",
"M",
")",
"A",
"=",
"numpy",
".",
"tile",
"(",
"Em",
",",
"(",
"len",
"(",
"Em",
")",
",",
"1"... | Computer approximate entropy (ApEN) of series X, specified by M and R.
Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build
embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of
Em is x(i),x(i+1), ... , x(i+M-1). Hence, the embedding lag and dimension
are 1 and ... | [
"Computer",
"approximate",
"entropy",
"(",
"ApEN",
")",
"of",
"series",
"X",
"specified",
"by",
"M",
"and",
"R",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L466-L536 |
mattja/nsim | nsim/analyses1/pyeeg.py | samp_entropy | def samp_entropy(X, M, R):
"""Computer sample entropy (SampEn) of series X, specified by M and R.
SampEn is very close to ApEn.
Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build
embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of
Em is x(i),x(i+1), ...... | python | def samp_entropy(X, M, R):
"""Computer sample entropy (SampEn) of series X, specified by M and R.
SampEn is very close to ApEn.
Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build
embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of
Em is x(i),x(i+1), ...... | [
"def",
"samp_entropy",
"(",
"X",
",",
"M",
",",
"R",
")",
":",
"N",
"=",
"len",
"(",
"X",
")",
"Em",
"=",
"embed_seq",
"(",
"X",
",",
"1",
",",
"M",
")",
"A",
"=",
"numpy",
".",
"tile",
"(",
"Em",
",",
"(",
"len",
"(",
"Em",
")",
",",
"... | Computer sample entropy (SampEn) of series X, specified by M and R.
SampEn is very close to ApEn.
Suppose given time series is X = [x(1), x(2), ... , x(N)]. We first build
embedding matrix Em, of dimension (N-M+1)-by-M, such that the i-th row of
Em is x(i),x(i+1), ... , x(i+M-1). Hence, the embedding ... | [
"Computer",
"sample",
"entropy",
"(",
"SampEn",
")",
"of",
"series",
"X",
"specified",
"by",
"M",
"and",
"R",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L539-L603 |
mattja/nsim | nsim/analyses1/pyeeg.py | dfa | def dfa(X, Ave=None, L=None):
"""Compute Detrended Fluctuation Analysis from a time series X and length of
boxes L.
The first step to compute DFA is to integrate the signal. Let original
series be X= [x(1), x(2), ..., x(N)].
The integrated signal Y = [y(1), y(2), ..., y(N)] is obtained as follows
... | python | def dfa(X, Ave=None, L=None):
"""Compute Detrended Fluctuation Analysis from a time series X and length of
boxes L.
The first step to compute DFA is to integrate the signal. Let original
series be X= [x(1), x(2), ..., x(N)].
The integrated signal Y = [y(1), y(2), ..., y(N)] is obtained as follows
... | [
"def",
"dfa",
"(",
"X",
",",
"Ave",
"=",
"None",
",",
"L",
"=",
"None",
")",
":",
"X",
"=",
"numpy",
".",
"array",
"(",
"X",
")",
"if",
"Ave",
"is",
"None",
":",
"Ave",
"=",
"numpy",
".",
"mean",
"(",
"X",
")",
"Y",
"=",
"numpy",
".",
"cu... | Compute Detrended Fluctuation Analysis from a time series X and length of
boxes L.
The first step to compute DFA is to integrate the signal. Let original
series be X= [x(1), x(2), ..., x(N)].
The integrated signal Y = [y(1), y(2), ..., y(N)] is obtained as follows
y(k) = \sum_{i=1}^{k}{x(i)-Ave} w... | [
"Compute",
"Detrended",
"Fluctuation",
"Analysis",
"from",
"a",
"time",
"series",
"X",
"and",
"length",
"of",
"boxes",
"L",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L606-L733 |
mattja/nsim | nsim/analyses1/pyeeg.py | permutation_entropy | def permutation_entropy(x, n, tau):
"""Compute Permutation Entropy of a given time series x, specified by
permutation order n and embedding lag tau.
Parameters
----------
x
list
a time series
n
integer
Permutation order
tau
integer
Embed... | python | def permutation_entropy(x, n, tau):
"""Compute Permutation Entropy of a given time series x, specified by
permutation order n and embedding lag tau.
Parameters
----------
x
list
a time series
n
integer
Permutation order
tau
integer
Embed... | [
"def",
"permutation_entropy",
"(",
"x",
",",
"n",
",",
"tau",
")",
":",
"PeSeq",
"=",
"[",
"]",
"Em",
"=",
"embed_seq",
"(",
"x",
",",
"tau",
",",
"n",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"Em",
")",
")",
":",
"r",
"="... | Compute Permutation Entropy of a given time series x, specified by
permutation order n and embedding lag tau.
Parameters
----------
x
list
a time series
n
integer
Permutation order
tau
integer
Embedding lag
Returns
----------
P... | [
"Compute",
"Permutation",
"Entropy",
"of",
"a",
"given",
"time",
"series",
"x",
"specified",
"by",
"permutation",
"order",
"n",
"and",
"embedding",
"lag",
"tau",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L736-L834 |
mattja/nsim | nsim/analyses1/pyeeg.py | information_based_similarity | def information_based_similarity(x, y, n):
"""Calculates the information based similarity of two time series x
and y.
Parameters
----------
x
list
a time series
y
list
a time series
n
integer
word order
Returns
----------
... | python | def information_based_similarity(x, y, n):
"""Calculates the information based similarity of two time series x
and y.
Parameters
----------
x
list
a time series
y
list
a time series
n
integer
word order
Returns
----------
... | [
"def",
"information_based_similarity",
"(",
"x",
",",
"y",
",",
"n",
")",
":",
"Wordlist",
"=",
"[",
"]",
"Space",
"=",
"[",
"[",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"1",
"]",
",",
"[",
"1",
",",
"0",
"]",
",",
"[",
"1",
",",
"1",
"]"... | Calculates the information based similarity of two time series x
and y.
Parameters
----------
x
list
a time series
y
list
a time series
n
integer
word order
Returns
----------
IBS
float
Information based si... | [
"Calculates",
"the",
"information",
"based",
"similarity",
"of",
"two",
"time",
"series",
"x",
"and",
"y",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L837-L1004 |
mattja/nsim | nsim/analyses1/pyeeg.py | LLE | def LLE(x, tau, n, T, fs):
"""Calculate largest Lyauponov exponent of a given time series x using
Rosenstein algorithm.
Parameters
----------
x
list
a time series
n
integer
embedding dimension
tau
integer
Embedding lag
fs
in... | python | def LLE(x, tau, n, T, fs):
"""Calculate largest Lyauponov exponent of a given time series x using
Rosenstein algorithm.
Parameters
----------
x
list
a time series
n
integer
embedding dimension
tau
integer
Embedding lag
fs
in... | [
"def",
"LLE",
"(",
"x",
",",
"tau",
",",
"n",
",",
"T",
",",
"fs",
")",
":",
"Em",
"=",
"embed_seq",
"(",
"x",
",",
"tau",
",",
"n",
")",
"M",
"=",
"len",
"(",
"Em",
")",
"A",
"=",
"numpy",
".",
"tile",
"(",
"Em",
",",
"(",
"len",
"(",
... | Calculate largest Lyauponov exponent of a given time series x using
Rosenstein algorithm.
Parameters
----------
x
list
a time series
n
integer
embedding dimension
tau
integer
Embedding lag
fs
integer
Sampling frequency
... | [
"Calculate",
"largest",
"Lyauponov",
"exponent",
"of",
"a",
"given",
"time",
"series",
"x",
"using",
"Rosenstein",
"algorithm",
"."
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/pyeeg.py#L1007-L1112 |
mattja/nsim | nsim/analyses1/phase.py | mod2pi | def mod2pi(ts):
"""For a timeseries where all variables represent phases (in radians),
return an equivalent timeseries where all values are in the range (-pi, pi]
"""
return np.pi - np.mod(np.pi - ts, 2*np.pi) | python | def mod2pi(ts):
"""For a timeseries where all variables represent phases (in radians),
return an equivalent timeseries where all values are in the range (-pi, pi]
"""
return np.pi - np.mod(np.pi - ts, 2*np.pi) | [
"def",
"mod2pi",
"(",
"ts",
")",
":",
"return",
"np",
".",
"pi",
"-",
"np",
".",
"mod",
"(",
"np",
".",
"pi",
"-",
"ts",
",",
"2",
"*",
"np",
".",
"pi",
")"
] | For a timeseries where all variables represent phases (in radians),
return an equivalent timeseries where all values are in the range (-pi, pi] | [
"For",
"a",
"timeseries",
"where",
"all",
"variables",
"represent",
"phases",
"(",
"in",
"radians",
")",
"return",
"an",
"equivalent",
"timeseries",
"where",
"all",
"values",
"are",
"in",
"the",
"range",
"(",
"-",
"pi",
"pi",
"]"
] | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/phase.py#L17-L21 |
mattja/nsim | nsim/analyses1/phase.py | phase_crossings | def phase_crossings(ts, phi=0.0):
"""For a single variable timeseries representing the phase of an oscillator,
find the times at which the phase crosses angle phi,
with the condition that the phase must visit phi+pi between crossings.
(Thus if noise causes the phase to wander back and forth across angl... | python | def phase_crossings(ts, phi=0.0):
"""For a single variable timeseries representing the phase of an oscillator,
find the times at which the phase crosses angle phi,
with the condition that the phase must visit phi+pi between crossings.
(Thus if noise causes the phase to wander back and forth across angl... | [
"def",
"phase_crossings",
"(",
"ts",
",",
"phi",
"=",
"0.0",
")",
":",
"#TODO support multivariate time series",
"ts",
"=",
"ts",
".",
"squeeze",
"(",
")",
"if",
"ts",
".",
"ndim",
"is",
"not",
"1",
":",
"raise",
"ValueError",
"(",
"'Currently can only use o... | For a single variable timeseries representing the phase of an oscillator,
find the times at which the phase crosses angle phi,
with the condition that the phase must visit phi+pi between crossings.
(Thus if noise causes the phase to wander back and forth across angle phi
without the oscillator doing a... | [
"For",
"a",
"single",
"variable",
"timeseries",
"representing",
"the",
"phase",
"of",
"an",
"oscillator",
"find",
"the",
"times",
"at",
"which",
"the",
"phase",
"crosses",
"angle",
"phi",
"with",
"the",
"condition",
"that",
"the",
"phase",
"must",
"visit",
"... | train | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analyses1/phase.py#L24-L82 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.