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
entry_page
()
Display this webapp's HTML form.
Display this webapp's HTML form.
def entry_page() -> 'html': """Display this webapp's HTML form.""" return render_template('entry.html', the_title='Welcome to search4letters on the web!')
[ "def", "entry_page", "(", ")", "->", "'html'", ":", "return", "render_template", "(", "'entry.html'", ",", "the_title", "=", "'Welcome to search4letters on the web!'", ")" ]
[ 69, 0 ]
[ 72, 77 ]
python
en
['en', 'en', 'en']
True
view_the_log
()
Display the contents of the log file as a HTML table.
Display the contents of the log file as a HTML table.
def view_the_log() -> 'html': """Display the contents of the log file as a HTML table.""" try: with UseDatabase(app.config['dbconfig']) as cursor: _SQL = """select phrase, letters, ip, browser_string, results from log""" cursor.execute(_SQL) conten...
[ "def", "view_the_log", "(", ")", "->", "'html'", ":", "try", ":", "with", "UseDatabase", "(", "app", ".", "config", "[", "'dbconfig'", "]", ")", "as", "cursor", ":", "_SQL", "=", "\"\"\"select phrase, letters, ip, browser_string, results\n from log\...
[ 77, 0 ]
[ 99, 18 ]
python
en
['en', 'en', 'en']
True
test_unsupported_precision_plugins
()
Test error messages are raised for unsupported precision plugins with CPU.
Test error messages are raised for unsupported precision plugins with CPU.
def test_unsupported_precision_plugins(): """ Test error messages are raised for unsupported precision plugins with CPU. """ trainer = Mock() model = Mock() accelerator = CPUAccelerator( training_type_plugin=SingleDevicePlugin(torch.device("cpu")), precision_plugin=MixedPrecisionPlugin() ) ...
[ "def", "test_unsupported_precision_plugins", "(", ")", ":", "trainer", "=", "Mock", "(", ")", "model", "=", "Mock", "(", ")", "accelerator", "=", "CPUAccelerator", "(", "training_type_plugin", "=", "SingleDevicePlugin", "(", "torch", ".", "device", "(", "\"cpu\"...
[ 11, 0 ]
[ 19, 55 ]
python
en
['en', 'en', 'en']
True
_make_options_dict
(precision=None, threshold=None, edgeitems=None, linewidth=None, suppress=None, nanstr=None, infstr=None, sign=None, formatter=None, floatmode=None, legacy=None)
make a dictionary out of the non-None arguments, plus sanity checks
make a dictionary out of the non-None arguments, plus sanity checks
def _make_options_dict(precision=None, threshold=None, edgeitems=None, linewidth=None, suppress=None, nanstr=None, infstr=None, sign=None, formatter=None, floatmode=None, legacy=None): """ make a dictionary out of the non-None arguments, plus sanity checks """ opti...
[ "def", "_make_options_dict", "(", "precision", "=", "None", ",", "threshold", "=", "None", ",", "edgeitems", "=", "None", ",", "linewidth", "=", "None", ",", "suppress", "=", "None", ",", "nanstr", "=", "None", ",", "infstr", "=", "None", ",", "sign", ...
[ 68, 0 ]
[ 94, 18 ]
python
en
['en', 'en', 'en']
True
set_printoptions
(precision=None, threshold=None, edgeitems=None, linewidth=None, suppress=None, nanstr=None, infstr=None, formatter=None, sign=None, floatmode=None, **kwarg)
Set printing options. These options determine the way floating point numbers, arrays and other NumPy objects are displayed. Parameters ---------- precision : int or None, optional Number of digits of precision for floating point output (default 8). May be `None` if `floatmode`...
Set printing options.
def set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, suppress=None, nanstr=None, infstr=None, formatter=None, sign=None, floatmode=None, **kwarg): """ Set printing options. These options determine the way floating point numbers, arra...
[ "def", "set_printoptions", "(", "precision", "=", "None", ",", "threshold", "=", "None", ",", "edgeitems", "=", "None", ",", "linewidth", "=", "None", ",", "suppress", "=", "None", ",", "nanstr", "=", "None", ",", "infstr", "=", "None", ",", "formatter",...
[ 98, 0 ]
[ 257, 32 ]
python
en
['en', 'error', 'th']
False
get_printoptions
()
Return the current print options. Returns ------- print_opts : dict Dictionary of current print options with keys - precision : int - threshold : int - edgeitems : int - linewidth : int - suppress : bool - nanstr : str - in...
Return the current print options.
def get_printoptions(): """ Return the current print options. Returns ------- print_opts : dict Dictionary of current print options with keys - precision : int - threshold : int - edgeitems : int - linewidth : int - suppress : bool ...
[ "def", "get_printoptions", "(", ")", ":", "return", "_format_options", ".", "copy", "(", ")" ]
[ 261, 0 ]
[ 287, 33 ]
python
en
['en', 'error', 'th']
False
printoptions
(*args, **kwargs)
Context manager for setting print options. Set print options for the scope of the `with` block, and restore the old options at the end. See `set_printoptions` for the full description of available options. Examples -------- >>> from numpy.testing import assert_equal >>> with np.printoptio...
Context manager for setting print options.
def printoptions(*args, **kwargs): """Context manager for setting print options. Set print options for the scope of the `with` block, and restore the old options at the end. See `set_printoptions` for the full description of available options. Examples -------- >>> from numpy.testing impo...
[ "def", "printoptions", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "opts", "=", "np", ".", "get_printoptions", "(", ")", "try", ":", "np", ".", "set_printoptions", "(", "*", "args", ",", "*", "*", "kwargs", ")", "yield", "np", ".", "get_pr...
[ 292, 0 ]
[ 322, 35 ]
python
en
['da', 'en', 'en']
True
_leading_trailing
(a, edgeitems, index=())
Keep only the N-D corners (leading and trailing edges) of an array. Should be passed a base-class ndarray, since it makes no guarantees about preserving subclasses.
Keep only the N-D corners (leading and trailing edges) of an array.
def _leading_trailing(a, edgeitems, index=()): """ Keep only the N-D corners (leading and trailing edges) of an array. Should be passed a base-class ndarray, since it makes no guarantees about preserving subclasses. """ axis = len(index) if axis == a.ndim: return a[index] if a....
[ "def", "_leading_trailing", "(", "a", ",", "edgeitems", ",", "index", "=", "(", ")", ")", ":", "axis", "=", "len", "(", "index", ")", "if", "axis", "==", "a", ".", "ndim", ":", "return", "a", "[", "index", "]", "if", "a", ".", "shape", "[", "ax...
[ 325, 0 ]
[ 342, 71 ]
python
en
['en', 'error', 'th']
False
_object_format
(o)
Object arrays containing lists should be printed unambiguously
Object arrays containing lists should be printed unambiguously
def _object_format(o): """ Object arrays containing lists should be printed unambiguously """ if type(o) is list: fmt = 'list({!r})' else: fmt = '{!r}' return fmt.format(o)
[ "def", "_object_format", "(", "o", ")", ":", "if", "type", "(", "o", ")", "is", "list", ":", "fmt", "=", "'list({!r})'", "else", ":", "fmt", "=", "'{!r}'", "return", "fmt", ".", "format", "(", "o", ")" ]
[ 345, 0 ]
[ 351, 24 ]
python
en
['en', 'en', 'en']
True
_get_format_function
(data, **options)
find the right formatting function for the dtype_
find the right formatting function for the dtype_
def _get_format_function(data, **options): """ find the right formatting function for the dtype_ """ dtype_ = data.dtype dtypeobj = dtype_.type formatdict = _get_formatdict(data, **options) if issubclass(dtypeobj, _nt.bool_): return formatdict['bool']() elif issubclass(dtypeobj, ...
[ "def", "_get_format_function", "(", "data", ",", "*", "*", "options", ")", ":", "dtype_", "=", "data", ".", "dtype", "dtypeobj", "=", "dtype_", ".", "type", "formatdict", "=", "_get_formatdict", "(", "data", ",", "*", "*", "options", ")", "if", "issubcla...
[ 412, 0 ]
[ 448, 39 ]
python
en
['en', 'error', 'th']
False
_recursive_guard
(fillvalue='...')
Like the python 3.2 reprlib.recursive_repr, but forwards *args and **kwargs Decorates a function such that if it calls itself with the same first argument, it returns `fillvalue` instead of recursing. Largely copied from reprlib.recursive_repr
Like the python 3.2 reprlib.recursive_repr, but forwards *args and **kwargs
def _recursive_guard(fillvalue='...'): """ Like the python 3.2 reprlib.recursive_repr, but forwards *args and **kwargs Decorates a function such that if it calls itself with the same first argument, it returns `fillvalue` instead of recursing. Largely copied from reprlib.recursive_repr """ ...
[ "def", "_recursive_guard", "(", "fillvalue", "=", "'...'", ")", ":", "def", "decorating_function", "(", "f", ")", ":", "repr_running", "=", "set", "(", ")", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", "(", "self", ",", "*", "args",...
[ 451, 0 ]
[ 477, 30 ]
python
en
['en', 'error', 'th']
False
array2string
(a, max_line_width=None, precision=None, suppress_small=None, separator=' ', prefix="", style=np._NoValue, formatter=None, threshold=None, edgeitems=None, sign=None, floatmode=None, suffix="", **kwarg)
Return a string representation of an array. Parameters ---------- a : array_like Input array. max_line_width : int, optional Inserts newlines if text is longer than `max_line_width`. Defaults to ``numpy.get_printoptions()['linewidth']``. precision : int or None, optiona...
Return a string representation of an array.
def array2string(a, max_line_width=None, precision=None, suppress_small=None, separator=' ', prefix="", style=np._NoValue, formatter=None, threshold=None, edgeitems=None, sign=None, floatmode=None, suffix="", **kwarg): """ Return a string repre...
[ "def", "array2string", "(", "a", ",", "max_line_width", "=", "None", ",", "precision", "=", "None", ",", "suppress_small", "=", "None", ",", "separator", "=", "' '", ",", "prefix", "=", "\"\"", ",", "style", "=", "np", ".", "_NoValue", ",", "formatter", ...
[ 520, 0 ]
[ 699, 55 ]
python
en
['en', 'error', 'th']
False
_formatArray
(a, format_function, line_width, next_line_prefix, separator, edge_items, summary_insert, legacy)
formatArray is designed for two modes of operation: 1. Full output 2. Summarized output
formatArray is designed for two modes of operation:
def _formatArray(a, format_function, line_width, next_line_prefix, separator, edge_items, summary_insert, legacy): """formatArray is designed for two modes of operation: 1. Full output 2. Summarized output """ def recurser(index, hanging_indent, curr_width): """ B...
[ "def", "_formatArray", "(", "a", ",", "format_function", ",", "line_width", ",", "next_line_prefix", ",", "separator", ",", "edge_items", ",", "summary_insert", ",", "legacy", ")", ":", "def", "recurser", "(", "index", ",", "hanging_indent", ",", "curr_width", ...
[ 716, 0 ]
[ 832, 23 ]
python
en
['en', 'en', 'en']
True
format_float_scientific
(x, precision=None, unique=True, trim='k', sign=False, pad_left=None, exp_digits=None)
Format a floating-point scalar as a decimal string in scientific notation. Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the "Dragon4" algorithm. Parameters ---------- x : python float or numpy floating scalar Value to format. ...
Format a floating-point scalar as a decimal string in scientific notation.
def format_float_scientific(x, precision=None, unique=True, trim='k', sign=False, pad_left=None, exp_digits=None): """ Format a floating-point scalar as a decimal string in scientific notation. Provides control over rounding, trimming and padding. Uses and assumes IEEE unbia...
[ "def", "format_float_scientific", "(", "x", ",", "precision", "=", "None", ",", "unique", "=", "True", ",", "trim", "=", "'k'", ",", "sign", "=", "False", ",", "pad_left", "=", "None", ",", "exp_digits", "=", "None", ")", ":", "precision", "=", "_none_...
[ 999, 0 ]
[ 1064, 52 ]
python
en
['en', 'error', 'th']
False
format_float_positional
(x, precision=None, unique=True, fractional=True, trim='k', sign=False, pad_left=None, pad_right=None)
Format a floating-point scalar as a decimal string in positional notation. Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the "Dragon4" algorithm. Parameters ---------- x : python float or numpy floating scalar Value to format. ...
Format a floating-point scalar as a decimal string in positional notation.
def format_float_positional(x, precision=None, unique=True, fractional=True, trim='k', sign=False, pad_left=None, pad_right=None): """ Format a floating-point scalar as a decimal string in positional notation. Provides control over rounding, trimming ...
[ "def", "format_float_positional", "(", "x", ",", "precision", "=", "None", ",", "unique", "=", "True", ",", "fractional", "=", "True", ",", "trim", "=", "'k'", ",", "sign", "=", "False", ",", "pad_left", "=", "None", ",", "pad_right", "=", "None", ")",...
[ 1068, 0 ]
[ 1141, 50 ]
python
en
['en', 'error', 'th']
False
_void_scalar_repr
(x)
Implements the repr for structured-void scalars. It is called from the scalartypes.c.src code, and is placed here because it uses the elementwise formatters defined above.
Implements the repr for structured-void scalars. It is called from the scalartypes.c.src code, and is placed here because it uses the elementwise formatters defined above.
def _void_scalar_repr(x): """ Implements the repr for structured-void scalars. It is called from the scalartypes.c.src code, and is placed here because it uses the elementwise formatters defined above. """ return StructuredVoidFormat.from_data(array(x), **_format_options)(x)
[ "def", "_void_scalar_repr", "(", "x", ")", ":", "return", "StructuredVoidFormat", ".", "from_data", "(", "array", "(", "x", ")", ",", "*", "*", "_format_options", ")", "(", "x", ")" ]
[ 1330, 0 ]
[ 1336, 73 ]
python
en
['en', 'error', 'th']
False
dtype_is_implied
(dtype)
Determine if the given dtype is implied by the representation of its values. Parameters ---------- dtype : dtype Data type Returns ------- implied : bool True if the dtype is implied by the representation of its values. Examples -------- >>> np.core.arrayprint...
Determine if the given dtype is implied by the representation of its values.
def dtype_is_implied(dtype): """ Determine if the given dtype is implied by the representation of its values. Parameters ---------- dtype : dtype Data type Returns ------- implied : bool True if the dtype is implied by the representation of its values. Examples ...
[ "def", "dtype_is_implied", "(", "dtype", ")", ":", "dtype", "=", "np", ".", "dtype", "(", "dtype", ")", "if", "_format_options", "[", "'legacy'", "]", "==", "'1.13'", "and", "dtype", ".", "type", "==", "bool_", ":", "return", "False", "# not just void type...
[ 1346, 0 ]
[ 1379, 38 ]
python
en
['en', 'error', 'th']
False
dtype_short_repr
(dtype)
Convert a dtype to a short form which evaluates to the same dtype. The intent is roughly that the following holds >>> from numpy import * >>> dt = np.int64([1, 2]).dtype >>> assert eval(dtype_short_repr(dt)) == dt
Convert a dtype to a short form which evaluates to the same dtype.
def dtype_short_repr(dtype): """ Convert a dtype to a short form which evaluates to the same dtype. The intent is roughly that the following holds >>> from numpy import * >>> dt = np.int64([1, 2]).dtype >>> assert eval(dtype_short_repr(dt)) == dt """ if dtype.names is not None: ...
[ "def", "dtype_short_repr", "(", "dtype", ")", ":", "if", "dtype", ".", "names", "is", "not", "None", ":", "# structured dtypes give a list or tuple repr", "return", "str", "(", "dtype", ")", "elif", "issubclass", "(", "dtype", ".", "type", ",", "flexible", ")"...
[ 1382, 0 ]
[ 1404, 19 ]
python
en
['en', 'error', 'th']
False
_array_repr_implementation
( arr, max_line_width=None, precision=None, suppress_small=None, array2string=array2string)
Internal version of array_repr() that allows overriding array2string.
Internal version of array_repr() that allows overriding array2string.
def _array_repr_implementation( arr, max_line_width=None, precision=None, suppress_small=None, array2string=array2string): """Internal version of array_repr() that allows overriding array2string.""" if max_line_width is None: max_line_width = _format_options['linewidth'] if type(arr...
[ "def", "_array_repr_implementation", "(", "arr", ",", "max_line_width", "=", "None", ",", "precision", "=", "None", ",", "suppress_small", "=", "None", ",", "array2string", "=", "array2string", ")", ":", "if", "max_line_width", "is", "None", ":", "max_line_width...
[ 1407, 0 ]
[ 1451, 39 ]
python
en
['en', 'en', 'en']
True
array_repr
(arr, max_line_width=None, precision=None, suppress_small=None)
Return the string representation of an array. Parameters ---------- arr : ndarray Input array. max_line_width : int, optional Inserts newlines if text is longer than `max_line_width`. Defaults to ``numpy.get_printoptions()['linewidth']``. precision : int, optional ...
Return the string representation of an array.
def array_repr(arr, max_line_width=None, precision=None, suppress_small=None): """ Return the string representation of an array. Parameters ---------- arr : ndarray Input array. max_line_width : int, optional Inserts newlines if text is longer than `max_line_width`. Defa...
[ "def", "array_repr", "(", "arr", ",", "max_line_width", "=", "None", ",", "precision", "=", "None", ",", "suppress_small", "=", "None", ")", ":", "return", "_array_repr_implementation", "(", "arr", ",", "max_line_width", ",", "precision", ",", "suppress_small", ...
[ 1460, 0 ]
[ 1505, 55 ]
python
en
['en', 'error', 'th']
False
_array_str_implementation
( a, max_line_width=None, precision=None, suppress_small=None, array2string=array2string)
Internal version of array_str() that allows overriding array2string.
Internal version of array_str() that allows overriding array2string.
def _array_str_implementation( a, max_line_width=None, precision=None, suppress_small=None, array2string=array2string): """Internal version of array_str() that allows overriding array2string.""" if (_format_options['legacy'] == '1.13' and a.shape == () and not a.dtype.names): ...
[ "def", "_array_str_implementation", "(", "a", ",", "max_line_width", "=", "None", ",", "precision", "=", "None", ",", "suppress_small", "=", "None", ",", "array2string", "=", "array2string", ")", ":", "if", "(", "_format_options", "[", "'legacy'", "]", "==", ...
[ 1511, 0 ]
[ 1528, 78 ]
python
en
['en', 'en', 'en']
True
array_str
(a, max_line_width=None, precision=None, suppress_small=None)
Return a string representation of the data in an array. The data in the array is returned as a single string. This function is similar to `array_repr`, the difference being that `array_repr` also returns information on the kind of array and its data type. Parameters ---------- a : ndarra...
Return a string representation of the data in an array.
def array_str(a, max_line_width=None, precision=None, suppress_small=None): """ Return a string representation of the data in an array. The data in the array is returned as a single string. This function is similar to `array_repr`, the difference being that `array_repr` also returns information on...
[ "def", "array_str", "(", "a", ",", "max_line_width", "=", "None", ",", "precision", "=", "None", ",", "suppress_small", "=", "None", ")", ":", "return", "_array_str_implementation", "(", "a", ",", "max_line_width", ",", "precision", ",", "suppress_small", ")" ...
[ 1537, 0 ]
[ 1573, 53 ]
python
en
['en', 'error', 'th']
False
set_string_function
(f, repr=True)
Set a Python function to be used when pretty printing arrays. Parameters ---------- f : function or None Function to be used to pretty print arrays. The function should expect a single array argument and return a string of the representation of the array. If None, the function ...
Set a Python function to be used when pretty printing arrays.
def set_string_function(f, repr=True): """ Set a Python function to be used when pretty printing arrays. Parameters ---------- f : function or None Function to be used to pretty print arrays. The function should expect a single array argument and return a string of the representatio...
[ "def", "set_string_function", "(", "f", ",", "repr", "=", "True", ")", ":", "if", "f", "is", "None", ":", "if", "repr", ":", "return", "multiarray", ".", "set_string_function", "(", "_default_array_repr", ",", "1", ")", "else", ":", "return", "multiarray",...
[ 1584, 0 ]
[ 1641, 54 ]
python
en
['en', 'error', 'th']
False
StructuredVoidFormat.from_data
(cls, data, **options)
This is a second way to initialize StructuredVoidFormat, using the raw data as input. Added to avoid changing the signature of __init__.
This is a second way to initialize StructuredVoidFormat, using the raw data as input. Added to avoid changing the signature of __init__.
def from_data(cls, data, **options): """ This is a second way to initialize StructuredVoidFormat, using the raw data as input. Added to avoid changing the signature of __init__. """ format_functions = [] for field_name in data.dtype.names: format_function = _g...
[ "def", "from_data", "(", "cls", ",", "data", ",", "*", "*", "options", ")", ":", "format_functions", "=", "[", "]", "for", "field_name", "in", "data", ".", "dtype", ".", "names", ":", "format_function", "=", "_get_format_function", "(", "data", "[", "fie...
[ 1296, 4 ]
[ 1307, 36 ]
python
en
['en', 'error', 'th']
False
english_upper
(s)
Apply English case rules to convert ASCII strings to all upper case. This is an internal utility function to replace calls to str.upper() such that we can avoid changing behavior with changing locales. In particular, Turkish has distinct dotted and dotless variants of the Latin letter "I" in both lowe...
Apply English case rules to convert ASCII strings to all upper case.
def english_upper(s): """ Apply English case rules to convert ASCII strings to all upper case. This is an internal utility function to replace calls to str.upper() such that we can avoid changing behavior with changing locales. In particular, Turkish has distinct dotted and dotless variants of the Lati...
[ "def", "english_upper", "(", "s", ")", ":", "uppered", "=", "s", ".", "translate", "(", "UPPER_TABLE", ")", "return", "uppered" ]
[ 161, 0 ]
[ 187, 18 ]
python
en
['en', 'en', 'en']
True
_checknames
(descr, names=None)
Checks that field names ``descr`` are not reserved keywords. If this is the case, a default 'f%i' is substituted. If the argument `names` is not None, updates the field names to valid names.
Checks that field names ``descr`` are not reserved keywords.
def _checknames(descr, names=None): """ Checks that field names ``descr`` are not reserved keywords. If this is the case, a default 'f%i' is substituted. If the argument `names` is not None, updates the field names to valid names. """ ndescr = len(descr) default_names = ['f%i' % i for i i...
[ "def", "_checknames", "(", "descr", ",", "names", "=", "None", ")", ":", "ndescr", "=", "len", "(", "descr", ")", "default_names", "=", "[", "'f%i'", "%", "i", "for", "i", "in", "range", "(", "ndescr", ")", "]", "if", "names", "is", "None", ":", ...
[ 48, 0 ]
[ 79, 27 ]
python
en
['en', 'error', 'th']
False
_mrreconstruct
(subtype, baseclass, baseshape, basetype,)
Build a new MaskedArray from the information stored in a pickle.
Build a new MaskedArray from the information stored in a pickle.
def _mrreconstruct(subtype, baseclass, baseshape, basetype,): """ Build a new MaskedArray from the information stored in a pickle. """ _data = ndarray.__new__(baseclass, baseshape, basetype).view(subtype) _mask = ndarray.__new__(ndarray, baseshape, 'b1') return subtype.__new__(subtype, _data, m...
[ "def", "_mrreconstruct", "(", "subtype", ",", "baseclass", ",", "baseshape", ",", "basetype", ",", ")", ":", "_data", "=", "ndarray", ".", "__new__", "(", "baseclass", ",", "baseshape", ",", "basetype", ")", ".", "view", "(", "subtype", ")", "_mask", "="...
[ 490, 0 ]
[ 497, 71 ]
python
en
['en', 'error', 'th']
False
fromarrays
(arraylist, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None, fill_value=None)
Creates a mrecarray from a (flat) list of masked arrays. Parameters ---------- arraylist : sequence A list of (masked) arrays. Each element of the sequence is first converted to a masked array if needed. If a 2D array is passed as argument, it is processed line by line dtyp...
Creates a mrecarray from a (flat) list of masked arrays.
def fromarrays(arraylist, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None, fill_value=None): """ Creates a mrecarray from a (flat) list of masked arrays. Parameters ---------- arraylist : sequence A list of (masked) ...
[ "def", "fromarrays", "(", "arraylist", ",", "dtype", "=", "None", ",", "shape", "=", "None", ",", "formats", "=", "None", ",", "names", "=", "None", ",", "titles", "=", "None", ",", "aligned", "=", "False", ",", "byteorder", "=", "None", ",", "fill_v...
[ 507, 0 ]
[ 547, 17 ]
python
en
['en', 'error', 'th']
False
fromrecords
(reclist, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None, fill_value=None, mask=nomask)
Creates a MaskedRecords from a list of records. Parameters ---------- reclist : sequence A list of records. Each element of the sequence is first converted to a masked array if needed. If a 2D array is passed as argument, it is processed line by line dtype : {None, dtype}, ...
Creates a MaskedRecords from a list of records.
def fromrecords(reclist, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None, fill_value=None, mask=nomask): """ Creates a MaskedRecords from a list of records. Parameters ---------- reclist : sequence A list of record...
[ "def", "fromrecords", "(", "reclist", ",", "dtype", "=", "None", ",", "shape", "=", "None", ",", "formats", "=", "None", ",", "names", "=", "None", ",", "titles", "=", "None", ",", "aligned", "=", "False", ",", "byteorder", "=", "None", ",", "fill_va...
[ 550, 0 ]
[ 612, 15 ]
python
en
['en', 'error', 'th']
False
_guessvartypes
(arr)
Tries to guess the dtypes of the str_ ndarray `arr`. Guesses by testing element-wise conversion. Returns a list of dtypes. The array is first converted to ndarray. If the array is 2D, the test is performed on the first line. An exception is raised if the file is 3D or more.
Tries to guess the dtypes of the str_ ndarray `arr`.
def _guessvartypes(arr): """ Tries to guess the dtypes of the str_ ndarray `arr`. Guesses by testing element-wise conversion. Returns a list of dtypes. The array is first converted to ndarray. If the array is 2D, the test is performed on the first line. An exception is raised if the file is 3D ...
[ "def", "_guessvartypes", "(", "arr", ")", ":", "vartypes", "=", "[", "]", "arr", "=", "np", ".", "asarray", "(", "arr", ")", "if", "arr", ".", "ndim", "==", "2", ":", "arr", "=", "arr", "[", "0", "]", "elif", "arr", ".", "ndim", ">", "2", ":"...
[ 615, 0 ]
[ 649, 19 ]
python
en
['en', 'error', 'th']
False
openfile
(fname)
Opens the file handle of file `fname`.
Opens the file handle of file `fname`.
def openfile(fname): """ Opens the file handle of file `fname`. """ # A file handle if hasattr(fname, 'readline'): return fname # Try to open the file and guess its type try: f = open(fname) except IOError: raise IOError("No such file: '%s'" % fname) if f.rea...
[ "def", "openfile", "(", "fname", ")", ":", "# A file handle", "if", "hasattr", "(", "fname", ",", "'readline'", ")", ":", "return", "fname", "# Try to open the file and guess its type", "try", ":", "f", "=", "open", "(", "fname", ")", "except", "IOError", ":",...
[ 652, 0 ]
[ 669, 49 ]
python
en
['en', 'error', 'th']
False
fromtextfile
(fname, delimitor=None, commentchar='#', missingchar='', varnames=None, vartypes=None)
Creates a mrecarray from data stored in the file `filename`. Parameters ---------- fname : {file name/handle} Handle of an opened file. delimitor : {None, string}, optional Alphanumeric character used to separate columns in the file. If None, any (group of) white spacestrin...
Creates a mrecarray from data stored in the file `filename`.
def fromtextfile(fname, delimitor=None, commentchar='#', missingchar='', varnames=None, vartypes=None): """ Creates a mrecarray from data stored in the file `filename`. Parameters ---------- fname : {file name/handle} Handle of an opened file. delimitor : {None, string}...
[ "def", "fromtextfile", "(", "fname", ",", "delimitor", "=", "None", ",", "commentchar", "=", "'#'", ",", "missingchar", "=", "''", ",", "varnames", "=", "None", ",", "vartypes", "=", "None", ")", ":", "# Try to open the file.", "ftext", "=", "openfile", "(...
[ 672, 0 ]
[ 737, 46 ]
python
en
['en', 'error', 'th']
False
addfield
(mrecord, newfield, newfieldname=None)
Adds a new field to the masked record array Uses `newfield` as data and `newfieldname` as name. If `newfieldname` is None, the new field name is set to 'fi', where `i` is the number of existing fields.
Adds a new field to the masked record array
def addfield(mrecord, newfield, newfieldname=None): """Adds a new field to the masked record array Uses `newfield` as data and `newfieldname` as name. If `newfieldname` is None, the new field name is set to 'fi', where `i` is the number of existing fields. """ _data = mrecord._data _mask =...
[ "def", "addfield", "(", "mrecord", ",", "newfield", ",", "newfieldname", "=", "None", ")", ":", "_data", "=", "mrecord", ".", "_data", "_mask", "=", "mrecord", ".", "_mask", "if", "newfieldname", "is", "None", "or", "newfieldname", "in", "reserved_fields", ...
[ 740, 0 ]
[ 774, 18 ]
python
en
['en', 'en', 'en']
True
MaskedRecords._data
(self)
Returns the data as a recarray.
Returns the data as a recarray.
def _data(self): """ Returns the data as a recarray. """ return ndarray.view(self, recarray)
[ "def", "_data", "(", "self", ")", ":", "return", "ndarray", ".", "view", "(", "self", ",", "recarray", ")" ]
[ 169, 4 ]
[ 174, 43 ]
python
en
['en', 'error', 'th']
False
MaskedRecords._fieldmask
(self)
Alias to mask.
Alias to mask.
def _fieldmask(self): """ Alias to mask. """ return self._mask
[ "def", "_fieldmask", "(", "self", ")", ":", "return", "self", ".", "_mask" ]
[ 177, 4 ]
[ 182, 25 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.__len__
(self)
Returns the length
Returns the length
def __len__(self): """ Returns the length """ # We have more than one record if self.ndim: return len(self._data) # We have only one record: return the nb of fields return len(self.dtype)
[ "def", "__len__", "(", "self", ")", ":", "# We have more than one record", "if", "self", ".", "ndim", ":", "return", "len", "(", "self", ".", "_data", ")", "# We have only one record: return the nb of fields", "return", "len", "(", "self", ".", "dtype", ")" ]
[ 184, 4 ]
[ 193, 30 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.__setattr__
(self, attr, val)
Sets the attribute attr to the value val.
Sets the attribute attr to the value val.
def __setattr__(self, attr, val): """ Sets the attribute attr to the value val. """ # Should we call __setmask__ first ? if attr in ['mask', 'fieldmask']: self.__setmask__(val) return # Create a shortcut (so that we don't have to call getattr all ...
[ "def", "__setattr__", "(", "self", ",", "attr", ",", "val", ")", ":", "# Should we call __setmask__ first ?", "if", "attr", "in", "[", "'mask'", ",", "'fieldmask'", "]", ":", "self", ".", "__setmask__", "(", "val", ")", "return", "# Create a shortcut (so that we...
[ 241, 4 ]
[ 295, 18 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.__getitem__
(self, indx)
Returns all the fields sharing the same fieldname base. The fieldname base is either `_data` or `_mask`.
Returns all the fields sharing the same fieldname base.
def __getitem__(self, indx): """ Returns all the fields sharing the same fieldname base. The fieldname base is either `_data` or `_mask`. """ _localdict = self.__dict__ _mask = ndarray.__getattribute__(self, '_mask') _data = ndarray.view(self, _localdict['_basec...
[ "def", "__getitem__", "(", "self", ",", "indx", ")", ":", "_localdict", "=", "self", ".", "__dict__", "_mask", "=", "ndarray", ".", "__getattribute__", "(", "self", ",", "'_mask'", ")", "_data", "=", "ndarray", ".", "view", "(", "self", ",", "_localdict"...
[ 297, 4 ]
[ 327, 18 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.__setitem__
(self, indx, value)
Sets the given record to value.
Sets the given record to value.
def __setitem__(self, indx, value): """ Sets the given record to value. """ MaskedArray.__setitem__(self, indx, value) if isinstance(indx, basestring): self._mask[indx] = ma.getmaskarray(value)
[ "def", "__setitem__", "(", "self", ",", "indx", ",", "value", ")", ":", "MaskedArray", ".", "__setitem__", "(", "self", ",", "indx", ",", "value", ")", "if", "isinstance", "(", "indx", ",", "basestring", ")", ":", "self", ".", "_mask", "[", "indx", "...
[ 329, 4 ]
[ 336, 53 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.__str__
(self)
Calculates the string representation.
Calculates the string representation.
def __str__(self): """ Calculates the string representation. """ if self.size > 1: mstr = ["(%s)" % ",".join([str(i) for i in s]) for s in zip(*[getattr(self, f) for f in self.dtype.names])] return "[%s]" % ", ".join(mstr) else: ...
[ "def", "__str__", "(", "self", ")", ":", "if", "self", ".", "size", ">", "1", ":", "mstr", "=", "[", "\"(%s)\"", "%", "\",\"", ".", "join", "(", "[", "str", "(", "i", ")", "for", "i", "in", "s", "]", ")", "for", "s", "in", "zip", "(", "*", ...
[ 338, 4 ]
[ 350, 43 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.__repr__
(self)
Calculates the repr representation.
Calculates the repr representation.
def __repr__(self): """ Calculates the repr representation. """ _names = self.dtype.names fmt = "%%%is : %%s" % (max([len(n) for n in _names]) + 4,) reprstr = [fmt % (f, getattr(self, f)) for f in self.dtype.names] reprstr.insert(0, 'masked_records(') rep...
[ "def", "__repr__", "(", "self", ")", ":", "_names", "=", "self", ".", "dtype", ".", "names", "fmt", "=", "\"%%%is : %%s\"", "%", "(", "max", "(", "[", "len", "(", "n", ")", "for", "n", "in", "_names", "]", ")", "+", "4", ",", ")", "reprstr", "=...
[ 352, 4 ]
[ 363, 38 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.view
(self, dtype=None, type=None)
Returns a view of the mrecarray.
Returns a view of the mrecarray.
def view(self, dtype=None, type=None): """ Returns a view of the mrecarray. """ # OK, basic copy-paste from MaskedArray.view. if dtype is None: if type is None: output = ndarray.view(self) else: output = ndarray.view(self, ...
[ "def", "view", "(", "self", ",", "dtype", "=", "None", ",", "type", "=", "None", ")", ":", "# OK, basic copy-paste from MaskedArray.view.", "if", "dtype", "is", "None", ":", "if", "type", "is", "None", ":", "output", "=", "ndarray", ".", "view", "(", "se...
[ 365, 4 ]
[ 404, 21 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.harden_mask
(self)
Forces the mask to hard.
Forces the mask to hard.
def harden_mask(self): """ Forces the mask to hard. """ self._hardmask = True
[ "def", "harden_mask", "(", "self", ")", ":", "self", ".", "_hardmask", "=", "True" ]
[ 406, 4 ]
[ 411, 29 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.soften_mask
(self)
Forces the mask to soft
Forces the mask to soft
def soften_mask(self): """ Forces the mask to soft """ self._hardmask = False
[ "def", "soften_mask", "(", "self", ")", ":", "self", ".", "_hardmask", "=", "False" ]
[ 413, 4 ]
[ 418, 30 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.copy
(self)
Returns a copy of the masked record.
Returns a copy of the masked record.
def copy(self): """ Returns a copy of the masked record. """ copied = self._data.copy().view(type(self)) copied._mask = self._mask.copy() return copied
[ "def", "copy", "(", "self", ")", ":", "copied", "=", "self", ".", "_data", ".", "copy", "(", ")", ".", "view", "(", "type", "(", "self", ")", ")", "copied", ".", "_mask", "=", "self", ".", "_mask", ".", "copy", "(", ")", "return", "copied" ]
[ 420, 4 ]
[ 427, 21 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.tolist
(self, fill_value=None)
Return the data portion of the array as a list. Data items are converted to the nearest compatible Python type. Masked values are converted to fill_value. If fill_value is None, the corresponding entries in the output list will be ``None``.
Return the data portion of the array as a list.
def tolist(self, fill_value=None): """ Return the data portion of the array as a list. Data items are converted to the nearest compatible Python type. Masked values are converted to fill_value. If fill_value is None, the corresponding entries in the output list will be ``None``....
[ "def", "tolist", "(", "self", ",", "fill_value", "=", "None", ")", ":", "if", "fill_value", "is", "not", "None", ":", "return", "self", ".", "filled", "(", "fill_value", ")", ".", "tolist", "(", ")", "result", "=", "narray", "(", "self", ".", "filled...
[ 429, 4 ]
[ 443, 30 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.__getstate__
(self)
Return the internal state of the masked array. This is for pickling.
Return the internal state of the masked array.
def __getstate__(self): """Return the internal state of the masked array. This is for pickling. """ state = (1, self.shape, self.dtype, self.flags.fnc, self._data.tobytes(), self._mask.tobytes(), ...
[ "def", "__getstate__", "(", "self", ")", ":", "state", "=", "(", "1", ",", "self", ".", "shape", ",", "self", ".", "dtype", ",", "self", ".", "flags", ".", "fnc", ",", "self", ".", "_data", ".", "tobytes", "(", ")", ",", "self", ".", "_mask", "...
[ 445, 4 ]
[ 459, 20 ]
python
en
['en', 'en', 'en']
True
MaskedRecords.__setstate__
(self, state)
Restore the internal state of the masked array. This is for pickling. ``state`` is typically the output of the ``__getstate__`` output, and is a 5-tuple: - class name - a tuple giving the shape of the data - a typecode for the data - a binary string for the da...
Restore the internal state of the masked array.
def __setstate__(self, state): """ Restore the internal state of the masked array. This is for pickling. ``state`` is typically the output of the ``__getstate__`` output, and is a 5-tuple: - class name - a tuple giving the shape of the data - a typecode for the...
[ "def", "__setstate__", "(", "self", ",", "state", ")", ":", "(", "ver", ",", "shp", ",", "typ", ",", "isf", ",", "raw", ",", "msk", ",", "flv", ")", "=", "state", "ndarray", ".", "__setstate__", "(", "self", ",", "(", "shp", ",", "typ", ",", "i...
[ 461, 4 ]
[ 479, 29 ]
python
en
['en', 'error', 'th']
False
MaskedRecords.__reduce__
(self)
Return a 3-tuple for pickling a MaskedArray.
Return a 3-tuple for pickling a MaskedArray.
def __reduce__(self): """ Return a 3-tuple for pickling a MaskedArray. """ return (_mrreconstruct, (self.__class__, self._baseclass, (0,), 'b',), self.__getstate__())
[ "def", "__reduce__", "(", "self", ")", ":", "return", "(", "_mrreconstruct", ",", "(", "self", ".", "__class__", ",", "self", ".", "_baseclass", ",", "(", "0", ",", ")", ",", "'b'", ",", ")", ",", "self", ".", "__getstate__", "(", ")", ")" ]
[ 481, 4 ]
[ 488, 36 ]
python
en
['en', 'error', 'th']
False
CommandLineParser.join
(argv)
Join a list of arguments into a command line string
Join a list of arguments into a command line string
def join(argv): """ Join a list of arguments into a command line string """ raise NotImplementedError
[ "def", "join", "(", "argv", ")", ":", "raise", "NotImplementedError" ]
[ 24, 4 ]
[ 26, 33 ]
python
en
['en', 'en', 'en']
True
CommandLineParser.split
(cmd)
Split a command line string into a list of arguments
Split a command line string into a list of arguments
def split(cmd): """ Split a command line string into a list of arguments """ raise NotImplementedError
[ "def", "split", "(", "cmd", ")", ":", "raise", "NotImplementedError" ]
[ 29, 4 ]
[ 31, 33 ]
python
en
['en', 'en', 'en']
True
ActionsClassTests.test_get_all_actions
(self)
Returns a dictionary listing all the functions on the class that have been decorated as actions, with some of the data about them.
Returns a dictionary listing all the functions on the class that have been decorated as actions, with some of the data about them.
def test_get_all_actions(self): """Returns a dictionary listing all the functions on the class that have been decorated as actions, with some of the data about them. """ class SomeActions(BaseActions): @rule_action(params={'foo': FIELD_TEXT}) def some_action(self...
[ "def", "test_get_all_actions", "(", "self", ")", ":", "class", "SomeActions", "(", "BaseActions", ")", ":", "@", "rule_action", "(", "params", "=", "{", "'foo'", ":", "FIELD_TEXT", "}", ")", "def", "some_action", "(", "self", ",", "foo", ")", ":", "retur...
[ 12, 4 ]
[ 32, 65 ]
python
en
['en', 'en', 'en']
True
ActionsClassTests.test_rule_action_with_no_params_or_label
(self)
A rule action should not have to specify paramers or label.
A rule action should not have to specify paramers or label.
def test_rule_action_with_no_params_or_label(self): """ A rule action should not have to specify paramers or label. """ @rule_action() def some_action(self): pass self.assertTrue(some_action.is_rule_action)
[ "def", "test_rule_action_with_no_params_or_label", "(", "self", ")", ":", "@", "rule_action", "(", ")", "def", "some_action", "(", "self", ")", ":", "pass", "self", ".", "assertTrue", "(", "some_action", ".", "is_rule_action", ")" ]
[ 50, 4 ]
[ 57, 51 ]
python
en
['en', 'en', 'en']
True
EngineTests.test_run_all_some_rule_triggered
(self, *args)
By default, does not stop on first triggered rule. Returns True if any rule was triggered, otherwise False
By default, does not stop on first triggered rule. Returns True if any rule was triggered, otherwise False
def test_run_all_some_rule_triggered(self, *args): """By default, does not stop on first triggered rule. Returns True if any rule was triggered, otherwise False """ rule1 = {'conditions': 'condition1', 'actions': 'action name 1'} rule2 = {'conditions': 'condition2', 'actions': 'a...
[ "def", "test_run_all_some_rule_triggered", "(", "self", ",", "*", "args", ")", ":", "rule1", "=", "{", "'conditions'", ":", "'condition1'", ",", "'actions'", ":", "'action name 1'", "}", "rule2", "=", "{", "'conditions'", ":", "'condition2'", ",", "'actions'", ...
[ 18, 4 ]
[ 41, 50 ]
python
en
['en', 'en', 'en']
True
EngineTests.test_async_run_all_some_rule_triggered
(self, *args)
By default, does not stop on first triggered rule. Returns True if any rule was triggered, otherwise False
By default, does not stop on first triggered rule. Returns True if any rule was triggered, otherwise False
def test_async_run_all_some_rule_triggered(self, *args): """By default, does not stop on first triggered rule. Returns True if any rule was triggered, otherwise False """ rule1 = {'conditions': 'condition1', 'actions': 'action name 1'} rule2 = {'conditions': 'condition2', 'action...
[ "def", "test_async_run_all_some_rule_triggered", "(", "self", ",", "*", "args", ")", ":", "rule1", "=", "{", "'conditions'", ":", "'condition1'", ",", "'actions'", ":", "'action name 1'", "}", "rule2", "=", "{", "'conditions'", ":", "'condition2'", ",", "'action...
[ 44, 4 ]
[ 68, 56 ]
python
en
['en', 'en', 'en']
True
apply_tag
(tag, cases)
Add the given tag (a string) to each of the cases (a list of LinalgCase objects)
Add the given tag (a string) to each of the cases (a list of LinalgCase objects)
def apply_tag(tag, cases): """ Add the given tag (a string) to each of the cases (a list of LinalgCase objects) """ assert tag in all_tags, "Invalid tag" for case in cases: case.tags = case.tags | {tag} return cases
[ "def", "apply_tag", "(", "tag", ",", "cases", ")", ":", "assert", "tag", "in", "all_tags", ",", "\"Invalid tag\"", "for", "case", "in", "cases", ":", "case", ".", "tags", "=", "case", ".", "tags", "|", "{", "tag", "}", "return", "cases" ]
[ 91, 0 ]
[ 99, 16 ]
python
en
['en', 'error', 'th']
False
_stride_comb_iter
(x)
Generate cartesian product of strides for all axes
Generate cartesian product of strides for all axes
def _stride_comb_iter(x): """ Generate cartesian product of strides for all axes """ if not isinstance(x, np.ndarray): yield x, "nop" return stride_set = [(1,)] * x.ndim stride_set[-1] = (1, 3, -4) if x.ndim > 1: stride_set[-2] = (1, 3, -4) if x.ndim > 2: ...
[ "def", "_stride_comb_iter", "(", "x", ")", ":", "if", "not", "isinstance", "(", "x", ",", "np", ".", "ndarray", ")", ":", "yield", "x", ",", "\"nop\"", "return", "stride_set", "=", "[", "(", "1", ",", ")", "]", "*", "x", ".", "ndim", "stride_set", ...
[ 269, 0 ]
[ 314, 38 ]
python
en
['en', 'error', 'th']
False
LinalgCase.__init__
(self, name, a, b, tags=set())
A bundle of arguments to be passed to a test case, with an identifying name, the operands a and b, and a set of tags to filter the tests
A bundle of arguments to be passed to a test case, with an identifying name, the operands a and b, and a set of tags to filter the tests
def __init__(self, name, a, b, tags=set()): """ A bundle of arguments to be passed to a test case, with an identifying name, the operands a and b, and a set of tags to filter the tests """ assert_(isinstance(name, str)) self.name = name self.a = a self.b =...
[ "def", "__init__", "(", "self", ",", "name", ",", "a", ",", "b", ",", "tags", "=", "set", "(", ")", ")", ":", "assert_", "(", "isinstance", "(", "name", ",", "str", ")", ")", "self", ".", "name", "=", "name", "self", ".", "a", "=", "a", "self...
[ 70, 4 ]
[ 79, 35 ]
python
en
['en', 'error', 'th']
False
LinalgCase.check
(self, do)
Run the function `do` on this test case, expanding arguments
Run the function `do` on this test case, expanding arguments
def check(self, do): """ Run the function `do` on this test case, expanding arguments """ do(self.a, self.b, tags=self.tags)
[ "def", "check", "(", "self", ",", "do", ")", ":", "do", "(", "self", ".", "a", ",", "self", ".", "b", ",", "tags", "=", "self", ".", "tags", ")" ]
[ 81, 4 ]
[ 85, 42 ]
python
en
['en', 'error', 'th']
False
LinalgTestCase.check_cases
(self, require=set(), exclude=set())
Run func on each of the cases with all of the tags in require, and none of the tags in exclude
Run func on each of the cases with all of the tags in require, and none of the tags in exclude
def check_cases(self, require=set(), exclude=set()): """ Run func on each of the cases with all of the tags in require, and none of the tags in exclude """ for case in self.TEST_CASES: # filter by require and exclude if case.tags & require != require: ...
[ "def", "check_cases", "(", "self", ",", "require", "=", "set", "(", ")", ",", "exclude", "=", "set", "(", ")", ")", ":", "for", "case", "in", "self", ".", "TEST_CASES", ":", "# filter by require and exclude", "if", "case", ".", "tags", "&", "require", ...
[ 337, 4 ]
[ 354, 41 ]
python
en
['en', 'error', 'th']
False
TestSVD.test_empty_identity
(self)
Empty input should put an identity matrix in u or vh
Empty input should put an identity matrix in u or vh
def test_empty_identity(self): """ Empty input should put an identity matrix in u or vh """ x = np.empty((4, 0)) u, s, vh = linalg.svd(x, compute_uv=True, hermitian=self.hermitian) assert_equal(u.shape, (4, 4)) assert_equal(vh.shape, (0, 0)) assert_equal(u, np.eye(4)) ...
[ "def", "test_empty_identity", "(", "self", ")", ":", "x", "=", "np", ".", "empty", "(", "(", "4", ",", "0", ")", ")", "u", ",", "s", ",", "vh", "=", "linalg", ".", "svd", "(", "x", ",", "compute_uv", "=", "True", ",", "hermitian", "=", "self", ...
[ 661, 4 ]
[ 673, 35 ]
python
en
['en', 'co', 'en']
True
Vid2Scene.detect
(self, frame)
Detect objects in the frame and write to self.objs
Detect objects in the frame and write to self.objs
def detect(self, frame): """Detect objects in the frame and write to self.objs""" height, width, channels = frame.shape if self.debug: print("debug, detect: frame info", height, width, channels) blob = cv2.dnn.blobFromImage(frame, 0.00392, (416, 416), ...
[ "def", "detect", "(", "self", ",", "frame", ")", ":", "height", ",", "width", ",", "channels", "=", "frame", ".", "shape", "if", "self", ".", "debug", ":", "print", "(", "\"debug, detect: frame info\"", ",", "height", ",", "width", ",", "channels", ")", ...
[ 171, 4 ]
[ 228, 20 ]
python
en
['en', 'en', 'en']
True
trimseq
(seq)
Remove small Poly series coefficients. Parameters ---------- seq : sequence Sequence of Poly series coefficients. This routine fails for empty sequences. Returns ------- series : sequence Subsequence with trailing zeros removed. If the resulting sequence would b...
Remove small Poly series coefficients.
def trimseq(seq): """Remove small Poly series coefficients. Parameters ---------- seq : sequence Sequence of Poly series coefficients. This routine fails for empty sequences. Returns ------- series : sequence Subsequence with trailing zeros removed. If the resulting...
[ "def", "trimseq", "(", "seq", ")", ":", "if", "len", "(", "seq", ")", "==", "0", ":", "return", "seq", "else", ":", "for", "i", "in", "range", "(", "len", "(", "seq", ")", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "if", "seq", "["...
[ 96, 0 ]
[ 123, 24 ]
python
en
['en', 'en', 'en']
True
as_series
(alist, trim=True)
Return argument as a list of 1-d arrays. The returned list contains array(s) of dtype double, complex double, or object. A 1-d argument of shape ``(N,)`` is parsed into ``N`` arrays of size one; a 2-d argument of shape ``(M,N)`` is parsed into ``M`` arrays of size ``N`` (i.e., is "parsed by row")...
Return argument as a list of 1-d arrays.
def as_series(alist, trim=True): """ Return argument as a list of 1-d arrays. The returned list contains array(s) of dtype double, complex double, or object. A 1-d argument of shape ``(N,)`` is parsed into ``N`` arrays of size one; a 2-d argument of shape ``(M,N)`` is parsed into ``M`` arrays ...
[ "def", "as_series", "(", "alist", ",", "trim", "=", "True", ")", ":", "arrays", "=", "[", "np", ".", "array", "(", "a", ",", "ndmin", "=", "1", ",", "copy", "=", "0", ")", "for", "a", "in", "alist", "]", "if", "min", "(", "[", "a", ".", "si...
[ 126, 0 ]
[ 199, 14 ]
python
en
['en', 'error', 'th']
False
trimcoef
(c, tol=0)
Remove "small" "trailing" coefficients from a polynomial. "Small" means "small in absolute value" and is controlled by the parameter `tol`; "trailing" means highest order coefficient(s), e.g., in ``[0, 1, 1, 0, 0]`` (which represents ``0 + x + x**2 + 0*x**3 + 0*x**4``) both the 3-rd and 4-th order...
Remove "small" "trailing" coefficients from a polynomial.
def trimcoef(c, tol=0): """ Remove "small" "trailing" coefficients from a polynomial. "Small" means "small in absolute value" and is controlled by the parameter `tol`; "trailing" means highest order coefficient(s), e.g., in ``[0, 1, 1, 0, 0]`` (which represents ``0 + x + x**2 + 0*x**3 + 0*x**4``) ...
[ "def", "trimcoef", "(", "c", ",", "tol", "=", "0", ")", ":", "if", "tol", "<", "0", ":", "raise", "ValueError", "(", "\"tol must be non-negative\"", ")", "[", "c", "]", "=", "as_series", "(", "[", "c", "]", ")", "[", "ind", "]", "=", "np", ".", ...
[ 202, 0 ]
[ 254, 37 ]
python
en
['en', 'error', 'th']
False
getdomain
(x)
Return a domain suitable for given abscissae. Find a domain suitable for a polynomial or Chebyshev series defined at the values supplied. Parameters ---------- x : array_like 1-d array of abscissae whose domain will be determined. Returns ------- domain : ndarray ...
Return a domain suitable for given abscissae.
def getdomain(x): """ Return a domain suitable for given abscissae. Find a domain suitable for a polynomial or Chebyshev series defined at the values supplied. Parameters ---------- x : array_like 1-d array of abscissae whose domain will be determined. Returns ------- ...
[ "def", "getdomain", "(", "x", ")", ":", "[", "x", "]", "=", "as_series", "(", "[", "x", "]", ",", "trim", "=", "False", ")", "if", "x", ".", "dtype", ".", "char", "in", "np", ".", "typecodes", "[", "'Complex'", "]", ":", "rmin", ",", "rmax", ...
[ 256, 0 ]
[ 300, 43 ]
python
en
['en', 'error', 'th']
False
mapparms
(old, new)
Linear map parameters between domains. Return the parameters of the linear map ``offset + scale*x`` that maps `old` to `new` such that ``old[i] -> new[i]``, ``i = 0, 1``. Parameters ---------- old, new : array_like Domains. Each domain must (successfully) convert to a 1-d array ...
Linear map parameters between domains.
def mapparms(old, new): """ Linear map parameters between domains. Return the parameters of the linear map ``offset + scale*x`` that maps `old` to `new` such that ``old[i] -> new[i]``, ``i = 0, 1``. Parameters ---------- old, new : array_like Domains. Each domain must (successfully...
[ "def", "mapparms", "(", "old", ",", "new", ")", ":", "oldlen", "=", "old", "[", "1", "]", "-", "old", "[", "0", "]", "newlen", "=", "new", "[", "1", "]", "-", "new", "[", "0", "]", "off", "=", "(", "old", "[", "1", "]", "*", "new", "[", ...
[ 302, 0 ]
[ 347, 19 ]
python
en
['en', 'error', 'th']
False
mapdomain
(x, old, new)
Apply linear map to input points. The linear map ``offset + scale*x`` that maps the domain `old` to the domain `new` is applied to the points `x`. Parameters ---------- x : array_like Points to be mapped. If `x` is a subtype of ndarray the subtype will be preserved. old, n...
Apply linear map to input points.
def mapdomain(x, old, new): """ Apply linear map to input points. The linear map ``offset + scale*x`` that maps the domain `old` to the domain `new` is applied to the points `x`. Parameters ---------- x : array_like Points to be mapped. If `x` is a subtype of ndarray the subtype ...
[ "def", "mapdomain", "(", "x", ",", "old", ",", "new", ")", ":", "x", "=", "np", ".", "asanyarray", "(", "x", ")", "off", ",", "scl", "=", "mapparms", "(", "old", ",", "new", ")", "return", "off", "+", "scl", "*", "x" ]
[ 349, 0 ]
[ 414, 22 ]
python
en
['en', 'error', 'th']
False
_vander2d
(vander_f, x, y, deg)
Helper function used to implement the ``<type>vander2d`` functions. Parameters ---------- vander_f : function(array_like, int) -> ndarray The 1d vander function, such as ``polyvander`` x, y, deg : See the ``<type>vander2d`` functions for more detail
Helper function used to implement the ``<type>vander2d`` functions.
def _vander2d(vander_f, x, y, deg): """ Helper function used to implement the ``<type>vander2d`` functions. Parameters ---------- vander_f : function(array_like, int) -> ndarray The 1d vander function, such as ``polyvander`` x, y, deg : See the ``<type>vander2d`` functions for m...
[ "def", "_vander2d", "(", "vander_f", ",", "x", ",", "y", ",", "deg", ")", ":", "degx", ",", "degy", "=", "[", "_deprecate_as_int", "(", "d", ",", "\"degrees\"", ")", "for", "d", "in", "deg", "]", "x", ",", "y", "=", "np", ".", "array", "(", "("...
[ 417, 0 ]
[ 437, 42 ]
python
en
['en', 'error', 'th']
False
_vander3d
(vander_f, x, y, z, deg)
Helper function used to implement the ``<type>vander3d`` functions. Parameters ---------- vander_f : function(array_like, int) -> ndarray The 1d vander function, such as ``polyvander`` x, y, z, deg : See the ``<type>vander3d`` functions for more detail
Helper function used to implement the ``<type>vander3d`` functions.
def _vander3d(vander_f, x, y, z, deg): """ Helper function used to implement the ``<type>vander3d`` functions. Parameters ---------- vander_f : function(array_like, int) -> ndarray The 1d vander function, such as ``polyvander`` x, y, z, deg : See the ``<type>vander3d`` functions...
[ "def", "_vander3d", "(", "vander_f", ",", "x", ",", "y", ",", "z", ",", "deg", ")", ":", "degx", ",", "degy", ",", "degz", "=", "[", "_deprecate_as_int", "(", "d", ",", "\"degrees\"", ")", "for", "d", "in", "deg", "]", "x", ",", "y", ",", "z", ...
[ 440, 0 ]
[ 461, 42 ]
python
en
['en', 'error', 'th']
False
_fromroots
(line_f, mul_f, roots)
Helper function used to implement the ``<type>fromroots`` functions. Parameters ---------- line_f : function(float, float) -> ndarray The ``<type>line`` function, such as ``polyline`` mul_f : function(array_like, array_like) -> ndarray The ``<type>mul`` function, such as ``polymul`...
Helper function used to implement the ``<type>fromroots`` functions.
def _fromroots(line_f, mul_f, roots): """ Helper function used to implement the ``<type>fromroots`` functions. Parameters ---------- line_f : function(float, float) -> ndarray The ``<type>line`` function, such as ``polyline`` mul_f : function(array_like, array_like) -> ndarray T...
[ "def", "_fromroots", "(", "line_f", ",", "mul_f", ",", "roots", ")", ":", "if", "len", "(", "roots", ")", "==", "0", ":", "return", "np", ".", "ones", "(", "1", ")", "else", ":", "[", "roots", "]", "=", "as_series", "(", "[", "roots", "]", ",",...
[ 464, 0 ]
[ 491, 19 ]
python
en
['en', 'error', 'th']
False
_valnd
(val_f, c, *args)
Helper function used to implement the ``<type>val<n>d`` functions. Parameters ---------- val_f : function(array_like, array_like, tensor: bool) -> array_like The ``<type>val`` function, such as ``polyval`` c, args : See the ``<type>val<n>d`` functions for more detail
Helper function used to implement the ``<type>val<n>d`` functions.
def _valnd(val_f, c, *args): """ Helper function used to implement the ``<type>val<n>d`` functions. Parameters ---------- val_f : function(array_like, array_like, tensor: bool) -> array_like The ``<type>val`` function, such as ``polyval`` c, args : See the ``<type>val<n>d`` func...
[ "def", "_valnd", "(", "val_f", ",", "c", ",", "*", "args", ")", ":", "try", ":", "args", "=", "tuple", "(", "np", ".", "array", "(", "args", ",", "copy", "=", "False", ")", ")", "except", "Exception", ":", "# preserve the old error message", "if", "l...
[ 494, 0 ]
[ 523, 12 ]
python
en
['en', 'error', 'th']
False
_gridnd
(val_f, c, *args)
Helper function used to implement the ``<type>grid<n>d`` functions. Parameters ---------- val_f : function(array_like, array_like, tensor: bool) -> array_like The ``<type>val`` function, such as ``polyval`` c, args : See the ``<type>grid<n>d`` functions for more detail
Helper function used to implement the ``<type>grid<n>d`` functions.
def _gridnd(val_f, c, *args): """ Helper function used to implement the ``<type>grid<n>d`` functions. Parameters ---------- val_f : function(array_like, array_like, tensor: bool) -> array_like The ``<type>val`` function, such as ``polyval`` c, args : See the ``<type>grid<n>d`` f...
[ "def", "_gridnd", "(", "val_f", ",", "c", ",", "*", "args", ")", ":", "for", "xi", "in", "args", ":", "c", "=", "val_f", "(", "xi", ",", "c", ")", "return", "c" ]
[ 526, 0 ]
[ 539, 12 ]
python
en
['en', 'error', 'th']
False
_div
(mul_f, c1, c2)
Helper function used to implement the ``<type>div`` functions. Implementation uses repeated subtraction of c2 multiplied by the nth basis. For some polynomial types, a more efficient approach may be possible. Parameters ---------- mul_f : function(array_like, array_like) -> array_like ...
Helper function used to implement the ``<type>div`` functions.
def _div(mul_f, c1, c2): """ Helper function used to implement the ``<type>div`` functions. Implementation uses repeated subtraction of c2 multiplied by the nth basis. For some polynomial types, a more efficient approach may be possible. Parameters ---------- mul_f : function(array_like, a...
[ "def", "_div", "(", "mul_f", ",", "c1", ",", "c2", ")", ":", "# c1, c2 are trimmed copies", "[", "c1", ",", "c2", "]", "=", "as_series", "(", "[", "c1", ",", "c2", "]", ")", "if", "c2", "[", "-", "1", "]", "==", "0", ":", "raise", "ZeroDivisionEr...
[ 542, 0 ]
[ 575, 32 ]
python
en
['en', 'error', 'th']
False
_add
(c1, c2)
Helper function used to implement the ``<type>add`` functions.
Helper function used to implement the ``<type>add`` functions.
def _add(c1, c2): """ Helper function used to implement the ``<type>add`` functions. """ # c1, c2 are trimmed copies [c1, c2] = as_series([c1, c2]) if len(c1) > len(c2): c1[:c2.size] += c2 ret = c1 else: c2[:c1.size] += c1 ret = c2 return trimseq(ret)
[ "def", "_add", "(", "c1", ",", "c2", ")", ":", "# c1, c2 are trimmed copies", "[", "c1", ",", "c2", "]", "=", "as_series", "(", "[", "c1", ",", "c2", "]", ")", "if", "len", "(", "c1", ")", ">", "len", "(", "c2", ")", ":", "c1", "[", ":", "c2"...
[ 578, 0 ]
[ 588, 23 ]
python
en
['en', 'en', 'en']
True
_sub
(c1, c2)
Helper function used to implement the ``<type>sub`` functions.
Helper function used to implement the ``<type>sub`` functions.
def _sub(c1, c2): """ Helper function used to implement the ``<type>sub`` functions. """ # c1, c2 are trimmed copies [c1, c2] = as_series([c1, c2]) if len(c1) > len(c2): c1[:c2.size] -= c2 ret = c1 else: c2 = -c2 c2[:c1.size] += c1 ret = c2 return trimseq(...
[ "def", "_sub", "(", "c1", ",", "c2", ")", ":", "# c1, c2 are trimmed copies", "[", "c1", ",", "c2", "]", "=", "as_series", "(", "[", "c1", ",", "c2", "]", ")", "if", "len", "(", "c1", ")", ">", "len", "(", "c2", ")", ":", "c1", "[", ":", "c2"...
[ 591, 0 ]
[ 602, 23 ]
python
en
['en', 'en', 'en']
True
_fit
(vander_f, x, y, deg, rcond=None, full=False, w=None)
Helper function used to implement the ``<type>fit`` functions. Parameters ---------- vander_f : function(array_like, int) -> ndarray The 1d vander function, such as ``polyvander`` c1, c2 : See the ``<type>fit`` functions for more detail
Helper function used to implement the ``<type>fit`` functions.
def _fit(vander_f, x, y, deg, rcond=None, full=False, w=None): """ Helper function used to implement the ``<type>fit`` functions. Parameters ---------- vander_f : function(array_like, int) -> ndarray The 1d vander function, such as ``polyvander`` c1, c2 : See the ``<type>fit`` f...
[ "def", "_fit", "(", "vander_f", ",", "x", ",", "y", ",", "deg", ",", "rcond", "=", "None", ",", "full", "=", "False", ",", "w", "=", "None", ")", ":", "x", "=", "np", ".", "asarray", "(", "x", ")", "+", "0.0", "y", "=", "np", ".", "asarray"...
[ 605, 0 ]
[ 690, 16 ]
python
en
['en', 'error', 'th']
False
_pow
(mul_f, c, pow, maxpower)
Helper function used to implement the ``<type>pow`` functions. Parameters ---------- vander_f : function(array_like, int) -> ndarray The 1d vander function, such as ``polyvander`` pow, maxpower : See the ``<type>pow`` functions for more detail mul_f : function(array_like, array...
Helper function used to implement the ``<type>pow`` functions.
def _pow(mul_f, c, pow, maxpower): """ Helper function used to implement the ``<type>pow`` functions. Parameters ---------- vander_f : function(array_like, int) -> ndarray The 1d vander function, such as ``polyvander`` pow, maxpower : See the ``<type>pow`` functions for more det...
[ "def", "_pow", "(", "mul_f", ",", "c", ",", "pow", ",", "maxpower", ")", ":", "# c is a trimmed copy", "[", "c", "]", "=", "as_series", "(", "[", "c", "]", ")", "power", "=", "int", "(", "pow", ")", "if", "power", "!=", "pow", "or", "power", "<",...
[ 693, 0 ]
[ 723, 18 ]
python
en
['en', 'error', 'th']
False
_deprecate_as_int
(x, desc)
Like `operator.index`, but emits a deprecation warning when passed a float Parameters ---------- x : int-like, or float with integral value Value to interpret as an integer desc : str description to include in any error message Raises ------ TypeError : if x is a non-i...
Like `operator.index`, but emits a deprecation warning when passed a float
def _deprecate_as_int(x, desc): """ Like `operator.index`, but emits a deprecation warning when passed a float Parameters ---------- x : int-like, or float with integral value Value to interpret as an integer desc : str description to include in any error message Raises ...
[ "def", "_deprecate_as_int", "(", "x", ",", "desc", ")", ":", "try", ":", "return", "operator", ".", "index", "(", "x", ")", "except", "TypeError", ":", "# Numpy 1.17.0, 2019-03-11", "try", ":", "ix", "=", "int", "(", "x", ")", "except", "TypeError", ":",...
[ 726, 0 ]
[ 761, 61 ]
python
en
['en', 'error', 'th']
False
IntegrationTests.test_export_rule_data
(self)
Tests that export_rule_data has the three expected keys in the right format.
Tests that export_rule_data has the three expected keys in the right format.
def test_export_rule_data(self): """Tests that export_rule_data has the three expected keys in the right format. """ all_data = export_rule_data(SomeVariables(), SomeActions()) self.assertEqual( all_data.get("actions"), [ { ...
[ "def", "test_export_rule_data", "(", "self", ")", ":", "all_data", "=", "export_rule_data", "(", "SomeVariables", "(", ")", ",", "SomeActions", "(", ")", ")", "self", ".", "assertEqual", "(", "all_data", ".", "get", "(", "\"actions\"", ")", ",", "[", "{", ...
[ 78, 4 ]
[ 167, 9 ]
python
en
['en', 'en', 'en']
True
Accelerator.__init__
( self, precision_plugin: PrecisionPlugin, training_type_plugin: TrainingTypePlugin, )
Args: precision_plugin: the plugin to handle precision-specific parts training_type_plugin: the plugin to handle different training routines
def __init__( self, precision_plugin: PrecisionPlugin, training_type_plugin: TrainingTypePlugin, ) -> None: """ Args: precision_plugin: the plugin to handle precision-specific parts training_type_plugin: the plugin to handle different training routine...
[ "def", "__init__", "(", "self", ",", "precision_plugin", ":", "PrecisionPlugin", ",", "training_type_plugin", ":", "TrainingTypePlugin", ",", ")", "->", "None", ":", "self", ".", "precision_plugin", "=", "precision_plugin", "self", ".", "training_type_plugin", "=", ...
[ 42, 4 ]
[ 58, 41 ]
python
en
['en', 'error', 'th']
False
Accelerator.setup
(self, trainer, model: LightningModule)
Connects the plugins to the training process, creates optimizers Args: trainer: the trainer instance to connect to model: the model to train
Connects the plugins to the training process, creates optimizers
def setup(self, trainer, model: LightningModule) -> None: """ Connects the plugins to the training process, creates optimizers Args: trainer: the trainer instance to connect to model: the model to train """ self.connect_training_type_plugin(self.training_...
[ "def", "setup", "(", "self", ",", "trainer", ",", "model", ":", "LightningModule", ")", "->", "None", ":", "self", ".", "connect_training_type_plugin", "(", "self", ".", "training_type_plugin", ",", "model", ")", "self", ".", "setup_optimizers", "(", "trainer"...
[ 60, 4 ]
[ 70, 60 ]
python
en
['en', 'error', 'th']
False
Accelerator.pre_dispatch
(self)
Hook to do something before the training/evaluation/prediction starts.
Hook to do something before the training/evaluation/prediction starts.
def pre_dispatch(self) -> None: """Hook to do something before the training/evaluation/prediction starts.""" self.training_type_plugin.pre_dispatch() self.precision_plugin.pre_dispatch()
[ "def", "pre_dispatch", "(", "self", ")", "->", "None", ":", "self", ".", "training_type_plugin", ".", "pre_dispatch", "(", ")", "self", ".", "precision_plugin", ".", "pre_dispatch", "(", ")" ]
[ 81, 4 ]
[ 84, 44 ]
python
en
['en', 'en', 'en']
True
Accelerator.post_dispatch
(self)
Hook to do something before the training/evaluation/prediction starts.
Hook to do something before the training/evaluation/prediction starts.
def post_dispatch(self) -> None: """Hook to do something before the training/evaluation/prediction starts.""" self.training_type_plugin.post_dispatch() self.precision_plugin.post_dispatch()
[ "def", "post_dispatch", "(", "self", ")", "->", "None", ":", "self", ".", "training_type_plugin", ".", "post_dispatch", "(", ")", "self", ".", "precision_plugin", ".", "post_dispatch", "(", ")" ]
[ 86, 4 ]
[ 89, 45 ]
python
en
['en', 'en', 'en']
True
Accelerator.model
(self)
Returns the model. This can also be a wrapped LightningModule. For retrieving the pure LightningModule use :attr:`Accelerator.lightning_module`
Returns the model. This can also be a wrapped LightningModule. For retrieving the pure LightningModule use :attr:`Accelerator.lightning_module`
def model(self) -> torch.nn.Module: """Returns the model. This can also be a wrapped LightningModule. For retrieving the pure LightningModule use :attr:`Accelerator.lightning_module` """ return self.training_type_plugin.model
[ "def", "model", "(", "self", ")", "->", "torch", ".", "nn", ".", "Module", ":", "return", "self", ".", "training_type_plugin", ".", "model" ]
[ 92, 4 ]
[ 97, 46 ]
python
en
['en', 'en', 'en']
True
Accelerator.lightning_module
(self)
Returns the pure LightningModule. To get the potentially wrapped model use :attr:`Accelerator.model`
Returns the pure LightningModule. To get the potentially wrapped model use :attr:`Accelerator.model`
def lightning_module(self) -> LightningModule: """Returns the pure LightningModule. To get the potentially wrapped model use :attr:`Accelerator.model` """ return self.training_type_plugin.lightning_module
[ "def", "lightning_module", "(", "self", ")", "->", "LightningModule", ":", "return", "self", ".", "training_type_plugin", ".", "lightning_module" ]
[ 104, 4 ]
[ 109, 57 ]
python
en
['en', 'et', 'en']
True
Accelerator.teardown
(self)
This method is called to teardown the training process. It is the right place to release memory and free other ressources.
This method is called to teardown the training process. It is the right place to release memory and free other ressources.
def teardown(self): """This method is called to teardown the training process. It is the right place to release memory and free other ressources. """ pass
[ "def", "teardown", "(", "self", ")", ":", "pass" ]
[ 115, 4 ]
[ 119, 12 ]
python
en
['en', 'en', 'en']
True
Accelerator.batch_to_device
(self, batch: Any, device: Optional[torch.device] = None)
Moves the batch to the correct device. The returned batch is of the same type as the input batch, just having all tensors on the correct device. Args: batch: The batch of samples to move to the correct device device: The target device
Moves the batch to the correct device. The returned batch is of the same type as the input batch, just having all tensors on the correct device.
def batch_to_device(self, batch: Any, device: Optional[torch.device] = None) -> Any: """Moves the batch to the correct device. The returned batch is of the same type as the input batch, just having all tensors on the correct device. Args: batch: The batch of samples to move to the c...
[ "def", "batch_to_device", "(", "self", ",", "batch", ":", "Any", ",", "device", ":", "Optional", "[", "torch", ".", "device", "]", "=", "None", ")", "->", "Any", ":", "model", "=", "self", ".", "lightning_module", "if", "model", "is", "not", "None", ...
[ 121, 4 ]
[ 134, 49 ]
python
en
['en', 'en', 'en']
True
Accelerator.on_train_start
(self)
Hook to do something upon the training start
Hook to do something upon the training start
def on_train_start(self): """Hook to do something upon the training start""" pass
[ "def", "on_train_start", "(", "self", ")", ":", "pass" ]
[ 136, 4 ]
[ 138, 12 ]
python
en
['en', 'en', 'en']
True
Accelerator.training_step
(self, args)
The actual training step. Args: args: the arguments for the models training step. Can consist of the following: batch (:class:`~torch.Tensor` | (:class:`~torch.Tensor`, ...) | [:class:`~torch.Tensor`, ...]): The output of your :class:`~torch.utils.data.DataLoader...
The actual training step.
def training_step(self, args): """The actual training step. Args: args: the arguments for the models training step. Can consist of the following: batch (:class:`~torch.Tensor` | (:class:`~torch.Tensor`, ...) | [:class:`~torch.Tensor`, ...]): The output of...
[ "def", "training_step", "(", "self", ",", "args", ")", ":", "args", "[", "0", "]", "=", "self", ".", "to_device", "(", "args", "[", "0", "]", ")", "with", "self", ".", "precision_plugin", ".", "train_step_context", "(", ")", ",", "self", ".", "traini...
[ 140, 4 ]
[ 156, 65 ]
python
en
['en', 'en', 'en']
True
Accelerator.validation_step
(self, args)
The actual validation step. Args: args: the arguments for the models validation step. Can consist of the following: batch (:class:`~torch.Tensor` | (:class:`~torch.Tensor`, ...) | [:class:`~torch.Tensor`, ...]): The output of your :class:`~torch.utils.data.DataLo...
The actual validation step.
def validation_step(self, args): """The actual validation step. Args: args: the arguments for the models validation step. Can consist of the following: batch (:class:`~torch.Tensor` | (:class:`~torch.Tensor`, ...) | [:class:`~torch.Tensor`, ...]): The out...
[ "def", "validation_step", "(", "self", ",", "args", ")", ":", "batch", "=", "self", ".", "to_device", "(", "args", "[", "0", "]", ")", "args", "[", "0", "]", "=", "batch", "with", "self", ".", "precision_plugin", ".", "val_step_context", "(", ")", ",...
[ 161, 4 ]
[ 177, 67 ]
python
en
['en', 'en', 'en']
True
Accelerator.test_step
(self, args)
The actual test step. Args: args: the arguments for the models test step. Can consist of the following: batch (:class:`~torch.Tensor` | (:class:`~torch.Tensor`, ...) | [:class:`~torch.Tensor`, ...]): The output of your :class:`~torch.utils.data.DataLoader`. A ten...
The actual test step.
def test_step(self, args): """The actual test step. Args: args: the arguments for the models test step. Can consist of the following: batch (:class:`~torch.Tensor` | (:class:`~torch.Tensor`, ...) | [:class:`~torch.Tensor`, ...]): The output of your :class...
[ "def", "test_step", "(", "self", ",", "args", ")", ":", "batch", "=", "self", ".", "to_device", "(", "args", "[", "0", "]", ")", "args", "[", "0", "]", "=", "batch", "with", "self", ".", "precision_plugin", ".", "test_step_context", "(", ")", ",", ...
[ 179, 4 ]
[ 195, 61 ]
python
en
['en', 'en', 'en']
True
Accelerator.predict
(self, args)
The actual predict step. Args: args: the arguments for the models predict step. Can consist of the following: batch (:class:`~torch.Tensor` | (:class:`~torch.Tensor`, ...) | [:class:`~torch.Tensor`, ...]): The output of your :class:`~torch.utils.data.DataLoader`....
The actual predict step.
def predict(self, args): """The actual predict step. Args: args: the arguments for the models predict step. Can consist of the following: batch (:class:`~torch.Tensor` | (:class:`~torch.Tensor`, ...) | [:class:`~torch.Tensor`, ...]): The output of your :c...
[ "def", "predict", "(", "self", ",", "args", ")", ":", "batch", "=", "self", ".", "to_device", "(", "args", "[", "0", "]", ")", "args", "[", "0", "]", "=", "batch", "with", "self", ".", "precision_plugin", ".", "predict_context", "(", ")", ",", "sel...
[ 197, 4 ]
[ 213, 59 ]
python
en
['en', 'en', 'en']
True
Accelerator.training_step_end
(self, output)
A hook to do something at the end of the training step Args: output: the output of the training step
A hook to do something at the end of the training step
def training_step_end(self, output): """A hook to do something at the end of the training step Args: output: the output of the training step """ return self.training_type_plugin.training_step_end(output)
[ "def", "training_step_end", "(", "self", ",", "output", ")", ":", "return", "self", ".", "training_type_plugin", ".", "training_step_end", "(", "output", ")" ]
[ 215, 4 ]
[ 221, 66 ]
python
en
['en', 'en', 'en']
True
Accelerator.test_step_end
(self, output)
A hook to do something at the end of the test step Args: output: the output of the test step
A hook to do something at the end of the test step
def test_step_end(self, output): """A hook to do something at the end of the test step Args: output: the output of the test step """ return self.training_type_plugin.test_step_end(output)
[ "def", "test_step_end", "(", "self", ",", "output", ")", ":", "return", "self", ".", "training_type_plugin", ".", "test_step_end", "(", "output", ")" ]
[ 223, 4 ]
[ 229, 62 ]
python
en
['en', 'en', 'en']
True
Accelerator.validation_step_end
(self, output)
A hook to do something at the end of the validation step Args: output: the output of the validation step
A hook to do something at the end of the validation step
def validation_step_end(self, output): """A hook to do something at the end of the validation step Args: output: the output of the validation step """ return self.training_type_plugin.validation_step_end(output)
[ "def", "validation_step_end", "(", "self", ",", "output", ")", ":", "return", "self", ".", "training_type_plugin", ".", "validation_step_end", "(", "output", ")" ]
[ 231, 4 ]
[ 237, 68 ]
python
en
['en', 'en', 'en']
True
Accelerator.backward
( self, closure_loss: torch.Tensor, optimizer: Optimizer, optimizer_idx: int, should_accumulate: bool, *args, **kwargs, )
Forwards backward-calls to the precision plugin. Args: closure_loss: a tensor holding the loss value to backpropagate should_accumulate: whether to accumulate gradients
Forwards backward-calls to the precision plugin.
def backward( self, closure_loss: torch.Tensor, optimizer: Optimizer, optimizer_idx: int, should_accumulate: bool, *args, **kwargs, ) -> torch.Tensor: """Forwards backward-calls to the precision plugin. Args: closure_loss: a tensor...
[ "def", "backward", "(", "self", ",", "closure_loss", ":", "torch", ".", "Tensor", ",", "optimizer", ":", "Optimizer", ",", "optimizer_idx", ":", "int", ",", "should_accumulate", ":", "bool", ",", "*", "args", ",", "*", "*", "kwargs", ",", ")", "->", "t...
[ 239, 4 ]
[ 262, 21 ]
python
en
['en', 'en', 'en']
True
Accelerator.optimizer_step
(self, optimizer: Optimizer, opt_idx: int, lambda_closure: Callable, **kwargs)
performs the actual optimizer step. Args: optimizer: the optimizer performing the step opt_idx: index of the current optimizer lambda_closure: closure calculating the loss value
performs the actual optimizer step.
def optimizer_step(self, optimizer: Optimizer, opt_idx: int, lambda_closure: Callable, **kwargs): """performs the actual optimizer step. Args: optimizer: the optimizer performing the step opt_idx: index of the current optimizer lambda_closure: closure calculating the...
[ "def", "optimizer_step", "(", "self", ",", "optimizer", ":", "Optimizer", ",", "opt_idx", ":", "int", ",", "lambda_closure", ":", "Callable", ",", "*", "*", "kwargs", ")", ":", "make_optimizer_step", "=", "self", ".", "precision_plugin", ".", "pre_optimizer_st...
[ 264, 4 ]
[ 279, 83 ]
python
en
['en', 'en', 'en']
True
Accelerator.optimizer_zero_grad
(self, current_epoch: int, batch_idx: int, optimizer: Optimizer, opt_idx: int)
Zeros all model parameter's gradients
Zeros all model parameter's gradients
def optimizer_zero_grad(self, current_epoch: int, batch_idx: int, optimizer: Optimizer, opt_idx: int) -> None: """Zeros all model parameter's gradients""" model_ref = self.lightning_module model_ref.optimizer_zero_grad(current_epoch, batch_idx, optimizer, opt_idx)
[ "def", "optimizer_zero_grad", "(", "self", ",", "current_epoch", ":", "int", ",", "batch_idx", ":", "int", ",", "optimizer", ":", "Optimizer", ",", "opt_idx", ":", "int", ")", "->", "None", ":", "model_ref", "=", "self", ".", "lightning_module", "model_ref",...
[ 284, 4 ]
[ 287, 83 ]
python
en
['es', 'nl', 'en']
False
Accelerator.clip_gradients
(self, optimizer: Optimizer, clip_val: Union[int, float])
clips all the optimizer parameters to the given value
clips all the optimizer parameters to the given value
def clip_gradients(self, optimizer: Optimizer, clip_val: Union[int, float]) -> None: """clips all the optimizer parameters to the given value""" self.precision_plugin.clip_gradients(optimizer, clip_val)
[ "def", "clip_gradients", "(", "self", ",", "optimizer", ":", "Optimizer", ",", "clip_val", ":", "Union", "[", "int", ",", "float", "]", ")", "->", "None", ":", "self", ".", "precision_plugin", ".", "clip_gradients", "(", "optimizer", ",", "clip_val", ")" ]
[ 289, 4 ]
[ 292, 65 ]
python
en
['en', 'en', 'en']
True