id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
14,100 | rootpy/rootpy | rootpy/decorators.py | method_file_check | def method_file_check(f):
"""
A decorator to check that a TFile as been created before f is called.
This function can decorate methods.
This requires special treatment since in Python 3 unbound methods are
just functions: http://stackoverflow.com/a/3589335/1002176 but to get
consistent access t... | python | def method_file_check(f):
"""
A decorator to check that a TFile as been created before f is called.
This function can decorate methods.
This requires special treatment since in Python 3 unbound methods are
just functions: http://stackoverflow.com/a/3589335/1002176 but to get
consistent access t... | [
"def",
"method_file_check",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"curr_dir",
"=",
"ROOT",
".",
"gDirectory",
"if",
"isinstance",
"(",
"curr_dir",
",",
"... | A decorator to check that a TFile as been created before f is called.
This function can decorate methods.
This requires special treatment since in Python 3 unbound methods are
just functions: http://stackoverflow.com/a/3589335/1002176 but to get
consistent access to the class in both 2.x and 3.x, we ne... | [
"A",
"decorator",
"to",
"check",
"that",
"a",
"TFile",
"as",
"been",
"created",
"before",
"f",
"is",
"called",
".",
"This",
"function",
"can",
"decorate",
"methods",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/decorators.py#L64-L86 |
14,101 | rootpy/rootpy | rootpy/decorators.py | chainable | def chainable(f):
"""
Decorator which causes a 'void' function to return self
Allows chaining of multiple modifier class methods.
"""
@wraps(f)
def wrapper(self, *args, **kwargs):
# perform action
f(self, *args, **kwargs)
# return reference to class.
return self
... | python | def chainable(f):
"""
Decorator which causes a 'void' function to return self
Allows chaining of multiple modifier class methods.
"""
@wraps(f)
def wrapper(self, *args, **kwargs):
# perform action
f(self, *args, **kwargs)
# return reference to class.
return self
... | [
"def",
"chainable",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# perform action",
"f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# re... | Decorator which causes a 'void' function to return self
Allows chaining of multiple modifier class methods. | [
"Decorator",
"which",
"causes",
"a",
"void",
"function",
"to",
"return",
"self"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/decorators.py#L103-L115 |
14,102 | rootpy/rootpy | rootpy/decorators.py | snake_case_methods | def snake_case_methods(cls, debug=False):
"""
A class decorator adding snake_case methods
that alias capitalized ROOT methods. cls must subclass
a ROOT class and define the _ROOT class variable.
"""
if not CONVERT_SNAKE_CASE:
return cls
# get the ROOT base class
root_base = cls._... | python | def snake_case_methods(cls, debug=False):
"""
A class decorator adding snake_case methods
that alias capitalized ROOT methods. cls must subclass
a ROOT class and define the _ROOT class variable.
"""
if not CONVERT_SNAKE_CASE:
return cls
# get the ROOT base class
root_base = cls._... | [
"def",
"snake_case_methods",
"(",
"cls",
",",
"debug",
"=",
"False",
")",
":",
"if",
"not",
"CONVERT_SNAKE_CASE",
":",
"return",
"cls",
"# get the ROOT base class",
"root_base",
"=",
"cls",
".",
"_ROOT",
"members",
"=",
"inspect",
".",
"getmembers",
"(",
"root... | A class decorator adding snake_case methods
that alias capitalized ROOT methods. cls must subclass
a ROOT class and define the _ROOT class variable. | [
"A",
"class",
"decorator",
"adding",
"snake_case",
"methods",
"that",
"alias",
"capitalized",
"ROOT",
"methods",
".",
"cls",
"must",
"subclass",
"a",
"ROOT",
"class",
"and",
"define",
"the",
"_ROOT",
"class",
"variable",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/decorators.py#L131-L184 |
14,103 | rootpy/rootpy | rootpy/decorators.py | sync | def sync(lock):
"""
A synchronization decorator
"""
def sync(f):
@wraps(f)
def new_function(*args, **kwargs):
lock.acquire()
try:
return f(*args, **kwargs)
finally:
lock.release()
return new_function
return s... | python | def sync(lock):
"""
A synchronization decorator
"""
def sync(f):
@wraps(f)
def new_function(*args, **kwargs):
lock.acquire()
try:
return f(*args, **kwargs)
finally:
lock.release()
return new_function
return s... | [
"def",
"sync",
"(",
"lock",
")",
":",
"def",
"sync",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"new_function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lock",
".",
"acquire",
"(",
")",
"try",
":",
"return",
"f",
"("... | A synchronization decorator | [
"A",
"synchronization",
"decorator"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/decorators.py#L187-L200 |
14,104 | rootpy/rootpy | rootpy/stats/correlated_values.py | as_ufloat | def as_ufloat(roorealvar):
"""
Cast a `RooRealVar` to an `uncertainties.ufloat`
"""
if isinstance(roorealvar, (U.AffineScalarFunc, U.Variable)):
return roorealvar
return U.ufloat((roorealvar.getVal(), roorealvar.getError())) | python | def as_ufloat(roorealvar):
"""
Cast a `RooRealVar` to an `uncertainties.ufloat`
"""
if isinstance(roorealvar, (U.AffineScalarFunc, U.Variable)):
return roorealvar
return U.ufloat((roorealvar.getVal(), roorealvar.getError())) | [
"def",
"as_ufloat",
"(",
"roorealvar",
")",
":",
"if",
"isinstance",
"(",
"roorealvar",
",",
"(",
"U",
".",
"AffineScalarFunc",
",",
"U",
".",
"Variable",
")",
")",
":",
"return",
"roorealvar",
"return",
"U",
".",
"ufloat",
"(",
"(",
"roorealvar",
".",
... | Cast a `RooRealVar` to an `uncertainties.ufloat` | [
"Cast",
"a",
"RooRealVar",
"to",
"an",
"uncertainties",
".",
"ufloat"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/correlated_values.py#L13-L19 |
14,105 | rootpy/rootpy | rootpy/stats/correlated_values.py | correlated_values | def correlated_values(param_names, roofitresult):
"""
Return symbolic values from a `RooFitResult` taking into account covariance
This is useful for numerically computing the uncertainties for expressions
using correlated values arising from a fit.
Parameters
----------
param_names: list ... | python | def correlated_values(param_names, roofitresult):
"""
Return symbolic values from a `RooFitResult` taking into account covariance
This is useful for numerically computing the uncertainties for expressions
using correlated values arising from a fit.
Parameters
----------
param_names: list ... | [
"def",
"correlated_values",
"(",
"param_names",
",",
"roofitresult",
")",
":",
"pars",
"=",
"roofitresult",
".",
"floatParsFinal",
"(",
")",
"#pars.Print()",
"pars",
"=",
"[",
"pars",
"[",
"i",
"]",
"for",
"i",
"in",
"range",
"(",
"pars",
".",
"getSize",
... | Return symbolic values from a `RooFitResult` taking into account covariance
This is useful for numerically computing the uncertainties for expressions
using correlated values arising from a fit.
Parameters
----------
param_names: list of strings
A list of parameters to extract from the re... | [
"Return",
"symbolic",
"values",
"from",
"a",
"RooFitResult",
"taking",
"into",
"account",
"covariance"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/correlated_values.py#L22-L75 |
14,106 | rootpy/rootpy | rootpy/tree/treemodel.py | TreeModelMeta.checkattr | def checkattr(metacls, attr, value):
"""
Only allow class attributes that are instances of
rootpy.types.Column, ROOT.TObject, or ROOT.ObjectProxy
"""
if not isinstance(value, (
types.MethodType,
types.FunctionType,
classmethod,
... | python | def checkattr(metacls, attr, value):
"""
Only allow class attributes that are instances of
rootpy.types.Column, ROOT.TObject, or ROOT.ObjectProxy
"""
if not isinstance(value, (
types.MethodType,
types.FunctionType,
classmethod,
... | [
"def",
"checkattr",
"(",
"metacls",
",",
"attr",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"types",
".",
"MethodType",
",",
"types",
".",
"FunctionType",
",",
"classmethod",
",",
"staticmethod",
",",
"property",
")",
")",... | Only allow class attributes that are instances of
rootpy.types.Column, ROOT.TObject, or ROOT.ObjectProxy | [
"Only",
"allow",
"class",
"attributes",
"that",
"are",
"instances",
"of",
"rootpy",
".",
"types",
".",
"Column",
"ROOT",
".",
"TObject",
"or",
"ROOT",
".",
"ObjectProxy"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treemodel.py#L53-L82 |
14,107 | rootpy/rootpy | rootpy/tree/treemodel.py | TreeModelMeta.prefix | def prefix(cls, name):
"""
Create a new TreeModel where class attribute
names are prefixed with ``name``
"""
attrs = dict([(name + attr, value) for attr, value in cls.get_attrs()])
return TreeModelMeta(
'_'.join([name, cls.__name__]),
(TreeModel,),... | python | def prefix(cls, name):
"""
Create a new TreeModel where class attribute
names are prefixed with ``name``
"""
attrs = dict([(name + attr, value) for attr, value in cls.get_attrs()])
return TreeModelMeta(
'_'.join([name, cls.__name__]),
(TreeModel,),... | [
"def",
"prefix",
"(",
"cls",
",",
"name",
")",
":",
"attrs",
"=",
"dict",
"(",
"[",
"(",
"name",
"+",
"attr",
",",
"value",
")",
"for",
"attr",
",",
"value",
"in",
"cls",
".",
"get_attrs",
"(",
")",
"]",
")",
"return",
"TreeModelMeta",
"(",
"'_'"... | Create a new TreeModel where class attribute
names are prefixed with ``name`` | [
"Create",
"a",
"new",
"TreeModel",
"where",
"class",
"attribute",
"names",
"are",
"prefixed",
"with",
"name"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treemodel.py#L84-L92 |
14,108 | rootpy/rootpy | rootpy/tree/treemodel.py | TreeModelMeta.get_attrs | def get_attrs(cls):
"""
Get all class attributes ordered by definition
"""
ignore = dir(type('dummy', (object,), {})) + ['__metaclass__']
attrs = [
item for item in inspect.getmembers(cls) if item[0] not in ignore
and not isinstance(
item[1... | python | def get_attrs(cls):
"""
Get all class attributes ordered by definition
"""
ignore = dir(type('dummy', (object,), {})) + ['__metaclass__']
attrs = [
item for item in inspect.getmembers(cls) if item[0] not in ignore
and not isinstance(
item[1... | [
"def",
"get_attrs",
"(",
"cls",
")",
":",
"ignore",
"=",
"dir",
"(",
"type",
"(",
"'dummy'",
",",
"(",
"object",
",",
")",
",",
"{",
"}",
")",
")",
"+",
"[",
"'__metaclass__'",
"]",
"attrs",
"=",
"[",
"item",
"for",
"item",
"in",
"inspect",
".",
... | Get all class attributes ordered by definition | [
"Get",
"all",
"class",
"attributes",
"ordered",
"by",
"definition"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treemodel.py#L104-L120 |
14,109 | rootpy/rootpy | rootpy/tree/treemodel.py | TreeModelMeta.to_struct | def to_struct(cls, name=None):
"""
Convert the TreeModel into a compiled C struct
"""
if name is None:
name = cls.__name__
basic_attrs = dict([(attr_name, value)
for attr_name, value in cls.get_attrs()
if isinsta... | python | def to_struct(cls, name=None):
"""
Convert the TreeModel into a compiled C struct
"""
if name is None:
name = cls.__name__
basic_attrs = dict([(attr_name, value)
for attr_name, value in cls.get_attrs()
if isinsta... | [
"def",
"to_struct",
"(",
"cls",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"cls",
".",
"__name__",
"basic_attrs",
"=",
"dict",
"(",
"[",
"(",
"attr_name",
",",
"value",
")",
"for",
"attr_name",
",",
"value",
"... | Convert the TreeModel into a compiled C struct | [
"Convert",
"the",
"TreeModel",
"into",
"a",
"compiled",
"C",
"struct"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/tree/treemodel.py#L122-L139 |
14,110 | rootpy/rootpy | rootpy/extern/hep/pdg.py | id_to_name | def id_to_name(id):
"""
Convert a PDG ID to a printable string.
"""
name = pdgid_names.get(id)
if not name:
name = repr(id)
return name | python | def id_to_name(id):
"""
Convert a PDG ID to a printable string.
"""
name = pdgid_names.get(id)
if not name:
name = repr(id)
return name | [
"def",
"id_to_name",
"(",
"id",
")",
":",
"name",
"=",
"pdgid_names",
".",
"get",
"(",
"id",
")",
"if",
"not",
"name",
":",
"name",
"=",
"repr",
"(",
"id",
")",
"return",
"name"
] | Convert a PDG ID to a printable string. | [
"Convert",
"a",
"PDG",
"ID",
"to",
"a",
"printable",
"string",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/hep/pdg.py#L36-L43 |
14,111 | rootpy/rootpy | rootpy/extern/hep/pdg.py | id_to_root_name | def id_to_root_name(id):
"""
Convert a PDG ID to a string with root markup.
"""
name = root_names.get(id)
if not name:
name = repr(id)
return name | python | def id_to_root_name(id):
"""
Convert a PDG ID to a string with root markup.
"""
name = root_names.get(id)
if not name:
name = repr(id)
return name | [
"def",
"id_to_root_name",
"(",
"id",
")",
":",
"name",
"=",
"root_names",
".",
"get",
"(",
"id",
")",
"if",
"not",
"name",
":",
"name",
"=",
"repr",
"(",
"id",
")",
"return",
"name"
] | Convert a PDG ID to a string with root markup. | [
"Convert",
"a",
"PDG",
"ID",
"to",
"a",
"string",
"with",
"root",
"markup",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/hep/pdg.py#L46-L53 |
14,112 | rootpy/rootpy | rootpy/utils/inject_closure.py | new_closure | def new_closure(vals):
"""
Build a new closure
"""
args = ','.join('x%i' % i for i in range(len(vals)))
f = eval("lambda %s:lambda:(%s)" % (args, args))
if sys.version_info[0] >= 3:
return f(*vals).__closure__
return f(*vals).func_closure | python | def new_closure(vals):
"""
Build a new closure
"""
args = ','.join('x%i' % i for i in range(len(vals)))
f = eval("lambda %s:lambda:(%s)" % (args, args))
if sys.version_info[0] >= 3:
return f(*vals).__closure__
return f(*vals).func_closure | [
"def",
"new_closure",
"(",
"vals",
")",
":",
"args",
"=",
"','",
".",
"join",
"(",
"'x%i'",
"%",
"i",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"vals",
")",
")",
")",
"f",
"=",
"eval",
"(",
"\"lambda %s:lambda:(%s)\"",
"%",
"(",
"args",
",",
"a... | Build a new closure | [
"Build",
"a",
"new",
"closure"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/inject_closure.py#L19-L27 |
14,113 | rootpy/rootpy | rootpy/utils/inject_closure.py | _inject_closure_values_fix_closures | def _inject_closure_values_fix_closures(c, injected, **kwargs):
"""
Recursively fix closures
Python bytecode for a closure looks like::
LOAD_CLOSURE var1
BUILD_TUPLE <n_of_vars_closed_over>
LOAD_CONST <code_object_containing_closure>
MAKE_CLOSURE
or this in 3.6... | python | def _inject_closure_values_fix_closures(c, injected, **kwargs):
"""
Recursively fix closures
Python bytecode for a closure looks like::
LOAD_CLOSURE var1
BUILD_TUPLE <n_of_vars_closed_over>
LOAD_CONST <code_object_containing_closure>
MAKE_CLOSURE
or this in 3.6... | [
"def",
"_inject_closure_values_fix_closures",
"(",
"c",
",",
"injected",
",",
"*",
"*",
"kwargs",
")",
":",
"code",
"=",
"c",
".",
"code",
"orig_len",
"=",
"len",
"(",
"code",
")",
"for",
"iback",
",",
"(",
"opcode",
",",
"value",
")",
"in",
"enumerate... | Recursively fix closures
Python bytecode for a closure looks like::
LOAD_CLOSURE var1
BUILD_TUPLE <n_of_vars_closed_over>
LOAD_CONST <code_object_containing_closure>
MAKE_CLOSURE
or this in 3.6 (MAKE_CLOSURE is no longer an opcode)::
LOAD_CLOSURE var1
... | [
"Recursively",
"fix",
"closures"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/inject_closure.py#L30-L75 |
14,114 | rootpy/rootpy | rootpy/utils/inject_closure.py | _inject_closure_values_fix_code | def _inject_closure_values_fix_code(c, injected, **kwargs):
"""
Fix code objects, recursively fixing any closures
"""
# Add more closure variables
c.freevars += injected
# Replace LOAD_GLOBAL with LOAD_DEREF (fetch from closure cells)
# for named variables
for i, (opcode, value) in enum... | python | def _inject_closure_values_fix_code(c, injected, **kwargs):
"""
Fix code objects, recursively fixing any closures
"""
# Add more closure variables
c.freevars += injected
# Replace LOAD_GLOBAL with LOAD_DEREF (fetch from closure cells)
# for named variables
for i, (opcode, value) in enum... | [
"def",
"_inject_closure_values_fix_code",
"(",
"c",
",",
"injected",
",",
"*",
"*",
"kwargs",
")",
":",
"# Add more closure variables",
"c",
".",
"freevars",
"+=",
"injected",
"# Replace LOAD_GLOBAL with LOAD_DEREF (fetch from closure cells)",
"# for named variables",
"for",
... | Fix code objects, recursively fixing any closures | [
"Fix",
"code",
"objects",
"recursively",
"fixing",
"any",
"closures"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/inject_closure.py#L78-L93 |
14,115 | rootpy/rootpy | rootpy/utils/inject_closure.py | inject_closure_values | def inject_closure_values(func, **kwargs):
"""
Returns a new function identical to the previous one except that it acts as
though global variables named in `kwargs` have been closed over with the
values specified in the `kwargs` dictionary.
Works on properties, class/static methods and functions.
... | python | def inject_closure_values(func, **kwargs):
"""
Returns a new function identical to the previous one except that it acts as
though global variables named in `kwargs` have been closed over with the
values specified in the `kwargs` dictionary.
Works on properties, class/static methods and functions.
... | [
"def",
"inject_closure_values",
"(",
"func",
",",
"*",
"*",
"kwargs",
")",
":",
"wrapped_by",
"=",
"None",
"if",
"isinstance",
"(",
"func",
",",
"property",
")",
":",
"fget",
",",
"fset",
",",
"fdel",
"=",
"func",
".",
"fget",
",",
"func",
".",
"fset... | Returns a new function identical to the previous one except that it acts as
though global variables named in `kwargs` have been closed over with the
values specified in the `kwargs` dictionary.
Works on properties, class/static methods and functions.
This can be useful for mocking and other nefarious ... | [
"Returns",
"a",
"new",
"function",
"identical",
"to",
"the",
"previous",
"one",
"except",
"that",
"it",
"acts",
"as",
"though",
"global",
"variables",
"named",
"in",
"kwargs",
"have",
"been",
"closed",
"over",
"with",
"the",
"values",
"specified",
"in",
"the... | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/utils/inject_closure.py#L137-L165 |
14,116 | rootpy/rootpy | rootpy/plotting/canvas.py | _PadBase.axes | def axes(self, ndim=1,
xlimits=None, ylimits=None, zlimits=None,
xbins=1, ybins=1, zbins=1):
"""
Create and return axes on this pad
"""
if xlimits is None:
xlimits = (0, 1)
if ylimits is None:
ylimits = (0, 1)
if zlimits i... | python | def axes(self, ndim=1,
xlimits=None, ylimits=None, zlimits=None,
xbins=1, ybins=1, zbins=1):
"""
Create and return axes on this pad
"""
if xlimits is None:
xlimits = (0, 1)
if ylimits is None:
ylimits = (0, 1)
if zlimits i... | [
"def",
"axes",
"(",
"self",
",",
"ndim",
"=",
"1",
",",
"xlimits",
"=",
"None",
",",
"ylimits",
"=",
"None",
",",
"zlimits",
"=",
"None",
",",
"xbins",
"=",
"1",
",",
"ybins",
"=",
"1",
",",
"zbins",
"=",
"1",
")",
":",
"if",
"xlimits",
"is",
... | Create and return axes on this pad | [
"Create",
"and",
"return",
"axes",
"on",
"this",
"pad"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/canvas.py#L34-L93 |
14,117 | rootpy/rootpy | rootpy/root2hdf5.py | root2hdf5 | def root2hdf5(rfile, hfile, rpath='',
entries=-1, userfunc=None,
show_progress=False,
ignore_exception=False,
**kwargs):
"""
Convert all trees in a ROOT file into tables in an HDF5 file.
Parameters
----------
rfile : string or asrootpy'd ROOT... | python | def root2hdf5(rfile, hfile, rpath='',
entries=-1, userfunc=None,
show_progress=False,
ignore_exception=False,
**kwargs):
"""
Convert all trees in a ROOT file into tables in an HDF5 file.
Parameters
----------
rfile : string or asrootpy'd ROOT... | [
"def",
"root2hdf5",
"(",
"rfile",
",",
"hfile",
",",
"rpath",
"=",
"''",
",",
"entries",
"=",
"-",
"1",
",",
"userfunc",
"=",
"None",
",",
"show_progress",
"=",
"False",
",",
"ignore_exception",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"own_r... | Convert all trees in a ROOT file into tables in an HDF5 file.
Parameters
----------
rfile : string or asrootpy'd ROOT File
A ROOT File handle or string path to an existing ROOT file.
hfile : string or PyTables HDF5 File
A PyTables HDF5 File handle or string path to an existing HDF5 fi... | [
"Convert",
"all",
"trees",
"in",
"a",
"ROOT",
"file",
"into",
"tables",
"in",
"an",
"HDF5",
"file",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/root2hdf5.py#L190-L310 |
14,118 | rootpy/rootpy | rootpy/plotting/graph.py | _Graph1DBase.Reverse | def Reverse(self, copy=False):
"""
Reverse the order of the points
"""
numPoints = self.GetN()
if copy:
revGraph = self.Clone()
else:
revGraph = self
X = self.GetX()
EXlow = self.GetEXlow()
EXhigh = self.GetEXhigh()
... | python | def Reverse(self, copy=False):
"""
Reverse the order of the points
"""
numPoints = self.GetN()
if copy:
revGraph = self.Clone()
else:
revGraph = self
X = self.GetX()
EXlow = self.GetEXlow()
EXhigh = self.GetEXhigh()
... | [
"def",
"Reverse",
"(",
"self",
",",
"copy",
"=",
"False",
")",
":",
"numPoints",
"=",
"self",
".",
"GetN",
"(",
")",
"if",
"copy",
":",
"revGraph",
"=",
"self",
".",
"Clone",
"(",
")",
"else",
":",
"revGraph",
"=",
"self",
"X",
"=",
"self",
".",
... | Reverse the order of the points | [
"Reverse",
"the",
"order",
"of",
"the",
"points"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/graph.py#L493-L515 |
14,119 | rootpy/rootpy | rootpy/plotting/graph.py | _Graph1DBase.Shift | def Shift(self, value, copy=False):
"""
Shift the graph left or right by value
"""
numPoints = self.GetN()
if copy:
shiftGraph = self.Clone()
else:
shiftGraph = self
X = self.GetX()
EXlow = self.GetEXlow()
EXhigh = self.GetE... | python | def Shift(self, value, copy=False):
"""
Shift the graph left or right by value
"""
numPoints = self.GetN()
if copy:
shiftGraph = self.Clone()
else:
shiftGraph = self
X = self.GetX()
EXlow = self.GetEXlow()
EXhigh = self.GetE... | [
"def",
"Shift",
"(",
"self",
",",
"value",
",",
"copy",
"=",
"False",
")",
":",
"numPoints",
"=",
"self",
".",
"GetN",
"(",
")",
"if",
"copy",
":",
"shiftGraph",
"=",
"self",
".",
"Clone",
"(",
")",
"else",
":",
"shiftGraph",
"=",
"self",
"X",
"=... | Shift the graph left or right by value | [
"Shift",
"the",
"graph",
"left",
"or",
"right",
"by",
"value"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/graph.py#L586-L607 |
14,120 | rootpy/rootpy | rootpy/plotting/graph.py | _Graph1DBase.Integrate | def Integrate(self):
"""
Integrate using the trapazoidal method
"""
area = 0.
X = self.GetX()
Y = self.GetY()
for i in range(self.GetN() - 1):
area += (X[i + 1] - X[i]) * (Y[i] + Y[i + 1]) / 2.
return area | python | def Integrate(self):
"""
Integrate using the trapazoidal method
"""
area = 0.
X = self.GetX()
Y = self.GetY()
for i in range(self.GetN() - 1):
area += (X[i + 1] - X[i]) * (Y[i] + Y[i + 1]) / 2.
return area | [
"def",
"Integrate",
"(",
"self",
")",
":",
"area",
"=",
"0.",
"X",
"=",
"self",
".",
"GetX",
"(",
")",
"Y",
"=",
"self",
".",
"GetY",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"GetN",
"(",
")",
"-",
"1",
")",
":",
"area",
"+=",... | Integrate using the trapazoidal method | [
"Integrate",
"using",
"the",
"trapazoidal",
"method"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/graph.py#L609-L618 |
14,121 | rootpy/rootpy | rootpy/plotting/graph.py | _Graph1DBase.Append | def Append(self, other):
"""
Append points from another graph
"""
orig_len = len(self)
self.Set(orig_len + len(other))
ipoint = orig_len
if hasattr(self, 'SetPointError'):
for point in other:
self.SetPoint(ipoint, point.x.value, point.y... | python | def Append(self, other):
"""
Append points from another graph
"""
orig_len = len(self)
self.Set(orig_len + len(other))
ipoint = orig_len
if hasattr(self, 'SetPointError'):
for point in other:
self.SetPoint(ipoint, point.x.value, point.y... | [
"def",
"Append",
"(",
"self",
",",
"other",
")",
":",
"orig_len",
"=",
"len",
"(",
"self",
")",
"self",
".",
"Set",
"(",
"orig_len",
"+",
"len",
"(",
"other",
")",
")",
"ipoint",
"=",
"orig_len",
"if",
"hasattr",
"(",
"self",
",",
"'SetPointError'",
... | Append points from another graph | [
"Append",
"points",
"from",
"another",
"graph"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/graph.py#L620-L638 |
14,122 | rootpy/rootpy | rootpy/memory/keepalive.py | keepalive | def keepalive(nurse, *patients):
"""
Keep ``patients`` alive at least as long as ``nurse`` is around using a
``WeakKeyDictionary``.
"""
if DISABLED:
return
if hashable(nurse):
hashable_patients = []
for p in patients:
if hashable(p):
log.debug(... | python | def keepalive(nurse, *patients):
"""
Keep ``patients`` alive at least as long as ``nurse`` is around using a
``WeakKeyDictionary``.
"""
if DISABLED:
return
if hashable(nurse):
hashable_patients = []
for p in patients:
if hashable(p):
log.debug(... | [
"def",
"keepalive",
"(",
"nurse",
",",
"*",
"patients",
")",
":",
"if",
"DISABLED",
":",
"return",
"if",
"hashable",
"(",
"nurse",
")",
":",
"hashable_patients",
"=",
"[",
"]",
"for",
"p",
"in",
"patients",
":",
"if",
"hashable",
"(",
"p",
")",
":",
... | Keep ``patients`` alive at least as long as ``nurse`` is around using a
``WeakKeyDictionary``. | [
"Keep",
"patients",
"alive",
"at",
"least",
"as",
"long",
"as",
"nurse",
"is",
"around",
"using",
"a",
"WeakKeyDictionary",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/memory/keepalive.py#L26-L45 |
14,123 | rootpy/rootpy | rootpy/plotting/hist.py | canonify_slice | def canonify_slice(s, n):
"""
Convert a slice object into a canonical form
to simplify treatment in histogram bin content
and edge slicing.
"""
if isinstance(s, (int, long)):
return canonify_slice(slice(s, s + 1, None), n)
start = s.start % n if s.start is not None else 0
stop = ... | python | def canonify_slice(s, n):
"""
Convert a slice object into a canonical form
to simplify treatment in histogram bin content
and edge slicing.
"""
if isinstance(s, (int, long)):
return canonify_slice(slice(s, s + 1, None), n)
start = s.start % n if s.start is not None else 0
stop = ... | [
"def",
"canonify_slice",
"(",
"s",
",",
"n",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"return",
"canonify_slice",
"(",
"slice",
"(",
"s",
",",
"s",
"+",
"1",
",",
"None",
")",
",",
"n",
")",
"start",
... | Convert a slice object into a canonical form
to simplify treatment in histogram bin content
and edge slicing. | [
"Convert",
"a",
"slice",
"object",
"into",
"a",
"canonical",
"form",
"to",
"simplify",
"treatment",
"in",
"histogram",
"bin",
"content",
"and",
"edge",
"slicing",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L37-L48 |
14,124 | rootpy/rootpy | rootpy/plotting/hist.py | bin_to_edge_slice | def bin_to_edge_slice(s, n):
"""
Convert a bin slice into a bin edge slice.
"""
s = canonify_slice(s, n)
start = s.start
stop = s.stop
if start > stop:
_stop = start + 1
start = stop + 1
stop = _stop
start = max(start - 1, 0)
step = abs(s.step)
if stop <= ... | python | def bin_to_edge_slice(s, n):
"""
Convert a bin slice into a bin edge slice.
"""
s = canonify_slice(s, n)
start = s.start
stop = s.stop
if start > stop:
_stop = start + 1
start = stop + 1
stop = _stop
start = max(start - 1, 0)
step = abs(s.step)
if stop <= ... | [
"def",
"bin_to_edge_slice",
"(",
"s",
",",
"n",
")",
":",
"s",
"=",
"canonify_slice",
"(",
"s",
",",
"n",
")",
"start",
"=",
"s",
".",
"start",
"stop",
"=",
"s",
".",
"stop",
"if",
"start",
">",
"stop",
":",
"_stop",
"=",
"start",
"+",
"1",
"st... | Convert a bin slice into a bin edge slice. | [
"Convert",
"a",
"bin",
"slice",
"into",
"a",
"bin",
"edge",
"slice",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L51-L69 |
14,125 | rootpy/rootpy | rootpy/plotting/hist.py | histogram | def histogram(data, *args, **kwargs):
"""
Create and fill a one-dimensional histogram.
The same arguments as the ``Hist`` class are expected.
If the number of bins and the ranges are not specified they are
automatically deduced with the ``autobinning`` function using the method
specified by the... | python | def histogram(data, *args, **kwargs):
"""
Create and fill a one-dimensional histogram.
The same arguments as the ``Hist`` class are expected.
If the number of bins and the ranges are not specified they are
automatically deduced with the ``autobinning`` function using the method
specified by the... | [
"def",
"histogram",
"(",
"data",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"autobinning",
"import",
"autobinning",
"dim",
"=",
"kwargs",
".",
"pop",
"(",
"'dim'",
",",
"1",
")",
"if",
"dim",
"!=",
"1",
":",
"raise",
"NotImpl... | Create and fill a one-dimensional histogram.
The same arguments as the ``Hist`` class are expected.
If the number of bins and the ranges are not specified they are
automatically deduced with the ``autobinning`` function using the method
specified by the ``binning`` argument. Only one-dimensional histog... | [
"Create",
"and",
"fill",
"a",
"one",
"-",
"dimensional",
"histogram",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L2649-L2669 |
14,126 | rootpy/rootpy | rootpy/plotting/hist.py | BinProxy.overflow | def overflow(self):
"""
Returns true if this BinProxy is for an overflow bin
"""
indices = self.hist.xyz(self.idx)
for i in range(self.hist.GetDimension()):
if indices[i] == 0 or indices[i] == self.hist.nbins(i) + 1:
return True
return False | python | def overflow(self):
"""
Returns true if this BinProxy is for an overflow bin
"""
indices = self.hist.xyz(self.idx)
for i in range(self.hist.GetDimension()):
if indices[i] == 0 or indices[i] == self.hist.nbins(i) + 1:
return True
return False | [
"def",
"overflow",
"(",
"self",
")",
":",
"indices",
"=",
"self",
".",
"hist",
".",
"xyz",
"(",
"self",
".",
"idx",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"hist",
".",
"GetDimension",
"(",
")",
")",
":",
"if",
"indices",
"[",
"i",
"]... | Returns true if this BinProxy is for an overflow bin | [
"Returns",
"true",
"if",
"this",
"BinProxy",
"is",
"for",
"an",
"overflow",
"bin"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L217-L225 |
14,127 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.xyz | def xyz(self, idx):
"""
return binx, biny, binz corresponding to the global bin number
"""
# Not implemented for Python 3:
# GetBinXYZ(i, x, y, z)
nx = self.GetNbinsX() + 2
ny = self.GetNbinsY() + 2
ndim = self.GetDimension()
if ndim < 2:
... | python | def xyz(self, idx):
"""
return binx, biny, binz corresponding to the global bin number
"""
# Not implemented for Python 3:
# GetBinXYZ(i, x, y, z)
nx = self.GetNbinsX() + 2
ny = self.GetNbinsY() + 2
ndim = self.GetDimension()
if ndim < 2:
... | [
"def",
"xyz",
"(",
"self",
",",
"idx",
")",
":",
"# Not implemented for Python 3:",
"# GetBinXYZ(i, x, y, z)",
"nx",
"=",
"self",
".",
"GetNbinsX",
"(",
")",
"+",
"2",
"ny",
"=",
"self",
".",
"GetNbinsY",
"(",
")",
"+",
"2",
"ndim",
"=",
"self",
".",
"... | return binx, biny, binz corresponding to the global bin number | [
"return",
"binx",
"biny",
"binz",
"corresponding",
"to",
"the",
"global",
"bin",
"number"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L377-L400 |
14,128 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.nbins | def nbins(self, axis=0, overflow=False):
"""
Get the number of bins along an axis
"""
if axis == 0:
nbins = self.GetNbinsX()
elif axis == 1:
nbins = self.GetNbinsY()
elif axis == 2:
nbins = self.GetNbinsZ()
else:
rai... | python | def nbins(self, axis=0, overflow=False):
"""
Get the number of bins along an axis
"""
if axis == 0:
nbins = self.GetNbinsX()
elif axis == 1:
nbins = self.GetNbinsY()
elif axis == 2:
nbins = self.GetNbinsZ()
else:
rai... | [
"def",
"nbins",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"overflow",
"=",
"False",
")",
":",
"if",
"axis",
"==",
"0",
":",
"nbins",
"=",
"self",
".",
"GetNbinsX",
"(",
")",
"elif",
"axis",
"==",
"1",
":",
"nbins",
"=",
"self",
".",
"GetNbinsY",
... | Get the number of bins along an axis | [
"Get",
"the",
"number",
"of",
"bins",
"along",
"an",
"axis"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L463-L477 |
14,129 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.bins_range | def bins_range(self, axis=0, overflow=False):
"""
Return a range of bin indices for iterating along an axis
Parameters
----------
axis : int, optional (default=1)
The axis (0, 1 or 2).
overflow : bool, optional (default=False)
If True then inclu... | python | def bins_range(self, axis=0, overflow=False):
"""
Return a range of bin indices for iterating along an axis
Parameters
----------
axis : int, optional (default=1)
The axis (0, 1 or 2).
overflow : bool, optional (default=False)
If True then inclu... | [
"def",
"bins_range",
"(",
"self",
",",
"axis",
"=",
"0",
",",
"overflow",
"=",
"False",
")",
":",
"nbins",
"=",
"self",
".",
"nbins",
"(",
"axis",
"=",
"axis",
",",
"overflow",
"=",
"False",
")",
"if",
"overflow",
":",
"start",
"=",
"0",
"end_offse... | Return a range of bin indices for iterating along an axis
Parameters
----------
axis : int, optional (default=1)
The axis (0, 1 or 2).
overflow : bool, optional (default=False)
If True then include the underflow and overflow bins
otherwise only incl... | [
"Return",
"a",
"range",
"of",
"bin",
"indices",
"for",
"iterating",
"along",
"an",
"axis"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L479-L506 |
14,130 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.uniform_binned | def uniform_binned(self, name=None):
"""
Return a new histogram with constant width bins along all axes by
using the bin indices as the bin edges of the new histogram.
"""
if self.GetDimension() == 1:
new_hist = Hist(
self.GetNbinsX(), 0, self.GetNbins... | python | def uniform_binned(self, name=None):
"""
Return a new histogram with constant width bins along all axes by
using the bin indices as the bin edges of the new histogram.
"""
if self.GetDimension() == 1:
new_hist = Hist(
self.GetNbinsX(), 0, self.GetNbins... | [
"def",
"uniform_binned",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"self",
".",
"GetDimension",
"(",
")",
"==",
"1",
":",
"new_hist",
"=",
"Hist",
"(",
"self",
".",
"GetNbinsX",
"(",
")",
",",
"0",
",",
"self",
".",
"GetNbinsX",
"(",
... | Return a new histogram with constant width bins along all axes by
using the bin indices as the bin edges of the new histogram. | [
"Return",
"a",
"new",
"histogram",
"with",
"constant",
"width",
"bins",
"along",
"all",
"axes",
"by",
"using",
"the",
"bin",
"indices",
"as",
"the",
"bin",
"edges",
"of",
"the",
"new",
"histogram",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L749-L775 |
14,131 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.underflow | def underflow(self, axis=0):
"""
Return the underflow for the given axis.
Depending on the dimension of the histogram, may return an array.
"""
if axis not in range(3):
raise ValueError("axis must be 0, 1, or 2")
if self.DIM == 1:
return self.GetB... | python | def underflow(self, axis=0):
"""
Return the underflow for the given axis.
Depending on the dimension of the histogram, may return an array.
"""
if axis not in range(3):
raise ValueError("axis must be 0, 1, or 2")
if self.DIM == 1:
return self.GetB... | [
"def",
"underflow",
"(",
"self",
",",
"axis",
"=",
"0",
")",
":",
"if",
"axis",
"not",
"in",
"range",
"(",
"3",
")",
":",
"raise",
"ValueError",
"(",
"\"axis must be 0, 1, or 2\"",
")",
"if",
"self",
".",
"DIM",
"==",
"1",
":",
"return",
"self",
".",... | Return the underflow for the given axis.
Depending on the dimension of the histogram, may return an array. | [
"Return",
"the",
"underflow",
"for",
"the",
"given",
"axis",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L777-L806 |
14,132 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.lowerbound | def lowerbound(self, axis=0):
"""
Get the lower bound of the binning along an axis
"""
if not 0 <= axis < self.GetDimension():
raise ValueError(
"axis must be a non-negative integer less than "
"the dimensionality of the histogram")
if ... | python | def lowerbound(self, axis=0):
"""
Get the lower bound of the binning along an axis
"""
if not 0 <= axis < self.GetDimension():
raise ValueError(
"axis must be a non-negative integer less than "
"the dimensionality of the histogram")
if ... | [
"def",
"lowerbound",
"(",
"self",
",",
"axis",
"=",
"0",
")",
":",
"if",
"not",
"0",
"<=",
"axis",
"<",
"self",
".",
"GetDimension",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"axis must be a non-negative integer less than \"",
"\"the dimensionality of the histo... | Get the lower bound of the binning along an axis | [
"Get",
"the",
"lower",
"bound",
"of",
"the",
"binning",
"along",
"an",
"axis"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L844-L858 |
14,133 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.bounds | def bounds(self, axis=0):
"""
Get the lower and upper bounds of the binning along an axis
"""
if not 0 <= axis < self.GetDimension():
raise ValueError(
"axis must be a non-negative integer less than "
"the dimensionality of the histogram")
... | python | def bounds(self, axis=0):
"""
Get the lower and upper bounds of the binning along an axis
"""
if not 0 <= axis < self.GetDimension():
raise ValueError(
"axis must be a non-negative integer less than "
"the dimensionality of the histogram")
... | [
"def",
"bounds",
"(",
"self",
",",
"axis",
"=",
"0",
")",
":",
"if",
"not",
"0",
"<=",
"axis",
"<",
"self",
".",
"GetDimension",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"axis must be a non-negative integer less than \"",
"\"the dimensionality of the histogram... | Get the lower and upper bounds of the binning along an axis | [
"Get",
"the",
"lower",
"and",
"upper",
"bounds",
"of",
"the",
"binning",
"along",
"an",
"axis"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L876-L890 |
14,134 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.check_compatibility | def check_compatibility(self, other, check_edges=False, precision=1E-7):
"""
Test whether two histograms are considered compatible by the number of
dimensions, number of bins along each axis, and optionally the bin
edges.
Parameters
----------
other : histogram
... | python | def check_compatibility(self, other, check_edges=False, precision=1E-7):
"""
Test whether two histograms are considered compatible by the number of
dimensions, number of bins along each axis, and optionally the bin
edges.
Parameters
----------
other : histogram
... | [
"def",
"check_compatibility",
"(",
"self",
",",
"other",
",",
"check_edges",
"=",
"False",
",",
"precision",
"=",
"1E-7",
")",
":",
"if",
"self",
".",
"GetDimension",
"(",
")",
"!=",
"other",
".",
"GetDimension",
"(",
")",
":",
"raise",
"TypeError",
"(",... | Test whether two histograms are considered compatible by the number of
dimensions, number of bins along each axis, and optionally the bin
edges.
Parameters
----------
other : histogram
A rootpy histogram
check_edges : bool, optional (default=False)
... | [
"Test",
"whether",
"two",
"histograms",
"are",
"considered",
"compatible",
"by",
"the",
"number",
"of",
"dimensions",
"number",
"of",
"bins",
"along",
"each",
"axis",
"and",
"optionally",
"the",
"bin",
"edges",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1018-L1063 |
14,135 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.fill_array | def fill_array(self, array, weights=None):
"""
Fill this histogram with a NumPy array
"""
try:
try:
from root_numpy import fill_hist as fill_func
except ImportError:
from root_numpy import fill_array as fill_func
except Impo... | python | def fill_array(self, array, weights=None):
"""
Fill this histogram with a NumPy array
"""
try:
try:
from root_numpy import fill_hist as fill_func
except ImportError:
from root_numpy import fill_array as fill_func
except Impo... | [
"def",
"fill_array",
"(",
"self",
",",
"array",
",",
"weights",
"=",
"None",
")",
":",
"try",
":",
"try",
":",
"from",
"root_numpy",
"import",
"fill_hist",
"as",
"fill_func",
"except",
"ImportError",
":",
"from",
"root_numpy",
"import",
"fill_array",
"as",
... | Fill this histogram with a NumPy array | [
"Fill",
"this",
"histogram",
"with",
"a",
"NumPy",
"array"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1192-L1206 |
14,136 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.fill_view | def fill_view(self, view):
"""
Fill this histogram from a view of another histogram
"""
other = view.hist
_other_x_center = other.axis(0).GetBinCenter
_other_y_center = other.axis(1).GetBinCenter
_other_z_center = other.axis(2).GetBinCenter
_other_get = ot... | python | def fill_view(self, view):
"""
Fill this histogram from a view of another histogram
"""
other = view.hist
_other_x_center = other.axis(0).GetBinCenter
_other_y_center = other.axis(1).GetBinCenter
_other_z_center = other.axis(2).GetBinCenter
_other_get = ot... | [
"def",
"fill_view",
"(",
"self",
",",
"view",
")",
":",
"other",
"=",
"view",
".",
"hist",
"_other_x_center",
"=",
"other",
".",
"axis",
"(",
"0",
")",
".",
"GetBinCenter",
"_other_y_center",
"=",
"other",
".",
"axis",
"(",
"1",
")",
".",
"GetBinCenter... | Fill this histogram from a view of another histogram | [
"Fill",
"this",
"histogram",
"from",
"a",
"view",
"of",
"another",
"histogram"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1208-L1237 |
14,137 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.get_sum_w2 | def get_sum_w2(self, ix, iy=0, iz=0):
"""
Obtain the true number of entries in the bin weighted by w^2
"""
if self.GetSumw2N() == 0:
raise RuntimeError(
"Attempting to access Sumw2 in histogram "
"where weights were not stored")
xl = se... | python | def get_sum_w2(self, ix, iy=0, iz=0):
"""
Obtain the true number of entries in the bin weighted by w^2
"""
if self.GetSumw2N() == 0:
raise RuntimeError(
"Attempting to access Sumw2 in histogram "
"where weights were not stored")
xl = se... | [
"def",
"get_sum_w2",
"(",
"self",
",",
"ix",
",",
"iy",
"=",
"0",
",",
"iz",
"=",
"0",
")",
":",
"if",
"self",
".",
"GetSumw2N",
"(",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
"\"Attempting to access Sumw2 in histogram \"",
"\"where weights were not... | Obtain the true number of entries in the bin weighted by w^2 | [
"Obtain",
"the",
"true",
"number",
"of",
"entries",
"in",
"the",
"bin",
"weighted",
"by",
"w^2"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1245-L1258 |
14,138 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.set_sum_w2 | def set_sum_w2(self, w, ix, iy=0, iz=0):
"""
Sets the true number of entries in the bin weighted by w^2
"""
if self.GetSumw2N() == 0:
raise RuntimeError(
"Attempting to access Sumw2 in histogram "
"where weights were not stored")
xl = s... | python | def set_sum_w2(self, w, ix, iy=0, iz=0):
"""
Sets the true number of entries in the bin weighted by w^2
"""
if self.GetSumw2N() == 0:
raise RuntimeError(
"Attempting to access Sumw2 in histogram "
"where weights were not stored")
xl = s... | [
"def",
"set_sum_w2",
"(",
"self",
",",
"w",
",",
"ix",
",",
"iy",
"=",
"0",
",",
"iz",
"=",
"0",
")",
":",
"if",
"self",
".",
"GetSumw2N",
"(",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
"\"Attempting to access Sumw2 in histogram \"",
"\"where we... | Sets the true number of entries in the bin weighted by w^2 | [
"Sets",
"the",
"true",
"number",
"of",
"entries",
"in",
"the",
"bin",
"weighted",
"by",
"w^2"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1260-L1273 |
14,139 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.rebinned | def rebinned(self, bins, axis=0):
"""
Return a new rebinned histogram
Parameters
----------
bins : int, tuple, or iterable
If ``bins`` is an int, then return a histogram that is rebinned by
grouping N=``bins`` bins together along the axis ``axis``.
... | python | def rebinned(self, bins, axis=0):
"""
Return a new rebinned histogram
Parameters
----------
bins : int, tuple, or iterable
If ``bins`` is an int, then return a histogram that is rebinned by
grouping N=``bins`` bins together along the axis ``axis``.
... | [
"def",
"rebinned",
"(",
"self",
",",
"bins",
",",
"axis",
"=",
"0",
")",
":",
"ndim",
"=",
"self",
".",
"GetDimension",
"(",
")",
"if",
"axis",
">=",
"ndim",
":",
"raise",
"ValueError",
"(",
"\"axis must be less than the dimensionality of the histogram\"",
")"... | Return a new rebinned histogram
Parameters
----------
bins : int, tuple, or iterable
If ``bins`` is an int, then return a histogram that is rebinned by
grouping N=``bins`` bins together along the axis ``axis``.
If ``bins`` is a tuple, then it must contain th... | [
"Return",
"a",
"new",
"rebinned",
"histogram"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1405-L1491 |
14,140 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.smoothed | def smoothed(self, iterations=1):
"""
Return a smoothed copy of this histogram
Parameters
----------
iterations : int, optional (default=1)
The number of smoothing iterations
Returns
-------
hist : asrootpy'd histogram
The smoot... | python | def smoothed(self, iterations=1):
"""
Return a smoothed copy of this histogram
Parameters
----------
iterations : int, optional (default=1)
The number of smoothing iterations
Returns
-------
hist : asrootpy'd histogram
The smoot... | [
"def",
"smoothed",
"(",
"self",
",",
"iterations",
"=",
"1",
")",
":",
"copy",
"=",
"self",
".",
"Clone",
"(",
"shallow",
"=",
"True",
")",
"copy",
".",
"Smooth",
"(",
"iterations",
")",
"return",
"copy"
] | Return a smoothed copy of this histogram
Parameters
----------
iterations : int, optional (default=1)
The number of smoothing iterations
Returns
-------
hist : asrootpy'd histogram
The smoothed histogram | [
"Return",
"a",
"smoothed",
"copy",
"of",
"this",
"histogram"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1493-L1512 |
14,141 | rootpy/rootpy | rootpy/plotting/hist.py | _HistBase.empty_clone | def empty_clone(self, binning=None, axis=0, type=None, **kwargs):
"""
Return a new empty histogram. The binning may be modified
along one axis by specifying the binning and axis arguments.
If binning is False, then the corresponding axis is dropped
from the returned histogram.
... | python | def empty_clone(self, binning=None, axis=0, type=None, **kwargs):
"""
Return a new empty histogram. The binning may be modified
along one axis by specifying the binning and axis arguments.
If binning is False, then the corresponding axis is dropped
from the returned histogram.
... | [
"def",
"empty_clone",
"(",
"self",
",",
"binning",
"=",
"None",
",",
"axis",
"=",
"0",
",",
"type",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ndim",
"=",
"self",
".",
"GetDimension",
"(",
")",
"if",
"binning",
"is",
"False",
"and",
"ndim",
... | Return a new empty histogram. The binning may be modified
along one axis by specifying the binning and axis arguments.
If binning is False, then the corresponding axis is dropped
from the returned histogram. | [
"Return",
"a",
"new",
"empty",
"histogram",
".",
"The",
"binning",
"may",
"be",
"modified",
"along",
"one",
"axis",
"by",
"specifying",
"the",
"binning",
"and",
"axis",
"arguments",
".",
"If",
"binning",
"is",
"False",
"then",
"the",
"corresponding",
"axis",... | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1514-L1542 |
14,142 | rootpy/rootpy | rootpy/plotting/hist.py | _Hist.poisson_errors | def poisson_errors(self):
"""
Return a TGraphAsymmErrors representation of this histogram where the
point y errors are Poisson.
"""
graph = Graph(self.nbins(axis=0), type='asymm')
graph.SetLineWidth(self.GetLineWidth())
graph.SetMarkerSize(self.GetMarkerSize())
... | python | def poisson_errors(self):
"""
Return a TGraphAsymmErrors representation of this histogram where the
point y errors are Poisson.
"""
graph = Graph(self.nbins(axis=0), type='asymm')
graph.SetLineWidth(self.GetLineWidth())
graph.SetMarkerSize(self.GetMarkerSize())
... | [
"def",
"poisson_errors",
"(",
"self",
")",
":",
"graph",
"=",
"Graph",
"(",
"self",
".",
"nbins",
"(",
"axis",
"=",
"0",
")",
",",
"type",
"=",
"'asymm'",
")",
"graph",
".",
"SetLineWidth",
"(",
"self",
".",
"GetLineWidth",
"(",
")",
")",
"graph",
... | Return a TGraphAsymmErrors representation of this histogram where the
point y errors are Poisson. | [
"Return",
"a",
"TGraphAsymmErrors",
"representation",
"of",
"this",
"histogram",
"where",
"the",
"point",
"y",
"errors",
"are",
"Poisson",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/plotting/hist.py#L1784-L1809 |
14,143 | rootpy/rootpy | rootpy/interactive/canvas_events.py | attach_event_handler | def attach_event_handler(canvas, handler=close_on_esc_or_middlemouse):
"""
Attach a handler function to the ProcessedEvent slot, defaulting to
closing when middle mouse is clicked or escape is pressed
Note that escape only works if the pad has focus, which in ROOT-land means
the mouse has to be ove... | python | def attach_event_handler(canvas, handler=close_on_esc_or_middlemouse):
"""
Attach a handler function to the ProcessedEvent slot, defaulting to
closing when middle mouse is clicked or escape is pressed
Note that escape only works if the pad has focus, which in ROOT-land means
the mouse has to be ove... | [
"def",
"attach_event_handler",
"(",
"canvas",
",",
"handler",
"=",
"close_on_esc_or_middlemouse",
")",
":",
"if",
"getattr",
"(",
"canvas",
",",
"\"_py_event_dispatcher_attached\"",
",",
"None",
")",
":",
"return",
"event_dispatcher",
"=",
"C",
".",
"TPyDispatcherPr... | Attach a handler function to the ProcessedEvent slot, defaulting to
closing when middle mouse is clicked or escape is pressed
Note that escape only works if the pad has focus, which in ROOT-land means
the mouse has to be over the canvas area. | [
"Attach",
"a",
"handler",
"function",
"to",
"the",
"ProcessedEvent",
"slot",
"defaulting",
"to",
"closing",
"when",
"middle",
"mouse",
"is",
"clicked",
"or",
"escape",
"is",
"pressed"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/interactive/canvas_events.py#L58-L75 |
14,144 | rootpy/rootpy | rootpy/extern/shortuuid/__init__.py | ShortUUID._num_to_string | def _num_to_string(self, number, pad_to_length=None):
"""
Convert a number to a string, using the given alphabet.
"""
output = ""
while number:
number, digit = divmod(number, self._alpha_len)
output += self._alphabet[digit]
if pad_to_length:
... | python | def _num_to_string(self, number, pad_to_length=None):
"""
Convert a number to a string, using the given alphabet.
"""
output = ""
while number:
number, digit = divmod(number, self._alpha_len)
output += self._alphabet[digit]
if pad_to_length:
... | [
"def",
"_num_to_string",
"(",
"self",
",",
"number",
",",
"pad_to_length",
"=",
"None",
")",
":",
"output",
"=",
"\"\"",
"while",
"number",
":",
"number",
",",
"digit",
"=",
"divmod",
"(",
"number",
",",
"self",
".",
"_alpha_len",
")",
"output",
"+=",
... | Convert a number to a string, using the given alphabet. | [
"Convert",
"a",
"number",
"to",
"a",
"string",
"using",
"the",
"given",
"alphabet",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/shortuuid/__init__.py#L17-L28 |
14,145 | rootpy/rootpy | rootpy/extern/shortuuid/__init__.py | ShortUUID._string_to_int | def _string_to_int(self, string):
"""
Convert a string to a number, using the given alphabet..
"""
number = 0
for char in string[::-1]:
number = number * self._alpha_len + self._alphabet.index(char)
return number | python | def _string_to_int(self, string):
"""
Convert a string to a number, using the given alphabet..
"""
number = 0
for char in string[::-1]:
number = number * self._alpha_len + self._alphabet.index(char)
return number | [
"def",
"_string_to_int",
"(",
"self",
",",
"string",
")",
":",
"number",
"=",
"0",
"for",
"char",
"in",
"string",
"[",
":",
":",
"-",
"1",
"]",
":",
"number",
"=",
"number",
"*",
"self",
".",
"_alpha_len",
"+",
"self",
".",
"_alphabet",
".",
"index... | Convert a string to a number, using the given alphabet.. | [
"Convert",
"a",
"string",
"to",
"a",
"number",
"using",
"the",
"given",
"alphabet",
".."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/shortuuid/__init__.py#L30-L37 |
14,146 | rootpy/rootpy | rootpy/extern/shortuuid/__init__.py | ShortUUID.uuid | def uuid(self, name=None, pad_length=22):
"""
Generate and return a UUID.
If the name parameter is provided, set the namespace to the provided
name and generate a UUID.
"""
# If no name is given, generate a random UUID.
if name is None:
uuid = _uu.uui... | python | def uuid(self, name=None, pad_length=22):
"""
Generate and return a UUID.
If the name parameter is provided, set the namespace to the provided
name and generate a UUID.
"""
# If no name is given, generate a random UUID.
if name is None:
uuid = _uu.uui... | [
"def",
"uuid",
"(",
"self",
",",
"name",
"=",
"None",
",",
"pad_length",
"=",
"22",
")",
":",
"# If no name is given, generate a random UUID.",
"if",
"name",
"is",
"None",
":",
"uuid",
"=",
"_uu",
".",
"uuid4",
"(",
")",
"elif",
"\"http\"",
"not",
"in",
... | Generate and return a UUID.
If the name parameter is provided, set the namespace to the provided
name and generate a UUID. | [
"Generate",
"and",
"return",
"a",
"UUID",
"."
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/extern/shortuuid/__init__.py#L55-L69 |
14,147 | rootpy/rootpy | rootpy/stats/workspace.py | Workspace.fit | def fit(self,
data='obsData',
model_config='ModelConfig',
param_const=None,
param_values=None,
param_ranges=None,
poi_const=False,
poi_value=None,
poi_range=None,
extended=False,
num_cpu=1,
... | python | def fit(self,
data='obsData',
model_config='ModelConfig',
param_const=None,
param_values=None,
param_ranges=None,
poi_const=False,
poi_value=None,
poi_range=None,
extended=False,
num_cpu=1,
... | [
"def",
"fit",
"(",
"self",
",",
"data",
"=",
"'obsData'",
",",
"model_config",
"=",
"'ModelConfig'",
",",
"param_const",
"=",
"None",
",",
"param_values",
"=",
"None",
",",
"param_ranges",
"=",
"None",
",",
"poi_const",
"=",
"False",
",",
"poi_value",
"=",... | Fit a pdf to data in a workspace
Parameters
----------
workspace : RooWorkspace
The workspace
data : str or RooAbsData, optional (default='obsData')
The name of the data or a RooAbsData instance.
model_config : str or ModelConfig, optional (default='Mo... | [
"Fit",
"a",
"pdf",
"to",
"data",
"in",
"a",
"workspace"
] | 3926935e1f2100d8ba68070c2ab44055d4800f73 | https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/stats/workspace.py#L162-L333 |
14,148 | Deepwalker/trafaret | trafaret/base.py | ensure_trafaret | def ensure_trafaret(trafaret):
"""
Helper for complex trafarets, takes trafaret instance or class
and returns trafaret instance
"""
if isinstance(trafaret, Trafaret):
return trafaret
elif isinstance(trafaret, type):
if issubclass(trafaret, Trafaret):
return trafaret()... | python | def ensure_trafaret(trafaret):
"""
Helper for complex trafarets, takes trafaret instance or class
and returns trafaret instance
"""
if isinstance(trafaret, Trafaret):
return trafaret
elif isinstance(trafaret, type):
if issubclass(trafaret, Trafaret):
return trafaret()... | [
"def",
"ensure_trafaret",
"(",
"trafaret",
")",
":",
"if",
"isinstance",
"(",
"trafaret",
",",
"Trafaret",
")",
":",
"return",
"trafaret",
"elif",
"isinstance",
"(",
"trafaret",
",",
"type",
")",
":",
"if",
"issubclass",
"(",
"trafaret",
",",
"Trafaret",
"... | Helper for complex trafarets, takes trafaret instance or class
and returns trafaret instance | [
"Helper",
"for",
"complex",
"trafarets",
"takes",
"trafaret",
"instance",
"or",
"class",
"and",
"returns",
"trafaret",
"instance"
] | 4cbe4226e7f65133ba184b946faa2d3cd0e39d17 | https://github.com/Deepwalker/trafaret/blob/4cbe4226e7f65133ba184b946faa2d3cd0e39d17/trafaret/base.py#L171-L188 |
14,149 | Deepwalker/trafaret | trafaret/base.py | DictKeys | def DictKeys(keys):
"""
Checks if dict has all given keys
:param keys:
:type keys:
>>> _dd(DictKeys(['a','b']).check({'a':1,'b':2,}))
"{'a': 1, 'b': 2}"
>>> extract_error(DictKeys(['a','b']), {'a':1,'b':2,'c':3,})
{'c': 'c is not allowed key'}
>>> extract_error(DictKeys(['key','key... | python | def DictKeys(keys):
"""
Checks if dict has all given keys
:param keys:
:type keys:
>>> _dd(DictKeys(['a','b']).check({'a':1,'b':2,}))
"{'a': 1, 'b': 2}"
>>> extract_error(DictKeys(['a','b']), {'a':1,'b':2,'c':3,})
{'c': 'c is not allowed key'}
>>> extract_error(DictKeys(['key','key... | [
"def",
"DictKeys",
"(",
"keys",
")",
":",
"req",
"=",
"[",
"(",
"Key",
"(",
"key",
")",
",",
"Any",
")",
"for",
"key",
"in",
"keys",
"]",
"return",
"Dict",
"(",
"dict",
"(",
"req",
")",
")"
] | Checks if dict has all given keys
:param keys:
:type keys:
>>> _dd(DictKeys(['a','b']).check({'a':1,'b':2,}))
"{'a': 1, 'b': 2}"
>>> extract_error(DictKeys(['a','b']), {'a':1,'b':2,'c':3,})
{'c': 'c is not allowed key'}
>>> extract_error(DictKeys(['key','key2']), {'key':'val'})
{'key2'... | [
"Checks",
"if",
"dict",
"has",
"all",
"given",
"keys"
] | 4cbe4226e7f65133ba184b946faa2d3cd0e39d17 | https://github.com/Deepwalker/trafaret/blob/4cbe4226e7f65133ba184b946faa2d3cd0e39d17/trafaret/base.py#L1064-L1079 |
14,150 | Deepwalker/trafaret | trafaret/base.py | guard | def guard(trafaret=None, **kwargs):
"""
Decorator for protecting function with trafarets
>>> @guard(a=String, b=Int, c=String)
... def fn(a, b, c="default"):
... '''docstring'''
... return (a, b, c)
...
>>> fn.__module__ = None
>>> help(fn)
Help on function fn:
<BLAN... | python | def guard(trafaret=None, **kwargs):
"""
Decorator for protecting function with trafarets
>>> @guard(a=String, b=Int, c=String)
... def fn(a, b, c="default"):
... '''docstring'''
... return (a, b, c)
...
>>> fn.__module__ = None
>>> help(fn)
Help on function fn:
<BLAN... | [
"def",
"guard",
"(",
"trafaret",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"(",
"trafaret",
"and",
"not",
"isinstance",
"(",
"trafaret",
",",
"Dict",
")",
"and",
"not",
"isinstance",
"(",
"trafaret",
",",
"Forward",
")",
")",
":",
"raise"... | Decorator for protecting function with trafarets
>>> @guard(a=String, b=Int, c=String)
... def fn(a, b, c="default"):
... '''docstring'''
... return (a, b, c)
...
>>> fn.__module__ = None
>>> help(fn)
Help on function fn:
<BLANKLINE>
fn(*args, **kwargs)
guarded w... | [
"Decorator",
"for",
"protecting",
"function",
"with",
"trafarets"
] | 4cbe4226e7f65133ba184b946faa2d3cd0e39d17 | https://github.com/Deepwalker/trafaret/blob/4cbe4226e7f65133ba184b946faa2d3cd0e39d17/trafaret/base.py#L1265-L1338 |
14,151 | Deepwalker/trafaret | trafaret/base.py | Dict._clone_args | def _clone_args(self):
""" return args to create new Dict clone
"""
keys = list(self.keys)
kw = {}
if self.allow_any or self.extras:
kw['allow_extra'] = list(self.extras)
if self.allow_any:
kw['allow_extra'].append('*')
kw['allo... | python | def _clone_args(self):
""" return args to create new Dict clone
"""
keys = list(self.keys)
kw = {}
if self.allow_any or self.extras:
kw['allow_extra'] = list(self.extras)
if self.allow_any:
kw['allow_extra'].append('*')
kw['allo... | [
"def",
"_clone_args",
"(",
"self",
")",
":",
"keys",
"=",
"list",
"(",
"self",
".",
"keys",
")",
"kw",
"=",
"{",
"}",
"if",
"self",
".",
"allow_any",
"or",
"self",
".",
"extras",
":",
"kw",
"[",
"'allow_extra'",
"]",
"=",
"list",
"(",
"self",
"."... | return args to create new Dict clone | [
"return",
"args",
"to",
"create",
"new",
"Dict",
"clone"
] | 4cbe4226e7f65133ba184b946faa2d3cd0e39d17 | https://github.com/Deepwalker/trafaret/blob/4cbe4226e7f65133ba184b946faa2d3cd0e39d17/trafaret/base.py#L942-L956 |
14,152 | Deepwalker/trafaret | trafaret/base.py | Dict.merge | def merge(self, other):
"""
Extends one Dict with other Dict Key`s or Key`s list,
or dict instance supposed for Dict
"""
ignore = self.ignore
extra = self.extras
if isinstance(other, Dict):
other_keys = other.keys
ignore += other.ignore
... | python | def merge(self, other):
"""
Extends one Dict with other Dict Key`s or Key`s list,
or dict instance supposed for Dict
"""
ignore = self.ignore
extra = self.extras
if isinstance(other, Dict):
other_keys = other.keys
ignore += other.ignore
... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"ignore",
"=",
"self",
".",
"ignore",
"extra",
"=",
"self",
".",
"extras",
"if",
"isinstance",
"(",
"other",
",",
"Dict",
")",
":",
"other_keys",
"=",
"other",
".",
"keys",
"ignore",
"+=",
"other",... | Extends one Dict with other Dict Key`s or Key`s list,
or dict instance supposed for Dict | [
"Extends",
"one",
"Dict",
"with",
"other",
"Dict",
"Key",
"s",
"or",
"Key",
"s",
"list",
"or",
"dict",
"instance",
"supposed",
"for",
"Dict"
] | 4cbe4226e7f65133ba184b946faa2d3cd0e39d17 | https://github.com/Deepwalker/trafaret/blob/4cbe4226e7f65133ba184b946faa2d3cd0e39d17/trafaret/base.py#L1040-L1059 |
14,153 | Deepwalker/trafaret | trafaret/visitor.py | get_deep_attr | def get_deep_attr(obj, keys):
""" Helper for DeepKey"""
cur = obj
for k in keys:
if isinstance(cur, Mapping) and k in cur:
cur = cur[k]
continue
else:
try:
cur = getattr(cur, k)
continue
except AttributeError:
... | python | def get_deep_attr(obj, keys):
""" Helper for DeepKey"""
cur = obj
for k in keys:
if isinstance(cur, Mapping) and k in cur:
cur = cur[k]
continue
else:
try:
cur = getattr(cur, k)
continue
except AttributeError:
... | [
"def",
"get_deep_attr",
"(",
"obj",
",",
"keys",
")",
":",
"cur",
"=",
"obj",
"for",
"k",
"in",
"keys",
":",
"if",
"isinstance",
"(",
"cur",
",",
"Mapping",
")",
"and",
"k",
"in",
"cur",
":",
"cur",
"=",
"cur",
"[",
"k",
"]",
"continue",
"else",
... | Helper for DeepKey | [
"Helper",
"for",
"DeepKey"
] | 4cbe4226e7f65133ba184b946faa2d3cd0e39d17 | https://github.com/Deepwalker/trafaret/blob/4cbe4226e7f65133ba184b946faa2d3cd0e39d17/trafaret/visitor.py#L10-L24 |
14,154 | Deepwalker/trafaret | trafaret/constructor.py | construct | def construct(arg):
'''
Shortcut syntax to define trafarets.
- int, str, float and bool will return t.Int, t.String, t.Float and t.Bool
- one element list will return t.List
- tuple or list with several args will return t.Tuple
- dict will return t.Dict. If key has '?' at the and it will be opt... | python | def construct(arg):
'''
Shortcut syntax to define trafarets.
- int, str, float and bool will return t.Int, t.String, t.Float and t.Bool
- one element list will return t.List
- tuple or list with several args will return t.Tuple
- dict will return t.Dict. If key has '?' at the and it will be opt... | [
"def",
"construct",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"t",
".",
"Trafaret",
")",
":",
"return",
"arg",
"elif",
"isinstance",
"(",
"arg",
",",
"tuple",
")",
"or",
"(",
"isinstance",
"(",
"arg",
",",
"list",
")",
"and",
"len"... | Shortcut syntax to define trafarets.
- int, str, float and bool will return t.Int, t.String, t.Float and t.Bool
- one element list will return t.List
- tuple or list with several args will return t.Tuple
- dict will return t.Dict. If key has '?' at the and it will be optional and '?' will be removed
... | [
"Shortcut",
"syntax",
"to",
"define",
"trafarets",
"."
] | 4cbe4226e7f65133ba184b946faa2d3cd0e39d17 | https://github.com/Deepwalker/trafaret/blob/4cbe4226e7f65133ba184b946faa2d3cd0e39d17/trafaret/constructor.py#L23-L61 |
14,155 | Deepwalker/trafaret | trafaret/keys.py | subdict | def subdict(name, *keys, **kw):
"""
Subdict key.
Takes a `name`, any number of keys as args and keyword argument `trafaret`.
Use it like:
def check_passwords_equal(data):
if data['password'] != data['password_confirm']:
return t.DataError('Passwords are not equal')
... | python | def subdict(name, *keys, **kw):
"""
Subdict key.
Takes a `name`, any number of keys as args and keyword argument `trafaret`.
Use it like:
def check_passwords_equal(data):
if data['password'] != data['password_confirm']:
return t.DataError('Passwords are not equal')
... | [
"def",
"subdict",
"(",
"name",
",",
"*",
"keys",
",",
"*",
"*",
"kw",
")",
":",
"trafaret",
"=",
"kw",
".",
"pop",
"(",
"'trafaret'",
")",
"# coz py2k",
"def",
"inner",
"(",
"data",
",",
"context",
"=",
"None",
")",
":",
"errors",
"=",
"False",
"... | Subdict key.
Takes a `name`, any number of keys as args and keyword argument `trafaret`.
Use it like:
def check_passwords_equal(data):
if data['password'] != data['password_confirm']:
return t.DataError('Passwords are not equal')
return data['password']
... | [
"Subdict",
"key",
"."
] | 4cbe4226e7f65133ba184b946faa2d3cd0e39d17 | https://github.com/Deepwalker/trafaret/blob/4cbe4226e7f65133ba184b946faa2d3cd0e39d17/trafaret/keys.py#L4-L50 |
14,156 | Deepwalker/trafaret | trafaret/keys.py | xor_key | def xor_key(first, second, trafaret):
"""
xor_key - takes `first` and `second` key names and `trafaret`.
Checks if we have only `first` or only `second` in data, not both,
and at least one.
Then checks key value against trafaret.
"""
trafaret = t.Trafaret._trafaret(trafaret)
def check... | python | def xor_key(first, second, trafaret):
"""
xor_key - takes `first` and `second` key names and `trafaret`.
Checks if we have only `first` or only `second` in data, not both,
and at least one.
Then checks key value against trafaret.
"""
trafaret = t.Trafaret._trafaret(trafaret)
def check... | [
"def",
"xor_key",
"(",
"first",
",",
"second",
",",
"trafaret",
")",
":",
"trafaret",
"=",
"t",
".",
"Trafaret",
".",
"_trafaret",
"(",
"trafaret",
")",
"def",
"check_",
"(",
"value",
")",
":",
"if",
"(",
"first",
"in",
"value",
")",
"^",
"(",
"sec... | xor_key - takes `first` and `second` key names and `trafaret`.
Checks if we have only `first` or only `second` in data, not both,
and at least one.
Then checks key value against trafaret. | [
"xor_key",
"-",
"takes",
"first",
"and",
"second",
"key",
"names",
"and",
"trafaret",
"."
] | 4cbe4226e7f65133ba184b946faa2d3cd0e39d17 | https://github.com/Deepwalker/trafaret/blob/4cbe4226e7f65133ba184b946faa2d3cd0e39d17/trafaret/keys.py#L53-L75 |
14,157 | Deepwalker/trafaret | trafaret/keys.py | confirm_key | def confirm_key(name, confirm_name, trafaret):
"""
confirm_key - takes `name`, `confirm_name` and `trafaret`.
Checks if data['name'] equals data['confirm_name'] and both
are valid against `trafaret`.
"""
def check_(value):
first, second = None, None
if name in value:
... | python | def confirm_key(name, confirm_name, trafaret):
"""
confirm_key - takes `name`, `confirm_name` and `trafaret`.
Checks if data['name'] equals data['confirm_name'] and both
are valid against `trafaret`.
"""
def check_(value):
first, second = None, None
if name in value:
... | [
"def",
"confirm_key",
"(",
"name",
",",
"confirm_name",
",",
"trafaret",
")",
":",
"def",
"check_",
"(",
"value",
")",
":",
"first",
",",
"second",
"=",
"None",
",",
"None",
"if",
"name",
"in",
"value",
":",
"first",
"=",
"value",
"[",
"name",
"]",
... | confirm_key - takes `name`, `confirm_name` and `trafaret`.
Checks if data['name'] equals data['confirm_name'] and both
are valid against `trafaret`. | [
"confirm_key",
"-",
"takes",
"name",
"confirm_name",
"and",
"trafaret",
"."
] | 4cbe4226e7f65133ba184b946faa2d3cd0e39d17 | https://github.com/Deepwalker/trafaret/blob/4cbe4226e7f65133ba184b946faa2d3cd0e39d17/trafaret/keys.py#L78-L101 |
14,158 | packethost/packet-python | packet/Manager.py | Manager.get_capacity | def get_capacity(self, legacy=None):
"""Get capacity of all facilities.
:param legacy: Indicate set of server types to include in response
Validation of `legacy` is left to the packet api to avoid going out of date if any new value is introduced.
The currently known values are:
... | python | def get_capacity(self, legacy=None):
"""Get capacity of all facilities.
:param legacy: Indicate set of server types to include in response
Validation of `legacy` is left to the packet api to avoid going out of date if any new value is introduced.
The currently known values are:
... | [
"def",
"get_capacity",
"(",
"self",
",",
"legacy",
"=",
"None",
")",
":",
"params",
"=",
"None",
"if",
"legacy",
":",
"params",
"=",
"{",
"'legacy'",
":",
"legacy",
"}",
"return",
"self",
".",
"call_api",
"(",
"'/capacity'",
",",
"params",
"=",
"params... | Get capacity of all facilities.
:param legacy: Indicate set of server types to include in response
Validation of `legacy` is left to the packet api to avoid going out of date if any new value is introduced.
The currently known values are:
- only (current default, will be switched "so... | [
"Get",
"capacity",
"of",
"all",
"facilities",
"."
] | 075ad8e3e5c12c1654b3598dc1e993818aeac061 | https://github.com/packethost/packet-python/blob/075ad8e3e5c12c1654b3598dc1e993818aeac061/packet/Manager.py#L170-L185 |
14,159 | priestc/moneywagon | moneywagon/currency_support.py | CurrencySupport.altcore_data | def altcore_data(self):
"""
Returns the crypto_data for all currencies defined in moneywagon that also
meet the minimum support for altcore. Data is keyed according to the
bitcore specification.
"""
ret = []
for symbol in self.supported_currencies(project='altcore... | python | def altcore_data(self):
"""
Returns the crypto_data for all currencies defined in moneywagon that also
meet the minimum support for altcore. Data is keyed according to the
bitcore specification.
"""
ret = []
for symbol in self.supported_currencies(project='altcore... | [
"def",
"altcore_data",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"symbol",
"in",
"self",
".",
"supported_currencies",
"(",
"project",
"=",
"'altcore'",
",",
"level",
"=",
"\"address\"",
")",
":",
"data",
"=",
"crypto_data",
"[",
"symbol",
"]",
... | Returns the crypto_data for all currencies defined in moneywagon that also
meet the minimum support for altcore. Data is keyed according to the
bitcore specification. | [
"Returns",
"the",
"crypto_data",
"for",
"all",
"currencies",
"defined",
"in",
"moneywagon",
"that",
"also",
"meet",
"the",
"minimum",
"support",
"for",
"altcore",
".",
"Data",
"is",
"keyed",
"according",
"to",
"the",
"bitcore",
"specification",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/currency_support.py#L101-L142 |
14,160 | priestc/moneywagon | moneywagon/tx.py | Transaction.from_unit_to_satoshi | def from_unit_to_satoshi(self, value, unit='satoshi'):
"""
Convert a value to satoshis. units can be any fiat currency.
By default the unit is satoshi.
"""
if not unit or unit == 'satoshi':
return value
if unit == 'bitcoin' or unit == 'btc':
return... | python | def from_unit_to_satoshi(self, value, unit='satoshi'):
"""
Convert a value to satoshis. units can be any fiat currency.
By default the unit is satoshi.
"""
if not unit or unit == 'satoshi':
return value
if unit == 'bitcoin' or unit == 'btc':
return... | [
"def",
"from_unit_to_satoshi",
"(",
"self",
",",
"value",
",",
"unit",
"=",
"'satoshi'",
")",
":",
"if",
"not",
"unit",
"or",
"unit",
"==",
"'satoshi'",
":",
"return",
"value",
"if",
"unit",
"==",
"'bitcoin'",
"or",
"unit",
"==",
"'btc'",
":",
"return",
... | Convert a value to satoshis. units can be any fiat currency.
By default the unit is satoshi. | [
"Convert",
"a",
"value",
"to",
"satoshis",
".",
"units",
"can",
"be",
"any",
"fiat",
"currency",
".",
"By",
"default",
"the",
"unit",
"is",
"satoshi",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/tx.py#L31-L43 |
14,161 | priestc/moneywagon | moneywagon/tx.py | Transaction._get_utxos | def _get_utxos(self, address, services, **modes):
"""
Using the service fallback engine, get utxos from remote service.
"""
return get_unspent_outputs(
self.crypto, address, services=services,
**modes
) | python | def _get_utxos(self, address, services, **modes):
"""
Using the service fallback engine, get utxos from remote service.
"""
return get_unspent_outputs(
self.crypto, address, services=services,
**modes
) | [
"def",
"_get_utxos",
"(",
"self",
",",
"address",
",",
"services",
",",
"*",
"*",
"modes",
")",
":",
"return",
"get_unspent_outputs",
"(",
"self",
".",
"crypto",
",",
"address",
",",
"services",
"=",
"services",
",",
"*",
"*",
"modes",
")"
] | Using the service fallback engine, get utxos from remote service. | [
"Using",
"the",
"service",
"fallback",
"engine",
"get",
"utxos",
"from",
"remote",
"service",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/tx.py#L58-L65 |
14,162 | priestc/moneywagon | moneywagon/tx.py | Transaction.total_input_satoshis | def total_input_satoshis(self):
"""
Add up all the satoshis coming from all input tx's.
"""
just_inputs = [x['input'] for x in self.ins]
return sum([x['amount'] for x in just_inputs]) | python | def total_input_satoshis(self):
"""
Add up all the satoshis coming from all input tx's.
"""
just_inputs = [x['input'] for x in self.ins]
return sum([x['amount'] for x in just_inputs]) | [
"def",
"total_input_satoshis",
"(",
"self",
")",
":",
"just_inputs",
"=",
"[",
"x",
"[",
"'input'",
"]",
"for",
"x",
"in",
"self",
".",
"ins",
"]",
"return",
"sum",
"(",
"[",
"x",
"[",
"'amount'",
"]",
"for",
"x",
"in",
"just_inputs",
"]",
")"
] | Add up all the satoshis coming from all input tx's. | [
"Add",
"up",
"all",
"the",
"satoshis",
"coming",
"from",
"all",
"input",
"tx",
"s",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/tx.py#L116-L121 |
14,163 | priestc/moneywagon | moneywagon/tx.py | Transaction.select_inputs | def select_inputs(self, amount):
'''Maximize transaction priority. Select the oldest inputs,
that are sufficient to cover the spent amount. Then,
remove any unneeded inputs, starting with
the smallest in value.
Returns sum of amounts of inputs selected'''
sorted_txin = sorted(self.in... | python | def select_inputs(self, amount):
'''Maximize transaction priority. Select the oldest inputs,
that are sufficient to cover the spent amount. Then,
remove any unneeded inputs, starting with
the smallest in value.
Returns sum of amounts of inputs selected'''
sorted_txin = sorted(self.in... | [
"def",
"select_inputs",
"(",
"self",
",",
"amount",
")",
":",
"sorted_txin",
"=",
"sorted",
"(",
"self",
".",
"ins",
",",
"key",
"=",
"lambda",
"x",
":",
"-",
"x",
"[",
"'input'",
"]",
"[",
"'confirmations'",
"]",
")",
"total_amount",
"=",
"0",
"for"... | Maximize transaction priority. Select the oldest inputs,
that are sufficient to cover the spent amount. Then,
remove any unneeded inputs, starting with
the smallest in value.
Returns sum of amounts of inputs selected | [
"Maximize",
"transaction",
"priority",
".",
"Select",
"the",
"oldest",
"inputs",
"that",
"are",
"sufficient",
"to",
"cover",
"the",
"spent",
"amount",
".",
"Then",
"remove",
"any",
"unneeded",
"inputs",
"starting",
"with",
"the",
"smallest",
"in",
"value",
"."... | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/tx.py#L123-L143 |
14,164 | priestc/moneywagon | moneywagon/tx.py | Transaction.onchain_exchange | def onchain_exchange(self, withdraw_crypto, withdraw_address, value, unit='satoshi'):
"""
This method is like `add_output` but it sends to another
"""
self.onchain_rate = get_onchain_exchange_rates(
self.crypto, withdraw_crypto, best=True, verbose=self.verbose
)
... | python | def onchain_exchange(self, withdraw_crypto, withdraw_address, value, unit='satoshi'):
"""
This method is like `add_output` but it sends to another
"""
self.onchain_rate = get_onchain_exchange_rates(
self.crypto, withdraw_crypto, best=True, verbose=self.verbose
)
... | [
"def",
"onchain_exchange",
"(",
"self",
",",
"withdraw_crypto",
",",
"withdraw_address",
",",
"value",
",",
"unit",
"=",
"'satoshi'",
")",
":",
"self",
".",
"onchain_rate",
"=",
"get_onchain_exchange_rates",
"(",
"self",
".",
"crypto",
",",
"withdraw_crypto",
",... | This method is like `add_output` but it sends to another | [
"This",
"method",
"is",
"like",
"add_output",
"but",
"it",
"sends",
"to",
"another"
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/tx.py#L162-L187 |
14,165 | priestc/moneywagon | moneywagon/tx.py | Transaction.fee | def fee(self, value=None, unit='satoshi'):
"""
Set the miner fee, if unit is not set, assumes value is satoshi.
If using 'optimal', make sure you have already added all outputs.
"""
convert = None
if not value:
# no fee was specified, use $0.02 as default.
... | python | def fee(self, value=None, unit='satoshi'):
"""
Set the miner fee, if unit is not set, assumes value is satoshi.
If using 'optimal', make sure you have already added all outputs.
"""
convert = None
if not value:
# no fee was specified, use $0.02 as default.
... | [
"def",
"fee",
"(",
"self",
",",
"value",
"=",
"None",
",",
"unit",
"=",
"'satoshi'",
")",
":",
"convert",
"=",
"None",
"if",
"not",
"value",
":",
"# no fee was specified, use $0.02 as default.",
"convert",
"=",
"get_current_price",
"(",
"self",
".",
"crypto",
... | Set the miner fee, if unit is not set, assumes value is satoshi.
If using 'optimal', make sure you have already added all outputs. | [
"Set",
"the",
"miner",
"fee",
"if",
"unit",
"is",
"not",
"set",
"assumes",
"value",
"is",
"satoshi",
".",
"If",
"using",
"optimal",
"make",
"sure",
"you",
"have",
"already",
"added",
"all",
"outputs",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/tx.py#L190-L215 |
14,166 | priestc/moneywagon | moneywagon/tx.py | Transaction.get_hex | def get_hex(self, signed=True):
"""
Given all the data the user has given so far, make the hex using pybitcointools
"""
total_ins_satoshi = self.total_input_satoshis()
if total_ins_satoshi == 0:
raise ValueError("Can't make transaction, there are zero inputs")
... | python | def get_hex(self, signed=True):
"""
Given all the data the user has given so far, make the hex using pybitcointools
"""
total_ins_satoshi = self.total_input_satoshis()
if total_ins_satoshi == 0:
raise ValueError("Can't make transaction, there are zero inputs")
... | [
"def",
"get_hex",
"(",
"self",
",",
"signed",
"=",
"True",
")",
":",
"total_ins_satoshi",
"=",
"self",
".",
"total_input_satoshis",
"(",
")",
"if",
"total_ins_satoshi",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Can't make transaction, there are zero inputs\"",
... | Given all the data the user has given so far, make the hex using pybitcointools | [
"Given",
"all",
"the",
"data",
"the",
"user",
"has",
"given",
"so",
"far",
"make",
"the",
"hex",
"using",
"pybitcointools"
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/tx.py#L227-L267 |
14,167 | priestc/moneywagon | moneywagon/__init__.py | get_current_price | def get_current_price(crypto, fiat, services=None, convert_to=None, helper_prices=None, **modes):
"""
High level function for getting current exchange rate for a cryptocurrency.
If the fiat value is not explicitly defined, it will try the wildcard service.
if that does not work, it tries converting to a... | python | def get_current_price(crypto, fiat, services=None, convert_to=None, helper_prices=None, **modes):
"""
High level function for getting current exchange rate for a cryptocurrency.
If the fiat value is not explicitly defined, it will try the wildcard service.
if that does not work, it tries converting to a... | [
"def",
"get_current_price",
"(",
"crypto",
",",
"fiat",
",",
"services",
"=",
"None",
",",
"convert_to",
"=",
"None",
",",
"helper_prices",
"=",
"None",
",",
"*",
"*",
"modes",
")",
":",
"fiat",
"=",
"fiat",
".",
"lower",
"(",
")",
"args",
"=",
"{",
... | High level function for getting current exchange rate for a cryptocurrency.
If the fiat value is not explicitly defined, it will try the wildcard service.
if that does not work, it tries converting to an intermediate cryptocurrency
if available. | [
"High",
"level",
"function",
"for",
"getting",
"current",
"exchange",
"rate",
"for",
"a",
"cryptocurrency",
".",
"If",
"the",
"fiat",
"value",
"is",
"not",
"explicitly",
"defined",
"it",
"will",
"try",
"the",
"wildcard",
"service",
".",
"if",
"that",
"does",... | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/__init__.py#L65-L120 |
14,168 | priestc/moneywagon | moneywagon/__init__.py | get_onchain_exchange_rates | def get_onchain_exchange_rates(deposit_crypto=None, withdraw_crypto=None, **modes):
"""
Gets exchange rates for all defined on-chain exchange services.
"""
from moneywagon.onchain_exchange import ALL_SERVICES
rates = []
for Service in ALL_SERVICES:
srv = Service(verbose=modes.get('verbo... | python | def get_onchain_exchange_rates(deposit_crypto=None, withdraw_crypto=None, **modes):
"""
Gets exchange rates for all defined on-chain exchange services.
"""
from moneywagon.onchain_exchange import ALL_SERVICES
rates = []
for Service in ALL_SERVICES:
srv = Service(verbose=modes.get('verbo... | [
"def",
"get_onchain_exchange_rates",
"(",
"deposit_crypto",
"=",
"None",
",",
"withdraw_crypto",
"=",
"None",
",",
"*",
"*",
"modes",
")",
":",
"from",
"moneywagon",
".",
"onchain_exchange",
"import",
"ALL_SERVICES",
"rates",
"=",
"[",
"]",
"for",
"Service",
"... | Gets exchange rates for all defined on-chain exchange services. | [
"Gets",
"exchange",
"rates",
"for",
"all",
"defined",
"on",
"-",
"chain",
"exchange",
"services",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/__init__.py#L301-L321 |
14,169 | priestc/moneywagon | moneywagon/__init__.py | generate_keypair | def generate_keypair(crypto, seed, password=None):
"""
Generate a private key and publickey for any currency, given a seed.
That seed can be random, or a brainwallet phrase.
"""
if crypto in ['eth', 'etc']:
raise CurrencyNotSupported("Ethereums not yet supported")
pub_byte, priv_byte = ... | python | def generate_keypair(crypto, seed, password=None):
"""
Generate a private key and publickey for any currency, given a seed.
That seed can be random, or a brainwallet phrase.
"""
if crypto in ['eth', 'etc']:
raise CurrencyNotSupported("Ethereums not yet supported")
pub_byte, priv_byte = ... | [
"def",
"generate_keypair",
"(",
"crypto",
",",
"seed",
",",
"password",
"=",
"None",
")",
":",
"if",
"crypto",
"in",
"[",
"'eth'",
",",
"'etc'",
"]",
":",
"raise",
"CurrencyNotSupported",
"(",
"\"Ethereums not yet supported\"",
")",
"pub_byte",
",",
"priv_byte... | Generate a private key and publickey for any currency, given a seed.
That seed can be random, or a brainwallet phrase. | [
"Generate",
"a",
"private",
"key",
"and",
"publickey",
"for",
"any",
"currency",
"given",
"a",
"seed",
".",
"That",
"seed",
"can",
"be",
"random",
"or",
"a",
"brainwallet",
"phrase",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/__init__.py#L324-L359 |
14,170 | priestc/moneywagon | moneywagon/__init__.py | sweep | def sweep(crypto, private_key, to_address, fee=None, password=None, **modes):
"""
Move all funds by private key to another address.
"""
from moneywagon.tx import Transaction
tx = Transaction(crypto, verbose=modes.get('verbose', False))
tx.add_inputs(private_key=private_key, password=password, **... | python | def sweep(crypto, private_key, to_address, fee=None, password=None, **modes):
"""
Move all funds by private key to another address.
"""
from moneywagon.tx import Transaction
tx = Transaction(crypto, verbose=modes.get('verbose', False))
tx.add_inputs(private_key=private_key, password=password, **... | [
"def",
"sweep",
"(",
"crypto",
",",
"private_key",
",",
"to_address",
",",
"fee",
"=",
"None",
",",
"password",
"=",
"None",
",",
"*",
"*",
"modes",
")",
":",
"from",
"moneywagon",
".",
"tx",
"import",
"Transaction",
"tx",
"=",
"Transaction",
"(",
"cry... | Move all funds by private key to another address. | [
"Move",
"all",
"funds",
"by",
"private",
"key",
"to",
"another",
"address",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/__init__.py#L367-L377 |
14,171 | priestc/moneywagon | moneywagon/__init__.py | guess_currency_from_address | def guess_currency_from_address(address):
"""
Given a crypto address, find which currency it likely belongs to.
Raises an exception if it can't find a match. Raises exception if address
is invalid.
"""
if is_py2:
fixer = lambda x: int(x.encode('hex'), 16)
else:
fixer = lambda... | python | def guess_currency_from_address(address):
"""
Given a crypto address, find which currency it likely belongs to.
Raises an exception if it can't find a match. Raises exception if address
is invalid.
"""
if is_py2:
fixer = lambda x: int(x.encode('hex'), 16)
else:
fixer = lambda... | [
"def",
"guess_currency_from_address",
"(",
"address",
")",
":",
"if",
"is_py2",
":",
"fixer",
"=",
"lambda",
"x",
":",
"int",
"(",
"x",
".",
"encode",
"(",
"'hex'",
")",
",",
"16",
")",
"else",
":",
"fixer",
"=",
"lambda",
"x",
":",
"x",
"# does noth... | Given a crypto address, find which currency it likely belongs to.
Raises an exception if it can't find a match. Raises exception if address
is invalid. | [
"Given",
"a",
"crypto",
"address",
"find",
"which",
"currency",
"it",
"likely",
"belongs",
"to",
".",
"Raises",
"an",
"exception",
"if",
"it",
"can",
"t",
"find",
"a",
"match",
".",
"Raises",
"exception",
"if",
"address",
"is",
"invalid",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/__init__.py#L414-L438 |
14,172 | priestc/moneywagon | moneywagon/__init__.py | service_table | def service_table(format='simple', authenticated=False):
"""
Returns a string depicting all services currently installed.
"""
if authenticated:
all_services = ExchangeUniverse.get_authenticated_services()
else:
all_services = ALL_SERVICES
if format == 'html':
linkify = l... | python | def service_table(format='simple', authenticated=False):
"""
Returns a string depicting all services currently installed.
"""
if authenticated:
all_services = ExchangeUniverse.get_authenticated_services()
else:
all_services = ALL_SERVICES
if format == 'html':
linkify = l... | [
"def",
"service_table",
"(",
"format",
"=",
"'simple'",
",",
"authenticated",
"=",
"False",
")",
":",
"if",
"authenticated",
":",
"all_services",
"=",
"ExchangeUniverse",
".",
"get_authenticated_services",
"(",
")",
"else",
":",
"all_services",
"=",
"ALL_SERVICES"... | Returns a string depicting all services currently installed. | [
"Returns",
"a",
"string",
"depicting",
"all",
"services",
"currently",
"installed",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/__init__.py#L637-L661 |
14,173 | priestc/moneywagon | moneywagon/__init__.py | ExchangeUniverse.find_pair | def find_pair(self, crypto="", fiat="", verbose=False):
"""
This utility is used to find an exchange that supports a given exchange pair.
"""
self.fetch_pairs()
if not crypto and not fiat:
raise Exception("Fiat or Crypto required")
def is_matched(crypto, fiat... | python | def find_pair(self, crypto="", fiat="", verbose=False):
"""
This utility is used to find an exchange that supports a given exchange pair.
"""
self.fetch_pairs()
if not crypto and not fiat:
raise Exception("Fiat or Crypto required")
def is_matched(crypto, fiat... | [
"def",
"find_pair",
"(",
"self",
",",
"crypto",
"=",
"\"\"",
",",
"fiat",
"=",
"\"\"",
",",
"verbose",
"=",
"False",
")",
":",
"self",
".",
"fetch_pairs",
"(",
")",
"if",
"not",
"crypto",
"and",
"not",
"fiat",
":",
"raise",
"Exception",
"(",
"\"Fiat ... | This utility is used to find an exchange that supports a given exchange pair. | [
"This",
"utility",
"is",
"used",
"to",
"find",
"an",
"exchange",
"that",
"supports",
"a",
"given",
"exchange",
"pair",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/__init__.py#L703-L725 |
14,174 | priestc/moneywagon | moneywagon/arbitrage.py | all_balances | def all_balances(currency, services=None, verbose=False, timeout=None):
"""
Get balances for passed in currency for all exchanges.
"""
balances = {}
if not services:
services = [
x(verbose=verbose, timeout=timeout)
for x in ExchangeUniverse.get_authenticated_services(... | python | def all_balances(currency, services=None, verbose=False, timeout=None):
"""
Get balances for passed in currency for all exchanges.
"""
balances = {}
if not services:
services = [
x(verbose=verbose, timeout=timeout)
for x in ExchangeUniverse.get_authenticated_services(... | [
"def",
"all_balances",
"(",
"currency",
",",
"services",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"timeout",
"=",
"None",
")",
":",
"balances",
"=",
"{",
"}",
"if",
"not",
"services",
":",
"services",
"=",
"[",
"x",
"(",
"verbose",
"=",
"verbo... | Get balances for passed in currency for all exchanges. | [
"Get",
"balances",
"for",
"passed",
"in",
"currency",
"for",
"all",
"exchanges",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/arbitrage.py#L8-L29 |
14,175 | priestc/moneywagon | moneywagon/arbitrage.py | total_exchange_balances | def total_exchange_balances(services=None, verbose=None, timeout=None, by_service=False):
"""
Returns all balances for all currencies for all exchanges
"""
balances = defaultdict(lambda: 0)
if not services:
services = [
x(verbose=verbose, timeout=timeout)
for x in Exc... | python | def total_exchange_balances(services=None, verbose=None, timeout=None, by_service=False):
"""
Returns all balances for all currencies for all exchanges
"""
balances = defaultdict(lambda: 0)
if not services:
services = [
x(verbose=verbose, timeout=timeout)
for x in Exc... | [
"def",
"total_exchange_balances",
"(",
"services",
"=",
"None",
",",
"verbose",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"by_service",
"=",
"False",
")",
":",
"balances",
"=",
"defaultdict",
"(",
"lambda",
":",
"0",
")",
"if",
"not",
"services",
":... | Returns all balances for all currencies for all exchanges | [
"Returns",
"all",
"balances",
"for",
"all",
"currencies",
"for",
"all",
"exchanges"
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/arbitrage.py#L31-L57 |
14,176 | priestc/moneywagon | moneywagon/bip38.py | compress | def compress(x, y):
"""
Given a x,y coordinate, encode in "compressed format"
Returned is always 33 bytes.
"""
polarity = "02" if y % 2 == 0 else "03"
wrap = lambda x: x
if not is_py2:
wrap = lambda x: bytes(x, 'ascii')
return unhexlify(wrap("%s%0.64x" % (polarity, x))) | python | def compress(x, y):
"""
Given a x,y coordinate, encode in "compressed format"
Returned is always 33 bytes.
"""
polarity = "02" if y % 2 == 0 else "03"
wrap = lambda x: x
if not is_py2:
wrap = lambda x: bytes(x, 'ascii')
return unhexlify(wrap("%s%0.64x" % (polarity, x))) | [
"def",
"compress",
"(",
"x",
",",
"y",
")",
":",
"polarity",
"=",
"\"02\"",
"if",
"y",
"%",
"2",
"==",
"0",
"else",
"\"03\"",
"wrap",
"=",
"lambda",
"x",
":",
"x",
"if",
"not",
"is_py2",
":",
"wrap",
"=",
"lambda",
"x",
":",
"bytes",
"(",
"x",
... | Given a x,y coordinate, encode in "compressed format"
Returned is always 33 bytes. | [
"Given",
"a",
"x",
"y",
"coordinate",
"encode",
"in",
"compressed",
"format",
"Returned",
"is",
"always",
"33",
"bytes",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/bip38.py#L36-L47 |
14,177 | priestc/moneywagon | moneywagon/bip38.py | Bip38EncryptedPrivateKey.decrypt | def decrypt(self, passphrase, wif=False):
"""
BIP0038 non-ec-multiply decryption. Returns hex privkey.
"""
passphrase = normalize('NFC', unicode(passphrase))
if is_py2:
passphrase = passphrase.encode('utf8')
if self.ec_multiply:
raise Exception("N... | python | def decrypt(self, passphrase, wif=False):
"""
BIP0038 non-ec-multiply decryption. Returns hex privkey.
"""
passphrase = normalize('NFC', unicode(passphrase))
if is_py2:
passphrase = passphrase.encode('utf8')
if self.ec_multiply:
raise Exception("N... | [
"def",
"decrypt",
"(",
"self",
",",
"passphrase",
",",
"wif",
"=",
"False",
")",
":",
"passphrase",
"=",
"normalize",
"(",
"'NFC'",
",",
"unicode",
"(",
"passphrase",
")",
")",
"if",
"is_py2",
":",
"passphrase",
"=",
"passphrase",
".",
"encode",
"(",
"... | BIP0038 non-ec-multiply decryption. Returns hex privkey. | [
"BIP0038",
"non",
"-",
"ec",
"-",
"multiply",
"decryption",
".",
"Returns",
"hex",
"privkey",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/bip38.py#L115-L153 |
14,178 | priestc/moneywagon | moneywagon/bip38.py | Bip38EncryptedPrivateKey.encrypt | def encrypt(cls, crypto, privkey, passphrase):
"""
BIP0038 non-ec-multiply encryption. Returns BIP0038 encrypted privkey.
"""
pub_byte, priv_byte = get_magic_bytes(crypto)
privformat = get_privkey_format(privkey)
if privformat in ['wif_compressed','hex_compressed']:
... | python | def encrypt(cls, crypto, privkey, passphrase):
"""
BIP0038 non-ec-multiply encryption. Returns BIP0038 encrypted privkey.
"""
pub_byte, priv_byte = get_magic_bytes(crypto)
privformat = get_privkey_format(privkey)
if privformat in ['wif_compressed','hex_compressed']:
... | [
"def",
"encrypt",
"(",
"cls",
",",
"crypto",
",",
"privkey",
",",
"passphrase",
")",
":",
"pub_byte",
",",
"priv_byte",
"=",
"get_magic_bytes",
"(",
"crypto",
")",
"privformat",
"=",
"get_privkey_format",
"(",
"privkey",
")",
"if",
"privformat",
"in",
"[",
... | BIP0038 non-ec-multiply encryption. Returns BIP0038 encrypted privkey. | [
"BIP0038",
"non",
"-",
"ec",
"-",
"multiply",
"encryption",
".",
"Returns",
"BIP0038",
"encrypted",
"privkey",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/bip38.py#L156-L195 |
14,179 | priestc/moneywagon | moneywagon/bip38.py | Bip38EncryptedPrivateKey.create_from_intermediate | def create_from_intermediate(cls, crypto, intermediate_point, seed, compressed=True, include_cfrm=True):
"""
Given an intermediate point, given to us by "owner", generate an address
and encrypted private key that can be decoded by the passphrase used to generate
the intermediate point.
... | python | def create_from_intermediate(cls, crypto, intermediate_point, seed, compressed=True, include_cfrm=True):
"""
Given an intermediate point, given to us by "owner", generate an address
and encrypted private key that can be decoded by the passphrase used to generate
the intermediate point.
... | [
"def",
"create_from_intermediate",
"(",
"cls",
",",
"crypto",
",",
"intermediate_point",
",",
"seed",
",",
"compressed",
"=",
"True",
",",
"include_cfrm",
"=",
"True",
")",
":",
"flagbyte",
"=",
"b'\\x20'",
"if",
"compressed",
"else",
"b'\\x00'",
"payload",
"=... | Given an intermediate point, given to us by "owner", generate an address
and encrypted private key that can be decoded by the passphrase used to generate
the intermediate point. | [
"Given",
"an",
"intermediate",
"point",
"given",
"to",
"us",
"by",
"owner",
"generate",
"an",
"address",
"and",
"encrypted",
"private",
"key",
"that",
"can",
"be",
"decoded",
"by",
"the",
"passphrase",
"used",
"to",
"generate",
"the",
"intermediate",
"point",
... | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/bip38.py#L198-L242 |
14,180 | priestc/moneywagon | moneywagon/bip38.py | Bip38ConfirmationCode.generate_address | def generate_address(self, passphrase):
"""
Make sure the confirm code is valid for the given password and address.
"""
inter = Bip38IntermediatePoint.create(passphrase, ownersalt=self.ownersalt)
public_key = privtopub(inter.passpoint)
# from Bip38EncryptedPrivateKey.c... | python | def generate_address(self, passphrase):
"""
Make sure the confirm code is valid for the given password and address.
"""
inter = Bip38IntermediatePoint.create(passphrase, ownersalt=self.ownersalt)
public_key = privtopub(inter.passpoint)
# from Bip38EncryptedPrivateKey.c... | [
"def",
"generate_address",
"(",
"self",
",",
"passphrase",
")",
":",
"inter",
"=",
"Bip38IntermediatePoint",
".",
"create",
"(",
"passphrase",
",",
"ownersalt",
"=",
"self",
".",
"ownersalt",
")",
"public_key",
"=",
"privtopub",
"(",
"inter",
".",
"passpoint",... | Make sure the confirm code is valid for the given password and address. | [
"Make",
"sure",
"the",
"confirm",
"code",
"is",
"valid",
"for",
"the",
"given",
"password",
"and",
"address",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/bip38.py#L372-L397 |
14,181 | priestc/moneywagon | moneywagon/services/blockchain_services.py | SmartBitAU.push_tx | def push_tx(self, crypto, tx_hex):
"""
This method is untested.
"""
url = "%s/pushtx" % self.base_url
return self.post_url(url, {'hex': tx_hex}).content | python | def push_tx(self, crypto, tx_hex):
"""
This method is untested.
"""
url = "%s/pushtx" % self.base_url
return self.post_url(url, {'hex': tx_hex}).content | [
"def",
"push_tx",
"(",
"self",
",",
"crypto",
",",
"tx_hex",
")",
":",
"url",
"=",
"\"%s/pushtx\"",
"%",
"self",
".",
"base_url",
"return",
"self",
".",
"post_url",
"(",
"url",
",",
"{",
"'hex'",
":",
"tx_hex",
"}",
")",
".",
"content"
] | This method is untested. | [
"This",
"method",
"is",
"untested",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/services/blockchain_services.py#L339-L344 |
14,182 | priestc/moneywagon | moneywagon/network_replay.py | NetworkReplay.replay_block | def replay_block(self, block_to_replay, limit=5):
"""
Replay all transactions in parent currency to passed in "source" currency.
Block_to_replay can either be an integer or a block object.
"""
if block_to_replay == 'latest':
if self.verbose:
print("Ge... | python | def replay_block(self, block_to_replay, limit=5):
"""
Replay all transactions in parent currency to passed in "source" currency.
Block_to_replay can either be an integer or a block object.
"""
if block_to_replay == 'latest':
if self.verbose:
print("Ge... | [
"def",
"replay_block",
"(",
"self",
",",
"block_to_replay",
",",
"limit",
"=",
"5",
")",
":",
"if",
"block_to_replay",
"==",
"'latest'",
":",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"\"Getting latest %s block header\"",
"%",
"source",
".",
"upper",
... | Replay all transactions in parent currency to passed in "source" currency.
Block_to_replay can either be an integer or a block object. | [
"Replay",
"all",
"transactions",
"in",
"parent",
"currency",
"to",
"passed",
"in",
"source",
"currency",
".",
"Block_to_replay",
"can",
"either",
"be",
"an",
"integer",
"or",
"a",
"block",
"object",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/network_replay.py#L39-L73 |
14,183 | priestc/moneywagon | moneywagon/supply_estimator.py | get_block_adjustments | def get_block_adjustments(crypto, points=None, intervals=None, **modes):
"""
This utility is used to determine the actual block rate. The output can be
directly copied to the `blocktime_adjustments` setting.
"""
from moneywagon import get_block
all_points = []
if intervals:
latest_b... | python | def get_block_adjustments(crypto, points=None, intervals=None, **modes):
"""
This utility is used to determine the actual block rate. The output can be
directly copied to the `blocktime_adjustments` setting.
"""
from moneywagon import get_block
all_points = []
if intervals:
latest_b... | [
"def",
"get_block_adjustments",
"(",
"crypto",
",",
"points",
"=",
"None",
",",
"intervals",
"=",
"None",
",",
"*",
"*",
"modes",
")",
":",
"from",
"moneywagon",
"import",
"get_block",
"all_points",
"=",
"[",
"]",
"if",
"intervals",
":",
"latest_block_height... | This utility is used to determine the actual block rate. The output can be
directly copied to the `blocktime_adjustments` setting. | [
"This",
"utility",
"is",
"used",
"to",
"determine",
"the",
"actual",
"block",
"rate",
".",
"The",
"output",
"can",
"be",
"directly",
"copied",
"to",
"the",
"blocktime_adjustments",
"setting",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/supply_estimator.py#L217-L253 |
14,184 | priestc/moneywagon | moneywagon/supply_estimator.py | SupplyEstimator._per_era_supply | def _per_era_supply(self, block_height):
"""
Calculate the coin supply based on 'eras' defined in crypto_data. Some
currencies don't have a simple algorithmically defined halfing schedule
so coins supply has to be defined explicitly per era.
"""
coins = 0
for era ... | python | def _per_era_supply(self, block_height):
"""
Calculate the coin supply based on 'eras' defined in crypto_data. Some
currencies don't have a simple algorithmically defined halfing schedule
so coins supply has to be defined explicitly per era.
"""
coins = 0
for era ... | [
"def",
"_per_era_supply",
"(",
"self",
",",
"block_height",
")",
":",
"coins",
"=",
"0",
"for",
"era",
"in",
"self",
".",
"supply_data",
"[",
"'eras'",
"]",
":",
"end_block",
"=",
"era",
"[",
"'end'",
"]",
"start_block",
"=",
"era",
"[",
"'start'",
"]"... | Calculate the coin supply based on 'eras' defined in crypto_data. Some
currencies don't have a simple algorithmically defined halfing schedule
so coins supply has to be defined explicitly per era. | [
"Calculate",
"the",
"coin",
"supply",
"based",
"on",
"eras",
"defined",
"in",
"crypto_data",
".",
"Some",
"currencies",
"don",
"t",
"have",
"a",
"simple",
"algorithmically",
"defined",
"halfing",
"schedule",
"so",
"coins",
"supply",
"has",
"to",
"be",
"defined... | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/supply_estimator.py#L169-L189 |
14,185 | priestc/moneywagon | moneywagon/core.py | _prepare_consensus | def _prepare_consensus(FetcherClass, results):
"""
Given a list of results, return a list that is simplified to make consensus
determination possible. Returns two item tuple, first arg is simplified list,
the second argument is a list of all services used in making these results.
"""
# _get_resu... | python | def _prepare_consensus(FetcherClass, results):
"""
Given a list of results, return a list that is simplified to make consensus
determination possible. Returns two item tuple, first arg is simplified list,
the second argument is a list of all services used in making these results.
"""
# _get_resu... | [
"def",
"_prepare_consensus",
"(",
"FetcherClass",
",",
"results",
")",
":",
"# _get_results returns lists of 2 item list, first element is service, second is the returned value.",
"# when determining consensus amoung services, only take into account values returned.",
"if",
"hasattr",
"(",
... | Given a list of results, return a list that is simplified to make consensus
determination possible. Returns two item tuple, first arg is simplified list,
the second argument is a list of all services used in making these results. | [
"Given",
"a",
"list",
"of",
"results",
"return",
"a",
"list",
"that",
"is",
"simplified",
"to",
"make",
"consensus",
"determination",
"possible",
".",
"Returns",
"two",
"item",
"tuple",
"first",
"arg",
"is",
"simplified",
"list",
"the",
"second",
"argument",
... | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L692-L707 |
14,186 | priestc/moneywagon | moneywagon/core.py | _get_results | def _get_results(FetcherClass, services, kwargs, num_results=None, fast=0, verbose=False, timeout=None):
"""
Does the fetching in multiple threads of needed. Used by paranoid and fast mode.
"""
results = []
if not num_results or fast:
num_results = len(services)
with futures.ThreadPool... | python | def _get_results(FetcherClass, services, kwargs, num_results=None, fast=0, verbose=False, timeout=None):
"""
Does the fetching in multiple threads of needed. Used by paranoid and fast mode.
"""
results = []
if not num_results or fast:
num_results = len(services)
with futures.ThreadPool... | [
"def",
"_get_results",
"(",
"FetcherClass",
",",
"services",
",",
"kwargs",
",",
"num_results",
"=",
"None",
",",
"fast",
"=",
"0",
",",
"verbose",
"=",
"False",
",",
"timeout",
"=",
"None",
")",
":",
"results",
"=",
"[",
"]",
"if",
"not",
"num_results... | Does the fetching in multiple threads of needed. Used by paranoid and fast mode. | [
"Does",
"the",
"fetching",
"in",
"multiple",
"threads",
"of",
"needed",
".",
"Used",
"by",
"paranoid",
"and",
"fast",
"mode",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L709-L745 |
14,187 | priestc/moneywagon | moneywagon/core.py | _do_private_mode | def _do_private_mode(FetcherClass, services, kwargs, random_wait_seconds, timeout, verbose):
"""
Private mode is only applicable to address_balance, unspent_outputs, and
historical_transactions. There will always be a list for the `addresses`
argument. Each address goes to a random service. Also a rando... | python | def _do_private_mode(FetcherClass, services, kwargs, random_wait_seconds, timeout, verbose):
"""
Private mode is only applicable to address_balance, unspent_outputs, and
historical_transactions. There will always be a list for the `addresses`
argument. Each address goes to a random service. Also a rando... | [
"def",
"_do_private_mode",
"(",
"FetcherClass",
",",
"services",
",",
"kwargs",
",",
"random_wait_seconds",
",",
"timeout",
",",
"verbose",
")",
":",
"addresses",
"=",
"kwargs",
".",
"pop",
"(",
"'addresses'",
")",
"results",
"=",
"{",
"}",
"with",
"futures"... | Private mode is only applicable to address_balance, unspent_outputs, and
historical_transactions. There will always be a list for the `addresses`
argument. Each address goes to a random service. Also a random delay is
performed before the external fetch for improved privacy. | [
"Private",
"mode",
"is",
"only",
"applicable",
"to",
"address_balance",
"unspent_outputs",
"and",
"historical_transactions",
".",
"There",
"will",
"always",
"be",
"a",
"list",
"for",
"the",
"addresses",
"argument",
".",
"Each",
"address",
"goes",
"to",
"a",
"ran... | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L747-L778 |
14,188 | priestc/moneywagon | moneywagon/core.py | currency_to_protocol | def currency_to_protocol(amount):
"""
Convert a string of 'currency units' to 'protocol units'. For instance
converts 19.1 bitcoin to 1910000000 satoshis.
Input is a float, output is an integer that is 1e8 times larger.
It is hard to do this conversion because multiplying
floats causes roundin... | python | def currency_to_protocol(amount):
"""
Convert a string of 'currency units' to 'protocol units'. For instance
converts 19.1 bitcoin to 1910000000 satoshis.
Input is a float, output is an integer that is 1e8 times larger.
It is hard to do this conversion because multiplying
floats causes roundin... | [
"def",
"currency_to_protocol",
"(",
"amount",
")",
":",
"if",
"type",
"(",
"amount",
")",
"in",
"[",
"float",
",",
"int",
"]",
":",
"amount",
"=",
"\"%.8f\"",
"%",
"amount",
"return",
"int",
"(",
"amount",
".",
"replace",
"(",
"\".\"",
",",
"''",
")"... | Convert a string of 'currency units' to 'protocol units'. For instance
converts 19.1 bitcoin to 1910000000 satoshis.
Input is a float, output is an integer that is 1e8 times larger.
It is hard to do this conversion because multiplying
floats causes rounding nubers which will mess up the transactions c... | [
"Convert",
"a",
"string",
"of",
"currency",
"units",
"to",
"protocol",
"units",
".",
"For",
"instance",
"converts",
"19",
".",
"1",
"bitcoin",
"to",
"1910000000",
"satoshis",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L781-L801 |
14,189 | priestc/moneywagon | moneywagon/core.py | to_rawtx | def to_rawtx(tx):
"""
Take a tx object in the moneywagon format and convert it to the format
that pybitcointools's `serialize` funcion takes, then return in raw hex
format.
"""
if tx.get('hex'):
return tx['hex']
new_tx = {}
locktime = tx.get('locktime', 0)
new_tx['locktime'... | python | def to_rawtx(tx):
"""
Take a tx object in the moneywagon format and convert it to the format
that pybitcointools's `serialize` funcion takes, then return in raw hex
format.
"""
if tx.get('hex'):
return tx['hex']
new_tx = {}
locktime = tx.get('locktime', 0)
new_tx['locktime'... | [
"def",
"to_rawtx",
"(",
"tx",
")",
":",
"if",
"tx",
".",
"get",
"(",
"'hex'",
")",
":",
"return",
"tx",
"[",
"'hex'",
"]",
"new_tx",
"=",
"{",
"}",
"locktime",
"=",
"tx",
".",
"get",
"(",
"'locktime'",
",",
"0",
")",
"new_tx",
"[",
"'locktime'",
... | Take a tx object in the moneywagon format and convert it to the format
that pybitcointools's `serialize` funcion takes, then return in raw hex
format. | [
"Take",
"a",
"tx",
"object",
"in",
"the",
"moneywagon",
"format",
"and",
"convert",
"it",
"to",
"the",
"format",
"that",
"pybitcointools",
"s",
"serialize",
"funcion",
"takes",
"then",
"return",
"in",
"raw",
"hex",
"format",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L862-L891 |
14,190 | priestc/moneywagon | moneywagon/core.py | Service.check_error | def check_error(self, response):
"""
If the service is returning an error, this function should raise an exception.
such as SkipThisService
"""
if response.status_code == 500:
raise ServiceError("500 - " + response.content)
if response.status_code == 503:
... | python | def check_error(self, response):
"""
If the service is returning an error, this function should raise an exception.
such as SkipThisService
"""
if response.status_code == 500:
raise ServiceError("500 - " + response.content)
if response.status_code == 503:
... | [
"def",
"check_error",
"(",
"self",
",",
"response",
")",
":",
"if",
"response",
".",
"status_code",
"==",
"500",
":",
"raise",
"ServiceError",
"(",
"\"500 - \"",
"+",
"response",
".",
"content",
")",
"if",
"response",
".",
"status_code",
"==",
"503",
":",
... | If the service is returning an error, this function should raise an exception.
such as SkipThisService | [
"If",
"the",
"service",
"is",
"returning",
"an",
"error",
"this",
"function",
"should",
"raise",
"an",
"exception",
".",
"such",
"as",
"SkipThisService"
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L111-L131 |
14,191 | priestc/moneywagon | moneywagon/core.py | Service.convert_currency | def convert_currency(self, base_fiat, base_amount, target_fiat):
"""
Convert one fiat amount to another fiat. Uses the fixer.io service.
"""
url = "http://api.fixer.io/latest?base=%s" % base_fiat
data = self.get_url(url).json()
try:
return data['rates'][target... | python | def convert_currency(self, base_fiat, base_amount, target_fiat):
"""
Convert one fiat amount to another fiat. Uses the fixer.io service.
"""
url = "http://api.fixer.io/latest?base=%s" % base_fiat
data = self.get_url(url).json()
try:
return data['rates'][target... | [
"def",
"convert_currency",
"(",
"self",
",",
"base_fiat",
",",
"base_amount",
",",
"target_fiat",
")",
":",
"url",
"=",
"\"http://api.fixer.io/latest?base=%s\"",
"%",
"base_fiat",
"data",
"=",
"self",
".",
"get_url",
"(",
"url",
")",
".",
"json",
"(",
")",
"... | Convert one fiat amount to another fiat. Uses the fixer.io service. | [
"Convert",
"one",
"fiat",
"amount",
"to",
"another",
"fiat",
".",
"Uses",
"the",
"fixer",
".",
"io",
"service",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L133-L142 |
14,192 | priestc/moneywagon | moneywagon/core.py | Service.fix_symbol | def fix_symbol(self, symbol, reverse=False):
"""
In comes a moneywagon format symbol, and returned in the symbol converted
to one the service can understand.
"""
if not self.symbol_mapping:
return symbol
for old, new in self.symbol_mapping:
if rev... | python | def fix_symbol(self, symbol, reverse=False):
"""
In comes a moneywagon format symbol, and returned in the symbol converted
to one the service can understand.
"""
if not self.symbol_mapping:
return symbol
for old, new in self.symbol_mapping:
if rev... | [
"def",
"fix_symbol",
"(",
"self",
",",
"symbol",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"symbol_mapping",
":",
"return",
"symbol",
"for",
"old",
",",
"new",
"in",
"self",
".",
"symbol_mapping",
":",
"if",
"reverse",
":",
"if"... | In comes a moneywagon format symbol, and returned in the symbol converted
to one the service can understand. | [
"In",
"comes",
"a",
"moneywagon",
"format",
"symbol",
"and",
"returned",
"in",
"the",
"symbol",
"converted",
"to",
"one",
"the",
"service",
"can",
"understand",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L151-L167 |
14,193 | priestc/moneywagon | moneywagon/core.py | Service.parse_market | def parse_market(self, market, split_char='_'):
"""
In comes the market identifier directly from the service. Returned is
the crypto and fiat identifier in moneywagon format.
"""
crypto, fiat = market.lower().split(split_char)
return (
self.fix_symbol(crypto, ... | python | def parse_market(self, market, split_char='_'):
"""
In comes the market identifier directly from the service. Returned is
the crypto and fiat identifier in moneywagon format.
"""
crypto, fiat = market.lower().split(split_char)
return (
self.fix_symbol(crypto, ... | [
"def",
"parse_market",
"(",
"self",
",",
"market",
",",
"split_char",
"=",
"'_'",
")",
":",
"crypto",
",",
"fiat",
"=",
"market",
".",
"lower",
"(",
")",
".",
"split",
"(",
"split_char",
")",
"return",
"(",
"self",
".",
"fix_symbol",
"(",
"crypto",
"... | In comes the market identifier directly from the service. Returned is
the crypto and fiat identifier in moneywagon format. | [
"In",
"comes",
"the",
"market",
"identifier",
"directly",
"from",
"the",
"service",
".",
"Returned",
"is",
"the",
"crypto",
"and",
"fiat",
"identifier",
"in",
"moneywagon",
"format",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L169-L178 |
14,194 | priestc/moneywagon | moneywagon/core.py | Service.make_market | def make_market(self, crypto, fiat, seperator="_"):
"""
Convert a crypto and fiat to a "market" string. All exchanges use their
own format for specifying markets. Subclasses can define their own
implementation.
"""
return ("%s%s%s" % (
self.fix_symbol(crypto),... | python | def make_market(self, crypto, fiat, seperator="_"):
"""
Convert a crypto and fiat to a "market" string. All exchanges use their
own format for specifying markets. Subclasses can define their own
implementation.
"""
return ("%s%s%s" % (
self.fix_symbol(crypto),... | [
"def",
"make_market",
"(",
"self",
",",
"crypto",
",",
"fiat",
",",
"seperator",
"=",
"\"_\"",
")",
":",
"return",
"(",
"\"%s%s%s\"",
"%",
"(",
"self",
".",
"fix_symbol",
"(",
"crypto",
")",
",",
"seperator",
",",
"self",
".",
"fix_symbol",
"(",
"fiat"... | Convert a crypto and fiat to a "market" string. All exchanges use their
own format for specifying markets. Subclasses can define their own
implementation. | [
"Convert",
"a",
"crypto",
"and",
"fiat",
"to",
"a",
"market",
"string",
".",
"All",
"exchanges",
"use",
"their",
"own",
"format",
"for",
"specifying",
"markets",
".",
"Subclasses",
"can",
"define",
"their",
"own",
"implementation",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L180-L188 |
14,195 | priestc/moneywagon | moneywagon/core.py | Service._external_request | def _external_request(self, method, url, *args, **kwargs):
"""
Wrapper for requests.get with useragent automatically set.
And also all requests are reponses are cached.
"""
self.last_url = url
if url in self.responses.keys() and method == 'get':
return self.re... | python | def _external_request(self, method, url, *args, **kwargs):
"""
Wrapper for requests.get with useragent automatically set.
And also all requests are reponses are cached.
"""
self.last_url = url
if url in self.responses.keys() and method == 'get':
return self.re... | [
"def",
"_external_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"last_url",
"=",
"url",
"if",
"url",
"in",
"self",
".",
"responses",
".",
"keys",
"(",
")",
"and",
"method",
"==",... | Wrapper for requests.get with useragent automatically set.
And also all requests are reponses are cached. | [
"Wrapper",
"for",
"requests",
".",
"get",
"with",
"useragent",
"automatically",
"set",
".",
"And",
"also",
"all",
"requests",
"are",
"reponses",
"are",
"cached",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L211-L246 |
14,196 | priestc/moneywagon | moneywagon/core.py | Service.get_block | def get_block(self, crypto, block_hash='', block_number='', latest=False):
"""
Get block based on either block height, block number or get the latest
block. Only one of the previous arguments must be passed on.
Returned is a dictionary object with the following keys:
* required... | python | def get_block(self, crypto, block_hash='', block_number='', latest=False):
"""
Get block based on either block height, block number or get the latest
block. Only one of the previous arguments must be passed on.
Returned is a dictionary object with the following keys:
* required... | [
"def",
"get_block",
"(",
"self",
",",
"crypto",
",",
"block_hash",
"=",
"''",
",",
"block_number",
"=",
"''",
",",
"latest",
"=",
"False",
")",
":",
"raise",
"NotImplementedError",
"(",
"self",
".",
"name",
"+",
"\" does not support getting getting block data. \... | Get block based on either block height, block number or get the latest
block. Only one of the previous arguments must be passed on.
Returned is a dictionary object with the following keys:
* required fields:
block_number - int
size - size of block
time - datetime objec... | [
"Get",
"block",
"based",
"on",
"either",
"block",
"height",
"block",
"number",
"or",
"get",
"the",
"latest",
"block",
".",
"Only",
"one",
"of",
"the",
"previous",
"arguments",
"must",
"be",
"passed",
"on",
"."
] | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L381-L411 |
14,197 | priestc/moneywagon | moneywagon/core.py | Service.make_order | def make_order(self, crypto, fiat, amount, price, type="limit"):
"""
This method buys or sells `crypto` on an exchange using `fiat` balance.
Type can either be "fill-or-kill", "post-only", "market", or "limit".
To get what modes are supported, consult make_order.supported_types
i... | python | def make_order(self, crypto, fiat, amount, price, type="limit"):
"""
This method buys or sells `crypto` on an exchange using `fiat` balance.
Type can either be "fill-or-kill", "post-only", "market", or "limit".
To get what modes are supported, consult make_order.supported_types
i... | [
"def",
"make_order",
"(",
"self",
",",
"crypto",
",",
"fiat",
",",
"amount",
",",
"price",
",",
"type",
"=",
"\"limit\"",
")",
":",
"raise",
"NotImplementedError",
"(",
"self",
".",
"name",
"+",
"\" does not support making orders. \"",
"\"Or rather it has no defin... | This method buys or sells `crypto` on an exchange using `fiat` balance.
Type can either be "fill-or-kill", "post-only", "market", or "limit".
To get what modes are supported, consult make_order.supported_types
if one is defined. | [
"This",
"method",
"buys",
"or",
"sells",
"crypto",
"on",
"an",
"exchange",
"using",
"fiat",
"balance",
".",
"Type",
"can",
"either",
"be",
"fill",
"-",
"or",
"-",
"kill",
"post",
"-",
"only",
"market",
"or",
"limit",
".",
"To",
"get",
"what",
"modes",
... | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L440-L450 |
14,198 | priestc/moneywagon | moneywagon/core.py | AutoFallbackFetcher._try_services | def _try_services(self, method_name, *args, **kwargs):
"""
Try each service until one returns a response. This function only
catches the bare minimum of exceptions from the service class. We want
exceptions to be raised so the service classes can be debugged and
fixed quickly.
... | python | def _try_services(self, method_name, *args, **kwargs):
"""
Try each service until one returns a response. This function only
catches the bare minimum of exceptions from the service class. We want
exceptions to be raised so the service classes can be debugged and
fixed quickly.
... | [
"def",
"_try_services",
"(",
"self",
",",
"method_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"crypto",
"=",
"(",
"(",
"args",
"and",
"args",
"[",
"0",
"]",
")",
"or",
"kwargs",
"[",
"'crypto'",
"]",
")",
".",
"lower",
"(",
")",
... | Try each service until one returns a response. This function only
catches the bare minimum of exceptions from the service class. We want
exceptions to be raised so the service classes can be debugged and
fixed quickly. | [
"Try",
"each",
"service",
"until",
"one",
"returns",
"a",
"response",
".",
"This",
"function",
"only",
"catches",
"the",
"bare",
"minimum",
"of",
"exceptions",
"from",
"the",
"service",
"class",
".",
"We",
"want",
"exceptions",
"to",
"be",
"raised",
"so",
... | 00518f1f557dcca8b3031f46d3564c2baa0227a3 | https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/core.py#L528-L592 |
14,199 | yt-project/unyt | unyt/array.py | uconcatenate | def uconcatenate(arrs, axis=0):
"""Concatenate a sequence of arrays.
This wrapper around numpy.concatenate preserves units. All input arrays
must have the same units. See the documentation of numpy.concatenate for
full details.
Examples
--------
>>> from unyt import cm
>>> A = [1, 2, ... | python | def uconcatenate(arrs, axis=0):
"""Concatenate a sequence of arrays.
This wrapper around numpy.concatenate preserves units. All input arrays
must have the same units. See the documentation of numpy.concatenate for
full details.
Examples
--------
>>> from unyt import cm
>>> A = [1, 2, ... | [
"def",
"uconcatenate",
"(",
"arrs",
",",
"axis",
"=",
"0",
")",
":",
"v",
"=",
"np",
".",
"concatenate",
"(",
"arrs",
",",
"axis",
"=",
"axis",
")",
"v",
"=",
"_validate_numpy_wrapper_units",
"(",
"v",
",",
"arrs",
")",
"return",
"v"
] | Concatenate a sequence of arrays.
This wrapper around numpy.concatenate preserves units. All input arrays
must have the same units. See the documentation of numpy.concatenate for
full details.
Examples
--------
>>> from unyt import cm
>>> A = [1, 2, 3]*cm
>>> B = [2, 3, 4]*cm
>>> ... | [
"Concatenate",
"a",
"sequence",
"of",
"arrays",
"."
] | 7a4eafc229f83784f4c63d639aee554f9a6b1ca0 | https://github.com/yt-project/unyt/blob/7a4eafc229f83784f4c63d639aee554f9a6b1ca0/unyt/array.py#L1945-L1963 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.