body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
def inverse_deriv(self, z):
"\n Derivative of the inverse of the Log-Log transform link function\n\n Parameters\n ----------\n z : array_like\n The value of the inverse of the LogLog link function at `p`\n\n Returns\n -------\n g^(-1)'(z) : ndarray\n ... | 1,061,430,631,846,378,800 | Derivative of the inverse of the Log-Log transform link function
Parameters
----------
z : array_like
The value of the inverse of the LogLog link function at `p`
Returns
-------
g^(-1)'(z) : ndarray
The derivative of the inverse of the LogLog link function | statsmodels/genmod/families/links.py | inverse_deriv | BioGeneTools/statsmodels | python | def inverse_deriv(self, z):
"\n Derivative of the inverse of the Log-Log transform link function\n\n Parameters\n ----------\n z : array_like\n The value of the inverse of the LogLog link function at `p`\n\n Returns\n -------\n g^(-1)'(z) : ndarray\n ... |
def inverse_deriv2(self, z):
"\n Second derivative of the inverse of the Log-Log transform link function\n\n Parameters\n ----------\n z : array_like\n The value of the inverse of the LogLog link function at `p`\n\n Returns\n -------\n g^(-1)''(z) : ndarra... | -7,096,429,890,514,333,000 | Second derivative of the inverse of the Log-Log transform link function
Parameters
----------
z : array_like
The value of the inverse of the LogLog link function at `p`
Returns
-------
g^(-1)''(z) : ndarray
The second derivative of the inverse of the LogLog link function | statsmodels/genmod/families/links.py | inverse_deriv2 | BioGeneTools/statsmodels | python | def inverse_deriv2(self, z):
"\n Second derivative of the inverse of the Log-Log transform link function\n\n Parameters\n ----------\n z : array_like\n The value of the inverse of the LogLog link function at `p`\n\n Returns\n -------\n g^(-1)(z) : ndarray\... |
def __call__(self, p):
'\n Negative Binomial transform link function\n\n Parameters\n ----------\n p : array_like\n Mean parameters\n\n Returns\n -------\n z : ndarray\n The negative binomial transform of `p`\n\n Notes\n -----\n ... | 5,409,394,703,314,850,000 | Negative Binomial transform link function
Parameters
----------
p : array_like
Mean parameters
Returns
-------
z : ndarray
The negative binomial transform of `p`
Notes
-----
g(p) = log(p/(p + 1/alpha)) | statsmodels/genmod/families/links.py | __call__ | BioGeneTools/statsmodels | python | def __call__(self, p):
'\n Negative Binomial transform link function\n\n Parameters\n ----------\n p : array_like\n Mean parameters\n\n Returns\n -------\n z : ndarray\n The negative binomial transform of `p`\n\n Notes\n -----\n ... |
def inverse(self, z):
'\n Inverse of the negative binomial transform\n\n Parameters\n ----------\n z : array_like\n The value of the inverse of the negative binomial link at `p`.\n\n Returns\n -------\n p : ndarray\n Mean parameters\n\n N... | -2,830,177,018,432,326,700 | Inverse of the negative binomial transform
Parameters
----------
z : array_like
The value of the inverse of the negative binomial link at `p`.
Returns
-------
p : ndarray
Mean parameters
Notes
-----
g^(-1)(z) = exp(z)/(alpha*(1-exp(z))) | statsmodels/genmod/families/links.py | inverse | BioGeneTools/statsmodels | python | def inverse(self, z):
'\n Inverse of the negative binomial transform\n\n Parameters\n ----------\n z : array_like\n The value of the inverse of the negative binomial link at `p`.\n\n Returns\n -------\n p : ndarray\n Mean parameters\n\n N... |
def deriv(self, p):
"\n Derivative of the negative binomial transform\n\n Parameters\n ----------\n p : array_like\n Mean parameters\n\n Returns\n -------\n g'(p) : ndarray\n The derivative of the negative binomial transform link function\n\n ... | -6,867,509,968,575,642,000 | Derivative of the negative binomial transform
Parameters
----------
p : array_like
Mean parameters
Returns
-------
g'(p) : ndarray
The derivative of the negative binomial transform link function
Notes
-----
g'(x) = 1/(x+alpha*x^2) | statsmodels/genmod/families/links.py | deriv | BioGeneTools/statsmodels | python | def deriv(self, p):
"\n Derivative of the negative binomial transform\n\n Parameters\n ----------\n p : array_like\n Mean parameters\n\n Returns\n -------\n g'(p) : ndarray\n The derivative of the negative binomial transform link function\n\n ... |
def deriv2(self, p):
"\n Second derivative of the negative binomial link function.\n\n Parameters\n ----------\n p : array_like\n Mean parameters\n\n Returns\n -------\n g''(p) : ndarray\n The second derivative of the negative binomial transform... | 521,529,222,361,369,200 | Second derivative of the negative binomial link function.
Parameters
----------
p : array_like
Mean parameters
Returns
-------
g''(p) : ndarray
The second derivative of the negative binomial transform link
function
Notes
-----
g''(x) = -(1+2*alpha*x)/(x+alpha*x^2)^2 | statsmodels/genmod/families/links.py | deriv2 | BioGeneTools/statsmodels | python | def deriv2(self, p):
"\n Second derivative of the negative binomial link function.\n\n Parameters\n ----------\n p : array_like\n Mean parameters\n\n Returns\n -------\n g(p) : ndarray\n The second derivative of the negative binomial transform l... |
def inverse_deriv(self, z):
"\n Derivative of the inverse of the negative binomial transform\n\n Parameters\n ----------\n z : array_like\n Usually the linear predictor for a GLM or GEE model\n\n Returns\n -------\n g^(-1)'(z) : ndarray\n The va... | -1,360,131,057,683,691,300 | Derivative of the inverse of the negative binomial transform
Parameters
----------
z : array_like
Usually the linear predictor for a GLM or GEE model
Returns
-------
g^(-1)'(z) : ndarray
The value of the derivative of the inverse of the negative
binomial link | statsmodels/genmod/families/links.py | inverse_deriv | BioGeneTools/statsmodels | python | def inverse_deriv(self, z):
"\n Derivative of the inverse of the negative binomial transform\n\n Parameters\n ----------\n z : array_like\n Usually the linear predictor for a GLM or GEE model\n\n Returns\n -------\n g^(-1)'(z) : ndarray\n The va... |
def _default_hashfunc(content, hashbits):
"\n Default hash function is variable-length version of Python's builtin hash.\n\n :param content: data that needs to hash.\n :return: return a decimal number.\n "
if (content == ''):
return 0
x = (ord(content[0]) << 7)
m = 1000003
mask =... | 2,345,190,079,828,529,700 | Default hash function is variable-length version of Python's builtin hash.
:param content: data that needs to hash.
:return: return a decimal number. | algorithms/hash/simhash.py | _default_hashfunc | SylvanasSun/code-snippets | python | def _default_hashfunc(content, hashbits):
"\n Default hash function is variable-length version of Python's builtin hash.\n\n :param content: data that needs to hash.\n :return: return a decimal number.\n "
if (content == ):
return 0
x = (ord(content[0]) << 7)
m = 1000003
mask = (... |
def _default_tokenizer_func(content, keyword_weight_pair):
"\n Default tokenizer function that uses jieba tokenizer.\n\n :param keyword_weight_pair: maximum pair number of the keyword-weight list.\n :return: return keyword-weight list. Example: [('Example',0.4511233019962264),('Hello',0.25548051420382073),... | 5,208,231,525,523,260,000 | Default tokenizer function that uses jieba tokenizer.
:param keyword_weight_pair: maximum pair number of the keyword-weight list.
:return: return keyword-weight list. Example: [('Example',0.4511233019962264),('Hello',0.25548051420382073),...]. | algorithms/hash/simhash.py | _default_tokenizer_func | SylvanasSun/code-snippets | python | def _default_tokenizer_func(content, keyword_weight_pair):
"\n Default tokenizer function that uses jieba tokenizer.\n\n :param keyword_weight_pair: maximum pair number of the keyword-weight list.\n :return: return keyword-weight list. Example: [('Example',0.4511233019962264),('Hello',0.25548051420382073),... |
def __init__(self, data, keyword_weight_pair=20, hash_bit_number=64, hashfunc=None, tokenizer_func=None):
'\n :param data: data that needs to be encode.\n :param keyword_weight_pair: maximum pair number of the keyword-weight list.\n :param hash_bit_number: maximum bit number for hashcode.\n ... | 6,896,240,115,283,153,000 | :param data: data that needs to be encode.
:param keyword_weight_pair: maximum pair number of the keyword-weight list.
:param hash_bit_number: maximum bit number for hashcode.
:param hashfunc: hash function,its first parameter must be data that needs to be encode
and the second parameter must be hash b... | algorithms/hash/simhash.py | __init__ | SylvanasSun/code-snippets | python | def __init__(self, data, keyword_weight_pair=20, hash_bit_number=64, hashfunc=None, tokenizer_func=None):
'\n :param data: data that needs to be encode.\n :param keyword_weight_pair: maximum pair number of the keyword-weight list.\n :param hash_bit_number: maximum bit number for hashcode.\n ... |
def simhash(self, content):
'\n Select policies for simhash on the different types of content.\n '
if (content is None):
self.hash = (- 1)
return
if isinstance(content, str):
features = self.tokenizer_func(content, self.keyword_weight_pari)
self.hash = self.buil... | 358,083,546,286,196,860 | Select policies for simhash on the different types of content. | algorithms/hash/simhash.py | simhash | SylvanasSun/code-snippets | python | def simhash(self, content):
'\n \n '
if (content is None):
self.hash = (- 1)
return
if isinstance(content, str):
features = self.tokenizer_func(content, self.keyword_weight_pari)
self.hash = self.build_from_features(features)
elif isinstance(content, collect... |
def build_from_features(self, features):
'\n :param features: a list of (token,weight) tuples or a token -> weight dict,\n if is a string so it need compute weight (a weight of 1 will be assumed).\n\n :return: a decimal digit for the accumulative result of each after handled fea... | 3,623,918,119,554,579,500 | :param features: a list of (token,weight) tuples or a token -> weight dict,
if is a string so it need compute weight (a weight of 1 will be assumed).
:return: a decimal digit for the accumulative result of each after handled features-weight pair. | algorithms/hash/simhash.py | build_from_features | SylvanasSun/code-snippets | python | def build_from_features(self, features):
'\n :param features: a list of (token,weight) tuples or a token -> weight dict,\n if is a string so it need compute weight (a weight of 1 will be assumed).\n\n :return: a decimal digit for the accumulative result of each after handled fea... |
def is_equal(self, another, limit=0.8):
'\n Determine two simhash are similar or not similar.\n\n :param another: another simhash.\n :param limit: a limit of the similarity.\n :return: if similarity greater than limit return true and else return false.\n '
if (another is None)... | -145,368,186,127,737,300 | Determine two simhash are similar or not similar.
:param another: another simhash.
:param limit: a limit of the similarity.
:return: if similarity greater than limit return true and else return false. | algorithms/hash/simhash.py | is_equal | SylvanasSun/code-snippets | python | def is_equal(self, another, limit=0.8):
'\n Determine two simhash are similar or not similar.\n\n :param another: another simhash.\n :param limit: a limit of the similarity.\n :return: if similarity greater than limit return true and else return false.\n '
if (another is None)... |
def hamming_distance(self, another):
'\n Compute hamming distance,hamming distance is a total number of different bits of two binary numbers.\n\n :param another: another simhash value.\n :return: a hamming distance that current simhash and another simhash.\n '
x = ((self.hash ^ anoth... | 4,441,790,304,206,754,300 | Compute hamming distance,hamming distance is a total number of different bits of two binary numbers.
:param another: another simhash value.
:return: a hamming distance that current simhash and another simhash. | algorithms/hash/simhash.py | hamming_distance | SylvanasSun/code-snippets | python | def hamming_distance(self, another):
'\n Compute hamming distance,hamming distance is a total number of different bits of two binary numbers.\n\n :param another: another simhash value.\n :return: a hamming distance that current simhash and another simhash.\n '
x = ((self.hash ^ anoth... |
def relpath(self, current_file, rel_path):
'\n Compute path given current file and relative path.\n '
script_dir = os.path.dirname(os.path.abspath(current_file))
rel_path = os.path.abspath(os.path.join(script_dir, rel_path))
return rel_path | -5,430,039,140,372,359,000 | Compute path given current file and relative path. | luigi/contrib/scalding.py | relpath | Ali-Tahir/luigi | python | def relpath(self, current_file, rel_path):
'\n \n '
script_dir = os.path.dirname(os.path.abspath(current_file))
rel_path = os.path.abspath(os.path.join(script_dir, rel_path))
return rel_path |
def source(self):
'\n Path to the scala source for this Scalding Job\n\n Either one of source() or jar() must be specified.\n '
return None | -3,100,607,564,920,193,500 | Path to the scala source for this Scalding Job
Either one of source() or jar() must be specified. | luigi/contrib/scalding.py | source | Ali-Tahir/luigi | python | def source(self):
'\n Path to the scala source for this Scalding Job\n\n Either one of source() or jar() must be specified.\n '
return None |
def jar(self):
'\n Path to the jar file for this Scalding Job\n\n Either one of source() or jar() must be specified.\n '
return None | -6,554,746,075,960,280,000 | Path to the jar file for this Scalding Job
Either one of source() or jar() must be specified. | luigi/contrib/scalding.py | jar | Ali-Tahir/luigi | python | def jar(self):
'\n Path to the jar file for this Scalding Job\n\n Either one of source() or jar() must be specified.\n '
return None |
def extra_jars(self):
'\n Extra jars for building and running this Scalding Job.\n '
return [] | -6,212,587,920,033,463,000 | Extra jars for building and running this Scalding Job. | luigi/contrib/scalding.py | extra_jars | Ali-Tahir/luigi | python | def extra_jars(self):
'\n \n '
return [] |
def job_class(self):
'\n optional main job class for this Scalding Job.\n '
return None | 4,452,208,310,207,736,300 | optional main job class for this Scalding Job. | luigi/contrib/scalding.py | job_class | Ali-Tahir/luigi | python | def job_class(self):
'\n \n '
return None |
def atomic_output(self):
'\n If True, then rewrite output arguments to be temp locations and\n atomically move them into place after the job finishes.\n '
return True | 5,549,941,568,464,626,000 | If True, then rewrite output arguments to be temp locations and
atomically move them into place after the job finishes. | luigi/contrib/scalding.py | atomic_output | Ali-Tahir/luigi | python | def atomic_output(self):
'\n If True, then rewrite output arguments to be temp locations and\n atomically move them into place after the job finishes.\n '
return True |
def job_args(self):
'\n Extra arguments to pass to the Scalding job.\n '
return [] | 7,189,867,044,952,383,000 | Extra arguments to pass to the Scalding job. | luigi/contrib/scalding.py | job_args | Ali-Tahir/luigi | python | def job_args(self):
'\n \n '
return [] |
def args(self):
'\n Returns an array of args to pass to the job.\n '
arglist = []
for (k, v) in six.iteritems(self.requires_hadoop()):
arglist.append(('--' + k))
arglist.extend([t.output().path for t in flatten(v)])
arglist.extend(['--output', self.output()])
arglist.ex... | -5,758,166,138,721,626,000 | Returns an array of args to pass to the job. | luigi/contrib/scalding.py | args | Ali-Tahir/luigi | python | def args(self):
'\n \n '
arglist = []
for (k, v) in six.iteritems(self.requires_hadoop()):
arglist.append(('--' + k))
arglist.extend([t.output().path for t in flatten(v)])
arglist.extend(['--output', self.output()])
arglist.extend(self.job_args())
return arglist |
def migrate():
' apply yoyo migrations '
logger.info('Migrating to the latest schema')
log.getLogger('yoyo').setLevel(log.DEBUG)
backend = get_backend(('sqlite:///' + DB_PATH))
migrations = read_migrations('./migrations')
with backend.lock():
backend.apply_migrations(backend.to_apply(mig... | 5,327,263,784,229,965,000 | apply yoyo migrations | src/app/fs.py | migrate | ratijas/multi_vote_bot | python | def migrate():
' '
logger.info('Migrating to the latest schema')
log.getLogger('yoyo').setLevel(log.DEBUG)
backend = get_backend(('sqlite:///' + DB_PATH))
migrations = read_migrations('./migrations')
with backend.lock():
backend.apply_migrations(backend.to_apply(migrations)) |
def setName(self, name=None):
' Set an individual name for the (sub) test. '
if (name != None):
self.name = name
else:
self.name = self.testName | 8,183,793,640,460,031,000 | Set an individual name for the (sub) test. | ctsimu/test.py | setName | BAMresearch/ctsimu-toolbox | python | def setName(self, name=None):
' '
if (name != None):
self.name = name
else:
self.name = self.testName |
def setResultFileDirectory(self, resultFileDirectory='.'):
' Set the location where test results should be saved. '
self.resultFileDirectory = resultFileDirectory
touchDirectory(self.resultFileDirectory) | 2,513,719,743,405,659,600 | Set the location where test results should be saved. | ctsimu/test.py | setResultFileDirectory | BAMresearch/ctsimu-toolbox | python | def setResultFileDirectory(self, resultFileDirectory='.'):
' '
self.resultFileDirectory = resultFileDirectory
touchDirectory(self.resultFileDirectory) |
def setRawOutput(self, rawOutput=False):
' Save intermediate projections as RAW instead of TIFF? '
self.rawOutput = rawOutput | 1,851,281,245,773,209,000 | Save intermediate projections as RAW instead of TIFF? | ctsimu/test.py | setRawOutput | BAMresearch/ctsimu-toolbox | python | def setRawOutput(self, rawOutput=False):
' '
self.rawOutput = rawOutput |
def plotResults(self):
' Plot results of evaluation. '
pass | -7,920,522,756,913,202,000 | Plot results of evaluation. | ctsimu/test.py | plotResults | BAMresearch/ctsimu-toolbox | python | def plotResults(self):
' '
pass |
def process_20_newsgroups(*, extract_dir='20_newsgroups', metadata=None, unpack_dir=None, opts={'subset': 'all', 'remove': "('headers', 'footers', 'quotes')"}):
'\n Process 20 newsgroups into (data, target, metadata) format.\n\n\n Parameters\n ----------\n unpack_dir: path\n The interim parent di... | 8,225,099,787,755,758,000 | Process 20 newsgroups into (data, target, metadata) format.
Parameters
----------
unpack_dir: path
The interim parent directory the dataset files have been unpacked into.
extract_dir: str
Name of the directory of the unpacked files relative to the unpack_dir. Note that
opts: dict default {"subset":"all", "rem... | src/data/process_functions.py | process_20_newsgroups | acwooding/docmap_playground | python | def process_20_newsgroups(*, extract_dir='20_newsgroups', metadata=None, unpack_dir=None, opts={'subset': 'all', 'remove': "('headers', 'footers', 'quotes')"}):
'\n Process 20 newsgroups into (data, target, metadata) format.\n\n\n Parameters\n ----------\n unpack_dir: path\n The interim parent di... |
def main(items=None, printmd=None, printcal=False, found=False, save=None, download=None, requestor_pays=False, **kwargs):
' Main function for performing a search '
if (items is None):
search = Search.search(**kwargs)
if found:
num = search.found()
print(('%s items found'... | -3,783,134,709,165,279,000 | Main function for performing a search | satsearch/main.py | main | lishrimp/sat-search | python | def main(items=None, printmd=None, printcal=False, found=False, save=None, download=None, requestor_pays=False, **kwargs):
' '
if (items is None):
search = Search.search(**kwargs)
if found:
num = search.found()
print(('%s items found' % num))
return num
... |
def _nose_tools_functions():
'Get an iterator of names and bound methods.'
module = _BUILDER.string_build(textwrap.dedent('\n import unittest\n\n class Test(unittest.TestCase):\n pass\n a = Test()\n '))
try:
case = next(module['a'].infer())
except astroid.InferenceError:
... | -155,066,971,101,152,830 | Get an iterator of names and bound methods. | venv/Lib/site-packages/astroid/brain/brain_nose.py | _nose_tools_functions | Nucl3arSn3k/randomplushmiku | python | def _nose_tools_functions():
module = _BUILDER.string_build(textwrap.dedent('\n import unittest\n\n class Test(unittest.TestCase):\n pass\n a = Test()\n '))
try:
case = next(module['a'].infer())
except astroid.InferenceError:
return
for method in case.methods():
... |
def _nose_tools_trivial_transform():
'Custom transform for the nose.tools module.'
stub = _BUILDER.string_build('__all__ = []')
all_entries = ['ok_', 'eq_']
for (pep8_name, method) in _nose_tools_functions():
all_entries.append(pep8_name)
stub[pep8_name] = method
all_assign = stub['_... | 4,951,586,181,410,846,000 | Custom transform for the nose.tools module. | venv/Lib/site-packages/astroid/brain/brain_nose.py | _nose_tools_trivial_transform | Nucl3arSn3k/randomplushmiku | python | def _nose_tools_trivial_transform():
stub = _BUILDER.string_build('__all__ = []')
all_entries = ['ok_', 'eq_']
for (pep8_name, method) in _nose_tools_functions():
all_entries.append(pep8_name)
stub[pep8_name] = method
all_assign = stub['__all__'].parent
all_object = astroid.List... |
def _flatten_args(pairs_in, args_out, prefix, visited_stack):
'Helper function for flatten_args. See `flatten_args` below for details.'
for (key, v) in pairs_in:
if (not isinstance(key, str)):
raise ValueError(('Keys must be strings. %r' % key))
flat_key = (((prefix + '.') + key) if ... | -496,815,897,776,520,260 | Helper function for flatten_args. See `flatten_args` below for details. | dmlab2d/settings_helper.py | _flatten_args | LaudateCorpus1/lab2d | python | def _flatten_args(pairs_in, args_out, prefix, visited_stack):
for (key, v) in pairs_in:
if (not isinstance(key, str)):
raise ValueError(('Keys must be strings. %r' % key))
flat_key = (((prefix + '.') + key) if prefix else key)
if (v is None):
args_out[flat_key] =... |
def flatten_args(args_in):
"Converts a dictionary of dictionarys and lists into a flat table.\n\n Args:\n args_in: dictionary containing a hierachy of dictionaries and lists. Leaf\n values can be strings, bools, numbers..\n\n Returns:\n A flat dictionary with keys separated by '.' and string values.\n ... | -401,289,397,659,758,140 | Converts a dictionary of dictionarys and lists into a flat table.
Args:
args_in: dictionary containing a hierachy of dictionaries and lists. Leaf
values can be strings, bools, numbers..
Returns:
A flat dictionary with keys separated by '.' and string values. | dmlab2d/settings_helper.py | flatten_args | LaudateCorpus1/lab2d | python | def flatten_args(args_in):
"Converts a dictionary of dictionarys and lists into a flat table.\n\n Args:\n args_in: dictionary containing a hierachy of dictionaries and lists. Leaf\n values can be strings, bools, numbers..\n\n Returns:\n A flat dictionary with keys separated by '.' and string values.\n ... |
def ReadTxtNet(file_path='', undirected=True):
' Read the txt network file. \n Notations: The network is unweighted.\n\n Parameters\n ----------\n file_path str : path of network file\n undirected bool : whether the edges are undirected\n\n Return\n ------\n net dict : a dict recording the c... | 3,508,495,473,879,411,700 | Read the txt network file.
Notations: The network is unweighted.
Parameters
----------
file_path str : path of network file
undirected bool : whether the edges are undirected
Return
------
net dict : a dict recording the connections in the graph
node2id dict : a dict mapping the nodes to their embedding indices
id2... | examples/pytorch/ogb/line/reading_data.py | ReadTxtNet | IzabelaMazur/dgl | python | def ReadTxtNet(file_path=, undirected=True):
' Read the txt network file. \n Notations: The network is unweighted.\n\n Parameters\n ----------\n file_path str : path of network file\n undirected bool : whether the edges are undirected\n\n Return\n ------\n net dict : a dict recording the con... |
def net2graph(net_sm):
' Transform the network to DGL graph\n\n Return \n ------\n G DGLGraph : graph by DGL\n '
start = time.time()
G = dgl.DGLGraph(net_sm)
end = time.time()
t = (end - start)
print(('Building DGLGraph in %.2fs' % t))
return G | 5,918,307,427,968,118,000 | Transform the network to DGL graph
Return
------
G DGLGraph : graph by DGL | examples/pytorch/ogb/line/reading_data.py | net2graph | IzabelaMazur/dgl | python | def net2graph(net_sm):
' Transform the network to DGL graph\n\n Return \n ------\n G DGLGraph : graph by DGL\n '
start = time.time()
G = dgl.DGLGraph(net_sm)
end = time.time()
t = (end - start)
print(('Building DGLGraph in %.2fs' % t))
return G |
def __init__(self, net_file, batch_size, num_samples, negative=5, gpus=[0], fast_neg=True, ogbl_name='', load_from_ogbl=False, ogbn_name='', load_from_ogbn=False):
" This class has the following functions:\n 1. Transform the txt network file into DGL graph;\n 2. Generate random walk sequences for the ... | 6,236,040,157,673,685,000 | This class has the following functions:
1. Transform the txt network file into DGL graph;
2. Generate random walk sequences for the trainer;
3. Provide the negative table if the user hopes to sample negative
nodes according to nodes' degrees;
Parameter
---------
net_file str : path of the dgl network file
walk_length ... | examples/pytorch/ogb/line/reading_data.py | __init__ | IzabelaMazur/dgl | python | def __init__(self, net_file, batch_size, num_samples, negative=5, gpus=[0], fast_neg=True, ogbl_name=, load_from_ogbl=False, ogbn_name=, load_from_ogbn=False):
" This class has the following functions:\n 1. Transform the txt network file into DGL graph;\n 2. Generate random walk sequences for the trai... |
def create_sampler(self, i):
' create random walk sampler '
return EdgeSampler(self.G, self.seeds[i]) | 9,179,441,167,527,142,000 | create random walk sampler | examples/pytorch/ogb/line/reading_data.py | create_sampler | IzabelaMazur/dgl | python | def create_sampler(self, i):
' '
return EdgeSampler(self.G, self.seeds[i]) |
def sample(self, seeds):
' seeds torch.LongTensor : a batch of indices of edges '
return self.edges[torch.LongTensor(seeds)] | -4,032,532,657,934,077,000 | seeds torch.LongTensor : a batch of indices of edges | examples/pytorch/ogb/line/reading_data.py | sample | IzabelaMazur/dgl | python | def sample(self, seeds):
' '
return self.edges[torch.LongTensor(seeds)] |
def mock_connection(aioclient_mock: AiohttpClientMocker) -> None:
'Mock the DirecTV connection for Home Assistant.'
aioclient_mock.get(f'http://{HOST}:8080/info/getVersion', text=load_fixture('directv/info-get-version.json'), headers={'Content-Type': CONTENT_TYPE_JSON})
aioclient_mock.get(f'http://{HOST}:80... | -5,259,314,499,135,104,000 | Mock the DirecTV connection for Home Assistant. | tests/components/directv/__init__.py | mock_connection | 2Fake/core | python | def mock_connection(aioclient_mock: AiohttpClientMocker) -> None:
aioclient_mock.get(f'http://{HOST}:8080/info/getVersion', text=load_fixture('directv/info-get-version.json'), headers={'Content-Type': CONTENT_TYPE_JSON})
aioclient_mock.get(f'http://{HOST}:8080/info/getLocations', text=load_fixture('directv... |
async def setup_integration(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, skip_entry_setup: bool=False, setup_error: bool=False) -> MockConfigEntry:
'Set up the DirecTV integration in Home Assistant.'
if setup_error:
aioclient_mock.get(f'http://{HOST}:8080/info/getVersion', status=HTTPStatus... | -8,370,659,672,752,647,000 | Set up the DirecTV integration in Home Assistant. | tests/components/directv/__init__.py | setup_integration | 2Fake/core | python | async def setup_integration(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, skip_entry_setup: bool=False, setup_error: bool=False) -> MockConfigEntry:
if setup_error:
aioclient_mock.get(f'http://{HOST}:8080/info/getVersion', status=HTTPStatus.INTERNAL_SERVER_ERROR)
else:
mock_conn... |
def __init__(self, **kwargs):
'\n Convolutional model\n :param kwargs:\n window_size: int\n stride_size: int\n test_percentage: float\n n_features: int\n n_outputs: int\n '
self.window_size = kwargs['window_size']
self.stride_size =... | 434,908,339,896,038,900 | Convolutional model
:param kwargs:
window_size: int
stride_size: int
test_percentage: float
n_features: int
n_outputs: int | archive/model_archive/ConvModel.py | __init__ | Sensors-in-Paradise/OpportunityML | python | def __init__(self, **kwargs):
'\n Convolutional model\n :param kwargs:\n window_size: int\n stride_size: int\n test_percentage: float\n n_features: int\n n_outputs: int\n '
self.window_size = kwargs['window_size']
self.stride_size =... |
def _get(self, *args, **kwargs):
"\n Retrieves a list of messages from the request's session. This storage\n always stores everything it is given, so return True for the\n all_retrieved flag.\n "
return (self.deserialize_messages(self.request.session.get(self.session_key)), True) | 5,995,305,131,204,208,000 | Retrieves a list of messages from the request's session. This storage
always stores everything it is given, so return True for the
all_retrieved flag. | django/contrib/messages/storage/session.py | _get | Acidburn0zzz/django | python | def _get(self, *args, **kwargs):
"\n Retrieves a list of messages from the request's session. This storage\n always stores everything it is given, so return True for the\n all_retrieved flag.\n "
return (self.deserialize_messages(self.request.session.get(self.session_key)), True) |
def _store(self, messages, response, *args, **kwargs):
"\n Stores a list of messages to the request's session.\n "
if messages:
self.request.session[self.session_key] = self.serialize_messages(messages)
else:
self.request.session.pop(self.session_key, None)
return [] | -7,376,848,117,602,780,000 | Stores a list of messages to the request's session. | django/contrib/messages/storage/session.py | _store | Acidburn0zzz/django | python | def _store(self, messages, response, *args, **kwargs):
"\n \n "
if messages:
self.request.session[self.session_key] = self.serialize_messages(messages)
else:
self.request.session.pop(self.session_key, None)
return [] |
def rad2deg(tensor: torch.Tensor) -> torch.Tensor:
'Function that converts angles from radians to degrees.\n\n Args:\n tensor (torch.Tensor): Tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Tensor with same shape as input.\n\n Example:\n >>> input = torch.tensor(3.1415926535) *... | -1,196,111,188,359,121,200 | Function that converts angles from radians to degrees.
Args:
tensor (torch.Tensor): Tensor of arbitrary shape.
Returns:
torch.Tensor: Tensor with same shape as input.
Example:
>>> input = torch.tensor(3.1415926535) * torch.rand(1, 3, 3)
>>> output = rad2deg(input) | kornia/geometry/conversions.py | rad2deg | anthonytec2/kornia | python | def rad2deg(tensor: torch.Tensor) -> torch.Tensor:
'Function that converts angles from radians to degrees.\n\n Args:\n tensor (torch.Tensor): Tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: Tensor with same shape as input.\n\n Example:\n >>> input = torch.tensor(3.1415926535) *... |
def deg2rad(tensor: torch.Tensor) -> torch.Tensor:
'Function that converts angles from degrees to radians.\n\n Args:\n tensor (torch.Tensor): Tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: tensor with same shape as input.\n\n Examples::\n\n >>> input = 360. * torch.rand(1, 3, ... | -2,303,698,553,219,946,800 | Function that converts angles from degrees to radians.
Args:
tensor (torch.Tensor): Tensor of arbitrary shape.
Returns:
torch.Tensor: tensor with same shape as input.
Examples::
>>> input = 360. * torch.rand(1, 3, 3)
>>> output = deg2rad(input) | kornia/geometry/conversions.py | deg2rad | anthonytec2/kornia | python | def deg2rad(tensor: torch.Tensor) -> torch.Tensor:
'Function that converts angles from degrees to radians.\n\n Args:\n tensor (torch.Tensor): Tensor of arbitrary shape.\n\n Returns:\n torch.Tensor: tensor with same shape as input.\n\n Examples::\n\n >>> input = 360. * torch.rand(1, 3, ... |
def pol2cart(rho: torch.Tensor, phi: torch.Tensor) -> Tuple[(torch.Tensor, torch.Tensor)]:
'Function that converts polar coordinates to cartesian coordinates.\n\n Args:\n rho (torch.Tensor): Tensor of arbitrary shape.\n phi (torch.Tensor): Tensor of same arbitrary shape.\n\n Returns:\n to... | -7,582,725,315,099,155,000 | Function that converts polar coordinates to cartesian coordinates.
Args:
rho (torch.Tensor): Tensor of arbitrary shape.
phi (torch.Tensor): Tensor of same arbitrary shape.
Returns:
torch.Tensor, torch.Tensor: Tensor with same shape as input.
Example:
>>> rho = torch.rand(1, 3, 3)
>>> phi = torch.... | kornia/geometry/conversions.py | pol2cart | anthonytec2/kornia | python | def pol2cart(rho: torch.Tensor, phi: torch.Tensor) -> Tuple[(torch.Tensor, torch.Tensor)]:
'Function that converts polar coordinates to cartesian coordinates.\n\n Args:\n rho (torch.Tensor): Tensor of arbitrary shape.\n phi (torch.Tensor): Tensor of same arbitrary shape.\n\n Returns:\n to... |
def cart2pol(x: torch.Tensor, y: torch.Tensor, eps: float=1e-08) -> Tuple[(torch.Tensor, torch.Tensor)]:
'Function that converts cartesian coordinates to polar coordinates.\n\n Args:\n rho (torch.Tensor): Tensor of arbitrary shape.\n phi (torch.Tensor): Tensor of same arbitrary shape.\n eps ... | 6,833,031,384,997,357,000 | Function that converts cartesian coordinates to polar coordinates.
Args:
rho (torch.Tensor): Tensor of arbitrary shape.
phi (torch.Tensor): Tensor of same arbitrary shape.
eps (float): To avoid division by zero. Default is 1e-8
Returns:
torch.Tensor, torch.Tensor: Tensor with same shape as input.
Exa... | kornia/geometry/conversions.py | cart2pol | anthonytec2/kornia | python | def cart2pol(x: torch.Tensor, y: torch.Tensor, eps: float=1e-08) -> Tuple[(torch.Tensor, torch.Tensor)]:
'Function that converts cartesian coordinates to polar coordinates.\n\n Args:\n rho (torch.Tensor): Tensor of arbitrary shape.\n phi (torch.Tensor): Tensor of same arbitrary shape.\n eps ... |
def convert_points_from_homogeneous(points: torch.Tensor, eps: float=1e-08) -> torch.Tensor:
'Function that converts points from homogeneous to Euclidean space.\n\n Examples::\n\n >>> input = torch.rand(2, 4, 3) # BxNx3\n >>> output = convert_points_from_homogeneous(input) # BxNx2\n '
if (... | -4,069,164,611,214,838,300 | Function that converts points from homogeneous to Euclidean space.
Examples::
>>> input = torch.rand(2, 4, 3) # BxNx3
>>> output = convert_points_from_homogeneous(input) # BxNx2 | kornia/geometry/conversions.py | convert_points_from_homogeneous | anthonytec2/kornia | python | def convert_points_from_homogeneous(points: torch.Tensor, eps: float=1e-08) -> torch.Tensor:
'Function that converts points from homogeneous to Euclidean space.\n\n Examples::\n\n >>> input = torch.rand(2, 4, 3) # BxNx3\n >>> output = convert_points_from_homogeneous(input) # BxNx2\n '
if (... |
def convert_points_to_homogeneous(points: torch.Tensor) -> torch.Tensor:
'Function that converts points from Euclidean to homogeneous space.\n\n Examples::\n\n >>> input = torch.rand(2, 4, 3) # BxNx3\n >>> output = convert_points_to_homogeneous(input) # BxNx4\n '
if (not isinstance(points,... | -5,162,432,132,527,074,000 | Function that converts points from Euclidean to homogeneous space.
Examples::
>>> input = torch.rand(2, 4, 3) # BxNx3
>>> output = convert_points_to_homogeneous(input) # BxNx4 | kornia/geometry/conversions.py | convert_points_to_homogeneous | anthonytec2/kornia | python | def convert_points_to_homogeneous(points: torch.Tensor) -> torch.Tensor:
'Function that converts points from Euclidean to homogeneous space.\n\n Examples::\n\n >>> input = torch.rand(2, 4, 3) # BxNx3\n >>> output = convert_points_to_homogeneous(input) # BxNx4\n '
if (not isinstance(points,... |
def convert_affinematrix_to_homography(A: torch.Tensor) -> torch.Tensor:
'Function that converts batch of affine matrices from [Bx2x3] to [Bx3x3].\n\n Examples::\n\n >>> input = torch.rand(2, 2, 3) # Bx2x3\n >>> output = convert_affinematrix_to_homography(input) # Bx3x3\n '
if (not isinsta... | -7,483,404,685,304,305,000 | Function that converts batch of affine matrices from [Bx2x3] to [Bx3x3].
Examples::
>>> input = torch.rand(2, 2, 3) # Bx2x3
>>> output = convert_affinematrix_to_homography(input) # Bx3x3 | kornia/geometry/conversions.py | convert_affinematrix_to_homography | anthonytec2/kornia | python | def convert_affinematrix_to_homography(A: torch.Tensor) -> torch.Tensor:
'Function that converts batch of affine matrices from [Bx2x3] to [Bx3x3].\n\n Examples::\n\n >>> input = torch.rand(2, 2, 3) # Bx2x3\n >>> output = convert_affinematrix_to_homography(input) # Bx3x3\n '
if (not isinsta... |
def convert_affinematrix_to_homography3d(A: torch.Tensor) -> torch.Tensor:
'Function that converts batch of affine matrices from [Bx3x4] to [Bx4x4].\n\n Examples::\n\n >>> input = torch.rand(2, 3, 4) # Bx3x4\n >>> output = convert_affinematrix_to_homography3d(input) # Bx4x4\n '
if (not isi... | 2,660,687,678,206,777,300 | Function that converts batch of affine matrices from [Bx3x4] to [Bx4x4].
Examples::
>>> input = torch.rand(2, 3, 4) # Bx3x4
>>> output = convert_affinematrix_to_homography3d(input) # Bx4x4 | kornia/geometry/conversions.py | convert_affinematrix_to_homography3d | anthonytec2/kornia | python | def convert_affinematrix_to_homography3d(A: torch.Tensor) -> torch.Tensor:
'Function that converts batch of affine matrices from [Bx3x4] to [Bx4x4].\n\n Examples::\n\n >>> input = torch.rand(2, 3, 4) # Bx3x4\n >>> output = convert_affinematrix_to_homography3d(input) # Bx4x4\n '
if (not isi... |
def angle_axis_to_rotation_matrix(angle_axis: torch.Tensor) -> torch.Tensor:
'Convert 3d vector of axis-angle rotation to 3x3 rotation matrix\n\n Args:\n angle_axis (torch.Tensor): tensor of 3d vector of axis-angle rotations.\n\n Returns:\n torch.Tensor: tensor of 3x3 rotation matrices.\n\n S... | -3,174,089,505,320,541,000 | Convert 3d vector of axis-angle rotation to 3x3 rotation matrix
Args:
angle_axis (torch.Tensor): tensor of 3d vector of axis-angle rotations.
Returns:
torch.Tensor: tensor of 3x3 rotation matrices.
Shape:
- Input: :math:`(N, 3)`
- Output: :math:`(N, 3, 3)`
Example:
>>> input = torch.rand(1, 3) ... | kornia/geometry/conversions.py | angle_axis_to_rotation_matrix | anthonytec2/kornia | python | def angle_axis_to_rotation_matrix(angle_axis: torch.Tensor) -> torch.Tensor:
'Convert 3d vector of axis-angle rotation to 3x3 rotation matrix\n\n Args:\n angle_axis (torch.Tensor): tensor of 3d vector of axis-angle rotations.\n\n Returns:\n torch.Tensor: tensor of 3x3 rotation matrices.\n\n S... |
def rotation_matrix_to_angle_axis(rotation_matrix: torch.Tensor) -> torch.Tensor:
'Convert 3x3 rotation matrix to Rodrigues vector.\n\n Args:\n rotation_matrix (torch.Tensor): rotation matrix.\n\n Returns:\n torch.Tensor: Rodrigues vector transformation.\n\n Shape:\n - Input: :math:`(N... | -4,264,213,605,656,858,000 | Convert 3x3 rotation matrix to Rodrigues vector.
Args:
rotation_matrix (torch.Tensor): rotation matrix.
Returns:
torch.Tensor: Rodrigues vector transformation.
Shape:
- Input: :math:`(N, 3, 3)`
- Output: :math:`(N, 3)`
Example:
>>> input = torch.rand(2, 3, 3) # Nx3x3
>>> output = rotation_m... | kornia/geometry/conversions.py | rotation_matrix_to_angle_axis | anthonytec2/kornia | python | def rotation_matrix_to_angle_axis(rotation_matrix: torch.Tensor) -> torch.Tensor:
'Convert 3x3 rotation matrix to Rodrigues vector.\n\n Args:\n rotation_matrix (torch.Tensor): rotation matrix.\n\n Returns:\n torch.Tensor: Rodrigues vector transformation.\n\n Shape:\n - Input: :math:`(N... |
def rotation_matrix_to_quaternion(rotation_matrix: torch.Tensor, eps: float=1e-08) -> torch.Tensor:
'Convert 3x3 rotation matrix to 4d quaternion vector.\n The quaternion vector has components in (x, y, z, w) format.\n\n Args:\n rotation_matrix (torch.Tensor): the rotation matrix to convert.\n e... | -6,200,754,844,404,515,000 | Convert 3x3 rotation matrix to 4d quaternion vector.
The quaternion vector has components in (x, y, z, w) format.
Args:
rotation_matrix (torch.Tensor): the rotation matrix to convert.
eps (float): small value to avoid zero division. Default: 1e-8.
Return:
torch.Tensor: the rotation in quaternion.
Shape:
... | kornia/geometry/conversions.py | rotation_matrix_to_quaternion | anthonytec2/kornia | python | def rotation_matrix_to_quaternion(rotation_matrix: torch.Tensor, eps: float=1e-08) -> torch.Tensor:
'Convert 3x3 rotation matrix to 4d quaternion vector.\n The quaternion vector has components in (x, y, z, w) format.\n\n Args:\n rotation_matrix (torch.Tensor): the rotation matrix to convert.\n e... |
def normalize_quaternion(quaternion: torch.Tensor, eps: float=1e-12) -> torch.Tensor:
'Normalizes a quaternion.\n The quaternion should be in (x, y, z, w) format.\n\n Args:\n quaternion (torch.Tensor): a tensor containing a quaternion to be\n normalized. The tensor can be of shape :math:`(*, 4... | 7,512,849,630,321,726,000 | Normalizes a quaternion.
The quaternion should be in (x, y, z, w) format.
Args:
quaternion (torch.Tensor): a tensor containing a quaternion to be
normalized. The tensor can be of shape :math:`(*, 4)`.
eps (Optional[bool]): small value to avoid division by zero.
Default: 1e-12.
Return:
torch.Te... | kornia/geometry/conversions.py | normalize_quaternion | anthonytec2/kornia | python | def normalize_quaternion(quaternion: torch.Tensor, eps: float=1e-12) -> torch.Tensor:
'Normalizes a quaternion.\n The quaternion should be in (x, y, z, w) format.\n\n Args:\n quaternion (torch.Tensor): a tensor containing a quaternion to be\n normalized. The tensor can be of shape :math:`(*, 4... |
def quaternion_to_rotation_matrix(quaternion: torch.Tensor) -> torch.Tensor:
'Converts a quaternion to a rotation matrix.\n The quaternion should be in (x, y, z, w) format.\n\n Args:\n quaternion (torch.Tensor): a tensor containing a quaternion to be\n converted. The tensor can be of shape :ma... | 3,522,370,856,670,667,300 | Converts a quaternion to a rotation matrix.
The quaternion should be in (x, y, z, w) format.
Args:
quaternion (torch.Tensor): a tensor containing a quaternion to be
converted. The tensor can be of shape :math:`(*, 4)`.
Return:
torch.Tensor: the rotation matrix of shape :math:`(*, 3, 3)`.
Example:
>... | kornia/geometry/conversions.py | quaternion_to_rotation_matrix | anthonytec2/kornia | python | def quaternion_to_rotation_matrix(quaternion: torch.Tensor) -> torch.Tensor:
'Converts a quaternion to a rotation matrix.\n The quaternion should be in (x, y, z, w) format.\n\n Args:\n quaternion (torch.Tensor): a tensor containing a quaternion to be\n converted. The tensor can be of shape :ma... |
def quaternion_to_angle_axis(quaternion: torch.Tensor) -> torch.Tensor:
'Convert quaternion vector to angle axis of rotation.\n The quaternion should be in (x, y, z, w) format.\n\n Adapted from ceres C++ library: ceres-solver/include/ceres/rotation.h\n\n Args:\n quaternion (torch.Tensor): tensor wit... | -3,117,967,537,888,511,000 | Convert quaternion vector to angle axis of rotation.
The quaternion should be in (x, y, z, w) format.
Adapted from ceres C++ library: ceres-solver/include/ceres/rotation.h
Args:
quaternion (torch.Tensor): tensor with quaternions.
Return:
torch.Tensor: tensor with angle axis of rotation.
Shape:
- Input: ... | kornia/geometry/conversions.py | quaternion_to_angle_axis | anthonytec2/kornia | python | def quaternion_to_angle_axis(quaternion: torch.Tensor) -> torch.Tensor:
'Convert quaternion vector to angle axis of rotation.\n The quaternion should be in (x, y, z, w) format.\n\n Adapted from ceres C++ library: ceres-solver/include/ceres/rotation.h\n\n Args:\n quaternion (torch.Tensor): tensor wit... |
def quaternion_log_to_exp(quaternion: torch.Tensor, eps: float=1e-08) -> torch.Tensor:
'Applies exponential map to log quaternion.\n The quaternion should be in (x, y, z, w) format.\n\n Args:\n quaternion (torch.Tensor): a tensor containing a quaternion to be\n converted. The tensor can be of ... | -2,785,614,319,673,772,500 | Applies exponential map to log quaternion.
The quaternion should be in (x, y, z, w) format.
Args:
quaternion (torch.Tensor): a tensor containing a quaternion to be
converted. The tensor can be of shape :math:`(*, 3)`.
Return:
torch.Tensor: the quaternion exponential map of shape :math:`(*, 4)`.
Example... | kornia/geometry/conversions.py | quaternion_log_to_exp | anthonytec2/kornia | python | def quaternion_log_to_exp(quaternion: torch.Tensor, eps: float=1e-08) -> torch.Tensor:
'Applies exponential map to log quaternion.\n The quaternion should be in (x, y, z, w) format.\n\n Args:\n quaternion (torch.Tensor): a tensor containing a quaternion to be\n converted. The tensor can be of ... |
def quaternion_exp_to_log(quaternion: torch.Tensor, eps: float=1e-08) -> torch.Tensor:
'Applies the log map to a quaternion.\n The quaternion should be in (x, y, z, w) format.\n\n Args:\n quaternion (torch.Tensor): a tensor containing a quaternion to be\n converted. The tensor can be of shape ... | 769,276,519,921,463,600 | Applies the log map to a quaternion.
The quaternion should be in (x, y, z, w) format.
Args:
quaternion (torch.Tensor): a tensor containing a quaternion to be
converted. The tensor can be of shape :math:`(*, 4)`.
Return:
torch.Tensor: the quaternion log map of shape :math:`(*, 3)`.
Example:
>>> quat... | kornia/geometry/conversions.py | quaternion_exp_to_log | anthonytec2/kornia | python | def quaternion_exp_to_log(quaternion: torch.Tensor, eps: float=1e-08) -> torch.Tensor:
'Applies the log map to a quaternion.\n The quaternion should be in (x, y, z, w) format.\n\n Args:\n quaternion (torch.Tensor): a tensor containing a quaternion to be\n converted. The tensor can be of shape ... |
def angle_axis_to_quaternion(angle_axis: torch.Tensor) -> torch.Tensor:
'Convert an angle axis to a quaternion.\n The quaternion vector has components in (x, y, z, w) format.\n\n Adapted from ceres C++ library: ceres-solver/include/ceres/rotation.h\n\n Args:\n angle_axis (torch.Tensor): tensor with ... | -4,953,389,899,023,492,000 | Convert an angle axis to a quaternion.
The quaternion vector has components in (x, y, z, w) format.
Adapted from ceres C++ library: ceres-solver/include/ceres/rotation.h
Args:
angle_axis (torch.Tensor): tensor with angle axis.
Return:
torch.Tensor: tensor with quaternion.
Shape:
- Input: :math:`(*, 3)` ... | kornia/geometry/conversions.py | angle_axis_to_quaternion | anthonytec2/kornia | python | def angle_axis_to_quaternion(angle_axis: torch.Tensor) -> torch.Tensor:
'Convert an angle axis to a quaternion.\n The quaternion vector has components in (x, y, z, w) format.\n\n Adapted from ceres C++ library: ceres-solver/include/ceres/rotation.h\n\n Args:\n angle_axis (torch.Tensor): tensor with ... |
def normalize_pixel_coordinates(pixel_coordinates: torch.Tensor, height: int, width: int, eps: float=1e-08) -> torch.Tensor:
'Normalize pixel coordinates between -1 and 1.\n\n Normalized, -1 if on extreme left, 1 if on extreme right (x = w-1).\n\n Args:\n pixel_coordinates (torch.Tensor): the grid with... | 5,259,801,237,466,521,000 | Normalize pixel coordinates between -1 and 1.
Normalized, -1 if on extreme left, 1 if on extreme right (x = w-1).
Args:
pixel_coordinates (torch.Tensor): the grid with pixel coordinates.
Shape can be :math:`(*, 2)`.
width (int): the maximum width in the x-axis.
height (int): the maximum height in th... | kornia/geometry/conversions.py | normalize_pixel_coordinates | anthonytec2/kornia | python | def normalize_pixel_coordinates(pixel_coordinates: torch.Tensor, height: int, width: int, eps: float=1e-08) -> torch.Tensor:
'Normalize pixel coordinates between -1 and 1.\n\n Normalized, -1 if on extreme left, 1 if on extreme right (x = w-1).\n\n Args:\n pixel_coordinates (torch.Tensor): the grid with... |
def denormalize_pixel_coordinates(pixel_coordinates: torch.Tensor, height: int, width: int, eps: float=1e-08) -> torch.Tensor:
'Denormalize pixel coordinates.\n\n The input is assumed to be -1 if on extreme left, 1 if on\n extreme right (x = w-1).\n\n Args:\n pixel_coordinates (torch.Tensor): the no... | 4,021,415,155,370,516,000 | Denormalize pixel coordinates.
The input is assumed to be -1 if on extreme left, 1 if on
extreme right (x = w-1).
Args:
pixel_coordinates (torch.Tensor): the normalized grid coordinates.
Shape can be :math:`(*, 2)`.
width (int): the maximum width in the x-axis.
height (int): the maximum height in th... | kornia/geometry/conversions.py | denormalize_pixel_coordinates | anthonytec2/kornia | python | def denormalize_pixel_coordinates(pixel_coordinates: torch.Tensor, height: int, width: int, eps: float=1e-08) -> torch.Tensor:
'Denormalize pixel coordinates.\n\n The input is assumed to be -1 if on extreme left, 1 if on\n extreme right (x = w-1).\n\n Args:\n pixel_coordinates (torch.Tensor): the no... |
def normalize_pixel_coordinates3d(pixel_coordinates: torch.Tensor, depth: int, height: int, width: int, eps: float=1e-08) -> torch.Tensor:
'Normalize pixel coordinates between -1 and 1.\n\n Normalized, -1 if on extreme left, 1 if on extreme right (x = w-1).\n\n Args:\n pixel_coordinates (torch.Tensor):... | -7,054,624,372,842,433,000 | Normalize pixel coordinates between -1 and 1.
Normalized, -1 if on extreme left, 1 if on extreme right (x = w-1).
Args:
pixel_coordinates (torch.Tensor): the grid with pixel coordinates.
Shape can be :math:`(*, 3)`.
depth (int): the maximum depth in the z-axis.
height (int): the maximum height in th... | kornia/geometry/conversions.py | normalize_pixel_coordinates3d | anthonytec2/kornia | python | def normalize_pixel_coordinates3d(pixel_coordinates: torch.Tensor, depth: int, height: int, width: int, eps: float=1e-08) -> torch.Tensor:
'Normalize pixel coordinates between -1 and 1.\n\n Normalized, -1 if on extreme left, 1 if on extreme right (x = w-1).\n\n Args:\n pixel_coordinates (torch.Tensor):... |
def denormalize_pixel_coordinates3d(pixel_coordinates: torch.Tensor, depth: int, height: int, width: int, eps: float=1e-08) -> torch.Tensor:
'Denormalize pixel coordinates.\n\n The input is assumed to be -1 if on extreme left, 1 if on\n extreme right (x = w-1).\n\n Args:\n pixel_coordinates (torch.T... | 9,005,497,196,688,565,000 | Denormalize pixel coordinates.
The input is assumed to be -1 if on extreme left, 1 if on
extreme right (x = w-1).
Args:
pixel_coordinates (torch.Tensor): the normalized grid coordinates.
Shape can be :math:`(*, 3)`.
depth (int): the maximum depth in the x-axis.
height (int): the maximum height in th... | kornia/geometry/conversions.py | denormalize_pixel_coordinates3d | anthonytec2/kornia | python | def denormalize_pixel_coordinates3d(pixel_coordinates: torch.Tensor, depth: int, height: int, width: int, eps: float=1e-08) -> torch.Tensor:
'Denormalize pixel coordinates.\n\n The input is assumed to be -1 if on extreme left, 1 if on\n extreme right (x = w-1).\n\n Args:\n pixel_coordinates (torch.T... |
def _set_group_flag(self):
'Set flag according to image aspect ratio.\n\n Images with aspect ratio greater than 1 will be set as group 1,\n otherwise group 0.\n '
self.flag = np.zeros(len(self), dtype=np.uint8) | 1,523,723,425,331,464,400 | Set flag according to image aspect ratio.
Images with aspect ratio greater than 1 will be set as group 1,
otherwise group 0. | mmdet/datasets/classify/imagenet.py | _set_group_flag | anorthman/mmdetection | python | def _set_group_flag(self):
'Set flag according to image aspect ratio.\n\n Images with aspect ratio greater than 1 will be set as group 1,\n otherwise group 0.\n '
self.flag = np.zeros(len(self), dtype=np.uint8) |
def _compute_total_loss(self, labels, logits):
'Summation of the categorical hinge loss for labels and logits.'
error = 0.0
for (label, logit) in zip(labels, logits):
positive = (label * logit)
negative = ((1 - label) * logit)
error += np.maximum(0.0, ((negative - positive) + 1.0))
... | -3,066,329,895,701,368,300 | Summation of the categorical hinge loss for labels and logits. | utils/train_eval_test.py | _compute_total_loss | AakashOfficial/tensor2robot | python | def _compute_total_loss(self, labels, logits):
error = 0.0
for (label, logit) in zip(labels, logits):
positive = (label * logit)
negative = ((1 - label) * logit)
error += np.maximum(0.0, ((negative - positive) + 1.0))
return error |
def test_train_eval_model(self):
'Tests that a simple model trains and exported models are valid.'
gin.bind_parameter('tf.estimator.RunConfig.save_checkpoints_steps', 100)
model_dir = self.create_tempdir().full_path
mock_t2r_model = mocks.MockT2RModel(preprocessor_cls=noop_preprocessor.NoOpPreprocessor)... | -5,027,032,026,927,736,000 | Tests that a simple model trains and exported models are valid. | utils/train_eval_test.py | test_train_eval_model | AakashOfficial/tensor2robot | python | def test_train_eval_model(self):
gin.bind_parameter('tf.estimator.RunConfig.save_checkpoints_steps', 100)
model_dir = self.create_tempdir().full_path
mock_t2r_model = mocks.MockT2RModel(preprocessor_cls=noop_preprocessor.NoOpPreprocessor)
mock_input_generator_train = mocks.MockInputGenerator(batch_... |
def test_init_from_checkpoint_global_step(self):
'Tests that a simple model trains and exported models are valid.'
gin.bind_parameter('tf.estimator.RunConfig.save_checkpoints_steps', 100)
gin.bind_parameter('tf.estimator.RunConfig.keep_checkpoint_max', 3)
model_dir = self.create_tempdir().full_path
... | -3,967,083,315,317,678,000 | Tests that a simple model trains and exported models are valid. | utils/train_eval_test.py | test_init_from_checkpoint_global_step | AakashOfficial/tensor2robot | python | def test_init_from_checkpoint_global_step(self):
gin.bind_parameter('tf.estimator.RunConfig.save_checkpoints_steps', 100)
gin.bind_parameter('tf.estimator.RunConfig.keep_checkpoint_max', 3)
model_dir = self.create_tempdir().full_path
mock_t2r_model = mocks.MockT2RModel(preprocessor_cls=noop_preproc... |
def test_init_from_checkpoint_use_avg_model_params_and_weights(self):
'Tests that a simple model trains and exported models are valid.'
gin.bind_parameter('tf.estimator.RunConfig.save_checkpoints_steps', 100)
gin.bind_parameter('tf.estimator.RunConfig.keep_checkpoint_max', 3)
model_dir = self.create_tem... | 4,479,116,241,257,387,500 | Tests that a simple model trains and exported models are valid. | utils/train_eval_test.py | test_init_from_checkpoint_use_avg_model_params_and_weights | AakashOfficial/tensor2robot | python | def test_init_from_checkpoint_use_avg_model_params_and_weights(self):
gin.bind_parameter('tf.estimator.RunConfig.save_checkpoints_steps', 100)
gin.bind_parameter('tf.estimator.RunConfig.keep_checkpoint_max', 3)
model_dir = self.create_tempdir().full_path
mock_t2r_model = mocks.MockT2RModel(preproce... |
async def async_setup_entry(hass, config_entry, async_add_entities, discovery_info=None):
'Set up the Agent cameras.'
filter_urllib3_logging()
cameras = []
server = hass.data[AGENT_DOMAIN][config_entry.entry_id][CONNECTION]
if (not server.devices):
_LOGGER.warning('Could not fetch cameras fr... | -561,701,980,941,086,000 | Set up the Agent cameras. | homeassistant/components/agent_dvr/camera.py | async_setup_entry | CantankerousBullMoose/core | python | async def async_setup_entry(hass, config_entry, async_add_entities, discovery_info=None):
filter_urllib3_logging()
cameras = []
server = hass.data[AGENT_DOMAIN][config_entry.entry_id][CONNECTION]
if (not server.devices):
_LOGGER.warning('Could not fetch cameras from Agent server')
r... |
def __init__(self, device):
'Initialize as a subclass of MjpegCamera.'
self._servername = device.client.name
self.server_url = device.client._server_url
device_info = {CONF_NAME: device.name, CONF_MJPEG_URL: f'{self.server_url}{device.mjpeg_image_url}&size={device.mjpegStreamWidth}x{device.mjpegStreamHe... | 4,172,856,412,794,285,000 | Initialize as a subclass of MjpegCamera. | homeassistant/components/agent_dvr/camera.py | __init__ | CantankerousBullMoose/core | python | def __init__(self, device):
self._servername = device.client.name
self.server_url = device.client._server_url
device_info = {CONF_NAME: device.name, CONF_MJPEG_URL: f'{self.server_url}{device.mjpeg_image_url}&size={device.mjpegStreamWidth}x{device.mjpegStreamHeight}', CONF_STILL_IMAGE_URL: f'{self.serv... |
@property
def device_info(self):
'Return the device info for adding the entity to the agent object.'
return {'identifiers': {(AGENT_DOMAIN, self._unique_id)}, 'name': self._name, 'manufacturer': 'Agent', 'model': 'Camera', 'sw_version': self.device.client.version} | 7,824,553,129,315,086,000 | Return the device info for adding the entity to the agent object. | homeassistant/components/agent_dvr/camera.py | device_info | CantankerousBullMoose/core | python | @property
def device_info(self):
return {'identifiers': {(AGENT_DOMAIN, self._unique_id)}, 'name': self._name, 'manufacturer': 'Agent', 'model': 'Camera', 'sw_version': self.device.client.version} |
async def async_update(self):
'Update our state from the Agent API.'
try:
(await self.device.update())
if self._removed:
_LOGGER.debug('%s reacquired', self._name)
self._removed = False
except AgentError:
if self.device.client.is_available:
if (not sel... | 1,274,266,635,563,659,800 | Update our state from the Agent API. | homeassistant/components/agent_dvr/camera.py | async_update | CantankerousBullMoose/core | python | async def async_update(self):
try:
(await self.device.update())
if self._removed:
_LOGGER.debug('%s reacquired', self._name)
self._removed = False
except AgentError:
if self.device.client.is_available:
if (not self._removed):
_LOGGER.e... |
@property
def extra_state_attributes(self):
'Return the Agent DVR camera state attributes.'
return {ATTR_ATTRIBUTION: ATTRIBUTION, 'editable': False, 'enabled': self.is_on, 'connected': self.connected, 'detected': self.is_detected, 'alerted': self.is_alerted, 'has_ptz': self.device.has_ptz, 'alerts_enabled': se... | -736,943,086,208,970,400 | Return the Agent DVR camera state attributes. | homeassistant/components/agent_dvr/camera.py | extra_state_attributes | CantankerousBullMoose/core | python | @property
def extra_state_attributes(self):
return {ATTR_ATTRIBUTION: ATTRIBUTION, 'editable': False, 'enabled': self.is_on, 'connected': self.connected, 'detected': self.is_detected, 'alerted': self.is_alerted, 'has_ptz': self.device.has_ptz, 'alerts_enabled': self.device.alerts_active} |
@property
def should_poll(self) -> bool:
'Update the state periodically.'
return True | -1,688,106,608,858,049,800 | Update the state periodically. | homeassistant/components/agent_dvr/camera.py | should_poll | CantankerousBullMoose/core | python | @property
def should_poll(self) -> bool:
return True |
@property
def is_recording(self) -> bool:
'Return whether the monitor is recording.'
return self.device.recording | -9,086,336,331,135,627,000 | Return whether the monitor is recording. | homeassistant/components/agent_dvr/camera.py | is_recording | CantankerousBullMoose/core | python | @property
def is_recording(self) -> bool:
return self.device.recording |
@property
def is_alerted(self) -> bool:
'Return whether the monitor has alerted.'
return self.device.alerted | 2,899,730,911,809,477,600 | Return whether the monitor has alerted. | homeassistant/components/agent_dvr/camera.py | is_alerted | CantankerousBullMoose/core | python | @property
def is_alerted(self) -> bool:
return self.device.alerted |
@property
def is_detected(self) -> bool:
'Return whether the monitor has alerted.'
return self.device.detected | -3,371,326,521,136,155,600 | Return whether the monitor has alerted. | homeassistant/components/agent_dvr/camera.py | is_detected | CantankerousBullMoose/core | python | @property
def is_detected(self) -> bool:
return self.device.detected |
@property
def available(self) -> bool:
'Return True if entity is available.'
return self.device.client.is_available | -6,033,986,792,712,892,000 | Return True if entity is available. | homeassistant/components/agent_dvr/camera.py | available | CantankerousBullMoose/core | python | @property
def available(self) -> bool:
return self.device.client.is_available |
@property
def connected(self) -> bool:
'Return True if entity is connected.'
return self.device.connected | -5,834,607,589,438,554,000 | Return True if entity is connected. | homeassistant/components/agent_dvr/camera.py | connected | CantankerousBullMoose/core | python | @property
def connected(self) -> bool:
return self.device.connected |
@property
def supported_features(self) -> int:
'Return supported features.'
return SUPPORT_ON_OFF | -1,076,124,439,051,380,700 | Return supported features. | homeassistant/components/agent_dvr/camera.py | supported_features | CantankerousBullMoose/core | python | @property
def supported_features(self) -> int:
return SUPPORT_ON_OFF |
@property
def is_on(self) -> bool:
'Return true if on.'
return self.device.online | -5,295,751,153,541,704,000 | Return true if on. | homeassistant/components/agent_dvr/camera.py | is_on | CantankerousBullMoose/core | python | @property
def is_on(self) -> bool:
return self.device.online |
@property
def icon(self):
'Return the icon to use in the frontend, if any.'
if self.is_on:
return 'mdi:camcorder'
return 'mdi:camcorder-off' | 6,399,328,152,966,332,000 | Return the icon to use in the frontend, if any. | homeassistant/components/agent_dvr/camera.py | icon | CantankerousBullMoose/core | python | @property
def icon(self):
if self.is_on:
return 'mdi:camcorder'
return 'mdi:camcorder-off' |
@property
def motion_detection_enabled(self):
'Return the camera motion detection status.'
return self.device.detector_active | 6,028,155,109,194,979,000 | Return the camera motion detection status. | homeassistant/components/agent_dvr/camera.py | motion_detection_enabled | CantankerousBullMoose/core | python | @property
def motion_detection_enabled(self):
return self.device.detector_active |
@property
def unique_id(self) -> str:
'Return a unique identifier for this agent object.'
return self._unique_id | 1,440,107,947,840,357,000 | Return a unique identifier for this agent object. | homeassistant/components/agent_dvr/camera.py | unique_id | CantankerousBullMoose/core | python | @property
def unique_id(self) -> str:
return self._unique_id |
async def async_enable_alerts(self):
'Enable alerts.'
(await self.device.alerts_on()) | 2,796,611,269,641,991,000 | Enable alerts. | homeassistant/components/agent_dvr/camera.py | async_enable_alerts | CantankerousBullMoose/core | python | async def async_enable_alerts(self):
(await self.device.alerts_on()) |
async def async_disable_alerts(self):
'Disable alerts.'
(await self.device.alerts_off()) | -6,570,747,929,846,081,000 | Disable alerts. | homeassistant/components/agent_dvr/camera.py | async_disable_alerts | CantankerousBullMoose/core | python | async def async_disable_alerts(self):
(await self.device.alerts_off()) |
async def async_enable_motion_detection(self):
'Enable motion detection.'
(await self.device.detector_on()) | -8,601,139,264,879,610,000 | Enable motion detection. | homeassistant/components/agent_dvr/camera.py | async_enable_motion_detection | CantankerousBullMoose/core | python | async def async_enable_motion_detection(self):
(await self.device.detector_on()) |
async def async_disable_motion_detection(self):
'Disable motion detection.'
(await self.device.detector_off()) | -7,355,442,744,444,951,000 | Disable motion detection. | homeassistant/components/agent_dvr/camera.py | async_disable_motion_detection | CantankerousBullMoose/core | python | async def async_disable_motion_detection(self):
(await self.device.detector_off()) |
async def async_start_recording(self):
'Start recording.'
(await self.device.record()) | -1,824,808,121,995,718,100 | Start recording. | homeassistant/components/agent_dvr/camera.py | async_start_recording | CantankerousBullMoose/core | python | async def async_start_recording(self):
(await self.device.record()) |
async def async_stop_recording(self):
'Stop recording.'
(await self.device.record_stop()) | 5,086,747,341,827,256,000 | Stop recording. | homeassistant/components/agent_dvr/camera.py | async_stop_recording | CantankerousBullMoose/core | python | async def async_stop_recording(self):
(await self.device.record_stop()) |
async def async_turn_on(self):
'Enable the camera.'
(await self.device.enable()) | -2,295,833,452,988,536,300 | Enable the camera. | homeassistant/components/agent_dvr/camera.py | async_turn_on | CantankerousBullMoose/core | python | async def async_turn_on(self):
(await self.device.enable()) |
async def async_snapshot(self):
'Take a snapshot.'
(await self.device.snapshot()) | 857,259,597,287,051,100 | Take a snapshot. | homeassistant/components/agent_dvr/camera.py | async_snapshot | CantankerousBullMoose/core | python | async def async_snapshot(self):
(await self.device.snapshot()) |
async def async_turn_off(self):
'Disable the camera.'
(await self.device.disable()) | 7,337,812,568,937,745,000 | Disable the camera. | homeassistant/components/agent_dvr/camera.py | async_turn_off | CantankerousBullMoose/core | python | async def async_turn_off(self):
(await self.device.disable()) |
def __init__(__self__, *, resource_group_name: pulumi.Input[str], workspace_name: pulumi.Input[str], location: Optional[pulumi.Input[str]]=None, sku: Optional[pulumi.Input['SkuArgs']]=None, sql_pool_name: Optional[pulumi.Input[str]]=None, tags: Optional[pulumi.Input[Mapping[(str, pulumi.Input[str])]]]=None):
"\n ... | -5,499,257,893,488,918,000 | The set of arguments for constructing a SqlPoolsV3 resource.
:param pulumi.Input[str] resource_group_name: The name of the resource group. The name is case insensitive.
:param pulumi.Input[str] workspace_name: The name of the workspace.
:param pulumi.Input[str] location: The geo-location where the resource lives
:param... | sdk/python/pulumi_azure_native/synapse/v20200401preview/sql_pools_v3.py | __init__ | sebtelko/pulumi-azure-native | python | def __init__(__self__, *, resource_group_name: pulumi.Input[str], workspace_name: pulumi.Input[str], location: Optional[pulumi.Input[str]]=None, sku: Optional[pulumi.Input['SkuArgs']]=None, sql_pool_name: Optional[pulumi.Input[str]]=None, tags: Optional[pulumi.Input[Mapping[(str, pulumi.Input[str])]]]=None):
"\n ... |
@property
@pulumi.getter(name='resourceGroupName')
def resource_group_name(self) -> pulumi.Input[str]:
'\n The name of the resource group. The name is case insensitive.\n '
return pulumi.get(self, 'resource_group_name') | 9,099,428,823,929,783,000 | The name of the resource group. The name is case insensitive. | sdk/python/pulumi_azure_native/synapse/v20200401preview/sql_pools_v3.py | resource_group_name | sebtelko/pulumi-azure-native | python | @property
@pulumi.getter(name='resourceGroupName')
def resource_group_name(self) -> pulumi.Input[str]:
'\n \n '
return pulumi.get(self, 'resource_group_name') |
@property
@pulumi.getter(name='workspaceName')
def workspace_name(self) -> pulumi.Input[str]:
'\n The name of the workspace.\n '
return pulumi.get(self, 'workspace_name') | -6,043,356,629,165,876,000 | The name of the workspace. | sdk/python/pulumi_azure_native/synapse/v20200401preview/sql_pools_v3.py | workspace_name | sebtelko/pulumi-azure-native | python | @property
@pulumi.getter(name='workspaceName')
def workspace_name(self) -> pulumi.Input[str]:
'\n \n '
return pulumi.get(self, 'workspace_name') |
@property
@pulumi.getter
def location(self) -> Optional[pulumi.Input[str]]:
'\n The geo-location where the resource lives\n '
return pulumi.get(self, 'location') | -3,407,978,898,650,888,000 | The geo-location where the resource lives | sdk/python/pulumi_azure_native/synapse/v20200401preview/sql_pools_v3.py | location | sebtelko/pulumi-azure-native | python | @property
@pulumi.getter
def location(self) -> Optional[pulumi.Input[str]]:
'\n \n '
return pulumi.get(self, 'location') |
@property
@pulumi.getter
def sku(self) -> Optional[pulumi.Input['SkuArgs']]:
'\n The sql pool SKU. The list of SKUs may vary by region and support offer.\n '
return pulumi.get(self, 'sku') | -9,123,214,329,469,217,000 | The sql pool SKU. The list of SKUs may vary by region and support offer. | sdk/python/pulumi_azure_native/synapse/v20200401preview/sql_pools_v3.py | sku | sebtelko/pulumi-azure-native | python | @property
@pulumi.getter
def sku(self) -> Optional[pulumi.Input['SkuArgs']]:
'\n \n '
return pulumi.get(self, 'sku') |
@property
@pulumi.getter(name='sqlPoolName')
def sql_pool_name(self) -> Optional[pulumi.Input[str]]:
'\n The name of the sql pool.\n '
return pulumi.get(self, 'sql_pool_name') | 2,546,227,187,852,153,000 | The name of the sql pool. | sdk/python/pulumi_azure_native/synapse/v20200401preview/sql_pools_v3.py | sql_pool_name | sebtelko/pulumi-azure-native | python | @property
@pulumi.getter(name='sqlPoolName')
def sql_pool_name(self) -> Optional[pulumi.Input[str]]:
'\n \n '
return pulumi.get(self, 'sql_pool_name') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.