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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
polyadd | (c1, c2) |
Add one polynomial to another.
Returns the sum of two polynomials `c1` + `c2`. The arguments are
sequences of coefficients from lowest order term to highest, i.e.,
[1,2,3] represents the polynomial ``1 + 2*x + 3*x**2``.
Parameters
----------
c1, c2 : array_like
1-D arrays of poly... |
Add one polynomial to another. | def polyadd(c1, c2):
"""
Add one polynomial to another.
Returns the sum of two polynomials `c1` + `c2`. The arguments are
sequences of coefficients from lowest order term to highest, i.e.,
[1,2,3] represents the polynomial ``1 + 2*x + 3*x**2``.
Parameters
----------
c1, c2 : array_lik... | [
"def",
"polyadd",
"(",
"c1",
",",
"c2",
")",
":",
"return",
"pu",
".",
"_add",
"(",
"c1",
",",
"c2",
")"
] | [
193,
0
] | [
226,
26
] | python | en | ['en', 'error', 'th'] | False |
polysub | (c1, c2) |
Subtract one polynomial from another.
Returns the difference of two polynomials `c1` - `c2`. The arguments
are sequences of coefficients from lowest order term to highest, i.e.,
[1,2,3] represents the polynomial ``1 + 2*x + 3*x**2``.
Parameters
----------
c1, c2 : array_like
1-D ... |
Subtract one polynomial from another. | def polysub(c1, c2):
"""
Subtract one polynomial from another.
Returns the difference of two polynomials `c1` - `c2`. The arguments
are sequences of coefficients from lowest order term to highest, i.e.,
[1,2,3] represents the polynomial ``1 + 2*x + 3*x**2``.
Parameters
----------
c1, ... | [
"def",
"polysub",
"(",
"c1",
",",
"c2",
")",
":",
"return",
"pu",
".",
"_sub",
"(",
"c1",
",",
"c2",
")"
] | [
229,
0
] | [
263,
26
] | python | en | ['en', 'error', 'th'] | False |
polymulx | (c) | Multiply a polynomial by x.
Multiply the polynomial `c` by x, where x is the independent
variable.
Parameters
----------
c : array_like
1-D array of polynomial coefficients ordered from low to
high.
Returns
-------
out : ndarray
Array representing the result o... | Multiply a polynomial by x. | def polymulx(c):
"""Multiply a polynomial by x.
Multiply the polynomial `c` by x, where x is the independent
variable.
Parameters
----------
c : array_like
1-D array of polynomial coefficients ordered from low to
high.
Returns
-------
out : ndarray
Array r... | [
"def",
"polymulx",
"(",
"c",
")",
":",
"# c is a trimmed copy",
"[",
"c",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c",
"]",
")",
"# The zero series needs special treatment",
"if",
"len",
"(",
"c",
")",
"==",
"1",
"and",
"c",
"[",
"0",
"]",
"==",
... | [
266,
0
] | [
303,
14
] | python | en | ['en', 'en', 'en'] | True |
polymul | (c1, c2) |
Multiply one polynomial by another.
Returns the product of two polynomials `c1` * `c2`. The arguments are
sequences of coefficients, from lowest order term to highest, e.g.,
[1,2,3] represents the polynomial ``1 + 2*x + 3*x**2.``
Parameters
----------
c1, c2 : array_like
1-D arra... |
Multiply one polynomial by another. | def polymul(c1, c2):
"""
Multiply one polynomial by another.
Returns the product of two polynomials `c1` * `c2`. The arguments are
sequences of coefficients, from lowest order term to highest, e.g.,
[1,2,3] represents the polynomial ``1 + 2*x + 3*x**2.``
Parameters
----------
c1, c2 :... | [
"def",
"polymul",
"(",
"c1",
",",
"c2",
")",
":",
"# c1, c2 are trimmed copies",
"[",
"c1",
",",
"c2",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c1",
",",
"c2",
"]",
")",
"ret",
"=",
"np",
".",
"convolve",
"(",
"c1",
",",
"c2",
")",
"return",
... | [
306,
0
] | [
341,
26
] | python | en | ['en', 'error', 'th'] | False |
polydiv | (c1, c2) |
Divide one polynomial by another.
Returns the quotient-with-remainder of two polynomials `c1` / `c2`.
The arguments are sequences of coefficients, from lowest order term
to highest, e.g., [1,2,3] represents ``1 + 2*x + 3*x**2``.
Parameters
----------
c1, c2 : array_like
1-D arrays... |
Divide one polynomial by another. | def polydiv(c1, c2):
"""
Divide one polynomial by another.
Returns the quotient-with-remainder of two polynomials `c1` / `c2`.
The arguments are sequences of coefficients, from lowest order term
to highest, e.g., [1,2,3] represents ``1 + 2*x + 3*x**2``.
Parameters
----------
c1, c2 : a... | [
"def",
"polydiv",
"(",
"c1",
",",
"c2",
")",
":",
"# c1, c2 are trimmed copies",
"[",
"c1",
",",
"c2",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c1",
",",
"c2",
"]",
")",
"if",
"c2",
"[",
"-",
"1",
"]",
"==",
"0",
":",
"raise",
"ZeroDivisionEr... | [
344,
0
] | [
399,
49
] | python | en | ['en', 'error', 'th'] | False |
polypow | (c, pow, maxpower=None) | Raise a polynomial to a power.
Returns the polynomial `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 ``1 + 2*x + 3*x**2.``
Parameters
----------
c : array_like
1-D array of array of series coefficient... | Raise a polynomial to a power. | def polypow(c, pow, maxpower=None):
"""Raise a polynomial to a power.
Returns the polynomial `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 ``1 + 2*x + 3*x**2.``
Parameters
----------
c : array_like
... | [
"def",
"polypow",
"(",
"c",
",",
"pow",
",",
"maxpower",
"=",
"None",
")",
":",
"# note: this is more efficient than `pu._pow(polymul, c1, c2)`, as it",
"# avoids calling `as_series` repeatedly",
"return",
"pu",
".",
"_pow",
"(",
"np",
".",
"convolve",
",",
"c",
",",
... | [
402,
0
] | [
438,
49
] | python | en | ['en', 'en', 'en'] | True |
polyder | (c, m=1, scl=1, axis=0) |
Differentiate a polynomial.
Returns the polynomial 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 alon... |
Differentiate a polynomial. | def polyder(c, m=1, scl=1, axis=0):
"""
Differentiate a polynomial.
Returns the polynomial 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 o... | [
"def",
"polyder",
"(",
"c",
",",
"m",
"=",
"1",
",",
"scl",
"=",
"1",
",",
"axis",
"=",
"0",
")",
":",
"c",
"=",
"np",
".",
"array",
"(",
"c",
",",
"ndmin",
"=",
"1",
",",
"copy",
"=",
"1",
")",
"if",
"c",
".",
"dtype",
".",
"char",
"in... | [
441,
0
] | [
520,
12
] | python | en | ['en', 'error', 'th'] | False |
polyint | (c, m=1, k=[], lbnd=0, scl=1, axis=0) |
Integrate a polynomial.
Returns the polynomial 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. ("Buyer
b... |
Integrate a polynomial. | def polyint(c, m=1, k=[], lbnd=0, scl=1, axis=0):
"""
Integrate a polynomial.
Returns the polynomial 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 ... | [
"def",
"polyint",
"(",
"c",
",",
"m",
"=",
"1",
",",
"k",
"=",
"[",
"]",
",",
"lbnd",
"=",
"0",
",",
"scl",
"=",
"1",
",",
"axis",
"=",
"0",
")",
":",
"c",
"=",
"np",
".",
"array",
"(",
"c",
",",
"ndmin",
"=",
"1",
",",
"copy",
"=",
"... | [
523,
0
] | [
639,
12
] | python | en | ['en', 'error', 'th'] | False |
polyval | (x, c, tensor=True) |
Evaluate a polynomial at points x.
If `c` is of length `n + 1`, this function returns the value
.. math:: p(x) = c_0 + c_1 * x + ... + c_n * x^n
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 case, either `x`
or its ... |
Evaluate a polynomial at points x. | def polyval(x, c, tensor=True):
"""
Evaluate a polynomial at points x.
If `c` is of length `n + 1`, this function returns the value
.. math:: p(x) = c_0 + c_1 * x + ... + c_n * x^n
The parameter `x` is converted to an array only if it is a tuple or a
list, otherwise it is treated as a scalar.... | [
"def",
"polyval",
"(",
"x",
",",
"c",
",",
"tensor",
"=",
"True",
")",
":",
"c",
"=",
"np",
".",
"array",
"(",
"c",
",",
"ndmin",
"=",
"1",
",",
"copy",
"=",
"0",
")",
"if",
"c",
".",
"dtype",
".",
"char",
"in",
"'?bBhHiIlLqQpP'",
":",
"# ast... | [
642,
0
] | [
735,
13
] | python | en | ['en', 'error', 'th'] | False |
polyvalfromroots | (x, r, tensor=True) |
Evaluate a polynomial specified by its roots at points x.
If `r` is of length `N`, this function returns the value
.. math:: p(x) = \\prod_{n=1}^{N} (x - r_n)
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 case, either `... |
Evaluate a polynomial specified by its roots at points x. | def polyvalfromroots(x, r, tensor=True):
"""
Evaluate a polynomial specified by its roots at points x.
If `r` is of length `N`, this function returns the value
.. math:: p(x) = \\prod_{n=1}^{N} (x - r_n)
The parameter `x` is converted to an array only if it is a tuple or a
list, otherwise it ... | [
"def",
"polyvalfromroots",
"(",
"x",
",",
"r",
",",
"tensor",
"=",
"True",
")",
":",
"r",
"=",
"np",
".",
"array",
"(",
"r",
",",
"ndmin",
"=",
"1",
",",
"copy",
"=",
"0",
")",
"if",
"r",
".",
"dtype",
".",
"char",
"in",
"'?bBhHiIlLqQpP'",
":",... | [
738,
0
] | [
823,
33
] | python | en | ['en', 'error', 'th'] | False |
polyval2d | (x, y, c) |
Evaluate a 2-D polynomial at points (x, y).
This function returns the value
.. math:: p(x,y) = \\sum_{i,j} c_{i,j} * x^i * y^j
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 same shape afte... |
Evaluate a 2-D polynomial at points (x, y). | def polyval2d(x, y, c):
"""
Evaluate a 2-D polynomial at points (x, y).
This function returns the value
.. math:: p(x,y) = \\sum_{i,j} c_{i,j} * x^i * y^j
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
... | [
"def",
"polyval2d",
"(",
"x",
",",
"y",
",",
"c",
")",
":",
"return",
"pu",
".",
"_valnd",
"(",
"polyval",
",",
"c",
",",
"x",
",",
"y",
")"
] | [
826,
0
] | [
873,
38
] | python | en | ['en', 'error', 'th'] | False |
polygrid2d | (x, y, c) |
Evaluate a 2-D polynomial on the Cartesian product of x and y.
This function returns the values:
.. math:: p(a,b) = \\sum_{i,j} c_{i,j} * a^i * b^j
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
`x` in the ... |
Evaluate a 2-D polynomial on the Cartesian product of x and y. | def polygrid2d(x, y, c):
"""
Evaluate a 2-D polynomial on the Cartesian product of x and y.
This function returns the values:
.. math:: p(a,b) = \\sum_{i,j} c_{i,j} * a^i * b^j
where the points `(a, b)` consist of all pairs formed by taking
`a` from `x` and `b` from `y`. The resulting points ... | [
"def",
"polygrid2d",
"(",
"x",
",",
"y",
",",
"c",
")",
":",
"return",
"pu",
".",
"_gridnd",
"(",
"polyval",
",",
"c",
",",
"x",
",",
"y",
")"
] | [
876,
0
] | [
926,
39
] | python | en | ['en', 'error', 'th'] | False |
polyval3d | (x, y, z, c) |
Evaluate a 3-D polynomial at points (x, y, z).
This function returns the values:
.. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * x^i * y^j * z^k
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 and
they must h... |
Evaluate a 3-D polynomial at points (x, y, z). | def polyval3d(x, y, z, c):
"""
Evaluate a 3-D polynomial at points (x, y, z).
This function returns the values:
.. math:: p(x,y,z) = \\sum_{i,j,k} c_{i,j,k} * x^i * y^j * z^k
The parameters `x`, `y`, and `z` are converted to arrays only if
they are tuples or a lists, otherwise they are treate... | [
"def",
"polyval3d",
"(",
"x",
",",
"y",
",",
"z",
",",
"c",
")",
":",
"return",
"pu",
".",
"_valnd",
"(",
"polyval",
",",
"c",
",",
"x",
",",
"y",
",",
"z",
")"
] | [
929,
0
] | [
977,
41
] | python | en | ['en', 'error', 'th'] | False |
polygrid3d | (x, y, z, c) |
Evaluate a 3-D polynomial 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} * a^i * b^j * c^k
where the points `(a, b, c)` consist of all triples formed by taking
`a` from `x`, `b` from `y`, and `c` from `z`. The resulting poin... |
Evaluate a 3-D polynomial on the Cartesian product of x, y and z. | def polygrid3d(x, y, z, c):
"""
Evaluate a 3-D polynomial 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} * a^i * b^j * c^k
where the points `(a, b, c)` consist of all triples formed by taking
`a` from `x`, `b` from `y`, a... | [
"def",
"polygrid3d",
"(",
"x",
",",
"y",
",",
"z",
",",
"c",
")",
":",
"return",
"pu",
".",
"_gridnd",
"(",
"polyval",
",",
"c",
",",
"x",
",",
"y",
",",
"z",
")"
] | [
980,
0
] | [
1033,
42
] | python | en | ['en', 'error', 'th'] | False |
polyvander | (x, deg) | Vandermonde matrix of given degree.
Returns the Vandermonde matrix of degree `deg` and sample points
`x`. The Vandermonde matrix is defined by
.. math:: V[..., i] = x^i,
where `0 <= i <= deg`. The leading indices of `V` index the elements of
`x` and the last index is the power of `x`.
If `c`... | Vandermonde matrix of given degree. | def polyvander(x, deg):
"""Vandermonde matrix of given degree.
Returns the Vandermonde matrix of degree `deg` and sample points
`x`. The Vandermonde matrix is defined by
.. math:: V[..., i] = x^i,
where `0 <= i <= deg`. The leading indices of `V` index the elements of
`x` and the last index i... | [
"def",
"polyvander",
"(",
"x",
",",
"deg",
")",
":",
"ideg",
"=",
"pu",
".",
"_deprecate_as_int",
"(",
"deg",
",",
"\"deg\"",
")",
"if",
"ideg",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"deg must be non-negative\"",
")",
"x",
"=",
"np",
".",
"array... | [
1036,
0
] | [
1087,
32
] | python | en | ['nl', 'it', 'en'] | False |
polyvander2d | (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] = x^i * y^j,
where `0 <= i <= deg[0]` and `0 <= j <= deg[1]`. The leading indices of
`V` ... | Pseudo-Vandermonde matrix of given degrees. | def polyvander2d(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] = x^i * y^j,
where `0 <= i <= deg[0]` and `0 <= j <= deg[... | [
"def",
"polyvander2d",
"(",
"x",
",",
"y",
",",
"deg",
")",
":",
"return",
"pu",
".",
"_vander2d",
"(",
"polyvander",
",",
"x",
",",
"y",
",",
"deg",
")"
] | [
1090,
0
] | [
1135,
46
] | python | ca | ['nl', 'ca', 'en'] | False |
polyvander3d | (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 The pseudo-Vandermonde matrix is defined by
.. math:: V[..., (m+1)(n+1)i + (n+1)j + k] = x^i * y^j * z^k,
where `... | Pseudo-Vandermonde matrix of given degrees. | def polyvander3d(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 The pseudo-Vandermonde matrix is defined by
.. math:: V[..., (m+1)(n+1)i + (n+1... | [
"def",
"polyvander3d",
"(",
"x",
",",
"y",
",",
"z",
",",
"deg",
")",
":",
"return",
"pu",
".",
"_vander3d",
"(",
"polyvander",
",",
"x",
",",
"y",
",",
"z",
",",
"deg",
")"
] | [
1138,
0
] | [
1189,
49
] | python | ca | ['nl', 'ca', 'en'] | False |
polyfit | (x, y, deg, rcond=None, full=False, w=None) |
Least-squares fit of a polynomial to data.
Return the coefficients of a polynomial 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 `y`, a... |
Least-squares fit of a polynomial to data. | def polyfit(x, y, deg, rcond=None, full=False, w=None):
"""
Least-squares fit of a polynomial to data.
Return the coefficients of a polynomial 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` i... | [
"def",
"polyfit",
"(",
"x",
",",
"y",
",",
"deg",
",",
"rcond",
"=",
"None",
",",
"full",
"=",
"False",
",",
"w",
"=",
"None",
")",
":",
"return",
"pu",
".",
"_fit",
"(",
"polyvander",
",",
"x",
",",
"y",
",",
"deg",
",",
"rcond",
",",
"full"... | [
1192,
0
] | [
1335,
57
] | python | en | ['en', 'error', 'th'] | False |
polycompanion | (c) |
Return the companion matrix of c.
The companion matrix for power series cannot be made symmetric by
scaling the basis, so this function differs from those for the
orthogonal polynomials.
Parameters
----------
c : array_like
1-D array of polynomial coefficients ordered from low to ... |
Return the companion matrix of c. | def polycompanion(c):
"""
Return the companion matrix of c.
The companion matrix for power series cannot be made symmetric by
scaling the basis, so this function differs from those for the
orthogonal polynomials.
Parameters
----------
c : array_like
1-D array of polynomial coef... | [
"def",
"polycompanion",
"(",
"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 1... | [
1338,
0
] | [
1375,
14
] | python | en | ['en', 'error', 'th'] | False |
polyroots | (c) |
Compute the roots of a polynomial.
Return the roots (a.k.a. "zeros") of the polynomial
.. math:: p(x) = \\sum_i c[i] * x^i.
Parameters
----------
c : 1-D array_like
1-D array of polynomial coefficients.
Returns
-------
out : ndarray
Array of the roots of the poly... |
Compute the roots of a polynomial. | def polyroots(c):
"""
Compute the roots of a polynomial.
Return the roots (a.k.a. "zeros") of the polynomial
.. math:: p(x) = \\sum_i c[i] * x^i.
Parameters
----------
c : 1-D array_like
1-D array of polynomial coefficients.
Returns
-------
out : ndarray
Array... | [
"def",
"polyroots",
"(",
"c",
")",
":",
"# c is a trimmed copy",
"[",
"c",
"]",
"=",
"pu",
".",
"as_series",
"(",
"[",
"c",
"]",
")",
"if",
"len",
"(",
"c",
")",
"<",
"2",
":",
"return",
"np",
".",
"array",
"(",
"[",
"]",
",",
"dtype",
"=",
"... | [
1378,
0
] | [
1434,
12
] | python | en | ['en', 'error', 'th'] | False |
_nan_mask | (a, out=None) |
Parameters
----------
a : array-like
Input array with at least 1 dimension.
out : ndarray, optional
Alternate output array in which to place the result. The default
is ``None``; if provided, it must have the same shape as the
expected output and will prevent the allocat... |
Parameters
----------
a : array-like
Input array with at least 1 dimension.
out : ndarray, optional
Alternate output array in which to place the result. The default
is ``None``; if provided, it must have the same shape as the
expected output and will prevent the allocat... | def _nan_mask(a, out=None):
"""
Parameters
----------
a : array-like
Input array with at least 1 dimension.
out : ndarray, optional
Alternate output array in which to place the result. The default
is ``None``; if provided, it must have the same shape as the
expected ... | [
"def",
"_nan_mask",
"(",
"a",
",",
"out",
"=",
"None",
")",
":",
"# we assume that a is an array for this private function",
"if",
"a",
".",
"dtype",
".",
"kind",
"not",
"in",
"'fc'",
":",
"return",
"True",
"y",
"=",
"np",
".",
"isnan",
"(",
"a",
",",
"o... | [
42,
0
] | [
67,
12
] | python | en | ['en', 'error', 'th'] | False |
_replace_nan | (a, val) |
If `a` is of inexact type, make a copy of `a`, replace NaNs with
the `val` value, and return the copy together with a boolean mask
marking the locations where NaNs were present. If `a` is not of
inexact type, do nothing and return `a` together with a mask of None.
Note that scalars will end up as ... |
If `a` is of inexact type, make a copy of `a`, replace NaNs with
the `val` value, and return the copy together with a boolean mask
marking the locations where NaNs were present. If `a` is not of
inexact type, do nothing and return `a` together with a mask of None. | def _replace_nan(a, val):
"""
If `a` is of inexact type, make a copy of `a`, replace NaNs with
the `val` value, and return the copy together with a boolean mask
marking the locations where NaNs were present. If `a` is not of
inexact type, do nothing and return `a` together with a mask of None.
... | [
"def",
"_replace_nan",
"(",
"a",
",",
"val",
")",
":",
"a",
"=",
"np",
".",
"array",
"(",
"a",
",",
"subok",
"=",
"True",
",",
"copy",
"=",
"True",
")",
"if",
"a",
".",
"dtype",
"==",
"np",
".",
"object_",
":",
"# object arrays do not support `isnan`... | [
69,
0
] | [
110,
18
] | python | en | ['en', 'error', 'th'] | False |
_copyto | (a, val, mask) |
Replace values in `a` with NaN where `mask` is True. This differs from
copyto in that it will deal with the case where `a` is a numpy scalar.
Parameters
----------
a : ndarray or numpy scalar
Array or numpy scalar some of whose values are to be replaced
by val.
val : numpy sca... |
Replace values in `a` with NaN where `mask` is True. This differs from
copyto in that it will deal with the case where `a` is a numpy scalar. | def _copyto(a, val, mask):
"""
Replace values in `a` with NaN where `mask` is True. This differs from
copyto in that it will deal with the case where `a` is a numpy scalar.
Parameters
----------
a : ndarray or numpy scalar
Array or numpy scalar some of whose values are to be replaced
... | [
"def",
"_copyto",
"(",
"a",
",",
"val",
",",
"mask",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"np",
".",
"ndarray",
")",
":",
"np",
".",
"copyto",
"(",
"a",
",",
"val",
",",
"where",
"=",
"mask",
",",
"casting",
"=",
"'unsafe'",
")",
"else"... | [
113,
0
] | [
139,
12
] | python | en | ['en', 'error', 'th'] | False |
_remove_nan_1d | (arr1d, overwrite_input=False) |
Equivalent to arr1d[~arr1d.isnan()], but in a different order
Presumably faster as it incurs fewer copies
Parameters
----------
arr1d : ndarray
Array to remove nans from
overwrite_input : bool
True if `arr1d` can be modified in place
Returns
-------
res : ndarray
... |
Equivalent to arr1d[~arr1d.isnan()], but in a different order | def _remove_nan_1d(arr1d, overwrite_input=False):
"""
Equivalent to arr1d[~arr1d.isnan()], but in a different order
Presumably faster as it incurs fewer copies
Parameters
----------
arr1d : ndarray
Array to remove nans from
overwrite_input : bool
True if `arr1d` can be modi... | [
"def",
"_remove_nan_1d",
"(",
"arr1d",
",",
"overwrite_input",
"=",
"False",
")",
":",
"c",
"=",
"np",
".",
"isnan",
"(",
"arr1d",
")",
"s",
"=",
"np",
".",
"nonzero",
"(",
"c",
")",
"[",
"0",
"]",
"if",
"s",
".",
"size",
"==",
"arr1d",
".",
"s... | [
142,
0
] | [
180,
36
] | python | en | ['en', 'error', 'th'] | False |
_divide_by_count | (a, b, out=None) |
Compute a/b ignoring invalid results. If `a` is an array the division
is done in place. If `a` is a scalar, then its type is preserved in the
output. If out is None, then then a is used instead so that the
division is in place. Note that this is only called with `a` an inexact
type.
Parameters... |
Compute a/b ignoring invalid results. If `a` is an array the division
is done in place. If `a` is a scalar, then its type is preserved in the
output. If out is None, then then a is used instead so that the
division is in place. Note that this is only called with `a` an inexact
type. | def _divide_by_count(a, b, out=None):
"""
Compute a/b ignoring invalid results. If `a` is an array the division
is done in place. If `a` is a scalar, then its type is preserved in the
output. If out is None, then then a is used instead so that the
division is in place. Note that this is only called ... | [
"def",
"_divide_by_count",
"(",
"a",
",",
"b",
",",
"out",
"=",
"None",
")",
":",
"with",
"np",
".",
"errstate",
"(",
"invalid",
"=",
"'ignore'",
",",
"divide",
"=",
"'ignore'",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"np",
".",
"ndarray",
")"... | [
183,
0
] | [
221,
65
] | python | en | ['en', 'error', 'th'] | False |
nanmin | (a, axis=None, out=None, keepdims=np._NoValue) |
Return minimum of an array or minimum along an axis, ignoring any NaNs.
When all-NaN slices are encountered a ``RuntimeWarning`` is raised and
Nan is returned for that slice.
Parameters
----------
a : array_like
Array containing numbers whose minimum is desired. If `a` is not an
... |
Return minimum of an array or minimum along an axis, ignoring any NaNs.
When all-NaN slices are encountered a ``RuntimeWarning`` is raised and
Nan is returned for that slice. | def nanmin(a, axis=None, out=None, keepdims=np._NoValue):
"""
Return minimum of an array or minimum along an axis, ignoring any NaNs.
When all-NaN slices are encountered a ``RuntimeWarning`` is raised and
Nan is returned for that slice.
Parameters
----------
a : array_like
Array con... | [
"def",
"nanmin",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"keepdims",
"is",
"not",
"np",
".",
"_NoValue",
":",
"kwargs",
"[",
"'keepdims'",
... | [
229,
0
] | [
336,
14
] | python | en | ['en', 'error', 'th'] | False |
nanmax | (a, axis=None, out=None, keepdims=np._NoValue) |
Return the maximum of an array or maximum along an axis, ignoring any
NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is
raised and NaN is returned for that slice.
Parameters
----------
a : array_like
Array containing numbers whose maximum is desired. If `a` is not an
... |
Return the maximum of an array or maximum along an axis, ignoring any
NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is
raised and NaN is returned for that slice. | def nanmax(a, axis=None, out=None, keepdims=np._NoValue):
"""
Return the maximum of an array or maximum along an axis, ignoring any
NaNs. When all-NaN slices are encountered a ``RuntimeWarning`` is
raised and NaN is returned for that slice.
Parameters
----------
a : array_like
Arra... | [
"def",
"nanmax",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"keepdims",
"is",
"not",
"np",
".",
"_NoValue",
":",
"kwargs",
"[",
"'keepdims'",
... | [
344,
0
] | [
451,
14
] | python | en | ['en', 'error', 'th'] | False |
nanargmin | (a, axis=None) |
Return the indices of the minimum values in the specified axis ignoring
NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the results
cannot be trusted if a slice contains only NaNs and Infs.
Parameters
----------
a : array_like
Input data.
axis : int, optional
Ax... |
Return the indices of the minimum values in the specified axis ignoring
NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the results
cannot be trusted if a slice contains only NaNs and Infs. | def nanargmin(a, axis=None):
"""
Return the indices of the minimum values in the specified axis ignoring
NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the results
cannot be trusted if a slice contains only NaNs and Infs.
Parameters
----------
a : array_like
Input data.... | [
"def",
"nanargmin",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"a",
",",
"mask",
"=",
"_replace_nan",
"(",
"a",
",",
"np",
".",
"inf",
")",
"res",
"=",
"np",
".",
"argmin",
"(",
"a",
",",
"axis",
"=",
"axis",
")",
"if",
"mask",
"is",
"not"... | [
459,
0
] | [
500,
14
] | python | en | ['en', 'error', 'th'] | False |
nanargmax | (a, axis=None) |
Return the indices of the maximum values in the specified axis ignoring
NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the
results cannot be trusted if a slice contains only NaNs and -Infs.
Parameters
----------
a : array_like
Input data.
axis : int, optional
... |
Return the indices of the maximum values in the specified axis ignoring
NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the
results cannot be trusted if a slice contains only NaNs and -Infs. | def nanargmax(a, axis=None):
"""
Return the indices of the maximum values in the specified axis ignoring
NaNs. For all-NaN slices ``ValueError`` is raised. Warning: the
results cannot be trusted if a slice contains only NaNs and -Infs.
Parameters
----------
a : array_like
Input dat... | [
"def",
"nanargmax",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"a",
",",
"mask",
"=",
"_replace_nan",
"(",
"a",
",",
"-",
"np",
".",
"inf",
")",
"res",
"=",
"np",
".",
"argmax",
"(",
"a",
",",
"axis",
"=",
"axis",
")",
"if",
"mask",
"is",
... | [
508,
0
] | [
550,
14
] | python | en | ['en', 'error', 'th'] | False |
nansum | (a, axis=None, dtype=None, out=None, keepdims=np._NoValue) |
Return the sum of array elements over a given axis treating Not a
Numbers (NaNs) as zero.
In NumPy versions <= 1.9.0 Nan is returned for slices that are all-NaN or
empty. In later versions zero is returned.
Parameters
----------
a : array_like
Array containing numbers whose sum is... |
Return the sum of array elements over a given axis treating Not a
Numbers (NaNs) as zero. | def nansum(a, axis=None, dtype=None, out=None, keepdims=np._NoValue):
"""
Return the sum of array elements over a given axis treating Not a
Numbers (NaNs) as zero.
In NumPy versions <= 1.9.0 Nan is returned for slices that are all-NaN or
empty. In later versions zero is returned.
Parameters
... | [
"def",
"nansum",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"a",
",",
"mask",
"=",
"_replace_nan",
"(",
"a",
",",
"0",
")",
"return",
"np",
".",... | [
558,
0
] | [
648,
72
] | python | en | ['en', 'error', 'th'] | False |
nanprod | (a, axis=None, dtype=None, out=None, keepdims=np._NoValue) |
Return the product of array elements over a given axis treating Not a
Numbers (NaNs) as ones.
One is returned for slices that are all-NaN or empty.
.. versionadded:: 1.10.0
Parameters
----------
a : array_like
Array containing numbers whose product is desired. If `a` is not an
... |
Return the product of array elements over a given axis treating Not a
Numbers (NaNs) as ones. | def nanprod(a, axis=None, dtype=None, out=None, keepdims=np._NoValue):
"""
Return the product of array elements over a given axis treating Not a
Numbers (NaNs) as ones.
One is returned for slices that are all-NaN or empty.
.. versionadded:: 1.10.0
Parameters
----------
a : array_like
... | [
"def",
"nanprod",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"a",
",",
"mask",
"=",
"_replace_nan",
"(",
"a",
",",
"1",
")",
"return",
"np",
"."... | [
656,
0
] | [
718,
73
] | python | en | ['en', 'error', 'th'] | False |
nancumsum | (a, axis=None, dtype=None, out=None) |
Return the cumulative sum of array elements over a given axis treating Not a
Numbers (NaNs) as zero. The cumulative sum does not change when NaNs are
encountered and leading NaNs are replaced by zeros.
Zeros are returned for slices that are all-NaN or empty.
.. versionadded:: 1.12.0
Paramet... |
Return the cumulative sum of array elements over a given axis treating Not a
Numbers (NaNs) as zero. The cumulative sum does not change when NaNs are
encountered and leading NaNs are replaced by zeros. | def nancumsum(a, axis=None, dtype=None, out=None):
"""
Return the cumulative sum of array elements over a given axis treating Not a
Numbers (NaNs) as zero. The cumulative sum does not change when NaNs are
encountered and leading NaNs are replaced by zeros.
Zeros are returned for slices that are al... | [
"def",
"nancumsum",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"a",
",",
"mask",
"=",
"_replace_nan",
"(",
"a",
",",
"0",
")",
"return",
"np",
".",
"cumsum",
"(",
"a",
",",
"axis",
"=",
"... | [
726,
0
] | [
788,
56
] | python | en | ['en', 'error', 'th'] | False |
nancumprod | (a, axis=None, dtype=None, out=None) |
Return the cumulative product of array elements over a given axis treating Not a
Numbers (NaNs) as one. The cumulative product does not change when NaNs are
encountered and leading NaNs are replaced by ones.
Ones are returned for slices that are all-NaN or empty.
.. versionadded:: 1.12.0
Pa... |
Return the cumulative product of array elements over a given axis treating Not a
Numbers (NaNs) as one. The cumulative product does not change when NaNs are
encountered and leading NaNs are replaced by ones. | def nancumprod(a, axis=None, dtype=None, out=None):
"""
Return the cumulative product of array elements over a given axis treating Not a
Numbers (NaNs) as one. The cumulative product does not change when NaNs are
encountered and leading NaNs are replaced by ones.
Ones are returned for slices that ... | [
"def",
"nancumprod",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"a",
",",
"mask",
"=",
"_replace_nan",
"(",
"a",
",",
"1",
")",
"return",
"np",
".",
"cumprod",
"(",
"a",
",",
"axis",
"=",
... | [
796,
0
] | [
855,
57
] | python | en | ['en', 'error', 'th'] | False |
nanmean | (a, axis=None, dtype=None, out=None, keepdims=np._NoValue) |
Compute the arithmetic mean along the specified axis, ignoring NaNs.
Returns the average of the array elements. The average is taken over
the flattened array by default, otherwise over the specified axis.
`float64` intermediate and return values are used for integer inputs.
For all-NaN slices, N... |
Compute the arithmetic mean along the specified axis, ignoring NaNs. | def nanmean(a, axis=None, dtype=None, out=None, keepdims=np._NoValue):
"""
Compute the arithmetic mean along the specified axis, ignoring NaNs.
Returns the average of the array elements. The average is taken over
the flattened array by default, otherwise over the specified axis.
`float64` intermed... | [
"def",
"nanmean",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"arr",
",",
"mask",
"=",
"_replace_nan",
"(",
"a",
",",
"0",
")",
"if",
"mask",
"is... | [
863,
0
] | [
957,
14
] | python | en | ['en', 'error', 'th'] | False |
_nanmedian1d | (arr1d, overwrite_input=False) |
Private function for rank 1 arrays. Compute the median ignoring NaNs.
See nanmedian for parameter usage
|
Private function for rank 1 arrays. Compute the median ignoring NaNs.
See nanmedian for parameter usage
| def _nanmedian1d(arr1d, overwrite_input=False):
"""
Private function for rank 1 arrays. Compute the median ignoring NaNs.
See nanmedian for parameter usage
"""
arr1d, overwrite_input = _remove_nan_1d(arr1d,
overwrite_input=overwrite_input)
if arr1d.siz... | [
"def",
"_nanmedian1d",
"(",
"arr1d",
",",
"overwrite_input",
"=",
"False",
")",
":",
"arr1d",
",",
"overwrite_input",
"=",
"_remove_nan_1d",
"(",
"arr1d",
",",
"overwrite_input",
"=",
"overwrite_input",
")",
"if",
"arr1d",
".",
"size",
"==",
"0",
":",
"retur... | [
960,
0
] | [
970,
60
] | python | en | ['en', 'error', 'th'] | False |
_nanmedian | (a, axis=None, out=None, overwrite_input=False) |
Private function that doesn't support extended axis or keepdims.
These methods are extended to this function using _ureduce
See nanmedian for parameter usage
|
Private function that doesn't support extended axis or keepdims.
These methods are extended to this function using _ureduce
See nanmedian for parameter usage | def _nanmedian(a, axis=None, out=None, overwrite_input=False):
"""
Private function that doesn't support extended axis or keepdims.
These methods are extended to this function using _ureduce
See nanmedian for parameter usage
"""
if axis is None or a.ndim == 1:
part = a.ravel()
i... | [
"def",
"_nanmedian",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"overwrite_input",
"=",
"False",
")",
":",
"if",
"axis",
"is",
"None",
"or",
"a",
".",
"ndim",
"==",
"1",
":",
"part",
"=",
"a",
".",
"ravel",
"(",
")",
"if"... | [
973,
0
] | [
996,
21
] | python | en | ['en', 'error', 'th'] | False |
_nanmedian_small | (a, axis=None, out=None, overwrite_input=False) |
sort + indexing median, faster for small medians along multiple
dimensions due to the high overhead of apply_along_axis
see nanmedian for parameter usage
|
sort + indexing median, faster for small medians along multiple
dimensions due to the high overhead of apply_along_axis | def _nanmedian_small(a, axis=None, out=None, overwrite_input=False):
"""
sort + indexing median, faster for small medians along multiple
dimensions due to the high overhead of apply_along_axis
see nanmedian for parameter usage
"""
a = np.ma.masked_array(a, np.isnan(a))
m = np.ma.median(a, a... | [
"def",
"_nanmedian_small",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"overwrite_input",
"=",
"False",
")",
":",
"a",
"=",
"np",
".",
"ma",
".",
"masked_array",
"(",
"a",
",",
"np",
".",
"isnan",
"(",
"a",
")",
")",
"m",
... | [
999,
0
] | [
1014,
27
] | python | en | ['en', 'error', 'th'] | False |
nanmedian | (a, axis=None, out=None, overwrite_input=False, keepdims=np._NoValue) |
Compute the median along the specified axis, while ignoring NaNs.
Returns the median of the array elements.
.. versionadded:: 1.9.0
Parameters
----------
a : array_like
Input array or object that can be converted to an array.
axis : {int, sequence of int, None}, optional
... |
Compute the median along the specified axis, while ignoring NaNs. | def nanmedian(a, axis=None, out=None, overwrite_input=False, keepdims=np._NoValue):
"""
Compute the median along the specified axis, while ignoring NaNs.
Returns the median of the array elements.
.. versionadded:: 1.9.0
Parameters
----------
a : array_like
Input array or object th... | [
"def",
"nanmedian",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"overwrite_input",
"=",
"False",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"a",
"=",
"np",
".",
"asanyarray",
"(",
"a",
")",
"# apply_along_axis in _nanm... | [
1023,
0
] | [
1118,
16
] | python | en | ['en', 'error', 'th'] | False |
nanpercentile | (a, q, axis=None, out=None, overwrite_input=False,
interpolation='linear', keepdims=np._NoValue) |
Compute the qth percentile of the data along the specified axis,
while ignoring nan values.
Returns the qth percentile(s) of the array elements.
.. versionadded:: 1.9.0
Parameters
----------
a : array_like
Input array or object that can be converted to an array, containing
... |
Compute the qth percentile of the data along the specified axis,
while ignoring nan values. | def nanpercentile(a, q, axis=None, out=None, overwrite_input=False,
interpolation='linear', keepdims=np._NoValue):
"""
Compute the qth percentile of the data along the specified axis,
while ignoring nan values.
Returns the qth percentile(s) of the array elements.
.. versionadded:... | [
"def",
"nanpercentile",
"(",
"a",
",",
"q",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"overwrite_input",
"=",
"False",
",",
"interpolation",
"=",
"'linear'",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"a",
"=",
"np",
".",
... | [
1127,
0
] | [
1244,
66
] | python | en | ['en', 'error', 'th'] | False |
nanquantile | (a, q, axis=None, out=None, overwrite_input=False,
interpolation='linear', keepdims=np._NoValue) |
Compute the qth quantile of the data along the specified axis,
while ignoring nan values.
Returns the qth quantile(s) of the array elements.
.. versionadded:: 1.15.0
Parameters
----------
a : array_like
Input array or object that can be converted to an array, containing
... |
Compute the qth quantile of the data along the specified axis,
while ignoring nan values.
Returns the qth quantile(s) of the array elements.
.. versionadded:: 1.15.0 | def nanquantile(a, q, axis=None, out=None, overwrite_input=False,
interpolation='linear', keepdims=np._NoValue):
"""
Compute the qth quantile of the data along the specified axis,
while ignoring nan values.
Returns the qth quantile(s) of the array elements.
.. versionadded:: 1.1... | [
"def",
"nanquantile",
"(",
"a",
",",
"q",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"overwrite_input",
"=",
"False",
",",
"interpolation",
"=",
"'linear'",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"a",
"=",
"np",
".",
"a... | [
1253,
0
] | [
1357,
66
] | python | en | ['en', 'error', 'th'] | False |
_nanquantile_unchecked | (a, q, axis=None, out=None, overwrite_input=False,
interpolation='linear', keepdims=np._NoValue) | Assumes that q is in [0, 1], and is an ndarray | Assumes that q is in [0, 1], and is an ndarray | def _nanquantile_unchecked(a, q, axis=None, out=None, overwrite_input=False,
interpolation='linear', keepdims=np._NoValue):
"""Assumes that q is in [0, 1], and is an ndarray"""
# apply_along_axis in _nanpercentile doesn't handle empty arrays well,
# so deal them upfront
if a.s... | [
"def",
"_nanquantile_unchecked",
"(",
"a",
",",
"q",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"overwrite_input",
"=",
"False",
",",
"interpolation",
"=",
"'linear'",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"# apply_along_axis ... | [
1360,
0
] | [
1375,
16
] | python | en | ['en', 'en', 'en'] | True |
_nanquantile_ureduce_func | (a, q, axis=None, out=None, overwrite_input=False,
interpolation='linear') |
Private function that doesn't support extended axis or keepdims.
These methods are extended to this function using _ureduce
See nanpercentile for parameter usage
|
Private function that doesn't support extended axis or keepdims.
These methods are extended to this function using _ureduce
See nanpercentile for parameter usage
| def _nanquantile_ureduce_func(a, q, axis=None, out=None, overwrite_input=False,
interpolation='linear'):
"""
Private function that doesn't support extended axis or keepdims.
These methods are extended to this function using _ureduce
See nanpercentile for parameter usage
... | [
"def",
"_nanquantile_ureduce_func",
"(",
"a",
",",
"q",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"overwrite_input",
"=",
"False",
",",
"interpolation",
"=",
"'linear'",
")",
":",
"if",
"axis",
"is",
"None",
"or",
"a",
".",
"ndim",
"==",
... | [
1378,
0
] | [
1399,
17
] | python | en | ['en', 'error', 'th'] | False |
_nanquantile_1d | (arr1d, q, overwrite_input=False, interpolation='linear') |
Private function for rank 1 arrays. Compute quantile ignoring NaNs.
See nanpercentile for parameter usage
|
Private function for rank 1 arrays. Compute quantile ignoring NaNs.
See nanpercentile for parameter usage
| def _nanquantile_1d(arr1d, q, overwrite_input=False, interpolation='linear'):
"""
Private function for rank 1 arrays. Compute quantile ignoring NaNs.
See nanpercentile for parameter usage
"""
arr1d, overwrite_input = _remove_nan_1d(arr1d,
overwrite_input=overwrite_input)
if arr1d.size ==... | [
"def",
"_nanquantile_1d",
"(",
"arr1d",
",",
"q",
",",
"overwrite_input",
"=",
"False",
",",
"interpolation",
"=",
"'linear'",
")",
":",
"arr1d",
",",
"overwrite_input",
"=",
"_remove_nan_1d",
"(",
"arr1d",
",",
"overwrite_input",
"=",
"overwrite_input",
")",
... | [
1402,
0
] | [
1413,
79
] | python | en | ['en', 'error', 'th'] | False |
nanvar | (a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue) |
Compute the variance along the specified axis, while ignoring NaNs.
Returns the variance of the array elements, a measure of the spread of
a distribution. The variance is computed for the flattened array by
default, otherwise over the specified axis.
For all-NaN slices or slices with zero degree... |
Compute the variance along the specified axis, while ignoring NaNs. | def nanvar(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue):
"""
Compute the variance along the specified axis, while ignoring NaNs.
Returns the variance of the array elements, a measure of the spread of
a distribution. The variance is computed for the flattened array by
default, ... | [
"def",
"nanvar",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"out",
"=",
"None",
",",
"ddof",
"=",
"0",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"arr",
",",
"mask",
"=",
"_replace_nan",
"(",
"a",
",",
"0",
... | [
1422,
0
] | [
1561,
14
] | python | en | ['en', 'error', 'th'] | False |
nanstd | (a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue) |
Compute the standard deviation along the specified axis, while
ignoring NaNs.
Returns the standard deviation, a measure of the spread of a
distribution, of the non-NaN array elements. The standard deviation is
computed for the flattened array by default, otherwise over the
specified axis.
... |
Compute the standard deviation along the specified axis, while
ignoring NaNs. | def nanstd(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue):
"""
Compute the standard deviation along the specified axis, while
ignoring NaNs.
Returns the standard deviation, a measure of the spread of a
distribution, of the non-NaN array elements. The standard deviation is
com... | [
"def",
"nanstd",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"out",
"=",
"None",
",",
"ddof",
"=",
"0",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"var",
"=",
"nanvar",
"(",
"a",
",",
"axis",
"=",
"axis",
"... | [
1570,
0
] | [
1670,
14
] | python | en | ['en', 'error', 'th'] | False |
test_multiple_optimizers_multiple_dataloaders | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test_multiple_optimizers_multiple_dataloaders(tmpdir):
"""
Tests that only training_step can be used
"""
class TestModel(BoringModel):
def on_train_epoch_start(self) -> None:
self.opt_0_seen = False
self.opt_1_seen = False
def training_step(self, batch, bat... | [
"def",
"test_multiple_optimizers_multiple_dataloaders",
"(",
"tmpdir",
")",
":",
"class",
"TestModel",
"(",
"BoringModel",
")",
":",
"def",
"on_train_epoch_start",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"opt_0_seen",
"=",
"False",
"self",
".",
"opt_1_... | [
114,
0
] | [
173,
27
] | python | en | ['en', 'error', 'th'] | False |
FBeta.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
"""
true_positives, predicted_positives, actual_positives = _fbeta_update(
... | [
"def",
"update",
"(",
"self",
",",
"preds",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
")",
":",
"true_positives",
",",
"predicted_positives",
",",
"actual_positives",
"=",
"_fbeta_update",
"(",
"preds",
",",
"target",
",",
"s... | [
111,
4
] | [
125,
49
] | python | en | ['en', 'error', 'th'] | False |
FBeta.compute | (self) |
Computes fbeta over state.
|
Computes fbeta over state.
| def compute(self) -> torch.Tensor:
"""
Computes fbeta over state.
"""
return _fbeta_compute(
self.true_positives, self.predicted_positives, self.actual_positives, self.beta, self.average
) | [
"def",
"compute",
"(",
"self",
")",
"->",
"torch",
".",
"Tensor",
":",
"return",
"_fbeta_compute",
"(",
"self",
".",
"true_positives",
",",
"self",
".",
"predicted_positives",
",",
"self",
".",
"actual_positives",
",",
"self",
".",
"beta",
",",
"self",
"."... | [
127,
4
] | [
133,
9
] | python | en | ['en', 'error', 'th'] | False |
ReadWriteMutex.acquire_read_lock | (self, wait=True) | Acquire the 'read' lock. | Acquire the 'read' lock. | def acquire_read_lock(self, wait=True):
"""Acquire the 'read' lock."""
self.condition.acquire()
try:
# see if a synchronous operation is waiting to start
# or is already running, in which case we wait (or just
# give up and return)
if wait:
... | [
"def",
"acquire_read_lock",
"(",
"self",
",",
"wait",
"=",
"True",
")",
":",
"self",
".",
"condition",
".",
"acquire",
"(",
")",
"try",
":",
"# see if a synchronous operation is waiting to start",
"# or is already running, in which case we wait (or just",
"# give up and ret... | [
33,
4
] | [
53,
23
] | python | en | ['en', 'it', 'en'] | True |
ReadWriteMutex.release_read_lock | (self) | Release the 'read' lock. | Release the 'read' lock. | def release_read_lock(self):
"""Release the 'read' lock."""
self.condition.acquire()
try:
self.async_ -= 1
# check if we are the last asynchronous reader thread
# out the door.
if self.async_ == 0:
# yes. so if a sync operation is ... | [
"def",
"release_read_lock",
"(",
"self",
")",
":",
"self",
".",
"condition",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"async_",
"-=",
"1",
"# check if we are the last asynchronous reader thread",
"# out the door.",
"if",
"self",
".",
"async_",
"==",
"0... | [
55,
4
] | [
73,
36
] | python | en | ['en', 'en', 'en'] | True |
ReadWriteMutex.acquire_write_lock | (self, wait=True) | Acquire the 'write' lock. | Acquire the 'write' lock. | def acquire_write_lock(self, wait=True):
"""Acquire the 'write' lock."""
self.condition.acquire()
try:
# here, we are not a synchronous reader, and after returning,
# assuming waiting or immediate availability, we will be.
if wait:
# if anothe... | [
"def",
"acquire_write_lock",
"(",
"self",
",",
"wait",
"=",
"True",
")",
":",
"self",
".",
"condition",
".",
"acquire",
"(",
")",
"try",
":",
"# here, we are not a synchronous reader, and after returning,",
"# assuming waiting or immediate availability, we will be.",
"if",
... | [
75,
4
] | [
111,
23
] | python | en | ['en', 'it', 'en'] | True |
ReadWriteMutex.release_write_lock | (self) | Release the 'write' lock. | Release the 'write' lock. | def release_write_lock(self):
"""Release the 'write' lock."""
self.condition.acquire()
try:
if self.current_sync_operation is not threading.currentThread():
raise LockError("Synchronizer error - current thread doesn't "
"have the write ... | [
"def",
"release_write_lock",
"(",
"self",
")",
":",
"self",
".",
"condition",
".",
"acquire",
"(",
")",
"try",
":",
"if",
"self",
".",
"current_sync_operation",
"is",
"not",
"threading",
".",
"currentThread",
"(",
")",
":",
"raise",
"LockError",
"(",
"\"Sy... | [
113,
4
] | [
131,
36
] | python | en | ['en', 'it', 'en'] | True |
counting_sort | (tlist, k, n) | Counting sort algo with sort in place.
Args:
tlist: target list to sort
k: max value assume known before hand
n: the length of the given list
map info to index of the count list.
Adv:
The count (after cum sum) will hold the actual posi... | Counting sort algo with sort in place.
Args:
tlist: target list to sort
k: max value assume known before hand
n: the length of the given list
map info to index of the count list.
Adv:
The count (after cum sum) will hold the actual posi... | def counting_sort(tlist, k, n):
""" Counting sort algo with sort in place.
Args:
tlist: target list to sort
k: max value assume known before hand
n: the length of the given list
map info to index of the count list.
Adv:
The coun... | [
"def",
"counting_sort",
"(",
"tlist",
",",
"k",
",",
"n",
")",
":",
"# Create a count list and using the index to map to the integer in tlist.\r",
"count_list",
"=",
"[",
"0",
"]",
"*",
"(",
"k",
"+",
"1",
")",
"# iterate the tgt_list to put into count list\r",
"for",
... | [
8,
0
] | [
39,
16
] | python | en | ['en', 'en', 'en'] | True |
restore_env_variables | () | Ensures that environment variables set during the test do not leak out. | Ensures that environment variables set during the test do not leak out. | def restore_env_variables():
""" Ensures that environment variables set during the test do not leak out. """
env_backup = os.environ.copy()
yield
# restore environment as it was before running the test
os.environ.clear()
os.environ.update(env_backup) | [
"def",
"restore_env_variables",
"(",
")",
":",
"env_backup",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"yield",
"# restore environment as it was before running the test",
"os",
".",
"environ",
".",
"clear",
"(",
")",
"os",
".",
"environ",
".",
"update",
... | [
24,
0
] | [
30,
33
] | python | en | ['en', 'en', 'en'] | True |
test_training_step_dict | (tmpdir) |
Tests that only training_step can be used
|
Tests that only training_step can be used
| def test_training_step_dict(tmpdir):
"""
Tests that only training_step can be used
"""
model = DeterministicModel()
model.training_step = model.training_step__dict_return
model.val_dataloader = None
trainer = Trainer(
default_root_dir=tmpdir,
fast_dev_run=True,
weigh... | [
"def",
"test_training_step_dict",
"(",
"tmpdir",
")",
":",
"model",
"=",
"DeterministicModel",
"(",
")",
"model",
".",
"training_step",
"=",
"model",
".",
"training_step__dict_return",
"model",
".",
"val_dataloader",
"=",
"None",
"trainer",
"=",
"Trainer",
"(",
... | [
23,
0
] | [
68,
64
] | python | en | ['en', 'error', 'th'] | False |
training_step_with_step_end | (tmpdir) |
Checks train_step + training_step_end
|
Checks train_step + training_step_end
| def training_step_with_step_end(tmpdir):
"""
Checks train_step + training_step_end
"""
model = DeterministicModel()
model.training_step = model.training_step__dict_return
model.training_step_end = model.training_step_end__dict
model.val_dataloader = None
trainer = Trainer(
defau... | [
"def",
"training_step_with_step_end",
"(",
"tmpdir",
")",
":",
"model",
"=",
"DeterministicModel",
"(",
")",
"model",
".",
"training_step",
"=",
"model",
".",
"training_step__dict_return",
"model",
".",
"training_step_end",
"=",
"model",
".",
"training_step_end__dict"... | [
71,
0
] | [
105,
44
] | python | en | ['en', 'error', 'th'] | False |
test_full_training_loop_dict | (tmpdir) |
Checks train_step + training_step_end + training_epoch_end
|
Checks train_step + training_step_end + training_epoch_end
| def test_full_training_loop_dict(tmpdir):
"""
Checks train_step + training_step_end + training_epoch_end
"""
model = DeterministicModel()
model.training_step = model.training_step__for_step_end_dict
model.training_step_end = model.training_step_end__dict
model.training_epoch_end = model.trai... | [
"def",
"test_full_training_loop_dict",
"(",
"tmpdir",
")",
":",
"model",
"=",
"DeterministicModel",
"(",
")",
"model",
".",
"training_step",
"=",
"model",
".",
"training_step__for_step_end_dict",
"model",
".",
"training_step_end",
"=",
"model",
".",
"training_step_end... | [
108,
0
] | [
148,
44
] | python | en | ['en', 'error', 'th'] | False |
test_result_obj_lr_scheduler_epoch | (tmpdir) |
test that the LR scheduler was called at the correct time with the correct metrics
|
test that the LR scheduler was called at the correct time with the correct metrics
| def test_result_obj_lr_scheduler_epoch(tmpdir):
"""
test that the LR scheduler was called at the correct time with the correct metrics
"""
model = DeterministicModel()
model.training_step = model.training_step__for_step_end_dict
model.training_step_end = model.training_step_end__dict
model.t... | [
"def",
"test_result_obj_lr_scheduler_epoch",
"(",
"tmpdir",
")",
":",
"model",
"=",
"DeterministicModel",
"(",
")",
"model",
".",
"training_step",
"=",
"model",
".",
"training_step__for_step_end_dict",
"model",
".",
"training_step_end",
"=",
"model",
".",
"training_st... | [
152,
0
] | [
170,
68
] | python | en | ['en', 'error', 'th'] | False |
test_result_obj_lr_scheduler_step | (tmpdir) |
test that the LR scheduler was called at the correct time with the correct metrics
|
test that the LR scheduler was called at the correct time with the correct metrics
| def test_result_obj_lr_scheduler_step(tmpdir):
"""
test that the LR scheduler was called at the correct time with the correct metrics
"""
model = DeterministicModel()
model.training_step = model.training_step__for_step_end_dict
model.training_step_end = model.training_step_end__dict
model.tr... | [
"def",
"test_result_obj_lr_scheduler_step",
"(",
"tmpdir",
")",
":",
"model",
"=",
"DeterministicModel",
"(",
")",
"model",
".",
"training_step",
"=",
"model",
".",
"training_step__for_step_end_dict",
"model",
".",
"training_step_end",
"=",
"model",
".",
"training_ste... | [
174,
0
] | [
192,
68
] | python | en | ['en', 'error', 'th'] | False |
test_train_step_epoch_end | (tmpdir) |
Checks train_step + training_epoch_end (NO training_step_end)
|
Checks train_step + training_epoch_end (NO training_step_end)
| def test_train_step_epoch_end(tmpdir):
"""
Checks train_step + training_epoch_end (NO training_step_end)
"""
model = DeterministicModel()
model.training_step = model.training_step__dict_return
model.training_step_end = None
model.training_epoch_end = model.training_epoch_end__dict
model.... | [
"def",
"test_train_step_epoch_end",
"(",
"tmpdir",
")",
":",
"model",
"=",
"DeterministicModel",
"(",
")",
"model",
".",
"training_step",
"=",
"model",
".",
"training_step__dict_return",
"model",
".",
"training_step_end",
"=",
"None",
"model",
".",
"training_epoch_e... | [
195,
0
] | [
236,
44
] | python | en | ['en', 'error', 'th'] | False |
_py_max_match | (scores) | Apply munkres algorithm to get the best match.
Args:
scores(np.ndarray): cost matrix.
Returns:
np.ndarray: best match.
| Apply munkres algorithm to get the best match. | def _py_max_match(scores):
"""Apply munkres algorithm to get the best match.
Args:
scores(np.ndarray): cost matrix.
Returns:
np.ndarray: best match.
"""
m = Munkres()
tmp = m.compute(scores)
tmp = np.array(tmp).astype(int)
return tmp | [
"def",
"_py_max_match",
"(",
"scores",
")",
":",
"m",
"=",
"Munkres",
"(",
")",
"tmp",
"=",
"m",
".",
"compute",
"(",
"scores",
")",
"tmp",
"=",
"np",
".",
"array",
"(",
"tmp",
")",
".",
"astype",
"(",
"int",
")",
"return",
"tmp"
] | [
12,
0
] | [
24,
14
] | python | en | ['en', 'en', 'en'] | True |
_match_by_tag | (inp, params) | Match joints by tags. Use Munkres algorithm to calculate the best match
for keypoints grouping.
Note:
number of keypoints: K
max number of a image: M
L: 2 if use flip test else 1
Args:
inp(tuple):
tag_k (np.ndarray[KxMxL]): tag corresponding to the
... | Match joints by tags. Use Munkres algorithm to calculate the best match
for keypoints grouping. | def _match_by_tag(inp, params):
"""Match joints by tags. Use Munkres algorithm to calculate the best match
for keypoints grouping.
Note:
number of keypoints: K
max number of a image: M
L: 2 if use flip test else 1
Args:
inp(tuple):
tag_k (np.ndarray[KxMxL]):... | [
"def",
"_match_by_tag",
"(",
"inp",
",",
"params",
")",
":",
"assert",
"isinstance",
"(",
"params",
",",
"_Params",
")",
",",
"'params should be class _Params()'",
"tag_k",
",",
"loc_k",
",",
"val_k",
"=",
"inp",
"default_",
"=",
"np",
".",
"zeros",
"(",
"... | [
27,
0
] | [
114,
14
] | python | en | ['en', 'en', 'en'] | True |
HeatmapParser.nms | (self, heatmaps) | Non-Maximum Suppression for heatmaps.
Args:
heatmap(torch.Tensor): Heatmaps before nms.
Returns:
torch.Tensor: Heatmaps after nms.
| Non-Maximum Suppression for heatmaps. | def nms(self, heatmaps):
"""Non-Maximum Suppression for heatmaps.
Args:
heatmap(torch.Tensor): Heatmaps before nms.
Returns:
torch.Tensor: Heatmaps after nms.
"""
maxm = self.pool(heatmaps)
maxm = torch.eq(maxm, heatmaps).float()
heatmap... | [
"def",
"nms",
"(",
"self",
",",
"heatmaps",
")",
":",
"maxm",
"=",
"self",
".",
"pool",
"(",
"heatmaps",
")",
"maxm",
"=",
"torch",
".",
"eq",
"(",
"maxm",
",",
"heatmaps",
")",
".",
"float",
"(",
")",
"heatmaps",
"=",
"heatmaps",
"*",
"maxm",
"r... | [
152,
4
] | [
166,
23
] | python | en | ['en', 'it', 'en'] | True |
HeatmapParser.match | (self, tag_k, loc_k, val_k) | Group keypoints to human poses in a batch.
Args:
tag_k (np.ndarray[NxKxMxL]): tag corresponding to the
top k values of feature map per keypoint.
loc_k (np.ndarray[NxKxMx2]): top k locations of the
feature maps for keypoint.
val_k (np.ndarray[N... | Group keypoints to human poses in a batch. | def match(self, tag_k, loc_k, val_k):
"""Group keypoints to human poses in a batch.
Args:
tag_k (np.ndarray[NxKxMxL]): tag corresponding to the
top k values of feature map per keypoint.
loc_k (np.ndarray[NxKxMx2]): top k locations of the
feature m... | [
"def",
"match",
"(",
"self",
",",
"tag_k",
",",
"loc_k",
",",
"val_k",
")",
":",
"def",
"_match",
"(",
"x",
")",
":",
"return",
"_match_by_tag",
"(",
"x",
",",
"self",
".",
"params",
")",
"return",
"list",
"(",
"map",
"(",
"_match",
",",
"zip",
"... | [
168,
4
] | [
186,
58
] | python | en | ['en', 'en', 'en'] | True |
HeatmapParser.top_k | (self, heatmaps, tags) | Find top_k values in an image.
Note:
batch size: N
number of keypoints: K
heatmap height: H
heatmap width: W
max number of people: M
If use flip testing, L=2; else L=1.
Args:
heatmaps (torch.Tensor[NxKxHxW])
... | Find top_k values in an image. | def top_k(self, heatmaps, tags):
"""Find top_k values in an image.
Note:
batch size: N
number of keypoints: K
heatmap height: H
heatmap width: W
max number of people: M
If use flip testing, L=2; else L=1.
Args:
... | [
"def",
"top_k",
"(",
"self",
",",
"heatmaps",
",",
"tags",
")",
":",
"heatmaps",
"=",
"self",
".",
"nms",
"(",
"heatmaps",
")",
"N",
",",
"K",
",",
"H",
",",
"W",
"=",
"heatmaps",
".",
"size",
"(",
")",
"heatmaps",
"=",
"heatmaps",
".",
"view",
... | [
188,
4
] | [
238,
18
] | python | en | ['en', 'en', 'en'] | True |
HeatmapParser.adjust | (ans, heatmaps) | Adjust the coordinates for better accuracy.
Note:
batch size: N
number of keypoints: K
heatmap height: H
heatmap width: W
Args:
ans (list(np.ndarray)): Keypoint predictions.
heatmaps (torch.Tensor[NxKxHxW]): Heatmaps.
| Adjust the coordinates for better accuracy. | def adjust(ans, heatmaps):
"""Adjust the coordinates for better accuracy.
Note:
batch size: N
number of keypoints: K
heatmap height: H
heatmap width: W
Args:
ans (list(np.ndarray)): Keypoint predictions.
heatmaps (torch.Te... | [
"def",
"adjust",
"(",
"ans",
",",
"heatmaps",
")",
":",
"_",
",",
"_",
",",
"H",
",",
"W",
"=",
"heatmaps",
".",
"shape",
"for",
"batch_id",
",",
"people",
"in",
"enumerate",
"(",
"ans",
")",
":",
"for",
"people_id",
",",
"people_i",
"in",
"enumera... | [
241,
4
] | [
275,
18
] | python | en | ['en', 'en', 'en'] | True |
HeatmapParser.refine | (heatmap, tag, keypoints, use_udp=False) | Given initial keypoint predictions, we identify missing joints.
Note:
number of keypoints: K
heatmap height: H
heatmap width: W
Args:
heatmap: np.ndarray of size (K, H, W).
tag: np.ndarray of size (K, H, W) if not flip.
keypoints:... | Given initial keypoint predictions, we identify missing joints. | def refine(heatmap, tag, keypoints, use_udp=False):
"""Given initial keypoint predictions, we identify missing joints.
Note:
number of keypoints: K
heatmap height: H
heatmap width: W
Args:
heatmap: np.ndarray of size (K, H, W).
tag: n... | [
"def",
"refine",
"(",
"heatmap",
",",
"tag",
",",
"keypoints",
",",
"use_udp",
"=",
"False",
")",
":",
"K",
",",
"H",
",",
"W",
"=",
"heatmap",
".",
"shape",
"if",
"len",
"(",
"tag",
".",
"shape",
")",
"==",
"3",
":",
"tag",
"=",
"tag",
"[",
... | [
278,
4
] | [
352,
24
] | python | en | ['en', 'en', 'en'] | True |
HeatmapParser.parse | (self, heatmaps, tags, adjust=True, refine=True) | Group keypoints into poses given heatmap and tag.
Note:
batch size: N
number of keypoints: K
heatmap height: H
heatmap width: W
L: 2 if use flip test else 1
Args:
heatmaps (torch.Tensor[NxKxHxW]): model output heatmaps.
... | Group keypoints into poses given heatmap and tag. | def parse(self, heatmaps, tags, adjust=True, refine=True):
"""Group keypoints into poses given heatmap and tag.
Note:
batch size: N
number of keypoints: K
heatmap height: H
heatmap width: W
L: 2 if use flip test else 1
Args:
... | [
"def",
"parse",
"(",
"self",
",",
"heatmaps",
",",
"tags",
",",
"adjust",
"=",
"True",
",",
"refine",
"=",
"True",
")",
":",
"ans",
"=",
"self",
".",
"match",
"(",
"*",
"*",
"self",
".",
"top_k",
"(",
"heatmaps",
",",
"tags",
")",
")",
"if",
"a... | [
354,
4
] | [
400,
26
] | python | en | ['en', 'en', 'en'] | True |
jpeg_res | (filename) | This function prints the resolution of the jpeg image file passed into it | This function prints the resolution of the jpeg image file passed into it | def jpeg_res(filename):
""""This function prints the resolution of the jpeg image file passed into it"""
# open image for reading in binary mode
with open(filename,'rb') as img_file:
# height of image (in 2 bytes) is at 164th position
img_file.seek(163)
# read the 2 bytes
a = img... | [
"def",
"jpeg_res",
"(",
"filename",
")",
":",
"# open image for reading in binary mode",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"img_file",
":",
"# height of image (in 2 bytes) is at 164th position",
"img_file",
".",
"seek",
"(",
"163",
")",
"# read ... | [
0,
0
] | [
21,
59
] | python | en | ['en', 'en', 'en'] | True |
check_inline | (cmd) | Return the inline identifier (may be empty). | Return the inline identifier (may be empty). | def check_inline(cmd):
"""Return the inline identifier (may be empty)."""
cmd._check_compiler()
body = textwrap.dedent("""
#ifndef __cplusplus
static %(inline)s int static_func (void)
{
return 0;
}
%(inline)s int nostatic_func (void)
{
... | [
"def",
"check_inline",
"(",
"cmd",
")",
":",
"cmd",
".",
"_check_compiler",
"(",
")",
"body",
"=",
"textwrap",
".",
"dedent",
"(",
"\"\"\"\n #ifndef __cplusplus\n static %(inline)s int static_func (void)\n {\n return 0;\n }\n %(inline)s... | [
9,
0
] | [
29,
13
] | python | en | ['en', 'fy', 'en'] | True |
check_restrict | (cmd) | Return the restrict identifier (may be empty). | Return the restrict identifier (may be empty). | def check_restrict(cmd):
"""Return the restrict identifier (may be empty)."""
cmd._check_compiler()
body = textwrap.dedent("""
static int static_func (char * %(restrict)s a)
{
return 0;
}
""")
for kw in ['restrict', '__restrict__', '__restrict']:
st =... | [
"def",
"check_restrict",
"(",
"cmd",
")",
":",
"cmd",
".",
"_check_compiler",
"(",
")",
"body",
"=",
"textwrap",
".",
"dedent",
"(",
"\"\"\"\n static int static_func (char * %(restrict)s a)\n {\n return 0;\n }\n \"\"\"",
")",
"for",
"kw"... | [
32,
0
] | [
47,
13
] | python | en | ['en', 'en', 'en'] | True |
check_compiler_gcc4 | (cmd) | Return True if the C compiler is GCC 4.x. | Return True if the C compiler is GCC 4.x. | def check_compiler_gcc4(cmd):
"""Return True if the C compiler is GCC 4.x."""
cmd._check_compiler()
body = textwrap.dedent("""
int
main()
{
#if (! defined __GNUC__) || (__GNUC__ < 4)
#error gcc >= 4 required
#endif
return 0;
}
""")
... | [
"def",
"check_compiler_gcc4",
"(",
"cmd",
")",
":",
"cmd",
".",
"_check_compiler",
"(",
")",
"body",
"=",
"textwrap",
".",
"dedent",
"(",
"\"\"\"\n int\n main()\n {\n #if (! defined __GNUC__) || (__GNUC__ < 4)\n #error gcc >= 4 required\n #... | [
50,
0
] | [
63,
44
] | python | en | ['en', 'la', 'en'] | True |
check_gcc_function_attribute | (cmd, attribute, name) | Return True if the given function attribute is supported. | Return True if the given function attribute is supported. | def check_gcc_function_attribute(cmd, attribute, name):
"""Return True if the given function attribute is supported."""
cmd._check_compiler()
body = textwrap.dedent("""
#pragma GCC diagnostic error "-Wattributes"
#pragma clang diagnostic error "-Wattributes"
int %s %s(void*);
... | [
"def",
"check_gcc_function_attribute",
"(",
"cmd",
",",
"attribute",
",",
"name",
")",
":",
"cmd",
".",
"_check_compiler",
"(",
")",
"body",
"=",
"textwrap",
".",
"dedent",
"(",
"\"\"\"\n #pragma GCC diagnostic error \"-Wattributes\"\n #pragma clang diagnostic... | [
66,
0
] | [
81,
49
] | python | en | ['en', 'en', 'en'] | True |
check_gcc_function_attribute_with_intrinsics | (cmd, attribute, name, code,
include) | Return True if the given function attribute is supported with
intrinsics. | Return True if the given function attribute is supported with
intrinsics. | def check_gcc_function_attribute_with_intrinsics(cmd, attribute, name, code,
include):
"""Return True if the given function attribute is supported with
intrinsics."""
cmd._check_compiler()
body = textwrap.dedent("""
#include<%s>
int %s %s(v... | [
"def",
"check_gcc_function_attribute_with_intrinsics",
"(",
"cmd",
",",
"attribute",
",",
"name",
",",
"code",
",",
"include",
")",
":",
"cmd",
".",
"_check_compiler",
"(",
")",
"body",
"=",
"textwrap",
".",
"dedent",
"(",
"\"\"\"\n #include<%s>\n int ... | [
84,
0
] | [
103,
49
] | python | en | ['en', 'en', 'en'] | True |
check_gcc_variable_attribute | (cmd, attribute) | Return True if the given variable attribute is supported. | Return True if the given variable attribute is supported. | def check_gcc_variable_attribute(cmd, attribute):
"""Return True if the given variable attribute is supported."""
cmd._check_compiler()
body = textwrap.dedent("""
#pragma GCC diagnostic error "-Wattributes"
#pragma clang diagnostic error "-Wattributes"
int %s foo;
int
... | [
"def",
"check_gcc_variable_attribute",
"(",
"cmd",
",",
"attribute",
")",
":",
"cmd",
".",
"_check_compiler",
"(",
")",
"body",
"=",
"textwrap",
".",
"dedent",
"(",
"\"\"\"\n #pragma GCC diagnostic error \"-Wattributes\"\n #pragma clang diagnostic error \"-Wattrib... | [
106,
0
] | [
121,
49
] | python | en | ['en', 'en', 'en'] | True |
ConfigValidator.verify_loop_configurations | (self, model: LightningModule) | r"""
Checks that the model is configured correctly before training or testing is started.
Args:
model: The model to check the configuration.
| r"""
Checks that the model is configured correctly before training or testing is started. | def verify_loop_configurations(self, model: LightningModule):
r"""
Checks that the model is configured correctly before training or testing is started.
Args:
model: The model to check the configuration.
"""
if not self.trainer.testing:
self.__verify_trai... | [
"def",
"verify_loop_configurations",
"(",
"self",
",",
"model",
":",
"LightningModule",
")",
":",
"if",
"not",
"self",
".",
"trainer",
".",
"testing",
":",
"self",
".",
"__verify_train_loop_configuration",
"(",
"model",
")",
"self",
".",
"__verify_eval_loop_config... | [
24,
4
] | [
37,
64
] | python | cy | ['en', 'cy', 'hi'] | False |
track_data_hook_calls | (fn) | A decorator that checks if prepare_data/setup have been called.
- When dm.prepare_data() is called, dm.has_prepared_data gets set to True
- When dm.setup('fit') is called, dm.has_setup_fit gets set to True
- When dm.setup('test') is called, dm.has_setup_test gets set to True
- When dm.setup() is called... | A decorator that checks if prepare_data/setup have been called. | def track_data_hook_calls(fn):
"""A decorator that checks if prepare_data/setup have been called.
- When dm.prepare_data() is called, dm.has_prepared_data gets set to True
- When dm.setup('fit') is called, dm.has_setup_fit gets set to True
- When dm.setup('test') is called, dm.has_setup_test gets set t... | [
"def",
"track_data_hook_calls",
"(",
"fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fn",
")",
"def",
"wrapped_fn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# The object instance from which setup or prepare_data was called",
"obj",
"=",
"args"... | [
53,
0
] | [
93,
21
] | python | en | ['en', 'en', 'en'] | True |
_DataModuleWrapper.__call__ | (cls, *args, **kwargs) | A wrapper for LightningDataModule that:
1. Runs user defined subclass's __init__
2. Assures prepare_data() runs on rank 0
3. Lets you check prepare_data and setup to see if they've been called
| A wrapper for LightningDataModule that: | def __call__(cls, *args, **kwargs):
"""A wrapper for LightningDataModule that:
1. Runs user defined subclass's __init__
2. Assures prepare_data() runs on rank 0
3. Lets you check prepare_data and setup to see if they've been called
"""
if not cls.__has_added_checks:
... | [
"def",
"__call__",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"cls",
".",
"__has_added_checks",
":",
"cls",
".",
"__has_added_checks",
"=",
"True",
"# Track prepare_data calls and make sure it runs on rank zero",
"cls",
".",
"p... | [
33,
4
] | [
50,
18
] | python | en | ['en', 'en', 'en'] | True |
LightningDataModule.train_transforms | (self) |
Optional transforms (or collection of transforms) you can apply to train dataset
|
Optional transforms (or collection of transforms) you can apply to train dataset
| def train_transforms(self):
"""
Optional transforms (or collection of transforms) you can apply to train dataset
"""
return self._train_transforms | [
"def",
"train_transforms",
"(",
"self",
")",
":",
"return",
"self",
".",
"_train_transforms"
] | [
160,
4
] | [
164,
37
] | python | en | ['en', 'error', 'th'] | False |
LightningDataModule.val_transforms | (self) |
Optional transforms (or collection of transforms) you can apply to validation dataset
|
Optional transforms (or collection of transforms) you can apply to validation dataset
| def val_transforms(self):
"""
Optional transforms (or collection of transforms) you can apply to validation dataset
"""
return self._val_transforms | [
"def",
"val_transforms",
"(",
"self",
")",
":",
"return",
"self",
".",
"_val_transforms"
] | [
171,
4
] | [
175,
35
] | python | en | ['en', 'error', 'th'] | False |
LightningDataModule.test_transforms | (self) |
Optional transforms (or collection of transforms) you can apply to test dataset
|
Optional transforms (or collection of transforms) you can apply to test dataset
| def test_transforms(self):
"""
Optional transforms (or collection of transforms) you can apply to test dataset
"""
return self._test_transforms | [
"def",
"test_transforms",
"(",
"self",
")",
":",
"return",
"self",
".",
"_test_transforms"
] | [
182,
4
] | [
186,
36
] | python | en | ['en', 'error', 'th'] | False |
LightningDataModule.dims | (self) |
A tuple describing the shape of your data. Extra functionality exposed in ``size``.
|
A tuple describing the shape of your data. Extra functionality exposed in ``size``.
| def dims(self):
"""
A tuple describing the shape of your data. Extra functionality exposed in ``size``.
"""
return self._dims | [
"def",
"dims",
"(",
"self",
")",
":",
"return",
"self",
".",
"_dims"
] | [
193,
4
] | [
197,
25
] | python | en | ['en', 'error', 'th'] | False |
LightningDataModule.size | (self, dim=None) |
Return the dimension of each input either as a tuple or list of tuples. You can index this
just as you would with a torch tensor.
|
Return the dimension of each input either as a tuple or list of tuples. You can index this
just as you would with a torch tensor.
| def size(self, dim=None) -> Union[Tuple, int]:
"""
Return the dimension of each input either as a tuple or list of tuples. You can index this
just as you would with a torch tensor.
"""
if dim is not None:
return self.dims[dim]
return self.dims | [
"def",
"size",
"(",
"self",
",",
"dim",
"=",
"None",
")",
"->",
"Union",
"[",
"Tuple",
",",
"int",
"]",
":",
"if",
"dim",
"is",
"not",
"None",
":",
"return",
"self",
".",
"dims",
"[",
"dim",
"]",
"return",
"self",
".",
"dims"
] | [
203,
4
] | [
212,
24
] | python | en | ['en', 'error', 'th'] | False |
LightningDataModule.has_prepared_data | (self) | Return bool letting you know if datamodule.prepare_data() has been called or not.
Returns:
bool: True if datamodule.prepare_data() has been called. False by default.
| Return bool letting you know if datamodule.prepare_data() has been called or not. | def has_prepared_data(self):
"""Return bool letting you know if datamodule.prepare_data() has been called or not.
Returns:
bool: True if datamodule.prepare_data() has been called. False by default.
"""
return self._has_prepared_data | [
"def",
"has_prepared_data",
"(",
"self",
")",
":",
"return",
"self",
".",
"_has_prepared_data"
] | [
215,
4
] | [
221,
38
] | python | en | ['en', 'en', 'en'] | True |
LightningDataModule.has_setup_fit | (self) | Return bool letting you know if datamodule.setup('fit') has been called or not.
Returns:
bool: True if datamodule.setup('fit') has been called. False by default.
| Return bool letting you know if datamodule.setup('fit') has been called or not. | def has_setup_fit(self):
"""Return bool letting you know if datamodule.setup('fit') has been called or not.
Returns:
bool: True if datamodule.setup('fit') has been called. False by default.
"""
return self._has_setup_fit | [
"def",
"has_setup_fit",
"(",
"self",
")",
":",
"return",
"self",
".",
"_has_setup_fit"
] | [
224,
4
] | [
230,
34
] | python | en | ['en', 'en', 'en'] | True |
LightningDataModule.has_setup_test | (self) | Return bool letting you know if datamodule.setup('test') has been called or not.
Returns:
bool: True if datamodule.setup('test') has been called. False by default.
| Return bool letting you know if datamodule.setup('test') has been called or not. | def has_setup_test(self):
"""Return bool letting you know if datamodule.setup('test') has been called or not.
Returns:
bool: True if datamodule.setup('test') has been called. False by default.
"""
return self._has_setup_test | [
"def",
"has_setup_test",
"(",
"self",
")",
":",
"return",
"self",
".",
"_has_setup_test"
] | [
233,
4
] | [
239,
35
] | python | en | ['en', 'en', 'en'] | True |
LightningDataModule.add_argparse_args | (cls, parent_parser: ArgumentParser) | r"""Extends existing argparse by default `LightningDataModule` attributes. | r"""Extends existing argparse by default `LightningDataModule` attributes. | def add_argparse_args(cls, parent_parser: ArgumentParser) -> ArgumentParser:
r"""Extends existing argparse by default `LightningDataModule` attributes."""
parser = ArgumentParser(parents=[parent_parser], add_help=False)
added_args = [x.dest for x in parser._actions]
blacklist = ["kwargs... | [
"def",
"add_argparse_args",
"(",
"cls",
",",
"parent_parser",
":",
"ArgumentParser",
")",
"->",
"ArgumentParser",
":",
"parser",
"=",
"ArgumentParser",
"(",
"parents",
"=",
"[",
"parent_parser",
"]",
",",
"add_help",
"=",
"False",
")",
"added_args",
"=",
"[",
... | [
250,
4
] | [
296,
21
] | python | en | ['en', 'en', 'en'] | True |
LightningDataModule.from_argparse_args | (cls, args: Union[Namespace, ArgumentParser], **kwargs) |
Create an instance from CLI arguments.
Args:
args: The parser or namespace to take arguments from. Only known arguments will be
parsed and passed to the :class:`LightningDataModule`.
**kwargs: Additional keyword arguments that may override ones in the parser or nam... |
Create an instance from CLI arguments. | def from_argparse_args(cls, args: Union[Namespace, ArgumentParser], **kwargs):
"""
Create an instance from CLI arguments.
Args:
args: The parser or namespace to take arguments from. Only known arguments will be
parsed and passed to the :class:`LightningDataModule`.
... | [
"def",
"from_argparse_args",
"(",
"cls",
",",
"args",
":",
"Union",
"[",
"Namespace",
",",
"ArgumentParser",
"]",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"args",
",",
"ArgumentParser",
")",
":",
"args",
"=",
"cls",
".",
"parse_argpars... | [
299,
4
] | [
325,
39
] | python | en | ['en', 'error', 'th'] | False |
LightningDataModule.get_init_arguments_and_types | (cls) | r"""Scans the DataModule signature and returns argument names, types and default values.
Returns:
List with tuples of 3 values:
(argument name, set with argument types, argument default value).
| r"""Scans the DataModule signature and returns argument names, types and default values. | def get_init_arguments_and_types(cls) -> List[Tuple[str, Tuple, Any]]:
r"""Scans the DataModule signature and returns argument names, types and default values.
Returns:
List with tuples of 3 values:
(argument name, set with argument types, argument default value).
"""
... | [
"def",
"get_init_arguments_and_types",
"(",
"cls",
")",
"->",
"List",
"[",
"Tuple",
"[",
"str",
",",
"Tuple",
",",
"Any",
"]",
"]",
":",
"datamodule_default_params",
"=",
"inspect",
".",
"signature",
"(",
"cls",
".",
"__init__",
")",
".",
"parameters",
"na... | [
328,
4
] | [
347,
32
] | python | en | ['en', 'en', 'en'] | True |
LightningDataModule.from_datasets | (
cls,
train_dataset: Optional[Union[Dataset, Sequence[Dataset], Mapping[str, Dataset]]] = None,
val_dataset: Optional[Union[Dataset, Sequence[Dataset]]] = None,
test_dataset: Optional[Union[Dataset, Sequence[Dataset]]] = None,
batch_size: int = 1,
num_workers: int = 0,
... | r"""
Create an instance from torch.utils.data.Dataset.
Args:
train_dataset: (optional) Dataset to be used for train_dataloader()
val_dataset: (optional) Dataset or list of Dataset to be used for val_dataloader()
test_dataset: (optional) Dataset or list of Dataset to ... | r"""
Create an instance from torch.utils.data.Dataset. | def from_datasets(
cls,
train_dataset: Optional[Union[Dataset, Sequence[Dataset], Mapping[str, Dataset]]] = None,
val_dataset: Optional[Union[Dataset, Sequence[Dataset]]] = None,
test_dataset: Optional[Union[Dataset, Sequence[Dataset]]] = None,
batch_size: int = 1,
num_wo... | [
"def",
"from_datasets",
"(",
"cls",
",",
"train_dataset",
":",
"Optional",
"[",
"Union",
"[",
"Dataset",
",",
"Sequence",
"[",
"Dataset",
"]",
",",
"Mapping",
"[",
"str",
",",
"Dataset",
"]",
"]",
"]",
"=",
"None",
",",
"val_dataset",
":",
"Optional",
... | [
350,
4
] | [
404,
25
] | python | cy | ['en', 'cy', 'hi'] | False |
test_resume_early_stopping_from_checkpoint | (tmpdir) |
Prevent regressions to bugs:
https://github.com/PyTorchLightning/pytorch-lightning/issues/1464
https://github.com/PyTorchLightning/pytorch-lightning/issues/1463
|
Prevent regressions to bugs:
https://github.com/PyTorchLightning/pytorch-lightning/issues/1464
https://github.com/PyTorchLightning/pytorch-lightning/issues/1463
| def test_resume_early_stopping_from_checkpoint(tmpdir):
"""
Prevent regressions to bugs:
https://github.com/PyTorchLightning/pytorch-lightning/issues/1464
https://github.com/PyTorchLightning/pytorch-lightning/issues/1463
"""
seed_everything(42)
model = ClassificationModel()
dm = ClassifD... | [
"def",
"test_resume_early_stopping_from_checkpoint",
"(",
"tmpdir",
")",
":",
"seed_everything",
"(",
"42",
")",
"model",
"=",
"ClassificationModel",
"(",
")",
"dm",
"=",
"ClassifDataModule",
"(",
")",
"checkpoint_callback",
"=",
"ModelCheckpoint",
"(",
"dirpath",
"... | [
48,
0
] | [
85,
30
] | python | en | ['en', 'error', 'th'] | False |
test_early_stopping_no_extraneous_invocations | (tmpdir) | Test to ensure that callback methods aren't being invoked outside of the callback handler. | Test to ensure that callback methods aren't being invoked outside of the callback handler. | def test_early_stopping_no_extraneous_invocations(tmpdir):
"""Test to ensure that callback methods aren't being invoked outside of the callback handler."""
model = ClassificationModel()
dm = ClassifDataModule()
early_stop_callback = EarlyStopping(monitor='train_loss')
expected_count = 4
trainer ... | [
"def",
"test_early_stopping_no_extraneous_invocations",
"(",
"tmpdir",
")",
":",
"model",
"=",
"ClassificationModel",
"(",
")",
"dm",
"=",
"ClassifDataModule",
"(",
")",
"early_stop_callback",
"=",
"EarlyStopping",
"(",
"monitor",
"=",
"'train_loss'",
")",
"expected_c... | [
89,
0
] | [
106,
77
] | python | en | ['en', 'en', 'en'] | True |
test_early_stopping_patience | (tmpdir, loss_values, patience, expected_stop_epoch) | Test to ensure that early stopping is not triggered before patience is exhausted. | Test to ensure that early stopping is not triggered before patience is exhausted. | def test_early_stopping_patience(tmpdir, loss_values, patience, expected_stop_epoch):
"""Test to ensure that early stopping is not triggered before patience is exhausted."""
class ModelOverrideValidationReturn(BoringModel):
validation_return_values = torch.Tensor(loss_values)
def validation_ep... | [
"def",
"test_early_stopping_patience",
"(",
"tmpdir",
",",
"loss_values",
",",
"patience",
",",
"expected_stop_epoch",
")",
":",
"class",
"ModelOverrideValidationReturn",
"(",
"BoringModel",
")",
":",
"validation_return_values",
"=",
"torch",
".",
"Tensor",
"(",
"loss... | [
117,
0
] | [
137,
55
] | python | en | ['en', 'en', 'en'] | True |
test_early_stopping_patience_train | (tmpdir, validation_step, loss_values, patience, expected_stop_epoch) | Test to ensure that early stopping is not triggered before patience is exhausted. | Test to ensure that early stopping is not triggered before patience is exhausted. | def test_early_stopping_patience_train(tmpdir, validation_step, loss_values, patience, expected_stop_epoch):
"""Test to ensure that early stopping is not triggered before patience is exhausted."""
class ModelOverrideTrainReturn(BoringModel):
train_return_values = torch.Tensor(loss_values)
def ... | [
"def",
"test_early_stopping_patience_train",
"(",
"tmpdir",
",",
"validation_step",
",",
"loss_values",
",",
"patience",
",",
"expected_stop_epoch",
")",
":",
"class",
"ModelOverrideTrainReturn",
"(",
"BoringModel",
")",
":",
"train_return_values",
"=",
"torch",
".",
... | [
149,
0
] | [
172,
55
] | python | en | ['en', 'en', 'en'] | True |
test_early_stopping_no_val_step | (tmpdir) | Test that early stopping callback falls back to training metrics when no validation defined. | Test that early stopping callback falls back to training metrics when no validation defined. | def test_early_stopping_no_val_step(tmpdir):
"""Test that early stopping callback falls back to training metrics when no validation defined."""
model = ClassificationModel()
dm = ClassifDataModule()
model.validation_step = None
model.val_dataloader = None
stopping = EarlyStopping(monitor='trai... | [
"def",
"test_early_stopping_no_val_step",
"(",
"tmpdir",
")",
":",
"model",
"=",
"ClassificationModel",
"(",
")",
"dm",
"=",
"ClassifDataModule",
"(",
")",
"model",
".",
"validation_step",
"=",
"None",
"model",
".",
"val_dataloader",
"=",
"None",
"stopping",
"="... | [
187,
0
] | [
205,
57
] | python | en | ['en', 'en', 'en'] | True |
test_early_stopping_functionality_arbitrary_key | (tmpdir) | Tests whether early stopping works with a custom key and dictionary results on val step. | Tests whether early stopping works with a custom key and dictionary results on val step. | def test_early_stopping_functionality_arbitrary_key(tmpdir):
"""Tests whether early stopping works with a custom key and dictionary results on val step."""
class CurrentModel(BoringModel):
def validation_epoch_end(self, outputs):
losses = [8, 4, 2, 3, 4, 5, 8, 10]
val_loss = lo... | [
"def",
"test_early_stopping_functionality_arbitrary_key",
"(",
"tmpdir",
")",
":",
"class",
"CurrentModel",
"(",
"BoringModel",
")",
":",
"def",
"validation_epoch_end",
"(",
"self",
",",
"outputs",
")",
":",
"losses",
"=",
"[",
"8",
",",
"4",
",",
"2",
",",
... | [
229,
0
] | [
248,
62
] | python | en | ['en', 'en', 'en'] | True |
test_min_steps_override_early_stopping_functionality | (tmpdir, step_freeze, min_steps, min_epochs) | Excepted Behaviour:
IF `min_steps` was set to a higher value than the `trainer.global_step` when `early_stopping` is being triggered,
THEN the trainer should continue until reaching `trainer.global_step` == `min_steps`, and stop.
IF `min_epochs` resulted in a higher number of steps than the `trainer.global... | Excepted Behaviour:
IF `min_steps` was set to a higher value than the `trainer.global_step` when `early_stopping` is being triggered,
THEN the trainer should continue until reaching `trainer.global_step` == `min_steps`, and stop. | def test_min_steps_override_early_stopping_functionality(tmpdir, step_freeze, min_steps, min_epochs):
"""Excepted Behaviour:
IF `min_steps` was set to a higher value than the `trainer.global_step` when `early_stopping` is being triggered,
THEN the trainer should continue until reaching `trainer.global_step`... | [
"def",
"test_min_steps_override_early_stopping_functionality",
"(",
"tmpdir",
",",
"step_freeze",
",",
"min_steps",
",",
"min_epochs",
")",
":",
"_logger",
".",
"disabled",
"=",
"True",
"original_loss_value",
"=",
"10",
"limit_train_batches",
"=",
"3",
"patience",
"="... | [
252,
0
] | [
340,
28
] | python | en | ['en', 'en', 'en'] | False |
test_model_torch_save | (tmpdir) | Test to ensure torch save does not fail for model and trainer. | Test to ensure torch save does not fail for model and trainer. | def test_model_torch_save(tmpdir):
"""Test to ensure torch save does not fail for model and trainer."""
model = BoringModel()
num_epochs = 1
trainer = Trainer(
default_root_dir=tmpdir,
max_epochs=num_epochs,
)
temp_path = os.path.join(tmpdir, 'temp.pt')
trainer.fit(model)
... | [
"def",
"test_model_torch_save",
"(",
"tmpdir",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"num_epochs",
"=",
"1",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"max_epochs",
"=",
"num_epochs",
",",
")",
"temp_path",
"=",
"os",... | [
23,
0
] | [
37,
35
] | python | en | ['en', 'en', 'en'] | True |
test_model_torch_save_ddp_cpu | (tmpdir) | Test to ensure torch save does not fail for model and trainer using cpu ddp. | Test to ensure torch save does not fail for model and trainer using cpu ddp. | def test_model_torch_save_ddp_cpu(tmpdir):
"""Test to ensure torch save does not fail for model and trainer using cpu ddp."""
model = BoringModel()
num_epochs = 1
trainer = Trainer(
default_root_dir=tmpdir,
max_epochs=num_epochs,
accelerator="ddp_cpu",
num_processes=2,
... | [
"def",
"test_model_torch_save_ddp_cpu",
"(",
"tmpdir",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"num_epochs",
"=",
"1",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"max_epochs",
"=",
"num_epochs",
",",
"accelerator",
"=",
"\... | [
41,
0
] | [
56,
34
] | python | en | ['en', 'en', 'en'] | True |
test_model_torch_save_ddp_cuda | (tmpdir) | Test to ensure torch save does not fail for model and trainer using gpu ddp. | Test to ensure torch save does not fail for model and trainer using gpu ddp. | def test_model_torch_save_ddp_cuda(tmpdir):
"""Test to ensure torch save does not fail for model and trainer using gpu ddp."""
model = BoringModel()
num_epochs = 1
trainer = Trainer(
default_root_dir=tmpdir,
max_epochs=num_epochs,
accelerator="ddp_spawn",
gpus=2,
)
... | [
"def",
"test_model_torch_save_ddp_cuda",
"(",
"tmpdir",
")",
":",
"model",
"=",
"BoringModel",
"(",
")",
"num_epochs",
"=",
"1",
"trainer",
"=",
"Trainer",
"(",
"default_root_dir",
"=",
"tmpdir",
",",
"max_epochs",
"=",
"num_epochs",
",",
"accelerator",
"=",
"... | [
60,
0
] | [
75,
34
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.