Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
FlatTestCase.testProcess3DTranspose
(self)
Test Process function 3D array, FORTRAN order
Test Process function 3D array, FORTRAN order
def testProcess3DTranspose(self): "Test Process function 3D array, FORTRAN order" print(self.typeStr, "... ", end=' ', file=sys.stderr) process = Flat.__dict__[self.typeStr + "Process"] pack_output = '' for i in range(24): pack_output += struct.pack(self.typeCode,i) ...
[ "def", "testProcess3DTranspose", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "process", "=", "Flat", ".", "__dict__", "[", "self", ".", "typeStr", ...
[ 54, 4 ]
[ 65, 51 ]
python
en
['en', 'en', 'en']
True
FlatTestCase.testProcessNoncontiguous
(self)
Test Process function with non-contiguous array, which should raise an error
Test Process function with non-contiguous array, which should raise an error
def testProcessNoncontiguous(self): "Test Process function with non-contiguous array, which should raise an error" print(self.typeStr, "... ", end=' ', file=sys.stderr) process = Flat.__dict__[self.typeStr + "Process"] pack_output = '' for i in range(24): pack_output ...
[ "def", "testProcessNoncontiguous", "(", "self", ")", ":", "print", "(", "self", ".", "typeStr", ",", "\"... \"", ",", "end", "=", "' '", ",", "file", "=", "sys", ".", "stderr", ")", "process", "=", "Flat", ".", "__dict__", "[", "self", ".", "typeStr", ...
[ 67, 4 ]
[ 76, 55 ]
python
en
['en', 'en', 'en']
True
test_logdir
(tmpdir)
Tests that the path is correct when checkpoint and loggers are used
Tests that the path is correct when checkpoint and loggers are used
def test_logdir(tmpdir): """ Tests that the path is correct when checkpoint and loggers are used """ expected = os.path.join(tmpdir, 'lightning_logs', 'version_0') model = TestModel(expected) trainer = Trainer( default_root_dir=tmpdir, max_steps=2, callbacks=[ModelCheck...
[ "def", "test_logdir", "(", "tmpdir", ")", ":", "expected", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "'lightning_logs'", ",", "'version_0'", ")", "model", "=", "TestModel", "(", "expected", ")", "trainer", "=", "Trainer", "(", "default_root_...
[ 32, 0 ]
[ 48, 38 ]
python
en
['en', 'error', 'th']
False
test_logdir_no_checkpoint_cb
(tmpdir)
Tests that the path is correct with no checkpoint
Tests that the path is correct with no checkpoint
def test_logdir_no_checkpoint_cb(tmpdir): """ Tests that the path is correct with no checkpoint """ expected = os.path.join(tmpdir, 'lightning_logs', 'version_0') model = TestModel(expected) trainer = Trainer( default_root_dir=tmpdir, max_steps=2, checkpoint_callback=Fal...
[ "def", "test_logdir_no_checkpoint_cb", "(", "tmpdir", ")", ":", "expected", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "'lightning_logs'", ",", "'version_0'", ")", "model", "=", "TestModel", "(", "expected", ")", "trainer", "=", "Trainer", "(",...
[ 51, 0 ]
[ 66, 38 ]
python
en
['en', 'error', 'th']
False
test_logdir_no_logger
(tmpdir)
Tests that the path is correct even when there is no logger
Tests that the path is correct even when there is no logger
def test_logdir_no_logger(tmpdir): """ Tests that the path is correct even when there is no logger """ expected = os.path.join(tmpdir) model = TestModel(expected) trainer = Trainer( default_root_dir=tmpdir, max_steps=2, logger=False, callbacks=[ModelCheckpoint(di...
[ "def", "test_logdir_no_logger", "(", "tmpdir", ")", ":", "expected", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ")", "model", "=", "TestModel", "(", "expected", ")", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "max_step...
[ 69, 0 ]
[ 85, 38 ]
python
en
['en', 'error', 'th']
False
test_logdir_no_logger_no_checkpoint
(tmpdir)
Tests that the path is correct even when there is no logger
Tests that the path is correct even when there is no logger
def test_logdir_no_logger_no_checkpoint(tmpdir): """ Tests that the path is correct even when there is no logger """ expected = os.path.join(tmpdir) model = TestModel(expected) trainer = Trainer( default_root_dir=tmpdir, max_steps=2, logger=False, checkpoint_call...
[ "def", "test_logdir_no_logger_no_checkpoint", "(", "tmpdir", ")", ":", "expected", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ")", "model", "=", "TestModel", "(", "expected", ")", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",...
[ 88, 0 ]
[ 104, 38 ]
python
en
['en', 'error', 'th']
False
test_logdir_custom_callback
(tmpdir)
Tests that the path is correct even when there is a custom callback
Tests that the path is correct even when there is a custom callback
def test_logdir_custom_callback(tmpdir): """ Tests that the path is correct even when there is a custom callback """ expected = os.path.join(tmpdir, 'lightning_logs', 'version_0') model = TestModel(expected) trainer = Trainer( default_root_dir=tmpdir, max_steps=2, callba...
[ "def", "test_logdir_custom_callback", "(", "tmpdir", ")", ":", "expected", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "'lightning_logs'", ",", "'version_0'", ")", "model", "=", "TestModel", "(", "expected", ")", "trainer", "=", "Trainer", "(", ...
[ 107, 0 ]
[ 122, 38 ]
python
en
['en', 'error', 'th']
False
test_logdir_custom_logger
(tmpdir)
Tests that the path is correct even when there is a custom logger
Tests that the path is correct even when there is a custom logger
def test_logdir_custom_logger(tmpdir): """ Tests that the path is correct even when there is a custom logger """ expected = os.path.join(tmpdir, 'custom_logs', 'version_0') model = TestModel(expected) trainer = Trainer( default_root_dir=tmpdir, max_steps=2, callbacks=[Mo...
[ "def", "test_logdir_custom_logger", "(", "tmpdir", ")", ":", "expected", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "'custom_logs'", ",", "'version_0'", ")", "model", "=", "TestModel", "(", "expected", ")", "trainer", "=", "Trainer", "(", "de...
[ 125, 0 ]
[ 141, 38 ]
python
en
['en', 'error', 'th']
False
poly2herme
(pol)
poly2herme(pol) Convert a polynomial to a Hermite series. Convert an array representing the coefficients of a polynomial (relative to the "standard" basis) ordered from lowest degree to highest, to an array of the coefficients of the equivalent Hermite series, ordered from lowest to highest d...
poly2herme(pol)
def poly2herme(pol): """ poly2herme(pol) Convert a polynomial to a Hermite series. Convert an array representing the coefficients of a polynomial (relative to the "standard" basis) ordered from lowest degree to highest, to an array of the coefficients of the equivalent Hermite series, ordered ...
[ "def", "poly2herme", "(", "pol", ")", ":", "[", "pol", "]", "=", "pu", ".", "as_series", "(", "[", "pol", "]", ")", "deg", "=", "len", "(", "pol", ")", "-", "1", "res", "=", "0", "for", "i", "in", "range", "(", "deg", ",", "-", "1", ",", ...
[ 82, 0 ]
[ 125, 14 ]
python
en
['en', 'error', 'th']
False
herme2poly
(c)
Convert a Hermite series to a polynomial. Convert an array representing the coefficients of a Hermite series, ordered from lowest degree to highest, to an array of the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest to highest degree. Parameter...
Convert a Hermite series to a polynomial.
def herme2poly(c): """ Convert a Hermite series to a polynomial. Convert an array representing the coefficients of a Hermite series, ordered from lowest degree to highest, to an array of the coefficients of the equivalent polynomial (relative to the "standard" basis) ordered from lowest to high...
[ "def", "herme2poly", "(", "c", ")", ":", "from", ".", "polynomial", "import", "polyadd", ",", "polysub", ",", "polymulx", "[", "c", "]", "=", "pu", ".", "as_series", "(", "[", "c", "]", ")", "n", "=", "len", "(", "c", ")", "if", "n", "==", "1",...
[ 128, 0 ]
[ 182, 40 ]
python
en
['en', 'error', 'th']
False
hermeline
(off, scl)
Hermite series whose graph is a straight line. Parameters ---------- off, scl : scalars The specified line is given by ``off + scl*x``. Returns ------- y : ndarray This module's representation of the Hermite series for ``off + scl*x``. See Also -------- ...
Hermite series whose graph is a straight line.
def hermeline(off, scl): """ Hermite series whose graph is a straight line. Parameters ---------- off, scl : scalars The specified line is given by ``off + scl*x``. Returns ------- y : ndarray This module's representation of the Hermite series for ``off + scl*...
[ "def", "hermeline", "(", "off", ",", "scl", ")", ":", "if", "scl", "!=", "0", ":", "return", "np", ".", "array", "(", "[", "off", ",", "scl", "]", ")", "else", ":", "return", "np", ".", "array", "(", "[", "off", "]", ")" ]
[ 202, 0 ]
[ 236, 30 ]
python
en
['en', 'error', 'th']
False
hermefromroots
(roots)
Generate a HermiteE series with given roots. The function returns the coefficients of the polynomial .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), in HermiteE form, where the `r_n` are the roots specified in `roots`. If a zero has multiplicity n, then it must appear in `roots` n time...
Generate a HermiteE series with given roots.
def hermefromroots(roots): """ Generate a HermiteE series with given roots. The function returns the coefficients of the polynomial .. math:: p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n), in HermiteE form, where the `r_n` are the roots specified in `roots`. If a zero has multiplicity n, the...
[ "def", "hermefromroots", "(", "roots", ")", ":", "return", "pu", ".", "_fromroots", "(", "hermeline", ",", "hermemul", ",", "roots", ")" ]
[ 239, 0 ]
[ 288, 52 ]
python
en
['en', 'error', 'th']
False
hermeadd
(c1, c2)
Add one Hermite series to another. Returns the sum of two Hermite series `c1` + `c2`. The arguments are sequences of coefficients ordered from lowest order term to highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : array_like 1-D ...
Add one Hermite series to another.
def hermeadd(c1, c2): """ Add one Hermite series to another. Returns the sum of two Hermite series `c1` + `c2`. The arguments are sequences of coefficients ordered from lowest order term to highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1,...
[ "def", "hermeadd", "(", "c1", ",", "c2", ")", ":", "return", "pu", ".", "_add", "(", "c1", ",", "c2", ")" ]
[ 291, 0 ]
[ 328, 26 ]
python
en
['en', 'error', 'th']
False
hermesub
(c1, c2)
Subtract one Hermite series from another. Returns the difference of two Hermite series `c1` - `c2`. The sequences of coefficients are from lowest order term to highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : array_like 1-D arra...
Subtract one Hermite series from another.
def hermesub(c1, c2): """ Subtract one Hermite series from another. Returns the difference of two Hermite series `c1` - `c2`. The sequences of coefficients are from lowest order term to highest, i.e., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 ...
[ "def", "hermesub", "(", "c1", ",", "c2", ")", ":", "return", "pu", ".", "_sub", "(", "c1", ",", "c2", ")" ]
[ 331, 0 ]
[ 368, 26 ]
python
en
['en', 'error', 'th']
False
hermemulx
(c)
Multiply a Hermite series by x. Multiply the Hermite series `c` by x, where x is the independent variable. Parameters ---------- c : array_like 1-D array of Hermite series coefficients ordered from low to high. Returns ------- out : ndarray Array representing ...
Multiply a Hermite series by x.
def hermemulx(c): """Multiply a Hermite series by x. Multiply the Hermite series `c` by x, where x is the independent variable. Parameters ---------- c : array_like 1-D array of Hermite series coefficients ordered from low to high. Returns ------- out : ndarray ...
[ "def", "hermemulx", "(", "c", ")", ":", "# c is a trimmed copy", "[", "c", "]", "=", "pu", ".", "as_series", "(", "[", "c", "]", ")", "# The zero series needs special treatment", "if", "len", "(", "c", ")", "==", "1", "and", "c", "[", "0", "]", "==", ...
[ 371, 0 ]
[ 417, 14 ]
python
en
['en', 'en', 'en']
True
hermemul
(c1, c2)
Multiply one Hermite series by another. Returns the product of two Hermite series `c1` * `c2`. The arguments are sequences of coefficients, from lowest order "term" to highest, e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : array_like ...
Multiply one Hermite series by another.
def hermemul(c1, c2): """ Multiply one Hermite series by another. Returns the product of two Hermite series `c1` * `c2`. The arguments are sequences of coefficients, from lowest order "term" to highest, e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- ...
[ "def", "hermemul", "(", "c1", ",", "c2", ")", ":", "# s1, s2 are trimmed copies", "[", "c1", ",", "c2", "]", "=", "pu", ".", "as_series", "(", "[", "c1", ",", "c2", "]", ")", "if", "len", "(", "c1", ")", ">", "len", "(", "c2", ")", ":", "c", ...
[ 420, 0 ]
[ 483, 38 ]
python
en
['en', 'error', 'th']
False
hermediv
(c1, c2)
Divide one Hermite series by another. Returns the quotient-with-remainder of two Hermite series `c1` / `c2`. The arguments are sequences of coefficients from lowest order "term" to highest, e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ---------- c1, c2 : ar...
Divide one Hermite series by another.
def hermediv(c1, c2): """ Divide one Hermite series by another. Returns the quotient-with-remainder of two Hermite series `c1` / `c2`. The arguments are sequences of coefficients from lowest order "term" to highest, e.g., [1,2,3] represents the series ``P_0 + 2*P_1 + 3*P_2``. Parameters ...
[ "def", "hermediv", "(", "c1", ",", "c2", ")", ":", "return", "pu", ".", "_div", "(", "hermemul", ",", "c1", ",", "c2", ")" ]
[ 486, 0 ]
[ 529, 36 ]
python
en
['en', 'error', 'th']
False
hermepow
(c, pow, maxpower=16)
Raise a Hermite series to a power. Returns the Hermite series `c` raised to the power `pow`. The argument `c` is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series ``P_0 + 2*P_1 + 3*P_2.`` Parameters ---------- c : array_like 1-D array of Hermite series c...
Raise a Hermite series to a power.
def hermepow(c, pow, maxpower=16): """Raise a Hermite series to a power. Returns the Hermite series `c` raised to the power `pow`. The argument `c` is a sequence of coefficients ordered from low to high. i.e., [1,2,3] is the series ``P_0 + 2*P_1 + 3*P_2.`` Parameters ---------- c : array_...
[ "def", "hermepow", "(", "c", ",", "pow", ",", "maxpower", "=", "16", ")", ":", "return", "pu", ".", "_pow", "(", "hermemul", ",", "c", ",", "pow", ",", "maxpower", ")" ]
[ 532, 0 ]
[ 566, 46 ]
python
en
['en', 'gd', 'en']
True
hermeder
(c, m=1, scl=1, axis=0)
Differentiate a Hermite_e series. Returns the series coefficients `c` differentiated `m` times along `axis`. At each iteration the result is multiplied by `scl` (the scaling factor is for use in a linear change of variable). The argument `c` is an array of coefficients from low to high degree alo...
Differentiate a Hermite_e series.
def hermeder(c, m=1, scl=1, axis=0): """ Differentiate a Hermite_e series. Returns the series coefficients `c` differentiated `m` times along `axis`. At each iteration the result is multiplied by `scl` (the scaling factor is for use in a linear change of variable). The argument `c` is an array...
[ "def", "hermeder", "(", "c", ",", "m", "=", "1", ",", "scl", "=", "1", ",", "axis", "=", "0", ")", ":", "c", "=", "np", ".", "array", "(", "c", ",", "ndmin", "=", "1", ",", "copy", "=", "1", ")", "if", "c", ".", "dtype", ".", "char", "i...
[ 569, 0 ]
[ 649, 12 ]
python
en
['en', 'error', 'th']
False
hermeint
(c, m=1, k=[], lbnd=0, scl=1, axis=0)
Integrate a Hermite_e series. Returns the Hermite_e series coefficients `c` integrated `m` times from `lbnd` along `axis`. At each iteration the resulting series is **multiplied** by `scl` and an integration constant, `k`, is added. The scaling factor is for use in a linear change of variable. ("...
Integrate a Hermite_e series.
def hermeint(c, m=1, k=[], lbnd=0, scl=1, axis=0): """ Integrate a Hermite_e series. Returns the Hermite_e series coefficients `c` integrated `m` times from `lbnd` along `axis`. At each iteration the resulting series is **multiplied** by `scl` and an integration constant, `k`, is added. The sca...
[ "def", "hermeint", "(", "c", ",", "m", "=", "1", ",", "k", "=", "[", "]", ",", "lbnd", "=", "0", ",", "scl", "=", "1", ",", "axis", "=", "0", ")", ":", "c", "=", "np", ".", "array", "(", "c", ",", "ndmin", "=", "1", ",", "copy", "=", ...
[ 652, 0 ]
[ 771, 12 ]
python
en
['en', 'error', 'th']
False
hermeval
(x, c, tensor=True)
Evaluate an HermiteE series at points x. If `c` is of length `n + 1`, this function returns the value: .. math:: p(x) = c_0 * He_0(x) + c_1 * He_1(x) + ... + c_n * He_n(x) The parameter `x` is converted to an array only if it is a tuple or a list, otherwise it is treated as a scalar. In either c...
Evaluate an HermiteE series at points x.
def hermeval(x, c, tensor=True): """ Evaluate an HermiteE series at points x. If `c` is of length `n + 1`, this function returns the value: .. math:: p(x) = c_0 * He_0(x) + c_1 * He_1(x) + ... + c_n * He_n(x) The parameter `x` is converted to an array only if it is a tuple or a list, otherwis...
[ "def", "hermeval", "(", "x", ",", "c", ",", "tensor", "=", "True", ")", ":", "c", "=", "np", ".", "array", "(", "c", ",", "ndmin", "=", "1", ",", "copy", "=", "0", ")", "if", "c", ".", "dtype", ".", "char", "in", "'?bBhHiIlLqQpP'", ":", "c", ...
[ 774, 0 ]
[ 866, 20 ]
python
en
['en', 'error', 'th']
False
hermeval2d
(x, y, c)
Evaluate a 2-D HermiteE series at points (x, y). This function returns the values: .. math:: p(x,y) = \\sum_{i,j} c_{i,j} * He_i(x) * He_j(y) The parameters `x` and `y` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars and they must have the ...
Evaluate a 2-D HermiteE series at points (x, y).
def hermeval2d(x, y, c): """ Evaluate a 2-D HermiteE series at points (x, y). This function returns the values: .. math:: p(x,y) = \\sum_{i,j} c_{i,j} * He_i(x) * He_j(y) The parameters `x` and `y` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a sca...
[ "def", "hermeval2d", "(", "x", ",", "y", ",", "c", ")", ":", "return", "pu", ".", "_valnd", "(", "hermeval", ",", "c", ",", "x", ",", "y", ")" ]
[ 869, 0 ]
[ 915, 39 ]
python
en
['en', 'error', 'th']
False
hermegrid2d
(x, y, c)
Evaluate a 2-D HermiteE series on the Cartesian product of x and y. This function returns the values: .. math:: p(a,b) = \\sum_{i,j} c_{i,j} * H_i(a) * H_j(b) where the points `(a, b)` consist of all pairs formed by taking `a` from `x` and `b` from `y`. The resulting points form a grid with ...
Evaluate a 2-D HermiteE series on the Cartesian product of x and y.
def hermegrid2d(x, y, c): """ Evaluate a 2-D HermiteE series on the Cartesian product of x and y. This function returns the values: .. math:: p(a,b) = \\sum_{i,j} c_{i,j} * H_i(a) * H_j(b) where the points `(a, b)` consist of all pairs formed by taking `a` from `x` and `b` from `y`. The resul...
[ "def", "hermegrid2d", "(", "x", ",", "y", ",", "c", ")", ":", "return", "pu", ".", "_gridnd", "(", "hermeval", ",", "c", ",", "x", ",", "y", ")" ]
[ 918, 0 ]
[ 968, 40 ]
python
en
['en', 'error', 'th']
False
hermeval3d
(x, y, z, c)
Evaluate a 3-D Hermite_e series at points (x, y, z). This function returns the values: .. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * He_i(x) * He_j(y) * He_k(z) The parameters `x`, `y`, and `z` are converted to arrays only if they are tuples or a lists, otherwise they are treated as a scalars a...
Evaluate a 3-D Hermite_e series at points (x, y, z).
def hermeval3d(x, y, z, c): """ Evaluate a 3-D Hermite_e series at points (x, y, z). This function returns the values: .. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * He_i(x) * He_j(y) * He_k(z) The parameters `x`, `y`, and `z` are converted to arrays only if they are tuples or a lists, otherw...
[ "def", "hermeval3d", "(", "x", ",", "y", ",", "z", ",", "c", ")", ":", "return", "pu", ".", "_valnd", "(", "hermeval", ",", "c", ",", "x", ",", "y", ",", "z", ")" ]
[ 971, 0 ]
[ 1019, 42 ]
python
en
['en', 'error', 'th']
False
hermegrid3d
(x, y, z, c)
Evaluate a 3-D HermiteE series on the Cartesian product of x, y, and z. This function returns the values: .. math:: p(a,b,c) = \\sum_{i,j,k} c_{i,j,k} * He_i(a) * He_j(b) * He_k(c) where the points `(a, b, c)` consist of all triples formed by taking `a` from `x`, `b` from `y`, and `c` from `z`. ...
Evaluate a 3-D HermiteE series on the Cartesian product of x, y, and z.
def hermegrid3d(x, y, z, c): """ Evaluate a 3-D HermiteE series on the Cartesian product of x, y, and z. This function returns the values: .. math:: p(a,b,c) = \\sum_{i,j,k} c_{i,j,k} * He_i(a) * He_j(b) * He_k(c) where the points `(a, b, c)` consist of all triples formed by taking `a` from `...
[ "def", "hermegrid3d", "(", "x", ",", "y", ",", "z", ",", "c", ")", ":", "return", "pu", ".", "_gridnd", "(", "hermeval", ",", "c", ",", "x", ",", "y", ",", "z", ")" ]
[ 1022, 0 ]
[ 1075, 43 ]
python
en
['en', 'error', 'th']
False
hermevander
(x, deg)
Pseudo-Vandermonde matrix of given degree. Returns the pseudo-Vandermonde matrix of degree `deg` and sample points `x`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., i] = He_i(x), where `0 <= i <= deg`. The leading indices of `V` index the elements of `x` and the last index is the ...
Pseudo-Vandermonde matrix of given degree.
def hermevander(x, deg): """Pseudo-Vandermonde matrix of given degree. Returns the pseudo-Vandermonde matrix of degree `deg` and sample points `x`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., i] = He_i(x), where `0 <= i <= deg`. The leading indices of `V` index the elements of ...
[ "def", "hermevander", "(", "x", ",", "deg", ")", ":", "ideg", "=", "pu", ".", "_deprecate_as_int", "(", "deg", ",", "\"deg\"", ")", "if", "ideg", "<", "0", ":", "raise", "ValueError", "(", "\"deg must be non-negative\"", ")", "x", "=", "np", ".", "arra...
[ 1078, 0 ]
[ 1135, 32 ]
python
ca
['nl', 'ca', 'en']
False
hermevander2d
(x, y, deg)
Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y)`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., (deg[1] + 1)*i + j] = He_i(x) * He_j(y), where `0 <= i <= deg[0]` and `0 <= j <= deg[1]`. The leading indices of ...
Pseudo-Vandermonde matrix of given degrees.
def hermevander2d(x, y, deg): """Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y)`. The pseudo-Vandermonde matrix is defined by .. math:: V[..., (deg[1] + 1)*i + j] = He_i(x) * He_j(y), where `0 <= i <= deg[0]` and `0 <= ...
[ "def", "hermevander2d", "(", "x", ",", "y", ",", "deg", ")", ":", "return", "pu", ".", "_vander2d", "(", "hermevander", ",", "x", ",", "y", ",", "deg", ")" ]
[ 1138, 0 ]
[ 1188, 47 ]
python
ca
['nl', 'ca', 'en']
False
hermevander3d
(x, y, z, deg)
Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y, z)`. If `l, m, n` are the given degrees in `x, y, z`, then Hehe pseudo-Vandermonde matrix is defined by .. math:: V[..., (m+1)(n+1)i + (n+1)j + k] = He_i(x)*He_j(y)*He_k(z), ...
Pseudo-Vandermonde matrix of given degrees.
def hermevander3d(x, y, z, deg): """Pseudo-Vandermonde matrix of given degrees. Returns the pseudo-Vandermonde matrix of degrees `deg` and sample points `(x, y, z)`. If `l, m, n` are the given degrees in `x, y, z`, then Hehe pseudo-Vandermonde matrix is defined by .. math:: V[..., (m+1)(n+1)i + (n...
[ "def", "hermevander3d", "(", "x", ",", "y", ",", "z", ",", "deg", ")", ":", "return", "pu", ".", "_vander3d", "(", "hermevander", ",", "x", ",", "y", ",", "z", ",", "deg", ")" ]
[ 1191, 0 ]
[ 1242, 50 ]
python
ca
['nl', 'ca', 'en']
False
hermefit
(x, y, deg, rcond=None, full=False, w=None)
Least squares fit of Hermite series to data. Return the coefficients of a HermiteE series of degree `deg` that is the least squares fit to the data values `y` given at points `x`. If `y` is 1-D the returned coefficients will also be 1-D. If `y` is 2-D multiple fits are done, one for each column of...
Least squares fit of Hermite series to data.
def hermefit(x, y, deg, rcond=None, full=False, w=None): """ Least squares fit of Hermite series to data. Return the coefficients of a HermiteE series of degree `deg` that is the least squares fit to the data values `y` given at points `x`. If `y` is 1-D the returned coefficients will also be 1-D. ...
[ "def", "hermefit", "(", "x", ",", "y", ",", "deg", ",", "rcond", "=", "None", ",", "full", "=", "False", ",", "w", "=", "None", ")", ":", "return", "pu", ".", "_fit", "(", "hermevander", ",", "x", ",", "y", ",", "deg", ",", "rcond", ",", "ful...
[ 1245, 0 ]
[ 1370, 58 ]
python
en
['en', 'error', 'th']
False
hermecompanion
(c)
Return the scaled companion matrix of c. The basis polynomials are scaled so that the companion matrix is symmetric when `c` is an HermiteE basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are guaranteed to be real if ...
Return the scaled companion matrix of c.
def hermecompanion(c): """ Return the scaled companion matrix of c. The basis polynomials are scaled so that the companion matrix is symmetric when `c` is an HermiteE basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are...
[ "def", "hermecompanion", "(", "c", ")", ":", "# c is a trimmed copy", "[", "c", "]", "=", "pu", ".", "as_series", "(", "[", "c", "]", ")", "if", "len", "(", "c", ")", "<", "2", ":", "raise", "ValueError", "(", "'Series must have maximum degree of at least ...
[ 1373, 0 ]
[ 1416, 14 ]
python
en
['en', 'error', 'th']
False
hermeroots
(c)
Compute the roots of a HermiteE series. Return the roots (a.k.a. "zeros") of the polynomial .. math:: p(x) = \\sum_i c[i] * He_i(x). Parameters ---------- c : 1-D array_like 1-D array of coefficients. Returns ------- out : ndarray Array of the roots of the series...
Compute the roots of a HermiteE series.
def hermeroots(c): """ Compute the roots of a HermiteE series. Return the roots (a.k.a. "zeros") of the polynomial .. math:: p(x) = \\sum_i c[i] * He_i(x). Parameters ---------- c : 1-D array_like 1-D array of coefficients. Returns ------- out : ndarray Array ...
[ "def", "hermeroots", "(", "c", ")", ":", "# c is a trimmed copy", "[", "c", "]", "=", "pu", ".", "as_series", "(", "[", "c", "]", ")", "if", "len", "(", "c", ")", "<=", "1", ":", "return", "np", ".", "array", "(", "[", "]", ",", "dtype", "=", ...
[ 1419, 0 ]
[ 1476, 12 ]
python
en
['en', 'error', 'th']
False
_normed_hermite_e_n
(x, n)
Evaluate a normalized HermiteE polynomial. Compute the value of the normalized HermiteE polynomial of degree ``n`` at the points ``x``. Parameters ---------- x : ndarray of double. Points at which to evaluate the function n : int Degree of the normalized HermiteE function...
Evaluate a normalized HermiteE polynomial.
def _normed_hermite_e_n(x, n): """ Evaluate a normalized HermiteE polynomial. Compute the value of the normalized HermiteE polynomial of degree ``n`` at the points ``x``. Parameters ---------- x : ndarray of double. Points at which to evaluate the function n : int Degr...
[ "def", "_normed_hermite_e_n", "(", "x", ",", "n", ")", ":", "if", "n", "==", "0", ":", "return", "np", ".", "full", "(", "x", ".", "shape", ",", "1", "/", "np", ".", "sqrt", "(", "np", ".", "sqrt", "(", "2", "*", "np", ".", "pi", ")", ")", ...
[ 1479, 0 ]
[ 1519, 20 ]
python
en
['en', 'error', 'th']
False
hermegauss
(deg)
Gauss-HermiteE quadrature. Computes the sample points and weights for Gauss-HermiteE quadrature. These sample points and weights will correctly integrate polynomials of degree :math:`2*deg - 1` or less over the interval :math:`[-\\inf, \\inf]` with the weight function :math:`f(x) = \\exp(-x^2/2)`....
Gauss-HermiteE quadrature.
def hermegauss(deg): """ Gauss-HermiteE quadrature. Computes the sample points and weights for Gauss-HermiteE quadrature. These sample points and weights will correctly integrate polynomials of degree :math:`2*deg - 1` or less over the interval :math:`[-\\inf, \\inf]` with the weight function :...
[ "def", "hermegauss", "(", "deg", ")", ":", "ideg", "=", "pu", ".", "_deprecate_as_int", "(", "deg", ",", "\"deg\"", ")", "if", "ideg", "<=", "0", ":", "raise", "ValueError", "(", "\"deg must be a positive integer\"", ")", "# first approximation of roots. We use th...
[ 1522, 0 ]
[ 1586, 15 ]
python
en
['en', 'error', 'th']
False
hermeweight
(x)
Weight function of the Hermite_e polynomials. The weight function is :math:`\\exp(-x^2/2)` and the interval of integration is :math:`[-\\inf, \\inf]`. the HermiteE polynomials are orthogonal, but not normalized, with respect to this weight function. Parameters ---------- x : array_like ...
Weight function of the Hermite_e polynomials.
def hermeweight(x): """Weight function of the Hermite_e polynomials. The weight function is :math:`\\exp(-x^2/2)` and the interval of integration is :math:`[-\\inf, \\inf]`. the HermiteE polynomials are orthogonal, but not normalized, with respect to this weight function. Parameters ----------...
[ "def", "hermeweight", "(", "x", ")", ":", "w", "=", "np", ".", "exp", "(", "-", ".5", "*", "x", "**", "2", ")", "return", "w" ]
[ 1589, 0 ]
[ 1613, 12 ]
python
en
['en', 'en', 'en']
True
diff
(a, b)
TODO: fix this function!!
TODO: fix this function!!
def diff(a, b): """ TODO: fix this function!! """ return a - b
[ "def", "diff", "(", "a", ",", "b", ")", ":", "return", "a", "-", "b" ]
[ 0, 0 ]
[ 4, 16 ]
python
en
['en', 'error', 'th']
False
simpleColor
(r,g,b)
simpleColor obtiene el nombre del color mas general al cual se acerca su formato R G B
simpleColor obtiene el nombre del color mas general al cual se acerca su formato R G B
def simpleColor(r,g,b): """ simpleColor obtiene el nombre del color mas general al cual se acerca su formato R G B """ r=int(r) g=int(g) b=int(b) bg = ir = 0 # TODO: Fix these variables try: #ROJO -------------------------------------------------- if r > g and r > b: ...
[ "def", "simpleColor", "(", "r", ",", "g", ",", "b", ")", ":", "r", "=", "int", "(", "r", ")", "g", "=", "int", "(", "g", ")", "b", "=", "int", "(", "b", ")", "bg", "=", "ir", "=", "0", "# TODO: Fix these variables", "try", ":", "#ROJO ---------...
[ 7, 0 ]
[ 173, 26 ]
python
es
['es', 'es', 'es']
True
test_tpu_device_absence
()
Check tpu_device_exists returns None when torch_xla is not available
Check tpu_device_exists returns None when torch_xla is not available
def test_tpu_device_absence(): """Check tpu_device_exists returns None when torch_xla is not available""" assert xla_utils.XLADeviceUtils.tpu_device_exists() is None
[ "def", "test_tpu_device_absence", "(", ")", ":", "assert", "xla_utils", ".", "XLADeviceUtils", ".", "tpu_device_exists", "(", ")", "is", "None" ]
[ 24, 0 ]
[ 26, 63 ]
python
en
['en', 'en', 'en']
True
test_tpu_device_presence
()
Check tpu_device_exists returns True when TPU is available
Check tpu_device_exists returns True when TPU is available
def test_tpu_device_presence(): """Check tpu_device_exists returns True when TPU is available""" assert xla_utils.XLADeviceUtils.tpu_device_exists() is True
[ "def", "test_tpu_device_presence", "(", ")", ":", "assert", "xla_utils", ".", "XLADeviceUtils", ".", "tpu_device_exists", "(", ")", "is", "True" ]
[ 31, 0 ]
[ 33, 63 ]
python
en
['en', 'en', 'en']
True
test_result_returns_within_timeout_seconds
()
Check that pl_multi_process returns within 10 seconds
Check that pl_multi_process returns within 10 seconds
def test_result_returns_within_timeout_seconds(): """Check that pl_multi_process returns within 10 seconds""" start = time.time() result = xla_utils.pl_multi_process(time.sleep)(xla_utils.TPU_CHECK_TIMEOUT * 1.25) end = time.time() elapsed_time = int(end - start) assert elapsed_time <= xla_utils...
[ "def", "test_result_returns_within_timeout_seconds", "(", ")", ":", "start", "=", "time", ".", "time", "(", ")", "result", "=", "xla_utils", ".", "pl_multi_process", "(", "time", ".", "sleep", ")", "(", "xla_utils", ".", "TPU_CHECK_TIMEOUT", "*", "1.25", ")", ...
[ 37, 0 ]
[ 44, 26 ]
python
en
['en', 'en', 'en']
True
init_pose_model
(config, checkpoint=None, device='cuda:0')
Initialize a pose model from config file. Args: config (str or :obj:`mmcv.Config`): Config file path or the config object. checkpoint (str, optional): Checkpoint path. If left as None, the model will not load any weights. Returns: nn.Module: The constructed dete...
Initialize a pose model from config file.
def init_pose_model(config, checkpoint=None, device='cuda:0'): """Initialize a pose model from config file. Args: config (str or :obj:`mmcv.Config`): Config file path or the config object. checkpoint (str, optional): Checkpoint path. If left as None, the model will not l...
[ "def", "init_pose_model", "(", "config", ",", "checkpoint", "=", "None", ",", "device", "=", "'cuda:0'", ")", ":", "if", "isinstance", "(", "config", ",", "str", ")", ":", "config", "=", "mmcv", ".", "Config", ".", "fromfile", "(", "config", ")", "elif...
[ 15, 0 ]
[ 41, 16 ]
python
en
['en', 'en', 'en']
True
_xyxy2xywh
(bbox_xyxy)
Transform the bbox format from x1y1x2y2 to xywh. Args: bbox_xyxy (np.ndarray): Bounding boxes (with scores), shaped (n, 4) or (n, 5). (left, top, right, bottom, [score]) Returns: np.ndarray: Bounding boxes (with scores), shaped (n, 4) or (n, 5). (left, top, width, height,...
Transform the bbox format from x1y1x2y2 to xywh.
def _xyxy2xywh(bbox_xyxy): """Transform the bbox format from x1y1x2y2 to xywh. Args: bbox_xyxy (np.ndarray): Bounding boxes (with scores), shaped (n, 4) or (n, 5). (left, top, right, bottom, [score]) Returns: np.ndarray: Bounding boxes (with scores), shaped (n, 4) or ...
[ "def", "_xyxy2xywh", "(", "bbox_xyxy", ")", ":", "bbox_xywh", "=", "bbox_xyxy", ".", "copy", "(", ")", "bbox_xywh", "[", ":", ",", "2", "]", "=", "bbox_xywh", "[", ":", ",", "2", "]", "-", "bbox_xywh", "[", ":", ",", "0", "]", "+", "1", "bbox_xyw...
[ 44, 0 ]
[ 58, 20 ]
python
en
['en', 'en', 'en']
True
_xywh2xyxy
(bbox_xywh)
Transform the bbox format from xywh to x1y1x2y2. Args: bbox_xywh (ndarray): Bounding boxes (with scores), shaped (n, 4) or (n, 5). (left, top, width, height, [score]) Returns: np.ndarray: Bounding boxes (with scores), shaped (n, 4) or (n, 5). (left, top, right, bottom, [sc...
Transform the bbox format from xywh to x1y1x2y2.
def _xywh2xyxy(bbox_xywh): """Transform the bbox format from xywh to x1y1x2y2. Args: bbox_xywh (ndarray): Bounding boxes (with scores), shaped (n, 4) or (n, 5). (left, top, width, height, [score]) Returns: np.ndarray: Bounding boxes (with scores), shaped (n, 4) or (n, ...
[ "def", "_xywh2xyxy", "(", "bbox_xywh", ")", ":", "bbox_xyxy", "=", "bbox_xywh", ".", "copy", "(", ")", "bbox_xyxy", "[", ":", ",", "2", "]", "=", "bbox_xyxy", "[", ":", ",", "2", "]", "+", "bbox_xyxy", "[", ":", ",", "0", "]", "-", "1", "bbox_xyx...
[ 61, 0 ]
[ 74, 20 ]
python
en
['en', 'en', 'en']
True
_box2cs
(cfg, box)
This encodes bbox(x,y,w,h) into (center, scale) Args: x, y, w, h Returns: tuple: A tuple containing center and scale. - np.ndarray[float32](2,): Center of the bbox (x, y). - np.ndarray[float32](2,): Scale of the bbox w & h.
This encodes bbox(x,y,w,h) into (center, scale)
def _box2cs(cfg, box): """This encodes bbox(x,y,w,h) into (center, scale) Args: x, y, w, h Returns: tuple: A tuple containing center and scale. - np.ndarray[float32](2,): Center of the bbox (x, y). - np.ndarray[float32](2,): Scale of the bbox w & h. """ x, y, w, h...
[ "def", "_box2cs", "(", "cfg", ",", "box", ")", ":", "x", ",", "y", ",", "w", ",", "h", "=", "box", "[", ":", "4", "]", "input_size", "=", "cfg", ".", "data_cfg", "[", "'image_size'", "]", "aspect_ratio", "=", "input_size", "[", "0", "]", "/", "...
[ 77, 0 ]
[ 105, 24 ]
python
en
['en', 'en', 'en']
True
_inference_single_pose_model
(model, img_or_path, bbox, dataset, return_heatmap=False)
Inference a single bbox. num_keypoints: K Args: model (nn.Module): The loaded pose model. image_name (str | np.ndarray):Image_name bbox (list | np.ndarray): Bounding boxes (with scores), shaped (4, ) or (5, ). (left, top, width, height, [score]) dataset (str): Datas...
Inference a single bbox.
def _inference_single_pose_model(model, img_or_path, bbox, dataset, return_heatmap=False): """Inference a single bbox. num_keypoints: K Args: model (nn.Module): The l...
[ "def", "_inference_single_pose_model", "(", "model", ",", "img_or_path", ",", "bbox", ",", "dataset", ",", "return_heatmap", "=", "False", ")", ":", "cfg", "=", "model", ".", "cfg", "device", "=", "next", "(", "model", ".", "parameters", "(", ")", ")", "...
[ 135, 0 ]
[ 239, 32 ]
python
en
['en', 'en', 'en']
True
inference_top_down_pose_model
(model, img_or_path, person_bboxes, bbox_thr=None, format='xywh', dataset='TopDownCocoDataset', return_heatmap=False...
Inference a single image with a list of person bounding boxes. num_people: P num_keypoints: K bbox height: H bbox width: W Args: model (nn.Module): The loaded pose model. image_name (str| np.ndarray): Image_name person_bboxes: (np.ndarray[P x 4] or [P x 5]): Each person bou...
Inference a single image with a list of person bounding boxes.
def inference_top_down_pose_model(model, img_or_path, person_bboxes, bbox_thr=None, format='xywh', dataset='TopDownCocoDataset', ...
[ "def", "inference_top_down_pose_model", "(", "model", ",", "img_or_path", ",", "person_bboxes", ",", "bbox_thr", "=", "None", ",", "format", "=", "'xywh'", ",", "dataset", "=", "'TopDownCocoDataset'", ",", "return_heatmap", "=", "False", ",", "outputs", "=", "No...
[ 242, 0 ]
[ 315, 41 ]
python
en
['en', 'en', 'en']
True
inference_bottom_up_pose_model
(model, img_or_path, return_heatmap=False, outputs=None)
Inference a single image. num_people: P num_keypoints: K bbox height: H bbox width: W Args: model (nn.Module): The loaded pose model. image_name (str| np.ndarray): Image_name. return_heatmap (bool) : Flag to return heatmap, default: False outputs (list(str) | tuple(...
Inference a single image.
def inference_bottom_up_pose_model(model, img_or_path, return_heatmap=False, outputs=None): """Inference a single image. num_people: P num_keypoints: K bbox height: H bbox width: W Args: ...
[ "def", "inference_bottom_up_pose_model", "(", "model", ",", "img_or_path", ",", "return_heatmap", "=", "False", ",", "outputs", "=", "None", ")", ":", "pose_results", "=", "[", "]", "returned_outputs", "=", "[", "]", "cfg", "=", "model", ".", "cfg", "device"...
[ 318, 0 ]
[ 397, 41 ]
python
en
['en', 'en', 'en']
True
vis_pose_result
(model, img, result, kpt_score_thr=0.3, dataset='TopDownCocoDataset', show=False, out_file=None)
Visualize the detection results on the image. Args: model (nn.Module): The loaded detector. img (str | np.ndarray): Image filename or loaded image. result (list[dict]): The results to draw over `img` (bbox_result, pose_result). kpt_score_thr (float): The threshold to...
Visualize the detection results on the image.
def vis_pose_result(model, img, result, kpt_score_thr=0.3, dataset='TopDownCocoDataset', show=False, out_file=None): """Visualize the detection results on the image. Args: model (nn.M...
[ "def", "vis_pose_result", "(", "model", ",", "img", ",", "result", ",", "kpt_score_thr", "=", "0.3", ",", "dataset", "=", "'TopDownCocoDataset'", ",", "show", "=", "False", ",", "out_file", "=", "None", ")", ":", "if", "hasattr", "(", "model", ",", "'mod...
[ 400, 0 ]
[ 544, 14 ]
python
en
['en', 'en', 'en']
True
LoadImage.__call__
(self, results)
Call function to load images into results. Args: results (dict): A result dict contains the file name of the image to be read. Returns: dict: ``results`` will be returned containing loaded image.
Call function to load images into results.
def __call__(self, results): """Call function to load images into results. Args: results (dict): A result dict contains the file name of the image to be read. Returns: dict: ``results`` will be returned containing loaded image. """ if isi...
[ "def", "__call__", "(", "self", ",", "results", ")", ":", "if", "isinstance", "(", "results", "[", "'img_or_path'", "]", ",", "str", ")", ":", "results", "[", "'image_file'", "]", "=", "results", "[", "'img_or_path'", "]", "else", ":", "results", "[", ...
[ 115, 4 ]
[ 132, 22 ]
python
en
['en', 'en', 'en']
True
test_seed_stays_same_with_multiple_seed_everything_calls
()
Ensure that after the initial seed everything, the seed stays the same for the same run.
Ensure that after the initial seed everything, the seed stays the same for the same run.
def test_seed_stays_same_with_multiple_seed_everything_calls(): """ Ensure that after the initial seed everything, the seed stays the same for the same run. """ with pytest.warns(UserWarning, match="No correct seed found"): seed_utils.seed_everything() initial_seed = os.environ.get("PL_G...
[ "def", "test_seed_stays_same_with_multiple_seed_everything_calls", "(", ")", ":", "with", "pytest", ".", "warns", "(", "UserWarning", ",", "match", "=", "\"No correct seed found\"", ")", ":", "seed_utils", ".", "seed_everything", "(", ")", "initial_seed", "=", "os", ...
[ 9, 0 ]
[ 23, 31 ]
python
en
['en', 'error', 'th']
False
test_correct_seed_with_environment_variable
()
Ensure that the PL_GLOBAL_SEED environment is read
Ensure that the PL_GLOBAL_SEED environment is read
def test_correct_seed_with_environment_variable(): """ Ensure that the PL_GLOBAL_SEED environment is read """ assert seed_utils.seed_everything() == 2020
[ "def", "test_correct_seed_with_environment_variable", "(", ")", ":", "assert", "seed_utils", ".", "seed_everything", "(", ")", "==", "2020" ]
[ 27, 0 ]
[ 31, 47 ]
python
en
['en', 'error', 'th']
False
test_invalid_seed
()
Ensure that we still fix the seed even if an invalid seed is given
Ensure that we still fix the seed even if an invalid seed is given
def test_invalid_seed(): """ Ensure that we still fix the seed even if an invalid seed is given """ with pytest.warns(UserWarning, match="No correct seed found"): seed = seed_utils.seed_everything() assert seed == 123
[ "def", "test_invalid_seed", "(", ")", ":", "with", "pytest", ".", "warns", "(", "UserWarning", ",", "match", "=", "\"No correct seed found\"", ")", ":", "seed", "=", "seed_utils", ".", "seed_everything", "(", ")", "assert", "seed", "==", "123" ]
[ 36, 0 ]
[ 42, 22 ]
python
en
['en', 'error', 'th']
False
test_out_of_bounds_seed
(seed)
Ensure that we still fix the seed even if an out-of-bounds seed is given
Ensure that we still fix the seed even if an out-of-bounds seed is given
def test_out_of_bounds_seed(seed): """ Ensure that we still fix the seed even if an out-of-bounds seed is given """ with pytest.warns(UserWarning, match="is not in bounds"): actual = seed_utils.seed_everything(seed) assert actual == 123
[ "def", "test_out_of_bounds_seed", "(", "seed", ")", ":", "with", "pytest", ".", "warns", "(", "UserWarning", ",", "match", "=", "\"is not in bounds\"", ")", ":", "actual", "=", "seed_utils", ".", "seed_everything", "(", "seed", ")", "assert", "actual", "==", ...
[ 48, 0 ]
[ 54, 24 ]
python
en
['en', 'error', 'th']
False
LearningRateMonitor.on_train_start
(self, trainer, *args, **kwargs)
Called before training, determines unique names for all lr schedulers in the case of multiple of the same type or in the case of multiple parameter groups Raises: MisconfigurationException: If ``Trainer`` has no ``logger``.
Called before training, determines unique names for all lr schedulers in the case of multiple of the same type or in the case of multiple parameter groups
def on_train_start(self, trainer, *args, **kwargs): """ Called before training, determines unique names for all lr schedulers in the case of multiple of the same type or in the case of multiple parameter groups Raises: MisconfigurationException: If ``...
[ "def", "on_train_start", "(", "self", ",", "trainer", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "trainer", ".", "logger", ":", "raise", "MisconfigurationException", "(", "'Cannot use `LearningRateMonitor` callback with `Trainer` that has no log...
[ 78, 4 ]
[ 116, 80 ]
python
en
['en', 'error', 'th']
False
get_user_input
(start, end)
input: two integer values lower limit 'start' and maximum 'end' the arguments aren't inclusive. output: if reading successful then returns the read integer. purpose: reads from command-line a integer in the given bounds. while input invalid ask...
input: two integer values lower limit 'start' and maximum 'end' the arguments aren't inclusive.
def get_user_input(start, end): """ input: two integer values lower limit 'start' and maximum 'end' the arguments aren't inclusive. output: if reading successful then returns the read integer. purpose: reads from command-line a integer in the given bounds. ...
[ "def", "get_user_input", "(", "start", ",", "end", ")", ":", "loop", "=", "True", "# controls while-loop", "while", "loop", ":", "try", ":", "# reads and converts the input from the console. ", "user_input", "=", "int", "(", "input", "(", "\"Enter Your choice: \"", ...
[ 0, 0 ]
[ 37, 21 ]
python
en
['en', 'error', 'th']
False
get_translated_text
(from_lang: str, to_lang: str, from_text: str)
ERROR: type should be string, got "\n https://qiita.com/fujino-fpu/items/e94d4ff9e7a5784b2987\n "
ERROR: type should be string, got "\n https://qiita.com/fujino-fpu/items/e94d4ff9e7a5784b2987\n "
def get_translated_text(from_lang: str, to_lang: str, from_text: str) -> str: ''' https://qiita.com/fujino-fpu/items/e94d4ff9e7a5784b2987 ''' sleep_time = 1 # urlencode from_text = urllib.parse.quote(from_text) # url作成 url = 'https://www.deepl.com/translator#' \ + from_lang + ...
[ "def", "get_translated_text", "(", "from_lang", ":", "str", ",", "to_lang", ":", "str", ",", "from_text", ":", "str", ")", "->", "str", ":", "sleep_time", "=", "1", "# urlencode", "from_text", "=", "urllib", ".", "parse", ".", "quote", "(", "from_text", ...
[ 104, 0 ]
[ 138, 18 ]
python
en
['en', 'error', 'th']
False
test_logging_to_progress_bar_with_reserved_key
(tmpdir)
Test that logging a metric with a reserved name to the progress bar raises a warning.
Test that logging a metric with a reserved name to the progress bar raises a warning.
def test_logging_to_progress_bar_with_reserved_key(tmpdir): """ Test that logging a metric with a reserved name to the progress bar raises a warning. """ class TestModel(BoringModel): def training_step(self, *args, **kwargs): output = super().training_step(*args, **kwargs) self...
[ "def", "test_logging_to_progress_bar_with_reserved_key", "(", "tmpdir", ")", ":", "class", "TestModel", "(", "BoringModel", ")", ":", "def", "training_step", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "output", "=", "super", "(", ")", ...
[ 6, 0 ]
[ 22, 26 ]
python
en
['en', 'en', 'en']
True
DeepSpeedPlugin.__init__
( self, zero_optimization: bool = True, stage: int = 2, cpu_offload: bool = True, contiguous_gradients: bool = True, overlap_comm: bool = True, allgather_partitions: bool = True, reduce_scatter: bool = True, allgather_bucket_size: int = 2e8, ...
Provides capabilities to run training using the DeepSpeed library, with training optimizations for large billion parameter models. `For more information: https://www.deepspeed.ai/`. .. warning:: ``DeepSpeedPlugin`` is in beta and subject to change. Defaults have been set to e...
def __init__( self, zero_optimization: bool = True, stage: int = 2, cpu_offload: bool = True, contiguous_gradients: bool = True, overlap_comm: bool = True, allgather_partitions: bool = True, reduce_scatter: bool = True, allgather_bucket_size: int =...
[ "def", "__init__", "(", "self", ",", "zero_optimization", ":", "bool", "=", "True", ",", "stage", ":", "int", "=", "2", ",", "cpu_offload", ":", "bool", "=", "True", ",", "contiguous_gradients", ":", "bool", "=", "True", ",", "overlap_comm", ":", "bool",...
[ 64, 4 ]
[ 178, 44 ]
python
en
['en', 'error', 'th']
False
_read_raw_data
(path)
Return the raw lines of the train and test files.
Return the raw lines of the train and test files.
def _read_raw_data(path): """ Return the raw lines of the train and test files. """ with zipfile.ZipFile(path) as datafile: return (datafile.read('ml-100k/ua.base').decode().split('\n'), datafile.read('ml-100k/ua.test').decode().split('\n'), datafile.read('ml-100...
[ "def", "_read_raw_data", "(", "path", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "path", ")", "as", "datafile", ":", "return", "(", "datafile", ".", "read", "(", "'ml-100k/ua.base'", ")", ".", "decode", "(", ")", ".", "split", "(", "'\\n'", ")",...
[ 10, 0 ]
[ 19, 85 ]
python
en
['en', 'error', 'th']
False
fetch_movielens
(data_home=None, indicator_features=True, genre_features=False, min_rating=0.0, download_if_missing=True)
Fetch the `Movielens 100k dataset <http://grouplens.org/datasets/movielens/100k/>`_. The dataset contains 100,000 interactions from 1000 users on 1700 movies, and is exhaustively described in its `README <http://files.grouplens.org/datasets/movielens/ml-100k-README.txt>`_. Parameters --------...
Fetch the `Movielens 100k dataset <http://grouplens.org/datasets/movielens/100k/>`_.
def fetch_movielens(data_home=None, indicator_features=True, genre_features=False, min_rating=0.0, download_if_missing=True): """ Fetch the `Movielens 100k dataset <http://grouplens.org/datasets/movielens/100k/>`_. The dataset contains 100,000 interactions from 1000 users on 1700 movies...
[ "def", "fetch_movielens", "(", "data_home", "=", "None", ",", "indicator_features", "=", "True", ",", "genre_features", "=", "False", ",", "min_rating", "=", "0.0", ",", "download_if_missing", "=", "True", ")", ":", "if", "not", "(", "indicator_features", "or"...
[ 106, 0 ]
[ 213, 15 ]
python
en
['en', 'error', 'th']
False
process_mmdet_results
(mmdet_results, cat_id=0)
Process mmdet results, and return a list of bboxes. :param mmdet_results: :param cat_id: category id (default: 0 for human) :return: a list of detected bounding boxes
Process mmdet results, and return a list of bboxes.
def process_mmdet_results(mmdet_results, cat_id=0): """Process mmdet results, and return a list of bboxes. :param mmdet_results: :param cat_id: category id (default: 0 for human) :return: a list of detected bounding boxes """ if isinstance(mmdet_results, tuple): det_results = mmdet_resu...
[ "def", "process_mmdet_results", "(", "mmdet_results", ",", "cat_id", "=", "0", ")", ":", "if", "isinstance", "(", "mmdet_results", ",", "tuple", ")", ":", "det_results", "=", "mmdet_results", "[", "0", "]", "else", ":", "det_results", "=", "mmdet_results", "...
[ 10, 0 ]
[ 21, 30 ]
python
en
['en', 'en', 'en']
True
main
()
Visualize the demo images. Using mmdet to detect the human.
Visualize the demo images.
def main(): """Visualize the demo images. Using mmdet to detect the human. """ parser = ArgumentParser() parser.add_argument('det_config', help='Config file for detection') parser.add_argument('det_checkpoint', help='Checkpoint file for detection') parser.add_argument('pose_config', help='C...
[ "def", "main", "(", ")", ":", "parser", "=", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'det_config'", ",", "help", "=", "'Config file for detection'", ")", "parser", ".", "add_argument", "(", "'det_checkpoint'", ",", "help", "=", "'Check...
[ 24, 0 ]
[ 135, 27 ]
python
en
['en', 'en', 'en']
True
_GenericTest.test_array_rank1_eq
(self)
Test two equal array of rank 1 are found equal.
Test two equal array of rank 1 are found equal.
def test_array_rank1_eq(self): """Test two equal array of rank 1 are found equal.""" a = np.array([1, 2]) b = np.array([1, 2]) self._test_equal(a, b)
[ "def", "test_array_rank1_eq", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "1", ",", "2", "]", ")", "b", "=", "np", ".", "array", "(", "[", "1", ",", "2", "]", ")", "self", ".", "_test_equal", "(", "a", ",", "b", ")" ]
[ 31, 4 ]
[ 36, 30 ]
python
en
['en', 'en', 'en']
True
_GenericTest.test_array_rank1_noteq
(self)
Test two different array of rank 1 are found not equal.
Test two different array of rank 1 are found not equal.
def test_array_rank1_noteq(self): """Test two different array of rank 1 are found not equal.""" a = np.array([1, 2]) b = np.array([2, 2]) self._test_not_equal(a, b)
[ "def", "test_array_rank1_noteq", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "1", ",", "2", "]", ")", "b", "=", "np", ".", "array", "(", "[", "2", ",", "2", "]", ")", "self", ".", "_test_not_equal", "(", "a", ",", "b", ")" ...
[ 38, 4 ]
[ 43, 34 ]
python
en
['en', 'en', 'en']
True
_GenericTest.test_array_rank2_eq
(self)
Test two equal array of rank 2 are found equal.
Test two equal array of rank 2 are found equal.
def test_array_rank2_eq(self): """Test two equal array of rank 2 are found equal.""" a = np.array([[1, 2], [3, 4]]) b = np.array([[1, 2], [3, 4]]) self._test_equal(a, b)
[ "def", "test_array_rank2_eq", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "[", "1", ",", "2", "]", ",", "[", "3", ",", "4", "]", "]", ")", "b", "=", "np", ".", "array", "(", "[", "[", "1", ",", "2", "]", ",", "[", "3"...
[ 45, 4 ]
[ 50, 30 ]
python
en
['en', 'en', 'en']
True
_GenericTest.test_array_diffshape
(self)
Test two arrays with different shapes are found not equal.
Test two arrays with different shapes are found not equal.
def test_array_diffshape(self): """Test two arrays with different shapes are found not equal.""" a = np.array([1, 2]) b = np.array([[1, 2], [1, 2]]) self._test_not_equal(a, b)
[ "def", "test_array_diffshape", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "1", ",", "2", "]", ")", "b", "=", "np", ".", "array", "(", "[", "[", "1", ",", "2", "]", ",", "[", "1", ",", "2", "]", "]", ")", "self", ".", ...
[ 52, 4 ]
[ 57, 34 ]
python
en
['en', 'en', 'en']
True
_GenericTest.test_objarray
(self)
Test object arrays.
Test object arrays.
def test_objarray(self): """Test object arrays.""" a = np.array([1, 1], dtype=object) self._test_equal(a, 1)
[ "def", "test_objarray", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "1", ",", "1", "]", ",", "dtype", "=", "object", ")", "self", ".", "_test_equal", "(", "a", ",", "1", ")" ]
[ 59, 4 ]
[ 62, 30 ]
python
en
['en', 'pl', 'en']
True
TestArrayEqual.test_generic_rank1
(self)
Test rank 1 array for all dtypes.
Test rank 1 array for all dtypes.
def test_generic_rank1(self): """Test rank 1 array for all dtypes.""" def foo(t): a = np.empty(2, t) a.fill(1) b = a.copy() c = a.copy() c.fill(0) self._test_equal(a, b) self._test_not_equal(c, b) # Test numeric...
[ "def", "test_generic_rank1", "(", "self", ")", ":", "def", "foo", "(", "t", ")", ":", "a", "=", "np", ".", "empty", "(", "2", ",", "t", ")", "a", ".", "fill", "(", "1", ")", "b", "=", "a", ".", "copy", "(", ")", "c", "=", "a", ".", "copy"...
[ 73, 4 ]
[ 90, 18 ]
python
en
['en', 'en', 'en']
True
TestArrayEqual.test_generic_rank3
(self)
Test rank 3 array for all dtypes.
Test rank 3 array for all dtypes.
def test_generic_rank3(self): """Test rank 3 array for all dtypes.""" def foo(t): a = np.empty((4, 2, 3), t) a.fill(1) b = a.copy() c = a.copy() c.fill(0) self._test_equal(a, b) self._test_not_equal(c, b) # Test...
[ "def", "test_generic_rank3", "(", "self", ")", ":", "def", "foo", "(", "t", ")", ":", "a", "=", "np", ".", "empty", "(", "(", "4", ",", "2", ",", "3", ")", ",", "t", ")", "a", ".", "fill", "(", "1", ")", "b", "=", "a", ".", "copy", "(", ...
[ 92, 4 ]
[ 109, 18 ]
python
en
['en', 'en', 'en']
True
TestArrayEqual.test_nan_array
(self)
Test arrays with nan values in them.
Test arrays with nan values in them.
def test_nan_array(self): """Test arrays with nan values in them.""" a = np.array([1, 2, np.nan]) b = np.array([1, 2, np.nan]) self._test_equal(a, b) c = np.array([1, 2, 3]) self._test_not_equal(c, b)
[ "def", "test_nan_array", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "1", ",", "2", ",", "np", ".", "nan", "]", ")", "b", "=", "np", ".", "array", "(", "[", "1", ",", "2", ",", "np", ".", "nan", "]", ")", "self", ".", ...
[ 111, 4 ]
[ 119, 34 ]
python
en
['en', 'en', 'en']
True
TestArrayEqual.test_string_arrays
(self)
Test two arrays with different shapes are found not equal.
Test two arrays with different shapes are found not equal.
def test_string_arrays(self): """Test two arrays with different shapes are found not equal.""" a = np.array(['floupi', 'floupa']) b = np.array(['floupi', 'floupa']) self._test_equal(a, b) c = np.array(['floupipi', 'floupa']) self._test_not_equal(c, b)
[ "def", "test_string_arrays", "(", "self", ")", ":", "a", "=", "np", ".", "array", "(", "[", "'floupi'", ",", "'floupa'", "]", ")", "b", "=", "np", ".", "array", "(", "[", "'floupi'", ",", "'floupa'", "]", ")", "self", ".", "_test_equal", "(", "a", ...
[ 121, 4 ]
[ 130, 34 ]
python
en
['en', 'en', 'en']
True
TestArrayEqual.test_recarrays
(self)
Test record arrays.
Test record arrays.
def test_recarrays(self): """Test record arrays.""" a = np.empty(2, [('floupi', float), ('floupa', float)]) a['floupi'] = [1, 2] a['floupa'] = [1, 2] b = a.copy() self._test_equal(a, b) c = np.empty(2, [('floupipi', float), ('floupa', float)]) c['floupip...
[ "def", "test_recarrays", "(", "self", ")", ":", "a", "=", "np", ".", "empty", "(", "2", ",", "[", "(", "'floupi'", ",", "float", ")", ",", "(", "'floupa'", ",", "float", ")", "]", ")", "a", "[", "'floupi'", "]", "=", "[", "1", ",", "2", "]", ...
[ 132, 4 ]
[ 148, 35 ]
python
en
['en', 'hu', 'en']
True
TestAlmostEqual.test_error_message
(self)
Check the message is formatted correctly for the decimal value. Also check the message when input includes inf or nan (gh12200)
Check the message is formatted correctly for the decimal value. Also check the message when input includes inf or nan (gh12200)
def test_error_message(self): """Check the message is formatted correctly for the decimal value. Also check the message when input includes inf or nan (gh12200)""" x = np.array([1.00000000001, 2.00000000002, 3.00003]) y = np.array([1.00000000002, 2.00000000003, 3.00004]) # Te...
[ "def", "test_error_message", "(", "self", ")", ":", "x", "=", "np", ".", "array", "(", "[", "1.00000000001", ",", "2.00000000002", ",", "3.00003", "]", ")", "y", "=", "np", ".", "array", "(", "[", "1.00000000002", ",", "2.00000000003", ",", "3.00004", ...
[ 512, 4 ]
[ 564, 61 ]
python
en
['en', 'en', 'en']
True
main
()
Provides option 'string' or 'file' to take input and prints the calculated SHA1 hash. unittest.main() has been commented because we probably dont want to run the test each time.
Provides option 'string' or 'file' to take input and prints the calculated SHA1 hash. unittest.main() has been commented because we probably dont want to run the test each time.
def main(): """ Provides option 'string' or 'file' to take input and prints the calculated SHA1 hash. unittest.main() has been commented because we probably dont want to run the test each time. """ # unittest.main() parser = argparse.ArgumentParser(description='Process some strings or files'...
[ "def", "main", "(", ")", ":", "# unittest.main()", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Process some strings or files'", ")", "parser", ".", "add_argument", "(", "'--string'", ",", "dest", "=", "'input_string'", ",", "defaul...
[ 100, 0 ]
[ 119, 44 ]
python
en
['en', 'error', 'th']
False
SHA1Hash.__init__
(self, data)
Inititates the variables data and h. h is a list of 5 8-digit Hexadecimal numbers corresponding to (1732584193, 4023233417, 2562383102, 271733878, 3285377520) respectively. We will start with this as a message digest. 0x is how you write Hexadecimal numbers in Python
Inititates the variables data and h. h is a list of 5 8-digit Hexadecimal numbers corresponding to (1732584193, 4023233417, 2562383102, 271733878, 3285377520) respectively. We will start with this as a message digest. 0x is how you write Hexadecimal numbers in Python
def __init__(self, data): """ Inititates the variables data and h. h is a list of 5 8-digit Hexadecimal numbers corresponding to (1732584193, 4023233417, 2562383102, 271733878, 3285377520) respectively. We will start with this as a message digest. 0x is how you write Hexadecimal ...
[ "def", "__init__", "(", "self", ",", "data", ")", ":", "self", ".", "data", "=", "data", "self", ".", "h", "=", "[", "0x67452301", ",", "0xEFCDAB89", ",", "0x98BADCFE", ",", "0x10325476", ",", "0xC3D2E1F0", "]" ]
[ 11, 4 ]
[ 19, 77 ]
python
en
['en', 'error', 'th']
False
SHA1Hash.rotate
(n, b)
Static method to be used inside other methods. Left rotates n by b.
Static method to be used inside other methods. Left rotates n by b.
def rotate(n, b): """ Static method to be used inside other methods. Left rotates n by b. """ return ((n << b) | (n >> (32 - b))) & 0xffffffff
[ "def", "rotate", "(", "n", ",", "b", ")", ":", "return", "(", "(", "n", "<<", "b", ")", "|", "(", "n", ">>", "(", "32", "-", "b", ")", ")", ")", "&", "0xffffffff" ]
[ 22, 4 ]
[ 26, 56 ]
python
en
['en', 'error', 'th']
False
SHA1Hash.padding
(self)
Pads the input message with zeros so that padded_data has 64 bytes or 512 bits
Pads the input message with zeros so that padded_data has 64 bytes or 512 bits
def padding(self): """ Pads the input message with zeros so that padded_data has 64 bytes or 512 bits """ padding = b'\x80' + b'\x00' * (63 - (len(self.data) + 8) % 64) padded_data = self.data + padding + struct.pack('>Q', 8 * len(self.data)) return padded_data
[ "def", "padding", "(", "self", ")", ":", "padding", "=", "b'\\x80'", "+", "b'\\x00'", "*", "(", "63", "-", "(", "len", "(", "self", ".", "data", ")", "+", "8", ")", "%", "64", ")", "padded_data", "=", "self", ".", "data", "+", "padding", "+", "...
[ 28, 4 ]
[ 34, 26 ]
python
en
['en', 'error', 'th']
False
SHA1Hash.split_blocks
(self)
Returns a list of bytestrings each of length 64
Returns a list of bytestrings each of length 64
def split_blocks(self): """ Returns a list of bytestrings each of length 64 """ return [self.padded_data[i:i + 64] for i in range(0, len(self.padded_data), 64)]
[ "def", "split_blocks", "(", "self", ")", ":", "return", "[", "self", ".", "padded_data", "[", "i", ":", "i", "+", "64", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "padded_data", ")", ",", "64", ")", "]" ]
[ 36, 4 ]
[ 40, 88 ]
python
en
['en', 'error', 'th']
False
SHA1Hash.expand_block
(self, block)
Takes a bytestring-block of length 64, unpacks it to a list of integers and returns a list of 80 integers pafter some bit operations
Takes a bytestring-block of length 64, unpacks it to a list of integers and returns a list of 80 integers pafter some bit operations
def expand_block(self, block): """ Takes a bytestring-block of length 64, unpacks it to a list of integers and returns a list of 80 integers pafter some bit operations """ w = list(struct.unpack('>16L', block)) + [0] * 64 for i in range(16, 80): w[i] = self.ro...
[ "def", "expand_block", "(", "self", ",", "block", ")", ":", "w", "=", "list", "(", "struct", ".", "unpack", "(", "'>16L'", ",", "block", ")", ")", "+", "[", "0", "]", "*", "64", "for", "i", "in", "range", "(", "16", ",", "80", ")", ":", "w", ...
[ 43, 4 ]
[ 51, 16 ]
python
en
['en', 'error', 'th']
False
SHA1Hash.final_hash
(self)
Calls all the other methods to process the input. Pads the data, then splits into blocks and then does a series of operations for each block (including expansion). For each block, the variable h that was initialized is copied to a,b,c,d,e and these 5 variables a,b,c,d,e undergo several ...
Calls all the other methods to process the input. Pads the data, then splits into blocks and then does a series of operations for each block (including expansion). For each block, the variable h that was initialized is copied to a,b,c,d,e and these 5 variables a,b,c,d,e undergo several ...
def final_hash(self): """ Calls all the other methods to process the input. Pads the data, then splits into blocks and then does a series of operations for each block (including expansion). For each block, the variable h that was initialized is copied to a,b,c,d,e and these 5 var...
[ "def", "final_hash", "(", "self", ")", ":", "self", ".", "padded_data", "=", "self", ".", "padding", "(", ")", "self", ".", "blocks", "=", "self", ".", "split_blocks", "(", ")", "for", "block", "in", "self", ".", "blocks", ":", "expanded_block", "=", ...
[ 53, 4 ]
[ 87, 53 ]
python
en
['en', 'error', 'th']
False
test_training_step_scalar
(tmpdir)
Tests that only training_step can be used
Tests that only training_step can be used
def test_training_step_scalar(tmpdir): """ Tests that only training_step can be used """ model = EvalModelTemplate() model.validation_step = None model.test_step = None model.training_step_end = None model.training_epoch_end = None model.validation_step = model.validation_step__dp ...
[ "def", "test_training_step_scalar", "(", "tmpdir", ")", ":", "model", "=", "EvalModelTemplate", "(", ")", "model", ".", "validation_step", "=", "None", "model", ".", "test_step", "=", "None", "model", ".", "training_step_end", "=", "None", "model", ".", "train...
[ 24, 0 ]
[ 57, 69 ]
python
en
['en', 'error', 'th']
False
R2Score.update
(self, preds: torch.Tensor, target: torch.Tensor)
Update state with predictions and targets. Args: preds: Predictions from model target: Ground truth values
Update state with predictions and targets.
def update(self, preds: torch.Tensor, target: torch.Tensor): """ Update state with predictions and targets. Args: preds: Predictions from model target: Ground truth values """ sum_squared_error, sum_error, residual, total = _r2score_update(preds, target) ...
[ "def", "update", "(", "self", ",", "preds", ":", "torch", ".", "Tensor", ",", "target", ":", "torch", ".", "Tensor", ")", ":", "sum_squared_error", ",", "sum_error", ",", "residual", ",", "total", "=", "_r2score_update", "(", "preds", ",", "target", ")",...
[ 119, 4 ]
[ 132, 27 ]
python
en
['en', 'error', 'th']
False
R2Score.compute
(self)
Computes r2 score over the metric states.
Computes r2 score over the metric states.
def compute(self) -> torch.Tensor: """ Computes r2 score over the metric states. """ return _r2score_compute( self.sum_squared_error, self.sum_error, self.residual, self.total, self.adjusted, self.multioutput )
[ "def", "compute", "(", "self", ")", "->", "torch", ".", "Tensor", ":", "return", "_r2score_compute", "(", "self", ".", "sum_squared_error", ",", "self", ".", "sum_error", ",", "self", ".", "residual", ",", "self", ".", "total", ",", "self", ".", "adjuste...
[ 134, 4 ]
[ 140, 9 ]
python
en
['en', 'error', 'th']
False
pytest_itemcollected
(item)
Check FPU precision mode was not changed during test collection. The clumsy way we do it here is mainly necessary because numpy still uses yield tests, which can execute code at test collection time.
Check FPU precision mode was not changed during test collection.
def pytest_itemcollected(item): """ Check FPU precision mode was not changed during test collection. The clumsy way we do it here is mainly necessary because numpy still uses yield tests, which can execute code at test collection time. """ global _old_fpu_mode mode = get_fpu_mode() ...
[ "def", "pytest_itemcollected", "(", "item", ")", ":", "global", "_old_fpu_mode", "mode", "=", "get_fpu_mode", "(", ")", "if", "_old_fpu_mode", "is", "None", ":", "_old_fpu_mode", "=", "mode", "elif", "mode", "!=", "_old_fpu_mode", ":", "_collect_results", "[", ...
[ 24, 0 ]
[ 40, 28 ]
python
en
['en', 'error', 'th']
False
check_fpu_mode
(request)
Check FPU precision mode was not changed during the test.
Check FPU precision mode was not changed during the test.
def check_fpu_mode(request): """ Check FPU precision mode was not changed during the test. """ old_mode = get_fpu_mode() yield new_mode = get_fpu_mode() if old_mode != new_mode: raise AssertionError("FPU precision mode changed from {0:#x} to {1:#x}" " du...
[ "def", "check_fpu_mode", "(", "request", ")", ":", "old_mode", "=", "get_fpu_mode", "(", ")", "yield", "new_mode", "=", "get_fpu_mode", "(", ")", "if", "old_mode", "!=", "new_mode", ":", "raise", "AssertionError", "(", "\"FPU precision mode changed from {0:#x} to {1...
[ 44, 0 ]
[ 61, 74 ]
python
en
['en', 'error', 'th']
False
get_tagname_or_hash
()
return tagname if exists else hash
return tagname if exists else hash
def get_tagname_or_hash(): """return tagname if exists else hash""" # get hash hash_cmd = ['git', 'rev-parse', '--short', 'HEAD'] hash_ = check_output(hash_cmd).decode('utf-8').strip() # get tagname tags_cmd = ['git', 'for-each-ref', '--points-at=HEAD', '--count=2', '--sort=-version:refname', '...
[ "def", "get_tagname_or_hash", "(", ")", ":", "# get hash", "hash_cmd", "=", "[", "'git'", ",", "'rev-parse'", ",", "'--short'", ",", "'HEAD'", "]", "hash_", "=", "check_output", "(", "hash_cmd", ")", ".", "decode", "(", "'utf-8'", ")", ".", "strip", "(", ...
[ 9, 0 ]
[ 23, 15 ]
python
en
['en', 'en', 'en']
True
test_get_model
(tmpdir)
Tests that `trainer.lightning_module` extracts the model correctly
Tests that `trainer.lightning_module` extracts the model correctly
def test_get_model(tmpdir): """ Tests that `trainer.lightning_module` extracts the model correctly """ model = TrainerGetModel() limit_train_batches = 2 trainer = Trainer( default_root_dir=tmpdir, limit_train_batches=limit_train_batches, limit_val_batches=2, max...
[ "def", "test_get_model", "(", "tmpdir", ")", ":", "model", "=", "TrainerGetModel", "(", ")", "limit_train_batches", "=", "2", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "limit_train_batches", "=", "limit_train_batches", ",", "limit_val...
[ 32, 0 ]
[ 46, 22 ]
python
en
['en', 'error', 'th']
False
test_get_model_ddp_cpu
(tmpdir)
Tests that `trainer.lightning_module` extracts the model correctly when using ddp on cpu
Tests that `trainer.lightning_module` extracts the model correctly when using ddp on cpu
def test_get_model_ddp_cpu(tmpdir): """ Tests that `trainer.lightning_module` extracts the model correctly when using ddp on cpu """ model = TrainerGetModel() limit_train_batches = 2 trainer = Trainer( default_root_dir=tmpdir, limit_train_batches=limit_train_batches, li...
[ "def", "test_get_model_ddp_cpu", "(", "tmpdir", ")", ":", "model", "=", "TrainerGetModel", "(", ")", "limit_train_batches", "=", "2", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "limit_train_batches", "=", "limit_train_batches", ",", "l...
[ 50, 0 ]
[ 66, 22 ]
python
en
['en', 'error', 'th']
False
test_get_model_gpu
(tmpdir)
Tests that `trainer.lightning_module` extracts the model correctly when using GPU
Tests that `trainer.lightning_module` extracts the model correctly when using GPU
def test_get_model_gpu(tmpdir): """ Tests that `trainer.lightning_module` extracts the model correctly when using GPU """ model = TrainerGetModel() limit_train_batches = 2 trainer = Trainer( default_root_dir=tmpdir, limit_train_batches=limit_train_batches, limit_val_bat...
[ "def", "test_get_model_gpu", "(", "tmpdir", ")", ":", "model", "=", "TrainerGetModel", "(", ")", "limit_train_batches", "=", "2", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "limit_train_batches", "=", "limit_train_batches", ",", "limit...
[ 70, 0 ]
[ 85, 22 ]
python
en
['en', 'error', 'th']
False
test_get_model_ddp_gpu
(tmpdir, args=None)
Tests that `trainer.lightning_module` extracts the model correctly when using GPU + ddp accelerators
Tests that `trainer.lightning_module` extracts the model correctly when using GPU + ddp accelerators
def test_get_model_ddp_gpu(tmpdir, args=None): """ Tests that `trainer.lightning_module` extracts the model correctly when using GPU + ddp accelerators """ model = TrainerGetModel() limit_train_batches = 2 trainer = Trainer( default_root_dir=tmpdir, limit_train_batches=limit_tr...
[ "def", "test_get_model_ddp_gpu", "(", "tmpdir", ",", "args", "=", "None", ")", ":", "model", "=", "TrainerGetModel", "(", ")", "limit_train_batches", "=", "2", "trainer", "=", "Trainer", "(", "default_root_dir", "=", "tmpdir", ",", "limit_train_batches", "=", ...
[ 91, 0 ]
[ 108, 12 ]
python
en
['en', 'error', 'th']
False
make_region
(*arg, **kw)
Instantiate a new :class:`.CacheRegion`. Currently, :func:`.make_region` is a passthrough to :class:`.CacheRegion`. See that class for constructor arguments.
Instantiate a new :class:`.CacheRegion`.
def make_region(*arg, **kw): """Instantiate a new :class:`.CacheRegion`. Currently, :func:`.make_region` is a passthrough to :class:`.CacheRegion`. See that class for constructor arguments. """ return CacheRegion(*arg, **kw)
[ "def", "make_region", "(", "*", "arg", ",", "*", "*", "kw", ")", ":", "return", "CacheRegion", "(", "*", "arg", ",", "*", "*", "kw", ")" ]
[ 1558, 0 ]
[ 1566, 34 ]
python
en
['en', 'pl', 'en']
True
RegionInvalidationStrategy.invalidate
(self, hard=True)
Region invalidation. :class:`.CacheRegion` propagated call. The default invalidation system works by setting a current timestamp (using ``time.time()``) to consider all older timestamps effectively invalidated.
Region invalidation.
def invalidate(self, hard=True): """Region invalidation. :class:`.CacheRegion` propagated call. The default invalidation system works by setting a current timestamp (using ``time.time()``) to consider all older timestamps effectively invalidated. """ raise NotI...
[ "def", "invalidate", "(", "self", ",", "hard", "=", "True", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 100, 4 ]
[ 110, 35 ]
python
en
['en', 'sv', 'en']
False
RegionInvalidationStrategy.is_hard_invalidated
(self, timestamp)
Check timestamp to determine if it was hard invalidated. :return: Boolean. True if ``timestamp`` is older than the last region invalidation time and region is invalidated in hard mode.
Check timestamp to determine if it was hard invalidated.
def is_hard_invalidated(self, timestamp): """Check timestamp to determine if it was hard invalidated. :return: Boolean. True if ``timestamp`` is older than the last region invalidation time and region is invalidated in hard mode. """ raise NotImplementedError()
[ "def", "is_hard_invalidated", "(", "self", ",", "timestamp", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 112, 4 ]
[ 121, 35 ]
python
en
['en', 'en', 'en']
True
RegionInvalidationStrategy.is_soft_invalidated
(self, timestamp)
Check timestamp to determine if it was soft invalidated. :return: Boolean. True if ``timestamp`` is older than the last region invalidation time and region is invalidated in soft mode.
Check timestamp to determine if it was soft invalidated.
def is_soft_invalidated(self, timestamp): """Check timestamp to determine if it was soft invalidated. :return: Boolean. True if ``timestamp`` is older than the last region invalidation time and region is invalidated in soft mode. """ raise NotImplementedError()
[ "def", "is_soft_invalidated", "(", "self", ",", "timestamp", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 123, 4 ]
[ 132, 35 ]
python
en
['en', 'en', 'en']
True
RegionInvalidationStrategy.is_invalidated
(self, timestamp)
Check timestamp to determine if it was invalidated. :return: Boolean. True if ``timestamp`` is older than the last region invalidation time.
Check timestamp to determine if it was invalidated.
def is_invalidated(self, timestamp): """Check timestamp to determine if it was invalidated. :return: Boolean. True if ``timestamp`` is older than the last region invalidation time. """ raise NotImplementedError()
[ "def", "is_invalidated", "(", "self", ",", "timestamp", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 134, 4 ]
[ 142, 35 ]
python
en
['en', 'en', 'en']
True
RegionInvalidationStrategy.was_soft_invalidated
(self)
Indicate the region was invalidated in soft mode. :return: Boolean. True if region was invalidated in soft mode.
Indicate the region was invalidated in soft mode.
def was_soft_invalidated(self): """Indicate the region was invalidated in soft mode. :return: Boolean. True if region was invalidated in soft mode. """ raise NotImplementedError()
[ "def", "was_soft_invalidated", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 144, 4 ]
[ 151, 35 ]
python
en
['en', 'en', 'en']
True
RegionInvalidationStrategy.was_hard_invalidated
(self)
Indicate the region was invalidated in hard mode. :return: Boolean. True if region was invalidated in hard mode.
Indicate the region was invalidated in hard mode.
def was_hard_invalidated(self): """Indicate the region was invalidated in hard mode. :return: Boolean. True if region was invalidated in hard mode. """ raise NotImplementedError()
[ "def", "was_hard_invalidated", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 153, 4 ]
[ 160, 35 ]
python
en
['en', 'en', 'en']
True
CacheRegion.__init__
( self, name=None, function_key_generator=function_key_generator, function_multi_key_generator=function_multi_key_generator, key_mangler=None, async_creation_runner=None, )
Construct a new :class:`.CacheRegion`.
Construct a new :class:`.CacheRegion`.
def __init__( self, name=None, function_key_generator=function_key_generator, function_multi_key_generator=function_multi_key_generator, key_mangler=None, async_creation_runner=None, ): """Construct a new :class:`.CacheRegion`.""" ...
[ "def", "__init__", "(", "self", ",", "name", "=", "None", ",", "function_key_generator", "=", "function_key_generator", ",", "function_multi_key_generator", "=", "function_multi_key_generator", ",", "key_mangler", "=", "None", ",", "async_creation_runner", "=", "None", ...
[ 329, 4 ]
[ 343, 63 ]
python
en
['en', 'lb', 'en']
True
CacheRegion.configure
( self, backend, expiration_time=None, arguments=None, _config_argument_dict=None, _config_prefix=None, wrap=None, replace_existing_backend=False, region_invalidator=None )
Configure a :class:`.CacheRegion`. The :class:`.CacheRegion` itself is returned. :param backend: Required. This is the name of the :class:`.CacheBackend` to use, and is resolved by loading the class from the ``dogpile.cache`` entrypoint. :param expiration_time: ...
Configure a :class:`.CacheRegion`.
def configure( self, backend, expiration_time=None, arguments=None, _config_argument_dict=None, _config_prefix=None, wrap=None, replace_existing_backend=False, region_invalidator=None ): """Configure a :class:`.C...
[ "def", "configure", "(", "self", ",", "backend", ",", "expiration_time", "=", "None", ",", "arguments", "=", "None", ",", "_config_argument_dict", "=", "None", ",", "_config_prefix", "=", "None", ",", "wrap", "=", "None", ",", "replace_existing_backend", "=", ...
[ 345, 4 ]
[ 449, 19 ]
python
en
['en', 'lb', 'it']
False
CacheRegion.wrap
(self, proxy)
Takes a ProxyBackend instance or class and wraps the attached backend.
Takes a ProxyBackend instance or class and wraps the attached backend.
def wrap(self, proxy): ''' Takes a ProxyBackend instance or class and wraps the attached backend. ''' # if we were passed a type rather than an instance then # initialize it. if type(proxy) == type: proxy = proxy() if not issubclass(type(proxy), ProxyBackend...
[ "def", "wrap", "(", "self", ",", "proxy", ")", ":", "# if we were passed a type rather than an instance then", "# initialize it.", "if", "type", "(", "proxy", ")", "==", "type", ":", "proxy", "=", "proxy", "(", ")", "if", "not", "issubclass", "(", "type", "(",...
[ 451, 4 ]
[ 464, 47 ]
python
en
['en', 'en', 'en']
True
CacheRegion.actual_backend
(self)
Return the ultimate backend underneath any proxies. The backend might be the result of one or more ``proxy.wrap`` applications. If so, derive the actual underlying backend. .. versionadded:: 0.6.6
Return the ultimate backend underneath any proxies.
def actual_backend(self): """Return the ultimate backend underneath any proxies. The backend might be the result of one or more ``proxy.wrap`` applications. If so, derive the actual underlying backend. .. versionadded:: 0.6.6 """ if self._actual_backend is None: ...
[ "def", "actual_backend", "(", "self", ")", ":", "if", "self", ".", "_actual_backend", "is", "None", ":", "_backend", "=", "self", ".", "backend", "while", "hasattr", "(", "_backend", ",", "'proxied'", ")", ":", "_backend", "=", "_backend", ".", "proxied", ...
[ 491, 4 ]
[ 505, 35 ]
python
en
['en', 'en', 'en']
True