repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Spinmob/spinmob
egg/_gui.py
DataboxPlot._set_number_of_plots
def _set_number_of_plots(self, n): """ Adjusts number of plots & curves to the desired value the gui. """ # multi plot, right number of plots and curves = great! if self.button_multi.is_checked() \ and len(self._curves) == len(self.plot_widgets) \ a...
python
def _set_number_of_plots(self, n): """ Adjusts number of plots & curves to the desired value the gui. """ # multi plot, right number of plots and curves = great! if self.button_multi.is_checked() \ and len(self._curves) == len(self.plot_widgets) \ a...
[ "def", "_set_number_of_plots", "(", "self", ",", "n", ")", ":", "# multi plot, right number of plots and curves = great!", "if", "self", ".", "button_multi", ".", "is_checked", "(", ")", "and", "len", "(", "self", ".", "_curves", ")", "==", "len", "(", "self", ...
Adjusts number of plots & curves to the desired value the gui.
[ "Adjusts", "number", "of", "plots", "&", "curves", "to", "the", "desired", "value", "the", "gui", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_gui.py#L2879-L2945
Spinmob/spinmob
egg/_gui.py
DataboxPlot._update_linked_axes
def _update_linked_axes(self): """ Loops over the axes and links / unlinks them. """ # no axes to link! if len(self.plot_widgets) <= 1: return # get the first plotItem a = self.plot_widgets[0].plotItem.getViewBox() # now loop through all the axes...
python
def _update_linked_axes(self): """ Loops over the axes and links / unlinks them. """ # no axes to link! if len(self.plot_widgets) <= 1: return # get the first plotItem a = self.plot_widgets[0].plotItem.getViewBox() # now loop through all the axes...
[ "def", "_update_linked_axes", "(", "self", ")", ":", "# no axes to link!", "if", "len", "(", "self", ".", "plot_widgets", ")", "<=", "1", ":", "return", "# get the first plotItem", "a", "=", "self", ".", "plot_widgets", "[", "0", "]", ".", "plotItem", ".", ...
Loops over the axes and links / unlinks them.
[ "Loops", "over", "the", "axes", "and", "links", "/", "unlinks", "them", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_gui.py#L2948-L2970
thriftrw/thriftrw-python
thriftrw/compile/scope.py
Scope.resolve_const_spec
def resolve_const_spec(self, name, lineno): """Finds and links the ConstSpec with the given name.""" if name in self.const_specs: return self.const_specs[name].link(self) if '.' in name: include_name, component = name.split('.', 1) if include_name in self.in...
python
def resolve_const_spec(self, name, lineno): """Finds and links the ConstSpec with the given name.""" if name in self.const_specs: return self.const_specs[name].link(self) if '.' in name: include_name, component = name.split('.', 1) if include_name in self.in...
[ "def", "resolve_const_spec", "(", "self", ",", "name", ",", "lineno", ")", ":", "if", "name", "in", "self", ".", "const_specs", ":", "return", "self", ".", "const_specs", "[", "name", "]", ".", "link", "(", "self", ")", "if", "'.'", "in", "name", ":"...
Finds and links the ConstSpec with the given name.
[ "Finds", "and", "links", "the", "ConstSpec", "with", "the", "given", "name", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/scope.py#L76-L93
thriftrw/thriftrw-python
thriftrw/compile/scope.py
Scope.resolve_type_spec
def resolve_type_spec(self, name, lineno): """Finds and links the TypeSpec with the given name.""" if name in self.type_specs: return self.type_specs[name].link(self) if '.' in name: include_name, component = name.split('.', 1) if include_name in self.includ...
python
def resolve_type_spec(self, name, lineno): """Finds and links the TypeSpec with the given name.""" if name in self.type_specs: return self.type_specs[name].link(self) if '.' in name: include_name, component = name.split('.', 1) if include_name in self.includ...
[ "def", "resolve_type_spec", "(", "self", ",", "name", ",", "lineno", ")", ":", "if", "name", "in", "self", ".", "type_specs", ":", "return", "self", ".", "type_specs", "[", "name", "]", ".", "link", "(", "self", ")", "if", "'.'", "in", "name", ":", ...
Finds and links the TypeSpec with the given name.
[ "Finds", "and", "links", "the", "TypeSpec", "with", "the", "given", "name", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/scope.py#L95-L112
thriftrw/thriftrw-python
thriftrw/compile/scope.py
Scope.resolve_service_spec
def resolve_service_spec(self, name, lineno): """Finds and links the ServiceSpec with the given name.""" if name in self.service_specs: return self.service_specs[name].link(self) if '.' in name: include_name, component = name.split('.', 2) if include_name in...
python
def resolve_service_spec(self, name, lineno): """Finds and links the ServiceSpec with the given name.""" if name in self.service_specs: return self.service_specs[name].link(self) if '.' in name: include_name, component = name.split('.', 2) if include_name in...
[ "def", "resolve_service_spec", "(", "self", ",", "name", ",", "lineno", ")", ":", "if", "name", "in", "self", ".", "service_specs", ":", "return", "self", ".", "service_specs", "[", "name", "]", ".", "link", "(", "self", ")", "if", "'.'", "in", "name",...
Finds and links the ServiceSpec with the given name.
[ "Finds", "and", "links", "the", "ServiceSpec", "with", "the", "given", "name", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/scope.py#L114-L131
thriftrw/thriftrw-python
thriftrw/compile/scope.py
Scope.add_include
def add_include(self, name, included_scope, module): """Register an imported module into this scope. Raises ``ThriftCompilerError`` if the name has already been used. """ # The compiler already ensures this. If we still get here with a # conflict, that's a bug. assert na...
python
def add_include(self, name, included_scope, module): """Register an imported module into this scope. Raises ``ThriftCompilerError`` if the name has already been used. """ # The compiler already ensures this. If we still get here with a # conflict, that's a bug. assert na...
[ "def", "add_include", "(", "self", ",", "name", ",", "included_scope", ",", "module", ")", ":", "# The compiler already ensures this. If we still get here with a", "# conflict, that's a bug.", "assert", "name", "not", "in", "self", ".", "included_scopes", "self", ".", "...
Register an imported module into this scope. Raises ``ThriftCompilerError`` if the name has already been used.
[ "Register", "an", "imported", "module", "into", "this", "scope", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/scope.py#L133-L143
thriftrw/thriftrw-python
thriftrw/compile/scope.py
Scope.add_service_spec
def add_service_spec(self, service_spec): """Registers the given ``ServiceSpec`` into the scope. Raises ``ThriftCompilerError`` if the name has already been used. """ assert service_spec is not None if service_spec.name in self.service_specs: raise ThriftCompilerErr...
python
def add_service_spec(self, service_spec): """Registers the given ``ServiceSpec`` into the scope. Raises ``ThriftCompilerError`` if the name has already been used. """ assert service_spec is not None if service_spec.name in self.service_specs: raise ThriftCompilerErr...
[ "def", "add_service_spec", "(", "self", ",", "service_spec", ")", ":", "assert", "service_spec", "is", "not", "None", "if", "service_spec", ".", "name", "in", "self", ".", "service_specs", ":", "raise", "ThriftCompilerError", "(", "'Cannot define service \"%s\". Tha...
Registers the given ``ServiceSpec`` into the scope. Raises ``ThriftCompilerError`` if the name has already been used.
[ "Registers", "the", "given", "ServiceSpec", "into", "the", "scope", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/scope.py#L145-L157
thriftrw/thriftrw-python
thriftrw/compile/scope.py
Scope.add_const_spec
def add_const_spec(self, const_spec): """Adds a ConstSpec to the compliation scope. If the ConstSpec's ``save`` attribute is True, the constant will be added to the module at the top-level. """ if const_spec.name in self.const_specs: raise ThriftCompilerError( ...
python
def add_const_spec(self, const_spec): """Adds a ConstSpec to the compliation scope. If the ConstSpec's ``save`` attribute is True, the constant will be added to the module at the top-level. """ if const_spec.name in self.const_specs: raise ThriftCompilerError( ...
[ "def", "add_const_spec", "(", "self", ",", "const_spec", ")", ":", "if", "const_spec", ".", "name", "in", "self", ".", "const_specs", ":", "raise", "ThriftCompilerError", "(", "'Cannot define constant \"%s\". That name is already taken.'", "%", "const_spec", ".", "nam...
Adds a ConstSpec to the compliation scope. If the ConstSpec's ``save`` attribute is True, the constant will be added to the module at the top-level.
[ "Adds", "a", "ConstSpec", "to", "the", "compliation", "scope", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/scope.py#L159-L170
thriftrw/thriftrw-python
thriftrw/compile/scope.py
Scope.add_surface
def add_surface(self, name, surface): """Adds a top-level attribute with the given name to the module.""" assert surface is not None if hasattr(self.module, name): raise ThriftCompilerError( 'Cannot define "%s". The name has already been used.' % name ) ...
python
def add_surface(self, name, surface): """Adds a top-level attribute with the given name to the module.""" assert surface is not None if hasattr(self.module, name): raise ThriftCompilerError( 'Cannot define "%s". The name has already been used.' % name ) ...
[ "def", "add_surface", "(", "self", ",", "name", ",", "surface", ")", ":", "assert", "surface", "is", "not", "None", "if", "hasattr", "(", "self", ".", "module", ",", "name", ")", ":", "raise", "ThriftCompilerError", "(", "'Cannot define \"%s\". The name has al...
Adds a top-level attribute with the given name to the module.
[ "Adds", "a", "top", "-", "level", "attribute", "with", "the", "given", "name", "to", "the", "module", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/scope.py#L172-L181
thriftrw/thriftrw-python
thriftrw/compile/scope.py
Scope.add_type_spec
def add_type_spec(self, name, spec, lineno): """Adds the given type to the scope. :param str name: Name of the new type :param spec: ``TypeSpec`` object containing information on the type, or a ``TypeReference`` if this is meant to be resolved during the ...
python
def add_type_spec(self, name, spec, lineno): """Adds the given type to the scope. :param str name: Name of the new type :param spec: ``TypeSpec`` object containing information on the type, or a ``TypeReference`` if this is meant to be resolved during the ...
[ "def", "add_type_spec", "(", "self", ",", "name", ",", "spec", ",", "lineno", ")", ":", "assert", "type", "is", "not", "None", "if", "name", "in", "self", ".", "type_specs", ":", "raise", "ThriftCompilerError", "(", "'Cannot define type \"%s\" at line %d. '", ...
Adds the given type to the scope. :param str name: Name of the new type :param spec: ``TypeSpec`` object containing information on the type, or a ``TypeReference`` if this is meant to be resolved during the ``link`` stage. :param lineno: ...
[ "Adds", "the", "given", "type", "to", "the", "scope", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/scope.py#L183-L204
Spinmob/spinmob
_functions.py
coarsen_array
def coarsen_array(a, level=2, method='mean'): """ Returns a coarsened (binned) version of the data. Currently supports any of the numpy array operations, e.g. min, max, mean, std, ... level=2 means every two data points will be binned. level=0 or 1 just returns a copy of the array """ i...
python
def coarsen_array(a, level=2, method='mean'): """ Returns a coarsened (binned) version of the data. Currently supports any of the numpy array operations, e.g. min, max, mean, std, ... level=2 means every two data points will be binned. level=0 or 1 just returns a copy of the array """ i...
[ "def", "coarsen_array", "(", "a", ",", "level", "=", "2", ",", "method", "=", "'mean'", ")", ":", "if", "a", "is", "None", ":", "return", "None", "# make sure it's a numpy array", "a", "=", "_n", ".", "array", "(", "a", ")", "# quickest option", "if", ...
Returns a coarsened (binned) version of the data. Currently supports any of the numpy array operations, e.g. min, max, mean, std, ... level=2 means every two data points will be binned. level=0 or 1 just returns a copy of the array
[ "Returns", "a", "coarsened", "(", "binned", ")", "version", "of", "the", "data", ".", "Currently", "supports", "any", "of", "the", "numpy", "array", "operations", "e", ".", "g", ".", "min", "max", "mean", "std", "...", "level", "=", "2", "means", "ever...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L10-L33
Spinmob/spinmob
_functions.py
coarsen_data
def coarsen_data(x, y, ey=None, ex=None, level=2, exponential=False): """ Coarsens the supplied data set. Returns coarsened arrays of x, y, along with quadrature-coarsened arrays of ey and ex if specified. Parameters ---------- x, y Data arrays. Can be lists (will convert to numpy a...
python
def coarsen_data(x, y, ey=None, ex=None, level=2, exponential=False): """ Coarsens the supplied data set. Returns coarsened arrays of x, y, along with quadrature-coarsened arrays of ey and ex if specified. Parameters ---------- x, y Data arrays. Can be lists (will convert to numpy a...
[ "def", "coarsen_data", "(", "x", ",", "y", ",", "ey", "=", "None", ",", "ex", "=", "None", ",", "level", "=", "2", ",", "exponential", "=", "False", ")", ":", "# Normal coarsening", "if", "not", "exponential", ":", "# Coarsen the data", "xc", "=", "coa...
Coarsens the supplied data set. Returns coarsened arrays of x, y, along with quadrature-coarsened arrays of ey and ex if specified. Parameters ---------- x, y Data arrays. Can be lists (will convert to numpy arrays). These are coarsened by taking an average. ey=None, ex=None ...
[ "Coarsens", "the", "supplied", "data", "set", ".", "Returns", "coarsened", "arrays", "of", "x", "y", "along", "with", "quadrature", "-", "coarsened", "arrays", "of", "ey", "and", "ex", "if", "specified", ".", "Parameters", "----------", "x", "y", "Data", "...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L35-L124
Spinmob/spinmob
_functions.py
coarsen_matrix
def coarsen_matrix(Z, xlevel=0, ylevel=0, method='average'): """ This returns a coarsened numpy matrix. method can be 'average', 'maximum', or 'minimum' """ # coarsen x if not ylevel: Z_coarsened = Z else: temp = [] for z in Z: temp.append(coarsen_array(z, ylevel, m...
python
def coarsen_matrix(Z, xlevel=0, ylevel=0, method='average'): """ This returns a coarsened numpy matrix. method can be 'average', 'maximum', or 'minimum' """ # coarsen x if not ylevel: Z_coarsened = Z else: temp = [] for z in Z: temp.append(coarsen_array(z, ylevel, m...
[ "def", "coarsen_matrix", "(", "Z", ",", "xlevel", "=", "0", ",", "ylevel", "=", "0", ",", "method", "=", "'average'", ")", ":", "# coarsen x", "if", "not", "ylevel", ":", "Z_coarsened", "=", "Z", "else", ":", "temp", "=", "[", "]", "for", "z", "in"...
This returns a coarsened numpy matrix. method can be 'average', 'maximum', or 'minimum'
[ "This", "returns", "a", "coarsened", "numpy", "matrix", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L128-L162
Spinmob/spinmob
_functions.py
erange
def erange(start, end, steps): """ Returns a numpy array over the specified range taking geometric steps. See also numpy.logspace() """ if start == 0: print("Nothing you multiply zero by gives you anything but zero. Try picking something small.") return None if end == 0: ...
python
def erange(start, end, steps): """ Returns a numpy array over the specified range taking geometric steps. See also numpy.logspace() """ if start == 0: print("Nothing you multiply zero by gives you anything but zero. Try picking something small.") return None if end == 0: ...
[ "def", "erange", "(", "start", ",", "end", ",", "steps", ")", ":", "if", "start", "==", "0", ":", "print", "(", "\"Nothing you multiply zero by gives you anything but zero. Try picking something small.\"", ")", "return", "None", "if", "end", "==", "0", ":", "print...
Returns a numpy array over the specified range taking geometric steps. See also numpy.logspace()
[ "Returns", "a", "numpy", "array", "over", "the", "specified", "range", "taking", "geometric", "steps", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L165-L188
Spinmob/spinmob
_functions.py
is_a_number
def is_a_number(s): """ This takes an object and determines whether it's a number or a string representing a number. """ if _s.fun.is_iterable(s) and not type(s) == str: return False try: float(s) return 1 except: try: complex(s) return 2 ...
python
def is_a_number(s): """ This takes an object and determines whether it's a number or a string representing a number. """ if _s.fun.is_iterable(s) and not type(s) == str: return False try: float(s) return 1 except: try: complex(s) return 2 ...
[ "def", "is_a_number", "(", "s", ")", ":", "if", "_s", ".", "fun", ".", "is_iterable", "(", "s", ")", "and", "not", "type", "(", "s", ")", "==", "str", ":", "return", "False", "try", ":", "float", "(", "s", ")", "return", "1", "except", ":", "tr...
This takes an object and determines whether it's a number or a string representing a number.
[ "This", "takes", "an", "object", "and", "determines", "whether", "it", "s", "a", "number", "or", "a", "string", "representing", "a", "number", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L190-L209
Spinmob/spinmob
_functions.py
array_shift
def array_shift(a, n, fill="average"): """ This will return an array with all the elements shifted forward in index by n. a is the array n is the amount by which to shift (can be positive or negative) fill="average" fill the new empty elements with the average of the array fill="wrap" ...
python
def array_shift(a, n, fill="average"): """ This will return an array with all the elements shifted forward in index by n. a is the array n is the amount by which to shift (can be positive or negative) fill="average" fill the new empty elements with the average of the array fill="wrap" ...
[ "def", "array_shift", "(", "a", ",", "n", ",", "fill", "=", "\"average\"", ")", ":", "new_a", "=", "_n", ".", "array", "(", "a", ")", "if", "n", "==", "0", ":", "return", "new_a", "fill_array", "=", "_n", ".", "array", "(", "[", "]", ")", "fill...
This will return an array with all the elements shifted forward in index by n. a is the array n is the amount by which to shift (can be positive or negative) fill="average" fill the new empty elements with the average of the array fill="wrap" fill the new empty elements with the lopped-of...
[ "This", "will", "return", "an", "array", "with", "all", "the", "elements", "shifted", "forward", "in", "index", "by", "n", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L224-L259
Spinmob/spinmob
_functions.py
assemble_covariance
def assemble_covariance(error, correlation): """ This takes an error vector and a correlation matrix and assembles the covariance """ covariance = [] for n in range(0, len(error)): covariance.append([]) for m in range(0, len(error)): covariance[n].append(correlation[n][m...
python
def assemble_covariance(error, correlation): """ This takes an error vector and a correlation matrix and assembles the covariance """ covariance = [] for n in range(0, len(error)): covariance.append([]) for m in range(0, len(error)): covariance[n].append(correlation[n][m...
[ "def", "assemble_covariance", "(", "error", ",", "correlation", ")", ":", "covariance", "=", "[", "]", "for", "n", "in", "range", "(", "0", ",", "len", "(", "error", ")", ")", ":", "covariance", ".", "append", "(", "[", "]", ")", "for", "m", "in", ...
This takes an error vector and a correlation matrix and assembles the covariance
[ "This", "takes", "an", "error", "vector", "and", "a", "correlation", "matrix", "and", "assembles", "the", "covariance" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L263-L273
Spinmob/spinmob
_functions.py
combine_dictionaries
def combine_dictionaries(a, b): """ returns the combined dictionary. a's values preferentially chosen """ c = {} for key in list(b.keys()): c[key]=b[key] for key in list(a.keys()): c[key]=a[key] return c
python
def combine_dictionaries(a, b): """ returns the combined dictionary. a's values preferentially chosen """ c = {} for key in list(b.keys()): c[key]=b[key] for key in list(a.keys()): c[key]=a[key] return c
[ "def", "combine_dictionaries", "(", "a", ",", "b", ")", ":", "c", "=", "{", "}", "for", "key", "in", "list", "(", "b", ".", "keys", "(", ")", ")", ":", "c", "[", "key", "]", "=", "b", "[", "key", "]", "for", "key", "in", "list", "(", "a", ...
returns the combined dictionary. a's values preferentially chosen
[ "returns", "the", "combined", "dictionary", ".", "a", "s", "values", "preferentially", "chosen" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L290-L298
Spinmob/spinmob
_functions.py
decompose_covariance
def decompose_covariance(c): """ This decomposes a covariance matrix into an error vector and a correlation matrix """ # make it a kickass copy of the original c = _n.array(c) # first get the error vector e = [] for n in range(0, len(c[0])): e.append(_n.sqrt(c[n][n])) # now cycle ...
python
def decompose_covariance(c): """ This decomposes a covariance matrix into an error vector and a correlation matrix """ # make it a kickass copy of the original c = _n.array(c) # first get the error vector e = [] for n in range(0, len(c[0])): e.append(_n.sqrt(c[n][n])) # now cycle ...
[ "def", "decompose_covariance", "(", "c", ")", ":", "# make it a kickass copy of the original", "c", "=", "_n", ".", "array", "(", "c", ")", "# first get the error vector", "e", "=", "[", "]", "for", "n", "in", "range", "(", "0", ",", "len", "(", "c", "[", ...
This decomposes a covariance matrix into an error vector and a correlation matrix
[ "This", "decomposes", "a", "covariance", "matrix", "into", "an", "error", "vector", "and", "a", "correlation", "matrix" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L326-L343
Spinmob/spinmob
_functions.py
derivative
def derivative(xdata, ydata): """ performs d(ydata)/d(xdata) with nearest-neighbor slopes must be well-ordered, returns new arrays [xdata, dydx_data] neighbors: """ D_ydata = [] D_xdata = [] for n in range(1, len(xdata)-1): D_xdata.append(xdata[n]) D_ydata.append((ydata[...
python
def derivative(xdata, ydata): """ performs d(ydata)/d(xdata) with nearest-neighbor slopes must be well-ordered, returns new arrays [xdata, dydx_data] neighbors: """ D_ydata = [] D_xdata = [] for n in range(1, len(xdata)-1): D_xdata.append(xdata[n]) D_ydata.append((ydata[...
[ "def", "derivative", "(", "xdata", ",", "ydata", ")", ":", "D_ydata", "=", "[", "]", "D_xdata", "=", "[", "]", "for", "n", "in", "range", "(", "1", ",", "len", "(", "xdata", ")", "-", "1", ")", ":", "D_xdata", ".", "append", "(", "xdata", "[", ...
performs d(ydata)/d(xdata) with nearest-neighbor slopes must be well-ordered, returns new arrays [xdata, dydx_data] neighbors:
[ "performs", "d", "(", "ydata", ")", "/", "d", "(", "xdata", ")", "with", "nearest", "-", "neighbor", "slopes", "must", "be", "well", "-", "ordered", "returns", "new", "arrays", "[", "xdata", "dydx_data", "]" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L345-L358
Spinmob/spinmob
_functions.py
derivative_fit
def derivative_fit(xdata, ydata, neighbors=1): """ loops over the data points, performing a least-squares linear fit of the nearest neighbors at each point. Returns an array of x-values and slopes. xdata should probably be well-ordered. neighbors How many data point on the left and right to incl...
python
def derivative_fit(xdata, ydata, neighbors=1): """ loops over the data points, performing a least-squares linear fit of the nearest neighbors at each point. Returns an array of x-values and slopes. xdata should probably be well-ordered. neighbors How many data point on the left and right to incl...
[ "def", "derivative_fit", "(", "xdata", ",", "ydata", ",", "neighbors", "=", "1", ")", ":", "x", "=", "[", "]", "dydx", "=", "[", "]", "nmax", "=", "len", "(", "xdata", ")", "-", "1", "for", "n", "in", "range", "(", "nmax", "+", "1", ")", ":",...
loops over the data points, performing a least-squares linear fit of the nearest neighbors at each point. Returns an array of x-values and slopes. xdata should probably be well-ordered. neighbors How many data point on the left and right to include.
[ "loops", "over", "the", "data", "points", "performing", "a", "least", "-", "squares", "linear", "fit", "of", "the", "nearest", "neighbors", "at", "each", "point", ".", "Returns", "an", "array", "of", "x", "-", "values", "and", "slopes", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L360-L389
Spinmob/spinmob
_functions.py
distort_matrix_X
def distort_matrix_X(Z, X, f, new_xmin, new_xmax, subsample=3): """ Applies a distortion (remapping) to the matrix Z (and x-values X) using function f. returns new_Z, new_X f is an INVERSE function old_x(new_x) Z is a matrix. X is an array where X[n] is the x-value associated with the array Z[n]. ...
python
def distort_matrix_X(Z, X, f, new_xmin, new_xmax, subsample=3): """ Applies a distortion (remapping) to the matrix Z (and x-values X) using function f. returns new_Z, new_X f is an INVERSE function old_x(new_x) Z is a matrix. X is an array where X[n] is the x-value associated with the array Z[n]. ...
[ "def", "distort_matrix_X", "(", "Z", ",", "X", ",", "f", ",", "new_xmin", ",", "new_xmax", ",", "subsample", "=", "3", ")", ":", "Z", "=", "_n", ".", "array", "(", "Z", ")", "X", "=", "_n", ".", "array", "(", "X", ")", "points", "=", "len", "...
Applies a distortion (remapping) to the matrix Z (and x-values X) using function f. returns new_Z, new_X f is an INVERSE function old_x(new_x) Z is a matrix. X is an array where X[n] is the x-value associated with the array Z[n]. new_xmin, new_xmax is the possible range of the distorted x-variable fo...
[ "Applies", "a", "distortion", "(", "remapping", ")", "to", "the", "matrix", "Z", "(", "and", "x", "-", "values", "X", ")", "using", "function", "f", ".", "returns", "new_Z", "new_X" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L406-L449
Spinmob/spinmob
_functions.py
distort_matrix_Y
def distort_matrix_Y(Z, Y, f, new_ymin, new_ymax, subsample=3): """ Applies a distortion (remapping) to the matrix Z (and y-values Y) using function f. returns new_Z, new_Y f is a function old_y(new_y) Z is a matrix. Y is an array where Y[n] is the y-value associated with the array Z[:,n]. ne...
python
def distort_matrix_Y(Z, Y, f, new_ymin, new_ymax, subsample=3): """ Applies a distortion (remapping) to the matrix Z (and y-values Y) using function f. returns new_Z, new_Y f is a function old_y(new_y) Z is a matrix. Y is an array where Y[n] is the y-value associated with the array Z[:,n]. ne...
[ "def", "distort_matrix_Y", "(", "Z", ",", "Y", ",", "f", ",", "new_ymin", ",", "new_ymax", ",", "subsample", "=", "3", ")", ":", "# just use the same methodology as before by transposing, distorting X, then", "# transposing back", "new_Z", ",", "new_Y", "=", "distort_...
Applies a distortion (remapping) to the matrix Z (and y-values Y) using function f. returns new_Z, new_Y f is a function old_y(new_y) Z is a matrix. Y is an array where Y[n] is the y-value associated with the array Z[:,n]. new_ymin, new_ymax is the range of the distorted x-variable for generating Z ...
[ "Applies", "a", "distortion", "(", "remapping", ")", "to", "the", "matrix", "Z", "(", "and", "y", "-", "values", "Y", ")", "using", "function", "f", ".", "returns", "new_Z", "new_Y" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L454-L471
Spinmob/spinmob
_functions.py
dumbguy_minimize
def dumbguy_minimize(f, xmin, xmax, xstep): """ This just steps x and looks for a peak returns x, f(x) """ prev = f(xmin) this = f(xmin+xstep) for x in frange(xmin+xstep,xmax,xstep): next = f(x+xstep) # see if we're on top if this < prev and this < next: return x, ...
python
def dumbguy_minimize(f, xmin, xmax, xstep): """ This just steps x and looks for a peak returns x, f(x) """ prev = f(xmin) this = f(xmin+xstep) for x in frange(xmin+xstep,xmax,xstep): next = f(x+xstep) # see if we're on top if this < prev and this < next: return x, ...
[ "def", "dumbguy_minimize", "(", "f", ",", "xmin", ",", "xmax", ",", "xstep", ")", ":", "prev", "=", "f", "(", "xmin", ")", "this", "=", "f", "(", "xmin", "+", "xstep", ")", "for", "x", "in", "frange", "(", "xmin", "+", "xstep", ",", "xmax", ","...
This just steps x and looks for a peak returns x, f(x)
[ "This", "just", "steps", "x", "and", "looks", "for", "a", "peak" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L477-L495
Spinmob/spinmob
_functions.py
elements_are_numbers
def elements_are_numbers(array): """ Tests whether the elements of the supplied array are numbers. """ # empty case if len(array) == 0: return 0 output_value = 1 for x in array: # test it and die if it's not a number test = is_a_number(x) if not test: return False ...
python
def elements_are_numbers(array): """ Tests whether the elements of the supplied array are numbers. """ # empty case if len(array) == 0: return 0 output_value = 1 for x in array: # test it and die if it's not a number test = is_a_number(x) if not test: return False ...
[ "def", "elements_are_numbers", "(", "array", ")", ":", "# empty case", "if", "len", "(", "array", ")", "==", "0", ":", "return", "0", "output_value", "=", "1", "for", "x", "in", "array", ":", "# test it and die if it's not a number", "test", "=", "is_a_number"...
Tests whether the elements of the supplied array are numbers.
[ "Tests", "whether", "the", "elements", "of", "the", "supplied", "array", "are", "numbers", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L497-L515
Spinmob/spinmob
_functions.py
equalize_list_lengths
def equalize_list_lengths(a,b): """ Modifies the length of list a to match b. Returns a. a can also not be a list (will convert it to one). a will not be modified. """ if not _s.fun.is_iterable(a): a = [a] a = list(a) while len(a)>len(b): a.pop(-1) while len(a)<len(b): a.append(a[-1...
python
def equalize_list_lengths(a,b): """ Modifies the length of list a to match b. Returns a. a can also not be a list (will convert it to one). a will not be modified. """ if not _s.fun.is_iterable(a): a = [a] a = list(a) while len(a)>len(b): a.pop(-1) while len(a)<len(b): a.append(a[-1...
[ "def", "equalize_list_lengths", "(", "a", ",", "b", ")", ":", "if", "not", "_s", ".", "fun", ".", "is_iterable", "(", "a", ")", ":", "a", "=", "[", "a", "]", "a", "=", "list", "(", "a", ")", "while", "len", "(", "a", ")", ">", "len", "(", "...
Modifies the length of list a to match b. Returns a. a can also not be a list (will convert it to one). a will not be modified.
[ "Modifies", "the", "length", "of", "list", "a", "to", "match", "b", ".", "Returns", "a", ".", "a", "can", "also", "not", "be", "a", "list", "(", "will", "convert", "it", "to", "one", ")", ".", "a", "will", "not", "be", "modified", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L535-L545
Spinmob/spinmob
_functions.py
find_N_peaks
def find_N_peaks(array, N=4, max_iterations=100, rec_max_iterations=3, recursion=1): """ This will run the find_peaks algorythm, adjusting the baseline until exactly N peaks are found. """ if recursion<0: return None # get an initial guess as to the baseline ymin = min(array) ymax = max(ar...
python
def find_N_peaks(array, N=4, max_iterations=100, rec_max_iterations=3, recursion=1): """ This will run the find_peaks algorythm, adjusting the baseline until exactly N peaks are found. """ if recursion<0: return None # get an initial guess as to the baseline ymin = min(array) ymax = max(ar...
[ "def", "find_N_peaks", "(", "array", ",", "N", "=", "4", ",", "max_iterations", "=", "100", ",", "rec_max_iterations", "=", "3", ",", "recursion", "=", "1", ")", ":", "if", "recursion", "<", "0", ":", "return", "None", "# get an initial guess as to the basel...
This will run the find_peaks algorythm, adjusting the baseline until exactly N peaks are found.
[ "This", "will", "run", "the", "find_peaks", "algorythm", "adjusting", "the", "baseline", "until", "exactly", "N", "peaks", "are", "found", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L547-L588
Spinmob/spinmob
_functions.py
find_peaks
def find_peaks(array, baseline=0.1, return_subarrays=False): """ This will try to identify the indices of the peaks in array, returning a list of indices in ascending order. Runs along the data set until it jumps above baseline. Then it considers all the subsequent data above the baseline as part of th...
python
def find_peaks(array, baseline=0.1, return_subarrays=False): """ This will try to identify the indices of the peaks in array, returning a list of indices in ascending order. Runs along the data set until it jumps above baseline. Then it considers all the subsequent data above the baseline as part of th...
[ "def", "find_peaks", "(", "array", ",", "baseline", "=", "0.1", ",", "return_subarrays", "=", "False", ")", ":", "peaks", "=", "[", "]", "if", "return_subarrays", ":", "subarray_values", "=", "[", "]", "subarray_indices", "=", "[", "]", "# loop over the data...
This will try to identify the indices of the peaks in array, returning a list of indices in ascending order. Runs along the data set until it jumps above baseline. Then it considers all the subsequent data above the baseline as part of the peak, and records the maximum of this data as one peak value.
[ "This", "will", "try", "to", "identify", "the", "indices", "of", "the", "peaks", "in", "array", "returning", "a", "list", "of", "indices", "in", "ascending", "order", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L591-L636
Spinmob/spinmob
_functions.py
find_zero_bisect
def find_zero_bisect(f, xmin, xmax, xprecision): """ This will bisect the range and zero in on zero. """ if f(xmax)*f(xmin) > 0: print("find_zero_bisect(): no zero on the range",xmin,"to",xmax) return None temp = min(xmin,xmax) xmax = max(xmin,xmax) xmin = temp xmid = (...
python
def find_zero_bisect(f, xmin, xmax, xprecision): """ This will bisect the range and zero in on zero. """ if f(xmax)*f(xmin) > 0: print("find_zero_bisect(): no zero on the range",xmin,"to",xmax) return None temp = min(xmin,xmax) xmax = max(xmin,xmax) xmin = temp xmid = (...
[ "def", "find_zero_bisect", "(", "f", ",", "xmin", ",", "xmax", ",", "xprecision", ")", ":", "if", "f", "(", "xmax", ")", "*", "f", "(", "xmin", ")", ">", "0", ":", "print", "(", "\"find_zero_bisect(): no zero on the range\"", ",", "xmin", ",", "\"to\"", ...
This will bisect the range and zero in on zero.
[ "This", "will", "bisect", "the", "range", "and", "zero", "in", "on", "zero", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L701-L735
Spinmob/spinmob
_functions.py
fit_linear
def fit_linear(xdata, ydata): """ Returns slope and intercept of line of best fit: y = a*x + b through the supplied data. Parameters ---------- xdata, ydata: Arrays of x data and y data (having matching lengths). """ x = _n.array(xdata) y = _n.arra...
python
def fit_linear(xdata, ydata): """ Returns slope and intercept of line of best fit: y = a*x + b through the supplied data. Parameters ---------- xdata, ydata: Arrays of x data and y data (having matching lengths). """ x = _n.array(xdata) y = _n.arra...
[ "def", "fit_linear", "(", "xdata", ",", "ydata", ")", ":", "x", "=", "_n", ".", "array", "(", "xdata", ")", "y", "=", "_n", ".", "array", "(", "ydata", ")", "ax", "=", "_n", ".", "average", "(", "x", ")", "ay", "=", "_n", ".", "average", "(",...
Returns slope and intercept of line of best fit: y = a*x + b through the supplied data. Parameters ---------- xdata, ydata: Arrays of x data and y data (having matching lengths).
[ "Returns", "slope", "and", "intercept", "of", "line", "of", "best", "fit", ":", "y", "=", "a", "*", "x", "+", "b", "through", "the", "supplied", "data", ".", "Parameters", "----------", "xdata", "ydata", ":", "Arrays", "of", "x", "data", "and", "y", ...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L738-L763
Spinmob/spinmob
_functions.py
frange
def frange(start, end, inc=1.0): """ A range function, that accepts float increments and reversed direction. See also numpy.linspace() """ start = 1.0*start end = 1.0*end inc = 1.0*inc # if we got a dumb increment if not inc: return _n.array([start,end]) # if the incremen...
python
def frange(start, end, inc=1.0): """ A range function, that accepts float increments and reversed direction. See also numpy.linspace() """ start = 1.0*start end = 1.0*end inc = 1.0*inc # if we got a dumb increment if not inc: return _n.array([start,end]) # if the incremen...
[ "def", "frange", "(", "start", ",", "end", ",", "inc", "=", "1.0", ")", ":", "start", "=", "1.0", "*", "start", "end", "=", "1.0", "*", "end", "inc", "=", "1.0", "*", "inc", "# if we got a dumb increment", "if", "not", "inc", ":", "return", "_n", "...
A range function, that accepts float increments and reversed direction. See also numpy.linspace()
[ "A", "range", "function", "that", "accepts", "float", "increments", "and", "reversed", "direction", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L770-L791
Spinmob/spinmob
_functions.py
generate_fake_data
def generate_fake_data(f='2*x-5', x=_n.linspace(-5,5,11), ey=1, ex=0, include_errors=False, **kwargs): """ Generates a set of fake data from the underlying "reality" (or mean behavior) function f. Parameters ---------- f: Underlying "reality" function or mean behavior. This can be a...
python
def generate_fake_data(f='2*x-5', x=_n.linspace(-5,5,11), ey=1, ex=0, include_errors=False, **kwargs): """ Generates a set of fake data from the underlying "reality" (or mean behavior) function f. Parameters ---------- f: Underlying "reality" function or mean behavior. This can be a...
[ "def", "generate_fake_data", "(", "f", "=", "'2*x-5'", ",", "x", "=", "_n", ".", "linspace", "(", "-", "5", ",", "5", ",", "11", ")", ",", "ey", "=", "1", ",", "ex", "=", "0", ",", "include_errors", "=", "False", ",", "*", "*", "kwargs", ")", ...
Generates a set of fake data from the underlying "reality" (or mean behavior) function f. Parameters ---------- f: Underlying "reality" function or mean behavior. This can be any python-evaluable string, and will have access to all the numpy functions (e.g., cos), scipy's sp...
[ "Generates", "a", "set", "of", "fake", "data", "from", "the", "underlying", "reality", "(", "or", "mean", "behavior", ")", "function", "f", ".", "Parameters", "----------", "f", ":", "Underlying", "reality", "function", "or", "mean", "behavior", ".", "This",...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L794-L846
Spinmob/spinmob
_functions.py
get_shell_history
def get_shell_history(): """ This only works with some shells. """ # try for ipython if 'get_ipython' in globals(): a = list(get_ipython().history_manager.input_hist_raw) a.reverse() return a elif 'SPYDER_SHELL_ID' in _os.environ: try: p = _os.path.jo...
python
def get_shell_history(): """ This only works with some shells. """ # try for ipython if 'get_ipython' in globals(): a = list(get_ipython().history_manager.input_hist_raw) a.reverse() return a elif 'SPYDER_SHELL_ID' in _os.environ: try: p = _os.path.jo...
[ "def", "get_shell_history", "(", ")", ":", "# try for ipython", "if", "'get_ipython'", "in", "globals", "(", ")", ":", "a", "=", "list", "(", "get_ipython", "(", ")", ".", "history_manager", ".", "input_hist_raw", ")", "a", ".", "reverse", "(", ")", "retur...
This only works with some shells.
[ "This", "only", "works", "with", "some", "shells", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L850-L881
Spinmob/spinmob
_functions.py
index
def index(value, array): """ Array search that behaves like I want it to. Totally dumb, I know. """ i = array.searchsorted(value) if i == len(array): return -1 else: return i
python
def index(value, array): """ Array search that behaves like I want it to. Totally dumb, I know. """ i = array.searchsorted(value) if i == len(array): return -1 else: return i
[ "def", "index", "(", "value", ",", "array", ")", ":", "i", "=", "array", ".", "searchsorted", "(", "value", ")", "if", "i", "==", "len", "(", "array", ")", ":", "return", "-", "1", "else", ":", "return", "i" ]
Array search that behaves like I want it to. Totally dumb, I know.
[ "Array", "search", "that", "behaves", "like", "I", "want", "it", "to", ".", "Totally", "dumb", "I", "know", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L896-L902
Spinmob/spinmob
_functions.py
index_nearest
def index_nearest(value, array): """ expects a _n.array returns the global minimum of (value-array)^2 """ a = (array-value)**2 return index(a.min(), a)
python
def index_nearest(value, array): """ expects a _n.array returns the global minimum of (value-array)^2 """ a = (array-value)**2 return index(a.min(), a)
[ "def", "index_nearest", "(", "value", ",", "array", ")", ":", "a", "=", "(", "array", "-", "value", ")", "**", "2", "return", "index", "(", "a", ".", "min", "(", ")", ",", "a", ")" ]
expects a _n.array returns the global minimum of (value-array)^2
[ "expects", "a", "_n", ".", "array", "returns", "the", "global", "minimum", "of", "(", "value", "-", "array", ")", "^2" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L904-L911
Spinmob/spinmob
_functions.py
index_next_crossing
def index_next_crossing(value, array, starting_index=0, direction=1): """ starts at starting_index, and walks through the array until it finds a crossing point with value set direction=-1 for down crossing """ for n in range(starting_index, len(array)-1): if (value-array[n] )*directi...
python
def index_next_crossing(value, array, starting_index=0, direction=1): """ starts at starting_index, and walks through the array until it finds a crossing point with value set direction=-1 for down crossing """ for n in range(starting_index, len(array)-1): if (value-array[n] )*directi...
[ "def", "index_next_crossing", "(", "value", ",", "array", ",", "starting_index", "=", "0", ",", "direction", "=", "1", ")", ":", "for", "n", "in", "range", "(", "starting_index", ",", "len", "(", "array", ")", "-", "1", ")", ":", "if", "(", "value", ...
starts at starting_index, and walks through the array until it finds a crossing point with value set direction=-1 for down crossing
[ "starts", "at", "starting_index", "and", "walks", "through", "the", "array", "until", "it", "finds", "a", "crossing", "point", "with", "value" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L913-L926
Spinmob/spinmob
_functions.py
insert_ordered
def insert_ordered(value, array): """ This will insert the value into the array, keeping it sorted, and returning the index where it was inserted """ index = 0 # search for the last array item that value is larger than for n in range(0,len(array)): if value >= array[n]: index = n+1...
python
def insert_ordered(value, array): """ This will insert the value into the array, keeping it sorted, and returning the index where it was inserted """ index = 0 # search for the last array item that value is larger than for n in range(0,len(array)): if value >= array[n]: index = n+1...
[ "def", "insert_ordered", "(", "value", ",", "array", ")", ":", "index", "=", "0", "# search for the last array item that value is larger than", "for", "n", "in", "range", "(", "0", ",", "len", "(", "array", ")", ")", ":", "if", "value", ">=", "array", "[", ...
This will insert the value into the array, keeping it sorted, and returning the index where it was inserted
[ "This", "will", "insert", "the", "value", "into", "the", "array", "keeping", "it", "sorted", "and", "returning", "the", "index", "where", "it", "was", "inserted" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L931-L944
Spinmob/spinmob
_functions.py
integrate_data
def integrate_data(xdata, ydata, xmin=None, xmax=None, autozero=0): """ Numerically integrates up the ydata using the trapezoid approximation. estimate the bin width (scaled by the specified amount). Returns (xdata, integrated ydata). autozero is the number of data points to use as an estimate of t...
python
def integrate_data(xdata, ydata, xmin=None, xmax=None, autozero=0): """ Numerically integrates up the ydata using the trapezoid approximation. estimate the bin width (scaled by the specified amount). Returns (xdata, integrated ydata). autozero is the number of data points to use as an estimate of t...
[ "def", "integrate_data", "(", "xdata", ",", "ydata", ",", "xmin", "=", "None", ",", "xmax", "=", "None", ",", "autozero", "=", "0", ")", ":", "# sort the arrays and make sure they're numpy arrays", "[", "xdata", ",", "ydata", "]", "=", "sort_matrix", "(", "[...
Numerically integrates up the ydata using the trapezoid approximation. estimate the bin width (scaled by the specified amount). Returns (xdata, integrated ydata). autozero is the number of data points to use as an estimate of the background (then subtracted before integrating).
[ "Numerically", "integrates", "up", "the", "ydata", "using", "the", "trapezoid", "approximation", ".", "estimate", "the", "bin", "width", "(", "scaled", "by", "the", "specified", "amount", ")", ".", "Returns", "(", "xdata", "integrated", "ydata", ")", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L952-L990
Spinmob/spinmob
_functions.py
invert_increasing_function
def invert_increasing_function(f, f0, xmin, xmax, tolerance, max_iterations=100): """ This will try try to qickly find a point on the f(x) curve between xmin and xmax that is equal to f0 within tolerance. """ for n in range(max_iterations): # start at the middle x = 0.5*(xmin+xmax) ...
python
def invert_increasing_function(f, f0, xmin, xmax, tolerance, max_iterations=100): """ This will try try to qickly find a point on the f(x) curve between xmin and xmax that is equal to f0 within tolerance. """ for n in range(max_iterations): # start at the middle x = 0.5*(xmin+xmax) ...
[ "def", "invert_increasing_function", "(", "f", ",", "f0", ",", "xmin", ",", "xmax", ",", "tolerance", ",", "max_iterations", "=", "100", ")", ":", "for", "n", "in", "range", "(", "max_iterations", ")", ":", "# start at the middle", "x", "=", "0.5", "*", ...
This will try try to qickly find a point on the f(x) curve between xmin and xmax that is equal to f0 within tolerance.
[ "This", "will", "try", "try", "to", "qickly", "find", "a", "point", "on", "the", "f", "(", "x", ")", "curve", "between", "xmin", "and", "xmax", "that", "is", "equal", "to", "f0", "within", "tolerance", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1029-L1047
Spinmob/spinmob
_functions.py
fft
def fft(t, y, pow2=False, window=None, rescale=False): """ FFT of y, assuming complex or real-valued inputs. This goes through the numpy fourier transform process, assembling and returning (frequencies, complex fft) given time and signal data y. Parameters ---------- t,y Time (t) ...
python
def fft(t, y, pow2=False, window=None, rescale=False): """ FFT of y, assuming complex or real-valued inputs. This goes through the numpy fourier transform process, assembling and returning (frequencies, complex fft) given time and signal data y. Parameters ---------- t,y Time (t) ...
[ "def", "fft", "(", "t", ",", "y", ",", "pow2", "=", "False", ",", "window", "=", "None", ",", "rescale", "=", "False", ")", ":", "# make sure they're numpy arrays, and make copies to avoid the referencing error", "y", "=", "_n", ".", "array", "(", "y", ")", ...
FFT of y, assuming complex or real-valued inputs. This goes through the numpy fourier transform process, assembling and returning (frequencies, complex fft) given time and signal data y. Parameters ---------- t,y Time (t) and signal (y) arrays with which to perform the fft. Note the t ...
[ "FFT", "of", "y", "assuming", "complex", "or", "real", "-", "valued", "inputs", ".", "This", "goes", "through", "the", "numpy", "fourier", "transform", "process", "assembling", "and", "returning", "(", "frequencies", "complex", "fft", ")", "given", "time", "...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1095-L1155
Spinmob/spinmob
_functions.py
psd
def psd(t, y, pow2=False, window=None, rescale=False): """ Single-sided power spectral density, assuming real valued inputs. This goes through the numpy fourier transform process, assembling and returning (frequencies, psd) given time and signal data y. Note it is defined such that sum(psd)*d...
python
def psd(t, y, pow2=False, window=None, rescale=False): """ Single-sided power spectral density, assuming real valued inputs. This goes through the numpy fourier transform process, assembling and returning (frequencies, psd) given time and signal data y. Note it is defined such that sum(psd)*d...
[ "def", "psd", "(", "t", ",", "y", ",", "pow2", "=", "False", ",", "window", "=", "None", ",", "rescale", "=", "False", ")", ":", "# do the actual fft", "f", ",", "Y", "=", "fft", "(", "t", ",", "y", ",", "pow2", ",", "window", ",", "rescale", "...
Single-sided power spectral density, assuming real valued inputs. This goes through the numpy fourier transform process, assembling and returning (frequencies, psd) given time and signal data y. Note it is defined such that sum(psd)*df, where df is the frequency spacing, is the variance of the or...
[ "Single", "-", "sided", "power", "spectral", "density", "assuming", "real", "valued", "inputs", ".", "This", "goes", "through", "the", "numpy", "fourier", "transform", "process", "assembling", "and", "returning", "(", "frequencies", "psd", ")", "given", "time", ...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1162-L1215
Spinmob/spinmob
_functions.py
replace_in_files
def replace_in_files(search, replace, depth=0, paths=None, confirm=True): """ Does a line-by-line search and replace, but only up to the "depth" line. """ # have the user select some files if paths==None: paths = _s.dialogs.MultipleFiles('DIS AND DAT|*.*') if paths == []: return fo...
python
def replace_in_files(search, replace, depth=0, paths=None, confirm=True): """ Does a line-by-line search and replace, but only up to the "depth" line. """ # have the user select some files if paths==None: paths = _s.dialogs.MultipleFiles('DIS AND DAT|*.*') if paths == []: return fo...
[ "def", "replace_in_files", "(", "search", ",", "replace", ",", "depth", "=", "0", ",", "paths", "=", "None", ",", "confirm", "=", "True", ")", ":", "# have the user select some files", "if", "paths", "==", "None", ":", "paths", "=", "_s", ".", "dialogs", ...
Does a line-by-line search and replace, but only up to the "depth" line.
[ "Does", "a", "line", "-", "by", "-", "line", "search", "and", "replace", "but", "only", "up", "to", "the", "depth", "line", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1232-L1262
Spinmob/spinmob
_functions.py
replace_lines_in_files
def replace_lines_in_files(search_string, replacement_line): """ Finds lines containing the search string and replaces the whole line with the specified replacement string. """ # have the user select some files paths = _s.dialogs.MultipleFiles('DIS AND DAT|*.*') if paths == []: return ...
python
def replace_lines_in_files(search_string, replacement_line): """ Finds lines containing the search string and replaces the whole line with the specified replacement string. """ # have the user select some files paths = _s.dialogs.MultipleFiles('DIS AND DAT|*.*') if paths == []: return ...
[ "def", "replace_lines_in_files", "(", "search_string", ",", "replacement_line", ")", ":", "# have the user select some files", "paths", "=", "_s", ".", "dialogs", ".", "MultipleFiles", "(", "'DIS AND DAT|*.*'", ")", "if", "paths", "==", "[", "]", ":", "return", "f...
Finds lines containing the search string and replaces the whole line with the specified replacement string.
[ "Finds", "lines", "containing", "the", "search", "string", "and", "replaces", "the", "whole", "line", "with", "the", "specified", "replacement", "string", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1264-L1284
Spinmob/spinmob
_functions.py
reverse
def reverse(array): """ returns a reversed numpy array """ l = list(array) l.reverse() return _n.array(l)
python
def reverse(array): """ returns a reversed numpy array """ l = list(array) l.reverse() return _n.array(l)
[ "def", "reverse", "(", "array", ")", ":", "l", "=", "list", "(", "array", ")", "l", ".", "reverse", "(", ")", "return", "_n", ".", "array", "(", "l", ")" ]
returns a reversed numpy array
[ "returns", "a", "reversed", "numpy", "array" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1286-L1292
Spinmob/spinmob
_functions.py
round_sigfigs
def round_sigfigs(x, n=2): """ Rounds the number to the specified significant figures. x can also be a list or array of numbers (in these cases, a numpy array is returned). """ iterable = is_iterable(x) if not iterable: x = [x] # make a copy to be safe x = _n.array(x) # loop o...
python
def round_sigfigs(x, n=2): """ Rounds the number to the specified significant figures. x can also be a list or array of numbers (in these cases, a numpy array is returned). """ iterable = is_iterable(x) if not iterable: x = [x] # make a copy to be safe x = _n.array(x) # loop o...
[ "def", "round_sigfigs", "(", "x", ",", "n", "=", "2", ")", ":", "iterable", "=", "is_iterable", "(", "x", ")", "if", "not", "iterable", ":", "x", "=", "[", "x", "]", "# make a copy to be safe", "x", "=", "_n", ".", "array", "(", "x", ")", "# loop o...
Rounds the number to the specified significant figures. x can also be a list or array of numbers (in these cases, a numpy array is returned).
[ "Rounds", "the", "number", "to", "the", "specified", "significant", "figures", ".", "x", "can", "also", "be", "a", "list", "or", "array", "of", "numbers", "(", "in", "these", "cases", "a", "numpy", "array", "is", "returned", ")", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1294-L1314
Spinmob/spinmob
_functions.py
shift_feature_to_x0
def shift_feature_to_x0(xdata, ydata, x0=0, feature=imax): """ Finds a feature in the the ydata and shifts xdata so the feature is centered at x0. Returns shifted xdata, ydata. Try me with plot.tweaks.manipulate_shown_data()! xdata,ydata data set x0=0 where to shift the peak feat...
python
def shift_feature_to_x0(xdata, ydata, x0=0, feature=imax): """ Finds a feature in the the ydata and shifts xdata so the feature is centered at x0. Returns shifted xdata, ydata. Try me with plot.tweaks.manipulate_shown_data()! xdata,ydata data set x0=0 where to shift the peak feat...
[ "def", "shift_feature_to_x0", "(", "xdata", ",", "ydata", ",", "x0", "=", "0", ",", "feature", "=", "imax", ")", ":", "i", "=", "feature", "(", "ydata", ")", "return", "xdata", "-", "xdata", "[", "i", "]", "+", "x0", ",", "ydata" ]
Finds a feature in the the ydata and shifts xdata so the feature is centered at x0. Returns shifted xdata, ydata. Try me with plot.tweaks.manipulate_shown_data()! xdata,ydata data set x0=0 where to shift the peak feature=imax function taking an array/list and returning the index of sa...
[ "Finds", "a", "feature", "in", "the", "the", "ydata", "and", "shifts", "xdata", "so", "the", "feature", "is", "centered", "at", "x0", ".", "Returns", "shifted", "xdata", "ydata", ".", "Try", "me", "with", "plot", ".", "tweaks", ".", "manipulate_shown_data"...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1329-L1339
Spinmob/spinmob
_functions.py
smooth_data
def smooth_data(xdata, ydata, yerror, amount=1): """ Returns smoothed [xdata, ydata, yerror]. Does not destroy the input arrays. """ new_xdata = smooth_array(_n.array(xdata), amount) new_ydata = smooth_array(_n.array(ydata), amount) if yerror is None: new_yerror = None else: ...
python
def smooth_data(xdata, ydata, yerror, amount=1): """ Returns smoothed [xdata, ydata, yerror]. Does not destroy the input arrays. """ new_xdata = smooth_array(_n.array(xdata), amount) new_ydata = smooth_array(_n.array(ydata), amount) if yerror is None: new_yerror = None else: ...
[ "def", "smooth_data", "(", "xdata", ",", "ydata", ",", "yerror", ",", "amount", "=", "1", ")", ":", "new_xdata", "=", "smooth_array", "(", "_n", ".", "array", "(", "xdata", ")", ",", "amount", ")", "new_ydata", "=", "smooth_array", "(", "_n", ".", "a...
Returns smoothed [xdata, ydata, yerror]. Does not destroy the input arrays.
[ "Returns", "smoothed", "[", "xdata", "ydata", "yerror", "]", ".", "Does", "not", "destroy", "the", "input", "arrays", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1383-L1393
Spinmob/spinmob
_functions.py
sort_matrix
def sort_matrix(a,n=0): """ This will rearrange the array a[n] from lowest to highest, and rearrange the rest of a[i]'s in the same way. It is dumb and slow. Returns a numpy array. """ a = _n.array(a) return a[:,a[n,:].argsort()]
python
def sort_matrix(a,n=0): """ This will rearrange the array a[n] from lowest to highest, and rearrange the rest of a[i]'s in the same way. It is dumb and slow. Returns a numpy array. """ a = _n.array(a) return a[:,a[n,:].argsort()]
[ "def", "sort_matrix", "(", "a", ",", "n", "=", "0", ")", ":", "a", "=", "_n", ".", "array", "(", "a", ")", "return", "a", "[", ":", ",", "a", "[", "n", ",", ":", "]", ".", "argsort", "(", ")", "]" ]
This will rearrange the array a[n] from lowest to highest, and rearrange the rest of a[i]'s in the same way. It is dumb and slow. Returns a numpy array.
[ "This", "will", "rearrange", "the", "array", "a", "[", "n", "]", "from", "lowest", "to", "highest", "and", "rearrange", "the", "rest", "of", "a", "[", "i", "]", "s", "in", "the", "same", "way", ".", "It", "is", "dumb", "and", "slow", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1395-L1403
Spinmob/spinmob
_functions.py
submatrix
def submatrix(matrix,i1,i2,j1,j2): """ returns the submatrix defined by the index bounds i1-i2 and j1-j2 Endpoints included! """ new = [] for i in range(i1,i2+1): new.append(matrix[i][j1:j2+1]) return _n.array(new)
python
def submatrix(matrix,i1,i2,j1,j2): """ returns the submatrix defined by the index bounds i1-i2 and j1-j2 Endpoints included! """ new = [] for i in range(i1,i2+1): new.append(matrix[i][j1:j2+1]) return _n.array(new)
[ "def", "submatrix", "(", "matrix", ",", "i1", ",", "i2", ",", "j1", ",", "j2", ")", ":", "new", "=", "[", "]", "for", "i", "in", "range", "(", "i1", ",", "i2", "+", "1", ")", ":", "new", ".", "append", "(", "matrix", "[", "i", "]", "[", "...
returns the submatrix defined by the index bounds i1-i2 and j1-j2 Endpoints included!
[ "returns", "the", "submatrix", "defined", "by", "the", "index", "bounds", "i1", "-", "i2", "and", "j1", "-", "j2" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1405-L1415
Spinmob/spinmob
_functions.py
trim_data
def trim_data(xmin, xmax, xdata, *args): """ Removes all the data except that in which xdata is between xmin and xmax. This does not mutilate the input arrays, and additional arrays can be supplied via args (provided they match xdata in shape) xmin and xmax can be None """ # make sure it'...
python
def trim_data(xmin, xmax, xdata, *args): """ Removes all the data except that in which xdata is between xmin and xmax. This does not mutilate the input arrays, and additional arrays can be supplied via args (provided they match xdata in shape) xmin and xmax can be None """ # make sure it'...
[ "def", "trim_data", "(", "xmin", ",", "xmax", ",", "xdata", ",", "*", "args", ")", ":", "# make sure it's a numpy array", "if", "not", "isinstance", "(", "xdata", ",", "_n", ".", "ndarray", ")", ":", "xdata", "=", "_n", ".", "array", "(", "xdata", ")",...
Removes all the data except that in which xdata is between xmin and xmax. This does not mutilate the input arrays, and additional arrays can be supplied via args (provided they match xdata in shape) xmin and xmax can be None
[ "Removes", "all", "the", "data", "except", "that", "in", "which", "xdata", "is", "between", "xmin", "and", "xmax", ".", "This", "does", "not", "mutilate", "the", "input", "arrays", "and", "additional", "arrays", "can", "be", "supplied", "via", "args", "(",...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1417-L1446
Spinmob/spinmob
_functions.py
trim_data_uber
def trim_data_uber(arrays, conditions): """ Non-destructively selects data from the supplied list of arrays based on the supplied list of conditions. Importantly, if any of the conditions are not met for the n'th data point, the n'th data point is rejected for all supplied arrays. Example ...
python
def trim_data_uber(arrays, conditions): """ Non-destructively selects data from the supplied list of arrays based on the supplied list of conditions. Importantly, if any of the conditions are not met for the n'th data point, the n'th data point is rejected for all supplied arrays. Example ...
[ "def", "trim_data_uber", "(", "arrays", ",", "conditions", ")", ":", "# dumb conditions", "if", "len", "(", "conditions", ")", "==", "0", ":", "return", "arrays", "if", "len", "(", "arrays", ")", "==", "0", ":", "return", "[", "]", "# find the indices to k...
Non-destructively selects data from the supplied list of arrays based on the supplied list of conditions. Importantly, if any of the conditions are not met for the n'th data point, the n'th data point is rejected for all supplied arrays. Example ------- x = numpy.linspace(0,10,20) y = num...
[ "Non", "-", "destructively", "selects", "data", "from", "the", "supplied", "list", "of", "arrays", "based", "on", "the", "supplied", "list", "of", "conditions", ".", "Importantly", "if", "any", "of", "the", "conditions", "are", "not", "met", "for", "the", ...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1448-L1478
fitnr/censusgeocode
censusgeocode/censusgeocode.py
CensusGeocode._fetch
def _fetch(self, searchtype, fields, **kwargs): '''Fetch a response from the Geocoding API.''' fields['vintage'] = self.vintage fields['benchmark'] = self.benchmark fields['format'] = 'json' if 'layers' in kwargs: fields['layers'] = kwargs['layers'] returnty...
python
def _fetch(self, searchtype, fields, **kwargs): '''Fetch a response from the Geocoding API.''' fields['vintage'] = self.vintage fields['benchmark'] = self.benchmark fields['format'] = 'json' if 'layers' in kwargs: fields['layers'] = kwargs['layers'] returnty...
[ "def", "_fetch", "(", "self", ",", "searchtype", ",", "fields", ",", "*", "*", "kwargs", ")", ":", "fields", "[", "'vintage'", "]", "=", "self", ".", "vintage", "fields", "[", "'benchmark'", "]", "=", "self", ".", "benchmark", "fields", "[", "'format'"...
Fetch a response from the Geocoding API.
[ "Fetch", "a", "response", "from", "the", "Geocoding", "API", "." ]
train
https://github.com/fitnr/censusgeocode/blob/9414c331a63fbcfff6b7295cd8935c40ce54c88c/censusgeocode/censusgeocode.py#L78-L105
fitnr/censusgeocode
censusgeocode/censusgeocode.py
CensusGeocode.coordinates
def coordinates(self, x, y, **kwargs): '''Geocode a (lon, lat) coordinate.''' kwargs['returntype'] = 'geographies' fields = { 'x': x, 'y': y } return self._fetch('coordinates', fields, **kwargs)
python
def coordinates(self, x, y, **kwargs): '''Geocode a (lon, lat) coordinate.''' kwargs['returntype'] = 'geographies' fields = { 'x': x, 'y': y } return self._fetch('coordinates', fields, **kwargs)
[ "def", "coordinates", "(", "self", ",", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'returntype'", "]", "=", "'geographies'", "fields", "=", "{", "'x'", ":", "x", ",", "'y'", ":", "y", "}", "return", "self", ".", "_fetch", "...
Geocode a (lon, lat) coordinate.
[ "Geocode", "a", "(", "lon", "lat", ")", "coordinate", "." ]
train
https://github.com/fitnr/censusgeocode/blob/9414c331a63fbcfff6b7295cd8935c40ce54c88c/censusgeocode/censusgeocode.py#L107-L115
fitnr/censusgeocode
censusgeocode/censusgeocode.py
CensusGeocode.address
def address(self, street, city=None, state=None, zipcode=None, **kwargs): '''Geocode an address.''' fields = { 'street': street, 'city': city, 'state': state, 'zip': zipcode, } return self._fetch('address', fields, **kwargs)
python
def address(self, street, city=None, state=None, zipcode=None, **kwargs): '''Geocode an address.''' fields = { 'street': street, 'city': city, 'state': state, 'zip': zipcode, } return self._fetch('address', fields, **kwargs)
[ "def", "address", "(", "self", ",", "street", ",", "city", "=", "None", ",", "state", "=", "None", ",", "zipcode", "=", "None", ",", "*", "*", "kwargs", ")", ":", "fields", "=", "{", "'street'", ":", "street", ",", "'city'", ":", "city", ",", "'s...
Geocode an address.
[ "Geocode", "an", "address", "." ]
train
https://github.com/fitnr/censusgeocode/blob/9414c331a63fbcfff6b7295cd8935c40ce54c88c/censusgeocode/censusgeocode.py#L117-L126
fitnr/censusgeocode
censusgeocode/censusgeocode.py
CensusGeocode.onelineaddress
def onelineaddress(self, address, **kwargs): '''Geocode an an address passed as one string. e.g. "4600 Silver Hill Rd, Suitland, MD 20746" ''' fields = { 'address': address, } return self._fetch('onelineaddress', fields, **kwargs)
python
def onelineaddress(self, address, **kwargs): '''Geocode an an address passed as one string. e.g. "4600 Silver Hill Rd, Suitland, MD 20746" ''' fields = { 'address': address, } return self._fetch('onelineaddress', fields, **kwargs)
[ "def", "onelineaddress", "(", "self", ",", "address", ",", "*", "*", "kwargs", ")", ":", "fields", "=", "{", "'address'", ":", "address", ",", "}", "return", "self", ".", "_fetch", "(", "'onelineaddress'", ",", "fields", ",", "*", "*", "kwargs", ")" ]
Geocode an an address passed as one string. e.g. "4600 Silver Hill Rd, Suitland, MD 20746"
[ "Geocode", "an", "an", "address", "passed", "as", "one", "string", ".", "e", ".", "g", ".", "4600", "Silver", "Hill", "Rd", "Suitland", "MD", "20746" ]
train
https://github.com/fitnr/censusgeocode/blob/9414c331a63fbcfff6b7295cd8935c40ce54c88c/censusgeocode/censusgeocode.py#L128-L136
fitnr/censusgeocode
censusgeocode/censusgeocode.py
CensusGeocode.addressbatch
def addressbatch(self, data, **kwargs): ''' Send either a CSV file or data to the addressbatch API. According to the Census, "there is currently an upper limit of 1000 records per batch file." If a file, must have no header and fields id,street,city,state,zip If data, should be a...
python
def addressbatch(self, data, **kwargs): ''' Send either a CSV file or data to the addressbatch API. According to the Census, "there is currently an upper limit of 1000 records per batch file." If a file, must have no header and fields id,street,city,state,zip If data, should be a...
[ "def", "addressbatch", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "# Does data quack like a file handle?", "if", "hasattr", "(", "data", ",", "'read'", ")", ":", "return", "self", ".", "_post_batch", "(", "f", "=", "data", ",", "*", "*"...
Send either a CSV file or data to the addressbatch API. According to the Census, "there is currently an upper limit of 1000 records per batch file." If a file, must have no header and fields id,street,city,state,zip If data, should be a list of dicts with the above fields (although ID is optiona...
[ "Send", "either", "a", "CSV", "file", "or", "data", "to", "the", "addressbatch", "API", ".", "According", "to", "the", "Census", "there", "is", "currently", "an", "upper", "limit", "of", "1000", "records", "per", "batch", "file", ".", "If", "a", "file", ...
train
https://github.com/fitnr/censusgeocode/blob/9414c331a63fbcfff6b7295cd8935c40ce54c88c/censusgeocode/censusgeocode.py#L195-L213
Spinmob/spinmob
_pylab_colormap.py
colormap.load_colormap
def load_colormap(self, name=None): """ Loads a colormap of the supplied name. None means used the internal name. (See self.get_name()) """ if name == None: name = self.get_name() if name == "" or not type(name)==str: return "Error: Bad name." # assemble the pat...
python
def load_colormap(self, name=None): """ Loads a colormap of the supplied name. None means used the internal name. (See self.get_name()) """ if name == None: name = self.get_name() if name == "" or not type(name)==str: return "Error: Bad name." # assemble the pat...
[ "def", "load_colormap", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "==", "None", ":", "name", "=", "self", ".", "get_name", "(", ")", "if", "name", "==", "\"\"", "or", "not", "type", "(", "name", ")", "==", "str", ":", "return...
Loads a colormap of the supplied name. None means used the internal name. (See self.get_name())
[ "Loads", "a", "colormap", "of", "the", "supplied", "name", ".", "None", "means", "used", "the", "internal", "name", ".", "(", "See", "self", ".", "get_name", "()", ")" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L64-L96
Spinmob/spinmob
_pylab_colormap.py
colormap.save_colormap
def save_colormap(self, name=None): """ Saves the colormap with the specified name. None means use internal name. (See get_name()) """ if name == None: name = self.get_name() if name == "" or not type(name)==str: return "Error: invalid name." # get the colormaps ...
python
def save_colormap(self, name=None): """ Saves the colormap with the specified name. None means use internal name. (See get_name()) """ if name == None: name = self.get_name() if name == "" or not type(name)==str: return "Error: invalid name." # get the colormaps ...
[ "def", "save_colormap", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "==", "None", ":", "name", "=", "self", ".", "get_name", "(", ")", "if", "name", "==", "\"\"", "or", "not", "type", "(", "name", ")", "==", "str", ":", "return...
Saves the colormap with the specified name. None means use internal name. (See get_name())
[ "Saves", "the", "colormap", "with", "the", "specified", "name", ".", "None", "means", "use", "internal", "name", ".", "(", "See", "get_name", "()", ")" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L98-L120
Spinmob/spinmob
_pylab_colormap.py
colormap.delete_colormap
def delete_colormap(self, name=None): """ Deletes the colormap with the specified name. None means use the internal name (see get_name()) """ if name == None: name = self.get_name() if name == "" or not type(name)==str: return "Error: invalid name." # assemble th...
python
def delete_colormap(self, name=None): """ Deletes the colormap with the specified name. None means use the internal name (see get_name()) """ if name == None: name = self.get_name() if name == "" or not type(name)==str: return "Error: invalid name." # assemble th...
[ "def", "delete_colormap", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "==", "None", ":", "name", "=", "self", ".", "get_name", "(", ")", "if", "name", "==", "\"\"", "or", "not", "type", "(", "name", ")", "==", "str", ":", "retu...
Deletes the colormap with the specified name. None means use the internal name (see get_name())
[ "Deletes", "the", "colormap", "with", "the", "specified", "name", ".", "None", "means", "use", "the", "internal", "name", "(", "see", "get_name", "()", ")" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L122-L134
Spinmob/spinmob
_pylab_colormap.py
colormap.set_name
def set_name(self, name="My Colormap"): """ Sets the name. Make sure the name is something your OS could name a file. """ if not type(name)==str: print("set_name(): Name must be a string.") return self._name = name return self
python
def set_name(self, name="My Colormap"): """ Sets the name. Make sure the name is something your OS could name a file. """ if not type(name)==str: print("set_name(): Name must be a string.") return self._name = name return self
[ "def", "set_name", "(", "self", ",", "name", "=", "\"My Colormap\"", ")", ":", "if", "not", "type", "(", "name", ")", "==", "str", ":", "print", "(", "\"set_name(): Name must be a string.\"", ")", "return", "self", ".", "_name", "=", "name", "return", "sel...
Sets the name. Make sure the name is something your OS could name a file.
[ "Sets", "the", "name", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L136-L146
Spinmob/spinmob
_pylab_colormap.py
colormap.set_image
def set_image(self, image='auto'): """ Set which pylab image to tweak. """ if image=="auto": image = _pylab.gca().images[0] self._image=image self.update_image()
python
def set_image(self, image='auto'): """ Set which pylab image to tweak. """ if image=="auto": image = _pylab.gca().images[0] self._image=image self.update_image()
[ "def", "set_image", "(", "self", ",", "image", "=", "'auto'", ")", ":", "if", "image", "==", "\"auto\"", ":", "image", "=", "_pylab", ".", "gca", "(", ")", ".", "images", "[", "0", "]", "self", ".", "_image", "=", "image", "self", ".", "update_imag...
Set which pylab image to tweak.
[ "Set", "which", "pylab", "image", "to", "tweak", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L154-L160
Spinmob/spinmob
_pylab_colormap.py
colormap.update_image
def update_image(self): """ Set's the image's cmap. """ if self._image: self._image.set_cmap(self.get_cmap()) _pylab.draw()
python
def update_image(self): """ Set's the image's cmap. """ if self._image: self._image.set_cmap(self.get_cmap()) _pylab.draw()
[ "def", "update_image", "(", "self", ")", ":", "if", "self", ".", "_image", ":", "self", ".", "_image", ".", "set_cmap", "(", "self", ".", "get_cmap", "(", ")", ")", "_pylab", ".", "draw", "(", ")" ]
Set's the image's cmap.
[ "Set", "s", "the", "image", "s", "cmap", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L162-L168
Spinmob/spinmob
_pylab_colormap.py
colormap.pop_colorpoint
def pop_colorpoint(self, n=0): """ Removes and returns the specified colorpoint. Will always leave two behind. """ # make sure we have more than 2; otherwise don't pop it, just return it if len(self._colorpoint_list) > 2: # do the popping x = self._color...
python
def pop_colorpoint(self, n=0): """ Removes and returns the specified colorpoint. Will always leave two behind. """ # make sure we have more than 2; otherwise don't pop it, just return it if len(self._colorpoint_list) > 2: # do the popping x = self._color...
[ "def", "pop_colorpoint", "(", "self", ",", "n", "=", "0", ")", ":", "# make sure we have more than 2; otherwise don't pop it, just return it", "if", "len", "(", "self", ".", "_colorpoint_list", ")", ">", "2", ":", "# do the popping", "x", "=", "self", ".", "_color...
Removes and returns the specified colorpoint. Will always leave two behind.
[ "Removes", "and", "returns", "the", "specified", "colorpoint", ".", "Will", "always", "leave", "two", "behind", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L170-L191
Spinmob/spinmob
_pylab_colormap.py
colormap.insert_colorpoint
def insert_colorpoint(self, position=0.5, color1=[1.0,1.0,0.0], color2=[1.0,1.0,0.0]): """ Inserts the specified color into the list. """ L = self._colorpoint_list # if position = 0 or 1, push the end points inward if position <= 0.0: L.insert(0,[0.0,color1...
python
def insert_colorpoint(self, position=0.5, color1=[1.0,1.0,0.0], color2=[1.0,1.0,0.0]): """ Inserts the specified color into the list. """ L = self._colorpoint_list # if position = 0 or 1, push the end points inward if position <= 0.0: L.insert(0,[0.0,color1...
[ "def", "insert_colorpoint", "(", "self", ",", "position", "=", "0.5", ",", "color1", "=", "[", "1.0", ",", "1.0", ",", "0.0", "]", ",", "color2", "=", "[", "1.0", ",", "1.0", ",", "0.0", "]", ")", ":", "L", "=", "self", ".", "_colorpoint_list", "...
Inserts the specified color into the list.
[ "Inserts", "the", "specified", "color", "into", "the", "list", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L193-L220
Spinmob/spinmob
_pylab_colormap.py
colormap.modify_colorpoint
def modify_colorpoint(self, n, position=0.5, color1=[1.0,1.0,1.0], color2=[1.0,1.0,1.0]): """ Changes the values of an existing colorpoint, then updates the colormap. """ if n==0.0 : position = 0.0 elif n==len(self._colorpoint_list)-1: position = 1.0 ...
python
def modify_colorpoint(self, n, position=0.5, color1=[1.0,1.0,1.0], color2=[1.0,1.0,1.0]): """ Changes the values of an existing colorpoint, then updates the colormap. """ if n==0.0 : position = 0.0 elif n==len(self._colorpoint_list)-1: position = 1.0 ...
[ "def", "modify_colorpoint", "(", "self", ",", "n", ",", "position", "=", "0.5", ",", "color1", "=", "[", "1.0", ",", "1.0", ",", "1.0", "]", ",", "color2", "=", "[", "1.0", ",", "1.0", ",", "1.0", "]", ")", ":", "if", "n", "==", "0.0", ":", "...
Changes the values of an existing colorpoint, then updates the colormap.
[ "Changes", "the", "values", "of", "an", "existing", "colorpoint", "then", "updates", "the", "colormap", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L222-L232
Spinmob/spinmob
_pylab_colormap.py
colormap.get_cmap
def get_cmap(self): """ Generates a pylab cmap object from the colorpoint data. """ # now generate the colormap from the ordered list r = [] g = [] b = [] for p in self._colorpoint_list: r.append((p[0], p[1][0]*1.0, p[2][0]*1.0)) g...
python
def get_cmap(self): """ Generates a pylab cmap object from the colorpoint data. """ # now generate the colormap from the ordered list r = [] g = [] b = [] for p in self._colorpoint_list: r.append((p[0], p[1][0]*1.0, p[2][0]*1.0)) g...
[ "def", "get_cmap", "(", "self", ")", ":", "# now generate the colormap from the ordered list", "r", "=", "[", "]", "g", "=", "[", "]", "b", "=", "[", "]", "for", "p", "in", "self", ".", "_colorpoint_list", ":", "r", ".", "append", "(", "(", "p", "[", ...
Generates a pylab cmap object from the colorpoint data.
[ "Generates", "a", "pylab", "cmap", "object", "from", "the", "colorpoint", "data", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L234-L252
Spinmob/spinmob
_pylab_colormap.py
colormap_interface._build_gui
def _build_gui(self): """ Removes all existing sliders and rebuilds them based on the colormap. """ # remove all widgets (should destroy all children too) self._central_widget.deleteLater() # remove all references to other controls self._sliders = [...
python
def _build_gui(self): """ Removes all existing sliders and rebuilds them based on the colormap. """ # remove all widgets (should destroy all children too) self._central_widget.deleteLater() # remove all references to other controls self._sliders = [...
[ "def", "_build_gui", "(", "self", ")", ":", "# remove all widgets (should destroy all children too)", "self", ".", "_central_widget", ".", "deleteLater", "(", ")", "# remove all references to other controls", "self", ".", "_sliders", "=", "[", "]", "self", ".", "_button...
Removes all existing sliders and rebuilds them based on the colormap.
[ "Removes", "all", "existing", "sliders", "and", "rebuilds", "them", "based", "on", "the", "colormap", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L290-L403
Spinmob/spinmob
_pylab_colormap.py
colormap_interface._signal_load
def _signal_load(self): """ Load the selected cmap. """ # set our name self.set_name(str(self._combobox_cmaps.currentText())) # load the colormap self.load_colormap() # rebuild the interface self._build_gui() self._button_save.setEnable...
python
def _signal_load(self): """ Load the selected cmap. """ # set our name self.set_name(str(self._combobox_cmaps.currentText())) # load the colormap self.load_colormap() # rebuild the interface self._build_gui() self._button_save.setEnable...
[ "def", "_signal_load", "(", "self", ")", ":", "# set our name", "self", ".", "set_name", "(", "str", "(", "self", ".", "_combobox_cmaps", ".", "currentText", "(", ")", ")", ")", "# load the colormap", "self", ".", "load_colormap", "(", ")", "# rebuild the inte...
Load the selected cmap.
[ "Load", "the", "selected", "cmap", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L406-L420
Spinmob/spinmob
_pylab_colormap.py
colormap_interface._button_save_clicked
def _button_save_clicked(self): """ Save the selected cmap. """ self.set_name(str(self._combobox_cmaps.currentText())) self.save_colormap() self._button_save.setEnabled(False) self._load_cmap_list()
python
def _button_save_clicked(self): """ Save the selected cmap. """ self.set_name(str(self._combobox_cmaps.currentText())) self.save_colormap() self._button_save.setEnabled(False) self._load_cmap_list()
[ "def", "_button_save_clicked", "(", "self", ")", ":", "self", ".", "set_name", "(", "str", "(", "self", ".", "_combobox_cmaps", ".", "currentText", "(", ")", ")", ")", "self", ".", "save_colormap", "(", ")", "self", ".", "_button_save", ".", "setEnabled", ...
Save the selected cmap.
[ "Save", "the", "selected", "cmap", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L423-L430
Spinmob/spinmob
_pylab_colormap.py
colormap_interface._button_delete_clicked
def _button_delete_clicked(self): """ Save the selected cmap. """ name = str(self._combobox_cmaps.currentText()) self.delete_colormap(name) self._combobox_cmaps.setEditText("") self._load_cmap_list()
python
def _button_delete_clicked(self): """ Save the selected cmap. """ name = str(self._combobox_cmaps.currentText()) self.delete_colormap(name) self._combobox_cmaps.setEditText("") self._load_cmap_list()
[ "def", "_button_delete_clicked", "(", "self", ")", ":", "name", "=", "str", "(", "self", ".", "_combobox_cmaps", ".", "currentText", "(", ")", ")", "self", ".", "delete_colormap", "(", "name", ")", "self", ".", "_combobox_cmaps", ".", "setEditText", "(", "...
Save the selected cmap.
[ "Save", "the", "selected", "cmap", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L432-L439
Spinmob/spinmob
_pylab_colormap.py
colormap_interface._color_dialog_changed
def _color_dialog_changed(self, n, top, c): """ Updates the color of the slider. """ self._button_save.setEnabled(True) cp = self._colorpoint_list[n] # if they're linked, set both if self._checkboxes[n].isChecked(): self.modify_colorpoint(n, cp[0], [...
python
def _color_dialog_changed(self, n, top, c): """ Updates the color of the slider. """ self._button_save.setEnabled(True) cp = self._colorpoint_list[n] # if they're linked, set both if self._checkboxes[n].isChecked(): self.modify_colorpoint(n, cp[0], [...
[ "def", "_color_dialog_changed", "(", "self", ",", "n", ",", "top", ",", "c", ")", ":", "self", ".", "_button_save", ".", "setEnabled", "(", "True", ")", "cp", "=", "self", ".", "_colorpoint_list", "[", "n", "]", "# if they're linked, set both", "if", "self...
Updates the color of the slider.
[ "Updates", "the", "color", "of", "the", "slider", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L442-L464
Spinmob/spinmob
_pylab_colormap.py
colormap_interface._button_plus_clicked
def _button_plus_clicked(self, n): """ Create a new colorpoint. """ self._button_save.setEnabled(True) self.insert_colorpoint(self._colorpoint_list[n][0], self._colorpoint_list[n][1], self._colorpoint_list[n][2]) ...
python
def _button_plus_clicked(self, n): """ Create a new colorpoint. """ self._button_save.setEnabled(True) self.insert_colorpoint(self._colorpoint_list[n][0], self._colorpoint_list[n][1], self._colorpoint_list[n][2]) ...
[ "def", "_button_plus_clicked", "(", "self", ",", "n", ")", ":", "self", ".", "_button_save", ".", "setEnabled", "(", "True", ")", "self", ".", "insert_colorpoint", "(", "self", ".", "_colorpoint_list", "[", "n", "]", "[", "0", "]", ",", "self", ".", "_...
Create a new colorpoint.
[ "Create", "a", "new", "colorpoint", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L468-L477
Spinmob/spinmob
_pylab_colormap.py
colormap_interface._button_minus_clicked
def _button_minus_clicked(self, n): """ Remove a new colorpoint. """ self._button_save.setEnabled(True) self.pop_colorpoint(n) self._build_gui()
python
def _button_minus_clicked(self, n): """ Remove a new colorpoint. """ self._button_save.setEnabled(True) self.pop_colorpoint(n) self._build_gui()
[ "def", "_button_minus_clicked", "(", "self", ",", "n", ")", ":", "self", ".", "_button_save", ".", "setEnabled", "(", "True", ")", "self", ".", "pop_colorpoint", "(", "n", ")", "self", ".", "_build_gui", "(", ")" ]
Remove a new colorpoint.
[ "Remove", "a", "new", "colorpoint", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L479-L486
Spinmob/spinmob
_pylab_colormap.py
colormap_interface._slider_changed
def _slider_changed(self, n): """ updates the colormap / plot """ self._button_save.setEnabled(True) self.modify_colorpoint(n, self._sliders[n].value()*0.001, self._colorpoint_list[n][1], self._colorpoint_list[n][2])
python
def _slider_changed(self, n): """ updates the colormap / plot """ self._button_save.setEnabled(True) self.modify_colorpoint(n, self._sliders[n].value()*0.001, self._colorpoint_list[n][1], self._colorpoint_list[n][2])
[ "def", "_slider_changed", "(", "self", ",", "n", ")", ":", "self", ".", "_button_save", ".", "setEnabled", "(", "True", ")", "self", ".", "modify_colorpoint", "(", "n", ",", "self", ".", "_sliders", "[", "n", "]", ".", "value", "(", ")", "*", "0.001"...
updates the colormap / plot
[ "updates", "the", "colormap", "/", "plot" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L488-L494
Spinmob/spinmob
_pylab_colormap.py
colormap_interface._color_button_clicked
def _color_button_clicked(self, n,top): """ Opens the dialog. """ self._button_save.setEnabled(True) if top: self._color_dialogs_top[n].open() else: self._color_dialogs_bottom[n].open()
python
def _color_button_clicked(self, n,top): """ Opens the dialog. """ self._button_save.setEnabled(True) if top: self._color_dialogs_top[n].open() else: self._color_dialogs_bottom[n].open()
[ "def", "_color_button_clicked", "(", "self", ",", "n", ",", "top", ")", ":", "self", ".", "_button_save", ".", "setEnabled", "(", "True", ")", "if", "top", ":", "self", ".", "_color_dialogs_top", "[", "n", "]", ".", "open", "(", ")", "else", ":", "se...
Opens the dialog.
[ "Opens", "the", "dialog", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L497-L504
Spinmob/spinmob
_pylab_colormap.py
colormap_interface._load_cmap_list
def _load_cmap_list(self): """ Searches the colormaps directory for all files, populates the list. """ # store the current name name = self.get_name() # clear the list self._combobox_cmaps.blockSignals(True) self._combobox_cmaps.clear() # list th...
python
def _load_cmap_list(self): """ Searches the colormaps directory for all files, populates the list. """ # store the current name name = self.get_name() # clear the list self._combobox_cmaps.blockSignals(True) self._combobox_cmaps.clear() # list th...
[ "def", "_load_cmap_list", "(", "self", ")", ":", "# store the current name", "name", "=", "self", ".", "get_name", "(", ")", "# clear the list", "self", ".", "_combobox_cmaps", ".", "blockSignals", "(", "True", ")", "self", ".", "_combobox_cmaps", ".", "clear", ...
Searches the colormaps directory for all files, populates the list.
[ "Searches", "the", "colormaps", "directory", "for", "all", "files", "populates", "the", "list", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_pylab_colormap.py#L507-L527
Spinmob/spinmob
_dialogs.py
save
def save(filters='*.*', text='Save THIS, facehead!', default_directory='default_directory', force_extension=None): """ Pops up a save dialog and returns the string path of the selected file. Parameters ---------- filters='*.*' Which file types should appear in the dialog. text='Save...
python
def save(filters='*.*', text='Save THIS, facehead!', default_directory='default_directory', force_extension=None): """ Pops up a save dialog and returns the string path of the selected file. Parameters ---------- filters='*.*' Which file types should appear in the dialog. text='Save...
[ "def", "save", "(", "filters", "=", "'*.*'", ",", "text", "=", "'Save THIS, facehead!'", ",", "default_directory", "=", "'default_directory'", ",", "force_extension", "=", "None", ")", ":", "# make sure the filters contains \"*.*\" as an option!", "if", "not", "'*'", ...
Pops up a save dialog and returns the string path of the selected file. Parameters ---------- filters='*.*' Which file types should appear in the dialog. text='Save THIS, facehead!' Title text for the dialog. default_directory='default_directory' Key for the spinmob.sett...
[ "Pops", "up", "a", "save", "dialog", "and", "returns", "the", "string", "path", "of", "the", "selected", "file", ".", "Parameters", "----------", "filters", "=", "*", ".", "*", "Which", "file", "types", "should", "appear", "in", "the", "dialog", ".", "te...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_dialogs.py#L9-L56
Spinmob/spinmob
_dialogs.py
load
def load(filters="*.*", text='Select a file, FACEFACE!', default_directory='default_directory'): """ Pops up a dialog for opening a single file. Returns a string path or None. """ # make sure the filters contains "*.*" as an option! if not '*' in filters.split(';'): filters = filters + ";;All files ...
python
def load(filters="*.*", text='Select a file, FACEFACE!', default_directory='default_directory'): """ Pops up a dialog for opening a single file. Returns a string path or None. """ # make sure the filters contains "*.*" as an option! if not '*' in filters.split(';'): filters = filters + ";;All files ...
[ "def", "load", "(", "filters", "=", "\"*.*\"", ",", "text", "=", "'Select a file, FACEFACE!'", ",", "default_directory", "=", "'default_directory'", ")", ":", "# make sure the filters contains \"*.*\" as an option!", "if", "not", "'*'", "in", "filters", ".", "split", ...
Pops up a dialog for opening a single file. Returns a string path or None.
[ "Pops", "up", "a", "dialog", "for", "opening", "a", "single", "file", ".", "Returns", "a", "string", "path", "or", "None", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_dialogs.py#L59-L82
Spinmob/spinmob
_dialogs.py
load_multiple
def load_multiple(filters="*.*", text='Select some files, FACEFACE!', default_directory='default_directory'): """ Pops up a dialog for opening more than one file. Returns a list of string paths or None. """ # make sure the filters contains "*.*" as an option! if not '*' in filters.split(';'): filter...
python
def load_multiple(filters="*.*", text='Select some files, FACEFACE!', default_directory='default_directory'): """ Pops up a dialog for opening more than one file. Returns a list of string paths or None. """ # make sure the filters contains "*.*" as an option! if not '*' in filters.split(';'): filter...
[ "def", "load_multiple", "(", "filters", "=", "\"*.*\"", ",", "text", "=", "'Select some files, FACEFACE!'", ",", "default_directory", "=", "'default_directory'", ")", ":", "# make sure the filters contains \"*.*\" as an option!", "if", "not", "'*'", "in", "filters", ".", ...
Pops up a dialog for opening more than one file. Returns a list of string paths or None.
[ "Pops", "up", "a", "dialog", "for", "opening", "more", "than", "one", "file", ".", "Returns", "a", "list", "of", "string", "paths", "or", "None", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_dialogs.py#L85-L109
Spinmob/spinmob
_prefs.py
Prefs.Dump
def Dump(self): """ Dumps the current prefs to the preferences.txt file """ prefs_file = open(self.prefs_path, 'w') for n in range(0,len(self.prefs)): if len(list(self.prefs.items())[n]) > 1: prefs_file.write(str(list(self.prefs.items())[n][0]) + ' = '...
python
def Dump(self): """ Dumps the current prefs to the preferences.txt file """ prefs_file = open(self.prefs_path, 'w') for n in range(0,len(self.prefs)): if len(list(self.prefs.items())[n]) > 1: prefs_file.write(str(list(self.prefs.items())[n][0]) + ' = '...
[ "def", "Dump", "(", "self", ")", ":", "prefs_file", "=", "open", "(", "self", ".", "prefs_path", ",", "'w'", ")", "for", "n", "in", "range", "(", "0", ",", "len", "(", "self", ".", "prefs", ")", ")", ":", "if", "len", "(", "list", "(", "self", ...
Dumps the current prefs to the preferences.txt file
[ "Dumps", "the", "current", "prefs", "to", "the", "preferences", ".", "txt", "file" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_prefs.py#L110-L119
thriftrw/thriftrw-python
thriftrw/compile/link.py
TypeSpecLinker.link
def link(self): """Resolve and link all types in the scope.""" type_specs = {} types = [] for name, type_spec in self.scope.type_specs.items(): type_spec = type_spec.link(self.scope) type_specs[name] = type_spec if type_spec.surface is not None: ...
python
def link(self): """Resolve and link all types in the scope.""" type_specs = {} types = [] for name, type_spec in self.scope.type_specs.items(): type_spec = type_spec.link(self.scope) type_specs[name] = type_spec if type_spec.surface is not None: ...
[ "def", "link", "(", "self", ")", ":", "type_specs", "=", "{", "}", "types", "=", "[", "]", "for", "name", ",", "type_spec", "in", "self", ".", "scope", ".", "type_specs", ".", "items", "(", ")", ":", "type_spec", "=", "type_spec", ".", "link", "(",...
Resolve and link all types in the scope.
[ "Resolve", "and", "link", "all", "types", "in", "the", "scope", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/link.py#L35-L50
thriftrw/thriftrw-python
thriftrw/loader.py
install
def install(path, name=None): """Compiles a Thrift file and installs it as a submodule of the caller. Given a tree organized like so:: foo/ __init__.py bar.py my_service.thrift You would do, .. code-block:: python my_service = thriftrw.install('my...
python
def install(path, name=None): """Compiles a Thrift file and installs it as a submodule of the caller. Given a tree organized like so:: foo/ __init__.py bar.py my_service.thrift You would do, .. code-block:: python my_service = thriftrw.install('my...
[ "def", "install", "(", "path", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "path", ")", ")", "[", "0", "]", "callermod", "="...
Compiles a Thrift file and installs it as a submodule of the caller. Given a tree organized like so:: foo/ __init__.py bar.py my_service.thrift You would do, .. code-block:: python my_service = thriftrw.install('my_service.thrift') To install ``m...
[ "Compiles", "a", "Thrift", "file", "and", "installs", "it", "as", "a", "submodule", "of", "the", "caller", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/loader.py#L111-L164
thriftrw/thriftrw-python
thriftrw/loader.py
Loader.loads
def loads(self, name, document): """Parse and compile the given Thrift document. :param str name: Name of the Thrift document. :param str document: The Thrift IDL as a string. """ return self.compiler.compile(name, document).link().surface
python
def loads(self, name, document): """Parse and compile the given Thrift document. :param str name: Name of the Thrift document. :param str document: The Thrift IDL as a string. """ return self.compiler.compile(name, document).link().surface
[ "def", "loads", "(", "self", ",", "name", ",", "document", ")", ":", "return", "self", ".", "compiler", ".", "compile", "(", "name", ",", "document", ")", ".", "link", "(", ")", ".", "surface" ]
Parse and compile the given Thrift document. :param str name: Name of the Thrift document. :param str document: The Thrift IDL as a string.
[ "Parse", "and", "compile", "the", "given", "Thrift", "document", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/loader.py#L61-L69
thriftrw/thriftrw-python
thriftrw/loader.py
Loader.load
def load(self, path, name=None): """Load and compile the given Thrift file. :param str path: Path to the ``.thrift`` file. :param str name: Name of the generated module. Defaults to the base name of the file. :returns: The compiled module....
python
def load(self, path, name=None): """Load and compile the given Thrift file. :param str path: Path to the ``.thrift`` file. :param str name: Name of the generated module. Defaults to the base name of the file. :returns: The compiled module....
[ "def", "load", "(", "self", ",", "path", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "path", ")", ")", "[", "0", "]", "# T...
Load and compile the given Thrift file. :param str path: Path to the ``.thrift`` file. :param str name: Name of the generated module. Defaults to the base name of the file. :returns: The compiled module.
[ "Load", "and", "compile", "the", "given", "Thrift", "file", "." ]
train
https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/loader.py#L71-L89
sgaynetdinov/py-vkontakte
vk/auth.py
get_url_implicit_flow_user
def get_url_implicit_flow_user(client_id, scope, redirect_uri='https://oauth.vk.com/blank.html', display='page', response_type='token', version=None, state=None, revoke=1): """ https://vk.com/dev/implicit_flow_user :return: url """ url =...
python
def get_url_implicit_flow_user(client_id, scope, redirect_uri='https://oauth.vk.com/blank.html', display='page', response_type='token', version=None, state=None, revoke=1): """ https://vk.com/dev/implicit_flow_user :return: url """ url =...
[ "def", "get_url_implicit_flow_user", "(", "client_id", ",", "scope", ",", "redirect_uri", "=", "'https://oauth.vk.com/blank.html'", ",", "display", "=", "'page'", ",", "response_type", "=", "'token'", ",", "version", "=", "None", ",", "state", "=", "None", ",", ...
https://vk.com/dev/implicit_flow_user :return: url
[ "https", ":", "//", "vk", ".", "com", "/", "dev", "/", "implicit_flow_user" ]
train
https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/auth.py#L11-L32
sgaynetdinov/py-vkontakte
vk/auth.py
get_url_authcode_flow_user
def get_url_authcode_flow_user(client_id, redirect_uri, display="page", scope=None, state=None): """Authorization Code Flow for User Access Token Use Authorization Code Flow to run VK API methods from the server side of an application. Access token received this way is not bound to an ip address but set of...
python
def get_url_authcode_flow_user(client_id, redirect_uri, display="page", scope=None, state=None): """Authorization Code Flow for User Access Token Use Authorization Code Flow to run VK API methods from the server side of an application. Access token received this way is not bound to an ip address but set of...
[ "def", "get_url_authcode_flow_user", "(", "client_id", ",", "redirect_uri", ",", "display", "=", "\"page\"", ",", "scope", "=", "None", ",", "state", "=", "None", ")", ":", "url", "=", "\"https://oauth.vk.com/authorize\"", "params", "=", "{", "\"client_id\"", ":...
Authorization Code Flow for User Access Token Use Authorization Code Flow to run VK API methods from the server side of an application. Access token received this way is not bound to an ip address but set of permissions that can be granted is limited for security reasons. Args: client_id (int): Ap...
[ "Authorization", "Code", "Flow", "for", "User", "Access", "Token" ]
train
https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/auth.py#L35-L76
Spinmob/spinmob
egg/example_from_wiki.py
get_fake_data
def get_fake_data(*a): """ Called whenever someone presses the "fire" button. """ # add columns of data to the databox d['x'] = _n.linspace(0,10,100) d['y'] = _n.cos(d['x']) + 0.1*_n.random.rand(100) # update the curve c.setData(d['x'], d['y'])
python
def get_fake_data(*a): """ Called whenever someone presses the "fire" button. """ # add columns of data to the databox d['x'] = _n.linspace(0,10,100) d['y'] = _n.cos(d['x']) + 0.1*_n.random.rand(100) # update the curve c.setData(d['x'], d['y'])
[ "def", "get_fake_data", "(", "*", "a", ")", ":", "# add columns of data to the databox", "d", "[", "'x'", "]", "=", "_n", ".", "linspace", "(", "0", ",", "10", ",", "100", ")", "d", "[", "'y'", "]", "=", "_n", ".", "cos", "(", "d", "[", "'x'", "]...
Called whenever someone presses the "fire" button.
[ "Called", "whenever", "someone", "presses", "the", "fire", "button", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/example_from_wiki.py#L49-L58
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.setOpts
def setOpts(self, **opts): """ Changes the behavior of the SpinBox. Accepts most of the arguments allowed in :func:`__init__ <pyqtgraph.SpinBox.__init__>`. """ #print opts for k in opts: if k == 'bounds': #print opts[k] ...
python
def setOpts(self, **opts): """ Changes the behavior of the SpinBox. Accepts most of the arguments allowed in :func:`__init__ <pyqtgraph.SpinBox.__init__>`. """ #print opts for k in opts: if k == 'bounds': #print opts[k] ...
[ "def", "setOpts", "(", "self", ",", "*", "*", "opts", ")", ":", "#print opts", "for", "k", "in", "opts", ":", "if", "k", "==", "'bounds'", ":", "#print opts[k]", "self", ".", "setMinimum", "(", "opts", "[", "k", "]", "[", "0", "]", ",", "update", ...
Changes the behavior of the SpinBox. Accepts most of the arguments allowed in :func:`__init__ <pyqtgraph.SpinBox.__init__>`.
[ "Changes", "the", "behavior", "of", "the", "SpinBox", ".", "Accepts", "most", "of", "the", "arguments", "allowed", "in", ":", "func", ":", "__init__", "<pyqtgraph", ".", "SpinBox", ".", "__init__", ">", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L139-L192
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.setMaximum
def setMaximum(self, m, update=True): """Set the maximum allowed value (or None for no limit)""" if m is not None: m = D(asUnicode(m)) self.opts['bounds'][1] = m if update: self.setValue()
python
def setMaximum(self, m, update=True): """Set the maximum allowed value (or None for no limit)""" if m is not None: m = D(asUnicode(m)) self.opts['bounds'][1] = m if update: self.setValue()
[ "def", "setMaximum", "(", "self", ",", "m", ",", "update", "=", "True", ")", ":", "if", "m", "is", "not", "None", ":", "m", "=", "D", "(", "asUnicode", "(", "m", ")", ")", "self", ".", "opts", "[", "'bounds'", "]", "[", "1", "]", "=", "m", ...
Set the maximum allowed value (or None for no limit)
[ "Set", "the", "maximum", "allowed", "value", "(", "or", "None", "for", "no", "limit", ")" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L196-L202
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.selectNumber
def selectNumber(self): """ Select the numerical portion of the text to allow quick editing by the user. """ le = self.lineEdit() text = asUnicode(le.text()) if self.opts['suffix'] == '': le.setSelection(0, len(text)) else: try: ...
python
def selectNumber(self): """ Select the numerical portion of the text to allow quick editing by the user. """ le = self.lineEdit() text = asUnicode(le.text()) if self.opts['suffix'] == '': le.setSelection(0, len(text)) else: try: ...
[ "def", "selectNumber", "(", "self", ")", ":", "le", "=", "self", ".", "lineEdit", "(", ")", "text", "=", "asUnicode", "(", "le", ".", "text", "(", ")", ")", "if", "self", ".", "opts", "[", "'suffix'", "]", "==", "''", ":", "le", ".", "setSelectio...
Select the numerical portion of the text to allow quick editing by the user.
[ "Select", "the", "numerical", "portion", "of", "the", "text", "to", "allow", "quick", "editing", "by", "the", "user", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L236-L249
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.value
def value(self): """ Return the value of this SpinBox. """ if self.opts['int']: return int(self.val) else: return float(self.val)
python
def value(self): """ Return the value of this SpinBox. """ if self.opts['int']: return int(self.val) else: return float(self.val)
[ "def", "value", "(", "self", ")", ":", "if", "self", ".", "opts", "[", "'int'", "]", ":", "return", "int", "(", "self", ".", "val", ")", "else", ":", "return", "float", "(", "self", ".", "val", ")" ]
Return the value of this SpinBox.
[ "Return", "the", "value", "of", "this", "SpinBox", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L251-L259
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.setValue
def setValue(self, value=None, update=True, delaySignal=False): """ Set the value of this spin. If the value is out of bounds, it will be clipped to the nearest boundary. If the spin is integer type, the value will be coerced to int. Returns the actual value set. ...
python
def setValue(self, value=None, update=True, delaySignal=False): """ Set the value of this spin. If the value is out of bounds, it will be clipped to the nearest boundary. If the spin is integer type, the value will be coerced to int. Returns the actual value set. ...
[ "def", "setValue", "(", "self", ",", "value", "=", "None", ",", "update", "=", "True", ",", "delaySignal", "=", "False", ")", ":", "if", "value", "is", "None", ":", "value", "=", "self", ".", "value", "(", ")", "bounds", "=", "self", ".", "opts", ...
Set the value of this spin. If the value is out of bounds, it will be clipped to the nearest boundary. If the spin is integer type, the value will be coerced to int. Returns the actual value set. If value is None, then the current value is used (this is for resetting th...
[ "Set", "the", "value", "of", "this", "spin", ".", "If", "the", "value", "is", "out", "of", "bounds", "it", "will", "be", "clipped", "to", "the", "nearest", "boundary", ".", "If", "the", "spin", "is", "integer", "type", "the", "value", "will", "be", "...
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L261-L297
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.interpret
def interpret(self): """Return value of text. Return False if text is invalid, raise exception if text is intermediate""" strn = self.lineEdit().text() suf = self.opts['suffix'] if len(suf) > 0: if strn[-len(suf):] != suf: return False #raise Excep...
python
def interpret(self): """Return value of text. Return False if text is invalid, raise exception if text is intermediate""" strn = self.lineEdit().text() suf = self.opts['suffix'] if len(suf) > 0: if strn[-len(suf):] != suf: return False #raise Excep...
[ "def", "interpret", "(", "self", ")", ":", "strn", "=", "self", ".", "lineEdit", "(", ")", ".", "text", "(", ")", "suf", "=", "self", ".", "opts", "[", "'suffix'", "]", "if", "len", "(", "suf", ")", ">", "0", ":", "if", "strn", "[", "-", "len...
Return value of text. Return False if text is invalid, raise exception if text is intermediate
[ "Return", "value", "of", "text", ".", "Return", "False", "if", "text", "is", "invalid", "raise", "exception", "if", "text", "is", "intermediate" ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L473-L489
Spinmob/spinmob
egg/_temporary_fixes.py
SpinBox.editingFinishedEvent
def editingFinishedEvent(self): """Edit has finished; set value.""" #print "Edit finished." if asUnicode(self.lineEdit().text()) == self.lastText: #print "no text change." return try: val = self.interpret() except: return ...
python
def editingFinishedEvent(self): """Edit has finished; set value.""" #print "Edit finished." if asUnicode(self.lineEdit().text()) == self.lastText: #print "no text change." return try: val = self.interpret() except: return ...
[ "def", "editingFinishedEvent", "(", "self", ")", ":", "#print \"Edit finished.\"", "if", "asUnicode", "(", "self", ".", "lineEdit", "(", ")", ".", "text", "(", ")", ")", "==", "self", ".", "lastText", ":", "#print \"no text change.\"", "return", "try", ":", ...
Edit has finished; set value.
[ "Edit", "has", "finished", ";", "set", "value", "." ]
train
https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/_temporary_fixes.py#L499-L516
sbaechler/django-scaffolding
scaffolding/management/commands/scaffold.py
Command.make_factory
def make_factory(self, cls, count): """ Get the generators from the Scaffolding class within the model. """ field_names = cls._meta.get_all_field_names() fields = {} text = [] finalizer = None scaffold = scaffolding.scaffold_for_model(cls) for field_name ...
python
def make_factory(self, cls, count): """ Get the generators from the Scaffolding class within the model. """ field_names = cls._meta.get_all_field_names() fields = {} text = [] finalizer = None scaffold = scaffolding.scaffold_for_model(cls) for field_name ...
[ "def", "make_factory", "(", "self", ",", "cls", ",", "count", ")", ":", "field_names", "=", "cls", ".", "_meta", ".", "get_all_field_names", "(", ")", "fields", "=", "{", "}", "text", "=", "[", "]", "finalizer", "=", "None", "scaffold", "=", "scaffoldi...
Get the generators from the Scaffolding class within the model.
[ "Get", "the", "generators", "from", "the", "Scaffolding", "class", "within", "the", "model", "." ]
train
https://github.com/sbaechler/django-scaffolding/blob/db78d99efe4fa1f3ef452fd0afd55fcdfdaea6db/scaffolding/management/commands/scaffold.py#L42-L66
KarchinLab/probabilistic2020
prob2020/python/indel.py
compute_indel_length
def compute_indel_length(fs_df): """Computes the indel length accounting for wether it is an insertion or deletion. Parameters ---------- fs_df : pd.DataFrame mutation input as dataframe only containing indel mutations Returns ------- indel_len : pd.Series length of ind...
python
def compute_indel_length(fs_df): """Computes the indel length accounting for wether it is an insertion or deletion. Parameters ---------- fs_df : pd.DataFrame mutation input as dataframe only containing indel mutations Returns ------- indel_len : pd.Series length of ind...
[ "def", "compute_indel_length", "(", "fs_df", ")", ":", "indel_len", "=", "pd", ".", "Series", "(", "index", "=", "fs_df", ".", "index", ")", "indel_len", "[", "fs_df", "[", "'Reference_Allele'", "]", "==", "'-'", "]", "=", "fs_df", "[", "'Tumor_Allele'", ...
Computes the indel length accounting for wether it is an insertion or deletion. Parameters ---------- fs_df : pd.DataFrame mutation input as dataframe only containing indel mutations Returns ------- indel_len : pd.Series length of indels
[ "Computes", "the", "indel", "length", "accounting", "for", "wether", "it", "is", "an", "insertion", "or", "deletion", "." ]
train
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/indel.py#L125-L143
KarchinLab/probabilistic2020
prob2020/python/indel.py
keep_indels
def keep_indels(mut_df, indel_len_col=True, indel_type_col=True): """Filters out all mutations that are not indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, resp...
python
def keep_indels(mut_df, indel_len_col=True, indel_type_col=True): """Filters out all mutations that are not indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, resp...
[ "def", "keep_indels", "(", "mut_df", ",", "indel_len_col", "=", "True", ",", "indel_type_col", "=", "True", ")", ":", "# keep only frameshifts", "mut_df", "=", "mut_df", "[", "is_indel_annotation", "(", "mut_df", ")", "]", "if", "indel_len_col", ":", "# calculat...
Filters out all mutations that are not indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, respectively. Parameters ---------- mut_df : pd.DataFrame mutation input file as a dataf...
[ "Filters", "out", "all", "mutations", "that", "are", "not", "indels", "." ]
train
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/indel.py#L146-L181
KarchinLab/probabilistic2020
prob2020/python/indel.py
keep_frameshifts
def keep_frameshifts(mut_df, indel_len_col=True): """Filters out all mutations that are not frameshift indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, respectively. P...
python
def keep_frameshifts(mut_df, indel_len_col=True): """Filters out all mutations that are not frameshift indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, respectively. P...
[ "def", "keep_frameshifts", "(", "mut_df", ",", "indel_len_col", "=", "True", ")", ":", "# keep only frameshifts", "mut_df", "=", "mut_df", "[", "is_frameshift_annotation", "(", "mut_df", ")", "]", "if", "indel_len_col", ":", "# calculate length", "mut_df", ".", "l...
Filters out all mutations that are not frameshift indels. Requires that one of the alleles have '-' indicating either an insertion or deletion depending if found in reference allele or somatic allele columns, respectively. Parameters ---------- mut_df : pd.DataFrame mutation input file...
[ "Filters", "out", "all", "mutations", "that", "are", "not", "frameshift", "indels", "." ]
train
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/indel.py#L184-L210
KarchinLab/probabilistic2020
prob2020/python/indel.py
is_frameshift_len
def is_frameshift_len(mut_df): """Simply returns a series indicating whether each corresponding mutation is a frameshift. This is based on the length of the indel. Thus may be fooled by frameshifts at exon-intron boundaries or other odd cases. Parameters ---------- mut_df : pd.DataFrame ...
python
def is_frameshift_len(mut_df): """Simply returns a series indicating whether each corresponding mutation is a frameshift. This is based on the length of the indel. Thus may be fooled by frameshifts at exon-intron boundaries or other odd cases. Parameters ---------- mut_df : pd.DataFrame ...
[ "def", "is_frameshift_len", "(", "mut_df", ")", ":", "# calculate length, 0-based coordinates", "#indel_len = mut_df['End_Position'] - mut_df['Start_Position']", "if", "'indel len'", "in", "mut_df", ".", "columns", ":", "indel_len", "=", "mut_df", "[", "'indel len'", "]", "...
Simply returns a series indicating whether each corresponding mutation is a frameshift. This is based on the length of the indel. Thus may be fooled by frameshifts at exon-intron boundaries or other odd cases. Parameters ---------- mut_df : pd.DataFrame mutation input file as a datafra...
[ "Simply", "returns", "a", "series", "indicating", "whether", "each", "corresponding", "mutation", "is", "a", "frameshift", "." ]
train
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/indel.py#L213-L243
KarchinLab/probabilistic2020
prob2020/python/indel.py
get_frameshift_lengths
def get_frameshift_lengths(num_bins): """Simple function that returns the lengths for each frameshift category if `num_bins` number of frameshift categories are requested. """ fs_len = [] i = 1 tmp_bins = 0 while(tmp_bins<num_bins): if i%3: fs_len.append(i) tm...
python
def get_frameshift_lengths(num_bins): """Simple function that returns the lengths for each frameshift category if `num_bins` number of frameshift categories are requested. """ fs_len = [] i = 1 tmp_bins = 0 while(tmp_bins<num_bins): if i%3: fs_len.append(i) tm...
[ "def", "get_frameshift_lengths", "(", "num_bins", ")", ":", "fs_len", "=", "[", "]", "i", "=", "1", "tmp_bins", "=", "0", "while", "(", "tmp_bins", "<", "num_bins", ")", ":", "if", "i", "%", "3", ":", "fs_len", ".", "append", "(", "i", ")", "tmp_bi...
Simple function that returns the lengths for each frameshift category if `num_bins` number of frameshift categories are requested.
[ "Simple", "function", "that", "returns", "the", "lengths", "for", "each", "frameshift", "category", "if", "num_bins", "number", "of", "frameshift", "categories", "are", "requested", "." ]
train
https://github.com/KarchinLab/probabilistic2020/blob/5d70583b0a7c07cfe32e95f3a70e05df412acb84/prob2020/python/indel.py#L289-L301