partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
popd
Go back to where you once were. :return: saved directory stack
reusables/cli.py
def popd(): """Go back to where you once were. :return: saved directory stack """ try: directory = _saved_paths.pop(0) except IndexError: return [os.getcwd()] os.chdir(directory) return [directory] + _saved_paths
def popd(): """Go back to where you once were. :return: saved directory stack """ try: directory = _saved_paths.pop(0) except IndexError: return [os.getcwd()] os.chdir(directory) return [directory] + _saved_paths
[ "Go", "back", "to", "where", "you", "once", "were", "." ]
cdgriffith/Reusables
python
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/cli.py#L59-L69
[ "def", "popd", "(", ")", ":", "try", ":", "directory", "=", "_saved_paths", ".", "pop", "(", "0", ")", "except", "IndexError", ":", "return", "[", "os", ".", "getcwd", "(", ")", "]", "os", ".", "chdir", "(", "directory", ")", "return", "[", "direct...
bc32f72e4baee7d76a6d58b88fcb23dd635155cd
train
ls
Know the best python implantation of ls? It's just to subprocess ls... (uses dir on windows). :param params: options to pass to ls or dir :param directory: if not this directory :param printed: If you're using this, you probably wanted it just printed :return: if not printed, you can parse it yours...
reusables/cli.py
def ls(params="", directory=".", printed=True): """Know the best python implantation of ls? It's just to subprocess ls... (uses dir on windows). :param params: options to pass to ls or dir :param directory: if not this directory :param printed: If you're using this, you probably wanted it just prin...
def ls(params="", directory=".", printed=True): """Know the best python implantation of ls? It's just to subprocess ls... (uses dir on windows). :param params: options to pass to ls or dir :param directory: if not this directory :param printed: If you're using this, you probably wanted it just prin...
[ "Know", "the", "best", "python", "implantation", "of", "ls?", "It", "s", "just", "to", "subprocess", "ls", "...", "(", "uses", "dir", "on", "windows", ")", "." ]
cdgriffith/Reusables
python
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/cli.py#L85-L101
[ "def", "ls", "(", "params", "=", "\"\"", ",", "directory", "=", "\".\"", ",", "printed", "=", "True", ")", ":", "command", "=", "\"{0} {1} {2}\"", ".", "format", "(", "\"ls\"", "if", "not", "win_based", "else", "\"dir\"", ",", "params", ",", "directory",...
bc32f72e4baee7d76a6d58b88fcb23dd635155cd
train
find
Designed for the interactive interpreter by making default order of find_files faster. :param name: Part of the file name :param ext: Extensions of the file you are looking for :param directory: Top location to recursively search for matching files :param match_case: If name has to be a direct matc...
reusables/cli.py
def find(name=None, ext=None, directory=".", match_case=False, disable_glob=False, depth=None): """ Designed for the interactive interpreter by making default order of find_files faster. :param name: Part of the file name :param ext: Extensions of the file you are looking for :param direct...
def find(name=None, ext=None, directory=".", match_case=False, disable_glob=False, depth=None): """ Designed for the interactive interpreter by making default order of find_files faster. :param name: Part of the file name :param ext: Extensions of the file you are looking for :param direct...
[ "Designed", "for", "the", "interactive", "interpreter", "by", "making", "default", "order", "of", "find_files", "faster", "." ]
cdgriffith/Reusables
python
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/cli.py#L104-L119
[ "def", "find", "(", "name", "=", "None", ",", "ext", "=", "None", ",", "directory", "=", "\".\"", ",", "match_case", "=", "False", ",", "disable_glob", "=", "False", ",", "depth", "=", "None", ")", ":", "return", "find_files_list", "(", "directory", "=...
bc32f72e4baee7d76a6d58b88fcb23dd635155cd
train
head
Read the first N lines of a file, defaults to 10 :param file_path: Path to file to read :param lines: Number of lines to read in :param encoding: defaults to utf-8 to decode as, will fail on binary :param printed: Automatically print the lines instead of returning it :param errors: Decoding errors:...
reusables/cli.py
def head(file_path, lines=10, encoding="utf-8", printed=True, errors='strict'): """ Read the first N lines of a file, defaults to 10 :param file_path: Path to file to read :param lines: Number of lines to read in :param encoding: defaults to utf-8 to decode as, will fail on binary :par...
def head(file_path, lines=10, encoding="utf-8", printed=True, errors='strict'): """ Read the first N lines of a file, defaults to 10 :param file_path: Path to file to read :param lines: Number of lines to read in :param encoding: defaults to utf-8 to decode as, will fail on binary :par...
[ "Read", "the", "first", "N", "lines", "of", "a", "file", "defaults", "to", "10" ]
cdgriffith/Reusables
python
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/cli.py#L122-L147
[ "def", "head", "(", "file_path", ",", "lines", "=", "10", ",", "encoding", "=", "\"utf-8\"", ",", "printed", "=", "True", ",", "errors", "=", "'strict'", ")", ":", "data", "=", "[", "]", "with", "open", "(", "file_path", ",", "\"rb\"", ")", "as", "...
bc32f72e4baee7d76a6d58b88fcb23dd635155cd
train
tail
A really silly way to get the last N lines, defaults to 10. :param file_path: Path to file to read :param lines: Number of lines to read in :param encoding: defaults to utf-8 to decode as, will fail on binary :param printed: Automatically print the lines instead of returning it :param errors: Deco...
reusables/cli.py
def tail(file_path, lines=10, encoding="utf-8", printed=True, errors='strict'): """ A really silly way to get the last N lines, defaults to 10. :param file_path: Path to file to read :param lines: Number of lines to read in :param encoding: defaults to utf-8 to decode as, will fail on bin...
def tail(file_path, lines=10, encoding="utf-8", printed=True, errors='strict'): """ A really silly way to get the last N lines, defaults to 10. :param file_path: Path to file to read :param lines: Number of lines to read in :param encoding: defaults to utf-8 to decode as, will fail on bin...
[ "A", "really", "silly", "way", "to", "get", "the", "last", "N", "lines", "defaults", "to", "10", "." ]
cdgriffith/Reusables
python
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/cli.py#L175-L201
[ "def", "tail", "(", "file_path", ",", "lines", "=", "10", ",", "encoding", "=", "\"utf-8\"", ",", "printed", "=", "True", ",", "errors", "=", "'strict'", ")", ":", "data", "=", "deque", "(", ")", "with", "open", "(", "file_path", ",", "\"rb\"", ")", ...
bc32f72e4baee7d76a6d58b88fcb23dd635155cd
train
cp
Copy files to a new location. :param src: list (or string) of paths of files to copy :param dst: file or folder to copy item(s) to :param overwrite: IF the file already exists, should I overwrite it?
reusables/cli.py
def cp(src, dst, overwrite=False): """ Copy files to a new location. :param src: list (or string) of paths of files to copy :param dst: file or folder to copy item(s) to :param overwrite: IF the file already exists, should I overwrite it? """ if not isinstance(src, list): src = [sr...
def cp(src, dst, overwrite=False): """ Copy files to a new location. :param src: list (or string) of paths of files to copy :param dst: file or folder to copy item(s) to :param overwrite: IF the file already exists, should I overwrite it? """ if not isinstance(src, list): src = [sr...
[ "Copy", "files", "to", "a", "new", "location", "." ]
cdgriffith/Reusables
python
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/cli.py#L204-L231
[ "def", "cp", "(", "src", ",", "dst", ",", "overwrite", "=", "False", ")", ":", "if", "not", "isinstance", "(", "src", ",", "list", ")", ":", "src", "=", "[", "src", "]", "dst", "=", "os", ".", "path", ".", "expanduser", "(", "dst", ")", "dst_fo...
bc32f72e4baee7d76a6d58b88fcb23dd635155cd
train
cut
Split a string into a list of N characters each. .. code:: python reusables.cut("abcdefghi") # ['ab', 'cd', 'ef', 'gh', 'i'] trailing gives you the following options: * normal: leaves remaining characters in their own last position * remove: return the list without the remainder char...
reusables/string_manipulation.py
def cut(string, characters=2, trailing="normal"): """ Split a string into a list of N characters each. .. code:: python reusables.cut("abcdefghi") # ['ab', 'cd', 'ef', 'gh', 'i'] trailing gives you the following options: * normal: leaves remaining characters in their own last pos...
def cut(string, characters=2, trailing="normal"): """ Split a string into a list of N characters each. .. code:: python reusables.cut("abcdefghi") # ['ab', 'cd', 'ef', 'gh', 'i'] trailing gives you the following options: * normal: leaves remaining characters in their own last pos...
[ "Split", "a", "string", "into", "a", "list", "of", "N", "characters", "each", "." ]
cdgriffith/Reusables
python
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/string_manipulation.py#L24-L69
[ "def", "cut", "(", "string", ",", "characters", "=", "2", ",", "trailing", "=", "\"normal\"", ")", ":", "split_str", "=", "[", "string", "[", "i", ":", "i", "+", "characters", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "string", "...
bc32f72e4baee7d76a6d58b88fcb23dd635155cd
train
int_to_roman
Convert an integer into a string of roman numbers. .. code: python reusables.int_to_roman(445) # 'CDXLV' :param integer: :return: roman string
reusables/string_manipulation.py
def int_to_roman(integer): """ Convert an integer into a string of roman numbers. .. code: python reusables.int_to_roman(445) # 'CDXLV' :param integer: :return: roman string """ if not isinstance(integer, int): raise ValueError("Input integer must be of type int")...
def int_to_roman(integer): """ Convert an integer into a string of roman numbers. .. code: python reusables.int_to_roman(445) # 'CDXLV' :param integer: :return: roman string """ if not isinstance(integer, int): raise ValueError("Input integer must be of type int")...
[ "Convert", "an", "integer", "into", "a", "string", "of", "roman", "numbers", "." ]
cdgriffith/Reusables
python
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/string_manipulation.py#L72-L94
[ "def", "int_to_roman", "(", "integer", ")", ":", "if", "not", "isinstance", "(", "integer", ",", "int", ")", ":", "raise", "ValueError", "(", "\"Input integer must be of type int\"", ")", "output", "=", "[", "]", "while", "integer", ">", "0", ":", "for", "...
bc32f72e4baee7d76a6d58b88fcb23dd635155cd
train
roman_to_int
Converts a string of roman numbers into an integer. .. code: python reusables.roman_to_int("XXXVI") # 36 :param roman_string: XVI or similar :return: parsed integer
reusables/string_manipulation.py
def roman_to_int(roman_string): """ Converts a string of roman numbers into an integer. .. code: python reusables.roman_to_int("XXXVI") # 36 :param roman_string: XVI or similar :return: parsed integer """ roman_string = roman_string.upper().strip() if "IIII" in roman_...
def roman_to_int(roman_string): """ Converts a string of roman numbers into an integer. .. code: python reusables.roman_to_int("XXXVI") # 36 :param roman_string: XVI or similar :return: parsed integer """ roman_string = roman_string.upper().strip() if "IIII" in roman_...
[ "Converts", "a", "string", "of", "roman", "numbers", "into", "an", "integer", "." ]
cdgriffith/Reusables
python
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/string_manipulation.py#L97-L135
[ "def", "roman_to_int", "(", "roman_string", ")", ":", "roman_string", "=", "roman_string", ".", "upper", "(", ")", ".", "strip", "(", ")", "if", "\"IIII\"", "in", "roman_string", ":", "raise", "ValueError", "(", "\"Malformed roman string\"", ")", "value", "=",...
bc32f72e4baee7d76a6d58b88fcb23dd635155cd
train
int_to_words
Converts an integer or float to words. .. code: python reusables.int_to_number(445) # 'four hundred forty-five' reusables.int_to_number(1.45) # 'one and forty-five hundredths' :param number: String, integer, or float to convert to words. The decimal can only be up to ...
reusables/string_manipulation.py
def int_to_words(number, european=False): """ Converts an integer or float to words. .. code: python reusables.int_to_number(445) # 'four hundred forty-five' reusables.int_to_number(1.45) # 'one and forty-five hundredths' :param number: String, integer, or float to co...
def int_to_words(number, european=False): """ Converts an integer or float to words. .. code: python reusables.int_to_number(445) # 'four hundred forty-five' reusables.int_to_number(1.45) # 'one and forty-five hundredths' :param number: String, integer, or float to co...
[ "Converts", "an", "integer", "or", "float", "to", "words", "." ]
cdgriffith/Reusables
python
https://github.com/cdgriffith/Reusables/blob/bc32f72e4baee7d76a6d58b88fcb23dd635155cd/reusables/string_manipulation.py#L138-L247
[ "def", "int_to_words", "(", "number", ",", "european", "=", "False", ")", ":", "def", "ones", "(", "n", ")", ":", "return", "\"\"", "if", "n", "==", "0", "else", "_numbers", "[", "n", "]", "def", "tens", "(", "n", ")", ":", "teen", "=", "int", ...
bc32f72e4baee7d76a6d58b88fcb23dd635155cd
train
filter_osm_file
Downloads (and compiles) osmfilter tool from web and calls that osmfilter to only filter out only the road elements.
roadmaptools/osmfilter.py
def filter_osm_file(): """ Downloads (and compiles) osmfilter tool from web and calls that osmfilter to only filter out only the road elements. """ print_info('Filtering OSM file...') start_time = time.time() if check_osmfilter(): # params = '--keep="highway=motorway =motorway...
def filter_osm_file(): """ Downloads (and compiles) osmfilter tool from web and calls that osmfilter to only filter out only the road elements. """ print_info('Filtering OSM file...') start_time = time.time() if check_osmfilter(): # params = '--keep="highway=motorway =motorway...
[ "Downloads", "(", "and", "compiles", ")", "osmfilter", "tool", "from", "web", "and", "calls", "that", "osmfilter", "to", "only", "filter", "out", "only", "the", "road", "elements", "." ]
aicenter/roadmap-processing
python
https://github.com/aicenter/roadmap-processing/blob/d9fb6e0b3bc1f11302a9e2ac62ee6db9484e2018/roadmaptools/osmfilter.py#L10-L37
[ "def", "filter_osm_file", "(", ")", ":", "print_info", "(", "'Filtering OSM file...'", ")", "start_time", "=", "time", ".", "time", "(", ")", "if", "check_osmfilter", "(", ")", ":", "# params = '--keep=\"highway=motorway =motorway_link =trunk =trunk_link =primary =primary_l...
d9fb6e0b3bc1f11302a9e2ac62ee6db9484e2018
train
task_list
Scans the modules set in RQ_JOBS_MODULES for RQ jobs decorated with @task Compiles a readable list for Job model task choices
django_rq_jobs/models.py
def task_list(): """ Scans the modules set in RQ_JOBS_MODULES for RQ jobs decorated with @task Compiles a readable list for Job model task choices """ try: jobs_module = settings.RQ_JOBS_MODULE except AttributeError: raise ImproperlyConfigured(_("You have to define RQ_JOBS_MODULE...
def task_list(): """ Scans the modules set in RQ_JOBS_MODULES for RQ jobs decorated with @task Compiles a readable list for Job model task choices """ try: jobs_module = settings.RQ_JOBS_MODULE except AttributeError: raise ImproperlyConfigured(_("You have to define RQ_JOBS_MODULE...
[ "Scans", "the", "modules", "set", "in", "RQ_JOBS_MODULES", "for", "RQ", "jobs", "decorated", "with" ]
Koed00/django-rq-jobs
python
https://github.com/Koed00/django-rq-jobs/blob/b25ffd15c91858406494ae0c29babf00c268db18/django_rq_jobs/models.py#L33-L65
[ "def", "task_list", "(", ")", ":", "try", ":", "jobs_module", "=", "settings", ".", "RQ_JOBS_MODULE", "except", "AttributeError", ":", "raise", "ImproperlyConfigured", "(", "_", "(", "\"You have to define RQ_JOBS_MODULE in settings.py\"", ")", ")", "if", "isinstance",...
b25ffd15c91858406494ae0c29babf00c268db18
train
Job.rq_job
The last RQ Job this ran on
django_rq_jobs/models.py
def rq_job(self): """The last RQ Job this ran on""" if not self.rq_id or not self.rq_origin: return try: return RQJob.fetch(self.rq_id, connection=get_connection(self.rq_origin)) except NoSuchJobError: return
def rq_job(self): """The last RQ Job this ran on""" if not self.rq_id or not self.rq_origin: return try: return RQJob.fetch(self.rq_id, connection=get_connection(self.rq_origin)) except NoSuchJobError: return
[ "The", "last", "RQ", "Job", "this", "ran", "on" ]
Koed00/django-rq-jobs
python
https://github.com/Koed00/django-rq-jobs/blob/b25ffd15c91858406494ae0c29babf00c268db18/django_rq_jobs/models.py#L95-L102
[ "def", "rq_job", "(", "self", ")", ":", "if", "not", "self", ".", "rq_id", "or", "not", "self", ".", "rq_origin", ":", "return", "try", ":", "return", "RQJob", ".", "fetch", "(", "self", ".", "rq_id", ",", "connection", "=", "get_connection", "(", "s...
b25ffd15c91858406494ae0c29babf00c268db18
train
Job.rq_link
Link to Django-RQ status page for this job
django_rq_jobs/models.py
def rq_link(self): """Link to Django-RQ status page for this job""" if self.rq_job: url = reverse('rq_job_detail', kwargs={'job_id': self.rq_id, 'queue_index': queue_index_by_name(self.rq_origin)}) return '<a href="{}">{}</a>'.format(url, self.rq_id)
def rq_link(self): """Link to Django-RQ status page for this job""" if self.rq_job: url = reverse('rq_job_detail', kwargs={'job_id': self.rq_id, 'queue_index': queue_index_by_name(self.rq_origin)}) return '<a href="{}">{}</a>'.format(url, self.rq_id)
[ "Link", "to", "Django", "-", "RQ", "status", "page", "for", "this", "job" ]
Koed00/django-rq-jobs
python
https://github.com/Koed00/django-rq-jobs/blob/b25ffd15c91858406494ae0c29babf00c268db18/django_rq_jobs/models.py#L109-L114
[ "def", "rq_link", "(", "self", ")", ":", "if", "self", ".", "rq_job", ":", "url", "=", "reverse", "(", "'rq_job_detail'", ",", "kwargs", "=", "{", "'job_id'", ":", "self", ".", "rq_id", ",", "'queue_index'", ":", "queue_index_by_name", "(", "self", ".", ...
b25ffd15c91858406494ae0c29babf00c268db18
train
Job.rq_task
The function to call for this task. Config errors are caught by tasks_list() already.
django_rq_jobs/models.py
def rq_task(self): """ The function to call for this task. Config errors are caught by tasks_list() already. """ task_path = self.task.split('.') module_name = '.'.join(task_path[:-1]) task_name = task_path[-1] module = importlib.import_module(module_name...
def rq_task(self): """ The function to call for this task. Config errors are caught by tasks_list() already. """ task_path = self.task.split('.') module_name = '.'.join(task_path[:-1]) task_name = task_path[-1] module = importlib.import_module(module_name...
[ "The", "function", "to", "call", "for", "this", "task", ".", "Config", "errors", "are", "caught", "by", "tasks_list", "()", "already", "." ]
Koed00/django-rq-jobs
python
https://github.com/Koed00/django-rq-jobs/blob/b25ffd15c91858406494ae0c29babf00c268db18/django_rq_jobs/models.py#L117-L127
[ "def", "rq_task", "(", "self", ")", ":", "task_path", "=", "self", ".", "task", ".", "split", "(", "'.'", ")", "module_name", "=", "'.'", ".", "join", "(", "task_path", "[", ":", "-", "1", "]", ")", "task_name", "=", "task_path", "[", "-", "1", "...
b25ffd15c91858406494ae0c29babf00c268db18
train
fix_module
Fix for tasks without a module. Provides backwards compatibility with < 0.1.5
django_rq_jobs/management/commands/rqjobs.py
def fix_module(job): """ Fix for tasks without a module. Provides backwards compatibility with < 0.1.5 """ modules = settings.RQ_JOBS_MODULE if not type(modules) == tuple: modules = [modules] for module in modules: try: module_match = importlib.import_module(module) ...
def fix_module(job): """ Fix for tasks without a module. Provides backwards compatibility with < 0.1.5 """ modules = settings.RQ_JOBS_MODULE if not type(modules) == tuple: modules = [modules] for module in modules: try: module_match = importlib.import_module(module) ...
[ "Fix", "for", "tasks", "without", "a", "module", ".", "Provides", "backwards", "compatibility", "with", "<", "0", ".", "1", ".", "5" ]
Koed00/django-rq-jobs
python
https://github.com/Koed00/django-rq-jobs/blob/b25ffd15c91858406494ae0c29babf00c268db18/django_rq_jobs/management/commands/rqjobs.py#L59-L74
[ "def", "fix_module", "(", "job", ")", ":", "modules", "=", "settings", ".", "RQ_JOBS_MODULE", "if", "not", "type", "(", "modules", ")", "==", "tuple", ":", "modules", "=", "[", "modules", "]", "for", "module", "in", "modules", ":", "try", ":", "module_...
b25ffd15c91858406494ae0c29babf00c268db18
train
drop_model_tables
Drop tables for all given models (in the right order).
aioorm/database.py
async def drop_model_tables(models, **drop_table_kwargs): """Drop tables for all given models (in the right order).""" for m in reversed(sort_models_topologically(models)): await m.drop_table(**drop_table_kwargs)
async def drop_model_tables(models, **drop_table_kwargs): """Drop tables for all given models (in the right order).""" for m in reversed(sort_models_topologically(models)): await m.drop_table(**drop_table_kwargs)
[ "Drop", "tables", "for", "all", "given", "models", "(", "in", "the", "right", "order", ")", "." ]
Python-Tools/aioorm
python
https://github.com/Python-Tools/aioorm/blob/f305e253ce748cda91b8bc9ec9c6b56e0e7681f7/aioorm/database.py#L244-L247
[ "async", "def", "drop_model_tables", "(", "models", ",", "*", "*", "drop_table_kwargs", ")", ":", "for", "m", "in", "reversed", "(", "sort_models_topologically", "(", "models", ")", ")", ":", "await", "m", ".", "drop_table", "(", "*", "*", "drop_table_kwargs...
f305e253ce748cda91b8bc9ec9c6b56e0e7681f7
train
model_to_dict
Convert a model instance (and any related objects) to a dictionary. :param bool recurse: Whether foreign-keys should be recursed. :param bool backrefs: Whether lists of related objects should be recursed. :param only: A list (or set) of field instances indicating which fields should be included. ...
aioorm/shortcuts.py
async def model_to_dict(model, recurse=True, backrefs=False, only=None, exclude=None, seen=None, extra_attrs=None, fields_from_query=None, max_depth=None): """ Convert a model instance (and any related objects) to a dictionary. :param bool recurse: Whether for...
async def model_to_dict(model, recurse=True, backrefs=False, only=None, exclude=None, seen=None, extra_attrs=None, fields_from_query=None, max_depth=None): """ Convert a model instance (and any related objects) to a dictionary. :param bool recurse: Whether for...
[ "Convert", "a", "model", "instance", "(", "and", "any", "related", "objects", ")", "to", "a", "dictionary", ".", ":", "param", "bool", "recurse", ":", "Whether", "foreign", "-", "keys", "should", "be", "recursed", ".", ":", "param", "bool", "backrefs", "...
Python-Tools/aioorm
python
https://github.com/Python-Tools/aioorm/blob/f305e253ce748cda91b8bc9ec9c6b56e0e7681f7/aioorm/shortcuts.py#L6-L101
[ "async", "def", "model_to_dict", "(", "model", ",", "recurse", "=", "True", ",", "backrefs", "=", "False", ",", "only", "=", "None", ",", "exclude", "=", "None", ",", "seen", "=", "None", ",", "extra_attrs", "=", "None", ",", "fields_from_query", "=", ...
f305e253ce748cda91b8bc9ec9c6b56e0e7681f7
train
RowConverter.extract_rows
Extract `self.sample_size` rows from the CSV file and analyze their data-types. :param str file_or_name: A string filename or a file handle. :param reader_kwargs: Arbitrary parameters to pass to the CSV reader. :returns: A 2-tuple containing a list of headers and list of rows ...
aioorm/utils/csv_utils/csv_loader.py
async def extract_rows(self, file_or_name, **reader_kwargs): """ Extract `self.sample_size` rows from the CSV file and analyze their data-types. :param str file_or_name: A string filename or a file handle. :param reader_kwargs: Arbitrary parameters to pass to the CSV reader. ...
async def extract_rows(self, file_or_name, **reader_kwargs): """ Extract `self.sample_size` rows from the CSV file and analyze their data-types. :param str file_or_name: A string filename or a file handle. :param reader_kwargs: Arbitrary parameters to pass to the CSV reader. ...
[ "Extract", "self", ".", "sample_size", "rows", "from", "the", "CSV", "file", "and", "analyze", "their", "data", "-", "types", ".", ":", "param", "str", "file_or_name", ":", "A", "string", "filename", "or", "a", "file", "handle", ".", ":", "param", "reade...
Python-Tools/aioorm
python
https://github.com/Python-Tools/aioorm/blob/f305e253ce748cda91b8bc9ec9c6b56e0e7681f7/aioorm/utils/csv_utils/csv_loader.py#L123-L150
[ "async", "def", "extract_rows", "(", "self", ",", "file_or_name", ",", "*", "*", "reader_kwargs", ")", ":", "rows", "=", "[", "]", "rows_to_read", "=", "self", ".", "sample_size", "async", "with", "self", ".", "get_reader", "(", "file_or_name", ",", "*", ...
f305e253ce748cda91b8bc9ec9c6b56e0e7681f7
train
RowConverter.get_checks
Return a list of functions to use when testing values.
aioorm/utils/csv_utils/csv_loader.py
def get_checks(self): """Return a list of functions to use when testing values.""" return [ self.is_date, self.is_datetime, self.is_integer, self.is_float, self.default]
def get_checks(self): """Return a list of functions to use when testing values.""" return [ self.is_date, self.is_datetime, self.is_integer, self.is_float, self.default]
[ "Return", "a", "list", "of", "functions", "to", "use", "when", "testing", "values", "." ]
Python-Tools/aioorm
python
https://github.com/Python-Tools/aioorm/blob/f305e253ce748cda91b8bc9ec9c6b56e0e7681f7/aioorm/utils/csv_utils/csv_loader.py#L152-L159
[ "def", "get_checks", "(", "self", ")", ":", "return", "[", "self", ".", "is_date", ",", "self", ".", "is_datetime", ",", "self", ".", "is_integer", ",", "self", ".", "is_float", ",", "self", ".", "default", "]" ]
f305e253ce748cda91b8bc9ec9c6b56e0e7681f7
train
RowConverter.analyze
Analyze the given rows and try to determine the type of value stored. :param list rows: A list-of-lists containing one or more rows from a csv file. :returns: A list of peewee Field objects for each column in the CSV.
aioorm/utils/csv_utils/csv_loader.py
def analyze(self, rows): """ Analyze the given rows and try to determine the type of value stored. :param list rows: A list-of-lists containing one or more rows from a csv file. :returns: A list of peewee Field objects for each column in the CSV. """ ...
def analyze(self, rows): """ Analyze the given rows and try to determine the type of value stored. :param list rows: A list-of-lists containing one or more rows from a csv file. :returns: A list of peewee Field objects for each column in the CSV. """ ...
[ "Analyze", "the", "given", "rows", "and", "try", "to", "determine", "the", "type", "of", "value", "stored", ".", ":", "param", "list", "rows", ":", "A", "list", "-", "of", "-", "lists", "containing", "one", "or", "more", "rows", "from", "a", "csv", "...
Python-Tools/aioorm
python
https://github.com/Python-Tools/aioorm/blob/f305e253ce748cda91b8bc9ec9c6b56e0e7681f7/aioorm/utils/csv_utils/csv_loader.py#L161-L180
[ "def", "analyze", "(", "self", ",", "rows", ")", ":", "transposed", "=", "zip", "(", "*", "rows", ")", "checks", "=", "self", ".", "get_checks", "(", ")", "column_types", "=", "[", "]", "for", "i", ",", "column", "in", "enumerate", "(", "transposed",...
f305e253ce748cda91b8bc9ec9c6b56e0e7681f7
train
BleachField.clean_text
Clean text using bleach.
bleachfields/bleachfield.py
def clean_text(self, text): '''Clean text using bleach.''' if text is None: return '' text = re.sub(ILLEGAL_CHARACTERS_RE, '', text) if '<' in text or '&lt' in text: text = clean(text, tags=self.tags, strip=self.strip) return unescape(text)
def clean_text(self, text): '''Clean text using bleach.''' if text is None: return '' text = re.sub(ILLEGAL_CHARACTERS_RE, '', text) if '<' in text or '&lt' in text: text = clean(text, tags=self.tags, strip=self.strip) return unescape(text)
[ "Clean", "text", "using", "bleach", "." ]
BetterWorks/django-bleachfields
python
https://github.com/BetterWorks/django-bleachfields/blob/6b49aad6daa8c1357af31a2f7941352561d04cd6/bleachfields/bleachfield.py#L26-L34
[ "def", "clean_text", "(", "self", ",", "text", ")", ":", "if", "text", "is", "None", ":", "return", "''", "text", "=", "re", ".", "sub", "(", "ILLEGAL_CHARACTERS_RE", ",", "''", ",", "text", ")", "if", "'<'", "in", "text", "or", "'&lt'", "in", "tex...
6b49aad6daa8c1357af31a2f7941352561d04cd6
train
LoadFromDisk.path
Constructs the path to categories, images and features. This path function assumes that the following storage scheme is used on the hard disk to access categories, images and features: - categories: /impath/category - images: /impath/category/category_image.png -...
ocupy/loader.py
def path(self, category = None, image = None, feature = None): """ Constructs the path to categories, images and features. This path function assumes that the following storage scheme is used on the hard disk to access categories, images and features: - categories: /impath/categor...
def path(self, category = None, image = None, feature = None): """ Constructs the path to categories, images and features. This path function assumes that the following storage scheme is used on the hard disk to access categories, images and features: - categories: /impath/categor...
[ "Constructs", "the", "path", "to", "categories", "images", "and", "features", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/loader.py#L168-L195
[ "def", "path", "(", "self", ",", "category", "=", "None", ",", "image", "=", "None", ",", "feature", "=", "None", ")", ":", "filename", "=", "None", "if", "not", "category", "is", "None", ":", "filename", "=", "join", "(", "self", ".", "impath", ",...
a0bd64f822576feaa502939d6bafd1183b237d16
train
LoadFromDisk.get_image
Loads an image from disk.
ocupy/loader.py
def get_image(self, cat, img): """ Loads an image from disk. """ filename = self.path(cat, img) data = [] if filename.endswith('mat'): data = loadmat(filename)['output'] else: data = imread(filename) if self.size is not None: return imr...
def get_image(self, cat, img): """ Loads an image from disk. """ filename = self.path(cat, img) data = [] if filename.endswith('mat'): data = loadmat(filename)['output'] else: data = imread(filename) if self.size is not None: return imr...
[ "Loads", "an", "image", "from", "disk", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/loader.py#L197-L208
[ "def", "get_image", "(", "self", ",", "cat", ",", "img", ")", ":", "filename", "=", "self", ".", "path", "(", "cat", ",", "img", ")", "data", "=", "[", "]", "if", "filename", ".", "endswith", "(", "'mat'", ")", ":", "data", "=", "loadmat", "(", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
LoadFromDisk.get_feature
Load a feature from disk.
ocupy/loader.py
def get_feature(self, cat, img, feature): """ Load a feature from disk. """ filename = self.path(cat, img, feature) data = loadmat(filename) name = [k for k in list(data.keys()) if not k.startswith('__')] if self.size is not None: return imresize(data[...
def get_feature(self, cat, img, feature): """ Load a feature from disk. """ filename = self.path(cat, img, feature) data = loadmat(filename) name = [k for k in list(data.keys()) if not k.startswith('__')] if self.size is not None: return imresize(data[...
[ "Load", "a", "feature", "from", "disk", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/loader.py#L210-L219
[ "def", "get_feature", "(", "self", ",", "cat", ",", "img", ",", "feature", ")", ":", "filename", "=", "self", ".", "path", "(", "cat", ",", "img", ",", "feature", ")", "data", "=", "loadmat", "(", "filename", ")", "name", "=", "[", "k", "for", "k...
a0bd64f822576feaa502939d6bafd1183b237d16
train
SaveToDisk.save_image
Saves a new image.
ocupy/loader.py
def save_image(self, cat, img, data): """Saves a new image.""" filename = self.path(cat, img) mkdir(filename) if type(data) == np.ndarray: data = Image.fromarray(data).convert('RGB') data.save(filename)
def save_image(self, cat, img, data): """Saves a new image.""" filename = self.path(cat, img) mkdir(filename) if type(data) == np.ndarray: data = Image.fromarray(data).convert('RGB') data.save(filename)
[ "Saves", "a", "new", "image", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/loader.py#L243-L249
[ "def", "save_image", "(", "self", ",", "cat", ",", "img", ",", "data", ")", ":", "filename", "=", "self", ".", "path", "(", "cat", ",", "img", ")", "mkdir", "(", "filename", ")", "if", "type", "(", "data", ")", "==", "np", ".", "ndarray", ":", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
SaveToDisk.save_feature
Saves a new feature.
ocupy/loader.py
def save_feature(self, cat, img, feature, data): """Saves a new feature.""" filename = self.path(cat, img, feature) mkdir(filename) savemat(filename, {'output':data})
def save_feature(self, cat, img, feature, data): """Saves a new feature.""" filename = self.path(cat, img, feature) mkdir(filename) savemat(filename, {'output':data})
[ "Saves", "a", "new", "feature", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/loader.py#L251-L255
[ "def", "save_feature", "(", "self", ",", "cat", ",", "img", ",", "feature", ",", "data", ")", ":", "filename", "=", "self", ".", "path", "(", "cat", ",", "img", ",", "feature", ")", "mkdir", "(", "filename", ")", "savemat", "(", "filename", ",", "{...
a0bd64f822576feaa502939d6bafd1183b237d16
train
factorise_field
This removes a common beginning from the data of the fields, placing the common element in a parameter and the different endings in the fields. if parameter_name is None, then it will be <field_name>_common. So far, it's probably only useful for the file_name. TODO: remove field entirely ...
ocupy/datamat_tools.py
def factorise_field(dm, field_name, boundary_char = None, parameter_name=None): """This removes a common beginning from the data of the fields, placing the common element in a parameter and the different endings in the fields. if parameter_name is None, then it will be <field_name>_common. So ...
def factorise_field(dm, field_name, boundary_char = None, parameter_name=None): """This removes a common beginning from the data of the fields, placing the common element in a parameter and the different endings in the fields. if parameter_name is None, then it will be <field_name>_common. So ...
[ "This", "removes", "a", "common", "beginning", "from", "the", "data", "of", "the", "fields", "placing", "the", "common", "element", "in", "a", "parameter", "and", "the", "different", "endings", "in", "the", "fields", ".", "if", "parameter_name", "is", "None"...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat_tools.py#L11-L34
[ "def", "factorise_field", "(", "dm", ",", "field_name", ",", "boundary_char", "=", "None", ",", "parameter_name", "=", "None", ")", ":", "old_data", "=", "dm", ".", "field", "(", "field_name", ")", "if", "isinstance", "(", "old_data", "[", "0", "]", ",",...
a0bd64f822576feaa502939d6bafd1183b237d16
train
randsample
Draws nr_samples random samples from vec.
ocupy/utils.py
def randsample(vec, nr_samples, with_replacement = False): """ Draws nr_samples random samples from vec. """ if not with_replacement: return np.random.permutation(vec)[0:nr_samples] else: return np.asarray(vec)[np.random.randint(0, len(vec), nr_samples)]
def randsample(vec, nr_samples, with_replacement = False): """ Draws nr_samples random samples from vec. """ if not with_replacement: return np.random.permutation(vec)[0:nr_samples] else: return np.asarray(vec)[np.random.randint(0, len(vec), nr_samples)]
[ "Draws", "nr_samples", "random", "samples", "from", "vec", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/utils.py#L63-L70
[ "def", "randsample", "(", "vec", ",", "nr_samples", ",", "with_replacement", "=", "False", ")", ":", "if", "not", "with_replacement", ":", "return", "np", ".", "random", ".", "permutation", "(", "vec", ")", "[", "0", ":", "nr_samples", "]", "else", ":", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
calc_resize_factor
Calculates how much prediction.shape and image_size differ.
ocupy/utils.py
def calc_resize_factor(prediction, image_size): """ Calculates how much prediction.shape and image_size differ. """ resize_factor_x = prediction.shape[1] / float(image_size[1]) resize_factor_y = prediction.shape[0] / float(image_size[0]) if abs(resize_factor_x - resize_factor_y) > 1.0/image_size...
def calc_resize_factor(prediction, image_size): """ Calculates how much prediction.shape and image_size differ. """ resize_factor_x = prediction.shape[1] / float(image_size[1]) resize_factor_y = prediction.shape[0] / float(image_size[0]) if abs(resize_factor_x - resize_factor_y) > 1.0/image_size...
[ "Calculates", "how", "much", "prediction", ".", "shape", "and", "image_size", "differ", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/utils.py#L78-L88
[ "def", "calc_resize_factor", "(", "prediction", ",", "image_size", ")", ":", "resize_factor_x", "=", "prediction", ".", "shape", "[", "1", "]", "/", "float", "(", "image_size", "[", "1", "]", ")", "resize_factor_y", "=", "prediction", ".", "shape", "[", "0...
a0bd64f822576feaa502939d6bafd1183b237d16
train
dict_2_mat
Creates a NumPy array from a dictionary with only integers as keys and NumPy arrays as values. Dimension 0 of the resulting array is formed from data.keys(). Missing values in keys can be filled up with np.nan (default) or ignored. Parameters ---------- data : dict a dictionary with int...
ocupy/utils.py
def dict_2_mat(data, fill = True): """ Creates a NumPy array from a dictionary with only integers as keys and NumPy arrays as values. Dimension 0 of the resulting array is formed from data.keys(). Missing values in keys can be filled up with np.nan (default) or ignored. Parameters ---------...
def dict_2_mat(data, fill = True): """ Creates a NumPy array from a dictionary with only integers as keys and NumPy arrays as values. Dimension 0 of the resulting array is formed from data.keys(). Missing values in keys can be filled up with np.nan (default) or ignored. Parameters ---------...
[ "Creates", "a", "NumPy", "array", "from", "a", "dictionary", "with", "only", "integers", "as", "keys", "and", "NumPy", "arrays", "as", "values", ".", "Dimension", "0", "of", "the", "resulting", "array", "is", "formed", "from", "data", ".", "keys", "()", ...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/utils.py#L90-L128
[ "def", "dict_2_mat", "(", "data", ",", "fill", "=", "True", ")", ":", "if", "any", "(", "[", "type", "(", "k", ")", "!=", "int", "for", "k", "in", "list", "(", "data", ".", "keys", "(", ")", ")", "]", ")", ":", "raise", "RuntimeError", "(", "...
a0bd64f822576feaa502939d6bafd1183b237d16
train
dict_fun
Apply a function to all values in a dictionary, return a dictionary with results. Parameters ---------- data : dict a dictionary whose values are adequate input to the second argument of this function. function : function a function that takes one argument Returns ...
ocupy/utils.py
def dict_fun(data, function): """ Apply a function to all values in a dictionary, return a dictionary with results. Parameters ---------- data : dict a dictionary whose values are adequate input to the second argument of this function. function : function a function...
def dict_fun(data, function): """ Apply a function to all values in a dictionary, return a dictionary with results. Parameters ---------- data : dict a dictionary whose values are adequate input to the second argument of this function. function : function a function...
[ "Apply", "a", "function", "to", "all", "values", "in", "a", "dictionary", "return", "a", "dictionary", "with", "results", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/utils.py#L130-L148
[ "def", "dict_fun", "(", "data", ",", "function", ")", ":", "return", "dict", "(", "(", "k", ",", "function", "(", "v", ")", ")", "for", "k", ",", "v", "in", "list", "(", "data", ".", "items", "(", ")", ")", ")" ]
a0bd64f822576feaa502939d6bafd1183b237d16
train
snip_string_middle
>>> snip_string_middle('this is long', 8) 'th...ong' >>> snip_string_middle('this is long', 12) 'this is long' >>> snip_string_middle('this is long', 8, '~') 'thi~long'
ocupy/utils.py
def snip_string_middle(string, max_len=20, snip_string='...'): """ >>> snip_string_middle('this is long', 8) 'th...ong' >>> snip_string_middle('this is long', 12) 'this is long' >>> snip_string_middle('this is long', 8, '~') 'thi~long' """ #warn('use snip_string() instead', Dep...
def snip_string_middle(string, max_len=20, snip_string='...'): """ >>> snip_string_middle('this is long', 8) 'th...ong' >>> snip_string_middle('this is long', 12) 'this is long' >>> snip_string_middle('this is long', 8, '~') 'thi~long' """ #warn('use snip_string() instead', Dep...
[ ">>>", "snip_string_middle", "(", "this", "is", "long", "8", ")", "th", "...", "ong", ">>>", "snip_string_middle", "(", "this", "is", "long", "12", ")", "this", "is", "long", ">>>", "snip_string_middle", "(", "this", "is", "long", "8", "~", ")", "thi~lon...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/utils.py#L150-L171
[ "def", "snip_string_middle", "(", "string", ",", "max_len", "=", "20", ",", "snip_string", "=", "'...'", ")", ":", "#warn('use snip_string() instead', DeprecationWarning)", "if", "len", "(", "string", ")", "<=", "max_len", ":", "new_string", "=", "string", "else",...
a0bd64f822576feaa502939d6bafd1183b237d16
train
snip_string
Snips a string so that it is no longer than max_len, replacing deleted characters with the snip_string. The snip is done at snip_point, which is a fraction between 0 and 1, indicating relatively where along the string to snip. snip_point of 0.5 would be the middle. >>> snip_string('this is long', 8)...
ocupy/utils.py
def snip_string(string, max_len=20, snip_string='...', snip_point=0.5): """ Snips a string so that it is no longer than max_len, replacing deleted characters with the snip_string. The snip is done at snip_point, which is a fraction between 0 and 1, indicating relatively where along the string to sni...
def snip_string(string, max_len=20, snip_string='...', snip_point=0.5): """ Snips a string so that it is no longer than max_len, replacing deleted characters with the snip_string. The snip is done at snip_point, which is a fraction between 0 and 1, indicating relatively where along the string to sni...
[ "Snips", "a", "string", "so", "that", "it", "is", "no", "longer", "than", "max_len", "replacing", "deleted", "characters", "with", "the", "snip_string", ".", "The", "snip", "is", "done", "at", "snip_point", "which", "is", "a", "fraction", "between", "0", "...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/utils.py#L173-L203
[ "def", "snip_string", "(", "string", ",", "max_len", "=", "20", ",", "snip_string", "=", "'...'", ",", "snip_point", "=", "0.5", ")", ":", "if", "len", "(", "string", ")", "<=", "max_len", ":", "new_string", "=", "string", "else", ":", "visible_len", "...
a0bd64f822576feaa502939d6bafd1183b237d16
train
find_common_beginning
Given a list of strings, finds finds the longest string that is common to the *beginning* of all strings in the list. boundary_char defines a boundary that must be preserved, so that the common string removed must end with this char.
ocupy/utils.py
def find_common_beginning(string_list, boundary_char = None): """Given a list of strings, finds finds the longest string that is common to the *beginning* of all strings in the list. boundary_char defines a boundary that must be preserved, so that the common string removed must end with this char. ...
def find_common_beginning(string_list, boundary_char = None): """Given a list of strings, finds finds the longest string that is common to the *beginning* of all strings in the list. boundary_char defines a boundary that must be preserved, so that the common string removed must end with this char. ...
[ "Given", "a", "list", "of", "strings", "finds", "finds", "the", "longest", "string", "that", "is", "common", "to", "the", "*", "beginning", "*", "of", "all", "strings", "in", "the", "list", ".", "boundary_char", "defines", "a", "boundary", "that", "must", ...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/utils.py#L205-L233
[ "def", "find_common_beginning", "(", "string_list", ",", "boundary_char", "=", "None", ")", ":", "common", "=", "''", "# by definition there is nothing common to 1 item...", "if", "len", "(", "string_list", ")", ">", "1", ":", "shortestLen", "=", "min", "(", "[", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
factorise_strings
Given a list of strings, finds the longest string that is common to the *beginning* of all strings in the list and returns a new list whose elements lack this common beginning. boundary_char defines a boundary that must be preserved, so that the common string removed must end with this char. ...
ocupy/utils.py
def factorise_strings (string_list, boundary_char=None): """Given a list of strings, finds the longest string that is common to the *beginning* of all strings in the list and returns a new list whose elements lack this common beginning. boundary_char defines a boundary that must be preserved, so th...
def factorise_strings (string_list, boundary_char=None): """Given a list of strings, finds the longest string that is common to the *beginning* of all strings in the list and returns a new list whose elements lack this common beginning. boundary_char defines a boundary that must be preserved, so th...
[ "Given", "a", "list", "of", "strings", "finds", "the", "longest", "string", "that", "is", "common", "to", "the", "*", "beginning", "*", "of", "all", "strings", "in", "the", "list", "and", "returns", "a", "new", "list", "whose", "elements", "lack", "this"...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/utils.py#L235-L277
[ "def", "factorise_strings", "(", "string_list", ",", "boundary_char", "=", "None", ")", ":", "cmn", "=", "find_common_beginning", "(", "string_list", ",", "boundary_char", ")", "new_list", "=", "[", "el", "[", "len", "(", "cmn", ")", ":", "]", "for", "el",...
a0bd64f822576feaa502939d6bafd1183b237d16
train
load
Load datamat at path. Parameters: path : string Absolute path of the file to load from.
ocupy/datamat.py
def load(path, variable='Datamat'): """ Load datamat at path. Parameters: path : string Absolute path of the file to load from. """ f = h5py.File(path,'r') try: dm = fromhdf5(f[variable]) finally: f.close() return dm
def load(path, variable='Datamat'): """ Load datamat at path. Parameters: path : string Absolute path of the file to load from. """ f = h5py.File(path,'r') try: dm = fromhdf5(f[variable]) finally: f.close() return dm
[ "Load", "datamat", "at", "path", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L528-L541
[ "def", "load", "(", "path", ",", "variable", "=", "'Datamat'", ")", ":", "f", "=", "h5py", ".", "File", "(", "path", ",", "'r'", ")", "try", ":", "dm", "=", "fromhdf5", "(", "f", "[", "variable", "]", ")", "finally", ":", "f", ".", "close", "("...
a0bd64f822576feaa502939d6bafd1183b237d16
train
VectorFactory
Creates a datamat from a dictionary that contains lists/arrays as values. Input: fields: Dictionary The values will be used as fields of the datamat and the keys as field names. parameters: Dictionary A dictionary whose values are added as parameters. Keys are us...
ocupy/datamat.py
def VectorFactory(fields, parameters, categories = None): ''' Creates a datamat from a dictionary that contains lists/arrays as values. Input: fields: Dictionary The values will be used as fields of the datamat and the keys as field names. parameters: Dictionary ...
def VectorFactory(fields, parameters, categories = None): ''' Creates a datamat from a dictionary that contains lists/arrays as values. Input: fields: Dictionary The values will be used as fields of the datamat and the keys as field names. parameters: Dictionary ...
[ "Creates", "a", "datamat", "from", "a", "dictionary", "that", "contains", "lists", "/", "arrays", "as", "values", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L560-L584
[ "def", "VectorFactory", "(", "fields", ",", "parameters", ",", "categories", "=", "None", ")", ":", "fm", "=", "Datamat", "(", "categories", "=", "categories", ")", "fm", ".", "_fields", "=", "list", "(", "fields", ".", "keys", "(", ")", ")", "for", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.filter
Filters a datamat by different aspects. This function is a device to filter the datamat by certain logical conditions. It takes as input a logical array (contains only True or False for every datapoint) and kicks out all datapoints for which the array says False. The logical array can c...
ocupy/datamat.py
def filter(self, index): #@ReservedAssignment """ Filters a datamat by different aspects. This function is a device to filter the datamat by certain logical conditions. It takes as input a logical array (contains only True or False for every datapoint) and kicks out all datapoin...
def filter(self, index): #@ReservedAssignment """ Filters a datamat by different aspects. This function is a device to filter the datamat by certain logical conditions. It takes as input a logical array (contains only True or False for every datapoint) and kicks out all datapoin...
[ "Filters", "a", "datamat", "by", "different", "aspects", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L140-L163
[ "def", "filter", "(", "self", ",", "index", ")", ":", "#@ReservedAssignment", "return", "Datamat", "(", "categories", "=", "self", ".", "_categories", ",", "datamat", "=", "self", ",", "index", "=", "index", ")" ]
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.copy
Returns a copy of the datamat.
ocupy/datamat.py
def copy(self): """ Returns a copy of the datamat. """ return self.filter(np.ones(self._num_fix).astype(bool))
def copy(self): """ Returns a copy of the datamat. """ return self.filter(np.ones(self._num_fix).astype(bool))
[ "Returns", "a", "copy", "of", "the", "datamat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L165-L169
[ "def", "copy", "(", "self", ")", ":", "return", "self", ".", "filter", "(", "np", ".", "ones", "(", "self", ".", "_num_fix", ")", ".", "astype", "(", "bool", ")", ")" ]
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.save
Saves Datamat to path. Parameters: path : string Absolute path of the file to save to.
ocupy/datamat.py
def save(self, path): """ Saves Datamat to path. Parameters: path : string Absolute path of the file to save to. """ f = h5py.File(path, 'w') try: fm_group = f.create_group('Datamat') for field in self.fieldnames(): ...
def save(self, path): """ Saves Datamat to path. Parameters: path : string Absolute path of the file to save to. """ f = h5py.File(path, 'w') try: fm_group = f.create_group('Datamat') for field in self.fieldnames(): ...
[ "Saves", "Datamat", "to", "path", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L190-L217
[ "def", "save", "(", "self", ",", "path", ")", ":", "f", "=", "h5py", ".", "File", "(", "path", ",", "'w'", ")", "try", ":", "fm_group", "=", "f", ".", "create_group", "(", "'Datamat'", ")", "for", "field", "in", "self", ".", "fieldnames", "(", ")...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.set_param
Set the value of a parameter.
ocupy/datamat.py
def set_param(self, key, value): """ Set the value of a parameter. """ self.__dict__[key] = value self._parameters[key] = value
def set_param(self, key, value): """ Set the value of a parameter. """ self.__dict__[key] = value self._parameters[key] = value
[ "Set", "the", "value", "of", "a", "parameter", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L234-L239
[ "def", "set_param", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "__dict__", "[", "key", "]", "=", "value", "self", ".", "_parameters", "[", "key", "]", "=", "value" ]
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.by_field
Returns an iterator that iterates over unique values of field Parameters: field : string Filters the datamat for every unique value in field and yields the filtered datamat. Returns: datamat : Datamat that is filtered according to one of the uniqu...
ocupy/datamat.py
def by_field(self, field): """ Returns an iterator that iterates over unique values of field Parameters: field : string Filters the datamat for every unique value in field and yields the filtered datamat. Returns: datamat : Datamat...
def by_field(self, field): """ Returns an iterator that iterates over unique values of field Parameters: field : string Filters the datamat for every unique value in field and yields the filtered datamat. Returns: datamat : Datamat...
[ "Returns", "an", "iterator", "that", "iterates", "over", "unique", "values", "of", "field" ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L241-L254
[ "def", "by_field", "(", "self", ",", "field", ")", ":", "for", "value", "in", "np", ".", "unique", "(", "self", ".", "__dict__", "[", "field", "]", ")", ":", "yield", "self", ".", "filter", "(", "self", ".", "__dict__", "[", "field", "]", "==", "...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.by_cat
Iterates over categories and returns a filtered datamat. If a categories object is attached, the images object for the given category is returned as well (else None is returned). Returns: (datamat, categories) : A tuple that contains first the filtered datamat (has ...
ocupy/datamat.py
def by_cat(self): """ Iterates over categories and returns a filtered datamat. If a categories object is attached, the images object for the given category is returned as well (else None is returned). Returns: (datamat, categories) : A tuple that contains first the ...
def by_cat(self): """ Iterates over categories and returns a filtered datamat. If a categories object is attached, the images object for the given category is returned as well (else None is returned). Returns: (datamat, categories) : A tuple that contains first the ...
[ "Iterates", "over", "categories", "and", "returns", "a", "filtered", "datamat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L256-L273
[ "def", "by_cat", "(", "self", ")", ":", "for", "value", "in", "np", ".", "unique", "(", "self", ".", "category", ")", ":", "cat_fm", "=", "self", ".", "filter", "(", "self", ".", "category", "==", "value", ")", "if", "self", ".", "_categories", ":"...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.by_filenumber
Iterates over categories and returns a filtered datamat. If a categories object is attached, the images object for the given category is returned as well (else None is returned). Returns: (datamat, categories) : A tuple that contains first the filtered datamat (has ...
ocupy/datamat.py
def by_filenumber(self): """ Iterates over categories and returns a filtered datamat. If a categories object is attached, the images object for the given category is returned as well (else None is returned). Returns: (datamat, categories) : A tuple that contains fir...
def by_filenumber(self): """ Iterates over categories and returns a filtered datamat. If a categories object is attached, the images object for the given category is returned as well (else None is returned). Returns: (datamat, categories) : A tuple that contains fir...
[ "Iterates", "over", "categories", "and", "returns", "a", "filtered", "datamat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L275-L292
[ "def", "by_filenumber", "(", "self", ")", ":", "for", "value", "in", "np", ".", "unique", "(", "self", ".", "filenumber", ")", ":", "file_fm", "=", "self", ".", "filter", "(", "self", ".", "filenumber", "==", "value", ")", "if", "self", ".", "_catego...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.add_field
Add a new field to the datamat. Parameters: name : string Name of the new field data : list Data for the new field, must be same length as all other fields.
ocupy/datamat.py
def add_field(self, name, data): """ Add a new field to the datamat. Parameters: name : string Name of the new field data : list Data for the new field, must be same length as all other fields. """ if name in self._fields: ...
def add_field(self, name, data): """ Add a new field to the datamat. Parameters: name : string Name of the new field data : list Data for the new field, must be same length as all other fields. """ if name in self._fields: ...
[ "Add", "a", "new", "field", "to", "the", "datamat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L294-L309
[ "def", "add_field", "(", "self", ",", "name", ",", "data", ")", ":", "if", "name", "in", "self", ".", "_fields", ":", "raise", "ValueError", "if", "not", "len", "(", "data", ")", "==", "self", ".", "_num_fix", ":", "raise", "ValueError", "self", ".",...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.add_field_like
Add a new field to the Datamat with the dtype of the like_array and the shape of the like_array except for the first dimension which will be instead the field-length of this Datamat.
ocupy/datamat.py
def add_field_like(self, name, like_array): """ Add a new field to the Datamat with the dtype of the like_array and the shape of the like_array except for the first dimension which will be instead the field-length of this Datamat. """ new_shape = list(like_array.shape) ...
def add_field_like(self, name, like_array): """ Add a new field to the Datamat with the dtype of the like_array and the shape of the like_array except for the first dimension which will be instead the field-length of this Datamat. """ new_shape = list(like_array.shape) ...
[ "Add", "a", "new", "field", "to", "the", "Datamat", "with", "the", "dtype", "of", "the", "like_array", "and", "the", "shape", "of", "the", "like_array", "except", "for", "the", "first", "dimension", "which", "will", "be", "instead", "the", "field", "-", ...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L311-L321
[ "def", "add_field_like", "(", "self", ",", "name", ",", "like_array", ")", ":", "new_shape", "=", "list", "(", "like_array", ".", "shape", ")", "new_shape", "[", "0", "]", "=", "len", "(", "self", ")", "new_data", "=", "ma", ".", "empty", "(", "new_s...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.annotate
Adds a new field (data_field) to the Datamat with data from the corresponding field of another Datamat (src_dm). This is accomplished through the use of a key_field, which is used to determine how the data is copied. This operation corresponds loosely to an SQL join operation. The two...
ocupy/datamat.py
def annotate (self, src_dm, data_field, key_field, take_first=True): """ Adds a new field (data_field) to the Datamat with data from the corresponding field of another Datamat (src_dm). This is accomplished through the use of a key_field, which is used to determine how the data is c...
def annotate (self, src_dm, data_field, key_field, take_first=True): """ Adds a new field (data_field) to the Datamat with data from the corresponding field of another Datamat (src_dm). This is accomplished through the use of a key_field, which is used to determine how the data is c...
[ "Adds", "a", "new", "field", "(", "data_field", ")", "to", "the", "Datamat", "with", "data", "from", "the", "corresponding", "field", "of", "another", "Datamat", "(", "src_dm", ")", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L323-L408
[ "def", "annotate", "(", "self", ",", "src_dm", ",", "data_field", ",", "key_field", ",", "take_first", "=", "True", ")", ":", "if", "key_field", "not", "in", "self", ".", "_fields", "or", "key_field", "not", "in", "src_dm", ".", "_fields", ":", "raise", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.rm_field
Remove a field from the datamat. Parameters: name : string Name of the field to be removed
ocupy/datamat.py
def rm_field(self, name): """ Remove a field from the datamat. Parameters: name : string Name of the field to be removed """ if not name in self._fields: raise ValueError self._fields.remove(name) del self.__dict__[name]
def rm_field(self, name): """ Remove a field from the datamat. Parameters: name : string Name of the field to be removed """ if not name in self._fields: raise ValueError self._fields.remove(name) del self.__dict__[name]
[ "Remove", "a", "field", "from", "the", "datamat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L410-L421
[ "def", "rm_field", "(", "self", ",", "name", ")", ":", "if", "not", "name", "in", "self", ".", "_fields", ":", "raise", "ValueError", "self", ".", "_fields", ".", "remove", "(", "name", ")", "del", "self", ".", "__dict__", "[", "name", "]" ]
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.add_parameter
Adds a parameter to the existing Datamat. Fails if parameter with same name already exists or if name is otherwise in this objects ___dict__ dictionary.
ocupy/datamat.py
def add_parameter(self, name, value): """ Adds a parameter to the existing Datamat. Fails if parameter with same name already exists or if name is otherwise in this objects ___dict__ dictionary. """ if name in self._parameters: raise ValueError("'%s' is alrea...
def add_parameter(self, name, value): """ Adds a parameter to the existing Datamat. Fails if parameter with same name already exists or if name is otherwise in this objects ___dict__ dictionary. """ if name in self._parameters: raise ValueError("'%s' is alrea...
[ "Adds", "a", "parameter", "to", "the", "existing", "Datamat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L423-L436
[ "def", "add_parameter", "(", "self", ",", "name", ",", "value", ")", ":", "if", "name", "in", "self", ".", "_parameters", ":", "raise", "ValueError", "(", "\"'%s' is already a parameter\"", "%", "(", "name", ")", ")", "elif", "name", "in", "self", ".", "...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.rm_parameter
Removes a parameter to the existing Datamat. Fails if parameter doesn't exist.
ocupy/datamat.py
def rm_parameter(self, name): """ Removes a parameter to the existing Datamat. Fails if parameter doesn't exist. """ if name not in self._parameters: raise ValueError("no '%s' parameter found" % (name)) del self._parameters[name] del self.__dict__[na...
def rm_parameter(self, name): """ Removes a parameter to the existing Datamat. Fails if parameter doesn't exist. """ if name not in self._parameters: raise ValueError("no '%s' parameter found" % (name)) del self._parameters[name] del self.__dict__[na...
[ "Removes", "a", "parameter", "to", "the", "existing", "Datamat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L438-L448
[ "def", "rm_parameter", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "_parameters", ":", "raise", "ValueError", "(", "\"no '%s' parameter found\"", "%", "(", "name", ")", ")", "del", "self", ".", "_parameters", "[", "name", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.parameter_to_field
Promotes a parameter to a field by creating a new array of same size as the other existing fields, filling it with the current value of the parameter, and then removing that parameter.
ocupy/datamat.py
def parameter_to_field(self, name): """ Promotes a parameter to a field by creating a new array of same size as the other existing fields, filling it with the current value of the parameter, and then removing that parameter. """ if name not in self._parameters: ...
def parameter_to_field(self, name): """ Promotes a parameter to a field by creating a new array of same size as the other existing fields, filling it with the current value of the parameter, and then removing that parameter. """ if name not in self._parameters: ...
[ "Promotes", "a", "parameter", "to", "a", "field", "by", "creating", "a", "new", "array", "of", "same", "size", "as", "the", "other", "existing", "fields", "filling", "it", "with", "the", "current", "value", "of", "the", "parameter", "and", "then", "removin...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L450-L464
[ "def", "parameter_to_field", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "_parameters", ":", "raise", "ValueError", "(", "\"no '%s' parameter found\"", "%", "(", "name", ")", ")", "if", "self", ".", "_fields", ".", "count", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Datamat.join
Adds content of a new Datamat to this Datamat. If a parameter of the Datamats is not equal or does not exist in one, it is promoted to a field. If the two Datamats have different fields then the elements for the Datamats that did not have the field will be NaN, unless 'minimal_...
ocupy/datamat.py
def join(self, fm_new, minimal_subset=True): """ Adds content of a new Datamat to this Datamat. If a parameter of the Datamats is not equal or does not exist in one, it is promoted to a field. If the two Datamats have different fields then the elements for the Datamats ...
def join(self, fm_new, minimal_subset=True): """ Adds content of a new Datamat to this Datamat. If a parameter of the Datamats is not equal or does not exist in one, it is promoted to a field. If the two Datamats have different fields then the elements for the Datamats ...
[ "Adds", "content", "of", "a", "new", "Datamat", "to", "this", "Datamat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/datamat.py#L466-L526
[ "def", "join", "(", "self", ",", "fm_new", ",", "minimal_subset", "=", "True", ")", ":", "# Check if parameters are equal. If not, promote them to fields.", "'''\n for (nm, val) in fm_new._parameters.items():\n if self._parameters.has_key(nm):\n if (val != ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
makeAngLenHist
Histograms and performs a spline fit on the given data, usually angle and length differences. Parameters: ad : array The data to be histogrammed along the x-axis. May range from -180 to 180. ld : array The data to be histogrammed along the y-axis. ...
ocupy/simulator.py
def makeAngLenHist(ad, ld, fm = None, collapse=True, fit=spline_base.fit2d): """ Histograms and performs a spline fit on the given data, usually angle and length differences. Parameters: ad : array The data to be histogrammed along the x-axis. May range from -180 t...
def makeAngLenHist(ad, ld, fm = None, collapse=True, fit=spline_base.fit2d): """ Histograms and performs a spline fit on the given data, usually angle and length differences. Parameters: ad : array The data to be histogrammed along the x-axis. May range from -180 t...
[ "Histograms", "and", "performs", "a", "spline", "fit", "on", "the", "given", "data", "usually", "angle", "and", "length", "differences", ".", "Parameters", ":", "ad", ":", "array", "The", "data", "to", "be", "histogrammed", "along", "the", "x", "-", "axis"...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L329-L372
[ "def", "makeAngLenHist", "(", "ad", ",", "ld", ",", "fm", "=", "None", ",", "collapse", "=", "True", ",", "fit", "=", "spline_base", ".", "fit2d", ")", ":", "if", "fm", ":", "ad", ",", "ld", "=", "anglendiff", "(", "fm", ",", "roll", "=", "2", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
makeHist
Constructs a (fitted) histogram of the given data. Parameters: x_val : array The data to be histogrammed along the x-axis. y_val : array The data to be histogrammed along the y-axis. fit : function or None, optional The function to use in order to fi...
ocupy/simulator.py
def makeHist(x_val, y_val, fit=spline_base.fit2d, bins=[np.linspace(-36.5,36.5,74),np.linspace(-180,180,361)]): """ Constructs a (fitted) histogram of the given data. Parameters: x_val : array The data to be histogrammed along the x-axis. y_val : array ...
def makeHist(x_val, y_val, fit=spline_base.fit2d, bins=[np.linspace(-36.5,36.5,74),np.linspace(-180,180,361)]): """ Constructs a (fitted) histogram of the given data. Parameters: x_val : array The data to be histogrammed along the x-axis. y_val : array ...
[ "Constructs", "a", "(", "fitted", ")", "histogram", "of", "the", "given", "data", ".", "Parameters", ":", "x_val", ":", "array", "The", "data", "to", "be", "histogrammed", "along", "the", "x", "-", "axis", ".", "y_val", ":", "array", "The", "data", "to...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L374-L405
[ "def", "makeHist", "(", "x_val", ",", "y_val", ",", "fit", "=", "spline_base", ".", "fit2d", ",", "bins", "=", "[", "np", ".", "linspace", "(", "-", "36.5", ",", "36.5", ",", "74", ")", ",", "np", ".", "linspace", "(", "-", "180", ",", "180", "...
a0bd64f822576feaa502939d6bafd1183b237d16
train
firstSacDist
Computes the distribution of angle and length combinations that were made as first saccades Parameters: fm : ocupy.fixmat The fixation data to be analysed
ocupy/simulator.py
def firstSacDist(fm): """ Computes the distribution of angle and length combinations that were made as first saccades Parameters: fm : ocupy.fixmat The fixation data to be analysed """ ang, leng, ad, ld = anglendiff(fm, return_abs=True) ...
def firstSacDist(fm): """ Computes the distribution of angle and length combinations that were made as first saccades Parameters: fm : ocupy.fixmat The fixation data to be analysed """ ang, leng, ad, ld = anglendiff(fm, return_abs=True) ...
[ "Computes", "the", "distribution", "of", "angle", "and", "length", "combinations", "that", "were", "made", "as", "first", "saccades", "Parameters", ":", "fm", ":", "ocupy", ".", "fixmat", "The", "fixation", "data", "to", "be", "analysed" ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L509-L523
[ "def", "firstSacDist", "(", "fm", ")", ":", "ang", ",", "leng", ",", "ad", ",", "ld", "=", "anglendiff", "(", "fm", ",", "return_abs", "=", "True", ")", "y_arg", "=", "leng", "[", "0", "]", "[", "np", ".", "roll", "(", "fm", ".", "fix", "==", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
trajLenDist
Computes the distribution of trajectory lengths, i.e. the number of saccades that were made as a part of one trajectory Parameters: fm : ocupy.fixmat The fixation data to be analysed
ocupy/simulator.py
def trajLenDist(fm): """ Computes the distribution of trajectory lengths, i.e. the number of saccades that were made as a part of one trajectory Parameters: fm : ocupy.fixmat The fixation data to be analysed """ trajLen = np.roll(fm.fix, 1...
def trajLenDist(fm): """ Computes the distribution of trajectory lengths, i.e. the number of saccades that were made as a part of one trajectory Parameters: fm : ocupy.fixmat The fixation data to be analysed """ trajLen = np.roll(fm.fix, 1...
[ "Computes", "the", "distribution", "of", "trajectory", "lengths", "i", ".", "e", ".", "the", "number", "of", "saccades", "that", "were", "made", "as", "a", "part", "of", "one", "trajectory", "Parameters", ":", "fm", ":", "ocupy", ".", "fixmat", "The", "f...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L525-L539
[ "def", "trajLenDist", "(", "fm", ")", ":", "trajLen", "=", "np", ".", "roll", "(", "fm", ".", "fix", ",", "1", ")", "[", "fm", ".", "fix", "==", "min", "(", "fm", ".", "fix", ")", "]", "val", ",", "borders", "=", "np", ".", "histogram", "(", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
reshift
Transforms the given number element into a range of [-180, 180], which covers all possible angle differences. This method reshifts larger or smaller numbers that might be the output of other angular calculations into that range by adding or subtracting 360, respectively. To make sure that angular data...
ocupy/simulator.py
def reshift(I): """ Transforms the given number element into a range of [-180, 180], which covers all possible angle differences. This method reshifts larger or smaller numbers that might be the output of other angular calculations into that range by adding or subtracting 360, respectively. To...
def reshift(I): """ Transforms the given number element into a range of [-180, 180], which covers all possible angle differences. This method reshifts larger or smaller numbers that might be the output of other angular calculations into that range by adding or subtracting 360, respectively. To...
[ "Transforms", "the", "given", "number", "element", "into", "a", "range", "of", "[", "-", "180", "180", "]", "which", "covers", "all", "possible", "angle", "differences", ".", "This", "method", "reshifts", "larger", "or", "smaller", "numbers", "that", "might"...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L541-L562
[ "def", "reshift", "(", "I", ")", ":", "# Output -180 to +180", "if", "type", "(", "I", ")", "==", "list", ":", "I", "=", "np", ".", "array", "(", "I", ")", "return", "(", "(", "I", "-", "180", ")", "%", "360", ")", "-", "180" ]
a0bd64f822576feaa502939d6bafd1183b237d16
train
FixGen.initializeData
Prepares the data to be replicated. Calculates the second-order length and angle dependencies between saccades and stores them in a fitted histogram. Parameters: fit : function, optional The method to use for fitting the histogram full_H1 : twod...
ocupy/simulator.py
def initializeData(self, fit = None, full_H1=None, max_length = 40, in_deg = True): """ Prepares the data to be replicated. Calculates the second-order length and angle dependencies between saccades and stores them in a fitted histogram. Parameters: ...
def initializeData(self, fit = None, full_H1=None, max_length = 40, in_deg = True): """ Prepares the data to be replicated. Calculates the second-order length and angle dependencies between saccades and stores them in a fitted histogram. Parameters: ...
[ "Prepares", "the", "data", "to", "be", "replicated", ".", "Calculates", "the", "second", "-", "order", "length", "and", "angle", "dependencies", "between", "saccades", "and", "stores", "them", "in", "a", "fitted", "histogram", ".", "Parameters", ":", "fit", ...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L90-L157
[ "def", "initializeData", "(", "self", ",", "fit", "=", "None", ",", "full_H1", "=", "None", ",", "max_length", "=", "40", ",", "in_deg", "=", "True", ")", ":", "a", ",", "l", ",", "ad", ",", "ld", "=", "anglendiff", "(", "self", ".", "fm", ",", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
FixGen._calc_xy
Calculates the coordinates after a specific saccade was made. Parameters: (x,y) : tuple of floats or ints The coordinates before the saccade was made angle : float or int The angle that the next saccade encloses with the horizonta...
ocupy/simulator.py
def _calc_xy(self, xxx_todo_changeme, angle, length): """ Calculates the coordinates after a specific saccade was made. Parameters: (x,y) : tuple of floats or ints The coordinates before the saccade was made angle : float or int Th...
def _calc_xy(self, xxx_todo_changeme, angle, length): """ Calculates the coordinates after a specific saccade was made. Parameters: (x,y) : tuple of floats or ints The coordinates before the saccade was made angle : float or int Th...
[ "Calculates", "the", "coordinates", "after", "a", "specific", "saccade", "was", "made", ".", "Parameters", ":", "(", "x", "y", ")", ":", "tuple", "of", "floats", "or", "ints", "The", "coordinates", "before", "the", "saccade", "was", "made", "angle", ":", ...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L159-L174
[ "def", "_calc_xy", "(", "self", ",", "xxx_todo_changeme", ",", "angle", ",", "length", ")", ":", "(", "x", ",", "y", ")", "=", "xxx_todo_changeme", "return", "(", "x", "+", "(", "cos", "(", "radians", "(", "angle", ")", ")", "*", "length", ")", ","...
a0bd64f822576feaa502939d6bafd1183b237d16
train
FixGen._draw
Draws a new length- and angle-difference pair and calculates length and angle absolutes matching the last saccade drawn. Parameters: prev_angle : float, optional The last angle that was drawn in the current trajectory prev_length : float, optional ...
ocupy/simulator.py
def _draw(self, prev_angle = None, prev_length = None): """ Draws a new length- and angle-difference pair and calculates length and angle absolutes matching the last saccade drawn. Parameters: prev_angle : float, optional The last angle that was drawn in the ...
def _draw(self, prev_angle = None, prev_length = None): """ Draws a new length- and angle-difference pair and calculates length and angle absolutes matching the last saccade drawn. Parameters: prev_angle : float, optional The last angle that was drawn in the ...
[ "Draws", "a", "new", "length", "-", "and", "angle", "-", "difference", "pair", "and", "calculates", "length", "and", "angle", "absolutes", "matching", "the", "last", "saccade", "drawn", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L176-L212
[ "def", "_draw", "(", "self", ",", "prev_angle", "=", "None", ",", "prev_length", "=", "None", ")", ":", "if", "(", "prev_angle", "is", "None", ")", "or", "(", "prev_length", "is", "None", ")", ":", "(", "length", ",", "angle", ")", "=", "np", ".", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
FixGen.sample_many
Generates a given number of trajectories, using the method sample(). Returns a fixmat with the generated data. Parameters: num_samples : int, optional The number of trajectories that shall be generated.
ocupy/simulator.py
def sample_many(self, num_samples = 2000): """ Generates a given number of trajectories, using the method sample(). Returns a fixmat with the generated data. Parameters: num_samples : int, optional The number of trajectories that shall be generated. ...
def sample_many(self, num_samples = 2000): """ Generates a given number of trajectories, using the method sample(). Returns a fixmat with the generated data. Parameters: num_samples : int, optional The number of trajectories that shall be generated. ...
[ "Generates", "a", "given", "number", "of", "trajectories", "using", "the", "method", "sample", "()", ".", "Returns", "a", "fixmat", "with", "the", "generated", "data", ".", "Parameters", ":", "num_samples", ":", "int", "optional", "The", "number", "of", "tra...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L241-L269
[ "def", "sample_many", "(", "self", ",", "num_samples", "=", "2000", ")", ":", "x", "=", "[", "]", "y", "=", "[", "]", "fix", "=", "[", "]", "sample", "=", "[", "]", "# XXX: Delete ProgressBar", "pbar", "=", "ProgressBar", "(", "widgets", "=", "[", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
FixGen.sample
Draws a trajectory length, first coordinates, lengths, angles and length-angle-difference pairs according to the empirical distribution. Each call creates one complete trajectory.
ocupy/simulator.py
def sample(self): """ Draws a trajectory length, first coordinates, lengths, angles and length-angle-difference pairs according to the empirical distribution. Each call creates one complete trajectory. """ lenghts = [] angles = [] coordinates = [] ...
def sample(self): """ Draws a trajectory length, first coordinates, lengths, angles and length-angle-difference pairs according to the empirical distribution. Each call creates one complete trajectory. """ lenghts = [] angles = [] coordinates = [] ...
[ "Draws", "a", "trajectory", "length", "first", "coordinates", "lengths", "angles", "and", "length", "-", "angle", "-", "difference", "pairs", "according", "to", "the", "empirical", "distribution", ".", "Each", "call", "creates", "one", "complete", "trajectory", ...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L271-L299
[ "def", "sample", "(", "self", ")", ":", "lenghts", "=", "[", "]", "angles", "=", "[", "]", "coordinates", "=", "[", "]", "fix", "=", "[", "]", "sample_size", "=", "int", "(", "round", "(", "self", ".", "trajLen_borders", "[", "self", ".", "drawFrom...
a0bd64f822576feaa502939d6bafd1183b237d16
train
FixGen.drawFrom
Draws a value from a cumulative sum. Parameters: cumsum : array Cumulative sum from which shall be drawn. Returns: int : Index of the cumulative sum element drawn.
ocupy/simulator.py
def drawFrom(self, cumsum, r): """ Draws a value from a cumulative sum. Parameters: cumsum : array Cumulative sum from which shall be drawn. Returns: int : Index of the cumulative sum element drawn. """ a = cumsum.rsplit(...
def drawFrom(self, cumsum, r): """ Draws a value from a cumulative sum. Parameters: cumsum : array Cumulative sum from which shall be drawn. Returns: int : Index of the cumulative sum element drawn. """ a = cumsum.rsplit(...
[ "Draws", "a", "value", "from", "a", "cumulative", "sum", ".", "Parameters", ":", "cumsum", ":", "array", "Cumulative", "sum", "from", "which", "shall", "be", "drawn", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/simulator.py#L305-L322
[ "def", "drawFrom", "(", "self", ",", "cumsum", ",", "r", ")", ":", "a", "=", "cumsum", ".", "rsplit", "(", ")", "if", "len", "(", "a", ")", ">", "1", ":", "b", "=", "eval", "(", "a", "[", "0", "]", ")", "[", "int", "(", "a", "[", "1", "...
a0bd64f822576feaa502939d6bafd1183b237d16
train
load
Load fixmat at path. Parameters: path : string Absolute path of the file to load from.
ocupy/fixmat.py
def load(path): """ Load fixmat at path. Parameters: path : string Absolute path of the file to load from. """ f = h5py.File(path,'r') if 'Fixmat' in f: fm_group = f['Fixmat'] else: fm_group = f['Datamat'] fields = {} params = {} for field, va...
def load(path): """ Load fixmat at path. Parameters: path : string Absolute path of the file to load from. """ f = h5py.File(path,'r') if 'Fixmat' in f: fm_group = f['Fixmat'] else: fm_group = f['Datamat'] fields = {} params = {} for field, va...
[ "Load", "fixmat", "at", "path", ".", "Parameters", ":", "path", ":", "string", "Absolute", "path", "of", "the", "file", "to", "load", "from", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/fixmat.py#L140-L160
[ "def", "load", "(", "path", ")", ":", "f", "=", "h5py", ".", "File", "(", "path", ",", "'r'", ")", "if", "'Fixmat'", "in", "f", ":", "fm_group", "=", "f", "[", "'Fixmat'", "]", "else", ":", "fm_group", "=", "f", "[", "'Datamat'", "]", "fields", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
compute_fdm
Computes a fixation density map for the calling fixmat. Creates a map the size of the image fixations were recorded on. Every pixel contains the frequency of fixations for this image. The fixation map is smoothed by convolution with a Gaussian kernel to approximate the area with highest processi...
ocupy/fixmat.py
def compute_fdm(fixmat, fwhm=2, scale_factor=1): """ Computes a fixation density map for the calling fixmat. Creates a map the size of the image fixations were recorded on. Every pixel contains the frequency of fixations for this image. The fixation map is smoothed by convolution with a ...
def compute_fdm(fixmat, fwhm=2, scale_factor=1): """ Computes a fixation density map for the calling fixmat. Creates a map the size of the image fixations were recorded on. Every pixel contains the frequency of fixations for this image. The fixation map is smoothed by convolution with a ...
[ "Computes", "a", "fixation", "density", "map", "for", "the", "calling", "fixmat", ".", "Creates", "a", "map", "the", "size", "of", "the", "image", "fixations", "were", "recorded", "on", ".", "Every", "pixel", "contains", "the", "frequency", "of", "fixations"...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/fixmat.py#L163-L207
[ "def", "compute_fdm", "(", "fixmat", ",", "fwhm", "=", "2", ",", "scale_factor", "=", "1", ")", ":", "# image category must exist (>-1) and image_size must be non-empty", "assert", "(", "len", "(", "fixmat", ".", "image_size", ")", "==", "2", "and", "(", "fixmat...
a0bd64f822576feaa502939d6bafd1183b237d16
train
relative_bias
Computes the relative bias, i.e. the distribution of saccade angles and amplitudes. Parameters: fm : DataMat The fixation data to use scale_factor : double Returns: 2D probability distribution of saccade angles and amplitudes.
ocupy/fixmat.py
def relative_bias(fm, scale_factor = 1, estimator = None): """ Computes the relative bias, i.e. the distribution of saccade angles and amplitudes. Parameters: fm : DataMat The fixation data to use scale_factor : double Returns: 2D probability distribution of s...
def relative_bias(fm, scale_factor = 1, estimator = None): """ Computes the relative bias, i.e. the distribution of saccade angles and amplitudes. Parameters: fm : DataMat The fixation data to use scale_factor : double Returns: 2D probability distribution of s...
[ "Computes", "the", "relative", "bias", "i", ".", "e", ".", "the", "distribution", "of", "saccade", "angles", "and", "amplitudes", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/fixmat.py#L209-L249
[ "def", "relative_bias", "(", "fm", ",", "scale_factor", "=", "1", ",", "estimator", "=", "None", ")", ":", "assert", "'fix'", "in", "fm", ".", "fieldnames", "(", ")", ",", "\"Can not work without fixation numbers\"", "excl", "=", "fm", ".", "fix", "-", "n...
a0bd64f822576feaa502939d6bafd1183b237d16
train
DirectoryFixmatFactory
Concatenates all fixmats in dir and returns the resulting single fixmat. Parameters: directory : string Path from which the fixmats should be loaded categories : instance of stimuli.Categories, optional If given, the resulting fixmat provides direct access ...
ocupy/fixmat.py
def DirectoryFixmatFactory(directory, categories = None, glob_str = '*.mat', var_name = 'fixmat'): """ Concatenates all fixmats in dir and returns the resulting single fixmat. Parameters: directory : string Path from which the fixmats should be loaded categories : instan...
def DirectoryFixmatFactory(directory, categories = None, glob_str = '*.mat', var_name = 'fixmat'): """ Concatenates all fixmats in dir and returns the resulting single fixmat. Parameters: directory : string Path from which the fixmats should be loaded categories : instan...
[ "Concatenates", "all", "fixmats", "in", "dir", "and", "returns", "the", "resulting", "single", "fixmat", ".", "Parameters", ":", "directory", ":", "string", "Path", "from", "which", "the", "fixmats", "should", "be", "loaded", "categories", ":", "instance", "of...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/fixmat.py#L252-L280
[ "def", "DirectoryFixmatFactory", "(", "directory", ",", "categories", "=", "None", ",", "glob_str", "=", "'*.mat'", ",", "var_name", "=", "'fixmat'", ")", ":", "files", "=", "glob", "(", "join", "(", "directory", ",", "glob_str", ")", ")", "if", "len", "...
a0bd64f822576feaa502939d6bafd1183b237d16
train
FixmatFactory
Loads a single fixmat (fixmatfile). Parameters: fixmatfile : string The matlab fixmat that should be loaded. categories : instance of stimuli.Categories, optional Links data in categories to data in fixmat.
ocupy/fixmat.py
def FixmatFactory(fixmatfile, categories = None, var_name = 'fixmat', field_name='x'): """ Loads a single fixmat (fixmatfile). Parameters: fixmatfile : string The matlab fixmat that should be loaded. categories : instance of stimuli.Categories, optional Links dat...
def FixmatFactory(fixmatfile, categories = None, var_name = 'fixmat', field_name='x'): """ Loads a single fixmat (fixmatfile). Parameters: fixmatfile : string The matlab fixmat that should be loaded. categories : instance of stimuli.Categories, optional Links dat...
[ "Loads", "a", "single", "fixmat", "(", "fixmatfile", ")", ".", "Parameters", ":", "fixmatfile", ":", "string", "The", "matlab", "fixmat", "that", "should", "be", "loaded", ".", "categories", ":", "instance", "of", "stimuli", ".", "Categories", "optional", "L...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/fixmat.py#L283-L325
[ "def", "FixmatFactory", "(", "fixmatfile", ",", "categories", "=", "None", ",", "var_name", "=", "'fixmat'", ",", "field_name", "=", "'x'", ")", ":", "try", ":", "data", "=", "loadmat", "(", "fixmatfile", ",", "struct_as_record", "=", "False", ")", "keys",...
a0bd64f822576feaa502939d6bafd1183b237d16
train
FixMat.add_feature_values
Adds feature values of feature 'feature' to all fixations in the calling fixmat. For fixations out of the image boundaries, NaNs are returned. The function generates a new attribute field named with the string in features that contains an np.array listing feature values...
ocupy/fixmat.py
def add_feature_values(self, features): """ Adds feature values of feature 'feature' to all fixations in the calling fixmat. For fixations out of the image boundaries, NaNs are returned. The function generates a new attribute field named with the string in featu...
def add_feature_values(self, features): """ Adds feature values of feature 'feature' to all fixations in the calling fixmat. For fixations out of the image boundaries, NaNs are returned. The function generates a new attribute field named with the string in featu...
[ "Adds", "feature", "values", "of", "feature", "feature", "to", "all", "fixations", "in", "the", "calling", "fixmat", ".", "For", "fixations", "out", "of", "the", "image", "boundaries", "NaNs", "are", "returned", ".", "The", "function", "generates", "a", "new...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/fixmat.py#L19-L60
[ "def", "add_feature_values", "(", "self", ",", "features", ")", ":", "if", "not", "'x'", "in", "self", ".", "fieldnames", "(", ")", ":", "raise", "RuntimeError", "(", "\"\"\"add_feature_values expects to find\n (x,y) locations in self.x and self.y. But self.x does no...
a0bd64f822576feaa502939d6bafd1183b237d16
train
FixMat.make_reg_data
Generates two M x N matrices with M feature values at fixations for N features. Controls are a random sample out of all non-fixated regions of an image or fixations of the same subject group on a randomly chosen image. Fixations are pooled over all subjects in the calling fixmat. ...
ocupy/fixmat.py
def make_reg_data(self, feature_list=None, all_controls=False): """ Generates two M x N matrices with M feature values at fixations for N features. Controls are a random sample out of all non-fixated regions of an image or fixations of the same subject group on a randomly chosen ...
def make_reg_data(self, feature_list=None, all_controls=False): """ Generates two M x N matrices with M feature values at fixations for N features. Controls are a random sample out of all non-fixated regions of an image or fixations of the same subject group on a randomly chosen ...
[ "Generates", "two", "M", "x", "N", "matrices", "with", "M", "feature", "values", "at", "fixations", "for", "N", "features", ".", "Controls", "are", "a", "random", "sample", "out", "of", "all", "non", "-", "fixated", "regions", "of", "an", "image", "or", ...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/fixmat.py#L62-L138
[ "def", "make_reg_data", "(", "self", ",", "feature_list", "=", "None", ",", "all_controls", "=", "False", ")", ":", "if", "not", "'x'", "in", "self", ".", "fieldnames", "(", ")", ":", "raise", "RuntimeError", "(", "\"\"\"make_reg_data expects to find\n (x...
a0bd64f822576feaa502939d6bafd1183b237d16
train
get_velocity
Compute velocity of eye-movements. Samplemat must contain fields 'x' and 'y', specifying the x,y coordinates of gaze location. The function assumes that the values in x,y are sampled continously at a rate specified by 'Hz'.
ocupy/samples2fix.py
def get_velocity(samplemat, Hz, blinks=None): ''' Compute velocity of eye-movements. Samplemat must contain fields 'x' and 'y', specifying the x,y coordinates of gaze location. The function assumes that the values in x,y are sampled continously at a rate specified by 'Hz'. ''' Hz = float(Hz...
def get_velocity(samplemat, Hz, blinks=None): ''' Compute velocity of eye-movements. Samplemat must contain fields 'x' and 'y', specifying the x,y coordinates of gaze location. The function assumes that the values in x,y are sampled continously at a rate specified by 'Hz'. ''' Hz = float(Hz...
[ "Compute", "velocity", "of", "eye", "-", "movements", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/samples2fix.py#L11-L30
[ "def", "get_velocity", "(", "samplemat", ",", "Hz", ",", "blinks", "=", "None", ")", ":", "Hz", "=", "float", "(", "Hz", ")", "distance", "=", "(", "(", "np", ".", "diff", "(", "samplemat", ".", "x", ")", "**", "2", ")", "+", "(", "np", ".", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
saccade_detection
Detect saccades in a stream of gaze location samples. Coordinates in samplemat are assumed to be in degrees. Saccades are detect by a velocity/acceleration threshold approach. A saccade starts when a) the velocity is above threshold, b) the acceleration is above acc_thresh at least once during the int...
ocupy/samples2fix.py
def saccade_detection(samplemat, Hz=200, threshold=30, acc_thresh=2000, min_duration=21, min_movement=.35, ignore_blinks=False): ''' Detect saccades in a stream of gaze location samples. Coordinates in samplemat are assumed to be in degrees. Saccades are det...
def saccade_detection(samplemat, Hz=200, threshold=30, acc_thresh=2000, min_duration=21, min_movement=.35, ignore_blinks=False): ''' Detect saccades in a stream of gaze location samples. Coordinates in samplemat are assumed to be in degrees. Saccades are det...
[ "Detect", "saccades", "in", "a", "stream", "of", "gaze", "location", "samples", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/samples2fix.py#L33-L98
[ "def", "saccade_detection", "(", "samplemat", ",", "Hz", "=", "200", ",", "threshold", "=", "30", ",", "acc_thresh", "=", "2000", ",", "min_duration", "=", "21", ",", "min_movement", "=", ".35", ",", "ignore_blinks", "=", "False", ")", ":", "if", "ignore...
a0bd64f822576feaa502939d6bafd1183b237d16
train
fixation_detection
Detect Fixation from saccades. Fixations are defined as intervals between saccades. This function also calcuates start and end times (in ms) for each fixation. Input: samplemat: datamat Contains the recorded samples and associated metadata. saccades: ndarray Logical ...
ocupy/samples2fix.py
def fixation_detection(samplemat, saccades, Hz=200, samples2fix=None, respect_trial_borders=False, sample_times=None): ''' Detect Fixation from saccades. Fixations are defined as intervals between saccades. This function also calcuates start and end times (in ms) for each fixatio...
def fixation_detection(samplemat, saccades, Hz=200, samples2fix=None, respect_trial_borders=False, sample_times=None): ''' Detect Fixation from saccades. Fixations are defined as intervals between saccades. This function also calcuates start and end times (in ms) for each fixatio...
[ "Detect", "Fixation", "from", "saccades", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/samples2fix.py#L101-L161
[ "def", "fixation_detection", "(", "samplemat", ",", "saccades", ",", "Hz", "=", "200", ",", "samples2fix", "=", "None", ",", "respect_trial_borders", "=", "False", ",", "sample_times", "=", "None", ")", ":", "if", "samples2fix", "is", "None", ":", "samples2f...
a0bd64f822576feaa502939d6bafd1183b237d16
train
parse
Parse a subscription list and return a dict containing the results. :param parse_obj: A file-like object or a string containing a URL, an absolute or relative filename, or an XML document. :type parse_obj: str or file :param agent: User-Agent header to be sent when requesting a URL :type agent:...
listparser/__init__.py
def parse(parse_obj, agent=None, etag=None, modified=None, inject=False): """Parse a subscription list and return a dict containing the results. :param parse_obj: A file-like object or a string containing a URL, an absolute or relative filename, or an XML document. :type parse_obj: str or file ...
def parse(parse_obj, agent=None, etag=None, modified=None, inject=False): """Parse a subscription list and return a dict containing the results. :param parse_obj: A file-like object or a string containing a URL, an absolute or relative filename, or an XML document. :type parse_obj: str or file ...
[ "Parse", "a", "subscription", "list", "and", "return", "a", "dict", "containing", "the", "results", "." ]
kurtmckee/listparser
python
https://github.com/kurtmckee/listparser/blob/f9bc310a0ce567cd0611fea68be99974021f53c7/listparser/__init__.py#L71-L144
[ "def", "parse", "(", "parse_obj", ",", "agent", "=", "None", ",", "etag", "=", "None", ",", "modified", "=", "None", ",", "inject", "=", "False", ")", ":", "guarantees", "=", "common", ".", "SuperDict", "(", "{", "'bozo'", ":", "0", ",", "'feeds'", ...
f9bc310a0ce567cd0611fea68be99974021f53c7
train
FixmatStimuliFactory
Constructs an categories object for all image / category combinations in the fixmat. Parameters: fm: FixMat Used for extracting valid category/image combination. loader: loader Loader that accesses the stimuli for this fixmat Returns: Categories object
ocupy/stimuli.py
def FixmatStimuliFactory(fm, loader): """ Constructs an categories object for all image / category combinations in the fixmat. Parameters: fm: FixMat Used for extracting valid category/image combination. loader: loader Loader that accesses the stimuli for th...
def FixmatStimuliFactory(fm, loader): """ Constructs an categories object for all image / category combinations in the fixmat. Parameters: fm: FixMat Used for extracting valid category/image combination. loader: loader Loader that accesses the stimuli for th...
[ "Constructs", "an", "categories", "object", "for", "all", "image", "/", "category", "combinations", "in", "the", "fixmat", ".", "Parameters", ":", "fm", ":", "FixMat", "Used", "for", "extracting", "valid", "category", "/", "image", "combination", ".", "loader"...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/stimuli.py#L177-L217
[ "def", "FixmatStimuliFactory", "(", "fm", ",", "loader", ")", ":", "# Find all feature names", "features", "=", "[", "]", "if", "loader", ".", "ftrpath", ":", "assert", "os", ".", "access", "(", "loader", ".", "ftrpath", ",", "os", ".", "R_OK", ")", "fea...
a0bd64f822576feaa502939d6bafd1183b237d16
train
DirectoryStimuliFactory
Takes an input path to the images folder of an experiment and generates automatically the category - filenumber list needed to construct an appropriate _categories object. Parameters : loader : Loader object which contains impath : string path to the input, i.e. ima...
ocupy/stimuli.py
def DirectoryStimuliFactory(loader): """ Takes an input path to the images folder of an experiment and generates automatically the category - filenumber list needed to construct an appropriate _categories object. Parameters : loader : Loader object which contains impath : s...
def DirectoryStimuliFactory(loader): """ Takes an input path to the images folder of an experiment and generates automatically the category - filenumber list needed to construct an appropriate _categories object. Parameters : loader : Loader object which contains impath : s...
[ "Takes", "an", "input", "path", "to", "the", "images", "folder", "of", "an", "experiment", "and", "generates", "automatically", "the", "category", "-", "filenumber", "list", "needed", "to", "construct", "an", "appropriate", "_categories", "object", ".", "Paramet...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/stimuli.py#L219-L278
[ "def", "DirectoryStimuliFactory", "(", "loader", ")", ":", "impath", "=", "loader", ".", "impath", "ftrpath", "=", "loader", ".", "ftrpath", "# checks whether user has reading permission for the path", "assert", "os", ".", "access", "(", "impath", ",", "os", ".", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Categories.fixations
Filter the fixmat such that it only contains fixations on images in categories that are also in the categories object
ocupy/stimuli.py
def fixations(self): ''' Filter the fixmat such that it only contains fixations on images in categories that are also in the categories object''' if not self._fixations: raise RuntimeError('This Images object does not have' +' an associated fixmat') if len(lis...
def fixations(self): ''' Filter the fixmat such that it only contains fixations on images in categories that are also in the categories object''' if not self._fixations: raise RuntimeError('This Images object does not have' +' an associated fixmat') if len(lis...
[ "Filter", "the", "fixmat", "such", "that", "it", "only", "contains", "fixations", "on", "images", "in", "categories", "that", "are", "also", "in", "the", "categories", "object" ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/stimuli.py#L49-L61
[ "def", "fixations", "(", "self", ")", ":", "if", "not", "self", ".", "_fixations", ":", "raise", "RuntimeError", "(", "'This Images object does not have'", "+", "' an associated fixmat'", ")", "if", "len", "(", "list", "(", "self", ".", "_categories", ".", "ke...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Image.data
Saves a new image to disk
ocupy/stimuli.py
def data(self, value): """ Saves a new image to disk """ self.loader.save_image(self.category, self.image, value)
def data(self, value): """ Saves a new image to disk """ self.loader.save_image(self.category, self.image, value)
[ "Saves", "a", "new", "image", "to", "disk" ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/stimuli.py#L140-L144
[ "def", "data", "(", "self", ",", "value", ")", ":", "self", ".", "loader", ".", "save_image", "(", "self", ".", "category", ",", "self", ".", "image", ",", "value", ")" ]
a0bd64f822576feaa502939d6bafd1183b237d16
train
Image.fixations
Returns all fixations that are on this image. A precondition for this to work is that a fixmat is associated with this Image object.
ocupy/stimuli.py
def fixations(self): """ Returns all fixations that are on this image. A precondition for this to work is that a fixmat is associated with this Image object. """ if not self._fixations: raise RuntimeError('This Images object does not have' +' ...
def fixations(self): """ Returns all fixations that are on this image. A precondition for this to work is that a fixmat is associated with this Image object. """ if not self._fixations: raise RuntimeError('This Images object does not have' +' ...
[ "Returns", "all", "fixations", "that", "are", "on", "this", "image", ".", "A", "precondition", "for", "this", "to", "work", "is", "that", "a", "fixmat", "is", "associated", "with", "this", "Image", "object", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/stimuli.py#L164-L174
[ "def", "fixations", "(", "self", ")", ":", "if", "not", "self", ".", "_fixations", ":", "raise", "RuntimeError", "(", "'This Images object does not have'", "+", "' an associated fixmat'", ")", "return", "self", ".", "_fixations", "[", "(", "self", ".", "_fixatio...
a0bd64f822576feaa502939d6bafd1183b237d16
train
SimpleXValidation.generate
Generator for creating the cross-validation slices. Returns A tuple of that contains two fixmats (training and test) and two Category objects (test and train).
ocupy/xvalidation.py
def generate(self): """ Generator for creating the cross-validation slices. Returns A tuple of that contains two fixmats (training and test) and two Category objects (test and train). """ for _ in range(0, self.num_slices): #1. separate fixm...
def generate(self): """ Generator for creating the cross-validation slices. Returns A tuple of that contains two fixmats (training and test) and two Category objects (test and train). """ for _ in range(0, self.num_slices): #1. separate fixm...
[ "Generator", "for", "creating", "the", "cross", "-", "validation", "slices", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/xvalidation.py#L42-L88
[ "def", "generate", "(", "self", ")", ":", "for", "_", "in", "range", "(", "0", ",", "self", ".", "num_slices", ")", ":", "#1. separate fixmat into test and training fixmat", "subjects", "=", "np", ".", "unique", "(", "self", ".", "fm", ".", "SUBJECTINDEX", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
prepare_data
Computes angle and length differences up to given order and deletes suspiciously long fixations. Input fm: Fixmat Fixmat for which to comput angle and length differences max_back: Int Computes delta angle and amplitude up to order max_back. dur_cap: Int ...
ocupy/saccade_geometry.py
def prepare_data(fm, max_back, dur_cap=700): ''' Computes angle and length differences up to given order and deletes suspiciously long fixations. Input fm: Fixmat Fixmat for which to comput angle and length differences max_back: Int Computes delta angle and ampli...
def prepare_data(fm, max_back, dur_cap=700): ''' Computes angle and length differences up to given order and deletes suspiciously long fixations. Input fm: Fixmat Fixmat for which to comput angle and length differences max_back: Int Computes delta angle and ampli...
[ "Computes", "angle", "and", "length", "differences", "up", "to", "given", "order", "and", "deletes", "suspiciously", "long", "fixations", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/saccade_geometry.py#L15-L48
[ "def", "prepare_data", "(", "fm", ",", "max_back", ",", "dur_cap", "=", "700", ")", ":", "durations", "=", "np", ".", "roll", "(", "fm", ".", "end", "-", "fm", ".", "start", ",", "1", ")", ".", "astype", "(", "float", ")", "angles", ",", "lengths...
a0bd64f822576feaa502939d6bafd1183b237d16
train
saccadic_momentum_effect
Computes the mean fixation duration at forward angles.
ocupy/saccade_geometry.py
def saccadic_momentum_effect(durations, forward_angle, summary_stat=nanmean): """ Computes the mean fixation duration at forward angles. """ durations_per_da = np.nan * np.ones((len(e_angle) - 1,)) for i, (bo, b1) in enumerate(zip(e_angle[:-1], e_angle[1:])): idx...
def saccadic_momentum_effect(durations, forward_angle, summary_stat=nanmean): """ Computes the mean fixation duration at forward angles. """ durations_per_da = np.nan * np.ones((len(e_angle) - 1,)) for i, (bo, b1) in enumerate(zip(e_angle[:-1], e_angle[1:])): idx...
[ "Computes", "the", "mean", "fixation", "duration", "at", "forward", "angles", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/saccade_geometry.py#L51-L63
[ "def", "saccadic_momentum_effect", "(", "durations", ",", "forward_angle", ",", "summary_stat", "=", "nanmean", ")", ":", "durations_per_da", "=", "np", ".", "nan", "*", "np", ".", "ones", "(", "(", "len", "(", "e_angle", ")", "-", "1", ",", ")", ")", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
ior_effect
Computes a measure of fixation durations at delta angle and delta length combinations.
ocupy/saccade_geometry.py
def ior_effect(durations, angle_diffs, length_diffs, summary_stat=np.mean, parallel=True, min_samples=20): """ Computes a measure of fixation durations at delta angle and delta length combinations. """ raster = np.empty((len(e_dist) - 1, len(e_angle) - 1), dtype=object) for a, (a_...
def ior_effect(durations, angle_diffs, length_diffs, summary_stat=np.mean, parallel=True, min_samples=20): """ Computes a measure of fixation durations at delta angle and delta length combinations. """ raster = np.empty((len(e_dist) - 1, len(e_angle) - 1), dtype=object) for a, (a_...
[ "Computes", "a", "measure", "of", "fixation", "durations", "at", "delta", "angle", "and", "delta", "length", "combinations", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/saccade_geometry.py#L66-L90
[ "def", "ior_effect", "(", "durations", ",", "angle_diffs", ",", "length_diffs", ",", "summary_stat", "=", "np", ".", "mean", ",", "parallel", "=", "True", ",", "min_samples", "=", "20", ")", ":", "raster", "=", "np", ".", "empty", "(", "(", "len", "(",...
a0bd64f822576feaa502939d6bafd1183b237d16
train
predict_fixation_duration
Fits a non-linear piecewise regression to fixtaion durations for a fixmat. Returns corrected fixation durations.
ocupy/saccade_geometry.py
def predict_fixation_duration( durations, angles, length_diffs, dataset=None, params=None): """ Fits a non-linear piecewise regression to fixtaion durations for a fixmat. Returns corrected fixation durations. """ if dataset is None: dataset = np.ones(durations.shape) corrected_d...
def predict_fixation_duration( durations, angles, length_diffs, dataset=None, params=None): """ Fits a non-linear piecewise regression to fixtaion durations for a fixmat. Returns corrected fixation durations. """ if dataset is None: dataset = np.ones(durations.shape) corrected_d...
[ "Fits", "a", "non", "-", "linear", "piecewise", "regression", "to", "fixtaion", "durations", "for", "a", "fixmat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/saccade_geometry.py#L93-L122
[ "def", "predict_fixation_duration", "(", "durations", ",", "angles", ",", "length_diffs", ",", "dataset", "=", "None", ",", "params", "=", "None", ")", ":", "if", "dataset", "is", "None", ":", "dataset", "=", "np", ".", "ones", "(", "durations", ".", "sh...
a0bd64f822576feaa502939d6bafd1183b237d16
train
subject_predictions
Calculates the saccadic momentum effect for individual subjects. Removes any effect of amplitude differences. The parameters are fitted on unbinned data. The effects are computed on binned data. See e_dist and e_angle for the binning parameter.
ocupy/saccade_geometry.py
def subject_predictions(fm, field='SUBJECTINDEX', method=predict_fixation_duration, data=None): ''' Calculates the saccadic momentum effect for individual subjects. Removes any effect of amplitude differences. The parameters are fitted on unbinned data. The effects are comp...
def subject_predictions(fm, field='SUBJECTINDEX', method=predict_fixation_duration, data=None): ''' Calculates the saccadic momentum effect for individual subjects. Removes any effect of amplitude differences. The parameters are fitted on unbinned data. The effects are comp...
[ "Calculates", "the", "saccadic", "momentum", "effect", "for", "individual", "subjects", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/saccade_geometry.py#L125-L158
[ "def", "subject_predictions", "(", "fm", ",", "field", "=", "'SUBJECTINDEX'", ",", "method", "=", "predict_fixation_duration", ",", "data", "=", "None", ")", ":", "if", "data", "is", "None", ":", "fma", ",", "dura", ",", "faa", ",", "adsa", ",", "ldsa", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
intersubject_scores
Calculates how well the fixations from a set of subjects on a set of images can be predicted with the fixations from another set of subjects on another set of images. The prediction is carried out by computing a fixation density map from fixations of predicting_subjects subjects on predicting_images im...
ocupy/bounds.py
def intersubject_scores(fm, category, predicting_filenumbers, predicting_subjects, predicted_filenumbers, predicted_subjects, controls = True, scale_factor = 1): """ Calculates how well the fixations from a set of subjects on a set of images can be predicted w...
def intersubject_scores(fm, category, predicting_filenumbers, predicting_subjects, predicted_filenumbers, predicted_subjects, controls = True, scale_factor = 1): """ Calculates how well the fixations from a set of subjects on a set of images can be predicted w...
[ "Calculates", "how", "well", "the", "fixations", "from", "a", "set", "of", "subjects", "on", "a", "set", "of", "images", "can", "be", "predicted", "with", "the", "fixations", "from", "another", "set", "of", "subjects", "on", "another", "set", "of", "images...
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/bounds.py#L12-L76
[ "def", "intersubject_scores", "(", "fm", ",", "category", ",", "predicting_filenumbers", ",", "predicting_subjects", ",", "predicted_filenumbers", ",", "predicted_subjects", ",", "controls", "=", "True", ",", "scale_factor", "=", "1", ")", ":", "predicting_fm", "=",...
a0bd64f822576feaa502939d6bafd1183b237d16
train
intersubject_scores_random_subjects
Calculates how well the fixations of n random subjects on one image can be predicted with the fixations of m other random subjects. Notes Function that uses intersubject_auc for computing auc. Parameters fm : fixmat instance category : int Category from which the fixati...
ocupy/bounds.py
def intersubject_scores_random_subjects(fm, category, filenumber, n_train, n_predict, controls=True, scale_factor = 1): """ Calculates how well the fixations of n random subjects on one image can be predicted with the fixations ...
def intersubject_scores_random_subjects(fm, category, filenumber, n_train, n_predict, controls=True, scale_factor = 1): """ Calculates how well the fixations of n random subjects on one image can be predicted with the fixations ...
[ "Calculates", "how", "well", "the", "fixations", "of", "n", "random", "subjects", "on", "one", "image", "can", "be", "predicted", "with", "the", "fixations", "of", "m", "other", "random", "subjects", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/bounds.py#L78-L121
[ "def", "intersubject_scores_random_subjects", "(", "fm", ",", "category", ",", "filenumber", ",", "n_train", ",", "n_predict", ",", "controls", "=", "True", ",", "scale_factor", "=", "1", ")", ":", "subjects", "=", "np", ".", "unique", "(", "fm", ".", "SUB...
a0bd64f822576feaa502939d6bafd1183b237d16
train
upper_bound
compute the inter-subject consistency upper bound for a fixmat. Input: fm : a fixmat instance nr_subs : the number of subjects used for the prediction. Defaults to the total number of subjects in the fixmat minus 1 scale_factor : the scale factor of the FDMs. Default is 1....
ocupy/bounds.py
def upper_bound(fm, nr_subs = None, scale_factor = 1): """ compute the inter-subject consistency upper bound for a fixmat. Input: fm : a fixmat instance nr_subs : the number of subjects used for the prediction. Defaults to the total number of subjects in the fixmat minus 1...
def upper_bound(fm, nr_subs = None, scale_factor = 1): """ compute the inter-subject consistency upper bound for a fixmat. Input: fm : a fixmat instance nr_subs : the number of subjects used for the prediction. Defaults to the total number of subjects in the fixmat minus 1...
[ "compute", "the", "inter", "-", "subject", "consistency", "upper", "bound", "for", "a", "fixmat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/bounds.py#L123-L173
[ "def", "upper_bound", "(", "fm", ",", "nr_subs", "=", "None", ",", "scale_factor", "=", "1", ")", ":", "nr_subs_total", "=", "len", "(", "np", ".", "unique", "(", "fm", ".", "SUBJECTINDEX", ")", ")", "if", "not", "nr_subs", ":", "nr_subs", "=", "nr_s...
a0bd64f822576feaa502939d6bafd1183b237d16
train
lower_bound
Compute the spatial bias lower bound for a fixmat. Input: fm : a fixmat instance nr_subs : the number of subjects used for the prediction. Defaults to the total number of subjects in the fixmat minus 1 nr_imgs : the number of images used for prediction. If given, the ...
ocupy/bounds.py
def lower_bound(fm, nr_subs = None, nr_imgs = None, scale_factor = 1): """ Compute the spatial bias lower bound for a fixmat. Input: fm : a fixmat instance nr_subs : the number of subjects used for the prediction. Defaults to the total number of subjects in the fixmat minu...
def lower_bound(fm, nr_subs = None, nr_imgs = None, scale_factor = 1): """ Compute the spatial bias lower bound for a fixmat. Input: fm : a fixmat instance nr_subs : the number of subjects used for the prediction. Defaults to the total number of subjects in the fixmat minu...
[ "Compute", "the", "spatial", "bias", "lower", "bound", "for", "a", "fixmat", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/bounds.py#L175-L243
[ "def", "lower_bound", "(", "fm", ",", "nr_subs", "=", "None", ",", "nr_imgs", "=", "None", ",", "scale_factor", "=", "1", ")", ":", "nr_subs_total", "=", "len", "(", "np", ".", "unique", "(", "fm", ".", "SUBJECTINDEX", ")", ")", "if", "nr_subs", "is"...
a0bd64f822576feaa502939d6bafd1183b237d16
train
ind2sub
Calculates subscripts for indices into regularly spaced matrixes.
ocupy/parallel.py
def ind2sub(ind, dimensions): """ Calculates subscripts for indices into regularly spaced matrixes. """ # check that the index is within range if ind >= np.prod(dimensions): raise RuntimeError("ind2sub: index exceeds array size") cum_dims = list(dimensions) cum_dims.reverse() m =...
def ind2sub(ind, dimensions): """ Calculates subscripts for indices into regularly spaced matrixes. """ # check that the index is within range if ind >= np.prod(dimensions): raise RuntimeError("ind2sub: index exceeds array size") cum_dims = list(dimensions) cum_dims.reverse() m =...
[ "Calculates", "subscripts", "for", "indices", "into", "regularly", "spaced", "matrixes", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L268-L289
[ "def", "ind2sub", "(", "ind", ",", "dimensions", ")", ":", "# check that the index is within range", "if", "ind", ">=", "np", ".", "prod", "(", "dimensions", ")", ":", "raise", "RuntimeError", "(", "\"ind2sub: index exceeds array size\"", ")", "cum_dims", "=", "li...
a0bd64f822576feaa502939d6bafd1183b237d16
train
sub2ind
An exemplary sub2ind implementation to create randomization scripts. This function calculates indices from subscripts into regularly spaced matrixes.
ocupy/parallel.py
def sub2ind(indices, dimensions): """ An exemplary sub2ind implementation to create randomization scripts. This function calculates indices from subscripts into regularly spaced matrixes. """ # check that none of the indices exceeds the size of the array if any([i > j for i, j in zip(...
def sub2ind(indices, dimensions): """ An exemplary sub2ind implementation to create randomization scripts. This function calculates indices from subscripts into regularly spaced matrixes. """ # check that none of the indices exceeds the size of the array if any([i > j for i, j in zip(...
[ "An", "exemplary", "sub2ind", "implementation", "to", "create", "randomization", "scripts", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L292-L314
[ "def", "sub2ind", "(", "indices", ",", "dimensions", ")", ":", "# check that none of the indices exceeds the size of the array", "if", "any", "(", "[", "i", ">", "j", "for", "i", ",", "j", "in", "zip", "(", "indices", ",", "dimensions", ")", "]", ")", ":", ...
a0bd64f822576feaa502939d6bafd1183b237d16
train
RestoreTaskStoreFactory
Restores a task store from file.
ocupy/parallel.py
def RestoreTaskStoreFactory(store_class, chunk_size, restore_file, save_file): """ Restores a task store from file. """ intm_results = np.load(restore_file) intm = intm_results[intm_results.files[0]] idx = np.isnan(intm).flatten().nonzero()[0] partitions = math.ceil(len(idx) / float(chunk_si...
def RestoreTaskStoreFactory(store_class, chunk_size, restore_file, save_file): """ Restores a task store from file. """ intm_results = np.load(restore_file) intm = intm_results[intm_results.files[0]] idx = np.isnan(intm).flatten().nonzero()[0] partitions = math.ceil(len(idx) / float(chunk_si...
[ "Restores", "a", "task", "store", "from", "file", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L316-L329
[ "def", "RestoreTaskStoreFactory", "(", "store_class", ",", "chunk_size", ",", "restore_file", ",", "save_file", ")", ":", "intm_results", "=", "np", ".", "load", "(", "restore_file", ")", "intm", "=", "intm_results", "[", "intm_results", ".", "files", "[", "0"...
a0bd64f822576feaa502939d6bafd1183b237d16
train
TaskManager.xmlrpc_reschedule
Reschedule all running tasks.
ocupy/parallel.py
def xmlrpc_reschedule(self): """ Reschedule all running tasks. """ if not len(self.scheduled_tasks) == 0: self.reschedule = list(self.scheduled_tasks.items()) self.scheduled_tasks = {} return True
def xmlrpc_reschedule(self): """ Reschedule all running tasks. """ if not len(self.scheduled_tasks) == 0: self.reschedule = list(self.scheduled_tasks.items()) self.scheduled_tasks = {} return True
[ "Reschedule", "all", "running", "tasks", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L61-L68
[ "def", "xmlrpc_reschedule", "(", "self", ")", ":", "if", "not", "len", "(", "self", ".", "scheduled_tasks", ")", "==", "0", ":", "self", ".", "reschedule", "=", "list", "(", "self", ".", "scheduled_tasks", ".", "items", "(", ")", ")", "self", ".", "s...
a0bd64f822576feaa502939d6bafd1183b237d16
train
TaskManager.xmlrpc_get_task
Return a new task description: ID and necessary parameters, all are given in a dictionary
ocupy/parallel.py
def xmlrpc_get_task(self): """ Return a new task description: ID and necessary parameters, all are given in a dictionary """ try: if len(self.reschedule) == 0: (task_id, cur_task) = next(self.task_iterator) else: (task_id, ...
def xmlrpc_get_task(self): """ Return a new task description: ID and necessary parameters, all are given in a dictionary """ try: if len(self.reschedule) == 0: (task_id, cur_task) = next(self.task_iterator) else: (task_id, ...
[ "Return", "a", "new", "task", "description", ":", "ID", "and", "necessary", "parameters", "all", "are", "given", "in", "a", "dictionary" ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L70-L88
[ "def", "xmlrpc_get_task", "(", "self", ")", ":", "try", ":", "if", "len", "(", "self", ".", "reschedule", ")", "==", "0", ":", "(", "task_id", ",", "cur_task", ")", "=", "next", "(", "self", ".", "task_iterator", ")", "else", ":", "(", "task_id", "...
a0bd64f822576feaa502939d6bafd1183b237d16
train
TaskManager.xmlrpc_task_done
Take the results of a computation and put it into the results list.
ocupy/parallel.py
def xmlrpc_task_done(self, result): """ Take the results of a computation and put it into the results list. """ (task_id, task_results) = result del self.scheduled_tasks[task_id] self.task_store.update_results(task_id, task_results) self.results += 1 retur...
def xmlrpc_task_done(self, result): """ Take the results of a computation and put it into the results list. """ (task_id, task_results) = result del self.scheduled_tasks[task_id] self.task_store.update_results(task_id, task_results) self.results += 1 retur...
[ "Take", "the", "results", "of", "a", "computation", "and", "put", "it", "into", "the", "results", "list", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L90-L98
[ "def", "xmlrpc_task_done", "(", "self", ",", "result", ")", ":", "(", "task_id", ",", "task_results", ")", "=", "result", "del", "self", ".", "scheduled_tasks", "[", "task_id", "]", "self", ".", "task_store", ".", "update_results", "(", "task_id", ",", "ta...
a0bd64f822576feaa502939d6bafd1183b237d16
train
TaskManager.xmlrpc_status
Return a status message
ocupy/parallel.py
def xmlrpc_status(self): """ Return a status message """ return (""" %i Jobs are still wating for execution %i Jobs are being processed %i Jobs are done """ %(self.task_store.partitions - self.results - len(self.scheduled_...
def xmlrpc_status(self): """ Return a status message """ return (""" %i Jobs are still wating for execution %i Jobs are being processed %i Jobs are done """ %(self.task_store.partitions - self.results - len(self.scheduled_...
[ "Return", "a", "status", "message" ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L100-L112
[ "def", "xmlrpc_status", "(", "self", ")", ":", "return", "(", "\"\"\"\n %i Jobs are still wating for execution\n %i Jobs are being processed\n %i Jobs are done\n \"\"\"", "%", "(", "self", ".", "task_store", ".", "partitions", "-", "self", ".", "resu...
a0bd64f822576feaa502939d6bafd1183b237d16
train
TaskManager.xmlrpc_save2file
Save results and own state into file.
ocupy/parallel.py
def xmlrpc_save2file(self, filename): """ Save results and own state into file. """ savefile = open(filename,'wb') try: pickle.dump({'scheduled':self.scheduled_tasks, 'reschedule':self.reschedule},savefile) except pickle.PicklingError...
def xmlrpc_save2file(self, filename): """ Save results and own state into file. """ savefile = open(filename,'wb') try: pickle.dump({'scheduled':self.scheduled_tasks, 'reschedule':self.reschedule},savefile) except pickle.PicklingError...
[ "Save", "results", "and", "own", "state", "into", "file", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L114-L125
[ "def", "xmlrpc_save2file", "(", "self", ",", "filename", ")", ":", "savefile", "=", "open", "(", "filename", ",", "'wb'", ")", "try", ":", "pickle", ".", "dump", "(", "{", "'scheduled'", ":", "self", ".", "scheduled_tasks", ",", "'reschedule'", ":", "sel...
a0bd64f822576feaa502939d6bafd1183b237d16
train
Worker.run
This function needs to be called to start the computation.
ocupy/parallel.py
def run(self): """This function needs to be called to start the computation.""" (task_id, tasks) = self.server.get_task() self.task_store.from_dict(tasks) for (index, task) in self.task_store: result = self.compute(index, task) self.results.append(result) ...
def run(self): """This function needs to be called to start the computation.""" (task_id, tasks) = self.server.get_task() self.task_store.from_dict(tasks) for (index, task) in self.task_store: result = self.compute(index, task) self.results.append(result) ...
[ "This", "function", "needs", "to", "be", "called", "to", "start", "the", "computation", "." ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L158-L165
[ "def", "run", "(", "self", ")", ":", "(", "task_id", ",", "tasks", ")", "=", "self", ".", "server", ".", "get_task", "(", ")", "self", ".", "task_store", ".", "from_dict", "(", "tasks", ")", "for", "(", "index", ",", "task", ")", "in", "self", "....
a0bd64f822576feaa502939d6bafd1183b237d16
train
TaskStore.from_dict
Configures the task store to be the task_store described in description
ocupy/parallel.py
def from_dict(self, description): """Configures the task store to be the task_store described in description""" assert(self.ident == description['ident']) self.partitions = description['partitions'] self.indices = description['indices']
def from_dict(self, description): """Configures the task store to be the task_store described in description""" assert(self.ident == description['ident']) self.partitions = description['partitions'] self.indices = description['indices']
[ "Configures", "the", "task", "store", "to", "be", "the", "task_store", "described", "in", "description" ]
nwilming/ocupy
python
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/parallel.py#L216-L221
[ "def", "from_dict", "(", "self", ",", "description", ")", ":", "assert", "(", "self", ".", "ident", "==", "description", "[", "'ident'", "]", ")", "self", ".", "partitions", "=", "description", "[", "'partitions'", "]", "self", ".", "indices", "=", "desc...
a0bd64f822576feaa502939d6bafd1183b237d16