repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
BlueBrain/NeuroM
neurom/utils.py
deprecated
def deprecated(fun_name=None, msg=""): '''Issue a deprecation warning for a function''' def _deprecated(fun): '''Issue a deprecation warning for a function''' @wraps(fun) def _wrapper(*args, **kwargs): '''Issue deprecation warning and forward arguments to fun''' n...
python
def deprecated(fun_name=None, msg=""): '''Issue a deprecation warning for a function''' def _deprecated(fun): '''Issue a deprecation warning for a function''' @wraps(fun) def _wrapper(*args, **kwargs): '''Issue deprecation warning and forward arguments to fun''' n...
[ "def", "deprecated", "(", "fun_name", "=", "None", ",", "msg", "=", "\"\"", ")", ":", "def", "_deprecated", "(", "fun", ")", ":", "'''Issue a deprecation warning for a function'''", "@", "wraps", "(", "fun", ")", "def", "_wrapper", "(", "*", "args", ",", "...
Issue a deprecation warning for a function
[ "Issue", "a", "deprecation", "warning", "for", "a", "function" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/utils.py#L86-L99
BlueBrain/NeuroM
neurom/check/__init__.py
check_wrapper
def check_wrapper(fun): '''Decorate a checking function''' @wraps(fun) def _wrapper(*args, **kwargs): '''Sets the title property of the result of running a checker''' title = fun.__name__.replace('_', ' ').capitalize() result = fun(*args, **kwargs) result.title = title ...
python
def check_wrapper(fun): '''Decorate a checking function''' @wraps(fun) def _wrapper(*args, **kwargs): '''Sets the title property of the result of running a checker''' title = fun.__name__.replace('_', ' ').capitalize() result = fun(*args, **kwargs) result.title = title ...
[ "def", "check_wrapper", "(", "fun", ")", ":", "@", "wraps", "(", "fun", ")", "def", "_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "'''Sets the title property of the result of running a checker'''", "title", "=", "fun", ".", "__name__", ".", ...
Decorate a checking function
[ "Decorate", "a", "checking", "function" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/__init__.py#L34-L44
BlueBrain/NeuroM
neurom/check/runner.py
CheckRunner.run
def run(self, path): '''Test a bunch of files and return a summary JSON report''' SEPARATOR = '=' * 40 summary = {} res = True for _f in utils.get_files_by_path(path): L.info(SEPARATOR) status, summ = self._check_file(_f) res &= status ...
python
def run(self, path): '''Test a bunch of files and return a summary JSON report''' SEPARATOR = '=' * 40 summary = {} res = True for _f in utils.get_files_by_path(path): L.info(SEPARATOR) status, summ = self._check_file(_f) res &= status ...
[ "def", "run", "(", "self", ",", "path", ")", ":", "SEPARATOR", "=", "'='", "*", "40", "summary", "=", "{", "}", "res", "=", "True", "for", "_f", "in", "utils", ".", "get_files_by_path", "(", "path", ")", ":", "L", ".", "info", "(", "SEPARATOR", "...
Test a bunch of files and return a summary JSON report
[ "Test", "a", "bunch", "of", "files", "and", "return", "a", "summary", "JSON", "report" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/runner.py#L53-L71
BlueBrain/NeuroM
neurom/check/runner.py
CheckRunner._do_check
def _do_check(self, obj, check_module, check_str): '''Run a check function on obj''' opts = self._config['options'] if check_str in opts: fargs = opts[check_str] if isinstance(fargs, list): out = check_wrapper(getattr(check_module, check_str))(obj, *fargs)...
python
def _do_check(self, obj, check_module, check_str): '''Run a check function on obj''' opts = self._config['options'] if check_str in opts: fargs = opts[check_str] if isinstance(fargs, list): out = check_wrapper(getattr(check_module, check_str))(obj, *fargs)...
[ "def", "_do_check", "(", "self", ",", "obj", ",", "check_module", ",", "check_str", ")", ":", "opts", "=", "self", ".", "_config", "[", "'options'", "]", "if", "check_str", "in", "opts", ":", "fargs", "=", "opts", "[", "check_str", "]", "if", "isinstan...
Run a check function on obj
[ "Run", "a", "check", "function", "on", "obj" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/runner.py#L73-L92
BlueBrain/NeuroM
neurom/check/runner.py
CheckRunner._check_loop
def _check_loop(self, obj, check_mod_str): '''Run all the checks in a check_module''' check_module = self._check_modules[check_mod_str] checks = self._config['checks'][check_mod_str] result = True summary = OrderedDict() for check in checks: ok = self._do_chec...
python
def _check_loop(self, obj, check_mod_str): '''Run all the checks in a check_module''' check_module = self._check_modules[check_mod_str] checks = self._config['checks'][check_mod_str] result = True summary = OrderedDict() for check in checks: ok = self._do_chec...
[ "def", "_check_loop", "(", "self", ",", "obj", ",", "check_mod_str", ")", ":", "check_module", "=", "self", ".", "_check_modules", "[", "check_mod_str", "]", "checks", "=", "self", ".", "_config", "[", "'checks'", "]", "[", "check_mod_str", "]", "result", ...
Run all the checks in a check_module
[ "Run", "all", "the", "checks", "in", "a", "check_module" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/runner.py#L94-L105
BlueBrain/NeuroM
neurom/check/runner.py
CheckRunner._check_file
def _check_file(self, f): '''Run tests on a morphology file''' L.info('File: %s', f) full_result = True full_summary = OrderedDict() try: data = load_data(f) except Exception as e: # pylint: disable=W0703 L.error('Failed to load data... skipping ...
python
def _check_file(self, f): '''Run tests on a morphology file''' L.info('File: %s', f) full_result = True full_summary = OrderedDict() try: data = load_data(f) except Exception as e: # pylint: disable=W0703 L.error('Failed to load data... skipping ...
[ "def", "_check_file", "(", "self", ",", "f", ")", ":", "L", ".", "info", "(", "'File: %s'", ",", "f", ")", "full_result", "=", "True", "full_summary", "=", "OrderedDict", "(", ")", "try", ":", "data", "=", "load_data", "(", "f", ")", "except", "Excep...
Run tests on a morphology file
[ "Run", "tests", "on", "a", "morphology", "file" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/runner.py#L107-L138
BlueBrain/NeuroM
neurom/check/runner.py
CheckRunner._log_msg
def _log_msg(self, msg, ok): '''Helper to log message to the right level''' if self._config['color']: CGREEN, CRED, CEND = '\033[92m', '\033[91m', '\033[0m' else: CGREEN = CRED = CEND = '' LOG_LEVELS = {False: logging.ERROR, True: logging.INFO} # pylint:...
python
def _log_msg(self, msg, ok): '''Helper to log message to the right level''' if self._config['color']: CGREEN, CRED, CEND = '\033[92m', '\033[91m', '\033[0m' else: CGREEN = CRED = CEND = '' LOG_LEVELS = {False: logging.ERROR, True: logging.INFO} # pylint:...
[ "def", "_log_msg", "(", "self", ",", "msg", ",", "ok", ")", ":", "if", "self", ".", "_config", "[", "'color'", "]", ":", "CGREEN", ",", "CRED", ",", "CEND", "=", "'\\033[92m'", ",", "'\\033[91m'", ",", "'\\033[0m'", "else", ":", "CGREEN", "=", "CRED"...
Helper to log message to the right level
[ "Helper", "to", "log", "message", "to", "the", "right", "level" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/runner.py#L140-L151
BlueBrain/NeuroM
neurom/check/runner.py
CheckRunner._sanitize_config
def _sanitize_config(config): '''check that the config has the correct keys, add missing keys if necessary''' if 'checks' in config: checks = config['checks'] if 'structural_checks' not in checks: checks['structural_checks'] = [] if 'neuron_checks' not...
python
def _sanitize_config(config): '''check that the config has the correct keys, add missing keys if necessary''' if 'checks' in config: checks = config['checks'] if 'structural_checks' not in checks: checks['structural_checks'] = [] if 'neuron_checks' not...
[ "def", "_sanitize_config", "(", "config", ")", ":", "if", "'checks'", "in", "config", ":", "checks", "=", "config", "[", "'checks'", "]", "if", "'structural_checks'", "not", "in", "checks", ":", "checks", "[", "'structural_checks'", "]", "=", "[", "]", "if...
check that the config has the correct keys, add missing keys if necessary
[ "check", "that", "the", "config", "has", "the", "correct", "keys", "add", "missing", "keys", "if", "necessary" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/runner.py#L154-L172
BlueBrain/NeuroM
neurom/io/swc.py
read
def read(filename, data_wrapper=DataWrapper): '''Read an SWC file and return a tuple of data, format.''' data = np.loadtxt(filename) if len(np.shape(data)) == 1: data = np.reshape(data, (1, -1)) data = data[:, [X, Y, Z, R, TYPE, ID, P]] return data_wrapper(data, 'SWC', None)
python
def read(filename, data_wrapper=DataWrapper): '''Read an SWC file and return a tuple of data, format.''' data = np.loadtxt(filename) if len(np.shape(data)) == 1: data = np.reshape(data, (1, -1)) data = data[:, [X, Y, Z, R, TYPE, ID, P]] return data_wrapper(data, 'SWC', None)
[ "def", "read", "(", "filename", ",", "data_wrapper", "=", "DataWrapper", ")", ":", "data", "=", "np", ".", "loadtxt", "(", "filename", ")", "if", "len", "(", "np", ".", "shape", "(", "data", ")", ")", "==", "1", ":", "data", "=", "np", ".", "resh...
Read an SWC file and return a tuple of data, format.
[ "Read", "an", "SWC", "file", "and", "return", "a", "tuple", "of", "data", "format", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/swc.py#L47-L53
BlueBrain/NeuroM
neurom/io/datawrapper.py
_merge_sections
def _merge_sections(sec_a, sec_b): '''Merge two sections Merges sec_a into sec_b and sets sec_a attributes to default ''' sec_b.ids = list(sec_a.ids) + list(sec_b.ids[1:]) sec_b.ntype = sec_a.ntype sec_b.pid = sec_a.pid sec_a.ids = [] sec_a.pid = -1 sec_a.ntype = 0
python
def _merge_sections(sec_a, sec_b): '''Merge two sections Merges sec_a into sec_b and sets sec_a attributes to default ''' sec_b.ids = list(sec_a.ids) + list(sec_b.ids[1:]) sec_b.ntype = sec_a.ntype sec_b.pid = sec_a.pid sec_a.ids = [] sec_a.pid = -1 sec_a.ntype = 0
[ "def", "_merge_sections", "(", "sec_a", ",", "sec_b", ")", ":", "sec_b", ".", "ids", "=", "list", "(", "sec_a", ".", "ids", ")", "+", "list", "(", "sec_b", ".", "ids", "[", "1", ":", "]", ")", "sec_b", ".", "ntype", "=", "sec_a", ".", "ntype", ...
Merge two sections Merges sec_a into sec_b and sets sec_a attributes to default
[ "Merge", "two", "sections" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L89-L100
BlueBrain/NeuroM
neurom/io/datawrapper.py
_section_end_points
def _section_end_points(structure_block, id_map): '''Get the section end-points''' soma_idx = structure_block[:, TYPE] == POINT_TYPE.SOMA soma_ids = structure_block[soma_idx, ID] neurite_idx = structure_block[:, TYPE] != POINT_TYPE.SOMA neurite_rows = structure_block[neurite_idx, :] soma_end_pts...
python
def _section_end_points(structure_block, id_map): '''Get the section end-points''' soma_idx = structure_block[:, TYPE] == POINT_TYPE.SOMA soma_ids = structure_block[soma_idx, ID] neurite_idx = structure_block[:, TYPE] != POINT_TYPE.SOMA neurite_rows = structure_block[neurite_idx, :] soma_end_pts...
[ "def", "_section_end_points", "(", "structure_block", ",", "id_map", ")", ":", "soma_idx", "=", "structure_block", "[", ":", ",", "TYPE", "]", "==", "POINT_TYPE", ".", "SOMA", "soma_ids", "=", "structure_block", "[", "soma_idx", ",", "ID", "]", "neurite_idx", ...
Get the section end-points
[ "Get", "the", "section", "end", "-", "points" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L103-L120
BlueBrain/NeuroM
neurom/io/datawrapper.py
_extract_sections
def _extract_sections(data_block): '''Make a list of sections from an SWC-style data wrapper block''' structure_block = data_block[:, COLS.TYPE:COLS.COL_COUNT].astype(np.int) # SWC ID -> structure_block position id_map = {-1: -1} for i, row in enumerate(structure_block): id_map[row[ID]] = i...
python
def _extract_sections(data_block): '''Make a list of sections from an SWC-style data wrapper block''' structure_block = data_block[:, COLS.TYPE:COLS.COL_COUNT].astype(np.int) # SWC ID -> structure_block position id_map = {-1: -1} for i, row in enumerate(structure_block): id_map[row[ID]] = i...
[ "def", "_extract_sections", "(", "data_block", ")", ":", "structure_block", "=", "data_block", "[", ":", ",", "COLS", ".", "TYPE", ":", "COLS", ".", "COL_COUNT", "]", ".", "astype", "(", "np", ".", "int", ")", "# SWC ID -> structure_block position", "id_map", ...
Make a list of sections from an SWC-style data wrapper block
[ "Make", "a", "list", "of", "sections", "from", "an", "SWC", "-", "style", "data", "wrapper", "block" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L142-L210
BlueBrain/NeuroM
neurom/io/datawrapper.py
DataWrapper.neurite_root_section_ids
def neurite_root_section_ids(self): '''Get the section IDs of the intitial neurite sections''' sec = self.sections return [i for i, ss in enumerate(sec) if ss.pid > -1 and (sec[ss.pid].ntype == POINT_TYPE.SOMA and ss.ntype != POINT_TYPE.SOMA)]
python
def neurite_root_section_ids(self): '''Get the section IDs of the intitial neurite sections''' sec = self.sections return [i for i, ss in enumerate(sec) if ss.pid > -1 and (sec[ss.pid].ntype == POINT_TYPE.SOMA and ss.ntype != POINT_TYPE.SOMA)]
[ "def", "neurite_root_section_ids", "(", "self", ")", ":", "sec", "=", "self", ".", "sections", "return", "[", "i", "for", "i", ",", "ss", "in", "enumerate", "(", "sec", ")", "if", "ss", ".", "pid", ">", "-", "1", "and", "(", "sec", "[", "ss", "."...
Get the section IDs of the intitial neurite sections
[ "Get", "the", "section", "IDs", "of", "the", "intitial", "neurite", "sections" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L76-L81
BlueBrain/NeuroM
neurom/io/datawrapper.py
DataWrapper.soma_points
def soma_points(self): '''Get the soma points''' db = self.data_block return db[db[:, COLS.TYPE] == POINT_TYPE.SOMA]
python
def soma_points(self): '''Get the soma points''' db = self.data_block return db[db[:, COLS.TYPE] == POINT_TYPE.SOMA]
[ "def", "soma_points", "(", "self", ")", ":", "db", "=", "self", ".", "data_block", "return", "db", "[", "db", "[", ":", ",", "COLS", ".", "TYPE", "]", "==", "POINT_TYPE", ".", "SOMA", "]" ]
Get the soma points
[ "Get", "the", "soma", "points" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L83-L86
BlueBrain/NeuroM
neurom/io/datawrapper.py
BlockNeuronBuilder.add_section
def add_section(self, id_, parent_id, section_type, points): '''add a section Args: id_(int): identifying number of the section parent_id(int): identifying number of the parent of this section section_type(int): the section type as defined by POINT_TYPE p...
python
def add_section(self, id_, parent_id, section_type, points): '''add a section Args: id_(int): identifying number of the section parent_id(int): identifying number of the parent of this section section_type(int): the section type as defined by POINT_TYPE p...
[ "def", "add_section", "(", "self", ",", "id_", ",", "parent_id", ",", "section_type", ",", "points", ")", ":", "# L.debug('Adding section %d, with parent %d, of type: %d with count: %d',", "# id_, parent_id, section_type, len(points))", "assert", "id_", "not", "in", "...
add a section Args: id_(int): identifying number of the section parent_id(int): identifying number of the parent of this section section_type(int): the section type as defined by POINT_TYPE points is an array of [X, Y, Z, R]
[ "add", "a", "section" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L234-L246
BlueBrain/NeuroM
neurom/io/datawrapper.py
BlockNeuronBuilder._make_datablock
def _make_datablock(self): '''Make a data_block and sections list as required by DataWrapper''' section_ids = sorted(self.sections) # create all insertion id's, this needs to be done ahead of time # as some of the children may have a lower id than their parents id_to_insert_id =...
python
def _make_datablock(self): '''Make a data_block and sections list as required by DataWrapper''' section_ids = sorted(self.sections) # create all insertion id's, this needs to be done ahead of time # as some of the children may have a lower id than their parents id_to_insert_id =...
[ "def", "_make_datablock", "(", "self", ")", ":", "section_ids", "=", "sorted", "(", "self", ".", "sections", ")", "# create all insertion id's, this needs to be done ahead of time", "# as some of the children may have a lower id than their parents", "id_to_insert_id", "=", "{", ...
Make a data_block and sections list as required by DataWrapper
[ "Make", "a", "data_block", "and", "sections", "list", "as", "required", "by", "DataWrapper" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L248-L277
BlueBrain/NeuroM
neurom/io/datawrapper.py
BlockNeuronBuilder._check_consistency
def _check_consistency(self): '''see if the sections have obvious errors''' type_count = defaultdict(int) for _, section in sorted(self.sections.items()): type_count[section.section_type] += 1 if type_count[POINT_TYPE.SOMA] != 1: L.info('Have %d somas, expected 1...
python
def _check_consistency(self): '''see if the sections have obvious errors''' type_count = defaultdict(int) for _, section in sorted(self.sections.items()): type_count[section.section_type] += 1 if type_count[POINT_TYPE.SOMA] != 1: L.info('Have %d somas, expected 1...
[ "def", "_check_consistency", "(", "self", ")", ":", "type_count", "=", "defaultdict", "(", "int", ")", "for", "_", ",", "section", "in", "sorted", "(", "self", ".", "sections", ".", "items", "(", ")", ")", ":", "type_count", "[", "section", ".", "secti...
see if the sections have obvious errors
[ "see", "if", "the", "sections", "have", "obvious", "errors" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L279-L286
BlueBrain/NeuroM
neurom/io/datawrapper.py
BlockNeuronBuilder.get_datawrapper
def get_datawrapper(self, file_format='BlockNeuronBuilder', data_wrapper=DataWrapper): '''returns a DataWrapper''' self._check_consistency() datablock, sections = self._make_datablock() return data_wrapper(datablock, file_format, sections)
python
def get_datawrapper(self, file_format='BlockNeuronBuilder', data_wrapper=DataWrapper): '''returns a DataWrapper''' self._check_consistency() datablock, sections = self._make_datablock() return data_wrapper(datablock, file_format, sections)
[ "def", "get_datawrapper", "(", "self", ",", "file_format", "=", "'BlockNeuronBuilder'", ",", "data_wrapper", "=", "DataWrapper", ")", ":", "self", ".", "_check_consistency", "(", ")", "datablock", ",", "sections", "=", "self", ".", "_make_datablock", "(", ")", ...
returns a DataWrapper
[ "returns", "a", "DataWrapper" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L288-L292
BlueBrain/NeuroM
neurom/io/utils.py
_is_morphology_file
def _is_morphology_file(filepath): """ Check if `filepath` is a file with one of morphology file extensions. """ return ( os.path.isfile(filepath) and os.path.splitext(filepath)[1].lower() in ('.swc', '.h5', '.asc') )
python
def _is_morphology_file(filepath): """ Check if `filepath` is a file with one of morphology file extensions. """ return ( os.path.isfile(filepath) and os.path.splitext(filepath)[1].lower() in ('.swc', '.h5', '.asc') )
[ "def", "_is_morphology_file", "(", "filepath", ")", ":", "return", "(", "os", ".", "path", ".", "isfile", "(", "filepath", ")", "and", "os", ".", "path", ".", "splitext", "(", "filepath", ")", "[", "1", "]", ".", "lower", "(", ")", "in", "(", "'.sw...
Check if `filepath` is a file with one of morphology file extensions.
[ "Check", "if", "filepath", "is", "a", "file", "with", "one", "of", "morphology", "file", "extensions", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L50-L55
BlueBrain/NeuroM
neurom/io/utils.py
get_morph_files
def get_morph_files(directory): '''Get a list of all morphology files in a directory Returns: list with all files with extensions '.swc' , 'h5' or '.asc' (case insensitive) ''' lsdir = (os.path.join(directory, m) for m in os.listdir(directory)) return list(filter(_is_morphology_file, lsdir)...
python
def get_morph_files(directory): '''Get a list of all morphology files in a directory Returns: list with all files with extensions '.swc' , 'h5' or '.asc' (case insensitive) ''' lsdir = (os.path.join(directory, m) for m in os.listdir(directory)) return list(filter(_is_morphology_file, lsdir)...
[ "def", "get_morph_files", "(", "directory", ")", ":", "lsdir", "=", "(", "os", ".", "path", ".", "join", "(", "directory", ",", "m", ")", "for", "m", "in", "os", ".", "listdir", "(", "directory", ")", ")", "return", "list", "(", "filter", "(", "_is...
Get a list of all morphology files in a directory Returns: list with all files with extensions '.swc' , 'h5' or '.asc' (case insensitive)
[ "Get", "a", "list", "of", "all", "morphology", "files", "in", "a", "directory" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L92-L99
BlueBrain/NeuroM
neurom/io/utils.py
get_files_by_path
def get_files_by_path(path): '''Get a file or set of files from a file path Return list of files with path ''' if os.path.isfile(path): return [path] if os.path.isdir(path): return get_morph_files(path) raise IOError('Invalid data path %s' % path)
python
def get_files_by_path(path): '''Get a file or set of files from a file path Return list of files with path ''' if os.path.isfile(path): return [path] if os.path.isdir(path): return get_morph_files(path) raise IOError('Invalid data path %s' % path)
[ "def", "get_files_by_path", "(", "path", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "return", "[", "path", "]", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "return", "get_morph_files", "(", "path", ")...
Get a file or set of files from a file path Return list of files with path
[ "Get", "a", "file", "or", "set", "of", "files", "from", "a", "file", "path" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L102-L112
BlueBrain/NeuroM
neurom/io/utils.py
load_neuron
def load_neuron(handle, reader=None): '''Build section trees from an h5 or swc file''' rdw = load_data(handle, reader) if isinstance(handle, StringType): name = os.path.splitext(os.path.basename(handle))[0] else: name = None return FstNeuron(rdw, name)
python
def load_neuron(handle, reader=None): '''Build section trees from an h5 or swc file''' rdw = load_data(handle, reader) if isinstance(handle, StringType): name = os.path.splitext(os.path.basename(handle))[0] else: name = None return FstNeuron(rdw, name)
[ "def", "load_neuron", "(", "handle", ",", "reader", "=", "None", ")", ":", "rdw", "=", "load_data", "(", "handle", ",", "reader", ")", "if", "isinstance", "(", "handle", ",", "StringType", ")", ":", "name", "=", "os", ".", "path", ".", "splitext", "(...
Build section trees from an h5 or swc file
[ "Build", "section", "trees", "from", "an", "h5", "or", "swc", "file" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L115-L122
BlueBrain/NeuroM
neurom/io/utils.py
load_neurons
def load_neurons(neurons, neuron_loader=load_neuron, name=None, population_class=Population, ignored_exceptions=()): '''Create a population object from all morphologies in a directory\ of from morphologies in a list of file names Param...
python
def load_neurons(neurons, neuron_loader=load_neuron, name=None, population_class=Population, ignored_exceptions=()): '''Create a population object from all morphologies in a directory\ of from morphologies in a list of file names Param...
[ "def", "load_neurons", "(", "neurons", ",", "neuron_loader", "=", "load_neuron", ",", "name", "=", "None", ",", "population_class", "=", "Population", ",", "ignored_exceptions", "=", "(", ")", ")", ":", "if", "isinstance", "(", "neurons", ",", "(", "list", ...
Create a population object from all morphologies in a directory\ of from morphologies in a list of file names Parameters: neurons: directory path or list of neuron file paths neuron_loader: function taking a filename and returning a neuron population_class: class representing popula...
[ "Create", "a", "population", "object", "from", "all", "morphologies", "in", "a", "directory", "\\", "of", "from", "morphologies", "in", "a", "list", "of", "file", "names" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L125-L164
BlueBrain/NeuroM
neurom/io/utils.py
_get_file
def _get_file(handle): '''Returns the filename of the file to read If handle is a stream, a temp file is written on disk first and its filename is returned''' if not isinstance(handle, IOBase): return handle fd, temp_file = tempfile.mkstemp(str(uuid.uuid4()), prefix='neurom-') os.close...
python
def _get_file(handle): '''Returns the filename of the file to read If handle is a stream, a temp file is written on disk first and its filename is returned''' if not isinstance(handle, IOBase): return handle fd, temp_file = tempfile.mkstemp(str(uuid.uuid4()), prefix='neurom-') os.close...
[ "def", "_get_file", "(", "handle", ")", ":", "if", "not", "isinstance", "(", "handle", ",", "IOBase", ")", ":", "return", "handle", "fd", ",", "temp_file", "=", "tempfile", ".", "mkstemp", "(", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", ",", ...
Returns the filename of the file to read If handle is a stream, a temp file is written on disk first and its filename is returned
[ "Returns", "the", "filename", "of", "the", "file", "to", "read" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L167-L180
BlueBrain/NeuroM
neurom/io/utils.py
load_data
def load_data(handle, reader=None): '''Unpack data into a raw data wrapper''' if not reader: reader = os.path.splitext(handle)[1][1:].lower() if reader not in _READERS: raise NeuroMError('Do not have a loader for "%s" extension' % reader) filename = _get_file(handle) try: r...
python
def load_data(handle, reader=None): '''Unpack data into a raw data wrapper''' if not reader: reader = os.path.splitext(handle)[1][1:].lower() if reader not in _READERS: raise NeuroMError('Do not have a loader for "%s" extension' % reader) filename = _get_file(handle) try: r...
[ "def", "load_data", "(", "handle", ",", "reader", "=", "None", ")", ":", "if", "not", "reader", ":", "reader", "=", "os", ".", "path", ".", "splitext", "(", "handle", ")", "[", "1", "]", "[", "1", ":", "]", ".", "lower", "(", ")", "if", "reader...
Unpack data into a raw data wrapper
[ "Unpack", "data", "into", "a", "raw", "data", "wrapper" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L183-L196
BlueBrain/NeuroM
neurom/io/utils.py
_load_h5
def _load_h5(filename): '''Delay loading of h5py until it is needed''' from neurom.io import hdf5 return hdf5.read(filename, remove_duplicates=False, data_wrapper=DataWrapper)
python
def _load_h5(filename): '''Delay loading of h5py until it is needed''' from neurom.io import hdf5 return hdf5.read(filename, remove_duplicates=False, data_wrapper=DataWrapper)
[ "def", "_load_h5", "(", "filename", ")", ":", "from", "neurom", ".", "io", "import", "hdf5", "return", "hdf5", ".", "read", "(", "filename", ",", "remove_duplicates", "=", "False", ",", "data_wrapper", "=", "DataWrapper", ")" ]
Delay loading of h5py until it is needed
[ "Delay", "loading", "of", "h5py", "until", "it", "is", "needed" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L199-L204
BlueBrain/NeuroM
neurom/io/utils.py
NeuronLoader._filepath
def _filepath(self, name): """ File path to `name` morphology file. """ if self.file_ext is None: candidates = glob.glob(os.path.join(self.directory, name + ".*")) try: return next(filter(_is_morphology_file, candidates)) except StopIteration: ...
python
def _filepath(self, name): """ File path to `name` morphology file. """ if self.file_ext is None: candidates = glob.glob(os.path.join(self.directory, name + ".*")) try: return next(filter(_is_morphology_file, candidates)) except StopIteration: ...
[ "def", "_filepath", "(", "self", ",", "name", ")", ":", "if", "self", ".", "file_ext", "is", "None", ":", "candidates", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "self", ".", "directory", ",", "name", "+", "\".*\"", ")", ...
File path to `name` morphology file.
[ "File", "path", "to", "name", "morphology", "file", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L75-L84
BlueBrain/NeuroM
neurom/viewer.py
draw
def draw(obj, mode='2d', **kwargs): '''Draw a morphology object Parameters: obj: morphology object to be drawn (neuron, tree, soma). mode (Optional[str]): drawing mode ('2d', '3d', 'dendrogram'). Defaults to '2d'. **kwargs: keyword arguments for underlying neurom.view.view functions. ...
python
def draw(obj, mode='2d', **kwargs): '''Draw a morphology object Parameters: obj: morphology object to be drawn (neuron, tree, soma). mode (Optional[str]): drawing mode ('2d', '3d', 'dendrogram'). Defaults to '2d'. **kwargs: keyword arguments for underlying neurom.view.view functions. ...
[ "def", "draw", "(", "obj", ",", "mode", "=", "'2d'", ",", "*", "*", "kwargs", ")", ":", "if", "mode", "not", "in", "MODES", ":", "raise", "InvalidDrawModeError", "(", "'Invalid drawing mode %s'", "%", "mode", ")", "if", "mode", "in", "(", "'2d'", ",", ...
Draw a morphology object Parameters: obj: morphology object to be drawn (neuron, tree, soma). mode (Optional[str]): drawing mode ('2d', '3d', 'dendrogram'). Defaults to '2d'. **kwargs: keyword arguments for underlying neurom.view.view functions. Raises: InvalidDrawModeError if ...
[ "Draw", "a", "morphology", "object" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/viewer.py#L77-L134
BlueBrain/NeuroM
examples/histogram.py
histogram
def histogram(neurons, feature, new_fig=True, subplot=False, normed=False, **kwargs): ''' Plot a histogram of the selected feature for the population of neurons. Plots x-axis versus y-axis on a scatter|histogram|binned values plot. More information about the plot and how it works. Parameters : ...
python
def histogram(neurons, feature, new_fig=True, subplot=False, normed=False, **kwargs): ''' Plot a histogram of the selected feature for the population of neurons. Plots x-axis versus y-axis on a scatter|histogram|binned values plot. More information about the plot and how it works. Parameters : ...
[ "def", "histogram", "(", "neurons", ",", "feature", ",", "new_fig", "=", "True", ",", "subplot", "=", "False", ",", "normed", "=", "False", ",", "*", "*", "kwargs", ")", ":", "bins", "=", "kwargs", ".", "get", "(", "'bins'", ",", "25", ")", "cumula...
Plot a histogram of the selected feature for the population of neurons. Plots x-axis versus y-axis on a scatter|histogram|binned values plot. More information about the plot and how it works. Parameters : neurons : list List of Neurons. Single neurons must be encapsulated in a list. ...
[ "Plot", "a", "histogram", "of", "the", "selected", "feature", "for", "the", "population", "of", "neurons", ".", "Plots", "x", "-", "axis", "versus", "y", "-", "axis", "on", "a", "scatter|histogram|binned", "values", "plot", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/histogram.py#L38-L93
BlueBrain/NeuroM
examples/histogram.py
population_feature_values
def population_feature_values(pops, feature): '''Extracts feature values per population ''' pops_feature_values = [] for pop in pops: feature_values = [getattr(neu, 'get_' + feature)() for neu in pop.neurons] # ugly hack to chain in case of list of lists if any([isinstance(p, ...
python
def population_feature_values(pops, feature): '''Extracts feature values per population ''' pops_feature_values = [] for pop in pops: feature_values = [getattr(neu, 'get_' + feature)() for neu in pop.neurons] # ugly hack to chain in case of list of lists if any([isinstance(p, ...
[ "def", "population_feature_values", "(", "pops", ",", "feature", ")", ":", "pops_feature_values", "=", "[", "]", "for", "pop", "in", "pops", ":", "feature_values", "=", "[", "getattr", "(", "neu", ",", "'get_'", "+", "feature", ")", "(", ")", "for", "neu...
Extracts feature values per population
[ "Extracts", "feature", "values", "per", "population" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/histogram.py#L96-L112
BlueBrain/NeuroM
examples/histogram.py
population_histogram
def population_histogram(pops, feature, new_fig=True, normed=False, subplot=False, **kwargs): ''' Plot a histogram of the selected feature for the population of neurons. Plots x-axis versus y-axis on a scatter|histogram|binned values plot. More information about the plot and how it works. Paramete...
python
def population_histogram(pops, feature, new_fig=True, normed=False, subplot=False, **kwargs): ''' Plot a histogram of the selected feature for the population of neurons. Plots x-axis versus y-axis on a scatter|histogram|binned values plot. More information about the plot and how it works. Paramete...
[ "def", "population_histogram", "(", "pops", ",", "feature", ",", "new_fig", "=", "True", ",", "normed", "=", "False", ",", "subplot", "=", "False", ",", "*", "*", "kwargs", ")", ":", "bins", "=", "kwargs", ".", "get", "(", "'bins'", ",", "25", ")", ...
Plot a histogram of the selected feature for the population of neurons. Plots x-axis versus y-axis on a scatter|histogram|binned values plot. More information about the plot and how it works. Parameters : populations : populations list feature : str The feature of interest. ...
[ "Plot", "a", "histogram", "of", "the", "selected", "feature", "for", "the", "population", "of", "neurons", ".", "Plots", "x", "-", "axis", "versus", "y", "-", "axis", "on", "a", "scatter|histogram|binned", "values", "plot", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/histogram.py#L115-L169
BlueBrain/NeuroM
examples/section_ids.py
get_segment
def get_segment(neuron, section_id, segment_id): '''Get a segment given a section and segment id Returns: array of two [x, y, z, r] points defining segment ''' sec = neuron.sections[section_id] return sec.points[segment_id:segment_id + 2][:, COLS.XYZR]
python
def get_segment(neuron, section_id, segment_id): '''Get a segment given a section and segment id Returns: array of two [x, y, z, r] points defining segment ''' sec = neuron.sections[section_id] return sec.points[segment_id:segment_id + 2][:, COLS.XYZR]
[ "def", "get_segment", "(", "neuron", ",", "section_id", ",", "segment_id", ")", ":", "sec", "=", "neuron", ".", "sections", "[", "section_id", "]", "return", "sec", ".", "points", "[", "segment_id", ":", "segment_id", "+", "2", "]", "[", ":", ",", "COL...
Get a segment given a section and segment id Returns: array of two [x, y, z, r] points defining segment
[ "Get", "a", "segment", "given", "a", "section", "and", "segment", "id" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/section_ids.py#L37-L44
BlueBrain/NeuroM
examples/extract_distribution.py
extract_data
def extract_data(data_path, feature): '''Loads a list of neurons, extracts feature and transforms the fitted distribution in the correct format. Returns the optimal distribution, corresponding parameters, minimun and maximum values. ''' population = nm.load_neurons(data_path) featu...
python
def extract_data(data_path, feature): '''Loads a list of neurons, extracts feature and transforms the fitted distribution in the correct format. Returns the optimal distribution, corresponding parameters, minimun and maximum values. ''' population = nm.load_neurons(data_path) featu...
[ "def", "extract_data", "(", "data_path", ",", "feature", ")", ":", "population", "=", "nm", ".", "load_neurons", "(", "data_path", ")", "feature_data", "=", "[", "nm", ".", "get", "(", "feature", ",", "n", ")", "for", "n", "in", "population", "]", "fea...
Loads a list of neurons, extracts feature and transforms the fitted distribution in the correct format. Returns the optimal distribution, corresponding parameters, minimun and maximum values.
[ "Loads", "a", "list", "of", "neurons", "extracts", "feature", "and", "transforms", "the", "fitted", "distribution", "in", "the", "correct", "format", ".", "Returns", "the", "optimal", "distribution", "corresponding", "parameters", "minimun", "and", "maximum", "val...
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/extract_distribution.py#L59-L70
BlueBrain/NeuroM
neurom/fst/_bifurcationfunc.py
local_bifurcation_angle
def local_bifurcation_angle(bif_point): '''Return the opening angle between two out-going sections in a bifurcation point We first ensure that the input point has only two children. The bifurcation angle is defined as the angle between the first non-zero length segments of a bifurcation point. ...
python
def local_bifurcation_angle(bif_point): '''Return the opening angle between two out-going sections in a bifurcation point We first ensure that the input point has only two children. The bifurcation angle is defined as the angle between the first non-zero length segments of a bifurcation point. ...
[ "def", "local_bifurcation_angle", "(", "bif_point", ")", ":", "def", "skip_0_length", "(", "sec", ")", ":", "'''Return the first point with non-zero distance to first point'''", "p0", "=", "sec", "[", "0", "]", "cur", "=", "sec", "[", "1", "]", "for", "i", ",", ...
Return the opening angle between two out-going sections in a bifurcation point We first ensure that the input point has only two children. The bifurcation angle is defined as the angle between the first non-zero length segments of a bifurcation point.
[ "Return", "the", "opening", "angle", "between", "two", "out", "-", "going", "sections", "in", "a", "bifurcation", "point" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_bifurcationfunc.py#L36-L61
BlueBrain/NeuroM
neurom/fst/_bifurcationfunc.py
remote_bifurcation_angle
def remote_bifurcation_angle(bif_point): '''Return the opening angle between two out-going sections in a bifurcation point We first ensure that the input point has only two children. The angle is defined as between the bifurcation point and the last points in the out-going sections. ''' as...
python
def remote_bifurcation_angle(bif_point): '''Return the opening angle between two out-going sections in a bifurcation point We first ensure that the input point has only two children. The angle is defined as between the bifurcation point and the last points in the out-going sections. ''' as...
[ "def", "remote_bifurcation_angle", "(", "bif_point", ")", ":", "assert", "len", "(", "bif_point", ".", "children", ")", "==", "2", ",", "'A bifurcation point must have exactly 2 children'", "return", "morphmath", ".", "angle_3points", "(", "bif_point", ".", "points", ...
Return the opening angle between two out-going sections in a bifurcation point We first ensure that the input point has only two children. The angle is defined as between the bifurcation point and the last points in the out-going sections.
[ "Return", "the", "opening", "angle", "between", "two", "out", "-", "going", "sections", "in", "a", "bifurcation", "point" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_bifurcationfunc.py#L64-L77
BlueBrain/NeuroM
neurom/fst/_bifurcationfunc.py
bifurcation_partition
def bifurcation_partition(bif_point): '''Calculate the partition at a bifurcation point We first ensure that the input point has only two children. The number of nodes in each child tree is counted. The partition is defined as the ratio of the largest number to the smallest number.''' assert len(b...
python
def bifurcation_partition(bif_point): '''Calculate the partition at a bifurcation point We first ensure that the input point has only two children. The number of nodes in each child tree is counted. The partition is defined as the ratio of the largest number to the smallest number.''' assert len(b...
[ "def", "bifurcation_partition", "(", "bif_point", ")", ":", "assert", "len", "(", "bif_point", ".", "children", ")", "==", "2", ",", "'A bifurcation point must have exactly 2 children'", "n", "=", "float", "(", "sum", "(", "1", "for", "_", "in", "bif_point", "...
Calculate the partition at a bifurcation point We first ensure that the input point has only two children. The number of nodes in each child tree is counted. The partition is defined as the ratio of the largest number to the smallest number.
[ "Calculate", "the", "partition", "at", "a", "bifurcation", "point" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_bifurcationfunc.py#L80-L91
BlueBrain/NeuroM
neurom/fst/_bifurcationfunc.py
partition_asymmetry
def partition_asymmetry(bif_point): '''Calculate the partition asymmetry at a bifurcation point as defined in https://www.ncbi.nlm.nih.gov/pubmed/18568015 The number of nodes in each child tree is counted. The partition is defined as the ratio of the absolute difference and the sum of the number of...
python
def partition_asymmetry(bif_point): '''Calculate the partition asymmetry at a bifurcation point as defined in https://www.ncbi.nlm.nih.gov/pubmed/18568015 The number of nodes in each child tree is counted. The partition is defined as the ratio of the absolute difference and the sum of the number of...
[ "def", "partition_asymmetry", "(", "bif_point", ")", ":", "assert", "len", "(", "bif_point", ".", "children", ")", "==", "2", ",", "'A bifurcation point must have exactly 2 children'", "n", "=", "float", "(", "sum", "(", "1", "for", "_", "in", "bif_point", "."...
Calculate the partition asymmetry at a bifurcation point as defined in https://www.ncbi.nlm.nih.gov/pubmed/18568015 The number of nodes in each child tree is counted. The partition is defined as the ratio of the absolute difference and the sum of the number of bifurcations in the two daughter subtrees ...
[ "Calculate", "the", "partition", "asymmetry", "at", "a", "bifurcation", "point", "as", "defined", "in", "https", ":", "//", "www", ".", "ncbi", ".", "nlm", ".", "nih", ".", "gov", "/", "pubmed", "/", "18568015" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_bifurcationfunc.py#L94-L107
BlueBrain/NeuroM
neurom/fst/_bifurcationfunc.py
partition_pair
def partition_pair(bif_point): '''Calculate the partition pairs at a bifurcation point The number of nodes in each child tree is counted. The partition pairs is the number of bifurcations in the two daughter subtrees at each branch point.''' n = float(sum(1 for _ in bif_point.children[0].ipreorder(...
python
def partition_pair(bif_point): '''Calculate the partition pairs at a bifurcation point The number of nodes in each child tree is counted. The partition pairs is the number of bifurcations in the two daughter subtrees at each branch point.''' n = float(sum(1 for _ in bif_point.children[0].ipreorder(...
[ "def", "partition_pair", "(", "bif_point", ")", ":", "n", "=", "float", "(", "sum", "(", "1", "for", "_", "in", "bif_point", ".", "children", "[", "0", "]", ".", "ipreorder", "(", ")", ")", ")", "m", "=", "float", "(", "sum", "(", "1", "for", "...
Calculate the partition pairs at a bifurcation point The number of nodes in each child tree is counted. The partition pairs is the number of bifurcations in the two daughter subtrees at each branch point.
[ "Calculate", "the", "partition", "pairs", "at", "a", "bifurcation", "point" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_bifurcationfunc.py#L110-L118
BlueBrain/NeuroM
neurom/io/neurolucida.py
_match_section
def _match_section(section, match): '''checks whether the `type` of section is in the `match` dictionary Works around the unknown ordering of s-expressions in each section. For instance, the `type` is the 3-rd one in for CellBodies ("CellBody" (Color Yellow) (CellBody) (S...
python
def _match_section(section, match): '''checks whether the `type` of section is in the `match` dictionary Works around the unknown ordering of s-expressions in each section. For instance, the `type` is the 3-rd one in for CellBodies ("CellBody" (Color Yellow) (CellBody) (S...
[ "def", "_match_section", "(", "section", ",", "match", ")", ":", "# TODO: rewrite this so it is more clear, and handles sets & dictionaries for matching", "for", "i", "in", "range", "(", "5", ")", ":", "if", "i", ">=", "len", "(", "section", ")", ":", "return", "N...
checks whether the `type` of section is in the `match` dictionary Works around the unknown ordering of s-expressions in each section. For instance, the `type` is the 3-rd one in for CellBodies ("CellBody" (Color Yellow) (CellBody) (Set "cell10") ) Returns: ...
[ "checks", "whether", "the", "type", "of", "section", "is", "in", "the", "match", "dictionary" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L64-L84
BlueBrain/NeuroM
neurom/io/neurolucida.py
_get_tokens
def _get_tokens(morph_fd): '''split a file-like into tokens: split on whitespace Note: this also strips newlines and comments ''' for line in morph_fd: line = line.rstrip() # remove \r\n line = line.split(';', 1)[0] # strip comments squash_token = [] # quoted strings get squ...
python
def _get_tokens(morph_fd): '''split a file-like into tokens: split on whitespace Note: this also strips newlines and comments ''' for line in morph_fd: line = line.rstrip() # remove \r\n line = line.split(';', 1)[0] # strip comments squash_token = [] # quoted strings get squ...
[ "def", "_get_tokens", "(", "morph_fd", ")", ":", "for", "line", "in", "morph_fd", ":", "line", "=", "line", ".", "rstrip", "(", ")", "# remove \\r\\n", "line", "=", "line", ".", "split", "(", "';'", ",", "1", ")", "[", "0", "]", "# strip comments", "...
split a file-like into tokens: split on whitespace Note: this also strips newlines and comments
[ "split", "a", "file", "-", "like", "into", "tokens", ":", "split", "on", "whitespace" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L87-L111
BlueBrain/NeuroM
neurom/io/neurolucida.py
_parse_section
def _parse_section(token_iter): '''take a stream of tokens, and create the tree structure that is defined by the s-expressions ''' sexp = [] for token in token_iter: if token == '(': new_sexp = _parse_section(token_iter) if not _match_section(new_sexp, UNWANTED_SECTIO...
python
def _parse_section(token_iter): '''take a stream of tokens, and create the tree structure that is defined by the s-expressions ''' sexp = [] for token in token_iter: if token == '(': new_sexp = _parse_section(token_iter) if not _match_section(new_sexp, UNWANTED_SECTIO...
[ "def", "_parse_section", "(", "token_iter", ")", ":", "sexp", "=", "[", "]", "for", "token", "in", "token_iter", ":", "if", "token", "==", "'('", ":", "new_sexp", "=", "_parse_section", "(", "token_iter", ")", "if", "not", "_match_section", "(", "new_sexp"...
take a stream of tokens, and create the tree structure that is defined by the s-expressions
[ "take", "a", "stream", "of", "tokens", "and", "create", "the", "tree", "structure", "that", "is", "defined", "by", "the", "s", "-", "expressions" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L114-L128
BlueBrain/NeuroM
neurom/io/neurolucida.py
_parse_sections
def _parse_sections(morph_fd): '''returns array of all the sections that exist The format is nested lists that correspond to the s-expressions ''' sections = [] token_iter = _get_tokens(morph_fd) for token in token_iter: if token == '(': # find top-level sections section = ...
python
def _parse_sections(morph_fd): '''returns array of all the sections that exist The format is nested lists that correspond to the s-expressions ''' sections = [] token_iter = _get_tokens(morph_fd) for token in token_iter: if token == '(': # find top-level sections section = ...
[ "def", "_parse_sections", "(", "morph_fd", ")", ":", "sections", "=", "[", "]", "token_iter", "=", "_get_tokens", "(", "morph_fd", ")", "for", "token", "in", "token_iter", ":", "if", "token", "==", "'('", ":", "# find top-level sections", "section", "=", "_p...
returns array of all the sections that exist The format is nested lists that correspond to the s-expressions
[ "returns", "array", "of", "all", "the", "sections", "that", "exist" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L131-L143
BlueBrain/NeuroM
neurom/io/neurolucida.py
_flatten_subsection
def _flatten_subsection(subsection, _type, offset, parent): '''Flatten a subsection from its nested version Args: subsection: Nested subsection as produced by _parse_section, except one level in _type: type of section, ie: AXON, etc parent: first element has this as it's parent ...
python
def _flatten_subsection(subsection, _type, offset, parent): '''Flatten a subsection from its nested version Args: subsection: Nested subsection as produced by _parse_section, except one level in _type: type of section, ie: AXON, etc parent: first element has this as it's parent ...
[ "def", "_flatten_subsection", "(", "subsection", ",", "_type", ",", "offset", ",", "parent", ")", ":", "for", "row", "in", "subsection", ":", "# TODO: Figure out what these correspond to in neurolucida", "if", "row", "in", "(", "'Low'", ",", "'Generated'", ",", "'...
Flatten a subsection from its nested version Args: subsection: Nested subsection as produced by _parse_section, except one level in _type: type of section, ie: AXON, etc parent: first element has this as it's parent offset: position in the final array of the first element Retur...
[ "Flatten", "a", "subsection", "from", "its", "nested", "version" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L146-L187
BlueBrain/NeuroM
neurom/io/neurolucida.py
_extract_section
def _extract_section(section): '''Find top level sections, and get their flat contents, and append them all Returns a numpy array with the row format: [X, Y, Z, R, TYPE, ID, PARENT_ID] Note: PARENT_ID starts at -1 for soma and 0 for neurites ''' # sections with only one element will be ski...
python
def _extract_section(section): '''Find top level sections, and get their flat contents, and append them all Returns a numpy array with the row format: [X, Y, Z, R, TYPE, ID, PARENT_ID] Note: PARENT_ID starts at -1 for soma and 0 for neurites ''' # sections with only one element will be ski...
[ "def", "_extract_section", "(", "section", ")", ":", "# sections with only one element will be skipped,", "if", "len", "(", "section", ")", "==", "1", ":", "assert", "section", "[", "0", "]", "==", "'Sections'", ",", "(", "'Only known usage of a single Section content...
Find top level sections, and get their flat contents, and append them all Returns a numpy array with the row format: [X, Y, Z, R, TYPE, ID, PARENT_ID] Note: PARENT_ID starts at -1 for soma and 0 for neurites
[ "Find", "top", "level", "sections", "and", "get", "their", "flat", "contents", "and", "append", "them", "all" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L190-L222
BlueBrain/NeuroM
neurom/io/neurolucida.py
_sections_to_raw_data
def _sections_to_raw_data(sections): '''convert list of sections into the `raw_data` format used in neurom This finds the soma, and attaches the neurites ''' soma = None neurites = [] for section in sections: neurite = _extract_section(section) if neurite is None: co...
python
def _sections_to_raw_data(sections): '''convert list of sections into the `raw_data` format used in neurom This finds the soma, and attaches the neurites ''' soma = None neurites = [] for section in sections: neurite = _extract_section(section) if neurite is None: co...
[ "def", "_sections_to_raw_data", "(", "sections", ")", ":", "soma", "=", "None", "neurites", "=", "[", "]", "for", "section", "in", "sections", ":", "neurite", "=", "_extract_section", "(", "section", ")", "if", "neurite", "is", "None", ":", "continue", "el...
convert list of sections into the `raw_data` format used in neurom This finds the soma, and attaches the neurites
[ "convert", "list", "of", "sections", "into", "the", "raw_data", "format", "used", "in", "neurom" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L225-L257
BlueBrain/NeuroM
neurom/io/neurolucida.py
read
def read(morph_file, data_wrapper=DataWrapper): '''return a 'raw_data' np.array with the full neuron, and the format of the file suitable to be wrapped by DataWrapper ''' msg = ('This is an experimental reader. ' 'There are no guarantees regarding ability to parse ' 'Neurolucida ....
python
def read(morph_file, data_wrapper=DataWrapper): '''return a 'raw_data' np.array with the full neuron, and the format of the file suitable to be wrapped by DataWrapper ''' msg = ('This is an experimental reader. ' 'There are no guarantees regarding ability to parse ' 'Neurolucida ....
[ "def", "read", "(", "morph_file", ",", "data_wrapper", "=", "DataWrapper", ")", ":", "msg", "=", "(", "'This is an experimental reader. '", "'There are no guarantees regarding ability to parse '", "'Neurolucida .asc files or correctness of output.'", ")", "warnings", ".", "warn...
return a 'raw_data' np.array with the full neuron, and the format of the file suitable to be wrapped by DataWrapper
[ "return", "a", "raw_data", "np", ".", "array", "with", "the", "full", "neuron", "and", "the", "format", "of", "the", "file", "suitable", "to", "be", "wrapped", "by", "DataWrapper" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L260-L275
BlueBrain/NeuroM
examples/get_features.py
stats
def stats(data): '''Dictionary with summary stats for data Returns: dicitonary with length, mean, sum, standard deviation,\ min and max of data ''' return {'len': len(data), 'mean': np.mean(data), 'sum': np.sum(data), 'std': np.std(data), ...
python
def stats(data): '''Dictionary with summary stats for data Returns: dicitonary with length, mean, sum, standard deviation,\ min and max of data ''' return {'len': len(data), 'mean': np.mean(data), 'sum': np.sum(data), 'std': np.std(data), ...
[ "def", "stats", "(", "data", ")", ":", "return", "{", "'len'", ":", "len", "(", "data", ")", ",", "'mean'", ":", "np", ".", "mean", "(", "data", ")", ",", "'sum'", ":", "np", ".", "sum", "(", "data", ")", ",", "'std'", ":", "np", ".", "std", ...
Dictionary with summary stats for data Returns: dicitonary with length, mean, sum, standard deviation,\ min and max of data
[ "Dictionary", "with", "summary", "stats", "for", "data" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/get_features.py#L43-L55
BlueBrain/NeuroM
neurom/apps/__init__.py
get_config
def get_config(config, default_config): '''Load configuration from file if in config, else use default''' if not config: logging.warning('Using default config: %s', default_config) config = default_config try: with open(config, 'r') as config_file: return yaml.load(confi...
python
def get_config(config, default_config): '''Load configuration from file if in config, else use default''' if not config: logging.warning('Using default config: %s', default_config) config = default_config try: with open(config, 'r') as config_file: return yaml.load(confi...
[ "def", "get_config", "(", "config", ",", "default_config", ")", ":", "if", "not", "config", ":", "logging", ".", "warning", "(", "'Using default config: %s'", ",", "default_config", ")", "config", "=", "default_config", "try", ":", "with", "open", "(", "config...
Load configuration from file if in config, else use default
[ "Load", "configuration", "from", "file", "if", "in", "config", "else", "use", "default" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/apps/__init__.py#L36-L48
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
soma_surface_area
def soma_surface_area(nrn, neurite_type=NeuriteType.soma): '''Get the surface area of a neuron's soma. Note: The surface area is calculated by assuming the soma is spherical. ''' assert neurite_type == NeuriteType.soma, 'Neurite type must be soma' return 4 * math.pi * nrn.soma.radius ** 2
python
def soma_surface_area(nrn, neurite_type=NeuriteType.soma): '''Get the surface area of a neuron's soma. Note: The surface area is calculated by assuming the soma is spherical. ''' assert neurite_type == NeuriteType.soma, 'Neurite type must be soma' return 4 * math.pi * nrn.soma.radius ** 2
[ "def", "soma_surface_area", "(", "nrn", ",", "neurite_type", "=", "NeuriteType", ".", "soma", ")", ":", "assert", "neurite_type", "==", "NeuriteType", ".", "soma", ",", "'Neurite type must be soma'", "return", "4", "*", "math", ".", "pi", "*", "nrn", ".", "s...
Get the surface area of a neuron's soma. Note: The surface area is calculated by assuming the soma is spherical.
[ "Get", "the", "surface", "area", "of", "a", "neuron", "s", "soma", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L46-L53
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
soma_surface_areas
def soma_surface_areas(nrn_pop, neurite_type=NeuriteType.soma): '''Get the surface areas of the somata in a population of neurons Note: The surface area is calculated by assuming the soma is spherical. Note: If a single neuron is passed, a single element list with the surface area o...
python
def soma_surface_areas(nrn_pop, neurite_type=NeuriteType.soma): '''Get the surface areas of the somata in a population of neurons Note: The surface area is calculated by assuming the soma is spherical. Note: If a single neuron is passed, a single element list with the surface area o...
[ "def", "soma_surface_areas", "(", "nrn_pop", ",", "neurite_type", "=", "NeuriteType", ".", "soma", ")", ":", "nrns", "=", "neuron_population", "(", "nrn_pop", ")", "assert", "neurite_type", "==", "NeuriteType", ".", "soma", ",", "'Neurite type must be soma'", "ret...
Get the surface areas of the somata in a population of neurons Note: The surface area is calculated by assuming the soma is spherical. Note: If a single neuron is passed, a single element list with the surface area of its soma member is returned.
[ "Get", "the", "surface", "areas", "of", "the", "somata", "in", "a", "population", "of", "neurons" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L56-L67
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
soma_radii
def soma_radii(nrn_pop, neurite_type=NeuriteType.soma): ''' Get the radii of the somata of a population of neurons Note: If a single neuron is passed, a single element list with the radius of its soma member is returned. ''' assert neurite_type == NeuriteType.soma, 'Neurite type must be...
python
def soma_radii(nrn_pop, neurite_type=NeuriteType.soma): ''' Get the radii of the somata of a population of neurons Note: If a single neuron is passed, a single element list with the radius of its soma member is returned. ''' assert neurite_type == NeuriteType.soma, 'Neurite type must be...
[ "def", "soma_radii", "(", "nrn_pop", ",", "neurite_type", "=", "NeuriteType", ".", "soma", ")", ":", "assert", "neurite_type", "==", "NeuriteType", ".", "soma", ",", "'Neurite type must be soma'", "nrns", "=", "neuron_population", "(", "nrn_pop", ")", "return", ...
Get the radii of the somata of a population of neurons Note: If a single neuron is passed, a single element list with the radius of its soma member is returned.
[ "Get", "the", "radii", "of", "the", "somata", "of", "a", "population", "of", "neurons" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L70-L79
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
trunk_section_lengths
def trunk_section_lengths(nrn, neurite_type=NeuriteType.all): '''list of lengths of trunk sections of neurites in a neuron''' neurite_filter = is_type(neurite_type) return [morphmath.section_length(s.root_node.points) for s in nrn.neurites if neurite_filter(s)]
python
def trunk_section_lengths(nrn, neurite_type=NeuriteType.all): '''list of lengths of trunk sections of neurites in a neuron''' neurite_filter = is_type(neurite_type) return [morphmath.section_length(s.root_node.points) for s in nrn.neurites if neurite_filter(s)]
[ "def", "trunk_section_lengths", "(", "nrn", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", "return", "[", "morphmath", ".", "section_length", "(", "s", ".", "root_node", ".", "points",...
list of lengths of trunk sections of neurites in a neuron
[ "list", "of", "lengths", "of", "trunk", "sections", "of", "neurites", "in", "a", "neuron" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L82-L86
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
trunk_origin_radii
def trunk_origin_radii(nrn, neurite_type=NeuriteType.all): '''radii of the trunk sections of neurites in a neuron''' neurite_filter = is_type(neurite_type) return [s.root_node.points[0][COLS.R] for s in nrn.neurites if neurite_filter(s)]
python
def trunk_origin_radii(nrn, neurite_type=NeuriteType.all): '''radii of the trunk sections of neurites in a neuron''' neurite_filter = is_type(neurite_type) return [s.root_node.points[0][COLS.R] for s in nrn.neurites if neurite_filter(s)]
[ "def", "trunk_origin_radii", "(", "nrn", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", "return", "[", "s", ".", "root_node", ".", "points", "[", "0", "]", "[", "COLS", ".", "R",...
radii of the trunk sections of neurites in a neuron
[ "radii", "of", "the", "trunk", "sections", "of", "neurites", "in", "a", "neuron" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L89-L92
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
trunk_origin_azimuths
def trunk_origin_azimuths(nrn, neurite_type=NeuriteType.all): '''Get a list of all the trunk origin azimuths of a neuron or population The azimuth is defined as Angle between x-axis and the vector defined by (initial tree point - soma center) on the x-z plane. The range of the azimuth angle [-pi, pi] ...
python
def trunk_origin_azimuths(nrn, neurite_type=NeuriteType.all): '''Get a list of all the trunk origin azimuths of a neuron or population The azimuth is defined as Angle between x-axis and the vector defined by (initial tree point - soma center) on the x-z plane. The range of the azimuth angle [-pi, pi] ...
[ "def", "trunk_origin_azimuths", "(", "nrn", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", "nrns", "=", "neuron_population", "(", "nrn", ")", "def", "_azimuth", "(", "section", ",", ...
Get a list of all the trunk origin azimuths of a neuron or population The azimuth is defined as Angle between x-axis and the vector defined by (initial tree point - soma center) on the x-z plane. The range of the azimuth angle [-pi, pi] radians
[ "Get", "a", "list", "of", "all", "the", "trunk", "origin", "azimuths", "of", "a", "neuron", "or", "population" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L95-L113
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
trunk_origin_elevations
def trunk_origin_elevations(nrn, neurite_type=NeuriteType.all): '''Get a list of all the trunk origin elevations of a neuron or population The elevation is defined as the angle between x-axis and the vector defined by (initial tree point - soma center) on the x-y half-plane. The range of the eleva...
python
def trunk_origin_elevations(nrn, neurite_type=NeuriteType.all): '''Get a list of all the trunk origin elevations of a neuron or population The elevation is defined as the angle between x-axis and the vector defined by (initial tree point - soma center) on the x-y half-plane. The range of the eleva...
[ "def", "trunk_origin_elevations", "(", "nrn", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", "nrns", "=", "neuron_population", "(", "nrn", ")", "def", "_elevation", "(", "section", ","...
Get a list of all the trunk origin elevations of a neuron or population The elevation is defined as the angle between x-axis and the vector defined by (initial tree point - soma center) on the x-y half-plane. The range of the elevation angle [-pi/2, pi/2] radians
[ "Get", "a", "list", "of", "all", "the", "trunk", "origin", "elevations", "of", "a", "neuron", "or", "population" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L116-L139
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
trunk_vectors
def trunk_vectors(nrn, neurite_type=NeuriteType.all): '''Calculates the vectors between all the trunks of the neuron and the soma center. ''' neurite_filter = is_type(neurite_type) nrns = neuron_population(nrn) return np.array([morphmath.vector(s.root_node.points[0], n.soma.center) ...
python
def trunk_vectors(nrn, neurite_type=NeuriteType.all): '''Calculates the vectors between all the trunks of the neuron and the soma center. ''' neurite_filter = is_type(neurite_type) nrns = neuron_population(nrn) return np.array([morphmath.vector(s.root_node.points[0], n.soma.center) ...
[ "def", "trunk_vectors", "(", "nrn", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", "nrns", "=", "neuron_population", "(", "nrn", ")", "return", "np", ".", "array", "(", "[", "morph...
Calculates the vectors between all the trunks of the neuron and the soma center.
[ "Calculates", "the", "vectors", "between", "all", "the", "trunks", "of", "the", "neuron", "and", "the", "soma", "center", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L142-L151
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
trunk_angles
def trunk_angles(nrn, neurite_type=NeuriteType.all): '''Calculates the angles between all the trunks of the neuron. The angles are defined on the x-y plane and the trees are sorted from the y axis and anticlock-wise. ''' vectors = trunk_vectors(nrn, neurite_type=neurite_type) # In order to avoid...
python
def trunk_angles(nrn, neurite_type=NeuriteType.all): '''Calculates the angles between all the trunks of the neuron. The angles are defined on the x-y plane and the trees are sorted from the y axis and anticlock-wise. ''' vectors = trunk_vectors(nrn, neurite_type=neurite_type) # In order to avoid...
[ "def", "trunk_angles", "(", "nrn", ",", "neurite_type", "=", "NeuriteType", ".", "all", ")", ":", "vectors", "=", "trunk_vectors", "(", "nrn", ",", "neurite_type", "=", "neurite_type", ")", "# In order to avoid the failure of the process in case the neurite_type does not ...
Calculates the angles between all the trunks of the neuron. The angles are defined on the x-y plane and the trees are sorted from the y axis and anticlock-wise.
[ "Calculates", "the", "angles", "between", "all", "the", "trunks", "of", "the", "neuron", ".", "The", "angles", "are", "defined", "on", "the", "x", "-", "y", "plane", "and", "the", "trees", "are", "sorted", "from", "the", "y", "axis", "and", "anticlock", ...
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L154-L177
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
sholl_crossings
def sholl_crossings(neurites, center, radii): '''calculate crossings of neurites Args: nrn(morph): morphology on which to perform Sholl analysis radii(iterable of floats): radii for which crossings will be counted Returns: Array of same length as radii, with a count of the number o...
python
def sholl_crossings(neurites, center, radii): '''calculate crossings of neurites Args: nrn(morph): morphology on which to perform Sholl analysis radii(iterable of floats): radii for which crossings will be counted Returns: Array of same length as radii, with a count of the number o...
[ "def", "sholl_crossings", "(", "neurites", ",", "center", ",", "radii", ")", ":", "def", "_count_crossings", "(", "neurite", ",", "radius", ")", ":", "'''count_crossings of segments in neurite with radius'''", "r2", "=", "radius", "**", "2", "count", "=", "0", "...
calculate crossings of neurites Args: nrn(morph): morphology on which to perform Sholl analysis radii(iterable of floats): radii for which crossings will be counted Returns: Array of same length as radii, with a count of the number of crossings for the respective radius
[ "calculate", "crossings", "of", "neurites" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L180-L206
BlueBrain/NeuroM
neurom/fst/_neuronfunc.py
sholl_frequency
def sholl_frequency(nrn, neurite_type=NeuriteType.all, step_size=10): '''perform Sholl frequency calculations on a population of neurites Args: nrn(morph): nrn or population neurite_type(NeuriteType): which neurites to operate on step_size(float): step size between Sholl radii Note...
python
def sholl_frequency(nrn, neurite_type=NeuriteType.all, step_size=10): '''perform Sholl frequency calculations on a population of neurites Args: nrn(morph): nrn or population neurite_type(NeuriteType): which neurites to operate on step_size(float): step size between Sholl radii Note...
[ "def", "sholl_frequency", "(", "nrn", ",", "neurite_type", "=", "NeuriteType", ".", "all", ",", "step_size", "=", "10", ")", ":", "nrns", "=", "neuron_population", "(", "nrn", ")", "neurite_filter", "=", "is_type", "(", "neurite_type", ")", "min_soma_edge", ...
perform Sholl frequency calculations on a population of neurites Args: nrn(morph): nrn or population neurite_type(NeuriteType): which neurites to operate on step_size(float): step size between Sholl radii Note: Given a neuron, the soma center is used for the concentric circles,...
[ "perform", "Sholl", "frequency", "calculations", "on", "a", "population", "of", "neurites" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L209-L245
BlueBrain/NeuroM
examples/plot_features.py
dist_points
def dist_points(bin_edges, d): """Return an array of values according to a distribution Points are calculated at the center of each bin """ bc = bin_centers(bin_edges) if d is not None: d = DISTS[d['type']](d, bc) return d, bc
python
def dist_points(bin_edges, d): """Return an array of values according to a distribution Points are calculated at the center of each bin """ bc = bin_centers(bin_edges) if d is not None: d = DISTS[d['type']](d, bc) return d, bc
[ "def", "dist_points", "(", "bin_edges", ",", "d", ")", ":", "bc", "=", "bin_centers", "(", "bin_edges", ")", "if", "d", "is", "not", "None", ":", "d", "=", "DISTS", "[", "d", "[", "'type'", "]", "]", "(", "d", ",", "bc", ")", "return", "d", ","...
Return an array of values according to a distribution Points are calculated at the center of each bin
[ "Return", "an", "array", "of", "values", "according", "to", "a", "distribution" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/plot_features.py#L70-L78
BlueBrain/NeuroM
examples/plot_features.py
calc_limits
def calc_limits(data, dist=None, padding=0.25): """Calculate a suitable range for a histogram Returns: tuple of (min, max) """ dmin = sys.float_info.max if dist is None else dist.get('min', sys.float_info.max) dmax = sys.float_info...
python
def calc_limits(data, dist=None, padding=0.25): """Calculate a suitable range for a histogram Returns: tuple of (min, max) """ dmin = sys.float_info.max if dist is None else dist.get('min', sys.float_info.max) dmax = sys.float_info...
[ "def", "calc_limits", "(", "data", ",", "dist", "=", "None", ",", "padding", "=", "0.25", ")", ":", "dmin", "=", "sys", ".", "float_info", ".", "max", "if", "dist", "is", "None", "else", "dist", ".", "get", "(", "'min'", ",", "sys", ".", "float_inf...
Calculate a suitable range for a histogram Returns: tuple of (min, max)
[ "Calculate", "a", "suitable", "range", "for", "a", "histogram" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/plot_features.py#L81-L95
BlueBrain/NeuroM
examples/plot_features.py
load_neurite_features
def load_neurite_features(filepath): '''Unpack relevant data into megadict''' stuff = defaultdict(lambda: defaultdict(list)) nrns = nm.load_neurons(filepath) # unpack data into arrays for nrn in nrns: for t in NEURITES_: for feat in FEATURES: stuff[feat][str(t).sp...
python
def load_neurite_features(filepath): '''Unpack relevant data into megadict''' stuff = defaultdict(lambda: defaultdict(list)) nrns = nm.load_neurons(filepath) # unpack data into arrays for nrn in nrns: for t in NEURITES_: for feat in FEATURES: stuff[feat][str(t).sp...
[ "def", "load_neurite_features", "(", "filepath", ")", ":", "stuff", "=", "defaultdict", "(", "lambda", ":", "defaultdict", "(", "list", ")", ")", "nrns", "=", "nm", ".", "load_neurons", "(", "filepath", ")", "# unpack data into arrays", "for", "nrn", "in", "...
Unpack relevant data into megadict
[ "Unpack", "relevant", "data", "into", "megadict" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/plot_features.py#L112-L123
BlueBrain/NeuroM
examples/plot_features.py
parse_args
def parse_args(): '''Parse command line arguments''' parser = argparse.ArgumentParser( description='Morphology feature plotter', epilog='Note: Makes plots of various features and superimposes\ input distributions. Plots are saved to PDF file.', formatter_class=argparse.ArgumentDe...
python
def parse_args(): '''Parse command line arguments''' parser = argparse.ArgumentParser( description='Morphology feature plotter', epilog='Note: Makes plots of various features and superimposes\ input distributions. Plots are saved to PDF file.', formatter_class=argparse.ArgumentDe...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Morphology feature plotter'", ",", "epilog", "=", "'Note: Makes plots of various features and superimposes\\\n input distributions. Plots are saved to PDF file.'"...
Parse command line arguments
[ "Parse", "command", "line", "arguments" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/plot_features.py#L129-L147
BlueBrain/NeuroM
examples/plot_features.py
main
def main(data_dir, mtype_file): # pylint: disable=too-many-locals '''Run the stuff''' # data structure to store results stuff = load_neurite_features(data_dir) sim_params = json.load(open(mtype_file)) # load histograms, distribution parameter sets and figures into arrays. # To plot figures, do...
python
def main(data_dir, mtype_file): # pylint: disable=too-many-locals '''Run the stuff''' # data structure to store results stuff = load_neurite_features(data_dir) sim_params = json.load(open(mtype_file)) # load histograms, distribution parameter sets and figures into arrays. # To plot figures, do...
[ "def", "main", "(", "data_dir", ",", "mtype_file", ")", ":", "# pylint: disable=too-many-locals", "# data structure to store results", "stuff", "=", "load_neurite_features", "(", "data_dir", ")", "sim_params", "=", "json", ".", "load", "(", "open", "(", "mtype_file", ...
Run the stuff
[ "Run", "the", "stuff" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/plot_features.py#L150-L191
BlueBrain/NeuroM
examples/density_plot.py
extract_density
def extract_density(population, plane='xy', bins=100, neurite_type=NeuriteType.basal_dendrite): '''Extracts the 2d histogram of the center coordinates of segments in the selected plane. ''' segment_midpoints = get_feat('segment_midpoints', population, neurite_type=neurite_type) horiz = segment_mi...
python
def extract_density(population, plane='xy', bins=100, neurite_type=NeuriteType.basal_dendrite): '''Extracts the 2d histogram of the center coordinates of segments in the selected plane. ''' segment_midpoints = get_feat('segment_midpoints', population, neurite_type=neurite_type) horiz = segment_mi...
[ "def", "extract_density", "(", "population", ",", "plane", "=", "'xy'", ",", "bins", "=", "100", ",", "neurite_type", "=", "NeuriteType", ".", "basal_dendrite", ")", ":", "segment_midpoints", "=", "get_feat", "(", "'segment_midpoints'", ",", "population", ",", ...
Extracts the 2d histogram of the center coordinates of segments in the selected plane.
[ "Extracts", "the", "2d", "histogram", "of", "the", "center", "coordinates", "of", "segments", "in", "the", "selected", "plane", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/density_plot.py#L39-L46
BlueBrain/NeuroM
examples/density_plot.py
plot_density
def plot_density(population, # pylint: disable=too-many-arguments, too-many-locals bins=100, new_fig=True, subplot=111, levels=None, plane='xy', colorlabel='Nodes per unit area', labelfontsize=16, color_map='Reds', no_colorbar=False, threshold=0.01, n...
python
def plot_density(population, # pylint: disable=too-many-arguments, too-many-locals bins=100, new_fig=True, subplot=111, levels=None, plane='xy', colorlabel='Nodes per unit area', labelfontsize=16, color_map='Reds', no_colorbar=False, threshold=0.01, n...
[ "def", "plot_density", "(", "population", ",", "# pylint: disable=too-many-arguments, too-many-locals", "bins", "=", "100", ",", "new_fig", "=", "True", ",", "subplot", "=", "111", ",", "levels", "=", "None", ",", "plane", "=", "'xy'", ",", "colorlabel", "=", ...
Plots the 2d histogram of the center coordinates of segments in the selected plane.
[ "Plots", "the", "2d", "histogram", "of", "the", "center", "coordinates", "of", "segments", "in", "the", "selected", "plane", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/density_plot.py#L49-L80
BlueBrain/NeuroM
examples/density_plot.py
plot_neuron_on_density
def plot_neuron_on_density(population, # pylint: disable=too-many-arguments bins=100, new_fig=True, subplot=111, levels=None, plane='xy', colorlabel='Nodes per unit area', labelfontsize=16, color_map='Reds', no_colorbar=False, threshold=0....
python
def plot_neuron_on_density(population, # pylint: disable=too-many-arguments bins=100, new_fig=True, subplot=111, levels=None, plane='xy', colorlabel='Nodes per unit area', labelfontsize=16, color_map='Reds', no_colorbar=False, threshold=0....
[ "def", "plot_neuron_on_density", "(", "population", ",", "# pylint: disable=too-many-arguments", "bins", "=", "100", ",", "new_fig", "=", "True", ",", "subplot", "=", "111", ",", "levels", "=", "None", ",", "plane", "=", "'xy'", ",", "colorlabel", "=", "'Nodes...
Plots the 2d histogram of the center coordinates of segments in the selected plane and superimposes the view of the first neurite of the collection.
[ "Plots", "the", "2d", "histogram", "of", "the", "center", "coordinates", "of", "segments", "in", "the", "selected", "plane", "and", "superimposes", "the", "view", "of", "the", "first", "neurite", "of", "the", "collection", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/density_plot.py#L83-L99
BlueBrain/NeuroM
neurom/geom/__init__.py
bounding_box
def bounding_box(obj): '''Get the (x, y, z) bounding box of an object containing points Returns: 2D numpy array of [[min_x, min_y, min_z], [max_x, max_y, max_z]] ''' return np.array([np.min(obj.points[:, 0:3], axis=0), np.max(obj.points[:, 0:3], axis=0)])
python
def bounding_box(obj): '''Get the (x, y, z) bounding box of an object containing points Returns: 2D numpy array of [[min_x, min_y, min_z], [max_x, max_y, max_z]] ''' return np.array([np.min(obj.points[:, 0:3], axis=0), np.max(obj.points[:, 0:3], axis=0)])
[ "def", "bounding_box", "(", "obj", ")", ":", "return", "np", ".", "array", "(", "[", "np", ".", "min", "(", "obj", ".", "points", "[", ":", ",", "0", ":", "3", "]", ",", "axis", "=", "0", ")", ",", "np", ".", "max", "(", "obj", ".", "points...
Get the (x, y, z) bounding box of an object containing points Returns: 2D numpy array of [[min_x, min_y, min_z], [max_x, max_y, max_z]]
[ "Get", "the", "(", "x", "y", "z", ")", "bounding", "box", "of", "an", "object", "containing", "points" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/geom/__init__.py#L36-L43
BlueBrain/NeuroM
neurom/check/morphtree.py
is_monotonic
def is_monotonic(neurite, tol): '''Check if neurite tree is monotonic If each child has smaller or equal diameters from its parent Args: neurite(Neurite): neurite to operate on tol(float): tolerance Returns: True if neurite monotonic ''' for node in neurite.iter_secti...
python
def is_monotonic(neurite, tol): '''Check if neurite tree is monotonic If each child has smaller or equal diameters from its parent Args: neurite(Neurite): neurite to operate on tol(float): tolerance Returns: True if neurite monotonic ''' for node in neurite.iter_secti...
[ "def", "is_monotonic", "(", "neurite", ",", "tol", ")", ":", "for", "node", "in", "neurite", ".", "iter_sections", "(", ")", ":", "# check that points in section satisfy monotonicity", "sec", "=", "node", ".", "points", "for", "point_id", "in", "range", "(", "...
Check if neurite tree is monotonic If each child has smaller or equal diameters from its parent Args: neurite(Neurite): neurite to operate on tol(float): tolerance Returns: True if neurite monotonic
[ "Check", "if", "neurite", "tree", "is", "monotonic" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/morphtree.py#L40-L64
BlueBrain/NeuroM
neurom/check/morphtree.py
is_flat
def is_flat(neurite, tol, method='tolerance'): '''Check if neurite is flat using the given method Args: neurite(Neurite): neurite to operate on tol(float): tolerance method(string): the method of flatness estimation: 'tolerance' returns true if any extent of the tree is smal...
python
def is_flat(neurite, tol, method='tolerance'): '''Check if neurite is flat using the given method Args: neurite(Neurite): neurite to operate on tol(float): tolerance method(string): the method of flatness estimation: 'tolerance' returns true if any extent of the tree is smal...
[ "def", "is_flat", "(", "neurite", ",", "tol", ",", "method", "=", "'tolerance'", ")", ":", "ext", "=", "principal_direction_extent", "(", "neurite", ".", "points", "[", ":", ",", "COLS", ".", "XYZ", "]", ")", "assert", "method", "in", "(", "'tolerance'",...
Check if neurite is flat using the given method Args: neurite(Neurite): neurite to operate on tol(float): tolerance method(string): the method of flatness estimation: 'tolerance' returns true if any extent of the tree is smaller than the given tolerance '...
[ "Check", "if", "neurite", "is", "flat", "using", "the", "given", "method" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/morphtree.py#L67-L88
BlueBrain/NeuroM
neurom/check/morphtree.py
is_back_tracking
def is_back_tracking(neurite): ''' Check if a neurite process backtracks to a previous node. Back-tracking takes place when a daughter of a branching process goes back and either overlaps with a previous point, or lies inside the cylindrical volume of the latter. Args: neurite(Neurite): neurite...
python
def is_back_tracking(neurite): ''' Check if a neurite process backtracks to a previous node. Back-tracking takes place when a daughter of a branching process goes back and either overlaps with a previous point, or lies inside the cylindrical volume of the latter. Args: neurite(Neurite): neurite...
[ "def", "is_back_tracking", "(", "neurite", ")", ":", "def", "pair", "(", "segs", ")", ":", "''' Pairs the input list into triplets'''", "return", "zip", "(", "segs", ",", "segs", "[", "1", ":", "]", ")", "def", "coords", "(", "node", ")", ":", "''' Returns...
Check if a neurite process backtracks to a previous node. Back-tracking takes place when a daughter of a branching process goes back and either overlaps with a previous point, or lies inside the cylindrical volume of the latter. Args: neurite(Neurite): neurite to operate on Returns: Tr...
[ "Check", "if", "a", "neurite", "process", "backtracks", "to", "a", "previous", "node", ".", "Back", "-", "tracking", "takes", "place", "when", "a", "daughter", "of", "a", "branching", "process", "goes", "back", "and", "either", "overlaps", "with", "a", "pr...
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/morphtree.py#L91-L187
BlueBrain/NeuroM
neurom/check/morphtree.py
get_flat_neurites
def get_flat_neurites(neuron, tol=0.1, method='ratio'): '''Check if a neuron has neurites that are flat within a tolerance Args: neurite(Neurite): neurite to operate on tol(float): the tolerance or the ratio method(string): 'tolerance' or 'ratio' described in :meth:`is_flat` Return...
python
def get_flat_neurites(neuron, tol=0.1, method='ratio'): '''Check if a neuron has neurites that are flat within a tolerance Args: neurite(Neurite): neurite to operate on tol(float): the tolerance or the ratio method(string): 'tolerance' or 'ratio' described in :meth:`is_flat` Return...
[ "def", "get_flat_neurites", "(", "neuron", ",", "tol", "=", "0.1", ",", "method", "=", "'ratio'", ")", ":", "return", "[", "n", "for", "n", "in", "neuron", ".", "neurites", "if", "is_flat", "(", "n", ",", "tol", ",", "method", ")", "]" ]
Check if a neuron has neurites that are flat within a tolerance Args: neurite(Neurite): neurite to operate on tol(float): the tolerance or the ratio method(string): 'tolerance' or 'ratio' described in :meth:`is_flat` Returns: Bool list corresponding to the flatness check for ea...
[ "Check", "if", "a", "neuron", "has", "neurites", "that", "are", "flat", "within", "a", "tolerance" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/morphtree.py#L190-L202
BlueBrain/NeuroM
neurom/check/morphtree.py
get_nonmonotonic_neurites
def get_nonmonotonic_neurites(neuron, tol=1e-6): '''Get neurites that are not monotonic Args: neurite(Neurite): neurite to operate on tol(float): the tolerance or the ratio Returns: list of neurites that do not satisfy monotonicity test ''' return [n for n in neuron.neurite...
python
def get_nonmonotonic_neurites(neuron, tol=1e-6): '''Get neurites that are not monotonic Args: neurite(Neurite): neurite to operate on tol(float): the tolerance or the ratio Returns: list of neurites that do not satisfy monotonicity test ''' return [n for n in neuron.neurite...
[ "def", "get_nonmonotonic_neurites", "(", "neuron", ",", "tol", "=", "1e-6", ")", ":", "return", "[", "n", "for", "n", "in", "neuron", ".", "neurites", "if", "not", "is_monotonic", "(", "n", ",", "tol", ")", "]" ]
Get neurites that are not monotonic Args: neurite(Neurite): neurite to operate on tol(float): the tolerance or the ratio Returns: list of neurites that do not satisfy monotonicity test
[ "Get", "neurites", "that", "are", "not", "monotonic" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/morphtree.py#L205-L215
BlueBrain/NeuroM
examples/radius_of_gyration.py
segment_centre_of_mass
def segment_centre_of_mass(seg): '''Calculate and return centre of mass of a segment. C, seg_volalculated as centre of mass of conical frustum''' h = mm.segment_length(seg) r0 = seg[0][COLS.R] r1 = seg[1][COLS.R] num = r0 * r0 + 2 * r0 * r1 + 3 * r1 * r1 denom = 4 * (r0 * r0 + r0 * r1 + r1 ...
python
def segment_centre_of_mass(seg): '''Calculate and return centre of mass of a segment. C, seg_volalculated as centre of mass of conical frustum''' h = mm.segment_length(seg) r0 = seg[0][COLS.R] r1 = seg[1][COLS.R] num = r0 * r0 + 2 * r0 * r1 + 3 * r1 * r1 denom = 4 * (r0 * r0 + r0 * r1 + r1 ...
[ "def", "segment_centre_of_mass", "(", "seg", ")", ":", "h", "=", "mm", ".", "segment_length", "(", "seg", ")", "r0", "=", "seg", "[", "0", "]", "[", "COLS", ".", "R", "]", "r1", "=", "seg", "[", "1", "]", "[", "COLS", ".", "R", "]", "num", "=...
Calculate and return centre of mass of a segment. C, seg_volalculated as centre of mass of conical frustum
[ "Calculate", "and", "return", "centre", "of", "mass", "of", "a", "segment", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/radius_of_gyration.py#L38-L48
BlueBrain/NeuroM
examples/radius_of_gyration.py
neurite_centre_of_mass
def neurite_centre_of_mass(neurite): '''Calculate and return centre of mass of a neurite.''' centre_of_mass = np.zeros(3) total_volume = 0 seg_vol = np.array(map(mm.segment_volume, nm.iter_segments(neurite))) seg_centre_of_mass = np.array(map(segment_centre_of_mass, nm.iter_segments(neurite))) ...
python
def neurite_centre_of_mass(neurite): '''Calculate and return centre of mass of a neurite.''' centre_of_mass = np.zeros(3) total_volume = 0 seg_vol = np.array(map(mm.segment_volume, nm.iter_segments(neurite))) seg_centre_of_mass = np.array(map(segment_centre_of_mass, nm.iter_segments(neurite))) ...
[ "def", "neurite_centre_of_mass", "(", "neurite", ")", ":", "centre_of_mass", "=", "np", ".", "zeros", "(", "3", ")", "total_volume", "=", "0", "seg_vol", "=", "np", ".", "array", "(", "map", "(", "mm", ".", "segment_volume", ",", "nm", ".", "iter_segment...
Calculate and return centre of mass of a neurite.
[ "Calculate", "and", "return", "centre", "of", "mass", "of", "a", "neurite", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/radius_of_gyration.py#L51-L64
BlueBrain/NeuroM
examples/radius_of_gyration.py
distance_sqr
def distance_sqr(point, seg): '''Calculate and return square Euclidian distance from given point to centre of mass of given segment.''' centre_of_mass = segment_centre_of_mass(seg) return sum(pow(np.subtract(point, centre_of_mass), 2))
python
def distance_sqr(point, seg): '''Calculate and return square Euclidian distance from given point to centre of mass of given segment.''' centre_of_mass = segment_centre_of_mass(seg) return sum(pow(np.subtract(point, centre_of_mass), 2))
[ "def", "distance_sqr", "(", "point", ",", "seg", ")", ":", "centre_of_mass", "=", "segment_centre_of_mass", "(", "seg", ")", "return", "sum", "(", "pow", "(", "np", ".", "subtract", "(", "point", ",", "centre_of_mass", ")", ",", "2", ")", ")" ]
Calculate and return square Euclidian distance from given point to centre of mass of given segment.
[ "Calculate", "and", "return", "square", "Euclidian", "distance", "from", "given", "point", "to", "centre", "of", "mass", "of", "given", "segment", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/radius_of_gyration.py#L67-L71
BlueBrain/NeuroM
examples/radius_of_gyration.py
radius_of_gyration
def radius_of_gyration(neurite): '''Calculate and return radius of gyration of a given neurite.''' centre_mass = neurite_centre_of_mass(neurite) sum_sqr_distance = 0 N = 0 dist_sqr = [distance_sqr(centre_mass, s) for s in nm.iter_segments(neurite)] sum_sqr_distance = np.sum(dist_sqr) N = len...
python
def radius_of_gyration(neurite): '''Calculate and return radius of gyration of a given neurite.''' centre_mass = neurite_centre_of_mass(neurite) sum_sqr_distance = 0 N = 0 dist_sqr = [distance_sqr(centre_mass, s) for s in nm.iter_segments(neurite)] sum_sqr_distance = np.sum(dist_sqr) N = len...
[ "def", "radius_of_gyration", "(", "neurite", ")", ":", "centre_mass", "=", "neurite_centre_of_mass", "(", "neurite", ")", "sum_sqr_distance", "=", "0", "N", "=", "0", "dist_sqr", "=", "[", "distance_sqr", "(", "centre_mass", ",", "s", ")", "for", "s", "in", ...
Calculate and return radius of gyration of a given neurite.
[ "Calculate", "and", "return", "radius", "of", "gyration", "of", "a", "given", "neurite", "." ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/radius_of_gyration.py#L74-L82
BlueBrain/NeuroM
apps/__main__.py
view
def view(input_file, plane, backend): '''A simple neuron viewer''' if backend == 'matplotlib': from neurom.viewer import draw kwargs = { 'mode': '3d' if plane == '3d' else '2d', } if plane != '3d': kwargs['plane'] = plane draw(load_neuron(input_fil...
python
def view(input_file, plane, backend): '''A simple neuron viewer''' if backend == 'matplotlib': from neurom.viewer import draw kwargs = { 'mode': '3d' if plane == '3d' else '2d', } if plane != '3d': kwargs['plane'] = plane draw(load_neuron(input_fil...
[ "def", "view", "(", "input_file", ",", "plane", ",", "backend", ")", ":", "if", "backend", "==", "'matplotlib'", ":", "from", "neurom", ".", "viewer", "import", "draw", "kwargs", "=", "{", "'mode'", ":", "'3d'", "if", "plane", "==", "'3d'", "else", "'2...
A simple neuron viewer
[ "A", "simple", "neuron", "viewer" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/apps/__main__.py#L23-L39
BlueBrain/NeuroM
neurom/apps/annotate.py
generate_annotation
def generate_annotation(result, settings): '''Generate the annotation for a given checker Arguments neuron(Neuron): The neuron object checker: A tuple where the first item is the checking function (usually from neuron_checks) and the second item is a dictionary of settings for ...
python
def generate_annotation(result, settings): '''Generate the annotation for a given checker Arguments neuron(Neuron): The neuron object checker: A tuple where the first item is the checking function (usually from neuron_checks) and the second item is a dictionary of settings for ...
[ "def", "generate_annotation", "(", "result", ",", "settings", ")", ":", "if", "result", ".", "status", ":", "return", "\"\"", "header", "=", "(", "\"\\n\\n\"", "\"({label} ; MUK_ANNOTATION\\n\"", "\" (Color {color}) ; MUK_ANNOTATION\\n\"", "\" (Name \\\"{name}\\\"...
Generate the annotation for a given checker Arguments neuron(Neuron): The neuron object checker: A tuple where the first item is the checking function (usually from neuron_checks) and the second item is a dictionary of settings for the annotation. It must contain t...
[ "Generate", "the", "annotation", "for", "a", "given", "checker" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/apps/annotate.py#L37-L62
BlueBrain/NeuroM
neurom/apps/annotate.py
annotate
def annotate(results, settings): '''Concatenate the annotations of all checkers''' annotations = (generate_annotation(result, setting) for result, setting in zip(results, settings)) return '\n'.join(annot for annot in annotations if annot)
python
def annotate(results, settings): '''Concatenate the annotations of all checkers''' annotations = (generate_annotation(result, setting) for result, setting in zip(results, settings)) return '\n'.join(annot for annot in annotations if annot)
[ "def", "annotate", "(", "results", ",", "settings", ")", ":", "annotations", "=", "(", "generate_annotation", "(", "result", ",", "setting", ")", "for", "result", ",", "setting", "in", "zip", "(", "results", ",", "settings", ")", ")", "return", "'\\n'", ...
Concatenate the annotations of all checkers
[ "Concatenate", "the", "annotations", "of", "all", "checkers" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/apps/annotate.py#L65-L69
BlueBrain/NeuroM
neurom/core/point.py
as_point
def as_point(row): '''Create a Point from a data block row''' return Point(row[COLS.X], row[COLS.Y], row[COLS.Z], row[COLS.R], int(row[COLS.TYPE]))
python
def as_point(row): '''Create a Point from a data block row''' return Point(row[COLS.X], row[COLS.Y], row[COLS.Z], row[COLS.R], int(row[COLS.TYPE]))
[ "def", "as_point", "(", "row", ")", ":", "return", "Point", "(", "row", "[", "COLS", ".", "X", "]", ",", "row", "[", "COLS", ".", "Y", "]", ",", "row", "[", "COLS", ".", "Z", "]", ",", "row", "[", "COLS", ".", "R", "]", ",", "int", "(", "...
Create a Point from a data block row
[ "Create", "a", "Point", "from", "a", "data", "block", "row" ]
train
https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/core/point.py#L38-L41
jambonsw/django-improved-user
src/improved_user/managers.py
UserManager.create_superuser
def create_superuser(self, email, password, **extra_fields): """Save new User with is_staff and is_superuser set to True""" extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) if extra_fields.get('is_staff') is not True: raise ValueError('S...
python
def create_superuser(self, email, password, **extra_fields): """Save new User with is_staff and is_superuser set to True""" extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) if extra_fields.get('is_staff') is not True: raise ValueError('S...
[ "def", "create_superuser", "(", "self", ",", "email", ",", "password", ",", "*", "*", "extra_fields", ")", ":", "extra_fields", ".", "setdefault", "(", "'is_staff'", ",", "True", ")", "extra_fields", ".", "setdefault", "(", "'is_superuser'", ",", "True", ")"...
Save new User with is_staff and is_superuser set to True
[ "Save", "new", "User", "with", "is_staff", "and", "is_superuser", "set", "to", "True" ]
train
https://github.com/jambonsw/django-improved-user/blob/e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4/src/improved_user/managers.py#L43-L51
jambonsw/django-improved-user
setup.py
load_file_contents
def load_file_contents(file_path, as_list=True): """Load file as string or list""" abs_file_path = join(HERE, file_path) with open(abs_file_path, encoding='utf-8') as file_pointer: if as_list: return file_pointer.read().splitlines() return file_pointer.read()
python
def load_file_contents(file_path, as_list=True): """Load file as string or list""" abs_file_path = join(HERE, file_path) with open(abs_file_path, encoding='utf-8') as file_pointer: if as_list: return file_pointer.read().splitlines() return file_pointer.read()
[ "def", "load_file_contents", "(", "file_path", ",", "as_list", "=", "True", ")", ":", "abs_file_path", "=", "join", "(", "HERE", ",", "file_path", ")", "with", "open", "(", "abs_file_path", ",", "encoding", "=", "'utf-8'", ")", "as", "file_pointer", ":", "...
Load file as string or list
[ "Load", "file", "as", "string", "or", "list" ]
train
https://github.com/jambonsw/django-improved-user/blob/e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4/setup.py#L22-L28
jambonsw/django-improved-user
src/improved_user/forms.py
AbstractUserCreationForm.clean_password2
def clean_password2(self): """ Check wether password 1 and password 2 are equivalent While ideally this would be done in clean, there is a chance a superclass could declare clean and forget to call super. We therefore opt to run this password mismatch check in password2 ...
python
def clean_password2(self): """ Check wether password 1 and password 2 are equivalent While ideally this would be done in clean, there is a chance a superclass could declare clean and forget to call super. We therefore opt to run this password mismatch check in password2 ...
[ "def", "clean_password2", "(", "self", ")", ":", "password1", "=", "self", ".", "cleaned_data", ".", "get", "(", "'password1'", ")", "password2", "=", "self", ".", "cleaned_data", ".", "get", "(", "'password2'", ")", "if", "password1", "and", "password2", ...
Check wether password 1 and password 2 are equivalent While ideally this would be done in clean, there is a chance a superclass could declare clean and forget to call super. We therefore opt to run this password mismatch check in password2 clean, but to show the error above password1 (a...
[ "Check", "wether", "password", "1", "and", "password", "2", "are", "equivalent" ]
train
https://github.com/jambonsw/django-improved-user/blob/e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4/src/improved_user/forms.py#L62-L84
jambonsw/django-improved-user
src/improved_user/forms.py
AbstractUserCreationForm._post_clean
def _post_clean(self): """Run password validaton after clean methods When clean methods are run, the user instance does not yet exist. To properly compare model values agains the password (in the UserAttributeSimilarityValidator), we wait until we have an instance to compare ag...
python
def _post_clean(self): """Run password validaton after clean methods When clean methods are run, the user instance does not yet exist. To properly compare model values agains the password (in the UserAttributeSimilarityValidator), we wait until we have an instance to compare ag...
[ "def", "_post_clean", "(", "self", ")", ":", "super", "(", ")", ".", "_post_clean", "(", ")", "# updates self.instance with form data", "password", "=", "self", ".", "cleaned_data", ".", "get", "(", "'password1'", ")", "if", "password", ":", "try", ":", "pas...
Run password validaton after clean methods When clean methods are run, the user instance does not yet exist. To properly compare model values agains the password (in the UserAttributeSimilarityValidator), we wait until we have an instance to compare against. https://code.djang...
[ "Run", "password", "validaton", "after", "clean", "methods" ]
train
https://github.com/jambonsw/django-improved-user/blob/e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4/src/improved_user/forms.py#L86-L107
jambonsw/django-improved-user
src/improved_user/model_mixins.py
EmailAuthMixin.clean
def clean(self): """Override default clean method to normalize email. Call :code:`super().clean()` if overriding. """ super().clean() self.email = self.__class__.objects.normalize_email(self.email)
python
def clean(self): """Override default clean method to normalize email. Call :code:`super().clean()` if overriding. """ super().clean() self.email = self.__class__.objects.normalize_email(self.email)
[ "def", "clean", "(", "self", ")", ":", "super", "(", ")", ".", "clean", "(", ")", "self", ".", "email", "=", "self", ".", "__class__", ".", "objects", ".", "normalize_email", "(", "self", ".", "email", ")" ]
Override default clean method to normalize email. Call :code:`super().clean()` if overriding.
[ "Override", "default", "clean", "method", "to", "normalize", "email", "." ]
train
https://github.com/jambonsw/django-improved-user/blob/e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4/src/improved_user/model_mixins.py#L69-L76
sfalkner/pynisher
pynisher/limit_function_call.py
subprocess_func
def subprocess_func(func, pipe, logger, mem_in_mb, cpu_time_limit_in_s, wall_time_limit_in_s, num_procs, grace_period_in_s, tmp_dir, *args, **kwargs): # simple signal handler to catch the signals for time limits def handler(signum, frame): # logs message with level debug on this logger logger.debug("signal hand...
python
def subprocess_func(func, pipe, logger, mem_in_mb, cpu_time_limit_in_s, wall_time_limit_in_s, num_procs, grace_period_in_s, tmp_dir, *args, **kwargs): # simple signal handler to catch the signals for time limits def handler(signum, frame): # logs message with level debug on this logger logger.debug("signal hand...
[ "def", "subprocess_func", "(", "func", ",", "pipe", ",", "logger", ",", "mem_in_mb", ",", "cpu_time_limit_in_s", ",", "wall_time_limit_in_s", ",", "num_procs", ",", "grace_period_in_s", ",", "tmp_dir", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# ...
for i in [x for x in dir(signal) if x.startswith("SIG")]: try: signum = getattr(signal,i) print("register {}, {}".format(signum, i)) signal.signal(signum, handler) except: print("Skipping %s"%i)
[ "for", "i", "in", "[", "x", "for", "x", "in", "dir", "(", "signal", ")", "if", "x", ".", "startswith", "(", "SIG", ")", "]", ":", "try", ":", "signum", "=", "getattr", "(", "signal", "i", ")", "print", "(", "register", "{}", "{}", ".", "format"...
train
https://github.com/sfalkner/pynisher/blob/8e9518e874673bfc0a62a54fa1580cd1df931617/pynisher/limit_function_call.py#L19-L130
mapbox/cligj
cligj/features.py
normalize_feature_inputs
def normalize_feature_inputs(ctx, param, value): """Click callback that normalizes feature input values. Returns a generator over features from the input value. Parameters ---------- ctx: a Click context param: the name of the argument or option value: object The value argument may...
python
def normalize_feature_inputs(ctx, param, value): """Click callback that normalizes feature input values. Returns a generator over features from the input value. Parameters ---------- ctx: a Click context param: the name of the argument or option value: object The value argument may...
[ "def", "normalize_feature_inputs", "(", "ctx", ",", "param", ",", "value", ")", ":", "for", "feature_like", "in", "value", "or", "(", "'-'", ",", ")", ":", "try", ":", "with", "click", ".", "open_file", "(", "feature_like", ")", "as", "src", ":", "for"...
Click callback that normalizes feature input values. Returns a generator over features from the input value. Parameters ---------- ctx: a Click context param: the name of the argument or option value: object The value argument may be one of the following: 1. A list of paths to...
[ "Click", "callback", "that", "normalizes", "feature", "input", "values", "." ]
train
https://github.com/mapbox/cligj/blob/1815692d99abfb4bc4b2d0411f67fa568f112c05/cligj/features.py#L8-L39
mapbox/cligj
cligj/features.py
iter_features
def iter_features(geojsonfile, func=None): """Extract GeoJSON features from a text file object. Given a file-like object containing a single GeoJSON feature collection text or a sequence of GeoJSON features, iter_features() iterates over lines of the file and yields GeoJSON features. Parameters ...
python
def iter_features(geojsonfile, func=None): """Extract GeoJSON features from a text file object. Given a file-like object containing a single GeoJSON feature collection text or a sequence of GeoJSON features, iter_features() iterates over lines of the file and yields GeoJSON features. Parameters ...
[ "def", "iter_features", "(", "geojsonfile", ",", "func", "=", "None", ")", ":", "func", "=", "func", "or", "(", "lambda", "x", ":", "x", ")", "first_line", "=", "next", "(", "geojsonfile", ")", "# Does the geojsonfile contain RS-delimited JSON sequences?", "if",...
Extract GeoJSON features from a text file object. Given a file-like object containing a single GeoJSON feature collection text or a sequence of GeoJSON features, iter_features() iterates over lines of the file and yields GeoJSON features. Parameters ---------- geojsonfile: a file-like object ...
[ "Extract", "GeoJSON", "features", "from", "a", "text", "file", "object", "." ]
train
https://github.com/mapbox/cligj/blob/1815692d99abfb4bc4b2d0411f67fa568f112c05/cligj/features.py#L42-L135
mapbox/cligj
cligj/features.py
iter_query
def iter_query(query): """Accept a filename, stream, or string. Returns an iterator over lines of the query.""" try: itr = click.open_file(query).readlines() except IOError: itr = [query] return itr
python
def iter_query(query): """Accept a filename, stream, or string. Returns an iterator over lines of the query.""" try: itr = click.open_file(query).readlines() except IOError: itr = [query] return itr
[ "def", "iter_query", "(", "query", ")", ":", "try", ":", "itr", "=", "click", ".", "open_file", "(", "query", ")", ".", "readlines", "(", ")", "except", "IOError", ":", "itr", "=", "[", "query", "]", "return", "itr" ]
Accept a filename, stream, or string. Returns an iterator over lines of the query.
[ "Accept", "a", "filename", "stream", "or", "string", ".", "Returns", "an", "iterator", "over", "lines", "of", "the", "query", "." ]
train
https://github.com/mapbox/cligj/blob/1815692d99abfb4bc4b2d0411f67fa568f112c05/cligj/features.py#L154-L161
mapbox/cligj
cligj/features.py
coords_from_query
def coords_from_query(query): """Transform a query line into a (lng, lat) pair of coordinates.""" try: coords = json.loads(query) except ValueError: query = query.replace(',', ' ') vals = query.split() coords = [float(v) for v in vals] return tuple(coords[:2])
python
def coords_from_query(query): """Transform a query line into a (lng, lat) pair of coordinates.""" try: coords = json.loads(query) except ValueError: query = query.replace(',', ' ') vals = query.split() coords = [float(v) for v in vals] return tuple(coords[:2])
[ "def", "coords_from_query", "(", "query", ")", ":", "try", ":", "coords", "=", "json", ".", "loads", "(", "query", ")", "except", "ValueError", ":", "query", "=", "query", ".", "replace", "(", "','", ",", "' '", ")", "vals", "=", "query", ".", "split...
Transform a query line into a (lng, lat) pair of coordinates.
[ "Transform", "a", "query", "line", "into", "a", "(", "lng", "lat", ")", "pair", "of", "coordinates", "." ]
train
https://github.com/mapbox/cligj/blob/1815692d99abfb4bc4b2d0411f67fa568f112c05/cligj/features.py#L164-L172
mapbox/cligj
cligj/features.py
normalize_feature_objects
def normalize_feature_objects(feature_objs): """Takes an iterable of GeoJSON-like Feature mappings or an iterable of objects with a geo interface and normalizes it to the former.""" for obj in feature_objs: if hasattr(obj, "__geo_interface__") and \ 'type' in obj.__geo_interface__.key...
python
def normalize_feature_objects(feature_objs): """Takes an iterable of GeoJSON-like Feature mappings or an iterable of objects with a geo interface and normalizes it to the former.""" for obj in feature_objs: if hasattr(obj, "__geo_interface__") and \ 'type' in obj.__geo_interface__.key...
[ "def", "normalize_feature_objects", "(", "feature_objs", ")", ":", "for", "obj", "in", "feature_objs", ":", "if", "hasattr", "(", "obj", ",", "\"__geo_interface__\"", ")", "and", "'type'", "in", "obj", ".", "__geo_interface__", ".", "keys", "(", ")", "and", ...
Takes an iterable of GeoJSON-like Feature mappings or an iterable of objects with a geo interface and normalizes it to the former.
[ "Takes", "an", "iterable", "of", "GeoJSON", "-", "like", "Feature", "mappings", "or", "an", "iterable", "of", "objects", "with", "a", "geo", "interface", "and", "normalizes", "it", "to", "the", "former", "." ]
train
https://github.com/mapbox/cligj/blob/1815692d99abfb4bc4b2d0411f67fa568f112c05/cligj/features.py#L175-L189
ludeeus/pytraccar
pytraccar/api.py
API.api
async def api(self, endpoint, params=None, test=False): """Comunicate with the API.""" data = {} url = "{}/{}".format(self._api, endpoint) try: async with async_timeout.timeout(8, loop=self._loop): response = await self._session.get( url, a...
python
async def api(self, endpoint, params=None, test=False): """Comunicate with the API.""" data = {} url = "{}/{}".format(self._api, endpoint) try: async with async_timeout.timeout(8, loop=self._loop): response = await self._session.get( url, a...
[ "async", "def", "api", "(", "self", ",", "endpoint", ",", "params", "=", "None", ",", "test", "=", "False", ")", ":", "data", "=", "{", "}", "url", "=", "\"{}/{}\"", ".", "format", "(", "self", ".", "_api", ",", "endpoint", ")", "try", ":", "asyn...
Comunicate with the API.
[ "Comunicate", "with", "the", "API", "." ]
train
https://github.com/ludeeus/pytraccar/blob/c7c635c334cc193c2da351a9fc8213d5095f77d6/pytraccar/api.py#L39-L79
ludeeus/pytraccar
pytraccar/api.py
API.get_device_info
async def get_device_info(self, custom_attributes=None): """Get the local installed version.""" await self.get_geofences() await self.get_devices() await self.get_positions() devinfo = {} try: # pylint: disable=too-many-nested-blocks for dev in self._devices ...
python
async def get_device_info(self, custom_attributes=None): """Get the local installed version.""" await self.get_geofences() await self.get_devices() await self.get_positions() devinfo = {} try: # pylint: disable=too-many-nested-blocks for dev in self._devices ...
[ "async", "def", "get_device_info", "(", "self", ",", "custom_attributes", "=", "None", ")", ":", "await", "self", ".", "get_geofences", "(", ")", "await", "self", ".", "get_devices", "(", ")", "await", "self", ".", "get_positions", "(", ")", "devinfo", "="...
Get the local installed version.
[ "Get", "the", "local", "installed", "version", "." ]
train
https://github.com/ludeeus/pytraccar/blob/c7c635c334cc193c2da351a9fc8213d5095f77d6/pytraccar/api.py#L85-L127
ludeeus/pytraccar
pytraccar/api.py
API.get_geofences
async def get_geofences(self): """Get the local installed version.""" data = await self.api("geofences") if self.connected and self.authenticated: for geofence in data or []: self._geofences[geofence["id"]] = geofence["name"] else: self._geofences ...
python
async def get_geofences(self): """Get the local installed version.""" data = await self.api("geofences") if self.connected and self.authenticated: for geofence in data or []: self._geofences[geofence["id"]] = geofence["name"] else: self._geofences ...
[ "async", "def", "get_geofences", "(", "self", ")", ":", "data", "=", "await", "self", ".", "api", "(", "\"geofences\"", ")", "if", "self", ".", "connected", "and", "self", ".", "authenticated", ":", "for", "geofence", "in", "data", "or", "[", "]", ":",...
Get the local installed version.
[ "Get", "the", "local", "installed", "version", "." ]
train
https://github.com/ludeeus/pytraccar/blob/c7c635c334cc193c2da351a9fc8213d5095f77d6/pytraccar/api.py#L129-L137
ludeeus/pytraccar
pytraccar/api.py
API.get_devices
async def get_devices(self): """Get the local installed version.""" data = await self.api("devices") if self.connected and self.authenticated: self._devices = data else: self._devices = self._devices _LOGGER.debug(self._devices)
python
async def get_devices(self): """Get the local installed version.""" data = await self.api("devices") if self.connected and self.authenticated: self._devices = data else: self._devices = self._devices _LOGGER.debug(self._devices)
[ "async", "def", "get_devices", "(", "self", ")", ":", "data", "=", "await", "self", ".", "api", "(", "\"devices\"", ")", "if", "self", ".", "connected", "and", "self", ".", "authenticated", ":", "self", ".", "_devices", "=", "data", "else", ":", "self"...
Get the local installed version.
[ "Get", "the", "local", "installed", "version", "." ]
train
https://github.com/ludeeus/pytraccar/blob/c7c635c334cc193c2da351a9fc8213d5095f77d6/pytraccar/api.py#L139-L146
ludeeus/pytraccar
pytraccar/api.py
API.get_positions
async def get_positions(self): """Get the local installed version.""" data = await self.api("positions") if self.connected and self.authenticated: self._positions = data else: self._positions = self._positions _LOGGER.debug(self._positions)
python
async def get_positions(self): """Get the local installed version.""" data = await self.api("positions") if self.connected and self.authenticated: self._positions = data else: self._positions = self._positions _LOGGER.debug(self._positions)
[ "async", "def", "get_positions", "(", "self", ")", ":", "data", "=", "await", "self", ".", "api", "(", "\"positions\"", ")", "if", "self", ".", "connected", "and", "self", ".", "authenticated", ":", "self", ".", "_positions", "=", "data", "else", ":", ...
Get the local installed version.
[ "Get", "the", "local", "installed", "version", "." ]
train
https://github.com/ludeeus/pytraccar/blob/c7c635c334cc193c2da351a9fc8213d5095f77d6/pytraccar/api.py#L148-L155
ludeeus/pytraccar
pytraccar/api.py
API.get_events
async def get_events( self, device_ids, group_ids=None, from_time=None, to_time=None, event_types=None ): """Get the local installed version.""" if to_time is None: to_time = datetime.utcnow() if from_time is None: from_time = to_time - timedelta(seconds=EVENT...
python
async def get_events( self, device_ids, group_ids=None, from_time=None, to_time=None, event_types=None ): """Get the local installed version.""" if to_time is None: to_time = datetime.utcnow() if from_time is None: from_time = to_time - timedelta(seconds=EVENT...
[ "async", "def", "get_events", "(", "self", ",", "device_ids", ",", "group_ids", "=", "None", ",", "from_time", "=", "None", ",", "to_time", "=", "None", ",", "event_types", "=", "None", ")", ":", "if", "to_time", "is", "None", ":", "to_time", "=", "dat...
Get the local installed version.
[ "Get", "the", "local", "installed", "version", "." ]
train
https://github.com/ludeeus/pytraccar/blob/c7c635c334cc193c2da351a9fc8213d5095f77d6/pytraccar/api.py#L157-L184
ludeeus/pytraccar
pytraccar/cli.py
runcli
async def runcli(): """Debug of pytraccar.""" async with aiohttp.ClientSession() as session: host = input("IP: ") username = input("Username: ") password = input("Password: ") print("\n\n\n") data = API(LOOP, session, username, password, host) await data.test_conn...
python
async def runcli(): """Debug of pytraccar.""" async with aiohttp.ClientSession() as session: host = input("IP: ") username = input("Username: ") password = input("Password: ") print("\n\n\n") data = API(LOOP, session, username, password, host) await data.test_conn...
[ "async", "def", "runcli", "(", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "session", ":", "host", "=", "input", "(", "\"IP: \"", ")", "username", "=", "input", "(", "\"Username: \"", ")", "password", "=", "input", "(", ...
Debug of pytraccar.
[ "Debug", "of", "pytraccar", "." ]
train
https://github.com/ludeeus/pytraccar/blob/c7c635c334cc193c2da351a9fc8213d5095f77d6/pytraccar/cli.py#L9-L25
alexdej/puzpy
puz.py
scramble_string
def scramble_string(s, key): """ s is the puzzle's solution in column-major order, omitting black squares: i.e. if the puzzle is: C A T # # A # # R solution is CATAR Key is a 4-digit number in the range 1000 <= key <= 9999 """ key = key_digits(key) for k in key...
python
def scramble_string(s, key): """ s is the puzzle's solution in column-major order, omitting black squares: i.e. if the puzzle is: C A T # # A # # R solution is CATAR Key is a 4-digit number in the range 1000 <= key <= 9999 """ key = key_digits(key) for k in key...
[ "def", "scramble_string", "(", "s", ",", "key", ")", ":", "key", "=", "key_digits", "(", "key", ")", "for", "k", "in", "key", ":", "# foreach digit in the key", "s", "=", "shift", "(", "s", ",", "key", ")", "# for each char by each digit in the key in sequence...
s is the puzzle's solution in column-major order, omitting black squares: i.e. if the puzzle is: C A T # # A # # R solution is CATAR Key is a 4-digit number in the range 1000 <= key <= 9999
[ "s", "is", "the", "puzzle", "s", "solution", "in", "column", "-", "major", "order", "omitting", "black", "squares", ":", "i", ".", "e", ".", "if", "the", "puzzle", "is", ":", "C", "A", "T", "#", "#", "A", "#", "#", "R", "solution", "is", "CATAR" ...
train
https://github.com/alexdej/puzpy/blob/8906ab899845d1200ac3411b4c2a2067cffa15d7/puz.py#L618-L637