repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
manns/pyspread | pyspread/src/gui/_dialogs.py | CsvParameterWidgets.OnDialectChoice | def OnDialectChoice(self, event):
"""Updates all param widgets confirming to the selcted dialect"""
dialect_name = event.GetString()
value = list(self.choices['dialects']).index(dialect_name)
if dialect_name == 'sniffer':
if self.csvfilepath is None:
event.S... | python | def OnDialectChoice(self, event):
"""Updates all param widgets confirming to the selcted dialect"""
dialect_name = event.GetString()
value = list(self.choices['dialects']).index(dialect_name)
if dialect_name == 'sniffer':
if self.csvfilepath is None:
event.S... | [
"def",
"OnDialectChoice",
"(",
"self",
",",
"event",
")",
":",
"dialect_name",
"=",
"event",
".",
"GetString",
"(",
")",
"value",
"=",
"list",
"(",
"self",
".",
"choices",
"[",
"'dialects'",
"]",
")",
".",
"index",
"(",
"dialect_name",
")",
"if",
"dial... | Updates all param widgets confirming to the selcted dialect | [
"Updates",
"all",
"param",
"widgets",
"confirming",
"to",
"the",
"selcted",
"dialect"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L386-L405 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | CsvParameterWidgets.OnWidget | def OnWidget(self, event):
"""Update the dialect widget to 'user'"""
self.choice_dialects.SetValue(len(self.choices['dialects']) - 1)
event.Skip() | python | def OnWidget(self, event):
"""Update the dialect widget to 'user'"""
self.choice_dialects.SetValue(len(self.choices['dialects']) - 1)
event.Skip() | [
"def",
"OnWidget",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"choice_dialects",
".",
"SetValue",
"(",
"len",
"(",
"self",
".",
"choices",
"[",
"'dialects'",
"]",
")",
"-",
"1",
")",
"event",
".",
"Skip",
"(",
")"
] | Update the dialect widget to 'user | [
"Update",
"the",
"dialect",
"widget",
"to",
"user"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L407-L411 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | CsvParameterWidgets.get_dialect | def get_dialect(self):
"""Returns a new dialect that implements the current selection"""
parameters = {}
for parameter in self.csv_params[2:]:
pname, ptype, plabel, phelp = parameter
widget = self._widget_from_p(pname, ptype)
if ptype is types.StringType o... | python | def get_dialect(self):
"""Returns a new dialect that implements the current selection"""
parameters = {}
for parameter in self.csv_params[2:]:
pname, ptype, plabel, phelp = parameter
widget = self._widget_from_p(pname, ptype)
if ptype is types.StringType o... | [
"def",
"get_dialect",
"(",
"self",
")",
":",
"parameters",
"=",
"{",
"}",
"for",
"parameter",
"in",
"self",
".",
"csv_params",
"[",
"2",
":",
"]",
":",
"pname",
",",
"ptype",
",",
"plabel",
",",
"phelp",
"=",
"parameter",
"widget",
"=",
"self",
".",
... | Returns a new dialect that implements the current selection | [
"Returns",
"a",
"new",
"dialect",
"that",
"implements",
"the",
"current",
"selection"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L413-L446 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | CSVPreviewGrid.OnMouse | def OnMouse(self, event):
"""Reduces clicks to enter an edit control"""
self.SetGridCursor(event.Row, event.Col)
self.EnableCellEditControl(True)
event.Skip() | python | def OnMouse(self, event):
"""Reduces clicks to enter an edit control"""
self.SetGridCursor(event.Row, event.Col)
self.EnableCellEditControl(True)
event.Skip() | [
"def",
"OnMouse",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"SetGridCursor",
"(",
"event",
".",
"Row",
",",
"event",
".",
"Col",
")",
"self",
".",
"EnableCellEditControl",
"(",
"True",
")",
"event",
".",
"Skip",
"(",
")"
] | Reduces clicks to enter an edit control | [
"Reduces",
"clicks",
"to",
"enter",
"an",
"edit",
"control"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L487-L492 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | CSVPreviewGrid.OnGridEditorCreated | def OnGridEditorCreated(self, event):
"""Used to capture Editor close events"""
editor = event.GetControl()
editor.Bind(wx.EVT_KILL_FOCUS, self.OnGridEditorClosed)
event.Skip() | python | def OnGridEditorCreated(self, event):
"""Used to capture Editor close events"""
editor = event.GetControl()
editor.Bind(wx.EVT_KILL_FOCUS, self.OnGridEditorClosed)
event.Skip() | [
"def",
"OnGridEditorCreated",
"(",
"self",
",",
"event",
")",
":",
"editor",
"=",
"event",
".",
"GetControl",
"(",
")",
"editor",
".",
"Bind",
"(",
"wx",
".",
"EVT_KILL_FOCUS",
",",
"self",
".",
"OnGridEditorClosed",
")",
"event",
".",
"Skip",
"(",
")"
] | Used to capture Editor close events | [
"Used",
"to",
"capture",
"Editor",
"close",
"events"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L499-L505 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | CSVPreviewGrid.OnGridEditorClosed | def OnGridEditorClosed(self, event):
"""Event handler for end of output type choice"""
try:
dialect, self.has_header = \
self.parent.csvwidgets.get_dialect()
except TypeError:
event.Skip()
return 0
self.fill_cells(dialect, self.has_he... | python | def OnGridEditorClosed(self, event):
"""Event handler for end of output type choice"""
try:
dialect, self.has_header = \
self.parent.csvwidgets.get_dialect()
except TypeError:
event.Skip()
return 0
self.fill_cells(dialect, self.has_he... | [
"def",
"OnGridEditorClosed",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"dialect",
",",
"self",
".",
"has_header",
"=",
"self",
".",
"parent",
".",
"csvwidgets",
".",
"get_dialect",
"(",
")",
"except",
"TypeError",
":",
"event",
".",
"Skip",
"(",
... | Event handler for end of output type choice | [
"Event",
"handler",
"for",
"end",
"of",
"output",
"type",
"choice"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L507-L517 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | CSVPreviewGrid.get_digest_keys | def get_digest_keys(self):
"""Returns a list of the type choices"""
digest_keys = []
for col in xrange(self.GetNumberCols()):
digest_key = self.GetCellValue(self.has_header, col)
if digest_key == "":
digest_key = self.digest_types.keys()[0]
di... | python | def get_digest_keys(self):
"""Returns a list of the type choices"""
digest_keys = []
for col in xrange(self.GetNumberCols()):
digest_key = self.GetCellValue(self.has_header, col)
if digest_key == "":
digest_key = self.digest_types.keys()[0]
di... | [
"def",
"get_digest_keys",
"(",
"self",
")",
":",
"digest_keys",
"=",
"[",
"]",
"for",
"col",
"in",
"xrange",
"(",
"self",
".",
"GetNumberCols",
"(",
")",
")",
":",
"digest_key",
"=",
"self",
".",
"GetCellValue",
"(",
"self",
".",
"has_header",
",",
"co... | Returns a list of the type choices | [
"Returns",
"a",
"list",
"of",
"the",
"type",
"choices"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L580-L590 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | CsvExportDialog.OnButtonApply | def OnButtonApply(self, event):
"""Updates the preview_textctrl"""
try:
dialect, self.has_header = self.csvwidgets.get_dialect()
except TypeError:
event.Skip()
return 0
self.preview_textctrl.fill(data=self.data, dialect=dialect)
event.Skip() | python | def OnButtonApply(self, event):
"""Updates the preview_textctrl"""
try:
dialect, self.has_header = self.csvwidgets.get_dialect()
except TypeError:
event.Skip()
return 0
self.preview_textctrl.fill(data=self.data, dialect=dialect)
event.Skip() | [
"def",
"OnButtonApply",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"dialect",
",",
"self",
".",
"has_header",
"=",
"self",
".",
"csvwidgets",
".",
"get_dialect",
"(",
")",
"except",
"TypeError",
":",
"event",
".",
"Skip",
"(",
")",
"return",
"0",... | Updates the preview_textctrl | [
"Updates",
"the",
"preview_textctrl"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L785-L796 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | MacroPanel._set_properties | def _set_properties(self):
"""Setup title, size and tooltips"""
self.codetext_ctrl.SetToolTipString(_("Enter python code here."))
self.apply_button.SetToolTipString(_("Apply changes to current macro"))
self.splitter.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
self.result_ctrl.SetMinS... | python | def _set_properties(self):
"""Setup title, size and tooltips"""
self.codetext_ctrl.SetToolTipString(_("Enter python code here."))
self.apply_button.SetToolTipString(_("Apply changes to current macro"))
self.splitter.SetBackgroundStyle(wx.BG_STYLE_COLOUR)
self.result_ctrl.SetMinS... | [
"def",
"_set_properties",
"(",
"self",
")",
":",
"self",
".",
"codetext_ctrl",
".",
"SetToolTipString",
"(",
"_",
"(",
"\"Enter python code here.\"",
")",
")",
"self",
".",
"apply_button",
".",
"SetToolTipString",
"(",
"_",
"(",
"\"Apply changes to current macro\"",... | Setup title, size and tooltips | [
"Setup",
"title",
"size",
"and",
"tooltips"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L868-L874 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | MacroPanel.OnApply | def OnApply(self, event):
"""Event handler for Apply button"""
# See if we have valid python
try:
ast.parse(self.macros)
except:
# Grab the traceback and print it for the user
s = StringIO()
e = exc_info()
# usr_tb will more th... | python | def OnApply(self, event):
"""Event handler for Apply button"""
# See if we have valid python
try:
ast.parse(self.macros)
except:
# Grab the traceback and print it for the user
s = StringIO()
e = exc_info()
# usr_tb will more th... | [
"def",
"OnApply",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"ast",
".",
"parse",
"(",
"self",
".",
"macros",
")",
"except",
":",
"s",
"=",
"StringIO",
"(",
")",
"e",
"=",
"exc_info",
"(",
")",
"usr_tb",
"=",
"get_user_codeframe",
"(",
"e",
... | Event handler for Apply button | [
"Event",
"handler",
"for",
"Apply",
"button"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L881-L907 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | MacroPanel.update_result_ctrl | def update_result_ctrl(self, event):
"""Update event result following execution by main window"""
# Check to see if macro window still exists
if not self:
return
printLen = 0
self.result_ctrl.SetValue('')
if hasattr(event, 'msg'):
# Output of scr... | python | def update_result_ctrl(self, event):
"""Update event result following execution by main window"""
# Check to see if macro window still exists
if not self:
return
printLen = 0
self.result_ctrl.SetValue('')
if hasattr(event, 'msg'):
# Output of scr... | [
"def",
"update_result_ctrl",
"(",
"self",
",",
"event",
")",
":",
"if",
"not",
"self",
":",
"return",
"printLen",
"=",
"0",
"self",
".",
"result_ctrl",
".",
"SetValue",
"(",
"''",
")",
"if",
"hasattr",
"(",
"event",
",",
"'msg'",
")",
":",
"self",
".... | Update event result following execution by main window | [
"Update",
"event",
"result",
"following",
"execution",
"by",
"main",
"window"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L909-L933 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | DimensionsEntryDialog._ondim | def _ondim(self, dimension, valuestring):
"""Converts valuestring to int and assigns result to self.dim
If there is an error (such as an empty valuestring) or if
the value is < 1, the value 1 is assigned to self.dim
Parameters
----------
dimension: int
\tDimens... | python | def _ondim(self, dimension, valuestring):
"""Converts valuestring to int and assigns result to self.dim
If there is an error (such as an empty valuestring) or if
the value is < 1, the value 1 is assigned to self.dim
Parameters
----------
dimension: int
\tDimens... | [
"def",
"_ondim",
"(",
"self",
",",
"dimension",
",",
"valuestring",
")",
":",
"try",
":",
"self",
".",
"dimensions",
"[",
"dimension",
"]",
"=",
"int",
"(",
"valuestring",
")",
"except",
"ValueError",
":",
"self",
".",
"dimensions",
"[",
"dimension",
"]"... | Converts valuestring to int and assigns result to self.dim
If there is an error (such as an empty valuestring) or if
the value is < 1, the value 1 is assigned to self.dim
Parameters
----------
dimension: int
\tDimension that is to be updated. Must be in [1:4]
v... | [
"Converts",
"valuestring",
"to",
"int",
"and",
"assigns",
"result",
"to",
"self",
".",
"dim"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L1001-L1025 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | CellEntryDialog.OnOk | def OnOk(self, event):
"""Posts a command event that makes the grid show the entered cell"""
# Get key values from textctrls
key_strings = [self.row_textctrl.GetValue(),
self.col_textctrl.GetValue(),
self.tab_textctrl.GetValue()]
key = []
... | python | def OnOk(self, event):
"""Posts a command event that makes the grid show the entered cell"""
# Get key values from textctrls
key_strings = [self.row_textctrl.GetValue(),
self.col_textctrl.GetValue(),
self.tab_textctrl.GetValue()]
key = []
... | [
"def",
"OnOk",
"(",
"self",
",",
"event",
")",
":",
"key_strings",
"=",
"[",
"self",
".",
"row_textctrl",
".",
"GetValue",
"(",
")",
",",
"self",
".",
"col_textctrl",
".",
"GetValue",
"(",
")",
",",
"self",
".",
"tab_textctrl",
".",
"GetValue",
"(",
... | Posts a command event that makes the grid show the entered cell | [
"Posts",
"a",
"command",
"event",
"that",
"makes",
"the",
"grid",
"show",
"the",
"entered",
"cell"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L1106-L1125 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | AboutDialog._set_properties | def _set_properties(self):
"""Setup title and label"""
self.SetTitle(_("About pyspread"))
label = _("pyspread {version}\nCopyright Martin Manns")
label = label.format(version=VERSION)
self.about_label.SetLabel(label) | python | def _set_properties(self):
"""Setup title and label"""
self.SetTitle(_("About pyspread"))
label = _("pyspread {version}\nCopyright Martin Manns")
label = label.format(version=VERSION)
self.about_label.SetLabel(label) | [
"def",
"_set_properties",
"(",
"self",
")",
":",
"self",
".",
"SetTitle",
"(",
"_",
"(",
"\"About pyspread\"",
")",
")",
"label",
"=",
"_",
"(",
"\"pyspread {version}\\nCopyright Martin Manns\"",
")",
"label",
"=",
"label",
".",
"format",
"(",
"version",
"=",
... | Setup title and label | [
"Setup",
"title",
"and",
"label"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L1163-L1171 | train |
manns/pyspread | pyspread/src/gui/_dialogs.py | PasteAsDialog.get_max_dim | def get_max_dim(self, obj):
"""Returns maximum dimensionality over which obj is iterable <= 2"""
try:
iter(obj)
except TypeError:
return 0
try:
for o in obj:
iter(o)
break
except TypeError:
return... | python | def get_max_dim(self, obj):
"""Returns maximum dimensionality over which obj is iterable <= 2"""
try:
iter(obj)
except TypeError:
return 0
try:
for o in obj:
iter(o)
break
except TypeError:
return... | [
"def",
"get_max_dim",
"(",
"self",
",",
"obj",
")",
":",
"try",
":",
"iter",
"(",
"obj",
")",
"except",
"TypeError",
":",
"return",
"0",
"try",
":",
"for",
"o",
"in",
"obj",
":",
"iter",
"(",
"o",
")",
"break",
"except",
"TypeError",
":",
"return",... | Returns maximum dimensionality over which obj is iterable <= 2 | [
"Returns",
"maximum",
"dimensionality",
"over",
"which",
"obj",
"is",
"iterable",
"<",
"=",
"2"
] | 0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0 | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_dialogs.py#L1473-L1490 | train |
dgraph-io/pydgraph | pydgraph/client_stub.py | DgraphClientStub.alter | def alter(self, operation, timeout=None, metadata=None, credentials=None):
"""Runs alter operation."""
return self.stub.Alter(operation, timeout=timeout, metadata=metadata,
credentials=credentials) | python | def alter(self, operation, timeout=None, metadata=None, credentials=None):
"""Runs alter operation."""
return self.stub.Alter(operation, timeout=timeout, metadata=metadata,
credentials=credentials) | [
"def",
"alter",
"(",
"self",
",",
"operation",
",",
"timeout",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"credentials",
"=",
"None",
")",
":",
"return",
"self",
".",
"stub",
".",
"Alter",
"(",
"operation",
",",
"timeout",
"=",
"timeout",
",",
"... | Runs alter operation. | [
"Runs",
"alter",
"operation",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/client_stub.py#L43-L46 | train |
dgraph-io/pydgraph | pydgraph/client_stub.py | DgraphClientStub.query | def query(self, req, timeout=None, metadata=None, credentials=None):
"""Runs query operation."""
return self.stub.Query(req, timeout=timeout, metadata=metadata,
credentials=credentials) | python | def query(self, req, timeout=None, metadata=None, credentials=None):
"""Runs query operation."""
return self.stub.Query(req, timeout=timeout, metadata=metadata,
credentials=credentials) | [
"def",
"query",
"(",
"self",
",",
"req",
",",
"timeout",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"credentials",
"=",
"None",
")",
":",
"return",
"self",
".",
"stub",
".",
"Query",
"(",
"req",
",",
"timeout",
"=",
"timeout",
",",
"metadata",
... | Runs query operation. | [
"Runs",
"query",
"operation",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/client_stub.py#L48-L51 | train |
dgraph-io/pydgraph | pydgraph/client_stub.py | DgraphClientStub.mutate | def mutate(self, mutation, timeout=None, metadata=None, credentials=None):
"""Runs mutate operation."""
return self.stub.Mutate(mutation, timeout=timeout, metadata=metadata,
credentials=credentials) | python | def mutate(self, mutation, timeout=None, metadata=None, credentials=None):
"""Runs mutate operation."""
return self.stub.Mutate(mutation, timeout=timeout, metadata=metadata,
credentials=credentials) | [
"def",
"mutate",
"(",
"self",
",",
"mutation",
",",
"timeout",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"credentials",
"=",
"None",
")",
":",
"return",
"self",
".",
"stub",
".",
"Mutate",
"(",
"mutation",
",",
"timeout",
"=",
"timeout",
",",
"... | Runs mutate operation. | [
"Runs",
"mutate",
"operation",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/client_stub.py#L53-L56 | train |
dgraph-io/pydgraph | pydgraph/client_stub.py | DgraphClientStub.commit_or_abort | def commit_or_abort(self, ctx, timeout=None, metadata=None,
credentials=None):
"""Runs commit or abort operation."""
return self.stub.CommitOrAbort(ctx, timeout=timeout, metadata=metadata,
credentials=credentials) | python | def commit_or_abort(self, ctx, timeout=None, metadata=None,
credentials=None):
"""Runs commit or abort operation."""
return self.stub.CommitOrAbort(ctx, timeout=timeout, metadata=metadata,
credentials=credentials) | [
"def",
"commit_or_abort",
"(",
"self",
",",
"ctx",
",",
"timeout",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"credentials",
"=",
"None",
")",
":",
"return",
"self",
".",
"stub",
".",
"CommitOrAbort",
"(",
"ctx",
",",
"timeout",
"=",
"timeout",
",... | Runs commit or abort operation. | [
"Runs",
"commit",
"or",
"abort",
"operation",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/client_stub.py#L58-L62 | train |
dgraph-io/pydgraph | pydgraph/client_stub.py | DgraphClientStub.check_version | def check_version(self, check, timeout=None, metadata=None,
credentials=None):
"""Returns the version of the Dgraph instance."""
return self.stub.CheckVersion(check, timeout=timeout,
metadata=metadata,
cred... | python | def check_version(self, check, timeout=None, metadata=None,
credentials=None):
"""Returns the version of the Dgraph instance."""
return self.stub.CheckVersion(check, timeout=timeout,
metadata=metadata,
cred... | [
"def",
"check_version",
"(",
"self",
",",
"check",
",",
"timeout",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"credentials",
"=",
"None",
")",
":",
"return",
"self",
".",
"stub",
".",
"CheckVersion",
"(",
"check",
",",
"timeout",
"=",
"timeout",
"... | Returns the version of the Dgraph instance. | [
"Returns",
"the",
"version",
"of",
"the",
"Dgraph",
"instance",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/client_stub.py#L64-L69 | train |
dgraph-io/pydgraph | pydgraph/client.py | DgraphClient.alter | def alter(self, operation, timeout=None, metadata=None, credentials=None):
"""Runs a modification via this client."""
new_metadata = self.add_login_metadata(metadata)
try:
return self.any_client().alter(operation, timeout=timeout,
metadata=... | python | def alter(self, operation, timeout=None, metadata=None, credentials=None):
"""Runs a modification via this client."""
new_metadata = self.add_login_metadata(metadata)
try:
return self.any_client().alter(operation, timeout=timeout,
metadata=... | [
"def",
"alter",
"(",
"self",
",",
"operation",
",",
"timeout",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"credentials",
"=",
"None",
")",
":",
"new_metadata",
"=",
"self",
".",
"add_login_metadata",
"(",
"metadata",
")",
"try",
":",
"return",
"self... | Runs a modification via this client. | [
"Runs",
"a",
"modification",
"via",
"this",
"client",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/client.py#L71-L87 | train |
dgraph-io/pydgraph | pydgraph/client.py | DgraphClient.txn | def txn(self, read_only=False, best_effort=False):
"""Creates a transaction."""
return txn.Txn(self, read_only=read_only, best_effort=best_effort) | python | def txn(self, read_only=False, best_effort=False):
"""Creates a transaction."""
return txn.Txn(self, read_only=read_only, best_effort=best_effort) | [
"def",
"txn",
"(",
"self",
",",
"read_only",
"=",
"False",
",",
"best_effort",
"=",
"False",
")",
":",
"return",
"txn",
".",
"Txn",
"(",
"self",
",",
"read_only",
"=",
"read_only",
",",
"best_effort",
"=",
"best_effort",
")"
] | Creates a transaction. | [
"Creates",
"a",
"transaction",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/client.py#L89-L91 | train |
dgraph-io/pydgraph | pydgraph/txn.py | Txn.query | def query(self, query, variables=None, timeout=None, metadata=None,
credentials=None):
"""Adds a query operation to the transaction."""
new_metadata = self._dg.add_login_metadata(metadata)
req = self._common_query(query, variables=variables)
try:
res = self._dc.... | python | def query(self, query, variables=None, timeout=None, metadata=None,
credentials=None):
"""Adds a query operation to the transaction."""
new_metadata = self._dg.add_login_metadata(metadata)
req = self._common_query(query, variables=variables)
try:
res = self._dc.... | [
"def",
"query",
"(",
"self",
",",
"query",
",",
"variables",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"credentials",
"=",
"None",
")",
":",
"new_metadata",
"=",
"self",
".",
"_dg",
".",
"add_login_metadata",
"(",
"me... | Adds a query operation to the transaction. | [
"Adds",
"a",
"query",
"operation",
"to",
"the",
"transaction",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/txn.py#L65-L85 | train |
dgraph-io/pydgraph | pydgraph/txn.py | Txn.mutate | def mutate(self, mutation=None, set_obj=None, del_obj=None, set_nquads=None,
del_nquads=None, commit_now=None, ignore_index_conflict=None,
timeout=None, metadata=None, credentials=None):
"""Adds a mutate operation to the transaction."""
mutation = self._common_mutate(
... | python | def mutate(self, mutation=None, set_obj=None, del_obj=None, set_nquads=None,
del_nquads=None, commit_now=None, ignore_index_conflict=None,
timeout=None, metadata=None, credentials=None):
"""Adds a mutate operation to the transaction."""
mutation = self._common_mutate(
... | [
"def",
"mutate",
"(",
"self",
",",
"mutation",
"=",
"None",
",",
"set_obj",
"=",
"None",
",",
"del_obj",
"=",
"None",
",",
"set_nquads",
"=",
"None",
",",
"del_nquads",
"=",
"None",
",",
"commit_now",
"=",
"None",
",",
"ignore_index_conflict",
"=",
"None... | Adds a mutate operation to the transaction. | [
"Adds",
"a",
"mutate",
"operation",
"to",
"the",
"transaction",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/txn.py#L104-L147 | train |
dgraph-io/pydgraph | pydgraph/txn.py | Txn.commit | def commit(self, timeout=None, metadata=None, credentials=None):
"""Commits the transaction."""
if not self._common_commit():
return
new_metadata = self._dg.add_login_metadata(metadata)
try:
self._dc.commit_or_abort(self._ctx, timeout=timeout,
... | python | def commit(self, timeout=None, metadata=None, credentials=None):
"""Commits the transaction."""
if not self._common_commit():
return
new_metadata = self._dg.add_login_metadata(metadata)
try:
self._dc.commit_or_abort(self._ctx, timeout=timeout,
... | [
"def",
"commit",
"(",
"self",
",",
"timeout",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"credentials",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_common_commit",
"(",
")",
":",
"return",
"new_metadata",
"=",
"self",
".",
"_dg",
".",
"ad... | Commits the transaction. | [
"Commits",
"the",
"transaction",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/txn.py#L188-L209 | train |
dgraph-io/pydgraph | pydgraph/txn.py | Txn.discard | def discard(self, timeout=None, metadata=None, credentials=None):
"""Discards the transaction."""
if not self._common_discard():
return
new_metadata = self._dg.add_login_metadata(metadata)
try:
self._dc.commit_or_abort(self._ctx, timeout=timeout,
... | python | def discard(self, timeout=None, metadata=None, credentials=None):
"""Discards the transaction."""
if not self._common_discard():
return
new_metadata = self._dg.add_login_metadata(metadata)
try:
self._dc.commit_or_abort(self._ctx, timeout=timeout,
... | [
"def",
"discard",
"(",
"self",
",",
"timeout",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"credentials",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_common_discard",
"(",
")",
":",
"return",
"new_metadata",
"=",
"self",
".",
"_dg",
".",
"... | Discards the transaction. | [
"Discards",
"the",
"transaction",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/txn.py#L232-L250 | train |
dgraph-io/pydgraph | pydgraph/txn.py | Txn.merge_context | def merge_context(self, src=None):
"""Merges context from this instance with src."""
if src is None:
# This condition will be true only if the server doesn't return a
# txn context after a query or mutation.
return
if self._ctx.start_ts == 0:
self... | python | def merge_context(self, src=None):
"""Merges context from this instance with src."""
if src is None:
# This condition will be true only if the server doesn't return a
# txn context after a query or mutation.
return
if self._ctx.start_ts == 0:
self... | [
"def",
"merge_context",
"(",
"self",
",",
"src",
"=",
"None",
")",
":",
"if",
"src",
"is",
"None",
":",
"return",
"if",
"self",
".",
"_ctx",
".",
"start_ts",
"==",
"0",
":",
"self",
".",
"_ctx",
".",
"start_ts",
"=",
"src",
".",
"start_ts",
"elif",... | Merges context from this instance with src. | [
"Merges",
"context",
"from",
"this",
"instance",
"with",
"src",
"."
] | 0fe85f6593cb2148475750bc8555a6fdf509054b | https://github.com/dgraph-io/pydgraph/blob/0fe85f6593cb2148475750bc8555a6fdf509054b/pydgraph/txn.py#L263-L277 | train |
anx-ckreuzberger/django-rest-passwordreset | django_rest_passwordreset/tokens.py | RandomStringTokenGenerator.generate_token | def generate_token(self, *args, **kwargs):
""" generates a pseudo random code using os.urandom and binascii.hexlify """
# determine the length based on min_length and max_length
length = random.randint(self.min_length, self.max_length)
# generate the token using os.urandom and hexlify
... | python | def generate_token(self, *args, **kwargs):
""" generates a pseudo random code using os.urandom and binascii.hexlify """
# determine the length based on min_length and max_length
length = random.randint(self.min_length, self.max_length)
# generate the token using os.urandom and hexlify
... | [
"def",
"generate_token",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"length",
"=",
"random",
".",
"randint",
"(",
"self",
".",
"min_length",
",",
"self",
".",
"max_length",
")",
"return",
"binascii",
".",
"hexlify",
"(",
"os",
".",
... | generates a pseudo random code using os.urandom and binascii.hexlify | [
"generates",
"a",
"pseudo",
"random",
"code",
"using",
"os",
".",
"urandom",
"and",
"binascii",
".",
"hexlify"
] | 7118d430d4b21f78a23530c88a33390c9b6a4f95 | https://github.com/anx-ckreuzberger/django-rest-passwordreset/blob/7118d430d4b21f78a23530c88a33390c9b6a4f95/django_rest_passwordreset/tokens.py#L61-L69 | train |
pinax/pinax-blog | pinax/blog/parsers/creole_parser.py | HtmlEmitter.get_text | def get_text(self, node):
"""Try to emit whatever text is in the node."""
try:
return node.children[0].content or ""
except (AttributeError, IndexError):
return node.content or "" | python | def get_text(self, node):
"""Try to emit whatever text is in the node."""
try:
return node.children[0].content or ""
except (AttributeError, IndexError):
return node.content or "" | [
"def",
"get_text",
"(",
"self",
",",
"node",
")",
":",
"try",
":",
"return",
"node",
".",
"children",
"[",
"0",
"]",
".",
"content",
"or",
"\"\"",
"except",
"(",
"AttributeError",
",",
"IndexError",
")",
":",
"return",
"node",
".",
"content",
"or",
"... | Try to emit whatever text is in the node. | [
"Try",
"to",
"emit",
"whatever",
"text",
"is",
"in",
"the",
"node",
"."
] | be1d64946381b47d197b258a488d5de56aacccce | https://github.com/pinax/pinax-blog/blob/be1d64946381b47d197b258a488d5de56aacccce/pinax/blog/parsers/creole_parser.py#L35-L40 | train |
pinax/pinax-blog | pinax/blog/parsers/creole_parser.py | HtmlEmitter.emit_children | def emit_children(self, node):
"""Emit all the children of a node."""
return "".join([self.emit_node(child) for child in node.children]) | python | def emit_children(self, node):
"""Emit all the children of a node."""
return "".join([self.emit_node(child) for child in node.children]) | [
"def",
"emit_children",
"(",
"self",
",",
"node",
")",
":",
"return",
"\"\"",
".",
"join",
"(",
"[",
"self",
".",
"emit_node",
"(",
"child",
")",
"for",
"child",
"in",
"node",
".",
"children",
"]",
")"
] | Emit all the children of a node. | [
"Emit",
"all",
"the",
"children",
"of",
"a",
"node",
"."
] | be1d64946381b47d197b258a488d5de56aacccce | https://github.com/pinax/pinax-blog/blob/be1d64946381b47d197b258a488d5de56aacccce/pinax/blog/parsers/creole_parser.py#L138-L140 | train |
pinax/pinax-blog | pinax/blog/parsers/creole_parser.py | HtmlEmitter.emit_node | def emit_node(self, node):
"""Emit a single node."""
emit = getattr(self, "%s_emit" % node.kind, self.default_emit)
return emit(node) | python | def emit_node(self, node):
"""Emit a single node."""
emit = getattr(self, "%s_emit" % node.kind, self.default_emit)
return emit(node) | [
"def",
"emit_node",
"(",
"self",
",",
"node",
")",
":",
"emit",
"=",
"getattr",
"(",
"self",
",",
"\"%s_emit\"",
"%",
"node",
".",
"kind",
",",
"self",
".",
"default_emit",
")",
"return",
"emit",
"(",
"node",
")"
] | Emit a single node. | [
"Emit",
"a",
"single",
"node",
"."
] | be1d64946381b47d197b258a488d5de56aacccce | https://github.com/pinax/pinax-blog/blob/be1d64946381b47d197b258a488d5de56aacccce/pinax/blog/parsers/creole_parser.py#L142-L145 | train |
pinax/pinax-blog | pinax/blog/views.py | ajax_preview | def ajax_preview(request, **kwargs):
"""
Currently only supports markdown
"""
data = {
"html": render_to_string("pinax/blog/_preview.html", {
"content": parse(request.POST.get("markup"))
})
}
return JsonResponse(data) | python | def ajax_preview(request, **kwargs):
"""
Currently only supports markdown
"""
data = {
"html": render_to_string("pinax/blog/_preview.html", {
"content": parse(request.POST.get("markup"))
})
}
return JsonResponse(data) | [
"def",
"ajax_preview",
"(",
"request",
",",
"**",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"html\"",
":",
"render_to_string",
"(",
"\"pinax/blog/_preview.html\"",
",",
"{",
"\"content\"",
":",
"parse",
"(",
"request",
".",
"POST",
".",
"get",
"(",
"\"markup\"... | Currently only supports markdown | [
"Currently",
"only",
"supports",
"markdown"
] | be1d64946381b47d197b258a488d5de56aacccce | https://github.com/pinax/pinax-blog/blob/be1d64946381b47d197b258a488d5de56aacccce/pinax/blog/views.py#L285-L294 | train |
closeio/tasktiger | tasktiger/redis_semaphore.py | Semaphore.set_system_lock | def set_system_lock(cls, redis, name, timeout):
"""
Set system lock for the semaphore.
Sets a system lock that will expire in timeout seconds. This
overrides all other locks. Existing locks cannot be renewed
and no new locks will be permitted until the system lock
expire... | python | def set_system_lock(cls, redis, name, timeout):
"""
Set system lock for the semaphore.
Sets a system lock that will expire in timeout seconds. This
overrides all other locks. Existing locks cannot be renewed
and no new locks will be permitted until the system lock
expire... | [
"def",
"set_system_lock",
"(",
"cls",
",",
"redis",
",",
"name",
",",
"timeout",
")",
":",
"pipeline",
"=",
"redis",
".",
"pipeline",
"(",
")",
"pipeline",
".",
"zadd",
"(",
"name",
",",
"SYSTEM_LOCK_ID",
",",
"time",
".",
"time",
"(",
")",
"+",
"tim... | Set system lock for the semaphore.
Sets a system lock that will expire in timeout seconds. This
overrides all other locks. Existing locks cannot be renewed
and no new locks will be permitted until the system lock
expires.
Arguments:
redis: Redis client
n... | [
"Set",
"system",
"lock",
"for",
"the",
"semaphore",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/redis_semaphore.py#L51-L69 | train |
closeio/tasktiger | tasktiger/redis_semaphore.py | Semaphore.acquire | def acquire(self):
"""
Obtain a semaphore lock.
Returns: Tuple that contains True/False if the lock was acquired and number of
locks in semaphore.
"""
acquired, locks = self._semaphore(keys=[self.name],
args=[self.lock_... | python | def acquire(self):
"""
Obtain a semaphore lock.
Returns: Tuple that contains True/False if the lock was acquired and number of
locks in semaphore.
"""
acquired, locks = self._semaphore(keys=[self.name],
args=[self.lock_... | [
"def",
"acquire",
"(",
"self",
")",
":",
"acquired",
",",
"locks",
"=",
"self",
".",
"_semaphore",
"(",
"keys",
"=",
"[",
"self",
".",
"name",
"]",
",",
"args",
"=",
"[",
"self",
".",
"lock_id",
",",
"self",
".",
"max_locks",
",",
"self",
".",
"t... | Obtain a semaphore lock.
Returns: Tuple that contains True/False if the lock was acquired and number of
locks in semaphore. | [
"Obtain",
"a",
"semaphore",
"lock",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/redis_semaphore.py#L76-L91 | train |
closeio/tasktiger | tasktiger/redis_lock.py | NewStyleLock.renew | def renew(self, new_timeout):
"""
Sets a new timeout for an already acquired lock.
``new_timeout`` can be specified as an integer or a float, both
representing the number of seconds.
"""
if self.local.token is None:
raise LockError("Cannot extend an unlocked ... | python | def renew(self, new_timeout):
"""
Sets a new timeout for an already acquired lock.
``new_timeout`` can be specified as an integer or a float, both
representing the number of seconds.
"""
if self.local.token is None:
raise LockError("Cannot extend an unlocked ... | [
"def",
"renew",
"(",
"self",
",",
"new_timeout",
")",
":",
"if",
"self",
".",
"local",
".",
"token",
"is",
"None",
":",
"raise",
"LockError",
"(",
"\"Cannot extend an unlocked lock\"",
")",
"if",
"self",
".",
"timeout",
"is",
"None",
":",
"raise",
"LockErr... | Sets a new timeout for an already acquired lock.
``new_timeout`` can be specified as an integer or a float, both
representing the number of seconds. | [
"Sets",
"a",
"new",
"timeout",
"for",
"an",
"already",
"acquired",
"lock",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/redis_lock.py#L122-L133 | train |
closeio/tasktiger | tasktiger/__init__.py | TaskTiger.task | def task(self, _fn=None, queue=None, hard_timeout=None, unique=None,
lock=None, lock_key=None, retry=None, retry_on=None,
retry_method=None, schedule=None, batch=False,
max_queue_size=None):
"""
Function decorator that defines the behavior of the function when it i... | python | def task(self, _fn=None, queue=None, hard_timeout=None, unique=None,
lock=None, lock_key=None, retry=None, retry_on=None,
retry_method=None, schedule=None, batch=False,
max_queue_size=None):
"""
Function decorator that defines the behavior of the function when it i... | [
"def",
"task",
"(",
"self",
",",
"_fn",
"=",
"None",
",",
"queue",
"=",
"None",
",",
"hard_timeout",
"=",
"None",
",",
"unique",
"=",
"None",
",",
"lock",
"=",
"None",
",",
"lock_key",
"=",
"None",
",",
"retry",
"=",
"None",
",",
"retry_on",
"=",
... | Function decorator that defines the behavior of the function when it is
used as a task. To use the default behavior, tasks don't need to be
decorated.
See README.rst for an explanation of the options. | [
"Function",
"decorator",
"that",
"defines",
"the",
"behavior",
"of",
"the",
"function",
"when",
"it",
"is",
"used",
"as",
"a",
"task",
".",
"To",
"use",
"the",
"default",
"behavior",
"tasks",
"don",
"t",
"need",
"to",
"be",
"decorated",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/__init__.py#L242-L297 | train |
closeio/tasktiger | tasktiger/__init__.py | TaskTiger.run_worker | def run_worker(self, queues=None, module=None, exclude_queues=None,
max_workers_per_queue=None, store_tracebacks=None):
"""
Main worker entry point method.
The arguments are explained in the module-level run_worker() method's
click options.
"""
try:
... | python | def run_worker(self, queues=None, module=None, exclude_queues=None,
max_workers_per_queue=None, store_tracebacks=None):
"""
Main worker entry point method.
The arguments are explained in the module-level run_worker() method's
click options.
"""
try:
... | [
"def",
"run_worker",
"(",
"self",
",",
"queues",
"=",
"None",
",",
"module",
"=",
"None",
",",
"exclude_queues",
"=",
"None",
",",
"max_workers_per_queue",
"=",
"None",
",",
"store_tracebacks",
"=",
"None",
")",
":",
"try",
":",
"module_names",
"=",
"modul... | Main worker entry point method.
The arguments are explained in the module-level run_worker() method's
click options. | [
"Main",
"worker",
"entry",
"point",
"method",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/__init__.py#L306-L331 | train |
closeio/tasktiger | tasktiger/__init__.py | TaskTiger.delay | def delay(self, func, args=None, kwargs=None, queue=None,
hard_timeout=None, unique=None, lock=None, lock_key=None,
when=None, retry=None, retry_on=None, retry_method=None,
max_queue_size=None):
"""
Queues a task. See README.rst for an explanation of the options... | python | def delay(self, func, args=None, kwargs=None, queue=None,
hard_timeout=None, unique=None, lock=None, lock_key=None,
when=None, retry=None, retry_on=None, retry_method=None,
max_queue_size=None):
"""
Queues a task. See README.rst for an explanation of the options... | [
"def",
"delay",
"(",
"self",
",",
"func",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"queue",
"=",
"None",
",",
"hard_timeout",
"=",
"None",
",",
"unique",
"=",
"None",
",",
"lock",
"=",
"None",
",",
"lock_key",
"=",
"None",
",",
... | Queues a task. See README.rst for an explanation of the options. | [
"Queues",
"a",
"task",
".",
"See",
"README",
".",
"rst",
"for",
"an",
"explanation",
"of",
"the",
"options",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/__init__.py#L333-L348 | train |
closeio/tasktiger | tasktiger/__init__.py | TaskTiger.get_queue_sizes | def get_queue_sizes(self, queue):
"""
Get the queue's number of tasks in each state.
Returns dict with queue size for the QUEUED, SCHEDULED, and ACTIVE
states. Does not include size of error queue.
"""
states = [QUEUED, SCHEDULED, ACTIVE]
pipeline = self.connect... | python | def get_queue_sizes(self, queue):
"""
Get the queue's number of tasks in each state.
Returns dict with queue size for the QUEUED, SCHEDULED, and ACTIVE
states. Does not include size of error queue.
"""
states = [QUEUED, SCHEDULED, ACTIVE]
pipeline = self.connect... | [
"def",
"get_queue_sizes",
"(",
"self",
",",
"queue",
")",
":",
"states",
"=",
"[",
"QUEUED",
",",
"SCHEDULED",
",",
"ACTIVE",
"]",
"pipeline",
"=",
"self",
".",
"connection",
".",
"pipeline",
"(",
")",
"for",
"state",
"in",
"states",
":",
"pipeline",
"... | Get the queue's number of tasks in each state.
Returns dict with queue size for the QUEUED, SCHEDULED, and ACTIVE
states. Does not include size of error queue. | [
"Get",
"the",
"queue",
"s",
"number",
"of",
"tasks",
"in",
"each",
"state",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/__init__.py#L350-L363 | train |
closeio/tasktiger | tasktiger/__init__.py | TaskTiger.get_queue_system_lock | def get_queue_system_lock(self, queue):
"""
Get system lock timeout
Returns time system lock expires or None if lock does not exist
"""
key = self._key(LOCK_REDIS_KEY, queue)
return Semaphore.get_system_lock(self.connection, key) | python | def get_queue_system_lock(self, queue):
"""
Get system lock timeout
Returns time system lock expires or None if lock does not exist
"""
key = self._key(LOCK_REDIS_KEY, queue)
return Semaphore.get_system_lock(self.connection, key) | [
"def",
"get_queue_system_lock",
"(",
"self",
",",
"queue",
")",
":",
"key",
"=",
"self",
".",
"_key",
"(",
"LOCK_REDIS_KEY",
",",
"queue",
")",
"return",
"Semaphore",
".",
"get_system_lock",
"(",
"self",
".",
"connection",
",",
"key",
")"
] | Get system lock timeout
Returns time system lock expires or None if lock does not exist | [
"Get",
"system",
"lock",
"timeout"
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/__init__.py#L370-L378 | train |
closeio/tasktiger | tasktiger/__init__.py | TaskTiger.set_queue_system_lock | def set_queue_system_lock(self, queue, timeout):
"""
Set system lock on a queue.
Max workers for this queue must be used for this to have any effect.
This will keep workers from processing tasks for this queue until
the timeout has expired. Active tasks will continue processing... | python | def set_queue_system_lock(self, queue, timeout):
"""
Set system lock on a queue.
Max workers for this queue must be used for this to have any effect.
This will keep workers from processing tasks for this queue until
the timeout has expired. Active tasks will continue processing... | [
"def",
"set_queue_system_lock",
"(",
"self",
",",
"queue",
",",
"timeout",
")",
":",
"key",
"=",
"self",
".",
"_key",
"(",
"LOCK_REDIS_KEY",
",",
"queue",
")",
"Semaphore",
".",
"set_system_lock",
"(",
"self",
".",
"connection",
",",
"key",
",",
"timeout",... | Set system lock on a queue.
Max workers for this queue must be used for this to have any effect.
This will keep workers from processing tasks for this queue until
the timeout has expired. Active tasks will continue processing their
current task.
timeout is number of seconds to... | [
"Set",
"system",
"lock",
"on",
"a",
"queue",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/__init__.py#L380-L394 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._install_signal_handlers | def _install_signal_handlers(self):
"""
Sets up signal handlers for safely stopping the worker.
"""
def request_stop(signum, frame):
self._stop_requested = True
self.log.info('stop requested, waiting for task to finish')
signal.signal(signal.SIGINT, reques... | python | def _install_signal_handlers(self):
"""
Sets up signal handlers for safely stopping the worker.
"""
def request_stop(signum, frame):
self._stop_requested = True
self.log.info('stop requested, waiting for task to finish')
signal.signal(signal.SIGINT, reques... | [
"def",
"_install_signal_handlers",
"(",
"self",
")",
":",
"def",
"request_stop",
"(",
"signum",
",",
"frame",
")",
":",
"self",
".",
"_stop_requested",
"=",
"True",
"self",
".",
"log",
".",
"info",
"(",
"'stop requested, waiting for task to finish'",
")",
"signa... | Sets up signal handlers for safely stopping the worker. | [
"Sets",
"up",
"signal",
"handlers",
"for",
"safely",
"stopping",
"the",
"worker",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L105-L113 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._uninstall_signal_handlers | def _uninstall_signal_handlers(self):
"""
Restores default signal handlers.
"""
signal.signal(signal.SIGINT, signal.SIG_DFL)
signal.signal(signal.SIGTERM, signal.SIG_DFL) | python | def _uninstall_signal_handlers(self):
"""
Restores default signal handlers.
"""
signal.signal(signal.SIGINT, signal.SIG_DFL)
signal.signal(signal.SIGTERM, signal.SIG_DFL) | [
"def",
"_uninstall_signal_handlers",
"(",
"self",
")",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"signal",
".",
"SIG_DFL",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"signal",
".",
"SIG_DFL",
")"
] | Restores default signal handlers. | [
"Restores",
"default",
"signal",
"handlers",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L115-L120 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._filter_queues | def _filter_queues(self, queues):
"""
Applies the queue filter to the given list of queues and returns the
queues that match. Note that a queue name matches any subqueues
starting with the name, followed by a date. For example, "foo" will
match both "foo" and "foo.bar".
"... | python | def _filter_queues(self, queues):
"""
Applies the queue filter to the given list of queues and returns the
queues that match. Note that a queue name matches any subqueues
starting with the name, followed by a date. For example, "foo" will
match both "foo" and "foo.bar".
"... | [
"def",
"_filter_queues",
"(",
"self",
",",
"queues",
")",
":",
"def",
"match",
"(",
"queue",
")",
":",
"for",
"part",
"in",
"reversed_dotted_parts",
"(",
"queue",
")",
":",
"if",
"part",
"in",
"self",
".",
"exclude_queues",
":",
"return",
"False",
"if",
... | Applies the queue filter to the given list of queues and returns the
queues that match. Note that a queue name matches any subqueues
starting with the name, followed by a date. For example, "foo" will
match both "foo" and "foo.bar". | [
"Applies",
"the",
"queue",
"filter",
"to",
"the",
"given",
"list",
"of",
"queues",
"and",
"returns",
"the",
"queues",
"that",
"match",
".",
"Note",
"that",
"a",
"queue",
"name",
"matches",
"any",
"subqueues",
"starting",
"with",
"the",
"name",
"followed",
... | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L122-L142 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._worker_queue_scheduled_tasks | def _worker_queue_scheduled_tasks(self):
"""
Helper method that takes due tasks from the SCHEDULED queue and puts
them in the QUEUED queue for execution. This should be called
periodically.
"""
queues = set(self._filter_queues(self.connection.smembers(
sel... | python | def _worker_queue_scheduled_tasks(self):
"""
Helper method that takes due tasks from the SCHEDULED queue and puts
them in the QUEUED queue for execution. This should be called
periodically.
"""
queues = set(self._filter_queues(self.connection.smembers(
sel... | [
"def",
"_worker_queue_scheduled_tasks",
"(",
"self",
")",
":",
"queues",
"=",
"set",
"(",
"self",
".",
"_filter_queues",
"(",
"self",
".",
"connection",
".",
"smembers",
"(",
"self",
".",
"_key",
"(",
"SCHEDULED",
")",
")",
")",
")",
"now",
"=",
"time",
... | Helper method that takes due tasks from the SCHEDULED queue and puts
them in the QUEUED queue for execution. This should be called
periodically. | [
"Helper",
"method",
"that",
"takes",
"due",
"tasks",
"from",
"the",
"SCHEDULED",
"queue",
"and",
"puts",
"them",
"in",
"the",
"QUEUED",
"queue",
"for",
"execution",
".",
"This",
"should",
"be",
"called",
"periodically",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L144-L175 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._wait_for_new_tasks | def _wait_for_new_tasks(self, timeout=0, batch_timeout=0):
"""
Check activity channel and wait as necessary.
This method is also used to slow down the main processing loop to reduce
the effects of rapidly sending Redis commands. This method will exit
for any of these conditions... | python | def _wait_for_new_tasks(self, timeout=0, batch_timeout=0):
"""
Check activity channel and wait as necessary.
This method is also used to slow down the main processing loop to reduce
the effects of rapidly sending Redis commands. This method will exit
for any of these conditions... | [
"def",
"_wait_for_new_tasks",
"(",
"self",
",",
"timeout",
"=",
"0",
",",
"batch_timeout",
"=",
"0",
")",
":",
"new_queue_found",
"=",
"False",
"start_time",
"=",
"batch_exit",
"=",
"time",
".",
"time",
"(",
")",
"while",
"True",
":",
"if",
"batch_exit",
... | Check activity channel and wait as necessary.
This method is also used to slow down the main processing loop to reduce
the effects of rapidly sending Redis commands. This method will exit
for any of these conditions:
1. _did_work is True, suggests there could be more work pending
... | [
"Check",
"activity",
"channel",
"and",
"wait",
"as",
"necessary",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L177-L220 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._execute_forked | def _execute_forked(self, tasks, log):
"""
Executes the tasks in the forked process. Multiple tasks can be passed
for batch processing. However, they must all use the same function and
will share the execution entry.
"""
success = False
execution = {}
as... | python | def _execute_forked(self, tasks, log):
"""
Executes the tasks in the forked process. Multiple tasks can be passed
for batch processing. However, they must all use the same function and
will share the execution entry.
"""
success = False
execution = {}
as... | [
"def",
"_execute_forked",
"(",
"self",
",",
"tasks",
",",
"log",
")",
":",
"success",
"=",
"False",
"execution",
"=",
"{",
"}",
"assert",
"len",
"(",
"tasks",
")",
"task_func",
"=",
"tasks",
"[",
"0",
"]",
".",
"serialized_func",
"assert",
"all",
"(",
... | Executes the tasks in the forked process. Multiple tasks can be passed
for batch processing. However, they must all use the same function and
will share the execution entry. | [
"Executes",
"the",
"tasks",
"in",
"the",
"forked",
"process",
".",
"Multiple",
"tasks",
"can",
"be",
"passed",
"for",
"batch",
"processing",
".",
"However",
"they",
"must",
"all",
"use",
"the",
"same",
"function",
"and",
"will",
"share",
"the",
"execution",
... | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L292-L370 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._get_queue_batch_size | def _get_queue_batch_size(self, queue):
"""Get queue batch size."""
# Fetch one item unless this is a batch queue.
# XXX: It would be more efficient to loop in reverse order and break.
batch_queues = self.config['BATCH_QUEUES']
batch_size = 1
for part in dotted_parts(que... | python | def _get_queue_batch_size(self, queue):
"""Get queue batch size."""
# Fetch one item unless this is a batch queue.
# XXX: It would be more efficient to loop in reverse order and break.
batch_queues = self.config['BATCH_QUEUES']
batch_size = 1
for part in dotted_parts(que... | [
"def",
"_get_queue_batch_size",
"(",
"self",
",",
"queue",
")",
":",
"batch_queues",
"=",
"self",
".",
"config",
"[",
"'BATCH_QUEUES'",
"]",
"batch_size",
"=",
"1",
"for",
"part",
"in",
"dotted_parts",
"(",
"queue",
")",
":",
"if",
"part",
"in",
"batch_que... | Get queue batch size. | [
"Get",
"queue",
"batch",
"size",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L372-L383 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._get_queue_lock | def _get_queue_lock(self, queue, log):
"""Get queue lock for max worker queues.
For max worker queues it returns a Lock if acquired and whether
it failed to acquire the lock.
"""
max_workers = self.max_workers_per_queue
# Check if this is single worker queue
for... | python | def _get_queue_lock(self, queue, log):
"""Get queue lock for max worker queues.
For max worker queues it returns a Lock if acquired and whether
it failed to acquire the lock.
"""
max_workers = self.max_workers_per_queue
# Check if this is single worker queue
for... | [
"def",
"_get_queue_lock",
"(",
"self",
",",
"queue",
",",
"log",
")",
":",
"max_workers",
"=",
"self",
".",
"max_workers_per_queue",
"for",
"part",
"in",
"dotted_parts",
"(",
"queue",
")",
":",
"if",
"part",
"in",
"self",
".",
"single_worker_queues",
":",
... | Get queue lock for max worker queues.
For max worker queues it returns a Lock if acquired and whether
it failed to acquire the lock. | [
"Get",
"queue",
"lock",
"for",
"max",
"worker",
"queues",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L385-L414 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._heartbeat | def _heartbeat(self, queue, task_ids):
"""
Updates the heartbeat for the given task IDs to prevent them from
timing out and being requeued.
"""
now = time.time()
self.connection.zadd(self._key(ACTIVE, queue),
**{task_id: now for task_id in tas... | python | def _heartbeat(self, queue, task_ids):
"""
Updates the heartbeat for the given task IDs to prevent them from
timing out and being requeued.
"""
now = time.time()
self.connection.zadd(self._key(ACTIVE, queue),
**{task_id: now for task_id in tas... | [
"def",
"_heartbeat",
"(",
"self",
",",
"queue",
",",
"task_ids",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"connection",
".",
"zadd",
"(",
"self",
".",
"_key",
"(",
"ACTIVE",
",",
"queue",
")",
",",
"**",
"{",
"task_id",
"... | Updates the heartbeat for the given task IDs to prevent them from
timing out and being requeued. | [
"Updates",
"the",
"heartbeat",
"for",
"the",
"given",
"task",
"IDs",
"to",
"prevent",
"them",
"from",
"timing",
"out",
"and",
"being",
"requeued",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L416-L423 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._execute | def _execute(self, queue, tasks, log, locks, queue_lock, all_task_ids):
"""
Executes the given tasks. Returns a boolean indicating whether
the tasks were executed successfully.
"""
# The tasks must use the same function.
assert len(tasks)
task_func = tasks[0].ser... | python | def _execute(self, queue, tasks, log, locks, queue_lock, all_task_ids):
"""
Executes the given tasks. Returns a boolean indicating whether
the tasks were executed successfully.
"""
# The tasks must use the same function.
assert len(tasks)
task_func = tasks[0].ser... | [
"def",
"_execute",
"(",
"self",
",",
"queue",
",",
"tasks",
",",
"log",
",",
"locks",
",",
"queue_lock",
",",
"all_task_ids",
")",
":",
"assert",
"len",
"(",
"tasks",
")",
"task_func",
"=",
"tasks",
"[",
"0",
"]",
".",
"serialized_func",
"assert",
"all... | Executes the given tasks. Returns a boolean indicating whether
the tasks were executed successfully. | [
"Executes",
"the",
"given",
"tasks",
".",
"Returns",
"a",
"boolean",
"indicating",
"whether",
"the",
"tasks",
"were",
"executed",
"successfully",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L425-L554 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._process_queue_message | def _process_queue_message(self, message_queue, new_queue_found, batch_exit,
start_time, timeout, batch_timeout):
"""Process a queue message from activity channel."""
for queue in self._filter_queues([message_queue]):
if queue not in self._queue_set:
... | python | def _process_queue_message(self, message_queue, new_queue_found, batch_exit,
start_time, timeout, batch_timeout):
"""Process a queue message from activity channel."""
for queue in self._filter_queues([message_queue]):
if queue not in self._queue_set:
... | [
"def",
"_process_queue_message",
"(",
"self",
",",
"message_queue",
",",
"new_queue_found",
",",
"batch_exit",
",",
"start_time",
",",
"timeout",
",",
"batch_timeout",
")",
":",
"for",
"queue",
"in",
"self",
".",
"_filter_queues",
"(",
"[",
"message_queue",
"]",... | Process a queue message from activity channel. | [
"Process",
"a",
"queue",
"message",
"from",
"activity",
"channel",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L556-L571 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._process_queue_tasks | def _process_queue_tasks(self, queue, queue_lock, task_ids, now, log):
"""Process tasks in queue."""
processed_count = 0
# Get all tasks
serialized_tasks = self.connection.mget([
self._key('task', task_id) for task_id in task_ids
])
# Parse tasks
ta... | python | def _process_queue_tasks(self, queue, queue_lock, task_ids, now, log):
"""Process tasks in queue."""
processed_count = 0
# Get all tasks
serialized_tasks = self.connection.mget([
self._key('task', task_id) for task_id in task_ids
])
# Parse tasks
ta... | [
"def",
"_process_queue_tasks",
"(",
"self",
",",
"queue",
",",
"queue_lock",
",",
"task_ids",
",",
"now",
",",
"log",
")",
":",
"processed_count",
"=",
"0",
"serialized_tasks",
"=",
"self",
".",
"connection",
".",
"mget",
"(",
"[",
"self",
".",
"_key",
"... | Process tasks in queue. | [
"Process",
"tasks",
"in",
"queue",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L573-L632 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._process_from_queue | def _process_from_queue(self, queue):
"""
Internal method to process a task batch from the given queue.
Args:
queue: Queue name to be processed
Returns:
Task IDs: List of tasks that were processed (even if there was an
error so that cli... | python | def _process_from_queue(self, queue):
"""
Internal method to process a task batch from the given queue.
Args:
queue: Queue name to be processed
Returns:
Task IDs: List of tasks that were processed (even if there was an
error so that cli... | [
"def",
"_process_from_queue",
"(",
"self",
",",
"queue",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"log",
"=",
"self",
".",
"log",
".",
"bind",
"(",
"queue",
"=",
"queue",
")",
"batch_size",
"=",
"self",
".",
"_get_queue_batch_size",
"(",
... | Internal method to process a task batch from the given queue.
Args:
queue: Queue name to be processed
Returns:
Task IDs: List of tasks that were processed (even if there was an
error so that client code can assume the queue is empty
... | [
"Internal",
"method",
"to",
"process",
"a",
"task",
"batch",
"from",
"the",
"given",
"queue",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L634-L690 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._execute_task_group | def _execute_task_group(self, queue, tasks, all_task_ids, queue_lock):
"""
Executes the given tasks in the queue. Updates the heartbeat for task
IDs passed in all_task_ids. This internal method is only meant to be
called from within _process_from_queue.
"""
log = self.log... | python | def _execute_task_group(self, queue, tasks, all_task_ids, queue_lock):
"""
Executes the given tasks in the queue. Updates the heartbeat for task
IDs passed in all_task_ids. This internal method is only meant to be
called from within _process_from_queue.
"""
log = self.log... | [
"def",
"_execute_task_group",
"(",
"self",
",",
"queue",
",",
"tasks",
",",
"all_task_ids",
",",
"queue_lock",
")",
":",
"log",
"=",
"self",
".",
"log",
".",
"bind",
"(",
"queue",
"=",
"queue",
")",
"locks",
"=",
"[",
"]",
"lock_ids",
"=",
"set",
"("... | Executes the given tasks in the queue. Updates the heartbeat for task
IDs passed in all_task_ids. This internal method is only meant to be
called from within _process_from_queue. | [
"Executes",
"the",
"given",
"tasks",
"in",
"the",
"queue",
".",
"Updates",
"the",
"heartbeat",
"for",
"task",
"IDs",
"passed",
"in",
"all_task_ids",
".",
"This",
"internal",
"method",
"is",
"only",
"meant",
"to",
"be",
"called",
"from",
"within",
"_process_f... | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L692-L757 | train |
closeio/tasktiger | tasktiger/worker.py | Worker._finish_task_processing | def _finish_task_processing(self, queue, task, success):
"""
After a task is executed, this method is called and ensures that
the task gets properly removed from the ACTIVE queue and, in case of an
error, retried or marked as failed.
"""
log = self.log.bind(queue=queue, t... | python | def _finish_task_processing(self, queue, task, success):
"""
After a task is executed, this method is called and ensures that
the task gets properly removed from the ACTIVE queue and, in case of an
error, retried or marked as failed.
"""
log = self.log.bind(queue=queue, t... | [
"def",
"_finish_task_processing",
"(",
"self",
",",
"queue",
",",
"task",
",",
"success",
")",
":",
"log",
"=",
"self",
".",
"log",
".",
"bind",
"(",
"queue",
"=",
"queue",
",",
"task_id",
"=",
"task",
".",
"id",
")",
"def",
"_mark_done",
"(",
")",
... | After a task is executed, this method is called and ensures that
the task gets properly removed from the ACTIVE queue and, in case of an
error, retried or marked as failed. | [
"After",
"a",
"task",
"is",
"executed",
"this",
"method",
"is",
"called",
"and",
"ensures",
"that",
"the",
"task",
"gets",
"properly",
"removed",
"from",
"the",
"ACTIVE",
"queue",
"and",
"in",
"case",
"of",
"an",
"error",
"retried",
"or",
"marked",
"as",
... | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L759-L859 | train |
closeio/tasktiger | tasktiger/worker.py | Worker.run | def run(self, once=False, force_once=False):
"""
Main loop of the worker.
Use once=True to execute any queued tasks and then exit.
Use force_once=True with once=True to always exit after one processing
loop even if tasks remain queued.
"""
self.log.info('ready',... | python | def run(self, once=False, force_once=False):
"""
Main loop of the worker.
Use once=True to execute any queued tasks and then exit.
Use force_once=True with once=True to always exit after one processing
loop even if tasks remain queued.
"""
self.log.info('ready',... | [
"def",
"run",
"(",
"self",
",",
"once",
"=",
"False",
",",
"force_once",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'ready'",
",",
"id",
"=",
"self",
".",
"id",
",",
"queues",
"=",
"sorted",
"(",
"self",
".",
"only_queues",
")... | Main loop of the worker.
Use once=True to execute any queued tasks and then exit.
Use force_once=True with once=True to always exit after one processing
loop even if tasks remain queued. | [
"Main",
"loop",
"of",
"the",
"worker",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/worker.py#L938-L1004 | train |
closeio/tasktiger | tasktiger/redis_scripts.py | RedisScripts.can_replicate_commands | def can_replicate_commands(self):
"""
Whether Redis supports single command replication.
"""
if not hasattr(self, '_can_replicate_commands'):
info = self.redis.info('server')
version_info = info['redis_version'].split('.')
major, minor = int(version_in... | python | def can_replicate_commands(self):
"""
Whether Redis supports single command replication.
"""
if not hasattr(self, '_can_replicate_commands'):
info = self.redis.info('server')
version_info = info['redis_version'].split('.')
major, minor = int(version_in... | [
"def",
"can_replicate_commands",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_can_replicate_commands'",
")",
":",
"info",
"=",
"self",
".",
"redis",
".",
"info",
"(",
"'server'",
")",
"version_info",
"=",
"info",
"[",
"'redis_version'"... | Whether Redis supports single command replication. | [
"Whether",
"Redis",
"supports",
"single",
"command",
"replication",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/redis_scripts.py#L301-L311 | train |
closeio/tasktiger | tasktiger/redis_scripts.py | RedisScripts.zpoppush | def zpoppush(self, source, destination, count, score, new_score,
client=None, withscores=False, on_success=None,
if_exists=None):
"""
Pops the first ``count`` members from the ZSET ``source`` and adds them
to the ZSET ``destination`` with a score of ``new_score`... | python | def zpoppush(self, source, destination, count, score, new_score,
client=None, withscores=False, on_success=None,
if_exists=None):
"""
Pops the first ``count`` members from the ZSET ``source`` and adds them
to the ZSET ``destination`` with a score of ``new_score`... | [
"def",
"zpoppush",
"(",
"self",
",",
"source",
",",
"destination",
",",
"count",
",",
"score",
",",
"new_score",
",",
"client",
"=",
"None",
",",
"withscores",
"=",
"False",
",",
"on_success",
"=",
"None",
",",
"if_exists",
"=",
"None",
")",
":",
"if",... | Pops the first ``count`` members from the ZSET ``source`` and adds them
to the ZSET ``destination`` with a score of ``new_score``. If ``score``
is not None, only members up to a score of ``score`` are used. Returns
the members that were moved and, if ``withscores`` is True, their
origina... | [
"Pops",
"the",
"first",
"count",
"members",
"from",
"the",
"ZSET",
"source",
"and",
"adds",
"them",
"to",
"the",
"ZSET",
"destination",
"with",
"a",
"score",
"of",
"new_score",
".",
"If",
"score",
"is",
"not",
"None",
"only",
"members",
"up",
"to",
"a",
... | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/redis_scripts.py#L339-L423 | train |
closeio/tasktiger | tasktiger/redis_scripts.py | RedisScripts.execute_pipeline | def execute_pipeline(self, pipeline, client=None):
"""
Executes the given Redis pipeline as a Lua script. When an error
occurs, the transaction stops executing, and an exception is raised.
This differs from Redis transactions, where execution continues after an
error. On success,... | python | def execute_pipeline(self, pipeline, client=None):
"""
Executes the given Redis pipeline as a Lua script. When an error
occurs, the transaction stops executing, and an exception is raised.
This differs from Redis transactions, where execution continues after an
error. On success,... | [
"def",
"execute_pipeline",
"(",
"self",
",",
"pipeline",
",",
"client",
"=",
"None",
")",
":",
"client",
"=",
"client",
"or",
"self",
".",
"redis",
"executing_pipeline",
"=",
"None",
"try",
":",
"stack",
"=",
"pipeline",
".",
"command_stack",
"script_args",
... | Executes the given Redis pipeline as a Lua script. When an error
occurs, the transaction stops executing, and an exception is raised.
This differs from Redis transactions, where execution continues after an
error. On success, a list of results is returned. The pipeline is
cleared after e... | [
"Executes",
"the",
"given",
"Redis",
"pipeline",
"as",
"a",
"Lua",
"script",
".",
"When",
"an",
"error",
"occurs",
"the",
"transaction",
"stops",
"executing",
"and",
"an",
"exception",
"is",
"raised",
".",
"This",
"differs",
"from",
"Redis",
"transactions",
... | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/redis_scripts.py#L466-L534 | train |
closeio/tasktiger | tasktiger/_internal.py | gen_unique_id | def gen_unique_id(serialized_name, args, kwargs):
"""
Generates and returns a hex-encoded 256-bit ID for the given task name and
args. Used to generate IDs for unique tasks or for task locks.
"""
return hashlib.sha256(json.dumps({
'func': serialized_name,
'args': args,
'kwarg... | python | def gen_unique_id(serialized_name, args, kwargs):
"""
Generates and returns a hex-encoded 256-bit ID for the given task name and
args. Used to generate IDs for unique tasks or for task locks.
"""
return hashlib.sha256(json.dumps({
'func': serialized_name,
'args': args,
'kwarg... | [
"def",
"gen_unique_id",
"(",
"serialized_name",
",",
"args",
",",
"kwargs",
")",
":",
"return",
"hashlib",
".",
"sha256",
"(",
"json",
".",
"dumps",
"(",
"{",
"'func'",
":",
"serialized_name",
",",
"'args'",
":",
"args",
",",
"'kwargs'",
":",
"kwargs",
"... | Generates and returns a hex-encoded 256-bit ID for the given task name and
args. Used to generate IDs for unique tasks or for task locks. | [
"Generates",
"and",
"returns",
"a",
"hex",
"-",
"encoded",
"256",
"-",
"bit",
"ID",
"for",
"the",
"given",
"task",
"name",
"and",
"args",
".",
"Used",
"to",
"generate",
"IDs",
"for",
"unique",
"tasks",
"or",
"for",
"task",
"locks",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/_internal.py#L56-L65 | train |
closeio/tasktiger | tasktiger/_internal.py | serialize_func_name | def serialize_func_name(func):
"""
Returns the dotted serialized path to the passed function.
"""
if func.__module__ == '__main__':
raise ValueError('Functions from the __main__ module cannot be '
'processed by workers.')
try:
# This will only work on Python ... | python | def serialize_func_name(func):
"""
Returns the dotted serialized path to the passed function.
"""
if func.__module__ == '__main__':
raise ValueError('Functions from the __main__ module cannot be '
'processed by workers.')
try:
# This will only work on Python ... | [
"def",
"serialize_func_name",
"(",
"func",
")",
":",
"if",
"func",
".",
"__module__",
"==",
"'__main__'",
":",
"raise",
"ValueError",
"(",
"'Functions from the __main__ module cannot be '",
"'processed by workers.'",
")",
"try",
":",
"func_name",
"=",
"func",
".",
"... | Returns the dotted serialized path to the passed function. | [
"Returns",
"the",
"dotted",
"serialized",
"path",
"to",
"the",
"passed",
"function",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/_internal.py#L67-L79 | train |
closeio/tasktiger | tasktiger/_internal.py | dotted_parts | def dotted_parts(s):
"""
For a string "a.b.c", yields "a", "a.b", "a.b.c".
"""
idx = -1
while s:
idx = s.find('.', idx+1)
if idx == -1:
yield s
break
yield s[:idx] | python | def dotted_parts(s):
"""
For a string "a.b.c", yields "a", "a.b", "a.b.c".
"""
idx = -1
while s:
idx = s.find('.', idx+1)
if idx == -1:
yield s
break
yield s[:idx] | [
"def",
"dotted_parts",
"(",
"s",
")",
":",
"idx",
"=",
"-",
"1",
"while",
"s",
":",
"idx",
"=",
"s",
".",
"find",
"(",
"'.'",
",",
"idx",
"+",
"1",
")",
"if",
"idx",
"==",
"-",
"1",
":",
"yield",
"s",
"break",
"yield",
"s",
"[",
":",
"idx",... | For a string "a.b.c", yields "a", "a.b", "a.b.c". | [
"For",
"a",
"string",
"a",
".",
"b",
".",
"c",
"yields",
"a",
"a",
".",
"b",
"a",
".",
"b",
".",
"c",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/_internal.py#L81-L91 | train |
closeio/tasktiger | tasktiger/_internal.py | reversed_dotted_parts | def reversed_dotted_parts(s):
"""
For a string "a.b.c", yields "a.b.c", "a.b", "a".
"""
idx = -1
if s:
yield s
while s:
idx = s.rfind('.', 0, idx)
if idx == -1:
break
yield s[:idx] | python | def reversed_dotted_parts(s):
"""
For a string "a.b.c", yields "a.b.c", "a.b", "a".
"""
idx = -1
if s:
yield s
while s:
idx = s.rfind('.', 0, idx)
if idx == -1:
break
yield s[:idx] | [
"def",
"reversed_dotted_parts",
"(",
"s",
")",
":",
"idx",
"=",
"-",
"1",
"if",
"s",
":",
"yield",
"s",
"while",
"s",
":",
"idx",
"=",
"s",
".",
"rfind",
"(",
"'.'",
",",
"0",
",",
"idx",
")",
"if",
"idx",
"==",
"-",
"1",
":",
"break",
"yield... | For a string "a.b.c", yields "a.b.c", "a.b", "a". | [
"For",
"a",
"string",
"a",
".",
"b",
".",
"c",
"yields",
"a",
".",
"b",
".",
"c",
"a",
".",
"b",
"a",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/_internal.py#L93-L104 | train |
closeio/tasktiger | tasktiger/logging.py | tasktiger_processor | def tasktiger_processor(logger, method_name, event_dict):
"""
TaskTiger structlog processor.
Inject the current task id for non-batch tasks.
"""
if g['current_tasks'] is not None and not g['current_task_is_batch']:
event_dict['task_id'] = g['current_tasks'][0].id
return event_dict | python | def tasktiger_processor(logger, method_name, event_dict):
"""
TaskTiger structlog processor.
Inject the current task id for non-batch tasks.
"""
if g['current_tasks'] is not None and not g['current_task_is_batch']:
event_dict['task_id'] = g['current_tasks'][0].id
return event_dict | [
"def",
"tasktiger_processor",
"(",
"logger",
",",
"method_name",
",",
"event_dict",
")",
":",
"if",
"g",
"[",
"'current_tasks'",
"]",
"is",
"not",
"None",
"and",
"not",
"g",
"[",
"'current_task_is_batch'",
"]",
":",
"event_dict",
"[",
"'task_id'",
"]",
"=",
... | TaskTiger structlog processor.
Inject the current task id for non-batch tasks. | [
"TaskTiger",
"structlog",
"processor",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/logging.py#L4-L14 | train |
closeio/tasktiger | tasktiger/task.py | Task.should_retry_on | def should_retry_on(self, exception_class, logger=None):
"""
Whether this task should be retried when the given exception occurs.
"""
for n in (self.retry_on or []):
try:
if issubclass(exception_class, import_attribute(n)):
return True
... | python | def should_retry_on(self, exception_class, logger=None):
"""
Whether this task should be retried when the given exception occurs.
"""
for n in (self.retry_on or []):
try:
if issubclass(exception_class, import_attribute(n)):
return True
... | [
"def",
"should_retry_on",
"(",
"self",
",",
"exception_class",
",",
"logger",
"=",
"None",
")",
":",
"for",
"n",
"in",
"(",
"self",
".",
"retry_on",
"or",
"[",
"]",
")",
":",
"try",
":",
"if",
"issubclass",
"(",
"exception_class",
",",
"import_attribute"... | Whether this task should be retried when the given exception occurs. | [
"Whether",
"this",
"task",
"should",
"be",
"retried",
"when",
"the",
"given",
"exception",
"occurs",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/task.py#L155-L167 | train |
closeio/tasktiger | tasktiger/task.py | Task.update_scheduled_time | def update_scheduled_time(self, when):
"""
Updates a scheduled task's date to the given date. If the task is not
scheduled, a TaskNotFound exception is raised.
"""
tiger = self.tiger
ts = get_timestamp(when)
assert ts
pipeline = tiger.connection.pipeline... | python | def update_scheduled_time(self, when):
"""
Updates a scheduled task's date to the given date. If the task is not
scheduled, a TaskNotFound exception is raised.
"""
tiger = self.tiger
ts = get_timestamp(when)
assert ts
pipeline = tiger.connection.pipeline... | [
"def",
"update_scheduled_time",
"(",
"self",
",",
"when",
")",
":",
"tiger",
"=",
"self",
".",
"tiger",
"ts",
"=",
"get_timestamp",
"(",
"when",
")",
"assert",
"ts",
"pipeline",
"=",
"tiger",
".",
"connection",
".",
"pipeline",
"(",
")",
"key",
"=",
"t... | Updates a scheduled task's date to the given date. If the task is not
scheduled, a TaskNotFound exception is raised. | [
"Updates",
"a",
"scheduled",
"task",
"s",
"date",
"to",
"the",
"given",
"date",
".",
"If",
"the",
"task",
"is",
"not",
"scheduled",
"a",
"TaskNotFound",
"exception",
"is",
"raised",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/task.py#L322-L342 | train |
closeio/tasktiger | tasktiger/task.py | Task.n_executions | def n_executions(self):
"""
Queries and returns the number of past task executions.
"""
pipeline = self.tiger.connection.pipeline()
pipeline.exists(self.tiger._key('task', self.id))
pipeline.llen(self.tiger._key('task', self.id, 'executions'))
exists, n_executions... | python | def n_executions(self):
"""
Queries and returns the number of past task executions.
"""
pipeline = self.tiger.connection.pipeline()
pipeline.exists(self.tiger._key('task', self.id))
pipeline.llen(self.tiger._key('task', self.id, 'executions'))
exists, n_executions... | [
"def",
"n_executions",
"(",
"self",
")",
":",
"pipeline",
"=",
"self",
".",
"tiger",
".",
"connection",
".",
"pipeline",
"(",
")",
"pipeline",
".",
"exists",
"(",
"self",
".",
"tiger",
".",
"_key",
"(",
"'task'",
",",
"self",
".",
"id",
")",
")",
"... | Queries and returns the number of past task executions. | [
"Queries",
"and",
"returns",
"the",
"number",
"of",
"past",
"task",
"executions",
"."
] | 59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a | https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/task.py#L421-L433 | train |
aewallin/allantools | allantools/noise_kasdin.py | Noise.set_input | def set_input(self, nr=2, qd=1, b=0):
""" Set inputs after initialization
Parameters
-------
nr: integer
length of generated time-series
number must be power of two
qd: float
discrete variance
b: float
noise type:
... | python | def set_input(self, nr=2, qd=1, b=0):
""" Set inputs after initialization
Parameters
-------
nr: integer
length of generated time-series
number must be power of two
qd: float
discrete variance
b: float
noise type:
... | [
"def",
"set_input",
"(",
"self",
",",
"nr",
"=",
"2",
",",
"qd",
"=",
"1",
",",
"b",
"=",
"0",
")",
":",
"self",
".",
"nr",
"=",
"nr",
"self",
".",
"qd",
"=",
"qd",
"self",
".",
"b",
"=",
"b"
] | Set inputs after initialization
Parameters
-------
nr: integer
length of generated time-series
number must be power of two
qd: float
discrete variance
b: float
noise type:
0 : White Phase Modulation (WPM)
... | [
"Set",
"inputs",
"after",
"initialization"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/noise_kasdin.py#L81-L102 | train |
aewallin/allantools | allantools/noise_kasdin.py | Noise.generateNoise | def generateNoise(self):
""" Generate noise time series based on input parameters
Returns
-------
time_series: np.array
Time series with colored noise.
len(time_series) == nr
"""
# Fill wfb array with white noise based on given discrete variance
... | python | def generateNoise(self):
""" Generate noise time series based on input parameters
Returns
-------
time_series: np.array
Time series with colored noise.
len(time_series) == nr
"""
# Fill wfb array with white noise based on given discrete variance
... | [
"def",
"generateNoise",
"(",
"self",
")",
":",
"wfb",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"nr",
"*",
"2",
")",
"wfb",
"[",
":",
"self",
".",
"nr",
"]",
"=",
"np",
".",
"random",
".",
"normal",
"(",
"0",
",",
"np",
".",
"sqrt",
"(",
"... | Generate noise time series based on input parameters
Returns
-------
time_series: np.array
Time series with colored noise.
len(time_series) == nr | [
"Generate",
"noise",
"time",
"series",
"based",
"on",
"input",
"parameters"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/noise_kasdin.py#L104-L130 | train |
aewallin/allantools | allantools/noise_kasdin.py | Noise.adev | def adev(self, tau0, tau):
""" return predicted ADEV of noise-type at given tau
"""
prefactor = self.adev_from_qd(tau0=tau0, tau=tau)
c = self.c_avar()
avar = pow(prefactor, 2)*pow(tau, c)
return np.sqrt(avar) | python | def adev(self, tau0, tau):
""" return predicted ADEV of noise-type at given tau
"""
prefactor = self.adev_from_qd(tau0=tau0, tau=tau)
c = self.c_avar()
avar = pow(prefactor, 2)*pow(tau, c)
return np.sqrt(avar) | [
"def",
"adev",
"(",
"self",
",",
"tau0",
",",
"tau",
")",
":",
"prefactor",
"=",
"self",
".",
"adev_from_qd",
"(",
"tau0",
"=",
"tau0",
",",
"tau",
"=",
"tau",
")",
"c",
"=",
"self",
".",
"c_avar",
"(",
")",
"avar",
"=",
"pow",
"(",
"prefactor",
... | return predicted ADEV of noise-type at given tau | [
"return",
"predicted",
"ADEV",
"of",
"noise",
"-",
"type",
"at",
"given",
"tau"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/noise_kasdin.py#L161-L168 | train |
aewallin/allantools | allantools/noise_kasdin.py | Noise.mdev | def mdev(self, tau0, tau):
""" return predicted MDEV of noise-type at given tau
"""
prefactor = self.mdev_from_qd(tau0=tau0, tau=tau)
c = self.c_mvar()
mvar = pow(prefactor, 2)*pow(tau, c)
return np.sqrt(mvar) | python | def mdev(self, tau0, tau):
""" return predicted MDEV of noise-type at given tau
"""
prefactor = self.mdev_from_qd(tau0=tau0, tau=tau)
c = self.c_mvar()
mvar = pow(prefactor, 2)*pow(tau, c)
return np.sqrt(mvar) | [
"def",
"mdev",
"(",
"self",
",",
"tau0",
",",
"tau",
")",
":",
"prefactor",
"=",
"self",
".",
"mdev_from_qd",
"(",
"tau0",
"=",
"tau0",
",",
"tau",
"=",
"tau",
")",
"c",
"=",
"self",
".",
"c_mvar",
"(",
")",
"mvar",
"=",
"pow",
"(",
"prefactor",
... | return predicted MDEV of noise-type at given tau | [
"return",
"predicted",
"MDEV",
"of",
"noise",
"-",
"type",
"at",
"given",
"tau"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/noise_kasdin.py#L170-L177 | train |
aewallin/allantools | allantools/noise.py | scipy_psd | def scipy_psd(x, f_sample=1.0, nr_segments=4):
""" PSD routine from scipy
we can compare our own numpy result against this one
"""
f_axis, psd_of_x = scipy.signal.welch(x, f_sample, nperseg=len(x)/nr_segments)
return f_axis, psd_of_x | python | def scipy_psd(x, f_sample=1.0, nr_segments=4):
""" PSD routine from scipy
we can compare our own numpy result against this one
"""
f_axis, psd_of_x = scipy.signal.welch(x, f_sample, nperseg=len(x)/nr_segments)
return f_axis, psd_of_x | [
"def",
"scipy_psd",
"(",
"x",
",",
"f_sample",
"=",
"1.0",
",",
"nr_segments",
"=",
"4",
")",
":",
"f_axis",
",",
"psd_of_x",
"=",
"scipy",
".",
"signal",
".",
"welch",
"(",
"x",
",",
"f_sample",
",",
"nperseg",
"=",
"len",
"(",
"x",
")",
"/",
"n... | PSD routine from scipy
we can compare our own numpy result against this one | [
"PSD",
"routine",
"from",
"scipy",
"we",
"can",
"compare",
"our",
"own",
"numpy",
"result",
"against",
"this",
"one"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/noise.py#L37-L42 | train |
aewallin/allantools | allantools/noise.py | iterpink | def iterpink(depth=20):
"""Generate a sequence of samples of pink noise.
pink noise generator
from http://pydoc.net/Python/lmj.sound/0.1.1/lmj.sound.noise/
Based on the Voss-McCartney algorithm, discussion and code examples at
http://www.firstpr.com.au/dsp/pink-noise/
depth: Use this many sam... | python | def iterpink(depth=20):
"""Generate a sequence of samples of pink noise.
pink noise generator
from http://pydoc.net/Python/lmj.sound/0.1.1/lmj.sound.noise/
Based on the Voss-McCartney algorithm, discussion and code examples at
http://www.firstpr.com.au/dsp/pink-noise/
depth: Use this many sam... | [
"def",
"iterpink",
"(",
"depth",
"=",
"20",
")",
":",
"values",
"=",
"numpy",
".",
"random",
".",
"randn",
"(",
"depth",
")",
"smooth",
"=",
"numpy",
".",
"random",
".",
"randn",
"(",
"depth",
")",
"source",
"=",
"numpy",
".",
"random",
".",
"randn... | Generate a sequence of samples of pink noise.
pink noise generator
from http://pydoc.net/Python/lmj.sound/0.1.1/lmj.sound.noise/
Based on the Voss-McCartney algorithm, discussion and code examples at
http://www.firstpr.com.au/dsp/pink-noise/
depth: Use this many samples of white noise to calculat... | [
"Generate",
"a",
"sequence",
"of",
"samples",
"of",
"pink",
"noise",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/noise.py#L85-L125 | train |
aewallin/allantools | examples/noise-color-demo.py | plotline | def plotline(plt, alpha, taus, style,label=""):
""" plot a line with the slope alpha """
y = [pow(tt, alpha) for tt in taus]
plt.loglog(taus, y, style,label=label) | python | def plotline(plt, alpha, taus, style,label=""):
""" plot a line with the slope alpha """
y = [pow(tt, alpha) for tt in taus]
plt.loglog(taus, y, style,label=label) | [
"def",
"plotline",
"(",
"plt",
",",
"alpha",
",",
"taus",
",",
"style",
",",
"label",
"=",
"\"\"",
")",
":",
"y",
"=",
"[",
"pow",
"(",
"tt",
",",
"alpha",
")",
"for",
"tt",
"in",
"taus",
"]",
"plt",
".",
"loglog",
"(",
"taus",
",",
"y",
",",... | plot a line with the slope alpha | [
"plot",
"a",
"line",
"with",
"the",
"slope",
"alpha"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/examples/noise-color-demo.py#L38-L41 | train |
aewallin/allantools | examples/b1_noise_id_figure.py | b1_noise_id | def b1_noise_id(x, af, rate):
""" B1 ratio for noise identification
ratio of Standard Variace to AVAR
"""
(taus,devs,errs,ns) = at.adev(x,taus=[af*rate],data_type="phase", rate=rate)
oadev_x = devs[0]
y = np.diff(x)
y_cut = np.array( y[:len(y)-(len(y)%af)] ) # cut to length
ass... | python | def b1_noise_id(x, af, rate):
""" B1 ratio for noise identification
ratio of Standard Variace to AVAR
"""
(taus,devs,errs,ns) = at.adev(x,taus=[af*rate],data_type="phase", rate=rate)
oadev_x = devs[0]
y = np.diff(x)
y_cut = np.array( y[:len(y)-(len(y)%af)] ) # cut to length
ass... | [
"def",
"b1_noise_id",
"(",
"x",
",",
"af",
",",
"rate",
")",
":",
"(",
"taus",
",",
"devs",
",",
"errs",
",",
"ns",
")",
"=",
"at",
".",
"adev",
"(",
"x",
",",
"taus",
"=",
"[",
"af",
"*",
"rate",
"]",
",",
"data_type",
"=",
"\"phase\"",
",",... | B1 ratio for noise identification
ratio of Standard Variace to AVAR | [
"B1",
"ratio",
"for",
"noise",
"identification",
"ratio",
"of",
"Standard",
"Variace",
"to",
"AVAR"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/examples/b1_noise_id_figure.py#L5-L19 | train |
aewallin/allantools | allantools/plot.py | Plot.plot | def plot(self, atDataset,
errorbars=False,
grid=False):
""" use matplotlib methods for plotting
Parameters
----------
atDataset : allantools.Dataset()
a dataset with computed data
errorbars : boolean
Plot errorbars. Defaults to F... | python | def plot(self, atDataset,
errorbars=False,
grid=False):
""" use matplotlib methods for plotting
Parameters
----------
atDataset : allantools.Dataset()
a dataset with computed data
errorbars : boolean
Plot errorbars. Defaults to F... | [
"def",
"plot",
"(",
"self",
",",
"atDataset",
",",
"errorbars",
"=",
"False",
",",
"grid",
"=",
"False",
")",
":",
"if",
"errorbars",
":",
"self",
".",
"ax",
".",
"errorbar",
"(",
"atDataset",
".",
"out",
"[",
"\"taus\"",
"]",
",",
"atDataset",
".",
... | use matplotlib methods for plotting
Parameters
----------
atDataset : allantools.Dataset()
a dataset with computed data
errorbars : boolean
Plot errorbars. Defaults to False
grid : boolean
Plot grid. Defaults to False | [
"use",
"matplotlib",
"methods",
"for",
"plotting"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/plot.py#L66-L92 | train |
aewallin/allantools | allantools/ci.py | greenhall_table2 | def greenhall_table2(alpha, d):
""" Table 2 from Greenhall 2004 """
row_idx = int(-alpha+2) # map 2-> row0 and -4-> row6
assert(row_idx in [0, 1, 2, 3, 4, 5])
col_idx = int(d-1)
table2 = [[(3.0/2.0, 1.0/2.0), (35.0/18.0, 1.0), (231.0/100.0, 3.0/2.0)], # alpha=+2
[(78.6, 25.2), (790.0, ... | python | def greenhall_table2(alpha, d):
""" Table 2 from Greenhall 2004 """
row_idx = int(-alpha+2) # map 2-> row0 and -4-> row6
assert(row_idx in [0, 1, 2, 3, 4, 5])
col_idx = int(d-1)
table2 = [[(3.0/2.0, 1.0/2.0), (35.0/18.0, 1.0), (231.0/100.0, 3.0/2.0)], # alpha=+2
[(78.6, 25.2), (790.0, ... | [
"def",
"greenhall_table2",
"(",
"alpha",
",",
"d",
")",
":",
"row_idx",
"=",
"int",
"(",
"-",
"alpha",
"+",
"2",
")",
"assert",
"(",
"row_idx",
"in",
"[",
"0",
",",
"1",
",",
"2",
",",
"3",
",",
"4",
",",
"5",
"]",
")",
"col_idx",
"=",
"int",... | Table 2 from Greenhall 2004 | [
"Table",
"2",
"from",
"Greenhall",
"2004"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/ci.py#L662-L676 | train |
aewallin/allantools | allantools/ci.py | greenhall_table1 | def greenhall_table1(alpha, d):
""" Table 1 from Greenhall 2004 """
row_idx = int(-alpha+2) # map 2-> row0 and -4-> row6
col_idx = int(d-1)
table1 = [[(2.0/3.0, 1.0/3.0), (7.0/9.0, 1.0/2.0), (22.0/25.0, 2.0/3.0)], # alpha=+2
[(0.840, 0.345), (0.997, 0.616), (1.141, 0.843)],
[... | python | def greenhall_table1(alpha, d):
""" Table 1 from Greenhall 2004 """
row_idx = int(-alpha+2) # map 2-> row0 and -4-> row6
col_idx = int(d-1)
table1 = [[(2.0/3.0, 1.0/3.0), (7.0/9.0, 1.0/2.0), (22.0/25.0, 2.0/3.0)], # alpha=+2
[(0.840, 0.345), (0.997, 0.616), (1.141, 0.843)],
[... | [
"def",
"greenhall_table1",
"(",
"alpha",
",",
"d",
")",
":",
"row_idx",
"=",
"int",
"(",
"-",
"alpha",
"+",
"2",
")",
"col_idx",
"=",
"int",
"(",
"d",
"-",
"1",
")",
"table1",
"=",
"[",
"[",
"(",
"2.0",
"/",
"3.0",
",",
"1.0",
"/",
"3.0",
")"... | Table 1 from Greenhall 2004 | [
"Table",
"1",
"from",
"Greenhall",
"2004"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/ci.py#L678-L691 | train |
aewallin/allantools | allantools/ci.py | edf_mtotdev | def edf_mtotdev(N, m, alpha):
""" Equivalent degrees of freedom for Modified Total Deviation
NIST SP1065 page 41, Table 8
"""
assert(alpha in [2, 1, 0, -1, -2])
NIST_SP1065_table8 = [(1.90, 2.1), (1.20, 1.40), (1.10, 1.2), (0.85, 0.50), (0.75, 0.31)]
#(b, c) = NIST_SP1065_table8[ abs(al... | python | def edf_mtotdev(N, m, alpha):
""" Equivalent degrees of freedom for Modified Total Deviation
NIST SP1065 page 41, Table 8
"""
assert(alpha in [2, 1, 0, -1, -2])
NIST_SP1065_table8 = [(1.90, 2.1), (1.20, 1.40), (1.10, 1.2), (0.85, 0.50), (0.75, 0.31)]
#(b, c) = NIST_SP1065_table8[ abs(al... | [
"def",
"edf_mtotdev",
"(",
"N",
",",
"m",
",",
"alpha",
")",
":",
"assert",
"(",
"alpha",
"in",
"[",
"2",
",",
"1",
",",
"0",
",",
"-",
"1",
",",
"-",
"2",
"]",
")",
"NIST_SP1065_table8",
"=",
"[",
"(",
"1.90",
",",
"2.1",
")",
",",
"(",
"1... | Equivalent degrees of freedom for Modified Total Deviation
NIST SP1065 page 41, Table 8 | [
"Equivalent",
"degrees",
"of",
"freedom",
"for",
"Modified",
"Total",
"Deviation",
"NIST",
"SP1065",
"page",
"41",
"Table",
"8"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/ci.py#L710-L721 | train |
aewallin/allantools | allantools/ci.py | edf_simple | def edf_simple(N, m, alpha):
"""Equivalent degrees of freedom.
Simple approximate formulae.
Parameters
----------
N : int
the number of phase samples
m : int
averaging factor, tau = m * tau0
alpha: int
exponent of f for the frequency PSD:
'wp' returns white p... | python | def edf_simple(N, m, alpha):
"""Equivalent degrees of freedom.
Simple approximate formulae.
Parameters
----------
N : int
the number of phase samples
m : int
averaging factor, tau = m * tau0
alpha: int
exponent of f for the frequency PSD:
'wp' returns white p... | [
"def",
"edf_simple",
"(",
"N",
",",
"m",
",",
"alpha",
")",
":",
"N",
"=",
"float",
"(",
"N",
")",
"m",
"=",
"float",
"(",
"m",
")",
"if",
"alpha",
"in",
"[",
"2",
",",
"1",
",",
"0",
",",
"-",
"1",
",",
"-",
"2",
"]",
":",
"if",
"alpha... | Equivalent degrees of freedom.
Simple approximate formulae.
Parameters
----------
N : int
the number of phase samples
m : int
averaging factor, tau = m * tau0
alpha: int
exponent of f for the frequency PSD:
'wp' returns white phase noise. alpha=+2
... | [
"Equivalent",
"degrees",
"of",
"freedom",
".",
"Simple",
"approximate",
"formulae",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/ci.py#L723-L789 | train |
aewallin/allantools | examples/gradev-demo.py | example1 | def example1():
"""
Compute the GRADEV of a white phase noise. Compares two different
scenarios. 1) The original data and 2) ADEV estimate with gap robust ADEV.
"""
N = 1000
f = 1
y = np.random.randn(1,N)[0,:]
x = [xx for xx in np.linspace(1,len(y),len(y))]
x_ax, y_ax, (err_l, err_h... | python | def example1():
"""
Compute the GRADEV of a white phase noise. Compares two different
scenarios. 1) The original data and 2) ADEV estimate with gap robust ADEV.
"""
N = 1000
f = 1
y = np.random.randn(1,N)[0,:]
x = [xx for xx in np.linspace(1,len(y),len(y))]
x_ax, y_ax, (err_l, err_h... | [
"def",
"example1",
"(",
")",
":",
"N",
"=",
"1000",
"f",
"=",
"1",
"y",
"=",
"np",
".",
"random",
".",
"randn",
"(",
"1",
",",
"N",
")",
"[",
"0",
",",
":",
"]",
"x",
"=",
"[",
"xx",
"for",
"xx",
"in",
"np",
".",
"linspace",
"(",
"1",
"... | Compute the GRADEV of a white phase noise. Compares two different
scenarios. 1) The original data and 2) ADEV estimate with gap robust ADEV. | [
"Compute",
"the",
"GRADEV",
"of",
"a",
"white",
"phase",
"noise",
".",
"Compares",
"two",
"different",
"scenarios",
".",
"1",
")",
"The",
"original",
"data",
"and",
"2",
")",
"ADEV",
"estimate",
"with",
"gap",
"robust",
"ADEV",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/examples/gradev-demo.py#L10-L32 | train |
aewallin/allantools | examples/gradev-demo.py | example2 | def example2():
"""
Compute the GRADEV of a nonstationary white phase noise.
"""
N=1000 # number of samples
f = 1 # data samples per second
s=1+5/N*np.arange(0,N)
y=s*np.random.randn(1,N)[0,:]
x = [xx for xx in np.linspace(1,len(y),len(y))]
x_ax, y_ax, (err_l, err_h) , ns = allan.gra... | python | def example2():
"""
Compute the GRADEV of a nonstationary white phase noise.
"""
N=1000 # number of samples
f = 1 # data samples per second
s=1+5/N*np.arange(0,N)
y=s*np.random.randn(1,N)[0,:]
x = [xx for xx in np.linspace(1,len(y),len(y))]
x_ax, y_ax, (err_l, err_h) , ns = allan.gra... | [
"def",
"example2",
"(",
")",
":",
"N",
"=",
"1000",
"f",
"=",
"1",
"s",
"=",
"1",
"+",
"5",
"/",
"N",
"*",
"np",
".",
"arange",
"(",
"0",
",",
"N",
")",
"y",
"=",
"s",
"*",
"np",
".",
"random",
".",
"randn",
"(",
"1",
",",
"N",
")",
"... | Compute the GRADEV of a nonstationary white phase noise. | [
"Compute",
"the",
"GRADEV",
"of",
"a",
"nonstationary",
"white",
"phase",
"noise",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/examples/gradev-demo.py#L34-L52 | train |
aewallin/allantools | allantools/allantools.py | tdev | def tdev(data, rate=1.0, data_type="phase", taus=None):
""" Time deviation.
Based on modified Allan variance.
.. math::
\\sigma^2_{TDEV}( \\tau ) = { \\tau^2 \\over 3 }
\\sigma^2_{MDEV}( \\tau )
Note that TDEV has a unit of seconds.
Parameters
----------
data: np.arra... | python | def tdev(data, rate=1.0, data_type="phase", taus=None):
""" Time deviation.
Based on modified Allan variance.
.. math::
\\sigma^2_{TDEV}( \\tau ) = { \\tau^2 \\over 3 }
\\sigma^2_{MDEV}( \\tau )
Note that TDEV has a unit of seconds.
Parameters
----------
data: np.arra... | [
"def",
"tdev",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"phase",
"=",
"input_to_phase",
"(",
"data",
",",
"rate",
",",
"data_type",
")",
"(",
"taus",
",",
"md",
",",
"mde",
",",
... | Time deviation.
Based on modified Allan variance.
.. math::
\\sigma^2_{TDEV}( \\tau ) = { \\tau^2 \\over 3 }
\\sigma^2_{MDEV}( \\tau )
Note that TDEV has a unit of seconds.
Parameters
----------
data: np.array
Input data. Provide either phase or frequency (fractio... | [
"Time",
"deviation",
".",
"Based",
"on",
"modified",
"Allan",
"variance",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L109-L155 | train |
aewallin/allantools | allantools/allantools.py | mdev | def mdev(data, rate=1.0, data_type="phase", taus=None):
""" Modified Allan deviation.
Used to distinguish between White and Flicker Phase Modulation.
.. math::
\\sigma^2_{MDEV}(m\\tau_0) = { 1 \\over 2 (m \\tau_0 )^2 (N-3m+1) }
\\sum_{j=1}^{N-3m+1} \\lbrace
\\sum_{i=j}^{j+m-1... | python | def mdev(data, rate=1.0, data_type="phase", taus=None):
""" Modified Allan deviation.
Used to distinguish between White and Flicker Phase Modulation.
.. math::
\\sigma^2_{MDEV}(m\\tau_0) = { 1 \\over 2 (m \\tau_0 )^2 (N-3m+1) }
\\sum_{j=1}^{N-3m+1} \\lbrace
\\sum_{i=j}^{j+m-1... | [
"def",
"mdev",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"phase",
"=",
"input_to_phase",
"(",
"data",
",",
"rate",
",",
"data_type",
")",
"(",
"phase",
",",
"ms",
",",
"taus_used",
... | Modified Allan deviation.
Used to distinguish between White and Flicker Phase Modulation.
.. math::
\\sigma^2_{MDEV}(m\\tau_0) = { 1 \\over 2 (m \\tau_0 )^2 (N-3m+1) }
\\sum_{j=1}^{N-3m+1} \\lbrace
\\sum_{i=j}^{j+m-1} {x}_{i+2m} - 2x_{i+m} + x_{i} \\rbrace^2
Parameters
--... | [
"Modified",
"Allan",
"deviation",
".",
"Used",
"to",
"distinguish",
"between",
"White",
"and",
"Flicker",
"Phase",
"Modulation",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L157-L245 | train |
aewallin/allantools | allantools/allantools.py | adev | def adev(data, rate=1.0, data_type="phase", taus=None):
""" Allan deviation.
Classic - use only if required - relatively poor confidence.
.. math::
\\sigma^2_{ADEV}(\\tau) = { 1 \\over 2 \\tau^2 }
\\langle ( {x}_{n+2} - 2x_{n+1} + x_{n} )^2 \\rangle
= { 1 \\over 2 (N-2) \\tau^2... | python | def adev(data, rate=1.0, data_type="phase", taus=None):
""" Allan deviation.
Classic - use only if required - relatively poor confidence.
.. math::
\\sigma^2_{ADEV}(\\tau) = { 1 \\over 2 \\tau^2 }
\\langle ( {x}_{n+2} - 2x_{n+1} + x_{n} )^2 \\rangle
= { 1 \\over 2 (N-2) \\tau^2... | [
"def",
"adev",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"phase",
"=",
"input_to_phase",
"(",
"data",
",",
"rate",
",",
"data_type",
")",
"(",
"phase",
",",
"m",
",",
"taus_used",
... | Allan deviation.
Classic - use only if required - relatively poor confidence.
.. math::
\\sigma^2_{ADEV}(\\tau) = { 1 \\over 2 \\tau^2 }
\\langle ( {x}_{n+2} - 2x_{n+1} + x_{n} )^2 \\rangle
= { 1 \\over 2 (N-2) \\tau^2 }
\\sum_{n=1}^{N-2} ( {x}_{n+2} - 2x_{n+1} + x_{n} )^2
... | [
"Allan",
"deviation",
".",
"Classic",
"-",
"use",
"only",
"if",
"required",
"-",
"relatively",
"poor",
"confidence",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L247-L311 | train |
aewallin/allantools | allantools/allantools.py | ohdev | def ohdev(data, rate=1.0, data_type="phase", taus=None):
""" Overlapping Hadamard deviation.
Better confidence than normal Hadamard.
.. math::
\\sigma^2_{OHDEV}(m\\tau_0) = { 1 \\over 6 (m \\tau_0 )^2 (N-3m) }
\\sum_{i=1}^{N-3m} ( {x}_{i+3m} - 3x_{i+2m} + 3x_{i+m} - x_{i} )^2
wher... | python | def ohdev(data, rate=1.0, data_type="phase", taus=None):
""" Overlapping Hadamard deviation.
Better confidence than normal Hadamard.
.. math::
\\sigma^2_{OHDEV}(m\\tau_0) = { 1 \\over 6 (m \\tau_0 )^2 (N-3m) }
\\sum_{i=1}^{N-3m} ( {x}_{i+3m} - 3x_{i+2m} + 3x_{i+m} - x_{i} )^2
wher... | [
"def",
"ohdev",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"phase",
"=",
"input_to_phase",
"(",
"data",
",",
"rate",
",",
"data_type",
")",
"(",
"phase",
",",
"m",
",",
"taus_used",
... | Overlapping Hadamard deviation.
Better confidence than normal Hadamard.
.. math::
\\sigma^2_{OHDEV}(m\\tau_0) = { 1 \\over 6 (m \\tau_0 )^2 (N-3m) }
\\sum_{i=1}^{N-3m} ( {x}_{i+3m} - 3x_{i+2m} + 3x_{i+m} - x_{i} )^2
where :math:`x_i` is the time-series of phase observations, spaced
... | [
"Overlapping",
"Hadamard",
"deviation",
".",
"Better",
"confidence",
"than",
"normal",
"Hadamard",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L420-L471 | train |
aewallin/allantools | allantools/allantools.py | calc_hdev_phase | def calc_hdev_phase(phase, rate, mj, stride):
""" main calculation fungtion for HDEV and OHDEV
Parameters
----------
phase: np.array
Phase data in seconds.
rate: float
The sampling rate for phase or frequency, in Hz
mj: int
M index value for stride
stride: int
... | python | def calc_hdev_phase(phase, rate, mj, stride):
""" main calculation fungtion for HDEV and OHDEV
Parameters
----------
phase: np.array
Phase data in seconds.
rate: float
The sampling rate for phase or frequency, in Hz
mj: int
M index value for stride
stride: int
... | [
"def",
"calc_hdev_phase",
"(",
"phase",
",",
"rate",
",",
"mj",
",",
"stride",
")",
":",
"tau0",
"=",
"1.0",
"/",
"float",
"(",
"rate",
")",
"mj",
"=",
"int",
"(",
"mj",
")",
"stride",
"=",
"int",
"(",
"stride",
")",
"d3",
"=",
"phase",
"[",
"3... | main calculation fungtion for HDEV and OHDEV
Parameters
----------
phase: np.array
Phase data in seconds.
rate: float
The sampling rate for phase or frequency, in Hz
mj: int
M index value for stride
stride: int
Size of stride
Returns
-------
(dev, de... | [
"main",
"calculation",
"fungtion",
"for",
"HDEV",
"and",
"OHDEV"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L515-L566 | train |
aewallin/allantools | allantools/allantools.py | totdev | def totdev(data, rate=1.0, data_type="phase", taus=None):
""" Total deviation.
Better confidence at long averages for Allan.
.. math::
\\sigma^2_{TOTDEV}( m\\tau_0 ) = { 1 \\over 2 (m\\tau_0)^2 (N-2) }
\\sum_{i=2}^{N-1} ( {x}^*_{i-m} - 2x^*_{i} + x^*_{i+m} )^2
Where :math:`x^... | python | def totdev(data, rate=1.0, data_type="phase", taus=None):
""" Total deviation.
Better confidence at long averages for Allan.
.. math::
\\sigma^2_{TOTDEV}( m\\tau_0 ) = { 1 \\over 2 (m\\tau_0)^2 (N-2) }
\\sum_{i=2}^{N-1} ( {x}^*_{i-m} - 2x^*_{i} + x^*_{i+m} )^2
Where :math:`x^... | [
"def",
"totdev",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"phase",
"=",
"input_to_phase",
"(",
"data",
",",
"rate",
",",
"data_type",
")",
"(",
"phase",
",",
"m",
",",
"taus_used",
... | Total deviation.
Better confidence at long averages for Allan.
.. math::
\\sigma^2_{TOTDEV}( m\\tau_0 ) = { 1 \\over 2 (m\\tau_0)^2 (N-2) }
\\sum_{i=2}^{N-1} ( {x}^*_{i-m} - 2x^*_{i} + x^*_{i+m} )^2
Where :math:`x^*_i` is a new time-series of length :math:`3N-4`
derived from ... | [
"Total",
"deviation",
".",
"Better",
"confidence",
"at",
"long",
"averages",
"for",
"Allan",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L568-L660 | train |
aewallin/allantools | allantools/allantools.py | mtotdev | def mtotdev(data, rate=1.0, data_type="phase", taus=None):
""" PRELIMINARY - REQUIRES FURTHER TESTING.
Modified Total deviation.
Better confidence at long averages for modified Allan
FIXME: bias-correction http://www.wriley.com/CI2.pdf page 6
The variance is scaled up (divided by t... | python | def mtotdev(data, rate=1.0, data_type="phase", taus=None):
""" PRELIMINARY - REQUIRES FURTHER TESTING.
Modified Total deviation.
Better confidence at long averages for modified Allan
FIXME: bias-correction http://www.wriley.com/CI2.pdf page 6
The variance is scaled up (divided by t... | [
"def",
"mtotdev",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"phase",
"=",
"input_to_phase",
"(",
"data",
",",
"rate",
",",
"data_type",
")",
"(",
"phase",
",",
"ms",
",",
"taus_used"... | PRELIMINARY - REQUIRES FURTHER TESTING.
Modified Total deviation.
Better confidence at long averages for modified Allan
FIXME: bias-correction http://www.wriley.com/CI2.pdf page 6
The variance is scaled up (divided by this number) based on the
noise-type identified.
WPM... | [
"PRELIMINARY",
"-",
"REQUIRES",
"FURTHER",
"TESTING",
".",
"Modified",
"Total",
"deviation",
".",
"Better",
"confidence",
"at",
"long",
"averages",
"for",
"modified",
"Allan"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L674-L716 | train |
aewallin/allantools | allantools/allantools.py | htotdev | def htotdev(data, rate=1.0, data_type="phase", taus=None):
""" PRELIMINARY - REQUIRES FURTHER TESTING.
Hadamard Total deviation.
Better confidence at long averages for Hadamard deviation
FIXME: bias corrections from http://www.wriley.com/CI2.pdf
W FM 0.995 alpha= 0
F... | python | def htotdev(data, rate=1.0, data_type="phase", taus=None):
""" PRELIMINARY - REQUIRES FURTHER TESTING.
Hadamard Total deviation.
Better confidence at long averages for Hadamard deviation
FIXME: bias corrections from http://www.wriley.com/CI2.pdf
W FM 0.995 alpha= 0
F... | [
"def",
"htotdev",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"if",
"data_type",
"==",
"\"phase\"",
":",
"phase",
"=",
"data",
"freq",
"=",
"phase2frequency",
"(",
"phase",
",",
"rate",
... | PRELIMINARY - REQUIRES FURTHER TESTING.
Hadamard Total deviation.
Better confidence at long averages for Hadamard deviation
FIXME: bias corrections from http://www.wriley.com/CI2.pdf
W FM 0.995 alpha= 0
F FM 0.851 alpha=-1
RW FM 0.771 alpha=-2
... | [
"PRELIMINARY",
"-",
"REQUIRES",
"FURTHER",
"TESTING",
".",
"Hadamard",
"Total",
"deviation",
".",
"Better",
"confidence",
"at",
"long",
"averages",
"for",
"Hadamard",
"deviation"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L787-L847 | train |
aewallin/allantools | allantools/allantools.py | theo1 | def theo1(data, rate=1.0, data_type="phase", taus=None):
""" PRELIMINARY - REQUIRES FURTHER TESTING.
Theo1 is a two-sample variance with improved confidence and
extended averaging factor range.
.. math::
\\sigma^2_{THEO1}(m\\tau_0) = { 1 \\over (m \\tau_0 )^2 (N-m) }
... | python | def theo1(data, rate=1.0, data_type="phase", taus=None):
""" PRELIMINARY - REQUIRES FURTHER TESTING.
Theo1 is a two-sample variance with improved confidence and
extended averaging factor range.
.. math::
\\sigma^2_{THEO1}(m\\tau_0) = { 1 \\over (m \\tau_0 )^2 (N-m) }
... | [
"def",
"theo1",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"phase",
"=",
"input_to_phase",
"(",
"data",
",",
"rate",
",",
"data_type",
")",
"tau0",
"=",
"1.0",
"/",
"rate",
"(",
"ph... | PRELIMINARY - REQUIRES FURTHER TESTING.
Theo1 is a two-sample variance with improved confidence and
extended averaging factor range.
.. math::
\\sigma^2_{THEO1}(m\\tau_0) = { 1 \\over (m \\tau_0 )^2 (N-m) }
\\sum_{i=1}^{N-m} \\sum_{\\delta=0}^{m/2-1}
... | [
"PRELIMINARY",
"-",
"REQUIRES",
"FURTHER",
"TESTING",
".",
"Theo1",
"is",
"a",
"two",
"-",
"sample",
"variance",
"with",
"improved",
"confidence",
"and",
"extended",
"averaging",
"factor",
"range",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L919-L987 | train |
aewallin/allantools | allantools/allantools.py | tierms | def tierms(data, rate=1.0, data_type="phase", taus=None):
""" Time Interval Error RMS.
Parameters
----------
data: np.array
Input data. Provide either phase or frequency (fractional,
adimensional).
rate: float
The sampling rate for data, in Hz. Defaults to 1.0
data_type:... | python | def tierms(data, rate=1.0, data_type="phase", taus=None):
""" Time Interval Error RMS.
Parameters
----------
data: np.array
Input data. Provide either phase or frequency (fractional,
adimensional).
rate: float
The sampling rate for data, in Hz. Defaults to 1.0
data_type:... | [
"def",
"tierms",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"phase",
"=",
"input_to_phase",
"(",
"data",
",",
"rate",
",",
"data_type",
")",
"(",
"data",
",",
"m",
",",
"taus_used",
... | Time Interval Error RMS.
Parameters
----------
data: np.array
Input data. Provide either phase or frequency (fractional,
adimensional).
rate: float
The sampling rate for data, in Hz. Defaults to 1.0
data_type: {'phase', 'freq'}
Data type, i.e. phase or frequency. Def... | [
"Time",
"Interval",
"Error",
"RMS",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L990-L1033 | train |
aewallin/allantools | allantools/allantools.py | mtie | def mtie(data, rate=1.0, data_type="phase", taus=None):
""" Maximum Time Interval Error.
Parameters
----------
data: np.array
Input data. Provide either phase or frequency (fractional,
adimensional).
rate: float
The sampling rate for data, in Hz. Defaults to 1.0
data_typ... | python | def mtie(data, rate=1.0, data_type="phase", taus=None):
""" Maximum Time Interval Error.
Parameters
----------
data: np.array
Input data. Provide either phase or frequency (fractional,
adimensional).
rate: float
The sampling rate for data, in Hz. Defaults to 1.0
data_typ... | [
"def",
"mtie",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"phase",
"=",
"input_to_phase",
"(",
"data",
",",
"rate",
",",
"data_type",
")",
"(",
"phase",
",",
"m",
",",
"taus_used",
... | Maximum Time Interval Error.
Parameters
----------
data: np.array
Input data. Provide either phase or frequency (fractional,
adimensional).
rate: float
The sampling rate for data, in Hz. Defaults to 1.0
data_type: {'phase', 'freq'}
Data type, i.e. phase or frequency.... | [
"Maximum",
"Time",
"Interval",
"Error",
"."
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L1061-L1101 | train |
aewallin/allantools | allantools/allantools.py | mtie_phase_fast | def mtie_phase_fast(phase, rate=1.0, data_type="phase", taus=None):
""" fast binary decomposition algorithm for MTIE
See: STEFANO BREGNI "Fast Algorithms for TVAR and MTIE Computation in
Characterization of Network Synchronization Performance"
"""
rate = float(rate)
phase = np.asarray(p... | python | def mtie_phase_fast(phase, rate=1.0, data_type="phase", taus=None):
""" fast binary decomposition algorithm for MTIE
See: STEFANO BREGNI "Fast Algorithms for TVAR and MTIE Computation in
Characterization of Network Synchronization Performance"
"""
rate = float(rate)
phase = np.asarray(p... | [
"def",
"mtie_phase_fast",
"(",
"phase",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
")",
":",
"rate",
"=",
"float",
"(",
"rate",
")",
"phase",
"=",
"np",
".",
"asarray",
"(",
"phase",
")",
"k_max",
"=",
"i... | fast binary decomposition algorithm for MTIE
See: STEFANO BREGNI "Fast Algorithms for TVAR and MTIE Computation in
Characterization of Network Synchronization Performance" | [
"fast",
"binary",
"decomposition",
"algorithm",
"for",
"MTIE"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L1108-L1163 | train |
aewallin/allantools | allantools/allantools.py | gradev | def gradev(data, rate=1.0, data_type="phase", taus=None,
ci=0.9, noisetype='wp'):
""" gap resistant overlapping Allan deviation
Parameters
----------
data: np.array
Input data. Provide either phase or frequency (fractional,
adimensional). Warning : phase data works better (fr... | python | def gradev(data, rate=1.0, data_type="phase", taus=None,
ci=0.9, noisetype='wp'):
""" gap resistant overlapping Allan deviation
Parameters
----------
data: np.array
Input data. Provide either phase or frequency (fractional,
adimensional). Warning : phase data works better (fr... | [
"def",
"gradev",
"(",
"data",
",",
"rate",
"=",
"1.0",
",",
"data_type",
"=",
"\"phase\"",
",",
"taus",
"=",
"None",
",",
"ci",
"=",
"0.9",
",",
"noisetype",
"=",
"'wp'",
")",
":",
"if",
"(",
"data_type",
"==",
"\"freq\"",
")",
":",
"print",
"(",
... | gap resistant overlapping Allan deviation
Parameters
----------
data: np.array
Input data. Provide either phase or frequency (fractional,
adimensional). Warning : phase data works better (frequency data is
first trantformed into phase using numpy.cumsum() function, which can
... | [
"gap",
"resistant",
"overlapping",
"Allan",
"deviation"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L1173-L1242 | train |
aewallin/allantools | allantools/allantools.py | input_to_phase | def input_to_phase(data, rate, data_type):
""" Take either phase or frequency as input and return phase
"""
if data_type == "phase":
return data
elif data_type == "freq":
return frequency2phase(data, rate)
else:
raise Exception("unknown data_type: " + data_type) | python | def input_to_phase(data, rate, data_type):
""" Take either phase or frequency as input and return phase
"""
if data_type == "phase":
return data
elif data_type == "freq":
return frequency2phase(data, rate)
else:
raise Exception("unknown data_type: " + data_type) | [
"def",
"input_to_phase",
"(",
"data",
",",
"rate",
",",
"data_type",
")",
":",
"if",
"data_type",
"==",
"\"phase\"",
":",
"return",
"data",
"elif",
"data_type",
"==",
"\"freq\"",
":",
"return",
"frequency2phase",
"(",
"data",
",",
"rate",
")",
"else",
":",... | Take either phase or frequency as input and return phase | [
"Take",
"either",
"phase",
"or",
"frequency",
"as",
"input",
"and",
"return",
"phase"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L1297-L1305 | train |
aewallin/allantools | allantools/allantools.py | trim_data | def trim_data(x):
"""
Trim leading and trailing NaNs from dataset
This is done by browsing the array from each end and store the index of the
first non-NaN in each case, the return the appropriate slice of the array
"""
# Find indices for first and last valid data
first = 0
while np.isna... | python | def trim_data(x):
"""
Trim leading and trailing NaNs from dataset
This is done by browsing the array from each end and store the index of the
first non-NaN in each case, the return the appropriate slice of the array
"""
# Find indices for first and last valid data
first = 0
while np.isna... | [
"def",
"trim_data",
"(",
"x",
")",
":",
"first",
"=",
"0",
"while",
"np",
".",
"isnan",
"(",
"x",
"[",
"first",
"]",
")",
":",
"first",
"+=",
"1",
"last",
"=",
"len",
"(",
"x",
")",
"while",
"np",
".",
"isnan",
"(",
"x",
"[",
"last",
"-",
"... | Trim leading and trailing NaNs from dataset
This is done by browsing the array from each end and store the index of the
first non-NaN in each case, the return the appropriate slice of the array | [
"Trim",
"leading",
"and",
"trailing",
"NaNs",
"from",
"dataset",
"This",
"is",
"done",
"by",
"browsing",
"the",
"array",
"from",
"each",
"end",
"and",
"store",
"the",
"index",
"of",
"the",
"first",
"non",
"-",
"NaN",
"in",
"each",
"case",
"the",
"return"... | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L1498-L1511 | train |
aewallin/allantools | allantools/allantools.py | three_cornered_hat_phase | def three_cornered_hat_phase(phasedata_ab, phasedata_bc,
phasedata_ca, rate, taus, function):
"""
Three Cornered Hat Method
Given three clocks A, B, C, we seek to find their variances
:math:`\\sigma^2_A`, :math:`\\sigma^2_B`, :math:`\\sigma^2_C`.
We measure three phase ... | python | def three_cornered_hat_phase(phasedata_ab, phasedata_bc,
phasedata_ca, rate, taus, function):
"""
Three Cornered Hat Method
Given three clocks A, B, C, we seek to find their variances
:math:`\\sigma^2_A`, :math:`\\sigma^2_B`, :math:`\\sigma^2_C`.
We measure three phase ... | [
"def",
"three_cornered_hat_phase",
"(",
"phasedata_ab",
",",
"phasedata_bc",
",",
"phasedata_ca",
",",
"rate",
",",
"taus",
",",
"function",
")",
":",
"(",
"tau_ab",
",",
"dev_ab",
",",
"err_ab",
",",
"ns_ab",
")",
"=",
"function",
"(",
"phasedata_ab",
",",
... | Three Cornered Hat Method
Given three clocks A, B, C, we seek to find their variances
:math:`\\sigma^2_A`, :math:`\\sigma^2_B`, :math:`\\sigma^2_C`.
We measure three phase differences, assuming no correlation between
the clocks, the measurements have variances:
.. math::
\\sigma^2_{AB} = ... | [
"Three",
"Cornered",
"Hat",
"Method"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L1513-L1588 | train |
aewallin/allantools | allantools/allantools.py | frequency2phase | def frequency2phase(freqdata, rate):
""" integrate fractional frequency data and output phase data
Parameters
----------
freqdata: np.array
Data array of fractional frequency measurements (nondimensional)
rate: float
The sampling rate for phase or frequency, in Hz
Returns
-... | python | def frequency2phase(freqdata, rate):
""" integrate fractional frequency data and output phase data
Parameters
----------
freqdata: np.array
Data array of fractional frequency measurements (nondimensional)
rate: float
The sampling rate for phase or frequency, in Hz
Returns
-... | [
"def",
"frequency2phase",
"(",
"freqdata",
",",
"rate",
")",
":",
"dt",
"=",
"1.0",
"/",
"float",
"(",
"rate",
")",
"freqdata",
"=",
"trim_data",
"(",
"freqdata",
")",
"phasedata",
"=",
"np",
".",
"cumsum",
"(",
"freqdata",
")",
"*",
"dt",
"phasedata",... | integrate fractional frequency data and output phase data
Parameters
----------
freqdata: np.array
Data array of fractional frequency measurements (nondimensional)
rate: float
The sampling rate for phase or frequency, in Hz
Returns
-------
phasedata: np.array
Time i... | [
"integrate",
"fractional",
"frequency",
"data",
"and",
"output",
"phase",
"data"
] | b5c695a5af4379fcea4d4ce93a066cb902e7ee0a | https://github.com/aewallin/allantools/blob/b5c695a5af4379fcea4d4ce93a066cb902e7ee0a/allantools/allantools.py#L1595-L1619 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.