repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
NoviceLive/intellicoder | intellicoder/converters.py | Converter.from_section | def from_section(cls, stream, section_name='.pic'):
"""Construct a Converter object from the specified section
of the specified binary stream."""
binary = Executable(stream)
section_data = binary.get_section_data(section_name)
return cls(section_data, binary.system) | python | def from_section(cls, stream, section_name='.pic'):
"""Construct a Converter object from the specified section
of the specified binary stream."""
binary = Executable(stream)
section_data = binary.get_section_data(section_name)
return cls(section_data, binary.system) | [
"def",
"from_section",
"(",
"cls",
",",
"stream",
",",
"section_name",
"=",
"'.pic'",
")",
":",
"binary",
"=",
"Executable",
"(",
"stream",
")",
"section_data",
"=",
"binary",
".",
"get_section_data",
"(",
"section_name",
")",
"return",
"cls",
"(",
"section_... | Construct a Converter object from the specified section
of the specified binary stream. | [
"Construct",
"a",
"Converter",
"object",
"from",
"the",
"specified",
"section",
"of",
"the",
"specified",
"binary",
"stream",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/converters.py#L64-L69 | train |
NoviceLive/intellicoder | intellicoder/converters.py | Converter.to_esc | def to_esc(self):
"""Convert to escape string."""
chunks = chunked(self.stream, 2)
return ''.join(r'\x' + ''.join(pair) for pair in chunks) | python | def to_esc(self):
"""Convert to escape string."""
chunks = chunked(self.stream, 2)
return ''.join(r'\x' + ''.join(pair) for pair in chunks) | [
"def",
"to_esc",
"(",
"self",
")",
":",
"chunks",
"=",
"chunked",
"(",
"self",
".",
"stream",
",",
"2",
")",
"return",
"''",
".",
"join",
"(",
"r'\\x'",
"+",
"''",
".",
"join",
"(",
"pair",
")",
"for",
"pair",
"in",
"chunks",
")"
] | Convert to escape string. | [
"Convert",
"to",
"escape",
"string",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/converters.py#L90-L93 | train |
sirfoga/pyhal | hal/maths/utils.py | get_percentage_relative_to | def get_percentage_relative_to(val, other):
"""Finds percentage between 2 numbers
:param val: number
:param other: number to compare to
:return: percentage of delta between first and second
"""
val = float(val)
other = float(other)
ratio = val / other - 1
return ratio * 100.0 | python | def get_percentage_relative_to(val, other):
"""Finds percentage between 2 numbers
:param val: number
:param other: number to compare to
:return: percentage of delta between first and second
"""
val = float(val)
other = float(other)
ratio = val / other - 1
return ratio * 100.0 | [
"def",
"get_percentage_relative_to",
"(",
"val",
",",
"other",
")",
":",
"val",
"=",
"float",
"(",
"val",
")",
"other",
"=",
"float",
"(",
"other",
")",
"ratio",
"=",
"val",
"/",
"other",
"-",
"1",
"return",
"ratio",
"*",
"100.0"
] | Finds percentage between 2 numbers
:param val: number
:param other: number to compare to
:return: percentage of delta between first and second | [
"Finds",
"percentage",
"between",
"2",
"numbers"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/maths/utils.py#L6-L17 | train |
JukeboxPipeline/jukeboxmaya | src/jukeboxmaya/addons/scenerelease/scenerelease.py | OptionWidget.setup_ui | def setup_ui(self, ):
"""Create all ui elements and layouts
:returns: None
:rtype: None
:raises: None
"""
self.main_vbox = QtGui.QVBoxLayout(self)
self.import_all_references_cb = QtGui.QCheckBox("Import references")
self.main_vbox.addWidget(self.import_al... | python | def setup_ui(self, ):
"""Create all ui elements and layouts
:returns: None
:rtype: None
:raises: None
"""
self.main_vbox = QtGui.QVBoxLayout(self)
self.import_all_references_cb = QtGui.QCheckBox("Import references")
self.main_vbox.addWidget(self.import_al... | [
"def",
"setup_ui",
"(",
"self",
",",
")",
":",
"self",
".",
"main_vbox",
"=",
"QtGui",
".",
"QVBoxLayout",
"(",
"self",
")",
"self",
".",
"import_all_references_cb",
"=",
"QtGui",
".",
"QCheckBox",
"(",
"\"Import references\"",
")",
"self",
".",
"main_vbox",... | Create all ui elements and layouts
:returns: None
:rtype: None
:raises: None | [
"Create",
"all",
"ui",
"elements",
"and",
"layouts"
] | c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c | https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/addons/scenerelease/scenerelease.py#L33-L42 | train |
JukeboxPipeline/jukeboxmaya | src/jukeboxmaya/addons/scenerelease/scenerelease.py | SceneReleaseActions.get_cleanups | def get_cleanups(self, ):
"""Get the cleanup actions for a releaes depending on the selected options
:returns: the cleanup actions
:rtype: :class:`jukeboxcore.action.ActionCollection`
:raises: None
"""
cleanups = []
open_unit = ActionUnit(name="Open",
... | python | def get_cleanups(self, ):
"""Get the cleanup actions for a releaes depending on the selected options
:returns: the cleanup actions
:rtype: :class:`jukeboxcore.action.ActionCollection`
:raises: None
"""
cleanups = []
open_unit = ActionUnit(name="Open",
... | [
"def",
"get_cleanups",
"(",
"self",
",",
")",
":",
"cleanups",
"=",
"[",
"]",
"open_unit",
"=",
"ActionUnit",
"(",
"name",
"=",
"\"Open\"",
",",
"description",
"=",
"\"Open the maya scene.\"",
",",
"actionfunc",
"=",
"open_scene",
")",
"cleanups",
".",
"appe... | Get the cleanup actions for a releaes depending on the selected options
:returns: the cleanup actions
:rtype: :class:`jukeboxcore.action.ActionCollection`
:raises: None | [
"Get",
"the",
"cleanup",
"actions",
"for",
"a",
"releaes",
"depending",
"on",
"the",
"selected",
"options"
] | c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c | https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/addons/scenerelease/scenerelease.py#L77-L105 | train |
lowandrew/OLCTools | spadespipeline/legacy_vtyper.py | Vtyper.epcr_primer_file | def epcr_primer_file(self, formattedprimers):
"""
Create the ePCR-compatible primer file from the dictionaries of primer combinations
"""
logging.info('Creating re-PCR-compatible primer file')
with open(formattedprimers, 'w') as formatted:
# Iterate through all the ta... | python | def epcr_primer_file(self, formattedprimers):
"""
Create the ePCR-compatible primer file from the dictionaries of primer combinations
"""
logging.info('Creating re-PCR-compatible primer file')
with open(formattedprimers, 'w') as formatted:
# Iterate through all the ta... | [
"def",
"epcr_primer_file",
"(",
"self",
",",
"formattedprimers",
")",
":",
"logging",
".",
"info",
"(",
"'Creating re-PCR-compatible primer file'",
")",
"with",
"open",
"(",
"formattedprimers",
",",
"'w'",
")",
"as",
"formatted",
":",
"for",
"basename",
"in",
"s... | Create the ePCR-compatible primer file from the dictionaries of primer combinations | [
"Create",
"the",
"ePCR",
"-",
"compatible",
"primer",
"file",
"from",
"the",
"dictionaries",
"of",
"primer",
"combinations"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/legacy_vtyper.py#L63-L85 | train |
lowandrew/OLCTools | spadespipeline/legacy_vtyper.py | Vtyper.epcr_threads | def epcr_threads(self, formattedprimers, ampliconsize=10000):
"""
Run ePCR in a multi-threaded fashion
"""
# Create the threads for the ePCR analysis
for sample in self.metadata:
if sample.general.bestassemblyfile != 'NA':
threads = Thread(target=self.... | python | def epcr_threads(self, formattedprimers, ampliconsize=10000):
"""
Run ePCR in a multi-threaded fashion
"""
# Create the threads for the ePCR analysis
for sample in self.metadata:
if sample.general.bestassemblyfile != 'NA':
threads = Thread(target=self.... | [
"def",
"epcr_threads",
"(",
"self",
",",
"formattedprimers",
",",
"ampliconsize",
"=",
"10000",
")",
":",
"for",
"sample",
"in",
"self",
".",
"metadata",
":",
"if",
"sample",
".",
"general",
".",
"bestassemblyfile",
"!=",
"'NA'",
":",
"threads",
"=",
"Thre... | Run ePCR in a multi-threaded fashion | [
"Run",
"ePCR",
"in",
"a",
"multi",
"-",
"threaded",
"fashion"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/legacy_vtyper.py#L87-L136 | train |
lowandrew/OLCTools | spadespipeline/legacy_vtyper.py | Vtyper.epcr_parse | def epcr_parse(self):
"""
Parse the ePCR outputs
"""
logging.info('Parsing ePCR outputs')
for sample in self.metadata:
if sample.general.bestassemblyfile != 'NA':
# Create a set to store all the unique results
toxin_set = set()
... | python | def epcr_parse(self):
"""
Parse the ePCR outputs
"""
logging.info('Parsing ePCR outputs')
for sample in self.metadata:
if sample.general.bestassemblyfile != 'NA':
# Create a set to store all the unique results
toxin_set = set()
... | [
"def",
"epcr_parse",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Parsing ePCR outputs'",
")",
"for",
"sample",
"in",
"self",
".",
"metadata",
":",
"if",
"sample",
".",
"general",
".",
"bestassemblyfile",
"!=",
"'NA'",
":",
"toxin_set",
"=",
"set"... | Parse the ePCR outputs | [
"Parse",
"the",
"ePCR",
"outputs"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/legacy_vtyper.py#L158-L182 | train |
lowandrew/OLCTools | spadespipeline/legacy_vtyper.py | Vtyper.epcr_report | def epcr_report(self):
"""
Create a report of the ePCR-calculated toxin profiles
"""
logging.info('Creating {at} report'.format(at=self.analysistype))
with open(os.path.join(self.reportpath, '{at}.csv'.format(at=self.analysistype)), 'w') as report:
data = 'Strain,Toxi... | python | def epcr_report(self):
"""
Create a report of the ePCR-calculated toxin profiles
"""
logging.info('Creating {at} report'.format(at=self.analysistype))
with open(os.path.join(self.reportpath, '{at}.csv'.format(at=self.analysistype)), 'w') as report:
data = 'Strain,Toxi... | [
"def",
"epcr_report",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Creating {at} report'",
".",
"format",
"(",
"at",
"=",
"self",
".",
"analysistype",
")",
")",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"reportpath... | Create a report of the ePCR-calculated toxin profiles | [
"Create",
"a",
"report",
"of",
"the",
"ePCR",
"-",
"calculated",
"toxin",
"profiles"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/legacy_vtyper.py#L184-L195 | train |
lowandrew/OLCTools | spadespipeline/legacy_vtyper.py | Custom.parse_epcr | def parse_epcr(self):
"""
Parse the ePCR output file. Populate dictionary of resutls. For alleles, find the best result based on the
number of mismatches before populating dictionary
"""
# Use the metadata object from the vtyper_object
for sample in self.vtyper_object.met... | python | def parse_epcr(self):
"""
Parse the ePCR output file. Populate dictionary of resutls. For alleles, find the best result based on the
number of mismatches before populating dictionary
"""
# Use the metadata object from the vtyper_object
for sample in self.vtyper_object.met... | [
"def",
"parse_epcr",
"(",
"self",
")",
":",
"for",
"sample",
"in",
"self",
".",
"vtyper_object",
".",
"metadata",
":",
"sample",
"[",
"self",
".",
"analysistype",
"]",
".",
"result_dict",
"=",
"dict",
"(",
")",
"with",
"open",
"(",
"sample",
"[",
"self... | Parse the ePCR output file. Populate dictionary of resutls. For alleles, find the best result based on the
number of mismatches before populating dictionary | [
"Parse",
"the",
"ePCR",
"output",
"file",
".",
"Populate",
"dictionary",
"of",
"resutls",
".",
"For",
"alleles",
"find",
"the",
"best",
"result",
"based",
"on",
"the",
"number",
"of",
"mismatches",
"before",
"populating",
"dictionary"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/legacy_vtyper.py#L228-L278 | train |
lowandrew/OLCTools | spadespipeline/legacy_vtyper.py | Custom.create_epr_report | def create_epr_report(self):
"""
Parse the results dictionaries, and create a final report
"""
# Open the report as a .csv file
with open(os.path.join(self.reportpath, 'ePCR_report.csv'), 'w') as report:
# Initialise a string to store the header
results = ... | python | def create_epr_report(self):
"""
Parse the results dictionaries, and create a final report
"""
# Open the report as a .csv file
with open(os.path.join(self.reportpath, 'ePCR_report.csv'), 'w') as report:
# Initialise a string to store the header
results = ... | [
"def",
"create_epr_report",
"(",
"self",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"reportpath",
",",
"'ePCR_report.csv'",
")",
",",
"'w'",
")",
"as",
"report",
":",
"results",
"=",
"'Sample,Gene,GenomeLocation,Amplicon... | Parse the results dictionaries, and create a final report | [
"Parse",
"the",
"results",
"dictionaries",
"and",
"create",
"a",
"final",
"report"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/legacy_vtyper.py#L299-L328 | train |
lowandrew/OLCTools | sipprCommon/create_sample_sheet.py | SampleSheet.samplesheet | def samplesheet(self):
"""
Create a custom sample sheet based on the original sample sheet for the run, but only including the samples
that did not pass the quality threshold on the previous iteration
"""
if self.demultiplex:
make_path(self.samplesheetpath)
... | python | def samplesheet(self):
"""
Create a custom sample sheet based on the original sample sheet for the run, but only including the samples
that did not pass the quality threshold on the previous iteration
"""
if self.demultiplex:
make_path(self.samplesheetpath)
... | [
"def",
"samplesheet",
"(",
"self",
")",
":",
"if",
"self",
".",
"demultiplex",
":",
"make_path",
"(",
"self",
".",
"samplesheetpath",
")",
"self",
".",
"customsamplesheet",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"samplesheetpath",
",",
"'... | Create a custom sample sheet based on the original sample sheet for the run, but only including the samples
that did not pass the quality threshold on the previous iteration | [
"Create",
"a",
"custom",
"sample",
"sheet",
"based",
"on",
"the",
"original",
"sample",
"sheet",
"for",
"the",
"run",
"but",
"only",
"including",
"the",
"samples",
"that",
"did",
"not",
"pass",
"the",
"quality",
"threshold",
"on",
"the",
"previous",
"iterati... | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/sipprCommon/create_sample_sheet.py#L10-L59 | train |
LeKono/pyhgnc | src/pyhgnc/manager/database.py | update | def update(connection=None, silent=False, hgnc_file_path=None, hcop_file_path=None, low_memory=False):
"""Update the database with current version of HGNC
:param str connection: conncetion string
:param bool silent: silent while import
:param str hgnc_file_path: import from path HGNC
:param str hco... | python | def update(connection=None, silent=False, hgnc_file_path=None, hcop_file_path=None, low_memory=False):
"""Update the database with current version of HGNC
:param str connection: conncetion string
:param bool silent: silent while import
:param str hgnc_file_path: import from path HGNC
:param str hco... | [
"def",
"update",
"(",
"connection",
"=",
"None",
",",
"silent",
"=",
"False",
",",
"hgnc_file_path",
"=",
"None",
",",
"hcop_file_path",
"=",
"None",
",",
"low_memory",
"=",
"False",
")",
":",
"database",
"=",
"DbManager",
"(",
"connection",
")",
"database... | Update the database with current version of HGNC
:param str connection: conncetion string
:param bool silent: silent while import
:param str hgnc_file_path: import from path HGNC
:param str hcop_file_path: import from path HCOP (orthologs)
:param bool low_memory: set to `True` if you have low memor... | [
"Update",
"the",
"database",
"with",
"current",
"version",
"of",
"HGNC"
] | 1cae20c40874bfb51581b7c5c1481707e942b5d0 | https://github.com/LeKono/pyhgnc/blob/1cae20c40874bfb51581b7c5c1481707e942b5d0/src/pyhgnc/manager/database.py#L408-L420 | train |
LeKono/pyhgnc | src/pyhgnc/manager/database.py | set_connection | def set_connection(connection=defaults.sqlalchemy_connection_string_default):
"""Set the connection string for sqlalchemy and write it to the config file.
.. code-block:: python
import pyhgnc
pyhgnc.set_connection('mysql+pymysql://{user}:{passwd}@{host}/{db}?charset={charset}')
.. hint::... | python | def set_connection(connection=defaults.sqlalchemy_connection_string_default):
"""Set the connection string for sqlalchemy and write it to the config file.
.. code-block:: python
import pyhgnc
pyhgnc.set_connection('mysql+pymysql://{user}:{passwd}@{host}/{db}?charset={charset}')
.. hint::... | [
"def",
"set_connection",
"(",
"connection",
"=",
"defaults",
".",
"sqlalchemy_connection_string_default",
")",
":",
"config_path",
"=",
"defaults",
".",
"config_file_path",
"config",
"=",
"RawConfigParser",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
... | Set the connection string for sqlalchemy and write it to the config file.
.. code-block:: python
import pyhgnc
pyhgnc.set_connection('mysql+pymysql://{user}:{passwd}@{host}/{db}?charset={charset}')
.. hint::
valid connection strings
- mysql+pymysql://user:passwd@localhost/d... | [
"Set",
"the",
"connection",
"string",
"for",
"sqlalchemy",
"and",
"write",
"it",
"to",
"the",
"config",
"file",
"."
] | 1cae20c40874bfb51581b7c5c1481707e942b5d0 | https://github.com/LeKono/pyhgnc/blob/1cae20c40874bfb51581b7c5c1481707e942b5d0/src/pyhgnc/manager/database.py#L423-L464 | train |
LeKono/pyhgnc | src/pyhgnc/manager/database.py | set_mysql_connection | def set_mysql_connection(host='localhost', user='pyhgnc_user', passwd='pyhgnc_passwd', db='pyhgnc',
charset='utf8'):
"""Method to set a MySQL connection
:param str host: MySQL database host
:param str user: MySQL database user
:param str passwd: MySQL database password
:par... | python | def set_mysql_connection(host='localhost', user='pyhgnc_user', passwd='pyhgnc_passwd', db='pyhgnc',
charset='utf8'):
"""Method to set a MySQL connection
:param str host: MySQL database host
:param str user: MySQL database user
:param str passwd: MySQL database password
:par... | [
"def",
"set_mysql_connection",
"(",
"host",
"=",
"'localhost'",
",",
"user",
"=",
"'pyhgnc_user'",
",",
"passwd",
"=",
"'pyhgnc_passwd'",
",",
"db",
"=",
"'pyhgnc'",
",",
"charset",
"=",
"'utf8'",
")",
":",
"connection_string",
"=",
"'mysql+pymysql://{user}:{passw... | Method to set a MySQL connection
:param str host: MySQL database host
:param str user: MySQL database user
:param str passwd: MySQL database password
:param str db: MySQL database name
:param str charset: MySQL database charater set
:return: connection string
:rtype: str | [
"Method",
"to",
"set",
"a",
"MySQL",
"connection"
] | 1cae20c40874bfb51581b7c5c1481707e942b5d0 | https://github.com/LeKono/pyhgnc/blob/1cae20c40874bfb51581b7c5c1481707e942b5d0/src/pyhgnc/manager/database.py#L467-L489 | train |
kevinconway/venvctrl | venvctrl/venv/relocate.py | RelocateMixin.relocate | def relocate(self, destination):
"""Configure the virtual environment for another path.
Args:
destination (str): The target path of the virtual environment.
Note:
This does not actually move the virtual environment. Is only
rewrites the metadata required to ... | python | def relocate(self, destination):
"""Configure the virtual environment for another path.
Args:
destination (str): The target path of the virtual environment.
Note:
This does not actually move the virtual environment. Is only
rewrites the metadata required to ... | [
"def",
"relocate",
"(",
"self",
",",
"destination",
")",
":",
"for",
"activate",
"in",
"self",
".",
"bin",
".",
"activates",
":",
"activate",
".",
"vpath",
"=",
"destination",
"for",
"binfile",
"in",
"self",
".",
"bin",
".",
"files",
":",
"if",
"binfil... | Configure the virtual environment for another path.
Args:
destination (str): The target path of the virtual environment.
Note:
This does not actually move the virtual environment. Is only
rewrites the metadata required to support a move. | [
"Configure",
"the",
"virtual",
"environment",
"for",
"another",
"path",
"."
] | 36d4e0e4d5ebced6385a6ade1198f4769ff2df41 | https://github.com/kevinconway/venvctrl/blob/36d4e0e4d5ebced6385a6ade1198f4769ff2df41/venvctrl/venv/relocate.py#L16-L38 | train |
kevinconway/venvctrl | venvctrl/venv/relocate.py | RelocateMixin.move | def move(self, destination):
"""Reconfigure and move the virtual environment to another path.
Args:
destination (str): The target path of the virtual environment.
Note:
Unlike `relocate`, this method *will* move the virtual to the
given path.
"""
... | python | def move(self, destination):
"""Reconfigure and move the virtual environment to another path.
Args:
destination (str): The target path of the virtual environment.
Note:
Unlike `relocate`, this method *will* move the virtual to the
given path.
"""
... | [
"def",
"move",
"(",
"self",
",",
"destination",
")",
":",
"self",
".",
"relocate",
"(",
"destination",
")",
"shutil",
".",
"move",
"(",
"self",
".",
"path",
",",
"destination",
")",
"self",
".",
"_path",
"=",
"destination"
] | Reconfigure and move the virtual environment to another path.
Args:
destination (str): The target path of the virtual environment.
Note:
Unlike `relocate`, this method *will* move the virtual to the
given path. | [
"Reconfigure",
"and",
"move",
"the",
"virtual",
"environment",
"to",
"another",
"path",
"."
] | 36d4e0e4d5ebced6385a6ade1198f4769ff2df41 | https://github.com/kevinconway/venvctrl/blob/36d4e0e4d5ebced6385a6ade1198f4769ff2df41/venvctrl/venv/relocate.py#L40-L52 | train |
lowandrew/OLCTools | accessoryFunctions/reportaggregator.py | Aggregate.aggregate | def aggregate(self):
"""
Aggregate all reports of the same type into a master report
"""
for report in self.reportset:
printtime('Processing {}'.format(report.split('.')[0]), self.start)
# Initialise the header for each report - MLST is different, as the header is... | python | def aggregate(self):
"""
Aggregate all reports of the same type into a master report
"""
for report in self.reportset:
printtime('Processing {}'.format(report.split('.')[0]), self.start)
# Initialise the header for each report - MLST is different, as the header is... | [
"def",
"aggregate",
"(",
"self",
")",
":",
"for",
"report",
"in",
"self",
".",
"reportset",
":",
"printtime",
"(",
"'Processing {}'",
".",
"format",
"(",
"report",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
")",
",",
"self",
".",
"start",
")",
"... | Aggregate all reports of the same type into a master report | [
"Aggregate",
"all",
"reports",
"of",
"the",
"same",
"type",
"into",
"a",
"master",
"report"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/accessoryFunctions/reportaggregator.py#L71-L106 | train |
etal/biocma | biocma/cma.py | _parse_blocks | def _parse_blocks(instream):
"""Parse an alignment block from the given file handle.
Block looks like:
[0_(1)=fa2cma(8){go=10000,gx=2000,pn=1000.0,lf=0,rf=0}:
(209)***********************************************...
... sequences, numbered 1-8 ...
_0].
"""
ilines = sugar.unblank(instr... | python | def _parse_blocks(instream):
"""Parse an alignment block from the given file handle.
Block looks like:
[0_(1)=fa2cma(8){go=10000,gx=2000,pn=1000.0,lf=0,rf=0}:
(209)***********************************************...
... sequences, numbered 1-8 ...
_0].
"""
ilines = sugar.unblank(instr... | [
"def",
"_parse_blocks",
"(",
"instream",
")",
":",
"ilines",
"=",
"sugar",
".",
"unblank",
"(",
"instream",
")",
"for",
"line",
"in",
"ilines",
":",
"if",
"line",
".",
"startswith",
"(",
"'['",
")",
":",
"level",
",",
"one",
",",
"name",
",",
"seqcou... | Parse an alignment block from the given file handle.
Block looks like:
[0_(1)=fa2cma(8){go=10000,gx=2000,pn=1000.0,lf=0,rf=0}:
(209)***********************************************...
... sequences, numbered 1-8 ...
_0]. | [
"Parse",
"an",
"alignment",
"block",
"from",
"the",
"given",
"file",
"handle",
"."
] | eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7 | https://github.com/etal/biocma/blob/eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7/biocma/cma.py#L43-L75 | train |
etal/biocma | biocma/cma.py | _parse_sequences | def _parse_sequences(ilines, expect_qlen):
"""Parse the sequences in the current block.
Sequence looks like:
$3=227(209):
>gi|15606894|ref|NP_214275.1| {|2(244)|<Aquificae(B)>}DNA polymerase III gamma subunit [Aquifex aeolicus VF5] >gi|2984127|gb|AAC07663.1| DNA polymerase III gamma subunit [Aquifex ... | python | def _parse_sequences(ilines, expect_qlen):
"""Parse the sequences in the current block.
Sequence looks like:
$3=227(209):
>gi|15606894|ref|NP_214275.1| {|2(244)|<Aquificae(B)>}DNA polymerase III gamma subunit [Aquifex aeolicus VF5] >gi|2984127|gb|AAC07663.1| DNA polymerase III gamma subunit [Aquifex ... | [
"def",
"_parse_sequences",
"(",
"ilines",
",",
"expect_qlen",
")",
":",
"while",
"True",
":",
"first",
"=",
"next",
"(",
"ilines",
")",
"if",
"first",
".",
"startswith",
"(",
"'_'",
")",
"and",
"first",
".",
"endswith",
"(",
"'].'",
")",
":",
"break",
... | Parse the sequences in the current block.
Sequence looks like:
$3=227(209):
>gi|15606894|ref|NP_214275.1| {|2(244)|<Aquificae(B)>}DNA polymerase III gamma subunit [Aquifex aeolicus VF5] >gi|2984127|gb|AAC07663.1| DNA polymerase III gamma subunit [Aquifex aeolicus VF5] >gi|75
{()YVPFARKYRPKFFREVIGQEAP... | [
"Parse",
"the",
"sequences",
"in",
"the",
"current",
"block",
"."
] | eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7 | https://github.com/etal/biocma/blob/eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7/biocma/cma.py#L78-L141 | train |
etal/biocma | biocma/cma.py | realign_seqs | def realign_seqs(block, gap_char='.', align_indels=False):
"""Add gaps to a block so all residues in a column are equivalent.
Given a block, containing a list of "sequences" (dicts) each containing a
"seq" (actual string sequence, where upper=match, lower=insert, dash=gap),
insert gaps (- or .) into th... | python | def realign_seqs(block, gap_char='.', align_indels=False):
"""Add gaps to a block so all residues in a column are equivalent.
Given a block, containing a list of "sequences" (dicts) each containing a
"seq" (actual string sequence, where upper=match, lower=insert, dash=gap),
insert gaps (- or .) into th... | [
"def",
"realign_seqs",
"(",
"block",
",",
"gap_char",
"=",
"'.'",
",",
"align_indels",
"=",
"False",
")",
":",
"all_chars",
"=",
"[",
"list",
"(",
"sq",
"[",
"'seq'",
"]",
")",
"for",
"sq",
"in",
"block",
"[",
"'sequences'",
"]",
"]",
"nrows",
"=",
... | Add gaps to a block so all residues in a column are equivalent.
Given a block, containing a list of "sequences" (dicts) each containing a
"seq" (actual string sequence, where upper=match, lower=insert, dash=gap),
insert gaps (- or .) into the sequences s.t.
1. columns line up properly, and
2. all ... | [
"Add",
"gaps",
"to",
"a",
"block",
"so",
"all",
"residues",
"in",
"a",
"column",
"are",
"equivalent",
"."
] | eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7 | https://github.com/etal/biocma/blob/eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7/biocma/cma.py#L342-L371 | train |
etal/biocma | biocma/cma.py | collapse_to_consensus | def collapse_to_consensus(seqrecords, strict=False, do_iron=True):
"""Opposite of realign_seqs.
Input sequences should all be the same length.
The first record must be the consensus.
"""
level = 0
name = seqrecords[0].id
# If this is a CMA alignment, extract additional info:
if hasattr... | python | def collapse_to_consensus(seqrecords, strict=False, do_iron=True):
"""Opposite of realign_seqs.
Input sequences should all be the same length.
The first record must be the consensus.
"""
level = 0
name = seqrecords[0].id
# If this is a CMA alignment, extract additional info:
if hasattr... | [
"def",
"collapse_to_consensus",
"(",
"seqrecords",
",",
"strict",
"=",
"False",
",",
"do_iron",
"=",
"True",
")",
":",
"level",
"=",
"0",
"name",
"=",
"seqrecords",
"[",
"0",
"]",
".",
"id",
"if",
"hasattr",
"(",
"seqrecords",
",",
"'_records'",
")",
"... | Opposite of realign_seqs.
Input sequences should all be the same length.
The first record must be the consensus. | [
"Opposite",
"of",
"realign_seqs",
"."
] | eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7 | https://github.com/etal/biocma/blob/eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7/biocma/cma.py#L426-L495 | train |
etal/biocma | biocma/cma.py | iron | def iron(sequence):
"""'Iron out' indel regions in the aligned sequence.
Any inserts next to deletions are converted to matches (uppercase).
Given a CMA string like:
AAAAbc--de-f--gAAA
Result:
AAAABCDEFgAAA
"""
r_indel = re.compile(r'(-[a-y]|[a-y]-)')
orig_sequence = sequen... | python | def iron(sequence):
"""'Iron out' indel regions in the aligned sequence.
Any inserts next to deletions are converted to matches (uppercase).
Given a CMA string like:
AAAAbc--de-f--gAAA
Result:
AAAABCDEFgAAA
"""
r_indel = re.compile(r'(-[a-y]|[a-y]-)')
orig_sequence = sequen... | [
"def",
"iron",
"(",
"sequence",
")",
":",
"r_indel",
"=",
"re",
".",
"compile",
"(",
"r'(-[a-y]|[a-y]-)'",
")",
"orig_sequence",
"=",
"sequence",
"while",
"r_indel",
".",
"search",
"(",
"sequence",
")",
":",
"in_insert",
"=",
"False",
"in_gap",
"=",
"False... | Iron out' indel regions in the aligned sequence.
Any inserts next to deletions are converted to matches (uppercase).
Given a CMA string like:
AAAAbc--de-f--gAAA
Result:
AAAABCDEFgAAA | [
"Iron",
"out",
"indel",
"regions",
"in",
"the",
"aligned",
"sequence",
"."
] | eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7 | https://github.com/etal/biocma/blob/eac0c57eb83a9498e53ccdeb9cbc3fe21a5826a7/biocma/cma.py#L498-L601 | train |
jreinhardt/handkerchief | handkerchief/handkerchief.py | get_github_content | def get_github_content(repo,path,auth=None):
"""
Retrieve text files from a github repo
"""
request = requests.get(file_url.format(repo=repo, path=path), auth=auth)
if not request.ok:
print("There is a problem with the request")
print(file_url.format(repo=repo, path=path))
print(request.json())
exit(1)
if... | python | def get_github_content(repo,path,auth=None):
"""
Retrieve text files from a github repo
"""
request = requests.get(file_url.format(repo=repo, path=path), auth=auth)
if not request.ok:
print("There is a problem with the request")
print(file_url.format(repo=repo, path=path))
print(request.json())
exit(1)
if... | [
"def",
"get_github_content",
"(",
"repo",
",",
"path",
",",
"auth",
"=",
"None",
")",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"file_url",
".",
"format",
"(",
"repo",
"=",
"repo",
",",
"path",
"=",
"path",
")",
",",
"auth",
"=",
"auth",
")... | Retrieve text files from a github repo | [
"Retrieve",
"text",
"files",
"from",
"a",
"github",
"repo"
] | 450291314ccbbf557b41a30ce9c523587758fe76 | https://github.com/jreinhardt/handkerchief/blob/450291314ccbbf557b41a30ce9c523587758fe76/handkerchief/handkerchief.py#L68-L80 | train |
jreinhardt/handkerchief | handkerchief/handkerchief.py | collect_reponames | def collect_reponames():
"""
Try to figure out a list of repos to consider by default from the contents of the working directory.
"""
reponames = []
#try to figure out the repo from git repo in current directory
try:
with open(os.devnull) as devnull:
remote_data = subprocess.check_output(["git","remote","-v... | python | def collect_reponames():
"""
Try to figure out a list of repos to consider by default from the contents of the working directory.
"""
reponames = []
#try to figure out the repo from git repo in current directory
try:
with open(os.devnull) as devnull:
remote_data = subprocess.check_output(["git","remote","-v... | [
"def",
"collect_reponames",
"(",
")",
":",
"reponames",
"=",
"[",
"]",
"try",
":",
"with",
"open",
"(",
"os",
".",
"devnull",
")",
"as",
"devnull",
":",
"remote_data",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"git\"",
",",
"\"remote\"",
",",
... | Try to figure out a list of repos to consider by default from the contents of the working directory. | [
"Try",
"to",
"figure",
"out",
"a",
"list",
"of",
"repos",
"to",
"consider",
"by",
"default",
"from",
"the",
"contents",
"of",
"the",
"working",
"directory",
"."
] | 450291314ccbbf557b41a30ce9c523587758fe76 | https://github.com/jreinhardt/handkerchief/blob/450291314ccbbf557b41a30ce9c523587758fe76/handkerchief/handkerchief.py#L248-L286 | train |
jreinhardt/handkerchief | handkerchief/handkerchief.py | collect_github_config | def collect_github_config():
"""
Try load Github configuration such as usernames from the local or global git config
"""
github_config = {}
for field in ["user", "token"]:
try:
github_config[field] = subprocess.check_output(["git", "config", "github.{}".format(field)]).decode('utf-8').strip()
except (OSErro... | python | def collect_github_config():
"""
Try load Github configuration such as usernames from the local or global git config
"""
github_config = {}
for field in ["user", "token"]:
try:
github_config[field] = subprocess.check_output(["git", "config", "github.{}".format(field)]).decode('utf-8').strip()
except (OSErro... | [
"def",
"collect_github_config",
"(",
")",
":",
"github_config",
"=",
"{",
"}",
"for",
"field",
"in",
"[",
"\"user\"",
",",
"\"token\"",
"]",
":",
"try",
":",
"github_config",
"[",
"field",
"]",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"git\"",
... | Try load Github configuration such as usernames from the local or global git config | [
"Try",
"load",
"Github",
"configuration",
"such",
"as",
"usernames",
"from",
"the",
"local",
"or",
"global",
"git",
"config"
] | 450291314ccbbf557b41a30ce9c523587758fe76 | https://github.com/jreinhardt/handkerchief/blob/450291314ccbbf557b41a30ce9c523587758fe76/handkerchief/handkerchief.py#L289-L299 | train |
portfors-lab/sparkle | sparkle/gui/calibration_widget.py | CalibrationWidget.setCurveModel | def setCurveModel(self, model):
"""Sets the stimulus model for the calibration curve test
:param model: Stimulus model that has a tone curve configured
:type model: :class:`StimulusModel <sparkle.stim.stimulus_model.StimulusModel>`
"""
self.stimModel = model
self.ui.curv... | python | def setCurveModel(self, model):
"""Sets the stimulus model for the calibration curve test
:param model: Stimulus model that has a tone curve configured
:type model: :class:`StimulusModel <sparkle.stim.stimulus_model.StimulusModel>`
"""
self.stimModel = model
self.ui.curv... | [
"def",
"setCurveModel",
"(",
"self",
",",
"model",
")",
":",
"self",
".",
"stimModel",
"=",
"model",
"self",
".",
"ui",
".",
"curveWidget",
".",
"setModel",
"(",
"model",
")"
] | Sets the stimulus model for the calibration curve test
:param model: Stimulus model that has a tone curve configured
:type model: :class:`StimulusModel <sparkle.stim.stimulus_model.StimulusModel>` | [
"Sets",
"the",
"stimulus",
"model",
"for",
"the",
"calibration",
"curve",
"test"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/calibration_widget.py#L24-L31 | train |
portfors-lab/sparkle | sparkle/gui/calibration_widget.py | CalibrationWidget.addOption | def addOption(self, stim):
"""Adds a stimulus to the list of stims to use for testing calibration
:param stim: stimulus to add to drop-down list
:type stim: :class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>`
"""
# set the editor widgets... | python | def addOption(self, stim):
"""Adds a stimulus to the list of stims to use for testing calibration
:param stim: stimulus to add to drop-down list
:type stim: :class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>`
"""
# set the editor widgets... | [
"def",
"addOption",
"(",
"self",
",",
"stim",
")",
":",
"self",
".",
"ui",
".",
"calTypeCmbbx",
".",
"insertItem",
"(",
"0",
",",
"stim",
".",
"name",
")",
"editor",
"=",
"stim",
".",
"showEditor",
"(",
")",
"durInput",
"=",
"editor",
".",
"durationI... | Adds a stimulus to the list of stims to use for testing calibration
:param stim: stimulus to add to drop-down list
:type stim: :class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>` | [
"Adds",
"a",
"stimulus",
"to",
"the",
"list",
"of",
"stims",
"to",
"use",
"for",
"testing",
"calibration"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/calibration_widget.py#L42-L56 | train |
portfors-lab/sparkle | sparkle/gui/calibration_widget.py | CalibrationWidget.saveToObject | def saveToObject(self):
"""Saves the current UI setting to the model"""
for i in range(self.ui.caleditorStack.count()):
try:
self.ui.caleditorStack.widget(i).saveToObject()
except AttributeError:
logger = logging.getLogger('main')
l... | python | def saveToObject(self):
"""Saves the current UI setting to the model"""
for i in range(self.ui.caleditorStack.count()):
try:
self.ui.caleditorStack.widget(i).saveToObject()
except AttributeError:
logger = logging.getLogger('main')
l... | [
"def",
"saveToObject",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"ui",
".",
"caleditorStack",
".",
"count",
"(",
")",
")",
":",
"try",
":",
"self",
".",
"ui",
".",
"caleditorStack",
".",
"widget",
"(",
"i",
")",
".",
"sa... | Saves the current UI setting to the model | [
"Saves",
"the",
"current",
"UI",
"setting",
"to",
"the",
"model"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/calibration_widget.py#L58-L65 | train |
portfors-lab/sparkle | sparkle/gui/calibration_widget.py | CalibrationWidget.isToneCal | def isToneCal(self):
"""Whether the currently selected calibration stimulus type is the calibration curve
:returns: boolean -- if the current combo box selection is calibration curve
"""
return self.ui.calTypeCmbbx.currentIndex() == self.ui.calTypeCmbbx.count() -1 | python | def isToneCal(self):
"""Whether the currently selected calibration stimulus type is the calibration curve
:returns: boolean -- if the current combo box selection is calibration curve
"""
return self.ui.calTypeCmbbx.currentIndex() == self.ui.calTypeCmbbx.count() -1 | [
"def",
"isToneCal",
"(",
"self",
")",
":",
"return",
"self",
".",
"ui",
".",
"calTypeCmbbx",
".",
"currentIndex",
"(",
")",
"==",
"self",
".",
"ui",
".",
"calTypeCmbbx",
".",
"count",
"(",
")",
"-",
"1"
] | Whether the currently selected calibration stimulus type is the calibration curve
:returns: boolean -- if the current combo box selection is calibration curve | [
"Whether",
"the",
"currently",
"selected",
"calibration",
"stimulus",
"type",
"is",
"the",
"calibration",
"curve"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/calibration_widget.py#L81-L86 | train |
portfors-lab/sparkle | sparkle/acq/players.py | AbstractPlayerBase.reset_generation | def reset_generation(self, trigger):
"""Re-arms the analog output according to current settings
:param trigger: name of the trigger terminal. ``None`` value means generation begins immediately on run
:type trigger: str
"""
self.tone_lock.acquire()
npts = self.stim.size... | python | def reset_generation(self, trigger):
"""Re-arms the analog output according to current settings
:param trigger: name of the trigger terminal. ``None`` value means generation begins immediately on run
:type trigger: str
"""
self.tone_lock.acquire()
npts = self.stim.size... | [
"def",
"reset_generation",
"(",
"self",
",",
"trigger",
")",
":",
"self",
".",
"tone_lock",
".",
"acquire",
"(",
")",
"npts",
"=",
"self",
".",
"stim",
".",
"size",
"try",
":",
"self",
".",
"aotask",
"=",
"AOTaskFinite",
"(",
"self",
".",
"aochan",
"... | Re-arms the analog output according to current settings
:param trigger: name of the trigger terminal. ``None`` value means generation begins immediately on run
:type trigger: str | [
"Re",
"-",
"arms",
"the",
"analog",
"output",
"according",
"to",
"current",
"settings"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/acq/players.py#L55-L87 | train |
portfors-lab/sparkle | sparkle/acq/players.py | AbstractPlayerBase.set_stim | def set_stim(self, signal, fs, attenuation=0):
"""Sets any vector as the next stimulus to be output. Does not call write to hardware"""
self.tone_lock.acquire()
self.stim = signal
self.fs = fs
self.atten = attenuation
self.stim_changed = True
self.tone_lock.rele... | python | def set_stim(self, signal, fs, attenuation=0):
"""Sets any vector as the next stimulus to be output. Does not call write to hardware"""
self.tone_lock.acquire()
self.stim = signal
self.fs = fs
self.atten = attenuation
self.stim_changed = True
self.tone_lock.rele... | [
"def",
"set_stim",
"(",
"self",
",",
"signal",
",",
"fs",
",",
"attenuation",
"=",
"0",
")",
":",
"self",
".",
"tone_lock",
".",
"acquire",
"(",
")",
"self",
".",
"stim",
"=",
"signal",
"self",
".",
"fs",
"=",
"fs",
"self",
".",
"atten",
"=",
"at... | Sets any vector as the next stimulus to be output. Does not call write to hardware | [
"Sets",
"any",
"vector",
"as",
"the",
"next",
"stimulus",
"to",
"be",
"output",
".",
"Does",
"not",
"call",
"write",
"to",
"hardware"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/acq/players.py#L89-L98 | train |
portfors-lab/sparkle | sparkle/acq/players.py | AbstractPlayerBase.connect_attenuator | def connect_attenuator(self, connect=True):
"""Establish a connection to the TDT PA5 attenuator"""
if connect:
try:
pa5 = win32com.client.Dispatch("PA5.x")
success = pa5.ConnectPA5('GB', 1)
if success == 1:
print 'Connection... | python | def connect_attenuator(self, connect=True):
"""Establish a connection to the TDT PA5 attenuator"""
if connect:
try:
pa5 = win32com.client.Dispatch("PA5.x")
success = pa5.ConnectPA5('GB', 1)
if success == 1:
print 'Connection... | [
"def",
"connect_attenuator",
"(",
"self",
",",
"connect",
"=",
"True",
")",
":",
"if",
"connect",
":",
"try",
":",
"pa5",
"=",
"win32com",
".",
"client",
".",
"Dispatch",
"(",
"\"PA5.x\"",
")",
"success",
"=",
"pa5",
".",
"ConnectPA5",
"(",
"'GB'",
","... | Establish a connection to the TDT PA5 attenuator | [
"Establish",
"a",
"connection",
"to",
"the",
"TDT",
"PA5",
"attenuator"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/acq/players.py#L153-L177 | train |
portfors-lab/sparkle | sparkle/acq/players.py | AbstractPlayerBase.start_timer | def start_timer(self, reprate):
"""Start the digital output task that serves as the acquistion trigger"""
print 'starting digital output at rate {} Hz'.format(reprate)
self.trigger_task = DigitalOutTask(self.trigger_src, reprate)
self.trigger_task.start() | python | def start_timer(self, reprate):
"""Start the digital output task that serves as the acquistion trigger"""
print 'starting digital output at rate {} Hz'.format(reprate)
self.trigger_task = DigitalOutTask(self.trigger_src, reprate)
self.trigger_task.start() | [
"def",
"start_timer",
"(",
"self",
",",
"reprate",
")",
":",
"print",
"'starting digital output at rate {} Hz'",
".",
"format",
"(",
"reprate",
")",
"self",
".",
"trigger_task",
"=",
"DigitalOutTask",
"(",
"self",
".",
"trigger_src",
",",
"reprate",
")",
"self",... | Start the digital output task that serves as the acquistion trigger | [
"Start",
"the",
"digital",
"output",
"task",
"that",
"serves",
"as",
"the",
"acquistion",
"trigger"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/acq/players.py#L183-L187 | train |
portfors-lab/sparkle | sparkle/acq/players.py | FinitePlayer.start | def start(self):
"""Writes output buffer and settings to device
:returns: numpy.ndarray -- if the first presentation of a novel stimulus, or None if a repeat stimulus
"""
# this shouldn't actually be possible still...
if self.aitask is not None:
self.stop()
... | python | def start(self):
"""Writes output buffer and settings to device
:returns: numpy.ndarray -- if the first presentation of a novel stimulus, or None if a repeat stimulus
"""
# this shouldn't actually be possible still...
if self.aitask is not None:
self.stop()
... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"aitask",
"is",
"not",
"None",
":",
"self",
".",
"stop",
"(",
")",
"raise",
"Exception",
"(",
"\"FIX ME : NESTED START OPERATIONS ALLOWED\"",
")",
"self",
".",
"daq_lock",
".",
"acquire",
"(",
")",
... | Writes output buffer and settings to device
:returns: numpy.ndarray -- if the first presentation of a novel stimulus, or None if a repeat stimulus | [
"Writes",
"output",
"buffer",
"and",
"settings",
"to",
"device"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/acq/players.py#L200-L216 | train |
portfors-lab/sparkle | sparkle/acq/players.py | FinitePlayer.stop | def stop(self):
"""Halts the acquisition, this must be called before resetting acquisition"""
try:
self.aitask.stop()
self.aotask.stop()
pass
except:
print u"No task running"
self.aitask = None
self.aotask = None | python | def stop(self):
"""Halts the acquisition, this must be called before resetting acquisition"""
try:
self.aitask.stop()
self.aotask.stop()
pass
except:
print u"No task running"
self.aitask = None
self.aotask = None | [
"def",
"stop",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"aitask",
".",
"stop",
"(",
")",
"self",
".",
"aotask",
".",
"stop",
"(",
")",
"pass",
"except",
":",
"print",
"u\"No task running\"",
"self",
".",
"aitask",
"=",
"None",
"self",
".",
"... | Halts the acquisition, this must be called before resetting acquisition | [
"Halts",
"the",
"acquisition",
"this",
"must",
"be",
"called",
"before",
"resetting",
"acquisition"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/acq/players.py#L268-L277 | train |
portfors-lab/sparkle | sparkle/acq/players.py | ContinuousPlayer.start_continuous | def start_continuous(self, aichans, update_hz=10):
"""Begins a continuous analog generation, calling a provided function
at a rate of 10Hz
:param aichans: name of channel(s) to record (analog input) from
:type aichans: list<str>
:param update_hz: Rate (Hz) at which to read data... | python | def start_continuous(self, aichans, update_hz=10):
"""Begins a continuous analog generation, calling a provided function
at a rate of 10Hz
:param aichans: name of channel(s) to record (analog input) from
:type aichans: list<str>
:param update_hz: Rate (Hz) at which to read data... | [
"def",
"start_continuous",
"(",
"self",
",",
"aichans",
",",
"update_hz",
"=",
"10",
")",
":",
"self",
".",
"daq_lock",
".",
"acquire",
"(",
")",
"self",
".",
"ngenerated",
"=",
"0",
"npts",
"=",
"int",
"(",
"self",
".",
"aifs",
"/",
"update_hz",
")"... | Begins a continuous analog generation, calling a provided function
at a rate of 10Hz
:param aichans: name of channel(s) to record (analog input) from
:type aichans: list<str>
:param update_hz: Rate (Hz) at which to read data from the device input buffer
:type update_hz: int | [
"Begins",
"a",
"continuous",
"analog",
"generation",
"calling",
"a",
"provided",
"function",
"at",
"a",
"rate",
"of",
"10Hz"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/acq/players.py#L286-L302 | train |
portfors-lab/sparkle | sparkle/acq/players.py | ContinuousPlayer.run | def run(self):
"""Executes the stimulus generation, and returns when completed"""
self.aotask.StartTask()
self.aotask.wait() # don't return until generation finished
self.aotask.stop()
self.aotask = None | python | def run(self):
"""Executes the stimulus generation, and returns when completed"""
self.aotask.StartTask()
self.aotask.wait() # don't return until generation finished
self.aotask.stop()
self.aotask = None | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"aotask",
".",
"StartTask",
"(",
")",
"self",
".",
"aotask",
".",
"wait",
"(",
")",
"self",
".",
"aotask",
".",
"stop",
"(",
")",
"self",
".",
"aotask",
"=",
"None"
] | Executes the stimulus generation, and returns when completed | [
"Executes",
"the",
"stimulus",
"generation",
"and",
"returns",
"when",
"completed"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/acq/players.py#L315-L320 | train |
portfors-lab/sparkle | sparkle/acq/players.py | ContinuousPlayer.stop_all | def stop_all(self):
"""Halts both the analog output and input tasks"""
if self.aotask is not None:
self.aotask.stop()
self.aitask.stop()
self.daq_lock.release()
self.aitask = None
self.aotask = None | python | def stop_all(self):
"""Halts both the analog output and input tasks"""
if self.aotask is not None:
self.aotask.stop()
self.aitask.stop()
self.daq_lock.release()
self.aitask = None
self.aotask = None | [
"def",
"stop_all",
"(",
"self",
")",
":",
"if",
"self",
".",
"aotask",
"is",
"not",
"None",
":",
"self",
".",
"aotask",
".",
"stop",
"(",
")",
"self",
".",
"aitask",
".",
"stop",
"(",
")",
"self",
".",
"daq_lock",
".",
"release",
"(",
")",
"self"... | Halts both the analog output and input tasks | [
"Halts",
"both",
"the",
"analog",
"output",
"and",
"input",
"tasks"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/acq/players.py#L344-L351 | train |
amigocloud/python-amigocloud | amigocloud/amigocloud.py | AmigoCloud.get | def get(self, url, params=None, raw=False, stream=False, **request_kwargs):
"""
GET request to AmigoCloud endpoint.
"""
full_url = self.build_url(url)
params = params or {}
# Add token (if it's not already there)
if self._token:
params.setdefault('to... | python | def get(self, url, params=None, raw=False, stream=False, **request_kwargs):
"""
GET request to AmigoCloud endpoint.
"""
full_url = self.build_url(url)
params = params or {}
# Add token (if it's not already there)
if self._token:
params.setdefault('to... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"stream",
"=",
"False",
",",
"**",
"request_kwargs",
")",
":",
"full_url",
"=",
"self",
".",
"build_url",
"(",
"url",
")",
"params",
"=",
"params",
"o... | GET request to AmigoCloud endpoint. | [
"GET",
"request",
"to",
"AmigoCloud",
"endpoint",
"."
] | d31403e7299cc46e3a3e1392090ee033f3a02b6d | https://github.com/amigocloud/python-amigocloud/blob/d31403e7299cc46e3a3e1392090ee033f3a02b6d/amigocloud/amigocloud.py#L118-L138 | train |
amigocloud/python-amigocloud | amigocloud/amigocloud.py | AmigoCloud.post | def post(self, url, data=None, files=None, headers=None, raw=False,
send_as_json=True, content_type=None, **request_kwargs):
"""
POST request to AmigoCloud endpoint.
"""
return self._secure_request(
url, 'post', data=data, files=files, headers=headers, raw=raw,
... | python | def post(self, url, data=None, files=None, headers=None, raw=False,
send_as_json=True, content_type=None, **request_kwargs):
"""
POST request to AmigoCloud endpoint.
"""
return self._secure_request(
url, 'post', data=data, files=files, headers=headers, raw=raw,
... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"files",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"send_as_json",
"=",
"True",
",",
"content_type",
"=",
"None",
",",
"**",
"request_kwargs",
")",
... | POST request to AmigoCloud endpoint. | [
"POST",
"request",
"to",
"AmigoCloud",
"endpoint",
"."
] | d31403e7299cc46e3a3e1392090ee033f3a02b6d | https://github.com/amigocloud/python-amigocloud/blob/d31403e7299cc46e3a3e1392090ee033f3a02b6d/amigocloud/amigocloud.py#L175-L185 | train |
amigocloud/python-amigocloud | amigocloud/amigocloud.py | AmigoCloud.upload_gallery_photo | def upload_gallery_photo(self, gallery_id, source_amigo_id, file_obj,
chunk_size=CHUNK_SIZE, force_chunked=False,
metadata=None):
"""
Upload a photo to a dataset's gallery.
"""
simple_upload_url = 'related_tables/%s/upload' % gal... | python | def upload_gallery_photo(self, gallery_id, source_amigo_id, file_obj,
chunk_size=CHUNK_SIZE, force_chunked=False,
metadata=None):
"""
Upload a photo to a dataset's gallery.
"""
simple_upload_url = 'related_tables/%s/upload' % gal... | [
"def",
"upload_gallery_photo",
"(",
"self",
",",
"gallery_id",
",",
"source_amigo_id",
",",
"file_obj",
",",
"chunk_size",
"=",
"CHUNK_SIZE",
",",
"force_chunked",
"=",
"False",
",",
"metadata",
"=",
"None",
")",
":",
"simple_upload_url",
"=",
"'related_tables/%s/... | Upload a photo to a dataset's gallery. | [
"Upload",
"a",
"photo",
"to",
"a",
"dataset",
"s",
"gallery",
"."
] | d31403e7299cc46e3a3e1392090ee033f3a02b6d | https://github.com/amigocloud/python-amigocloud/blob/d31403e7299cc46e3a3e1392090ee033f3a02b6d/amigocloud/amigocloud.py#L306-L326 | train |
amigocloud/python-amigocloud | amigocloud/amigocloud.py | AmigoCloud.listen_user_events | def listen_user_events(self):
"""
Authenticate to start listening to user events.
"""
if not self._user_id:
raise AmigoCloudError(self.error_msg['logged_in_websockets'])
response = self.get('/me/start_websocket_session')
websocket_session = response['websock... | python | def listen_user_events(self):
"""
Authenticate to start listening to user events.
"""
if not self._user_id:
raise AmigoCloudError(self.error_msg['logged_in_websockets'])
response = self.get('/me/start_websocket_session')
websocket_session = response['websock... | [
"def",
"listen_user_events",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_user_id",
":",
"raise",
"AmigoCloudError",
"(",
"self",
".",
"error_msg",
"[",
"'logged_in_websockets'",
"]",
")",
"response",
"=",
"self",
".",
"get",
"(",
"'/me/start_websocket_s... | Authenticate to start listening to user events. | [
"Authenticate",
"to",
"start",
"listening",
"to",
"user",
"events",
"."
] | d31403e7299cc46e3a3e1392090ee033f3a02b6d | https://github.com/amigocloud/python-amigocloud/blob/d31403e7299cc46e3a3e1392090ee033f3a02b6d/amigocloud/amigocloud.py#L328-L340 | train |
amigocloud/python-amigocloud | amigocloud/amigocloud.py | AmigoCloud.listen_dataset_events | def listen_dataset_events(self, owner_id, project_id, dataset_id):
"""
Authenticate to start using dataset events.
"""
if not self._user_id:
raise AmigoCloudError(self.error_msg['logged_in_websockets'])
url = '/users/%s/projects/%s/datasets/%s/start_websocket_sessio... | python | def listen_dataset_events(self, owner_id, project_id, dataset_id):
"""
Authenticate to start using dataset events.
"""
if not self._user_id:
raise AmigoCloudError(self.error_msg['logged_in_websockets'])
url = '/users/%s/projects/%s/datasets/%s/start_websocket_sessio... | [
"def",
"listen_dataset_events",
"(",
"self",
",",
"owner_id",
",",
"project_id",
",",
"dataset_id",
")",
":",
"if",
"not",
"self",
".",
"_user_id",
":",
"raise",
"AmigoCloudError",
"(",
"self",
".",
"error_msg",
"[",
"'logged_in_websockets'",
"]",
")",
"url",
... | Authenticate to start using dataset events. | [
"Authenticate",
"to",
"start",
"using",
"dataset",
"events",
"."
] | d31403e7299cc46e3a3e1392090ee033f3a02b6d | https://github.com/amigocloud/python-amigocloud/blob/d31403e7299cc46e3a3e1392090ee033f3a02b6d/amigocloud/amigocloud.py#L342-L356 | train |
loganasherjones/yapconf | yapconf/docs.py | build_markdown_table | def build_markdown_table(headers, rows, row_keys=None):
"""Build a lined up markdown table.
Args:
headers (dict): A key -> value pairing fo the headers.
rows (list): List of dictionaries that contain all the keys listed in
the headers.
row_keys (list): A sorted list of keys to d... | python | def build_markdown_table(headers, rows, row_keys=None):
"""Build a lined up markdown table.
Args:
headers (dict): A key -> value pairing fo the headers.
rows (list): List of dictionaries that contain all the keys listed in
the headers.
row_keys (list): A sorted list of keys to d... | [
"def",
"build_markdown_table",
"(",
"headers",
",",
"rows",
",",
"row_keys",
"=",
"None",
")",
":",
"row_maxes",
"=",
"_find_row_maxes",
"(",
"headers",
",",
"rows",
")",
"row_keys",
"=",
"row_keys",
"or",
"[",
"key",
"for",
"key",
",",
"value",
"in",
"h... | Build a lined up markdown table.
Args:
headers (dict): A key -> value pairing fo the headers.
rows (list): List of dictionaries that contain all the keys listed in
the headers.
row_keys (list): A sorted list of keys to display
Returns:
A valid Markdown Table as a string... | [
"Build",
"a",
"lined",
"up",
"markdown",
"table",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/docs.py#L123-L144 | train |
jason-weirather/pythologist | pythologist/interface/__init__.py | SegmentationImageOutput.write_to_path | def write_to_path(self,path,suffix='',format='png',overwrite=False):
"""
Output the data the dataframe's 'image' column to a directory structured by project->sample and named by frame
Args:
path (str): Where to write the directory of images
suffix (str): for labeling the... | python | def write_to_path(self,path,suffix='',format='png',overwrite=False):
"""
Output the data the dataframe's 'image' column to a directory structured by project->sample and named by frame
Args:
path (str): Where to write the directory of images
suffix (str): for labeling the... | [
"def",
"write_to_path",
"(",
"self",
",",
"path",
",",
"suffix",
"=",
"''",
",",
"format",
"=",
"'png'",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
"and",
"overwrite",
"is",
"False",
":",
"ra... | Output the data the dataframe's 'image' column to a directory structured by project->sample and named by frame
Args:
path (str): Where to write the directory of images
suffix (str): for labeling the imaages you write
format (str): default 'png' format to write the file
... | [
"Output",
"the",
"data",
"the",
"dataframe",
"s",
"image",
"column",
"to",
"a",
"directory",
"structured",
"by",
"project",
"-",
">",
"sample",
"and",
"named",
"by",
"frame"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/interface/__init__.py#L22-L43 | train |
jason-weirather/pythologist | pythologist/interface/__init__.py | SegmentationImages.build_segmentation_image | def build_segmentation_image(self,schema,background=(0,0,0,0)):
"""
Put together an image. Defined by a list of layers with RGBA colors
Make the schema example
| schema = [
| {'subset_logic':SL(phenotypes=['SOX10+']),
| 'edge_color':(31, 31, 4... | python | def build_segmentation_image(self,schema,background=(0,0,0,0)):
"""
Put together an image. Defined by a list of layers with RGBA colors
Make the schema example
| schema = [
| {'subset_logic':SL(phenotypes=['SOX10+']),
| 'edge_color':(31, 31, 4... | [
"def",
"build_segmentation_image",
"(",
"self",
",",
"schema",
",",
"background",
"=",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
")",
":",
"cummulative",
"=",
"self",
".",
"copy",
"(",
")",
"def",
"_set_blank",
"(",
"img",
",",
"blank",
")",
":"... | Put together an image. Defined by a list of layers with RGBA colors
Make the schema example
| schema = [
| {'subset_logic':SL(phenotypes=['SOX10+']),
| 'edge_color':(31, 31, 46,255),
| 'watershed_steps':0,
| 'fill_color':(51, 5... | [
"Put",
"together",
"an",
"image",
".",
"Defined",
"by",
"a",
"list",
"of",
"layers",
"with",
"RGBA",
"colors"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/interface/__init__.py#L147-L197 | train |
luhnmod10/python | luhnmod10/__init__.py | valid | def valid(number):
"""
Returns true if the number string is luhn valid, and false otherwise. The
number string passed to the function must contain only numeric characters
otherwise behavior is undefined.
"""
checksum = 0
number_len = len(number)
offset = ord('0')
i = number_len - ... | python | def valid(number):
"""
Returns true if the number string is luhn valid, and false otherwise. The
number string passed to the function must contain only numeric characters
otherwise behavior is undefined.
"""
checksum = 0
number_len = len(number)
offset = ord('0')
i = number_len - ... | [
"def",
"valid",
"(",
"number",
")",
":",
"checksum",
"=",
"0",
"number_len",
"=",
"len",
"(",
"number",
")",
"offset",
"=",
"ord",
"(",
"'0'",
")",
"i",
"=",
"number_len",
"-",
"1",
"while",
"i",
">=",
"0",
":",
"n",
"=",
"ord",
"(",
"number",
... | Returns true if the number string is luhn valid, and false otherwise. The
number string passed to the function must contain only numeric characters
otherwise behavior is undefined. | [
"Returns",
"true",
"if",
"the",
"number",
"string",
"is",
"luhn",
"valid",
"and",
"false",
"otherwise",
".",
"The",
"number",
"string",
"passed",
"to",
"the",
"function",
"must",
"contain",
"only",
"numeric",
"characters",
"otherwise",
"behavior",
"is",
"undef... | 7cd1e9e4029dd364a10435bd80ed48a2cc180491 | https://github.com/luhnmod10/python/blob/7cd1e9e4029dd364a10435bd80ed48a2cc180491/luhnmod10/__init__.py#L1-L27 | train |
IS-ENES-Data/esgf-pid | esgfpid/connector.py | Connector.create_publication_assistant | def create_publication_assistant(self, **args):
'''
Create an assistant for a dataset that allows to make PID
requests for the dataset and all of its files.
:param drs_id: Mandatory. The dataset id of the dataset
to be published.
:param version_number: Mandatory. Th... | python | def create_publication_assistant(self, **args):
'''
Create an assistant for a dataset that allows to make PID
requests for the dataset and all of its files.
:param drs_id: Mandatory. The dataset id of the dataset
to be published.
:param version_number: Mandatory. Th... | [
"def",
"create_publication_assistant",
"(",
"self",
",",
"**",
"args",
")",
":",
"logdebug",
"(",
"LOGGER",
",",
"'Creating publication assistant..'",
")",
"mandatory_args",
"=",
"[",
"'drs_id'",
",",
"'version_number'",
",",
"'is_replica'",
"]",
"esgfpid",
".",
"... | Create an assistant for a dataset that allows to make PID
requests for the dataset and all of its files.
:param drs_id: Mandatory. The dataset id of the dataset
to be published.
:param version_number: Mandatory. The version number of the
dataset to be published.
... | [
"Create",
"an",
"assistant",
"for",
"a",
"dataset",
"that",
"allows",
"to",
"make",
"PID",
"requests",
"for",
"the",
"dataset",
"and",
"all",
"of",
"its",
"files",
"."
] | 2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41 | https://github.com/IS-ENES-Data/esgf-pid/blob/2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41/esgfpid/connector.py#L287-L341 | train |
IS-ENES-Data/esgf-pid | esgfpid/connector.py | Connector.unpublish_one_version | def unpublish_one_version(self, **args):
'''
Sends a PID update request for the unpublication of one version
of a dataset currently published at the given data node.
Either the handle or the pair of drs_id and version_number
have to be provided, otherwise an exception will occur... | python | def unpublish_one_version(self, **args):
'''
Sends a PID update request for the unpublication of one version
of a dataset currently published at the given data node.
Either the handle or the pair of drs_id and version_number
have to be provided, otherwise an exception will occur... | [
"def",
"unpublish_one_version",
"(",
"self",
",",
"**",
"args",
")",
":",
"optional_args",
"=",
"[",
"'handle'",
",",
"'drs_id'",
",",
"'version_number'",
"]",
"esgfpid",
".",
"utils",
".",
"add_missing_optional_args_with_value_none",
"(",
"args",
",",
"optional_a... | Sends a PID update request for the unpublication of one version
of a dataset currently published at the given data node.
Either the handle or the pair of drs_id and version_number
have to be provided, otherwise an exception will occur.
The consumer will of course check the PID request ... | [
"Sends",
"a",
"PID",
"update",
"request",
"for",
"the",
"unpublication",
"of",
"one",
"version",
"of",
"a",
"dataset",
"currently",
"published",
"at",
"the",
"given",
"data",
"node",
"."
] | 2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41 | https://github.com/IS-ENES-Data/esgf-pid/blob/2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41/esgfpid/connector.py#L351-L401 | train |
IS-ENES-Data/esgf-pid | esgfpid/connector.py | Connector.unpublish_all_versions | def unpublish_all_versions(self, **args):
'''
Sends a PID update request for the unpublication of all versions
of a dataset currently published at the given data node.
If the library has solr access, it will try to find all the
dataset versions and their handles from solr, and s... | python | def unpublish_all_versions(self, **args):
'''
Sends a PID update request for the unpublication of all versions
of a dataset currently published at the given data node.
If the library has solr access, it will try to find all the
dataset versions and their handles from solr, and s... | [
"def",
"unpublish_all_versions",
"(",
"self",
",",
"**",
"args",
")",
":",
"mandatory_args",
"=",
"[",
"'drs_id'",
"]",
"esgfpid",
".",
"utils",
".",
"check_presence_of_mandatory_args",
"(",
"args",
",",
"mandatory_args",
")",
"if",
"self",
".",
"__data_node",
... | Sends a PID update request for the unpublication of all versions
of a dataset currently published at the given data node.
If the library has solr access, it will try to find all the
dataset versions and their handles from solr, and send individual
messages for each version. Otherwise, o... | [
"Sends",
"a",
"PID",
"update",
"request",
"for",
"the",
"unpublication",
"of",
"all",
"versions",
"of",
"a",
"dataset",
"currently",
"published",
"at",
"the",
"given",
"data",
"node",
"."
] | 2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41 | https://github.com/IS-ENES-Data/esgf-pid/blob/2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41/esgfpid/connector.py#L403-L446 | train |
IS-ENES-Data/esgf-pid | esgfpid/connector.py | Connector.add_errata_ids | def add_errata_ids(self, **args):
'''
Add errata ids to a dataset handle record.
To call this method, you do not need to provide the
PID of the dataset. Instead, the PID string is derived
from the dataset id and the version number.
:param errata_ids: Mandatory. A list o... | python | def add_errata_ids(self, **args):
'''
Add errata ids to a dataset handle record.
To call this method, you do not need to provide the
PID of the dataset. Instead, the PID string is derived
from the dataset id and the version number.
:param errata_ids: Mandatory. A list o... | [
"def",
"add_errata_ids",
"(",
"self",
",",
"**",
"args",
")",
":",
"mandatory_args",
"=",
"[",
"'drs_id'",
",",
"'version_number'",
",",
"'errata_ids'",
"]",
"esgfpid",
".",
"utils",
".",
"check_presence_of_mandatory_args",
"(",
"args",
",",
"mandatory_args",
")... | Add errata ids to a dataset handle record.
To call this method, you do not need to provide the
PID of the dataset. Instead, the PID string is derived
from the dataset id and the version number.
:param errata_ids: Mandatory. A list of errata ids (strings)
to be added to the ... | [
"Add",
"errata",
"ids",
"to",
"a",
"dataset",
"handle",
"record",
"."
] | 2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41 | https://github.com/IS-ENES-Data/esgf-pid/blob/2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41/esgfpid/connector.py#L448-L484 | train |
IS-ENES-Data/esgf-pid | esgfpid/connector.py | Connector.make_handle_from_drsid_and_versionnumber | def make_handle_from_drsid_and_versionnumber(self, **args):
'''
Create a handle string for a specific dataset, based
on its dataset id and version number, and the prefix
passed to the library at initializing.
:param drs_id: The dataset id of the dataset.
:param version_n... | python | def make_handle_from_drsid_and_versionnumber(self, **args):
'''
Create a handle string for a specific dataset, based
on its dataset id and version number, and the prefix
passed to the library at initializing.
:param drs_id: The dataset id of the dataset.
:param version_n... | [
"def",
"make_handle_from_drsid_and_versionnumber",
"(",
"self",
",",
"**",
"args",
")",
":",
"args",
"[",
"'prefix'",
"]",
"=",
"self",
".",
"prefix",
"return",
"esgfpid",
".",
"utils",
".",
"make_handle_from_drsid_and_versionnumber",
"(",
"**",
"args",
")"
] | Create a handle string for a specific dataset, based
on its dataset id and version number, and the prefix
passed to the library at initializing.
:param drs_id: The dataset id of the dataset.
:param version_number: The version number of the dataset
(as a string or integer, th... | [
"Create",
"a",
"handle",
"string",
"for",
"a",
"specific",
"dataset",
"based",
"on",
"its",
"dataset",
"id",
"and",
"version",
"number",
"and",
"the",
"prefix",
"passed",
"to",
"the",
"library",
"at",
"initializing",
"."
] | 2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41 | https://github.com/IS-ENES-Data/esgf-pid/blob/2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41/esgfpid/connector.py#L605-L617 | train |
portfors-lab/sparkle | sparkle/gui/abstract_drag_view.py | AbstractDragView.mousePressEvent | def mousePressEvent(self, event):
"""saves the drag position, so we know when a drag should be initiated"""
super(AbstractDragView, self).mousePressEvent(event)
self.dragStartPosition = event.pos() | python | def mousePressEvent(self, event):
"""saves the drag position, so we know when a drag should be initiated"""
super(AbstractDragView, self).mousePressEvent(event)
self.dragStartPosition = event.pos() | [
"def",
"mousePressEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"AbstractDragView",
",",
"self",
")",
".",
"mousePressEvent",
"(",
"event",
")",
"self",
".",
"dragStartPosition",
"=",
"event",
".",
"pos",
"(",
")"
] | saves the drag position, so we know when a drag should be initiated | [
"saves",
"the",
"drag",
"position",
"so",
"we",
"know",
"when",
"a",
"drag",
"should",
"be",
"initiated"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/abstract_drag_view.py#L56-L59 | train |
portfors-lab/sparkle | sparkle/gui/abstract_drag_view.py | AbstractDragView.dragLeaveEvent | def dragLeaveEvent(self, event):
"""Clears drop cursor line"""
super(AbstractDragView, self).dragLeaveEvent(event)
self.dragline = None
self.viewport().update()
event.accept() | python | def dragLeaveEvent(self, event):
"""Clears drop cursor line"""
super(AbstractDragView, self).dragLeaveEvent(event)
self.dragline = None
self.viewport().update()
event.accept() | [
"def",
"dragLeaveEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"AbstractDragView",
",",
"self",
")",
".",
"dragLeaveEvent",
"(",
"event",
")",
"self",
".",
"dragline",
"=",
"None",
"self",
".",
"viewport",
"(",
")",
".",
"update",
"(",
")"... | Clears drop cursor line | [
"Clears",
"drop",
"cursor",
"line"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/abstract_drag_view.py#L135-L140 | train |
portfors-lab/sparkle | sparkle/gui/abstract_drag_view.py | AbstractDragView.childEvent | def childEvent(self, event):
"""Catches items dropped off edge of view,
reinserts at original position
:param event: contains event parameters for child object events
:type event: :qtdoc:`QChildEvent`
"""
super(AbstractDragView, self).childEvent(event)
if ev... | python | def childEvent(self, event):
"""Catches items dropped off edge of view,
reinserts at original position
:param event: contains event parameters for child object events
:type event: :qtdoc:`QChildEvent`
"""
super(AbstractDragView, self).childEvent(event)
if ev... | [
"def",
"childEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"AbstractDragView",
",",
"self",
")",
".",
"childEvent",
"(",
"event",
")",
"if",
"event",
".",
"type",
"(",
")",
"==",
"QtCore",
".",
"QEvent",
".",
"ChildRemoved",
":",
"if",
"... | Catches items dropped off edge of view,
reinserts at original position
:param event: contains event parameters for child object events
:type event: :qtdoc:`QChildEvent` | [
"Catches",
"items",
"dropped",
"off",
"edge",
"of",
"view",
"reinserts",
"at",
"original",
"position"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/abstract_drag_view.py#L170-L185 | train |
portfors-lab/sparkle | sparkle/gui/abstract_drag_view.py | AbstractDragView.mouseReleaseEvent | def mouseReleaseEvent(self, event):
"""Resets the drag start position"""
super(AbstractDragView, self).mouseReleaseEvent(event)
self.dragStartPosition = None | python | def mouseReleaseEvent(self, event):
"""Resets the drag start position"""
super(AbstractDragView, self).mouseReleaseEvent(event)
self.dragStartPosition = None | [
"def",
"mouseReleaseEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"AbstractDragView",
",",
"self",
")",
".",
"mouseReleaseEvent",
"(",
"event",
")",
"self",
".",
"dragStartPosition",
"=",
"None"
] | Resets the drag start position | [
"Resets",
"the",
"drag",
"start",
"position"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/abstract_drag_view.py#L187-L190 | train |
dpa-newslab/livebridge | livebridge/storages/mongo.py | MongoStorage.setup | async def setup(self):
"""Setting up MongoDB collections, if they not exist."""
try:
db = await self.db
collections = await db.list_collection_names()
created = False
if self.table_name not in collections:
# create table
log... | python | async def setup(self):
"""Setting up MongoDB collections, if they not exist."""
try:
db = await self.db
collections = await db.list_collection_names()
created = False
if self.table_name not in collections:
# create table
log... | [
"async",
"def",
"setup",
"(",
"self",
")",
":",
"try",
":",
"db",
"=",
"await",
"self",
".",
"db",
"collections",
"=",
"await",
"db",
".",
"list_collection_names",
"(",
")",
"created",
"=",
"False",
"if",
"self",
".",
"table_name",
"not",
"in",
"collec... | Setting up MongoDB collections, if they not exist. | [
"Setting",
"up",
"MongoDB",
"collections",
"if",
"they",
"not",
"exist",
"."
] | d930e887faa2f882d15b574f0f1fe4a580d7c5fa | https://github.com/dpa-newslab/livebridge/blob/d930e887faa2f882d15b574f0f1fe4a580d7c5fa/livebridge/storages/mongo.py#L57-L78 | train |
portfors-lab/sparkle | sparkle/gui/stim/component_detail.py | ComponentsDetailWidget.setDoc | def setDoc(self, docs):
"""Sets the documentation to display
:param docs: a list of the stimuli doc, which are dicts
:type docs: list<dict>
"""
# sort stim by start time
docs = sorted(docs, key=lambda k: k['start_s'])
for doc in docs:
stim_type = doc... | python | def setDoc(self, docs):
"""Sets the documentation to display
:param docs: a list of the stimuli doc, which are dicts
:type docs: list<dict>
"""
# sort stim by start time
docs = sorted(docs, key=lambda k: k['start_s'])
for doc in docs:
stim_type = doc... | [
"def",
"setDoc",
"(",
"self",
",",
"docs",
")",
":",
"docs",
"=",
"sorted",
"(",
"docs",
",",
"key",
"=",
"lambda",
"k",
":",
"k",
"[",
"'start_s'",
"]",
")",
"for",
"doc",
"in",
"docs",
":",
"stim_type",
"=",
"doc",
"[",
"'stim_type'",
"]",
"if"... | Sets the documentation to display
:param docs: a list of the stimuli doc, which are dicts
:type docs: list<dict> | [
"Sets",
"the",
"documentation",
"to",
"display"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/component_detail.py#L38-L55 | train |
portfors-lab/sparkle | sparkle/gui/stim/component_detail.py | ComponentsDetailSelector.setComponents | def setComponents(self, components):
"""Clears and sets the components contained in this widget
:param components: list of documentation for subclasses of AbStractStimulusComponents
:type Components: list<dict>
"""
layout = self.layout()
for comp in components:
... | python | def setComponents(self, components):
"""Clears and sets the components contained in this widget
:param components: list of documentation for subclasses of AbStractStimulusComponents
:type Components: list<dict>
"""
layout = self.layout()
for comp in components:
... | [
"def",
"setComponents",
"(",
"self",
",",
"components",
")",
":",
"layout",
"=",
"self",
".",
"layout",
"(",
")",
"for",
"comp",
"in",
"components",
":",
"attrWidget",
"=",
"ComponentAttributerChecker",
"(",
"comp",
")",
"layout",
".",
"addWidget",
"(",
"a... | Clears and sets the components contained in this widget
:param components: list of documentation for subclasses of AbStractStimulusComponents
:type Components: list<dict> | [
"Clears",
"and",
"sets",
"the",
"components",
"contained",
"in",
"this",
"widget"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/component_detail.py#L96-L105 | train |
portfors-lab/sparkle | sparkle/gui/stim/component_detail.py | ComponentsDetailSelector.setCheckedDetails | def setCheckedDetails(self, checked):
"""Sets which components are checked
:param checked: dictionary of stimtype:list<attribute names> for which components and their attributes should be checked
:type checked: dict
"""
layout = self.layout()
for i in range(layout.count(... | python | def setCheckedDetails(self, checked):
"""Sets which components are checked
:param checked: dictionary of stimtype:list<attribute names> for which components and their attributes should be checked
:type checked: dict
"""
layout = self.layout()
for i in range(layout.count(... | [
"def",
"setCheckedDetails",
"(",
"self",
",",
"checked",
")",
":",
"layout",
"=",
"self",
".",
"layout",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"layout",
".",
"count",
"(",
")",
")",
":",
"w",
"=",
"layout",
".",
"itemAt",
"(",
"i",
")",
".",
... | Sets which components are checked
:param checked: dictionary of stimtype:list<attribute names> for which components and their attributes should be checked
:type checked: dict | [
"Sets",
"which",
"components",
"are",
"checked"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/component_detail.py#L107-L117 | train |
portfors-lab/sparkle | sparkle/gui/stim/component_detail.py | ComponentsDetailSelector.getCheckedDetails | def getCheckedDetails(self):
"""Gets the currently checked components and checked attributes
:returns: dict -- of members with stimtype:list<attribute names>
"""
attrs = {}
layout = self.layout()
for i in range(layout.count()):
w = layout.itemAt(i).widget()
... | python | def getCheckedDetails(self):
"""Gets the currently checked components and checked attributes
:returns: dict -- of members with stimtype:list<attribute names>
"""
attrs = {}
layout = self.layout()
for i in range(layout.count()):
w = layout.itemAt(i).widget()
... | [
"def",
"getCheckedDetails",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"}",
"layout",
"=",
"self",
".",
"layout",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"layout",
".",
"count",
"(",
")",
")",
":",
"w",
"=",
"layout",
".",
"itemAt",
"(",
"i",
... | Gets the currently checked components and checked attributes
:returns: dict -- of members with stimtype:list<attribute names> | [
"Gets",
"the",
"currently",
"checked",
"components",
"and",
"checked",
"attributes"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/component_detail.py#L119-L129 | train |
portfors-lab/sparkle | sparkle/gui/stim/component_detail.py | ComponentAttributerChecker.getChecked | def getChecked(self):
"""Gets the checked attributes
:returns: list<str> -- checked attribute names
"""
attrs = []
layout = self.layout()
for i in range(layout.count()):
w = layout.itemAt(i).widget()
if w.isChecked():
attrs.append(... | python | def getChecked(self):
"""Gets the checked attributes
:returns: list<str> -- checked attribute names
"""
attrs = []
layout = self.layout()
for i in range(layout.count()):
w = layout.itemAt(i).widget()
if w.isChecked():
attrs.append(... | [
"def",
"getChecked",
"(",
"self",
")",
":",
"attrs",
"=",
"[",
"]",
"layout",
"=",
"self",
".",
"layout",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"layout",
".",
"count",
"(",
")",
")",
":",
"w",
"=",
"layout",
".",
"itemAt",
"(",
"i",
")",
... | Gets the checked attributes
:returns: list<str> -- checked attribute names | [
"Gets",
"the",
"checked",
"attributes"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/component_detail.py#L165-L176 | train |
portfors-lab/sparkle | sparkle/gui/qprotocol.py | QProtocolTabelModel.headerData | def headerData(self, section, orientation, role):
"""Get the Header for the columns in the table
Required by view, see :qtdoc:`subclassing<qabstractitemmodel.subclassing>`
:param section: column of header to return
:type section: int
"""
if role == QtCore.Qt.DisplayRole... | python | def headerData(self, section, orientation, role):
"""Get the Header for the columns in the table
Required by view, see :qtdoc:`subclassing<qabstractitemmodel.subclassing>`
:param section: column of header to return
:type section: int
"""
if role == QtCore.Qt.DisplayRole... | [
"def",
"headerData",
"(",
"self",
",",
"section",
",",
"orientation",
",",
"role",
")",
":",
"if",
"role",
"==",
"QtCore",
".",
"Qt",
".",
"DisplayRole",
":",
"if",
"orientation",
"==",
"QtCore",
".",
"Qt",
".",
"Horizontal",
":",
"return",
"self",
"."... | Get the Header for the columns in the table
Required by view, see :qtdoc:`subclassing<qabstractitemmodel.subclassing>`
:param section: column of header to return
:type section: int | [
"Get",
"the",
"Header",
"for",
"the",
"columns",
"in",
"the",
"table"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/qprotocol.py#L23-L33 | train |
portfors-lab/sparkle | sparkle/gui/qprotocol.py | ProtocolView.cursor | def cursor(self, pos):
"""Returns a line at the nearest row split between tests.
Re-implemented from :meth:`AbstractDragView<sparkle.gui.abstract_drag_view.AbstractDragView.cursor>`
"""
row = self.indexAt(pos).row()
if row == -1:
row = self.model().rowCount()
... | python | def cursor(self, pos):
"""Returns a line at the nearest row split between tests.
Re-implemented from :meth:`AbstractDragView<sparkle.gui.abstract_drag_view.AbstractDragView.cursor>`
"""
row = self.indexAt(pos).row()
if row == -1:
row = self.model().rowCount()
... | [
"def",
"cursor",
"(",
"self",
",",
"pos",
")",
":",
"row",
"=",
"self",
".",
"indexAt",
"(",
"pos",
")",
".",
"row",
"(",
")",
"if",
"row",
"==",
"-",
"1",
":",
"row",
"=",
"self",
".",
"model",
"(",
")",
".",
"rowCount",
"(",
")",
"row_heigh... | Returns a line at the nearest row split between tests.
Re-implemented from :meth:`AbstractDragView<sparkle.gui.abstract_drag_view.AbstractDragView.cursor>` | [
"Returns",
"a",
"line",
"at",
"the",
"nearest",
"row",
"split",
"between",
"tests",
"."
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/qprotocol.py#L211-L222 | train |
portfors-lab/sparkle | sparkle/gui/qprotocol.py | ProtocolView.mousePressEvent | def mousePressEvent(self, event):
"""Launches edit of cell if first column clicked, otherwise passes to super class"""
index = self.indexAt(event.pos())
if index.isValid():
if index.column() == 0:
self.edit(index, QtGui.QAbstractItemView.DoubleClicked, event)
... | python | def mousePressEvent(self, event):
"""Launches edit of cell if first column clicked, otherwise passes to super class"""
index = self.indexAt(event.pos())
if index.isValid():
if index.column() == 0:
self.edit(index, QtGui.QAbstractItemView.DoubleClicked, event)
... | [
"def",
"mousePressEvent",
"(",
"self",
",",
"event",
")",
":",
"index",
"=",
"self",
".",
"indexAt",
"(",
"event",
".",
"pos",
"(",
")",
")",
"if",
"index",
".",
"isValid",
"(",
")",
":",
"if",
"index",
".",
"column",
"(",
")",
"==",
"0",
":",
... | Launches edit of cell if first column clicked, otherwise passes to super class | [
"Launches",
"edit",
"of",
"cell",
"if",
"first",
"column",
"clicked",
"otherwise",
"passes",
"to",
"super",
"class"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/qprotocol.py#L224-L231 | train |
lsst-sqre/sqre-codekit | codekit/cli/github_list_repos.py | run | def run():
"""List repos and teams"""
args = parse_args()
codetools.setup_logging(args.debug)
global g
g = pygithub.login_github(token_path=args.token_path, token=args.token)
if not args.hide:
args.hide = []
org = g.get_organization(args.organization)
try:
repos = li... | python | def run():
"""List repos and teams"""
args = parse_args()
codetools.setup_logging(args.debug)
global g
g = pygithub.login_github(token_path=args.token_path, token=args.token)
if not args.hide:
args.hide = []
org = g.get_organization(args.organization)
try:
repos = li... | [
"def",
"run",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
")",
"codetools",
".",
"setup_logging",
"(",
"args",
".",
"debug",
")",
"global",
"g",
"g",
"=",
"pygithub",
".",
"login_github",
"(",
"token_path",
"=",
"args",
".",
"token_path",
",",
"toke... | List repos and teams | [
"List",
"repos",
"and",
"teams"
] | 98122404cd9065d4d1d570867fe518042669126c | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/cli/github_list_repos.py#L73-L111 | train |
sirfoga/pyhal | hal/charts/models.py | SimpleChart.create_bar_chart | def create_bar_chart(self, x_labels, y_values, y_label):
"""Creates bar char
:param x_labels: Names for each variable
:param y_values: Values of x labels
:param y_label: Label of y axis
:return: Bar chart
"""
self.setup(0.25)
ax1 = self.get_ax()
a... | python | def create_bar_chart(self, x_labels, y_values, y_label):
"""Creates bar char
:param x_labels: Names for each variable
:param y_values: Values of x labels
:param y_label: Label of y axis
:return: Bar chart
"""
self.setup(0.25)
ax1 = self.get_ax()
a... | [
"def",
"create_bar_chart",
"(",
"self",
",",
"x_labels",
",",
"y_values",
",",
"y_label",
")",
":",
"self",
".",
"setup",
"(",
"0.25",
")",
"ax1",
"=",
"self",
".",
"get_ax",
"(",
")",
"ax1",
".",
"set_xticks",
"(",
"list",
"(",
"range",
"(",
"len",
... | Creates bar char
:param x_labels: Names for each variable
:param y_values: Values of x labels
:param y_label: Label of y axis
:return: Bar chart | [
"Creates",
"bar",
"char"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/charts/models.py#L48-L66 | train |
sirfoga/pyhal | hal/charts/models.py | SimpleChart.create_multiple_bar_chart | def create_multiple_bar_chart(self, x_labels, mul_y_values, mul_y_labels,
normalize=False):
"""Creates bar chart with multiple lines
:param x_labels: Names for each variable
:param mul_y_values: list of values of x labels
:param mul_y_labels: list of la... | python | def create_multiple_bar_chart(self, x_labels, mul_y_values, mul_y_labels,
normalize=False):
"""Creates bar chart with multiple lines
:param x_labels: Names for each variable
:param mul_y_values: list of values of x labels
:param mul_y_labels: list of la... | [
"def",
"create_multiple_bar_chart",
"(",
"self",
",",
"x_labels",
",",
"mul_y_values",
",",
"mul_y_labels",
",",
"normalize",
"=",
"False",
")",
":",
"self",
".",
"setup",
"(",
"0.25",
")",
"ax1",
"=",
"self",
".",
"get_ax",
"(",
")",
"ax1",
".",
"set_xt... | Creates bar chart with multiple lines
:param x_labels: Names for each variable
:param mul_y_values: list of values of x labels
:param mul_y_labels: list of labels for each y value
:param normalize: True iff you want to normalize each y series
:return: Bar chart | [
"Creates",
"bar",
"chart",
"with",
"multiple",
"lines"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/charts/models.py#L68-L111 | train |
TorkamaniLab/metapipe | metapipe/models/command.py | Command.file_parts | def file_parts(self):
""" Returns a list of the file tokens in the list of parts. """
file_parts = []
for part in self.parts:
try:
for sub_part in part:
if isinstance(sub_part, FileToken):
file_parts.append(sub_part)
... | python | def file_parts(self):
""" Returns a list of the file tokens in the list of parts. """
file_parts = []
for part in self.parts:
try:
for sub_part in part:
if isinstance(sub_part, FileToken):
file_parts.append(sub_part)
... | [
"def",
"file_parts",
"(",
"self",
")",
":",
"file_parts",
"=",
"[",
"]",
"for",
"part",
"in",
"self",
".",
"parts",
":",
"try",
":",
"for",
"sub_part",
"in",
"part",
":",
"if",
"isinstance",
"(",
"sub_part",
",",
"FileToken",
")",
":",
"file_parts",
... | Returns a list of the file tokens in the list of parts. | [
"Returns",
"a",
"list",
"of",
"the",
"file",
"tokens",
"in",
"the",
"list",
"of",
"parts",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/command.py#L47-L58 | train |
TorkamaniLab/metapipe | metapipe/models/command.py | Command.update_dependent_files | def update_dependent_files(self, prev_commands=[]):
""" Update the command's dependencies based on the evaluated input and
output of previous commands.
"""
for command in prev_commands:
for my_input in self.input_parts:
for their_output in command.output_parts... | python | def update_dependent_files(self, prev_commands=[]):
""" Update the command's dependencies based on the evaluated input and
output of previous commands.
"""
for command in prev_commands:
for my_input in self.input_parts:
for their_output in command.output_parts... | [
"def",
"update_dependent_files",
"(",
"self",
",",
"prev_commands",
"=",
"[",
"]",
")",
":",
"for",
"command",
"in",
"prev_commands",
":",
"for",
"my_input",
"in",
"self",
".",
"input_parts",
":",
"for",
"their_output",
"in",
"command",
".",
"output_parts",
... | Update the command's dependencies based on the evaluated input and
output of previous commands. | [
"Update",
"the",
"command",
"s",
"dependencies",
"based",
"on",
"the",
"evaluated",
"input",
"and",
"output",
"of",
"previous",
"commands",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/command.py#L66-L74 | train |
TorkamaniLab/metapipe | metapipe/models/command.py | Command.eval | def eval(self):
""" Evaluate the given job and return a complete shell script to be run
by the job manager.
"""
eval = []
for part in self.parts:
try:
result = part.eval()
except AttributeError:
result = part
if ... | python | def eval(self):
""" Evaluate the given job and return a complete shell script to be run
by the job manager.
"""
eval = []
for part in self.parts:
try:
result = part.eval()
except AttributeError:
result = part
if ... | [
"def",
"eval",
"(",
"self",
")",
":",
"eval",
"=",
"[",
"]",
"for",
"part",
"in",
"self",
".",
"parts",
":",
"try",
":",
"result",
"=",
"part",
".",
"eval",
"(",
")",
"except",
"AttributeError",
":",
"result",
"=",
"part",
"if",
"result",
"[",
"-... | Evaluate the given job and return a complete shell script to be run
by the job manager. | [
"Evaluate",
"the",
"given",
"job",
"and",
"return",
"a",
"complete",
"shell",
"script",
"to",
"be",
"run",
"by",
"the",
"job",
"manager",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/command.py#L76-L89 | train |
JukeboxPipeline/jukeboxmaya | src/jukeboxmaya/mayaplugins/jbreftrack.py | JB_ReftrackNode.add_type | def add_type(cls, typ):
"""Register a type for jb_reftrack nodes.
A type specifies how the reference should be handled. For example the type shader will connect shaders
with the parent when it the shaders are loaded.
Default types are :data:`JB_ReftrackNode.types`.
.. Note:: Yo... | python | def add_type(cls, typ):
"""Register a type for jb_reftrack nodes.
A type specifies how the reference should be handled. For example the type shader will connect shaders
with the parent when it the shaders are loaded.
Default types are :data:`JB_ReftrackNode.types`.
.. Note:: Yo... | [
"def",
"add_type",
"(",
"cls",
",",
"typ",
")",
":",
"if",
"not",
"isinstance",
"(",
"typ",
",",
"basestring",
")",
":",
"raise",
"TypeError",
"(",
"\"The type should be a string. But is %s\"",
"%",
"type",
"(",
"typ",
")",
")",
"cls",
".",
"types",
".",
... | Register a type for jb_reftrack nodes.
A type specifies how the reference should be handled. For example the type shader will connect shaders
with the parent when it the shaders are loaded.
Default types are :data:`JB_ReftrackNode.types`.
.. Note:: You have to add types before you init... | [
"Register",
"a",
"type",
"for",
"jb_reftrack",
"nodes",
"."
] | c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c | https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/mayaplugins/jbreftrack.py#L79-L96 | train |
FriendCode/funky | funky/funky.py | transform | def transform(transform_func):
"""Apply a transformation to a functions return value"""
def decorator(func):
@wraps(func)
def f(*args, **kwargs):
return transform_func(
func(*args, **kwargs)
)
return f
return decorator | python | def transform(transform_func):
"""Apply a transformation to a functions return value"""
def decorator(func):
@wraps(func)
def f(*args, **kwargs):
return transform_func(
func(*args, **kwargs)
)
return f
return decorator | [
"def",
"transform",
"(",
"transform_func",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"f",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"return",
"transform_func",
"(",
"func",
"(",
"*",
"args",
... | Apply a transformation to a functions return value | [
"Apply",
"a",
"transformation",
"to",
"a",
"functions",
"return",
"value"
] | 25450a61d531c97615384fc5ef80e4eee97200ac | https://github.com/FriendCode/funky/blob/25450a61d531c97615384fc5ef80e4eee97200ac/funky/funky.py#L193-L202 | train |
FriendCode/funky | funky/funky.py | subkey | def subkey(dct, keys):
"""Get an entry from a dict of dicts by the list of keys to 'follow'
"""
key = keys[0]
if len(keys) == 1:
return dct[key]
return subkey(dct[key], keys[1:]) | python | def subkey(dct, keys):
"""Get an entry from a dict of dicts by the list of keys to 'follow'
"""
key = keys[0]
if len(keys) == 1:
return dct[key]
return subkey(dct[key], keys[1:]) | [
"def",
"subkey",
"(",
"dct",
",",
"keys",
")",
":",
"key",
"=",
"keys",
"[",
"0",
"]",
"if",
"len",
"(",
"keys",
")",
"==",
"1",
":",
"return",
"dct",
"[",
"key",
"]",
"return",
"subkey",
"(",
"dct",
"[",
"key",
"]",
",",
"keys",
"[",
"1",
... | Get an entry from a dict of dicts by the list of keys to 'follow' | [
"Get",
"an",
"entry",
"from",
"a",
"dict",
"of",
"dicts",
"by",
"the",
"list",
"of",
"keys",
"to",
"follow"
] | 25450a61d531c97615384fc5ef80e4eee97200ac | https://github.com/FriendCode/funky/blob/25450a61d531c97615384fc5ef80e4eee97200ac/funky/funky.py#L257-L263 | train |
sirfoga/pyhal | hal/internet/services/google/gauthenticator.py | GoogleApiOAuth.get_driver | def get_driver(self, name, version):
"""Authenticates and creates new API driver to perform scope stuff
:param name: Name of driver
:param version: Version of driver
:return: driver
"""
user_credentials = self.get_user_credentials() # get credentials
return disc... | python | def get_driver(self, name, version):
"""Authenticates and creates new API driver to perform scope stuff
:param name: Name of driver
:param version: Version of driver
:return: driver
"""
user_credentials = self.get_user_credentials() # get credentials
return disc... | [
"def",
"get_driver",
"(",
"self",
",",
"name",
",",
"version",
")",
":",
"user_credentials",
"=",
"self",
".",
"get_user_credentials",
"(",
")",
"return",
"discovery",
".",
"build",
"(",
"name",
",",
"version",
",",
"http",
"=",
"self",
".",
"authenticate"... | Authenticates and creates new API driver to perform scope stuff
:param name: Name of driver
:param version: Version of driver
:return: driver | [
"Authenticates",
"and",
"creates",
"new",
"API",
"driver",
"to",
"perform",
"scope",
"stuff"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/services/google/gauthenticator.py#L69-L80 | train |
portfors-lab/sparkle | sparkle/run/chart_runner.py | ChartRunner.start_chart | def start_chart(self):
"""Begin on-going chart style acqusition"""
self.current_dataset_name = self.chart_name
self.datafile.init_data(self.current_dataset_name, mode='continuous')
self.chart_name = increment_title(self.chart_name)
# stimulus tracker channel hard-coded a... | python | def start_chart(self):
"""Begin on-going chart style acqusition"""
self.current_dataset_name = self.chart_name
self.datafile.init_data(self.current_dataset_name, mode='continuous')
self.chart_name = increment_title(self.chart_name)
# stimulus tracker channel hard-coded a... | [
"def",
"start_chart",
"(",
"self",
")",
":",
"self",
".",
"current_dataset_name",
"=",
"self",
".",
"chart_name",
"self",
".",
"datafile",
".",
"init_data",
"(",
"self",
".",
"current_dataset_name",
",",
"mode",
"=",
"'continuous'",
")",
"self",
".",
"chart_... | Begin on-going chart style acqusition | [
"Begin",
"on",
"-",
"going",
"chart",
"style",
"acqusition"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/run/chart_runner.py#L18-L25 | train |
portfors-lab/sparkle | sparkle/tools/qtdoc.py | qtdoc_role | def qtdoc_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Links to a Qt class's doc
Returns 2 part tuple containing list of nodes to insert into the
document and a list of system messages. Both are allowed to be
empty.
:param name: The role name used in the document.
:p... | python | def qtdoc_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Links to a Qt class's doc
Returns 2 part tuple containing list of nodes to insert into the
document and a list of system messages. Both are allowed to be
empty.
:param name: The role name used in the document.
:p... | [
"def",
"qtdoc_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"{",
"}",
",",
"content",
"=",
"[",
"]",
")",
":",
"base",
"=",
"'http://qt-project.org/doc/qt-4.8/'",
"match",
"=",
"re",
".",
"search",
... | Links to a Qt class's doc
Returns 2 part tuple containing list of nodes to insert into the
document and a list of system messages. Both are allowed to be
empty.
:param name: The role name used in the document.
:param rawtext: The entire markup snippet, with role.
:param text: The text marked ... | [
"Links",
"to",
"a",
"Qt",
"class",
"s",
"doc"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/tools/qtdoc.py#L9-L41 | train |
NoviceLive/intellicoder | intellicoder/transformers.py | update_func_body | def update_func_body(original, updater=None):
"""Update all function body using the updating function."""
updated = ''
regex = r'([_\w][_\w\d]*)\s*\(.*\)\s*\{'
match = re.search(regex, original)
while match:
name = match.group(1)
logging.debug(_('Found candidate: %s'), name)
... | python | def update_func_body(original, updater=None):
"""Update all function body using the updating function."""
updated = ''
regex = r'([_\w][_\w\d]*)\s*\(.*\)\s*\{'
match = re.search(regex, original)
while match:
name = match.group(1)
logging.debug(_('Found candidate: %s'), name)
... | [
"def",
"update_func_body",
"(",
"original",
",",
"updater",
"=",
"None",
")",
":",
"updated",
"=",
"''",
"regex",
"=",
"r'([_\\w][_\\w\\d]*)\\s*\\(.*\\)\\s*\\{'",
"match",
"=",
"re",
".",
"search",
"(",
"regex",
",",
"original",
")",
"while",
"match",
":",
"... | Update all function body using the updating function. | [
"Update",
"all",
"function",
"body",
"using",
"the",
"updating",
"function",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/transformers.py#L272-L288 | train |
NoviceLive/intellicoder | intellicoder/transformers.py | find_balance_index | def find_balance_index(source, start='{', end='}'):
"""Get the first balance index."""
state = 1
for index, char in enumerate(source):
if char == start:
state += 1
elif char == end:
state -= 1
if state == 0:
return index
raise RuntimeError('Thi... | python | def find_balance_index(source, start='{', end='}'):
"""Get the first balance index."""
state = 1
for index, char in enumerate(source):
if char == start:
state += 1
elif char == end:
state -= 1
if state == 0:
return index
raise RuntimeError('Thi... | [
"def",
"find_balance_index",
"(",
"source",
",",
"start",
"=",
"'{'",
",",
"end",
"=",
"'}'",
")",
":",
"state",
"=",
"1",
"for",
"index",
",",
"char",
"in",
"enumerate",
"(",
"source",
")",
":",
"if",
"char",
"==",
"start",
":",
"state",
"+=",
"1"... | Get the first balance index. | [
"Get",
"the",
"first",
"balance",
"index",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/transformers.py#L291-L301 | train |
NoviceLive/intellicoder | intellicoder/transformers.py | WindowsTransformer.transform_sources | def transform_sources(self, sources, with_string=False):
"""Get the defintions of needed strings and functions
after replacement.
"""
modules = {}
updater = partial(
self.replace_source, modules=modules, prefix='string_')
for filename in sources:
u... | python | def transform_sources(self, sources, with_string=False):
"""Get the defintions of needed strings and functions
after replacement.
"""
modules = {}
updater = partial(
self.replace_source, modules=modules, prefix='string_')
for filename in sources:
u... | [
"def",
"transform_sources",
"(",
"self",
",",
"sources",
",",
"with_string",
"=",
"False",
")",
":",
"modules",
"=",
"{",
"}",
"updater",
"=",
"partial",
"(",
"self",
".",
"replace_source",
",",
"modules",
"=",
"modules",
",",
"prefix",
"=",
"'string_'",
... | Get the defintions of needed strings and functions
after replacement. | [
"Get",
"the",
"defintions",
"of",
"needed",
"strings",
"and",
"functions",
"after",
"replacement",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/transformers.py#L80-L91 | train |
NoviceLive/intellicoder | intellicoder/transformers.py | WindowsTransformer.replace_source | def replace_source(self, source, name, modules, prefix):
"""Scan C source code for string literals as well as
function calls and do replacement using the specified
replacing function.
Note that the regular expression currently used for strings
is naive or quick and dirty.
... | python | def replace_source(self, source, name, modules, prefix):
"""Scan C source code for string literals as well as
function calls and do replacement using the specified
replacing function.
Note that the regular expression currently used for strings
is naive or quick and dirty.
... | [
"def",
"replace_source",
"(",
"self",
",",
"source",
",",
"name",
",",
"modules",
",",
"prefix",
")",
":",
"needs_windll",
"=",
"False",
"def",
"_func_replacer",
"(",
"match",
",",
"modules",
",",
"windll",
")",
":",
"matched",
"=",
"match",
".",
"group"... | Scan C source code for string literals as well as
function calls and do replacement using the specified
replacing function.
Note that the regular expression currently used for strings
is naive or quick and dirty. | [
"Scan",
"C",
"source",
"code",
"for",
"string",
"literals",
"as",
"well",
"as",
"function",
"calls",
"and",
"do",
"replacement",
"using",
"the",
"specified",
"replacing",
"function",
".",
"Note",
"that",
"the",
"regular",
"expression",
"currently",
"used",
"fo... | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/transformers.py#L93-L155 | train |
NoviceLive/intellicoder | intellicoder/transformers.py | WindowsTransformer.build_funcs | def build_funcs(modules):
"""Build a used functions and modules list
for later consumption.
"""
kernel32 = ['kernel32_']
try:
kernel32 += remove_dups(modules['kernel32'])
except KeyError:
if len(modules) and 'LoadLibraryA' not in kernel32:
... | python | def build_funcs(modules):
"""Build a used functions and modules list
for later consumption.
"""
kernel32 = ['kernel32_']
try:
kernel32 += remove_dups(modules['kernel32'])
except KeyError:
if len(modules) and 'LoadLibraryA' not in kernel32:
... | [
"def",
"build_funcs",
"(",
"modules",
")",
":",
"kernel32",
"=",
"[",
"'kernel32_'",
"]",
"try",
":",
"kernel32",
"+=",
"remove_dups",
"(",
"modules",
"[",
"'kernel32'",
"]",
")",
"except",
"KeyError",
":",
"if",
"len",
"(",
"modules",
")",
"and",
"'Load... | Build a used functions and modules list
for later consumption. | [
"Build",
"a",
"used",
"functions",
"and",
"modules",
"list",
"for",
"later",
"consumption",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/transformers.py#L158-L177 | train |
NoviceLive/intellicoder | intellicoder/transformers.py | WindowsTransformer.build_strings | def build_strings(strings, prefix):
"""Construct string definitions according to
the previously maintained table.
"""
strings = [
(
make_c_str(prefix + str(number), value),
reloc_ptr(
prefix + str(number), 'reloc_delta', 'ch... | python | def build_strings(strings, prefix):
"""Construct string definitions according to
the previously maintained table.
"""
strings = [
(
make_c_str(prefix + str(number), value),
reloc_ptr(
prefix + str(number), 'reloc_delta', 'ch... | [
"def",
"build_strings",
"(",
"strings",
",",
"prefix",
")",
":",
"strings",
"=",
"[",
"(",
"make_c_str",
"(",
"prefix",
"+",
"str",
"(",
"number",
")",
",",
"value",
")",
",",
"reloc_ptr",
"(",
"prefix",
"+",
"str",
"(",
"number",
")",
",",
"'reloc_d... | Construct string definitions according to
the previously maintained table. | [
"Construct",
"string",
"definitions",
"according",
"to",
"the",
"previously",
"maintained",
"table",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/transformers.py#L180-L192 | train |
IS-ENES-Data/esgf-pid | esgfpid/assistant/publish.py | DatasetPublicationAssistant.add_file | def add_file(self, **args):
'''
Adds a file's information to the set of files to be
published in this dataset.
:param file_name: Mandatory. The file name (string).
This information will simply be included in the
PID record, but not used for anything.
:pa... | python | def add_file(self, **args):
'''
Adds a file's information to the set of files to be
published in this dataset.
:param file_name: Mandatory. The file name (string).
This information will simply be included in the
PID record, but not used for anything.
:pa... | [
"def",
"add_file",
"(",
"self",
",",
"**",
"args",
")",
":",
"self",
".",
"__check_if_adding_files_allowed_right_now",
"(",
")",
"mandatory_args",
"=",
"[",
"'file_name'",
",",
"'file_handle'",
",",
"'file_size'",
",",
"'checksum'",
",",
"'publish_path'",
",",
"... | Adds a file's information to the set of files to be
published in this dataset.
:param file_name: Mandatory. The file name (string).
This information will simply be included in the
PID record, but not used for anything.
:param file_handle: Mandatory. The handle (PID) of
... | [
"Adds",
"a",
"file",
"s",
"information",
"to",
"the",
"set",
"of",
"files",
"to",
"be",
"published",
"in",
"this",
"dataset",
"."
] | 2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41 | https://github.com/IS-ENES-Data/esgf-pid/blob/2f4909bb3ff79c0b6ed2932e0dd8b3bb6aec5e41/esgfpid/assistant/publish.py#L119-L177 | train |
NoviceLive/intellicoder | intellicoder/utils.py | run_program | def run_program(program, *args):
"""Wrap subprocess.check_output to make life easier."""
real_args = [program]
real_args.extend(args)
logging.debug(_('check_output arguments: %s'), real_args)
check_output(real_args, universal_newlines=True) | python | def run_program(program, *args):
"""Wrap subprocess.check_output to make life easier."""
real_args = [program]
real_args.extend(args)
logging.debug(_('check_output arguments: %s'), real_args)
check_output(real_args, universal_newlines=True) | [
"def",
"run_program",
"(",
"program",
",",
"*",
"args",
")",
":",
"real_args",
"=",
"[",
"program",
"]",
"real_args",
".",
"extend",
"(",
"args",
")",
"logging",
".",
"debug",
"(",
"_",
"(",
"'check_output arguments: %s'",
")",
",",
"real_args",
")",
"ch... | Wrap subprocess.check_output to make life easier. | [
"Wrap",
"subprocess",
".",
"check_output",
"to",
"make",
"life",
"easier",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L57-L62 | train |
NoviceLive/intellicoder | intellicoder/utils.py | get_parent_dir | def get_parent_dir(name):
"""Get the parent directory of a filename."""
parent_dir = os.path.dirname(os.path.dirname(name))
if parent_dir:
return parent_dir
return os.path.abspath('.') | python | def get_parent_dir(name):
"""Get the parent directory of a filename."""
parent_dir = os.path.dirname(os.path.dirname(name))
if parent_dir:
return parent_dir
return os.path.abspath('.') | [
"def",
"get_parent_dir",
"(",
"name",
")",
":",
"parent_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"name",
")",
")",
"if",
"parent_dir",
":",
"return",
"parent_dir",
"return",
"os",
".",
"path",
".",
"a... | Get the parent directory of a filename. | [
"Get",
"the",
"parent",
"directory",
"of",
"a",
"filename",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L76-L81 | train |
NoviceLive/intellicoder | intellicoder/utils.py | split_ext | def split_ext(path, basename=True):
"""Wrap them to make life easier."""
if basename:
path = os.path.basename(path)
return os.path.splitext(path) | python | def split_ext(path, basename=True):
"""Wrap them to make life easier."""
if basename:
path = os.path.basename(path)
return os.path.splitext(path) | [
"def",
"split_ext",
"(",
"path",
",",
"basename",
"=",
"True",
")",
":",
"if",
"basename",
":",
"path",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"return",
"os",
".",
"path",
".",
"splitext",
"(",
"path",
")"
] | Wrap them to make life easier. | [
"Wrap",
"them",
"to",
"make",
"life",
"easier",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L105-L109 | train |
NoviceLive/intellicoder | intellicoder/utils.py | ad_hoc_magic_from_file | def ad_hoc_magic_from_file(filename, **kwargs):
"""Ad-hoc emulation of magic.from_file from python-magic."""
with open(filename, 'rb') as stream:
head = stream.read(16)
if head[:4] == b'\x7fELF':
return b'application/x-executable'
elif head[:2] == b'MZ':
return b'... | python | def ad_hoc_magic_from_file(filename, **kwargs):
"""Ad-hoc emulation of magic.from_file from python-magic."""
with open(filename, 'rb') as stream:
head = stream.read(16)
if head[:4] == b'\x7fELF':
return b'application/x-executable'
elif head[:2] == b'MZ':
return b'... | [
"def",
"ad_hoc_magic_from_file",
"(",
"filename",
",",
"**",
"kwargs",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"stream",
":",
"head",
"=",
"stream",
".",
"read",
"(",
"16",
")",
"if",
"head",
"[",
":",
"4",
"]",
"==",
"b'... | Ad-hoc emulation of magic.from_file from python-magic. | [
"Ad",
"-",
"hoc",
"emulation",
"of",
"magic",
".",
"from_file",
"from",
"python",
"-",
"magic",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L113-L122 | train |
NoviceLive/intellicoder | intellicoder/utils.py | expand_path | def expand_path(*paths):
"""Expand the path with the directory of the executed file."""
return os.path.join(
os.path.dirname(os.path.realpath(sys.argv[0])), *paths) | python | def expand_path(*paths):
"""Expand the path with the directory of the executed file."""
return os.path.join(
os.path.dirname(os.path.realpath(sys.argv[0])), *paths) | [
"def",
"expand_path",
"(",
"*",
"paths",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"sys",
".",
"argv",
"[",
"0",
"]",
")",
")",
",",
"*",
"paths",
... | Expand the path with the directory of the executed file. | [
"Expand",
"the",
"path",
"with",
"the",
"directory",
"of",
"the",
"executed",
"file",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L125-L128 | train |
NoviceLive/intellicoder | intellicoder/utils.py | translate_filenames | def translate_filenames(filenames):
"""Convert filenames from Linux to Windows."""
if is_windows():
return filenames
for index, filename in enumerate(filenames):
filenames[index] = vboxsf_to_windows(filename) | python | def translate_filenames(filenames):
"""Convert filenames from Linux to Windows."""
if is_windows():
return filenames
for index, filename in enumerate(filenames):
filenames[index] = vboxsf_to_windows(filename) | [
"def",
"translate_filenames",
"(",
"filenames",
")",
":",
"if",
"is_windows",
"(",
")",
":",
"return",
"filenames",
"for",
"index",
",",
"filename",
"in",
"enumerate",
"(",
"filenames",
")",
":",
"filenames",
"[",
"index",
"]",
"=",
"vboxsf_to_windows",
"(",... | Convert filenames from Linux to Windows. | [
"Convert",
"filenames",
"from",
"Linux",
"to",
"Windows",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L166-L171 | train |
NoviceLive/intellicoder | intellicoder/utils.py | vboxsf_to_windows | def vboxsf_to_windows(filename, letter='f:'):
"""Convert the Linux path name to a Windows one."""
home = os.path.expanduser('~')
filename = os.path.abspath(filename).replace(home, letter)
return filename.replace('/', '\\') | python | def vboxsf_to_windows(filename, letter='f:'):
"""Convert the Linux path name to a Windows one."""
home = os.path.expanduser('~')
filename = os.path.abspath(filename).replace(home, letter)
return filename.replace('/', '\\') | [
"def",
"vboxsf_to_windows",
"(",
"filename",
",",
"letter",
"=",
"'f:'",
")",
":",
"home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
".",
"replace",
"(",
"hom... | Convert the Linux path name to a Windows one. | [
"Convert",
"the",
"Linux",
"path",
"name",
"to",
"a",
"Windows",
"one",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L174-L178 | train |
NoviceLive/intellicoder | intellicoder/utils.py | read_files | def read_files(filenames, with_name=False):
"""Read many files."""
text = [read_file(filename) for filename in filenames]
if with_name:
return dict(zip(filenames, text))
return text | python | def read_files(filenames, with_name=False):
"""Read many files."""
text = [read_file(filename) for filename in filenames]
if with_name:
return dict(zip(filenames, text))
return text | [
"def",
"read_files",
"(",
"filenames",
",",
"with_name",
"=",
"False",
")",
":",
"text",
"=",
"[",
"read_file",
"(",
"filename",
")",
"for",
"filename",
"in",
"filenames",
"]",
"if",
"with_name",
":",
"return",
"dict",
"(",
"zip",
"(",
"filenames",
",",
... | Read many files. | [
"Read",
"many",
"files",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L181-L186 | train |
NoviceLive/intellicoder | intellicoder/utils.py | write_files | def write_files(text, where='.'):
"""Write many files."""
for filename in text:
target = os.path.join(where, filename)
write_file(target, text[filename]) | python | def write_files(text, where='.'):
"""Write many files."""
for filename in text:
target = os.path.join(where, filename)
write_file(target, text[filename]) | [
"def",
"write_files",
"(",
"text",
",",
"where",
"=",
"'.'",
")",
":",
"for",
"filename",
"in",
"text",
":",
"target",
"=",
"os",
".",
"path",
".",
"join",
"(",
"where",
",",
"filename",
")",
"write_file",
"(",
"target",
",",
"text",
"[",
"filename",... | Write many files. | [
"Write",
"many",
"files",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L189-L193 | train |
NoviceLive/intellicoder | intellicoder/utils.py | write_file | def write_file(filename, text):
"""Write text to a file."""
logging.debug(_('Writing file: %s'), filename)
try:
with open(filename, 'w') as writable:
writable.write(text)
except (PermissionError, NotADirectoryError):
logging.error(_('Error writing file: %s'), filename)
... | python | def write_file(filename, text):
"""Write text to a file."""
logging.debug(_('Writing file: %s'), filename)
try:
with open(filename, 'w') as writable:
writable.write(text)
except (PermissionError, NotADirectoryError):
logging.error(_('Error writing file: %s'), filename)
... | [
"def",
"write_file",
"(",
"filename",
",",
"text",
")",
":",
"logging",
".",
"debug",
"(",
"_",
"(",
"'Writing file: %s'",
")",
",",
"filename",
")",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"writable",
":",
"writable",
".",
... | Write text to a file. | [
"Write",
"text",
"to",
"a",
"file",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L196-L205 | train |
NoviceLive/intellicoder | intellicoder/utils.py | stylify_files | def stylify_files(text):
"""Stylify many files."""
for filename in text:
text[filename] = stylify_code(text[filename])
return text | python | def stylify_files(text):
"""Stylify many files."""
for filename in text:
text[filename] = stylify_code(text[filename])
return text | [
"def",
"stylify_files",
"(",
"text",
")",
":",
"for",
"filename",
"in",
"text",
":",
"text",
"[",
"filename",
"]",
"=",
"stylify_code",
"(",
"text",
"[",
"filename",
"]",
")",
"return",
"text"
] | Stylify many files. | [
"Stylify",
"many",
"files",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L208-L212 | train |
NoviceLive/intellicoder | intellicoder/utils.py | stylify_code | def stylify_code(code):
"""Stylify the C source code using astyle."""
try:
output = check_output(
['astyle', '--max-code-length=69', '--indent=spaces=2'],
universal_newlines=True, input=code
)
except (OSError, CalledProcessError, TypeError):
logging.debug(_('f... | python | def stylify_code(code):
"""Stylify the C source code using astyle."""
try:
output = check_output(
['astyle', '--max-code-length=69', '--indent=spaces=2'],
universal_newlines=True, input=code
)
except (OSError, CalledProcessError, TypeError):
logging.debug(_('f... | [
"def",
"stylify_code",
"(",
"code",
")",
":",
"try",
":",
"output",
"=",
"check_output",
"(",
"[",
"'astyle'",
",",
"'--max-code-length=69'",
",",
"'--indent=spaces=2'",
"]",
",",
"universal_newlines",
"=",
"True",
",",
"input",
"=",
"code",
")",
"except",
"... | Stylify the C source code using astyle. | [
"Stylify",
"the",
"C",
"source",
"code",
"using",
"astyle",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L215-L225 | train |
NoviceLive/intellicoder | intellicoder/utils.py | sort_item | def sort_item(iterable, number, reverse=False):
"""Sort the itertable according to the given number item."""
return sorted(iterable, key=itemgetter(number), reverse=reverse) | python | def sort_item(iterable, number, reverse=False):
"""Sort the itertable according to the given number item."""
return sorted(iterable, key=itemgetter(number), reverse=reverse) | [
"def",
"sort_item",
"(",
"iterable",
",",
"number",
",",
"reverse",
"=",
"False",
")",
":",
"return",
"sorted",
"(",
"iterable",
",",
"key",
"=",
"itemgetter",
"(",
"number",
")",
",",
"reverse",
"=",
"reverse",
")"
] | Sort the itertable according to the given number item. | [
"Sort",
"the",
"itertable",
"according",
"to",
"the",
"given",
"number",
"item",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L233-L235 | train |
NoviceLive/intellicoder | intellicoder/utils.py | remove_by | def remove_by(keys, original):
"""Remove items in a list according to another list."""
for i in [
original[index]
for index, needed in enumerate(keys) if not needed
]:
original.remove(i) | python | def remove_by(keys, original):
"""Remove items in a list according to another list."""
for i in [
original[index]
for index, needed in enumerate(keys) if not needed
]:
original.remove(i) | [
"def",
"remove_by",
"(",
"keys",
",",
"original",
")",
":",
"for",
"i",
"in",
"[",
"original",
"[",
"index",
"]",
"for",
"index",
",",
"needed",
"in",
"enumerate",
"(",
"keys",
")",
"if",
"not",
"needed",
"]",
":",
"original",
".",
"remove",
"(",
"... | Remove items in a list according to another list. | [
"Remove",
"items",
"in",
"a",
"list",
"according",
"to",
"another",
"list",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L262-L268 | train |
NoviceLive/intellicoder | intellicoder/utils.py | group_by | def group_by(iterable, key_func):
"""Wrap itertools.groupby to make life easier."""
groups = (
list(sub) for key, sub in groupby(iterable, key_func)
)
return zip(groups, groups) | python | def group_by(iterable, key_func):
"""Wrap itertools.groupby to make life easier."""
groups = (
list(sub) for key, sub in groupby(iterable, key_func)
)
return zip(groups, groups) | [
"def",
"group_by",
"(",
"iterable",
",",
"key_func",
")",
":",
"groups",
"=",
"(",
"list",
"(",
"sub",
")",
"for",
"key",
",",
"sub",
"in",
"groupby",
"(",
"iterable",
",",
"key_func",
")",
")",
"return",
"zip",
"(",
"groups",
",",
"groups",
")"
] | Wrap itertools.groupby to make life easier. | [
"Wrap",
"itertools",
".",
"groupby",
"to",
"make",
"life",
"easier",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/utils.py#L271-L276 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.