repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Nic30/hwtGraph | hwtGraph/elk/fromHwt/flattenPorts.py | flattenPort | def flattenPort(port: LPort):
"""
Flatten hierarchical ports
"""
yield port
if port.children:
for ch in port.children:
yield from flattenPort(ch)
port.children.clear() | python | def flattenPort(port: LPort):
"""
Flatten hierarchical ports
"""
yield port
if port.children:
for ch in port.children:
yield from flattenPort(ch)
port.children.clear() | [
"def",
"flattenPort",
"(",
"port",
":",
"LPort",
")",
":",
"yield",
"port",
"if",
"port",
".",
"children",
":",
"for",
"ch",
"in",
"port",
".",
"children",
":",
"yield",
"from",
"flattenPort",
"(",
"ch",
")",
"port",
".",
"children",
".",
"clear",
"(... | Flatten hierarchical ports | [
"Flatten",
"hierarchical",
"ports"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/flattenPorts.py#L7-L15 | train | Flatten a port into a single list of hierarchy. |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/flattenPorts.py | _flattenPortsSide | def _flattenPortsSide(side: List[LNode]) -> List[LNode]:
"""
Flatten hierarchical ports on node side
"""
new_side = []
for i in side:
for new_p in flattenPort(i):
new_side.append(new_p)
return new_side | python | def _flattenPortsSide(side: List[LNode]) -> List[LNode]:
"""
Flatten hierarchical ports on node side
"""
new_side = []
for i in side:
for new_p in flattenPort(i):
new_side.append(new_p)
return new_side | [
"def",
"_flattenPortsSide",
"(",
"side",
":",
"List",
"[",
"LNode",
"]",
")",
"->",
"List",
"[",
"LNode",
"]",
":",
"new_side",
"=",
"[",
"]",
"for",
"i",
"in",
"side",
":",
"for",
"new_p",
"in",
"flattenPort",
"(",
"i",
")",
":",
"new_side",
".",
... | Flatten hierarchical ports on node side | [
"Flatten",
"hierarchical",
"ports",
"on",
"node",
"side"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/flattenPorts.py#L18-L26 | train | Flatten hierarchical ports on node side |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/flattenPorts.py | flattenPorts | def flattenPorts(root: LNode):
"""
Flatten ports to simplify layout generation
:attention: children property is destroyed, parent property stays same
"""
for u in root.children:
u.west = _flattenPortsSide(u.west)
u.east = _flattenPortsSide(u.east)
u.north = _flattenPortsSide... | python | def flattenPorts(root: LNode):
"""
Flatten ports to simplify layout generation
:attention: children property is destroyed, parent property stays same
"""
for u in root.children:
u.west = _flattenPortsSide(u.west)
u.east = _flattenPortsSide(u.east)
u.north = _flattenPortsSide... | [
"def",
"flattenPorts",
"(",
"root",
":",
"LNode",
")",
":",
"for",
"u",
"in",
"root",
".",
"children",
":",
"u",
".",
"west",
"=",
"_flattenPortsSide",
"(",
"u",
".",
"west",
")",
"u",
".",
"east",
"=",
"_flattenPortsSide",
"(",
"u",
".",
"east",
"... | Flatten ports to simplify layout generation
:attention: children property is destroyed, parent property stays same | [
"Flatten",
"ports",
"to",
"simplify",
"layout",
"generation"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/flattenPorts.py#L29-L39 | train | Flatten ports to simplify layout generation |
eventifyio/eventify | eventify/__init__.py | Eventify.set_missing_defaults | def set_missing_defaults(self):
"""
Ensure that minimal configuration is
setup and set defaults for missing values
"""
if 'pub_options' not in self.config:
self.config['pub_options'] = {
'acknowledge': True,
'retain': True
}... | python | def set_missing_defaults(self):
"""
Ensure that minimal configuration is
setup and set defaults for missing values
"""
if 'pub_options' not in self.config:
self.config['pub_options'] = {
'acknowledge': True,
'retain': True
}... | [
"def",
"set_missing_defaults",
"(",
"self",
")",
":",
"if",
"'pub_options'",
"not",
"in",
"self",
".",
"config",
":",
"self",
".",
"config",
"[",
"'pub_options'",
"]",
"=",
"{",
"'acknowledge'",
":",
"True",
",",
"'retain'",
":",
"True",
"}",
"if",
"'sub... | Ensure that minimal configuration is
setup and set defaults for missing values | [
"Ensure",
"that",
"minimal",
"configuration",
"is",
"setup",
"and",
"set",
"defaults",
"for",
"missing",
"values"
] | 0e519964a56bd07a879b266f21f177749c63aaed | https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/__init__.py#L48-L71 | train | Ensure that minimal configuration is set and set defaults for missing values |
eventifyio/eventify | eventify/__init__.py | Eventify.config_sanity_check | def config_sanity_check(self):
"""
Base configuration sanity checks
"""
if 'name' not in self.config:
raise EventifyConfigError(
"""Required configuration parameter missing!
Please configure "name" as a string in your
configurat... | python | def config_sanity_check(self):
"""
Base configuration sanity checks
"""
if 'name' not in self.config:
raise EventifyConfigError(
"""Required configuration parameter missing!
Please configure "name" as a string in your
configurat... | [
"def",
"config_sanity_check",
"(",
"self",
")",
":",
"if",
"'name'",
"not",
"in",
"self",
".",
"config",
":",
"raise",
"EventifyConfigError",
"(",
"\"\"\"Required configuration parameter missing!\n Please configure \"name\" as a string in your\n config... | Base configuration sanity checks | [
"Base",
"configuration",
"sanity",
"checks"
] | 0e519964a56bd07a879b266f21f177749c63aaed | https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/__init__.py#L73-L93 | train | Base configuration sanity checks |
eventifyio/eventify | eventify/__init__.py | Eventify.load_config | def load_config(self):
"""
Load configuration for the service
Args:
config_file: Configuration file path
"""
logger.debug('loading config file: %s', self.config_file)
if os.path.exists(self.config_file):
with open(self.config_file) as file_handle:... | python | def load_config(self):
"""
Load configuration for the service
Args:
config_file: Configuration file path
"""
logger.debug('loading config file: %s', self.config_file)
if os.path.exists(self.config_file):
with open(self.config_file) as file_handle:... | [
"def",
"load_config",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'loading config file: %s'",
",",
"self",
".",
"config_file",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"config_file",
")",
":",
"with",
"open",
"(",
"self",
... | Load configuration for the service
Args:
config_file: Configuration file path | [
"Load",
"configuration",
"for",
"the",
"service"
] | 0e519964a56bd07a879b266f21f177749c63aaed | https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/__init__.py#L96-L112 | train | Load the configuration for the service |
eventifyio/eventify | eventify/__init__.py | Eventify.check_event_loop | def check_event_loop():
"""
Check if event loop is closed and
create a new event loop
"""
loop = asyncio.get_event_loop()
if loop.is_closed():
asyncio.set_event_loop(asyncio.new_event_loop()) | python | def check_event_loop():
"""
Check if event loop is closed and
create a new event loop
"""
loop = asyncio.get_event_loop()
if loop.is_closed():
asyncio.set_event_loop(asyncio.new_event_loop()) | [
"def",
"check_event_loop",
"(",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"if",
"loop",
".",
"is_closed",
"(",
")",
":",
"asyncio",
".",
"set_event_loop",
"(",
"asyncio",
".",
"new_event_loop",
"(",
")",
")"
] | Check if event loop is closed and
create a new event loop | [
"Check",
"if",
"event",
"loop",
"is",
"closed",
"and",
"create",
"a",
"new",
"event",
"loop"
] | 0e519964a56bd07a879b266f21f177749c63aaed | https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/__init__.py#L115-L122 | train | Check if event loop is closed and create a new event loop |
geophysics-ubonn/crtomo_tools | src/td_run_all_local.py | is_tomodir | def is_tomodir(subdirectories):
"""provided with the subdirectories of a given directory, check if this is
a tomodir
"""
required = (
'exe',
'config',
'rho',
'mod',
'inv'
)
is_tomodir = True
for subdir in required:
if subdir not in subdirectori... | python | def is_tomodir(subdirectories):
"""provided with the subdirectories of a given directory, check if this is
a tomodir
"""
required = (
'exe',
'config',
'rho',
'mod',
'inv'
)
is_tomodir = True
for subdir in required:
if subdir not in subdirectori... | [
"def",
"is_tomodir",
"(",
"subdirectories",
")",
":",
"required",
"=",
"(",
"'exe'",
",",
"'config'",
",",
"'rho'",
",",
"'mod'",
",",
"'inv'",
")",
"is_tomodir",
"=",
"True",
"for",
"subdir",
"in",
"required",
":",
"if",
"subdir",
"not",
"in",
"subdirec... | provided with the subdirectories of a given directory, check if this is
a tomodir | [
"provided",
"with",
"the",
"subdirectories",
"of",
"a",
"given",
"directory",
"check",
"if",
"this",
"is",
"a",
"tomodir"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_run_all_local.py#L54-L69 | train | check if this is a tomodir |
geophysics-ubonn/crtomo_tools | src/td_run_all_local.py | check_if_needs_modeling | def check_if_needs_modeling(tomodir):
"""check of we need to run CRMod in a given tomodir
"""
print('check for modeling', tomodir)
required_files = (
'config' + os.sep + 'config.dat',
'rho' + os.sep + 'rho.dat',
'grid' + os.sep + 'elem.dat',
'grid' + os.sep + 'elec.dat',
... | python | def check_if_needs_modeling(tomodir):
"""check of we need to run CRMod in a given tomodir
"""
print('check for modeling', tomodir)
required_files = (
'config' + os.sep + 'config.dat',
'rho' + os.sep + 'rho.dat',
'grid' + os.sep + 'elem.dat',
'grid' + os.sep + 'elec.dat',
... | [
"def",
"check_if_needs_modeling",
"(",
"tomodir",
")",
":",
"print",
"(",
"'check for modeling'",
",",
"tomodir",
")",
"required_files",
"=",
"(",
"'config'",
"+",
"os",
".",
"sep",
"+",
"'config.dat'",
",",
"'rho'",
"+",
"os",
".",
"sep",
"+",
"'rho.dat'",
... | check of we need to run CRMod in a given tomodir | [
"check",
"of",
"we",
"need",
"to",
"run",
"CRMod",
"in",
"a",
"given",
"tomodir"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_run_all_local.py#L72-L98 | train | check if we need to run CRMod in a given tomodir |
geophysics-ubonn/crtomo_tools | src/td_run_all_local.py | check_if_needs_inversion | def check_if_needs_inversion(tomodir):
"""check of we need to run CRTomo in a given tomodir
"""
required_files = (
'grid' + os.sep + 'elem.dat',
'grid' + os.sep + 'elec.dat',
'exe' + os.sep + 'crtomo.cfg',
)
needs_inversion = True
for filename in required_files:
... | python | def check_if_needs_inversion(tomodir):
"""check of we need to run CRTomo in a given tomodir
"""
required_files = (
'grid' + os.sep + 'elem.dat',
'grid' + os.sep + 'elec.dat',
'exe' + os.sep + 'crtomo.cfg',
)
needs_inversion = True
for filename in required_files:
... | [
"def",
"check_if_needs_inversion",
"(",
"tomodir",
")",
":",
"required_files",
"=",
"(",
"'grid'",
"+",
"os",
".",
"sep",
"+",
"'elem.dat'",
",",
"'grid'",
"+",
"os",
".",
"sep",
"+",
"'elec.dat'",
",",
"'exe'",
"+",
"os",
".",
"sep",
"+",
"'crtomo.cfg'"... | check of we need to run CRTomo in a given tomodir | [
"check",
"of",
"we",
"need",
"to",
"run",
"CRTomo",
"in",
"a",
"given",
"tomodir"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_run_all_local.py#L101-L130 | train | check if we need to run CRTomo in a given tomodir |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | check_boundaries | def check_boundaries(boundaries):
# generate a complex number for each (x,y) pair
xy = boundaries[:, 0] + 1j * boundaries[:, 1]
"""
# for numpy > 1.9 , use:
unique_values, indices, indices_rev, counts = np.unique(
xy,
return_index=True,
return_inverse=True,
return_cou... | python | def check_boundaries(boundaries):
# generate a complex number for each (x,y) pair
xy = boundaries[:, 0] + 1j * boundaries[:, 1]
"""
# for numpy > 1.9 , use:
unique_values, indices, indices_rev, counts = np.unique(
xy,
return_index=True,
return_inverse=True,
return_cou... | [
"def",
"check_boundaries",
"(",
"boundaries",
")",
":",
"# generate a complex number for each (x,y) pair",
"xy",
"=",
"boundaries",
"[",
":",
",",
"0",
"]",
"+",
"1j",
"*",
"boundaries",
"[",
":",
",",
"1",
"]",
"# numpy 1.8 -->",
"unique_values",
",",
"indices"... | # for numpy > 1.9 , use:
unique_values, indices, indices_rev, counts = np.unique(
xy,
return_index=True,
return_inverse=True,
return_counts=True) | [
"#",
"for",
"numpy",
">",
"1",
".",
"9",
"use",
":",
"unique_values",
"indices",
"indices_rev",
"counts",
"=",
"np",
".",
"unique",
"(",
"xy",
"return_index",
"=",
"True",
"return_inverse",
"=",
"True",
"return_counts",
"=",
"True",
")"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L365-L398 | train | Check that there are no duplicate boundary coordinates. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | add_stabilizer_nodes | def add_stabilizer_nodes(boundaries_raw, electrodes, nr_nodes_between):
"""
Segmentation of nodes:
we have the existing nodes
N.F is the ratio of required nodes and existing nodes
first, add N nodes to each segment
then, add one more node to the F first segments
* assume ord... | python | def add_stabilizer_nodes(boundaries_raw, electrodes, nr_nodes_between):
"""
Segmentation of nodes:
we have the existing nodes
N.F is the ratio of required nodes and existing nodes
first, add N nodes to each segment
then, add one more node to the F first segments
* assume ord... | [
"def",
"add_stabilizer_nodes",
"(",
"boundaries_raw",
",",
"electrodes",
",",
"nr_nodes_between",
")",
":",
"boundaries",
"=",
"[",
"]",
"boundaries",
"=",
"boundaries_raw",
"# find first electrode in boundary",
"for",
"nr",
"in",
"range",
"(",
"electrodes",
".",
"s... | Segmentation of nodes:
we have the existing nodes
N.F is the ratio of required nodes and existing nodes
first, add N nodes to each segment
then, add one more node to the F first segments
* assume ordered boundaries | [
"Segmentation",
"of",
"nodes",
":",
"we",
"have",
"the",
"existing",
"nodes",
"N",
".",
"F",
"is",
"the",
"ratio",
"of",
"required",
"nodes",
"and",
"existing",
"nodes",
"first",
"add",
"N",
"nodes",
"to",
"each",
"segment",
"then",
"add",
"one",
"more",... | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L401-L454 | train | This function adds stabilizer nodes to the internal list of nodes that are not already in the internal list. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.get_point_id | def get_point_id(self, p, char_length):
"""
Return the id of the given point (x,y) tuple.
"""
print('Checking point', p)
# TODO: This search loop NEEDS to be replaced with something sane
index = -1
for nr, i in enumerate(self.Points):
if(np.all(i == p)... | python | def get_point_id(self, p, char_length):
"""
Return the id of the given point (x,y) tuple.
"""
print('Checking point', p)
# TODO: This search loop NEEDS to be replaced with something sane
index = -1
for nr, i in enumerate(self.Points):
if(np.all(i == p)... | [
"def",
"get_point_id",
"(",
"self",
",",
"p",
",",
"char_length",
")",
":",
"print",
"(",
"'Checking point'",
",",
"p",
")",
"# TODO: This search loop NEEDS to be replaced with something sane",
"index",
"=",
"-",
"1",
"for",
"nr",
",",
"i",
"in",
"enumerate",
"(... | Return the id of the given point (x,y) tuple. | [
"Return",
"the",
"id",
"of",
"the",
"given",
"point",
"(",
"x",
"y",
")",
"tuple",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L112-L131 | train | Returns the id of the given point. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.add_boundary | def add_boundary(self, p1, p2, btype):
"""
Add a boundary line
"""
index = self.add_line(p1, p2, self.char_lengths['boundary'])
# self.Boundaries.append((p1_id,p2_id,btype))
self.BoundaryIndices.append(index)
self.Boundaries.append((p1, p2, btype)) | python | def add_boundary(self, p1, p2, btype):
"""
Add a boundary line
"""
index = self.add_line(p1, p2, self.char_lengths['boundary'])
# self.Boundaries.append((p1_id,p2_id,btype))
self.BoundaryIndices.append(index)
self.Boundaries.append((p1, p2, btype)) | [
"def",
"add_boundary",
"(",
"self",
",",
"p1",
",",
"p2",
",",
"btype",
")",
":",
"index",
"=",
"self",
".",
"add_line",
"(",
"p1",
",",
"p2",
",",
"self",
".",
"char_lengths",
"[",
"'boundary'",
"]",
")",
"# self.Boundaries.append((p1_id,p2_id,btype))",
"... | Add a boundary line | [
"Add",
"a",
"boundary",
"line"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L133-L140 | train | Add a boundary line to the set of boundary entries. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.add_line | def add_line(self, p1, p2, char_length):
"""
Add a line to the list. Check if the nodes already exist, and add them
if not.
Return the line index (1-indixed, starting with 1)
"""
p1_id = self.get_point_id(p1, char_length)
p2_id = self.get_point_id(p2, char_length... | python | def add_line(self, p1, p2, char_length):
"""
Add a line to the list. Check if the nodes already exist, and add them
if not.
Return the line index (1-indixed, starting with 1)
"""
p1_id = self.get_point_id(p1, char_length)
p2_id = self.get_point_id(p2, char_length... | [
"def",
"add_line",
"(",
"self",
",",
"p1",
",",
"p2",
",",
"char_length",
")",
":",
"p1_id",
"=",
"self",
".",
"get_point_id",
"(",
"p1",
",",
"char_length",
")",
"p2_id",
"=",
"self",
".",
"get_point_id",
"(",
"p2",
",",
"char_length",
")",
"self",
... | Add a line to the list. Check if the nodes already exist, and add them
if not.
Return the line index (1-indixed, starting with 1) | [
"Add",
"a",
"line",
"to",
"the",
"list",
".",
"Check",
"if",
"the",
"nodes",
"already",
"exist",
"and",
"add",
"them",
"if",
"not",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L142-L152 | train | Add a line to the list. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.is_in | def is_in(self, search_list, pair):
"""
If pair is in search_list, return the index. Otherwise return -1
"""
index = -1
for nr, i in enumerate(search_list):
if(np.all(i == pair)):
return nr
return index | python | def is_in(self, search_list, pair):
"""
If pair is in search_list, return the index. Otherwise return -1
"""
index = -1
for nr, i in enumerate(search_list):
if(np.all(i == pair)):
return nr
return index | [
"def",
"is_in",
"(",
"self",
",",
"search_list",
",",
"pair",
")",
":",
"index",
"=",
"-",
"1",
"for",
"nr",
",",
"i",
"in",
"enumerate",
"(",
"search_list",
")",
":",
"if",
"(",
"np",
".",
"all",
"(",
"i",
"==",
"pair",
")",
")",
":",
"return"... | If pair is in search_list, return the index. Otherwise return -1 | [
"If",
"pair",
"is",
"in",
"search_list",
"return",
"the",
"index",
".",
"Otherwise",
"return",
"-",
"1"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L154-L162 | train | Returns the index of the item in the list that is in the list. If the item is not in the list return - 1. Otherwise return - 1. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.read_electrodes | def read_electrodes(self, electrodes):
"""
Read in electrodes, check if points already exist
"""
for nr, electrode in enumerate(electrodes):
index = self.get_point_id(
electrode, self.char_lengths['electrode'])
self.Electrodes.append(index) | python | def read_electrodes(self, electrodes):
"""
Read in electrodes, check if points already exist
"""
for nr, electrode in enumerate(electrodes):
index = self.get_point_id(
electrode, self.char_lengths['electrode'])
self.Electrodes.append(index) | [
"def",
"read_electrodes",
"(",
"self",
",",
"electrodes",
")",
":",
"for",
"nr",
",",
"electrode",
"in",
"enumerate",
"(",
"electrodes",
")",
":",
"index",
"=",
"self",
".",
"get_point_id",
"(",
"electrode",
",",
"self",
".",
"char_lengths",
"[",
"'electro... | Read in electrodes, check if points already exist | [
"Read",
"in",
"electrodes",
"check",
"if",
"points",
"already",
"exist"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L164-L171 | train | Read in electrodes from the given list of electrodes. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.read_extra_nodes | def read_extra_nodes(self, filename):
"""Read extra nodes in. Format: x y
What happens if we add nodes on the boundaries, which are not included
in the boundaries?
"""
data = np.atleast_2d(np.loadtxt(filename))
for nr, pair in enumerate(data):
index = self.ge... | python | def read_extra_nodes(self, filename):
"""Read extra nodes in. Format: x y
What happens if we add nodes on the boundaries, which are not included
in the boundaries?
"""
data = np.atleast_2d(np.loadtxt(filename))
for nr, pair in enumerate(data):
index = self.ge... | [
"def",
"read_extra_nodes",
"(",
"self",
",",
"filename",
")",
":",
"data",
"=",
"np",
".",
"atleast_2d",
"(",
"np",
".",
"loadtxt",
"(",
"filename",
")",
")",
"for",
"nr",
",",
"pair",
"in",
"enumerate",
"(",
"data",
")",
":",
"index",
"=",
"self",
... | Read extra nodes in. Format: x y
What happens if we add nodes on the boundaries, which are not included
in the boundaries? | [
"Read",
"extra",
"nodes",
"in",
".",
"Format",
":",
"x",
"y"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L173-L182 | train | Read extra nodes from a file. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.read_extra_lines | def read_extra_lines(self, filename):
"""Read extra lines from the given filename. Each line is defined in
one line with four coordinates: x1 y1 x2 y2. (x1,y1) denotes the
starting point, (x2, y2) the end point of the line.
"""
data = np.atleast_2d(np.loadtxt(filename))
f... | python | def read_extra_lines(self, filename):
"""Read extra lines from the given filename. Each line is defined in
one line with four coordinates: x1 y1 x2 y2. (x1,y1) denotes the
starting point, (x2, y2) the end point of the line.
"""
data = np.atleast_2d(np.loadtxt(filename))
f... | [
"def",
"read_extra_lines",
"(",
"self",
",",
"filename",
")",
":",
"data",
"=",
"np",
".",
"atleast_2d",
"(",
"np",
".",
"loadtxt",
"(",
"filename",
")",
")",
"for",
"nr",
",",
"coords",
"in",
"enumerate",
"(",
"data",
")",
":",
"p1",
"=",
"[",
"co... | Read extra lines from the given filename. Each line is defined in
one line with four coordinates: x1 y1 x2 y2. (x1,y1) denotes the
starting point, (x2, y2) the end point of the line. | [
"Read",
"extra",
"lines",
"from",
"the",
"given",
"filename",
".",
"Each",
"line",
"is",
"defined",
"in",
"one",
"line",
"with",
"four",
"coordinates",
":",
"x1",
"y1",
"x2",
"y2",
".",
"(",
"x1",
"y1",
")",
"denotes",
"the",
"starting",
"point",
"(",
... | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L184-L194 | train | Read extra lines from the given file. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.write_electrodes | def write_electrodes(self, filename):
"""
Write X Y coordinates of electrodes
"""
fid = open(filename, 'w')
for i in self.Electrodes:
fid.write('{0} {1}\n'.format(self.Points[i][0], self.Points[i][1]))
fid.close() | python | def write_electrodes(self, filename):
"""
Write X Y coordinates of electrodes
"""
fid = open(filename, 'w')
for i in self.Electrodes:
fid.write('{0} {1}\n'.format(self.Points[i][0], self.Points[i][1]))
fid.close() | [
"def",
"write_electrodes",
"(",
"self",
",",
"filename",
")",
":",
"fid",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"for",
"i",
"in",
"self",
".",
"Electrodes",
":",
"fid",
".",
"write",
"(",
"'{0} {1}\\n'",
".",
"format",
"(",
"self",
".",
"Poi... | Write X Y coordinates of electrodes | [
"Write",
"X",
"Y",
"coordinates",
"of",
"electrodes"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L196-L203 | train | Write X Y coordinates of electrodes to file |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.write_boundaries | def write_boundaries(self, filename):
"""
Write boundary lines X1 Y1 X2 Y2 TYPE to file
"""
fid = open(filename, 'w')
for i in self.Boundaries:
print(i)
# fid.write('{0} {1} {2}\n'.format(i[0], i[1], i[2]))
fid.write(
'{0} {1} {... | python | def write_boundaries(self, filename):
"""
Write boundary lines X1 Y1 X2 Y2 TYPE to file
"""
fid = open(filename, 'w')
for i in self.Boundaries:
print(i)
# fid.write('{0} {1} {2}\n'.format(i[0], i[1], i[2]))
fid.write(
'{0} {1} {... | [
"def",
"write_boundaries",
"(",
"self",
",",
"filename",
")",
":",
"fid",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"for",
"i",
"in",
"self",
".",
"Boundaries",
":",
"print",
"(",
"i",
")",
"# fid.write('{0} {1} {2}\\n'.format(i[0], i[1], i[2]))",
"fid",
... | Write boundary lines X1 Y1 X2 Y2 TYPE to file | [
"Write",
"boundary",
"lines",
"X1",
"Y1",
"X2",
"Y2",
"TYPE",
"to",
"file"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L205-L216 | train | Write the boundaries of the current assessment to a file. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.read_char_lengths | def read_char_lengths(self, filename, electrode_filename):
"""Read characteristic lengths from the given file.
The file is expected to have either 1 or 4 entries/lines with
characteristic lengths > 0 (floats). If only one value is encountered,
it is used for all four entities. If four v... | python | def read_char_lengths(self, filename, electrode_filename):
"""Read characteristic lengths from the given file.
The file is expected to have either 1 or 4 entries/lines with
characteristic lengths > 0 (floats). If only one value is encountered,
it is used for all four entities. If four v... | [
"def",
"read_char_lengths",
"(",
"self",
",",
"filename",
",",
"electrode_filename",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"data",
"=",
"np",
".",
"atleast_1d",
"(",
"np",
".",
"loadtxt",
"(",
"filename",
")",
")"... | Read characteristic lengths from the given file.
The file is expected to have either 1 or 4 entries/lines with
characteristic lengths > 0 (floats). If only one value is encountered,
it is used for all four entities. If four values are encountered, they
are assigned, in order, to:
... | [
"Read",
"characteristic",
"lengths",
"from",
"the",
"given",
"file",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L218-L287 | train | Read the character lengths from the given file. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.write_points | def write_points(self, fid):
"""
Write the grid points to the GMSH-command file.
Parameters
----------
fid: file object for the command file (.geo)
"""
for nr, point in enumerate(self.Points):
fid.write(
'Point({0}) = {{{1}, {2}, 0, {... | python | def write_points(self, fid):
"""
Write the grid points to the GMSH-command file.
Parameters
----------
fid: file object for the command file (.geo)
"""
for nr, point in enumerate(self.Points):
fid.write(
'Point({0}) = {{{1}, {2}, 0, {... | [
"def",
"write_points",
"(",
"self",
",",
"fid",
")",
":",
"for",
"nr",
",",
"point",
"in",
"enumerate",
"(",
"self",
".",
"Points",
")",
":",
"fid",
".",
"write",
"(",
"'Point({0}) = {{{1}, {2}, 0, {3}}};\\n'",
".",
"format",
"(",
"nr",
"+",
"1",
",",
... | Write the grid points to the GMSH-command file.
Parameters
----------
fid: file object for the command file (.geo) | [
"Write",
"the",
"grid",
"points",
"to",
"the",
"GMSH",
"-",
"command",
"file",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L289-L301 | train | Writes the grid points to the GMSH - command file. |
geophysics-ubonn/crtomo_tools | src/cr_trig_create.py | Mesh.write_geo_file | def write_geo_file(self, filename):
"""
Write the .geo file
"""
fid = open(filename, 'w')
# 2D mesh algorithm (1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal,
# 7=bamg, 8=delquad)
# according to the GMSH-mailing list the frontal algorithm should be
# one ... | python | def write_geo_file(self, filename):
"""
Write the .geo file
"""
fid = open(filename, 'w')
# 2D mesh algorithm (1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal,
# 7=bamg, 8=delquad)
# according to the GMSH-mailing list the frontal algorithm should be
# one ... | [
"def",
"write_geo_file",
"(",
"self",
",",
"filename",
")",
":",
"fid",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"# 2D mesh algorithm (1=MeshAdapt, 2=Automatic, 5=Delaunay, 6=Frontal,",
"# 7=bamg, 8=delquad)",
"# according to the GMSH-mailing list the frontal algorithm shou... | Write the .geo file | [
"Write",
"the",
".",
"geo",
"file"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_create.py#L317-L362 | train | Write the. geo file. |
zalando-stups/lizzy-client | lizzy_client/lizzy.py | Lizzy.get_output | def get_output(cls, response: requests.Response) -> str:
"""
Extracts the senza cli output from the response
"""
output = response.headers['X-Lizzy-Output'] # type: str
output = output.replace('\\n', '\n') # unescape new lines
lines = ('[AGENT] {}'.format(line) for line... | python | def get_output(cls, response: requests.Response) -> str:
"""
Extracts the senza cli output from the response
"""
output = response.headers['X-Lizzy-Output'] # type: str
output = output.replace('\\n', '\n') # unescape new lines
lines = ('[AGENT] {}'.format(line) for line... | [
"def",
"get_output",
"(",
"cls",
",",
"response",
":",
"requests",
".",
"Response",
")",
"->",
"str",
":",
"output",
"=",
"response",
".",
"headers",
"[",
"'X-Lizzy-Output'",
"]",
"# type: str",
"output",
"=",
"output",
".",
"replace",
"(",
"'\\\\n'",
",",... | Extracts the senza cli output from the response | [
"Extracts",
"the",
"senza",
"cli",
"output",
"from",
"the",
"response"
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/lizzy.py#L25-L32 | train | Extracts the senza cli output from the response |
zalando-stups/lizzy-client | lizzy_client/lizzy.py | Lizzy.new_stack | def new_stack(self,
keep_stacks: int,
new_traffic: int,
senza_yaml: dict,
stack_version: str,
disable_rollback: bool,
parameters: List[str],
region: Optional[str],
dry_run: boo... | python | def new_stack(self,
keep_stacks: int,
new_traffic: int,
senza_yaml: dict,
stack_version: str,
disable_rollback: bool,
parameters: List[str],
region: Optional[str],
dry_run: boo... | [
"def",
"new_stack",
"(",
"self",
",",
"keep_stacks",
":",
"int",
",",
"new_traffic",
":",
"int",
",",
"senza_yaml",
":",
"dict",
",",
"stack_version",
":",
"str",
",",
"disable_rollback",
":",
"bool",
",",
"parameters",
":",
"List",
"[",
"str",
"]",
",",... | Requests a new stack. | [
"Requests",
"a",
"new",
"stack",
"."
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/lizzy.py#L76-L103 | train | Requests a new stack. |
geophysics-ubonn/crtomo_tools | lib/crtomo/analytical_solution.py | pot_ana | def pot_ana(r, rho):
"""Return the analytical potential in distance r over a homogeneous
half-space
"""
I = 1.0
sigma = 1.0 / rho
phi = np.divide(I, (2.0 * np.pi * sigma * r))
return phi | python | def pot_ana(r, rho):
"""Return the analytical potential in distance r over a homogeneous
half-space
"""
I = 1.0
sigma = 1.0 / rho
phi = np.divide(I, (2.0 * np.pi * sigma * r))
return phi | [
"def",
"pot_ana",
"(",
"r",
",",
"rho",
")",
":",
"I",
"=",
"1.0",
"sigma",
"=",
"1.0",
"/",
"rho",
"phi",
"=",
"np",
".",
"divide",
"(",
"I",
",",
"(",
"2.0",
"*",
"np",
".",
"pi",
"*",
"sigma",
"*",
"r",
")",
")",
"return",
"phi"
] | Return the analytical potential in distance r over a homogeneous
half-space | [
"Return",
"the",
"analytical",
"potential",
"in",
"distance",
"r",
"over",
"a",
"homogeneous",
"half",
"-",
"space"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/analytical_solution.py#L12-L19 | train | Return the analytical potential in distance r over a homogeneous
half - space
|
geophysics-ubonn/crtomo_tools | lib/crtomo/analytical_solution.py | compute_potentials_analytical_hs | def compute_potentials_analytical_hs(grid, configs_raw, rho):
"""Compute the potential superpositions of each current dipole in the
configurations, using the provided resistivity
Parameters
----------
grid:
crt_grid object with loaded FE grid. Used for the electrode positions
configs_ra... | python | def compute_potentials_analytical_hs(grid, configs_raw, rho):
"""Compute the potential superpositions of each current dipole in the
configurations, using the provided resistivity
Parameters
----------
grid:
crt_grid object with loaded FE grid. Used for the electrode positions
configs_ra... | [
"def",
"compute_potentials_analytical_hs",
"(",
"grid",
",",
"configs_raw",
",",
"rho",
")",
":",
"potentials",
"=",
"[",
"]",
"nodes_sorted",
"=",
"grid",
".",
"nodes",
"[",
"'sorted'",
"]",
"nodes_raw",
"=",
"grid",
".",
"nodes",
"[",
"'sorted'",
"]",
"f... | Compute the potential superpositions of each current dipole in the
configurations, using the provided resistivity
Parameters
----------
grid:
crt_grid object with loaded FE grid. Used for the electrode positions
configs_raw: numpy.ndarray
Nx4 array containing N four-point spreads
... | [
"Compute",
"the",
"potential",
"superpositions",
"of",
"each",
"current",
"dipole",
"in",
"the",
"configurations",
"using",
"the",
"provided",
"resistivity"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/analytical_solution.py#L22-L68 | train | Compute the potential superpositions of each current dipole in the given configs using the provided resistivity of half - space. |
geophysics-ubonn/crtomo_tools | lib/crtomo/analytical_solution.py | compute_voltages | def compute_voltages(grid, configs_raw, potentials_raw):
"""Given a list of potential distribution and corresponding four-point
spreads, compute the voltages
Parameters
----------
grid:
crt_grid object the grid is used to infer electrode positions
configs_raw: Nx4 array
containi... | python | def compute_voltages(grid, configs_raw, potentials_raw):
"""Given a list of potential distribution and corresponding four-point
spreads, compute the voltages
Parameters
----------
grid:
crt_grid object the grid is used to infer electrode positions
configs_raw: Nx4 array
containi... | [
"def",
"compute_voltages",
"(",
"grid",
",",
"configs_raw",
",",
"potentials_raw",
")",
":",
"# we operate on 0-indexed arrays, config holds 1-indexed values",
"# configs = configs_raw - 1",
"voltages",
"=",
"[",
"]",
"for",
"config",
",",
"potentials",
"in",
"zip",
"(",
... | Given a list of potential distribution and corresponding four-point
spreads, compute the voltages
Parameters
----------
grid:
crt_grid object the grid is used to infer electrode positions
configs_raw: Nx4 array
containing the measurement configs (1-indexed)
potentials_raw: list ... | [
"Given",
"a",
"list",
"of",
"potential",
"distribution",
"and",
"corresponding",
"four",
"-",
"point",
"spreads",
"compute",
"the",
"voltages"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/analytical_solution.py#L71-L97 | train | Given a list of potential distribution and corresponding four - point chains compute the voltages of the electrodes in the order they appear. |
pgxcentre/geneparse | geneparse/extract/__main__.py | vcf_writer | def vcf_writer(parser, keep, extract, args):
"""Writes the data in VCF format."""
# The output
output = sys.stdout if args.output == "-" else open(args.output, "w")
try:
# Getting the samples
samples = np.array(parser.get_samples(), dtype=str)
k = _get_sample_select(samples=samp... | python | def vcf_writer(parser, keep, extract, args):
"""Writes the data in VCF format."""
# The output
output = sys.stdout if args.output == "-" else open(args.output, "w")
try:
# Getting the samples
samples = np.array(parser.get_samples(), dtype=str)
k = _get_sample_select(samples=samp... | [
"def",
"vcf_writer",
"(",
"parser",
",",
"keep",
",",
"extract",
",",
"args",
")",
":",
"# The output",
"output",
"=",
"sys",
".",
"stdout",
"if",
"args",
".",
"output",
"==",
"\"-\"",
"else",
"open",
"(",
"args",
".",
"output",
",",
"\"w\"",
")",
"t... | Writes the data in VCF format. | [
"Writes",
"the",
"data",
"in",
"VCF",
"format",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/extract/__main__.py#L133-L184 | train | Writes the data in VCF format. |
pgxcentre/geneparse | geneparse/extract/__main__.py | csv_writer | def csv_writer(parser, keep, extract, args):
"""Writes the data in CSV format."""
# The output
output = sys.stdout if args.output == "-" else open(args.output, "w")
try:
# Getting the samples
samples = np.array(parser.get_samples(), dtype=str)
k = _get_sample_select(samples=samp... | python | def csv_writer(parser, keep, extract, args):
"""Writes the data in CSV format."""
# The output
output = sys.stdout if args.output == "-" else open(args.output, "w")
try:
# Getting the samples
samples = np.array(parser.get_samples(), dtype=str)
k = _get_sample_select(samples=samp... | [
"def",
"csv_writer",
"(",
"parser",
",",
"keep",
",",
"extract",
",",
"args",
")",
":",
"# The output",
"output",
"=",
"sys",
".",
"stdout",
"if",
"args",
".",
"output",
"==",
"\"-\"",
"else",
"open",
"(",
"args",
".",
"output",
",",
"\"w\"",
")",
"t... | Writes the data in CSV format. | [
"Writes",
"the",
"data",
"in",
"CSV",
"format",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/extract/__main__.py#L187-L241 | train | Writes the data in CSV format. |
pgxcentre/geneparse | geneparse/extract/__main__.py | bed_writer | def bed_writer(parser, keep, extract, args):
"""Writes BED/BIM/FAM files."""
# The output bed and bim file
bim_fn = args.output + ".bim"
with open(bim_fn, "w") as bim, PyPlink(args.output, "w") as bed:
# Getting the samples
samples = np.array(parser.get_samples(), dtype=str)
k = ... | python | def bed_writer(parser, keep, extract, args):
"""Writes BED/BIM/FAM files."""
# The output bed and bim file
bim_fn = args.output + ".bim"
with open(bim_fn, "w") as bim, PyPlink(args.output, "w") as bed:
# Getting the samples
samples = np.array(parser.get_samples(), dtype=str)
k = ... | [
"def",
"bed_writer",
"(",
"parser",
",",
"keep",
",",
"extract",
",",
"args",
")",
":",
"# The output bed and bim file",
"bim_fn",
"=",
"args",
".",
"output",
"+",
"\".bim\"",
"with",
"open",
"(",
"bim_fn",
",",
"\"w\"",
")",
"as",
"bim",
",",
"PyPlink",
... | Writes BED/BIM/FAM files. | [
"Writes",
"BED",
"/",
"BIM",
"/",
"FAM",
"files",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/extract/__main__.py#L244-L283 | train | Writes the BED file containing the current set of markers and the FAM files. |
pgxcentre/geneparse | geneparse/extract/__main__.py | _get_sample_select | def _get_sample_select(samples, keep):
"""Returns a vector of True/False to keep samples."""
k = np.ones_like(samples, dtype=bool)
if keep is not None:
k = np.array([s in keep for s in samples], dtype=bool)
if np.sum(k) == 0:
logger.warning("No samples matched the keep list")
... | python | def _get_sample_select(samples, keep):
"""Returns a vector of True/False to keep samples."""
k = np.ones_like(samples, dtype=bool)
if keep is not None:
k = np.array([s in keep for s in samples], dtype=bool)
if np.sum(k) == 0:
logger.warning("No samples matched the keep list")
... | [
"def",
"_get_sample_select",
"(",
"samples",
",",
"keep",
")",
":",
"k",
"=",
"np",
".",
"ones_like",
"(",
"samples",
",",
"dtype",
"=",
"bool",
")",
"if",
"keep",
"is",
"not",
"None",
":",
"k",
"=",
"np",
".",
"array",
"(",
"[",
"s",
"in",
"keep... | Returns a vector of True/False to keep samples. | [
"Returns",
"a",
"vector",
"of",
"True",
"/",
"False",
"to",
"keep",
"samples",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/extract/__main__.py#L286-L293 | train | Returns a vector of True or False to keep samples. |
pgxcentre/geneparse | geneparse/extract/__main__.py | _get_generator | def _get_generator(parser, extract, keep, check_maf):
"""Generates the data (with extract markers and keep, if required."""
if extract is not None:
parser = Extractor(parser, names=extract)
for data in parser.iter_genotypes():
data.genotypes = data.genotypes[keep]
# Checking the MA... | python | def _get_generator(parser, extract, keep, check_maf):
"""Generates the data (with extract markers and keep, if required."""
if extract is not None:
parser = Extractor(parser, names=extract)
for data in parser.iter_genotypes():
data.genotypes = data.genotypes[keep]
# Checking the MA... | [
"def",
"_get_generator",
"(",
"parser",
",",
"extract",
",",
"keep",
",",
"check_maf",
")",
":",
"if",
"extract",
"is",
"not",
"None",
":",
"parser",
"=",
"Extractor",
"(",
"parser",
",",
"names",
"=",
"extract",
")",
"for",
"data",
"in",
"parser",
"."... | Generates the data (with extract markers and keep, if required. | [
"Generates",
"the",
"data",
"(",
"with",
"extract",
"markers",
"and",
"keep",
"if",
"required",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/extract/__main__.py#L296-L308 | train | Generates the data from the parser with extract markers and keep if required. |
pgxcentre/geneparse | geneparse/extract/__main__.py | check_args | def check_args(args):
"""Checks the arguments and options."""
# Checking that only VCF can have a - (stdout) as output
if args.output_format not in _streamable_format and args.output == "-":
logger.error("{} format cannot be streamed to standard output"
"".format(args.output_for... | python | def check_args(args):
"""Checks the arguments and options."""
# Checking that only VCF can have a - (stdout) as output
if args.output_format not in _streamable_format and args.output == "-":
logger.error("{} format cannot be streamed to standard output"
"".format(args.output_for... | [
"def",
"check_args",
"(",
"args",
")",
":",
"# Checking that only VCF can have a - (stdout) as output",
"if",
"args",
".",
"output_format",
"not",
"in",
"_streamable_format",
"and",
"args",
".",
"output",
"==",
"\"-\"",
":",
"logger",
".",
"error",
"(",
"\"{} format... | Checks the arguments and options. | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/extract/__main__.py#L311-L326 | train | Checks the arguments and options. |
pgxcentre/geneparse | geneparse/extract/__main__.py | parse_args | def parse_args():
"""Parses the arguments and options."""
parser = argparse.ArgumentParser(
prog="geneparse-extractor",
description="Genotype file extractor. This tool will extract markers "
"according to names or to genomic locations.",
epilog="The parser arguments (... | python | def parse_args():
"""Parses the arguments and options."""
parser = argparse.ArgumentParser(
prog="geneparse-extractor",
description="Genotype file extractor. This tool will extract markers "
"according to names or to genomic locations.",
epilog="The parser arguments (... | [
"def",
"parse_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"\"geneparse-extractor\"",
",",
"description",
"=",
"\"Genotype file extractor. This tool will extract markers \"",
"\"according to names or to genomic locations.\"",
",",
... | Parses the arguments and options. | [
"Parses",
"the",
"arguments",
"and",
"options",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/extract/__main__.py#L329-L385 | train | Parses the arguments and options and returns the arguments and options. |
hotzenklotz/pybeerxml | pybeerxml/hop.py | Hop.bitterness | def bitterness(self, ibu_method, early_og, batch_size):
"Calculate bitterness based on chosen method"
if ibu_method == "tinseth":
bitterness = 1.65 * math.pow(0.000125, early_og - 1.0) * ((1 - math.pow(math.e, -0.04 * self.time)) / 4.15) * ((self.alpha / 100.0 * self.amount * 1000000) / bat... | python | def bitterness(self, ibu_method, early_og, batch_size):
"Calculate bitterness based on chosen method"
if ibu_method == "tinseth":
bitterness = 1.65 * math.pow(0.000125, early_og - 1.0) * ((1 - math.pow(math.e, -0.04 * self.time)) / 4.15) * ((self.alpha / 100.0 * self.amount * 1000000) / bat... | [
"def",
"bitterness",
"(",
"self",
",",
"ibu_method",
",",
"early_og",
",",
"batch_size",
")",
":",
"if",
"ibu_method",
"==",
"\"tinseth\"",
":",
"bitterness",
"=",
"1.65",
"*",
"math",
".",
"pow",
"(",
"0.000125",
",",
"early_og",
"-",
"1.0",
")",
"*",
... | Calculate bitterness based on chosen method | [
"Calculate",
"bitterness",
"based",
"on",
"chosen",
"method"
] | e9cf8d6090b1e01e5bbb101e255792b134affbe0 | https://github.com/hotzenklotz/pybeerxml/blob/e9cf8d6090b1e01e5bbb101e255792b134affbe0/pybeerxml/hop.py#L18-L32 | train | Calculate bitterness based on chosen method |
Alidron/spyrk | spyrk/spark_cloud.py | SparkCloud._check_error | def _check_error(response):
"""Raises an exception if the Spark Cloud returned an error."""
if (not response.ok) or (response.status_code != 200):
raise Exception(
response.json()['error'] + ': ' +
response.json()['error_description']
) | python | def _check_error(response):
"""Raises an exception if the Spark Cloud returned an error."""
if (not response.ok) or (response.status_code != 200):
raise Exception(
response.json()['error'] + ': ' +
response.json()['error_description']
) | [
"def",
"_check_error",
"(",
"response",
")",
":",
"if",
"(",
"not",
"response",
".",
"ok",
")",
"or",
"(",
"response",
".",
"status_code",
"!=",
"200",
")",
":",
"raise",
"Exception",
"(",
"response",
".",
"json",
"(",
")",
"[",
"'error'",
"]",
"+",
... | Raises an exception if the Spark Cloud returned an error. | [
"Raises",
"an",
"exception",
"if",
"the",
"Spark",
"Cloud",
"returned",
"an",
"error",
"."
] | fc1d7c0892a351cf742bf07e95b852fd6bf7c108 | https://github.com/Alidron/spyrk/blob/fc1d7c0892a351cf742bf07e95b852fd6bf7c108/spyrk/spark_cloud.py#L76-L82 | train | Raises an exception if the Spark Cloud returned an error. |
Alidron/spyrk | spyrk/spark_cloud.py | SparkCloud._login | def _login(self, username, password):
"""Proceed to login to the Spark Cloud and returns an access token."""
data = {
'username': username,
'password': password,
'grant_type': 'password'
}
r = self.spark_api.oauth.token.POST(auth=('spark', 'spark'), da... | python | def _login(self, username, password):
"""Proceed to login to the Spark Cloud and returns an access token."""
data = {
'username': username,
'password': password,
'grant_type': 'password'
}
r = self.spark_api.oauth.token.POST(auth=('spark', 'spark'), da... | [
"def",
"_login",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"data",
"=",
"{",
"'username'",
":",
"username",
",",
"'password'",
":",
"password",
",",
"'grant_type'",
":",
"'password'",
"}",
"r",
"=",
"self",
".",
"spark_api",
".",
"oauth",
... | Proceed to login to the Spark Cloud and returns an access token. | [
"Proceed",
"to",
"login",
"to",
"the",
"Spark",
"Cloud",
"and",
"returns",
"an",
"access",
"token",
"."
] | fc1d7c0892a351cf742bf07e95b852fd6bf7c108 | https://github.com/Alidron/spyrk/blob/fc1d7c0892a351cf742bf07e95b852fd6bf7c108/spyrk/spark_cloud.py#L84-L93 | train | Proceed to login to the Spark Cloud and returns an access token. |
Alidron/spyrk | spyrk/spark_cloud.py | SparkCloud.devices | def devices(self):
"""Create a dictionary of devices known to the user account."""
params = {'access_token': self.access_token}
r = self.spark_api.GET(params=params, timeout=self.timeout)
self._check_error(r)
json_list = r.json()
devices_dict = {}
if json_list:
... | python | def devices(self):
"""Create a dictionary of devices known to the user account."""
params = {'access_token': self.access_token}
r = self.spark_api.GET(params=params, timeout=self.timeout)
self._check_error(r)
json_list = r.json()
devices_dict = {}
if json_list:
... | [
"def",
"devices",
"(",
"self",
")",
":",
"params",
"=",
"{",
"'access_token'",
":",
"self",
".",
"access_token",
"}",
"r",
"=",
"self",
".",
"spark_api",
".",
"GET",
"(",
"params",
"=",
"params",
",",
"timeout",
"=",
"self",
".",
"timeout",
")",
"sel... | Create a dictionary of devices known to the user account. | [
"Create",
"a",
"dictionary",
"of",
"devices",
"known",
"to",
"the",
"user",
"account",
"."
] | fc1d7c0892a351cf742bf07e95b852fd6bf7c108 | https://github.com/Alidron/spyrk/blob/fc1d7c0892a351cf742bf07e95b852fd6bf7c108/spyrk/spark_cloud.py#L96-L125 | train | Create a dictionary of devices known to the user account. |
Alidron/spyrk | spyrk/spark_cloud.py | SparkCloud._get_device_info | def _get_device_info(self, device_id):
"""Queries the Spark Cloud for detailed information about a device."""
params = {'access_token': self.access_token}
r = self.spark_api(device_id).GET(params=params, timeout=30)
self._check_error(r)
return r.json() | python | def _get_device_info(self, device_id):
"""Queries the Spark Cloud for detailed information about a device."""
params = {'access_token': self.access_token}
r = self.spark_api(device_id).GET(params=params, timeout=30)
self._check_error(r)
return r.json() | [
"def",
"_get_device_info",
"(",
"self",
",",
"device_id",
")",
":",
"params",
"=",
"{",
"'access_token'",
":",
"self",
".",
"access_token",
"}",
"r",
"=",
"self",
".",
"spark_api",
"(",
"device_id",
")",
".",
"GET",
"(",
"params",
"=",
"params",
",",
"... | Queries the Spark Cloud for detailed information about a device. | [
"Queries",
"the",
"Spark",
"Cloud",
"for",
"detailed",
"information",
"about",
"a",
"device",
"."
] | fc1d7c0892a351cf742bf07e95b852fd6bf7c108 | https://github.com/Alidron/spyrk/blob/fc1d7c0892a351cf742bf07e95b852fd6bf7c108/spyrk/spark_cloud.py#L127-L132 | train | Queries the Spark Cloud for detailed information about a device. |
Alidron/spyrk | spyrk/spark_cloud.py | _BaseDevice.make_device_class | def make_device_class(spark_cloud, entries, timeout=30):
"""Returns a dynamic Device class based on what a GET device list from
the Spark Cloud returns.
spark_cloud parameter should be the caller instance of SparkCloud.
entries parameter should be the list of fields the... | python | def make_device_class(spark_cloud, entries, timeout=30):
"""Returns a dynamic Device class based on what a GET device list from
the Spark Cloud returns.
spark_cloud parameter should be the caller instance of SparkCloud.
entries parameter should be the list of fields the... | [
"def",
"make_device_class",
"(",
"spark_cloud",
",",
"entries",
",",
"timeout",
"=",
"30",
")",
":",
"attrs",
"=",
"list",
"(",
"set",
"(",
"list",
"(",
"entries",
")",
"+",
"[",
"'requires_deep_update'",
",",
"'functions'",
",",
"'variables'",
",",
"'api'... | Returns a dynamic Device class based on what a GET device list from
the Spark Cloud returns.
spark_cloud parameter should be the caller instance of SparkCloud.
entries parameter should be the list of fields the Spark Cloud API is
returning. | [
"Returns",
"a",
"dynamic",
"Device",
"class",
"based",
"on",
"what",
"a",
"GET",
"device",
"list",
"from",
"the",
"Spark",
"Cloud",
"returns",
".",
"spark_cloud",
"parameter",
"should",
"be",
"the",
"caller",
"instance",
"of",
"SparkCloud",
".",
"entries",
"... | fc1d7c0892a351cf742bf07e95b852fd6bf7c108 | https://github.com/Alidron/spyrk/blob/fc1d7c0892a351cf742bf07e95b852fd6bf7c108/spyrk/spark_cloud.py#L156-L177 | train | Returns a dynamic Device class based on what a GET device list from
the Spark Cloud returns. |
zalando-stups/lizzy-client | lizzy_client/metrics.py | report_metric | def report_metric(metric_name: str, value: int, fail_silently: bool=True):
"""
Tries to report a metric, ignoring all errors
"""
if metricz is None:
return
configuration = Configuration()
try:
lizzy_domain = urlparse(configuration.lizzy_url).netloc
lizzy_name, _ = lizzy... | python | def report_metric(metric_name: str, value: int, fail_silently: bool=True):
"""
Tries to report a metric, ignoring all errors
"""
if metricz is None:
return
configuration = Configuration()
try:
lizzy_domain = urlparse(configuration.lizzy_url).netloc
lizzy_name, _ = lizzy... | [
"def",
"report_metric",
"(",
"metric_name",
":",
"str",
",",
"value",
":",
"int",
",",
"fail_silently",
":",
"bool",
"=",
"True",
")",
":",
"if",
"metricz",
"is",
"None",
":",
"return",
"configuration",
"=",
"Configuration",
"(",
")",
"try",
":",
"lizzy_... | Tries to report a metric, ignoring all errors | [
"Tries",
"to",
"report",
"a",
"metric",
"ignoring",
"all",
"errors"
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/metrics.py#L19-L47 | train | Tries to report a metric to the Lizzy server |
KnightConan/sspdatatables | src/sspdatatables/templatetags/form_field.py | get_form_bound_field | def get_form_bound_field(form, field_name):
"""
Intends to get the bound field from the form regarding the field name
:param form: Django Form: django form instance
:param field_name: str: name of the field in form instance
:return: Django Form bound field
"""
field = form.fields[field_name... | python | def get_form_bound_field(form, field_name):
"""
Intends to get the bound field from the form regarding the field name
:param form: Django Form: django form instance
:param field_name: str: name of the field in form instance
:return: Django Form bound field
"""
field = form.fields[field_name... | [
"def",
"get_form_bound_field",
"(",
"form",
",",
"field_name",
")",
":",
"field",
"=",
"form",
".",
"fields",
"[",
"field_name",
"]",
"field",
"=",
"field",
".",
"get_bound_field",
"(",
"form",
",",
"field_name",
")",
"return",
"field"
] | Intends to get the bound field from the form regarding the field name
:param form: Django Form: django form instance
:param field_name: str: name of the field in form instance
:return: Django Form bound field | [
"Intends",
"to",
"get",
"the",
"bound",
"field",
"from",
"the",
"form",
"regarding",
"the",
"field",
"name"
] | 1179a11358734e5e472e5eee703e8d34fa49e9bf | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/templatetags/form_field.py#L10-L20 | train | Gets the bound field from the form with the given field name |
rhayes777/PyAutoFit | autofit/conf.py | AncestorConfig.read | def read(self, module_name):
"""
Read a particular config file
Parameters
----------
module_name: String
The analysis_path of the module for which a config is to be read (priors relate one to one with configs).
"""
self.parser.read("{}/{}.ini".format(... | python | def read(self, module_name):
"""
Read a particular config file
Parameters
----------
module_name: String
The analysis_path of the module for which a config is to be read (priors relate one to one with configs).
"""
self.parser.read("{}/{}.ini".format(... | [
"def",
"read",
"(",
"self",
",",
"module_name",
")",
":",
"self",
".",
"parser",
".",
"read",
"(",
"\"{}/{}.ini\"",
".",
"format",
"(",
"self",
".",
"path",
",",
"module_name",
".",
"split",
"(",
"\".\"",
")",
"[",
"-",
"1",
"]",
")",
")"
] | Read a particular config file
Parameters
----------
module_name: String
The analysis_path of the module for which a config is to be read (priors relate one to one with configs). | [
"Read",
"a",
"particular",
"config",
"file"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/conf.py#L117-L126 | train | Reads a particular config file from the specified module. |
rhayes777/PyAutoFit | autofit/conf.py | AncestorConfig.get_for_nearest_ancestor | def get_for_nearest_ancestor(self, cls, attribute_name):
"""
Find a prior with the attribute analysis_path from the config for this class or one of its ancestors
Parameters
----------
cls: class
The class of interest
attribute_name: String
The ana... | python | def get_for_nearest_ancestor(self, cls, attribute_name):
"""
Find a prior with the attribute analysis_path from the config for this class or one of its ancestors
Parameters
----------
cls: class
The class of interest
attribute_name: String
The ana... | [
"def",
"get_for_nearest_ancestor",
"(",
"self",
",",
"cls",
",",
"attribute_name",
")",
":",
"for",
"family_cls",
"in",
"family",
"(",
"cls",
")",
":",
"if",
"self",
".",
"has",
"(",
"family_cls",
".",
"__module__",
",",
"family_cls",
".",
"__name__",
",",... | Find a prior with the attribute analysis_path from the config for this class or one of its ancestors
Parameters
----------
cls: class
The class of interest
attribute_name: String
The analysis_path of the attribute
Returns
-------
prior_arr... | [
"Find",
"a",
"prior",
"with",
"the",
"attribute",
"analysis_path",
"from",
"the",
"config",
"for",
"this",
"class",
"or",
"one",
"of",
"its",
"ancestors"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/conf.py#L128-L153 | train | Returns the prior with the given analysis_path for this class or one of its ancestors. |
rhayes777/PyAutoFit | autofit/conf.py | AncestorConfig.has | def has(self, module_name, class_name, attribute_name):
"""
Parameters
----------
module_name: String
The analysis_path of the module
class_name: String
The analysis_path of the class
attribute_name: String
The analysis_path of the attr... | python | def has(self, module_name, class_name, attribute_name):
"""
Parameters
----------
module_name: String
The analysis_path of the module
class_name: String
The analysis_path of the class
attribute_name: String
The analysis_path of the attr... | [
"def",
"has",
"(",
"self",
",",
"module_name",
",",
"class_name",
",",
"attribute_name",
")",
":",
"self",
".",
"read",
"(",
"module_name",
")",
"return",
"self",
".",
"parser",
".",
"has_option",
"(",
"class_name",
",",
"attribute_name",
")"
] | Parameters
----------
module_name: String
The analysis_path of the module
class_name: String
The analysis_path of the class
attribute_name: String
The analysis_path of the attribute
Returns
-------
has_prior: bool
T... | [
"Parameters",
"----------",
"module_name",
":",
"String",
"The",
"analysis_path",
"of",
"the",
"module",
"class_name",
":",
"String",
"The",
"analysis_path",
"of",
"the",
"class",
"attribute_name",
":",
"String",
"The",
"analysis_path",
"of",
"the",
"attribute"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/conf.py#L175-L192 | train | Returns True iff the option with the given name is present in the module class and attribute. |
wdv4758h/python-everywhere | everywhere/base.py | fib | def fib(number: int) -> int:
"""
Simple Fibonacci function.
>>> fib(10)
55
"""
if number < 2:
return number
return fib(number - 1) + fib(number - 2) | python | def fib(number: int) -> int:
"""
Simple Fibonacci function.
>>> fib(10)
55
"""
if number < 2:
return number
return fib(number - 1) + fib(number - 2) | [
"def",
"fib",
"(",
"number",
":",
"int",
")",
"->",
"int",
":",
"if",
"number",
"<",
"2",
":",
"return",
"number",
"return",
"fib",
"(",
"number",
"-",
"1",
")",
"+",
"fib",
"(",
"number",
"-",
"2",
")"
] | Simple Fibonacci function.
>>> fib(10)
55 | [
"Simple",
"Fibonacci",
"function",
"."
] | 1d1bafd9f908b08c7bdb0470c6e54181c928f32f | https://github.com/wdv4758h/python-everywhere/blob/1d1bafd9f908b08c7bdb0470c6e54181c928f32f/everywhere/base.py#L7-L16 | train | Simple Fibonacci function. |
geophysics-ubonn/crtomo_tools | lib/crtomo/nodeManager.py | NodeMan.add_data | def add_data(self, data):
"""Add data to the node value sets
Parameters
----------
data: numpy.ndarray
one or more node value sets. It must either be 1D or 2D, with the
first dimension the number of parameter sets (K), and the second
the number of ele... | python | def add_data(self, data):
"""Add data to the node value sets
Parameters
----------
data: numpy.ndarray
one or more node value sets. It must either be 1D or 2D, with the
first dimension the number of parameter sets (K), and the second
the number of ele... | [
"def",
"add_data",
"(",
"self",
",",
"data",
")",
":",
"subdata",
"=",
"np",
".",
"atleast_2d",
"(",
"data",
")",
"# we try to accommodate transposed input",
"if",
"subdata",
".",
"shape",
"[",
"1",
"]",
"!=",
"self",
".",
"grid",
".",
"nr_of_nodes",
":",
... | Add data to the node value sets
Parameters
----------
data: numpy.ndarray
one or more node value sets. It must either be 1D or 2D, with the
first dimension the number of parameter sets (K), and the second
the number of elements (Z): K x Z
Examples
... | [
"Add",
"data",
"to",
"the",
"node",
"value",
"sets"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/nodeManager.py#L38-L87 | train | Add data to the node value sets and return the ids of the new node value sets. |
edx/edx-celeryutils | celery_utils/management/commands/drop_djcelery_tables.py | Command._log_execute | def _log_execute(self, cursor, sql, context=""):
"""
Log a given SQL input (as string) before executing it.
"""
log.info("{} raw SQL:\n{}".format(context, sql))
cursor.execute(sql) | python | def _log_execute(self, cursor, sql, context=""):
"""
Log a given SQL input (as string) before executing it.
"""
log.info("{} raw SQL:\n{}".format(context, sql))
cursor.execute(sql) | [
"def",
"_log_execute",
"(",
"self",
",",
"cursor",
",",
"sql",
",",
"context",
"=",
"\"\"",
")",
":",
"log",
".",
"info",
"(",
"\"{} raw SQL:\\n{}\"",
".",
"format",
"(",
"context",
",",
"sql",
")",
")",
"cursor",
".",
"execute",
"(",
"sql",
")"
] | Log a given SQL input (as string) before executing it. | [
"Log",
"a",
"given",
"SQL",
"input",
"(",
"as",
"string",
")",
"before",
"executing",
"it",
"."
] | d8745f5f0929ad154fad779a19fbefe7f51e9498 | https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/management/commands/drop_djcelery_tables.py#L41-L46 | train | Log a given SQL input before executing it. |
albert12132/templar | templar/api/rules/table_of_contents.py | HtmlTableOfContents._build_list | def _build_list(self, matches, current_level='1'):
"""Builds an unordered HTML list out of the list of matches, stopping at the first match
that is smaller than current_level (e.g. h1 < h2).
This method uses mutual recursion with _build_list_items and expects _build_list_items to
delete... | python | def _build_list(self, matches, current_level='1'):
"""Builds an unordered HTML list out of the list of matches, stopping at the first match
that is smaller than current_level (e.g. h1 < h2).
This method uses mutual recursion with _build_list_items and expects _build_list_items to
delete... | [
"def",
"_build_list",
"(",
"self",
",",
"matches",
",",
"current_level",
"=",
"'1'",
")",
":",
"lines",
"=",
"[",
"'<ul>'",
"]",
"while",
"matches",
"and",
"current_level",
"<=",
"matches",
"[",
"0",
"]",
"[",
"0",
"]",
":",
"# Build list items and indent ... | Builds an unordered HTML list out of the list of matches, stopping at the first match
that is smaller than current_level (e.g. h1 < h2).
This method uses mutual recursion with _build_list_items and expects _build_list_items to
delete matches as it processes them.
This method uses strin... | [
"Builds",
"an",
"unordered",
"HTML",
"list",
"out",
"of",
"the",
"list",
"of",
"matches",
"stopping",
"at",
"the",
"first",
"match",
"that",
"is",
"smaller",
"than",
"current_level",
"(",
"e",
".",
"g",
".",
"h1",
"<",
"h2",
")",
"."
] | 39851c89730ab69e5c73d0a46adca2a44ecc4165 | https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/api/rules/table_of_contents.py#L35-L54 | train | Builds an unordered HTML list out of the list of matches. |
albert12132/templar | templar/api/rules/table_of_contents.py | HtmlTableOfContents._build_list_items | def _build_list_items(self, matches):
"""Returns the HTML list items for the next matches that have a larger (or equal) header
compared to the first header's level.
This method mutatively removes elements from the front of matches as it processes each
element. This method assumes matche... | python | def _build_list_items(self, matches):
"""Returns the HTML list items for the next matches that have a larger (or equal) header
compared to the first header's level.
This method mutatively removes elements from the front of matches as it processes each
element. This method assumes matche... | [
"def",
"_build_list_items",
"(",
"self",
",",
"matches",
")",
":",
"assert",
"len",
"(",
"matches",
")",
">",
"0",
",",
"\"Should be at least one match, by assumption\"",
"lines",
"=",
"[",
"]",
"current_level",
"=",
"matches",
"[",
"0",
"]",
"[",
"0",
"]",
... | Returns the HTML list items for the next matches that have a larger (or equal) header
compared to the first header's level.
This method mutatively removes elements from the front of matches as it processes each
element. This method assumes matches contains at least one match.
PARAMETER... | [
"Returns",
"the",
"HTML",
"list",
"items",
"for",
"the",
"next",
"matches",
"that",
"have",
"a",
"larger",
"(",
"or",
"equal",
")",
"header",
"compared",
"to",
"the",
"first",
"header",
"s",
"level",
"."
] | 39851c89730ab69e5c73d0a46adca2a44ecc4165 | https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/api/rules/table_of_contents.py#L57-L85 | train | Builds the HTML list items for the next header that has a larger or equal header s level. |
usc-isi-i2/dig-sandpaper | digsandpaper/coarse/postprocess/similarity_score_rerank_component.py | SimilarityScoreRerank.add_highlights_docs | def add_highlights_docs(docs):
"""
"highlight": {
"knowledge_graph.title.value": [
"Before 1 January 2018, will <em>South</em> <em>Korea</em> file a World Trade Organization dispute against the United States related to solar panels?"
]
}
"""
if not... | python | def add_highlights_docs(docs):
"""
"highlight": {
"knowledge_graph.title.value": [
"Before 1 January 2018, will <em>South</em> <em>Korea</em> file a World Trade Organization dispute against the United States related to solar panels?"
]
}
"""
if not... | [
"def",
"add_highlights_docs",
"(",
"docs",
")",
":",
"if",
"not",
"isinstance",
"(",
"docs",
",",
"list",
")",
":",
"docs",
"=",
"[",
"docs",
"]",
"for",
"doc",
"in",
"docs",
":",
"if",
"'matched_sentence'",
"in",
"doc",
"[",
"'_source'",
"]",
":",
"... | "highlight": {
"knowledge_graph.title.value": [
"Before 1 January 2018, will <em>South</em> <em>Korea</em> file a World Trade Organization dispute against the United States related to solar panels?"
]
} | [
"highlight",
":",
"{",
"knowledge_graph",
".",
"title",
".",
"value",
":",
"[",
"Before",
"1",
"January",
"2018",
"will",
"<em",
">",
"South<",
"/",
"em",
">",
"<em",
">",
"Korea<",
"/",
"em",
">",
"file",
"a",
"World",
"Trade",
"Organization",
"disput... | c7a905ceec28ad0cc9e7da7ede2fd3d2fc93c3d6 | https://github.com/usc-isi-i2/dig-sandpaper/blob/c7a905ceec28ad0cc9e7da7ede2fd3d2fc93c3d6/digsandpaper/coarse/postprocess/similarity_score_rerank_component.py#L85-L110 | train | Adds highlights to the given list of docs. |
reorx/torext | torext/utils.py | SingletonMixin.instance | def instance(cls, *args, **kwgs):
"""Will be the only instance"""
if not hasattr(cls, "_instance"):
cls._instance = cls(*args, **kwgs)
return cls._instance | python | def instance(cls, *args, **kwgs):
"""Will be the only instance"""
if not hasattr(cls, "_instance"):
cls._instance = cls(*args, **kwgs)
return cls._instance | [
"def",
"instance",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwgs",
")",
":",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"\"_instance\"",
")",
":",
"cls",
".",
"_instance",
"=",
"cls",
"(",
"*",
"args",
",",
"*",
"*",
"kwgs",
")",
"return",
"... | Will be the only instance | [
"Will",
"be",
"the",
"only",
"instance"
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/utils.py#L56-L60 | train | Will be the only instance of this class |
reorx/torext | torext/utils.py | LocalProxy.get_current_object | def get_current_object(self):
"""Return the current object. This is useful if you want the real
object behind the proxy at a time for performance reasons or because
you want to pass the object into a different context.
"""
if not hasattr(self.__local, '__release_local__'):
... | python | def get_current_object(self):
"""Return the current object. This is useful if you want the real
object behind the proxy at a time for performance reasons or because
you want to pass the object into a different context.
"""
if not hasattr(self.__local, '__release_local__'):
... | [
"def",
"get_current_object",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
".",
"__local",
",",
"'__release_local__'",
")",
":",
"return",
"self",
".",
"__local",
"(",
")",
"try",
":",
"return",
"getattr",
"(",
"self",
".",
"__local",
",",
... | Return the current object. This is useful if you want the real
object behind the proxy at a time for performance reasons or because
you want to pass the object into a different context. | [
"Return",
"the",
"current",
"object",
".",
"This",
"is",
"useful",
"if",
"you",
"want",
"the",
"real",
"object",
"behind",
"the",
"proxy",
"at",
"a",
"time",
"for",
"performance",
"reasons",
"or",
"because",
"you",
"want",
"to",
"pass",
"the",
"object",
... | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/utils.py#L240-L250 | train | Return the current object. |
assamite/creamas | creamas/examples/grid/utils.py | configure_logger | def configure_logger(logger, filename, folder, log_level):
'''Configure logging behvior for the simulations.
'''
fmt = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
if folder is not None:
log_file = os.path.join(folder, filename)
hdl = logging.FileHandler(log_file)
... | python | def configure_logger(logger, filename, folder, log_level):
'''Configure logging behvior for the simulations.
'''
fmt = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
if folder is not None:
log_file = os.path.join(folder, filename)
hdl = logging.FileHandler(log_file)
... | [
"def",
"configure_logger",
"(",
"logger",
",",
"filename",
",",
"folder",
",",
"log_level",
")",
":",
"fmt",
"=",
"logging",
".",
"Formatter",
"(",
"'%(asctime)s %(levelname)s: %(message)s'",
")",
"if",
"folder",
"is",
"not",
"None",
":",
"log_file",
"=",
"os"... | Configure logging behvior for the simulations. | [
"Configure",
"logging",
"behvior",
"for",
"the",
"simulations",
"."
] | 54dc3e31c97a3f938e58272f8ab80b6bcafeff58 | https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/grid/utils.py#L11-L25 | train | Configure the logger behvior for the simulations. |
tech-pi/doufo | src/python/doufo/function.py | _nargs | def _nargs(f) -> Optional[int]:
'''
number of positional arguments values. Dynamically computed from the arguments attribute.
'''
if isinstance(f, Function):
return f.nargs
spec = inspect.getfullargspec(f)
if spec.varargs is not None:
return None
return len(spec.args) | python | def _nargs(f) -> Optional[int]:
'''
number of positional arguments values. Dynamically computed from the arguments attribute.
'''
if isinstance(f, Function):
return f.nargs
spec = inspect.getfullargspec(f)
if spec.varargs is not None:
return None
return len(spec.args) | [
"def",
"_nargs",
"(",
"f",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"if",
"isinstance",
"(",
"f",
",",
"Function",
")",
":",
"return",
"f",
".",
"nargs",
"spec",
"=",
"inspect",
".",
"getfullargspec",
"(",
"f",
")",
"if",
"spec",
".",
"varargs"... | number of positional arguments values. Dynamically computed from the arguments attribute. | [
"number",
"of",
"positional",
"arguments",
"values",
".",
"Dynamically",
"computed",
"from",
"the",
"arguments",
"attribute",
"."
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L93-L102 | train | Dynamically computed from the arguments attribute. |
tech-pi/doufo | src/python/doufo/function.py | _ndefs | def _ndefs(f):
'''
number of any default values for positional or keyword parameters
'''
if isinstance(f, Function):
return f.ndefs
spec = inspect.getfullargspec(f)
if spec.defaults is None:
return 0
return len(spec.defaults) | python | def _ndefs(f):
'''
number of any default values for positional or keyword parameters
'''
if isinstance(f, Function):
return f.ndefs
spec = inspect.getfullargspec(f)
if spec.defaults is None:
return 0
return len(spec.defaults) | [
"def",
"_ndefs",
"(",
"f",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"Function",
")",
":",
"return",
"f",
".",
"ndefs",
"spec",
"=",
"inspect",
".",
"getfullargspec",
"(",
"f",
")",
"if",
"spec",
".",
"defaults",
"is",
"None",
":",
"return",
"0"... | number of any default values for positional or keyword parameters | [
"number",
"of",
"any",
"default",
"values",
"for",
"positional",
"or",
"keyword",
"parameters"
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L105-L114 | train | Returns the number of default values for positional or keyword parameters
|
tech-pi/doufo | src/python/doufo/function.py | func | def func(nargs: Optional[int] = None, nouts: Optional[int] = None, ndefs: Optional[int] = None):
"""
decorates normal function to Function with (optional) number of arguments and outputs.
: func(nargs: Optional[int] = None, nouts: Optional[int] = None, ndefs: Optional[int] = None)
"""
retur... | python | def func(nargs: Optional[int] = None, nouts: Optional[int] = None, ndefs: Optional[int] = None):
"""
decorates normal function to Function with (optional) number of arguments and outputs.
: func(nargs: Optional[int] = None, nouts: Optional[int] = None, ndefs: Optional[int] = None)
"""
retur... | [
"def",
"func",
"(",
"nargs",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"nouts",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"ndefs",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
":",
"return",
"lambda",
"f",
":",
"wraps",... | decorates normal function to Function with (optional) number of arguments and outputs.
: func(nargs: Optional[int] = None, nouts: Optional[int] = None, ndefs: Optional[int] = None) | [
"decorates",
"normal",
"function",
"to",
"Function",
"with",
"(",
"optional",
")",
"number",
"of",
"arguments",
"and",
"outputs",
"."
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L239-L245 | train | Decorates normal function to Function with ( optional ) number of arguments and outputs. |
tech-pi/doufo | src/python/doufo/function.py | singledispatch | def singledispatch(*, nargs=None, nouts=None, ndefs=None):
"""
singledispatch decorate of both functools.singledispatch and func
"""
def wrapper(f):
return wraps(f)(SingleDispatchFunction(f, nargs=nargs, nouts=nouts, ndefs=ndefs))
return wrapper | python | def singledispatch(*, nargs=None, nouts=None, ndefs=None):
"""
singledispatch decorate of both functools.singledispatch and func
"""
def wrapper(f):
return wraps(f)(SingleDispatchFunction(f, nargs=nargs, nouts=nouts, ndefs=ndefs))
return wrapper | [
"def",
"singledispatch",
"(",
"*",
",",
"nargs",
"=",
"None",
",",
"nouts",
"=",
"None",
",",
"ndefs",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"return",
"wraps",
"(",
"f",
")",
"(",
"SingleDispatchFunction",
"(",
"f",
",",
"nar... | singledispatch decorate of both functools.singledispatch and func | [
"singledispatch",
"decorate",
"of",
"both",
"functools",
".",
"singledispatch",
"and",
"func"
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L285-L293 | train | decorator for functools. singledispatch |
tech-pi/doufo | src/python/doufo/function.py | multidispatch | def multidispatch(*, nargs=None, nouts=None):
"""
multidispatch decorate of both functools.singledispatch and func
"""
def wrapper(f):
return wraps(f)(MultiDispatchFunction(f, nargs=nargs, nouts=nouts))
return wrapper | python | def multidispatch(*, nargs=None, nouts=None):
"""
multidispatch decorate of both functools.singledispatch and func
"""
def wrapper(f):
return wraps(f)(MultiDispatchFunction(f, nargs=nargs, nouts=nouts))
return wrapper | [
"def",
"multidispatch",
"(",
"*",
",",
"nargs",
"=",
"None",
",",
"nouts",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"return",
"wraps",
"(",
"f",
")",
"(",
"MultiDispatchFunction",
"(",
"f",
",",
"nargs",
"=",
"nargs",
",",
"nout... | multidispatch decorate of both functools.singledispatch and func | [
"multidispatch",
"decorate",
"of",
"both",
"functools",
".",
"singledispatch",
"and",
"func"
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L318-L325 | train | multidispatch decorator for functions that are called multiple times. |
tech-pi/doufo | src/python/doufo/function.py | flip | def flip(f: Callable) -> Function:
"""
flip order of first two arguments to function.
"""
nargs_, nouts_, ndefs_ = nargs(f), nouts(f), ndefs(f)
return WrappedFunction(lambda *args, **kwargs: f(args[1], args[0], *args[2:], **kwargs),
nargs=nargs_, nouts=nouts_, ndefs=nd... | python | def flip(f: Callable) -> Function:
"""
flip order of first two arguments to function.
"""
nargs_, nouts_, ndefs_ = nargs(f), nouts(f), ndefs(f)
return WrappedFunction(lambda *args, **kwargs: f(args[1], args[0], *args[2:], **kwargs),
nargs=nargs_, nouts=nouts_, ndefs=nd... | [
"def",
"flip",
"(",
"f",
":",
"Callable",
")",
"->",
"Function",
":",
"nargs_",
",",
"nouts_",
",",
"ndefs_",
"=",
"nargs",
"(",
"f",
")",
",",
"nouts",
"(",
"f",
")",
",",
"ndefs",
"(",
"f",
")",
"return",
"WrappedFunction",
"(",
"lambda",
"*",
... | flip order of first two arguments to function. | [
"flip",
"order",
"of",
"first",
"two",
"arguments",
"to",
"function",
"."
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L329-L335 | train | Flip order of first two arguments to function. |
tech-pi/doufo | src/python/doufo/function.py | tagfunc | def tagfunc(nargs=None, ndefs=None, nouts=None):
"""
decorate of tagged function
"""
def wrapper(f):
return wraps(f)(FunctionWithTag(f, nargs=nargs, nouts=nouts, ndefs=ndefs))
return wrapper | python | def tagfunc(nargs=None, ndefs=None, nouts=None):
"""
decorate of tagged function
"""
def wrapper(f):
return wraps(f)(FunctionWithTag(f, nargs=nargs, nouts=nouts, ndefs=ndefs))
return wrapper | [
"def",
"tagfunc",
"(",
"nargs",
"=",
"None",
",",
"ndefs",
"=",
"None",
",",
"nouts",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"return",
"wraps",
"(",
"f",
")",
"(",
"FunctionWithTag",
"(",
"f",
",",
"nargs",
"=",
"nargs",
","... | decorate of tagged function | [
"decorate",
"of",
"tagged",
"function"
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L388-L395 | train | decorator for tagged function
|
tech-pi/doufo | src/python/doufo/function.py | _ | def _(f, x):
"""
fmap for dict like, not `f` should have signature `f::key->value->(key, value)`
"""
result = {}
for k, v in x.items():
k_, v_ = f(k, v)
result[k_] = v_
return result | python | def _(f, x):
"""
fmap for dict like, not `f` should have signature `f::key->value->(key, value)`
"""
result = {}
for k, v in x.items():
k_, v_ = f(k, v)
result[k_] = v_
return result | [
"def",
"_",
"(",
"f",
",",
"x",
")",
":",
"result",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"x",
".",
"items",
"(",
")",
":",
"k_",
",",
"v_",
"=",
"f",
"(",
"k",
",",
"v",
")",
"result",
"[",
"k_",
"]",
"=",
"v_",
"return",
"result"... | fmap for dict like, not `f` should have signature `f::key->value->(key, value)` | [
"fmap",
"for",
"dict",
"like",
"not",
"f",
"should",
"have",
"signature",
"f",
"::",
"key",
"-",
">",
"value",
"-",
">",
"(",
"key",
"value",
")"
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L418-L426 | train | fmap for dict like not f should have signature f::key - > value - > key - > value |
tech-pi/doufo | src/python/doufo/function.py | pass_key | def pass_key(f):
"""
helper function for fmap of dict to concern only on values.
`pass_key(f)` would return a function which shadow input `key` and combine it
with return of `f(value)` to `(key, f(value))`.
"""
@func(nargs=1, nouts=1)
def wrapper(k, v):
return (k, f(v))
return wr... | python | def pass_key(f):
"""
helper function for fmap of dict to concern only on values.
`pass_key(f)` would return a function which shadow input `key` and combine it
with return of `f(value)` to `(key, f(value))`.
"""
@func(nargs=1, nouts=1)
def wrapper(k, v):
return (k, f(v))
return wr... | [
"def",
"pass_key",
"(",
"f",
")",
":",
"@",
"func",
"(",
"nargs",
"=",
"1",
",",
"nouts",
"=",
"1",
")",
"def",
"wrapper",
"(",
"k",
",",
"v",
")",
":",
"return",
"(",
"k",
",",
"f",
"(",
"v",
")",
")",
"return",
"wrapper"
] | helper function for fmap of dict to concern only on values.
`pass_key(f)` would return a function which shadow input `key` and combine it
with return of `f(value)` to `(key, f(value))`. | [
"helper",
"function",
"for",
"fmap",
"of",
"dict",
"to",
"concern",
"only",
"on",
"values",
".",
"pass_key",
"(",
"f",
")",
"would",
"return",
"a",
"function",
"which",
"shadow",
"input",
"key",
"and",
"combine",
"it",
"with",
"return",
"of",
"f",
"(",
... | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L429-L438 | train | wrapper function for fmap of dict to concern only on keys. |
tech-pi/doufo | src/python/doufo/function.py | filter_ | def filter_(f, x):
"""
function version of filter, when `x` is a Functor of Monoid, it will call:
`reduce(lambda e: e.extend, x.fmap(f))`
"""
return reduce(lambda e, v: e.extend(v), x.fmap(f)) | python | def filter_(f, x):
"""
function version of filter, when `x` is a Functor of Monoid, it will call:
`reduce(lambda e: e.extend, x.fmap(f))`
"""
return reduce(lambda e, v: e.extend(v), x.fmap(f)) | [
"def",
"filter_",
"(",
"f",
",",
"x",
")",
":",
"return",
"reduce",
"(",
"lambda",
"e",
",",
"v",
":",
"e",
".",
"extend",
"(",
"v",
")",
",",
"x",
".",
"fmap",
"(",
"f",
")",
")"
] | function version of filter, when `x` is a Functor of Monoid, it will call:
`reduce(lambda e: e.extend, x.fmap(f))` | [
"function",
"version",
"of",
"filter",
"when",
"x",
"is",
"a",
"Functor",
"of",
"Monoid",
"it",
"will",
"call",
":",
"reduce",
"(",
"lambda",
"e",
":",
"e",
".",
"extend",
"x",
".",
"fmap",
"(",
"f",
"))"
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L442-L447 | train | filter function version of filter |
tech-pi/doufo | src/python/doufo/function.py | _ | def _(f, x):
"""
filter for dict, note `f` should have signature: `f::key->value->bool`
"""
return {k: v for k, v in x.items() if f(k, v)} | python | def _(f, x):
"""
filter for dict, note `f` should have signature: `f::key->value->bool`
"""
return {k: v for k, v in x.items() if f(k, v)} | [
"def",
"_",
"(",
"f",
",",
"x",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"x",
".",
"items",
"(",
")",
"if",
"f",
"(",
"k",
",",
"v",
")",
"}"
] | filter for dict, note `f` should have signature: `f::key->value->bool` | [
"filter",
"for",
"dict",
"note",
"f",
"should",
"have",
"signature",
":",
"f",
"::",
"key",
"-",
">",
"value",
"-",
">",
"bool"
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L461-L465 | train | filter for dict |
tech-pi/doufo | src/python/doufo/function.py | WrappedFunction.fmap | def fmap(self, f: 'WrappedFunction') -> 'WrappedFunction':
'''
function map for Wrapped Function. A forced transfermation to WrappedFunction would be applied.async def
fmap(self, f: 'WrappedFunction') -> 'WrappedFunction'
'''
if not isinstance(f, WrappedFunction):
... | python | def fmap(self, f: 'WrappedFunction') -> 'WrappedFunction':
'''
function map for Wrapped Function. A forced transfermation to WrappedFunction would be applied.async def
fmap(self, f: 'WrappedFunction') -> 'WrappedFunction'
'''
if not isinstance(f, WrappedFunction):
... | [
"def",
"fmap",
"(",
"self",
",",
"f",
":",
"'WrappedFunction'",
")",
"->",
"'WrappedFunction'",
":",
"if",
"not",
"isinstance",
"(",
"f",
",",
"WrappedFunction",
")",
":",
"f",
"=",
"WrappedFunction",
"(",
"f",
")",
"return",
"WrappedFunction",
"(",
"lambd... | function map for Wrapped Function. A forced transfermation to WrappedFunction would be applied.async def
fmap(self, f: 'WrappedFunction') -> 'WrappedFunction' | [
"function",
"map",
"for",
"Wrapped",
"Function",
".",
"A",
"forced",
"transfermation",
"to",
"WrappedFunction",
"would",
"be",
"applied",
".",
"async",
"def"
] | 3d375fef30670597768a6eef809b75b4b1b5a3fd | https://github.com/tech-pi/doufo/blob/3d375fef30670597768a6eef809b75b4b1b5a3fd/src/python/doufo/function.py#L184-L192 | train | A forced transfermation to WrappedFunction would be applied. |
Kortemme-Lab/klab | klab/bio/pdbml.py | PDBML_slow.retrieve | def retrieve(pdb_id, cache_dir = None):
'''Creates a PDBML object by using a cached copy of the files if they exists or by retrieving the files from the RCSB.'''
pdb_contents = None
xml_contents = None
pdb_id = pdb_id.upper()
if cache_dir:
# Check to see whether we ... | python | def retrieve(pdb_id, cache_dir = None):
'''Creates a PDBML object by using a cached copy of the files if they exists or by retrieving the files from the RCSB.'''
pdb_contents = None
xml_contents = None
pdb_id = pdb_id.upper()
if cache_dir:
# Check to see whether we ... | [
"def",
"retrieve",
"(",
"pdb_id",
",",
"cache_dir",
"=",
"None",
")",
":",
"pdb_contents",
"=",
"None",
"xml_contents",
"=",
"None",
"pdb_id",
"=",
"pdb_id",
".",
"upper",
"(",
")",
"if",
"cache_dir",
":",
"# Check to see whether we have a cached copy of the PDB f... | Creates a PDBML object by using a cached copy of the files if they exists or by retrieving the files from the RCSB. | [
"Creates",
"a",
"PDBML",
"object",
"by",
"using",
"a",
"cached",
"copy",
"of",
"the",
"files",
"if",
"they",
"exists",
"or",
"by",
"retrieving",
"the",
"files",
"from",
"the",
"RCSB",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdbml.py#L58-L88 | train | Creates a PDBML object by using a cached copy of the files if they exists or by retrieving the files from the RCSB. |
Kortemme-Lab/klab | klab/bio/pdbml.py | PDBML_slow.parse_deprecation | def parse_deprecation(self):
'''Checks to see if the PDB file has been deprecated and, if so, what the new ID is.'''
deprecation_tag = self.main_tag.getElementsByTagName("PDBx:pdbx_database_PDB_obs_sprCategory")
assert(len(deprecation_tag) <= 1)
if deprecation_tag:
deprecatio... | python | def parse_deprecation(self):
'''Checks to see if the PDB file has been deprecated and, if so, what the new ID is.'''
deprecation_tag = self.main_tag.getElementsByTagName("PDBx:pdbx_database_PDB_obs_sprCategory")
assert(len(deprecation_tag) <= 1)
if deprecation_tag:
deprecatio... | [
"def",
"parse_deprecation",
"(",
"self",
")",
":",
"deprecation_tag",
"=",
"self",
".",
"main_tag",
".",
"getElementsByTagName",
"(",
"\"PDBx:pdbx_database_PDB_obs_sprCategory\"",
")",
"assert",
"(",
"len",
"(",
"deprecation_tag",
")",
"<=",
"1",
")",
"if",
"depre... | Checks to see if the PDB file has been deprecated and, if so, what the new ID is. | [
"Checks",
"to",
"see",
"if",
"the",
"PDB",
"file",
"has",
"been",
"deprecated",
"and",
"if",
"so",
"what",
"the",
"new",
"ID",
"is",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdbml.py#L104-L123 | train | Checks to see if the PDB file has been deprecated and what the new ID is. |
Kortemme-Lab/klab | klab/bio/pdbml.py | PDBML_slow.parse_atoms | def parse_atoms(self):
'''All ATOM lines are parsed even though only one per residue needs to be parsed. The reason for parsing all the
lines is just to sanity-checks that the ATOMs within one residue are consistent with each other.'''
atom_site_header_tag = self.main_tag.getElementsByTagNam... | python | def parse_atoms(self):
'''All ATOM lines are parsed even though only one per residue needs to be parsed. The reason for parsing all the
lines is just to sanity-checks that the ATOMs within one residue are consistent with each other.'''
atom_site_header_tag = self.main_tag.getElementsByTagNam... | [
"def",
"parse_atoms",
"(",
"self",
")",
":",
"atom_site_header_tag",
"=",
"self",
".",
"main_tag",
".",
"getElementsByTagName",
"(",
"\"PDBx:atom_siteCategory\"",
")",
"assert",
"(",
"len",
"(",
"atom_site_header_tag",
")",
"==",
"1",
")",
"atom_site_header_tag",
... | All ATOM lines are parsed even though only one per residue needs to be parsed. The reason for parsing all the
lines is just to sanity-checks that the ATOMs within one residue are consistent with each other. | [
"All",
"ATOM",
"lines",
"are",
"parsed",
"even",
"though",
"only",
"one",
"per",
"residue",
"needs",
"to",
"be",
"parsed",
".",
"The",
"reason",
"for",
"parsing",
"all",
"the",
"lines",
"is",
"just",
"to",
"sanity",
"-",
"checks",
"that",
"the",
"ATOMs",... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdbml.py#L125-L157 | train | Parses all ATOM lines and creates a SequenceMap object for each ATOM residue. |
Kortemme-Lab/klab | klab/bio/pdbml.py | PDBML.retrieve | def retrieve(pdb_id, cache_dir = None, bio_cache = None):
'''Creates a PDBML object by using a cached copy of the files if they exists or by retrieving the files from the RCSB.'''
pdb_contents = None
xml_contents = None
pdb_id = pdb_id.upper()
if bio_cache:
pdb_cont... | python | def retrieve(pdb_id, cache_dir = None, bio_cache = None):
'''Creates a PDBML object by using a cached copy of the files if they exists or by retrieving the files from the RCSB.'''
pdb_contents = None
xml_contents = None
pdb_id = pdb_id.upper()
if bio_cache:
pdb_cont... | [
"def",
"retrieve",
"(",
"pdb_id",
",",
"cache_dir",
"=",
"None",
",",
"bio_cache",
"=",
"None",
")",
":",
"pdb_contents",
"=",
"None",
"xml_contents",
"=",
"None",
"pdb_id",
"=",
"pdb_id",
".",
"upper",
"(",
")",
"if",
"bio_cache",
":",
"pdb_contents",
"... | Creates a PDBML object by using a cached copy of the files if they exists or by retrieving the files from the RCSB. | [
"Creates",
"a",
"PDBML",
"object",
"by",
"using",
"a",
"cached",
"copy",
"of",
"the",
"files",
"if",
"they",
"exists",
"or",
"by",
"retrieving",
"the",
"files",
"from",
"the",
"RCSB",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdbml.py#L356-L394 | train | Creates a PDBML object by using a cached copy of the files if they exists or by retrieving the files from the RCSB. |
Kortemme-Lab/klab | klab/bio/pdbml.py | PDBML.parse_deprecated_tags | def parse_deprecated_tags(self, name, attributes):
'''Checks to see if the PDB file has been deprecated and, if so, what the new ID is.'''
if name == 'PDBx:pdbx_database_PDB_obs_spr':
self.counters['PDBx:pdbx_database_PDB_obs_spr'] = self.counters.get('PDBx:pdbx_database_PDB_obs_spr', 0) + 1... | python | def parse_deprecated_tags(self, name, attributes):
'''Checks to see if the PDB file has been deprecated and, if so, what the new ID is.'''
if name == 'PDBx:pdbx_database_PDB_obs_spr':
self.counters['PDBx:pdbx_database_PDB_obs_spr'] = self.counters.get('PDBx:pdbx_database_PDB_obs_spr', 0) + 1... | [
"def",
"parse_deprecated_tags",
"(",
"self",
",",
"name",
",",
"attributes",
")",
":",
"if",
"name",
"==",
"'PDBx:pdbx_database_PDB_obs_spr'",
":",
"self",
".",
"counters",
"[",
"'PDBx:pdbx_database_PDB_obs_spr'",
"]",
"=",
"self",
".",
"counters",
".",
"get",
"... | Checks to see if the PDB file has been deprecated and, if so, what the new ID is. | [
"Checks",
"to",
"see",
"if",
"the",
"PDB",
"file",
"has",
"been",
"deprecated",
"and",
"if",
"so",
"what",
"the",
"new",
"ID",
"is",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdbml.py#L425-L437 | train | Checks to see if the PDB file has been deprecated and what the new ID is. |
Kortemme-Lab/klab | klab/bio/pdbml.py | PDBML.parse_atom_site | def parse_atom_site(self, name, attributes):
'''Parse the atom tag attributes. Most atom tags do not have attributes.'''
if name == "PDBx:pdbx_PDB_ins_code":
assert(not(self.current_atom_site.ATOMResidueiCodeIsNull))
if attributes.get('xsi:nil') == 'true':
self.cu... | python | def parse_atom_site(self, name, attributes):
'''Parse the atom tag attributes. Most atom tags do not have attributes.'''
if name == "PDBx:pdbx_PDB_ins_code":
assert(not(self.current_atom_site.ATOMResidueiCodeIsNull))
if attributes.get('xsi:nil') == 'true':
self.cu... | [
"def",
"parse_atom_site",
"(",
"self",
",",
"name",
",",
"attributes",
")",
":",
"if",
"name",
"==",
"\"PDBx:pdbx_PDB_ins_code\"",
":",
"assert",
"(",
"not",
"(",
"self",
".",
"current_atom_site",
".",
"ATOMResidueiCodeIsNull",
")",
")",
"if",
"attributes",
".... | Parse the atom tag attributes. Most atom tags do not have attributes. | [
"Parse",
"the",
"atom",
"tag",
"attributes",
".",
"Most",
"atom",
"tags",
"do",
"not",
"have",
"attributes",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdbml.py#L471-L480 | train | Parse the atom tag attributes. Most atom tags do not have attributes. |
Kortemme-Lab/klab | klab/bio/pdbml.py | PDBML.parse_atom_tag_data | def parse_atom_tag_data(self, name, tag_content):
'''Parse the atom tag data.'''
current_atom_site = self.current_atom_site
if current_atom_site.IsHETATM:
# Early out - do not parse HETATM records
return
elif name == 'PDBx:atom_site':
# We have to han... | python | def parse_atom_tag_data(self, name, tag_content):
'''Parse the atom tag data.'''
current_atom_site = self.current_atom_site
if current_atom_site.IsHETATM:
# Early out - do not parse HETATM records
return
elif name == 'PDBx:atom_site':
# We have to han... | [
"def",
"parse_atom_tag_data",
"(",
"self",
",",
"name",
",",
"tag_content",
")",
":",
"current_atom_site",
"=",
"self",
".",
"current_atom_site",
"if",
"current_atom_site",
".",
"IsHETATM",
":",
"# Early out - do not parse HETATM records",
"return",
"elif",
"name",
"=... | Parse the atom tag data. | [
"Parse",
"the",
"atom",
"tag",
"data",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdbml.py#L482-L550 | train | Parse the atom tag data. |
Kortemme-Lab/klab | klab/bio/pdbml.py | PDBML.create_atom_data | def create_atom_data(self):
'''The atom site work is split into two parts. This function type-converts the tags.'''
current_atom_site = self.current_atom_site
# Only parse ATOM records
if current_atom_site.IsHETATM:
# Early out - do not parse HETATM records
retu... | python | def create_atom_data(self):
'''The atom site work is split into two parts. This function type-converts the tags.'''
current_atom_site = self.current_atom_site
# Only parse ATOM records
if current_atom_site.IsHETATM:
# Early out - do not parse HETATM records
retu... | [
"def",
"create_atom_data",
"(",
"self",
")",
":",
"current_atom_site",
"=",
"self",
".",
"current_atom_site",
"# Only parse ATOM records",
"if",
"current_atom_site",
".",
"IsHETATM",
":",
"# Early out - do not parse HETATM records",
"return",
"None",
",",
"None",
",",
"... | The atom site work is split into two parts. This function type-converts the tags. | [
"The",
"atom",
"site",
"work",
"is",
"split",
"into",
"two",
"parts",
".",
"This",
"function",
"type",
"-",
"converts",
"the",
"tags",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdbml.py#L552-L564 | train | The atom site work is split into two parts. This function type - converts the tags. |
Kortemme-Lab/klab | klab/unmerged/rpache/functions_lib.py | get_ranks | def get_ranks(values):
'''
Converts raw values into ranks for rank correlation coefficients
:param values: list of values (int/float)
:return: a dict mapping value -> rank
'''
ranks = {}
sorted_values = sorted(values)
for i in range(len(sorted_values)):
value = sorted_values[i]
... | python | def get_ranks(values):
'''
Converts raw values into ranks for rank correlation coefficients
:param values: list of values (int/float)
:return: a dict mapping value -> rank
'''
ranks = {}
sorted_values = sorted(values)
for i in range(len(sorted_values)):
value = sorted_values[i]
... | [
"def",
"get_ranks",
"(",
"values",
")",
":",
"ranks",
"=",
"{",
"}",
"sorted_values",
"=",
"sorted",
"(",
"values",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"sorted_values",
")",
")",
":",
"value",
"=",
"sorted_values",
"[",
"i",
"]",
"if",
... | Converts raw values into ranks for rank correlation coefficients
:param values: list of values (int/float)
:return: a dict mapping value -> rank | [
"Converts",
"raw",
"values",
"into",
"ranks",
"for",
"rank",
"correlation",
"coefficients",
":",
"param",
"values",
":",
"list",
"of",
"values",
"(",
"int",
"/",
"float",
")",
":",
"return",
":",
"a",
"dict",
"mapping",
"value",
"-",
">",
"rank"
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/unmerged/rpache/functions_lib.py#L237-L249 | train | Converts raw values into ranks for rank correlation coefficients
|
Kortemme-Lab/klab | klab/unmerged/rpache/functions_lib.py | gamma | def gamma(ranks_list1,ranks_list2):
'''
Goodman and Kruskal's gamma correlation coefficient
:param ranks_list1: a list of ranks (integers)
:param ranks_list2: a second list of ranks (integers) of equal length with corresponding entries
:return: Gamma correlation coefficient (rank correlation ignorin... | python | def gamma(ranks_list1,ranks_list2):
'''
Goodman and Kruskal's gamma correlation coefficient
:param ranks_list1: a list of ranks (integers)
:param ranks_list2: a second list of ranks (integers) of equal length with corresponding entries
:return: Gamma correlation coefficient (rank correlation ignorin... | [
"def",
"gamma",
"(",
"ranks_list1",
",",
"ranks_list2",
")",
":",
"num_concordant_pairs",
"=",
"0",
"num_discordant_pairs",
"=",
"0",
"num_tied_x",
"=",
"0",
"num_tied_y",
"=",
"0",
"num_tied_xy",
"=",
"0",
"num_items",
"=",
"len",
"(",
"ranks_list1",
")",
"... | Goodman and Kruskal's gamma correlation coefficient
:param ranks_list1: a list of ranks (integers)
:param ranks_list2: a second list of ranks (integers) of equal length with corresponding entries
:return: Gamma correlation coefficient (rank correlation ignoring ties) | [
"Goodman",
"and",
"Kruskal",
"s",
"gamma",
"correlation",
"coefficient",
":",
"param",
"ranks_list1",
":",
"a",
"list",
"of",
"ranks",
"(",
"integers",
")",
":",
"param",
"ranks_list2",
":",
"a",
"second",
"list",
"of",
"ranks",
"(",
"integers",
")",
"of",... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/unmerged/rpache/functions_lib.py#L252-L285 | train | Calculates the Gamma correlation coefficient of a Goodman and Kruskal s current group. |
Kortemme-Lab/klab | klab/unmerged/rpache/functions_lib.py | gamma_CC | def gamma_CC(values_list1, values_list2):
'''
Goodman and Kruskal's gamma correlation coefficient wrapper
:param values_list1: a list of values
:param values_list2: a second list of values of equal length with corresponding entries
:return: Gamma correlation coefficient (rank correlation ignoring ti... | python | def gamma_CC(values_list1, values_list2):
'''
Goodman and Kruskal's gamma correlation coefficient wrapper
:param values_list1: a list of values
:param values_list2: a second list of values of equal length with corresponding entries
:return: Gamma correlation coefficient (rank correlation ignoring ti... | [
"def",
"gamma_CC",
"(",
"values_list1",
",",
"values_list2",
")",
":",
"ranks1",
"=",
"get_ranks",
"(",
"values_list1",
")",
"ranks_list1",
"=",
"[",
"]",
"for",
"value",
"in",
"values_list1",
":",
"rank",
"=",
"ranks1",
"[",
"value",
"]",
"ranks_list1",
"... | Goodman and Kruskal's gamma correlation coefficient wrapper
:param values_list1: a list of values
:param values_list2: a second list of values of equal length with corresponding entries
:return: Gamma correlation coefficient (rank correlation ignoring ties) | [
"Goodman",
"and",
"Kruskal",
"s",
"gamma",
"correlation",
"coefficient",
"wrapper",
":",
"param",
"values_list1",
":",
"a",
"list",
"of",
"values",
":",
"param",
"values_list2",
":",
"a",
"second",
"list",
"of",
"values",
"of",
"equal",
"length",
"with",
"co... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/unmerged/rpache/functions_lib.py#L288-L305 | train | This function computes the Gamma Correlation coefficient of two lists of values. |
aacanakin/glim | glim/utils.py | import_source | def import_source(module, path, pass_errors=False):
"""
Function imports a module given full path
Args
----
module (string): the module name
path (string): the full path of module
pass_errors(boolean): the switch for function
to skip errors or not.
Returns
-------
module (m... | python | def import_source(module, path, pass_errors=False):
"""
Function imports a module given full path
Args
----
module (string): the module name
path (string): the full path of module
pass_errors(boolean): the switch for function
to skip errors or not.
Returns
-------
module (m... | [
"def",
"import_source",
"(",
"module",
",",
"path",
",",
"pass_errors",
"=",
"False",
")",
":",
"try",
":",
"m",
"=",
"imp",
".",
"load_source",
"(",
"module",
",",
"path",
")",
"return",
"m",
"except",
"Exception",
"as",
"e",
":",
"return",
"None"
] | Function imports a module given full path
Args
----
module (string): the module name
path (string): the full path of module
pass_errors(boolean): the switch for function
to skip errors or not.
Returns
-------
module (module): the module object.
Raises
------
e (Excepti... | [
"Function",
"imports",
"a",
"module",
"given",
"full",
"path"
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/utils.py#L17-L40 | train | Function imports a module given a full path |
aacanakin/glim | glim/utils.py | import_module | def import_module(module, pass_errors=False):
"""
Function imports a module given module name
Args
----
module (string): the module name
pass_errors(boolean): the switch for function
to skip errors or not.
Returns
-------
module (module): the module object.
Raises
----... | python | def import_module(module, pass_errors=False):
"""
Function imports a module given module name
Args
----
module (string): the module name
pass_errors(boolean): the switch for function
to skip errors or not.
Returns
-------
module (module): the module object.
Raises
----... | [
"def",
"import_module",
"(",
"module",
",",
"pass_errors",
"=",
"False",
")",
":",
"frm",
"=",
"module",
".",
"split",
"(",
"'.'",
")",
"try",
":",
"m",
"=",
"__import__",
"(",
"module",
",",
"fromlist",
"=",
"[",
"frm",
"[",
"1",
"]",
"]",
")",
... | Function imports a module given module name
Args
----
module (string): the module name
pass_errors(boolean): the switch for function
to skip errors or not.
Returns
-------
module (module): the module object.
Raises
------
exception (Exception): any kind of exceptions durin... | [
"Function",
"imports",
"a",
"module",
"given",
"module",
"name"
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/utils.py#L45-L79 | train | Function imports a module given a module name. |
aacanakin/glim | glim/utils.py | copytree | def copytree(src, dst, symlinks=False, ignore=None):
"""
Function recursively copies from directory to directory.
Args
----
src (string): the full path of source directory
dst (string): the full path of destination directory
symlinks (boolean): the switch for tracking symlinks
ignore (l... | python | def copytree(src, dst, symlinks=False, ignore=None):
"""
Function recursively copies from directory to directory.
Args
----
src (string): the full path of source directory
dst (string): the full path of destination directory
symlinks (boolean): the switch for tracking symlinks
ignore (l... | [
"def",
"copytree",
"(",
"src",
",",
"dst",
",",
"symlinks",
"=",
"False",
",",
"ignore",
"=",
"None",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dst",
")",
":",
"os",
".",
"mkdir",
"(",
"dst",
")",
"try",
":",
"for",
"item",... | Function recursively copies from directory to directory.
Args
----
src (string): the full path of source directory
dst (string): the full path of destination directory
symlinks (boolean): the switch for tracking symlinks
ignore (list): the ignore list | [
"Function",
"recursively",
"copies",
"from",
"directory",
"to",
"directory",
"."
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/utils.py#L84-L106 | train | Function recursively copies from source directory to destination directory. |
aacanakin/glim | glim/utils.py | empty | def empty(key, dict):
"""
Function determines if the dict key exists or it is empty
Args
----
key (string): the dict key
dict (dict): the dict to be searched
"""
if key in dict.keys():
if dict[key]:
return False
return True | python | def empty(key, dict):
"""
Function determines if the dict key exists or it is empty
Args
----
key (string): the dict key
dict (dict): the dict to be searched
"""
if key in dict.keys():
if dict[key]:
return False
return True | [
"def",
"empty",
"(",
"key",
",",
"dict",
")",
":",
"if",
"key",
"in",
"dict",
".",
"keys",
"(",
")",
":",
"if",
"dict",
"[",
"key",
"]",
":",
"return",
"False",
"return",
"True"
] | Function determines if the dict key exists or it is empty
Args
----
key (string): the dict key
dict (dict): the dict to be searched | [
"Function",
"determines",
"if",
"the",
"dict",
"key",
"exists",
"or",
"it",
"is",
"empty"
] | 71a20ac149a1292c0d6c1dc7414985ea51854f7a | https://github.com/aacanakin/glim/blob/71a20ac149a1292c0d6c1dc7414985ea51854f7a/glim/utils.py#L109-L121 | train | Function determines if the dict key exists and is empty |
Kortemme-Lab/klab | klab/bio/pymolmod/colors.py | ColorScheme.update | def update(self, path, node):
'''Update the dict with a new color using a 'path' through the dict. You can either pass an existing path e.g.
'Scaffold.mutations' to override a color or part of the hierarchy or you can add a new leaf node or dict.'''
assert(type(path) == type(self.name))
... | python | def update(self, path, node):
'''Update the dict with a new color using a 'path' through the dict. You can either pass an existing path e.g.
'Scaffold.mutations' to override a color or part of the hierarchy or you can add a new leaf node or dict.'''
assert(type(path) == type(self.name))
... | [
"def",
"update",
"(",
"self",
",",
"path",
",",
"node",
")",
":",
"assert",
"(",
"type",
"(",
"path",
")",
"==",
"type",
"(",
"self",
".",
"name",
")",
")",
"assert",
"(",
"type",
"(",
"node",
")",
"==",
"type",
"(",
"self",
".",
"name",
")",
... | Update the dict with a new color using a 'path' through the dict. You can either pass an existing path e.g.
'Scaffold.mutations' to override a color or part of the hierarchy or you can add a new leaf node or dict. | [
"Update",
"the",
"dict",
"with",
"a",
"new",
"color",
"using",
"a",
"path",
"through",
"the",
"dict",
".",
"You",
"can",
"either",
"pass",
"an",
"existing",
"path",
"e",
".",
"g",
".",
"Scaffold",
".",
"mutations",
"to",
"override",
"a",
"color",
"or",... | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pymolmod/colors.py#L385-L397 | train | Update the dict with a new color using a path through the dict. |
Kortemme-Lab/klab | klab/bio/pymolmod/colors.py | ColorScheme.lookup | def lookup(self, path, must_be_leaf = False):
'''Looks up a part of the color scheme. If used for looking up colors, must_be_leaf should be True.'''
assert(type(path) == type(self.name))
d = self.color_scheme
tokens = path.split('.')
for t in tokens[:-1]:
d = d.get(t... | python | def lookup(self, path, must_be_leaf = False):
'''Looks up a part of the color scheme. If used for looking up colors, must_be_leaf should be True.'''
assert(type(path) == type(self.name))
d = self.color_scheme
tokens = path.split('.')
for t in tokens[:-1]:
d = d.get(t... | [
"def",
"lookup",
"(",
"self",
",",
"path",
",",
"must_be_leaf",
"=",
"False",
")",
":",
"assert",
"(",
"type",
"(",
"path",
")",
"==",
"type",
"(",
"self",
".",
"name",
")",
")",
"d",
"=",
"self",
".",
"color_scheme",
"tokens",
"=",
"path",
".",
... | Looks up a part of the color scheme. If used for looking up colors, must_be_leaf should be True. | [
"Looks",
"up",
"a",
"part",
"of",
"the",
"color",
"scheme",
".",
"If",
"used",
"for",
"looking",
"up",
"colors",
"must_be_leaf",
"should",
"be",
"True",
"."
] | 6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b | https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pymolmod/colors.py#L399-L411 | train | Looks up a part of the color scheme. If used for looking up colors must_be_leaf should be True. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | resolve_pid | def resolve_pid(fetched_pid):
"""Retrieve the real PID given a fetched PID.
:param pid: fetched PID to resolve.
"""
return PersistentIdentifier.get(
pid_type=fetched_pid.pid_type,
pid_value=fetched_pid.pid_value,
pid_provider=fetched_pid.provider.pid_provider
) | python | def resolve_pid(fetched_pid):
"""Retrieve the real PID given a fetched PID.
:param pid: fetched PID to resolve.
"""
return PersistentIdentifier.get(
pid_type=fetched_pid.pid_type,
pid_value=fetched_pid.pid_value,
pid_provider=fetched_pid.provider.pid_provider
) | [
"def",
"resolve_pid",
"(",
"fetched_pid",
")",
":",
"return",
"PersistentIdentifier",
".",
"get",
"(",
"pid_type",
"=",
"fetched_pid",
".",
"pid_type",
",",
"pid_value",
"=",
"fetched_pid",
".",
"pid_value",
",",
"pid_provider",
"=",
"fetched_pid",
".",
"provide... | Retrieve the real PID given a fetched PID.
:param pid: fetched PID to resolve. | [
"Retrieve",
"the",
"real",
"PID",
"given",
"a",
"fetched",
"PID",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L69-L78 | train | Retrieve the real PID given a fetched PID. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDQuery.ordered | def ordered(self, ord='desc'):
"""Order the query result on the relations' indexes."""
if ord not in ('asc', 'desc', ):
raise
ord_f = getattr(PIDRelation.index, ord)()
return self.order_by(ord_f) | python | def ordered(self, ord='desc'):
"""Order the query result on the relations' indexes."""
if ord not in ('asc', 'desc', ):
raise
ord_f = getattr(PIDRelation.index, ord)()
return self.order_by(ord_f) | [
"def",
"ordered",
"(",
"self",
",",
"ord",
"=",
"'desc'",
")",
":",
"if",
"ord",
"not",
"in",
"(",
"'asc'",
",",
"'desc'",
",",
")",
":",
"raise",
"ord_f",
"=",
"getattr",
"(",
"PIDRelation",
".",
"index",
",",
"ord",
")",
"(",
")",
"return",
"se... | Order the query result on the relations' indexes. | [
"Order",
"the",
"query",
"result",
"on",
"the",
"relations",
"indexes",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L53-L58 | train | Order the query result on the relations s indexes. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDQuery.status | def status(self, status_in):
"""Filter the PIDs based on their status."""
if isinstance(status_in, PIDStatus):
status_in = [status_in, ]
return self.filter(
self._filtered_pid_class.status.in_(status_in)
) | python | def status(self, status_in):
"""Filter the PIDs based on their status."""
if isinstance(status_in, PIDStatus):
status_in = [status_in, ]
return self.filter(
self._filtered_pid_class.status.in_(status_in)
) | [
"def",
"status",
"(",
"self",
",",
"status_in",
")",
":",
"if",
"isinstance",
"(",
"status_in",
",",
"PIDStatus",
")",
":",
"status_in",
"=",
"[",
"status_in",
",",
"]",
"return",
"self",
".",
"filter",
"(",
"self",
".",
"_filtered_pid_class",
".",
"stat... | Filter the PIDs based on their status. | [
"Filter",
"the",
"PIDs",
"based",
"on",
"their",
"status",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L60-L66 | train | Filter the PIDs based on their status. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNode._resolved_pid | def _resolved_pid(self):
"""Resolve self.pid if it is a fetched pid."""
if not isinstance(self.pid, PersistentIdentifier):
return resolve_pid(self.pid)
return self.pid | python | def _resolved_pid(self):
"""Resolve self.pid if it is a fetched pid."""
if not isinstance(self.pid, PersistentIdentifier):
return resolve_pid(self.pid)
return self.pid | [
"def",
"_resolved_pid",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"pid",
",",
"PersistentIdentifier",
")",
":",
"return",
"resolve_pid",
"(",
"self",
".",
"pid",
")",
"return",
"self",
".",
"pid"
] | Resolve self.pid if it is a fetched pid. | [
"Resolve",
"self",
".",
"pid",
"if",
"it",
"is",
"a",
"fetched",
"pid",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L105-L109 | train | Resolve self. pid if it is a fetched pid. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNode._get_child_relation | def _get_child_relation(self, child_pid):
"""Retrieve the relation between this node and a child PID."""
return PIDRelation.query.filter_by(
parent=self._resolved_pid,
child=child_pid,
relation_type=self.relation_type.id).one() | python | def _get_child_relation(self, child_pid):
"""Retrieve the relation between this node and a child PID."""
return PIDRelation.query.filter_by(
parent=self._resolved_pid,
child=child_pid,
relation_type=self.relation_type.id).one() | [
"def",
"_get_child_relation",
"(",
"self",
",",
"child_pid",
")",
":",
"return",
"PIDRelation",
".",
"query",
".",
"filter_by",
"(",
"parent",
"=",
"self",
".",
"_resolved_pid",
",",
"child",
"=",
"child_pid",
",",
"relation_type",
"=",
"self",
".",
"relatio... | Retrieve the relation between this node and a child PID. | [
"Retrieve",
"the",
"relation",
"between",
"this",
"node",
"and",
"a",
"child",
"PID",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L111-L116 | train | Retrieve the relation between this node and a child PID. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNode._check_child_limits | def _check_child_limits(self, child_pid):
"""Check that inserting a child is within the limits."""
if self.max_children is not None and \
self.children.count() >= self.max_children:
raise PIDRelationConsistencyError(
"Max number of children is set to {}.".
... | python | def _check_child_limits(self, child_pid):
"""Check that inserting a child is within the limits."""
if self.max_children is not None and \
self.children.count() >= self.max_children:
raise PIDRelationConsistencyError(
"Max number of children is set to {}.".
... | [
"def",
"_check_child_limits",
"(",
"self",
",",
"child_pid",
")",
":",
"if",
"self",
".",
"max_children",
"is",
"not",
"None",
"and",
"self",
".",
"children",
".",
"count",
"(",
")",
">=",
"self",
".",
"max_children",
":",
"raise",
"PIDRelationConsistencyErr... | Check that inserting a child is within the limits. | [
"Check",
"that",
"inserting",
"a",
"child",
"is",
"within",
"the",
"limits",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L118-L131 | train | Check that inserting a child is within the limits. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNode._connected_pids | def _connected_pids(self, from_parent=True):
"""Follow a relationship to find connected PIDs.abs.
:param from_parent: search children from the current pid if True, else
search for its parents.
:type from_parent: bool
"""
to_pid = aliased(PersistentIdentifier, name='to_pi... | python | def _connected_pids(self, from_parent=True):
"""Follow a relationship to find connected PIDs.abs.
:param from_parent: search children from the current pid if True, else
search for its parents.
:type from_parent: bool
"""
to_pid = aliased(PersistentIdentifier, name='to_pi... | [
"def",
"_connected_pids",
"(",
"self",
",",
"from_parent",
"=",
"True",
")",
":",
"to_pid",
"=",
"aliased",
"(",
"PersistentIdentifier",
",",
"name",
"=",
"'to_pid'",
")",
"if",
"from_parent",
":",
"to_relation",
"=",
"PIDRelation",
".",
"child_id",
"from_rela... | Follow a relationship to find connected PIDs.abs.
:param from_parent: search children from the current pid if True, else
search for its parents.
:type from_parent: bool | [
"Follow",
"a",
"relationship",
"to",
"find",
"connected",
"PIDs",
".",
"abs",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L133-L167 | train | Follow a relationship to find connected PIDs. abs. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNode.insert_child | def insert_child(self, child_pid):
"""Add the given PID to the list of children PIDs."""
self._check_child_limits(child_pid)
try:
# TODO: Here add the check for the max parents and the max children
with db.session.begin_nested():
if not isinstance(child_pi... | python | def insert_child(self, child_pid):
"""Add the given PID to the list of children PIDs."""
self._check_child_limits(child_pid)
try:
# TODO: Here add the check for the max parents and the max children
with db.session.begin_nested():
if not isinstance(child_pi... | [
"def",
"insert_child",
"(",
"self",
",",
"child_pid",
")",
":",
"self",
".",
"_check_child_limits",
"(",
"child_pid",
")",
"try",
":",
"# TODO: Here add the check for the max parents and the max children",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
... | Add the given PID to the list of children PIDs. | [
"Add",
"the",
"given",
"PID",
"to",
"the",
"list",
"of",
"children",
"PIDs",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L189-L201 | train | Add the given PID to the list of children PIDs. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNode.remove_child | def remove_child(self, child_pid):
"""Remove a child from a PID concept."""
with db.session.begin_nested():
if not isinstance(child_pid, PersistentIdentifier):
child_pid = resolve_pid(child_pid)
relation = PIDRelation.query.filter_by(
parent=self._... | python | def remove_child(self, child_pid):
"""Remove a child from a PID concept."""
with db.session.begin_nested():
if not isinstance(child_pid, PersistentIdentifier):
child_pid = resolve_pid(child_pid)
relation = PIDRelation.query.filter_by(
parent=self._... | [
"def",
"remove_child",
"(",
"self",
",",
"child_pid",
")",
":",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"child_pid",
",",
"PersistentIdentifier",
")",
":",
"child_pid",
"=",
"resolve_pid",
"(",
"chi... | Remove a child from a PID concept. | [
"Remove",
"a",
"child",
"from",
"a",
"PID",
"concept",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L203-L212 | train | Remove a child from a PID concept. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNodeOrdered.index | def index(self, child_pid):
"""Index of the child in the relation."""
if not isinstance(child_pid, PersistentIdentifier):
child_pid = resolve_pid(child_pid)
relation = PIDRelation.query.filter_by(
parent=self._resolved_pid,
child=child_pid,
relatio... | python | def index(self, child_pid):
"""Index of the child in the relation."""
if not isinstance(child_pid, PersistentIdentifier):
child_pid = resolve_pid(child_pid)
relation = PIDRelation.query.filter_by(
parent=self._resolved_pid,
child=child_pid,
relatio... | [
"def",
"index",
"(",
"self",
",",
"child_pid",
")",
":",
"if",
"not",
"isinstance",
"(",
"child_pid",
",",
"PersistentIdentifier",
")",
":",
"child_pid",
"=",
"resolve_pid",
"(",
"child_pid",
")",
"relation",
"=",
"PIDRelation",
".",
"query",
".",
"filter_by... | Index of the child in the relation. | [
"Index",
"of",
"the",
"child",
"in",
"the",
"relation",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L222-L230 | train | Index of the child in the relation. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNodeOrdered.is_last_child | def is_last_child(self, child_pid):
"""
Determine if 'pid' is the latest version of a resource.
Resolves True for Versioned PIDs which are the oldest of its siblings.
False otherwise, also for Head PIDs.
"""
last_child = self.last_child
if last_child is None:
... | python | def is_last_child(self, child_pid):
"""
Determine if 'pid' is the latest version of a resource.
Resolves True for Versioned PIDs which are the oldest of its siblings.
False otherwise, also for Head PIDs.
"""
last_child = self.last_child
if last_child is None:
... | [
"def",
"is_last_child",
"(",
"self",
",",
"child_pid",
")",
":",
"last_child",
"=",
"self",
".",
"last_child",
"if",
"last_child",
"is",
"None",
":",
"return",
"False",
"return",
"last_child",
"==",
"child_pid"
] | Determine if 'pid' is the latest version of a resource.
Resolves True for Versioned PIDs which are the oldest of its siblings.
False otherwise, also for Head PIDs. | [
"Determine",
"if",
"pid",
"is",
"the",
"latest",
"version",
"of",
"a",
"resource",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L232-L242 | train | Determines if pid is the latest version of a resource. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNodeOrdered.last_child | def last_child(self):
"""
Get the latest PID as pointed by the Head PID.
If the 'pid' is a Head PID, return the latest of its children.
If the 'pid' is a Version PID, return the latest of its siblings.
Return None for the non-versioned PIDs.
"""
return self.child... | python | def last_child(self):
"""
Get the latest PID as pointed by the Head PID.
If the 'pid' is a Head PID, return the latest of its children.
If the 'pid' is a Version PID, return the latest of its siblings.
Return None for the non-versioned PIDs.
"""
return self.child... | [
"def",
"last_child",
"(",
"self",
")",
":",
"return",
"self",
".",
"children",
".",
"filter",
"(",
"PIDRelation",
".",
"index",
".",
"isnot",
"(",
"None",
")",
")",
".",
"ordered",
"(",
")",
".",
"first",
"(",
")"
] | Get the latest PID as pointed by the Head PID.
If the 'pid' is a Head PID, return the latest of its children.
If the 'pid' is a Version PID, return the latest of its siblings.
Return None for the non-versioned PIDs. | [
"Get",
"the",
"latest",
"PID",
"as",
"pointed",
"by",
"the",
"Head",
"PID",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L245-L254 | train | Return the last child of the head PID. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNodeOrdered.next_child | def next_child(self, child_pid):
"""Get the next child PID in the PID relation."""
relation = self._get_child_relation(child_pid)
if relation.index is not None:
return self.children.filter(
PIDRelation.index > relation.index
).ordered(ord='asc').first()
... | python | def next_child(self, child_pid):
"""Get the next child PID in the PID relation."""
relation = self._get_child_relation(child_pid)
if relation.index is not None:
return self.children.filter(
PIDRelation.index > relation.index
).ordered(ord='asc').first()
... | [
"def",
"next_child",
"(",
"self",
",",
"child_pid",
")",
":",
"relation",
"=",
"self",
".",
"_get_child_relation",
"(",
"child_pid",
")",
"if",
"relation",
".",
"index",
"is",
"not",
"None",
":",
"return",
"self",
".",
"children",
".",
"filter",
"(",
"PI... | Get the next child PID in the PID relation. | [
"Get",
"the",
"next",
"child",
"PID",
"in",
"the",
"PID",
"relation",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L256-L264 | train | Get the next child PID in the PID relation. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNodeOrdered.insert_child | def insert_child(self, child_pid, index=-1):
"""Insert a new child into a PID concept.
Argument 'index' can take the following values:
0,1,2,... - insert child PID at the specified position
-1 - insert the child PID at the last position
None - insert child without or... | python | def insert_child(self, child_pid, index=-1):
"""Insert a new child into a PID concept.
Argument 'index' can take the following values:
0,1,2,... - insert child PID at the specified position
-1 - insert the child PID at the last position
None - insert child without or... | [
"def",
"insert_child",
"(",
"self",
",",
"child_pid",
",",
"index",
"=",
"-",
"1",
")",
":",
"self",
".",
"_check_child_limits",
"(",
"child_pid",
")",
"if",
"index",
"is",
"None",
":",
"index",
"=",
"-",
"1",
"try",
":",
"with",
"db",
".",
"session"... | Insert a new child into a PID concept.
Argument 'index' can take the following values:
0,1,2,... - insert child PID at the specified position
-1 - insert the child PID at the last position
None - insert child without order (no re-ordering is done)
NOTE: If 'inde... | [
"Insert",
"a",
"new",
"child",
"into",
"a",
"PID",
"concept",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L276-L307 | train | Insert a new child into a PID concept. |
inveniosoftware/invenio-pidrelations | invenio_pidrelations/api.py | PIDNodeOrdered.remove_child | def remove_child(self, child_pid, reorder=False):
"""Remove a child from a PID concept."""
super(PIDNodeOrdered, self).remove_child(child_pid)
child_relations = self._resolved_pid.child_relations.filter(
PIDRelation.relation_type == self.relation_type.id).order_by(
PI... | python | def remove_child(self, child_pid, reorder=False):
"""Remove a child from a PID concept."""
super(PIDNodeOrdered, self).remove_child(child_pid)
child_relations = self._resolved_pid.child_relations.filter(
PIDRelation.relation_type == self.relation_type.id).order_by(
PI... | [
"def",
"remove_child",
"(",
"self",
",",
"child_pid",
",",
"reorder",
"=",
"False",
")",
":",
"super",
"(",
"PIDNodeOrdered",
",",
"self",
")",
".",
"remove_child",
"(",
"child_pid",
")",
"child_relations",
"=",
"self",
".",
"_resolved_pid",
".",
"child_rela... | Remove a child from a PID concept. | [
"Remove",
"a",
"child",
"from",
"a",
"PID",
"concept",
"."
] | a49f3725cf595b663c5b04814280b231f88bc333 | https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/api.py#L309-L317 | train | Remove a child from a PID concept. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.