partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | decode_filename | Return Unicode filename. | autopep8.py | def decode_filename(filename):
"""Return Unicode filename."""
if isinstance(filename, unicode):
return filename
return filename.decode(sys.getfilesystemencoding()) | def decode_filename(filename):
"""Return Unicode filename."""
if isinstance(filename, unicode):
return filename
return filename.decode(sys.getfilesystemencoding()) | [
"Return",
"Unicode",
"filename",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L3784-L3789 | [
"def",
"decode_filename",
"(",
"filename",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"unicode",
")",
":",
"return",
"filename",
"return",
"filename",
".",
"decode",
"(",
"sys",
".",
"getfilesystemencoding",
"(",
")",
")"
] | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | supported_fixes | Yield pep8 error codes that autopep8 fixes.
Each item we yield is a tuple of the code followed by its
description. | autopep8.py | def supported_fixes():
"""Yield pep8 error codes that autopep8 fixes.
Each item we yield is a tuple of the code followed by its
description.
"""
yield ('E101', docstring_summary(reindent.__doc__))
instance = FixPEP8(filename=None, options=None, contents='')
for attribute in dir(instance):... | def supported_fixes():
"""Yield pep8 error codes that autopep8 fixes.
Each item we yield is a tuple of the code followed by its
description.
"""
yield ('E101', docstring_summary(reindent.__doc__))
instance = FixPEP8(filename=None, options=None, contents='')
for attribute in dir(instance):... | [
"Yield",
"pep8",
"error",
"codes",
"that",
"autopep8",
"fixes",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L3792-L3817 | [
"def",
"supported_fixes",
"(",
")",
":",
"yield",
"(",
"'E101'",
",",
"docstring_summary",
"(",
"reindent",
".",
"__doc__",
")",
")",
"instance",
"=",
"FixPEP8",
"(",
"filename",
"=",
"None",
",",
"options",
"=",
"None",
",",
"contents",
"=",
"''",
")",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | line_shortening_rank | Return rank of candidate.
This is for sorting candidates. | autopep8.py | def line_shortening_rank(candidate, indent_word, max_line_length,
experimental=False):
"""Return rank of candidate.
This is for sorting candidates.
"""
if not candidate.strip():
return 0
rank = 0
lines = candidate.rstrip().split('\n')
offset = 0
if (
... | def line_shortening_rank(candidate, indent_word, max_line_length,
experimental=False):
"""Return rank of candidate.
This is for sorting candidates.
"""
if not candidate.strip():
return 0
rank = 0
lines = candidate.rstrip().split('\n')
offset = 0
if (
... | [
"Return",
"rank",
"of",
"candidate",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L3825-L3970 | [
"def",
"line_shortening_rank",
"(",
"candidate",
",",
"indent_word",
",",
"max_line_length",
",",
"experimental",
"=",
"False",
")",
":",
"if",
"not",
"candidate",
".",
"strip",
"(",
")",
":",
"return",
"0",
"rank",
"=",
"0",
"lines",
"=",
"candidate",
"."... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | standard_deviation | Return standard deviation. | autopep8.py | def standard_deviation(numbers):
"""Return standard deviation."""
numbers = list(numbers)
if not numbers:
return 0
mean = sum(numbers) / len(numbers)
return (sum((n - mean) ** 2 for n in numbers) /
len(numbers)) ** .5 | def standard_deviation(numbers):
"""Return standard deviation."""
numbers = list(numbers)
if not numbers:
return 0
mean = sum(numbers) / len(numbers)
return (sum((n - mean) ** 2 for n in numbers) /
len(numbers)) ** .5 | [
"Return",
"standard",
"deviation",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L3973-L3980 | [
"def",
"standard_deviation",
"(",
"numbers",
")",
":",
"numbers",
"=",
"list",
"(",
"numbers",
")",
"if",
"not",
"numbers",
":",
"return",
"0",
"mean",
"=",
"sum",
"(",
"numbers",
")",
"/",
"len",
"(",
"numbers",
")",
"return",
"(",
"sum",
"(",
"(",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | count_unbalanced_brackets | Return number of unmatched open/close brackets. | autopep8.py | def count_unbalanced_brackets(line):
"""Return number of unmatched open/close brackets."""
count = 0
for opening, closing in ['()', '[]', '{}']:
count += abs(line.count(opening) - line.count(closing))
return count | def count_unbalanced_brackets(line):
"""Return number of unmatched open/close brackets."""
count = 0
for opening, closing in ['()', '[]', '{}']:
count += abs(line.count(opening) - line.count(closing))
return count | [
"Return",
"number",
"of",
"unmatched",
"open",
"/",
"close",
"brackets",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L3992-L3998 | [
"def",
"count_unbalanced_brackets",
"(",
"line",
")",
":",
"count",
"=",
"0",
"for",
"opening",
",",
"closing",
"in",
"[",
"'()'",
",",
"'[]'",
",",
"'{}'",
"]",
":",
"count",
"+=",
"abs",
"(",
"line",
".",
"count",
"(",
"opening",
")",
"-",
"line",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | split_at_offsets | Split line at offsets.
Return list of strings. | autopep8.py | def split_at_offsets(line, offsets):
"""Split line at offsets.
Return list of strings.
"""
result = []
previous_offset = 0
current_offset = 0
for current_offset in sorted(offsets):
if current_offset < len(line) and previous_offset != current_offset:
result.append(line[... | def split_at_offsets(line, offsets):
"""Split line at offsets.
Return list of strings.
"""
result = []
previous_offset = 0
current_offset = 0
for current_offset in sorted(offsets):
if current_offset < len(line) and previous_offset != current_offset:
result.append(line[... | [
"Split",
"line",
"at",
"offsets",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L4001-L4018 | [
"def",
"split_at_offsets",
"(",
"line",
",",
"offsets",
")",
":",
"result",
"=",
"[",
"]",
"previous_offset",
"=",
"0",
"current_offset",
"=",
"0",
"for",
"current_offset",
"in",
"sorted",
"(",
"offsets",
")",
":",
"if",
"current_offset",
"<",
"len",
"(",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | match_file | Return True if file is okay for modifying/recursing. | autopep8.py | def match_file(filename, exclude):
"""Return True if file is okay for modifying/recursing."""
base_name = os.path.basename(filename)
if base_name.startswith('.'):
return False
for pattern in exclude:
if fnmatch.fnmatch(base_name, pattern):
return False
if fnmatch.fn... | def match_file(filename, exclude):
"""Return True if file is okay for modifying/recursing."""
base_name = os.path.basename(filename)
if base_name.startswith('.'):
return False
for pattern in exclude:
if fnmatch.fnmatch(base_name, pattern):
return False
if fnmatch.fn... | [
"Return",
"True",
"if",
"file",
"is",
"okay",
"for",
"modifying",
"/",
"recursing",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L4040-L4056 | [
"def",
"match_file",
"(",
"filename",
",",
"exclude",
")",
":",
"base_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
"if",
"base_name",
".",
"startswith",
"(",
"'.'",
")",
":",
"return",
"False",
"for",
"pattern",
"in",
"exclude",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | fix_multiple_files | Fix list of files.
Optionally fix files recursively. | autopep8.py | def fix_multiple_files(filenames, options, output=None):
"""Fix list of files.
Optionally fix files recursively.
"""
results = []
filenames = find_files(filenames, options.recursive, options.exclude)
if options.jobs > 1:
import multiprocessing
pool = multiprocessing.Pool(option... | def fix_multiple_files(filenames, options, output=None):
"""Fix list of files.
Optionally fix files recursively.
"""
results = []
filenames = find_files(filenames, options.recursive, options.exclude)
if options.jobs > 1:
import multiprocessing
pool = multiprocessing.Pool(option... | [
"Fix",
"list",
"of",
"files",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L4085-L4112 | [
"def",
"fix_multiple_files",
"(",
"filenames",
",",
"options",
",",
"output",
"=",
"None",
")",
":",
"results",
"=",
"[",
"]",
"filenames",
"=",
"find_files",
"(",
"filenames",
",",
"options",
".",
"recursive",
",",
"options",
".",
"exclude",
")",
"if",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | wrap_output | Return output with specified encoding. | autopep8.py | def wrap_output(output, encoding):
"""Return output with specified encoding."""
return codecs.getwriter(encoding)(output.buffer
if hasattr(output, 'buffer')
else output) | def wrap_output(output, encoding):
"""Return output with specified encoding."""
return codecs.getwriter(encoding)(output.buffer
if hasattr(output, 'buffer')
else output) | [
"Return",
"output",
"with",
"specified",
"encoding",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L4151-L4155 | [
"def",
"wrap_output",
"(",
"output",
",",
"encoding",
")",
":",
"return",
"codecs",
".",
"getwriter",
"(",
"encoding",
")",
"(",
"output",
".",
"buffer",
"if",
"hasattr",
"(",
"output",
",",
"'buffer'",
")",
"else",
"output",
")"
] | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix | Return a version of the source code with PEP 8 violations fixed. | autopep8.py | def fix(self):
"""Return a version of the source code with PEP 8 violations fixed."""
pep8_options = {
'ignore': self.options.ignore,
'select': self.options.select,
'max_line_length': self.options.max_line_length,
'hang_closing': self.options.hang_closing,... | def fix(self):
"""Return a version of the source code with PEP 8 violations fixed."""
pep8_options = {
'ignore': self.options.ignore,
'select': self.options.select,
'max_line_length': self.options.max_line_length,
'hang_closing': self.options.hang_closing,... | [
"Return",
"a",
"version",
"of",
"the",
"source",
"code",
"with",
"PEP",
"8",
"violations",
"fixed",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L567-L601 | [
"def",
"fix",
"(",
"self",
")",
":",
"pep8_options",
"=",
"{",
"'ignore'",
":",
"self",
".",
"options",
".",
"ignore",
",",
"'select'",
":",
"self",
".",
"options",
".",
"select",
",",
"'max_line_length'",
":",
"self",
".",
"options",
".",
"max_line_leng... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8._fix_reindent | Fix a badly indented line.
This is done by adding or removing from its initial indent only. | autopep8.py | def _fix_reindent(self, result):
"""Fix a badly indented line.
This is done by adding or removing from its initial indent only.
"""
num_indent_spaces = int(result['info'].split()[1])
line_index = result['line'] - 1
target = self.source[line_index]
self.source[l... | def _fix_reindent(self, result):
"""Fix a badly indented line.
This is done by adding or removing from its initial indent only.
"""
num_indent_spaces = int(result['info'].split()[1])
line_index = result['line'] - 1
target = self.source[line_index]
self.source[l... | [
"Fix",
"a",
"badly",
"indented",
"line",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L603-L613 | [
"def",
"_fix_reindent",
"(",
"self",
",",
"result",
")",
":",
"num_indent_spaces",
"=",
"int",
"(",
"result",
"[",
"'info'",
"]",
".",
"split",
"(",
")",
"[",
"1",
"]",
")",
"line_index",
"=",
"result",
"[",
"'line'",
"]",
"-",
"1",
"target",
"=",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e112 | Fix under-indented comments. | autopep8.py | def fix_e112(self, result):
"""Fix under-indented comments."""
line_index = result['line'] - 1
target = self.source[line_index]
if not target.lstrip().startswith('#'):
# Don't screw with invalid syntax.
return []
self.source[line_index] = self.indent_wor... | def fix_e112(self, result):
"""Fix under-indented comments."""
line_index = result['line'] - 1
target = self.source[line_index]
if not target.lstrip().startswith('#'):
# Don't screw with invalid syntax.
return []
self.source[line_index] = self.indent_wor... | [
"Fix",
"under",
"-",
"indented",
"comments",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L615-L624 | [
"def",
"fix_e112",
"(",
"self",
",",
"result",
")",
":",
"line_index",
"=",
"result",
"[",
"'line'",
"]",
"-",
"1",
"target",
"=",
"self",
".",
"source",
"[",
"line_index",
"]",
"if",
"not",
"target",
".",
"lstrip",
"(",
")",
".",
"startswith",
"(",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e113 | Fix unexpected indentation. | autopep8.py | def fix_e113(self, result):
"""Fix unexpected indentation."""
line_index = result['line'] - 1
target = self.source[line_index]
indent = _get_indentation(target)
stripped = target.lstrip()
self.source[line_index] = indent[1:] + stripped | def fix_e113(self, result):
"""Fix unexpected indentation."""
line_index = result['line'] - 1
target = self.source[line_index]
indent = _get_indentation(target)
stripped = target.lstrip()
self.source[line_index] = indent[1:] + stripped | [
"Fix",
"unexpected",
"indentation",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L626-L632 | [
"def",
"fix_e113",
"(",
"self",
",",
"result",
")",
":",
"line_index",
"=",
"result",
"[",
"'line'",
"]",
"-",
"1",
"target",
"=",
"self",
".",
"source",
"[",
"line_index",
"]",
"indent",
"=",
"_get_indentation",
"(",
"target",
")",
"stripped",
"=",
"t... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e125 | Fix indentation undistinguish from the next logical line. | autopep8.py | def fix_e125(self, result):
"""Fix indentation undistinguish from the next logical line."""
num_indent_spaces = int(result['info'].split()[1])
line_index = result['line'] - 1
target = self.source[line_index]
spaces_to_add = num_indent_spaces - len(_get_indentation(target))
... | def fix_e125(self, result):
"""Fix indentation undistinguish from the next logical line."""
num_indent_spaces = int(result['info'].split()[1])
line_index = result['line'] - 1
target = self.source[line_index]
spaces_to_add = num_indent_spaces - len(_get_indentation(target))
... | [
"Fix",
"indentation",
"undistinguish",
"from",
"the",
"next",
"logical",
"line",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L648-L664 | [
"def",
"fix_e125",
"(",
"self",
",",
"result",
")",
":",
"num_indent_spaces",
"=",
"int",
"(",
"result",
"[",
"'info'",
"]",
".",
"split",
"(",
")",
"[",
"1",
"]",
")",
"line_index",
"=",
"result",
"[",
"'line'",
"]",
"-",
"1",
"target",
"=",
"self... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e131 | Fix indentation undistinguish from the next logical line. | autopep8.py | def fix_e131(self, result):
"""Fix indentation undistinguish from the next logical line."""
num_indent_spaces = int(result['info'].split()[1])
line_index = result['line'] - 1
target = self.source[line_index]
spaces_to_add = num_indent_spaces - len(_get_indentation(target))
... | def fix_e131(self, result):
"""Fix indentation undistinguish from the next logical line."""
num_indent_spaces = int(result['info'].split()[1])
line_index = result['line'] - 1
target = self.source[line_index]
spaces_to_add = num_indent_spaces - len(_get_indentation(target))
... | [
"Fix",
"indentation",
"undistinguish",
"from",
"the",
"next",
"logical",
"line",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L666-L679 | [
"def",
"fix_e131",
"(",
"self",
",",
"result",
")",
":",
"num_indent_spaces",
"=",
"int",
"(",
"result",
"[",
"'info'",
"]",
".",
"split",
"(",
")",
"[",
"1",
"]",
")",
"line_index",
"=",
"result",
"[",
"'line'",
"]",
"-",
"1",
"target",
"=",
"self... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e224 | Remove extraneous whitespace around operator. | autopep8.py | def fix_e224(self, result):
"""Remove extraneous whitespace around operator."""
target = self.source[result['line'] - 1]
offset = result['column'] - 1
fixed = target[:offset] + target[offset:].replace('\t', ' ')
self.source[result['line'] - 1] = fixed | def fix_e224(self, result):
"""Remove extraneous whitespace around operator."""
target = self.source[result['line'] - 1]
offset = result['column'] - 1
fixed = target[:offset] + target[offset:].replace('\t', ' ')
self.source[result['line'] - 1] = fixed | [
"Remove",
"extraneous",
"whitespace",
"around",
"operator",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L693-L698 | [
"def",
"fix_e224",
"(",
"self",
",",
"result",
")",
":",
"target",
"=",
"self",
".",
"source",
"[",
"result",
"[",
"'line'",
"]",
"-",
"1",
"]",
"offset",
"=",
"result",
"[",
"'column'",
"]",
"-",
"1",
"fixed",
"=",
"target",
"[",
":",
"offset",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e225 | Fix missing whitespace around operator. | autopep8.py | def fix_e225(self, result):
"""Fix missing whitespace around operator."""
target = self.source[result['line'] - 1]
offset = result['column'] - 1
fixed = target[:offset] + ' ' + target[offset:]
# Only proceed if non-whitespace characters match.
# And make sure we don't br... | def fix_e225(self, result):
"""Fix missing whitespace around operator."""
target = self.source[result['line'] - 1]
offset = result['column'] - 1
fixed = target[:offset] + ' ' + target[offset:]
# Only proceed if non-whitespace characters match.
# And make sure we don't br... | [
"Fix",
"missing",
"whitespace",
"around",
"operator",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L700-L729 | [
"def",
"fix_e225",
"(",
"self",
",",
"result",
")",
":",
"target",
"=",
"self",
".",
"source",
"[",
"result",
"[",
"'line'",
"]",
"-",
"1",
"]",
"offset",
"=",
"result",
"[",
"'column'",
"]",
"-",
"1",
"fixed",
"=",
"target",
"[",
":",
"offset",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e231 | Add missing whitespace. | autopep8.py | def fix_e231(self, result):
"""Add missing whitespace."""
line_index = result['line'] - 1
target = self.source[line_index]
offset = result['column']
fixed = target[:offset].rstrip() + ' ' + target[offset:].lstrip()
self.source[line_index] = fixed | def fix_e231(self, result):
"""Add missing whitespace."""
line_index = result['line'] - 1
target = self.source[line_index]
offset = result['column']
fixed = target[:offset].rstrip() + ' ' + target[offset:].lstrip()
self.source[line_index] = fixed | [
"Add",
"missing",
"whitespace",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L731-L737 | [
"def",
"fix_e231",
"(",
"self",
",",
"result",
")",
":",
"line_index",
"=",
"result",
"[",
"'line'",
"]",
"-",
"1",
"target",
"=",
"self",
".",
"source",
"[",
"line_index",
"]",
"offset",
"=",
"result",
"[",
"'column'",
"]",
"fixed",
"=",
"target",
"... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e251 | Remove whitespace around parameter '=' sign. | autopep8.py | def fix_e251(self, result):
"""Remove whitespace around parameter '=' sign."""
line_index = result['line'] - 1
target = self.source[line_index]
# This is necessary since pycodestyle sometimes reports columns that
# goes past the end of the physical line. This happens in cases li... | def fix_e251(self, result):
"""Remove whitespace around parameter '=' sign."""
line_index = result['line'] - 1
target = self.source[line_index]
# This is necessary since pycodestyle sometimes reports columns that
# goes past the end of the physical line. This happens in cases li... | [
"Remove",
"whitespace",
"around",
"parameter",
"=",
"sign",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L739-L764 | [
"def",
"fix_e251",
"(",
"self",
",",
"result",
")",
":",
"line_index",
"=",
"result",
"[",
"'line'",
"]",
"-",
"1",
"target",
"=",
"self",
".",
"source",
"[",
"line_index",
"]",
"# This is necessary since pycodestyle sometimes reports columns that",
"# goes past the... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e262 | Fix spacing after comment hash. | autopep8.py | def fix_e262(self, result):
"""Fix spacing after comment hash."""
target = self.source[result['line'] - 1]
offset = result['column']
code = target[:offset].rstrip(' \t#')
comment = target[offset:].lstrip(' \t#')
fixed = code + (' # ' + comment if comment.strip() else '... | def fix_e262(self, result):
"""Fix spacing after comment hash."""
target = self.source[result['line'] - 1]
offset = result['column']
code = target[:offset].rstrip(' \t#')
comment = target[offset:].lstrip(' \t#')
fixed = code + (' # ' + comment if comment.strip() else '... | [
"Fix",
"spacing",
"after",
"comment",
"hash",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L766-L776 | [
"def",
"fix_e262",
"(",
"self",
",",
"result",
")",
":",
"target",
"=",
"self",
".",
"source",
"[",
"result",
"[",
"'line'",
"]",
"-",
"1",
"]",
"offset",
"=",
"result",
"[",
"'column'",
"]",
"code",
"=",
"target",
"[",
":",
"offset",
"]",
".",
"... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e271 | Fix extraneous whitespace around keywords. | autopep8.py | def fix_e271(self, result):
"""Fix extraneous whitespace around keywords."""
line_index = result['line'] - 1
target = self.source[line_index]
offset = result['column'] - 1
fixed = fix_whitespace(target,
offset=offset,
... | def fix_e271(self, result):
"""Fix extraneous whitespace around keywords."""
line_index = result['line'] - 1
target = self.source[line_index]
offset = result['column'] - 1
fixed = fix_whitespace(target,
offset=offset,
... | [
"Fix",
"extraneous",
"whitespace",
"around",
"keywords",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L778-L791 | [
"def",
"fix_e271",
"(",
"self",
",",
"result",
")",
":",
"line_index",
"=",
"result",
"[",
"'line'",
"]",
"-",
"1",
"target",
"=",
"self",
".",
"source",
"[",
"line_index",
"]",
"offset",
"=",
"result",
"[",
"'column'",
"]",
"-",
"1",
"fixed",
"=",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e301 | Add missing blank line. | autopep8.py | def fix_e301(self, result):
"""Add missing blank line."""
cr = '\n'
self.source[result['line'] - 1] = cr + self.source[result['line'] - 1] | def fix_e301(self, result):
"""Add missing blank line."""
cr = '\n'
self.source[result['line'] - 1] = cr + self.source[result['line'] - 1] | [
"Add",
"missing",
"blank",
"line",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L793-L796 | [
"def",
"fix_e301",
"(",
"self",
",",
"result",
")",
":",
"cr",
"=",
"'\\n'",
"self",
".",
"source",
"[",
"result",
"[",
"'line'",
"]",
"-",
"1",
"]",
"=",
"cr",
"+",
"self",
".",
"source",
"[",
"result",
"[",
"'line'",
"]",
"-",
"1",
"]"
] | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e302 | Add missing 2 blank lines. | autopep8.py | def fix_e302(self, result):
"""Add missing 2 blank lines."""
add_linenum = 2 - int(result['info'].split()[-1])
cr = '\n' * add_linenum
self.source[result['line'] - 1] = cr + self.source[result['line'] - 1] | def fix_e302(self, result):
"""Add missing 2 blank lines."""
add_linenum = 2 - int(result['info'].split()[-1])
cr = '\n' * add_linenum
self.source[result['line'] - 1] = cr + self.source[result['line'] - 1] | [
"Add",
"missing",
"2",
"blank",
"lines",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L798-L802 | [
"def",
"fix_e302",
"(",
"self",
",",
"result",
")",
":",
"add_linenum",
"=",
"2",
"-",
"int",
"(",
"result",
"[",
"'info'",
"]",
".",
"split",
"(",
")",
"[",
"-",
"1",
"]",
")",
"cr",
"=",
"'\\n'",
"*",
"add_linenum",
"self",
".",
"source",
"[",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e303 | Remove extra blank lines. | autopep8.py | def fix_e303(self, result):
"""Remove extra blank lines."""
delete_linenum = int(result['info'].split('(')[1].split(')')[0]) - 2
delete_linenum = max(1, delete_linenum)
# We need to count because pycodestyle reports an offset line number if
# there are comments.
cnt = 0
... | def fix_e303(self, result):
"""Remove extra blank lines."""
delete_linenum = int(result['info'].split('(')[1].split(')')[0]) - 2
delete_linenum = max(1, delete_linenum)
# We need to count because pycodestyle reports an offset line number if
# there are comments.
cnt = 0
... | [
"Remove",
"extra",
"blank",
"lines",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L804-L821 | [
"def",
"fix_e303",
"(",
"self",
",",
"result",
")",
":",
"delete_linenum",
"=",
"int",
"(",
"result",
"[",
"'info'",
"]",
".",
"split",
"(",
"'('",
")",
"[",
"1",
"]",
".",
"split",
"(",
"')'",
")",
"[",
"0",
"]",
")",
"-",
"2",
"delete_linenum",... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e304 | Remove blank line following function decorator. | autopep8.py | def fix_e304(self, result):
"""Remove blank line following function decorator."""
line = result['line'] - 2
if not self.source[line].strip():
self.source[line] = '' | def fix_e304(self, result):
"""Remove blank line following function decorator."""
line = result['line'] - 2
if not self.source[line].strip():
self.source[line] = '' | [
"Remove",
"blank",
"line",
"following",
"function",
"decorator",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L823-L827 | [
"def",
"fix_e304",
"(",
"self",
",",
"result",
")",
":",
"line",
"=",
"result",
"[",
"'line'",
"]",
"-",
"2",
"if",
"not",
"self",
".",
"source",
"[",
"line",
"]",
".",
"strip",
"(",
")",
":",
"self",
".",
"source",
"[",
"line",
"]",
"=",
"''"
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e305 | Add missing 2 blank lines after end of function or class. | autopep8.py | def fix_e305(self, result):
"""Add missing 2 blank lines after end of function or class."""
add_delete_linenum = 2 - int(result['info'].split()[-1])
cnt = 0
offset = result['line'] - 2
modified_lines = []
if add_delete_linenum < 0:
# delete cr
add_... | def fix_e305(self, result):
"""Add missing 2 blank lines after end of function or class."""
add_delete_linenum = 2 - int(result['info'].split()[-1])
cnt = 0
offset = result['line'] - 2
modified_lines = []
if add_delete_linenum < 0:
# delete cr
add_... | [
"Add",
"missing",
"2",
"blank",
"lines",
"after",
"end",
"of",
"function",
"or",
"class",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L829-L860 | [
"def",
"fix_e305",
"(",
"self",
",",
"result",
")",
":",
"add_delete_linenum",
"=",
"2",
"-",
"int",
"(",
"result",
"[",
"'info'",
"]",
".",
"split",
"(",
")",
"[",
"-",
"1",
"]",
")",
"cnt",
"=",
"0",
"offset",
"=",
"result",
"[",
"'line'",
"]",... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e401 | Put imports on separate lines. | autopep8.py | def fix_e401(self, result):
"""Put imports on separate lines."""
line_index = result['line'] - 1
target = self.source[line_index]
offset = result['column'] - 1
if not target.lstrip().startswith('import'):
return []
indentation = re.split(pattern=r'\bimport\b... | def fix_e401(self, result):
"""Put imports on separate lines."""
line_index = result['line'] - 1
target = self.source[line_index]
offset = result['column'] - 1
if not target.lstrip().startswith('import'):
return []
indentation = re.split(pattern=r'\bimport\b... | [
"Put",
"imports",
"on",
"separate",
"lines",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L862-L875 | [
"def",
"fix_e401",
"(",
"self",
",",
"result",
")",
":",
"line_index",
"=",
"result",
"[",
"'line'",
"]",
"-",
"1",
"target",
"=",
"self",
".",
"source",
"[",
"line_index",
"]",
"offset",
"=",
"result",
"[",
"'column'",
"]",
"-",
"1",
"if",
"not",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e502 | Remove extraneous escape of newline. | autopep8.py | def fix_e502(self, result):
"""Remove extraneous escape of newline."""
(line_index, _, target) = get_index_offset_contents(result,
self.source)
self.source[line_index] = target.rstrip('\n\r \t\\') + '\n' | def fix_e502(self, result):
"""Remove extraneous escape of newline."""
(line_index, _, target) = get_index_offset_contents(result,
self.source)
self.source[line_index] = target.rstrip('\n\r \t\\') + '\n' | [
"Remove",
"extraneous",
"escape",
"of",
"newline",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L983-L987 | [
"def",
"fix_e502",
"(",
"self",
",",
"result",
")",
":",
"(",
"line_index",
",",
"_",
",",
"target",
")",
"=",
"get_index_offset_contents",
"(",
"result",
",",
"self",
".",
"source",
")",
"self",
".",
"source",
"[",
"line_index",
"]",
"=",
"target",
".... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e701 | Put colon-separated compound statement on separate lines. | autopep8.py | def fix_e701(self, result):
"""Put colon-separated compound statement on separate lines."""
line_index = result['line'] - 1
target = self.source[line_index]
c = result['column']
fixed_source = (target[:c] + '\n' +
_get_indentation(target) + self.indent_wo... | def fix_e701(self, result):
"""Put colon-separated compound statement on separate lines."""
line_index = result['line'] - 1
target = self.source[line_index]
c = result['column']
fixed_source = (target[:c] + '\n' +
_get_indentation(target) + self.indent_wo... | [
"Put",
"colon",
"-",
"separated",
"compound",
"statement",
"on",
"separate",
"lines",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L989-L999 | [
"def",
"fix_e701",
"(",
"self",
",",
"result",
")",
":",
"line_index",
"=",
"result",
"[",
"'line'",
"]",
"-",
"1",
"target",
"=",
"self",
".",
"source",
"[",
"line_index",
"]",
"c",
"=",
"result",
"[",
"'column'",
"]",
"fixed_source",
"=",
"(",
"tar... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e702 | Put semicolon-separated compound statement on separate lines. | autopep8.py | def fix_e702(self, result, logical):
"""Put semicolon-separated compound statement on separate lines."""
if not logical:
return [] # pragma: no cover
logical_lines = logical[2]
# Avoid applying this when indented.
# https://docs.python.org/reference/compound_stmts.h... | def fix_e702(self, result, logical):
"""Put semicolon-separated compound statement on separate lines."""
if not logical:
return [] # pragma: no cover
logical_lines = logical[2]
# Avoid applying this when indented.
# https://docs.python.org/reference/compound_stmts.h... | [
"Put",
"semicolon",
"-",
"separated",
"compound",
"statement",
"on",
"separate",
"lines",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1001-L1041 | [
"def",
"fix_e702",
"(",
"self",
",",
"result",
",",
"logical",
")",
":",
"if",
"not",
"logical",
":",
"return",
"[",
"]",
"# pragma: no cover",
"logical_lines",
"=",
"logical",
"[",
"2",
"]",
"# Avoid applying this when indented.",
"# https://docs.python.org/referen... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e704 | Fix multiple statements on one line def | autopep8.py | def fix_e704(self, result):
"""Fix multiple statements on one line def"""
(line_index, _, target) = get_index_offset_contents(result,
self.source)
match = STARTSWITH_DEF_REGEX.match(target)
if match:
self.source[line... | def fix_e704(self, result):
"""Fix multiple statements on one line def"""
(line_index, _, target) = get_index_offset_contents(result,
self.source)
match = STARTSWITH_DEF_REGEX.match(target)
if match:
self.source[line... | [
"Fix",
"multiple",
"statements",
"on",
"one",
"line",
"def"
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1043-L1052 | [
"def",
"fix_e704",
"(",
"self",
",",
"result",
")",
":",
"(",
"line_index",
",",
"_",
",",
"target",
")",
"=",
"get_index_offset_contents",
"(",
"result",
",",
"self",
".",
"source",
")",
"match",
"=",
"STARTSWITH_DEF_REGEX",
".",
"match",
"(",
"target",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e711 | Fix comparison with None. | autopep8.py | def fix_e711(self, result):
"""Fix comparison with None."""
(line_index, offset, target) = get_index_offset_contents(result,
self.source)
right_offset = offset + 2
if right_offset >= len(target):
return []
... | def fix_e711(self, result):
"""Fix comparison with None."""
(line_index, offset, target) = get_index_offset_contents(result,
self.source)
right_offset = offset + 2
if right_offset >= len(target):
return []
... | [
"Fix",
"comparison",
"with",
"None",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1054-L1077 | [
"def",
"fix_e711",
"(",
"self",
",",
"result",
")",
":",
"(",
"line_index",
",",
"offset",
",",
"target",
")",
"=",
"get_index_offset_contents",
"(",
"result",
",",
"self",
".",
"source",
")",
"right_offset",
"=",
"offset",
"+",
"2",
"if",
"right_offset",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e712 | Fix (trivial case of) comparison with boolean. | autopep8.py | def fix_e712(self, result):
"""Fix (trivial case of) comparison with boolean."""
(line_index, offset, target) = get_index_offset_contents(result,
self.source)
# Handle very easy "not" special cases.
if re.match(r'^\s*if [\... | def fix_e712(self, result):
"""Fix (trivial case of) comparison with boolean."""
(line_index, offset, target) = get_index_offset_contents(result,
self.source)
# Handle very easy "not" special cases.
if re.match(r'^\s*if [\... | [
"Fix",
"(",
"trivial",
"case",
"of",
")",
"comparison",
"with",
"boolean",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1079-L1115 | [
"def",
"fix_e712",
"(",
"self",
",",
"result",
")",
":",
"(",
"line_index",
",",
"offset",
",",
"target",
")",
"=",
"get_index_offset_contents",
"(",
"result",
",",
"self",
".",
"source",
")",
"# Handle very easy \"not\" special cases.",
"if",
"re",
".",
"matc... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e713 | Fix (trivial case of) non-membership check. | autopep8.py | def fix_e713(self, result):
"""Fix (trivial case of) non-membership check."""
(line_index, offset, target) = get_index_offset_contents(result,
self.source)
# to convert once 'not in' -> 'in'
before_target = target[:offset]... | def fix_e713(self, result):
"""Fix (trivial case of) non-membership check."""
(line_index, offset, target) = get_index_offset_contents(result,
self.source)
# to convert once 'not in' -> 'in'
before_target = target[:offset]... | [
"Fix",
"(",
"trivial",
"case",
"of",
")",
"non",
"-",
"membership",
"check",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1117-L1147 | [
"def",
"fix_e713",
"(",
"self",
",",
"result",
")",
":",
"(",
"line_index",
",",
"offset",
",",
"target",
")",
"=",
"get_index_offset_contents",
"(",
"result",
",",
"self",
".",
"source",
")",
"# to convert once 'not in' -> 'in'",
"before_target",
"=",
"target",... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e714 | Fix object identity should be 'is not' case. | autopep8.py | def fix_e714(self, result):
"""Fix object identity should be 'is not' case."""
(line_index, offset, target) = get_index_offset_contents(result,
self.source)
# to convert once 'is not' -> 'is'
before_target = target[:offset... | def fix_e714(self, result):
"""Fix object identity should be 'is not' case."""
(line_index, offset, target) = get_index_offset_contents(result,
self.source)
# to convert once 'is not' -> 'is'
before_target = target[:offset... | [
"Fix",
"object",
"identity",
"should",
"be",
"is",
"not",
"case",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1149-L1178 | [
"def",
"fix_e714",
"(",
"self",
",",
"result",
")",
":",
"(",
"line_index",
",",
"offset",
",",
"target",
")",
"=",
"get_index_offset_contents",
"(",
"result",
",",
"self",
".",
"source",
")",
"# to convert once 'is not' -> 'is'",
"before_target",
"=",
"target",... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_e731 | Fix do not assign a lambda expression check. | autopep8.py | def fix_e731(self, result):
"""Fix do not assign a lambda expression check."""
(line_index, _, target) = get_index_offset_contents(result,
self.source)
match = LAMBDA_REGEX.search(target)
if match:
end = match.end()
... | def fix_e731(self, result):
"""Fix do not assign a lambda expression check."""
(line_index, _, target) = get_index_offset_contents(result,
self.source)
match = LAMBDA_REGEX.search(target)
if match:
end = match.end()
... | [
"Fix",
"do",
"not",
"assign",
"a",
"lambda",
"expression",
"check",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1190-L1199 | [
"def",
"fix_e731",
"(",
"self",
",",
"result",
")",
":",
"(",
"line_index",
",",
"_",
",",
"target",
")",
"=",
"get_index_offset_contents",
"(",
"result",
",",
"self",
".",
"source",
")",
"match",
"=",
"LAMBDA_REGEX",
".",
"search",
"(",
"target",
")",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_w291 | Remove trailing whitespace. | autopep8.py | def fix_w291(self, result):
"""Remove trailing whitespace."""
fixed_line = self.source[result['line'] - 1].rstrip()
self.source[result['line'] - 1] = fixed_line + '\n' | def fix_w291(self, result):
"""Remove trailing whitespace."""
fixed_line = self.source[result['line'] - 1].rstrip()
self.source[result['line'] - 1] = fixed_line + '\n' | [
"Remove",
"trailing",
"whitespace",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1201-L1204 | [
"def",
"fix_w291",
"(",
"self",
",",
"result",
")",
":",
"fixed_line",
"=",
"self",
".",
"source",
"[",
"result",
"[",
"'line'",
"]",
"-",
"1",
"]",
".",
"rstrip",
"(",
")",
"self",
".",
"source",
"[",
"result",
"[",
"'line'",
"]",
"-",
"1",
"]",... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | FixPEP8.fix_w391 | Remove trailing blank lines. | autopep8.py | def fix_w391(self, _):
"""Remove trailing blank lines."""
blank_count = 0
for line in reversed(self.source):
line = line.rstrip()
if line:
break
else:
blank_count += 1
original_length = len(self.source)
self.sou... | def fix_w391(self, _):
"""Remove trailing blank lines."""
blank_count = 0
for line in reversed(self.source):
line = line.rstrip()
if line:
break
else:
blank_count += 1
original_length = len(self.source)
self.sou... | [
"Remove",
"trailing",
"blank",
"lines",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L1206-L1218 | [
"def",
"fix_w391",
"(",
"self",
",",
"_",
")",
":",
"blank_count",
"=",
"0",
"for",
"line",
"in",
"reversed",
"(",
"self",
".",
"source",
")",
":",
"line",
"=",
"line",
".",
"rstrip",
"(",
")",
"if",
"line",
":",
"break",
"else",
":",
"blank_count"... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | ReformattedLines.current_size | The size of the current line minus the indentation. | autopep8.py | def current_size(self):
"""The size of the current line minus the indentation."""
size = 0
for item in reversed(self._lines):
size += item.size
if isinstance(item, self._LineBreak):
break
return size | def current_size(self):
"""The size of the current line minus the indentation."""
size = 0
for item in reversed(self._lines):
size += item.size
if isinstance(item, self._LineBreak):
break
return size | [
"The",
"size",
"of",
"the",
"current",
"line",
"minus",
"the",
"indentation",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L2107-L2115 | [
"def",
"current_size",
"(",
"self",
")",
":",
"size",
"=",
"0",
"for",
"item",
"in",
"reversed",
"(",
"self",
".",
"_lines",
")",
":",
"size",
"+=",
"item",
".",
"size",
"if",
"isinstance",
"(",
"item",
",",
"self",
".",
"_LineBreak",
")",
":",
"br... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | ReformattedLines._add_item | Add an item to the line.
Reflow the line to get the best formatting after the item is
inserted. The bracket depth indicates if the item is being
inserted inside of a container or not. | autopep8.py | def _add_item(self, item, indent_amt):
"""Add an item to the line.
Reflow the line to get the best formatting after the item is
inserted. The bracket depth indicates if the item is being
inserted inside of a container or not.
"""
if self._prev_item and self._prev_item.i... | def _add_item(self, item, indent_amt):
"""Add an item to the line.
Reflow the line to get the best formatting after the item is
inserted. The bracket depth indicates if the item is being
inserted inside of a container or not.
"""
if self._prev_item and self._prev_item.i... | [
"Add",
"an",
"item",
"to",
"the",
"line",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L2134-L2173 | [
"def",
"_add_item",
"(",
"self",
",",
"item",
",",
"indent_amt",
")",
":",
"if",
"self",
".",
"_prev_item",
"and",
"self",
".",
"_prev_item",
".",
"is_string",
"and",
"item",
".",
"is_string",
":",
"# Place consecutive string literals on separate lines.",
"self",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | ReformattedLines._prevent_default_initializer_splitting | Prevent splitting between a default initializer.
When there is a default initializer, it's best to keep it all on
the same line. It's nicer and more readable, even if it goes
over the maximum allowable line length. This goes back along the
current line to determine if we have a default ... | autopep8.py | def _prevent_default_initializer_splitting(self, item, indent_amt):
"""Prevent splitting between a default initializer.
When there is a default initializer, it's best to keep it all on
the same line. It's nicer and more readable, even if it goes
over the maximum allowable line length. T... | def _prevent_default_initializer_splitting(self, item, indent_amt):
"""Prevent splitting between a default initializer.
When there is a default initializer, it's best to keep it all on
the same line. It's nicer and more readable, even if it goes
over the maximum allowable line length. T... | [
"Prevent",
"splitting",
"between",
"a",
"default",
"initializer",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L2211-L2248 | [
"def",
"_prevent_default_initializer_splitting",
"(",
"self",
",",
"item",
",",
"indent_amt",
")",
":",
"if",
"unicode",
"(",
"item",
")",
"==",
"'='",
":",
"# This is the assignment in the initializer. Just remove spaces for",
"# now.",
"self",
".",
"_delete_whitespace",... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | ReformattedLines._enforce_space | Enforce a space in certain situations.
There are cases where we will want a space where normally we
wouldn't put one. This just enforces the addition of a space. | autopep8.py | def _enforce_space(self, item):
"""Enforce a space in certain situations.
There are cases where we will want a space where normally we
wouldn't put one. This just enforces the addition of a space.
"""
if isinstance(self._lines[-1],
(self._Space, self._Line... | def _enforce_space(self, item):
"""Enforce a space in certain situations.
There are cases where we will want a space where normally we
wouldn't put one. This just enforces the addition of a space.
"""
if isinstance(self._lines[-1],
(self._Space, self._Line... | [
"Enforce",
"a",
"space",
"in",
"certain",
"situations",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L2277-L2301 | [
"def",
"_enforce_space",
"(",
"self",
",",
"item",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_lines",
"[",
"-",
"1",
"]",
",",
"(",
"self",
".",
"_Space",
",",
"self",
".",
"_LineBreak",
",",
"self",
".",
"_Indent",
")",
")",
":",
"return",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | ReformattedLines._delete_whitespace | Delete all whitespace from the end of the line. | autopep8.py | def _delete_whitespace(self):
"""Delete all whitespace from the end of the line."""
while isinstance(self._lines[-1], (self._Space, self._LineBreak,
self._Indent)):
del self._lines[-1] | def _delete_whitespace(self):
"""Delete all whitespace from the end of the line."""
while isinstance(self._lines[-1], (self._Space, self._LineBreak,
self._Indent)):
del self._lines[-1] | [
"Delete",
"all",
"whitespace",
"from",
"the",
"end",
"of",
"the",
"line",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L2303-L2307 | [
"def",
"_delete_whitespace",
"(",
"self",
")",
":",
"while",
"isinstance",
"(",
"self",
".",
"_lines",
"[",
"-",
"1",
"]",
",",
"(",
"self",
".",
"_Space",
",",
"self",
".",
"_LineBreak",
",",
"self",
".",
"_Indent",
")",
")",
":",
"del",
"self",
"... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | Container._get_extent | The extent of the full element.
E.g., the length of a function call or keyword. | autopep8.py | def _get_extent(self, index):
"""The extent of the full element.
E.g., the length of a function call or keyword.
"""
extent = 0
prev_item = get_item(self._items, index - 1)
seen_dot = prev_item and unicode(prev_item) == '.'
while index < len(self._items):
... | def _get_extent(self, index):
"""The extent of the full element.
E.g., the length of a function call or keyword.
"""
extent = 0
prev_item = get_item(self._items, index - 1)
seen_dot = prev_item and unicode(prev_item) == '.'
while index < len(self._items):
... | [
"The",
"extent",
"of",
"the",
"full",
"element",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L2475-L2510 | [
"def",
"_get_extent",
"(",
"self",
",",
"index",
")",
":",
"extent",
"=",
"0",
"prev_item",
"=",
"get_item",
"(",
"self",
".",
"_items",
",",
"index",
"-",
"1",
")",
"seen_dot",
"=",
"prev_item",
"and",
"unicode",
"(",
"prev_item",
")",
"==",
"'.'",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | Reindenter.run | Fix indentation and return modified line numbers.
Line numbers are indexed at 1. | autopep8.py | def run(self, indent_size=DEFAULT_INDENT_SIZE):
"""Fix indentation and return modified line numbers.
Line numbers are indexed at 1.
"""
if indent_size < 1:
return self.input_text
try:
stats = _reindent_stats(tokenize.generate_tokens(self.getline))
... | def run(self, indent_size=DEFAULT_INDENT_SIZE):
"""Fix indentation and return modified line numbers.
Line numbers are indexed at 1.
"""
if indent_size < 1:
return self.input_text
try:
stats = _reindent_stats(tokenize.generate_tokens(self.getline))
... | [
"Fix",
"indentation",
"and",
"return",
"modified",
"line",
"numbers",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L2980-L3060 | [
"def",
"run",
"(",
"self",
",",
"indent_size",
"=",
"DEFAULT_INDENT_SIZE",
")",
":",
"if",
"indent_size",
"<",
"1",
":",
"return",
"self",
".",
"input_text",
"try",
":",
"stats",
"=",
"_reindent_stats",
"(",
"tokenize",
".",
"generate_tokens",
"(",
"self",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | Reindenter.getline | Line-getter for tokenize. | autopep8.py | def getline(self):
"""Line-getter for tokenize."""
if self.index >= len(self.lines):
line = ''
else:
line = self.lines[self.index]
self.index += 1
return line | def getline(self):
"""Line-getter for tokenize."""
if self.index >= len(self.lines):
line = ''
else:
line = self.lines[self.index]
self.index += 1
return line | [
"Line",
"-",
"getter",
"for",
"tokenize",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L3062-L3069 | [
"def",
"getline",
"(",
"self",
")",
":",
"if",
"self",
".",
"index",
">=",
"len",
"(",
"self",
".",
"lines",
")",
":",
"line",
"=",
"''",
"else",
":",
"line",
"=",
"self",
".",
"lines",
"[",
"self",
".",
"index",
"]",
"self",
".",
"index",
"+="... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | CachedTokenizer.generate_tokens | A stand-in for tokenize.generate_tokens(). | autopep8.py | def generate_tokens(self, text):
"""A stand-in for tokenize.generate_tokens()."""
if text != self.last_text:
string_io = io.StringIO(text)
self.last_tokens = list(
tokenize.generate_tokens(string_io.readline)
)
self.last_text = text
... | def generate_tokens(self, text):
"""A stand-in for tokenize.generate_tokens()."""
if text != self.last_text:
string_io = io.StringIO(text)
self.last_tokens = list(
tokenize.generate_tokens(string_io.readline)
)
self.last_text = text
... | [
"A",
"stand",
"-",
"in",
"for",
"tokenize",
".",
"generate_tokens",
"()",
"."
] | hhatto/autopep8 | python | https://github.com/hhatto/autopep8/blob/fda3bb39181437b6b8a0aa0185f21ae5f14385dd/autopep8.py#L4219-L4227 | [
"def",
"generate_tokens",
"(",
"self",
",",
"text",
")",
":",
"if",
"text",
"!=",
"self",
".",
"last_text",
":",
"string_io",
"=",
"io",
".",
"StringIO",
"(",
"text",
")",
"self",
".",
"last_tokens",
"=",
"list",
"(",
"tokenize",
".",
"generate_tokens",
... | fda3bb39181437b6b8a0aa0185f21ae5f14385dd |
train | LeastSquaresFilter.reset | reset filter back to state at time of construction | filterpy/leastsq/least_squares.py | def reset(self):
""" reset filter back to state at time of construction"""
self.n = 0 # nth step in the recursion
self.x = np.zeros(self._order + 1)
self.K = np.zeros(self._order + 1)
self.y = 0 | def reset(self):
""" reset filter back to state at time of construction"""
self.n = 0 # nth step in the recursion
self.x = np.zeros(self._order + 1)
self.K = np.zeros(self._order + 1)
self.y = 0 | [
"reset",
"filter",
"back",
"to",
"state",
"at",
"time",
"of",
"construction"
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/leastsq/least_squares.py#L104-L110 | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"n",
"=",
"0",
"# nth step in the recursion",
"self",
".",
"x",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"_order",
"+",
"1",
")",
"self",
".",
"K",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | LeastSquaresFilter.update | Update filter with new measurement `z`
Returns
-------
x : np.array
estimate for this time step (same as self.x) | filterpy/leastsq/least_squares.py | def update(self, z):
""" Update filter with new measurement `z`
Returns
-------
x : np.array
estimate for this time step (same as self.x)
"""
self.n += 1
# rename for readability
n = self.n
dt = self.dt
x = self.x
K =... | def update(self, z):
""" Update filter with new measurement `z`
Returns
-------
x : np.array
estimate for this time step (same as self.x)
"""
self.n += 1
# rename for readability
n = self.n
dt = self.dt
x = self.x
K =... | [
"Update",
"filter",
"with",
"new",
"measurement",
"z"
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/leastsq/least_squares.py#L112-L155 | [
"def",
"update",
"(",
"self",
",",
"z",
")",
":",
"self",
".",
"n",
"+=",
"1",
"# rename for readability",
"n",
"=",
"self",
".",
"n",
"dt",
"=",
"self",
".",
"dt",
"x",
"=",
"self",
".",
"x",
"K",
"=",
"self",
".",
"K",
"y",
"=",
"self",
"."... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | LeastSquaresFilter.errors | Computes and returns the error and standard deviation of the
filter at this time step.
Returns
-------
error : np.array size 1xorder+1
std : np.array size 1xorder+1 | filterpy/leastsq/least_squares.py | def errors(self):
"""
Computes and returns the error and standard deviation of the
filter at this time step.
Returns
-------
error : np.array size 1xorder+1
std : np.array size 1xorder+1
"""
n = self.n
dt = self.dt
order = self._... | def errors(self):
"""
Computes and returns the error and standard deviation of the
filter at this time step.
Returns
-------
error : np.array size 1xorder+1
std : np.array size 1xorder+1
"""
n = self.n
dt = self.dt
order = self._... | [
"Computes",
"and",
"returns",
"the",
"error",
"and",
"standard",
"deviation",
"of",
"the",
"filter",
"at",
"this",
"time",
"step",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/leastsq/least_squares.py#L157-L205 | [
"def",
"errors",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"n",
"dt",
"=",
"self",
".",
"dt",
"order",
"=",
"self",
".",
"_order",
"sigma",
"=",
"self",
".",
"sigma",
"error",
"=",
"np",
".",
"zeros",
"(",
"order",
"+",
"1",
")",
"std",
"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | update | Add a new measurement (z) to the Kalman filter. If z is None, nothing
is changed.
This can handle either the multidimensional or unidimensional case. If
all parameters are floats instead of arrays the filter will still work,
and return floats for x, P as the result.
update(1, 2, 1, 1, 1) # univar... | filterpy/kalman/kalman_filter.py | def update(x, P, z, R, H=None, return_all=False):
"""
Add a new measurement (z) to the Kalman filter. If z is None, nothing
is changed.
This can handle either the multidimensional or unidimensional case. If
all parameters are floats instead of arrays the filter will still work,
and return float... | def update(x, P, z, R, H=None, return_all=False):
"""
Add a new measurement (z) to the Kalman filter. If z is None, nothing
is changed.
This can handle either the multidimensional or unidimensional case. If
all parameters are floats instead of arrays the filter will still work,
and return float... | [
"Add",
"a",
"new",
"measurement",
"(",
"z",
")",
"to",
"the",
"Kalman",
"filter",
".",
"If",
"z",
"is",
"None",
"nothing",
"is",
"changed",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1297-L1404 | [
"def",
"update",
"(",
"x",
",",
"P",
",",
"z",
",",
"R",
",",
"H",
"=",
"None",
",",
"return_all",
"=",
"False",
")",
":",
"#pylint: disable=bare-except",
"if",
"z",
"is",
"None",
":",
"if",
"return_all",
":",
"return",
"x",
",",
"P",
",",
"None",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | update_steadystate | Add a new measurement (z) to the Kalman filter. If z is None, nothing
is changed.
Parameters
----------
x : numpy.array(dim_x, 1), or float
State estimate vector
z : (dim_z, 1): array_like
measurement for this update. z can be a scalar if dim_z is 1,
otherwise it must be... | filterpy/kalman/kalman_filter.py | def update_steadystate(x, z, K, H=None):
"""
Add a new measurement (z) to the Kalman filter. If z is None, nothing
is changed.
Parameters
----------
x : numpy.array(dim_x, 1), or float
State estimate vector
z : (dim_z, 1): array_like
measurement for this update. z can be... | def update_steadystate(x, z, K, H=None):
"""
Add a new measurement (z) to the Kalman filter. If z is None, nothing
is changed.
Parameters
----------
x : numpy.array(dim_x, 1), or float
State estimate vector
z : (dim_z, 1): array_like
measurement for this update. z can be... | [
"Add",
"a",
"new",
"measurement",
"(",
"z",
")",
"to",
"the",
"Kalman",
"filter",
".",
"If",
"z",
"is",
"None",
"nothing",
"is",
"changed",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1407-L1464 | [
"def",
"update_steadystate",
"(",
"x",
",",
"z",
",",
"K",
",",
"H",
"=",
"None",
")",
":",
"if",
"z",
"is",
"None",
":",
"return",
"x",
"if",
"H",
"is",
"None",
":",
"H",
"=",
"np",
".",
"array",
"(",
"[",
"1",
"]",
")",
"if",
"np",
".",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | predict | Predict next state (prior) using the Kalman filter state propagation
equations.
Parameters
----------
x : numpy.array
State estimate vector
P : numpy.array
Covariance matrix
F : numpy.array()
State Transition matrix
Q : numpy.array, Optional
Process noise... | filterpy/kalman/kalman_filter.py | def predict(x, P, F=1, Q=0, u=0, B=1, alpha=1.):
"""
Predict next state (prior) using the Kalman filter state propagation
equations.
Parameters
----------
x : numpy.array
State estimate vector
P : numpy.array
Covariance matrix
F : numpy.array()
State Transitio... | def predict(x, P, F=1, Q=0, u=0, B=1, alpha=1.):
"""
Predict next state (prior) using the Kalman filter state propagation
equations.
Parameters
----------
x : numpy.array
State estimate vector
P : numpy.array
Covariance matrix
F : numpy.array()
State Transitio... | [
"Predict",
"next",
"state",
"(",
"prior",
")",
"using",
"the",
"Kalman",
"filter",
"state",
"propagation",
"equations",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1467-L1517 | [
"def",
"predict",
"(",
"x",
",",
"P",
",",
"F",
"=",
"1",
",",
"Q",
"=",
"0",
",",
"u",
"=",
"0",
",",
"B",
"=",
"1",
",",
"alpha",
"=",
"1.",
")",
":",
"if",
"np",
".",
"isscalar",
"(",
"F",
")",
":",
"F",
"=",
"np",
".",
"array",
"(... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | predict_steadystate | Predict next state (prior) using the Kalman filter state propagation
equations. This steady state form only computes x, assuming that the
covariance is constant.
Parameters
----------
x : numpy.array
State estimate vector
P : numpy.array
Covariance matrix
F : numpy.array(... | filterpy/kalman/kalman_filter.py | def predict_steadystate(x, F=1, u=0, B=1):
"""
Predict next state (prior) using the Kalman filter state propagation
equations. This steady state form only computes x, assuming that the
covariance is constant.
Parameters
----------
x : numpy.array
State estimate vector
P : nump... | def predict_steadystate(x, F=1, u=0, B=1):
"""
Predict next state (prior) using the Kalman filter state propagation
equations. This steady state form only computes x, assuming that the
covariance is constant.
Parameters
----------
x : numpy.array
State estimate vector
P : nump... | [
"Predict",
"next",
"state",
"(",
"prior",
")",
"using",
"the",
"Kalman",
"filter",
"state",
"propagation",
"equations",
".",
"This",
"steady",
"state",
"form",
"only",
"computes",
"x",
"assuming",
"that",
"the",
"covariance",
"is",
"constant",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1520-L1556 | [
"def",
"predict_steadystate",
"(",
"x",
",",
"F",
"=",
"1",
",",
"u",
"=",
"0",
",",
"B",
"=",
"1",
")",
":",
"if",
"np",
".",
"isscalar",
"(",
"F",
")",
":",
"F",
"=",
"np",
".",
"array",
"(",
"F",
")",
"x",
"=",
"dot",
"(",
"F",
",",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | batch_filter | Batch processes a sequences of measurements.
Parameters
----------
zs : list-like
list of measurements at each time step. Missing measurements must be
represented by None.
Fs : list-like
list of values to use for the state transition matrix matrix.
Qs : list-like
... | filterpy/kalman/kalman_filter.py | def batch_filter(x, P, zs, Fs, Qs, Hs, Rs, Bs=None, us=None,
update_first=False, saver=None):
"""
Batch processes a sequences of measurements.
Parameters
----------
zs : list-like
list of measurements at each time step. Missing measurements must be
represented by N... | def batch_filter(x, P, zs, Fs, Qs, Hs, Rs, Bs=None, us=None,
update_first=False, saver=None):
"""
Batch processes a sequences of measurements.
Parameters
----------
zs : list-like
list of measurements at each time step. Missing measurements must be
represented by N... | [
"Batch",
"processes",
"a",
"sequences",
"of",
"measurements",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1560-L1684 | [
"def",
"batch_filter",
"(",
"x",
",",
"P",
",",
"zs",
",",
"Fs",
",",
"Qs",
",",
"Hs",
",",
"Rs",
",",
"Bs",
"=",
"None",
",",
"us",
"=",
"None",
",",
"update_first",
"=",
"False",
",",
"saver",
"=",
"None",
")",
":",
"n",
"=",
"np",
".",
"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | rts_smoother | Runs the Rauch-Tung-Striebal Kalman smoother on a set of
means and covariances computed by a Kalman filter. The usual input
would come from the output of `KalmanFilter.batch_filter()`.
Parameters
----------
Xs : numpy.array
array of the means (state variable x) of the output of a Kalman
... | filterpy/kalman/kalman_filter.py | def rts_smoother(Xs, Ps, Fs, Qs):
"""
Runs the Rauch-Tung-Striebal Kalman smoother on a set of
means and covariances computed by a Kalman filter. The usual input
would come from the output of `KalmanFilter.batch_filter()`.
Parameters
----------
Xs : numpy.array
array of the means (s... | def rts_smoother(Xs, Ps, Fs, Qs):
"""
Runs the Rauch-Tung-Striebal Kalman smoother on a set of
means and covariances computed by a Kalman filter. The usual input
would come from the output of `KalmanFilter.batch_filter()`.
Parameters
----------
Xs : numpy.array
array of the means (s... | [
"Runs",
"the",
"Rauch",
"-",
"Tung",
"-",
"Striebal",
"Kalman",
"smoother",
"on",
"a",
"set",
"of",
"means",
"and",
"covariances",
"computed",
"by",
"a",
"Kalman",
"filter",
".",
"The",
"usual",
"input",
"would",
"come",
"from",
"the",
"output",
"of",
"K... | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1688-L1754 | [
"def",
"rts_smoother",
"(",
"Xs",
",",
"Ps",
",",
"Fs",
",",
"Qs",
")",
":",
"if",
"len",
"(",
"Xs",
")",
"!=",
"len",
"(",
"Ps",
")",
":",
"raise",
"ValueError",
"(",
"'length of Xs and Ps must be the same'",
")",
"n",
"=",
"Xs",
".",
"shape",
"[",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.predict | Predict next state (prior) using the Kalman filter state propagation
equations.
Parameters
----------
u : np.array
Optional control vector. If not `None`, it is multiplied by B
to create the control input into the system.
B : np.array(dim_x, dim_z), or ... | filterpy/kalman/kalman_filter.py | def predict(self, u=None, B=None, F=None, Q=None):
"""
Predict next state (prior) using the Kalman filter state propagation
equations.
Parameters
----------
u : np.array
Optional control vector. If not `None`, it is multiplied by B
to create the ... | def predict(self, u=None, B=None, F=None, Q=None):
"""
Predict next state (prior) using the Kalman filter state propagation
equations.
Parameters
----------
u : np.array
Optional control vector. If not `None`, it is multiplied by B
to create the ... | [
"Predict",
"next",
"state",
"(",
"prior",
")",
"using",
"the",
"Kalman",
"filter",
"state",
"propagation",
"equations",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L443-L488 | [
"def",
"predict",
"(",
"self",
",",
"u",
"=",
"None",
",",
"B",
"=",
"None",
",",
"F",
"=",
"None",
",",
"Q",
"=",
"None",
")",
":",
"if",
"B",
"is",
"None",
":",
"B",
"=",
"self",
".",
"B",
"if",
"F",
"is",
"None",
":",
"F",
"=",
"self",... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.predict_steadystate | Predict state (prior) using the Kalman filter state propagation
equations. Only x is updated, P is left unchanged. See
update_steadstate() for a longer explanation of when to use this
method.
Parameters
----------
u : np.array
Optional control vector. If non... | filterpy/kalman/kalman_filter.py | def predict_steadystate(self, u=0, B=None):
"""
Predict state (prior) using the Kalman filter state propagation
equations. Only x is updated, P is left unchanged. See
update_steadstate() for a longer explanation of when to use this
method.
Parameters
----------
... | def predict_steadystate(self, u=0, B=None):
"""
Predict state (prior) using the Kalman filter state propagation
equations. Only x is updated, P is left unchanged. See
update_steadstate() for a longer explanation of when to use this
method.
Parameters
----------
... | [
"Predict",
"state",
"(",
"prior",
")",
"using",
"the",
"Kalman",
"filter",
"state",
"propagation",
"equations",
".",
"Only",
"x",
"is",
"updated",
"P",
"is",
"left",
"unchanged",
".",
"See",
"update_steadstate",
"()",
"for",
"a",
"longer",
"explanation",
"of... | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L567-L597 | [
"def",
"predict_steadystate",
"(",
"self",
",",
"u",
"=",
"0",
",",
"B",
"=",
"None",
")",
":",
"if",
"B",
"is",
"None",
":",
"B",
"=",
"self",
".",
"B",
"# x = Fx + Bu",
"if",
"B",
"is",
"not",
"None",
":",
"self",
".",
"x",
"=",
"dot",
"(",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.update_steadystate | Add a new measurement (z) to the Kalman filter without recomputing
the Kalman gain K, the state covariance P, or the system
uncertainty S.
You can use this for LTI systems since the Kalman gain and covariance
converge to a fixed value. Precompute these and assign them explicitly,
... | filterpy/kalman/kalman_filter.py | def update_steadystate(self, z):
"""
Add a new measurement (z) to the Kalman filter without recomputing
the Kalman gain K, the state covariance P, or the system
uncertainty S.
You can use this for LTI systems since the Kalman gain and covariance
converge to a fixed value... | def update_steadystate(self, z):
"""
Add a new measurement (z) to the Kalman filter without recomputing
the Kalman gain K, the state covariance P, or the system
uncertainty S.
You can use this for LTI systems since the Kalman gain and covariance
converge to a fixed value... | [
"Add",
"a",
"new",
"measurement",
"(",
"z",
")",
"to",
"the",
"Kalman",
"filter",
"without",
"recomputing",
"the",
"Kalman",
"gain",
"K",
"the",
"state",
"covariance",
"P",
"or",
"the",
"system",
"uncertainty",
"S",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L599-L672 | [
"def",
"update_steadystate",
"(",
"self",
",",
"z",
")",
":",
"# set to None to force recompute",
"self",
".",
"_log_likelihood",
"=",
"None",
"self",
".",
"_likelihood",
"=",
"None",
"self",
".",
"_mahalanobis",
"=",
"None",
"if",
"z",
"is",
"None",
":",
"s... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.update_correlated | Add a new measurement (z) to the Kalman filter assuming that
process noise and measurement noise are correlated as defined in
the `self.M` matrix.
If z is None, nothing is changed.
Parameters
----------
z : (dim_z, 1): array_like
measurement for this update.... | filterpy/kalman/kalman_filter.py | def update_correlated(self, z, R=None, H=None):
""" Add a new measurement (z) to the Kalman filter assuming that
process noise and measurement noise are correlated as defined in
the `self.M` matrix.
If z is None, nothing is changed.
Parameters
----------
z : (di... | def update_correlated(self, z, R=None, H=None):
""" Add a new measurement (z) to the Kalman filter assuming that
process noise and measurement noise are correlated as defined in
the `self.M` matrix.
If z is None, nothing is changed.
Parameters
----------
z : (di... | [
"Add",
"a",
"new",
"measurement",
"(",
"z",
")",
"to",
"the",
"Kalman",
"filter",
"assuming",
"that",
"process",
"noise",
"and",
"measurement",
"noise",
"are",
"correlated",
"as",
"defined",
"in",
"the",
"self",
".",
"M",
"matrix",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L674-L749 | [
"def",
"update_correlated",
"(",
"self",
",",
"z",
",",
"R",
"=",
"None",
",",
"H",
"=",
"None",
")",
":",
"# set to None to force recompute",
"self",
".",
"_log_likelihood",
"=",
"None",
"self",
".",
"_likelihood",
"=",
"None",
"self",
".",
"_mahalanobis",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.batch_filter | Batch processes a sequences of measurements.
Parameters
----------
zs : list-like
list of measurements at each time step `self.dt`. Missing
measurements must be represented by `None`.
Fs : None, list-like, default=None
optional value or list of valu... | filterpy/kalman/kalman_filter.py | def batch_filter(self, zs, Fs=None, Qs=None, Hs=None,
Rs=None, Bs=None, us=None, update_first=False,
saver=None):
""" Batch processes a sequences of measurements.
Parameters
----------
zs : list-like
list of measurements at each tim... | def batch_filter(self, zs, Fs=None, Qs=None, Hs=None,
Rs=None, Bs=None, us=None, update_first=False,
saver=None):
""" Batch processes a sequences of measurements.
Parameters
----------
zs : list-like
list of measurements at each tim... | [
"Batch",
"processes",
"a",
"sequences",
"of",
"measurements",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L751-L918 | [
"def",
"batch_filter",
"(",
"self",
",",
"zs",
",",
"Fs",
"=",
"None",
",",
"Qs",
"=",
"None",
",",
"Hs",
"=",
"None",
",",
"Rs",
"=",
"None",
",",
"Bs",
"=",
"None",
",",
"us",
"=",
"None",
",",
"update_first",
"=",
"False",
",",
"saver",
"=",... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.rts_smoother | Runs the Rauch-Tung-Striebal Kalman smoother on a set of
means and covariances computed by a Kalman filter. The usual input
would come from the output of `KalmanFilter.batch_filter()`.
Parameters
----------
Xs : numpy.array
array of the means (state variable x) of th... | filterpy/kalman/kalman_filter.py | def rts_smoother(self, Xs, Ps, Fs=None, Qs=None, inv=np.linalg.inv):
"""
Runs the Rauch-Tung-Striebal Kalman smoother on a set of
means and covariances computed by a Kalman filter. The usual input
would come from the output of `KalmanFilter.batch_filter()`.
Parameters
--... | def rts_smoother(self, Xs, Ps, Fs=None, Qs=None, inv=np.linalg.inv):
"""
Runs the Rauch-Tung-Striebal Kalman smoother on a set of
means and covariances computed by a Kalman filter. The usual input
would come from the output of `KalmanFilter.batch_filter()`.
Parameters
--... | [
"Runs",
"the",
"Rauch",
"-",
"Tung",
"-",
"Striebal",
"Kalman",
"smoother",
"on",
"a",
"set",
"of",
"means",
"and",
"covariances",
"computed",
"by",
"a",
"Kalman",
"filter",
".",
"The",
"usual",
"input",
"would",
"come",
"from",
"the",
"output",
"of",
"K... | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L920-L999 | [
"def",
"rts_smoother",
"(",
"self",
",",
"Xs",
",",
"Ps",
",",
"Fs",
"=",
"None",
",",
"Qs",
"=",
"None",
",",
"inv",
"=",
"np",
".",
"linalg",
".",
"inv",
")",
":",
"if",
"len",
"(",
"Xs",
")",
"!=",
"len",
"(",
"Ps",
")",
":",
"raise",
"V... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.get_prediction | Predicts the next state of the filter and returns it without
altering the state of the filter.
Parameters
----------
u : np.array
optional control input
Returns
-------
(x, P) : tuple
State vector and covariance array of the prediction. | filterpy/kalman/kalman_filter.py | def get_prediction(self, u=0):
"""
Predicts the next state of the filter and returns it without
altering the state of the filter.
Parameters
----------
u : np.array
optional control input
Returns
-------
(x, P) : tuple
S... | def get_prediction(self, u=0):
"""
Predicts the next state of the filter and returns it without
altering the state of the filter.
Parameters
----------
u : np.array
optional control input
Returns
-------
(x, P) : tuple
S... | [
"Predicts",
"the",
"next",
"state",
"of",
"the",
"filter",
"and",
"returns",
"it",
"without",
"altering",
"the",
"state",
"of",
"the",
"filter",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1001-L1021 | [
"def",
"get_prediction",
"(",
"self",
",",
"u",
"=",
"0",
")",
":",
"x",
"=",
"dot",
"(",
"self",
".",
"F",
",",
"self",
".",
"x",
")",
"+",
"dot",
"(",
"self",
".",
"B",
",",
"u",
")",
"P",
"=",
"self",
".",
"_alpha_sq",
"*",
"dot",
"(",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.get_update | Computes the new estimate based on measurement `z` and returns it
without altering the state of the filter.
Parameters
----------
z : (dim_z, 1): array_like
measurement for this update. z can be a scalar if dim_z is 1,
otherwise it must be convertible to a colum... | filterpy/kalman/kalman_filter.py | def get_update(self, z=None):
"""
Computes the new estimate based on measurement `z` and returns it
without altering the state of the filter.
Parameters
----------
z : (dim_z, 1): array_like
measurement for this update. z can be a scalar if dim_z is 1,
... | def get_update(self, z=None):
"""
Computes the new estimate based on measurement `z` and returns it
without altering the state of the filter.
Parameters
----------
z : (dim_z, 1): array_like
measurement for this update. z can be a scalar if dim_z is 1,
... | [
"Computes",
"the",
"new",
"estimate",
"based",
"on",
"measurement",
"z",
"and",
"returns",
"it",
"without",
"altering",
"the",
"state",
"of",
"the",
"filter",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1023-L1070 | [
"def",
"get_update",
"(",
"self",
",",
"z",
"=",
"None",
")",
":",
"if",
"z",
"is",
"None",
":",
"return",
"self",
".",
"x",
",",
"self",
".",
"P",
"z",
"=",
"reshape_z",
"(",
"z",
",",
"self",
".",
"dim_z",
",",
"self",
".",
"x",
".",
"ndim"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.log_likelihood | log-likelihood of the last measurement. | filterpy/kalman/kalman_filter.py | def log_likelihood(self):
"""
log-likelihood of the last measurement.
"""
if self._log_likelihood is None:
self._log_likelihood = logpdf(x=self.y, cov=self.S)
return self._log_likelihood | def log_likelihood(self):
"""
log-likelihood of the last measurement.
"""
if self._log_likelihood is None:
self._log_likelihood = logpdf(x=self.y, cov=self.S)
return self._log_likelihood | [
"log",
"-",
"likelihood",
"of",
"the",
"last",
"measurement",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1100-L1106 | [
"def",
"log_likelihood",
"(",
"self",
")",
":",
"if",
"self",
".",
"_log_likelihood",
"is",
"None",
":",
"self",
".",
"_log_likelihood",
"=",
"logpdf",
"(",
"x",
"=",
"self",
".",
"y",
",",
"cov",
"=",
"self",
".",
"S",
")",
"return",
"self",
".",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.likelihood | Computed from the log-likelihood. The log-likelihood can be very
small, meaning a large negative value such as -28000. Taking the
exp() of that results in 0.0, which can break typical algorithms
which multiply by this value, so by default we always return a
number >= sys.float_info.min. | filterpy/kalman/kalman_filter.py | def likelihood(self):
"""
Computed from the log-likelihood. The log-likelihood can be very
small, meaning a large negative value such as -28000. Taking the
exp() of that results in 0.0, which can break typical algorithms
which multiply by this value, so by default we always retu... | def likelihood(self):
"""
Computed from the log-likelihood. The log-likelihood can be very
small, meaning a large negative value such as -28000. Taking the
exp() of that results in 0.0, which can break typical algorithms
which multiply by this value, so by default we always retu... | [
"Computed",
"from",
"the",
"log",
"-",
"likelihood",
".",
"The",
"log",
"-",
"likelihood",
"can",
"be",
"very",
"small",
"meaning",
"a",
"large",
"negative",
"value",
"such",
"as",
"-",
"28000",
".",
"Taking",
"the",
"exp",
"()",
"of",
"that",
"results",... | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1109-L1121 | [
"def",
"likelihood",
"(",
"self",
")",
":",
"if",
"self",
".",
"_likelihood",
"is",
"None",
":",
"self",
".",
"_likelihood",
"=",
"exp",
"(",
"self",
".",
"log_likelihood",
")",
"if",
"self",
".",
"_likelihood",
"==",
"0",
":",
"self",
".",
"_likelihoo... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.mahalanobis | Mahalanobis distance of measurement. E.g. 3 means measurement
was 3 standard deviations away from the predicted value.
Returns
-------
mahalanobis : float | filterpy/kalman/kalman_filter.py | def mahalanobis(self):
""""
Mahalanobis distance of measurement. E.g. 3 means measurement
was 3 standard deviations away from the predicted value.
Returns
-------
mahalanobis : float
"""
if self._mahalanobis is None:
self._mahalanobis = sqrt(f... | def mahalanobis(self):
""""
Mahalanobis distance of measurement. E.g. 3 means measurement
was 3 standard deviations away from the predicted value.
Returns
-------
mahalanobis : float
"""
if self._mahalanobis is None:
self._mahalanobis = sqrt(f... | [
"Mahalanobis",
"distance",
"of",
"measurement",
".",
"E",
".",
"g",
".",
"3",
"means",
"measurement",
"was",
"3",
"standard",
"deviations",
"away",
"from",
"the",
"predicted",
"value",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1124-L1135 | [
"def",
"mahalanobis",
"(",
"self",
")",
":",
"if",
"self",
".",
"_mahalanobis",
"is",
"None",
":",
"self",
".",
"_mahalanobis",
"=",
"sqrt",
"(",
"float",
"(",
"dot",
"(",
"dot",
"(",
"self",
".",
"y",
".",
"T",
",",
"self",
".",
"SI",
")",
",",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | KalmanFilter.log_likelihood_of | log likelihood of the measurement `z`. This should only be called
after a call to update(). Calling after predict() will yield an
incorrect result. | filterpy/kalman/kalman_filter.py | def log_likelihood_of(self, z):
"""
log likelihood of the measurement `z`. This should only be called
after a call to update(). Calling after predict() will yield an
incorrect result."""
if z is None:
return log(sys.float_info.min)
return logpdf(z, dot(self.H... | def log_likelihood_of(self, z):
"""
log likelihood of the measurement `z`. This should only be called
after a call to update(). Calling after predict() will yield an
incorrect result."""
if z is None:
return log(sys.float_info.min)
return logpdf(z, dot(self.H... | [
"log",
"likelihood",
"of",
"the",
"measurement",
"z",
".",
"This",
"should",
"only",
"be",
"called",
"after",
"a",
"call",
"to",
"update",
"()",
".",
"Calling",
"after",
"predict",
"()",
"will",
"yield",
"an",
"incorrect",
"result",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/kalman_filter.py#L1148-L1156 | [
"def",
"log_likelihood_of",
"(",
"self",
",",
"z",
")",
":",
"if",
"z",
"is",
"None",
":",
"return",
"log",
"(",
"sys",
".",
"float_info",
".",
"min",
")",
"return",
"logpdf",
"(",
"z",
",",
"dot",
"(",
"self",
".",
"H",
",",
"self",
".",
"x",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | MerweScaledSigmaPoints.sigma_points | Computes the sigma points for an unscented Kalman filter
given the mean (x) and covariance(P) of the filter.
Returns tuple of the sigma points and weights.
Works with both scalar and array inputs:
sigma_points (5, 9, 2) # mean 5, covariance 9
sigma_points ([5, 2], 9*eye(2), 2) #... | filterpy/kalman/sigma_points.py | def sigma_points(self, x, P):
""" Computes the sigma points for an unscented Kalman filter
given the mean (x) and covariance(P) of the filter.
Returns tuple of the sigma points and weights.
Works with both scalar and array inputs:
sigma_points (5, 9, 2) # mean 5, covariance 9
... | def sigma_points(self, x, P):
""" Computes the sigma points for an unscented Kalman filter
given the mean (x) and covariance(P) of the filter.
Returns tuple of the sigma points and weights.
Works with both scalar and array inputs:
sigma_points (5, 9, 2) # mean 5, covariance 9
... | [
"Computes",
"the",
"sigma",
"points",
"for",
"an",
"unscented",
"Kalman",
"filter",
"given",
"the",
"mean",
"(",
"x",
")",
"and",
"covariance",
"(",
"P",
")",
"of",
"the",
"filter",
".",
"Returns",
"tuple",
"of",
"the",
"sigma",
"points",
"and",
"weights... | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/sigma_points.py#L124-L177 | [
"def",
"sigma_points",
"(",
"self",
",",
"x",
",",
"P",
")",
":",
"if",
"self",
".",
"n",
"!=",
"np",
".",
"size",
"(",
"x",
")",
":",
"raise",
"ValueError",
"(",
"\"expected size(x) {}, but size is {}\"",
".",
"format",
"(",
"self",
".",
"n",
",",
"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | MerweScaledSigmaPoints._compute_weights | Computes the weights for the scaled unscented Kalman filter. | filterpy/kalman/sigma_points.py | def _compute_weights(self):
""" Computes the weights for the scaled unscented Kalman filter.
"""
n = self.n
lambda_ = self.alpha**2 * (n +self.kappa) - n
c = .5 / (n + lambda_)
self.Wc = np.full(2*n + 1, c)
self.Wm = np.full(2*n + 1, c)
self.Wc[0] = lam... | def _compute_weights(self):
""" Computes the weights for the scaled unscented Kalman filter.
"""
n = self.n
lambda_ = self.alpha**2 * (n +self.kappa) - n
c = .5 / (n + lambda_)
self.Wc = np.full(2*n + 1, c)
self.Wm = np.full(2*n + 1, c)
self.Wc[0] = lam... | [
"Computes",
"the",
"weights",
"for",
"the",
"scaled",
"unscented",
"Kalman",
"filter",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/sigma_points.py#L180-L192 | [
"def",
"_compute_weights",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"n",
"lambda_",
"=",
"self",
".",
"alpha",
"**",
"2",
"*",
"(",
"n",
"+",
"self",
".",
"kappa",
")",
"-",
"n",
"c",
"=",
".5",
"/",
"(",
"n",
"+",
"lambda_",
")",
"self"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | JulierSigmaPoints._compute_weights | Computes the weights for the unscented Kalman filter. In this
formulation the weights for the mean and covariance are the same. | filterpy/kalman/sigma_points.py | def _compute_weights(self):
""" Computes the weights for the unscented Kalman filter. In this
formulation the weights for the mean and covariance are the same.
"""
n = self.n
k = self.kappa
self.Wm = np.full(2*n+1, .5 / (n + k))
self.Wm[0] = k / (n+k)
se... | def _compute_weights(self):
""" Computes the weights for the unscented Kalman filter. In this
formulation the weights for the mean and covariance are the same.
"""
n = self.n
k = self.kappa
self.Wm = np.full(2*n+1, .5 / (n + k))
self.Wm[0] = k / (n+k)
se... | [
"Computes",
"the",
"weights",
"for",
"the",
"unscented",
"Kalman",
"filter",
".",
"In",
"this",
"formulation",
"the",
"weights",
"for",
"the",
"mean",
"and",
"covariance",
"are",
"the",
"same",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/sigma_points.py#L360-L370 | [
"def",
"_compute_weights",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"n",
"k",
"=",
"self",
".",
"kappa",
"self",
".",
"Wm",
"=",
"np",
".",
"full",
"(",
"2",
"*",
"n",
"+",
"1",
",",
".5",
"/",
"(",
"n",
"+",
"k",
")",
")",
"self",
"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | SimplexSigmaPoints.sigma_points | Computes the implex sigma points for an unscented Kalman filter
given the mean (x) and covariance(P) of the filter.
Returns tuple of the sigma points and weights.
Works with both scalar and array inputs:
sigma_points (5, 9, 2) # mean 5, covariance 9
sigma_points ([5, 2], 9*eye(2... | filterpy/kalman/sigma_points.py | def sigma_points(self, x, P):
"""
Computes the implex sigma points for an unscented Kalman filter
given the mean (x) and covariance(P) of the filter.
Returns tuple of the sigma points and weights.
Works with both scalar and array inputs:
sigma_points (5, 9, 2) # mean 5, ... | def sigma_points(self, x, P):
"""
Computes the implex sigma points for an unscented Kalman filter
given the mean (x) and covariance(P) of the filter.
Returns tuple of the sigma points and weights.
Works with both scalar and array inputs:
sigma_points (5, 9, 2) # mean 5, ... | [
"Computes",
"the",
"implex",
"sigma",
"points",
"for",
"an",
"unscented",
"Kalman",
"filter",
"given",
"the",
"mean",
"(",
"x",
")",
"and",
"covariance",
"(",
"P",
")",
"of",
"the",
"filter",
".",
"Returns",
"tuple",
"of",
"the",
"sigma",
"points",
"and"... | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/sigma_points.py#L454-L512 | [
"def",
"sigma_points",
"(",
"self",
",",
"x",
",",
"P",
")",
":",
"if",
"self",
".",
"n",
"!=",
"np",
".",
"size",
"(",
"x",
")",
":",
"raise",
"ValueError",
"(",
"\"expected size(x) {}, but size is {}\"",
".",
"format",
"(",
"self",
".",
"n",
",",
"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | SimplexSigmaPoints._compute_weights | Computes the weights for the scaled unscented Kalman filter. | filterpy/kalman/sigma_points.py | def _compute_weights(self):
""" Computes the weights for the scaled unscented Kalman filter. """
n = self.n
c = 1. / (n + 1)
self.Wm = np.full(n + 1, c)
self.Wc = self.Wm | def _compute_weights(self):
""" Computes the weights for the scaled unscented Kalman filter. """
n = self.n
c = 1. / (n + 1)
self.Wm = np.full(n + 1, c)
self.Wc = self.Wm | [
"Computes",
"the",
"weights",
"for",
"the",
"scaled",
"unscented",
"Kalman",
"filter",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/sigma_points.py#L515-L521 | [
"def",
"_compute_weights",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"n",
"c",
"=",
"1.",
"/",
"(",
"n",
"+",
"1",
")",
"self",
".",
"Wm",
"=",
"np",
".",
"full",
"(",
"n",
"+",
"1",
",",
"c",
")",
"self",
".",
"Wc",
"=",
"self",
".",... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | unscented_transform | r"""
Computes unscented transform of a set of sigma points and weights.
returns the mean and covariance in a tuple.
This works in conjunction with the UnscentedKalmanFilter class.
Parameters
----------
sigmas: ndarray, of size (n, 2n+1)
2D array of sigma points.
Wm : ndarray [# ... | filterpy/kalman/unscented_transform.py | def unscented_transform(sigmas, Wm, Wc, noise_cov=None,
mean_fn=None, residual_fn=None):
r"""
Computes unscented transform of a set of sigma points and weights.
returns the mean and covariance in a tuple.
This works in conjunction with the UnscentedKalmanFilter class.
Para... | def unscented_transform(sigmas, Wm, Wc, noise_cov=None,
mean_fn=None, residual_fn=None):
r"""
Computes unscented transform of a set of sigma points and weights.
returns the mean and covariance in a tuple.
This works in conjunction with the UnscentedKalmanFilter class.
Para... | [
"r",
"Computes",
"unscented",
"transform",
"of",
"a",
"set",
"of",
"sigma",
"points",
"and",
"weights",
".",
"returns",
"the",
"mean",
"and",
"covariance",
"in",
"a",
"tuple",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/unscented_transform.py#L22-L128 | [
"def",
"unscented_transform",
"(",
"sigmas",
",",
"Wm",
",",
"Wc",
",",
"noise_cov",
"=",
"None",
",",
"mean_fn",
"=",
"None",
",",
"residual_fn",
"=",
"None",
")",
":",
"kmax",
",",
"n",
"=",
"sigmas",
".",
"shape",
"try",
":",
"if",
"mean_fn",
"is"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | mahalanobis | Computes the Mahalanobis distance between the state vector x from the
Gaussian `mean` with covariance `cov`. This can be thought as the number
of standard deviations x is from the mean, i.e. a return value of 3 means
x is 3 std from mean.
Parameters
----------
x : (N,) array_like, or float
... | filterpy/stats/stats.py | def mahalanobis(x, mean, cov):
"""
Computes the Mahalanobis distance between the state vector x from the
Gaussian `mean` with covariance `cov`. This can be thought as the number
of standard deviations x is from the mean, i.e. a return value of 3 means
x is 3 std from mean.
Parameters
------... | def mahalanobis(x, mean, cov):
"""
Computes the Mahalanobis distance between the state vector x from the
Gaussian `mean` with covariance `cov`. This can be thought as the number
of standard deviations x is from the mean, i.e. a return value of 3 means
x is 3 std from mean.
Parameters
------... | [
"Computes",
"the",
"Mahalanobis",
"distance",
"between",
"the",
"state",
"vector",
"x",
"from",
"the",
"Gaussian",
"mean",
"with",
"covariance",
"cov",
".",
"This",
"can",
"be",
"thought",
"as",
"the",
"number",
"of",
"standard",
"deviations",
"x",
"is",
"fr... | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L63-L108 | [
"def",
"mahalanobis",
"(",
"x",
",",
"mean",
",",
"cov",
")",
":",
"x",
"=",
"_validate_vector",
"(",
"x",
")",
"mean",
"=",
"_validate_vector",
"(",
"mean",
")",
"if",
"x",
".",
"shape",
"!=",
"mean",
".",
"shape",
":",
"raise",
"ValueError",
"(",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | log_likelihood | Returns log-likelihood of the measurement z given the Gaussian
posterior (x, P) using measurement function H and measurement
covariance error R | filterpy/stats/stats.py | def log_likelihood(z, x, P, H, R):
"""
Returns log-likelihood of the measurement z given the Gaussian
posterior (x, P) using measurement function H and measurement
covariance error R
"""
S = np.dot(H, np.dot(P, H.T)) + R
return logpdf(z, np.dot(H, x), S) | def log_likelihood(z, x, P, H, R):
"""
Returns log-likelihood of the measurement z given the Gaussian
posterior (x, P) using measurement function H and measurement
covariance error R
"""
S = np.dot(H, np.dot(P, H.T)) + R
return logpdf(z, np.dot(H, x), S) | [
"Returns",
"log",
"-",
"likelihood",
"of",
"the",
"measurement",
"z",
"given",
"the",
"Gaussian",
"posterior",
"(",
"x",
"P",
")",
"using",
"measurement",
"function",
"H",
"and",
"measurement",
"covariance",
"error",
"R"
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L111-L118 | [
"def",
"log_likelihood",
"(",
"z",
",",
"x",
",",
"P",
",",
"H",
",",
"R",
")",
":",
"S",
"=",
"np",
".",
"dot",
"(",
"H",
",",
"np",
".",
"dot",
"(",
"P",
",",
"H",
".",
"T",
")",
")",
"+",
"R",
"return",
"logpdf",
"(",
"z",
",",
"np",... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | likelihood | Returns likelihood of the measurement z given the Gaussian
posterior (x, P) using measurement function H and measurement
covariance error R | filterpy/stats/stats.py | def likelihood(z, x, P, H, R):
"""
Returns likelihood of the measurement z given the Gaussian
posterior (x, P) using measurement function H and measurement
covariance error R
"""
return np.exp(log_likelihood(z, x, P, H, R)) | def likelihood(z, x, P, H, R):
"""
Returns likelihood of the measurement z given the Gaussian
posterior (x, P) using measurement function H and measurement
covariance error R
"""
return np.exp(log_likelihood(z, x, P, H, R)) | [
"Returns",
"likelihood",
"of",
"the",
"measurement",
"z",
"given",
"the",
"Gaussian",
"posterior",
"(",
"x",
"P",
")",
"using",
"measurement",
"function",
"H",
"and",
"measurement",
"covariance",
"error",
"R"
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L121-L127 | [
"def",
"likelihood",
"(",
"z",
",",
"x",
",",
"P",
",",
"H",
",",
"R",
")",
":",
"return",
"np",
".",
"exp",
"(",
"log_likelihood",
"(",
"z",
",",
"x",
",",
"P",
",",
"H",
",",
"R",
")",
")"
] | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | logpdf | Computes the log of the probability density function of the normal
N(mean, cov) for the data x. The normal may be univariate or multivariate.
Wrapper for older versions of scipy.multivariate_normal.logpdf which
don't support support the allow_singular keyword prior to verion 0.15.0.
If it is not suppo... | filterpy/stats/stats.py | def logpdf(x, mean=None, cov=1, allow_singular=True):
"""
Computes the log of the probability density function of the normal
N(mean, cov) for the data x. The normal may be univariate or multivariate.
Wrapper for older versions of scipy.multivariate_normal.logpdf which
don't support support the allo... | def logpdf(x, mean=None, cov=1, allow_singular=True):
"""
Computes the log of the probability density function of the normal
N(mean, cov) for the data x. The normal may be univariate or multivariate.
Wrapper for older versions of scipy.multivariate_normal.logpdf which
don't support support the allo... | [
"Computes",
"the",
"log",
"of",
"the",
"probability",
"density",
"function",
"of",
"the",
"normal",
"N",
"(",
"mean",
"cov",
")",
"for",
"the",
"data",
"x",
".",
"The",
"normal",
"may",
"be",
"univariate",
"or",
"multivariate",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L130-L153 | [
"def",
"logpdf",
"(",
"x",
",",
"mean",
"=",
"None",
",",
"cov",
"=",
"1",
",",
"allow_singular",
"=",
"True",
")",
":",
"if",
"mean",
"is",
"not",
"None",
":",
"flat_mean",
"=",
"np",
".",
"asarray",
"(",
"mean",
")",
".",
"flatten",
"(",
")",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | gaussian | returns normal distribution (pdf) for x given a Gaussian with the
specified mean and variance. All must be scalars.
gaussian (1,2,3) is equivalent to scipy.stats.norm(2,math.sqrt(3)).pdf(1)
It is quite a bit faster albeit much less flexible than the latter.
Parameters
----------
x : scalar or... | filterpy/stats/stats.py | def gaussian(x, mean, var, normed=True):
"""
returns normal distribution (pdf) for x given a Gaussian with the
specified mean and variance. All must be scalars.
gaussian (1,2,3) is equivalent to scipy.stats.norm(2,math.sqrt(3)).pdf(1)
It is quite a bit faster albeit much less flexible than the latt... | def gaussian(x, mean, var, normed=True):
"""
returns normal distribution (pdf) for x given a Gaussian with the
specified mean and variance. All must be scalars.
gaussian (1,2,3) is equivalent to scipy.stats.norm(2,math.sqrt(3)).pdf(1)
It is quite a bit faster albeit much less flexible than the latt... | [
"returns",
"normal",
"distribution",
"(",
"pdf",
")",
"for",
"x",
"given",
"a",
"Gaussian",
"with",
"the",
"specified",
"mean",
"and",
"variance",
".",
"All",
"must",
"be",
"scalars",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L156-L200 | [
"def",
"gaussian",
"(",
"x",
",",
"mean",
",",
"var",
",",
"normed",
"=",
"True",
")",
":",
"g",
"=",
"(",
"(",
"2",
"*",
"math",
".",
"pi",
"*",
"var",
")",
"**",
"-",
".5",
")",
"*",
"np",
".",
"exp",
"(",
"(",
"-",
"0.5",
"*",
"(",
"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | mul | Multiply Gaussian (mean1, var1) with (mean2, var2) and return the
results as a tuple (mean, var).
Strictly speaking the product of two Gaussian PDFs is a Gaussian
function, not Gaussian PDF. It is, however, proportional to a Gaussian
PDF, so it is safe to treat the output as a PDF for any filter using
... | filterpy/stats/stats.py | def mul(mean1, var1, mean2, var2):
"""
Multiply Gaussian (mean1, var1) with (mean2, var2) and return the
results as a tuple (mean, var).
Strictly speaking the product of two Gaussian PDFs is a Gaussian
function, not Gaussian PDF. It is, however, proportional to a Gaussian
PDF, so it is safe to ... | def mul(mean1, var1, mean2, var2):
"""
Multiply Gaussian (mean1, var1) with (mean2, var2) and return the
results as a tuple (mean, var).
Strictly speaking the product of two Gaussian PDFs is a Gaussian
function, not Gaussian PDF. It is, however, proportional to a Gaussian
PDF, so it is safe to ... | [
"Multiply",
"Gaussian",
"(",
"mean1",
"var1",
")",
"with",
"(",
"mean2",
"var2",
")",
"and",
"return",
"the",
"results",
"as",
"a",
"tuple",
"(",
"mean",
"var",
")",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L204-L250 | [
"def",
"mul",
"(",
"mean1",
",",
"var1",
",",
"mean2",
",",
"var2",
")",
":",
"mean",
"=",
"(",
"var1",
"*",
"mean2",
"+",
"var2",
"*",
"mean1",
")",
"/",
"(",
"var1",
"+",
"var2",
")",
"var",
"=",
"1",
"/",
"(",
"1",
"/",
"var1",
"+",
"1",... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | mul_pdf | Multiply Gaussian (mean1, var1) with (mean2, var2) and return the
results as a tuple (mean, var, scale_factor).
Strictly speaking the product of two Gaussian PDFs is a Gaussian
function, not Gaussian PDF. It is, however, proportional to a Gaussian
PDF. `scale_factor` provides this proportionality const... | filterpy/stats/stats.py | def mul_pdf(mean1, var1, mean2, var2):
"""
Multiply Gaussian (mean1, var1) with (mean2, var2) and return the
results as a tuple (mean, var, scale_factor).
Strictly speaking the product of two Gaussian PDFs is a Gaussian
function, not Gaussian PDF. It is, however, proportional to a Gaussian
PDF.... | def mul_pdf(mean1, var1, mean2, var2):
"""
Multiply Gaussian (mean1, var1) with (mean2, var2) and return the
results as a tuple (mean, var, scale_factor).
Strictly speaking the product of two Gaussian PDFs is a Gaussian
function, not Gaussian PDF. It is, however, proportional to a Gaussian
PDF.... | [
"Multiply",
"Gaussian",
"(",
"mean1",
"var1",
")",
"with",
"(",
"mean2",
"var2",
")",
"and",
"return",
"the",
"results",
"as",
"a",
"tuple",
"(",
"mean",
"var",
"scale_factor",
")",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L253-L306 | [
"def",
"mul_pdf",
"(",
"mean1",
",",
"var1",
",",
"mean2",
",",
"var2",
")",
":",
"mean",
"=",
"(",
"var1",
"*",
"mean2",
"+",
"var2",
"*",
"mean1",
")",
"/",
"(",
"var1",
"+",
"var2",
")",
"var",
"=",
"1.",
"/",
"(",
"1.",
"/",
"var1",
"+",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | multivariate_gaussian | This is designed to replace scipy.stats.multivariate_normal
which is not available before version 0.14. You may either pass in a
multivariate set of data:
.. code-block:: Python
multivariate_gaussian (array([1,1]), array([3,4]), eye(2)*1.4)
multivariate_gaussian (array([1,1,1]), array([3,4,5... | filterpy/stats/stats.py | def multivariate_gaussian(x, mu, cov):
"""
This is designed to replace scipy.stats.multivariate_normal
which is not available before version 0.14. You may either pass in a
multivariate set of data:
.. code-block:: Python
multivariate_gaussian (array([1,1]), array([3,4]), eye(2)*1.4)
... | def multivariate_gaussian(x, mu, cov):
"""
This is designed to replace scipy.stats.multivariate_normal
which is not available before version 0.14. You may either pass in a
multivariate set of data:
.. code-block:: Python
multivariate_gaussian (array([1,1]), array([3,4]), eye(2)*1.4)
... | [
"This",
"is",
"designed",
"to",
"replace",
"scipy",
".",
"stats",
".",
"multivariate_normal",
"which",
"is",
"not",
"available",
"before",
"version",
"0",
".",
"14",
".",
"You",
"may",
"either",
"pass",
"in",
"a",
"multivariate",
"set",
"of",
"data",
":"
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L320-L396 | [
"def",
"multivariate_gaussian",
"(",
"x",
",",
"mu",
",",
"cov",
")",
":",
"warnings",
".",
"warn",
"(",
"(",
"\"This was implemented before SciPy version 0.14, which implemented \"",
"\"scipy.stats.multivariate_normal. This function will be removed in \"",
"\"a future release of F... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | multivariate_multiply | Multiplies the two multivariate Gaussians together and returns the
results as the tuple (mean, covariance).
Examples
--------
.. code-block:: Python
m, c = multivariate_multiply([7.0, 2], [[1.0, 2.0], [2.0, 1.0]],
[3.2, 0], [[8.0, 1.1], [1.1,8.0]])
Pa... | filterpy/stats/stats.py | def multivariate_multiply(m1, c1, m2, c2):
"""
Multiplies the two multivariate Gaussians together and returns the
results as the tuple (mean, covariance).
Examples
--------
.. code-block:: Python
m, c = multivariate_multiply([7.0, 2], [[1.0, 2.0], [2.0, 1.0]],
... | def multivariate_multiply(m1, c1, m2, c2):
"""
Multiplies the two multivariate Gaussians together and returns the
results as the tuple (mean, covariance).
Examples
--------
.. code-block:: Python
m, c = multivariate_multiply([7.0, 2], [[1.0, 2.0], [2.0, 1.0]],
... | [
"Multiplies",
"the",
"two",
"multivariate",
"Gaussians",
"together",
"and",
"returns",
"the",
"results",
"as",
"the",
"tuple",
"(",
"mean",
"covariance",
")",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L399-L454 | [
"def",
"multivariate_multiply",
"(",
"m1",
",",
"c1",
",",
"m2",
",",
"c2",
")",
":",
"C1",
"=",
"np",
".",
"asarray",
"(",
"c1",
")",
"C2",
"=",
"np",
".",
"asarray",
"(",
"c2",
")",
"M1",
"=",
"np",
".",
"asarray",
"(",
"m1",
")",
"M2",
"="... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | plot_discrete_cdf | Plots a normal distribution CDF with the given mean and variance.
x-axis contains the mean, the y-axis shows the cumulative probability.
Parameters
----------
xs : list-like of scalars
x values corresponding to the values in `y`s. Can be `None`, in which
case range(len(ys)) will be use... | filterpy/stats/stats.py | def plot_discrete_cdf(xs, ys, ax=None, xlabel=None, ylabel=None,
label=None):
"""
Plots a normal distribution CDF with the given mean and variance.
x-axis contains the mean, the y-axis shows the cumulative probability.
Parameters
----------
xs : list-like of scalars
... | def plot_discrete_cdf(xs, ys, ax=None, xlabel=None, ylabel=None,
label=None):
"""
Plots a normal distribution CDF with the given mean and variance.
x-axis contains the mean, the y-axis shows the cumulative probability.
Parameters
----------
xs : list-like of scalars
... | [
"Plots",
"a",
"normal",
"distribution",
"CDF",
"with",
"the",
"given",
"mean",
"and",
"variance",
".",
"x",
"-",
"axis",
"contains",
"the",
"mean",
"the",
"y",
"-",
"axis",
"shows",
"the",
"cumulative",
"probability",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L457-L504 | [
"def",
"plot_discrete_cdf",
"(",
"xs",
",",
"ys",
",",
"ax",
"=",
"None",
",",
"xlabel",
"=",
"None",
",",
"ylabel",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"if",
"ax",
"is",
"None",
":"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | plot_gaussian_cdf | Plots a normal distribution CDF with the given mean and variance.
x-axis contains the mean, the y-axis shows the cumulative probability.
Parameters
----------
mean : scalar, default 0.
mean for the normal distribution.
variance : scalar, default 0.
variance for the normal distribu... | filterpy/stats/stats.py | def plot_gaussian_cdf(mean=0., variance=1.,
ax=None,
xlim=None, ylim=(0., 1.),
xlabel=None, ylabel=None,
label=None):
"""
Plots a normal distribution CDF with the given mean and variance.
x-axis contains the mean, the y-... | def plot_gaussian_cdf(mean=0., variance=1.,
ax=None,
xlim=None, ylim=(0., 1.),
xlabel=None, ylabel=None,
label=None):
"""
Plots a normal distribution CDF with the given mean and variance.
x-axis contains the mean, the y-... | [
"Plots",
"a",
"normal",
"distribution",
"CDF",
"with",
"the",
"given",
"mean",
"and",
"variance",
".",
"x",
"-",
"axis",
"contains",
"the",
"mean",
"the",
"y",
"-",
"axis",
"shows",
"the",
"cumulative",
"probability",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L507-L562 | [
"def",
"plot_gaussian_cdf",
"(",
"mean",
"=",
"0.",
",",
"variance",
"=",
"1.",
",",
"ax",
"=",
"None",
",",
"xlim",
"=",
"None",
",",
"ylim",
"=",
"(",
"0.",
",",
"1.",
")",
",",
"xlabel",
"=",
"None",
",",
"ylabel",
"=",
"None",
",",
"label",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | plot_gaussian_pdf | Plots a normal distribution PDF with the given mean and variance.
x-axis contains the mean, the y-axis shows the probability density.
Parameters
----------
mean : scalar, default 0.
mean for the normal distribution.
variance : scalar, default 1., optional
variance for the normal d... | filterpy/stats/stats.py | def plot_gaussian_pdf(mean=0.,
variance=1.,
std=None,
ax=None,
mean_line=False,
xlim=None, ylim=None,
xlabel=None, ylabel=None,
label=None):
"""
Plots a norma... | def plot_gaussian_pdf(mean=0.,
variance=1.,
std=None,
ax=None,
mean_line=False,
xlim=None, ylim=None,
xlabel=None, ylabel=None,
label=None):
"""
Plots a norma... | [
"Plots",
"a",
"normal",
"distribution",
"PDF",
"with",
"the",
"given",
"mean",
"and",
"variance",
".",
"x",
"-",
"axis",
"contains",
"the",
"mean",
"the",
"y",
"-",
"axis",
"shows",
"the",
"probability",
"density",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L565-L647 | [
"def",
"plot_gaussian_pdf",
"(",
"mean",
"=",
"0.",
",",
"variance",
"=",
"1.",
",",
"std",
"=",
"None",
",",
"ax",
"=",
"None",
",",
"mean_line",
"=",
"False",
",",
"xlim",
"=",
"None",
",",
"ylim",
"=",
"None",
",",
"xlabel",
"=",
"None",
",",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | plot_gaussian | DEPRECATED. Use plot_gaussian_pdf() instead. This is poorly named, as
there are multiple ways to plot a Gaussian. | filterpy/stats/stats.py | def plot_gaussian(mean=0., variance=1.,
ax=None,
mean_line=False,
xlim=None,
ylim=None,
xlabel=None,
ylabel=None,
label=None):
"""
DEPRECATED. Use plot_gaussian_pdf() instead. This is po... | def plot_gaussian(mean=0., variance=1.,
ax=None,
mean_line=False,
xlim=None,
ylim=None,
xlabel=None,
ylabel=None,
label=None):
"""
DEPRECATED. Use plot_gaussian_pdf() instead. This is po... | [
"DEPRECATED",
".",
"Use",
"plot_gaussian_pdf",
"()",
"instead",
".",
"This",
"is",
"poorly",
"named",
"as",
"there",
"are",
"multiple",
"ways",
"to",
"plot",
"a",
"Gaussian",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L650-L668 | [
"def",
"plot_gaussian",
"(",
"mean",
"=",
"0.",
",",
"variance",
"=",
"1.",
",",
"ax",
"=",
"None",
",",
"mean_line",
"=",
"False",
",",
"xlim",
"=",
"None",
",",
"ylim",
"=",
"None",
",",
"xlabel",
"=",
"None",
",",
"ylabel",
"=",
"None",
",",
"... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | covariance_ellipse | Returns a tuple defining the ellipse representing the 2 dimensional
covariance matrix P.
Parameters
----------
P : nd.array shape (2,2)
covariance matrix
deviations : int (optional, default = 1)
# of standard deviations. Default is 1.
Returns (angle_radians, width_radius, heigh... | filterpy/stats/stats.py | def covariance_ellipse(P, deviations=1):
"""
Returns a tuple defining the ellipse representing the 2 dimensional
covariance matrix P.
Parameters
----------
P : nd.array shape (2,2)
covariance matrix
deviations : int (optional, default = 1)
# of standard deviations. Default i... | def covariance_ellipse(P, deviations=1):
"""
Returns a tuple defining the ellipse representing the 2 dimensional
covariance matrix P.
Parameters
----------
P : nd.array shape (2,2)
covariance matrix
deviations : int (optional, default = 1)
# of standard deviations. Default i... | [
"Returns",
"a",
"tuple",
"defining",
"the",
"ellipse",
"representing",
"the",
"2",
"dimensional",
"covariance",
"matrix",
"P",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L671-L696 | [
"def",
"covariance_ellipse",
"(",
"P",
",",
"deviations",
"=",
"1",
")",
":",
"U",
",",
"s",
",",
"_",
"=",
"linalg",
".",
"svd",
"(",
"P",
")",
"orientation",
"=",
"math",
".",
"atan2",
"(",
"U",
"[",
"1",
",",
"0",
"]",
",",
"U",
"[",
"0",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | _eigsorted | Computes eigenvalues and eigenvectors of a covariance matrix and returns
them sorted by eigenvalue.
Parameters
----------
cov : ndarray
covariance matrix
asc : bool, default=True
determines whether we are sorted smallest to largest (asc=True),
or largest to smallest (asc=Fa... | filterpy/stats/stats.py | def _eigsorted(cov, asc=True):
"""
Computes eigenvalues and eigenvectors of a covariance matrix and returns
them sorted by eigenvalue.
Parameters
----------
cov : ndarray
covariance matrix
asc : bool, default=True
determines whether we are sorted smallest to largest (asc=Tr... | def _eigsorted(cov, asc=True):
"""
Computes eigenvalues and eigenvectors of a covariance matrix and returns
them sorted by eigenvalue.
Parameters
----------
cov : ndarray
covariance matrix
asc : bool, default=True
determines whether we are sorted smallest to largest (asc=Tr... | [
"Computes",
"eigenvalues",
"and",
"eigenvectors",
"of",
"a",
"covariance",
"matrix",
"and",
"returns",
"them",
"sorted",
"by",
"eigenvalue",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L699-L729 | [
"def",
"_eigsorted",
"(",
"cov",
",",
"asc",
"=",
"True",
")",
":",
"eigval",
",",
"eigvec",
"=",
"np",
".",
"linalg",
".",
"eigh",
"(",
"cov",
")",
"order",
"=",
"eigval",
".",
"argsort",
"(",
")",
"if",
"not",
"asc",
":",
"# sort largest to smalles... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | plot_3d_covariance | Plots a covariance matrix `cov` as a 3D ellipsoid centered around
the `mean`.
Parameters
----------
mean : 3-vector
mean in x, y, z. Can be any type convertable to a row vector.
cov : ndarray 3x3
covariance matrix
std : double, default=1
standard deviation of ellipsoi... | filterpy/stats/stats.py | def plot_3d_covariance(mean, cov, std=1.,
ax=None, title=None,
color=None, alpha=1.,
label_xyz=True,
N=60,
shade=True,
limit_xyz=True,
**kwargs):
"""
P... | def plot_3d_covariance(mean, cov, std=1.,
ax=None, title=None,
color=None, alpha=1.,
label_xyz=True,
N=60,
shade=True,
limit_xyz=True,
**kwargs):
"""
P... | [
"Plots",
"a",
"covariance",
"matrix",
"cov",
"as",
"a",
"3D",
"ellipsoid",
"centered",
"around",
"the",
"mean",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L732-L862 | [
"def",
"plot_3d_covariance",
"(",
"mean",
",",
"cov",
",",
"std",
"=",
"1.",
",",
"ax",
"=",
"None",
",",
"title",
"=",
"None",
",",
"color",
"=",
"None",
",",
"alpha",
"=",
"1.",
",",
"label_xyz",
"=",
"True",
",",
"N",
"=",
"60",
",",
"shade",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | plot_covariance_ellipse | Deprecated function to plot a covariance ellipse. Use plot_covariance
instead.
See Also
--------
plot_covariance | filterpy/stats/stats.py | def plot_covariance_ellipse(
mean, cov=None, variance=1.0, std=None,
ellipse=None, title=None, axis_equal=True, show_semiaxis=False,
facecolor=None, edgecolor=None,
fc='none', ec='#004080',
alpha=1.0, xlim=None, ylim=None,
ls='solid'):
"""
Deprecated function to p... | def plot_covariance_ellipse(
mean, cov=None, variance=1.0, std=None,
ellipse=None, title=None, axis_equal=True, show_semiaxis=False,
facecolor=None, edgecolor=None,
fc='none', ec='#004080',
alpha=1.0, xlim=None, ylim=None,
ls='solid'):
"""
Deprecated function to p... | [
"Deprecated",
"function",
"to",
"plot",
"a",
"covariance",
"ellipse",
".",
"Use",
"plot_covariance",
"instead",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L865-L887 | [
"def",
"plot_covariance_ellipse",
"(",
"mean",
",",
"cov",
"=",
"None",
",",
"variance",
"=",
"1.0",
",",
"std",
"=",
"None",
",",
"ellipse",
"=",
"None",
",",
"title",
"=",
"None",
",",
"axis_equal",
"=",
"True",
",",
"show_semiaxis",
"=",
"False",
",... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | _std_tuple_of | Convienence function for plotting. Given one of var, standard
deviation, or interval, return the std. Any of the three can be an
iterable list.
Examples
--------
>>>_std_tuple_of(var=[1, 3, 9])
(1, 2, 3) | filterpy/stats/stats.py | def _std_tuple_of(var=None, std=None, interval=None):
"""
Convienence function for plotting. Given one of var, standard
deviation, or interval, return the std. Any of the three can be an
iterable list.
Examples
--------
>>>_std_tuple_of(var=[1, 3, 9])
(1, 2, 3)
"""
if std is n... | def _std_tuple_of(var=None, std=None, interval=None):
"""
Convienence function for plotting. Given one of var, standard
deviation, or interval, return the std. Any of the three can be an
iterable list.
Examples
--------
>>>_std_tuple_of(var=[1, 3, 9])
(1, 2, 3)
"""
if std is n... | [
"Convienence",
"function",
"for",
"plotting",
".",
"Given",
"one",
"of",
"var",
"standard",
"deviation",
"or",
"interval",
"return",
"the",
"std",
".",
"Any",
"of",
"the",
"three",
"can",
"be",
"an",
"iterable",
"list",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L890-L920 | [
"def",
"_std_tuple_of",
"(",
"var",
"=",
"None",
",",
"std",
"=",
"None",
",",
"interval",
"=",
"None",
")",
":",
"if",
"std",
"is",
"not",
"None",
":",
"if",
"np",
".",
"isscalar",
"(",
"std",
")",
":",
"std",
"=",
"(",
"std",
",",
")",
"retur... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | plot_covariance | Plots the covariance ellipse for the 2D normal defined by (mean, cov)
`variance` is the normal sigma^2 that we want to plot. If list-like,
ellipses for all ellipses will be ploted. E.g. [1,2] will plot the
sigma^2 = 1 and sigma^2 = 2 ellipses. Alternatively, use std for the
standard deviation, in which... | filterpy/stats/stats.py | def plot_covariance(
mean, cov=None, variance=1.0, std=None, interval=None,
ellipse=None, title=None, axis_equal=True,
show_semiaxis=False, show_center=True,
facecolor=None, edgecolor=None,
fc='none', ec='#004080',
alpha=1.0, xlim=None, ylim=None,
ls='solid'):
... | def plot_covariance(
mean, cov=None, variance=1.0, std=None, interval=None,
ellipse=None, title=None, axis_equal=True,
show_semiaxis=False, show_center=True,
facecolor=None, edgecolor=None,
fc='none', ec='#004080',
alpha=1.0, xlim=None, ylim=None,
ls='solid'):
... | [
"Plots",
"the",
"covariance",
"ellipse",
"for",
"the",
"2D",
"normal",
"defined",
"by",
"(",
"mean",
"cov",
")"
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L923-L1066 | [
"def",
"plot_covariance",
"(",
"mean",
",",
"cov",
"=",
"None",
",",
"variance",
"=",
"1.0",
",",
"std",
"=",
"None",
",",
"interval",
"=",
"None",
",",
"ellipse",
"=",
"None",
",",
"title",
"=",
"None",
",",
"axis_equal",
"=",
"True",
",",
"show_sem... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | norm_cdf | Computes the probability that a Gaussian distribution lies
within a range of values.
Parameters
----------
x_range : (float, float)
tuple of range to compute probability for
mu : float
mean of the Gaussian
var : float, optional
variance of the Gaussian. Ignored if `st... | filterpy/stats/stats.py | def norm_cdf(x_range, mu, var=1, std=None):
"""
Computes the probability that a Gaussian distribution lies
within a range of values.
Parameters
----------
x_range : (float, float)
tuple of range to compute probability for
mu : float
mean of the Gaussian
var : float, o... | def norm_cdf(x_range, mu, var=1, std=None):
"""
Computes the probability that a Gaussian distribution lies
within a range of values.
Parameters
----------
x_range : (float, float)
tuple of range to compute probability for
mu : float
mean of the Gaussian
var : float, o... | [
"Computes",
"the",
"probability",
"that",
"a",
"Gaussian",
"distribution",
"lies",
"within",
"a",
"range",
"of",
"values",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L1069-L1099 | [
"def",
"norm_cdf",
"(",
"x_range",
",",
"mu",
",",
"var",
"=",
"1",
",",
"std",
"=",
"None",
")",
":",
"if",
"std",
"is",
"None",
":",
"std",
"=",
"math",
".",
"sqrt",
"(",
"var",
")",
"return",
"abs",
"(",
"norm",
".",
"cdf",
"(",
"x_range",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | _to_cov | If x is a scalar, returns a covariance matrix generated from it
as the identity matrix multiplied by x. The dimension will be nxn.
If x is already a 2D numpy array then it is returned unchanged.
Raises ValueError if not positive definite | filterpy/stats/stats.py | def _to_cov(x, n):
"""
If x is a scalar, returns a covariance matrix generated from it
as the identity matrix multiplied by x. The dimension will be nxn.
If x is already a 2D numpy array then it is returned unchanged.
Raises ValueError if not positive definite
"""
if np.isscalar(x):
... | def _to_cov(x, n):
"""
If x is a scalar, returns a covariance matrix generated from it
as the identity matrix multiplied by x. The dimension will be nxn.
If x is already a 2D numpy array then it is returned unchanged.
Raises ValueError if not positive definite
"""
if np.isscalar(x):
... | [
"If",
"x",
"is",
"a",
"scalar",
"returns",
"a",
"covariance",
"matrix",
"generated",
"from",
"it",
"as",
"the",
"identity",
"matrix",
"multiplied",
"by",
"x",
".",
"The",
"dimension",
"will",
"be",
"nxn",
".",
"If",
"x",
"is",
"already",
"a",
"2D",
"nu... | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L1102-L1123 | [
"def",
"_to_cov",
"(",
"x",
",",
"n",
")",
":",
"if",
"np",
".",
"isscalar",
"(",
"x",
")",
":",
"if",
"x",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'covariance must be > 0'",
")",
"return",
"np",
".",
"eye",
"(",
"n",
")",
"*",
"x",
"x",
"=... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | rand_student_t | return random number distributed by student's t distribution with
`df` degrees of freedom with the specified mean and standard deviation. | filterpy/stats/stats.py | def rand_student_t(df, mu=0, std=1):
"""
return random number distributed by student's t distribution with
`df` degrees of freedom with the specified mean and standard deviation.
"""
x = random.gauss(0, std)
y = 2.0*random.gammavariate(0.5 * df, 2.0)
return x / (math.sqrt(y / df)) + mu | def rand_student_t(df, mu=0, std=1):
"""
return random number distributed by student's t distribution with
`df` degrees of freedom with the specified mean and standard deviation.
"""
x = random.gauss(0, std)
y = 2.0*random.gammavariate(0.5 * df, 2.0)
return x / (math.sqrt(y / df)) + mu | [
"return",
"random",
"number",
"distributed",
"by",
"student",
"s",
"t",
"distribution",
"with",
"df",
"degrees",
"of",
"freedom",
"with",
"the",
"specified",
"mean",
"and",
"standard",
"deviation",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L1126-L1134 | [
"def",
"rand_student_t",
"(",
"df",
",",
"mu",
"=",
"0",
",",
"std",
"=",
"1",
")",
":",
"x",
"=",
"random",
".",
"gauss",
"(",
"0",
",",
"std",
")",
"y",
"=",
"2.0",
"*",
"random",
".",
"gammavariate",
"(",
"0.5",
"*",
"df",
",",
"2.0",
")",... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | NESS | Computes the normalized estimated error squared test on a sequence
of estimates. The estimates are optimal if the mean error is zero and
the covariance matches the Kalman filter's covariance. If this holds,
then the mean of the NESS should be equal to or less than the dimension
of x.
Examples
-... | filterpy/stats/stats.py | def NESS(xs, est_xs, ps):
"""
Computes the normalized estimated error squared test on a sequence
of estimates. The estimates are optimal if the mean error is zero and
the covariance matches the Kalman filter's covariance. If this holds,
then the mean of the NESS should be equal to or less than the d... | def NESS(xs, est_xs, ps):
"""
Computes the normalized estimated error squared test on a sequence
of estimates. The estimates are optimal if the mean error is zero and
the covariance matches the Kalman filter's covariance. If this holds,
then the mean of the NESS should be equal to or less than the d... | [
"Computes",
"the",
"normalized",
"estimated",
"error",
"squared",
"test",
"on",
"a",
"sequence",
"of",
"estimates",
".",
"The",
"estimates",
"are",
"optimal",
"if",
"the",
"mean",
"error",
"is",
"zero",
"and",
"the",
"covariance",
"matches",
"the",
"Kalman",
... | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/stats/stats.py#L1137-L1178 | [
"def",
"NESS",
"(",
"xs",
",",
"est_xs",
",",
"ps",
")",
":",
"est_err",
"=",
"xs",
"-",
"est_xs",
"ness",
"=",
"[",
"]",
"for",
"x",
",",
"p",
"in",
"zip",
"(",
"est_err",
",",
"ps",
")",
":",
"ness",
".",
"append",
"(",
"np",
".",
"dot",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | spherical_radial_sigmas | r""" Creates cubature points for the the specified state and covariance
according to [1].
Parameters
----------
x: ndarray (column vector)
examples: np.array([[1.], [2.]])
P : scalar, or np.array
Covariance of the filter.
References
----------
.. [1] Arasaratnam, I, ... | filterpy/kalman/CubatureKalmanFilter.py | def spherical_radial_sigmas(x, P):
r""" Creates cubature points for the the specified state and covariance
according to [1].
Parameters
----------
x: ndarray (column vector)
examples: np.array([[1.], [2.]])
P : scalar, or np.array
Covariance of the filter.
References
... | def spherical_radial_sigmas(x, P):
r""" Creates cubature points for the the specified state and covariance
according to [1].
Parameters
----------
x: ndarray (column vector)
examples: np.array([[1.], [2.]])
P : scalar, or np.array
Covariance of the filter.
References
... | [
"r",
"Creates",
"cubature",
"points",
"for",
"the",
"the",
"specified",
"state",
"and",
"covariance",
"according",
"to",
"[",
"1",
"]",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/CubatureKalmanFilter.py#L32-L61 | [
"def",
"spherical_radial_sigmas",
"(",
"x",
",",
"P",
")",
":",
"n",
",",
"_",
"=",
"P",
".",
"shape",
"x",
"=",
"x",
".",
"flatten",
"(",
")",
"sigmas",
"=",
"np",
".",
"empty",
"(",
"(",
"2",
"*",
"n",
",",
"n",
")",
")",
"U",
"=",
"chole... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | ckf_transform | Compute mean and covariance of array of cubature points.
Parameters
----------
Xs : ndarray
Cubature points
Q : ndarray
Noise covariance
Returns
-------
mean : ndarray
mean of the cubature points
variance: ndarray
covariance matrix of the cubature ... | filterpy/kalman/CubatureKalmanFilter.py | def ckf_transform(Xs, Q):
"""
Compute mean and covariance of array of cubature points.
Parameters
----------
Xs : ndarray
Cubature points
Q : ndarray
Noise covariance
Returns
-------
mean : ndarray
mean of the cubature points
variance: ndarray
... | def ckf_transform(Xs, Q):
"""
Compute mean and covariance of array of cubature points.
Parameters
----------
Xs : ndarray
Cubature points
Q : ndarray
Noise covariance
Returns
-------
mean : ndarray
mean of the cubature points
variance: ndarray
... | [
"Compute",
"mean",
"and",
"covariance",
"of",
"array",
"of",
"cubature",
"points",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/CubatureKalmanFilter.py#L64-L98 | [
"def",
"ckf_transform",
"(",
"Xs",
",",
"Q",
")",
":",
"m",
",",
"n",
"=",
"Xs",
".",
"shape",
"x",
"=",
"sum",
"(",
"Xs",
",",
"0",
")",
"[",
":",
",",
"None",
"]",
"/",
"m",
"P",
"=",
"np",
".",
"zeros",
"(",
"(",
"n",
",",
"n",
")",
... | 8123214de798ffb63db968bb0b9492ee74e77950 |
train | CubatureKalmanFilter.predict | r""" Performs the predict step of the CKF. On return, self.x and
self.P contain the predicted state (x) and covariance (P).
Important: this MUST be called before update() is called for the first
time.
Parameters
----------
dt : double, optional
If specified... | filterpy/kalman/CubatureKalmanFilter.py | def predict(self, dt=None, fx_args=()):
r""" Performs the predict step of the CKF. On return, self.x and
self.P contain the predicted state (x) and covariance (P).
Important: this MUST be called before update() is called for the first
time.
Parameters
----------
... | def predict(self, dt=None, fx_args=()):
r""" Performs the predict step of the CKF. On return, self.x and
self.P contain the predicted state (x) and covariance (P).
Important: this MUST be called before update() is called for the first
time.
Parameters
----------
... | [
"r",
"Performs",
"the",
"predict",
"step",
"of",
"the",
"CKF",
".",
"On",
"return",
"self",
".",
"x",
"and",
"self",
".",
"P",
"contain",
"the",
"predicted",
"state",
"(",
"x",
")",
"and",
"covariance",
"(",
"P",
")",
"."
] | rlabbe/filterpy | python | https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/kalman/CubatureKalmanFilter.py#L292-L327 | [
"def",
"predict",
"(",
"self",
",",
"dt",
"=",
"None",
",",
"fx_args",
"=",
"(",
")",
")",
":",
"if",
"dt",
"is",
"None",
":",
"dt",
"=",
"self",
".",
"_dt",
"if",
"not",
"isinstance",
"(",
"fx_args",
",",
"tuple",
")",
":",
"fx_args",
"=",
"("... | 8123214de798ffb63db968bb0b9492ee74e77950 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.