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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
CI-WATER/gsshapy | gsshapy/modeling/event.py | Event.prepare_rapid_streamflow | def prepare_rapid_streamflow(self, path_to_rapid_qout, connection_list_file):
"""
Prepares RAPID streamflow for GSSHA simulation
"""
ihg_filename = '{0}.ihg'.format(self.project_manager.name)
with tmp_chdir(self.project_manager.project_directory):
# write out IHG file... | python | def prepare_rapid_streamflow(self, path_to_rapid_qout, connection_list_file):
"""
Prepares RAPID streamflow for GSSHA simulation
"""
ihg_filename = '{0}.ihg'.format(self.project_manager.name)
with tmp_chdir(self.project_manager.project_directory):
# write out IHG file... | [
"def",
"prepare_rapid_streamflow",
"(",
"self",
",",
"path_to_rapid_qout",
",",
"connection_list_file",
")",
":",
"ihg_filename",
"=",
"'{0}.ihg'",
".",
"format",
"(",
"self",
".",
"project_manager",
".",
"name",
")",
"with",
"tmp_chdir",
"(",
"self",
".",
"proj... | Prepares RAPID streamflow for GSSHA simulation | [
"Prepares",
"RAPID",
"streamflow",
"for",
"GSSHA",
"simulation"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/modeling/event.py#L255-L312 | train | Prepares RAPID streamflow for GSSHA simulation. |
CI-WATER/gsshapy | gsshapy/modeling/event.py | EventMode.set_simulation_duration | def set_simulation_duration(self, simulation_duration):
"""
set the simulation_duration
see: http://www.gsshawiki.com/Project_File:Required_Inputs
"""
self.project_manager.setCard('TOT_TIME', str(simulation_duration.total_seconds()/60.0))
super(EventMode, self).set_simula... | python | def set_simulation_duration(self, simulation_duration):
"""
set the simulation_duration
see: http://www.gsshawiki.com/Project_File:Required_Inputs
"""
self.project_manager.setCard('TOT_TIME', str(simulation_duration.total_seconds()/60.0))
super(EventMode, self).set_simula... | [
"def",
"set_simulation_duration",
"(",
"self",
",",
"simulation_duration",
")",
":",
"self",
".",
"project_manager",
".",
"setCard",
"(",
"'TOT_TIME'",
",",
"str",
"(",
"simulation_duration",
".",
"total_seconds",
"(",
")",
"/",
"60.0",
")",
")",
"super",
"(",... | set the simulation_duration
see: http://www.gsshawiki.com/Project_File:Required_Inputs | [
"set",
"the",
"simulation_duration",
"see",
":",
"http",
":",
"//",
"www",
".",
"gsshawiki",
".",
"com",
"/",
"Project_File",
":",
"Required_Inputs"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/modeling/event.py#L374-L381 | train | set the simulation duration of the event mode |
CI-WATER/gsshapy | gsshapy/modeling/event.py | EventMode.add_uniform_precip_event | def add_uniform_precip_event(self, intensity, duration):
"""
Add a uniform precip event
"""
self.project_manager.setCard('PRECIP_UNIF', '')
self.project_manager.setCard('RAIN_INTENSITY', str(intensity))
self.project_manager.setCard('RAIN_DURATION', str(duration.total_seco... | python | def add_uniform_precip_event(self, intensity, duration):
"""
Add a uniform precip event
"""
self.project_manager.setCard('PRECIP_UNIF', '')
self.project_manager.setCard('RAIN_INTENSITY', str(intensity))
self.project_manager.setCard('RAIN_DURATION', str(duration.total_seco... | [
"def",
"add_uniform_precip_event",
"(",
"self",
",",
"intensity",
",",
"duration",
")",
":",
"self",
".",
"project_manager",
".",
"setCard",
"(",
"'PRECIP_UNIF'",
",",
"''",
")",
"self",
".",
"project_manager",
".",
"setCard",
"(",
"'RAIN_INTENSITY'",
",",
"st... | Add a uniform precip event | [
"Add",
"a",
"uniform",
"precip",
"event"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/modeling/event.py#L383-L389 | train | Add a uniform precip event to the project manager. |
CI-WATER/gsshapy | gsshapy/modeling/event.py | LongTermMode._update_gmt | def _update_gmt(self):
"""
Based on timezone and start date, the GMT card is updated
"""
if self.simulation_start is not None:
# NOTE: Because of daylight savings time,
# offset result depends on time of the year
offset_string = str(self.simulation_sta... | python | def _update_gmt(self):
"""
Based on timezone and start date, the GMT card is updated
"""
if self.simulation_start is not None:
# NOTE: Because of daylight savings time,
# offset result depends on time of the year
offset_string = str(self.simulation_sta... | [
"def",
"_update_gmt",
"(",
"self",
")",
":",
"if",
"self",
".",
"simulation_start",
"is",
"not",
"None",
":",
"# NOTE: Because of daylight savings time,",
"# offset result depends on time of the year",
"offset_string",
"=",
"str",
"(",
"self",
".",
"simulation_start",
"... | Based on timezone and start date, the GMT card is updated | [
"Based",
"on",
"timezone",
"and",
"start",
"date",
"the",
"GMT",
"card",
"is",
"updated"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/modeling/event.py#L497-L506 | train | Update the GMT card based on timezone and start date |
CI-WATER/gsshapy | gsshapy/modeling/event.py | LongTermMode.prepare_hmet_lsm | def prepare_hmet_lsm(self, lsm_data_var_map_array,
hmet_ascii_output_folder=None,
netcdf_file_path=None):
"""
Prepares HMET data for GSSHA simulation from land surface model data.
Parameters:
lsm_data_var_map_array(str): Array with c... | python | def prepare_hmet_lsm(self, lsm_data_var_map_array,
hmet_ascii_output_folder=None,
netcdf_file_path=None):
"""
Prepares HMET data for GSSHA simulation from land surface model data.
Parameters:
lsm_data_var_map_array(str): Array with c... | [
"def",
"prepare_hmet_lsm",
"(",
"self",
",",
"lsm_data_var_map_array",
",",
"hmet_ascii_output_folder",
"=",
"None",
",",
"netcdf_file_path",
"=",
"None",
")",
":",
"if",
"self",
".",
"l2g",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"LSM converter not loade... | Prepares HMET data for GSSHA simulation from land surface model data.
Parameters:
lsm_data_var_map_array(str): Array with connections for LSM output and GSSHA input. See: :func:`~gsshapy.grid.GRIDtoGSSHA.`
hmet_ascii_output_folder(Optional[str]): Path to diretory to output HMET ASCII fi... | [
"Prepares",
"HMET",
"data",
"for",
"GSSHA",
"simulation",
"from",
"land",
"surface",
"model",
"data",
"."
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/modeling/event.py#L508-L542 | train | Prepares HMET data for GSSHA simulation from LSM input and GSSHA output. |
Robpol86/etaprogress | etaprogress/components/misc.py | terminal_width | def terminal_width():
"""Returns the terminal's width (number of character columns)."""
try:
if os.name == 'nt':
_WindowsCSBI.initialize()
return _WindowsCSBI.get_info(_WindowsCSBI.HANDLE_STDOUT)['terminal_width']
return struct.unpack('hhhh', fcntl.ioctl(0, termios.TIOCGW... | python | def terminal_width():
"""Returns the terminal's width (number of character columns)."""
try:
if os.name == 'nt':
_WindowsCSBI.initialize()
return _WindowsCSBI.get_info(_WindowsCSBI.HANDLE_STDOUT)['terminal_width']
return struct.unpack('hhhh', fcntl.ioctl(0, termios.TIOCGW... | [
"def",
"terminal_width",
"(",
")",
":",
"try",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"_WindowsCSBI",
".",
"initialize",
"(",
")",
"return",
"_WindowsCSBI",
".",
"get_info",
"(",
"_WindowsCSBI",
".",
"HANDLE_STDOUT",
")",
"[",
"'terminal_width'",
... | Returns the terminal's width (number of character columns). | [
"Returns",
"the",
"terminal",
"s",
"width",
"(",
"number",
"of",
"character",
"columns",
")",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/components/misc.py#L123-L131 | train | Returns the terminal s width. |
Robpol86/etaprogress | etaprogress/components/misc.py | get_remaining_width | def get_remaining_width(sample_string, max_terminal_width=None):
"""Returns the number of characters available if sample string were to be printed in the terminal.
Positional arguments:
sample_string -- gets the length of this string.
Keyword arguments:
max_terminal_width -- limit the overall widt... | python | def get_remaining_width(sample_string, max_terminal_width=None):
"""Returns the number of characters available if sample string were to be printed in the terminal.
Positional arguments:
sample_string -- gets the length of this string.
Keyword arguments:
max_terminal_width -- limit the overall widt... | [
"def",
"get_remaining_width",
"(",
"sample_string",
",",
"max_terminal_width",
"=",
"None",
")",
":",
"if",
"max_terminal_width",
"is",
"not",
"None",
":",
"available_width",
"=",
"min",
"(",
"terminal_width",
"(",
")",
",",
"max_terminal_width",
")",
"else",
":... | Returns the number of characters available if sample string were to be printed in the terminal.
Positional arguments:
sample_string -- gets the length of this string.
Keyword arguments:
max_terminal_width -- limit the overall width of everything to these many characters.
Returns:
Integer. | [
"Returns",
"the",
"number",
"of",
"characters",
"available",
"if",
"sample",
"string",
"were",
"to",
"be",
"printed",
"in",
"the",
"terminal",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/components/misc.py#L134-L150 | train | Returns the number of characters available in the terminal if the sample string was to be printed in the terminal. |
Robpol86/etaprogress | etaprogress/components/misc.py | _WindowsCSBI._define_csbi | def _define_csbi():
"""Defines structs and populates _WindowsCSBI.CSBI."""
if _WindowsCSBI.CSBI is not None:
return
class COORD(ctypes.Structure):
"""Windows COORD structure. http://msdn.microsoft.com/en-us/library/windows/desktop/ms682119"""
_fields_ = [('X'... | python | def _define_csbi():
"""Defines structs and populates _WindowsCSBI.CSBI."""
if _WindowsCSBI.CSBI is not None:
return
class COORD(ctypes.Structure):
"""Windows COORD structure. http://msdn.microsoft.com/en-us/library/windows/desktop/ms682119"""
_fields_ = [('X'... | [
"def",
"_define_csbi",
"(",
")",
":",
"if",
"_WindowsCSBI",
".",
"CSBI",
"is",
"not",
"None",
":",
"return",
"class",
"COORD",
"(",
"ctypes",
".",
"Structure",
")",
":",
"\"\"\"Windows COORD structure. http://msdn.microsoft.com/en-us/library/windows/desktop/ms682119\"\"\"... | Defines structs and populates _WindowsCSBI.CSBI. | [
"Defines",
"structs",
"and",
"populates",
"_WindowsCSBI",
".",
"CSBI",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/components/misc.py#L39-L65 | train | Defines structs and populates _WindowsCSBI. CSBI. |
Robpol86/etaprogress | etaprogress/components/misc.py | _WindowsCSBI.initialize | def initialize():
"""Initializes the WINDLL resource and populated the CSBI class variable."""
_WindowsCSBI._define_csbi()
_WindowsCSBI.HANDLE_STDERR = _WindowsCSBI.HANDLE_STDERR or _WindowsCSBI.WINDLL.kernel32.GetStdHandle(-12)
_WindowsCSBI.HANDLE_STDOUT = _WindowsCSBI.HANDLE_STDOUT or ... | python | def initialize():
"""Initializes the WINDLL resource and populated the CSBI class variable."""
_WindowsCSBI._define_csbi()
_WindowsCSBI.HANDLE_STDERR = _WindowsCSBI.HANDLE_STDERR or _WindowsCSBI.WINDLL.kernel32.GetStdHandle(-12)
_WindowsCSBI.HANDLE_STDOUT = _WindowsCSBI.HANDLE_STDOUT or ... | [
"def",
"initialize",
"(",
")",
":",
"_WindowsCSBI",
".",
"_define_csbi",
"(",
")",
"_WindowsCSBI",
".",
"HANDLE_STDERR",
"=",
"_WindowsCSBI",
".",
"HANDLE_STDERR",
"or",
"_WindowsCSBI",
".",
"WINDLL",
".",
"kernel32",
".",
"GetStdHandle",
"(",
"-",
"12",
")",
... | Initializes the WINDLL resource and populated the CSBI class variable. | [
"Initializes",
"the",
"WINDLL",
"resource",
"and",
"populated",
"the",
"CSBI",
"class",
"variable",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/components/misc.py#L68-L81 | train | Initializes the WINDLL resource and populated the CSBI class variable. |
Robpol86/etaprogress | etaprogress/components/misc.py | _WindowsCSBI.get_info | def get_info(handle):
"""Get information about this current console window (for Microsoft Windows only).
Raises IOError if attempt to get information fails (if there is no console window).
Don't forget to call _WindowsCSBI.initialize() once in your application before calling this method.
... | python | def get_info(handle):
"""Get information about this current console window (for Microsoft Windows only).
Raises IOError if attempt to get information fails (if there is no console window).
Don't forget to call _WindowsCSBI.initialize() once in your application before calling this method.
... | [
"def",
"get_info",
"(",
"handle",
")",
":",
"# Query Win32 API.",
"csbi",
"=",
"_WindowsCSBI",
".",
"CSBI",
"(",
")",
"try",
":",
"if",
"not",
"_WindowsCSBI",
".",
"WINDLL",
".",
"kernel32",
".",
"GetConsoleScreenBufferInfo",
"(",
"handle",
",",
"ctypes",
".... | Get information about this current console window (for Microsoft Windows only).
Raises IOError if attempt to get information fails (if there is no console window).
Don't forget to call _WindowsCSBI.initialize() once in your application before calling this method.
Positional arguments:
... | [
"Get",
"information",
"about",
"this",
"current",
"console",
"window",
"(",
"for",
"Microsoft",
"Windows",
"only",
")",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/components/misc.py#L84-L120 | train | Get information about this current console window. |
churchill-lab/gbrs | gbrs/emase_utils.py | stencil | def stencil(**kwargs):
"""
Applying genotype calls to multi-way alignment incidence matrix
:param alnfile: alignment incidence file (h5),
:param gtypefile: genotype calls by GBRS (tsv),
:param grpfile: gene ID to isoform ID mapping info (tsv)
:return: genotyped version of alignment incidence fi... | python | def stencil(**kwargs):
"""
Applying genotype calls to multi-way alignment incidence matrix
:param alnfile: alignment incidence file (h5),
:param gtypefile: genotype calls by GBRS (tsv),
:param grpfile: gene ID to isoform ID mapping info (tsv)
:return: genotyped version of alignment incidence fi... | [
"def",
"stencil",
"(",
"*",
"*",
"kwargs",
")",
":",
"alnfile",
"=",
"kwargs",
".",
"get",
"(",
"'alnfile'",
")",
"gtypefile",
"=",
"kwargs",
".",
"get",
"(",
"'gtypefile'",
")",
"grpfile",
"=",
"kwargs",
".",
"get",
"(",
"'grpfile'",
")",
"if",
"grp... | Applying genotype calls to multi-way alignment incidence matrix
:param alnfile: alignment incidence file (h5),
:param gtypefile: genotype calls by GBRS (tsv),
:param grpfile: gene ID to isoform ID mapping info (tsv)
:return: genotyped version of alignment incidence file (h5) | [
"Applying",
"genotype",
"calls",
"to",
"multi",
"-",
"way",
"alignment",
"incidence",
"matrix"
] | 0f32d2620e82cb1459e56083af7c6e5c72d6ea88 | https://github.com/churchill-lab/gbrs/blob/0f32d2620e82cb1459e56083af7c6e5c72d6ea88/gbrs/emase_utils.py#L160-L213 | train | This function is used to stencil the genotyped version of alignment incidence file. |
churchill-lab/gbrs | gbrs/emase_utils.py | quantify | def quantify(**kwargs):
"""
Quantify expected read counts
:param alnfile: alignment incidence file (h5)
:param grpfile: gene ID to isoform ID mapping info (tsv)
:param lenfile: transcript lengths (tsv)
:param multiread_model: emase model (default: 4)
:param read_length: read length (default... | python | def quantify(**kwargs):
"""
Quantify expected read counts
:param alnfile: alignment incidence file (h5)
:param grpfile: gene ID to isoform ID mapping info (tsv)
:param lenfile: transcript lengths (tsv)
:param multiread_model: emase model (default: 4)
:param read_length: read length (default... | [
"def",
"quantify",
"(",
"*",
"*",
"kwargs",
")",
":",
"alnfile",
"=",
"kwargs",
".",
"get",
"(",
"'alnfile'",
")",
"grpfile",
"=",
"kwargs",
".",
"get",
"(",
"'grpfile'",
")",
"if",
"grpfile",
"is",
"None",
":",
"grpfile2chk",
"=",
"os",
".",
"path",... | Quantify expected read counts
:param alnfile: alignment incidence file (h5)
:param grpfile: gene ID to isoform ID mapping info (tsv)
:param lenfile: transcript lengths (tsv)
:param multiread_model: emase model (default: 4)
:param read_length: read length (default: 100)
:param pseudocount: prior... | [
"Quantify",
"expected",
"read",
"counts"
] | 0f32d2620e82cb1459e56083af7c6e5c72d6ea88 | https://github.com/churchill-lab/gbrs/blob/0f32d2620e82cb1459e56083af7c6e5c72d6ea88/gbrs/emase_utils.py#L216-L305 | train | Quantify expected read counts for a single sequence of sequences. |
hellupline/flask-manager | flask_manager/tree.py | Tree.register_items | def register_items(self, items):
"""Bulk ``register_item``.
Args:
items (iterable[Tree]):
Sequence of nodes to be registered as children.
"""
for item in items:
item.set_parent(self)
self.items.extend(items) | python | def register_items(self, items):
"""Bulk ``register_item``.
Args:
items (iterable[Tree]):
Sequence of nodes to be registered as children.
"""
for item in items:
item.set_parent(self)
self.items.extend(items) | [
"def",
"register_items",
"(",
"self",
",",
"items",
")",
":",
"for",
"item",
"in",
"items",
":",
"item",
".",
"set_parent",
"(",
"self",
")",
"self",
".",
"items",
".",
"extend",
"(",
"items",
")"
] | Bulk ``register_item``.
Args:
items (iterable[Tree]):
Sequence of nodes to be registered as children. | [
"Bulk",
"register_item",
"."
] | 70e48309f73aacf55f5c37b43165791ae1cf6861 | https://github.com/hellupline/flask-manager/blob/70e48309f73aacf55f5c37b43165791ae1cf6861/flask_manager/tree.py#L38-L47 | train | Bulk register_item. |
hellupline/flask-manager | flask_manager/tree.py | Tree.endpoints | def endpoints(self):
"""
Get all the endpoints under this node in a tree like structure.
Returns:
(tuple):
name (str): This node's name.
endpoint (str): Endpoint name relative to root.
children (list): ``child.endpoints for each child
... | python | def endpoints(self):
"""
Get all the endpoints under this node in a tree like structure.
Returns:
(tuple):
name (str): This node's name.
endpoint (str): Endpoint name relative to root.
children (list): ``child.endpoints for each child
... | [
"def",
"endpoints",
"(",
"self",
")",
":",
"children",
"=",
"[",
"item",
".",
"endpoints",
"(",
")",
"for",
"item",
"in",
"self",
".",
"items",
"]",
"return",
"self",
".",
"name",
",",
"self",
".",
"endpoint",
",",
"children"
] | Get all the endpoints under this node in a tree like structure.
Returns:
(tuple):
name (str): This node's name.
endpoint (str): Endpoint name relative to root.
children (list): ``child.endpoints for each child | [
"Get",
"all",
"the",
"endpoints",
"under",
"this",
"node",
"in",
"a",
"tree",
"like",
"structure",
"."
] | 70e48309f73aacf55f5c37b43165791ae1cf6861 | https://github.com/hellupline/flask-manager/blob/70e48309f73aacf55f5c37b43165791ae1cf6861/flask_manager/tree.py#L74-L86 | train | Get all the endpoints under this node in a tree like structure. |
hellupline/flask-manager | flask_manager/tree.py | Tree.absolute_name | def absolute_name(self):
"""Get the absolute name of ``self``.
Returns:
str: the absolute name.
"""
if self.is_root() or self.parent.is_root():
return utils.slugify(self.name)
return ':'.join([self.parent.absolute_name, utils.slugify(self.name)]) | python | def absolute_name(self):
"""Get the absolute name of ``self``.
Returns:
str: the absolute name.
"""
if self.is_root() or self.parent.is_root():
return utils.slugify(self.name)
return ':'.join([self.parent.absolute_name, utils.slugify(self.name)]) | [
"def",
"absolute_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_root",
"(",
")",
"or",
"self",
".",
"parent",
".",
"is_root",
"(",
")",
":",
"return",
"utils",
".",
"slugify",
"(",
"self",
".",
"name",
")",
"return",
"':'",
".",
"join",
"(",
... | Get the absolute name of ``self``.
Returns:
str: the absolute name. | [
"Get",
"the",
"absolute",
"name",
"of",
"self",
"."
] | 70e48309f73aacf55f5c37b43165791ae1cf6861 | https://github.com/hellupline/flask-manager/blob/70e48309f73aacf55f5c37b43165791ae1cf6861/flask_manager/tree.py#L103-L111 | train | Get the absolute name of self. |
hellupline/flask-manager | flask_manager/tree.py | Tree.absolute_url | def absolute_url(self):
"""Get the absolute url of ``self``.
Returns:
str: the absolute url.
"""
if self.is_root():
return utils.concat_urls(self.url)
return utils.concat_urls(self.parent.absolute_url, self.url) | python | def absolute_url(self):
"""Get the absolute url of ``self``.
Returns:
str: the absolute url.
"""
if self.is_root():
return utils.concat_urls(self.url)
return utils.concat_urls(self.parent.absolute_url, self.url) | [
"def",
"absolute_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_root",
"(",
")",
":",
"return",
"utils",
".",
"concat_urls",
"(",
"self",
".",
"url",
")",
"return",
"utils",
".",
"concat_urls",
"(",
"self",
".",
"parent",
".",
"absolute_url",
",",... | Get the absolute url of ``self``.
Returns:
str: the absolute url. | [
"Get",
"the",
"absolute",
"url",
"of",
"self",
"."
] | 70e48309f73aacf55f5c37b43165791ae1cf6861 | https://github.com/hellupline/flask-manager/blob/70e48309f73aacf55f5c37b43165791ae1cf6861/flask_manager/tree.py#L114-L122 | train | Get the absolute url of the current instance. |
theodoregoetz/wernher | wernher/map_view.py | MapView.split_tracks | def split_tracks(lat,lon,*args):
'''assumes eastward motion'''
tracks = []
lt,ln = [lat[0]],[lon[0]]
zz = [[z[0]] for z in args]
for i in range(1,len(lon)):
lt.append(lat[i])
for z,a in zip(zz,args):
z.append(a[i])
d1 = abs(lon[... | python | def split_tracks(lat,lon,*args):
'''assumes eastward motion'''
tracks = []
lt,ln = [lat[0]],[lon[0]]
zz = [[z[0]] for z in args]
for i in range(1,len(lon)):
lt.append(lat[i])
for z,a in zip(zz,args):
z.append(a[i])
d1 = abs(lon[... | [
"def",
"split_tracks",
"(",
"lat",
",",
"lon",
",",
"*",
"args",
")",
":",
"tracks",
"=",
"[",
"]",
"lt",
",",
"ln",
"=",
"[",
"lat",
"[",
"0",
"]",
"]",
",",
"[",
"lon",
"[",
"0",
"]",
"]",
"zz",
"=",
"[",
"[",
"z",
"[",
"0",
"]",
"]",... | assumes eastward motion | [
"assumes",
"eastward",
"motion"
] | ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e | https://github.com/theodoregoetz/wernher/blob/ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e/wernher/map_view.py#L56-L87 | train | assumes eastward motion |
Robpol86/etaprogress | etaprogress/progress.py | ProgressBar.str_fraction | def str_fraction(self):
"""Returns the fraction with additional whitespace."""
if self.undefined:
return None
denominator = locale.format('%d', self.denominator, grouping=True)
numerator = self.str_numerator.rjust(len(denominator))
return '{0}/{1}'.format(numerator, d... | python | def str_fraction(self):
"""Returns the fraction with additional whitespace."""
if self.undefined:
return None
denominator = locale.format('%d', self.denominator, grouping=True)
numerator = self.str_numerator.rjust(len(denominator))
return '{0}/{1}'.format(numerator, d... | [
"def",
"str_fraction",
"(",
"self",
")",
":",
"if",
"self",
".",
"undefined",
":",
"return",
"None",
"denominator",
"=",
"locale",
".",
"format",
"(",
"'%d'",
",",
"self",
".",
"denominator",
",",
"grouping",
"=",
"True",
")",
"numerator",
"=",
"self",
... | Returns the fraction with additional whitespace. | [
"Returns",
"the",
"fraction",
"with",
"additional",
"whitespace",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/progress.py#L75-L81 | train | Returns the fraction with additional whitespace. |
Robpol86/etaprogress | etaprogress/progress.py | ProgressBarBits.str_fraction | def str_fraction(self):
"""Returns the fraction with additional whitespace."""
if self._eta.undefined:
return None
# Determine denominator and its unit.
unit_denominator, unit = self._unit_class(self.denominator).auto
formatter = '%d' if unit_denominator == self.deno... | python | def str_fraction(self):
"""Returns the fraction with additional whitespace."""
if self._eta.undefined:
return None
# Determine denominator and its unit.
unit_denominator, unit = self._unit_class(self.denominator).auto
formatter = '%d' if unit_denominator == self.deno... | [
"def",
"str_fraction",
"(",
"self",
")",
":",
"if",
"self",
".",
"_eta",
".",
"undefined",
":",
"return",
"None",
"# Determine denominator and its unit.",
"unit_denominator",
",",
"unit",
"=",
"self",
".",
"_unit_class",
"(",
"self",
".",
"denominator",
")",
"... | Returns the fraction with additional whitespace. | [
"Returns",
"the",
"fraction",
"with",
"additional",
"whitespace",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/progress.py#L114-L132 | train | Returns the fraction with additional whitespace. |
Robpol86/etaprogress | etaprogress/progress.py | ProgressBarBits.str_numerator | def str_numerator(self):
"""Returns the numerator with formatting."""
if not self.undefined:
return None
unit_numerator, unit = self._unit_class(self.numerator).auto
formatter = '%d' if unit_numerator == self.numerator else '%0.2f'
numerator = locale.format(formatter,... | python | def str_numerator(self):
"""Returns the numerator with formatting."""
if not self.undefined:
return None
unit_numerator, unit = self._unit_class(self.numerator).auto
formatter = '%d' if unit_numerator == self.numerator else '%0.2f'
numerator = locale.format(formatter,... | [
"def",
"str_numerator",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"undefined",
":",
"return",
"None",
"unit_numerator",
",",
"unit",
"=",
"self",
".",
"_unit_class",
"(",
"self",
".",
"numerator",
")",
".",
"auto",
"formatter",
"=",
"'%d'",
"if",
... | Returns the numerator with formatting. | [
"Returns",
"the",
"numerator",
"with",
"formatting",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/progress.py#L135-L142 | train | Returns the numerator with formatting. |
Robpol86/etaprogress | etaprogress/progress.py | ProgressBarWget.str_eta | def str_eta(self):
"""Returns a formatted ETA value for the progress bar."""
eta = eta_letters(self._eta.elapsed) if self.done else self._eta_string
if not eta:
return ''
if eta.count(' ') > 1:
eta = ' '.join(eta.split(' ')[:2]) # Only show up to two units (h and... | python | def str_eta(self):
"""Returns a formatted ETA value for the progress bar."""
eta = eta_letters(self._eta.elapsed) if self.done else self._eta_string
if not eta:
return ''
if eta.count(' ') > 1:
eta = ' '.join(eta.split(' ')[:2]) # Only show up to two units (h and... | [
"def",
"str_eta",
"(",
"self",
")",
":",
"eta",
"=",
"eta_letters",
"(",
"self",
".",
"_eta",
".",
"elapsed",
")",
"if",
"self",
".",
"done",
"else",
"self",
".",
"_eta_string",
"if",
"not",
"eta",
":",
"return",
"''",
"if",
"eta",
".",
"count",
"(... | Returns a formatted ETA value for the progress bar. | [
"Returns",
"a",
"formatted",
"ETA",
"value",
"for",
"the",
"progress",
"bar",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/progress.py#L229-L236 | train | Returns a formatted ETA value for the progress bar. |
Robpol86/etaprogress | etaprogress/progress.py | ProgressBarWget.str_rate | def str_rate(self):
"""Returns the rate with formatting. If done, returns the overall rate instead."""
# Handle special cases.
if not self._eta.started or self._eta.stalled or not self.rate:
return '--.-KiB/s'
unit_rate, unit = UnitByte(self._eta.rate_overall if self.done el... | python | def str_rate(self):
"""Returns the rate with formatting. If done, returns the overall rate instead."""
# Handle special cases.
if not self._eta.started or self._eta.stalled or not self.rate:
return '--.-KiB/s'
unit_rate, unit = UnitByte(self._eta.rate_overall if self.done el... | [
"def",
"str_rate",
"(",
"self",
")",
":",
"# Handle special cases.",
"if",
"not",
"self",
".",
"_eta",
".",
"started",
"or",
"self",
".",
"_eta",
".",
"stalled",
"or",
"not",
"self",
".",
"rate",
":",
"return",
"'--.-KiB/s'",
"unit_rate",
",",
"unit",
"=... | Returns the rate with formatting. If done, returns the overall rate instead. | [
"Returns",
"the",
"rate",
"with",
"formatting",
".",
"If",
"done",
"returns",
"the",
"overall",
"rate",
"instead",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/progress.py#L239-L252 | train | Returns the rate with formatting. If done returns the overall rate instead. |
Robpol86/etaprogress | etaprogress/progress.py | ProgressBarYum.str_eta | def str_eta(self):
"""Returns a formatted ETA value for the progress bar."""
if self.done:
return eta_hms(self._eta.elapsed, always_show_hours=True, hours_leading_zero=True)
if not self._eta_string:
return ''
return '{0} ETA'.format(self._eta_string) | python | def str_eta(self):
"""Returns a formatted ETA value for the progress bar."""
if self.done:
return eta_hms(self._eta.elapsed, always_show_hours=True, hours_leading_zero=True)
if not self._eta_string:
return ''
return '{0} ETA'.format(self._eta_string) | [
"def",
"str_eta",
"(",
"self",
")",
":",
"if",
"self",
".",
"done",
":",
"return",
"eta_hms",
"(",
"self",
".",
"_eta",
".",
"elapsed",
",",
"always_show_hours",
"=",
"True",
",",
"hours_leading_zero",
"=",
"True",
")",
"if",
"not",
"self",
".",
"_eta_... | Returns a formatted ETA value for the progress bar. | [
"Returns",
"a",
"formatted",
"ETA",
"value",
"for",
"the",
"progress",
"bar",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/progress.py#L320-L326 | train | Returns a formatted ETA value for the progress bar. |
Robpol86/etaprogress | etaprogress/progress.py | ProgressBarYum.str_numerator | def str_numerator(self):
"""Returns the numerator with formatting."""
unit_numerator, unit = UnitByte(self.numerator).auto_no_thousands
if unit_numerator >= 10:
formatter = '%d'
else:
formatter = '%0.1f'
return '{0} {1}'.format(locale.format(formatter, uni... | python | def str_numerator(self):
"""Returns the numerator with formatting."""
unit_numerator, unit = UnitByte(self.numerator).auto_no_thousands
if unit_numerator >= 10:
formatter = '%d'
else:
formatter = '%0.1f'
return '{0} {1}'.format(locale.format(formatter, uni... | [
"def",
"str_numerator",
"(",
"self",
")",
":",
"unit_numerator",
",",
"unit",
"=",
"UnitByte",
"(",
"self",
".",
"numerator",
")",
".",
"auto_no_thousands",
"if",
"unit_numerator",
">=",
"10",
":",
"formatter",
"=",
"'%d'",
"else",
":",
"formatter",
"=",
"... | Returns the numerator with formatting. | [
"Returns",
"the",
"numerator",
"with",
"formatting",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/progress.py#L329-L336 | train | Returns the numerator with formatting. |
Robpol86/etaprogress | etaprogress/progress.py | ProgressBarYum.str_rate | def str_rate(self):
"""Returns the rate with formatting."""
# Handle special cases.
if not self._eta.started or self._eta.stalled or not self.rate:
return '--- KiB/s'
unit_rate, unit = UnitByte(self.rate).auto_no_thousands
if unit_rate >= 10:
formatter = ... | python | def str_rate(self):
"""Returns the rate with formatting."""
# Handle special cases.
if not self._eta.started or self._eta.stalled or not self.rate:
return '--- KiB/s'
unit_rate, unit = UnitByte(self.rate).auto_no_thousands
if unit_rate >= 10:
formatter = ... | [
"def",
"str_rate",
"(",
"self",
")",
":",
"# Handle special cases.",
"if",
"not",
"self",
".",
"_eta",
".",
"started",
"or",
"self",
".",
"_eta",
".",
"stalled",
"or",
"not",
"self",
".",
"rate",
":",
"return",
"'--- KiB/s'",
"unit_rate",
",",
"unit",
"=... | Returns the rate with formatting. | [
"Returns",
"the",
"rate",
"with",
"formatting",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/progress.py#L339-L350 | train | Returns the rate with formatting. |
CI-WATER/gsshapy | gsshapy/lib/db_tools.py | init_db | def init_db(sqlalchemy_url):
"""
Initialize database with gsshapy tables
"""
engine = create_engine(sqlalchemy_url)
start = time.time()
metadata.create_all(engine)
return time.time() - start | python | def init_db(sqlalchemy_url):
"""
Initialize database with gsshapy tables
"""
engine = create_engine(sqlalchemy_url)
start = time.time()
metadata.create_all(engine)
return time.time() - start | [
"def",
"init_db",
"(",
"sqlalchemy_url",
")",
":",
"engine",
"=",
"create_engine",
"(",
"sqlalchemy_url",
")",
"start",
"=",
"time",
".",
"time",
"(",
")",
"metadata",
".",
"create_all",
"(",
"engine",
")",
"return",
"time",
".",
"time",
"(",
")",
"-",
... | Initialize database with gsshapy tables | [
"Initialize",
"database",
"with",
"gsshapy",
"tables"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/db_tools.py#L35-L42 | train | Initialize database with gsshapy tables
|
CI-WATER/gsshapy | gsshapy/lib/db_tools.py | init_sqlite_memory | def init_sqlite_memory(initTime=False):
"""
Initialize SQLite in Memory Only Database
Args:
initTime(Optional[bool]): If True, it will print the amount of time to generate database.
Returns:
tuple: The tuple contains sqlalchemy_url(str), which is the path to use
when creat... | python | def init_sqlite_memory(initTime=False):
"""
Initialize SQLite in Memory Only Database
Args:
initTime(Optional[bool]): If True, it will print the amount of time to generate database.
Returns:
tuple: The tuple contains sqlalchemy_url(str), which is the path to use
when creat... | [
"def",
"init_sqlite_memory",
"(",
"initTime",
"=",
"False",
")",
":",
"sqlalchemy_url",
"=",
"'sqlite://'",
"engine",
"=",
"create_engine",
"(",
"sqlalchemy_url",
",",
"poolclass",
"=",
"SingletonThreadPool",
")",
"start",
"=",
"time",
".",
"time",
"(",
")",
"... | Initialize SQLite in Memory Only Database
Args:
initTime(Optional[bool]): If True, it will print the amount of time to generate database.
Returns:
tuple: The tuple contains sqlalchemy_url(str), which is the path to use
when creating a session as well as engine(str), which is the p... | [
"Initialize",
"SQLite",
"in",
"Memory",
"Only",
"Database",
"Args",
":",
"initTime",
"(",
"Optional",
"[",
"bool",
"]",
")",
":",
"If",
"True",
"it",
"will",
"print",
"the",
"amount",
"of",
"time",
"to",
"generate",
"database",
"."
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/db_tools.py#L45-L79 | train | Initialize SQLite in Memory Only Database
|
CI-WATER/gsshapy | gsshapy/lib/db_tools.py | init_sqlite_db | def init_sqlite_db(path, initTime=False):
"""
Initialize SQLite Database
Args:
path(str): Path to database (Ex. '/home/username/my_sqlite.db').
initTime(Optional[bool]): If True, it will print the amount of time to generate database.
Example::
from gsshapy.lib.db_tools... | python | def init_sqlite_db(path, initTime=False):
"""
Initialize SQLite Database
Args:
path(str): Path to database (Ex. '/home/username/my_sqlite.db').
initTime(Optional[bool]): If True, it will print the amount of time to generate database.
Example::
from gsshapy.lib.db_tools... | [
"def",
"init_sqlite_db",
"(",
"path",
",",
"initTime",
"=",
"False",
")",
":",
"sqlite_base_url",
"=",
"'sqlite:///'",
"sqlalchemy_url",
"=",
"sqlite_base_url",
"+",
"path",
"init_time",
"=",
"init_db",
"(",
"sqlalchemy_url",
")",
"if",
"initTime",
":",
"print",... | Initialize SQLite Database
Args:
path(str): Path to database (Ex. '/home/username/my_sqlite.db').
initTime(Optional[bool]): If True, it will print the amount of time to generate database.
Example::
from gsshapy.lib.db_tools import init_sqlite_db, create_session
... | [
"Initialize",
"SQLite",
"Database",
"Args",
":",
"path",
"(",
"str",
")",
":",
"Path",
"to",
"database",
"(",
"Ex",
".",
"/",
"home",
"/",
"username",
"/",
"my_sqlite",
".",
"db",
")",
".",
"initTime",
"(",
"Optional",
"[",
"bool",
"]",
")",
":",
"... | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/db_tools.py#L82-L117 | train | Initialize SQLite Database
|
CI-WATER/gsshapy | gsshapy/lib/db_tools.py | init_postgresql_db | def init_postgresql_db(username, host, database, port='', password='', initTime=False):
"""
Initialize PostgreSQL Database
.. note:: psycopg2 or similar driver required
Args:
username(str): Database username.
host(str): Database host URL.
database(str): Database name.
... | python | def init_postgresql_db(username, host, database, port='', password='', initTime=False):
"""
Initialize PostgreSQL Database
.. note:: psycopg2 or similar driver required
Args:
username(str): Database username.
host(str): Database host URL.
database(str): Database name.
... | [
"def",
"init_postgresql_db",
"(",
"username",
",",
"host",
",",
"database",
",",
"port",
"=",
"''",
",",
"password",
"=",
"''",
",",
"initTime",
"=",
"False",
")",
":",
"postgresql_base_url",
"=",
"'postgresql://'",
"if",
"password",
"!=",
"''",
":",
"pass... | Initialize PostgreSQL Database
.. note:: psycopg2 or similar driver required
Args:
username(str): Database username.
host(str): Database host URL.
database(str): Database name.
port(Optional[int,str]): Database port.
password(Optional[str]): Database password.
... | [
"Initialize",
"PostgreSQL",
"Database",
"..",
"note",
"::",
"psycopg2",
"or",
"similar",
"driver",
"required",
"Args",
":",
"username",
"(",
"str",
")",
":",
"Database",
"username",
".",
"host",
"(",
"str",
")",
":",
"Database",
"host",
"URL",
".",
"databa... | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/db_tools.py#L120-L174 | train | Initialize PostgreSQL Database |
CI-WATER/gsshapy | gsshapy/lib/db_tools.py | init_mysql_db | def init_mysql_db(username, host, database, port='', password='', initTime=False):
"""
Initialize MySQL Database
.. note:: mysql-python or similar driver required
Args:
username(str): Database username.
host(str): Database host URL.
database(str): Database name.
... | python | def init_mysql_db(username, host, database, port='', password='', initTime=False):
"""
Initialize MySQL Database
.. note:: mysql-python or similar driver required
Args:
username(str): Database username.
host(str): Database host URL.
database(str): Database name.
... | [
"def",
"init_mysql_db",
"(",
"username",
",",
"host",
",",
"database",
",",
"port",
"=",
"''",
",",
"password",
"=",
"''",
",",
"initTime",
"=",
"False",
")",
":",
"mysql_base_url",
"=",
"'mysql://'",
"if",
"password",
"!=",
"''",
":",
"password",
"=",
... | Initialize MySQL Database
.. note:: mysql-python or similar driver required
Args:
username(str): Database username.
host(str): Database host URL.
database(str): Database name.
port(Optional[int,str]): Database port.
password(Optional[str]): Database password.
... | [
"Initialize",
"MySQL",
"Database",
"..",
"note",
"::",
"mysql",
"-",
"python",
"or",
"similar",
"driver",
"required",
"Args",
":",
"username",
"(",
"str",
")",
":",
"Database",
"username",
".",
"host",
"(",
"str",
")",
":",
"Database",
"host",
"URL",
"."... | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/db_tools.py#L177-L231 | train | Initialize MySQL Database |
CI-WATER/gsshapy | gsshapy/lib/db_tools.py | get_sessionmaker | def get_sessionmaker(sqlalchemy_url, engine=None):
"""
Create session with database to work in
"""
if engine is None:
engine = create_engine(sqlalchemy_url)
return sessionmaker(bind=engine) | python | def get_sessionmaker(sqlalchemy_url, engine=None):
"""
Create session with database to work in
"""
if engine is None:
engine = create_engine(sqlalchemy_url)
return sessionmaker(bind=engine) | [
"def",
"get_sessionmaker",
"(",
"sqlalchemy_url",
",",
"engine",
"=",
"None",
")",
":",
"if",
"engine",
"is",
"None",
":",
"engine",
"=",
"create_engine",
"(",
"sqlalchemy_url",
")",
"return",
"sessionmaker",
"(",
"bind",
"=",
"engine",
")"
] | Create session with database to work in | [
"Create",
"session",
"with",
"database",
"to",
"work",
"in"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/db_tools.py#L234-L240 | train | Create session with database to work in
|
CI-WATER/gsshapy | gsshapy/lib/db_tools.py | get_project_session | def get_project_session(project_name, project_directory, map_type=None):
"""
Load project manager and in memory sqlite db sessionmaker for GSSHA project
"""
sqlalchemy_url, sql_engine = init_sqlite_memory()
gdb_sessionmaker = get_sessionmaker(sqlalchemy_url, sql_engine)
project_manager = Project... | python | def get_project_session(project_name, project_directory, map_type=None):
"""
Load project manager and in memory sqlite db sessionmaker for GSSHA project
"""
sqlalchemy_url, sql_engine = init_sqlite_memory()
gdb_sessionmaker = get_sessionmaker(sqlalchemy_url, sql_engine)
project_manager = Project... | [
"def",
"get_project_session",
"(",
"project_name",
",",
"project_directory",
",",
"map_type",
"=",
"None",
")",
":",
"sqlalchemy_url",
",",
"sql_engine",
"=",
"init_sqlite_memory",
"(",
")",
"gdb_sessionmaker",
"=",
"get_sessionmaker",
"(",
"sqlalchemy_url",
",",
"s... | Load project manager and in memory sqlite db sessionmaker for GSSHA project | [
"Load",
"project",
"manager",
"and",
"in",
"memory",
"sqlite",
"db",
"sessionmaker",
"for",
"GSSHA",
"project"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/db_tools.py#L243-L252 | train | Load project manager and in memory sqlite db sessionmaker for GSSHA project |
Pylons/plaster | src/plaster/loaders.py | get_settings | def get_settings(config_uri, section=None, defaults=None):
"""
Load the settings from a named section.
.. code-block:: python
settings = plaster.get_settings(...)
print(settings['foo'])
:param config_uri: Anything that can be parsed by
:func:`plaster.parse_uri`.
:param se... | python | def get_settings(config_uri, section=None, defaults=None):
"""
Load the settings from a named section.
.. code-block:: python
settings = plaster.get_settings(...)
print(settings['foo'])
:param config_uri: Anything that can be parsed by
:func:`plaster.parse_uri`.
:param se... | [
"def",
"get_settings",
"(",
"config_uri",
",",
"section",
"=",
"None",
",",
"defaults",
"=",
"None",
")",
":",
"loader",
"=",
"get_loader",
"(",
"config_uri",
")",
"return",
"loader",
".",
"get_settings",
"(",
"section",
",",
"defaults",
")"
] | Load the settings from a named section.
.. code-block:: python
settings = plaster.get_settings(...)
print(settings['foo'])
:param config_uri: Anything that can be parsed by
:func:`plaster.parse_uri`.
:param section: The name of the section in the config file. If this is
`... | [
"Load",
"the",
"settings",
"from",
"a",
"named",
"section",
"."
] | e70e55c182a8300d7ccf67e54d47740c72e72cd8 | https://github.com/Pylons/plaster/blob/e70e55c182a8300d7ccf67e54d47740c72e72cd8/src/plaster/loaders.py#L33-L60 | train | Load the settings from a named section. |
Pylons/plaster | src/plaster/loaders.py | get_loader | def get_loader(config_uri, protocols=None):
"""
Find a :class:`plaster.ILoader` object capable of handling ``config_uri``.
:param config_uri: Anything that can be parsed by
:func:`plaster.parse_uri`.
:param protocols: Zero or more :term:`loader protocol` identifiers that
the loader mus... | python | def get_loader(config_uri, protocols=None):
"""
Find a :class:`plaster.ILoader` object capable of handling ``config_uri``.
:param config_uri: Anything that can be parsed by
:func:`plaster.parse_uri`.
:param protocols: Zero or more :term:`loader protocol` identifiers that
the loader mus... | [
"def",
"get_loader",
"(",
"config_uri",
",",
"protocols",
"=",
"None",
")",
":",
"config_uri",
"=",
"parse_uri",
"(",
"config_uri",
")",
"requested_scheme",
"=",
"config_uri",
".",
"scheme",
"matched_loaders",
"=",
"find_loaders",
"(",
"requested_scheme",
",",
"... | Find a :class:`plaster.ILoader` object capable of handling ``config_uri``.
:param config_uri: Anything that can be parsed by
:func:`plaster.parse_uri`.
:param protocols: Zero or more :term:`loader protocol` identifiers that
the loader must implement to match the desired ``config_uri``.
:r... | [
"Find",
"a",
":",
"class",
":",
"plaster",
".",
"ILoader",
"object",
"capable",
"of",
"handling",
"config_uri",
"."
] | e70e55c182a8300d7ccf67e54d47740c72e72cd8 | https://github.com/Pylons/plaster/blob/e70e55c182a8300d7ccf67e54d47740c72e72cd8/src/plaster/loaders.py#L84-L117 | train | Find a loader object capable of handling config_uri. |
Pylons/plaster | src/plaster/loaders.py | find_loaders | def find_loaders(scheme, protocols=None):
"""
Find all loaders that match the requested scheme and protocols.
:param scheme: Any valid scheme. Examples would be something like ``ini``
or ``ini+pastedeploy``.
:param protocols: Zero or more :term:`loader protocol` identifiers that
the lo... | python | def find_loaders(scheme, protocols=None):
"""
Find all loaders that match the requested scheme and protocols.
:param scheme: Any valid scheme. Examples would be something like ``ini``
or ``ini+pastedeploy``.
:param protocols: Zero or more :term:`loader protocol` identifiers that
the lo... | [
"def",
"find_loaders",
"(",
"scheme",
",",
"protocols",
"=",
"None",
")",
":",
"# build a list of all required entry points",
"matching_groups",
"=",
"[",
"'plaster.loader_factory'",
"]",
"if",
"protocols",
":",
"matching_groups",
"+=",
"[",
"'plaster.{0}_loader_factory'"... | Find all loaders that match the requested scheme and protocols.
:param scheme: Any valid scheme. Examples would be something like ``ini``
or ``ini+pastedeploy``.
:param protocols: Zero or more :term:`loader protocol` identifiers that
the loader must implement. If ``None`` then only generic loa... | [
"Find",
"all",
"loaders",
"that",
"match",
"the",
"requested",
"scheme",
"and",
"protocols",
"."
] | e70e55c182a8300d7ccf67e54d47740c72e72cd8 | https://github.com/Pylons/plaster/blob/e70e55c182a8300d7ccf67e54d47740c72e72cd8/src/plaster/loaders.py#L120-L173 | train | Find all loaders that match the requested scheme and protocols. |
pedrotgn/pyactor | pyactor/thread/parallels.py | ActorParallel.receive | def receive(self, msg):
'''
Overwriting :meth:`Actor.receive`, adds the checks and
functionalities requiered by parallel methods.
:param msg: The message is a dictionary using the constants
defined in util.py (:mod:`pyactor.util`).
'''
if msg[TYPE] == TELL an... | python | def receive(self, msg):
'''
Overwriting :meth:`Actor.receive`, adds the checks and
functionalities requiered by parallel methods.
:param msg: The message is a dictionary using the constants
defined in util.py (:mod:`pyactor.util`).
'''
if msg[TYPE] == TELL an... | [
"def",
"receive",
"(",
"self",
",",
"msg",
")",
":",
"if",
"msg",
"[",
"TYPE",
"]",
"==",
"TELL",
"and",
"msg",
"[",
"METHOD",
"]",
"==",
"'stop'",
":",
"self",
".",
"running",
"=",
"False",
"else",
":",
"result",
"=",
"None",
"try",
":",
"invoke... | Overwriting :meth:`Actor.receive`, adds the checks and
functionalities requiered by parallel methods.
:param msg: The message is a dictionary using the constants
defined in util.py (:mod:`pyactor.util`). | [
"Overwriting",
":",
"meth",
":",
"Actor",
".",
"receive",
"adds",
"the",
"checks",
"and",
"functionalities",
"requiered",
"by",
"parallel",
"methods",
"."
] | 24d98d134dd4228f2ba38e83611e9c3f50ec2fd4 | https://github.com/pedrotgn/pyactor/blob/24d98d134dd4228f2ba38e83611e9c3f50ec2fd4/pyactor/thread/parallels.py#L35-L68 | train | Overwriting Actor. receive adds the checks and the functionalities requiered by parallel methods. |
vinci1it2000/schedula | schedula/utils/dsp.py | combine_dicts | def combine_dicts(*dicts, copy=False, base=None):
"""
Combines multiple dicts in one.
:param dicts:
A sequence of dicts.
:type dicts: dict
:param copy:
If True, it returns a deepcopy of input values.
:type copy: bool, optional
:param base:
Base dict where combine m... | python | def combine_dicts(*dicts, copy=False, base=None):
"""
Combines multiple dicts in one.
:param dicts:
A sequence of dicts.
:type dicts: dict
:param copy:
If True, it returns a deepcopy of input values.
:type copy: bool, optional
:param base:
Base dict where combine m... | [
"def",
"combine_dicts",
"(",
"*",
"dicts",
",",
"copy",
"=",
"False",
",",
"base",
"=",
"None",
")",
":",
"if",
"len",
"(",
"dicts",
")",
"==",
"1",
"and",
"base",
"is",
"None",
":",
"# Only one input dict.",
"cd",
"=",
"dicts",
"[",
"0",
"]",
".",... | Combines multiple dicts in one.
:param dicts:
A sequence of dicts.
:type dicts: dict
:param copy:
If True, it returns a deepcopy of input values.
:type copy: bool, optional
:param base:
Base dict where combine multiple dicts in one.
:type base: dict, optional
:ret... | [
"Combines",
"multiple",
"dicts",
"in",
"one",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L34-L71 | train | Combines multiple dicts in one. |
vinci1it2000/schedula | schedula/utils/dsp.py | kk_dict | def kk_dict(*kk, **adict):
"""
Merges and defines dictionaries with values identical to keys.
:param kk:
A sequence of keys and/or dictionaries.
:type kk: object | dict, optional
:param adict:
A dictionary.
:type adict: dict, optional
:return:
Merged dictionary.
... | python | def kk_dict(*kk, **adict):
"""
Merges and defines dictionaries with values identical to keys.
:param kk:
A sequence of keys and/or dictionaries.
:type kk: object | dict, optional
:param adict:
A dictionary.
:type adict: dict, optional
:return:
Merged dictionary.
... | [
"def",
"kk_dict",
"(",
"*",
"kk",
",",
"*",
"*",
"adict",
")",
":",
"for",
"k",
"in",
"kk",
":",
"if",
"isinstance",
"(",
"k",
",",
"dict",
")",
":",
"if",
"not",
"set",
"(",
"k",
")",
".",
"isdisjoint",
"(",
"adict",
")",
":",
"raise",
"Valu... | Merges and defines dictionaries with values identical to keys.
:param kk:
A sequence of keys and/or dictionaries.
:type kk: object | dict, optional
:param adict:
A dictionary.
:type adict: dict, optional
:return:
Merged dictionary.
:rtype: dict
Example::
... | [
"Merges",
"and",
"defines",
"dictionaries",
"with",
"values",
"identical",
"to",
"keys",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L74-L121 | train | Returns a dictionary that contains all the keys and values identical to keys. |
vinci1it2000/schedula | schedula/utils/dsp.py | bypass | def bypass(*inputs, copy=False):
"""
Returns the same arguments.
:param inputs:
Inputs values.
:type inputs: T
:param copy:
If True, it returns a deepcopy of input values.
:type copy: bool, optional
:return:
Same input values.
:rtype: (T, ...), T
Example::... | python | def bypass(*inputs, copy=False):
"""
Returns the same arguments.
:param inputs:
Inputs values.
:type inputs: T
:param copy:
If True, it returns a deepcopy of input values.
:type copy: bool, optional
:return:
Same input values.
:rtype: (T, ...), T
Example::... | [
"def",
"bypass",
"(",
"*",
"inputs",
",",
"copy",
"=",
"False",
")",
":",
"if",
"len",
"(",
"inputs",
")",
"==",
"1",
":",
"inputs",
"=",
"inputs",
"[",
"0",
"]",
"# Same inputs.",
"return",
"_copy",
".",
"deepcopy",
"(",
"inputs",
")",
"if",
"copy... | Returns the same arguments.
:param inputs:
Inputs values.
:type inputs: T
:param copy:
If True, it returns a deepcopy of input values.
:type copy: bool, optional
:return:
Same input values.
:rtype: (T, ...), T
Example::
>>> bypass('a', 'b', 'c')
(... | [
"Returns",
"the",
"same",
"arguments",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L124-L151 | train | Returns the same arguments. |
vinci1it2000/schedula | schedula/utils/dsp.py | map_dict | def map_dict(key_map, *dicts, copy=False, base=None):
"""
Returns a dict with new key values.
:param key_map:
A dictionary that maps the dict keys ({old key: new key}
:type key_map: dict
:param dicts:
A sequence of dicts.
:type dicts: dict
:param copy:
If True, it ... | python | def map_dict(key_map, *dicts, copy=False, base=None):
"""
Returns a dict with new key values.
:param key_map:
A dictionary that maps the dict keys ({old key: new key}
:type key_map: dict
:param dicts:
A sequence of dicts.
:type dicts: dict
:param copy:
If True, it ... | [
"def",
"map_dict",
"(",
"key_map",
",",
"*",
"dicts",
",",
"copy",
"=",
"False",
",",
"base",
"=",
"None",
")",
":",
"it",
"=",
"combine_dicts",
"(",
"*",
"dicts",
")",
".",
"items",
"(",
")",
"# Combine dicts.",
"get",
"=",
"key_map",
".",
"get",
... | Returns a dict with new key values.
:param key_map:
A dictionary that maps the dict keys ({old key: new key}
:type key_map: dict
:param dicts:
A sequence of dicts.
:type dicts: dict
:param copy:
If True, it returns a deepcopy of input values.
:type copy: bool, optional... | [
"Returns",
"a",
"dict",
"with",
"new",
"key",
"values",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L176-L212 | train | Returns a dict that maps the keys of the given dicts. |
vinci1it2000/schedula | schedula/utils/dsp.py | map_list | def map_list(key_map, *inputs, copy=False, base=None):
"""
Returns a new dict.
:param key_map:
A list that maps the dict keys ({old key: new key}
:type key_map: list[str | dict | list]
:param inputs:
A sequence of data.
:type inputs: iterable | dict | int | float | list | tuple... | python | def map_list(key_map, *inputs, copy=False, base=None):
"""
Returns a new dict.
:param key_map:
A list that maps the dict keys ({old key: new key}
:type key_map: list[str | dict | list]
:param inputs:
A sequence of data.
:type inputs: iterable | dict | int | float | list | tuple... | [
"def",
"map_list",
"(",
"key_map",
",",
"*",
"inputs",
",",
"copy",
"=",
"False",
",",
"base",
"=",
"None",
")",
":",
"d",
"=",
"{",
"}",
"if",
"base",
"is",
"None",
"else",
"base",
"# Initialize empty dict.",
"for",
"m",
",",
"v",
"in",
"zip",
"("... | Returns a new dict.
:param key_map:
A list that maps the dict keys ({old key: new key}
:type key_map: list[str | dict | list]
:param inputs:
A sequence of data.
:type inputs: iterable | dict | int | float | list | tuple
:param copy:
If True, it returns a deepcopy of input ... | [
"Returns",
"a",
"new",
"dict",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L215-L272 | train | Returns a new dict with the keys that map the input list. |
vinci1it2000/schedula | schedula/utils/dsp.py | selector | def selector(keys, dictionary, copy=False, output_type='dict',
allow_miss=False):
"""
Selects the chosen dictionary keys from the given dictionary.
:param keys:
Keys to select.
:type keys: list, tuple, set
:param dictionary:
A dictionary.
:type dictionary: dict
... | python | def selector(keys, dictionary, copy=False, output_type='dict',
allow_miss=False):
"""
Selects the chosen dictionary keys from the given dictionary.
:param keys:
Keys to select.
:type keys: list, tuple, set
:param dictionary:
A dictionary.
:type dictionary: dict
... | [
"def",
"selector",
"(",
"keys",
",",
"dictionary",
",",
"copy",
"=",
"False",
",",
"output_type",
"=",
"'dict'",
",",
"allow_miss",
"=",
"False",
")",
":",
"if",
"not",
"allow_miss",
":",
"# noinspection PyUnusedLocal",
"def",
"check",
"(",
"key",
")",
":"... | Selects the chosen dictionary keys from the given dictionary.
:param keys:
Keys to select.
:type keys: list, tuple, set
:param dictionary:
A dictionary.
:type dictionary: dict
:param copy:
If True the output contains deep-copies of the values.
:type copy: bool
:pa... | [
"Selects",
"the",
"chosen",
"dictionary",
"keys",
"from",
"the",
"given",
"dictionary",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L275-L334 | train | Select the chosen dictionary keys from the given dictionary. |
vinci1it2000/schedula | schedula/utils/dsp.py | replicate_value | def replicate_value(value, n=2, copy=True):
"""
Replicates `n` times the input value.
:param n:
Number of replications.
:type n: int
:param value:
Value to be replicated.
:type value: T
:param copy:
If True the list contains deep-copies of the value.
:type copy... | python | def replicate_value(value, n=2, copy=True):
"""
Replicates `n` times the input value.
:param n:
Number of replications.
:type n: int
:param value:
Value to be replicated.
:type value: T
:param copy:
If True the list contains deep-copies of the value.
:type copy... | [
"def",
"replicate_value",
"(",
"value",
",",
"n",
"=",
"2",
",",
"copy",
"=",
"True",
")",
":",
"return",
"bypass",
"(",
"*",
"[",
"value",
"]",
"*",
"n",
",",
"copy",
"=",
"copy",
")"
] | Replicates `n` times the input value.
:param n:
Number of replications.
:type n: int
:param value:
Value to be replicated.
:type value: T
:param copy:
If True the list contains deep-copies of the value.
:type copy: bool
:return:
A list with the value repli... | [
"Replicates",
"n",
"times",
"the",
"input",
"value",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L337-L365 | train | Replicates the input value n times the input value. |
vinci1it2000/schedula | schedula/utils/dsp.py | parent_func | def parent_func(func, input_id=None):
"""
Return the parent function of a wrapped function (wrapped with
:class:`functools.partial` and :class:`add_args`).
:param func:
Wrapped function.
:type func: callable
:param input_id:
Index of the first input of the wrapped function.
... | python | def parent_func(func, input_id=None):
"""
Return the parent function of a wrapped function (wrapped with
:class:`functools.partial` and :class:`add_args`).
:param func:
Wrapped function.
:type func: callable
:param input_id:
Index of the first input of the wrapped function.
... | [
"def",
"parent_func",
"(",
"func",
",",
"input_id",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"func",
",",
"functools",
".",
"partial",
")",
":",
"if",
"input_id",
"is",
"not",
"None",
":",
"# noinspection PyTypeChecker",
"input_id",
"+=",
"len",
"("... | Return the parent function of a wrapped function (wrapped with
:class:`functools.partial` and :class:`add_args`).
:param func:
Wrapped function.
:type func: callable
:param input_id:
Index of the first input of the wrapped function.
:type input_id: int
:return:
Parent ... | [
"Return",
"the",
"parent",
"function",
"of",
"a",
"wrapped",
"function",
"(",
"wrapped",
"with",
":",
"class",
":",
"functools",
".",
"partial",
"and",
":",
"class",
":",
"add_args",
")",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L368-L399 | train | Return the parent function of a wrapped function. |
vinci1it2000/schedula | schedula/utils/dsp.py | stack_nested_keys | def stack_nested_keys(nested_dict, key=(), depth=-1):
"""
Stacks the keys of nested-dictionaries into tuples and yields a list of
k-v pairs.
:param nested_dict:
Nested dictionary.
:type nested_dict: dict
:param key:
Initial keys.
:type key: tuple, optional
:param depth... | python | def stack_nested_keys(nested_dict, key=(), depth=-1):
"""
Stacks the keys of nested-dictionaries into tuples and yields a list of
k-v pairs.
:param nested_dict:
Nested dictionary.
:type nested_dict: dict
:param key:
Initial keys.
:type key: tuple, optional
:param depth... | [
"def",
"stack_nested_keys",
"(",
"nested_dict",
",",
"key",
"=",
"(",
")",
",",
"depth",
"=",
"-",
"1",
")",
":",
"if",
"depth",
"!=",
"0",
"and",
"hasattr",
"(",
"nested_dict",
",",
"'items'",
")",
":",
"for",
"k",
",",
"v",
"in",
"nested_dict",
"... | Stacks the keys of nested-dictionaries into tuples and yields a list of
k-v pairs.
:param nested_dict:
Nested dictionary.
:type nested_dict: dict
:param key:
Initial keys.
:type key: tuple, optional
:param depth:
Maximum keys depth.
:type depth: int, optional
... | [
"Stacks",
"the",
"keys",
"of",
"nested",
"-",
"dictionaries",
"into",
"tuples",
"and",
"yields",
"a",
"list",
"of",
"k",
"-",
"v",
"pairs",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L475-L501 | train | Stacks the keys of nested - dictionaries into tuples and yields a list of k - v pairs. |
vinci1it2000/schedula | schedula/utils/dsp.py | get_nested_dicts | def get_nested_dicts(nested_dict, *keys, default=None, init_nesting=dict):
"""
Get/Initialize the value of nested-dictionaries.
:param nested_dict:
Nested dictionary.
:type nested_dict: dict
:param keys:
Nested keys.
:type keys: object
:param default:
Function used... | python | def get_nested_dicts(nested_dict, *keys, default=None, init_nesting=dict):
"""
Get/Initialize the value of nested-dictionaries.
:param nested_dict:
Nested dictionary.
:type nested_dict: dict
:param keys:
Nested keys.
:type keys: object
:param default:
Function used... | [
"def",
"get_nested_dicts",
"(",
"nested_dict",
",",
"*",
"keys",
",",
"default",
"=",
"None",
",",
"init_nesting",
"=",
"dict",
")",
":",
"if",
"keys",
":",
"default",
"=",
"default",
"or",
"init_nesting",
"if",
"keys",
"[",
"0",
"]",
"in",
"nested_dict"... | Get/Initialize the value of nested-dictionaries.
:param nested_dict:
Nested dictionary.
:type nested_dict: dict
:param keys:
Nested keys.
:type keys: object
:param default:
Function used to initialize a new value.
:type default: callable, optional
:param init_nest... | [
"Get",
"/",
"Initialize",
"the",
"value",
"of",
"nested",
"-",
"dictionaries",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L504-L538 | train | Get the value of nested - dicts. |
vinci1it2000/schedula | schedula/utils/dsp.py | are_in_nested_dicts | def are_in_nested_dicts(nested_dict, *keys):
"""
Nested keys are inside of nested-dictionaries.
:param nested_dict:
Nested dictionary.
:type nested_dict: dict
:param keys:
Nested keys.
:type keys: object
:return:
True if nested keys are inside of nested-dictionarie... | python | def are_in_nested_dicts(nested_dict, *keys):
"""
Nested keys are inside of nested-dictionaries.
:param nested_dict:
Nested dictionary.
:type nested_dict: dict
:param keys:
Nested keys.
:type keys: object
:return:
True if nested keys are inside of nested-dictionarie... | [
"def",
"are_in_nested_dicts",
"(",
"nested_dict",
",",
"*",
"keys",
")",
":",
"if",
"keys",
":",
"# noinspection PyBroadException",
"try",
":",
"return",
"are_in_nested_dicts",
"(",
"nested_dict",
"[",
"keys",
"[",
"0",
"]",
"]",
",",
"*",
"keys",
"[",
"1",
... | Nested keys are inside of nested-dictionaries.
:param nested_dict:
Nested dictionary.
:type nested_dict: dict
:param keys:
Nested keys.
:type keys: object
:return:
True if nested keys are inside of nested-dictionaries, otherwise False.
:rtype: bool | [
"Nested",
"keys",
"are",
"inside",
"of",
"nested",
"-",
"dictionaries",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L541-L564 | train | Returns True if nested keys are inside of nested - dictionaries otherwise False. |
vinci1it2000/schedula | schedula/utils/dsp.py | combine_nested_dicts | def combine_nested_dicts(*nested_dicts, depth=-1, base=None):
"""
Merge nested-dictionaries.
:param nested_dicts:
Nested dictionaries.
:type nested_dicts: dict
:param depth:
Maximum keys depth.
:type depth: int, optional
:param base:
Base dict where combine multipl... | python | def combine_nested_dicts(*nested_dicts, depth=-1, base=None):
"""
Merge nested-dictionaries.
:param nested_dicts:
Nested dictionaries.
:type nested_dicts: dict
:param depth:
Maximum keys depth.
:type depth: int, optional
:param base:
Base dict where combine multipl... | [
"def",
"combine_nested_dicts",
"(",
"*",
"nested_dicts",
",",
"depth",
"=",
"-",
"1",
",",
"base",
"=",
"None",
")",
":",
"if",
"base",
"is",
"None",
":",
"base",
"=",
"{",
"}",
"for",
"nested_dict",
"in",
"nested_dicts",
":",
"for",
"k",
",",
"v",
... | Merge nested-dictionaries.
:param nested_dicts:
Nested dictionaries.
:type nested_dicts: dict
:param depth:
Maximum keys depth.
:type depth: int, optional
:param base:
Base dict where combine multiple dicts in one.
:type base: dict, optional
:return:
Combi... | [
"Merge",
"nested",
"-",
"dictionaries",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L567-L603 | train | Combine nested - dictionaries. |
vinci1it2000/schedula | schedula/utils/dsp.py | add_function | def add_function(dsp, inputs_kwargs=False, inputs_defaults=False, **kw):
"""
Decorator to add a function to a dispatcher.
:param dsp:
A dispatcher.
:type dsp: schedula.Dispatcher
:param inputs_kwargs:
Do you want to include kwargs as inputs?
:type inputs_kwargs: bool
... | python | def add_function(dsp, inputs_kwargs=False, inputs_defaults=False, **kw):
"""
Decorator to add a function to a dispatcher.
:param dsp:
A dispatcher.
:type dsp: schedula.Dispatcher
:param inputs_kwargs:
Do you want to include kwargs as inputs?
:type inputs_kwargs: bool
... | [
"def",
"add_function",
"(",
"dsp",
",",
"inputs_kwargs",
"=",
"False",
",",
"inputs_defaults",
"=",
"False",
",",
"*",
"*",
"kw",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"dsp",
".",
"add_func",
"(",
"f",
",",
"inputs_kwargs",
"=",
"inputs_kwa... | Decorator to add a function to a dispatcher.
:param dsp:
A dispatcher.
:type dsp: schedula.Dispatcher
:param inputs_kwargs:
Do you want to include kwargs as inputs?
:type inputs_kwargs: bool
:param inputs_defaults:
Do you want to set default values?
:type inputs_... | [
"Decorator",
"to",
"add",
"a",
"function",
"to",
"a",
"dispatcher",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L1242-L1296 | train | Decorator to add a function to a dispatcher. |
vinci1it2000/schedula | schedula/utils/dsp.py | SubDispatch.blue | def blue(self, memo=None):
"""
Constructs a Blueprint out of the current object.
:param memo:
A dictionary to cache Blueprints.
:type memo: dict[T,schedula.utils.blue.Blueprint]
:return:
A Blueprint of the current object.
:rtype: schedula.utils.b... | python | def blue(self, memo=None):
"""
Constructs a Blueprint out of the current object.
:param memo:
A dictionary to cache Blueprints.
:type memo: dict[T,schedula.utils.blue.Blueprint]
:return:
A Blueprint of the current object.
:rtype: schedula.utils.b... | [
"def",
"blue",
"(",
"self",
",",
"memo",
"=",
"None",
")",
":",
"memo",
"=",
"{",
"}",
"if",
"memo",
"is",
"None",
"else",
"memo",
"if",
"self",
"not",
"in",
"memo",
":",
"import",
"inspect",
"from",
".",
"blue",
"import",
"Blueprint",
",",
"_paren... | Constructs a Blueprint out of the current object.
:param memo:
A dictionary to cache Blueprints.
:type memo: dict[T,schedula.utils.blue.Blueprint]
:return:
A Blueprint of the current object.
:rtype: schedula.utils.blue.Blueprint | [
"Constructs",
"a",
"Blueprint",
"out",
"of",
"the",
"current",
"object",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/dsp.py#L741-L762 | train | Returns a Blueprint instance for the current object. |
leplatrem/django-sizefield | sizefield/widgets.py | FileSizeWidget.value_from_datadict | def value_from_datadict(self, data, files, name):
"""
Given a dictionary of data and this widget's name, returns the value
of this widget. Returns None if it's not provided.
"""
value = super(FileSizeWidget, self).value_from_datadict(data, files, name)
if value not in EMP... | python | def value_from_datadict(self, data, files, name):
"""
Given a dictionary of data and this widget's name, returns the value
of this widget. Returns None if it's not provided.
"""
value = super(FileSizeWidget, self).value_from_datadict(data, files, name)
if value not in EMP... | [
"def",
"value_from_datadict",
"(",
"self",
",",
"data",
",",
"files",
",",
"name",
")",
":",
"value",
"=",
"super",
"(",
"FileSizeWidget",
",",
"self",
")",
".",
"value_from_datadict",
"(",
"data",
",",
"files",
",",
"name",
")",
"if",
"value",
"not",
... | Given a dictionary of data and this widget's name, returns the value
of this widget. Returns None if it's not provided. | [
"Given",
"a",
"dictionary",
"of",
"data",
"and",
"this",
"widget",
"s",
"name",
"returns",
"the",
"value",
"of",
"this",
"widget",
".",
"Returns",
"None",
"if",
"it",
"s",
"not",
"provided",
"."
] | 6a273a43a2e8d157ee438811c0824eae534bcdb2 | https://github.com/leplatrem/django-sizefield/blob/6a273a43a2e8d157ee438811c0824eae534bcdb2/sizefield/widgets.py#L17-L28 | train | Returns the value of this widget from a dictionary of data and this widget s name. |
theodoregoetz/wernher | sandbox/PIDControl.py | Device.control_force | def control_force(self,c):
'''represents physical limitation of the control'''
# bring instance variables into local scope
g = self.g
s = self.s
return g * (2/π) * arctan((s/g) * c) | python | def control_force(self,c):
'''represents physical limitation of the control'''
# bring instance variables into local scope
g = self.g
s = self.s
return g * (2/π) * arctan((s/g) * c) | [
"def",
"control_force",
"(",
"self",
",",
"c",
")",
":",
"# bring instance variables into local scope",
"g",
"=",
"self",
".",
"g",
"s",
"=",
"self",
".",
"s",
"return",
"g",
"*",
"(",
"2",
"/",
"π)",
" ",
" ",
"rctan(",
"(",
"s",
"/",
"g",
")",
" ... | represents physical limitation of the control | [
"represents",
"physical",
"limitation",
"of",
"the",
"control"
] | ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e | https://github.com/theodoregoetz/wernher/blob/ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e/sandbox/PIDControl.py#L30-L37 | train | represents physical limitation of the control |
theodoregoetz/wernher | sandbox/PIDControl.py | Device.force | def force(self,c):
'''control force plus the external forces (drag, etc)'''
# bring instance variables into local scope
x = self.x
v = self.v
b = self.b
k = self.k
x0 = self.x0
F = self.control_force(c)
return F - b*v - k... | python | def force(self,c):
'''control force plus the external forces (drag, etc)'''
# bring instance variables into local scope
x = self.x
v = self.v
b = self.b
k = self.k
x0 = self.x0
F = self.control_force(c)
return F - b*v - k... | [
"def",
"force",
"(",
"self",
",",
"c",
")",
":",
"# bring instance variables into local scope",
"x",
"=",
"self",
".",
"x",
"v",
"=",
"self",
".",
"v",
"b",
"=",
"self",
".",
"b",
"k",
"=",
"self",
".",
"k",
"x0",
"=",
"self",
".",
"x0",
"F",
"="... | control force plus the external forces (drag, etc) | [
"control",
"force",
"plus",
"the",
"external",
"forces",
"(",
"drag",
"etc",
")"
] | ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e | https://github.com/theodoregoetz/wernher/blob/ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e/sandbox/PIDControl.py#L39-L51 | train | control force plus the external forces |
theodoregoetz/wernher | wernher/orbit.py | right_ascension | def right_ascension(self):
'''of ascending node'''
nx,ny = self.node_line_vector
n = self.node_line
Ω = arccos(nx/n)
if ny < 0:
Ω = 2*π - Ω
return Ω | python | def right_ascension(self):
'''of ascending node'''
nx,ny = self.node_line_vector
n = self.node_line
Ω = arccos(nx/n)
if ny < 0:
Ω = 2*π - Ω
return Ω | [
"def",
"right_ascension",
"(",
"self",
")",
":",
"nx",
",",
"ny",
"=",
"self",
".",
"node_line_vector",
"n",
"=",
"self",
".",
"node_line",
"Ω ",
" ",
"rccos(",
"n",
"x/",
"n",
")",
"",
"if",
"ny",
"<",
"0",
":",
"Ω ",
" ",
"*",
"π",
" -",
"Ω",... | of ascending node | [
"of",
"ascending",
"node"
] | ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e | https://github.com/theodoregoetz/wernher/blob/ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e/wernher/orbit.py#L231-L238 | train | of ascending node |
theodoregoetz/wernher | wernher/orbit.py | transform | def transform(self):
'''P⃗,Q⃗,W⃗'''
i = self.inclination
Ω = self.longitude_of_ascending_node
ω = self.argument_of_periapsis
si = sin(i)
ci = cos(i)
sΩ = sin(Ω)
cΩ = cos(Ω)
sω = sin(ω)
cω = cos(ω)
Q = np.array([
[-sΩ*... | python | def transform(self):
'''P⃗,Q⃗,W⃗'''
i = self.inclination
Ω = self.longitude_of_ascending_node
ω = self.argument_of_periapsis
si = sin(i)
ci = cos(i)
sΩ = sin(Ω)
cΩ = cos(Ω)
sω = sin(ω)
cω = cos(ω)
Q = np.array([
[-sΩ*... | [
"def",
"transform",
"(",
"self",
")",
":",
"i",
"=",
"self",
".",
"inclination",
"Ω ",
" ",
"elf.",
"l",
"ongitude_of_ascending_node",
"ω ",
" ",
"elf.",
"a",
"rgument_of_periapsis",
"si",
"=",
"sin",
"(",
"i",
")",
"ci",
"=",
"cos",
"(",
"i",
")",
"... | P⃗,Q⃗,W⃗ | [
"P⃗",
"Q⃗",
"W⃗"
] | ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e | https://github.com/theodoregoetz/wernher/blob/ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e/wernher/orbit.py#L747-L771 | train | Transform the internal state of the object into a vector of P Q and W. |
dsoprea/PySecure | pysecure/easy.py | connect_ssh_with_cb | def connect_ssh_with_cb(ssh_cb, user, host, auth_cb, allow_new=True,
verbosity=0):
"""A "managed" SSH session. When the session is ready, we'll invoke the
"ssh_cb" callback.
"""
with connect_ssh(user, host, auth_cb, allow_new=True, verbosity=0) as ssh:
ssh_cb(ssh) | python | def connect_ssh_with_cb(ssh_cb, user, host, auth_cb, allow_new=True,
verbosity=0):
"""A "managed" SSH session. When the session is ready, we'll invoke the
"ssh_cb" callback.
"""
with connect_ssh(user, host, auth_cb, allow_new=True, verbosity=0) as ssh:
ssh_cb(ssh) | [
"def",
"connect_ssh_with_cb",
"(",
"ssh_cb",
",",
"user",
",",
"host",
",",
"auth_cb",
",",
"allow_new",
"=",
"True",
",",
"verbosity",
"=",
"0",
")",
":",
"with",
"connect_ssh",
"(",
"user",
",",
"host",
",",
"auth_cb",
",",
"allow_new",
"=",
"True",
... | A "managed" SSH session. When the session is ready, we'll invoke the
"ssh_cb" callback. | [
"A",
"managed",
"SSH",
"session",
".",
"When",
"the",
"session",
"is",
"ready",
"we",
"ll",
"invoke",
"the",
"ssh_cb",
"callback",
"."
] | ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0 | https://github.com/dsoprea/PySecure/blob/ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0/pysecure/easy.py#L20-L27 | train | Connect to a managed SSH session. |
dsoprea/PySecure | pysecure/easy.py | connect_sftp_with_cb | def connect_sftp_with_cb(sftp_cb, *args, **kwargs):
"""A "managed" SFTP session. When the SSH session and an additional SFTP
session are ready, invoke the sftp_cb callback.
"""
with _connect_sftp(*args, **kwargs) as (ssh, sftp):
sftp_cb(ssh, sftp) | python | def connect_sftp_with_cb(sftp_cb, *args, **kwargs):
"""A "managed" SFTP session. When the SSH session and an additional SFTP
session are ready, invoke the sftp_cb callback.
"""
with _connect_sftp(*args, **kwargs) as (ssh, sftp):
sftp_cb(ssh, sftp) | [
"def",
"connect_sftp_with_cb",
"(",
"sftp_cb",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"_connect_sftp",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"as",
"(",
"ssh",
",",
"sftp",
")",
":",
"sftp_cb",
"(",
"ssh",
",",
"sftp"... | A "managed" SFTP session. When the SSH session and an additional SFTP
session are ready, invoke the sftp_cb callback. | [
"A",
"managed",
"SFTP",
"session",
".",
"When",
"the",
"SSH",
"session",
"and",
"an",
"additional",
"SFTP",
"session",
"are",
"ready",
"invoke",
"the",
"sftp_cb",
"callback",
"."
] | ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0 | https://github.com/dsoprea/PySecure/blob/ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0/pysecure/easy.py#L39-L45 | train | A managed SFTP session. |
dsoprea/PySecure | pysecure/easy.py | get_key_auth_cb | def get_key_auth_cb(key_filepath):
"""This is just a convenience function for key-based login."""
def auth_cb(ssh):
key = ssh_pki_import_privkey_file(key_filepath)
ssh.userauth_publickey(key)
return auth_cb | python | def get_key_auth_cb(key_filepath):
"""This is just a convenience function for key-based login."""
def auth_cb(ssh):
key = ssh_pki_import_privkey_file(key_filepath)
ssh.userauth_publickey(key)
return auth_cb | [
"def",
"get_key_auth_cb",
"(",
"key_filepath",
")",
":",
"def",
"auth_cb",
"(",
"ssh",
")",
":",
"key",
"=",
"ssh_pki_import_privkey_file",
"(",
"key_filepath",
")",
"ssh",
".",
"userauth_publickey",
"(",
"key",
")",
"return",
"auth_cb"
] | This is just a convenience function for key-based login. | [
"This",
"is",
"just",
"a",
"convenience",
"function",
"for",
"key",
"-",
"based",
"login",
"."
] | ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0 | https://github.com/dsoprea/PySecure/blob/ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0/pysecure/easy.py#L47-L54 | train | This is just a convenience function for key - based login. |
vinci1it2000/schedula | schedula/utils/alg.py | add_edge_fun | def add_edge_fun(graph):
"""
Returns a function that adds an edge to the `graph` checking only the out
node.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:return:
A function that adds an edge to the `graph`.
:rtype: callable
"""
# N... | python | def add_edge_fun(graph):
"""
Returns a function that adds an edge to the `graph` checking only the out
node.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:return:
A function that adds an edge to the `graph`.
:rtype: callable
"""
# N... | [
"def",
"add_edge_fun",
"(",
"graph",
")",
":",
"# Namespace shortcut for speed.",
"succ",
",",
"pred",
",",
"node",
"=",
"graph",
".",
"_succ",
",",
"graph",
".",
"_pred",
",",
"graph",
".",
"_node",
"def",
"add_edge",
"(",
"u",
",",
"v",
",",
"*",
"*"... | Returns a function that adds an edge to the `graph` checking only the out
node.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:return:
A function that adds an edge to the `graph`.
:rtype: callable | [
"Returns",
"a",
"function",
"that",
"adds",
"an",
"edge",
"to",
"the",
"graph",
"checking",
"only",
"the",
"out",
"node",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/alg.py#L22-L45 | train | Returns a function that adds an edge to the graph checking only the out
node. |
vinci1it2000/schedula | schedula/utils/alg.py | remove_edge_fun | def remove_edge_fun(graph):
"""
Returns a function that removes an edge from the `graph`.
..note:: The out node is removed if this is isolate.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:return:
A function that remove an edge from the `graph`... | python | def remove_edge_fun(graph):
"""
Returns a function that removes an edge from the `graph`.
..note:: The out node is removed if this is isolate.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:return:
A function that remove an edge from the `graph`... | [
"def",
"remove_edge_fun",
"(",
"graph",
")",
":",
"# Namespace shortcut for speed.",
"rm_edge",
",",
"rm_node",
"=",
"graph",
".",
"remove_edge",
",",
"graph",
".",
"remove_node",
"from",
"networkx",
"import",
"is_isolate",
"def",
"remove_edge",
"(",
"u",
",",
"... | Returns a function that removes an edge from the `graph`.
..note:: The out node is removed if this is isolate.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:return:
A function that remove an edge from the `graph`.
:rtype: callable | [
"Returns",
"a",
"function",
"that",
"removes",
"an",
"edge",
"from",
"the",
"graph",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/alg.py#L48-L72 | train | Returns a function that removes an edge from the node. |
vinci1it2000/schedula | schedula/utils/alg.py | get_unused_node_id | def get_unused_node_id(graph, initial_guess='unknown', _format='{}<%d>'):
"""
Finds an unused node id in `graph`.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:param initial_guess:
Initial node id guess.
:type initial_guess: str, optional
:... | python | def get_unused_node_id(graph, initial_guess='unknown', _format='{}<%d>'):
"""
Finds an unused node id in `graph`.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:param initial_guess:
Initial node id guess.
:type initial_guess: str, optional
:... | [
"def",
"get_unused_node_id",
"(",
"graph",
",",
"initial_guess",
"=",
"'unknown'",
",",
"_format",
"=",
"'{}<%d>'",
")",
":",
"has_node",
"=",
"graph",
".",
"has_node",
"# Namespace shortcut for speed.",
"n",
"=",
"counter",
"(",
")",
"# Counter.",
"node_id_format... | Finds an unused node id in `graph`.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:param initial_guess:
Initial node id guess.
:type initial_guess: str, optional
:param _format:
Format to generate the new node id if the given is already used... | [
"Finds",
"an",
"unused",
"node",
"id",
"in",
"graph",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/alg.py#L75-L105 | train | Returns an unused node id in a directed graph. |
vinci1it2000/schedula | schedula/utils/alg.py | add_func_edges | def add_func_edges(dsp, fun_id, nodes_bunch, edge_weights=None, input=True,
data_nodes=None):
"""
Adds function node edges.
:param dsp:
A dispatcher that identifies the model adopted.
:type dsp: schedula.Dispatcher
:param fun_id:
Function node id.
:type fun_i... | python | def add_func_edges(dsp, fun_id, nodes_bunch, edge_weights=None, input=True,
data_nodes=None):
"""
Adds function node edges.
:param dsp:
A dispatcher that identifies the model adopted.
:type dsp: schedula.Dispatcher
:param fun_id:
Function node id.
:type fun_i... | [
"def",
"add_func_edges",
"(",
"dsp",
",",
"fun_id",
",",
"nodes_bunch",
",",
"edge_weights",
"=",
"None",
",",
"input",
"=",
"True",
",",
"data_nodes",
"=",
"None",
")",
":",
"# Namespace shortcut for speed.",
"add_edge",
"=",
"_add_edge_dmap_fun",
"(",
"dsp",
... | Adds function node edges.
:param dsp:
A dispatcher that identifies the model adopted.
:type dsp: schedula.Dispatcher
:param fun_id:
Function node id.
:type fun_id: str
:param nodes_bunch:
A container of nodes which will be iterated through once.
:type nodes_bunch: iter... | [
"Adds",
"function",
"node",
"edges",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/alg.py#L108-L166 | train | Adds function node edges to the graph. |
vinci1it2000/schedula | schedula/utils/alg.py | _add_edge_dmap_fun | def _add_edge_dmap_fun(graph, edges_weights=None):
"""
Adds edge to the dispatcher map.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:param edges_weights:
Edge weights.
:type edges_weights: dict, optional
:return:
A function that ad... | python | def _add_edge_dmap_fun(graph, edges_weights=None):
"""
Adds edge to the dispatcher map.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:param edges_weights:
Edge weights.
:type edges_weights: dict, optional
:return:
A function that ad... | [
"def",
"_add_edge_dmap_fun",
"(",
"graph",
",",
"edges_weights",
"=",
"None",
")",
":",
"add",
"=",
"graph",
".",
"add_edge",
"# Namespace shortcut for speed.",
"if",
"edges_weights",
"is",
"not",
"None",
":",
"def",
"add_edge",
"(",
"i",
",",
"o",
",",
"w",... | Adds edge to the dispatcher map.
:param graph:
A directed graph.
:type graph: networkx.classes.digraph.DiGraph
:param edges_weights:
Edge weights.
:type edges_weights: dict, optional
:return:
A function that adds an edge to the `graph`.
:rtype: callable | [
"Adds",
"edge",
"to",
"the",
"dispatcher",
"map",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/alg.py#L169-L199 | train | A function that adds an edge to the dispatcher map. |
vinci1it2000/schedula | schedula/utils/alg.py | _get_node | def _get_node(nodes, node_id, fuzzy=True):
"""
Returns a dispatcher node that match the given node id.
:param nodes:
Dispatcher nodes.
:type nodes: dict
:param node_id:
Node id.
:type node_id: str
:return:
The dispatcher node and its id.
:rtype: (str, dict)
... | python | def _get_node(nodes, node_id, fuzzy=True):
"""
Returns a dispatcher node that match the given node id.
:param nodes:
Dispatcher nodes.
:type nodes: dict
:param node_id:
Node id.
:type node_id: str
:return:
The dispatcher node and its id.
:rtype: (str, dict)
... | [
"def",
"_get_node",
"(",
"nodes",
",",
"node_id",
",",
"fuzzy",
"=",
"True",
")",
":",
"try",
":",
"return",
"node_id",
",",
"nodes",
"[",
"node_id",
"]",
"# Return dispatcher node and its id.",
"except",
"KeyError",
"as",
"ex",
":",
"if",
"fuzzy",
":",
"i... | Returns a dispatcher node that match the given node id.
:param nodes:
Dispatcher nodes.
:type nodes: dict
:param node_id:
Node id.
:type node_id: str
:return:
The dispatcher node and its id.
:rtype: (str, dict) | [
"Returns",
"a",
"dispatcher",
"node",
"that",
"match",
"the",
"given",
"node",
"id",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/alg.py#L202-L227 | train | Returns a dispatcher node that matches the given node id. |
vinci1it2000/schedula | schedula/utils/alg.py | get_sub_node | def get_sub_node(dsp, path, node_attr='auto', solution=NONE, _level=0,
_dsp_name=NONE):
"""
Returns a sub node of a dispatcher.
:param dsp:
A dispatcher object or a sub dispatch function.
:type dsp: schedula.Dispatcher | SubDispatch
:param path:
A sequence of node... | python | def get_sub_node(dsp, path, node_attr='auto', solution=NONE, _level=0,
_dsp_name=NONE):
"""
Returns a sub node of a dispatcher.
:param dsp:
A dispatcher object or a sub dispatch function.
:type dsp: schedula.Dispatcher | SubDispatch
:param path:
A sequence of node... | [
"def",
"get_sub_node",
"(",
"dsp",
",",
"path",
",",
"node_attr",
"=",
"'auto'",
",",
"solution",
"=",
"NONE",
",",
"_level",
"=",
"0",
",",
"_dsp_name",
"=",
"NONE",
")",
":",
"path",
"=",
"list",
"(",
"path",
")",
"if",
"isinstance",
"(",
"dsp",
... | Returns a sub node of a dispatcher.
:param dsp:
A dispatcher object or a sub dispatch function.
:type dsp: schedula.Dispatcher | SubDispatch
:param path:
A sequence of node ids or a single node id. Each id identifies a
sub-level node.
:type path: tuple, str
:param node_at... | [
"Returns",
"a",
"sub",
"node",
"of",
"a",
"dispatcher",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/alg.py#L259-L418 | train | This function returns a sub - node of a dispatcher and a path. |
vinci1it2000/schedula | schedula/utils/alg.py | get_full_pipe | def get_full_pipe(sol, base=()):
"""
Returns the full pipe of a dispatch run.
:param sol:
A Solution object.
:type sol: schedula.utils.Solution
:param base:
Base node id.
:type base: tuple[str]
:return:
Full pipe of a dispatch run.
:rtype: DspPipe
"""
... | python | def get_full_pipe(sol, base=()):
"""
Returns the full pipe of a dispatch run.
:param sol:
A Solution object.
:type sol: schedula.utils.Solution
:param base:
Base node id.
:type base: tuple[str]
:return:
Full pipe of a dispatch run.
:rtype: DspPipe
"""
... | [
"def",
"get_full_pipe",
"(",
"sol",
",",
"base",
"=",
"(",
")",
")",
":",
"pipe",
",",
"i",
"=",
"DspPipe",
"(",
")",
",",
"len",
"(",
"base",
")",
"for",
"p",
"in",
"sol",
".",
"_pipe",
":",
"n",
",",
"s",
"=",
"p",
"[",
"-",
"1",
"]",
"... | Returns the full pipe of a dispatch run.
:param sol:
A Solution object.
:type sol: schedula.utils.Solution
:param base:
Base node id.
:type base: tuple[str]
:return:
Full pipe of a dispatch run.
:rtype: DspPipe | [
"Returns",
"the",
"full",
"pipe",
"of",
"a",
"dispatch",
"run",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/alg.py#L426-L471 | train | Returns the full pipe of a solution. |
CI-WATER/gsshapy | gsshapy/lib/spn_chunk.py | connectChunk | def connectChunk(key, chunk):
"""
Parse Storm Pipe CONNECT Chunk Method
"""
schunk = chunk[0].strip().split()
result = {'slinkNumber': schunk[1],
'upSjunc': schunk[2],
'downSjunc': schunk[3]}
return result | python | def connectChunk(key, chunk):
"""
Parse Storm Pipe CONNECT Chunk Method
"""
schunk = chunk[0].strip().split()
result = {'slinkNumber': schunk[1],
'upSjunc': schunk[2],
'downSjunc': schunk[3]}
return result | [
"def",
"connectChunk",
"(",
"key",
",",
"chunk",
")",
":",
"schunk",
"=",
"chunk",
"[",
"0",
"]",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"result",
"=",
"{",
"'slinkNumber'",
":",
"schunk",
"[",
"1",
"]",
",",
"'upSjunc'",
":",
"schunk",
... | Parse Storm Pipe CONNECT Chunk Method | [
"Parse",
"Storm",
"Pipe",
"CONNECT",
"Chunk",
"Method"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/spn_chunk.py#L15-L25 | train | Parse a Storm Pipe CONNECT Chunk Method |
CI-WATER/gsshapy | gsshapy/lib/spn_chunk.py | sjuncChunk | def sjuncChunk(key, chunk):
"""
Parse Super Junction (SJUNC) Chunk Method
"""
schunk = chunk[0].strip().split()
result = {'sjuncNumber': schunk[1],
'groundSurfaceElev': schunk[2],
'invertElev': schunk[3],
'manholeSA': schunk[4],
'inletCode': s... | python | def sjuncChunk(key, chunk):
"""
Parse Super Junction (SJUNC) Chunk Method
"""
schunk = chunk[0].strip().split()
result = {'sjuncNumber': schunk[1],
'groundSurfaceElev': schunk[2],
'invertElev': schunk[3],
'manholeSA': schunk[4],
'inletCode': s... | [
"def",
"sjuncChunk",
"(",
"key",
",",
"chunk",
")",
":",
"schunk",
"=",
"chunk",
"[",
"0",
"]",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"result",
"=",
"{",
"'sjuncNumber'",
":",
"schunk",
"[",
"1",
"]",
",",
"'groundSurfaceElev'",
":",
"sch... | Parse Super Junction (SJUNC) Chunk Method | [
"Parse",
"Super",
"Junction",
"(",
"SJUNC",
")",
"Chunk",
"Method"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/spn_chunk.py#L27-L43 | train | Parse Super Junction Chunk Method
|
CI-WATER/gsshapy | gsshapy/lib/spn_chunk.py | slinkChunk | def slinkChunk(key, lines):
"""
Parse Super Link (SLINK) Chunk Method
"""
KEYWORDS = ('SLINK',
'NODE',
'PIPE')
result = {'slinkNumber':None,
'numPipes':None,
'nodes':[],
'pipes':[]}
chunks = pt.chunk(KEYWORDS, lines)
... | python | def slinkChunk(key, lines):
"""
Parse Super Link (SLINK) Chunk Method
"""
KEYWORDS = ('SLINK',
'NODE',
'PIPE')
result = {'slinkNumber':None,
'numPipes':None,
'nodes':[],
'pipes':[]}
chunks = pt.chunk(KEYWORDS, lines)
... | [
"def",
"slinkChunk",
"(",
"key",
",",
"lines",
")",
":",
"KEYWORDS",
"=",
"(",
"'SLINK'",
",",
"'NODE'",
",",
"'PIPE'",
")",
"result",
"=",
"{",
"'slinkNumber'",
":",
"None",
",",
"'numPipes'",
":",
"None",
",",
"'nodes'",
":",
"[",
"]",
",",
"'pipes... | Parse Super Link (SLINK) Chunk Method | [
"Parse",
"Super",
"Link",
"(",
"SLINK",
")",
"Chunk",
"Method"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/spn_chunk.py#L45-L100 | train | Parse Super Link Chunk Method
|
hellupline/flask-manager | flask_manager/ext/sqlalchemy.py | SQLAlchemyController.get_items | def get_items(self, page=1, order_by=None, filters=None):
"""
Fetch database for items matching.
Args:
page (int):
which page will be sliced
slice size is ``self.per_page``.
order_by (str):
a field name to order query by.
... | python | def get_items(self, page=1, order_by=None, filters=None):
"""
Fetch database for items matching.
Args:
page (int):
which page will be sliced
slice size is ``self.per_page``.
order_by (str):
a field name to order query by.
... | [
"def",
"get_items",
"(",
"self",
",",
"page",
"=",
"1",
",",
"order_by",
"=",
"None",
",",
"filters",
"=",
"None",
")",
":",
"start",
"=",
"(",
"page",
"-",
"1",
")",
"*",
"self",
".",
"per_page",
"query",
"=",
"self",
".",
"get_query",
"(",
")",... | Fetch database for items matching.
Args:
page (int):
which page will be sliced
slice size is ``self.per_page``.
order_by (str):
a field name to order query by.
filters (dict):
a ``filter name``: ``value`` dict.
... | [
"Fetch",
"database",
"for",
"items",
"matching",
"."
] | 70e48309f73aacf55f5c37b43165791ae1cf6861 | https://github.com/hellupline/flask-manager/blob/70e48309f73aacf55f5c37b43165791ae1cf6861/flask_manager/ext/sqlalchemy.py#L160-L184 | train | Fetch database for items matching. |
theodoregoetz/wernher | wernher/colorline.py | colorline | def colorline(ax, x, y, z, **kwargs):
"""
http://nbviewer.ipython.org/github/dpsanders/matplotlib-examples/blob/master/colorline.ipynb
http://matplotlib.org/examples/pylab_examples/multicolored_line.html
Plot a colored line with coordinates x and y
Optionally specify colors in the array z
Option... | python | def colorline(ax, x, y, z, **kwargs):
"""
http://nbviewer.ipython.org/github/dpsanders/matplotlib-examples/blob/master/colorline.ipynb
http://matplotlib.org/examples/pylab_examples/multicolored_line.html
Plot a colored line with coordinates x and y
Optionally specify colors in the array z
Option... | [
"def",
"colorline",
"(",
"ax",
",",
"x",
",",
"y",
",",
"z",
",",
"*",
"*",
"kwargs",
")",
":",
"# Special case if a single number:",
"if",
"not",
"hasattr",
"(",
"z",
",",
"\"__iter__\"",
")",
":",
"# to check for numerical input -- this is a hack",
"z",
"=",... | http://nbviewer.ipython.org/github/dpsanders/matplotlib-examples/blob/master/colorline.ipynb
http://matplotlib.org/examples/pylab_examples/multicolored_line.html
Plot a colored line with coordinates x and y
Optionally specify colors in the array z
Optionally specify a colormap, a norm function and a lin... | [
"http",
":",
"//",
"nbviewer",
".",
"ipython",
".",
"org",
"/",
"github",
"/",
"dpsanders",
"/",
"matplotlib",
"-",
"examples",
"/",
"blob",
"/",
"master",
"/",
"colorline",
".",
"ipynb",
"http",
":",
"//",
"matplotlib",
".",
"org",
"/",
"examples",
"/... | ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e | https://github.com/theodoregoetz/wernher/blob/ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e/wernher/colorline.py#L6-L28 | train | Plots a colored line with coordinates x y z |
theodoregoetz/wernher | wernher/colorline.py | make_segments | def make_segments(x, y):
"""
Create list of line segments from x and y coordinates, in the correct format
for LineCollection: an array of the form numlines x (points per line) x 2 (x
and y) array
"""
points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], point... | python | def make_segments(x, y):
"""
Create list of line segments from x and y coordinates, in the correct format
for LineCollection: an array of the form numlines x (points per line) x 2 (x
and y) array
"""
points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], point... | [
"def",
"make_segments",
"(",
"x",
",",
"y",
")",
":",
"points",
"=",
"np",
".",
"array",
"(",
"[",
"x",
",",
"y",
"]",
")",
".",
"T",
".",
"reshape",
"(",
"-",
"1",
",",
"1",
",",
"2",
")",
"segments",
"=",
"np",
".",
"concatenate",
"(",
"[... | Create list of line segments from x and y coordinates, in the correct format
for LineCollection: an array of the form numlines x (points per line) x 2 (x
and y) array | [
"Create",
"list",
"of",
"line",
"segments",
"from",
"x",
"and",
"y",
"coordinates",
"in",
"the",
"correct",
"format",
"for",
"LineCollection",
":",
"an",
"array",
"of",
"the",
"form",
"numlines",
"x",
"(",
"points",
"per",
"line",
")",
"x",
"2",
"(",
"... | ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e | https://github.com/theodoregoetz/wernher/blob/ef5d3aabe24e532b5eab33cd0212b2dbc2c9022e/wernher/colorline.py#L31-L40 | train | Create list of line segments from x and y coordinates in the correct format
|
CI-WATER/gsshapy | gsshapy/orm/generic.py | GenericFile._read | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Generic File Read from File Method
"""
# Persist name and extension of file
self.name = name
self.fileExtension = extension
# Open file and pa... | python | def _read(self, directory, filename, session, path, name, extension, spatial, spatialReferenceID, replaceParamFile):
"""
Generic File Read from File Method
"""
# Persist name and extension of file
self.name = name
self.fileExtension = extension
# Open file and pa... | [
"def",
"_read",
"(",
"self",
",",
"directory",
",",
"filename",
",",
"session",
",",
"path",
",",
"name",
",",
"extension",
",",
"spatial",
",",
"spatialReferenceID",
",",
"replaceParamFile",
")",
":",
"# Persist name and extension of file",
"self",
".",
"name",... | Generic File Read from File Method | [
"Generic",
"File",
"Read",
"from",
"File",
"Method"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/generic.py#L55-L65 | train | Generic File Read from File Method |
wheerd/multiset | multiset.py | BaseMultiset.isdisjoint | def isdisjoint(self, other):
r"""Return True if the set has no elements in common with other.
Sets are disjoint iff their intersection is the empty set.
>>> ms = Multiset('aab')
>>> ms.isdisjoint('bc')
False
>>> ms.isdisjoint(Multiset('ccd'))
True
Args:... | python | def isdisjoint(self, other):
r"""Return True if the set has no elements in common with other.
Sets are disjoint iff their intersection is the empty set.
>>> ms = Multiset('aab')
>>> ms.isdisjoint('bc')
False
>>> ms.isdisjoint(Multiset('ccd'))
True
Args:... | [
"def",
"isdisjoint",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"_sequence_types",
"+",
"(",
"BaseMultiset",
",",
")",
")",
":",
"pass",
"elif",
"not",
"isinstance",
"(",
"other",
",",
"Container",
")",
":",
"other",
"=... | r"""Return True if the set has no elements in common with other.
Sets are disjoint iff their intersection is the empty set.
>>> ms = Multiset('aab')
>>> ms.isdisjoint('bc')
False
>>> ms.isdisjoint(Multiset('ccd'))
True
Args:
other: The other set to ... | [
"r",
"Return",
"True",
"if",
"the",
"set",
"has",
"no",
"elements",
"in",
"common",
"with",
"other",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L148-L167 | train | Return True if the set has no elements in common with other. |
wheerd/multiset | multiset.py | BaseMultiset.difference | def difference(self, *others):
r"""Return a new multiset with all elements from the others removed.
>>> ms = Multiset('aab')
>>> sorted(ms.difference('bc'))
['a', 'a']
You can also use the ``-`` operator for the same effect. However, the operator version
will only accep... | python | def difference(self, *others):
r"""Return a new multiset with all elements from the others removed.
>>> ms = Multiset('aab')
>>> sorted(ms.difference('bc'))
['a', 'a']
You can also use the ``-`` operator for the same effect. However, the operator version
will only accep... | [
"def",
"difference",
"(",
"self",
",",
"*",
"others",
")",
":",
"result",
"=",
"self",
".",
"__copy__",
"(",
")",
"_elements",
"=",
"result",
".",
"_elements",
"_total",
"=",
"result",
".",
"_total",
"for",
"other",
"in",
"map",
"(",
"self",
".",
"_a... | r"""Return a new multiset with all elements from the others removed.
>>> ms = Multiset('aab')
>>> sorted(ms.difference('bc'))
['a', 'a']
You can also use the ``-`` operator for the same effect. However, the operator version
will only accept a set as other operator, not any iter... | [
"r",
"Return",
"a",
"new",
"multiset",
"with",
"all",
"elements",
"from",
"the",
"others",
"removed",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L169-L208 | train | r Returns a new multiset with all elements from the others removed. |
wheerd/multiset | multiset.py | BaseMultiset.union | def union(self, *others):
r"""Return a new multiset with all elements from the multiset and the others with maximal multiplicities.
>>> ms = Multiset('aab')
>>> sorted(ms.union('bc'))
['a', 'a', 'b', 'c']
You can also use the ``|`` operator for the same effect. However, the ope... | python | def union(self, *others):
r"""Return a new multiset with all elements from the multiset and the others with maximal multiplicities.
>>> ms = Multiset('aab')
>>> sorted(ms.union('bc'))
['a', 'a', 'b', 'c']
You can also use the ``|`` operator for the same effect. However, the ope... | [
"def",
"union",
"(",
"self",
",",
"*",
"others",
")",
":",
"result",
"=",
"self",
".",
"__copy__",
"(",
")",
"_elements",
"=",
"result",
".",
"_elements",
"_total",
"=",
"result",
".",
"_total",
"for",
"other",
"in",
"map",
"(",
"self",
".",
"_as_map... | r"""Return a new multiset with all elements from the multiset and the others with maximal multiplicities.
>>> ms = Multiset('aab')
>>> sorted(ms.union('bc'))
['a', 'a', 'b', 'c']
You can also use the ``|`` operator for the same effect. However, the operator version
will only ac... | [
"r",
"Return",
"a",
"new",
"multiset",
"with",
"all",
"elements",
"from",
"the",
"multiset",
"and",
"the",
"others",
"with",
"maximal",
"multiplicities",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L222-L256 | train | r Return a new multiset with all elements from the multiset and the others with maximal multiplicities. |
wheerd/multiset | multiset.py | BaseMultiset.intersection | def intersection(self, *others):
r"""Return a new multiset with elements common to the multiset and all others.
>>> ms = Multiset('aab')
>>> sorted(ms.intersection('abc'))
['a', 'b']
You can also use the ``&`` operator for the same effect. However, the operator version
... | python | def intersection(self, *others):
r"""Return a new multiset with elements common to the multiset and all others.
>>> ms = Multiset('aab')
>>> sorted(ms.intersection('abc'))
['a', 'b']
You can also use the ``&`` operator for the same effect. However, the operator version
... | [
"def",
"intersection",
"(",
"self",
",",
"*",
"others",
")",
":",
"result",
"=",
"self",
".",
"__copy__",
"(",
")",
"_elements",
"=",
"result",
".",
"_elements",
"_total",
"=",
"result",
".",
"_total",
"for",
"other",
"in",
"map",
"(",
"self",
".",
"... | r"""Return a new multiset with elements common to the multiset and all others.
>>> ms = Multiset('aab')
>>> sorted(ms.intersection('abc'))
['a', 'b']
You can also use the ``&`` operator for the same effect. However, the operator version
will only accept a set as other operator,... | [
"r",
"Return",
"a",
"new",
"multiset",
"with",
"elements",
"common",
"to",
"the",
"multiset",
"and",
"all",
"others",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L316-L354 | train | r Return a new multiset with elements common to the multiset and all others. |
wheerd/multiset | multiset.py | BaseMultiset.symmetric_difference | def symmetric_difference(self, other):
r"""Return a new set with elements in either the set or other but not both.
>>> ms = Multiset('aab')
>>> sorted(ms.symmetric_difference('abc'))
['a', 'c']
You can also use the ``^`` operator for the same effect. However, the operator versi... | python | def symmetric_difference(self, other):
r"""Return a new set with elements in either the set or other but not both.
>>> ms = Multiset('aab')
>>> sorted(ms.symmetric_difference('abc'))
['a', 'c']
You can also use the ``^`` operator for the same effect. However, the operator versi... | [
"def",
"symmetric_difference",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"self",
".",
"_as_multiset",
"(",
"other",
")",
"result",
"=",
"self",
".",
"__class__",
"(",
")",
"_total",
"=",
"0",
"_elements",
"=",
"result",
".",
"_elements",
"self_e... | r"""Return a new set with elements in either the set or other but not both.
>>> ms = Multiset('aab')
>>> sorted(ms.symmetric_difference('abc'))
['a', 'c']
You can also use the ``^`` operator for the same effect. However, the operator version
will only accept a set as other oper... | [
"r",
"Return",
"a",
"new",
"set",
"with",
"elements",
"in",
"either",
"the",
"set",
"or",
"other",
"but",
"not",
"both",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L365-L405 | train | Return a new set with elements in either the set or other but not both. |
wheerd/multiset | multiset.py | BaseMultiset.times | def times(self, factor):
"""Return a new set with each element's multiplicity multiplied with the given scalar factor.
>>> ms = Multiset('aab')
>>> sorted(ms.times(2))
['a', 'a', 'a', 'a', 'b', 'b']
You can also use the ``*`` operator for the same effect:
>>> sorted(ms... | python | def times(self, factor):
"""Return a new set with each element's multiplicity multiplied with the given scalar factor.
>>> ms = Multiset('aab')
>>> sorted(ms.times(2))
['a', 'a', 'a', 'a', 'b', 'b']
You can also use the ``*`` operator for the same effect:
>>> sorted(ms... | [
"def",
"times",
"(",
"self",
",",
"factor",
")",
":",
"if",
"factor",
"==",
"0",
":",
"return",
"self",
".",
"__class__",
"(",
")",
"if",
"factor",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'The factor must no be negative.'",
")",
"result",
"=",
"self"... | Return a new set with each element's multiplicity multiplied with the given scalar factor.
>>> ms = Multiset('aab')
>>> sorted(ms.times(2))
['a', 'a', 'a', 'a', 'b', 'b']
You can also use the ``*`` operator for the same effect:
>>> sorted(ms * 3)
['a', 'a', 'a', 'a', '... | [
"Return",
"a",
"new",
"set",
"with",
"each",
"element",
"s",
"multiplicity",
"multiplied",
"with",
"the",
"given",
"scalar",
"factor",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L416-L443 | train | Returns a new set with each element s multiplicity multiplied with the given scalar factor. |
wheerd/multiset | multiset.py | Multiset.update | def update(self, *others):
r"""Like :meth:`dict.update` but add multiplicities instead of replacing them.
>>> ms = Multiset('aab')
>>> ms.update('abc')
>>> sorted(ms)
['a', 'a', 'a', 'b', 'b', 'c']
Note that the operator ``+=`` is equivalent to :meth:`update`, except th... | python | def update(self, *others):
r"""Like :meth:`dict.update` but add multiplicities instead of replacing them.
>>> ms = Multiset('aab')
>>> ms.update('abc')
>>> sorted(ms)
['a', 'a', 'a', 'b', 'b', 'c']
Note that the operator ``+=`` is equivalent to :meth:`update`, except th... | [
"def",
"update",
"(",
"self",
",",
"*",
"others",
")",
":",
"_elements",
"=",
"self",
".",
"_elements",
"for",
"other",
"in",
"map",
"(",
"self",
".",
"_as_mapping",
",",
"others",
")",
":",
"for",
"element",
",",
"multiplicity",
"in",
"other",
".",
... | r"""Like :meth:`dict.update` but add multiplicities instead of replacing them.
>>> ms = Multiset('aab')
>>> ms.update('abc')
>>> sorted(ms)
['a', 'a', 'a', 'b', 'b', 'c']
Note that the operator ``+=`` is equivalent to :meth:`update`, except that the operator will only
a... | [
"r",
"Like",
":",
"meth",
":",
"dict",
".",
"update",
"but",
"add",
"multiplicities",
"instead",
"of",
"replacing",
"them",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L692-L717 | train | Like dict. update but adds multiplicities instead of replacing them. |
wheerd/multiset | multiset.py | Multiset.union_update | def union_update(self, *others):
r"""Update the multiset, adding elements from all others using the maximum multiplicity.
>>> ms = Multiset('aab')
>>> ms.union_update('bc')
>>> sorted(ms)
['a', 'a', 'b', 'c']
You can also use the ``|=`` operator for the same effect. How... | python | def union_update(self, *others):
r"""Update the multiset, adding elements from all others using the maximum multiplicity.
>>> ms = Multiset('aab')
>>> ms.union_update('bc')
>>> sorted(ms)
['a', 'a', 'b', 'c']
You can also use the ``|=`` operator for the same effect. How... | [
"def",
"union_update",
"(",
"self",
",",
"*",
"others",
")",
":",
"_elements",
"=",
"self",
".",
"_elements",
"_total",
"=",
"self",
".",
"_total",
"for",
"other",
"in",
"map",
"(",
"self",
".",
"_as_mapping",
",",
"others",
")",
":",
"for",
"element",... | r"""Update the multiset, adding elements from all others using the maximum multiplicity.
>>> ms = Multiset('aab')
>>> ms.union_update('bc')
>>> sorted(ms)
['a', 'a', 'b', 'c']
You can also use the ``|=`` operator for the same effect. However, the operator version
will o... | [
"r",
"Update",
"the",
"multiset",
"adding",
"elements",
"from",
"all",
"others",
"using",
"the",
"maximum",
"multiplicity",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L719-L750 | train | Update the multiset with the union of the elements in this set and the others. |
wheerd/multiset | multiset.py | Multiset.intersection_update | def intersection_update(self, *others):
r"""Update the multiset, keeping only elements found in it and all others.
>>> ms = Multiset('aab')
>>> ms.intersection_update('bc')
>>> sorted(ms)
['b']
You can also use the ``&=`` operator for the same effect. However, the opera... | python | def intersection_update(self, *others):
r"""Update the multiset, keeping only elements found in it and all others.
>>> ms = Multiset('aab')
>>> ms.intersection_update('bc')
>>> sorted(ms)
['b']
You can also use the ``&=`` operator for the same effect. However, the opera... | [
"def",
"intersection_update",
"(",
"self",
",",
"*",
"others",
")",
":",
"for",
"other",
"in",
"map",
"(",
"self",
".",
"_as_mapping",
",",
"others",
")",
":",
"for",
"element",
",",
"current_count",
"in",
"list",
"(",
"self",
".",
"items",
"(",
")",
... | r"""Update the multiset, keeping only elements found in it and all others.
>>> ms = Multiset('aab')
>>> ms.intersection_update('bc')
>>> sorted(ms)
['b']
You can also use the ``&=`` operator for the same effect. However, the operator version
will only accept a set as ot... | [
"r",
"Update",
"the",
"multiset",
"keeping",
"only",
"elements",
"found",
"in",
"it",
"and",
"all",
"others",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L760-L787 | train | r Update the multiset keeping only elements found in it and all others. |
wheerd/multiset | multiset.py | Multiset.difference_update | def difference_update(self, *others):
r"""Remove all elements contained the others from this multiset.
>>> ms = Multiset('aab')
>>> ms.difference_update('abc')
>>> sorted(ms)
['a']
You can also use the ``-=`` operator for the same effect. However, the operator version
... | python | def difference_update(self, *others):
r"""Remove all elements contained the others from this multiset.
>>> ms = Multiset('aab')
>>> ms.difference_update('abc')
>>> sorted(ms)
['a']
You can also use the ``-=`` operator for the same effect. However, the operator version
... | [
"def",
"difference_update",
"(",
"self",
",",
"*",
"others",
")",
":",
"for",
"other",
"in",
"map",
"(",
"self",
".",
"_as_multiset",
",",
"others",
")",
":",
"for",
"element",
",",
"multiplicity",
"in",
"other",
".",
"items",
"(",
")",
":",
"self",
... | r"""Remove all elements contained the others from this multiset.
>>> ms = Multiset('aab')
>>> ms.difference_update('abc')
>>> sorted(ms)
['a']
You can also use the ``-=`` operator for the same effect. However, the operator version
will only accept a set as other operato... | [
"r",
"Remove",
"all",
"elements",
"contained",
"the",
"others",
"from",
"this",
"multiset",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L797-L822 | train | r Returns a new multiset with the elements contained in others removed. |
wheerd/multiset | multiset.py | Multiset.symmetric_difference_update | def symmetric_difference_update(self, other):
r"""Update the multiset to contain only elements in either this multiset or the other but not both.
>>> ms = Multiset('aab')
>>> ms.symmetric_difference_update('abc')
>>> sorted(ms)
['a', 'c']
You can also use the ``^=`` ope... | python | def symmetric_difference_update(self, other):
r"""Update the multiset to contain only elements in either this multiset or the other but not both.
>>> ms = Multiset('aab')
>>> ms.symmetric_difference_update('abc')
>>> sorted(ms)
['a', 'c']
You can also use the ``^=`` ope... | [
"def",
"symmetric_difference_update",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"self",
".",
"_as_multiset",
"(",
"other",
")",
"elements",
"=",
"set",
"(",
"self",
".",
"distinct_elements",
"(",
")",
")",
"|",
"set",
"(",
"other",
".",
"distinc... | r"""Update the multiset to contain only elements in either this multiset or the other but not both.
>>> ms = Multiset('aab')
>>> ms.symmetric_difference_update('abc')
>>> sorted(ms)
['a', 'c']
You can also use the ``^=`` operator for the same effect. However, the operator versi... | [
"r",
"Update",
"the",
"multiset",
"to",
"contain",
"only",
"elements",
"in",
"either",
"this",
"multiset",
"or",
"the",
"other",
"but",
"not",
"both",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L832-L860 | train | Update the multiset to contain only elements in either this multiset or the other but not both. |
wheerd/multiset | multiset.py | Multiset.times_update | def times_update(self, factor):
"""Update each this multiset by multiplying each element's multiplicity with the given scalar factor.
>>> ms = Multiset('aab')
>>> ms.times_update(2)
>>> sorted(ms)
['a', 'a', 'a', 'a', 'b', 'b']
You can also use the ``*=`` operator for t... | python | def times_update(self, factor):
"""Update each this multiset by multiplying each element's multiplicity with the given scalar factor.
>>> ms = Multiset('aab')
>>> ms.times_update(2)
>>> sorted(ms)
['a', 'a', 'a', 'a', 'b', 'b']
You can also use the ``*=`` operator for t... | [
"def",
"times_update",
"(",
"self",
",",
"factor",
")",
":",
"if",
"factor",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"The factor must not be negative.\"",
")",
"elif",
"factor",
"==",
"0",
":",
"self",
".",
"clear",
"(",
")",
"else",
":",
"_elements",... | Update each this multiset by multiplying each element's multiplicity with the given scalar factor.
>>> ms = Multiset('aab')
>>> ms.times_update(2)
>>> sorted(ms)
['a', 'a', 'a', 'a', 'b', 'b']
You can also use the ``*=`` operator for the same effect:
>>> ms = Multiset(... | [
"Update",
"each",
"this",
"multiset",
"by",
"multiplying",
"each",
"element",
"s",
"multiplicity",
"with",
"the",
"given",
"scalar",
"factor",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L870-L899 | train | Update each element in the multiset by multiplying each element s multiplicity with the given scalar factor. |
wheerd/multiset | multiset.py | Multiset.add | def add(self, element, multiplicity=1):
"""Adds an element to the multiset.
>>> ms = Multiset()
>>> ms.add('a')
>>> sorted(ms)
['a']
An optional multiplicity can be specified to define how many of the element are added:
>>> ms.add('b', 2)
>>> sorted(ms)... | python | def add(self, element, multiplicity=1):
"""Adds an element to the multiset.
>>> ms = Multiset()
>>> ms.add('a')
>>> sorted(ms)
['a']
An optional multiplicity can be specified to define how many of the element are added:
>>> ms.add('b', 2)
>>> sorted(ms)... | [
"def",
"add",
"(",
"self",
",",
"element",
",",
"multiplicity",
"=",
"1",
")",
":",
"if",
"multiplicity",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"Multiplicity must be positive\"",
")",
"self",
".",
"_elements",
"[",
"element",
"]",
"+=",
"multiplicity"... | Adds an element to the multiset.
>>> ms = Multiset()
>>> ms.add('a')
>>> sorted(ms)
['a']
An optional multiplicity can be specified to define how many of the element are added:
>>> ms.add('b', 2)
>>> sorted(ms)
['a', 'b', 'b']
This extends the ... | [
"Adds",
"an",
"element",
"to",
"the",
"multiset",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L907-L932 | train | Adds an element to the multiset. |
wheerd/multiset | multiset.py | Multiset.remove | def remove(self, element, multiplicity=None):
"""Removes an element from the multiset.
If no multiplicity is specified, the element is completely removed from the multiset:
>>> ms = Multiset('aabbbc')
>>> ms.remove('a')
2
>>> sorted(ms)
['b', 'b', 'b', 'c']
... | python | def remove(self, element, multiplicity=None):
"""Removes an element from the multiset.
If no multiplicity is specified, the element is completely removed from the multiset:
>>> ms = Multiset('aabbbc')
>>> ms.remove('a')
2
>>> sorted(ms)
['b', 'b', 'b', 'c']
... | [
"def",
"remove",
"(",
"self",
",",
"element",
",",
"multiplicity",
"=",
"None",
")",
":",
"_elements",
"=",
"self",
".",
"_elements",
"if",
"element",
"not",
"in",
"_elements",
":",
"raise",
"KeyError",
"old_multiplicity",
"=",
"_elements",
".",
"get",
"("... | Removes an element from the multiset.
If no multiplicity is specified, the element is completely removed from the multiset:
>>> ms = Multiset('aabbbc')
>>> ms.remove('a')
2
>>> sorted(ms)
['b', 'b', 'b', 'c']
If the multiplicity is given, it is subtracted from ... | [
"Removes",
"an",
"element",
"from",
"the",
"multiset",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L934-L987 | train | Removes an element from the multiset. |
wheerd/multiset | multiset.py | Multiset.discard | def discard(self, element, multiplicity=None):
"""Removes the `element` from the multiset.
If multiplicity is ``None``, all occurrences of the element are removed:
>>> ms = Multiset('aab')
>>> ms.discard('a')
2
>>> sorted(ms)
['b']
Otherwise, the multip... | python | def discard(self, element, multiplicity=None):
"""Removes the `element` from the multiset.
If multiplicity is ``None``, all occurrences of the element are removed:
>>> ms = Multiset('aab')
>>> ms.discard('a')
2
>>> sorted(ms)
['b']
Otherwise, the multip... | [
"def",
"discard",
"(",
"self",
",",
"element",
",",
"multiplicity",
"=",
"None",
")",
":",
"_elements",
"=",
"self",
".",
"_elements",
"if",
"element",
"in",
"_elements",
":",
"old_multiplicity",
"=",
"_elements",
"[",
"element",
"]",
"if",
"multiplicity",
... | Removes the `element` from the multiset.
If multiplicity is ``None``, all occurrences of the element are removed:
>>> ms = Multiset('aab')
>>> ms.discard('a')
2
>>> sorted(ms)
['b']
Otherwise, the multiplicity is subtracted from the one in the multiset and the
... | [
"Removes",
"the",
"element",
"from",
"the",
"multiset",
"."
] | 1f002397096edae3da32d004e3159345a476999c | https://github.com/wheerd/multiset/blob/1f002397096edae3da32d004e3159345a476999c/multiset.py#L989-L1048 | train | Removes the element from the multiset. |
vinci1it2000/schedula | schedula/utils/asy.py | shutdown_executors | def shutdown_executors(wait=True):
"""
Clean-up the resources of all initialized executors.
:param wait:
If True then shutdown will not return until all running futures have
finished executing and the resources used by the executors have been
reclaimed.
:type wait: bool
:re... | python | def shutdown_executors(wait=True):
"""
Clean-up the resources of all initialized executors.
:param wait:
If True then shutdown will not return until all running futures have
finished executing and the resources used by the executors have been
reclaimed.
:type wait: bool
:re... | [
"def",
"shutdown_executors",
"(",
"wait",
"=",
"True",
")",
":",
"return",
"{",
"k",
":",
"shutdown_executor",
"(",
"k",
",",
"wait",
")",
"for",
"k",
"in",
"list",
"(",
"_EXECUTORS",
".",
"keys",
"(",
")",
")",
"}"
] | Clean-up the resources of all initialized executors.
:param wait:
If True then shutdown will not return until all running futures have
finished executing and the resources used by the executors have been
reclaimed.
:type wait: bool
:return:
Shutdown pool executor.
:rtyp... | [
"Clean",
"-",
"up",
"the",
"resources",
"of",
"all",
"initialized",
"executors",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/asy.py#L88-L102 | train | Clean - up all resources of all initialized executors. |
vinci1it2000/schedula | schedula/utils/asy.py | async_process | def async_process(funcs, *args, executor=False, sol=None, callback=None, **kw):
"""
Execute `func(*args)` in an asynchronous parallel process.
:param funcs:
Functions to be executed.
:type funcs: list[callable]
:param args:
Arguments to be passed to first function call.
:type a... | python | def async_process(funcs, *args, executor=False, sol=None, callback=None, **kw):
"""
Execute `func(*args)` in an asynchronous parallel process.
:param funcs:
Functions to be executed.
:type funcs: list[callable]
:param args:
Arguments to be passed to first function call.
:type a... | [
"def",
"async_process",
"(",
"funcs",
",",
"*",
"args",
",",
"executor",
"=",
"False",
",",
"sol",
"=",
"None",
",",
"callback",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"name",
"=",
"_executor_name",
"(",
"executor",
",",
"sol",
".",
"dsp",
")"... | Execute `func(*args)` in an asynchronous parallel process.
:param funcs:
Functions to be executed.
:type funcs: list[callable]
:param args:
Arguments to be passed to first function call.
:type args: tuple
:param executor:
Pool executor to run the function.
:type execut... | [
"Execute",
"func",
"(",
"*",
"args",
")",
"in",
"an",
"asynchronous",
"parallel",
"process",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/asy.py#L132-L175 | train | Execute functions in an asynchronous parallel process. |
vinci1it2000/schedula | schedula/utils/asy.py | async_thread | def async_thread(sol, args, node_attr, node_id, *a, **kw):
"""
Execute `sol._evaluate_node` in an asynchronous thread.
:param sol:
Solution to be updated.
:type sol: schedula.utils.sol.Solution
:param args:
Arguments to be passed to node calls.
:type args: tuple
:param nod... | python | def async_thread(sol, args, node_attr, node_id, *a, **kw):
"""
Execute `sol._evaluate_node` in an asynchronous thread.
:param sol:
Solution to be updated.
:type sol: schedula.utils.sol.Solution
:param args:
Arguments to be passed to node calls.
:type args: tuple
:param nod... | [
"def",
"async_thread",
"(",
"sol",
",",
"args",
",",
"node_attr",
",",
"node_id",
",",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"executor",
"=",
"_get_executor",
"(",
"_executor_name",
"(",
"kw",
".",
"get",
"(",
"'executor'",
",",
"False",
")",
",",... | Execute `sol._evaluate_node` in an asynchronous thread.
:param sol:
Solution to be updated.
:type sol: schedula.utils.sol.Solution
:param args:
Arguments to be passed to node calls.
:type args: tuple
:param node_attr:
Dictionary of node attributes.
:type node_attr: dic... | [
"Execute",
"sol",
".",
"_evaluate_node",
"in",
"an",
"asynchronous",
"thread",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/asy.py#L206-L277 | train | Execute sol. _evaluate_node in an asynchronous thread. |
vinci1it2000/schedula | schedula/utils/asy.py | await_result | def await_result(obj, timeout=None):
"""
Return the result of a `Future` object.
:param obj:
Value object.
:type obj: concurrent.futures.Future | object
:param timeout:
The number of seconds to wait for the result if the future isn't done.
If None, then there is no limit on... | python | def await_result(obj, timeout=None):
"""
Return the result of a `Future` object.
:param obj:
Value object.
:type obj: concurrent.futures.Future | object
:param timeout:
The number of seconds to wait for the result if the future isn't done.
If None, then there is no limit on... | [
"def",
"await_result",
"(",
"obj",
",",
"timeout",
"=",
"None",
")",
":",
"from",
"concurrent",
".",
"futures",
"import",
"Future",
"return",
"obj",
".",
"result",
"(",
"timeout",
")",
"if",
"isinstance",
"(",
"obj",
",",
"Future",
")",
"else",
"obj"
] | Return the result of a `Future` object.
:param obj:
Value object.
:type obj: concurrent.futures.Future | object
:param timeout:
The number of seconds to wait for the result if the future isn't done.
If None, then there is no limit on the wait time.
:type timeout: int
:retu... | [
"Return",
"the",
"result",
"of",
"a",
"Future",
"object",
"."
] | addb9fd685be81544b796c51383ac00a31543ce9 | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/asy.py#L440-L466 | train | A blocking function that returns the result of a Future object. |
dsoprea/PySecure | pysecure/_version.py | git_versions_from_vcs | def git_versions_from_vcs(tag_prefix, root, verbose=False):
"""Return a dictionary of values derived directly from the VCS. This is the
third attempt to find information by get_versions().
"""
# this runs 'git' from the root of the source tree. This only gets called
# if the git-archive 'subst' key... | python | def git_versions_from_vcs(tag_prefix, root, verbose=False):
"""Return a dictionary of values derived directly from the VCS. This is the
third attempt to find information by get_versions().
"""
# this runs 'git' from the root of the source tree. This only gets called
# if the git-archive 'subst' key... | [
"def",
"git_versions_from_vcs",
"(",
"tag_prefix",
",",
"root",
",",
"verbose",
"=",
"False",
")",
":",
"# this runs 'git' from the root of the source tree. This only gets called",
"# if the git-archive 'subst' keywords were *not* expanded, and",
"# _version.py hasn't already been rewrit... | Return a dictionary of values derived directly from the VCS. This is the
third attempt to find information by get_versions(). | [
"Return",
"a",
"dictionary",
"of",
"values",
"derived",
"directly",
"from",
"the",
"VCS",
".",
"This",
"is",
"the",
"third",
"attempt",
"to",
"find",
"information",
"by",
"get_versions",
"()",
"."
] | ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0 | https://github.com/dsoprea/PySecure/blob/ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0/pysecure/_version.py#L173-L263 | train | Return a dictionary of values derived directly from the VCS. This is the first attempt to find the versions of the VCS. |
dsoprea/PySecure | pysecure/_version.py | get_versions | def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
"""This variation of get_versions() will be used in _version.py ."""
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
# __file__, we can work backwards from there to the root. Some
# py2exe/bbfreeze/no... | python | def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
"""This variation of get_versions() will be used in _version.py ."""
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
# __file__, we can work backwards from there to the root. Some
# py2exe/bbfreeze/no... | [
"def",
"get_versions",
"(",
"default",
"=",
"{",
"\"version\"",
":",
"\"unknown\"",
",",
"\"full\"",
":",
"\"\"",
"}",
",",
"verbose",
"=",
"False",
")",
":",
"# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have",
"# __file__, we can work backwards fro... | This variation of get_versions() will be used in _version.py . | [
"This",
"variation",
"of",
"get_versions",
"()",
"will",
"be",
"used",
"in",
"_version",
".",
"py",
"."
] | ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0 | https://github.com/dsoprea/PySecure/blob/ff7e01a0a77e79564cb00b6e38b4e6f9f88674f0/pysecure/_version.py#L267-L295 | train | This function returns a list of version strings for the current version of the current versionfile. |
CI-WATER/gsshapy | gsshapy/lib/pivot.py | pivot | def pivot(table, left, top, value):
"""
Creates a cross-tab or pivot table from a normalised input table. Use this
function to 'denormalize' a table of normalized records.
* The table argument can be a list of dictionaries or a Table object.
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/... | python | def pivot(table, left, top, value):
"""
Creates a cross-tab or pivot table from a normalised input table. Use this
function to 'denormalize' a table of normalized records.
* The table argument can be a list of dictionaries or a Table object.
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/... | [
"def",
"pivot",
"(",
"table",
",",
"left",
",",
"top",
",",
"value",
")",
":",
"rs",
"=",
"{",
"}",
"ysort",
"=",
"[",
"]",
"xsort",
"=",
"[",
"]",
"for",
"row",
"in",
"table",
":",
"yaxis",
"=",
"tuple",
"(",
"[",
"row",
"[",
"c",
"]",
"fo... | Creates a cross-tab or pivot table from a normalised input table. Use this
function to 'denormalize' a table of normalized records.
* The table argument can be a list of dictionaries or a Table object.
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/334621)
* The left argument is a tuple of he... | [
"Creates",
"a",
"cross",
"-",
"tab",
"or",
"pivot",
"table",
"from",
"a",
"normalised",
"input",
"table",
".",
"Use",
"this",
"function",
"to",
"denormalize",
"a",
"table",
"of",
"normalized",
"records",
"."
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/lib/pivot.py#L14-L94 | train | Pivot a table from a normalised input table. |
CI-WATER/gsshapy | gsshapy/grid/hrrr_to_gssha.py | download_hrrr_for_gssha | def download_hrrr_for_gssha(main_directory,
forecast_start_date_string, #EX. '20160913'
forecast_start_hour_string, #EX. '00' to '23'
leftlon=-180, rightlon=180,
toplat=90,bottomlat=-90):
"""
Function... | python | def download_hrrr_for_gssha(main_directory,
forecast_start_date_string, #EX. '20160913'
forecast_start_hour_string, #EX. '00' to '23'
leftlon=-180, rightlon=180,
toplat=90,bottomlat=-90):
"""
Function... | [
"def",
"download_hrrr_for_gssha",
"(",
"main_directory",
",",
"forecast_start_date_string",
",",
"#EX. '20160913'",
"forecast_start_hour_string",
",",
"#EX. '00' to '23'",
"leftlon",
"=",
"-",
"180",
",",
"rightlon",
"=",
"180",
",",
"toplat",
"=",
"90",
",",
"bottoml... | Function to download HRRR data for GSSHA
URL:
http://nomads.ncep.noaa.gov/cgi-bin/filter_hrrr_2d.pl
Args:
main_directory(str): Location of the output for the forecast data.
forecast_start_date_string(str): String for day of forecast. Ex. '20160913'
forecast_start_hour_string(st... | [
"Function",
"to",
"download",
"HRRR",
"data",
"for",
"GSSHA"
] | 00fd4af0fd65f1614d75a52fe950a04fb0867f4c | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/grid/hrrr_to_gssha.py#L24-L114 | train | Function to download HRRR data for GSSHA forecasts. |
timofurrer/ramlient | ramlient/core.py | Node._patch_resource | def _patch_resource(self, method):
"""
Patch the current RAML ResourceNode by the resource with the
correct method if it exists
If the resource with the specified method does not exist
an exception is raised.
:param str method: the method of the reso... | python | def _patch_resource(self, method):
"""
Patch the current RAML ResourceNode by the resource with the
correct method if it exists
If the resource with the specified method does not exist
an exception is raised.
:param str method: the method of the reso... | [
"def",
"_patch_resource",
"(",
"self",
",",
"method",
")",
":",
"resource",
"=",
"self",
".",
"client",
".",
"get_resource",
"(",
"\"\"",
",",
"self",
".",
"resource",
".",
"path",
",",
"method",
")",
"if",
"not",
"resource",
":",
"raise",
"UnsupportedRe... | Patch the current RAML ResourceNode by the resource with the
correct method if it exists
If the resource with the specified method does not exist
an exception is raised.
:param str method: the method of the resource
:raises UnsupportedResourceMethodError: i... | [
"Patch",
"the",
"current",
"RAML",
"ResourceNode",
"by",
"the",
"resource",
"with",
"the",
"correct",
"method",
"if",
"it",
"exists"
] | e93092252635a6b3b0aca2c390b9f820368b791c | https://github.com/timofurrer/ramlient/blob/e93092252635a6b3b0aca2c390b9f820368b791c/ramlient/core.py#L61-L77 | train | Patch the current RAML ResourceNode by the resource with the specified method if it exists. |
timofurrer/ramlient | ramlient/core.py | Client.parse_raml | def parse_raml(self):
"""
Parse RAML file
"""
if utils.is_url(self.ramlfile):
raml = utils.download_file(self.ramlfile)
else:
with codecs.open(self.ramlfile, "rb", encoding="utf-8") as raml_f:
raml = raml_f.read()
loader = raml... | python | def parse_raml(self):
"""
Parse RAML file
"""
if utils.is_url(self.ramlfile):
raml = utils.download_file(self.ramlfile)
else:
with codecs.open(self.ramlfile, "rb", encoding="utf-8") as raml_f:
raml = raml_f.read()
loader = raml... | [
"def",
"parse_raml",
"(",
"self",
")",
":",
"if",
"utils",
".",
"is_url",
"(",
"self",
".",
"ramlfile",
")",
":",
"raml",
"=",
"utils",
".",
"download_file",
"(",
"self",
".",
"ramlfile",
")",
"else",
":",
"with",
"codecs",
".",
"open",
"(",
"self",
... | Parse RAML file | [
"Parse",
"RAML",
"file"
] | e93092252635a6b3b0aca2c390b9f820368b791c | https://github.com/timofurrer/ramlient/blob/e93092252635a6b3b0aca2c390b9f820368b791c/ramlient/core.py#L112-L124 | train | Parse the RAML file and store the result in self. raml |
timofurrer/ramlient | ramlient/core.py | Client.get_resource | def get_resource(self, base_resource_path, resource_path, method=None):
"""
Gets a resource by it's path and optional by it's method
This method does not care about the supported resource methods
unless it is specified.
:param str resource_path: The path of the ... | python | def get_resource(self, base_resource_path, resource_path, method=None):
"""
Gets a resource by it's path and optional by it's method
This method does not care about the supported resource methods
unless it is specified.
:param str resource_path: The path of the ... | [
"def",
"get_resource",
"(",
"self",
",",
"base_resource_path",
",",
"resource_path",
",",
"method",
"=",
"None",
")",
":",
"basic_path",
"=",
"base_resource_path",
"+",
"resource_path",
"dynamic_path",
"=",
"base_resource_path",
"+",
"\"{\"",
"+",
"resource_path",
... | Gets a resource by it's path and optional by it's method
This method does not care about the supported resource methods
unless it is specified.
:param str resource_path: The path of the resource
:param str method: The method of the path.
:returns: the resou... | [
"Gets",
"a",
"resource",
"by",
"it",
"s",
"path",
"and",
"optional",
"by",
"it",
"s",
"method"
] | e93092252635a6b3b0aca2c390b9f820368b791c | https://github.com/timofurrer/ramlient/blob/e93092252635a6b3b0aca2c390b9f820368b791c/ramlient/core.py#L140-L163 | train | Gets a resource by it s path and optional by it s method |
Robpol86/etaprogress | etaprogress/components/units.py | UnitBit.auto | def auto(self):
"""Returns the highest whole-number unit."""
if self._value >= 1000000000000:
return self.tb, 'tb'
if self._value >= 1000000000:
return self.gb, 'gb'
if self._value >= 1000000:
return self.mb, 'mb'
if self._value >= 1000:
... | python | def auto(self):
"""Returns the highest whole-number unit."""
if self._value >= 1000000000000:
return self.tb, 'tb'
if self._value >= 1000000000:
return self.gb, 'gb'
if self._value >= 1000000:
return self.mb, 'mb'
if self._value >= 1000:
... | [
"def",
"auto",
"(",
"self",
")",
":",
"if",
"self",
".",
"_value",
">=",
"1000000000000",
":",
"return",
"self",
".",
"tb",
",",
"'tb'",
"if",
"self",
".",
"_value",
">=",
"1000000000",
":",
"return",
"self",
".",
"gb",
",",
"'gb'",
"if",
"self",
"... | Returns the highest whole-number unit. | [
"Returns",
"the",
"highest",
"whole",
"-",
"number",
"unit",
"."
] | 224e8a248c2bf820bad218763281914ad3983fff | https://github.com/Robpol86/etaprogress/blob/224e8a248c2bf820bad218763281914ad3983fff/etaprogress/components/units.py#L36-L47 | train | Returns the highest whole - number unit. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.