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 |
|---|---|---|---|---|---|---|---|---|---|---|
wolfhong/formic | formic/treewalk.py | TreeWalk.tree_walk | def tree_walk(cls, directory, tree):
"""Walks a tree returned by `cls.list_to_tree` returning a list of
3-tuples as if from os.walk()."""
results = []
dirs = [d for d in tree if d != FILE_MARKER]
files = tree[FILE_MARKER]
results.append((directory, dirs, files))
f... | python | def tree_walk(cls, directory, tree):
"""Walks a tree returned by `cls.list_to_tree` returning a list of
3-tuples as if from os.walk()."""
results = []
dirs = [d for d in tree if d != FILE_MARKER]
files = tree[FILE_MARKER]
results.append((directory, dirs, files))
f... | [
"def",
"tree_walk",
"(",
"cls",
",",
"directory",
",",
"tree",
")",
":",
"results",
"=",
"[",
"]",
"dirs",
"=",
"[",
"d",
"for",
"d",
"in",
"tree",
"if",
"d",
"!=",
"FILE_MARKER",
"]",
"files",
"=",
"tree",
"[",
"FILE_MARKER",
"]",
"results",
".",
... | Walks a tree returned by `cls.list_to_tree` returning a list of
3-tuples as if from os.walk(). | [
"Walks",
"a",
"tree",
"returned",
"by",
"cls",
".",
"list_to_tree",
"returning",
"a",
"list",
"of",
"3",
"-",
"tuples",
"as",
"if",
"from",
"os",
".",
"walk",
"()",
"."
] | train | https://github.com/wolfhong/formic/blob/0d81eb88dcbb6fa705194fc6ccf2993f4abbaa76/formic/treewalk.py#L34-L45 |
wolfhong/formic | formic/treewalk.py | TreeWalk.walk_from_list | def walk_from_list(cls, files):
"""A function that mimics :func:`os.walk()` by simulating a directory with
the list of files passed as an argument.
:param files: A list of file paths
:return: A function that mimics :func:`os.walk()` walking a directory
containing only t... | python | def walk_from_list(cls, files):
"""A function that mimics :func:`os.walk()` by simulating a directory with
the list of files passed as an argument.
:param files: A list of file paths
:return: A function that mimics :func:`os.walk()` walking a directory
containing only t... | [
"def",
"walk_from_list",
"(",
"cls",
",",
"files",
")",
":",
"tree",
"=",
"cls",
".",
"list_to_tree",
"(",
"files",
")",
"def",
"walk",
"(",
"directory",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"cls",
".",
"tree_walk",
"(",
"directory",
",",
"tr... | A function that mimics :func:`os.walk()` by simulating a directory with
the list of files passed as an argument.
:param files: A list of file paths
:return: A function that mimics :func:`os.walk()` walking a directory
containing only the files listed in the argument | [
"A",
"function",
"that",
"mimics",
":",
"func",
":",
"os",
".",
"walk",
"()",
"by",
"simulating",
"a",
"directory",
"with",
"the",
"list",
"of",
"files",
"passed",
"as",
"an",
"argument",
"."
] | train | https://github.com/wolfhong/formic/blob/0d81eb88dcbb6fa705194fc6ccf2993f4abbaa76/formic/treewalk.py#L48-L61 |
wichmannpas/django-rest-authtoken | rest_authtoken/models.py | AuthToken.create_token_for_user | def create_token_for_user(user: get_user_model()) -> bytes:
"""
Create a new random auth token for user.
"""
token = urandom(48)
AuthToken.objects.create(
hashed_token=AuthToken._hash_token(token),
user=user)
return token | python | def create_token_for_user(user: get_user_model()) -> bytes:
"""
Create a new random auth token for user.
"""
token = urandom(48)
AuthToken.objects.create(
hashed_token=AuthToken._hash_token(token),
user=user)
return token | [
"def",
"create_token_for_user",
"(",
"user",
":",
"get_user_model",
"(",
")",
")",
"->",
"bytes",
":",
"token",
"=",
"urandom",
"(",
"48",
")",
"AuthToken",
".",
"objects",
".",
"create",
"(",
"hashed_token",
"=",
"AuthToken",
".",
"_hash_token",
"(",
"tok... | Create a new random auth token for user. | [
"Create",
"a",
"new",
"random",
"auth",
"token",
"for",
"user",
"."
] | train | https://github.com/wichmannpas/django-rest-authtoken/blob/ef9153a64bfa5c30be10b0c53a74bd1d11f02cc6/rest_authtoken/models.py#L36-L44 |
radujica/baloo | baloo/core/series.py | Series.str | def str(self):
"""Get Access to string functions.
Returns
-------
StringMethods
Examples
--------
>>> sr = bl.Series([b' aB ', b'GoOsfrABA'])
>>> print(sr.str.lower().evaluate())
<BLANKLINE>
--- ---------
0 ab
1 go... | python | def str(self):
"""Get Access to string functions.
Returns
-------
StringMethods
Examples
--------
>>> sr = bl.Series([b' aB ', b'GoOsfrABA'])
>>> print(sr.str.lower().evaluate())
<BLANKLINE>
--- ---------
0 ab
1 go... | [
"def",
"str",
"(",
"self",
")",
":",
"if",
"self",
".",
"dtype",
".",
"char",
"!=",
"'S'",
":",
"raise",
"AttributeError",
"(",
"'Can only use .str when data is of type np.bytes_'",
")",
"from",
".",
"strings",
"import",
"StringMethods",
"return",
"StringMethods",... | Get Access to string functions.
Returns
-------
StringMethods
Examples
--------
>>> sr = bl.Series([b' aB ', b'GoOsfrABA'])
>>> print(sr.str.lower().evaluate())
<BLANKLINE>
--- ---------
0 ab
1 goosfraba | [
"Get",
"Access",
"to",
"string",
"functions",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/series.py#L143-L165 |
radujica/baloo | baloo/core/series.py | Series.evaluate | def evaluate(self, verbose=False, decode=True, passes=None, num_threads=1, apply_experimental=True):
"""Evaluates by creating a Series containing evaluated data and index.
See `LazyResult`
Returns
-------
Series
Series with evaluated data and index.
Example... | python | def evaluate(self, verbose=False, decode=True, passes=None, num_threads=1, apply_experimental=True):
"""Evaluates by creating a Series containing evaluated data and index.
See `LazyResult`
Returns
-------
Series
Series with evaluated data and index.
Example... | [
"def",
"evaluate",
"(",
"self",
",",
"verbose",
"=",
"False",
",",
"decode",
"=",
"True",
",",
"passes",
"=",
"None",
",",
"num_threads",
"=",
"1",
",",
"apply_experimental",
"=",
"True",
")",
":",
"# TODO: work on masking (branch masking) ~ evaluate the mask firs... | Evaluates by creating a Series containing evaluated data and index.
See `LazyResult`
Returns
-------
Series
Series with evaluated data and index.
Examples
--------
>>> sr = bl.Series(np.arange(3)) > 0
>>> weld_code = sr.values # accessing v... | [
"Evaluates",
"by",
"creating",
"a",
"Series",
"containing",
"evaluated",
"data",
"and",
"index",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/series.py#L269-L293 |
radujica/baloo | baloo/core/series.py | Series.tail | def tail(self, n=5):
"""Return Series with the last n values.
Parameters
----------
n : int
Number of values.
Returns
-------
Series
Series containing the last n values.
Examples
--------
>>> sr = bl.Series(np.ara... | python | def tail(self, n=5):
"""Return Series with the last n values.
Parameters
----------
n : int
Number of values.
Returns
-------
Series
Series containing the last n values.
Examples
--------
>>> sr = bl.Series(np.ara... | [
"def",
"tail",
"(",
"self",
",",
"n",
"=",
"5",
")",
":",
"if",
"self",
".",
"_length",
"is",
"not",
"None",
":",
"length",
"=",
"self",
".",
"_length",
"else",
":",
"length",
"=",
"self",
".",
"_lazy_len",
"(",
")",
".",
"weld_expr",
"return",
"... | Return Series with the last n values.
Parameters
----------
n : int
Number of values.
Returns
-------
Series
Series containing the last n values.
Examples
--------
>>> sr = bl.Series(np.arange(3))
>>> print(sr.tai... | [
"Return",
"Series",
"with",
"the",
"last",
"n",
"values",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/series.py#L320-L348 |
radujica/baloo | baloo/core/series.py | Series.agg | def agg(self, aggregations):
"""Multiple aggregations optimized.
Parameters
----------
aggregations : list of str
Which aggregations to perform.
Returns
-------
Series
Series with resulting aggregations.
"""
check_type(ag... | python | def agg(self, aggregations):
"""Multiple aggregations optimized.
Parameters
----------
aggregations : list of str
Which aggregations to perform.
Returns
-------
Series
Series with resulting aggregations.
"""
check_type(ag... | [
"def",
"agg",
"(",
"self",
",",
"aggregations",
")",
":",
"check_type",
"(",
"aggregations",
",",
"list",
")",
"new_index",
"=",
"Index",
"(",
"np",
".",
"array",
"(",
"aggregations",
",",
"dtype",
"=",
"np",
".",
"bytes_",
")",
",",
"np",
".",
"dtyp... | Multiple aggregations optimized.
Parameters
----------
aggregations : list of str
Which aggregations to perform.
Returns
-------
Series
Series with resulting aggregations. | [
"Multiple",
"aggregations",
"optimized",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/series.py#L370-L388 |
radujica/baloo | baloo/core/series.py | Series.unique | def unique(self):
"""Return unique values in the Series.
Note that because it is hash-based, the result will NOT be in the same order (unlike pandas).
Returns
-------
LazyArrayResult
Unique values in random order.
"""
return LazyArrayResult(weld_uni... | python | def unique(self):
"""Return unique values in the Series.
Note that because it is hash-based, the result will NOT be in the same order (unlike pandas).
Returns
-------
LazyArrayResult
Unique values in random order.
"""
return LazyArrayResult(weld_uni... | [
"def",
"unique",
"(",
"self",
")",
":",
"return",
"LazyArrayResult",
"(",
"weld_unique",
"(",
"self",
".",
"values",
",",
"self",
".",
"weld_type",
")",
",",
"self",
".",
"weld_type",
")"
] | Return unique values in the Series.
Note that because it is hash-based, the result will NOT be in the same order (unlike pandas).
Returns
-------
LazyArrayResult
Unique values in random order. | [
"Return",
"unique",
"values",
"in",
"the",
"Series",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/series.py#L390-L403 |
radujica/baloo | baloo/core/series.py | Series.fillna | def fillna(self, value):
"""Returns Series with missing values replaced with value.
Parameters
----------
value : {int, float, bytes, bool}
Scalar value to replace missing values with.
Returns
-------
Series
With missing values replaced.
... | python | def fillna(self, value):
"""Returns Series with missing values replaced with value.
Parameters
----------
value : {int, float, bytes, bool}
Scalar value to replace missing values with.
Returns
-------
Series
With missing values replaced.
... | [
"def",
"fillna",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"is_scalar",
"(",
"value",
")",
":",
"raise",
"TypeError",
"(",
"'Value to replace with is not a valid scalar'",
")",
"return",
"Series",
"(",
"weld_replace",
"(",
"self",
".",
"weld_expr",
","... | Returns Series with missing values replaced with value.
Parameters
----------
value : {int, float, bytes, bool}
Scalar value to replace missing values with.
Returns
-------
Series
With missing values replaced. | [
"Returns",
"Series",
"with",
"missing",
"values",
"replaced",
"with",
"value",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/series.py#L416-L439 |
radujica/baloo | baloo/core/series.py | Series.apply | def apply(self, func, mapping=None, new_dtype=None, **kwargs):
"""Apply an element-wise UDF to the Series.
There are currently 6 options for using a UDF. First 4 are lazy,
other 2 are eager and require the use of the raw decorator:
- One of the predefined functions in baloo.functions.
... | python | def apply(self, func, mapping=None, new_dtype=None, **kwargs):
"""Apply an element-wise UDF to the Series.
There are currently 6 options for using a UDF. First 4 are lazy,
other 2 are eager and require the use of the raw decorator:
- One of the predefined functions in baloo.functions.
... | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"mapping",
"=",
"None",
",",
"new_dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"callable",
"(",
"func",
")",
":",
"return",
"Series",
"(",
"func",
"(",
"self",
".",
"values",
",",
"w... | Apply an element-wise UDF to the Series.
There are currently 6 options for using a UDF. First 4 are lazy,
other 2 are eager and require the use of the raw decorator:
- One of the predefined functions in baloo.functions.
- Implementing a function which encodes the result. kwargs are aut... | [
"Apply",
"an",
"element",
"-",
"wise",
"UDF",
"to",
"the",
"Series",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/series.py#L441-L548 |
radujica/baloo | baloo/core/series.py | Series.from_pandas | def from_pandas(cls, series):
"""Create baloo Series from pandas Series.
Parameters
----------
series : pandas.series.Series
Returns
-------
Series
"""
from pandas import Index as PandasIndex, MultiIndex as PandasMultiIndex
if isinstanc... | python | def from_pandas(cls, series):
"""Create baloo Series from pandas Series.
Parameters
----------
series : pandas.series.Series
Returns
-------
Series
"""
from pandas import Index as PandasIndex, MultiIndex as PandasMultiIndex
if isinstanc... | [
"def",
"from_pandas",
"(",
"cls",
",",
"series",
")",
":",
"from",
"pandas",
"import",
"Index",
"as",
"PandasIndex",
",",
"MultiIndex",
"as",
"PandasMultiIndex",
"if",
"isinstance",
"(",
"series",
".",
"index",
",",
"PandasIndex",
")",
":",
"baloo_index",
"=... | Create baloo Series from pandas Series.
Parameters
----------
series : pandas.series.Series
Returns
-------
Series | [
"Create",
"baloo",
"Series",
"from",
"pandas",
"Series",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/series.py#L551-L572 |
photo/openphoto-python | trovebox/api/api_system.py | ApiSystem.diagnostics | def diagnostics(self, **kwds):
"""
Endpoint: /system/diagnostics.json
Runs a set of diagnostic tests on the server.
Returns a dictionary containing the results.
"""
# Don't process the result automatically, since this raises an exception
# on failure, which doesn... | python | def diagnostics(self, **kwds):
"""
Endpoint: /system/diagnostics.json
Runs a set of diagnostic tests on the server.
Returns a dictionary containing the results.
"""
# Don't process the result automatically, since this raises an exception
# on failure, which doesn... | [
"def",
"diagnostics",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"# Don't process the result automatically, since this raises an exception",
"# on failure, which doesn't provide the cause of the failure",
"self",
".",
"_client",
".",
"get",
"(",
"\"/system/diagnostics.json\"",... | Endpoint: /system/diagnostics.json
Runs a set of diagnostic tests on the server.
Returns a dictionary containing the results. | [
"Endpoint",
":",
"/",
"system",
"/",
"diagnostics",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_system.py#L16-L27 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | read_source_manifest | def read_source_manifest(file_name):
"""Reads Illumina manifest."""
alleles = {}
open_function = open
if file_name.endswith(".gz"):
open_function = gzip.open
with open_function(file_name, 'rb') as input_file:
header_index = dict([
(col_name, i) for i, col_name in
... | python | def read_source_manifest(file_name):
"""Reads Illumina manifest."""
alleles = {}
open_function = open
if file_name.endswith(".gz"):
open_function = gzip.open
with open_function(file_name, 'rb') as input_file:
header_index = dict([
(col_name, i) for i, col_name in
... | [
"def",
"read_source_manifest",
"(",
"file_name",
")",
":",
"alleles",
"=",
"{",
"}",
"open_function",
"=",
"open",
"if",
"file_name",
".",
"endswith",
"(",
"\".gz\"",
")",
":",
"open_function",
"=",
"gzip",
".",
"open",
"with",
"open_function",
"(",
"file_na... | Reads Illumina manifest. | [
"Reads",
"Illumina",
"manifest",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L144-L172 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | read_source_alleles | def read_source_alleles(file_name):
"""Reads an allele file."""
alleles = {}
open_function = open
if file_name.endswith(".gz"):
open_function = gzip.open
with open_function(file_name, 'rb') as input_file:
for line in input_file:
row = line.rstrip("\r\n").split("\t")
... | python | def read_source_alleles(file_name):
"""Reads an allele file."""
alleles = {}
open_function = open
if file_name.endswith(".gz"):
open_function = gzip.open
with open_function(file_name, 'rb') as input_file:
for line in input_file:
row = line.rstrip("\r\n").split("\t")
... | [
"def",
"read_source_alleles",
"(",
"file_name",
")",
":",
"alleles",
"=",
"{",
"}",
"open_function",
"=",
"open",
"if",
"file_name",
".",
"endswith",
"(",
"\".gz\"",
")",
":",
"open_function",
"=",
"gzip",
".",
"open",
"with",
"open_function",
"(",
"file_nam... | Reads an allele file. | [
"Reads",
"an",
"allele",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L175-L188 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | compute_statistics | def compute_statistics(out_dir, gold_prefix, source_prefix, same_samples,
use_sge, final_out_prefix):
"""Compute the statistics."""
# Now, creating a temporary directory
if not os.path.isdir(out_dir):
try:
os.mkdir(out_dir)
except OSError:
msg =... | python | def compute_statistics(out_dir, gold_prefix, source_prefix, same_samples,
use_sge, final_out_prefix):
"""Compute the statistics."""
# Now, creating a temporary directory
if not os.path.isdir(out_dir):
try:
os.mkdir(out_dir)
except OSError:
msg =... | [
"def",
"compute_statistics",
"(",
"out_dir",
",",
"gold_prefix",
",",
"source_prefix",
",",
"same_samples",
",",
"use_sge",
",",
"final_out_prefix",
")",
":",
"# Now, creating a temporary directory",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"out_dir",
")... | Compute the statistics. | [
"Compute",
"the",
"statistics",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L248-L401 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | check_fam_for_samples | def check_fam_for_samples(required_samples, source, gold):
"""Check fam files for required_samples."""
# Checking the source panel
source_samples = set()
with open(source, 'r') as input_file:
for line in input_file:
sample = tuple(line.rstrip("\r\n").split(" ")[:2])
if sa... | python | def check_fam_for_samples(required_samples, source, gold):
"""Check fam files for required_samples."""
# Checking the source panel
source_samples = set()
with open(source, 'r') as input_file:
for line in input_file:
sample = tuple(line.rstrip("\r\n").split(" ")[:2])
if sa... | [
"def",
"check_fam_for_samples",
"(",
"required_samples",
",",
"source",
",",
"gold",
")",
":",
"# Checking the source panel",
"source_samples",
"=",
"set",
"(",
")",
"with",
"open",
"(",
"source",
",",
"'r'",
")",
"as",
"input_file",
":",
"for",
"line",
"in",
... | Check fam files for required_samples. | [
"Check",
"fam",
"files",
"for",
"required_samples",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L404-L433 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | read_same_samples_file | def read_same_samples_file(filename, out_prefix):
"""Reads a file containing same samples."""
# The same samples
same_samples = []
# Creating the extraction files
gold_file = None
try:
gold_file = open(out_prefix + ".gold_samples2keep", 'w')
except IOError:
msg = "{}: can't ... | python | def read_same_samples_file(filename, out_prefix):
"""Reads a file containing same samples."""
# The same samples
same_samples = []
# Creating the extraction files
gold_file = None
try:
gold_file = open(out_prefix + ".gold_samples2keep", 'w')
except IOError:
msg = "{}: can't ... | [
"def",
"read_same_samples_file",
"(",
"filename",
",",
"out_prefix",
")",
":",
"# The same samples",
"same_samples",
"=",
"[",
"]",
"# Creating the extraction files",
"gold_file",
"=",
"None",
"try",
":",
"gold_file",
"=",
"open",
"(",
"out_prefix",
"+",
"\".gold_sa... | Reads a file containing same samples. | [
"Reads",
"a",
"file",
"containing",
"same",
"samples",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L436-L474 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | flipSNPs | def flipSNPs(inPrefix, outPrefix, flipFileName):
"""Flip SNPs using Plink."""
plinkCommand = ["plink", "--noweb", "--bfile", inPrefix, "--flip",
flipFileName, "--make-bed", "--out", outPrefix]
runCommand(plinkCommand) | python | def flipSNPs(inPrefix, outPrefix, flipFileName):
"""Flip SNPs using Plink."""
plinkCommand = ["plink", "--noweb", "--bfile", inPrefix, "--flip",
flipFileName, "--make-bed", "--out", outPrefix]
runCommand(plinkCommand) | [
"def",
"flipSNPs",
"(",
"inPrefix",
",",
"outPrefix",
",",
"flipFileName",
")",
":",
"plinkCommand",
"=",
"[",
"\"plink\"",
",",
"\"--noweb\"",
",",
"\"--bfile\"",
",",
"inPrefix",
",",
"\"--flip\"",
",",
"flipFileName",
",",
"\"--make-bed\"",
",",
"\"--out\"",
... | Flip SNPs using Plink. | [
"Flip",
"SNPs",
"using",
"Plink",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L477-L481 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | exclude_SNPs_samples | def exclude_SNPs_samples(inPrefix, outPrefix, exclusionSNP=None,
keepSample=None, transpose=False):
"""Exclude some SNPs and keep some samples using Plink."""
if (exclusionSNP is None) and (keepSample is None):
msg = "Something wront with development... work on that source code.... | python | def exclude_SNPs_samples(inPrefix, outPrefix, exclusionSNP=None,
keepSample=None, transpose=False):
"""Exclude some SNPs and keep some samples using Plink."""
if (exclusionSNP is None) and (keepSample is None):
msg = "Something wront with development... work on that source code.... | [
"def",
"exclude_SNPs_samples",
"(",
"inPrefix",
",",
"outPrefix",
",",
"exclusionSNP",
"=",
"None",
",",
"keepSample",
"=",
"None",
",",
"transpose",
"=",
"False",
")",
":",
"if",
"(",
"exclusionSNP",
"is",
"None",
")",
"and",
"(",
"keepSample",
"is",
"Non... | Exclude some SNPs and keep some samples using Plink. | [
"Exclude",
"some",
"SNPs",
"and",
"keep",
"some",
"samples",
"using",
"Plink",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L484-L505 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | renameSNPs | def renameSNPs(inPrefix, updateFileName, outPrefix):
"""Updates the name of the SNPs using Plink."""
plinkCommand = ["plink", "--noweb", "--bfile", inPrefix, "--update-map",
updateFileName, "--update-name", "--make-bed", "--out",
outPrefix]
runCommand(plinkCommand) | python | def renameSNPs(inPrefix, updateFileName, outPrefix):
"""Updates the name of the SNPs using Plink."""
plinkCommand = ["plink", "--noweb", "--bfile", inPrefix, "--update-map",
updateFileName, "--update-name", "--make-bed", "--out",
outPrefix]
runCommand(plinkCommand) | [
"def",
"renameSNPs",
"(",
"inPrefix",
",",
"updateFileName",
",",
"outPrefix",
")",
":",
"plinkCommand",
"=",
"[",
"\"plink\"",
",",
"\"--noweb\"",
",",
"\"--bfile\"",
",",
"inPrefix",
",",
"\"--update-map\"",
",",
"updateFileName",
",",
"\"--update-name\"",
",",
... | Updates the name of the SNPs using Plink. | [
"Updates",
"the",
"name",
"of",
"the",
"SNPs",
"using",
"Plink",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L508-L513 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | findFlippedSNPs | def findFlippedSNPs(goldFrqFile1, sourceAlleles, outPrefix):
"""Find flipped SNPs and flip them in the data1."""
goldAlleles = {}
with open(goldFrqFile1, "r") as inputFile:
headerIndex = None
for i, line in enumerate(inputFile):
row = createRowFromPlinkSpacedOutput(line)
... | python | def findFlippedSNPs(goldFrqFile1, sourceAlleles, outPrefix):
"""Find flipped SNPs and flip them in the data1."""
goldAlleles = {}
with open(goldFrqFile1, "r") as inputFile:
headerIndex = None
for i, line in enumerate(inputFile):
row = createRowFromPlinkSpacedOutput(line)
... | [
"def",
"findFlippedSNPs",
"(",
"goldFrqFile1",
",",
"sourceAlleles",
",",
"outPrefix",
")",
":",
"goldAlleles",
"=",
"{",
"}",
"with",
"open",
"(",
"goldFrqFile1",
",",
"\"r\"",
")",
"as",
"inputFile",
":",
"headerIndex",
"=",
"None",
"for",
"i",
",",
"lin... | Find flipped SNPs and flip them in the data1. | [
"Find",
"flipped",
"SNPs",
"and",
"flip",
"them",
"in",
"the",
"data1",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L516-L625 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | findOverlappingSNPsWithGoldStandard | def findOverlappingSNPsWithGoldStandard(prefix, gold_prefixe, out_prefix,
use_marker_names=False):
"""Find the overlapping SNPs in 4 different data sets."""
# Reading the main file
sourceSnpToExtract = {}
if use_marker_names:
sourceSnpToExtract = set()
... | python | def findOverlappingSNPsWithGoldStandard(prefix, gold_prefixe, out_prefix,
use_marker_names=False):
"""Find the overlapping SNPs in 4 different data sets."""
# Reading the main file
sourceSnpToExtract = {}
if use_marker_names:
sourceSnpToExtract = set()
... | [
"def",
"findOverlappingSNPsWithGoldStandard",
"(",
"prefix",
",",
"gold_prefixe",
",",
"out_prefix",
",",
"use_marker_names",
"=",
"False",
")",
":",
"# Reading the main file",
"sourceSnpToExtract",
"=",
"{",
"}",
"if",
"use_marker_names",
":",
"sourceSnpToExtract",
"="... | Find the overlapping SNPs in 4 different data sets. | [
"Find",
"the",
"overlapping",
"SNPs",
"in",
"4",
"different",
"data",
"sets",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L635-L729 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | extractSNPs | def extractSNPs(prefixes, snpToExtractFileNames, outPrefixes, runSGE):
"""Extract a list of SNPs using Plink."""
s = None
jobIDs = []
jobTemplates = []
if runSGE:
# Add the environment variable for DRMAA package
if "DRMAA_LIBRARY_PATH" not in os.environ:
t = "/shares/data... | python | def extractSNPs(prefixes, snpToExtractFileNames, outPrefixes, runSGE):
"""Extract a list of SNPs using Plink."""
s = None
jobIDs = []
jobTemplates = []
if runSGE:
# Add the environment variable for DRMAA package
if "DRMAA_LIBRARY_PATH" not in os.environ:
t = "/shares/data... | [
"def",
"extractSNPs",
"(",
"prefixes",
",",
"snpToExtractFileNames",
",",
"outPrefixes",
",",
"runSGE",
")",
":",
"s",
"=",
"None",
"jobIDs",
"=",
"[",
"]",
"jobTemplates",
"=",
"[",
"]",
"if",
"runSGE",
":",
"# Add the environment variable for DRMAA package",
"... | Extract a list of SNPs using Plink. | [
"Extract",
"a",
"list",
"of",
"SNPs",
"using",
"Plink",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L732-L797 |
lemieuxl/pyGenClean | pyGenClean/Misc/compare_gold_standard.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: a :py:class:`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 r... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: a :py:class:`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 r... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Check if we have the binary files",
"for",
"prefix",
"in",
"[",
"args",
".",
"bfile",
",",
"args",
".",
"gold_bfile",
"]",
":",
"if",
"prefix",
"is",
"None",
":",
"msg",
"=",
"\"no input file\"",
"raise",
"Progra... | Checks the arguments and options.
:param args: a :py:class:`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
:py:clas... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Misc/compare_gold_standard.py#L880-L929 |
davidchall/topas2numpy | topas2numpy/binned.py | BinnedResult._read_binary | def _read_binary(self):
"""Reads data and metadata from binary format."""
# NOTE: binary files store binned data using Fortran-like ordering.
# Dimensions are iterated like z, y, x (so x changes fastest)
header_path = self.path + 'header'
with open(header_path) as f_header:
... | python | def _read_binary(self):
"""Reads data and metadata from binary format."""
# NOTE: binary files store binned data using Fortran-like ordering.
# Dimensions are iterated like z, y, x (so x changes fastest)
header_path = self.path + 'header'
with open(header_path) as f_header:
... | [
"def",
"_read_binary",
"(",
"self",
")",
":",
"# NOTE: binary files store binned data using Fortran-like ordering.",
"# Dimensions are iterated like z, y, x (so x changes fastest)",
"header_path",
"=",
"self",
".",
"path",
"+",
"'header'",
"with",
"open",
"(",
"header_path",
")... | Reads data and metadata from binary format. | [
"Reads",
"data",
"and",
"metadata",
"from",
"binary",
"format",
"."
] | train | https://github.com/davidchall/topas2numpy/blob/db751dc95c57e530f890118fed407611dbbbdcbc/topas2numpy/binned.py#L58-L77 |
davidchall/topas2numpy | topas2numpy/binned.py | BinnedResult._read_ascii | def _read_ascii(self):
"""Reads data and metadata from ASCII format."""
# NOTE: ascii files store binned data using C-like ordering.
# Dimensions are iterated like x, y, z (so z changes fastest)
header_str = ''
with open(self.path) as f:
for line in f:
... | python | def _read_ascii(self):
"""Reads data and metadata from ASCII format."""
# NOTE: ascii files store binned data using C-like ordering.
# Dimensions are iterated like x, y, z (so z changes fastest)
header_str = ''
with open(self.path) as f:
for line in f:
... | [
"def",
"_read_ascii",
"(",
"self",
")",
":",
"# NOTE: ascii files store binned data using C-like ordering.",
"# Dimensions are iterated like x, y, z (so z changes fastest)",
"header_str",
"=",
"''",
"with",
"open",
"(",
"self",
".",
"path",
")",
"as",
"f",
":",
"for",
"li... | Reads data and metadata from ASCII format. | [
"Reads",
"data",
"and",
"metadata",
"from",
"ASCII",
"format",
"."
] | train | https://github.com/davidchall/topas2numpy/blob/db751dc95c57e530f890118fed407611dbbbdcbc/topas2numpy/binned.py#L79-L101 |
davidchall/topas2numpy | topas2numpy/binned.py | BinnedResult._read_header | def _read_header(self, header_str):
"""Reads metadata from the header."""
# regular expressions
re_float = '[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?'
re_uint = '\d+'
re_binning = '{d} in (?P<nbins>' + re_uint + ') bin[ s] '
re_binning += 'of (?P<binwidth>' + re_float + ')... | python | def _read_header(self, header_str):
"""Reads metadata from the header."""
# regular expressions
re_float = '[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?'
re_uint = '\d+'
re_binning = '{d} in (?P<nbins>' + re_uint + ') bin[ s] '
re_binning += 'of (?P<binwidth>' + re_float + ')... | [
"def",
"_read_header",
"(",
"self",
",",
"header_str",
")",
":",
"# regular expressions",
"re_float",
"=",
"'[-+]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?'",
"re_uint",
"=",
"'\\d+'",
"re_binning",
"=",
"'{d} in (?P<nbins>'",
"+",
"re_uint",
"+",
"') bin[ s] '",
"re_binni... | Reads metadata from the header. | [
"Reads",
"metadata",
"from",
"the",
"header",
"."
] | train | https://github.com/davidchall/topas2numpy/blob/db751dc95c57e530f890118fed407611dbbbdcbc/topas2numpy/binned.py#L103-L157 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/sex_check.py | main | def main(argString=None):
"""The main function of the module.
:param argString: the options.
:type argString: list
These are the following steps:
1. Prints the options.
2. Checks if there are enough markers on the chromosome ``23``
(:py:func:`checkBim`). If not, quits here.
3. ... | python | def main(argString=None):
"""The main function of the module.
:param argString: the options.
:type argString: list
These are the following steps:
1. Prints the options.
2. Checks if there are enough markers on the chromosome ``23``
(:py:func:`checkBim`). If not, quits here.
3. ... | [
"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 following steps:
1. Prints the options.
2. Checks if there are enough markers on the chromosome ``23``
(:py:func:`checkBim`). If not, quits here.
3. Runs the sex check analysis usin... | [
"The",
"main",
"function",
"of",
"the",
"module",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L36-L124 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/sex_check.py | createGenderPlot | def createGenderPlot(bfile, intensities, problematic_samples, format,
out_prefix):
"""Creates the gender plot.
:param bfile: the prefix of the input binary file.
:param intensities: the file containing the intensities.
:param problematic_samples: the file containing the problematic... | python | def createGenderPlot(bfile, intensities, problematic_samples, format,
out_prefix):
"""Creates the gender plot.
:param bfile: the prefix of the input binary file.
:param intensities: the file containing the intensities.
:param problematic_samples: the file containing the problematic... | [
"def",
"createGenderPlot",
"(",
"bfile",
",",
"intensities",
",",
"problematic_samples",
",",
"format",
",",
"out_prefix",
")",
":",
"gender_plot_options",
"=",
"[",
"\"--bfile\"",
",",
"bfile",
",",
"\"--intensities\"",
",",
"intensities",
",",
"\"--sex-problems\""... | Creates the gender plot.
:param bfile: the prefix of the input binary file.
:param intensities: the file containing the intensities.
:param problematic_samples: the file containing the problematic samples.
:param format: the format of the output plot.
:param out_prefix: the prefix of the output fil... | [
"Creates",
"the",
"gender",
"plot",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L127-L154 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/sex_check.py | createLrrBafPlot | def createLrrBafPlot(raw_dir, problematic_samples, format, dpi, out_prefix):
"""Creates the LRR and BAF plot.
:param raw_dir: the directory containing the intensities.
:param problematic_samples: the file containing the problematic samples.
:param format: the format of the plot.
:param dpi: the DPI... | python | def createLrrBafPlot(raw_dir, problematic_samples, format, dpi, out_prefix):
"""Creates the LRR and BAF plot.
:param raw_dir: the directory containing the intensities.
:param problematic_samples: the file containing the problematic samples.
:param format: the format of the plot.
:param dpi: the DPI... | [
"def",
"createLrrBafPlot",
"(",
"raw_dir",
",",
"problematic_samples",
",",
"format",
",",
"dpi",
",",
"out_prefix",
")",
":",
"# First, we create an output directory",
"dir_name",
"=",
"out_prefix",
"+",
"\".LRR_BAF\"",
"if",
"not",
"os",
".",
"path",
".",
"isdir... | Creates the LRR and BAF plot.
:param raw_dir: the directory containing the intensities.
:param problematic_samples: the file containing the problematic samples.
:param format: the format of the plot.
:param dpi: the DPI of the resulting images.
:param out_prefix: the prefix of the output file.
... | [
"Creates",
"the",
"LRR",
"and",
"BAF",
"plot",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L157-L190 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/sex_check.py | checkBim | def checkBim(fileName, minNumber, chromosome):
"""Checks the BIM file for chrN markers.
:param fileName:
:param minNumber:
:param chromosome:
:type fileName: str
:type minNumber: int
:type chromosome: str
:returns: ``True`` if there are at least ``minNumber`` markers on
... | python | def checkBim(fileName, minNumber, chromosome):
"""Checks the BIM file for chrN markers.
:param fileName:
:param minNumber:
:param chromosome:
:type fileName: str
:type minNumber: int
:type chromosome: str
:returns: ``True`` if there are at least ``minNumber`` markers on
... | [
"def",
"checkBim",
"(",
"fileName",
",",
"minNumber",
",",
"chromosome",
")",
":",
"nbMarkers",
"=",
"0",
"with",
"open",
"(",
"fileName",
",",
"'r'",
")",
"as",
"inputFile",
":",
"for",
"line",
"in",
"inputFile",
":",
"row",
"=",
"line",
".",
"rstrip"... | Checks the BIM file for chrN markers.
:param fileName:
:param minNumber:
:param chromosome:
:type fileName: str
:type minNumber: int
:type chromosome: str
:returns: ``True`` if there are at least ``minNumber`` markers on
chromosome ``chromosome``, ``False`` otherwise. | [
"Checks",
"the",
"BIM",
"file",
"for",
"chrN",
"markers",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L193-L216 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/sex_check.py | computeNoCall | def computeNoCall(fileName):
"""Computes the number of no call.
:param fileName: the name of the file
:type fileName: str
Reads the ``ped`` file created by Plink using the ``recodeA`` options (see
:py:func:`createPedChr24UsingPlink`) and computes the number and percentage
of no calls on the c... | python | def computeNoCall(fileName):
"""Computes the number of no call.
:param fileName: the name of the file
:type fileName: str
Reads the ``ped`` file created by Plink using the ``recodeA`` options (see
:py:func:`createPedChr24UsingPlink`) and computes the number and percentage
of no calls on the c... | [
"def",
"computeNoCall",
"(",
"fileName",
")",
":",
"outputFile",
"=",
"None",
"try",
":",
"outputFile",
"=",
"open",
"(",
"fileName",
"+",
"\".noCall\"",
",",
"\"w\"",
")",
"except",
"IOError",
":",
"msg",
"=",
"\"%s: can't write file\"",
"%",
"fileName",
"+... | Computes the number of no call.
:param fileName: the name of the file
:type fileName: str
Reads the ``ped`` file created by Plink using the ``recodeA`` options (see
:py:func:`createPedChr24UsingPlink`) and computes the number and percentage
of no calls on the chromosome ``24``. | [
"Computes",
"the",
"number",
"of",
"no",
"call",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L219-L263 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/sex_check.py | computeHeteroPercentage | def computeHeteroPercentage(fileName):
"""Computes the heterozygosity percentage.
:param fileName: the name of the input file.
:type fileName: str
Reads the ``ped`` file created by Plink using the ``recodeA`` options (see
:py:func:`createPedChr23UsingPlink`) and computes the heterozygosity
pe... | python | def computeHeteroPercentage(fileName):
"""Computes the heterozygosity percentage.
:param fileName: the name of the input file.
:type fileName: str
Reads the ``ped`` file created by Plink using the ``recodeA`` options (see
:py:func:`createPedChr23UsingPlink`) and computes the heterozygosity
pe... | [
"def",
"computeHeteroPercentage",
"(",
"fileName",
")",
":",
"outputFile",
"=",
"None",
"try",
":",
"outputFile",
"=",
"open",
"(",
"fileName",
"+",
"\".hetero\"",
",",
"\"w\"",
")",
"except",
"IOError",
":",
"msg",
"=",
"\"%s: can't write file\"",
"%",
"fileN... | Computes the heterozygosity percentage.
:param fileName: the name of the input file.
:type fileName: str
Reads the ``ped`` file created by Plink using the ``recodeA`` options (see
:py:func:`createPedChr23UsingPlink`) and computes the heterozygosity
percentage on the chromosome ``23``. | [
"Computes",
"the",
"heterozygosity",
"percentage",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L266-L321 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/sex_check.py | readCheckSexFile | def readCheckSexFile(fileName, allProblemsFileName, idsFileName, femaleF,
maleF):
"""Reads the Plink check-sex output file.
:param fileName: the name of the input file.
:param allProblemsFileName: the name of the output file that will contain
all the pro... | python | def readCheckSexFile(fileName, allProblemsFileName, idsFileName, femaleF,
maleF):
"""Reads the Plink check-sex output file.
:param fileName: the name of the input file.
:param allProblemsFileName: the name of the output file that will contain
all the pro... | [
"def",
"readCheckSexFile",
"(",
"fileName",
",",
"allProblemsFileName",
",",
"idsFileName",
",",
"femaleF",
",",
"maleF",
")",
":",
"allProblemsFile",
"=",
"None",
"try",
":",
"allProblemsFile",
"=",
"open",
"(",
"allProblemsFileName",
",",
"'w'",
")",
"except",... | Reads the Plink check-sex output file.
:param fileName: the name of the input file.
:param allProblemsFileName: the name of the output file that will contain
all the problems.
:param idsFileName: the name of the output file what will contain samples
w... | [
"Reads",
"the",
"Plink",
"check",
"-",
"sex",
"output",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L324-L450 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/sex_check.py | createPedChr23UsingPlink | def createPedChr23UsingPlink(options):
"""Run Plink to create a ped format.
:param options: the options.
:type options: argparse.Namespace
Uses Plink to create a ``ped`` file of markers on the chromosome ``23``. It
uses the ``recodeA`` options to use additive coding. It also subsets the
data ... | python | def createPedChr23UsingPlink(options):
"""Run Plink to create a ped format.
:param options: the options.
:type options: argparse.Namespace
Uses Plink to create a ``ped`` file of markers on the chromosome ``23``. It
uses the ``recodeA`` options to use additive coding. It also subsets the
data ... | [
"def",
"createPedChr23UsingPlink",
"(",
"options",
")",
":",
"plinkCommand",
"=",
"[",
"\"plink\"",
",",
"\"--noweb\"",
",",
"\"--bfile\"",
",",
"options",
".",
"bfile",
",",
"\"--chr\"",
",",
"\"23\"",
",",
"\"--recodeA\"",
",",
"\"--keep\"",
",",
"options",
... | Run Plink to create a ped format.
:param options: the options.
:type options: argparse.Namespace
Uses Plink to create a ``ped`` file of markers on the chromosome ``23``. It
uses the ``recodeA`` options to use additive coding. It also subsets the
data to keep only samples with sex problems. | [
"Run",
"Plink",
"to",
"create",
"a",
"ped",
"format",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L469-L485 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/sex_check.py | createPedChr24UsingPlink | def createPedChr24UsingPlink(options):
"""Run plink to create a ped format.
:param options: the options.
:type options: argparse.Namespace
Uses Plink to create a ``ped`` file of markers on the chromosome ``24``. It
uses the ``recodeA`` options to use additive coding. It also subsets the
data ... | python | def createPedChr24UsingPlink(options):
"""Run plink to create a ped format.
:param options: the options.
:type options: argparse.Namespace
Uses Plink to create a ``ped`` file of markers on the chromosome ``24``. It
uses the ``recodeA`` options to use additive coding. It also subsets the
data ... | [
"def",
"createPedChr24UsingPlink",
"(",
"options",
")",
":",
"plinkCommand",
"=",
"[",
"\"plink\"",
",",
"\"--noweb\"",
",",
"\"--bfile\"",
",",
"options",
".",
"bfile",
",",
"\"--chr\"",
",",
"\"24\"",
",",
"\"--recodeA\"",
",",
"\"--keep\"",
",",
"options",
... | Run plink to create a ped format.
:param options: the options.
:type options: argparse.Namespace
Uses Plink to create a ``ped`` file of markers on the chromosome ``24``. It
uses the ``recodeA`` options to use additive coding. It also subsets the
data to keep only samples with sex problems. | [
"Run",
"plink",
"to",
"create",
"a",
"ped",
"format",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L488-L504 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/sex_check.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` class... | 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` class... | [
"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 th... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/sex_check.py#L531-L565 |
simoninireland/epyc | epyc/clusterlab.py | ClusterLab.use_dill | def use_dill( self ):
"""Make the cluster use Dill as pickler for transferring results. This isn't
generally needed, but is sometimes useful for particularly complex experiments
such as those involving closures. (Or, to put it another way, if you find yourself
tempted to use this method,... | python | def use_dill( self ):
"""Make the cluster use Dill as pickler for transferring results. This isn't
generally needed, but is sometimes useful for particularly complex experiments
such as those involving closures. (Or, to put it another way, if you find yourself
tempted to use this method,... | [
"def",
"use_dill",
"(",
"self",
")",
":",
"self",
".",
"open",
"(",
")",
"with",
"self",
".",
"sync_imports",
"(",
"quiet",
"=",
"True",
")",
":",
"import",
"dill",
"self",
".",
"_client",
".",
"direct_view",
"(",
")",
".",
"use_dill",
"(",
")"
] | Make the cluster use Dill as pickler for transferring results. This isn't
generally needed, but is sometimes useful for particularly complex experiments
such as those involving closures. (Or, to put it another way, if you find yourself
tempted to use this method, consider re-structuring your exp... | [
"Make",
"the",
"cluster",
"use",
"Dill",
"as",
"pickler",
"for",
"transferring",
"results",
".",
"This",
"isn",
"t",
"generally",
"needed",
"but",
"is",
"sometimes",
"useful",
"for",
"particularly",
"complex",
"experiments",
"such",
"as",
"those",
"involving",
... | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/clusterlab.py#L110-L118 |
simoninireland/epyc | epyc/clusterlab.py | ClusterLab.sync_imports | def sync_imports( self, quiet = False ):
"""Return a context manager to control imports onto all the engines
in the underlying cluster. This method is used within a ``with`` statement.
Any imports should be done with no experiments running, otherwise the
method will block until the clus... | python | def sync_imports( self, quiet = False ):
"""Return a context manager to control imports onto all the engines
in the underlying cluster. This method is used within a ``with`` statement.
Any imports should be done with no experiments running, otherwise the
method will block until the clus... | [
"def",
"sync_imports",
"(",
"self",
",",
"quiet",
"=",
"False",
")",
":",
"self",
".",
"open",
"(",
")",
"return",
"self",
".",
"_client",
"[",
":",
"]",
".",
"sync_imports",
"(",
"quiet",
"=",
"quiet",
")"
] | Return a context manager to control imports onto all the engines
in the underlying cluster. This method is used within a ``with`` statement.
Any imports should be done with no experiments running, otherwise the
method will block until the cluster is quiet. Generally imports will be one
... | [
"Return",
"a",
"context",
"manager",
"to",
"control",
"imports",
"onto",
"all",
"the",
"engines",
"in",
"the",
"underlying",
"cluster",
".",
"This",
"method",
"is",
"used",
"within",
"a",
"with",
"statement",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/clusterlab.py#L120-L133 |
simoninireland/epyc | epyc/clusterlab.py | ClusterLab._mixup | def _mixup( self, ps ):
"""Private method to mix up a list of values in-place using a Fisher-Yates
shuffle (see https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
:param ps: the array
:returns: the array, shuffled in-place"""
for i in range(len(ps) - 1, 0, -1):
j =... | python | def _mixup( self, ps ):
"""Private method to mix up a list of values in-place using a Fisher-Yates
shuffle (see https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
:param ps: the array
:returns: the array, shuffled in-place"""
for i in range(len(ps) - 1, 0, -1):
j =... | [
"def",
"_mixup",
"(",
"self",
",",
"ps",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"ps",
")",
"-",
"1",
",",
"0",
",",
"-",
"1",
")",
":",
"j",
"=",
"int",
"(",
"numpy",
".",
"random",
".",
"random",
"(",
")",
"*",
"i",
")",
... | Private method to mix up a list of values in-place using a Fisher-Yates
shuffle (see https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
:param ps: the array
:returns: the array, shuffled in-place | [
"Private",
"method",
"to",
"mix",
"up",
"a",
"list",
"of",
"values",
"in",
"-",
"place",
"using",
"a",
"Fisher",
"-",
"Yates",
"shuffle",
"(",
"see",
"https",
":",
"//",
"en",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"Fisher",
"-",
"Yates_shuf... | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/clusterlab.py#L135-L146 |
simoninireland/epyc | epyc/clusterlab.py | ClusterLab.runExperiment | def runExperiment( self, e ):
"""Run the experiment across the parameter space in parallel using
all the engines in the cluster. This method returns immediately.
The experiments are run asynchronously, with the points in the parameter
space being explored randomly so that intermediate r... | python | def runExperiment( self, e ):
"""Run the experiment across the parameter space in parallel using
all the engines in the cluster. This method returns immediately.
The experiments are run asynchronously, with the points in the parameter
space being explored randomly so that intermediate r... | [
"def",
"runExperiment",
"(",
"self",
",",
"e",
")",
":",
"# create the parameter space",
"space",
"=",
"self",
".",
"parameterSpace",
"(",
")",
"# only proceed if there's work to do",
"if",
"len",
"(",
"space",
")",
">",
"0",
":",
"nb",
"=",
"self",
".",
"no... | Run the experiment across the parameter space in parallel using
all the engines in the cluster. This method returns immediately.
The experiments are run asynchronously, with the points in the parameter
space being explored randomly so that intermediate retrievals of results
are more rep... | [
"Run",
"the",
"experiment",
"across",
"the",
"parameter",
"space",
"in",
"parallel",
"using",
"all",
"the",
"engines",
"in",
"the",
"cluster",
".",
"This",
"method",
"returns",
"immediately",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/clusterlab.py#L148-L193 |
simoninireland/epyc | epyc/clusterlab.py | ClusterLab.updateResults | def updateResults( self ):
"""Update our results within any pending results that have completed since we
last retrieved results from the cluster.
:returns: the number of pending results completed at this call"""
# we do all the tests for pending results against the notebook directly,
... | python | def updateResults( self ):
"""Update our results within any pending results that have completed since we
last retrieved results from the cluster.
:returns: the number of pending results completed at this call"""
# we do all the tests for pending results against the notebook directly,
... | [
"def",
"updateResults",
"(",
"self",
")",
":",
"# we do all the tests for pending results against the notebook directly,",
"# as the corresponding methods on self call this method themselves",
"nb",
"=",
"self",
".",
"notebook",
"(",
")",
"# look for pending results if we're waiting fo... | Update our results within any pending results that have completed since we
last retrieved results from the cluster.
:returns: the number of pending results completed at this call | [
"Update",
"our",
"results",
"within",
"any",
"pending",
"results",
"that",
"have",
"completed",
"since",
"we",
"last",
"retrieved",
"results",
"from",
"the",
"cluster",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/clusterlab.py#L195-L233 |
simoninireland/epyc | epyc/clusterlab.py | ClusterLab._availableResultsFraction | def _availableResultsFraction( self ):
"""Private method to return the fraction of results available, as a real number
between 0 and 1. This does not update the results fetched from the cluster.
:returns: the fraction of available results"""
tr = self.notebook().numberOfResults() + self... | python | def _availableResultsFraction( self ):
"""Private method to return the fraction of results available, as a real number
between 0 and 1. This does not update the results fetched from the cluster.
:returns: the fraction of available results"""
tr = self.notebook().numberOfResults() + self... | [
"def",
"_availableResultsFraction",
"(",
"self",
")",
":",
"tr",
"=",
"self",
".",
"notebook",
"(",
")",
".",
"numberOfResults",
"(",
")",
"+",
"self",
".",
"notebook",
"(",
")",
".",
"numberOfPendingResults",
"(",
")",
"if",
"tr",
"==",
"0",
":",
"ret... | Private method to return the fraction of results available, as a real number
between 0 and 1. This does not update the results fetched from the cluster.
:returns: the fraction of available results | [
"Private",
"method",
"to",
"return",
"the",
"fraction",
"of",
"results",
"available",
"as",
"a",
"real",
"number",
"between",
"0",
"and",
"1",
".",
"This",
"does",
"not",
"update",
"the",
"results",
"fetched",
"from",
"the",
"cluster",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/clusterlab.py#L249-L258 |
simoninireland/epyc | epyc/clusterlab.py | ClusterLab.wait | def wait( self, timeout = -1 ):
"""Wait for all pending results to be finished. If timeout is set,
return after this many seconds regardless.
:param timeout: timeout period in seconds (defaults to forever)
:returns: True if all the results completed"""
# we can't use ipyparalle... | python | def wait( self, timeout = -1 ):
"""Wait for all pending results to be finished. If timeout is set,
return after this many seconds regardless.
:param timeout: timeout period in seconds (defaults to forever)
:returns: True if all the results completed"""
# we can't use ipyparalle... | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"-",
"1",
")",
":",
"# we can't use ipyparallel.Client.wait() for this, because that",
"# method only works for cases where the Client object is the one that",
"# submitted the jobs to the cluster hub -- and therefore has the",
"# necessar... | Wait for all pending results to be finished. If timeout is set,
return after this many seconds regardless.
:param timeout: timeout period in seconds (defaults to forever)
:returns: True if all the results completed | [
"Wait",
"for",
"all",
"pending",
"results",
"to",
"be",
"finished",
".",
"If",
"timeout",
"is",
"set",
"return",
"after",
"this",
"many",
"seconds",
"regardless",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/clusterlab.py#L275-L327 |
simoninireland/epyc | epyc/clusterlab.py | ClusterLab._abortJobs | def _abortJobs( self, js ):
"""Private method to abort a set of jobs.
:param js: the job ids to be aborted"""
self.open()
self._client.abort(jobs = js)
self.close() | python | def _abortJobs( self, js ):
"""Private method to abort a set of jobs.
:param js: the job ids to be aborted"""
self.open()
self._client.abort(jobs = js)
self.close() | [
"def",
"_abortJobs",
"(",
"self",
",",
"js",
")",
":",
"self",
".",
"open",
"(",
")",
"self",
".",
"_client",
".",
"abort",
"(",
"jobs",
"=",
"js",
")",
"self",
".",
"close",
"(",
")"
] | Private method to abort a set of jobs.
:param js: the job ids to be aborted | [
"Private",
"method",
"to",
"abort",
"a",
"set",
"of",
"jobs",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/clusterlab.py#L343-L349 |
simoninireland/epyc | epyc/clusterlab.py | ClusterLab.cancelPendingResultsFor | def cancelPendingResultsFor( self, params ):
"""Cancel any results pending for experiments at the given point
in the parameter space.
:param params: the experimental parameters"""
# grab the result job ids
jobs = self.pendingResultsFor(params)
if len(jo... | python | def cancelPendingResultsFor( self, params ):
"""Cancel any results pending for experiments at the given point
in the parameter space.
:param params: the experimental parameters"""
# grab the result job ids
jobs = self.pendingResultsFor(params)
if len(jo... | [
"def",
"cancelPendingResultsFor",
"(",
"self",
",",
"params",
")",
":",
"# grab the result job ids",
"jobs",
"=",
"self",
".",
"pendingResultsFor",
"(",
"params",
")",
"if",
"len",
"(",
"jobs",
")",
">",
"0",
":",
"# abort in the cluster",
"self",
".",
"_abort... | Cancel any results pending for experiments at the given point
in the parameter space.
:param params: the experimental parameters | [
"Cancel",
"any",
"results",
"pending",
"for",
"experiments",
"at",
"the",
"given",
"point",
"in",
"the",
"parameter",
"space",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/clusterlab.py#L351-L365 |
simoninireland/epyc | epyc/clusterlab.py | ClusterLab.cancelAllPendingResults | def cancelAllPendingResults( self ):
"""Cancel all pending results."""
# grab all the pending job ids
jobs = self.pendingResults()
if len(jobs) > 0:
# abort in the cluster
self._abortJobs(jobs)
# cancel in the notebook ... | python | def cancelAllPendingResults( self ):
"""Cancel all pending results."""
# grab all the pending job ids
jobs = self.pendingResults()
if len(jobs) > 0:
# abort in the cluster
self._abortJobs(jobs)
# cancel in the notebook ... | [
"def",
"cancelAllPendingResults",
"(",
"self",
")",
":",
"# grab all the pending job ids",
"jobs",
"=",
"self",
".",
"pendingResults",
"(",
")",
"if",
"len",
"(",
"jobs",
")",
">",
"0",
":",
"# abort in the cluster",
"self",
".",
"_abortJobs",
"(",
"jobs",
")"... | Cancel all pending results. | [
"Cancel",
"all",
"pending",
"results",
"."
] | train | https://github.com/simoninireland/epyc/blob/b3b61007741a0ab3de64df89070a6f30de8ec268/epyc/clusterlab.py#L367-L378 |
eyeseast/python-tablefu | table_fu/__init__.py | TableFu.sort | def sort(self, column_name=None, reverse=False):
"""
Sort rows in this table, preserving a record of how that
sorting is done in TableFu.options['sorted_by']
"""
if not column_name and self.options.has_key('sorted_by'):
column_name = self.options['sorted_by'].keys()[0... | python | def sort(self, column_name=None, reverse=False):
"""
Sort rows in this table, preserving a record of how that
sorting is done in TableFu.options['sorted_by']
"""
if not column_name and self.options.has_key('sorted_by'):
column_name = self.options['sorted_by'].keys()[0... | [
"def",
"sort",
"(",
"self",
",",
"column_name",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"not",
"column_name",
"and",
"self",
".",
"options",
".",
"has_key",
"(",
"'sorted_by'",
")",
":",
"column_name",
"=",
"self",
".",
"options",
"[... | Sort rows in this table, preserving a record of how that
sorting is done in TableFu.options['sorted_by'] | [
"Sort",
"rows",
"in",
"this",
"table",
"preserving",
"a",
"record",
"of",
"how",
"that",
"sorting",
"is",
"done",
"in",
"TableFu",
".",
"options",
"[",
"sorted_by",
"]"
] | train | https://github.com/eyeseast/python-tablefu/blob/d8761c1f87e3f89d9b89b0b6b9283fc4738b6676/table_fu/__init__.py#L135-L146 |
eyeseast/python-tablefu | table_fu/__init__.py | TableFu.filter | def filter(self, func=None, **query):
"""
Tables can be filtered in one of two ways:
- Simple keyword arguments return rows where values match *exactly*
- Pass in a function and return rows where that function evaluates to True
In either case, a new TableFu instance is... | python | def filter(self, func=None, **query):
"""
Tables can be filtered in one of two ways:
- Simple keyword arguments return rows where values match *exactly*
- Pass in a function and return rows where that function evaluates to True
In either case, a new TableFu instance is... | [
"def",
"filter",
"(",
"self",
",",
"func",
"=",
"None",
",",
"*",
"*",
"query",
")",
":",
"if",
"callable",
"(",
"func",
")",
":",
"result",
"=",
"filter",
"(",
"func",
",",
"self",
")",
"result",
".",
"insert",
"(",
"0",
",",
"self",
".",
"def... | Tables can be filtered in one of two ways:
- Simple keyword arguments return rows where values match *exactly*
- Pass in a function and return rows where that function evaluates to True
In either case, a new TableFu instance is returned | [
"Tables",
"can",
"be",
"filtered",
"in",
"one",
"of",
"two",
"ways",
":",
"-",
"Simple",
"keyword",
"arguments",
"return",
"rows",
"where",
"values",
"match",
"*",
"exactly",
"*",
"-",
"Pass",
"in",
"a",
"function",
"and",
"return",
"rows",
"where",
"tha... | train | https://github.com/eyeseast/python-tablefu/blob/d8761c1f87e3f89d9b89b0b6b9283fc4738b6676/table_fu/__init__.py#L181-L197 |
eyeseast/python-tablefu | table_fu/__init__.py | TableFu.facet_by | def facet_by(self, column):
"""
Faceting creates new TableFu instances with rows matching
each possible value.
"""
faceted_spreadsheets = {}
for row in self.rows:
if row[column]:
col = row[column].value
if faceted_spreadsheets.h... | python | def facet_by(self, column):
"""
Faceting creates new TableFu instances with rows matching
each possible value.
"""
faceted_spreadsheets = {}
for row in self.rows:
if row[column]:
col = row[column].value
if faceted_spreadsheets.h... | [
"def",
"facet_by",
"(",
"self",
",",
"column",
")",
":",
"faceted_spreadsheets",
"=",
"{",
"}",
"for",
"row",
"in",
"self",
".",
"rows",
":",
"if",
"row",
"[",
"column",
"]",
":",
"col",
"=",
"row",
"[",
"column",
"]",
".",
"value",
"if",
"faceted_... | Faceting creates new TableFu instances with rows matching
each possible value. | [
"Faceting",
"creates",
"new",
"TableFu",
"instances",
"with",
"rows",
"matching",
"each",
"possible",
"value",
"."
] | train | https://github.com/eyeseast/python-tablefu/blob/d8761c1f87e3f89d9b89b0b6b9283fc4738b6676/table_fu/__init__.py#L199-L225 |
eyeseast/python-tablefu | table_fu/__init__.py | TableFu.map | def map(self, func, *columns):
"""
Map a function to rows, or to given columns
"""
if not columns:
return map(func, self.rows)
else:
values = (self.values(column) for column in columns)
result = [map(func, v) for v in values]
if len... | python | def map(self, func, *columns):
"""
Map a function to rows, or to given columns
"""
if not columns:
return map(func, self.rows)
else:
values = (self.values(column) for column in columns)
result = [map(func, v) for v in values]
if len... | [
"def",
"map",
"(",
"self",
",",
"func",
",",
"*",
"columns",
")",
":",
"if",
"not",
"columns",
":",
"return",
"map",
"(",
"func",
",",
"self",
".",
"rows",
")",
"else",
":",
"values",
"=",
"(",
"self",
".",
"values",
"(",
"column",
")",
"for",
... | Map a function to rows, or to given columns | [
"Map",
"a",
"function",
"to",
"rows",
"or",
"to",
"given",
"columns"
] | train | https://github.com/eyeseast/python-tablefu/blob/d8761c1f87e3f89d9b89b0b6b9283fc4738b6676/table_fu/__init__.py#L239-L251 |
eyeseast/python-tablefu | table_fu/__init__.py | TableFu.csv | def csv(self, **kwargs):
"""
Export this table as a CSV
"""
out = StringIO()
writer = csv.DictWriter(out, self.columns, **kwargs)
writer.writerow(dict(zip(self.columns, self.columns)))
writer.writerows(dict(row.items()) for row in self.rows)
retur... | python | def csv(self, **kwargs):
"""
Export this table as a CSV
"""
out = StringIO()
writer = csv.DictWriter(out, self.columns, **kwargs)
writer.writerow(dict(zip(self.columns, self.columns)))
writer.writerows(dict(row.items()) for row in self.rows)
retur... | [
"def",
"csv",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"out",
"=",
"StringIO",
"(",
")",
"writer",
"=",
"csv",
".",
"DictWriter",
"(",
"out",
",",
"self",
".",
"columns",
",",
"*",
"*",
"kwargs",
")",
"writer",
".",
"writerow",
"(",
"dict"... | Export this table as a CSV | [
"Export",
"this",
"table",
"as",
"a",
"CSV"
] | train | https://github.com/eyeseast/python-tablefu/blob/d8761c1f87e3f89d9b89b0b6b9283fc4738b6676/table_fu/__init__.py#L260-L269 |
eyeseast/python-tablefu | table_fu/__init__.py | TableFu.from_file | def from_file(fn, **options):
"""
Creates a new TableFu instance from a file or path
"""
if hasattr(fn, 'read'):
return TableFu(fn, **options)
with open(fn) as f:
return TableFu(f, **options) | python | def from_file(fn, **options):
"""
Creates a new TableFu instance from a file or path
"""
if hasattr(fn, 'read'):
return TableFu(fn, **options)
with open(fn) as f:
return TableFu(f, **options) | [
"def",
"from_file",
"(",
"fn",
",",
"*",
"*",
"options",
")",
":",
"if",
"hasattr",
"(",
"fn",
",",
"'read'",
")",
":",
"return",
"TableFu",
"(",
"fn",
",",
"*",
"*",
"options",
")",
"with",
"open",
"(",
"fn",
")",
"as",
"f",
":",
"return",
"Ta... | Creates a new TableFu instance from a file or path | [
"Creates",
"a",
"new",
"TableFu",
"instance",
"from",
"a",
"file",
"or",
"path"
] | train | https://github.com/eyeseast/python-tablefu/blob/d8761c1f87e3f89d9b89b0b6b9283fc4738b6676/table_fu/__init__.py#L281-L288 |
eyeseast/python-tablefu | table_fu/__init__.py | TableFu.from_url | def from_url(url, **options):
"""
Downloads the contents of a given URL and loads it
into a new TableFu instance
"""
resp = urllib2.urlopen(url)
return TableFu(resp, **options) | python | def from_url(url, **options):
"""
Downloads the contents of a given URL and loads it
into a new TableFu instance
"""
resp = urllib2.urlopen(url)
return TableFu(resp, **options) | [
"def",
"from_url",
"(",
"url",
",",
"*",
"*",
"options",
")",
":",
"resp",
"=",
"urllib2",
".",
"urlopen",
"(",
"url",
")",
"return",
"TableFu",
"(",
"resp",
",",
"*",
"*",
"options",
")"
] | Downloads the contents of a given URL and loads it
into a new TableFu instance | [
"Downloads",
"the",
"contents",
"of",
"a",
"given",
"URL",
"and",
"loads",
"it",
"into",
"a",
"new",
"TableFu",
"instance"
] | train | https://github.com/eyeseast/python-tablefu/blob/d8761c1f87e3f89d9b89b0b6b9283fc4738b6676/table_fu/__init__.py#L291-L297 |
eyeseast/python-tablefu | table_fu/__init__.py | Row.get | def get(self, column_name, default=None):
"""
Return the Datum for column_name, or default.
"""
if column_name in self.table.default_columns:
index = self.table.default_columns.index(column_name)
return Datum(self.cells[index], self.row_num, column_name, self.tabl... | python | def get(self, column_name, default=None):
"""
Return the Datum for column_name, or default.
"""
if column_name in self.table.default_columns:
index = self.table.default_columns.index(column_name)
return Datum(self.cells[index], self.row_num, column_name, self.tabl... | [
"def",
"get",
"(",
"self",
",",
"column_name",
",",
"default",
"=",
"None",
")",
":",
"if",
"column_name",
"in",
"self",
".",
"table",
".",
"default_columns",
":",
"index",
"=",
"self",
".",
"table",
".",
"default_columns",
".",
"index",
"(",
"column_nam... | Return the Datum for column_name, or default. | [
"Return",
"the",
"Datum",
"for",
"column_name",
"or",
"default",
"."
] | train | https://github.com/eyeseast/python-tablefu/blob/d8761c1f87e3f89d9b89b0b6b9283fc4738b6676/table_fu/__init__.py#L326-L333 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/plot_eigenvalues.py | main | def main(argString=None):
"""The main function.
The purpose of this module is to plot Eigenvectors provided by the
Eigensoft software.
Here are the steps of this module:
1. Reads the Eigenvector (:py:func:`read_eigenvalues`).
2. Plots the Scree Plot (:py:func:`create_scree_plot`).
"""
... | python | def main(argString=None):
"""The main function.
The purpose of this module is to plot Eigenvectors provided by the
Eigensoft software.
Here are the steps of this module:
1. Reads the Eigenvector (:py:func:`read_eigenvalues`).
2. Plots the Scree Plot (:py:func:`create_scree_plot`).
"""
... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parse_args",
"(",
"argString",
")",
"check_args",
"(",
"args",
")",
"# Reads the eigenvalues",
"eigenvalues",
"=",
"read_eigenvalues",
"(",
"args",
".",
"ev... | The main function.
The purpose of this module is to plot Eigenvectors provided by the
Eigensoft software.
Here are the steps of this module:
1. Reads the Eigenvector (:py:func:`read_eigenvalues`).
2. Plots the Scree Plot (:py:func:`create_scree_plot`). | [
"The",
"main",
"function",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/plot_eigenvalues.py#L34-L54 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/plot_eigenvalues.py | create_scree_plot | def create_scree_plot(data, o_filename, options):
"""Creates the scree plot.
:param data: the eigenvalues.
:param o_filename: the name of the output files.
:param options: the options.
:type data: numpy.ndarray
:type o_filename: str
:type options: argparse.Namespace
"""
# Importin... | python | def create_scree_plot(data, o_filename, options):
"""Creates the scree plot.
:param data: the eigenvalues.
:param o_filename: the name of the output files.
:param options: the options.
:type data: numpy.ndarray
:type o_filename: str
:type options: argparse.Namespace
"""
# Importin... | [
"def",
"create_scree_plot",
"(",
"data",
",",
"o_filename",
",",
"options",
")",
":",
"# Importing plt",
"mpl",
".",
"use",
"(",
"\"Agg\"",
")",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"plt",
".",
"ioff",
"(",
")",
"# Computing the cumulative sum",... | Creates the scree plot.
:param data: the eigenvalues.
:param o_filename: the name of the output files.
:param options: the options.
:type data: numpy.ndarray
:type o_filename: str
:type options: argparse.Namespace | [
"Creates",
"the",
"scree",
"plot",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/plot_eigenvalues.py#L57-L128 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/plot_eigenvalues.py | read_eigenvalues | def read_eigenvalues(i_filename):
"""Reads the eigenvalues from EIGENSOFT results.
:param i_filename: the name of the input file.
:type i_filename: str
:returns: a :py:class:`numpy.ndarray` array containing the eigenvalues.
"""
# The data is the first line of the result file (should begin wi... | python | def read_eigenvalues(i_filename):
"""Reads the eigenvalues from EIGENSOFT results.
:param i_filename: the name of the input file.
:type i_filename: str
:returns: a :py:class:`numpy.ndarray` array containing the eigenvalues.
"""
# The data is the first line of the result file (should begin wi... | [
"def",
"read_eigenvalues",
"(",
"i_filename",
")",
":",
"# The data is the first line of the result file (should begin with",
"# \"#eigvals\"",
"data",
"=",
"None",
"with",
"open",
"(",
"i_filename",
",",
"\"r\"",
")",
"as",
"i_file",
":",
"data",
"=",
"re",
".",
"s... | Reads the eigenvalues from EIGENSOFT results.
:param i_filename: the name of the input file.
:type i_filename: str
:returns: a :py:class:`numpy.ndarray` array containing the eigenvalues. | [
"Reads",
"the",
"eigenvalues",
"from",
"EIGENSOFT",
"results",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/plot_eigenvalues.py#L131-L154 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/plot_eigenvalues.py | check_args | def check_args(args):
"""Checks the arguments and options.
:param args: an object containing the options and arguments 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
:p... | python | def check_args(args):
"""Checks the arguments and options.
:param args: an object containing the options and arguments 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
:p... | [
"def",
"check_args",
"(",
"args",
")",
":",
"# Checking that the input file exists",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"args",
".",
"evec",
")",
":",
"m",
"=",
"\"{}: no such file\"",
".",
"format",
"(",
"args",
".",
"evec",
")",
"raise",... | Checks the arguments and options.
:param args: an object containing the options and arguments 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
:py:class:`ProgramError` class,... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/plot_eigenvalues.py#L157-L175 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/plot_eigenvalues.py | parse_args | def parse_args(argString=None):
"""Parses the command line options and arguments.
:returns: A :py:class:`argparse.Namespace` object created by the
:py:mod:`argparse` module. It contains the values of the
different options.
====================== ====== =========================... | python | def parse_args(argString=None):
"""Parses the command line options and arguments.
:returns: A :py:class:`argparse.Namespace` object created by the
:py:mod:`argparse` module. It contains the values of the
different options.
====================== ====== =========================... | [
"def",
"parse_args",
"(",
"argString",
"=",
"None",
")",
":",
"args",
"=",
"None",
"if",
"argString",
"is",
"None",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"else",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
"argString",
")",
... | Parses the command line options and arguments.
:returns: A :py:class:`argparse.Namespace` object created by the
:py:mod:`argparse` module. It contains the values of the
different options.
====================== ====== ================================
Options Typ... | [
"Parses",
"the",
"command",
"line",
"options",
"and",
"arguments",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/plot_eigenvalues.py#L178-L205 |
fbngrm/babelpy | babelpy/dump.py | dump_json | def dump_json(token_dict, dump_path):
"""write json data to file
"""
if sys.version > '3':
with open(dump_path, 'w', encoding='utf-8') as output_file:
json.dump(token_dict, output_file, indent=4)
else:
with open(dump_path, 'w') as output_file:
json.dump(token_dict... | python | def dump_json(token_dict, dump_path):
"""write json data to file
"""
if sys.version > '3':
with open(dump_path, 'w', encoding='utf-8') as output_file:
json.dump(token_dict, output_file, indent=4)
else:
with open(dump_path, 'w') as output_file:
json.dump(token_dict... | [
"def",
"dump_json",
"(",
"token_dict",
",",
"dump_path",
")",
":",
"if",
"sys",
".",
"version",
">",
"'3'",
":",
"with",
"open",
"(",
"dump_path",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"output_file",
":",
"json",
".",
"dump",
"(",
"... | write json data to file | [
"write",
"json",
"data",
"to",
"file"
] | train | https://github.com/fbngrm/babelpy/blob/ff305abecddd66aed40c32f0010485cf192e5f17/babelpy/dump.py#L7-L15 |
fbngrm/babelpy | babelpy/parser.py | parse | def parse():
"""parse arguments supplied by cmd-line
"""
parser = argparse.ArgumentParser(
description='BabelFy Entity Tagger',
formatter_class=argparse.RawTextHelpFormatter
)
group = parser.add_mutually_exclusive_group()
group.add_argument(
... | python | def parse():
"""parse arguments supplied by cmd-line
"""
parser = argparse.ArgumentParser(
description='BabelFy Entity Tagger',
formatter_class=argparse.RawTextHelpFormatter
)
group = parser.add_mutually_exclusive_group()
group.add_argument(
... | [
"def",
"parse",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'BabelFy Entity Tagger'",
",",
"formatter_class",
"=",
"argparse",
".",
"RawTextHelpFormatter",
")",
"group",
"=",
"parser",
".",
"add_mutually_exclusive_group... | parse arguments supplied by cmd-line | [
"parse",
"arguments",
"supplied",
"by",
"cmd",
"-",
"line"
] | train | https://github.com/fbngrm/babelpy/blob/ff305abecddd66aed40c32f0010485cf192e5f17/babelpy/parser.py#L3-L73 |
gasparka/pyhacores | pyhacores/filter/fir.py | FIR.main | def main(self, x):
""" Transposed FIR structure """
self.acc[0] = x * self.TAPS[-1]
for i in range(1, len(self.acc)):
self.acc[i] = self.acc[i - 1] + x * self.TAPS[len(self.TAPS) - 1 - i]
self.out = self.acc[-1]
return self.out | python | def main(self, x):
""" Transposed FIR structure """
self.acc[0] = x * self.TAPS[-1]
for i in range(1, len(self.acc)):
self.acc[i] = self.acc[i - 1] + x * self.TAPS[len(self.TAPS) - 1 - i]
self.out = self.acc[-1]
return self.out | [
"def",
"main",
"(",
"self",
",",
"x",
")",
":",
"self",
".",
"acc",
"[",
"0",
"]",
"=",
"x",
"*",
"self",
".",
"TAPS",
"[",
"-",
"1",
"]",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"self",
".",
"acc",
")",
")",
":",
"self",
... | Transposed FIR structure | [
"Transposed",
"FIR",
"structure"
] | train | https://github.com/gasparka/pyhacores/blob/16c186fbbf90385f2ba3498395123e79b6fcf340/pyhacores/filter/fir.py#L15-L22 |
tomi77/django-extra-tools | django_extra_tools/db/__init__.py | pg_version | def pg_version(using=None):
"""
Return tuple with PostgreSQL version of a specific connection
:type using: str
:param using: Connection name
:rtype: tuple
:return: PostgreSQL version
"""
connection = get_connection(using)
cursor = connection.cursor()
cursor.execute('SHOW server_... | python | def pg_version(using=None):
"""
Return tuple with PostgreSQL version of a specific connection
:type using: str
:param using: Connection name
:rtype: tuple
:return: PostgreSQL version
"""
connection = get_connection(using)
cursor = connection.cursor()
cursor.execute('SHOW server_... | [
"def",
"pg_version",
"(",
"using",
"=",
"None",
")",
":",
"connection",
"=",
"get_connection",
"(",
"using",
")",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"'SHOW server_version'",
")",
"row",
"=",
"cursor",
".",
... | Return tuple with PostgreSQL version of a specific connection
:type using: str
:param using: Connection name
:rtype: tuple
:return: PostgreSQL version | [
"Return",
"tuple",
"with",
"PostgreSQL",
"version",
"of",
"a",
"specific",
"connection",
":",
"type",
"using",
":",
"str",
":",
"param",
"using",
":",
"Connection",
"name",
":",
"rtype",
":",
"tuple",
":",
"return",
":",
"PostgreSQL",
"version"
] | train | https://github.com/tomi77/django-extra-tools/blob/fb6d226bc5cf3fc0eb8abe61a512c3f5c7dcc8a8/django_extra_tools/db/__init__.py#L12-L26 |
tomi77/django-extra-tools | django_extra_tools/db/__init__.py | batch_qs | def batch_qs(qs, batch_size=1000):
"""
Returns a (start, end, total, queryset) tuple for each batch in the given
queryset.
Usage:
# Make sure to order your queryset
article_qs = Article.objects.order_by('id')
for start, end, total, qs in batch_qs(article_qs):
print "... | python | def batch_qs(qs, batch_size=1000):
"""
Returns a (start, end, total, queryset) tuple for each batch in the given
queryset.
Usage:
# Make sure to order your queryset
article_qs = Article.objects.order_by('id')
for start, end, total, qs in batch_qs(article_qs):
print "... | [
"def",
"batch_qs",
"(",
"qs",
",",
"batch_size",
"=",
"1000",
")",
":",
"total",
"=",
"qs",
".",
"count",
"(",
")",
"for",
"start",
"in",
"range",
"(",
"0",
",",
"total",
",",
"batch_size",
")",
":",
"end",
"=",
"min",
"(",
"start",
"+",
"batch_s... | Returns a (start, end, total, queryset) tuple for each batch in the given
queryset.
Usage:
# Make sure to order your queryset
article_qs = Article.objects.order_by('id')
for start, end, total, qs in batch_qs(article_qs):
print "Now processing %s - %s of %s" % (start + 1, end... | [
"Returns",
"a",
"(",
"start",
"end",
"total",
"queryset",
")",
"tuple",
"for",
"each",
"batch",
"in",
"the",
"given",
"queryset",
"."
] | train | https://github.com/tomi77/django-extra-tools/blob/fb6d226bc5cf3fc0eb8abe61a512c3f5c7dcc8a8/django_extra_tools/db/__init__.py#L29-L45 |
photo/openphoto-python | trovebox/api/api_tag.py | ApiTags.list | def list(self, **kwds):
"""
Endpoint: /tags/list.json
Returns a list of Tag objects.
"""
tags = self._client.get("/tags/list.json", **kwds)["result"]
tags = self._result_to_list(tags)
return [Tag(self._client, tag) for tag in tags] | python | def list(self, **kwds):
"""
Endpoint: /tags/list.json
Returns a list of Tag objects.
"""
tags = self._client.get("/tags/list.json", **kwds)["result"]
tags = self._result_to_list(tags)
return [Tag(self._client, tag) for tag in tags] | [
"def",
"list",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"tags",
"=",
"self",
".",
"_client",
".",
"get",
"(",
"\"/tags/list.json\"",
",",
"*",
"*",
"kwds",
")",
"[",
"\"result\"",
"]",
"tags",
"=",
"self",
".",
"_result_to_list",
"(",
"tags",
... | Endpoint: /tags/list.json
Returns a list of Tag objects. | [
"Endpoint",
":",
"/",
"tags",
"/",
"list",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_tag.py#L9-L17 |
photo/openphoto-python | trovebox/api/api_tag.py | ApiTag.create | def create(self, tag, **kwds):
"""
Endpoint: /tag/create.json
Creates a new tag.
Returns True if successful.
Raises a TroveboxError if not.
"""
return self._client.post("/tag/create.json", tag=tag, **kwds)["result"] | python | def create(self, tag, **kwds):
"""
Endpoint: /tag/create.json
Creates a new tag.
Returns True if successful.
Raises a TroveboxError if not.
"""
return self._client.post("/tag/create.json", tag=tag, **kwds)["result"] | [
"def",
"create",
"(",
"self",
",",
"tag",
",",
"*",
"*",
"kwds",
")",
":",
"return",
"self",
".",
"_client",
".",
"post",
"(",
"\"/tag/create.json\"",
",",
"tag",
"=",
"tag",
",",
"*",
"*",
"kwds",
")",
"[",
"\"result\"",
"]"
] | Endpoint: /tag/create.json
Creates a new tag.
Returns True if successful.
Raises a TroveboxError if not. | [
"Endpoint",
":",
"/",
"tag",
"/",
"create",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_tag.py#L21-L29 |
photo/openphoto-python | trovebox/api/api_tag.py | ApiTag.delete | def delete(self, tag, **kwds):
"""
Endpoint: /tag/<id>/delete.json
Deletes a tag.
Returns True if successful.
Raises a TroveboxError if not.
"""
return self._client.post("/tag/%s/delete.json" %
self._quote_url(self._extract_id(tag... | python | def delete(self, tag, **kwds):
"""
Endpoint: /tag/<id>/delete.json
Deletes a tag.
Returns True if successful.
Raises a TroveboxError if not.
"""
return self._client.post("/tag/%s/delete.json" %
self._quote_url(self._extract_id(tag... | [
"def",
"delete",
"(",
"self",
",",
"tag",
",",
"*",
"*",
"kwds",
")",
":",
"return",
"self",
".",
"_client",
".",
"post",
"(",
"\"/tag/%s/delete.json\"",
"%",
"self",
".",
"_quote_url",
"(",
"self",
".",
"_extract_id",
"(",
"tag",
")",
")",
",",
"*",... | Endpoint: /tag/<id>/delete.json
Deletes a tag.
Returns True if successful.
Raises a TroveboxError if not. | [
"Endpoint",
":",
"/",
"tag",
"/",
"<id",
">",
"/",
"delete",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_tag.py#L31-L41 |
photo/openphoto-python | trovebox/api/api_tag.py | ApiTag.update | def update(self, tag, **kwds):
"""
Endpoint: /tag/<id>/update.json
Updates a tag with the specified parameters.
Returns the updated tag object.
"""
result = self._client.post("/tag/%s/update.json" %
self._quote_url(self._extract_id(tag)... | python | def update(self, tag, **kwds):
"""
Endpoint: /tag/<id>/update.json
Updates a tag with the specified parameters.
Returns the updated tag object.
"""
result = self._client.post("/tag/%s/update.json" %
self._quote_url(self._extract_id(tag)... | [
"def",
"update",
"(",
"self",
",",
"tag",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"post",
"(",
"\"/tag/%s/update.json\"",
"%",
"self",
".",
"_quote_url",
"(",
"self",
".",
"_extract_id",
"(",
"tag",
")",
")",
",",... | Endpoint: /tag/<id>/update.json
Updates a tag with the specified parameters.
Returns the updated tag object. | [
"Endpoint",
":",
"/",
"tag",
"/",
"<id",
">",
"/",
"update",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_tag.py#L43-L53 |
kissmetrics/py-KISSmetrics | KISSmetrics/client_compat.py | ClientCompat.record | def record(self, action, props=None, path=KISSmetrics.RECORD_PATH,
resp=False):
"""Record event for identity with any properties.
:param action: event performed
:param props: any additional data to include
:type props: dict
:param resp: indicate whether to return ... | python | def record(self, action, props=None, path=KISSmetrics.RECORD_PATH,
resp=False):
"""Record event for identity with any properties.
:param action: event performed
:param props: any additional data to include
:type props: dict
:param resp: indicate whether to return ... | [
"def",
"record",
"(",
"self",
",",
"action",
",",
"props",
"=",
"None",
",",
"path",
"=",
"KISSmetrics",
".",
"RECORD_PATH",
",",
"resp",
"=",
"False",
")",
":",
"self",
".",
"check_id_key",
"(",
")",
"timestamp",
"=",
"None",
"if",
"not",
"props",
"... | Record event for identity with any properties.
:param action: event performed
:param props: any additional data to include
:type props: dict
:param resp: indicate whether to return response
:type resp: boolean
:returns: an HTTP response for request if `resp=True`
... | [
"Record",
"event",
"for",
"identity",
"with",
"any",
"properties",
"."
] | train | https://github.com/kissmetrics/py-KISSmetrics/blob/705bf3fe26dd440abdf37bf213396b68af385523/KISSmetrics/client_compat.py#L57-L81 |
kissmetrics/py-KISSmetrics | KISSmetrics/client_compat.py | ClientCompat.set | def set(self, data, path=KISSmetrics.SET_PATH, resp=False):
"""Set a properties provided in `data` for identity.
:param data: key-value pairs to associate with identity
:type data: dict
:param path: endpoint path; defaults to ``KISSmetrics.SET_PATH``
:param resp: indicate whethe... | python | def set(self, data, path=KISSmetrics.SET_PATH, resp=False):
"""Set a properties provided in `data` for identity.
:param data: key-value pairs to associate with identity
:type data: dict
:param path: endpoint path; defaults to ``KISSmetrics.SET_PATH``
:param resp: indicate whethe... | [
"def",
"set",
"(",
"self",
",",
"data",
",",
"path",
"=",
"KISSmetrics",
".",
"SET_PATH",
",",
"resp",
"=",
"False",
")",
":",
"self",
".",
"check_id_key",
"(",
")",
"timestamp",
"=",
"None",
"response",
"=",
"self",
".",
"client",
".",
"set",
"(",
... | Set a properties provided in `data` for identity.
:param data: key-value pairs to associate with identity
:type data: dict
:param path: endpoint path; defaults to ``KISSmetrics.SET_PATH``
:param resp: indicate whether to return response
:type resp: boolean
:returns: an ... | [
"Set",
"a",
"properties",
"provided",
"in",
"data",
"for",
"identity",
"."
] | train | https://github.com/kissmetrics/py-KISSmetrics/blob/705bf3fe26dd440abdf37bf213396b68af385523/KISSmetrics/client_compat.py#L83-L103 |
kissmetrics/py-KISSmetrics | KISSmetrics/client_compat.py | ClientCompat.alias | def alias(self, name, alias_to, path=KISSmetrics.ALIAS_PATH, resp=False):
"""Map `name` to `alias_to`; actions done by one resolve to other.
:param name: consider as same individual as ``alias_to``
:param alias_to: consider an alias of ``name``
:param path: endpoint path; defaults to ``... | python | def alias(self, name, alias_to, path=KISSmetrics.ALIAS_PATH, resp=False):
"""Map `name` to `alias_to`; actions done by one resolve to other.
:param name: consider as same individual as ``alias_to``
:param alias_to: consider an alias of ``name``
:param path: endpoint path; defaults to ``... | [
"def",
"alias",
"(",
"self",
",",
"name",
",",
"alias_to",
",",
"path",
"=",
"KISSmetrics",
".",
"ALIAS_PATH",
",",
"resp",
"=",
"False",
")",
":",
"self",
".",
"check_init",
"(",
")",
"response",
"=",
"self",
".",
"client",
".",
"alias",
"(",
"perso... | Map `name` to `alias_to`; actions done by one resolve to other.
:param name: consider as same individual as ``alias_to``
:param alias_to: consider an alias of ``name``
:param path: endpoint path; defaults to ``KISSmetrics.ALIAS_PATH``
:param resp: indicate whether to return response
... | [
"Map",
"name",
"to",
"alias_to",
";",
"actions",
"done",
"by",
"one",
"resolve",
"to",
"other",
"."
] | train | https://github.com/kissmetrics/py-KISSmetrics/blob/705bf3fe26dd440abdf37bf213396b68af385523/KISSmetrics/client_compat.py#L105-L123 |
williamjameshandley/fgivenx | fgivenx/mass.py | PMF | def PMF(samples, y):
""" Compute the probability mass function.
The set of samples defines a probability density P(y),
which is computed using a kernel density estimator.
From :math:`P(y)` we define:
:math:`\mathrm{pmf}(p) = \int_{P(y)<p} P(y) dy`
This is the cumulative d... | python | def PMF(samples, y):
""" Compute the probability mass function.
The set of samples defines a probability density P(y),
which is computed using a kernel density estimator.
From :math:`P(y)` we define:
:math:`\mathrm{pmf}(p) = \int_{P(y)<p} P(y) dy`
This is the cumulative d... | [
"def",
"PMF",
"(",
"samples",
",",
"y",
")",
":",
"# Remove any nans from the samples",
"samples",
"=",
"numpy",
".",
"array",
"(",
"samples",
")",
"samples",
"=",
"samples",
"[",
"~",
"numpy",
".",
"isnan",
"(",
"samples",
")",
"]",
"try",
":",
"# Compu... | Compute the probability mass function.
The set of samples defines a probability density P(y),
which is computed using a kernel density estimator.
From :math:`P(y)` we define:
:math:`\mathrm{pmf}(p) = \int_{P(y)<p} P(y) dy`
This is the cumulative distribution function expresse... | [
"Compute",
"the",
"probability",
"mass",
"function",
"."
] | train | https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/mass.py#L9-L117 |
williamjameshandley/fgivenx | fgivenx/mass.py | compute_pmf | def compute_pmf(fsamps, y, **kwargs):
""" Compute the pmf defined by fsamps at each x for each y.
Parameters
----------
fsamps: 2D array-like
array of function samples, as returned by
:func:`fgivenx.compute_samples`
y: 1D array-like
y values to evaluate the PMF at
para... | python | def compute_pmf(fsamps, y, **kwargs):
""" Compute the pmf defined by fsamps at each x for each y.
Parameters
----------
fsamps: 2D array-like
array of function samples, as returned by
:func:`fgivenx.compute_samples`
y: 1D array-like
y values to evaluate the PMF at
para... | [
"def",
"compute_pmf",
"(",
"fsamps",
",",
"y",
",",
"*",
"*",
"kwargs",
")",
":",
"parallel",
"=",
"kwargs",
".",
"pop",
"(",
"'parallel'",
",",
"False",
")",
"cache",
"=",
"kwargs",
".",
"pop",
"(",
"'cache'",
",",
"''",
")",
"tqdm_kwargs",
"=",
"... | Compute the pmf defined by fsamps at each x for each y.
Parameters
----------
fsamps: 2D array-like
array of function samples, as returned by
:func:`fgivenx.compute_samples`
y: 1D array-like
y values to evaluate the PMF at
parallel, tqdm_kwargs: optional
see docstr... | [
"Compute",
"the",
"pmf",
"defined",
"by",
"fsamps",
"at",
"each",
"x",
"for",
"each",
"y",
"."
] | train | https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/mass.py#L120-L161 |
radujica/baloo | baloo/weld/weld_ops.py | weld_range | def weld_range(start, stop, step):
"""Create a vector for the range parameters above.
Parameters
----------
start : int
stop : int or WeldObject
Could be the lazily computed length of a WeldObject vec.
step : int
Returns
-------
WeldObject
Representation of this com... | python | def weld_range(start, stop, step):
"""Create a vector for the range parameters above.
Parameters
----------
start : int
stop : int or WeldObject
Could be the lazily computed length of a WeldObject vec.
step : int
Returns
-------
WeldObject
Representation of this com... | [
"def",
"weld_range",
"(",
"start",
",",
"stop",
",",
"step",
")",
":",
"if",
"isinstance",
"(",
"stop",
",",
"WeldObject",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"stop",
")",
"stop",
"=",
"obj_id",
"else",
":",
"weld_obj",
... | Create a vector for the range parameters above.
Parameters
----------
start : int
stop : int or WeldObject
Could be the lazily computed length of a WeldObject vec.
step : int
Returns
-------
WeldObject
Representation of this computation. | [
"Create",
"a",
"vector",
"for",
"the",
"range",
"parameters",
"above",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L11-L48 |
radujica/baloo | baloo/weld/weld_ops.py | weld_compare | def weld_compare(array, scalar, operation, weld_type):
"""Applies comparison operation between each element in the array with scalar.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data.
scalar : {int, float, str, bool, bytes_}
Value to compare with; must be same ty... | python | def weld_compare(array, scalar, operation, weld_type):
"""Applies comparison operation between each element in the array with scalar.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data.
scalar : {int, float, str, bool, bytes_}
Value to compare with; must be same ty... | [
"def",
"weld_compare",
"(",
"array",
",",
"scalar",
",",
"operation",
",",
"weld_type",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"if",
"not",
"isinstance",
"(",
"scalar",
",",
"str",
")",
":",
"scalar",
"=",
"to_... | Applies comparison operation between each element in the array with scalar.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data.
scalar : {int, float, str, bool, bytes_}
Value to compare with; must be same type as the values in the array. If not a str,
it is cas... | [
"Applies",
"comparison",
"operation",
"between",
"each",
"element",
"in",
"the",
"array",
"with",
"scalar",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L51-L94 |
radujica/baloo | baloo/weld/weld_ops.py | weld_filter | def weld_filter(array, weld_type, bool_array):
"""Returns a new array only with the elements with a corresponding True in bool_array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data.
weld_type : WeldType
Type of the elements in the input array.
bool_array : ... | python | def weld_filter(array, weld_type, bool_array):
"""Returns a new array only with the elements with a corresponding True in bool_array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data.
weld_type : WeldType
Type of the elements in the input array.
bool_array : ... | [
"def",
"weld_filter",
"(",
"array",
",",
"weld_type",
",",
"bool_array",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"bool_obj_id",
"=",
"get_weld_obj_id",
"(",
"weld_obj",
",",
"bool_array",
")",
"weld_template",
"=",
"\... | Returns a new array only with the elements with a corresponding True in bool_array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data.
weld_type : WeldType
Type of the elements in the input array.
bool_array : numpy.ndarray or WeldObject
Array of bool with... | [
"Returns",
"a",
"new",
"array",
"only",
"with",
"the",
"elements",
"with",
"a",
"corresponding",
"True",
"in",
"bool_array",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L97-L133 |
radujica/baloo | baloo/weld/weld_ops.py | weld_slice | def weld_slice(array, weld_type, slice_, default_start=0, default_stop=0, default_step=1):
"""Returns a new array according to the given slice.
Parameters
----------
array : numpy.ndarray or WeldObject
1-dimensional array.
weld_type : WeldType
Type of the elements in the input array... | python | def weld_slice(array, weld_type, slice_, default_start=0, default_stop=0, default_step=1):
"""Returns a new array according to the given slice.
Parameters
----------
array : numpy.ndarray or WeldObject
1-dimensional array.
weld_type : WeldType
Type of the elements in the input array... | [
"def",
"weld_slice",
"(",
"array",
",",
"weld_type",
",",
"slice_",
",",
"default_start",
"=",
"0",
",",
"default_stop",
"=",
"0",
",",
"default_step",
"=",
"1",
")",
":",
"from",
".",
".",
"core",
".",
"utils",
"import",
"replace_slice_defaults",
"slice_"... | Returns a new array according to the given slice.
Parameters
----------
array : numpy.ndarray or WeldObject
1-dimensional array.
weld_type : WeldType
Type of the elements in the input array.
slice_ : slice
Subset to return. Assumed valid slice.
default_start : int, optio... | [
"Returns",
"a",
"new",
"array",
"according",
"to",
"the",
"given",
"slice",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L136-L187 |
radujica/baloo | baloo/weld/weld_ops.py | weld_tail | def weld_tail(array, length, n):
"""Return the last n elements.
Parameters
----------
array : numpy.ndarray or WeldObject
Array to select from.
length : int or WeldObject
Length of the array. Int if already known can simplify the computation.
n : int
How many values.
... | python | def weld_tail(array, length, n):
"""Return the last n elements.
Parameters
----------
array : numpy.ndarray or WeldObject
Array to select from.
length : int or WeldObject
Length of the array. Int if already known can simplify the computation.
n : int
How many values.
... | [
"def",
"weld_tail",
"(",
"array",
",",
"length",
",",
"n",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"if",
"isinstance",
"(",
"length",
",",
"WeldObject",
")",
":",
"length",
"=",
"get_weld_obj_id",
"(",
"weld_obj",... | Return the last n elements.
Parameters
----------
array : numpy.ndarray or WeldObject
Array to select from.
length : int or WeldObject
Length of the array. Int if already known can simplify the computation.
n : int
How many values.
Returns
-------
WeldObject
... | [
"Return",
"the",
"last",
"n",
"elements",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L191-L228 |
radujica/baloo | baloo/weld/weld_ops.py | weld_array_op | def weld_array_op(array1, array2, result_type, operation):
"""Applies operation to each pair of elements in the arrays.
Their lengths and types are assumed to be the same.
Parameters
----------
array1 : numpy.ndarray or WeldObject
Input array.
array2 : numpy.ndarray or WeldObject
... | python | def weld_array_op(array1, array2, result_type, operation):
"""Applies operation to each pair of elements in the arrays.
Their lengths and types are assumed to be the same.
Parameters
----------
array1 : numpy.ndarray or WeldObject
Input array.
array2 : numpy.ndarray or WeldObject
... | [
"def",
"weld_array_op",
"(",
"array1",
",",
"array2",
",",
"result_type",
",",
"operation",
")",
":",
"obj_id1",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array1",
")",
"obj_id2",
"=",
"get_weld_obj_id",
"(",
"weld_obj",
",",
"array2",
")",
"if",
"op... | Applies operation to each pair of elements in the arrays.
Their lengths and types are assumed to be the same.
Parameters
----------
array1 : numpy.ndarray or WeldObject
Input array.
array2 : numpy.ndarray or WeldObject
Second input array.
result_type : WeldType
Weld typ... | [
"Applies",
"operation",
"to",
"each",
"pair",
"of",
"elements",
"in",
"the",
"arrays",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L232-L275 |
radujica/baloo | baloo/weld/weld_ops.py | weld_invert | def weld_invert(array):
"""Inverts a bool array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
Returns
-------
WeldObject
Representation of this computation.
"""
obj_id, weld_obj = create_weld_object(array)
weld... | python | def weld_invert(array):
"""Inverts a bool array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
Returns
-------
WeldObject
Representation of this computation.
"""
obj_id, weld_obj = create_weld_object(array)
weld... | [
"def",
"weld_invert",
"(",
"array",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"weld_template",
"=",
"\"\"\"result(\n for({array},\n appender[bool],\n |b: appender[bool], i: i64, e: bool|\n if(e, merge(b, false), mer... | Inverts a bool array.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
Returns
-------
WeldObject
Representation of this computation. | [
"Inverts",
"a",
"bool",
"array",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L278-L304 |
radujica/baloo | baloo/weld/weld_ops.py | weld_iloc_int | def weld_iloc_int(array, index):
"""Retrieves the value at index.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
index : int
The array index from which to retrieve value.
Returns
-------
WeldObject
Representation o... | python | def weld_iloc_int(array, index):
"""Retrieves the value at index.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
index : int
The array index from which to retrieve value.
Returns
-------
WeldObject
Representation o... | [
"def",
"weld_iloc_int",
"(",
"array",
",",
"index",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"weld_template",
"=",
"'lookup({array}, {index}L)'",
"weld_obj",
".",
"weld_code",
"=",
"weld_template",
".",
"format",
"(",
"a... | Retrieves the value at index.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
index : int
The array index from which to retrieve value.
Returns
-------
WeldObject
Representation of this computation. | [
"Retrieves",
"the",
"value",
"at",
"index",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L307-L330 |
radujica/baloo | baloo/weld/weld_ops.py | weld_iloc_indices | def weld_iloc_indices(array, weld_type, indices):
"""Retrieve the values at indices.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
weld_type : WeldType
The WeldType of the array data.
indices : numpy.ndarray or WeldObject
... | python | def weld_iloc_indices(array, weld_type, indices):
"""Retrieve the values at indices.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
weld_type : WeldType
The WeldType of the array data.
indices : numpy.ndarray or WeldObject
... | [
"def",
"weld_iloc_indices",
"(",
"array",
",",
"weld_type",
",",
"indices",
")",
":",
"weld_obj",
"=",
"create_empty_weld_object",
"(",
")",
"weld_obj_id_array",
"=",
"get_weld_obj_id",
"(",
"weld_obj",
",",
"array",
")",
"weld_obj_id_indices",
"=",
"get_weld_obj_id... | Retrieve the values at indices.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
weld_type : WeldType
The WeldType of the array data.
indices : numpy.ndarray or WeldObject
The indices to lookup.
Returns
-------
WeldO... | [
"Retrieve",
"the",
"values",
"at",
"indices",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L333-L367 |
radujica/baloo | baloo/weld/weld_ops.py | weld_iloc_indices_with_missing | def weld_iloc_indices_with_missing(array, weld_type, indices):
"""Retrieve the values at indices. Indices greater than array length get replaced with
a corresponding-type missing value literal.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
... | python | def weld_iloc_indices_with_missing(array, weld_type, indices):
"""Retrieve the values at indices. Indices greater than array length get replaced with
a corresponding-type missing value literal.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
... | [
"def",
"weld_iloc_indices_with_missing",
"(",
"array",
",",
"weld_type",
",",
"indices",
")",
":",
"weld_obj",
"=",
"create_empty_weld_object",
"(",
")",
"weld_obj_id_array",
"=",
"get_weld_obj_id",
"(",
"weld_obj",
",",
"array",
")",
"weld_obj_id_indices",
"=",
"ge... | Retrieve the values at indices. Indices greater than array length get replaced with
a corresponding-type missing value literal.
Parameters
----------
array : numpy.ndarray or WeldObject
Input data. Assumed to be bool data.
weld_type : WeldType
The WeldType of the array data.
ind... | [
"Retrieve",
"the",
"values",
"at",
"indices",
".",
"Indices",
"greater",
"than",
"array",
"length",
"get",
"replaced",
"with",
"a",
"corresponding",
"-",
"type",
"missing",
"value",
"literal",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L370-L414 |
radujica/baloo | baloo/weld/weld_ops.py | weld_element_wise_op | def weld_element_wise_op(array, weld_type, scalar, operation):
"""Applies operation to each element in the array with scalar.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
scalar : {int, float... | python | def weld_element_wise_op(array, weld_type, scalar, operation):
"""Applies operation to each element in the array with scalar.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
scalar : {int, float... | [
"def",
"weld_element_wise_op",
"(",
"array",
",",
"weld_type",
",",
"scalar",
",",
"operation",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"scalar",
"=",
"to_weld_literal",
"(",
"scalar",
",",
"weld_type",
")",
"if",
"... | Applies operation to each element in the array with scalar.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of each element in the input array.
scalar : {int, float, str, bool, bytes_}
Value to compare with; must be same type ... | [
"Applies",
"operation",
"to",
"each",
"element",
"in",
"the",
"array",
"with",
"scalar",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L417-L459 |
radujica/baloo | baloo/weld/weld_ops.py | weld_sort | def weld_sort(arrays, weld_types, readable_text, ascending=True):
"""Sort the arrays.
Parameters
----------
arrays : list of (numpy.ndarray or WeldObject)
Arrays to put in a struct.
weld_types : list of WeldType
The Weld types of the arrays in the same order.
readable_text : str... | python | def weld_sort(arrays, weld_types, readable_text, ascending=True):
"""Sort the arrays.
Parameters
----------
arrays : list of (numpy.ndarray or WeldObject)
Arrays to put in a struct.
weld_types : list of WeldType
The Weld types of the arrays in the same order.
readable_text : str... | [
"def",
"weld_sort",
"(",
"arrays",
",",
"weld_types",
",",
"readable_text",
",",
"ascending",
"=",
"True",
")",
":",
"weld_obj_sort",
"=",
"_weld_sort",
"(",
"arrays",
",",
"weld_types",
",",
"ascending",
")",
"weld_obj_struct",
"=",
"weld_vec_of_struct_to_struct_... | Sort the arrays.
Parameters
----------
arrays : list of (numpy.ndarray or WeldObject)
Arrays to put in a struct.
weld_types : list of WeldType
The Weld types of the arrays in the same order.
readable_text : str
Explanatory string to add in the Weld placeholder.
ascending... | [
"Sort",
"the",
"arrays",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L495-L526 |
radujica/baloo | baloo/weld/weld_ops.py | weld_unique | def weld_unique(array, weld_type):
"""Return the unique elements 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 ... | python | def weld_unique(array, weld_type):
"""Return the unique elements 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 ... | [
"def",
"weld_unique",
"(",
"array",
",",
"weld_type",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"array",
")",
"weld_template",
"=",
"\"\"\"map(\n tovec(\n result(\n for(\n map(\n {array},\n ... | Return the unique elements 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. | [
"Return",
"the",
"unique",
"elements",
"of",
"the",
"array",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L529-L569 |
radujica/baloo | baloo/weld/weld_ops.py | weld_drop_duplicates | def weld_drop_duplicates(arrays, weld_types, subset_indices, keep):
"""Return the unique elements of the array.
Parameters
----------
arrays : list of (numpy.ndarray or WeldObject)
Input arrays.
weld_types : list of WeldType
Type of elements in the input arrays.
subset_indices :... | python | def weld_drop_duplicates(arrays, weld_types, subset_indices, keep):
"""Return the unique elements of the array.
Parameters
----------
arrays : list of (numpy.ndarray or WeldObject)
Input arrays.
weld_types : list of WeldType
Type of elements in the input arrays.
subset_indices :... | [
"def",
"weld_drop_duplicates",
"(",
"arrays",
",",
"weld_types",
",",
"subset_indices",
",",
"keep",
")",
":",
"weld_obj_struct",
"=",
"weld_arrays_to_vec_of_struct",
"(",
"arrays",
",",
"weld_types",
")",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
... | Return the unique elements of the array.
Parameters
----------
arrays : list of (numpy.ndarray or WeldObject)
Input arrays.
weld_types : list of WeldType
Type of elements in the input arrays.
subset_indices : list of int
Indices of which arrays to consider from arrays when c... | [
"Return",
"the",
"unique",
"elements",
"of",
"the",
"array",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L572-L655 |
radujica/baloo | baloo/weld/weld_ops.py | weld_replace | def weld_replace(array, weld_type, this, to):
"""Replaces 'this' values to 'to' value.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of the data in the array.
this : {int, float, str, bool, bytes}
Scalar to replace.
... | python | def weld_replace(array, weld_type, this, to):
"""Replaces 'this' values to 'to' value.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of the data in the array.
this : {int, float, str, bool, bytes}
Scalar to replace.
... | [
"def",
"weld_replace",
"(",
"array",
",",
"weld_type",
",",
"this",
",",
"to",
")",
":",
"if",
"not",
"isinstance",
"(",
"this",
",",
"str",
")",
":",
"this",
"=",
"to_weld_literal",
"(",
"this",
",",
"weld_type",
")",
"to",
"=",
"to_weld_literal",
"("... | Replaces 'this' values to 'to' value.
Parameters
----------
array : numpy.ndarray or WeldObject
Input array.
weld_type : WeldType
Type of the data in the array.
this : {int, float, str, bool, bytes}
Scalar to replace.
to : {int, float, str, bool, bytes}
Scalar to... | [
"Replaces",
"this",
"values",
"to",
"to",
"value",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L658-L697 |
radujica/baloo | baloo/weld/weld_ops.py | weld_udf | def weld_udf(weld_template, mapping):
"""Create WeldObject to encode weld_template code given mapping.
Parameters
----------
weld_template : str
Weld code to encode.
mapping : dict
Which substitutions to make in the weld_template.
Returns
-------
WeldObject
Repr... | python | def weld_udf(weld_template, mapping):
"""Create WeldObject to encode weld_template code given mapping.
Parameters
----------
weld_template : str
Weld code to encode.
mapping : dict
Which substitutions to make in the weld_template.
Returns
-------
WeldObject
Repr... | [
"def",
"weld_udf",
"(",
"weld_template",
",",
"mapping",
")",
":",
"weld_obj",
"=",
"create_empty_weld_object",
"(",
")",
"for",
"k",
",",
"v",
"in",
"mapping",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"(",
"np",
".",
"ndarray",
... | Create WeldObject to encode weld_template code given mapping.
Parameters
----------
weld_template : str
Weld code to encode.
mapping : dict
Which substitutions to make in the weld_template.
Returns
-------
WeldObject
Representation of this computation. | [
"Create",
"WeldObject",
"to",
"encode",
"weld_template",
"code",
"given",
"mapping",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_ops.py#L700-L725 |
vinitkumar/pycrawler | crawler.py | option_parser | def option_parser():
"""Option Parser to give various options."""
usage = '''
$ ./crawler -d5 <url>
Here in this case it goes till depth of 5 and url is target URL to
start crawling.
'''
version = "2.0.0"
parser = optparse.OptionParser(usage=usag... | python | def option_parser():
"""Option Parser to give various options."""
usage = '''
$ ./crawler -d5 <url>
Here in this case it goes till depth of 5 and url is target URL to
start crawling.
'''
version = "2.0.0"
parser = optparse.OptionParser(usage=usag... | [
"def",
"option_parser",
"(",
")",
":",
"usage",
"=",
"'''\n $ ./crawler -d5 <url>\n Here in this case it goes till depth of 5 and url is target URL to\n start crawling.\n '''",
"version",
"=",
"\"2.0.0\"",
"parser",
"=",
"optparse",
".... | Option Parser to give various options. | [
"Option",
"Parser",
"to",
"give",
"various",
"options",
"."
] | train | https://github.com/vinitkumar/pycrawler/blob/d3fe6d2da1469fc701c4fe04df88cee9cc8cd9c3/crawler.py#L17-L39 |
vinitkumar/pycrawler | crawler.py | getlinks | async def getlinks(url):
"""Get Links from the Linkfetcher class."""
page = Linkfetcher(url)
await page.linkfetch()
for i, url in enumerate(page):
return (i, url) | python | async def getlinks(url):
"""Get Links from the Linkfetcher class."""
page = Linkfetcher(url)
await page.linkfetch()
for i, url in enumerate(page):
return (i, url) | [
"async",
"def",
"getlinks",
"(",
"url",
")",
":",
"page",
"=",
"Linkfetcher",
"(",
"url",
")",
"await",
"page",
".",
"linkfetch",
"(",
")",
"for",
"i",
",",
"url",
"in",
"enumerate",
"(",
"page",
")",
":",
"return",
"(",
"i",
",",
"url",
")"
] | Get Links from the Linkfetcher class. | [
"Get",
"Links",
"from",
"the",
"Linkfetcher",
"class",
"."
] | train | https://github.com/vinitkumar/pycrawler/blob/d3fe6d2da1469fc701c4fe04df88cee9cc8cd9c3/crawler.py#L42-L47 |
vinitkumar/pycrawler | crawler.py | main | async def main():
""" Main class."""
opts, args = option_parser()
url = args[0]
if opts.links:
getlinks(url)
raise SystemExit(0)
depth = opts.depth
sTime = time.time()
webcrawler = Webcrawler(url, depth)
webcrawler.crawl()
eTime = time.time()
tTime = eTime - sT... | python | async def main():
""" Main class."""
opts, args = option_parser()
url = args[0]
if opts.links:
getlinks(url)
raise SystemExit(0)
depth = opts.depth
sTime = time.time()
webcrawler = Webcrawler(url, depth)
webcrawler.crawl()
eTime = time.time()
tTime = eTime - sT... | [
"async",
"def",
"main",
"(",
")",
":",
"opts",
",",
"args",
"=",
"option_parser",
"(",
")",
"url",
"=",
"args",
"[",
"0",
"]",
"if",
"opts",
".",
"links",
":",
"getlinks",
"(",
"url",
")",
"raise",
"SystemExit",
"(",
"0",
")",
"depth",
"=",
"opts... | Main class. | [
"Main",
"class",
"."
] | train | https://github.com/vinitkumar/pycrawler/blob/d3fe6d2da1469fc701c4fe04df88cee9cc8cd9c3/crawler.py#L50-L75 |
olasitarska/django-gulp-rev | gulp_rev/__init__.py | _get_mapping | def _get_mapping():
"""
Finds and loads gulp's rev-manifest.json file.
In default, this is looking for rev-manifest.json file places in your
STATIC_ROOT. Can be overriden to a specific location by setting
DJANGO_GULP_REV_PATH.
"""
global _STATIC_MAPPING
if _STATIC_MAPPING is None:
... | python | def _get_mapping():
"""
Finds and loads gulp's rev-manifest.json file.
In default, this is looking for rev-manifest.json file places in your
STATIC_ROOT. Can be overriden to a specific location by setting
DJANGO_GULP_REV_PATH.
"""
global _STATIC_MAPPING
if _STATIC_MAPPING is None:
... | [
"def",
"_get_mapping",
"(",
")",
":",
"global",
"_STATIC_MAPPING",
"if",
"_STATIC_MAPPING",
"is",
"None",
":",
"manifest_path",
"=",
"getattr",
"(",
"settings",
",",
"'DJANGO_GULP_REV_PATH'",
",",
"os",
".",
"path",
".",
"join",
"(",
"getattr",
"(",
"settings"... | Finds and loads gulp's rev-manifest.json file.
In default, this is looking for rev-manifest.json file places in your
STATIC_ROOT. Can be overriden to a specific location by setting
DJANGO_GULP_REV_PATH. | [
"Finds",
"and",
"loads",
"gulp",
"s",
"rev",
"-",
"manifest",
".",
"json",
"file",
".",
"In",
"default",
"this",
"is",
"looking",
"for",
"rev",
"-",
"manifest",
".",
"json",
"file",
"places",
"in",
"your",
"STATIC_ROOT",
".",
"Can",
"be",
"overriden",
... | train | https://github.com/olasitarska/django-gulp-rev/blob/cb6b725d23906ef4451e9d73b91d8e1888a0b954/gulp_rev/__init__.py#L15-L35 |
olasitarska/django-gulp-rev | gulp_rev/__init__.py | production_url | def production_url(path, original):
"""
For a production environment (DEBUG=False), replaces original path
created by Django's {% static %} template tag with relevant path from
our mapping.
"""
mapping = _get_mapping()
if mapping:
if path in mapping:
return original.repla... | python | def production_url(path, original):
"""
For a production environment (DEBUG=False), replaces original path
created by Django's {% static %} template tag with relevant path from
our mapping.
"""
mapping = _get_mapping()
if mapping:
if path in mapping:
return original.repla... | [
"def",
"production_url",
"(",
"path",
",",
"original",
")",
":",
"mapping",
"=",
"_get_mapping",
"(",
")",
"if",
"mapping",
":",
"if",
"path",
"in",
"mapping",
":",
"return",
"original",
".",
"replace",
"(",
"path",
",",
"mapping",
"[",
"path",
"]",
")... | For a production environment (DEBUG=False), replaces original path
created by Django's {% static %} template tag with relevant path from
our mapping. | [
"For",
"a",
"production",
"environment",
"(",
"DEBUG",
"=",
"False",
")",
"replaces",
"original",
"path",
"created",
"by",
"Django",
"s",
"{",
"%",
"static",
"%",
"}",
"template",
"tag",
"with",
"relevant",
"path",
"from",
"our",
"mapping",
"."
] | train | https://github.com/olasitarska/django-gulp-rev/blob/cb6b725d23906ef4451e9d73b91d8e1888a0b954/gulp_rev/__init__.py#L44-L56 |
olasitarska/django-gulp-rev | gulp_rev/__init__.py | static_rev | def static_rev(path):
"""
Gets a joined path with the STATIC_URL setting, and applies revisioning
depending on DEBUG setting.
Usage::
{% load rev %}
{% static_rev "css/base.css" %}
Example::
{% static_rev "css/base.css" %}
On DEBUG=True will return: /static/css/base... | python | def static_rev(path):
"""
Gets a joined path with the STATIC_URL setting, and applies revisioning
depending on DEBUG setting.
Usage::
{% load rev %}
{% static_rev "css/base.css" %}
Example::
{% static_rev "css/base.css" %}
On DEBUG=True will return: /static/css/base... | [
"def",
"static_rev",
"(",
"path",
")",
":",
"static_path",
"=",
"StaticNode",
".",
"handle_simple",
"(",
"path",
")",
"if",
"is_debug",
"(",
")",
":",
"return",
"dev_url",
"(",
"static_path",
")",
"return",
"production_url",
"(",
"path",
",",
"static_path",
... | Gets a joined path with the STATIC_URL setting, and applies revisioning
depending on DEBUG setting.
Usage::
{% load rev %}
{% static_rev "css/base.css" %}
Example::
{% static_rev "css/base.css" %}
On DEBUG=True will return: /static/css/base.css?d9wdjs
On DEBUG=False... | [
"Gets",
"a",
"joined",
"path",
"with",
"the",
"STATIC_URL",
"setting",
"and",
"applies",
"revisioning",
"depending",
"on",
"DEBUG",
"setting",
"."
] | train | https://github.com/olasitarska/django-gulp-rev/blob/cb6b725d23906ef4451e9d73b91d8e1888a0b954/gulp_rev/__init__.py#L58-L77 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL._build_object_table | def _build_object_table(self):
'''Builds the object table for each RDDL type.'''
types = self.domain.types
objects = dict(self.non_fluents.objects)
self.object_table = dict()
for name, value in self.domain.types:
if value == 'object':
objs = objects[na... | python | def _build_object_table(self):
'''Builds the object table for each RDDL type.'''
types = self.domain.types
objects = dict(self.non_fluents.objects)
self.object_table = dict()
for name, value in self.domain.types:
if value == 'object':
objs = objects[na... | [
"def",
"_build_object_table",
"(",
"self",
")",
":",
"types",
"=",
"self",
".",
"domain",
".",
"types",
"objects",
"=",
"dict",
"(",
"self",
".",
"non_fluents",
".",
"objects",
")",
"self",
".",
"object_table",
"=",
"dict",
"(",
")",
"for",
"name",
","... | Builds the object table for each RDDL type. | [
"Builds",
"the",
"object",
"table",
"for",
"each",
"RDDL",
"type",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L58-L71 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL._build_fluent_table | def _build_fluent_table(self):
'''Builds the fluent table for each RDDL pvariable.'''
self.fluent_table = collections.OrderedDict()
for name, size in zip(self.domain.non_fluent_ordering, self.non_fluent_size):
non_fluent = self.domain.non_fluents[name]
self.fluent_table[... | python | def _build_fluent_table(self):
'''Builds the fluent table for each RDDL pvariable.'''
self.fluent_table = collections.OrderedDict()
for name, size in zip(self.domain.non_fluent_ordering, self.non_fluent_size):
non_fluent = self.domain.non_fluents[name]
self.fluent_table[... | [
"def",
"_build_fluent_table",
"(",
"self",
")",
":",
"self",
".",
"fluent_table",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"for",
"name",
",",
"size",
"in",
"zip",
"(",
"self",
".",
"domain",
".",
"non_fluent_ordering",
",",
"self",
".",
"non_flue... | Builds the fluent table for each RDDL pvariable. | [
"Builds",
"the",
"fluent",
"table",
"for",
"each",
"RDDL",
"pvariable",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L73-L91 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.non_fluent_variables | def non_fluent_variables(self) -> FluentParamsList:
'''Returns the instantiated non-fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings.
'''
fluents = self... | python | def non_fluent_variables(self) -> FluentParamsList:
'''Returns the instantiated non-fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings.
'''
fluents = self... | [
"def",
"non_fluent_variables",
"(",
"self",
")",
"->",
"FluentParamsList",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"non_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"non_fluent_ordering",
"return",
"self",
".",
"_fluent_params",
"(",
"fluents"... | Returns the instantiated non-fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings. | [
"Returns",
"the",
"instantiated",
"non",
"-",
"fluents",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L94-L103 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.state_fluent_variables | def state_fluent_variables(self) -> FluentParamsList:
'''Returns the instantiated state fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings.
'''
fluents = ... | python | def state_fluent_variables(self) -> FluentParamsList:
'''Returns the instantiated state fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings.
'''
fluents = ... | [
"def",
"state_fluent_variables",
"(",
"self",
")",
"->",
"FluentParamsList",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"state_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"state_fluent_ordering",
"return",
"self",
".",
"_fluent_params",
"(",
"fl... | Returns the instantiated state fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings. | [
"Returns",
"the",
"instantiated",
"state",
"fluents",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L106-L115 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.