repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | chooseBestDuplicates | def chooseBestDuplicates(tped, samples, oldSamples, completion,
concordance_all, prefix):
"""Choose the best duplicates according to the completion rate.
:param tped: the ``tped`` containing the duplicated samples.
:param samples: the updated position of the samples in the tped con... | python | def chooseBestDuplicates(tped, samples, oldSamples, completion,
concordance_all, prefix):
"""Choose the best duplicates according to the completion rate.
:param tped: the ``tped`` containing the duplicated samples.
:param samples: the updated position of the samples in the tped con... | [
"def",
"chooseBestDuplicates",
"(",
"tped",
",",
"samples",
",",
"oldSamples",
",",
"completion",
",",
"concordance_all",
",",
"prefix",
")",
":",
"# The output files",
"chosenFile",
"=",
"None",
"try",
":",
"chosenFile",
"=",
"open",
"(",
"prefix",
"+",
"\".c... | Choose the best duplicates according to the completion rate.
:param tped: the ``tped`` containing the duplicated samples.
:param samples: the updated position of the samples in the tped containing
only duplicated samples.
:param oldSamples: the original duplicated sample positions.
... | [
"Choose",
"the",
"best",
"duplicates",
"according",
"to",
"the",
"completion",
"rate",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L434-L562 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | printDuplicatedTPEDandTFAM | def printDuplicatedTPEDandTFAM(tped, tfam, samples, oldSamples, prefix):
"""Print the TPED and TFAM of the duplicated samples.
:param tped: the ``tped`` containing duplicated samples.
:param tfam: the ``tfam`` containing duplicated samples.
:param samples: the updated position of the samples in the tpe... | python | def printDuplicatedTPEDandTFAM(tped, tfam, samples, oldSamples, prefix):
"""Print the TPED and TFAM of the duplicated samples.
:param tped: the ``tped`` containing duplicated samples.
:param tfam: the ``tfam`` containing duplicated samples.
:param samples: the updated position of the samples in the tpe... | [
"def",
"printDuplicatedTPEDandTFAM",
"(",
"tped",
",",
"tfam",
",",
"samples",
",",
"oldSamples",
",",
"prefix",
")",
":",
"# Print the TPED",
"outputTPED",
"=",
"None",
"try",
":",
"outputTPED",
"=",
"open",
"(",
"prefix",
"+",
"\".duplicated_samples.tped\"",
"... | Print the TPED and TFAM of the duplicated samples.
:param tped: the ``tped`` containing duplicated samples.
:param tfam: the ``tfam`` containing duplicated samples.
:param samples: the updated position of the samples in the tped containing
only duplicated samples.
:param oldSamples:... | [
"Print",
"the",
"TPED",
"and",
"TFAM",
"of",
"the",
"duplicated",
"samples",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L565-L615 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | printConcordance | def printConcordance(concordance, prefix):
"""Print the concordance.
:param concordance: the concordance of each sample.
:param prefix: the prefix of all the files.
:type concordance: dict
:type prefix: str
:returns: the concordance percentage (dict)
The concordance is the number of geno... | python | def printConcordance(concordance, prefix):
"""Print the concordance.
:param concordance: the concordance of each sample.
:param prefix: the prefix of all the files.
:type concordance: dict
:type prefix: str
:returns: the concordance percentage (dict)
The concordance is the number of geno... | [
"def",
"printConcordance",
"(",
"concordance",
",",
"prefix",
")",
":",
"outFile",
"=",
"None",
"try",
":",
"outFile",
"=",
"open",
"(",
"prefix",
"+",
"\".concordance\"",
",",
"\"w\"",
")",
"except",
"IOError",
":",
"msg",
"=",
"\"%s: can't write file\"",
"... | Print the concordance.
:param concordance: the concordance of each sample.
:param prefix: the prefix of all the files.
:type concordance: dict
:type prefix: str
:returns: the concordance percentage (dict)
The concordance is the number of genotypes that are equal when comparing a
duplicat... | [
"Print",
"the",
"concordance",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L618-L666 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | printStatistics | def printStatistics(completion, concordance, tpedSamples, oldSamples, prefix):
"""Print the statistics in a file.
:param completion: the completion of each duplicated samples.
:param concordance: the concordance of each duplicated samples.
:param tpedSamples: the updated position of the samples in the ... | python | def printStatistics(completion, concordance, tpedSamples, oldSamples, prefix):
"""Print the statistics in a file.
:param completion: the completion of each duplicated samples.
:param concordance: the concordance of each duplicated samples.
:param tpedSamples: the updated position of the samples in the ... | [
"def",
"printStatistics",
"(",
"completion",
",",
"concordance",
",",
"tpedSamples",
",",
"oldSamples",
",",
"prefix",
")",
":",
"# Compute the completion percentage on none zero values",
"none_zero_indexes",
"=",
"np",
".",
"where",
"(",
"completion",
"[",
"1",
"]",
... | Print the statistics in a file.
:param completion: the completion of each duplicated samples.
:param concordance: the concordance of each duplicated samples.
:param tpedSamples: the updated position of the samples in the tped
containing only duplicated samples.
:param oldSamples... | [
"Print",
"the",
"statistics",
"in",
"a",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L669-L746 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | computeStatistics | def computeStatistics(tped, tfam, samples, oldSamples, prefix):
"""Computes the completion and concordance of each samples.
:param tped: the ``tped`` containing duplicated samples.
:param tfam: the ``tfam`` containing duplicated samples.
:param samples: the updated position of the samples in the tped c... | python | def computeStatistics(tped, tfam, samples, oldSamples, prefix):
"""Computes the completion and concordance of each samples.
:param tped: the ``tped`` containing duplicated samples.
:param tfam: the ``tfam`` containing duplicated samples.
:param samples: the updated position of the samples in the tped c... | [
"def",
"computeStatistics",
"(",
"tped",
",",
"tfam",
",",
"samples",
",",
"oldSamples",
",",
"prefix",
")",
":",
"# The diff file containing the genotype differences between a pair of",
"# duplicated samples",
"diffOutput",
"=",
"None",
"try",
":",
"diffOutput",
"=",
"... | Computes the completion and concordance of each samples.
:param tped: the ``tped`` containing duplicated samples.
:param tfam: the ``tfam`` containing duplicated samples.
:param samples: the updated position of the samples in the tped containing
only duplicated samples.
:param oldSa... | [
"Computes",
"the",
"completion",
"and",
"concordance",
"of",
"each",
"samples",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L749-L920 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | processTPED | def processTPED(uniqueSamples, duplicatedSamples, fileName, prefix):
"""Process the TPED file.
:param uniqueSamples: the position of unique samples.
:param duplicatedSamples: the position of duplicated samples.
:param fileName: the name of the file.
:param prefix: the prefix of all the files.
... | python | def processTPED(uniqueSamples, duplicatedSamples, fileName, prefix):
"""Process the TPED file.
:param uniqueSamples: the position of unique samples.
:param duplicatedSamples: the position of duplicated samples.
:param fileName: the name of the file.
:param prefix: the prefix of all the files.
... | [
"def",
"processTPED",
"(",
"uniqueSamples",
",",
"duplicatedSamples",
",",
"fileName",
",",
"prefix",
")",
":",
"# Getting the indexes",
"uI",
"=",
"sorted",
"(",
"uniqueSamples",
".",
"values",
"(",
")",
")",
"dI",
"=",
"[",
"]",
"for",
"item",
"in",
"dup... | Process the TPED file.
:param uniqueSamples: the position of unique samples.
:param duplicatedSamples: the position of duplicated samples.
:param fileName: the name of the file.
:param prefix: the prefix of all the files.
:type uniqueSamples: dict
:type duplicatedSamples: collections.defaultdi... | [
"Process",
"the",
"TPED",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L923-L985 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | printUniqueTFAM | def printUniqueTFAM(tfam, samples, prefix):
"""Prints a new TFAM with only unique samples.
:param tfam: a representation of a TFAM file.
:param samples: the position of the samples
:param prefix: the prefix of the output file name
:type tfam: list
:type samples: dict
:type prefix: str
... | python | def printUniqueTFAM(tfam, samples, prefix):
"""Prints a new TFAM with only unique samples.
:param tfam: a representation of a TFAM file.
:param samples: the position of the samples
:param prefix: the prefix of the output file name
:type tfam: list
:type samples: dict
:type prefix: str
... | [
"def",
"printUniqueTFAM",
"(",
"tfam",
",",
"samples",
",",
"prefix",
")",
":",
"fileName",
"=",
"prefix",
"+",
"\".unique_samples.tfam\"",
"try",
":",
"with",
"open",
"(",
"fileName",
",",
"\"w\"",
")",
"as",
"outputFile",
":",
"for",
"i",
"in",
"sorted",... | Prints a new TFAM with only unique samples.
:param tfam: a representation of a TFAM file.
:param samples: the position of the samples
:param prefix: the prefix of the output file name
:type tfam: list
:type samples: dict
:type prefix: str | [
"Prints",
"a",
"new",
"TFAM",
"with",
"only",
"unique",
"samples",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L988-L1007 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | findDuplicates | def findDuplicates(tfam):
"""Finds the duplicates in a TFAM.
:param tfam: representation of a ``tfam`` file.
:type tfam: list
:returns: two :py:class:`dict`, containing unique and duplicated samples
position.
"""
uSamples = {}
dSamples = defaultdict(list)
for i, row in e... | python | def findDuplicates(tfam):
"""Finds the duplicates in a TFAM.
:param tfam: representation of a ``tfam`` file.
:type tfam: list
:returns: two :py:class:`dict`, containing unique and duplicated samples
position.
"""
uSamples = {}
dSamples = defaultdict(list)
for i, row in e... | [
"def",
"findDuplicates",
"(",
"tfam",
")",
":",
"uSamples",
"=",
"{",
"}",
"dSamples",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"i",
",",
"row",
"in",
"enumerate",
"(",
"tfam",
")",
":",
"sampleID",
"=",
"tuple",
"(",
"row",
"[",
":",
"2",
"]",... | Finds the duplicates in a TFAM.
:param tfam: representation of a ``tfam`` file.
:type tfam: list
:returns: two :py:class:`dict`, containing unique and duplicated samples
position. | [
"Finds",
"the",
"duplicates",
"in",
"a",
"TFAM",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L1010-L1041 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: :py:class:`argparse.Namespace`
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exce... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: :py:class:`argparse.Namespace`
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exce... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Checking the input files",
"for",
"suffix",
"in",
"[",
"\".tped\"",
",",
"\".tfam\"",
"]",
":",
"fileName",
"=",
"args",
".",
"tfile",
"+",
"suffix",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"fileN... | Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: :py:class:`argparse.Namespace`
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L1066-L1102 |
simoninireland/epyc | epyc/jsonlabnotebook.py | MetadataEncoder.default | def default( self, o ):
"""If o is a datetime object, convert it to an ISO string. If it is an
exception, convert it to a string. If it is a numpy int, coerce it to
a Python int.
:param o: the field to serialise
:returns: a string encoding of the field"""
if isinstance(o... | python | def default( self, o ):
"""If o is a datetime object, convert it to an ISO string. If it is an
exception, convert it to a string. If it is a numpy int, coerce it to
a Python int.
:param o: the field to serialise
:returns: a string encoding of the field"""
if isinstance(o... | [
"def",
"default",
"(",
"self",
",",
"o",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"datetime",
")",
":",
"# date/time, return an ISO formatted string",
"return",
"o",
".",
"isoformat",
"(",
")",
"else",
":",
"if",
"isinstance",
"(",
"o",
",",
"Exception... | If o is a datetime object, convert it to an ISO string. If it is an
exception, convert it to a string. If it is a numpy int, coerce it to
a Python int.
:param o: the field to serialise
:returns: a string encoding of the field | [
"If",
"o",
"is",
"a",
"datetime",
"object",
"convert",
"it",
"to",
"an",
"ISO",
"string",
".",
"If",
"it",
"is",
"an",
"exception",
"convert",
"it",
"to",
"a",
"string",
".",
"If",
"it",
"is",
"a",
"numpy",
"int",
"coerce",
"it",
"to",
"a",
"Python... | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/jsonlabnotebook.py#L23-L44 |
simoninireland/epyc | epyc/jsonlabnotebook.py | JSONLabNotebook._load | def _load( self, fn ):
"""Retrieve the notebook from the given file.
:param fn: the file name"""
# if file is empty, create an empty notebook
if os.path.getsize(fn) == 0:
self._description = None
self._results = dict()
self._pending = dict()
... | python | def _load( self, fn ):
"""Retrieve the notebook from the given file.
:param fn: the file name"""
# if file is empty, create an empty notebook
if os.path.getsize(fn) == 0:
self._description = None
self._results = dict()
self._pending = dict()
... | [
"def",
"_load",
"(",
"self",
",",
"fn",
")",
":",
"# if file is empty, create an empty notebook",
"if",
"os",
".",
"path",
".",
"getsize",
"(",
"fn",
")",
"==",
"0",
":",
"self",
".",
"_description",
"=",
"None",
"self",
".",
"_results",
"=",
"dict",
"("... | Retrieve the notebook from the given file.
:param fn: the file name | [
"Retrieve",
"the",
"notebook",
"from",
"the",
"given",
"file",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/jsonlabnotebook.py#L95-L117 |
simoninireland/epyc | epyc/jsonlabnotebook.py | JSONLabNotebook._patchDatetimeMetadata | def _patchDatetimeMetadata( self, res, mk ):
"""Private method to patch an ISO datetime string to a datetime object
for metadata key mk.
:param res: results dict
:param mk: metadata key"""
t = res[epyc.Experiment.METADATA][mk]
res[epyc.Experiment.METADATA][mk] = dateutil... | python | def _patchDatetimeMetadata( self, res, mk ):
"""Private method to patch an ISO datetime string to a datetime object
for metadata key mk.
:param res: results dict
:param mk: metadata key"""
t = res[epyc.Experiment.METADATA][mk]
res[epyc.Experiment.METADATA][mk] = dateutil... | [
"def",
"_patchDatetimeMetadata",
"(",
"self",
",",
"res",
",",
"mk",
")",
":",
"t",
"=",
"res",
"[",
"epyc",
".",
"Experiment",
".",
"METADATA",
"]",
"[",
"mk",
"]",
"res",
"[",
"epyc",
".",
"Experiment",
".",
"METADATA",
"]",
"[",
"mk",
"]",
"=",
... | Private method to patch an ISO datetime string to a datetime object
for metadata key mk.
:param res: results dict
:param mk: metadata key | [
"Private",
"method",
"to",
"patch",
"an",
"ISO",
"datetime",
"string",
"to",
"a",
"datetime",
"object",
"for",
"metadata",
"key",
"mk",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/jsonlabnotebook.py#L119-L126 |
simoninireland/epyc | epyc/jsonlabnotebook.py | JSONLabNotebook.patch | def patch( self ):
"""Patch the results dict. The default processes the :attr:`Experiment.START_TIME`
and :attr:`Experiment.END_TIME` metadata fields back into Python `datetime` objects
from ISO strings. This isn't strictly necessary, but it makes notebook
data structure more Pythonic.""... | python | def patch( self ):
"""Patch the results dict. The default processes the :attr:`Experiment.START_TIME`
and :attr:`Experiment.END_TIME` metadata fields back into Python `datetime` objects
from ISO strings. This isn't strictly necessary, but it makes notebook
data structure more Pythonic.""... | [
"def",
"patch",
"(",
"self",
")",
":",
"for",
"k",
"in",
"self",
".",
"_results",
".",
"keys",
"(",
")",
":",
"ars",
"=",
"self",
".",
"_results",
"[",
"k",
"]",
"for",
"res",
"in",
"ars",
":",
"if",
"isinstance",
"(",
"res",
",",
"dict",
")",
... | Patch the results dict. The default processes the :attr:`Experiment.START_TIME`
and :attr:`Experiment.END_TIME` metadata fields back into Python `datetime` objects
from ISO strings. This isn't strictly necessary, but it makes notebook
data structure more Pythonic. | [
"Patch",
"the",
"results",
"dict",
".",
"The",
"default",
"processes",
"the",
":",
"attr",
":",
"Experiment",
".",
"START_TIME",
"and",
":",
"attr",
":",
"Experiment",
".",
"END_TIME",
"metadata",
"fields",
"back",
"into",
"Python",
"datetime",
"objects",
"f... | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/jsonlabnotebook.py#L128-L144 |
simoninireland/epyc | epyc/jsonlabnotebook.py | JSONLabNotebook._save | def _save( self, fn ):
"""Persist the notebook to the given file.
:param fn: the file name"""
# create JSON object
j = json.dumps({ 'description': self.description(),
'pending': self._pending,
'results': self._results },
... | python | def _save( self, fn ):
"""Persist the notebook to the given file.
:param fn: the file name"""
# create JSON object
j = json.dumps({ 'description': self.description(),
'pending': self._pending,
'results': self._results },
... | [
"def",
"_save",
"(",
"self",
",",
"fn",
")",
":",
"# create JSON object",
"j",
"=",
"json",
".",
"dumps",
"(",
"{",
"'description'",
":",
"self",
".",
"description",
"(",
")",
",",
"'pending'",
":",
"self",
".",
"_pending",
",",
"'results'",
":",
"self... | Persist the notebook to the given file.
:param fn: the file name | [
"Persist",
"the",
"notebook",
"to",
"the",
"given",
"file",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/jsonlabnotebook.py#L146-L160 |
CalebBell/fpi | fpi/drag.py | Barati_high | def Barati_high(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_.
.. math::
C_D = 8\times 10^{-6}\left[(Re/6530)^2 + \tanh(Re) - 8\ln(Re)/\ln(10)\right]
- 0.4119\exp(-2.08\times10^{43}/[Re + Re^2]^4)
-2.1344\exp(-\{[\ln(Re^2 + 10.7563)/\ln(10)]^2 + 9.... | python | def Barati_high(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_.
.. math::
C_D = 8\times 10^{-6}\left[(Re/6530)^2 + \tanh(Re) - 8\ln(Re)/\ln(10)\right]
- 0.4119\exp(-2.08\times10^{43}/[Re + Re^2]^4)
-2.1344\exp(-\{[\ln(Re^2 + 10.7563)/\ln(10)]^2 + 9.... | [
"def",
"Barati_high",
"(",
"Re",
")",
":",
"Cd",
"=",
"(",
"8E-6",
"*",
"(",
"(",
"Re",
"/",
"6530.",
")",
"**",
"2",
"+",
"tanh",
"(",
"Re",
")",
"-",
"8",
"*",
"log",
"(",
"Re",
")",
"/",
"log",
"(",
"10.",
")",
")",
"-",
"0.4119",
"*",... | r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_.
.. math::
C_D = 8\times 10^{-6}\left[(Re/6530)^2 + \tanh(Re) - 8\ln(Re)/\ln(10)\right]
- 0.4119\exp(-2.08\times10^{43}/[Re + Re^2]^4)
-2.1344\exp(-\{[\ln(Re^2 + 10.7563)/\ln(10)]^2 + 9.9867\}/Re)
+0.135... | [
"r",
"Calculates",
"drag",
"coefficient",
"of",
"a",
"smooth",
"sphere",
"using",
"the",
"method",
"in",
"[",
"1",
"]",
"_",
"."
] | train | https://github.com/CalebBell/fpi/blob/6e6da3b9d0c17e10cc0886c97bc1bb8aeba2cca5/fpi/drag.py#L105-L153 |
CalebBell/fpi | fpi/drag.py | Morsi_Alexander | def Morsi_Alexander(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left\{ \begin{array}{ll}
\frac{24}{Re} & \mbox{if $Re < 0.1$}\\
\frac{22.73}{Re}+\frac{0.0903}{Re^2} + 3.69 & \mbox{if $0.1 < Re < 1$}\\
... | python | def Morsi_Alexander(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left\{ \begin{array}{ll}
\frac{24}{Re} & \mbox{if $Re < 0.1$}\\
\frac{22.73}{Re}+\frac{0.0903}{Re^2} + 3.69 & \mbox{if $0.1 < Re < 1$}\\
... | [
"def",
"Morsi_Alexander",
"(",
"Re",
")",
":",
"if",
"Re",
"<",
"0.1",
":",
"Cd",
"=",
"24.",
"/",
"Re",
"elif",
"Re",
"<",
"1",
":",
"Cd",
"=",
"22.73",
"/",
"Re",
"+",
"0.0903",
"/",
"Re",
"**",
"2",
"+",
"3.69",
"elif",
"Re",
"<",
"10",
... | r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left\{ \begin{array}{ll}
\frac{24}{Re} & \mbox{if $Re < 0.1$}\\
\frac{22.73}{Re}+\frac{0.0903}{Re^2} + 3.69 & \mbox{if $0.1 < Re < 1$}\\
\frac{29.1667}{Re}-\frac{3.... | [
"r",
"Calculates",
"drag",
"coefficient",
"of",
"a",
"smooth",
"sphere",
"using",
"the",
"method",
"in",
"[",
"1",
"]",
"_",
"as",
"described",
"in",
"[",
"2",
"]",
"_",
"."
] | train | https://github.com/CalebBell/fpi/blob/6e6da3b9d0c17e10cc0886c97bc1bb8aeba2cca5/fpi/drag.py#L278-L340 |
CalebBell/fpi | fpi/drag.py | Flemmer_Banks | def Flemmer_Banks(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \frac{24}{Re}10^E
E = 0.383Re^{0.356}-0.207Re^{0.396} - \frac{0.143}{1+(\log_{10} Re)^2}
Parameters
----------
Re : float
Reynolds n... | python | def Flemmer_Banks(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \frac{24}{Re}10^E
E = 0.383Re^{0.356}-0.207Re^{0.396} - \frac{0.143}{1+(\log_{10} Re)^2}
Parameters
----------
Re : float
Reynolds n... | [
"def",
"Flemmer_Banks",
"(",
"Re",
")",
":",
"E",
"=",
"0.383",
"*",
"Re",
"**",
"0.356",
"-",
"0.207",
"*",
"Re",
"**",
"0.396",
"-",
"0.143",
"/",
"(",
"1",
"+",
"(",
"log10",
"(",
"Re",
")",
")",
"**",
"2",
")",
"Cd",
"=",
"24.",
"/",
"R... | r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \frac{24}{Re}10^E
E = 0.383Re^{0.356}-0.207Re^{0.396} - \frac{0.143}{1+(\log_{10} Re)^2}
Parameters
----------
Re : float
Reynolds number of the sphere, [-]
... | [
"r",
"Calculates",
"drag",
"coefficient",
"of",
"a",
"smooth",
"sphere",
"using",
"the",
"method",
"in",
"[",
"1",
"]",
"_",
"as",
"described",
"in",
"[",
"2",
"]",
"_",
"."
] | train | https://github.com/CalebBell/fpi/blob/6e6da3b9d0c17e10cc0886c97bc1bb8aeba2cca5/fpi/drag.py#L383-L424 |
CalebBell/fpi | fpi/drag.py | Clift | def Clift(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left\{ \begin{array}{ll}
\frac{24}{Re} + \frac{3}{16} & \mbox{if $Re < 0.01$}\\
\frac{24}{Re}(1 + 0.1315Re^{0.82 - 0.05\log Re}) & \mbox{if $0.01 < Re < ... | python | def Clift(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left\{ \begin{array}{ll}
\frac{24}{Re} + \frac{3}{16} & \mbox{if $Re < 0.01$}\\
\frac{24}{Re}(1 + 0.1315Re^{0.82 - 0.05\log Re}) & \mbox{if $0.01 < Re < ... | [
"def",
"Clift",
"(",
"Re",
")",
":",
"if",
"Re",
"<",
"0.01",
":",
"Cd",
"=",
"24.",
"/",
"Re",
"+",
"3",
"/",
"16.",
"elif",
"Re",
"<",
"20",
":",
"Cd",
"=",
"24.",
"/",
"Re",
"*",
"(",
"1",
"+",
"0.1315",
"*",
"Re",
"**",
"(",
"0.82",
... | r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left\{ \begin{array}{ll}
\frac{24}{Re} + \frac{3}{16} & \mbox{if $Re < 0.01$}\\
\frac{24}{Re}(1 + 0.1315Re^{0.82 - 0.05\log Re}) & \mbox{if $0.01 < Re < 20$}\\
\fra... | [
"r",
"Calculates",
"drag",
"coefficient",
"of",
"a",
"smooth",
"sphere",
"using",
"the",
"method",
"in",
"[",
"1",
"]",
"_",
"as",
"described",
"in",
"[",
"2",
"]",
"_",
"."
] | train | https://github.com/CalebBell/fpi/blob/6e6da3b9d0c17e10cc0886c97bc1bb8aeba2cca5/fpi/drag.py#L720-L783 |
CalebBell/fpi | fpi/drag.py | Almedeij | def Almedeij(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left[\frac{1}{(\phi_1 + \phi_2)^{-1} + (\phi_3)^{-1}} + \phi_4\right]^{0.1}
\phi_1 = (24Re^{-1})^{10} + (21Re^{-0.67})^{10} + (4Re^{-0.33})^{10} + 0.4^{10}
... | python | def Almedeij(Re):
r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left[\frac{1}{(\phi_1 + \phi_2)^{-1} + (\phi_3)^{-1}} + \phi_4\right]^{0.1}
\phi_1 = (24Re^{-1})^{10} + (21Re^{-0.67})^{10} + (4Re^{-0.33})^{10} + 0.4^{10}
... | [
"def",
"Almedeij",
"(",
"Re",
")",
":",
"phi4",
"=",
"(",
"(",
"6E-17",
"*",
"Re",
"**",
"2.63",
")",
"**",
"-",
"10",
"+",
"0.2",
"**",
"-",
"10",
")",
"**",
"-",
"1",
"phi3",
"=",
"(",
"1.57E8",
"*",
"Re",
"**",
"-",
"1.625",
")",
"**",
... | r'''Calculates drag coefficient of a smooth sphere using the method in
[1]_ as described in [2]_.
.. math::
C_D = \left[\frac{1}{(\phi_1 + \phi_2)^{-1} + (\phi_3)^{-1}} + \phi_4\right]^{0.1}
\phi_1 = (24Re^{-1})^{10} + (21Re^{-0.67})^{10} + (4Re^{-0.33})^{10} + 0.4^{10}
\phi_2 = \left... | [
"r",
"Calculates",
"drag",
"coefficient",
"of",
"a",
"smooth",
"sphere",
"using",
"the",
"method",
"in",
"[",
"1",
"]",
"_",
"as",
"described",
"in",
"[",
"2",
"]",
"_",
"."
] | train | https://github.com/CalebBell/fpi/blob/6e6da3b9d0c17e10cc0886c97bc1bb8aeba2cca5/fpi/drag.py#L834-L885 |
photo/openphoto-python | trovebox/api/api_base.py | ApiBase._build_option_string | def _build_option_string(self, options):
"""
:param options: dictionary containing the options
:returns: option_string formatted for an API endpoint
"""
option_string = ""
if options is not None:
for key in options:
option_string += "/%s-%s" % ... | python | def _build_option_string(self, options):
"""
:param options: dictionary containing the options
:returns: option_string formatted for an API endpoint
"""
option_string = ""
if options is not None:
for key in options:
option_string += "/%s-%s" % ... | [
"def",
"_build_option_string",
"(",
"self",
",",
"options",
")",
":",
"option_string",
"=",
"\"\"",
"if",
"options",
"is",
"not",
"None",
":",
"for",
"key",
"in",
"options",
":",
"option_string",
"+=",
"\"/%s-%s\"",
"%",
"(",
"key",
",",
"options",
"[",
... | :param options: dictionary containing the options
:returns: option_string formatted for an API endpoint | [
":",
"param",
"options",
":",
"dictionary",
"containing",
"the",
"options",
":",
"returns",
":",
"option_string",
"formatted",
"for",
"an",
"API",
"endpoint"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_base.py#L15-L24 |
fraoustin/flaskserver | flaskserver/main.py | start | def start(path=None, host=None, port=None, color=None, cors=None, detach=False, nolog=False):
"""start web server"""
if detach:
sys.argv.append('--no-log')
idx = sys.argv.index('-d')
del sys.argv[idx]
cmd = sys.executable + ' ' + ' '.join([sys.argv[0], 'start'] + sys.argv[1... | python | def start(path=None, host=None, port=None, color=None, cors=None, detach=False, nolog=False):
"""start web server"""
if detach:
sys.argv.append('--no-log')
idx = sys.argv.index('-d')
del sys.argv[idx]
cmd = sys.executable + ' ' + ' '.join([sys.argv[0], 'start'] + sys.argv[1... | [
"def",
"start",
"(",
"path",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"color",
"=",
"None",
",",
"cors",
"=",
"None",
",",
"detach",
"=",
"False",
",",
"nolog",
"=",
"False",
")",
":",
"if",
"detach",
":",
"sys",
".... | start web server | [
"start",
"web",
"server"
] | train | https://github.com/fraoustin/flaskserver/blob/27ce6ead523ae42286993cab04406d17a92c6535/flaskserver/main.py#L173-L199 |
fraoustin/flaskserver | flaskserver/main.py | status | def status(host=None, port=None):
"""status web server"""
app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
if app.config['HOST'] == "0.0.0.0":
host="127.0.0.1"
else:
h... | python | def status(host=None, port=None):
"""status web server"""
app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
if app.config['HOST'] == "0.0.0.0":
host="127.0.0.1"
else:
h... | [
"def",
"status",
"(",
"host",
"=",
"None",
",",
"port",
"=",
"None",
")",
":",
"app",
".",
"config",
"[",
"'HOST'",
"]",
"=",
"first_value",
"(",
"host",
",",
"app",
".",
"config",
".",
"get",
"(",
"'HOST'",
",",
"None",
")",
",",
"'0.0.0.0'",
")... | status web server | [
"status",
"web",
"server"
] | train | https://github.com/fraoustin/flaskserver/blob/27ce6ead523ae42286993cab04406d17a92c6535/flaskserver/main.py#L203-L224 |
fraoustin/flaskserver | flaskserver/main.py | stop | def stop(host=None, port=None):
"""stop of web server"""
app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
if app.config['HOST'] == "0.0.0.0":
host="127.0.0.1"
else:
ho... | python | def stop(host=None, port=None):
"""stop of web server"""
app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
if app.config['HOST'] == "0.0.0.0":
host="127.0.0.1"
else:
ho... | [
"def",
"stop",
"(",
"host",
"=",
"None",
",",
"port",
"=",
"None",
")",
":",
"app",
".",
"config",
"[",
"'HOST'",
"]",
"=",
"first_value",
"(",
"host",
",",
"app",
".",
"config",
".",
"get",
"(",
"'HOST'",
",",
"None",
")",
",",
"'0.0.0.0'",
")",... | stop of web server | [
"stop",
"of",
"web",
"server"
] | train | https://github.com/fraoustin/flaskserver/blob/27ce6ead523ae42286993cab04406d17a92c6535/flaskserver/main.py#L229-L245 |
fraoustin/flaskserver | flaskserver/main.py | log | def log(host=None, port=None, limit=0):
"""view log of web server"""
app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
if app.config['HOST'] == "0.0.0.0":
host="127.0.0.1"
else:... | python | def log(host=None, port=None, limit=0):
"""view log of web server"""
app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
if app.config['HOST'] == "0.0.0.0":
host="127.0.0.1"
else:... | [
"def",
"log",
"(",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"limit",
"=",
"0",
")",
":",
"app",
".",
"config",
"[",
"'HOST'",
"]",
"=",
"first_value",
"(",
"host",
",",
"app",
".",
"config",
".",
"get",
"(",
"'HOST'",
",",
"None",
")... | view log of web server | [
"view",
"log",
"of",
"web",
"server"
] | train | https://github.com/fraoustin/flaskserver/blob/27ce6ead523ae42286993cab04406d17a92c6535/flaskserver/main.py#L250-L270 |
omaraboumrad/mastool | mastool/practices.py | find_for_x_in_y_keys | def find_for_x_in_y_keys(node):
"""Finds looping against dictionary keys"""
return (
isinstance(node, ast.For)
and h.call_name_is(node.iter, 'keys')
) | python | def find_for_x_in_y_keys(node):
"""Finds looping against dictionary keys"""
return (
isinstance(node, ast.For)
and h.call_name_is(node.iter, 'keys')
) | [
"def",
"find_for_x_in_y_keys",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"ast",
".",
"For",
")",
"and",
"h",
".",
"call_name_is",
"(",
"node",
".",
"iter",
",",
"'keys'",
")",
")"
] | Finds looping against dictionary keys | [
"Finds",
"looping",
"against",
"dictionary",
"keys"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L13-L18 |
omaraboumrad/mastool | mastool/practices.py | find_if_x_retbool_else_retbool | def find_if_x_retbool_else_retbool(node):
"""Finds simplifiable if condition"""
return (
isinstance(node, ast.If)
and isinstance(node.body[0], ast.Return)
and h.is_boolean(node.body[0].value)
and h.has_else(node)
and isinstance(node.orelse[0], ast.Return)
and h.is... | python | def find_if_x_retbool_else_retbool(node):
"""Finds simplifiable if condition"""
return (
isinstance(node, ast.If)
and isinstance(node.body[0], ast.Return)
and h.is_boolean(node.body[0].value)
and h.has_else(node)
and isinstance(node.orelse[0], ast.Return)
and h.is... | [
"def",
"find_if_x_retbool_else_retbool",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"ast",
".",
"If",
")",
"and",
"isinstance",
"(",
"node",
".",
"body",
"[",
"0",
"]",
",",
"ast",
".",
"Return",
")",
"and",
"h",
".",
"is_b... | Finds simplifiable if condition | [
"Finds",
"simplifiable",
"if",
"condition"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L25-L34 |
omaraboumrad/mastool | mastool/practices.py | find_path_join_using_plus | def find_path_join_using_plus(node):
"""Finds joining path with plus"""
return (
isinstance(node, ast.BinOp)
and isinstance(node.op, ast.Add)
and isinstance(node.left, ast.BinOp)
and isinstance(node.left.op, ast.Add)
and isinstance(node.left.right, ast.Str)
and no... | python | def find_path_join_using_plus(node):
"""Finds joining path with plus"""
return (
isinstance(node, ast.BinOp)
and isinstance(node.op, ast.Add)
and isinstance(node.left, ast.BinOp)
and isinstance(node.left.op, ast.Add)
and isinstance(node.left.right, ast.Str)
and no... | [
"def",
"find_path_join_using_plus",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"ast",
".",
"BinOp",
")",
"and",
"isinstance",
"(",
"node",
".",
"op",
",",
"ast",
".",
"Add",
")",
"and",
"isinstance",
"(",
"node",
".",
"left",... | Finds joining path with plus | [
"Finds",
"joining",
"path",
"with",
"plus"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L40-L49 |
omaraboumrad/mastool | mastool/practices.py | find_assign_to_builtin | def find_assign_to_builtin(node):
"""Finds assigning to built-ins"""
# The list of forbidden builtins is constant and not determined at
# runtime anyomre. The reason behind this change is that certain
# modules (like `gettext` for instance) would mess with the
# builtins module making this practice... | python | def find_assign_to_builtin(node):
"""Finds assigning to built-ins"""
# The list of forbidden builtins is constant and not determined at
# runtime anyomre. The reason behind this change is that certain
# modules (like `gettext` for instance) would mess with the
# builtins module making this practice... | [
"def",
"find_assign_to_builtin",
"(",
"node",
")",
":",
"# The list of forbidden builtins is constant and not determined at",
"# runtime anyomre. The reason behind this change is that certain",
"# modules (like `gettext` for instance) would mess with the",
"# builtins module making this practice y... | Finds assigning to built-ins | [
"Finds",
"assigning",
"to",
"built",
"-",
"ins"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L55-L98 |
omaraboumrad/mastool | mastool/practices.py | find_silent_exception | def find_silent_exception(node):
"""Finds silent generic exceptions"""
return (
isinstance(node, ast.ExceptHandler)
and node.type is None
and len(node.body) == 1
and isinstance(node.body[0], ast.Pass)
) | python | def find_silent_exception(node):
"""Finds silent generic exceptions"""
return (
isinstance(node, ast.ExceptHandler)
and node.type is None
and len(node.body) == 1
and isinstance(node.body[0], ast.Pass)
) | [
"def",
"find_silent_exception",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"ast",
".",
"ExceptHandler",
")",
"and",
"node",
".",
"type",
"is",
"None",
"and",
"len",
"(",
"node",
".",
"body",
")",
"==",
"1",
"and",
"isinstance... | Finds silent generic exceptions | [
"Finds",
"silent",
"generic",
"exceptions"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L116-L123 |
omaraboumrad/mastool | mastool/practices.py | find_import_star | def find_import_star(node):
"""Finds import stars"""
return (
isinstance(node, ast.ImportFrom)
and '*' in h.importfrom_names(node.names)
) | python | def find_import_star(node):
"""Finds import stars"""
return (
isinstance(node, ast.ImportFrom)
and '*' in h.importfrom_names(node.names)
) | [
"def",
"find_import_star",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"ast",
".",
"ImportFrom",
")",
"and",
"'*'",
"in",
"h",
".",
"importfrom_names",
"(",
"node",
".",
"names",
")",
")"
] | Finds import stars | [
"Finds",
"import",
"stars"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L129-L134 |
omaraboumrad/mastool | mastool/practices.py | find_equals_true_or_false | def find_equals_true_or_false(node):
"""Finds equals true or false"""
return (
isinstance(node, ast.Compare)
and len(node.ops) == 1
and isinstance(node.ops[0], ast.Eq)
and any(h.is_boolean(n) for n in node.comparators)
) | python | def find_equals_true_or_false(node):
"""Finds equals true or false"""
return (
isinstance(node, ast.Compare)
and len(node.ops) == 1
and isinstance(node.ops[0], ast.Eq)
and any(h.is_boolean(n) for n in node.comparators)
) | [
"def",
"find_equals_true_or_false",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"ast",
".",
"Compare",
")",
"and",
"len",
"(",
"node",
".",
"ops",
")",
"==",
"1",
"and",
"isinstance",
"(",
"node",
".",
"ops",
"[",
"0",
"]",
... | Finds equals true or false | [
"Finds",
"equals",
"true",
"or",
"false"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L140-L147 |
omaraboumrad/mastool | mastool/practices.py | find_poor_default_arg | def find_poor_default_arg(node):
"""Finds poor default args"""
poor_defaults = [
ast.Call,
ast.Dict,
ast.DictComp,
ast.GeneratorExp,
ast.List,
ast.ListComp,
ast.Set,
ast.SetComp,
]
# pylint: disable=unidiomatic-typecheck
return (
... | python | def find_poor_default_arg(node):
"""Finds poor default args"""
poor_defaults = [
ast.Call,
ast.Dict,
ast.DictComp,
ast.GeneratorExp,
ast.List,
ast.ListComp,
ast.Set,
ast.SetComp,
]
# pylint: disable=unidiomatic-typecheck
return (
... | [
"def",
"find_poor_default_arg",
"(",
"node",
")",
":",
"poor_defaults",
"=",
"[",
"ast",
".",
"Call",
",",
"ast",
".",
"Dict",
",",
"ast",
".",
"DictComp",
",",
"ast",
".",
"GeneratorExp",
",",
"ast",
".",
"List",
",",
"ast",
".",
"ListComp",
",",
"a... | Finds poor default args | [
"Finds",
"poor",
"default",
"args"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L154-L171 |
omaraboumrad/mastool | mastool/practices.py | find_if_expression_as_statement | def find_if_expression_as_statement(node):
"""Finds an "if" expression as a statement"""
return (
isinstance(node, ast.Expr)
and isinstance(node.value, ast.IfExp)
) | python | def find_if_expression_as_statement(node):
"""Finds an "if" expression as a statement"""
return (
isinstance(node, ast.Expr)
and isinstance(node.value, ast.IfExp)
) | [
"def",
"find_if_expression_as_statement",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"ast",
".",
"Expr",
")",
"and",
"isinstance",
"(",
"node",
".",
"value",
",",
"ast",
".",
"IfExp",
")",
")"
] | Finds an "if" expression as a statement | [
"Finds",
"an",
"if",
"expression",
"as",
"a",
"statement"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L178-L183 |
omaraboumrad/mastool | mastool/practices.py | find_comprehension_as_statement | def find_comprehension_as_statement(node):
"""Finds a comprehension as a statement"""
return (
isinstance(node, ast.Expr)
and isinstance(node.value, (ast.ListComp,
ast.DictComp,
ast.SetComp))
) | python | def find_comprehension_as_statement(node):
"""Finds a comprehension as a statement"""
return (
isinstance(node, ast.Expr)
and isinstance(node.value, (ast.ListComp,
ast.DictComp,
ast.SetComp))
) | [
"def",
"find_comprehension_as_statement",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"ast",
".",
"Expr",
")",
"and",
"isinstance",
"(",
"node",
".",
"value",
",",
"(",
"ast",
".",
"ListComp",
",",
"ast",
".",
"DictComp",
",",
... | Finds a comprehension as a statement | [
"Finds",
"a",
"comprehension",
"as",
"a",
"statement"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L189-L196 |
omaraboumrad/mastool | mastool/practices.py | find_generator_as_statement | def find_generator_as_statement(node):
"""Finds a generator as a statement"""
return (
isinstance(node, ast.Expr)
and isinstance(node.value, ast.GeneratorExp)
) | python | def find_generator_as_statement(node):
"""Finds a generator as a statement"""
return (
isinstance(node, ast.Expr)
and isinstance(node.value, ast.GeneratorExp)
) | [
"def",
"find_generator_as_statement",
"(",
"node",
")",
":",
"return",
"(",
"isinstance",
"(",
"node",
",",
"ast",
".",
"Expr",
")",
"and",
"isinstance",
"(",
"node",
".",
"value",
",",
"ast",
".",
"GeneratorExp",
")",
")"
] | Finds a generator as a statement | [
"Finds",
"a",
"generator",
"as",
"a",
"statement"
] | train | https://github.com/omaraboumrad/mastool/blob/0ec566de6717d03c6ec61affe5d1e9ff8d7e6ebd/mastool/practices.py#L202-L207 |
lemieuxl/pyGenClean | pyGenClean/FlagHW/flag_hw.py | main | def main(argString=None):
"""The main function.
:param argString: the options.
:type argString: list
These are the steps performed by this module:
1. Prints the options of the module.
2. Computes the number of markers in the input file
(:py:func:`computeNumberOfMarkers`).
3. If th... | python | def main(argString=None):
"""The main function.
:param argString: the options.
:type argString: list
These are the steps performed by this module:
1. Prints the options of the module.
2. Computes the number of markers in the input file
(:py:func:`computeNumberOfMarkers`).
3. If th... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
"argString",
")",
"checkArgs",
"(",
"args",
")",
"logger",
".",
"info",
"(",
"\"Options used:\"",
")",
"for",
"key",
",",
"value",
"i... | The main function.
:param argString: the options.
:type argString: list
These are the steps performed by this module:
1. Prints the options of the module.
2. Computes the number of markers in the input file
(:py:func:`computeNumberOfMarkers`).
3. If there are no markers, the module st... | [
"The",
"main",
"function",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/FlagHW/flag_hw.py#L36-L117 |
lemieuxl/pyGenClean | pyGenClean/FlagHW/flag_hw.py | compareBIMfiles | def compareBIMfiles(beforeFileName, afterFileName, outputFileName):
"""Compare two BIM files for differences.
:param beforeFileName: the name of the file before modification.
:param afterFileName: the name of the file after modification.
:param outputFileName: the name of the output file (containing th... | python | def compareBIMfiles(beforeFileName, afterFileName, outputFileName):
"""Compare two BIM files for differences.
:param beforeFileName: the name of the file before modification.
:param afterFileName: the name of the file after modification.
:param outputFileName: the name of the output file (containing th... | [
"def",
"compareBIMfiles",
"(",
"beforeFileName",
",",
"afterFileName",
",",
"outputFileName",
")",
":",
"# Creating the options",
"options",
"=",
"Dummy",
"(",
")",
"options",
".",
"before",
"=",
"beforeFileName",
"options",
".",
"after",
"=",
"afterFileName",
"op... | Compare two BIM files for differences.
:param beforeFileName: the name of the file before modification.
:param afterFileName: the name of the file after modification.
:param outputFileName: the name of the output file (containing the
differences between the ``before`` and the ``a... | [
"Compare",
"two",
"BIM",
"files",
"for",
"differences",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/FlagHW/flag_hw.py#L120-L156 |
lemieuxl/pyGenClean | pyGenClean/FlagHW/flag_hw.py | computeNumberOfMarkers | def computeNumberOfMarkers(inputFileName):
"""Count the number of marker (line) in a BIM file.
:param inputFileName: the name of the ``bim`` file.
:type inputFileName: str
:returns: the number of marker in the ``bim`` file.
"""
nbLine = 0
with open(inputFileName, "r") as inputFile:
... | python | def computeNumberOfMarkers(inputFileName):
"""Count the number of marker (line) in a BIM file.
:param inputFileName: the name of the ``bim`` file.
:type inputFileName: str
:returns: the number of marker in the ``bim`` file.
"""
nbLine = 0
with open(inputFileName, "r") as inputFile:
... | [
"def",
"computeNumberOfMarkers",
"(",
"inputFileName",
")",
":",
"nbLine",
"=",
"0",
"with",
"open",
"(",
"inputFileName",
",",
"\"r\"",
")",
"as",
"inputFile",
":",
"nbLine",
"=",
"len",
"(",
"inputFile",
".",
"readlines",
"(",
")",
")",
"return",
"nbLine... | Count the number of marker (line) in a BIM file.
:param inputFileName: the name of the ``bim`` file.
:type inputFileName: str
:returns: the number of marker in the ``bim`` file. | [
"Count",
"the",
"number",
"of",
"marker",
"(",
"line",
")",
"in",
"a",
"BIM",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/FlagHW/flag_hw.py#L159-L173 |
lemieuxl/pyGenClean | pyGenClean/FlagHW/flag_hw.py | computeHWE | def computeHWE(prefix, threshold, outPrefix):
"""Compute the Hardy Weinberg test using Plink.
:param prefix: the prefix of all the files.
:param threshold: the Hardy Weinberg threshold.
:param outPrefix: the prefix of the output file.
:type prefix: str
:type threshold: str
:type outPrefix:... | python | def computeHWE(prefix, threshold, outPrefix):
"""Compute the Hardy Weinberg test using Plink.
:param prefix: the prefix of all the files.
:param threshold: the Hardy Weinberg threshold.
:param outPrefix: the prefix of the output file.
:type prefix: str
:type threshold: str
:type outPrefix:... | [
"def",
"computeHWE",
"(",
"prefix",
",",
"threshold",
",",
"outPrefix",
")",
":",
"plinkCommand",
"=",
"[",
"\"plink\"",
",",
"\"--noweb\"",
",",
"\"--bfile\"",
",",
"prefix",
",",
"\"--hwe\"",
",",
"threshold",
",",
"\"--make-bed\"",
",",
"\"--out\"",
",",
... | Compute the Hardy Weinberg test using Plink.
:param prefix: the prefix of all the files.
:param threshold: the Hardy Weinberg threshold.
:param outPrefix: the prefix of the output file.
:type prefix: str
:type threshold: str
:type outPrefix: str
Uses Plink to exclude markers that failed t... | [
"Compute",
"the",
"Hardy",
"Weinberg",
"test",
"using",
"Plink",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/FlagHW/flag_hw.py#L176-L193 |
lemieuxl/pyGenClean | pyGenClean/FlagHW/flag_hw.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: :py:class:`argparse.Namespace`
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exce... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: :py:class:`argparse.Namespace`
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exce... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Check if we have the tped and the tfam files",
"for",
"fileName",
"in",
"[",
"args",
".",
"bfile",
"+",
"i",
"for",
"i",
"in",
"[",
"\".bed\"",
",",
"\".bim\"",
",",
"\".fam\"",
"]",
"]",
":",
"if",
"not",
"os"... | Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: :py:class:`argparse.Namespace`
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/FlagHW/flag_hw.py#L219-L251 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/subset_data.py | subset_data | def subset_data(options):
"""Subset the data.
:param options: the options.
:type options: argparse.Namespace
Subset the data using either ``--exclude`` or ``--extract``for markers or
``--remove`` or ``keep`` for samples.
"""
# The plink command
plinkCommand = ["plink", "--noweb"]
... | python | def subset_data(options):
"""Subset the data.
:param options: the options.
:type options: argparse.Namespace
Subset the data using either ``--exclude`` or ``--extract``for markers or
``--remove`` or ``keep`` for samples.
"""
# The plink command
plinkCommand = ["plink", "--noweb"]
... | [
"def",
"subset_data",
"(",
"options",
")",
":",
"# The plink command",
"plinkCommand",
"=",
"[",
"\"plink\"",
",",
"\"--noweb\"",
"]",
"# The input file prefix",
"if",
"options",
".",
"is_bfile",
":",
"plinkCommand",
"+=",
"[",
"\"--bfile\"",
",",
"options",
".",
... | Subset the data.
:param options: the options.
:type options: argparse.Namespace
Subset the data using either ``--exclude`` or ``--extract``for markers or
``--remove`` or ``keep`` for samples. | [
"Subset",
"the",
"data",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/subset_data.py#L61-L100 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/subset_data.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Check the input files",
"if",
"not",
"args",
".",
"is_bfile",
"and",
"not",
"args",
".",
"is_tfile",
"and",
"not",
"args",
".",
"is_file",
":",
"msg",
"=",
"\"needs one input file type (--is-bfile, --is-tfile or --is-fil... | Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` class, a message is printed to t... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/subset_data.py#L122-L202 |
shichaoji/json2df | build/lib/json2df/base.py | series2df | def series2df(Series, layer=2, split_sign = '_'):
"""expect pass a series that each row is string formated Json data with the same structure"""
try:
Series.columns
Series = Series.iloc[:,0]
except:
pass
def _helper(x, layer=2):
try:
return flatten_dict(as... | python | def series2df(Series, layer=2, split_sign = '_'):
"""expect pass a series that each row is string formated Json data with the same structure"""
try:
Series.columns
Series = Series.iloc[:,0]
except:
pass
def _helper(x, layer=2):
try:
return flatten_dict(as... | [
"def",
"series2df",
"(",
"Series",
",",
"layer",
"=",
"2",
",",
"split_sign",
"=",
"'_'",
")",
":",
"try",
":",
"Series",
".",
"columns",
"Series",
"=",
"Series",
".",
"iloc",
"[",
":",
",",
"0",
"]",
"except",
":",
"pass",
"def",
"_helper",
"(",
... | expect pass a series that each row is string formated Json data with the same structure | [
"expect",
"pass",
"a",
"series",
"that",
"each",
"row",
"is",
"string",
"formated",
"Json",
"data",
"with",
"the",
"same",
"structure"
] | train | https://github.com/shichaoji/json2df/blob/0463d6b494ab636b3c654616cb6be3b1e09e61a0/build/lib/json2df/base.py#L48-L67 |
shichaoji/json2df | build/lib/json2df/base.py | LoadFile.load_data | def load_data(self, path, *args, **kwargs):
"""see print instance.doc, e.g. cat=LoadFile(kind='excel')
read how to use cat.load_data, exec: print (cat.doc)"""
self.df = self._load(path,*args, **kwargs)
self.series = self.df.iloc[:,0]
print ("Success! file length: " +str(self.df... | python | def load_data(self, path, *args, **kwargs):
"""see print instance.doc, e.g. cat=LoadFile(kind='excel')
read how to use cat.load_data, exec: print (cat.doc)"""
self.df = self._load(path,*args, **kwargs)
self.series = self.df.iloc[:,0]
print ("Success! file length: " +str(self.df... | [
"def",
"load_data",
"(",
"self",
",",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"df",
"=",
"self",
".",
"_load",
"(",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"series",
"=",
"self",
... | see print instance.doc, e.g. cat=LoadFile(kind='excel')
read how to use cat.load_data, exec: print (cat.doc) | [
"see",
"print",
"instance",
".",
"doc",
"e",
".",
"g",
".",
"cat",
"=",
"LoadFile",
"(",
"kind",
"=",
"excel",
")",
"read",
"how",
"to",
"use",
"cat",
".",
"load_data",
"exec",
":",
"print",
"(",
"cat",
".",
"doc",
")"
] | train | https://github.com/shichaoji/json2df/blob/0463d6b494ab636b3c654616cb6be3b1e09e61a0/build/lib/json2df/base.py#L100-L105 |
shichaoji/json2df | build/lib/json2df/base.py | LoadFile.convert | def convert(self, layer=2, split_sign = '_', *args, **kwargs):
"""convert data to DataFrame"""
return series2df(self.series, *args, **kwargs) | python | def convert(self, layer=2, split_sign = '_', *args, **kwargs):
"""convert data to DataFrame"""
return series2df(self.series, *args, **kwargs) | [
"def",
"convert",
"(",
"self",
",",
"layer",
"=",
"2",
",",
"split_sign",
"=",
"'_'",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"series2df",
"(",
"self",
".",
"series",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | convert data to DataFrame | [
"convert",
"data",
"to",
"DataFrame"
] | train | https://github.com/shichaoji/json2df/blob/0463d6b494ab636b3c654616cb6be3b1e09e61a0/build/lib/json2df/base.py#L107-L109 |
lemieuxl/pyGenClean | pyGenClean/PlateBias/plate_bias.py | main | def main(argString=None):
"""The main function of this module.
:param argString: the options.
:type argString: list
These are the steps:
1. Runs a plate bias analysis using Plink
(:py:func:`executePlateBiasAnalysis`).
2. Extracts the list of significant markers after plate bias analys... | python | def main(argString=None):
"""The main function of this module.
:param argString: the options.
:type argString: list
These are the steps:
1. Runs a plate bias analysis using Plink
(:py:func:`executePlateBiasAnalysis`).
2. Extracts the list of significant markers after plate bias analys... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
"argString",
")",
"checkArgs",
"(",
"args",
")",
"logger",
".",
"info",
"(",
"\"Options used:\"",
")",
"for",
"key",
",",
"value",
"i... | The main function of this module.
:param argString: the options.
:type argString: list
These are the steps:
1. Runs a plate bias analysis using Plink
(:py:func:`executePlateBiasAnalysis`).
2. Extracts the list of significant markers after plate bias analysis
(:py:func:`extractSigni... | [
"The",
"main",
"function",
"of",
"this",
"module",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlateBias/plate_bias.py#L34-L73 |
lemieuxl/pyGenClean | pyGenClean/PlateBias/plate_bias.py | createSummaryFile | def createSummaryFile(results, maf, prefix):
"""Creat the final summary file containing plate bias results.
:param results: the list of all the significant results.
:param maf: the minor allele frequency of the significant results.
:param prefix: the prefix of all the files.
:type results: list
... | python | def createSummaryFile(results, maf, prefix):
"""Creat the final summary file containing plate bias results.
:param results: the list of all the significant results.
:param maf: the minor allele frequency of the significant results.
:param prefix: the prefix of all the files.
:type results: list
... | [
"def",
"createSummaryFile",
"(",
"results",
",",
"maf",
",",
"prefix",
")",
":",
"o_filename",
"=",
"prefix",
"+",
"\".significant_SNPs.summary\"",
"try",
":",
"with",
"open",
"(",
"o_filename",
",",
"\"w\"",
")",
"as",
"o_file",
":",
"print",
">>",
"o_file"... | Creat the final summary file containing plate bias results.
:param results: the list of all the significant results.
:param maf: the minor allele frequency of the significant results.
:param prefix: the prefix of all the files.
:type results: list
:type maf: dict
:type prefix: str | [
"Creat",
"the",
"final",
"summary",
"file",
"containing",
"plate",
"bias",
"results",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlateBias/plate_bias.py#L76-L106 |
lemieuxl/pyGenClean | pyGenClean/PlateBias/plate_bias.py | extractSignificantSNPs | def extractSignificantSNPs(prefix):
"""Extract significant SNPs in the fisher file.
:param prefix: the prefix of the input file.
:type prefix: str
Reads a list of significant markers (``prefix.assoc.fisher``) after plate
bias analysis with Plink. Writes a file (``prefix.significant_SNPs.txt``)
... | python | def extractSignificantSNPs(prefix):
"""Extract significant SNPs in the fisher file.
:param prefix: the prefix of the input file.
:type prefix: str
Reads a list of significant markers (``prefix.assoc.fisher``) after plate
bias analysis with Plink. Writes a file (``prefix.significant_SNPs.txt``)
... | [
"def",
"extractSignificantSNPs",
"(",
"prefix",
")",
":",
"# The list of all assoc files",
"fileNames",
"=",
"glob",
".",
"glob",
"(",
"prefix",
"+",
"\".*.assoc.fisher\"",
")",
"# The object to save an assoc row",
"AssocRow",
"=",
"namedtuple",
"(",
"\"AssocRow\"",
","... | Extract significant SNPs in the fisher file.
:param prefix: the prefix of the input file.
:type prefix: str
Reads a list of significant markers (``prefix.assoc.fisher``) after plate
bias analysis with Plink. Writes a file (``prefix.significant_SNPs.txt``)
containing those significant markers. | [
"Extract",
"significant",
"SNPs",
"in",
"the",
"fisher",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlateBias/plate_bias.py#L109-L185 |
lemieuxl/pyGenClean | pyGenClean/PlateBias/plate_bias.py | computeFrequencyOfSignificantSNPs | def computeFrequencyOfSignificantSNPs(options):
"""Computes the frequency of the significant markers.
:param options: the options.
:type options: argparse.Namespace
Extract a list of markers (significant after plate bias analysis) and
computes their frequencies.
"""
# The plink command
... | python | def computeFrequencyOfSignificantSNPs(options):
"""Computes the frequency of the significant markers.
:param options: the options.
:type options: argparse.Namespace
Extract a list of markers (significant after plate bias analysis) and
computes their frequencies.
"""
# The plink command
... | [
"def",
"computeFrequencyOfSignificantSNPs",
"(",
"options",
")",
":",
"# The plink command",
"plinkCommand",
"=",
"[",
"\"plink\"",
",",
"\"--noweb\"",
",",
"\"--bfile\"",
",",
"options",
".",
"bfile",
",",
"\"--extract\"",
",",
"options",
".",
"out",
"+",
"\".sig... | Computes the frequency of the significant markers.
:param options: the options.
:type options: argparse.Namespace
Extract a list of markers (significant after plate bias analysis) and
computes their frequencies. | [
"Computes",
"the",
"frequency",
"of",
"the",
"significant",
"markers",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlateBias/plate_bias.py#L188-L224 |
lemieuxl/pyGenClean | pyGenClean/PlateBias/plate_bias.py | executePlateBiasAnalysis | def executePlateBiasAnalysis(options):
"""Execute the plate bias analysis with Plink.
:param options: the options.
:type options: argparse.Namespace
"""
# The plink command
plinkCommand = ["plink", "--noweb", "--bfile", options.bfile,
"--loop-assoc", options.loop_assoc, "-... | python | def executePlateBiasAnalysis(options):
"""Execute the plate bias analysis with Plink.
:param options: the options.
:type options: argparse.Namespace
"""
# The plink command
plinkCommand = ["plink", "--noweb", "--bfile", options.bfile,
"--loop-assoc", options.loop_assoc, "-... | [
"def",
"executePlateBiasAnalysis",
"(",
"options",
")",
":",
"# The plink command",
"plinkCommand",
"=",
"[",
"\"plink\"",
",",
"\"--noweb\"",
",",
"\"--bfile\"",
",",
"options",
".",
"bfile",
",",
"\"--loop-assoc\"",
",",
"options",
".",
"loop_assoc",
",",
"\"--f... | Execute the plate bias analysis with Plink.
:param options: the options.
:type options: argparse.Namespace | [
"Execute",
"the",
"plate",
"bias",
"analysis",
"with",
"Plink",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlateBias/plate_bias.py#L227-L239 |
lemieuxl/pyGenClean | pyGenClean/PlateBias/plate_bias.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Check if we have the tped and the tfam files",
"for",
"fileName",
"in",
"[",
"args",
".",
"bfile",
"+",
"i",
"for",
"i",
"in",
"[",
"\".bed\"",
",",
"\".bim\"",
",",
"\".fam\"",
"]",
"]",
":",
"if",
"not",
"os"... | Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` class, a message is printed to t... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlateBias/plate_bias.py#L265-L290 |
ryanpetrello/cleaver | cleaver/util.py | random_variant | def random_variant(variants, weights):
"""
A generator that, given a list of variants and a corresponding list of
weights, returns one random weighted selection.
"""
total = 0
accumulator = []
for w in weights:
total += w
accumulator.append(total)
r = randint(0, total - ... | python | def random_variant(variants, weights):
"""
A generator that, given a list of variants and a corresponding list of
weights, returns one random weighted selection.
"""
total = 0
accumulator = []
for w in weights:
total += w
accumulator.append(total)
r = randint(0, total - ... | [
"def",
"random_variant",
"(",
"variants",
",",
"weights",
")",
":",
"total",
"=",
"0",
"accumulator",
"=",
"[",
"]",
"for",
"w",
"in",
"weights",
":",
"total",
"+=",
"w",
"accumulator",
".",
"append",
"(",
"total",
")",
"r",
"=",
"randint",
"(",
"0",... | A generator that, given a list of variants and a corresponding list of
weights, returns one random weighted selection. | [
"A",
"generator",
"that",
"given",
"a",
"list",
"of",
"variants",
"and",
"a",
"corresponding",
"list",
"of",
"weights",
"returns",
"one",
"random",
"weighted",
"selection",
"."
] | train | https://github.com/ryanpetrello/cleaver/blob/0ef266e1a0603c6d414df4b9926ce2a59844db35/cleaver/util.py#L7-L19 |
rlgomes/delta | delta/parse.py | parse | def parse(duration, context=None):
"""
parse the duration string which contains a human readable duration and
return a datetime.timedelta object representing that duration
arguments:
duration - the duration string following a notation like so:
"1 hour"
"1 m... | python | def parse(duration, context=None):
"""
parse the duration string which contains a human readable duration and
return a datetime.timedelta object representing that duration
arguments:
duration - the duration string following a notation like so:
"1 hour"
"1 m... | [
"def",
"parse",
"(",
"duration",
",",
"context",
"=",
"None",
")",
":",
"matcher",
"=",
"_PATTERN",
".",
"match",
"(",
"duration",
")",
"if",
"matcher",
"is",
"None",
"or",
"matcher",
".",
"end",
"(",
")",
"<",
"len",
"(",
"duration",
")",
":",
"ra... | parse the duration string which contains a human readable duration and
return a datetime.timedelta object representing that duration
arguments:
duration - the duration string following a notation like so:
"1 hour"
"1 month and 3 days" "1 year 2 weeks and 75 days"
... | [
"parse",
"the",
"duration",
"string",
"which",
"contains",
"a",
"human",
"readable",
"duration",
"and",
"return",
"a",
"datetime",
".",
"timedelta",
"object",
"representing",
"that",
"duration"
] | train | https://github.com/rlgomes/delta/blob/a75146086a9777bb49b01e72e97aaa5cb0844fc9/delta/parse.py#L30-L159 |
lemieuxl/pyGenClean | pyGenClean/FlagMAF/flag_maf_zero.py | main | def main(argString=None):
"""The main function.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Computes the frequencies using Plinl (:py:func:`computeFrequency`).
3. Finds markers with MAF of 0, and saves them in a file
(:py:fun... | python | def main(argString=None):
"""The main function.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Computes the frequencies using Plinl (:py:func:`computeFrequency`).
3. Finds markers with MAF of 0, and saves them in a file
(:py:fun... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
"argString",
")",
"checkArgs",
"(",
"args",
")",
"logger",
".",
"info",
"(",
"\"Options used:\"",
")",
"for",
"key",
",",
"value",
"i... | The main function.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Computes the frequencies using Plinl (:py:func:`computeFrequency`).
3. Finds markers with MAF of 0, and saves them in a file
(:py:func:`findSnpWithMaf0`). | [
"The",
"main",
"function",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/FlagMAF/flag_maf_zero.py#L31-L60 |
lemieuxl/pyGenClean | pyGenClean/FlagMAF/flag_maf_zero.py | findSnpWithMaf0 | def findSnpWithMaf0(freqFileName, prefix):
"""Finds SNPs with MAF of 0 and put them in a file.
:param freqFileName: the name of the frequency file.
:param prefix: the prefix of all the files.
:type freqFileName: str
:type prefix: str
Reads a frequency file from Plink, and find markers with a ... | python | def findSnpWithMaf0(freqFileName, prefix):
"""Finds SNPs with MAF of 0 and put them in a file.
:param freqFileName: the name of the frequency file.
:param prefix: the prefix of all the files.
:type freqFileName: str
:type prefix: str
Reads a frequency file from Plink, and find markers with a ... | [
"def",
"findSnpWithMaf0",
"(",
"freqFileName",
",",
"prefix",
")",
":",
"maf_0_set",
"=",
"set",
"(",
")",
"na_set",
"=",
"set",
"(",
")",
"try",
":",
"with",
"open",
"(",
"freqFileName",
",",
"\"r\"",
")",
"as",
"inputFile",
":",
"headerIndex",
"=",
"... | Finds SNPs with MAF of 0 and put them in a file.
:param freqFileName: the name of the frequency file.
:param prefix: the prefix of all the files.
:type freqFileName: str
:type prefix: str
Reads a frequency file from Plink, and find markers with a minor allele
frequency of zero. | [
"Finds",
"SNPs",
"with",
"MAF",
"of",
"0",
"and",
"put",
"them",
"in",
"a",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/FlagMAF/flag_maf_zero.py#L63-L136 |
Tinche/bower-cache | bowercache/init.py | init_site | def init_site():
"""Initialize a Bower Cache site using the template."""
site_name = 'bowercachesite'
dir_name = sys.argv[1] if len(sys.argv) > 1 else site_name
settings = site_name + ".settings"
template_filename = resource_filename(bowercache.__name__,
'pr... | python | def init_site():
"""Initialize a Bower Cache site using the template."""
site_name = 'bowercachesite'
dir_name = sys.argv[1] if len(sys.argv) > 1 else site_name
settings = site_name + ".settings"
template_filename = resource_filename(bowercache.__name__,
'pr... | [
"def",
"init_site",
"(",
")",
":",
"site_name",
"=",
"'bowercachesite'",
"dir_name",
"=",
"sys",
".",
"argv",
"[",
"1",
"]",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
">",
"1",
"else",
"site_name",
"settings",
"=",
"site_name",
"+",
"\".settings\"",
"... | Initialize a Bower Cache site using the template. | [
"Initialize",
"a",
"Bower",
"Cache",
"site",
"using",
"the",
"template",
"."
] | train | https://github.com/Tinche/bower-cache/blob/1bf82c65a659c7eaa6b7aad90763d39ffd7f91fd/bowercache/init.py#L15-L44 |
gasparka/pyhacores | pyhacores/cordic/nco.py | NCO.main | def main(self, phase_inc):
"""
:param phase_inc: amount of rotation applied for next clock cycle, must be normalized to -1 to 1.
:rtype: Complex
"""
self.phase_acc = self.phase_acc + phase_inc
start_x = self.INIT_X
start_y = Sfix(0.0, 0, -17)
x, y, phase... | python | def main(self, phase_inc):
"""
:param phase_inc: amount of rotation applied for next clock cycle, must be normalized to -1 to 1.
:rtype: Complex
"""
self.phase_acc = self.phase_acc + phase_inc
start_x = self.INIT_X
start_y = Sfix(0.0, 0, -17)
x, y, phase... | [
"def",
"main",
"(",
"self",
",",
"phase_inc",
")",
":",
"self",
".",
"phase_acc",
"=",
"self",
".",
"phase_acc",
"+",
"phase_inc",
"start_x",
"=",
"self",
".",
"INIT_X",
"start_y",
"=",
"Sfix",
"(",
"0.0",
",",
"0",
",",
"-",
"17",
")",
"x",
",",
... | :param phase_inc: amount of rotation applied for next clock cycle, must be normalized to -1 to 1.
:rtype: Complex | [
":",
"param",
"phase_inc",
":",
"amount",
"of",
"rotation",
"applied",
"for",
"next",
"clock",
"cycle",
"must",
"be",
"normalized",
"to",
"-",
"1",
"to",
"1",
".",
":",
"rtype",
":",
"Complex"
] | train | https://github.com/gasparka/pyhacores/blob/16c186fbbf90385f2ba3498395123e79b6fcf340/pyhacores/cordic/nco.py#L20-L35 |
CulturePlex/django-zotero | django_zotero/templatetags/zotero_tags_extras.py | zotero_tags | def zotero_tags(parser, token):
"""
Returns the code to be translated by Zotero.
Usage:
{% zotero_tags
object=object
vocabulary=vocabulary
output_method=output_method %}
Example:
{% zotero_tags object=document1 vocabulary="dc" output_method="meta" %}
... | python | def zotero_tags(parser, token):
"""
Returns the code to be translated by Zotero.
Usage:
{% zotero_tags
object=object
vocabulary=vocabulary
output_method=output_method %}
Example:
{% zotero_tags object=document1 vocabulary="dc" output_method="meta" %}
... | [
"def",
"zotero_tags",
"(",
"parser",
",",
"token",
")",
":",
"default",
"=",
"{",
"'object'",
":",
"u''",
",",
"'vocabulary'",
":",
"u'dc'",
",",
"'output_method'",
":",
"u'meta'",
"}",
"letters",
"=",
"[",
"'zero'",
",",
"'one'",
",",
"'two'",
",",
"'... | Returns the code to be translated by Zotero.
Usage:
{% zotero_tags
object=object
vocabulary=vocabulary
output_method=output_method %}
Example:
{% zotero_tags object=document1 vocabulary="dc" output_method="meta" %} | [
"Returns",
"the",
"code",
"to",
"be",
"translated",
"by",
"Zotero",
".",
"Usage",
":",
"{",
"%",
"zotero_tags",
"object",
"=",
"object",
"vocabulary",
"=",
"vocabulary",
"output_method",
"=",
"output_method",
"%",
"}",
"Example",
":",
"{",
"%",
"zotero_tags"... | train | https://github.com/CulturePlex/django-zotero/blob/de31583a80a2bd2459c118fb5aa767a2842e0b00/django_zotero/templatetags/zotero_tags_extras.py#L9-L59 |
natemara/aloft.py | aloft/__init__.py | airport_codes | def airport_codes():
"""
Returns the set of airport codes that is available to be requested.
"""
html = requests.get(URL).text
data_block = _find_data_block(html)
return _airport_codes_from_data_block(data_block) | python | def airport_codes():
"""
Returns the set of airport codes that is available to be requested.
"""
html = requests.get(URL).text
data_block = _find_data_block(html)
return _airport_codes_from_data_block(data_block) | [
"def",
"airport_codes",
"(",
")",
":",
"html",
"=",
"requests",
".",
"get",
"(",
"URL",
")",
".",
"text",
"data_block",
"=",
"_find_data_block",
"(",
"html",
")",
"return",
"_airport_codes_from_data_block",
"(",
"data_block",
")"
] | Returns the set of airport codes that is available to be requested. | [
"Returns",
"the",
"set",
"of",
"airport",
"codes",
"that",
"is",
"available",
"to",
"be",
"requested",
"."
] | train | https://github.com/natemara/aloft.py/blob/be1e9a785aa0932bd7c761714977e70d2409181c/aloft/__init__.py#L50-L57 |
ilblackdragon/django-misc | misc/json_encode.py | json_encode | def json_encode(data):
"""
The main issues with django's default json serializer is that properties that
had been added to an object dynamically are being ignored (and it also has
problems with some models).
"""
def _any(data):
ret = None
# Opps, we used to check if it is of ty... | python | def json_encode(data):
"""
The main issues with django's default json serializer is that properties that
had been added to an object dynamically are being ignored (and it also has
problems with some models).
"""
def _any(data):
ret = None
# Opps, we used to check if it is of ty... | [
"def",
"json_encode",
"(",
"data",
")",
":",
"def",
"_any",
"(",
"data",
")",
":",
"ret",
"=",
"None",
"# Opps, we used to check if it is of type list, but that fails ",
"# i.e. in the case of django.newforms.utils.ErrorList, which extends",
"# the type \"list\". Oh man, that was a... | The main issues with django's default json serializer is that properties that
had been added to an object dynamically are being ignored (and it also has
problems with some models). | [
"The",
"main",
"issues",
"with",
"django",
"s",
"default",
"json",
"serializer",
"is",
"that",
"properties",
"that",
"had",
"been",
"added",
"to",
"an",
"object",
"dynamically",
"are",
"being",
"ignored",
"(",
"and",
"it",
"also",
"has",
"problems",
"with",
... | train | https://github.com/ilblackdragon/django-misc/blob/0accd2dc97de656a1c9e275be81e817f78a2eb9d/misc/json_encode.py#L24-L84 |
ilblackdragon/django-misc | misc/json_encode.py | json_template | def json_template(data, template_name, template_context):
"""Old style, use JSONTemplateResponse instead of this.
"""
html = render_to_string(template_name, template_context)
data = data or {}
data['html'] = html
return HttpResponse(json_encode(data), content_type='application/json') | python | def json_template(data, template_name, template_context):
"""Old style, use JSONTemplateResponse instead of this.
"""
html = render_to_string(template_name, template_context)
data = data or {}
data['html'] = html
return HttpResponse(json_encode(data), content_type='application/json') | [
"def",
"json_template",
"(",
"data",
",",
"template_name",
",",
"template_context",
")",
":",
"html",
"=",
"render_to_string",
"(",
"template_name",
",",
"template_context",
")",
"data",
"=",
"data",
"or",
"{",
"}",
"data",
"[",
"'html'",
"]",
"=",
"html",
... | Old style, use JSONTemplateResponse instead of this. | [
"Old",
"style",
"use",
"JSONTemplateResponse",
"instead",
"of",
"this",
"."
] | train | https://github.com/ilblackdragon/django-misc/blob/0accd2dc97de656a1c9e275be81e817f78a2eb9d/misc/json_encode.py#L89-L95 |
CulturePlex/django-zotero | django_zotero/signals.py | check_save | def check_save(sender, **kwargs):
"""
Checks item type uniqueness, field applicability and multiplicity.
"""
tag = kwargs['instance']
obj = Tag.get_object(tag)
previous_tags = Tag.get_tags(obj)
err_uniq = check_item_type_uniqueness(tag, previous_tags)
err_appl = check_field_applicab... | python | def check_save(sender, **kwargs):
"""
Checks item type uniqueness, field applicability and multiplicity.
"""
tag = kwargs['instance']
obj = Tag.get_object(tag)
previous_tags = Tag.get_tags(obj)
err_uniq = check_item_type_uniqueness(tag, previous_tags)
err_appl = check_field_applicab... | [
"def",
"check_save",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"tag",
"=",
"kwargs",
"[",
"'instance'",
"]",
"obj",
"=",
"Tag",
".",
"get_object",
"(",
"tag",
")",
"previous_tags",
"=",
"Tag",
".",
"get_tags",
"(",
"obj",
")",
"err_uniq",
"="... | Checks item type uniqueness, field applicability and multiplicity. | [
"Checks",
"item",
"type",
"uniqueness",
"field",
"applicability",
"and",
"multiplicity",
"."
] | train | https://github.com/CulturePlex/django-zotero/blob/de31583a80a2bd2459c118fb5aa767a2842e0b00/django_zotero/signals.py#L8-L21 |
CulturePlex/django-zotero | django_zotero/signals.py | check_item_type_uniqueness | def check_item_type_uniqueness(tag, previous_tags):
"""
Check the uniqueness of the 'item type' for an object.
"""
fail = False
#If the tag is being created...
if not tag.id:
#... and the new item type is different from previous item types (for
#example, different from the first ... | python | def check_item_type_uniqueness(tag, previous_tags):
"""
Check the uniqueness of the 'item type' for an object.
"""
fail = False
#If the tag is being created...
if not tag.id:
#... and the new item type is different from previous item types (for
#example, different from the first ... | [
"def",
"check_item_type_uniqueness",
"(",
"tag",
",",
"previous_tags",
")",
":",
"fail",
"=",
"False",
"#If the tag is being created...",
"if",
"not",
"tag",
".",
"id",
":",
"#... and the new item type is different from previous item types (for",
"#example, different from the f... | Check the uniqueness of the 'item type' for an object. | [
"Check",
"the",
"uniqueness",
"of",
"the",
"item",
"type",
"for",
"an",
"object",
"."
] | train | https://github.com/CulturePlex/django-zotero/blob/de31583a80a2bd2459c118fb5aa767a2842e0b00/django_zotero/signals.py#L24-L40 |
CulturePlex/django-zotero | django_zotero/signals.py | check_field_multiplicity | def check_field_multiplicity(tag, previous_tags):
"""
Check the multiplicity of a 'field' for an object.
"""
fail = False
#If the field is single
if not tag.field.multiple:
#If the tag is being created...
if not tag.id:
#... and the new field was already included in t... | python | def check_field_multiplicity(tag, previous_tags):
"""
Check the multiplicity of a 'field' for an object.
"""
fail = False
#If the field is single
if not tag.field.multiple:
#If the tag is being created...
if not tag.id:
#... and the new field was already included in t... | [
"def",
"check_field_multiplicity",
"(",
"tag",
",",
"previous_tags",
")",
":",
"fail",
"=",
"False",
"#If the field is single",
"if",
"not",
"tag",
".",
"field",
".",
"multiple",
":",
"#If the tag is being created...",
"if",
"not",
"tag",
".",
"id",
":",
"#... a... | Check the multiplicity of a 'field' for an object. | [
"Check",
"the",
"multiplicity",
"of",
"a",
"field",
"for",
"an",
"object",
"."
] | train | https://github.com/CulturePlex/django-zotero/blob/de31583a80a2bd2459c118fb5aa767a2842e0b00/django_zotero/signals.py#L51-L68 |
CulturePlex/django-zotero | django_zotero/signals.py | generate_error_message | def generate_error_message(tag, err_uniq, err_appl, err_mult):
"""
Generate the error message for an object.
"""
err = []
if err_uniq:
err.append('Uniqueness restriction: item type %s' % tag.item_type)
if err_appl:
err.append('Applicability restriction: field %s' % tag.field)
... | python | def generate_error_message(tag, err_uniq, err_appl, err_mult):
"""
Generate the error message for an object.
"""
err = []
if err_uniq:
err.append('Uniqueness restriction: item type %s' % tag.item_type)
if err_appl:
err.append('Applicability restriction: field %s' % tag.field)
... | [
"def",
"generate_error_message",
"(",
"tag",
",",
"err_uniq",
",",
"err_appl",
",",
"err_mult",
")",
":",
"err",
"=",
"[",
"]",
"if",
"err_uniq",
":",
"err",
".",
"append",
"(",
"'Uniqueness restriction: item type %s'",
"%",
"tag",
".",
"item_type",
")",
"if... | Generate the error message for an object. | [
"Generate",
"the",
"error",
"message",
"for",
"an",
"object",
"."
] | train | https://github.com/CulturePlex/django-zotero/blob/de31583a80a2bd2459c118fb5aa767a2842e0b00/django_zotero/signals.py#L71-L82 |
CulturePlex/django-zotero | django_zotero/signals.py | delete_tags | def delete_tags(sender, **kwargs):
"""
Delete the tags pointing to an object.
"""
try:
obj = kwargs.get('instance')
tags = Tag.get_tags(obj)
tags.delete()
except AttributeError:
pass | python | def delete_tags(sender, **kwargs):
"""
Delete the tags pointing to an object.
"""
try:
obj = kwargs.get('instance')
tags = Tag.get_tags(obj)
tags.delete()
except AttributeError:
pass | [
"def",
"delete_tags",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"obj",
"=",
"kwargs",
".",
"get",
"(",
"'instance'",
")",
"tags",
"=",
"Tag",
".",
"get_tags",
"(",
"obj",
")",
"tags",
".",
"delete",
"(",
")",
"except",
"Attribut... | Delete the tags pointing to an object. | [
"Delete",
"the",
"tags",
"pointing",
"to",
"an",
"object",
"."
] | train | https://github.com/CulturePlex/django-zotero/blob/de31583a80a2bd2459c118fb5aa767a2842e0b00/django_zotero/signals.py#L86-L95 |
d9magai/flake8-checkstyle | flake8_checkstyle/plugin.py | CheckstylePlugin.finished | def finished(self, filename):
"""Make Checkystyle ElementTree."""
if len(self.errors) < 1:
return
element = ET.SubElement(self.checkstyle_element, 'file', name=filename)
for error in self.errors:
message = error.code + ' ' + error.text
prefix = error.... | python | def finished(self, filename):
"""Make Checkystyle ElementTree."""
if len(self.errors) < 1:
return
element = ET.SubElement(self.checkstyle_element, 'file', name=filename)
for error in self.errors:
message = error.code + ' ' + error.text
prefix = error.... | [
"def",
"finished",
"(",
"self",
",",
"filename",
")",
":",
"if",
"len",
"(",
"self",
".",
"errors",
")",
"<",
"1",
":",
"return",
"element",
"=",
"ET",
".",
"SubElement",
"(",
"self",
".",
"checkstyle_element",
",",
"'file'",
",",
"name",
"=",
"filen... | Make Checkystyle ElementTree. | [
"Make",
"Checkystyle",
"ElementTree",
"."
] | train | https://github.com/d9magai/flake8-checkstyle/blob/9af5dd0260644516f0192945bee00111c0eff495/flake8_checkstyle/plugin.py#L48-L64 |
d9magai/flake8-checkstyle | flake8_checkstyle/plugin.py | CheckstylePlugin.stop | def stop(self):
"""Output Checkstyle XML reports."""
et = ET.ElementTree(self.checkstyle_element)
f = BytesIO()
et.write(f, encoding='utf-8', xml_declaration=True)
xml = f.getvalue().decode('utf-8')
if self.output_fd is None:
print(xml)
else:
... | python | def stop(self):
"""Output Checkstyle XML reports."""
et = ET.ElementTree(self.checkstyle_element)
f = BytesIO()
et.write(f, encoding='utf-8', xml_declaration=True)
xml = f.getvalue().decode('utf-8')
if self.output_fd is None:
print(xml)
else:
... | [
"def",
"stop",
"(",
"self",
")",
":",
"et",
"=",
"ET",
".",
"ElementTree",
"(",
"self",
".",
"checkstyle_element",
")",
"f",
"=",
"BytesIO",
"(",
")",
"et",
".",
"write",
"(",
"f",
",",
"encoding",
"=",
"'utf-8'",
",",
"xml_declaration",
"=",
"True",... | Output Checkstyle XML reports. | [
"Output",
"Checkstyle",
"XML",
"reports",
"."
] | train | https://github.com/d9magai/flake8-checkstyle/blob/9af5dd0260644516f0192945bee00111c0eff495/flake8_checkstyle/plugin.py#L66-L76 |
HewlettPackard/python-hpICsp | hpICsp/connectionHPOneView.py | connectionHPOneView.encode_multipart_formdata | def encode_multipart_formdata(self, fields, filename, verbose=False):
"""
fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data
to be uploaded as files
Return (content_type, body) ready for httplib... | python | def encode_multipart_formdata(self, fields, filename, verbose=False):
"""
fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data
to be uploaded as files
Return (content_type, body) ready for httplib... | [
"def",
"encode_multipart_formdata",
"(",
"self",
",",
"fields",
",",
"filename",
",",
"verbose",
"=",
"False",
")",
":",
"BOUNDARY",
"=",
"'----------ThIs_Is_tHe_bouNdaRY_$'",
"CRLF",
"=",
"'\\r\\n'",
"content_type",
"=",
"'multipart/form-data; boundary=%s'",
"%",
"BO... | fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data
to be uploaded as files
Return (content_type, body) ready for httplib.HTTP instance | [
"fields",
"is",
"a",
"sequence",
"of",
"(",
"name",
"value",
")",
"elements",
"for",
"regular",
"form",
"fields",
".",
"files",
"is",
"a",
"sequence",
"of",
"(",
"name",
"filename",
"value",
")",
"elements",
"for",
"data",
"to",
"be",
"uploaded",
"as",
... | train | https://github.com/HewlettPackard/python-hpICsp/blob/f9a7278cdf8fe5e530dc264c9cc69be54d28a4b5/hpICsp/connectionHPOneView.py#L159-L186 |
lemieuxl/pyGenClean | pyGenClean/NoCallHetero/clean_noCall_hetero_snps.py | main | def main(argString=None):
"""The main function of the module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Reads the ``tfam`` and ``tped`` files and find all heterozygous and all
failed markers (:py:func:`processTPEDandTFAM`).
... | python | def main(argString=None):
"""The main function of the module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Reads the ``tfam`` and ``tped`` files and find all heterozygous and all
failed markers (:py:func:`processTPEDandTFAM`).
... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
"argString",
")",
"checkArgs",
"(",
"args",
")",
"logger",
".",
"info",
"(",
"\"Options used:\"",
")",
"for",
"key",
",",
"value",
"i... | The main function of the module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Reads the ``tfam`` and ``tped`` files and find all heterozygous and all
failed markers (:py:func:`processTPEDandTFAM`). | [
"The",
"main",
"function",
"of",
"the",
"module",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/NoCallHetero/clean_noCall_hetero_snps.py#L32-L56 |
lemieuxl/pyGenClean | pyGenClean/NoCallHetero/clean_noCall_hetero_snps.py | processTPEDandTFAM | def processTPEDandTFAM(tped, tfam, prefix):
"""Process the TPED and TFAM files.
:param tped: the name of the ``tped`` file.
:param tfam: the name of the ``tfam`` file.
:param prefix: the prefix of the output files.
:type tped: str
:type tfam: str
:type prefix: str
Copies the original ... | python | def processTPEDandTFAM(tped, tfam, prefix):
"""Process the TPED and TFAM files.
:param tped: the name of the ``tped`` file.
:param tfam: the name of the ``tfam`` file.
:param prefix: the prefix of the output files.
:type tped: str
:type tfam: str
:type prefix: str
Copies the original ... | [
"def",
"processTPEDandTFAM",
"(",
"tped",
",",
"tfam",
",",
"prefix",
")",
":",
"# Copying the tfam file",
"try",
":",
"shutil",
".",
"copy",
"(",
"tfam",
",",
"prefix",
"+",
"\".tfam\"",
")",
"except",
"IOError",
":",
"msg",
"=",
"\"%s: can't write file\"",
... | Process the TPED and TFAM files.
:param tped: the name of the ``tped`` file.
:param tfam: the name of the ``tfam`` file.
:param prefix: the prefix of the output files.
:type tped: str
:type tfam: str
:type prefix: str
Copies the original ``tfam`` file into ``prefix.tfam``. Then, it reads ... | [
"Process",
"the",
"TPED",
"and",
"TFAM",
"files",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/NoCallHetero/clean_noCall_hetero_snps.py#L59-L148 |
lemieuxl/pyGenClean | pyGenClean/NoCallHetero/clean_noCall_hetero_snps.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Checking the input files",
"for",
"suffix",
"in",
"[",
"\".tped\"",
",",
"\".tfam\"",
"]",
":",
"fileName",
"=",
"args",
".",
"tfile",
"+",
"suffix",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"fileN... | Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` class, a message is printed to t... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/NoCallHetero/clean_noCall_hetero_snps.py#L151-L172 |
radujica/baloo | baloo/weld/weld_aggs.py | weld_count | def weld_count(array):
"""Returns the length of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
Returns
-------
WeldObject
Representation of this computation.
"""
obj_id, weld_obj = create_weld_object(array)
weld_template = _w... | python | def weld_count(array):
"""Returns the length of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
Returns
-------
WeldObject
Representation of this computation.
"""
obj_id, weld_obj = create_weld_object(array)
weld_template = _w... | [
"def",
"weld_count",
"(",
"array",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"weld_template",
"=",
"_weld_count_code",
"weld_obj",
".",
"weld_code",
"=",
"weld_template",
".",
"format",
"(",
"array",
"=",
"obj_id",
")",... | Returns the length of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
Returns
-------
WeldObject
Representation of this computation. | [
"Returns",
"the",
"length",
"of",
"the",
"array",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_aggs.py#L9-L29 |
radujica/baloo | baloo/weld/weld_aggs.py | weld_aggregate | def weld_aggregate(array, weld_type, operation):
"""Returns operation on the elements in the array.
Arguments
---------
array : WeldObject or numpy.ndarray
Input array.
weld_type : WeldType
Weld type of each element in the input array.
operation : {'+', '*', 'min', 'max'}
... | python | def weld_aggregate(array, weld_type, operation):
"""Returns operation on the elements in the array.
Arguments
---------
array : WeldObject or numpy.ndarray
Input array.
weld_type : WeldType
Weld type of each element in the input array.
operation : {'+', '*', 'min', 'max'}
... | [
"def",
"weld_aggregate",
"(",
"array",
",",
"weld_type",
",",
"operation",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"weld_template",
"=",
"_weld_aggregate_code",
"weld_obj",
".",
"weld_code",
"=",
"weld_template",
".",
"... | Returns operation on the elements in the array.
Arguments
---------
array : WeldObject or numpy.ndarray
Input array.
weld_type : WeldType
Weld type of each element in the input array.
operation : {'+', '*', 'min', 'max'}
Operation to apply.
Returns
-------
WeldO... | [
"Returns",
"operation",
"on",
"the",
"elements",
"in",
"the",
"array",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_aggs.py#L52-L78 |
radujica/baloo | baloo/weld/weld_aggs.py | weld_mean | def weld_mean(array, weld_type):
"""Returns the mean of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
Returns
-------
WeldObject
Representation of this computation.... | python | def weld_mean(array, weld_type):
"""Returns the mean of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
Returns
-------
WeldObject
Representation of this computation.... | [
"def",
"weld_mean",
"(",
"array",
",",
"weld_type",
")",
":",
"weld_obj_sum",
"=",
"weld_aggregate",
"(",
"array",
",",
"weld_type",
",",
"'+'",
")",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"weld_obj_sum_id",
"=",
"get_weld_obj... | Returns the mean of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
Returns
-------
WeldObject
Representation of this computation. | [
"Returns",
"the",
"mean",
"of",
"the",
"array",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_aggs.py#L84-L110 |
radujica/baloo | baloo/weld/weld_aggs.py | weld_variance | def weld_variance(array, weld_type):
"""Returns the variance of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
Returns
-------
WeldObject
Representation of this comp... | python | def weld_variance(array, weld_type):
"""Returns the variance of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
Returns
-------
WeldObject
Representation of this comp... | [
"def",
"weld_variance",
"(",
"array",
",",
"weld_type",
")",
":",
"weld_obj_mean",
"=",
"weld_mean",
"(",
"array",
",",
"weld_type",
")",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"weld_obj_mean_id",
"=",
"get_weld_obj_id",
"(",
... | Returns the variance of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
Returns
-------
WeldObject
Representation of this computation. | [
"Returns",
"the",
"variance",
"of",
"the",
"array",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_aggs.py#L124-L151 |
radujica/baloo | baloo/weld/weld_aggs.py | weld_standard_deviation | def weld_standard_deviation(array, weld_type):
"""Returns the *sample* standard deviation of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
Returns
-------
WeldObject
... | python | def weld_standard_deviation(array, weld_type):
"""Returns the *sample* standard deviation of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
Returns
-------
WeldObject
... | [
"def",
"weld_standard_deviation",
"(",
"array",
",",
"weld_type",
")",
":",
"weld_obj_var",
"=",
"weld_variance",
"(",
"array",
",",
"weld_type",
")",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"weld_obj_var",
")",
"weld_obj_var_id",
"=",
"get_weld... | Returns the *sample* standard deviation of the array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
Returns
-------
WeldObject
Representation of this computation. | [
"Returns",
"the",
"*",
"sample",
"*",
"standard",
"deviation",
"of",
"the",
"array",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_aggs.py#L157-L182 |
radujica/baloo | baloo/weld/weld_aggs.py | weld_agg | def weld_agg(array, weld_type, aggregations):
"""Multiple aggregations, optimized.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
aggregations : list of str
Which aggregations to comput... | python | def weld_agg(array, weld_type, aggregations):
"""Multiple aggregations, optimized.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
aggregations : list of str
Which aggregations to comput... | [
"def",
"weld_agg",
"(",
"array",
",",
"weld_type",
",",
"aggregations",
")",
":",
"from",
"functools",
"import",
"reduce",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"# find which aggregation computations are actually needed",
"to_compute",... | Multiple aggregations, optimized.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
aggregations : list of str
Which aggregations to compute.
Returns
-------
WeldObject
Re... | [
"Multiple",
"aggregations",
"optimized",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_aggs.py#L225-L268 |
mpasternak/django-dsl | django_dsl/parser.py | p_expression_b_op | def p_expression_b_op(p):
'''expression : expression B_OP expression'''
if p[2] == 'AND':
p[0] = p[1] & p[3]
elif p[2] == 'OR':
p[0] = p[1] | p[3] | python | def p_expression_b_op(p):
'''expression : expression B_OP expression'''
if p[2] == 'AND':
p[0] = p[1] & p[3]
elif p[2] == 'OR':
p[0] = p[1] | p[3] | [
"def",
"p_expression_b_op",
"(",
"p",
")",
":",
"if",
"p",
"[",
"2",
"]",
"==",
"'AND'",
":",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
"&",
"p",
"[",
"3",
"]",
"elif",
"p",
"[",
"2",
"]",
"==",
"'OR'",
":",
"p",
"[",
"0",
"]",
"=",
... | expression : expression B_OP expression | [
"expression",
":",
"expression",
"B_OP",
"expression"
] | train | https://github.com/mpasternak/django-dsl/blob/da1fe4da92503841a4ba5ae9db100248cf98437d/django_dsl/parser.py#L22-L27 |
mpasternak/django-dsl | django_dsl/parser.py | p_expression_ID | def p_expression_ID(p):
"""expression : FIELD operation value
"""
lookup = compa2lookup[p[2]]
try:
field = get_shortcut(p[1])
except KeyError:
field = p[1]
if lookup:
field = '%s__%s' % (field, lookup)
# In some situations (which ones?), python
# refuses unicod... | python | def p_expression_ID(p):
"""expression : FIELD operation value
"""
lookup = compa2lookup[p[2]]
try:
field = get_shortcut(p[1])
except KeyError:
field = p[1]
if lookup:
field = '%s__%s' % (field, lookup)
# In some situations (which ones?), python
# refuses unicod... | [
"def",
"p_expression_ID",
"(",
"p",
")",
":",
"lookup",
"=",
"compa2lookup",
"[",
"p",
"[",
"2",
"]",
"]",
"try",
":",
"field",
"=",
"get_shortcut",
"(",
"p",
"[",
"1",
"]",
")",
"except",
"KeyError",
":",
"field",
"=",
"p",
"[",
"1",
"]",
"if",
... | expression : FIELD operation value | [
"expression",
":",
"FIELD",
"operation",
"value"
] | train | https://github.com/mpasternak/django-dsl/blob/da1fe4da92503841a4ba5ae9db100248cf98437d/django_dsl/parser.py#L64-L84 |
jor-/util | util/math/sparse/solve.py | cholesky | def cholesky(L, b, P=None):
'''
P A P' = L L'
'''
logger.debug('Solving system of dim {} with cholesky factors'.format(len(b)))
## convert L and U to csr format
is_csr = scipy.sparse.isspmatrix_csr(L)
is_csc = scipy.sparse.isspmatrix_csc(L)
if not is_csr and not is_csc:
warnin... | python | def cholesky(L, b, P=None):
'''
P A P' = L L'
'''
logger.debug('Solving system of dim {} with cholesky factors'.format(len(b)))
## convert L and U to csr format
is_csr = scipy.sparse.isspmatrix_csr(L)
is_csc = scipy.sparse.isspmatrix_csc(L)
if not is_csr and not is_csc:
warnin... | [
"def",
"cholesky",
"(",
"L",
",",
"b",
",",
"P",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'Solving system of dim {} with cholesky factors'",
".",
"format",
"(",
"len",
"(",
"b",
")",
")",
")",
"## convert L and U to csr format",
"is_csr",
"=",
"s... | P A P' = L L' | [
"P",
"A",
"P",
"=",
"L",
"L"
] | train | https://github.com/jor-/util/blob/0eb0be84430f88885f4d48335596ca8881f85587/util/math/sparse/solve.py#L30-L55 |
Kromey/django-simplecaptcha | simplecaptcha/decorators.py | captchaform | def captchaform(field_name):
"""Decorator to add a simple captcha to a form
To use this decorator, you must specify the captcha field's name as an
argument to the decorator. For example:
@captchaform('captcha')
class MyForm(Form):
pass
This would add a new form field named 'captcha' t... | python | def captchaform(field_name):
"""Decorator to add a simple captcha to a form
To use this decorator, you must specify the captcha field's name as an
argument to the decorator. For example:
@captchaform('captcha')
class MyForm(Form):
pass
This would add a new form field named 'captcha' t... | [
"def",
"captchaform",
"(",
"field_name",
")",
":",
"def",
"wrapper",
"(",
"orig_form",
")",
":",
"\"\"\"The actual function that wraps and modifies the form\"\"\"",
"# Get the original init method so we can call it later",
"orig_init",
"=",
"orig_form",
".",
"__init__",
"def",
... | Decorator to add a simple captcha to a form
To use this decorator, you must specify the captcha field's name as an
argument to the decorator. For example:
@captchaform('captcha')
class MyForm(Form):
pass
This would add a new form field named 'captcha' to the Django form MyForm.
Nothin... | [
"Decorator",
"to",
"add",
"a",
"simple",
"captcha",
"to",
"a",
"form"
] | train | https://github.com/Kromey/django-simplecaptcha/blob/16dd401e3317daf78143e9250f98b48c22cabd2d/simplecaptcha/decorators.py#L4-L61 |
jcconnell/python-spotcrime | spotcrime/__init__.py | _validate_incident_date_range | def _validate_incident_date_range(incident, numdays):
"""Returns true if incident is within date range"""
try:
datetime_object = datetime.datetime.strptime(incident.get('date'), '%m/%d/%y %I:%M %p')
except ValueError:
raise ValueError("Incorrect date format, should be MM/DD/YY HH:MM AM/PM")
... | python | def _validate_incident_date_range(incident, numdays):
"""Returns true if incident is within date range"""
try:
datetime_object = datetime.datetime.strptime(incident.get('date'), '%m/%d/%y %I:%M %p')
except ValueError:
raise ValueError("Incorrect date format, should be MM/DD/YY HH:MM AM/PM")
... | [
"def",
"_validate_incident_date_range",
"(",
"incident",
",",
"numdays",
")",
":",
"try",
":",
"datetime_object",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"incident",
".",
"get",
"(",
"'date'",
")",
",",
"'%m/%d/%y %I:%M %p'",
")",
"except",
"Va... | Returns true if incident is within date range | [
"Returns",
"true",
"if",
"incident",
"is",
"within",
"date",
"range"
] | train | https://github.com/jcconnell/python-spotcrime/blob/3e0bde254a63e33c099ea509a0662be581ebe1bf/spotcrime/__init__.py#L18-L28 |
jcconnell/python-spotcrime | spotcrime/__init__.py | _incident_transform | def _incident_transform(incident):
"""Get output dict from incident."""
return {
'id': incident.get('cdid'),
'type': incident.get('type'),
'timestamp': incident.get('date'),
'lat': incident.get('lat'),
'lon': incident.get('lon'),
'location': incident.get('address'... | python | def _incident_transform(incident):
"""Get output dict from incident."""
return {
'id': incident.get('cdid'),
'type': incident.get('type'),
'timestamp': incident.get('date'),
'lat': incident.get('lat'),
'lon': incident.get('lon'),
'location': incident.get('address'... | [
"def",
"_incident_transform",
"(",
"incident",
")",
":",
"return",
"{",
"'id'",
":",
"incident",
".",
"get",
"(",
"'cdid'",
")",
",",
"'type'",
":",
"incident",
".",
"get",
"(",
"'type'",
")",
",",
"'timestamp'",
":",
"incident",
".",
"get",
"(",
"'dat... | Get output dict from incident. | [
"Get",
"output",
"dict",
"from",
"incident",
"."
] | train | https://github.com/jcconnell/python-spotcrime/blob/3e0bde254a63e33c099ea509a0662be581ebe1bf/spotcrime/__init__.py#L31-L41 |
jcconnell/python-spotcrime | spotcrime/__init__.py | SpotCrime.get_incidents | def get_incidents(self):
"""Get incidents."""
resp = requests.get(CRIME_URL, params=self._get_params(), headers=self.headers)
incidents = [] # type: List[Dict[str, str]]
data = resp.json()
if ATTR_CRIMES not in data:
return incidents
for incident in data.get(... | python | def get_incidents(self):
"""Get incidents."""
resp = requests.get(CRIME_URL, params=self._get_params(), headers=self.headers)
incidents = [] # type: List[Dict[str, str]]
data = resp.json()
if ATTR_CRIMES not in data:
return incidents
for incident in data.get(... | [
"def",
"get_incidents",
"(",
"self",
")",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"CRIME_URL",
",",
"params",
"=",
"self",
".",
"_get_params",
"(",
")",
",",
"headers",
"=",
"self",
".",
"headers",
")",
"incidents",
"=",
"[",
"]",
"# type: List[... | Get incidents. | [
"Get",
"incidents",
"."
] | train | https://github.com/jcconnell/python-spotcrime/blob/3e0bde254a63e33c099ea509a0662be581ebe1bf/spotcrime/__init__.py#L89-L100 |
david-caro/python-autosemver | autosemver/api.py | _needs_git | def _needs_git(func):
"""
Small decorator to make sure we have the git repo, or report error
otherwise.
"""
@wraps(func)
def myfunc(*args, **kwargs):
if not WITH_GIT:
raise RuntimeError(
"Dulwich library not available, can't extract info from the "
... | python | def _needs_git(func):
"""
Small decorator to make sure we have the git repo, or report error
otherwise.
"""
@wraps(func)
def myfunc(*args, **kwargs):
if not WITH_GIT:
raise RuntimeError(
"Dulwich library not available, can't extract info from the "
... | [
"def",
"_needs_git",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"myfunc",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"WITH_GIT",
":",
"raise",
"RuntimeError",
"(",
"\"Dulwich library not available, can't extract info... | Small decorator to make sure we have the git repo, or report error
otherwise. | [
"Small",
"decorator",
"to",
"make",
"sure",
"we",
"have",
"the",
"git",
"repo",
"or",
"report",
"error",
"otherwise",
"."
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/api.py#L77-L92 |
david-caro/python-autosemver | autosemver/api.py | tag_versions | def tag_versions(repo_path):
"""
Given a repo will add a tag for each major version.
Args:
repo_path(str): path to the git repository to tag.
"""
repo = dulwich.repo.Repo(repo_path)
tags = get_tags(repo)
maj_version = 0
feat_version = 0
fix_version = 0
last_maj_version =... | python | def tag_versions(repo_path):
"""
Given a repo will add a tag for each major version.
Args:
repo_path(str): path to the git repository to tag.
"""
repo = dulwich.repo.Repo(repo_path)
tags = get_tags(repo)
maj_version = 0
feat_version = 0
fix_version = 0
last_maj_version =... | [
"def",
"tag_versions",
"(",
"repo_path",
")",
":",
"repo",
"=",
"dulwich",
".",
"repo",
".",
"Repo",
"(",
"repo_path",
")",
"tags",
"=",
"get_tags",
"(",
"repo",
")",
"maj_version",
"=",
"0",
"feat_version",
"=",
"0",
"fix_version",
"=",
"0",
"last_maj_v... | Given a repo will add a tag for each major version.
Args:
repo_path(str): path to the git repository to tag. | [
"Given",
"a",
"repo",
"will",
"add",
"a",
"tag",
"for",
"each",
"major",
"version",
"."
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/api.py#L223-L267 |
david-caro/python-autosemver | autosemver/api.py | get_releasenotes | def get_releasenotes(repo_path, from_commit=None, bugtracker_url=''):
"""
Given a repo and optionally a base revision to start from, will return
a text suitable for the relase notes announcement, grouping the bugs, the
features and the api-breaking changes.
Args:
repo_path(str): Path to the... | python | def get_releasenotes(repo_path, from_commit=None, bugtracker_url=''):
"""
Given a repo and optionally a base revision to start from, will return
a text suitable for the relase notes announcement, grouping the bugs, the
features and the api-breaking changes.
Args:
repo_path(str): Path to the... | [
"def",
"get_releasenotes",
"(",
"repo_path",
",",
"from_commit",
"=",
"None",
",",
"bugtracker_url",
"=",
"''",
")",
":",
"repo",
"=",
"dulwich",
".",
"repo",
".",
"Repo",
"(",
"repo_path",
")",
"tags",
"=",
"get_tags",
"(",
"repo",
")",
"refs",
"=",
"... | Given a repo and optionally a base revision to start from, will return
a text suitable for the relase notes announcement, grouping the bugs, the
features and the api-breaking changes.
Args:
repo_path(str): Path to the code git repository.
from_commit(str): Refspec of the commit to start agg... | [
"Given",
"a",
"repo",
"and",
"optionally",
"a",
"base",
"revision",
"to",
"start",
"from",
"will",
"return",
"a",
"text",
"suitable",
"for",
"the",
"relase",
"notes",
"announcement",
"grouping",
"the",
"bugs",
"the",
"features",
"and",
"the",
"api",
"-",
"... | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/api.py#L310-L439 |
radujica/baloo | baloo/functions/unary.py | _weld_unary | def _weld_unary(array, weld_type, operation):
"""Apply operation on each element in the array.
As mentioned by Weld, the operations follow the behavior of the equivalent C functions from math.h
Parameters
----------
array : numpy.ndarray or WeldObject
Data
weld_type : WeldType
... | python | def _weld_unary(array, weld_type, operation):
"""Apply operation on each element in the array.
As mentioned by Weld, the operations follow the behavior of the equivalent C functions from math.h
Parameters
----------
array : numpy.ndarray or WeldObject
Data
weld_type : WeldType
... | [
"def",
"_weld_unary",
"(",
"array",
",",
"weld_type",
",",
"operation",
")",
":",
"if",
"weld_type",
"not",
"in",
"{",
"WeldFloat",
"(",
")",
",",
"WeldDouble",
"(",
")",
"}",
":",
"raise",
"TypeError",
"(",
"'Unary operation supported only on scalar f32 or f64'... | Apply operation on each element in the array.
As mentioned by Weld, the operations follow the behavior of the equivalent C functions from math.h
Parameters
----------
array : numpy.ndarray or WeldObject
Data
weld_type : WeldType
Of the data
operation : {'exp', 'log', 'sqrt', 's... | [
"Apply",
"operation",
"on",
"each",
"element",
"in",
"the",
"array",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/functions/unary.py#L4-L31 |
photo/openphoto-python | trovebox/objects/action.py | Action._update_fields_with_objects | def _update_fields_with_objects(self):
""" Convert dict fields into objects, where appropriate """
# Update the photo target with photo objects
if self.target is not None:
if self.target_type == "photo":
self.target = Photo(self._client, self.target)
else:... | python | def _update_fields_with_objects(self):
""" Convert dict fields into objects, where appropriate """
# Update the photo target with photo objects
if self.target is not None:
if self.target_type == "photo":
self.target = Photo(self._client, self.target)
else:... | [
"def",
"_update_fields_with_objects",
"(",
"self",
")",
":",
"# Update the photo target with photo objects",
"if",
"self",
".",
"target",
"is",
"not",
"None",
":",
"if",
"self",
".",
"target_type",
"==",
"\"photo\"",
":",
"self",
".",
"target",
"=",
"Photo",
"("... | Convert dict fields into objects, where appropriate | [
"Convert",
"dict",
"fields",
"into",
"objects",
"where",
"appropriate"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/action.py#L17-L25 |
photo/openphoto-python | trovebox/objects/action.py | Action.delete | def delete(self, **kwds):
"""
Endpoint: /action/<id>/delete.json
Deletes this action.
Returns True if successful.
Raises a TroveboxError if not.
"""
result = self._client.action.delete(self, **kwds)
self._delete_fields()
return result | python | def delete(self, **kwds):
"""
Endpoint: /action/<id>/delete.json
Deletes this action.
Returns True if successful.
Raises a TroveboxError if not.
"""
result = self._client.action.delete(self, **kwds)
self._delete_fields()
return result | [
"def",
"delete",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"action",
".",
"delete",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
"self",
".",
"_delete_fields",
"(",
")",
"return",
"result"
] | Endpoint: /action/<id>/delete.json
Deletes this action.
Returns True if successful.
Raises a TroveboxError if not. | [
"Endpoint",
":",
"/",
"action",
"/",
"<id",
">",
"/",
"delete",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/action.py#L27-L37 |
photo/openphoto-python | trovebox/objects/action.py | Action.view | def view(self, **kwds):
"""
Endpoint: /action/<id>/view.json
Requests the full contents of the action.
Updates the action object's fields with the response.
"""
result = self._client.action.view(self, **kwds)
self._replace_fields(result.get_fields())
self... | python | def view(self, **kwds):
"""
Endpoint: /action/<id>/view.json
Requests the full contents of the action.
Updates the action object's fields with the response.
"""
result = self._client.action.view(self, **kwds)
self._replace_fields(result.get_fields())
self... | [
"def",
"view",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"action",
".",
"view",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
"self",
".",
"_replace_fields",
"(",
"result",
".",
"get_fields",
"(",
")",
"... | Endpoint: /action/<id>/view.json
Requests the full contents of the action.
Updates the action object's fields with the response. | [
"Endpoint",
":",
"/",
"action",
"/",
"<id",
">",
"/",
"view",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/action.py#L39-L48 |
tenforce/docker-py-aiohttp | aiodockerpy/api/client.py | APIClient._stream_raw_result | async def _stream_raw_result(self, res):
''' Stream result for TTY-enabled container above API 1.6 '''
async with res.context as response:
response.raise_for_status()
async for out in response.content.iter_chunked(1):
yield out.decode() | python | async def _stream_raw_result(self, res):
''' Stream result for TTY-enabled container above API 1.6 '''
async with res.context as response:
response.raise_for_status()
async for out in response.content.iter_chunked(1):
yield out.decode() | [
"async",
"def",
"_stream_raw_result",
"(",
"self",
",",
"res",
")",
":",
"async",
"with",
"res",
".",
"context",
"as",
"response",
":",
"response",
".",
"raise_for_status",
"(",
")",
"async",
"for",
"out",
"in",
"response",
".",
"content",
".",
"iter_chunk... | Stream result for TTY-enabled container above API 1.6 | [
"Stream",
"result",
"for",
"TTY",
"-",
"enabled",
"container",
"above",
"API",
"1",
".",
"6"
] | train | https://github.com/tenforce/docker-py-aiohttp/blob/ab997f18bdbeb6d83abc6e5281934493552015f3/aiodockerpy/api/client.py#L142-L147 |
tenforce/docker-py-aiohttp | aiodockerpy/api/client.py | APIClient._stream_helper | async def _stream_helper(self, response, decode=False):
"""Generator for data coming from a chunked-encoded HTTP response."""
if decode:
async for chunk in json_stream(
self._stream_helper(response, False)):
yield chunk
else:
async wit... | python | async def _stream_helper(self, response, decode=False):
"""Generator for data coming from a chunked-encoded HTTP response."""
if decode:
async for chunk in json_stream(
self._stream_helper(response, False)):
yield chunk
else:
async wit... | [
"async",
"def",
"_stream_helper",
"(",
"self",
",",
"response",
",",
"decode",
"=",
"False",
")",
":",
"if",
"decode",
":",
"async",
"for",
"chunk",
"in",
"json_stream",
"(",
"self",
".",
"_stream_helper",
"(",
"response",
",",
"False",
")",
")",
":",
... | Generator for data coming from a chunked-encoded HTTP response. | [
"Generator",
"for",
"data",
"coming",
"from",
"a",
"chunked",
"-",
"encoded",
"HTTP",
"response",
"."
] | train | https://github.com/tenforce/docker-py-aiohttp/blob/ab997f18bdbeb6d83abc6e5281934493552015f3/aiodockerpy/api/client.py#L149-L165 |
lemieuxl/pyGenClean | pyGenClean/MarkerMissingness/snp_missingness.py | main | def main(argString=None):
"""The main function of the module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Runs Plink with the ``geno`` option (:py:func:`runPlink`).
3. Compares the two ``bim`` files (before and after the Plink ``gen... | python | def main(argString=None):
"""The main function of the module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Runs Plink with the ``geno`` option (:py:func:`runPlink`).
3. Compares the two ``bim`` files (before and after the Plink ``gen... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
"argString",
")",
"checkArgs",
"(",
"args",
")",
"logger",
".",
"info",
"(",
"\"Options used:\"",
")",
"for",
"key",
",",
"value",
"i... | The main function of the module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Runs Plink with the ``geno`` option (:py:func:`runPlink`).
3. Compares the two ``bim`` files (before and after the Plink ``geno``
analysis) (:py:func:`c... | [
"The",
"main",
"function",
"of",
"the",
"module",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/MarkerMissingness/snp_missingness.py#L31-L60 |
lemieuxl/pyGenClean | pyGenClean/MarkerMissingness/snp_missingness.py | compareBIM | def compareBIM(args):
"""Compare two BIM file.
:param args: the options.
:type args: argparse.Namespace
Creates a *Dummy* object to mimic an :py:class:`argparse.Namespace` class
containing the options for the :py:mod:`pyGenClean.PlinkUtils.compare_bim`
module.
"""
# Creating the Comp... | python | def compareBIM(args):
"""Compare two BIM file.
:param args: the options.
:type args: argparse.Namespace
Creates a *Dummy* object to mimic an :py:class:`argparse.Namespace` class
containing the options for the :py:mod:`pyGenClean.PlinkUtils.compare_bim`
module.
"""
# Creating the Comp... | [
"def",
"compareBIM",
"(",
"args",
")",
":",
"# Creating the CompareBIM options",
"class",
"Dummy",
"(",
"object",
")",
":",
"pass",
"compareBIM_args",
"=",
"Dummy",
"(",
")",
"compareBIM_args",
".",
"before",
"=",
"args",
".",
"bfile",
"+",
"\".bim\"",
"compar... | Compare two BIM file.
:param args: the options.
:type args: argparse.Namespace
Creates a *Dummy* object to mimic an :py:class:`argparse.Namespace` class
containing the options for the :py:mod:`pyGenClean.PlinkUtils.compare_bim`
module. | [
"Compare",
"two",
"BIM",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/MarkerMissingness/snp_missingness.py#L63-L94 |
lemieuxl/pyGenClean | pyGenClean/MarkerMissingness/snp_missingness.py | runPlink | def runPlink(options):
"""Runs Plink with the geno option.
:param options: the options.
:type options: argparse.Namespace
"""
# The plink command
plinkCommand = ["plink", "--noweb", "--bfile", options.bfile, "--geno",
str(options.geno), "--make-bed", "--out", options.out]
... | python | def runPlink(options):
"""Runs Plink with the geno option.
:param options: the options.
:type options: argparse.Namespace
"""
# The plink command
plinkCommand = ["plink", "--noweb", "--bfile", options.bfile, "--geno",
str(options.geno), "--make-bed", "--out", options.out]
... | [
"def",
"runPlink",
"(",
"options",
")",
":",
"# The plink command",
"plinkCommand",
"=",
"[",
"\"plink\"",
",",
"\"--noweb\"",
",",
"\"--bfile\"",
",",
"options",
".",
"bfile",
",",
"\"--geno\"",
",",
"str",
"(",
"options",
".",
"geno",
")",
",",
"\"--make-b... | Runs Plink with the geno option.
:param options: the options.
:type options: argparse.Namespace | [
"Runs",
"Plink",
"with",
"the",
"geno",
"option",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/MarkerMissingness/snp_missingness.py#L97-L115 |
widdowquinn/pyADHoRe | pyadhore/iadhore.py | read | def read(mfile, sfile):
""" Returns an IadhoreData object, constructed from the passed
i-ADHoRe multiplicon and segments output.
- mfile (str), location of multiplicons.txt
- sfile (str), location of segments.txt
"""
assert os.path.isfile(mfile), "%s multiplicon file does not exist"... | python | def read(mfile, sfile):
""" Returns an IadhoreData object, constructed from the passed
i-ADHoRe multiplicon and segments output.
- mfile (str), location of multiplicons.txt
- sfile (str), location of segments.txt
"""
assert os.path.isfile(mfile), "%s multiplicon file does not exist"... | [
"def",
"read",
"(",
"mfile",
",",
"sfile",
")",
":",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"mfile",
")",
",",
"\"%s multiplicon file does not exist\"",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"sfile",
")",
",",
"\"%s segments file does no... | Returns an IadhoreData object, constructed from the passed
i-ADHoRe multiplicon and segments output.
- mfile (str), location of multiplicons.txt
- sfile (str), location of segments.txt | [
"Returns",
"an",
"IadhoreData",
"object",
"constructed",
"from",
"the",
"passed",
"i",
"-",
"ADHoRe",
"multiplicon",
"and",
"segments",
"output",
"."
] | train | https://github.com/widdowquinn/pyADHoRe/blob/b2ebbf6ae9c6afe9262eb0e3d9cf395970e38533/pyadhore/iadhore.py#L366-L375 |
widdowquinn/pyADHoRe | pyadhore/iadhore.py | IadhoreData._dbsetup | def _dbsetup(self):
""" Create/open local SQLite database
"""
self._dbconn = sqlite3.connect(self._db_file)
# Create table for multiplicons
sql = '''CREATE TABLE multiplicons
(id, genome_x, list_x, parent, genome_y, list_y, level,
number_of_anch... | python | def _dbsetup(self):
""" Create/open local SQLite database
"""
self._dbconn = sqlite3.connect(self._db_file)
# Create table for multiplicons
sql = '''CREATE TABLE multiplicons
(id, genome_x, list_x, parent, genome_y, list_y, level,
number_of_anch... | [
"def",
"_dbsetup",
"(",
"self",
")",
":",
"self",
".",
"_dbconn",
"=",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"_db_file",
")",
"# Create table for multiplicons",
"sql",
"=",
"'''CREATE TABLE multiplicons\n (id, genome_x, list_x, parent, genome_y, list_... | Create/open local SQLite database | [
"Create",
"/",
"open",
"local",
"SQLite",
"database"
] | train | https://github.com/widdowquinn/pyADHoRe/blob/b2ebbf6ae9c6afe9262eb0e3d9cf395970e38533/pyadhore/iadhore.py#L82-L96 |
widdowquinn/pyADHoRe | pyadhore/iadhore.py | IadhoreData._parse_multiplicons | def _parse_multiplicons(self):
""" Read the multiplicon output file, and parse into a (i) tree using
NetworkX, and (ii) an SQLite database.
"""
# Parse data with csv reader
reader = csv.reader(open(self._multiplicon_file, 'rU'),
delimiter='\t')
... | python | def _parse_multiplicons(self):
""" Read the multiplicon output file, and parse into a (i) tree using
NetworkX, and (ii) an SQLite database.
"""
# Parse data with csv reader
reader = csv.reader(open(self._multiplicon_file, 'rU'),
delimiter='\t')
... | [
"def",
"_parse_multiplicons",
"(",
"self",
")",
":",
"# Parse data with csv reader",
"reader",
"=",
"csv",
".",
"reader",
"(",
"open",
"(",
"self",
".",
"_multiplicon_file",
",",
"'rU'",
")",
",",
"delimiter",
"=",
"'\\t'",
")",
"for",
"row",
"in",
"reader",... | Read the multiplicon output file, and parse into a (i) tree using
NetworkX, and (ii) an SQLite database. | [
"Read",
"the",
"multiplicon",
"output",
"file",
"and",
"parse",
"into",
"a",
"(",
"i",
")",
"tree",
"using",
"NetworkX",
"and",
"(",
"ii",
")",
"an",
"SQLite",
"database",
"."
] | train | https://github.com/widdowquinn/pyADHoRe/blob/b2ebbf6ae9c6afe9262eb0e3d9cf395970e38533/pyadhore/iadhore.py#L98-L120 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.