repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/swc.py#L47-L53 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L89-L100 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L103-L120 | train |
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",
")",
"id_map",
"=",
"{",
"-",
"1",
":",
"-",
... | Make a list of sections from an SWC-style data wrapper block | [
"Make",
"a",
"list",
"of",
"sections",
"from",
"an",
"SWC",
"-",
"style",
"data",
"wrapper",
"block"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L142-L210 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L76-L81 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L83-L86 | train |
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",
")",
":",
"assert",
"id_",
"not",
"in",
"self",
".",
"sections",
",",
"'id %s already exists in sections'",
"%",
"id_",
"self",
".",
"sections",
"[",
"id_",
... | 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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L234-L246 | train |
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",
")",
"id_to_insert_id",
"=",
"{",
"}",
"row_count",
"=",
"0",
"for",
"section_id",
"in",
"section_ids",
":",
"row_count",
"+=",
"len",
"(",
"self",... | Make a data_block and sections list as required by DataWrapper | [
"Make",
"a",
"data_block",
"and",
"sections",
"list",
"as",
"required",
"by",
"DataWrapper"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L248-L277 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L279-L286 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/datawrapper.py#L288-L292 | train |
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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L50-L55 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L92-L99 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L102-L112 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L115-L122 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L125-L164 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L167-L180 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L183-L196 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L199-L204 | train |
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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/utils.py#L75-L84 | train |
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'",
",",
"'de... | 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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/viewer.py#L77-L134 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/histogram.py#L96-L112 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/section_ids.py#L37-L44 | train |
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... | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/extract_distribution.py#L59-L70 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_bifurcationfunc.py#L80-L91 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_bifurcationfunc.py#L110-L118 | train |
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",
")",
":",
"for",
"i",
"in",
"range",
"(",
"5",
")",
":",
"if",
"i",
">=",
"len",
"(",
"section",
")",
":",
"return",
"None",
"if",
"isinstance",
"(",
"section",
"[",
"i",
"]",
",",
"StringType"... | 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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L64-L84 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L114-L128 | train |
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",
"==",
"'('",
":",
"section",
"=",
"_parse_section",
"(",
"token_... | 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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L131-L143 | train |
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",
":",
"if",
"row",
"in",
"(",
"'Low'",
",",
"'Generated'",
",",
"'High'",
",",
")",
":",
"continue",
"elif",
"isinstan... | 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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L146-L187 | train |
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",
")",
":",
"if",
"len",
"(",
"section",
")",
"==",
"1",
":",
"assert",
"section",
"[",
"0",
"]",
"==",
"'Sections'",
",",
"(",
"'Only known usage of a single Section content is \"Sections\", found %s'",
"%",
"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 | [
"Find",
"top",
"level",
"sections",
"and",
"get",
"their",
"flat",
"contents",
"and",
"append",
"them",
"all"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L190-L222 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L225-L257 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/io/neurolucida.py#L260-L275 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/get_features.py#L43-L55 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/apps/__init__.py#L36-L48 | train |
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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L46-L53 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L56-L67 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L70-L79 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L82-L86 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L89-L92 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L95-L113 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L116-L139 | train |
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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L142-L151 | train |
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",
")",
"if",
"not",
"vectors",
".",
"size",
":",
"return",
"[",
"]",
"d... | 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",
... | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L154-L177 | train |
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",
")",
":",
"r2",
"=",
"radius",
"**",
"2",
"count",
"=",
"0",
"for",
"start",
",",
"end",
"in",
"iter_segments",
... | 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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L180-L206 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/_neuronfunc.py#L209-L245 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/plot_features.py#L70-L78 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/plot_features.py#L81-L95 | train |
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",
")",
"for",
"nrn",
"in",
"nrns",
":",
"for",
"t",
... | Unpack relevant data into megadict | [
"Unpack",
"relevant",
"data",
"into",
"megadict"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/plot_features.py#L112-L123 | train |
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",
")",
":",
"stuff",
"=",
"load_neurite_features",
"(",
"data_dir",
")",
"sim_params",
"=",
"json",
".",
"load",
"(",
"open",
"(",
"mtype_file",
")",
")",
"_plots",
"=",
"[",
"]",
"for",
"feat",
",",
"d"... | Run the stuff | [
"Run",
"the",
"stuff"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/plot_features.py#L150-L191 | train |
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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/density_plot.py#L39-L46 | train |
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",
",",
"bins",
"=",
"100",
",",
"new_fig",
"=",
"True",
",",
"subplot",
"=",
"111",
",",
"levels",
"=",
"None",
",",
"plane",
"=",
"'xy'",
",",
"colorlabel",
"=",
"'Nodes per unit area'",
",",
"labelfontsize",
"=",
... | 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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/density_plot.py#L49-L80 | train |
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",
",",
"bins",
"=",
"100",
",",
"new_fig",
"=",
"True",
",",
"subplot",
"=",
"111",
",",
"levels",
"=",
"None",
",",
"plane",
"=",
"'xy'",
",",
"colorlabel",
"=",
"'Nodes per unit area'",
",",
"labelfontsize"... | 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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/density_plot.py#L83-L99 | train |
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",
"(",
")",
":",
"sec",
"=",
"node",
".",
"points",
"for",
"point_id",
"in",
"range",
"(",
"len",
"(",
"sec",
")",
"-",
"1",
")",
":",
... | 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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/morphtree.py#L40-L64 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/morphtree.py#L67-L88 | train |
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",
")",
":",
"return",
"zip",
"(",
"segs",
",",
"segs",
"[",
"1",
":",
"]",
")",
"def",
"coords",
"(",
"node",
")",
":",
"return",
"node",
"[",
"COLS",
".",
"XYZ",
"]",... | 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... | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/morphtree.py#L91-L187 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/morphtree.py#L190-L202 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/check/morphtree.py#L205-L215 | train |
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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/radius_of_gyration.py#L38-L48 | train |
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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/radius_of_gyration.py#L51-L64 | train |
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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/radius_of_gyration.py#L67-L71 | train |
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",
"."
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/radius_of_gyration.py#L74-L82 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/apps/__main__.py#L23-L39 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/apps/annotate.py#L37-L62 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/apps/annotate.py#L65-L69 | train |
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"
] | 254bb73535b20053d175bc4725bade662177d12b | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/core/point.py#L38-L41 | train |
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",
")",
"i... | Save new User with is_staff and is_superuser set to True | [
"Save",
"new",
"User",
"with",
"is_staff",
"and",
"is_superuser",
"set",
"to",
"True"
] | e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4 | https://github.com/jambonsw/django-improved-user/blob/e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4/src/improved_user/managers.py#L43-L51 | train |
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"
] | e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4 | https://github.com/jambonsw/django-improved-user/blob/e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4/setup.py#L22-L28 | train |
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"
] | e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4 | https://github.com/jambonsw/django-improved-user/blob/e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4/src/improved_user/forms.py#L62-L84 | train |
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",
"(",
")",
"password",
"=",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"'password1'",
")",
"if",
"password",
":",
"try",
":",
"password_validation",
".",
"validate_passwo... | 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"
] | e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4 | https://github.com/jambonsw/django-improved-user/blob/e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4/src/improved_user/forms.py#L86-L107 | train |
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",
"."
] | e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4 | https://github.com/jambonsw/django-improved-user/blob/e5fbb4f0d5f7491b9f06f7eb2812127b5e4616d4/src/improved_user/model_mixins.py#L69-L76 | train |
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",
"."
] | 1815692d99abfb4bc4b2d0411f67fa568f112c05 | https://github.com/mapbox/cligj/blob/1815692d99abfb4bc4b2d0411f67fa568f112c05/cligj/features.py#L8-L39 | train |
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",
")",
"if",
"first_line",
".",
"startswith",
"(",
"u'\\x1e'",
")... | 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",
"."
] | 1815692d99abfb4bc4b2d0411f67fa568f112c05 | https://github.com/mapbox/cligj/blob/1815692d99abfb4bc4b2d0411f67fa568f112c05/cligj/features.py#L42-L135 | train |
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",
"."
] | 1815692d99abfb4bc4b2d0411f67fa568f112c05 | https://github.com/mapbox/cligj/blob/1815692d99abfb4bc4b2d0411f67fa568f112c05/cligj/features.py#L154-L161 | train |
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",
"."
] | 1815692d99abfb4bc4b2d0411f67fa568f112c05 | https://github.com/mapbox/cligj/blob/1815692d99abfb4bc4b2d0411f67fa568f112c05/cligj/features.py#L175-L189 | train |
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",
"."
] | c7c635c334cc193c2da351a9fc8213d5095f77d6 | https://github.com/ludeeus/pytraccar/blob/c7c635c334cc193c2da351a9fc8213d5095f77d6/pytraccar/api.py#L39-L79 | train |
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",
"."
] | c7c635c334cc193c2da351a9fc8213d5095f77d6 | https://github.com/ludeeus/pytraccar/blob/c7c635c334cc193c2da351a9fc8213d5095f77d6/pytraccar/cli.py#L9-L25 | train |
alexdej/puzpy | puz.py | restore | def restore(s, t):
"""
s is the source string, it can contain '.'
t is the target, it's smaller than s by the number of '.'s in s
Each char in s is replaced by the corresponding
char in t, jumping over '.'s in s.
>>> restore('ABC.DEF', 'XYZABC')
'XYZ.ABC'
"""
t = (c for c in t)
... | python | def restore(s, t):
"""
s is the source string, it can contain '.'
t is the target, it's smaller than s by the number of '.'s in s
Each char in s is replaced by the corresponding
char in t, jumping over '.'s in s.
>>> restore('ABC.DEF', 'XYZABC')
'XYZ.ABC'
"""
t = (c for c in t)
... | [
"def",
"restore",
"(",
"s",
",",
"t",
")",
":",
"t",
"=",
"(",
"c",
"for",
"c",
"in",
"t",
")",
"return",
"''",
".",
"join",
"(",
"next",
"(",
"t",
")",
"if",
"not",
"is_blacksquare",
"(",
"c",
")",
"else",
"c",
"for",
"c",
"in",
"s",
")"
] | s is the source string, it can contain '.'
t is the target, it's smaller than s by the number of '.'s in s
Each char in s is replaced by the corresponding
char in t, jumping over '.'s in s.
>>> restore('ABC.DEF', 'XYZABC')
'XYZ.ABC' | [
"s",
"is",
"the",
"source",
"string",
"it",
"can",
"contain",
".",
"t",
"is",
"the",
"target",
"it",
"s",
"smaller",
"than",
"s",
"by",
"the",
"number",
"of",
".",
"s",
"in",
"s"
] | 8906ab899845d1200ac3411b4c2a2067cffa15d7 | https://github.com/alexdej/puzpy/blob/8906ab899845d1200ac3411b4c2a2067cffa15d7/puz.py#L696-L708 | train |
instacart/ahab | ahab/__init__.py | Ahab.default | def default(event, data):
"""The default handler prints basic event info."""
messages = defaultdict(lambda: 'Avast:')
messages['start'] = 'Thar she blows!'
messages['tag'] = 'Thar she blows!'
messages['stop'] = 'Away into the depths:'
messages['destroy'] = 'Away into the ... | python | def default(event, data):
"""The default handler prints basic event info."""
messages = defaultdict(lambda: 'Avast:')
messages['start'] = 'Thar she blows!'
messages['tag'] = 'Thar she blows!'
messages['stop'] = 'Away into the depths:'
messages['destroy'] = 'Away into the ... | [
"def",
"default",
"(",
"event",
",",
"data",
")",
":",
"messages",
"=",
"defaultdict",
"(",
"lambda",
":",
"'Avast:'",
")",
"messages",
"[",
"'start'",
"]",
"=",
"'Thar she blows!'",
"messages",
"[",
"'tag'",
"]",
"=",
"'Thar she blows!'",
"messages",
"[",
... | The default handler prints basic event info. | [
"The",
"default",
"handler",
"prints",
"basic",
"event",
"info",
"."
] | da85dc6d89f5d0c49d3a26a25ea3710c7881b150 | https://github.com/instacart/ahab/blob/da85dc6d89f5d0c49d3a26a25ea3710c7881b150/ahab/__init__.py#L58-L69 | train |
instacart/ahab | examples/nathook.py | table | def table(tab):
"""Access IPTables transactionally in a uniform way.
Ensures all access is done without autocommit and that only the outer
most task commits, and also ensures we refresh once and commit once.
"""
global open_tables
if tab in open_tables:
yield open_tables[tab]
else:
... | python | def table(tab):
"""Access IPTables transactionally in a uniform way.
Ensures all access is done without autocommit and that only the outer
most task commits, and also ensures we refresh once and commit once.
"""
global open_tables
if tab in open_tables:
yield open_tables[tab]
else:
... | [
"def",
"table",
"(",
"tab",
")",
":",
"global",
"open_tables",
"if",
"tab",
"in",
"open_tables",
":",
"yield",
"open_tables",
"[",
"tab",
"]",
"else",
":",
"open_tables",
"[",
"tab",
"]",
"=",
"iptc",
".",
"Table",
"(",
"tab",
")",
"open_tables",
"[",
... | Access IPTables transactionally in a uniform way.
Ensures all access is done without autocommit and that only the outer
most task commits, and also ensures we refresh once and commit once. | [
"Access",
"IPTables",
"transactionally",
"in",
"a",
"uniform",
"way",
"."
] | da85dc6d89f5d0c49d3a26a25ea3710c7881b150 | https://github.com/instacart/ahab/blob/da85dc6d89f5d0c49d3a26a25ea3710c7881b150/examples/nathook.py#L124-L139 | train |
hotdoc/hotdoc | hotdoc/core/formatter.py | Formatter.format_symbol | def format_symbol(self, symbol, link_resolver):
"""
Format a symbols.Symbol
"""
if not symbol:
return ''
if isinstance(symbol, FieldSymbol):
return ''
# pylint: disable=unused-variable
out = self._format_symbol(symbol)
template = ... | python | def format_symbol(self, symbol, link_resolver):
"""
Format a symbols.Symbol
"""
if not symbol:
return ''
if isinstance(symbol, FieldSymbol):
return ''
# pylint: disable=unused-variable
out = self._format_symbol(symbol)
template = ... | [
"def",
"format_symbol",
"(",
"self",
",",
"symbol",
",",
"link_resolver",
")",
":",
"if",
"not",
"symbol",
":",
"return",
"''",
"if",
"isinstance",
"(",
"symbol",
",",
"FieldSymbol",
")",
":",
"return",
"''",
"out",
"=",
"self",
".",
"_format_symbol",
"(... | Format a symbols.Symbol | [
"Format",
"a",
"symbols",
".",
"Symbol"
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/formatter.py#L219-L235 | train |
hotdoc/hotdoc | hotdoc/core/database.py | Database.add_comment | def add_comment(self, comment):
"""
Add a comment to the database.
Args:
comment (hotdoc.core.Comment): comment to add
"""
if not comment:
return
self.__comments[comment.name] = comment
self.comment_added_signal(self, comment) | python | def add_comment(self, comment):
"""
Add a comment to the database.
Args:
comment (hotdoc.core.Comment): comment to add
"""
if not comment:
return
self.__comments[comment.name] = comment
self.comment_added_signal(self, comment) | [
"def",
"add_comment",
"(",
"self",
",",
"comment",
")",
":",
"if",
"not",
"comment",
":",
"return",
"self",
".",
"__comments",
"[",
"comment",
".",
"name",
"]",
"=",
"comment",
"self",
".",
"comment_added_signal",
"(",
"self",
",",
"comment",
")"
] | Add a comment to the database.
Args:
comment (hotdoc.core.Comment): comment to add | [
"Add",
"a",
"comment",
"to",
"the",
"database",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/database.py#L77-L88 | train |
hotdoc/hotdoc | hotdoc/utils/utils.py | touch | def touch(fname):
"""
Mimics the `touch` command
Busy loops until the mtime has actually been changed, use for tests only
"""
orig_mtime = get_mtime(fname)
while get_mtime(fname) == orig_mtime:
pathlib.Path(fname).touch() | python | def touch(fname):
"""
Mimics the `touch` command
Busy loops until the mtime has actually been changed, use for tests only
"""
orig_mtime = get_mtime(fname)
while get_mtime(fname) == orig_mtime:
pathlib.Path(fname).touch() | [
"def",
"touch",
"(",
"fname",
")",
":",
"orig_mtime",
"=",
"get_mtime",
"(",
"fname",
")",
"while",
"get_mtime",
"(",
"fname",
")",
"==",
"orig_mtime",
":",
"pathlib",
".",
"Path",
"(",
"fname",
")",
".",
"touch",
"(",
")"
] | Mimics the `touch` command
Busy loops until the mtime has actually been changed, use for tests only | [
"Mimics",
"the",
"touch",
"command"
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/utils/utils.py#L306-L314 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.debug | def debug(self, message, domain=None):
"""
Shortcut function for `utils.loggable.debug`
Args:
message: see `utils.loggable.debug`
domain: see `utils.loggable.debug`
"""
if domain is None:
domain = self.extension_name
debug(message, dom... | python | def debug(self, message, domain=None):
"""
Shortcut function for `utils.loggable.debug`
Args:
message: see `utils.loggable.debug`
domain: see `utils.loggable.debug`
"""
if domain is None:
domain = self.extension_name
debug(message, dom... | [
"def",
"debug",
"(",
"self",
",",
"message",
",",
"domain",
"=",
"None",
")",
":",
"if",
"domain",
"is",
"None",
":",
"domain",
"=",
"self",
".",
"extension_name",
"debug",
"(",
"message",
",",
"domain",
")"
] | Shortcut function for `utils.loggable.debug`
Args:
message: see `utils.loggable.debug`
domain: see `utils.loggable.debug` | [
"Shortcut",
"function",
"for",
"utils",
".",
"loggable",
".",
"debug"
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L148-L158 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.info | def info(self, message, domain=None):
"""
Shortcut function for `utils.loggable.info`
Args:
message: see `utils.loggable.info`
domain: see `utils.loggable.info`
"""
if domain is None:
domain = self.extension_name
info(message, domain) | python | def info(self, message, domain=None):
"""
Shortcut function for `utils.loggable.info`
Args:
message: see `utils.loggable.info`
domain: see `utils.loggable.info`
"""
if domain is None:
domain = self.extension_name
info(message, domain) | [
"def",
"info",
"(",
"self",
",",
"message",
",",
"domain",
"=",
"None",
")",
":",
"if",
"domain",
"is",
"None",
":",
"domain",
"=",
"self",
".",
"extension_name",
"info",
"(",
"message",
",",
"domain",
")"
] | Shortcut function for `utils.loggable.info`
Args:
message: see `utils.loggable.info`
domain: see `utils.loggable.info` | [
"Shortcut",
"function",
"for",
"utils",
".",
"loggable",
".",
"info"
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L160-L170 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.parse_config | def parse_config(self, config):
"""
Override this, making sure to chain up first, if your extension adds
its own custom command line arguments, or you want to do any further
processing on the automatically added arguments.
The default implementation will set attributes on the ex... | python | def parse_config(self, config):
"""
Override this, making sure to chain up first, if your extension adds
its own custom command line arguments, or you want to do any further
processing on the automatically added arguments.
The default implementation will set attributes on the ex... | [
"def",
"parse_config",
"(",
"self",
",",
"config",
")",
":",
"prefix",
"=",
"self",
".",
"argument_prefix",
"self",
".",
"sources",
"=",
"config",
".",
"get_sources",
"(",
"prefix",
")",
"self",
".",
"smart_sources",
"=",
"[",
"self",
".",
"_get_smart_file... | Override this, making sure to chain up first, if your extension adds
its own custom command line arguments, or you want to do any further
processing on the automatically added arguments.
The default implementation will set attributes on the extension:
- 'sources': a set of absolute path... | [
"Override",
"this",
"making",
"sure",
"to",
"chain",
"up",
"first",
"if",
"your",
"extension",
"adds",
"its",
"own",
"custom",
"command",
"line",
"arguments",
"or",
"you",
"want",
"to",
"do",
"any",
"further",
"processing",
"on",
"the",
"automatically",
"add... | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L403-L437 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.add_attrs | def add_attrs(self, symbol, **kwargs):
"""
Helper for setting symbol extension attributes
"""
for key, val in kwargs.items():
symbol.add_extension_attribute(self.extension_name, key, val) | python | def add_attrs(self, symbol, **kwargs):
"""
Helper for setting symbol extension attributes
"""
for key, val in kwargs.items():
symbol.add_extension_attribute(self.extension_name, key, val) | [
"def",
"add_attrs",
"(",
"self",
",",
"symbol",
",",
"**",
"kwargs",
")",
":",
"for",
"key",
",",
"val",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"symbol",
".",
"add_extension_attribute",
"(",
"self",
".",
"extension_name",
",",
"key",
",",
"val",
... | Helper for setting symbol extension attributes | [
"Helper",
"for",
"setting",
"symbol",
"extension",
"attributes"
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L439-L444 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.get_attr | def get_attr(self, symbol, attrname):
"""
Helper for getting symbol extension attributes
"""
return symbol.extension_attributes.get(self.extension_name, {}).get(
attrname, None) | python | def get_attr(self, symbol, attrname):
"""
Helper for getting symbol extension attributes
"""
return symbol.extension_attributes.get(self.extension_name, {}).get(
attrname, None) | [
"def",
"get_attr",
"(",
"self",
",",
"symbol",
",",
"attrname",
")",
":",
"return",
"symbol",
".",
"extension_attributes",
".",
"get",
"(",
"self",
".",
"extension_name",
",",
"{",
"}",
")",
".",
"get",
"(",
"attrname",
",",
"None",
")"
] | Helper for getting symbol extension attributes | [
"Helper",
"for",
"getting",
"symbol",
"extension",
"attributes"
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L446-L451 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.add_index_argument | def add_index_argument(cls, group):
"""
Subclasses may call this to add an index argument.
Args:
group: arparse.ArgumentGroup, the extension argument group
prefix: str, arguments have to be namespaced
"""
prefix = cls.argument_prefix
group.add_ar... | python | def add_index_argument(cls, group):
"""
Subclasses may call this to add an index argument.
Args:
group: arparse.ArgumentGroup, the extension argument group
prefix: str, arguments have to be namespaced
"""
prefix = cls.argument_prefix
group.add_ar... | [
"def",
"add_index_argument",
"(",
"cls",
",",
"group",
")",
":",
"prefix",
"=",
"cls",
".",
"argument_prefix",
"group",
".",
"add_argument",
"(",
"'--%s-index'",
"%",
"prefix",
",",
"action",
"=",
"\"store\"",
",",
"dest",
"=",
"\"%s_index\"",
"%",
"prefix",... | Subclasses may call this to add an index argument.
Args:
group: arparse.ArgumentGroup, the extension argument group
prefix: str, arguments have to be namespaced | [
"Subclasses",
"may",
"call",
"this",
"to",
"add",
"an",
"index",
"argument",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L479-L493 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.add_sources_argument | def add_sources_argument(cls, group, allow_filters=True, prefix=None, add_root_paths=False):
"""
Subclasses may call this to add sources and source_filters arguments.
Args:
group: arparse.ArgumentGroup, the extension argument group
allow_filters: bool, Whether the exten... | python | def add_sources_argument(cls, group, allow_filters=True, prefix=None, add_root_paths=False):
"""
Subclasses may call this to add sources and source_filters arguments.
Args:
group: arparse.ArgumentGroup, the extension argument group
allow_filters: bool, Whether the exten... | [
"def",
"add_sources_argument",
"(",
"cls",
",",
"group",
",",
"allow_filters",
"=",
"True",
",",
"prefix",
"=",
"None",
",",
"add_root_paths",
"=",
"False",
")",
":",
"prefix",
"=",
"prefix",
"or",
"cls",
".",
"argument_prefix",
"group",
".",
"add_argument",... | Subclasses may call this to add sources and source_filters arguments.
Args:
group: arparse.ArgumentGroup, the extension argument group
allow_filters: bool, Whether the extension wishes to expose a
source_filters argument.
prefix: str, arguments have to be na... | [
"Subclasses",
"may",
"call",
"this",
"to",
"add",
"sources",
"and",
"source_filters",
"arguments",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L496-L526 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.add_path_argument | def add_path_argument(cls, group, argname, dest=None, help_=None):
"""
Subclasses may call this to expose a path argument.
Args:
group: arparse.ArgumentGroup, the extension argument group
argname: str, the name of the argument, will be namespaced.
dest: str, ... | python | def add_path_argument(cls, group, argname, dest=None, help_=None):
"""
Subclasses may call this to expose a path argument.
Args:
group: arparse.ArgumentGroup, the extension argument group
argname: str, the name of the argument, will be namespaced.
dest: str, ... | [
"def",
"add_path_argument",
"(",
"cls",
",",
"group",
",",
"argname",
",",
"dest",
"=",
"None",
",",
"help_",
"=",
"None",
")",
":",
"prefixed",
"=",
"'%s-%s'",
"%",
"(",
"cls",
".",
"argument_prefix",
",",
"argname",
")",
"if",
"dest",
"is",
"None",
... | Subclasses may call this to expose a path argument.
Args:
group: arparse.ArgumentGroup, the extension argument group
argname: str, the name of the argument, will be namespaced.
dest: str, similar to the `dest` argument of
`argparse.ArgumentParser.add_argument... | [
"Subclasses",
"may",
"call",
"this",
"to",
"expose",
"a",
"path",
"argument",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L529-L551 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.add_paths_argument | def add_paths_argument(cls, group, argname, dest=None, help_=None):
"""
Subclasses may call this to expose a paths argument.
Args:
group: arparse.ArgumentGroup, the extension argument group
argname: str, the name of the argument, will be namespaced.
dest: str... | python | def add_paths_argument(cls, group, argname, dest=None, help_=None):
"""
Subclasses may call this to expose a paths argument.
Args:
group: arparse.ArgumentGroup, the extension argument group
argname: str, the name of the argument, will be namespaced.
dest: str... | [
"def",
"add_paths_argument",
"(",
"cls",
",",
"group",
",",
"argname",
",",
"dest",
"=",
"None",
",",
"help_",
"=",
"None",
")",
":",
"prefixed",
"=",
"'%s-%s'",
"%",
"(",
"cls",
".",
"argument_prefix",
",",
"argname",
")",
"if",
"dest",
"is",
"None",
... | Subclasses may call this to expose a paths argument.
Args:
group: arparse.ArgumentGroup, the extension argument group
argname: str, the name of the argument, will be namespaced.
dest: str, similar to the `dest` argument of
`argparse.ArgumentParser.add_argumen... | [
"Subclasses",
"may",
"call",
"this",
"to",
"expose",
"a",
"paths",
"argument",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L554-L576 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.create_symbol | def create_symbol(self, *args, **kwargs):
"""
Extensions that discover and create instances of `symbols.Symbol`
should do this through this method, as it will keep an index
of these which can be used when generating a "naive index".
See `database.Database.create_symbol` for more... | python | def create_symbol(self, *args, **kwargs):
"""
Extensions that discover and create instances of `symbols.Symbol`
should do this through this method, as it will keep an index
of these which can be used when generating a "naive index".
See `database.Database.create_symbol` for more... | [
"def",
"create_symbol",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
".",
"get",
"(",
"'project_name'",
")",
":",
"kwargs",
"[",
"'project_name'",
"]",
"=",
"self",
".",
"project",
".",
"project_name",
"sym",
"="... | Extensions that discover and create instances of `symbols.Symbol`
should do this through this method, as it will keep an index
of these which can be used when generating a "naive index".
See `database.Database.create_symbol` for more
information.
Args:
args: see `da... | [
"Extensions",
"that",
"discover",
"and",
"create",
"instances",
"of",
"symbols",
".",
"Symbol",
"should",
"do",
"this",
"through",
"this",
"method",
"as",
"it",
"will",
"keep",
"an",
"index",
"of",
"these",
"which",
"can",
"be",
"used",
"when",
"generating",... | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L584-L609 | train |
hotdoc/hotdoc | hotdoc/core/extension.py | Extension.format_page | def format_page(self, page, link_resolver, output):
"""
Called by `project.Project.format_page`, to leave full control
to extensions over the formatting of the pages they are
responsible of.
Args:
page: tree.Page, the page to format.
link_resolver: links.... | python | def format_page(self, page, link_resolver, output):
"""
Called by `project.Project.format_page`, to leave full control
to extensions over the formatting of the pages they are
responsible of.
Args:
page: tree.Page, the page to format.
link_resolver: links.... | [
"def",
"format_page",
"(",
"self",
",",
"page",
",",
"link_resolver",
",",
"output",
")",
":",
"debug",
"(",
"'Formatting page %s'",
"%",
"page",
".",
"link",
".",
"ref",
",",
"'formatting'",
")",
"if",
"output",
":",
"actual_output",
"=",
"os",
".",
"pa... | Called by `project.Project.format_page`, to leave full control
to extensions over the formatting of the pages they are
responsible of.
Args:
page: tree.Page, the page to format.
link_resolver: links.LinkResolver, object responsible
for resolving links pot... | [
"Called",
"by",
"project",
".",
"Project",
".",
"format_page",
"to",
"leave",
"full",
"control",
"to",
"extensions",
"over",
"the",
"formatting",
"of",
"the",
"pages",
"they",
"are",
"responsible",
"of",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/extension.py#L646-L668 | train |
hotdoc/hotdoc | hotdoc/core/project.py | Project.add_subproject | def add_subproject(self, fname, conf_path):
"""Creates and adds a new subproject."""
config = Config(conf_file=conf_path)
proj = Project(self.app,
dependency_map=self.dependency_map)
proj.parse_name_from_config(config)
proj.parse_config(config)
proj... | python | def add_subproject(self, fname, conf_path):
"""Creates and adds a new subproject."""
config = Config(conf_file=conf_path)
proj = Project(self.app,
dependency_map=self.dependency_map)
proj.parse_name_from_config(config)
proj.parse_config(config)
proj... | [
"def",
"add_subproject",
"(",
"self",
",",
"fname",
",",
"conf_path",
")",
":",
"config",
"=",
"Config",
"(",
"conf_file",
"=",
"conf_path",
")",
"proj",
"=",
"Project",
"(",
"self",
".",
"app",
",",
"dependency_map",
"=",
"self",
".",
"dependency_map",
... | Creates and adds a new subproject. | [
"Creates",
"and",
"adds",
"a",
"new",
"subproject",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/project.py#L226-L234 | train |
hotdoc/hotdoc | hotdoc/core/tree.py | _no_duplicates_constructor | def _no_duplicates_constructor(loader, node, deep=False):
"""Check for duplicate keys."""
mapping = {}
for key_node, value_node in node.value:
key = loader.construct_object(key_node, deep=deep)
value = loader.construct_object(value_node, deep=deep)
if key in mapping:
rai... | python | def _no_duplicates_constructor(loader, node, deep=False):
"""Check for duplicate keys."""
mapping = {}
for key_node, value_node in node.value:
key = loader.construct_object(key_node, deep=deep)
value = loader.construct_object(value_node, deep=deep)
if key in mapping:
rai... | [
"def",
"_no_duplicates_constructor",
"(",
"loader",
",",
"node",
",",
"deep",
"=",
"False",
")",
":",
"mapping",
"=",
"{",
"}",
"for",
"key_node",
",",
"value_node",
"in",
"node",
".",
"value",
":",
"key",
"=",
"loader",
".",
"construct_object",
"(",
"ke... | Check for duplicate keys. | [
"Check",
"for",
"duplicate",
"keys",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/tree.py#L49-L63 | train |
hotdoc/hotdoc | hotdoc/core/tree.py | Page.resolve_symbols | def resolve_symbols(self, tree, database, link_resolver):
"""
When this method is called, the page's symbol names are queried
from `database`, and added to lists of actual symbols, sorted
by symbol class.
"""
self.typed_symbols = self.__get_empty_typed_symbols()
a... | python | def resolve_symbols(self, tree, database, link_resolver):
"""
When this method is called, the page's symbol names are queried
from `database`, and added to lists of actual symbols, sorted
by symbol class.
"""
self.typed_symbols = self.__get_empty_typed_symbols()
a... | [
"def",
"resolve_symbols",
"(",
"self",
",",
"tree",
",",
"database",
",",
"link_resolver",
")",
":",
"self",
".",
"typed_symbols",
"=",
"self",
".",
"__get_empty_typed_symbols",
"(",
")",
"all_syms",
"=",
"OrderedSet",
"(",
")",
"for",
"sym_name",
"in",
"sel... | When this method is called, the page's symbol names are queried
from `database`, and added to lists of actual symbols, sorted
by symbol class. | [
"When",
"this",
"method",
"is",
"called",
"the",
"page",
"s",
"symbol",
"names",
"are",
"queried",
"from",
"database",
"and",
"added",
"to",
"lists",
"of",
"actual",
"symbols",
"sorted",
"by",
"symbol",
"class",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/tree.py#L196-L240 | train |
hotdoc/hotdoc | hotdoc/core/tree.py | Tree.walk | def walk(self, parent=None):
"""Generator that yields pages in infix order
Args:
parent: hotdoc.core.tree.Page, optional, the page to start
traversal from. If None, defaults to the root of the tree.
Yields:
hotdoc.core.tree.Page: the next page
""... | python | def walk(self, parent=None):
"""Generator that yields pages in infix order
Args:
parent: hotdoc.core.tree.Page, optional, the page to start
traversal from. If None, defaults to the root of the tree.
Yields:
hotdoc.core.tree.Page: the next page
""... | [
"def",
"walk",
"(",
"self",
",",
"parent",
"=",
"None",
")",
":",
"if",
"parent",
"is",
"None",
":",
"yield",
"self",
".",
"root",
"parent",
"=",
"self",
".",
"root",
"for",
"cpage_name",
"in",
"parent",
".",
"subpages",
":",
"cpage",
"=",
"self",
... | Generator that yields pages in infix order
Args:
parent: hotdoc.core.tree.Page, optional, the page to start
traversal from. If None, defaults to the root of the tree.
Yields:
hotdoc.core.tree.Page: the next page | [
"Generator",
"that",
"yields",
"pages",
"in",
"infix",
"order"
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/core/tree.py#L514-L532 | train |
hotdoc/hotdoc | hotdoc/extensions/__init__.py | get_extension_classes | def get_extension_classes():
"""
Hotdoc's setuptools entry point
"""
res = [SyntaxHighlightingExtension, SearchExtension, TagExtension,
DevhelpExtension, LicenseExtension, GitUploadExtension,
EditOnGitHubExtension]
if sys.version_info[1] >= 5:
res += [DBusExtension]
... | python | def get_extension_classes():
"""
Hotdoc's setuptools entry point
"""
res = [SyntaxHighlightingExtension, SearchExtension, TagExtension,
DevhelpExtension, LicenseExtension, GitUploadExtension,
EditOnGitHubExtension]
if sys.version_info[1] >= 5:
res += [DBusExtension]
... | [
"def",
"get_extension_classes",
"(",
")",
":",
"res",
"=",
"[",
"SyntaxHighlightingExtension",
",",
"SearchExtension",
",",
"TagExtension",
",",
"DevhelpExtension",
",",
"LicenseExtension",
",",
"GitUploadExtension",
",",
"EditOnGitHubExtension",
"]",
"if",
"sys",
"."... | Hotdoc's setuptools entry point | [
"Hotdoc",
"s",
"setuptools",
"entry",
"point"
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/extensions/__init__.py#L40-L63 | train |
hotdoc/hotdoc | hotdoc/extensions/c/clang/cindex.py | register_functions | def register_functions(lib, ignore_errors):
"""Register function prototypes with a libclang library instance.
This must be called as part of library instantiation so Python knows how
to call out to the shared library.
"""
def register(item):
return register_function(lib, item, ignore_error... | python | def register_functions(lib, ignore_errors):
"""Register function prototypes with a libclang library instance.
This must be called as part of library instantiation so Python knows how
to call out to the shared library.
"""
def register(item):
return register_function(lib, item, ignore_error... | [
"def",
"register_functions",
"(",
"lib",
",",
"ignore_errors",
")",
":",
"def",
"register",
"(",
"item",
")",
":",
"return",
"register_function",
"(",
"lib",
",",
"item",
",",
"ignore_errors",
")",
"for",
"f",
"in",
"functionList",
":",
"register",
"(",
"f... | Register function prototypes with a libclang library instance.
This must be called as part of library instantiation so Python knows how
to call out to the shared library. | [
"Register",
"function",
"prototypes",
"with",
"a",
"libclang",
"library",
"instance",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/extensions/c/clang/cindex.py#L3814-L3825 | train |
hotdoc/hotdoc | hotdoc/extensions/c/clang/cindex.py | SourceLocation.from_offset | def from_offset(tu, file, offset):
"""Retrieve a SourceLocation from a given character offset.
tu -- TranslationUnit file belongs to
file -- File instance to obtain offset from
offset -- Integer character offset within file
"""
return conf.lib.clang_getLocationForOffset(... | python | def from_offset(tu, file, offset):
"""Retrieve a SourceLocation from a given character offset.
tu -- TranslationUnit file belongs to
file -- File instance to obtain offset from
offset -- Integer character offset within file
"""
return conf.lib.clang_getLocationForOffset(... | [
"def",
"from_offset",
"(",
"tu",
",",
"file",
",",
"offset",
")",
":",
"return",
"conf",
".",
"lib",
".",
"clang_getLocationForOffset",
"(",
"tu",
",",
"file",
",",
"offset",
")"
] | Retrieve a SourceLocation from a given character offset.
tu -- TranslationUnit file belongs to
file -- File instance to obtain offset from
offset -- Integer character offset within file | [
"Retrieve",
"a",
"SourceLocation",
"from",
"a",
"given",
"character",
"offset",
"."
] | 1067cdc8482b585b364a38fb52ca5d904e486280 | https://github.com/hotdoc/hotdoc/blob/1067cdc8482b585b364a38fb52ca5d904e486280/hotdoc/extensions/c/clang/cindex.py#L217-L224 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.