id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
12,300
thunder-project/thunder
thunder/images/images.py
Images.subtract
def subtract(self, val): """ Subtract a constant value or an image from all images. Parameters ---------- val : int, float, or ndarray Value to subtract. """ if isinstance(val, ndarray): if val.shape != self.value_shape: ra...
python
def subtract(self, val): """ Subtract a constant value or an image from all images. Parameters ---------- val : int, float, or ndarray Value to subtract. """ if isinstance(val, ndarray): if val.shape != self.value_shape: ra...
[ "def", "subtract", "(", "self", ",", "val", ")", ":", "if", "isinstance", "(", "val", ",", "ndarray", ")", ":", "if", "val", ".", "shape", "!=", "self", ".", "value_shape", ":", "raise", "Exception", "(", "'Cannot subtract image with dimensions %s '", "'from...
Subtract a constant value or an image from all images. Parameters ---------- val : int, float, or ndarray Value to subtract.
[ "Subtract", "a", "constant", "value", "or", "an", "image", "from", "all", "images", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/images/images.py#L456-L470
12,301
thunder-project/thunder
thunder/images/images.py
Images.topng
def topng(self, path, prefix='image', overwrite=False): """ Write 2d images as PNG files. Files will be written into a newly-created directory. Three-dimensional data will be treated as RGB channels. Parameters ---------- path : string Path to output...
python
def topng(self, path, prefix='image', overwrite=False): """ Write 2d images as PNG files. Files will be written into a newly-created directory. Three-dimensional data will be treated as RGB channels. Parameters ---------- path : string Path to output...
[ "def", "topng", "(", "self", ",", "path", ",", "prefix", "=", "'image'", ",", "overwrite", "=", "False", ")", ":", "from", "thunder", ".", "images", ".", "writers", "import", "topng", "# TODO add back colormap and vmin/vmax", "topng", "(", "self", ",", "path...
Write 2d images as PNG files. Files will be written into a newly-created directory. Three-dimensional data will be treated as RGB channels. Parameters ---------- path : string Path to output directory, must be one level below an existing directory. prefix :...
[ "Write", "2d", "images", "as", "PNG", "files", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/images/images.py#L472-L492
12,302
thunder-project/thunder
thunder/images/images.py
Images.map_as_series
def map_as_series(self, func, value_size=None, dtype=None, chunk_size='auto'): """ Efficiently apply a function to images as series data. For images data that represent image sequences, this method applies a function to each pixel's series, and then returns to the images format,...
python
def map_as_series(self, func, value_size=None, dtype=None, chunk_size='auto'): """ Efficiently apply a function to images as series data. For images data that represent image sequences, this method applies a function to each pixel's series, and then returns to the images format,...
[ "def", "map_as_series", "(", "self", ",", "func", ",", "value_size", "=", "None", ",", "dtype", "=", "None", ",", "chunk_size", "=", "'auto'", ")", ":", "blocks", "=", "self", ".", "toblocks", "(", "chunk_size", "=", "chunk_size", ")", "if", "value_size"...
Efficiently apply a function to images as series data. For images data that represent image sequences, this method applies a function to each pixel's series, and then returns to the images format, using an efficient intermediate block representation. Parameters --------...
[ "Efficiently", "apply", "a", "function", "to", "images", "as", "series", "data", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/images/images.py#L536-L577
12,303
thunder-project/thunder
thunder/blocks/blocks.py
Blocks.count
def count(self): """ Explicit count of the number of items. For lazy or distributed data, will force a computation. """ if self.mode == 'spark': return self.tordd().count() if self.mode == 'local': return prod(self.values.values.shape)
python
def count(self): """ Explicit count of the number of items. For lazy or distributed data, will force a computation. """ if self.mode == 'spark': return self.tordd().count() if self.mode == 'local': return prod(self.values.values.shape)
[ "def", "count", "(", "self", ")", ":", "if", "self", ".", "mode", "==", "'spark'", ":", "return", "self", ".", "tordd", "(", ")", ".", "count", "(", ")", "if", "self", ".", "mode", "==", "'local'", ":", "return", "prod", "(", "self", ".", "values...
Explicit count of the number of items. For lazy or distributed data, will force a computation.
[ "Explicit", "count", "of", "the", "number", "of", "items", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/blocks/blocks.py#L30-L40
12,304
thunder-project/thunder
thunder/blocks/blocks.py
Blocks.collect_blocks
def collect_blocks(self): """ Collect the blocks in a list """ if self.mode == 'spark': return self.values.tordd().sortByKey().values().collect() if self.mode == 'local': return self.values.values.flatten().tolist()
python
def collect_blocks(self): """ Collect the blocks in a list """ if self.mode == 'spark': return self.values.tordd().sortByKey().values().collect() if self.mode == 'local': return self.values.values.flatten().tolist()
[ "def", "collect_blocks", "(", "self", ")", ":", "if", "self", ".", "mode", "==", "'spark'", ":", "return", "self", ".", "values", ".", "tordd", "(", ")", ".", "sortByKey", "(", ")", ".", "values", "(", ")", ".", "collect", "(", ")", "if", "self", ...
Collect the blocks in a list
[ "Collect", "the", "blocks", "in", "a", "list" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/blocks/blocks.py#L42-L50
12,305
thunder-project/thunder
thunder/blocks/blocks.py
Blocks.map
def map(self, func, value_shape=None, dtype=None): """ Apply an array -> array function to each block """ mapped = self.values.map(func, value_shape=value_shape, dtype=dtype) return self._constructor(mapped).__finalize__(self, noprop=('dtype',))
python
def map(self, func, value_shape=None, dtype=None): """ Apply an array -> array function to each block """ mapped = self.values.map(func, value_shape=value_shape, dtype=dtype) return self._constructor(mapped).__finalize__(self, noprop=('dtype',))
[ "def", "map", "(", "self", ",", "func", ",", "value_shape", "=", "None", ",", "dtype", "=", "None", ")", ":", "mapped", "=", "self", ".", "values", ".", "map", "(", "func", ",", "value_shape", "=", "value_shape", ",", "dtype", "=", "dtype", ")", "r...
Apply an array -> array function to each block
[ "Apply", "an", "array", "-", ">", "array", "function", "to", "each", "block" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/blocks/blocks.py#L52-L57
12,306
thunder-project/thunder
thunder/blocks/blocks.py
Blocks.toimages
def toimages(self): """ Convert blocks to images. """ from thunder.images.images import Images if self.mode == 'spark': values = self.values.values_to_keys((0,)).unchunk() if self.mode == 'local': values = self.values.unchunk() return Im...
python
def toimages(self): """ Convert blocks to images. """ from thunder.images.images import Images if self.mode == 'spark': values = self.values.values_to_keys((0,)).unchunk() if self.mode == 'local': values = self.values.unchunk() return Im...
[ "def", "toimages", "(", "self", ")", ":", "from", "thunder", ".", "images", ".", "images", "import", "Images", "if", "self", ".", "mode", "==", "'spark'", ":", "values", "=", "self", ".", "values", ".", "values_to_keys", "(", "(", "0", ",", ")", ")",...
Convert blocks to images.
[ "Convert", "blocks", "to", "images", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/blocks/blocks.py#L75-L87
12,307
thunder-project/thunder
thunder/blocks/blocks.py
Blocks.toseries
def toseries(self): """ Converts blocks to series. """ from thunder.series.series import Series if self.mode == 'spark': values = self.values.values_to_keys(tuple(range(1, len(self.shape)))).unchunk() if self.mode == 'local': values = self.values...
python
def toseries(self): """ Converts blocks to series. """ from thunder.series.series import Series if self.mode == 'spark': values = self.values.values_to_keys(tuple(range(1, len(self.shape)))).unchunk() if self.mode == 'local': values = self.values...
[ "def", "toseries", "(", "self", ")", ":", "from", "thunder", ".", "series", ".", "series", "import", "Series", "if", "self", ".", "mode", "==", "'spark'", ":", "values", "=", "self", ".", "values", ".", "values_to_keys", "(", "tuple", "(", "range", "("...
Converts blocks to series.
[ "Converts", "blocks", "to", "series", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/blocks/blocks.py#L89-L102
12,308
thunder-project/thunder
thunder/blocks/blocks.py
Blocks.toarray
def toarray(self): """ Convert blocks to local ndarray """ if self.mode == 'spark': return self.values.unchunk().toarray() if self.mode == 'local': return self.values.unchunk()
python
def toarray(self): """ Convert blocks to local ndarray """ if self.mode == 'spark': return self.values.unchunk().toarray() if self.mode == 'local': return self.values.unchunk()
[ "def", "toarray", "(", "self", ")", ":", "if", "self", ".", "mode", "==", "'spark'", ":", "return", "self", ".", "values", ".", "unchunk", "(", ")", ".", "toarray", "(", ")", "if", "self", ".", "mode", "==", "'local'", ":", "return", "self", ".", ...
Convert blocks to local ndarray
[ "Convert", "blocks", "to", "local", "ndarray" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/blocks/blocks.py#L104-L112
12,309
thunder-project/thunder
thunder/series/series.py
Series.flatten
def flatten(self): """ Reshape all dimensions but the last into a single dimension """ size = prod(self.shape[:-1]) return self.reshape(size, self.shape[-1])
python
def flatten(self): """ Reshape all dimensions but the last into a single dimension """ size = prod(self.shape[:-1]) return self.reshape(size, self.shape[-1])
[ "def", "flatten", "(", "self", ")", ":", "size", "=", "prod", "(", "self", ".", "shape", "[", ":", "-", "1", "]", ")", "return", "self", ".", "reshape", "(", "size", ",", "self", ".", "shape", "[", "-", "1", "]", ")" ]
Reshape all dimensions but the last into a single dimension
[ "Reshape", "all", "dimensions", "but", "the", "last", "into", "a", "single", "dimension" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L81-L86
12,310
thunder-project/thunder
thunder/series/series.py
Series.tospark
def tospark(self, engine=None): """ Convert to spark mode. """ from thunder.series.readers import fromarray if self.mode == 'spark': logging.getLogger('thunder').warn('images already in local mode') pass if engine is None: raise Value...
python
def tospark(self, engine=None): """ Convert to spark mode. """ from thunder.series.readers import fromarray if self.mode == 'spark': logging.getLogger('thunder').warn('images already in local mode') pass if engine is None: raise Value...
[ "def", "tospark", "(", "self", ",", "engine", "=", "None", ")", ":", "from", "thunder", ".", "series", ".", "readers", "import", "fromarray", "if", "self", ".", "mode", "==", "'spark'", ":", "logging", ".", "getLogger", "(", "'thunder'", ")", ".", "war...
Convert to spark mode.
[ "Convert", "to", "spark", "mode", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L122-L135
12,311
thunder-project/thunder
thunder/series/series.py
Series.sample
def sample(self, n=100, seed=None): """ Extract random sample of records. Parameters ---------- n : int, optional, default = 100 The number of data points to sample. seed : int, optional, default = None Random seed. """ if n < 1: ...
python
def sample(self, n=100, seed=None): """ Extract random sample of records. Parameters ---------- n : int, optional, default = 100 The number of data points to sample. seed : int, optional, default = None Random seed. """ if n < 1: ...
[ "def", "sample", "(", "self", ",", "n", "=", "100", ",", "seed", "=", "None", ")", ":", "if", "n", "<", "1", ":", "raise", "ValueError", "(", "\"Number of samples must be larger than 0, got '%g'\"", "%", "n", ")", "if", "seed", "is", "None", ":", "seed",...
Extract random sample of records. Parameters ---------- n : int, optional, default = 100 The number of data points to sample. seed : int, optional, default = None Random seed.
[ "Extract", "random", "sample", "of", "records", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L137-L163
12,312
thunder-project/thunder
thunder/series/series.py
Series.map
def map(self, func, index=None, value_shape=None, dtype=None, with_keys=False): """ Map an array -> array function over each record. Parameters ---------- func : function A function of a single record. index : array-like, optional, default = None ...
python
def map(self, func, index=None, value_shape=None, dtype=None, with_keys=False): """ Map an array -> array function over each record. Parameters ---------- func : function A function of a single record. index : array-like, optional, default = None ...
[ "def", "map", "(", "self", ",", "func", ",", "index", "=", "None", ",", "value_shape", "=", "None", ",", "dtype", "=", "None", ",", "with_keys", "=", "False", ")", ":", "# if new index is given, can infer missing value_shape", "if", "value_shape", "is", "None"...
Map an array -> array function over each record. Parameters ---------- func : function A function of a single record. index : array-like, optional, default = None If known, the index to be used following function evaluation. value_shape : int, optional,...
[ "Map", "an", "array", "-", ">", "array", "function", "over", "each", "record", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L165-L202
12,313
thunder-project/thunder
thunder/series/series.py
Series.mean
def mean(self): """ Compute the mean across records """ return self._constructor(self.values.mean(axis=self.baseaxes, keepdims=True))
python
def mean(self): """ Compute the mean across records """ return self._constructor(self.values.mean(axis=self.baseaxes, keepdims=True))
[ "def", "mean", "(", "self", ")", ":", "return", "self", ".", "_constructor", "(", "self", ".", "values", ".", "mean", "(", "axis", "=", "self", ".", "baseaxes", ",", "keepdims", "=", "True", ")", ")" ]
Compute the mean across records
[ "Compute", "the", "mean", "across", "records" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L215-L219
12,314
thunder-project/thunder
thunder/series/series.py
Series.sum
def sum(self): """ Compute the sum across records. """ return self._constructor(self.values.sum(axis=self.baseaxes, keepdims=True))
python
def sum(self): """ Compute the sum across records. """ return self._constructor(self.values.sum(axis=self.baseaxes, keepdims=True))
[ "def", "sum", "(", "self", ")", ":", "return", "self", ".", "_constructor", "(", "self", ".", "values", ".", "sum", "(", "axis", "=", "self", ".", "baseaxes", ",", "keepdims", "=", "True", ")", ")" ]
Compute the sum across records.
[ "Compute", "the", "sum", "across", "records", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L233-L237
12,315
thunder-project/thunder
thunder/series/series.py
Series.max
def max(self): """ Compute the max across records. """ return self._constructor(self.values.max(axis=self.baseaxes, keepdims=True))
python
def max(self): """ Compute the max across records. """ return self._constructor(self.values.max(axis=self.baseaxes, keepdims=True))
[ "def", "max", "(", "self", ")", ":", "return", "self", ".", "_constructor", "(", "self", ".", "values", ".", "max", "(", "axis", "=", "self", ".", "baseaxes", ",", "keepdims", "=", "True", ")", ")" ]
Compute the max across records.
[ "Compute", "the", "max", "across", "records", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L239-L243
12,316
thunder-project/thunder
thunder/series/series.py
Series.min
def min(self): """ Compute the min across records. """ return self._constructor(self.values.min(axis=self.baseaxes, keepdims=True))
python
def min(self): """ Compute the min across records. """ return self._constructor(self.values.min(axis=self.baseaxes, keepdims=True))
[ "def", "min", "(", "self", ")", ":", "return", "self", ".", "_constructor", "(", "self", ".", "values", ".", "min", "(", "axis", "=", "self", ".", "baseaxes", ",", "keepdims", "=", "True", ")", ")" ]
Compute the min across records.
[ "Compute", "the", "min", "across", "records", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L245-L249
12,317
thunder-project/thunder
thunder/series/series.py
Series.reshape
def reshape(self, *shape): """ Reshape the Series object Cannot change the last dimension. Parameters ---------- shape: one or more ints New shape """ if prod(self.shape) != prod(shape): raise ValueError("Reshaping must leave the ...
python
def reshape(self, *shape): """ Reshape the Series object Cannot change the last dimension. Parameters ---------- shape: one or more ints New shape """ if prod(self.shape) != prod(shape): raise ValueError("Reshaping must leave the ...
[ "def", "reshape", "(", "self", ",", "*", "shape", ")", ":", "if", "prod", "(", "self", ".", "shape", ")", "!=", "prod", "(", "shape", ")", ":", "raise", "ValueError", "(", "\"Reshaping must leave the number of elements unchanged\"", ")", "if", "self", ".", ...
Reshape the Series object Cannot change the last dimension. Parameters ---------- shape: one or more ints New shape
[ "Reshape", "the", "Series", "object" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L251-L273
12,318
thunder-project/thunder
thunder/series/series.py
Series.between
def between(self, left, right): """ Select subset of values within the given index range. Inclusive on the left; exclusive on the right. Parameters ---------- left : int Left-most index in the desired range. right: int Right-most index i...
python
def between(self, left, right): """ Select subset of values within the given index range. Inclusive on the left; exclusive on the right. Parameters ---------- left : int Left-most index in the desired range. right: int Right-most index i...
[ "def", "between", "(", "self", ",", "left", ",", "right", ")", ":", "crit", "=", "lambda", "x", ":", "left", "<=", "x", "<", "right", "return", "self", ".", "select", "(", "crit", ")" ]
Select subset of values within the given index range. Inclusive on the left; exclusive on the right. Parameters ---------- left : int Left-most index in the desired range. right: int Right-most index in the desired range.
[ "Select", "subset", "of", "values", "within", "the", "given", "index", "range", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L275-L290
12,319
thunder-project/thunder
thunder/series/series.py
Series.select
def select(self, crit): """ Select subset of values that match a given index criterion. Parameters ---------- crit : function, list, str, int Criterion function to map to indices, specific index value, or list of indices. """ import types ...
python
def select(self, crit): """ Select subset of values that match a given index criterion. Parameters ---------- crit : function, list, str, int Criterion function to map to indices, specific index value, or list of indices. """ import types ...
[ "def", "select", "(", "self", ",", "crit", ")", ":", "import", "types", "# handle lists, strings, and ints", "if", "not", "isinstance", "(", "crit", ",", "types", ".", "FunctionType", ")", ":", "# set(\"foo\") -> {\"f\", \"o\"}; wrap in list to prevent:", "if", "isins...
Select subset of values that match a given index criterion. Parameters ---------- crit : function, list, str, int Criterion function to map to indices, specific index value, or list of indices.
[ "Select", "subset", "of", "values", "that", "match", "a", "given", "index", "criterion", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L292-L348
12,320
thunder-project/thunder
thunder/series/series.py
Series.center
def center(self, axis=1): """ Subtract the mean either within or across records. Parameters ---------- axis : int, optional, default = 1 Which axis to center along, within (1) or across (0) records. """ if axis == 1: return self.map(lambda...
python
def center(self, axis=1): """ Subtract the mean either within or across records. Parameters ---------- axis : int, optional, default = 1 Which axis to center along, within (1) or across (0) records. """ if axis == 1: return self.map(lambda...
[ "def", "center", "(", "self", ",", "axis", "=", "1", ")", ":", "if", "axis", "==", "1", ":", "return", "self", ".", "map", "(", "lambda", "x", ":", "x", "-", "mean", "(", "x", ")", ")", "elif", "axis", "==", "0", ":", "meanval", "=", "self", ...
Subtract the mean either within or across records. Parameters ---------- axis : int, optional, default = 1 Which axis to center along, within (1) or across (0) records.
[ "Subtract", "the", "mean", "either", "within", "or", "across", "records", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L350-L365
12,321
thunder-project/thunder
thunder/series/series.py
Series.standardize
def standardize(self, axis=1): """ Divide by standard deviation either within or across records. Parameters ---------- axis : int, optional, default = 0 Which axis to standardize along, within (1) or across (0) records """ if axis == 1: re...
python
def standardize(self, axis=1): """ Divide by standard deviation either within or across records. Parameters ---------- axis : int, optional, default = 0 Which axis to standardize along, within (1) or across (0) records """ if axis == 1: re...
[ "def", "standardize", "(", "self", ",", "axis", "=", "1", ")", ":", "if", "axis", "==", "1", ":", "return", "self", ".", "map", "(", "lambda", "x", ":", "x", "/", "std", "(", "x", ")", ")", "elif", "axis", "==", "0", ":", "stdval", "=", "self...
Divide by standard deviation either within or across records. Parameters ---------- axis : int, optional, default = 0 Which axis to standardize along, within (1) or across (0) records
[ "Divide", "by", "standard", "deviation", "either", "within", "or", "across", "records", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L367-L382
12,322
thunder-project/thunder
thunder/series/series.py
Series.zscore
def zscore(self, axis=1): """ Subtract the mean and divide by standard deviation within or across records. Parameters ---------- axis : int, optional, default = 0 Which axis to zscore along, within (1) or across (0) records """ if axis == 1: ...
python
def zscore(self, axis=1): """ Subtract the mean and divide by standard deviation within or across records. Parameters ---------- axis : int, optional, default = 0 Which axis to zscore along, within (1) or across (0) records """ if axis == 1: ...
[ "def", "zscore", "(", "self", ",", "axis", "=", "1", ")", ":", "if", "axis", "==", "1", ":", "return", "self", ".", "map", "(", "lambda", "x", ":", "(", "x", "-", "mean", "(", "x", ")", ")", "/", "std", "(", "x", ")", ")", "elif", "axis", ...
Subtract the mean and divide by standard deviation within or across records. Parameters ---------- axis : int, optional, default = 0 Which axis to zscore along, within (1) or across (0) records
[ "Subtract", "the", "mean", "and", "divide", "by", "standard", "deviation", "within", "or", "across", "records", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L384-L400
12,323
thunder-project/thunder
thunder/series/series.py
Series.squelch
def squelch(self, threshold): """ Set all records that do not exceed the given threhsold to 0. Parameters ---------- threshold : scalar Level below which to set records to zero """ func = lambda x: zeros(x.shape) if max(x) < threshold else x r...
python
def squelch(self, threshold): """ Set all records that do not exceed the given threhsold to 0. Parameters ---------- threshold : scalar Level below which to set records to zero """ func = lambda x: zeros(x.shape) if max(x) < threshold else x r...
[ "def", "squelch", "(", "self", ",", "threshold", ")", ":", "func", "=", "lambda", "x", ":", "zeros", "(", "x", ".", "shape", ")", "if", "max", "(", "x", ")", "<", "threshold", "else", "x", "return", "self", ".", "map", "(", "func", ")" ]
Set all records that do not exceed the given threhsold to 0. Parameters ---------- threshold : scalar Level below which to set records to zero
[ "Set", "all", "records", "that", "do", "not", "exceed", "the", "given", "threhsold", "to", "0", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L402-L412
12,324
thunder-project/thunder
thunder/series/series.py
Series.correlate
def correlate(self, signal): """ Correlate records against one or many one-dimensional arrays. Parameters ---------- signal : array-like One or more signals to correlate against. """ s = asarray(signal) if s.ndim == 1: if size(s) ...
python
def correlate(self, signal): """ Correlate records against one or many one-dimensional arrays. Parameters ---------- signal : array-like One or more signals to correlate against. """ s = asarray(signal) if s.ndim == 1: if size(s) ...
[ "def", "correlate", "(", "self", ",", "signal", ")", ":", "s", "=", "asarray", "(", "signal", ")", "if", "s", ".", "ndim", "==", "1", ":", "if", "size", "(", "s", ")", "!=", "self", ".", "shape", "[", "-", "1", "]", ":", "raise", "ValueError", ...
Correlate records against one or many one-dimensional arrays. Parameters ---------- signal : array-like One or more signals to correlate against.
[ "Correlate", "records", "against", "one", "or", "many", "one", "-", "dimensional", "arrays", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L414-L440
12,325
thunder-project/thunder
thunder/series/series.py
Series._check_panel
def _check_panel(self, length): """ Check that given fixed panel length evenly divides index. Parameters ---------- length : int Fixed length with which to subdivide index """ n = len(self.index) if divmod(n, length)[1] != 0: raise...
python
def _check_panel(self, length): """ Check that given fixed panel length evenly divides index. Parameters ---------- length : int Fixed length with which to subdivide index """ n = len(self.index) if divmod(n, length)[1] != 0: raise...
[ "def", "_check_panel", "(", "self", ",", "length", ")", ":", "n", "=", "len", "(", "self", ".", "index", ")", "if", "divmod", "(", "n", ",", "length", ")", "[", "1", "]", "!=", "0", ":", "raise", "ValueError", "(", "\"Panel length '%g' must evenly divi...
Check that given fixed panel length evenly divides index. Parameters ---------- length : int Fixed length with which to subdivide index
[ "Check", "that", "given", "fixed", "panel", "length", "evenly", "divides", "index", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L442-L457
12,326
thunder-project/thunder
thunder/series/series.py
Series.mean_by_panel
def mean_by_panel(self, length): """ Compute the mean across fixed sized panels of each record. Splits each record into panels of size `length`, and then computes the mean across panels. Panel length must subdivide record exactly. Parameters ---------- l...
python
def mean_by_panel(self, length): """ Compute the mean across fixed sized panels of each record. Splits each record into panels of size `length`, and then computes the mean across panels. Panel length must subdivide record exactly. Parameters ---------- l...
[ "def", "mean_by_panel", "(", "self", ",", "length", ")", ":", "self", ".", "_check_panel", "(", "length", ")", "func", "=", "lambda", "v", ":", "v", ".", "reshape", "(", "-", "1", ",", "length", ")", ".", "mean", "(", "axis", "=", "0", ")", "newi...
Compute the mean across fixed sized panels of each record. Splits each record into panels of size `length`, and then computes the mean across panels. Panel length must subdivide record exactly. Parameters ---------- length : int Fixed length with which to su...
[ "Compute", "the", "mean", "across", "fixed", "sized", "panels", "of", "each", "record", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L459-L475
12,327
thunder-project/thunder
thunder/series/series.py
Series._makemasks
def _makemasks(self, index=None, level=0): """ Internal function for generating masks for selecting values based on multi-index values. As all other multi-index functions will call this function, basic type-checking is also performed at this stage. """ if index is None: ...
python
def _makemasks(self, index=None, level=0): """ Internal function for generating masks for selecting values based on multi-index values. As all other multi-index functions will call this function, basic type-checking is also performed at this stage. """ if index is None: ...
[ "def", "_makemasks", "(", "self", ",", "index", "=", "None", ",", "level", "=", "0", ")", ":", "if", "index", "is", "None", ":", "index", "=", "self", ".", "index", "try", ":", "dims", "=", "len", "(", "array", "(", "index", ")", ".", "shape", ...
Internal function for generating masks for selecting values based on multi-index values. As all other multi-index functions will call this function, basic type-checking is also performed at this stage.
[ "Internal", "function", "for", "generating", "masks", "for", "selecting", "values", "based", "on", "multi", "-", "index", "values", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L477-L507
12,328
thunder-project/thunder
thunder/series/series.py
Series._map_by_index
def _map_by_index(self, function, level=0): """ An internal function for maping a function to groups of values based on a multi-index Elements of each record are grouped according to unique value combinations of the multi- index across the given levels of the multi-index. Then the given...
python
def _map_by_index(self, function, level=0): """ An internal function for maping a function to groups of values based on a multi-index Elements of each record are grouped according to unique value combinations of the multi- index across the given levels of the multi-index. Then the given...
[ "def", "_map_by_index", "(", "self", ",", "function", ",", "level", "=", "0", ")", ":", "if", "type", "(", "level", ")", "is", "int", ":", "level", "=", "[", "level", "]", "masks", ",", "ind", "=", "self", ".", "_makemasks", "(", "index", "=", "s...
An internal function for maping a function to groups of values based on a multi-index Elements of each record are grouped according to unique value combinations of the multi- index across the given levels of the multi-index. Then the given function is applied to to each of these groups separate...
[ "An", "internal", "function", "for", "maping", "a", "function", "to", "groups", "of", "values", "based", "on", "a", "multi", "-", "index" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L509-L528
12,329
thunder-project/thunder
thunder/series/series.py
Series.aggregate_by_index
def aggregate_by_index(self, function, level=0): """ Aggregrate data in each record, grouping by index values. For each unique value of the index, applies a function to the group indexed by that value. Returns a Series indexed by those unique values. For the result to be a valid...
python
def aggregate_by_index(self, function, level=0): """ Aggregrate data in each record, grouping by index values. For each unique value of the index, applies a function to the group indexed by that value. Returns a Series indexed by those unique values. For the result to be a valid...
[ "def", "aggregate_by_index", "(", "self", ",", "function", ",", "level", "=", "0", ")", ":", "result", "=", "self", ".", "_map_by_index", "(", "function", ",", "level", "=", "level", ")", "return", "result", ".", "map", "(", "lambda", "v", ":", "array"...
Aggregrate data in each record, grouping by index values. For each unique value of the index, applies a function to the group indexed by that value. Returns a Series indexed by those unique values. For the result to be a valid Series object, the aggregating function should return a simp...
[ "Aggregrate", "data", "in", "each", "record", "grouping", "by", "index", "values", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L628-L649
12,330
thunder-project/thunder
thunder/series/series.py
Series.gramian
def gramian(self): """ Compute gramian of a distributed matrix. The gramian is defined as the product of the matrix with its transpose, i.e. A^T * A. """ if self.mode == 'spark': rdd = self.values.tordd() from pyspark.accumulators import Accumula...
python
def gramian(self): """ Compute gramian of a distributed matrix. The gramian is defined as the product of the matrix with its transpose, i.e. A^T * A. """ if self.mode == 'spark': rdd = self.values.tordd() from pyspark.accumulators import Accumula...
[ "def", "gramian", "(", "self", ")", ":", "if", "self", ".", "mode", "==", "'spark'", ":", "rdd", "=", "self", ".", "values", ".", "tordd", "(", ")", "from", "pyspark", ".", "accumulators", "import", "AccumulatorParam", "class", "MatrixAccumulator", "(", ...
Compute gramian of a distributed matrix. The gramian is defined as the product of the matrix with its transpose, i.e. A^T * A.
[ "Compute", "gramian", "of", "a", "distributed", "matrix", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L731-L763
12,331
thunder-project/thunder
thunder/series/series.py
Series.times
def times(self, other): """ Multiply a matrix by another one. Other matrix must be a numpy array, a scalar, or another matrix in local mode. Parameters ---------- other : Matrix, scalar, or numpy array A matrix to multiply with """ if...
python
def times(self, other): """ Multiply a matrix by another one. Other matrix must be a numpy array, a scalar, or another matrix in local mode. Parameters ---------- other : Matrix, scalar, or numpy array A matrix to multiply with """ if...
[ "def", "times", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "ScalarType", ")", ":", "other", "=", "asarray", "(", "other", ")", "index", "=", "self", ".", "index", "else", ":", "if", "isinstance", "(", "other", ",", ...
Multiply a matrix by another one. Other matrix must be a numpy array, a scalar, or another matrix in local mode. Parameters ---------- other : Matrix, scalar, or numpy array A matrix to multiply with
[ "Multiply", "a", "matrix", "by", "another", "one", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L765-L805
12,332
thunder-project/thunder
thunder/series/series.py
Series._makewindows
def _makewindows(self, indices, window): """ Make masks used by windowing functions Given a list of indices specifying window centers, and a window size, construct a list of index arrays, one per window, that index into the target array Parameters ---------- ...
python
def _makewindows(self, indices, window): """ Make masks used by windowing functions Given a list of indices specifying window centers, and a window size, construct a list of index arrays, one per window, that index into the target array Parameters ---------- ...
[ "def", "_makewindows", "(", "self", ",", "indices", ",", "window", ")", ":", "div", "=", "divmod", "(", "window", ",", "2", ")", "before", "=", "div", "[", "0", "]", "after", "=", "div", "[", "0", "]", "+", "div", "[", "1", "]", "index", "=", ...
Make masks used by windowing functions Given a list of indices specifying window centers, and a window size, construct a list of index arrays, one per window, that index into the target array Parameters ---------- indices : array-like List of times specifyin...
[ "Make", "masks", "used", "by", "windowing", "functions" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L807-L835
12,333
thunder-project/thunder
thunder/series/series.py
Series.mean_by_window
def mean_by_window(self, indices, window): """ Average series across multiple windows specified by their centers. Parameters ---------- indices : array-like List of times specifying window centers window : int Window size """ mask...
python
def mean_by_window(self, indices, window): """ Average series across multiple windows specified by their centers. Parameters ---------- indices : array-like List of times specifying window centers window : int Window size """ mask...
[ "def", "mean_by_window", "(", "self", ",", "indices", ",", "window", ")", ":", "masks", "=", "self", ".", "_makewindows", "(", "indices", ",", "window", ")", "newindex", "=", "arange", "(", "0", ",", "len", "(", "masks", "[", "0", "]", ")", ")", "r...
Average series across multiple windows specified by their centers. Parameters ---------- indices : array-like List of times specifying window centers window : int Window size
[ "Average", "series", "across", "multiple", "windows", "specified", "by", "their", "centers", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L837-L851
12,334
thunder-project/thunder
thunder/series/series.py
Series.subsample
def subsample(self, sample_factor=2): """ Subsample series by an integer factor. Parameters ---------- sample_factor : positive integer, optional, default=2 Factor for downsampling. """ if sample_factor < 0: raise Exception('Factor for sub...
python
def subsample(self, sample_factor=2): """ Subsample series by an integer factor. Parameters ---------- sample_factor : positive integer, optional, default=2 Factor for downsampling. """ if sample_factor < 0: raise Exception('Factor for sub...
[ "def", "subsample", "(", "self", ",", "sample_factor", "=", "2", ")", ":", "if", "sample_factor", "<", "0", ":", "raise", "Exception", "(", "'Factor for subsampling must be postive, got %g'", "%", "sample_factor", ")", "s", "=", "slice", "(", "0", ",", "len", ...
Subsample series by an integer factor. Parameters ---------- sample_factor : positive integer, optional, default=2 Factor for downsampling.
[ "Subsample", "series", "by", "an", "integer", "factor", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L853-L866
12,335
thunder-project/thunder
thunder/series/series.py
Series.downsample
def downsample(self, sample_factor=2): """ Downsample series by an integer factor by averaging. Parameters ---------- sample_factor : positive integer, optional, default=2 Factor for downsampling. """ if sample_factor < 0: raise Exception(...
python
def downsample(self, sample_factor=2): """ Downsample series by an integer factor by averaging. Parameters ---------- sample_factor : positive integer, optional, default=2 Factor for downsampling. """ if sample_factor < 0: raise Exception(...
[ "def", "downsample", "(", "self", ",", "sample_factor", "=", "2", ")", ":", "if", "sample_factor", "<", "0", ":", "raise", "Exception", "(", "'Factor for subsampling must be postive, got %g'", "%", "sample_factor", ")", "newlength", "=", "floor", "(", "len", "("...
Downsample series by an integer factor by averaging. Parameters ---------- sample_factor : positive integer, optional, default=2 Factor for downsampling.
[ "Downsample", "series", "by", "an", "integer", "factor", "by", "averaging", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L868-L882
12,336
thunder-project/thunder
thunder/series/series.py
Series.fourier
def fourier(self, freq=None): """ Compute statistics of a Fourier decomposition on series data. Parameters ---------- freq : int Digital frequency at which to compute coherence and phase """ def get(y, freq): y = y - mean(y) nf...
python
def fourier(self, freq=None): """ Compute statistics of a Fourier decomposition on series data. Parameters ---------- freq : int Digital frequency at which to compute coherence and phase """ def get(y, freq): y = y - mean(y) nf...
[ "def", "fourier", "(", "self", ",", "freq", "=", "None", ")", ":", "def", "get", "(", "y", ",", "freq", ")", ":", "y", "=", "y", "-", "mean", "(", "y", ")", "nframes", "=", "len", "(", "y", ")", "ft", "=", "fft", ".", "fft", "(", "y", ")"...
Compute statistics of a Fourier decomposition on series data. Parameters ---------- freq : int Digital frequency at which to compute coherence and phase
[ "Compute", "statistics", "of", "a", "Fourier", "decomposition", "on", "series", "data", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L884-L912
12,337
thunder-project/thunder
thunder/series/series.py
Series.convolve
def convolve(self, signal, mode='full'): """ Convolve series data against another signal. Parameters ---------- signal : array Signal to convolve with (must be 1D) mode : str, optional, default='full' Mode of convolution, options are 'full', 'sam...
python
def convolve(self, signal, mode='full'): """ Convolve series data against another signal. Parameters ---------- signal : array Signal to convolve with (must be 1D) mode : str, optional, default='full' Mode of convolution, options are 'full', 'sam...
[ "def", "convolve", "(", "self", ",", "signal", ",", "mode", "=", "'full'", ")", ":", "from", "numpy", "import", "convolve", "s", "=", "asarray", "(", "signal", ")", "n", "=", "size", "(", "self", ".", "index", ")", "m", "=", "size", "(", "s", ")"...
Convolve series data against another signal. Parameters ---------- signal : array Signal to convolve with (must be 1D) mode : str, optional, default='full' Mode of convolution, options are 'full', 'same', and 'valid'
[ "Convolve", "series", "data", "against", "another", "signal", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L914-L943
12,338
thunder-project/thunder
thunder/series/series.py
Series.crosscorr
def crosscorr(self, signal, lag=0): """ Cross correlate series data against another signal. Parameters ---------- signal : array Signal to correlate against (must be 1D). lag : int Range of lags to consider, will cover (-lag, +lag). """ ...
python
def crosscorr(self, signal, lag=0): """ Cross correlate series data against another signal. Parameters ---------- signal : array Signal to correlate against (must be 1D). lag : int Range of lags to consider, will cover (-lag, +lag). """ ...
[ "def", "crosscorr", "(", "self", ",", "signal", ",", "lag", "=", "0", ")", ":", "from", "scipy", ".", "linalg", "import", "norm", "s", "=", "asarray", "(", "signal", ")", "s", "=", "s", "-", "mean", "(", "s", ")", "s", "=", "s", "/", "norm", ...
Cross correlate series data against another signal. Parameters ---------- signal : array Signal to correlate against (must be 1D). lag : int Range of lags to consider, will cover (-lag, +lag).
[ "Cross", "correlate", "series", "data", "against", "another", "signal", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L945-L994
12,339
thunder-project/thunder
thunder/series/series.py
Series.detrend
def detrend(self, method='linear', order=5): """ Detrend series data with linear or nonlinear detrending. Preserve intercept so that subsequent operations can adjust the baseline. Parameters ---------- method : str, optional, default = 'linear' Detrending me...
python
def detrend(self, method='linear', order=5): """ Detrend series data with linear or nonlinear detrending. Preserve intercept so that subsequent operations can adjust the baseline. Parameters ---------- method : str, optional, default = 'linear' Detrending me...
[ "def", "detrend", "(", "self", ",", "method", "=", "'linear'", ",", "order", "=", "5", ")", ":", "check_options", "(", "method", ",", "[", "'linear'", ",", "'nonlinear'", "]", ")", "if", "method", "==", "'linear'", ":", "order", "=", "1", "def", "fun...
Detrend series data with linear or nonlinear detrending. Preserve intercept so that subsequent operations can adjust the baseline. Parameters ---------- method : str, optional, default = 'linear' Detrending method order : int, optional, default = 5 Orde...
[ "Detrend", "series", "data", "with", "linear", "or", "nonlinear", "detrending", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L996-L1022
12,340
thunder-project/thunder
thunder/series/series.py
Series.normalize
def normalize(self, method='percentile', window=None, perc=20, offset=0.1): """ Normalize by subtracting and dividing by a baseline. Baseline can be derived from a global mean or percentile, or a smoothed percentile estimated within a rolling window. Windowed baselines may only ...
python
def normalize(self, method='percentile', window=None, perc=20, offset=0.1): """ Normalize by subtracting and dividing by a baseline. Baseline can be derived from a global mean or percentile, or a smoothed percentile estimated within a rolling window. Windowed baselines may only ...
[ "def", "normalize", "(", "self", ",", "method", "=", "'percentile'", ",", "window", "=", "None", ",", "perc", "=", "20", ",", "offset", "=", "0.1", ")", ":", "check_options", "(", "method", ",", "[", "'mean'", ",", "'percentile'", ",", "'window'", ",",...
Normalize by subtracting and dividing by a baseline. Baseline can be derived from a global mean or percentile, or a smoothed percentile estimated within a rolling window. Windowed baselines may only be well-defined for temporal series data. Parameters ---------- ...
[ "Normalize", "by", "subtracting", "and", "dividing", "by", "a", "baseline", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L1024-L1081
12,341
thunder-project/thunder
thunder/series/series.py
Series.toimages
def toimages(self, chunk_size='auto'): """ Converts to images data. This method is equivalent to series.toblocks(size).toimages(). Parameters ---------- chunk_size : str or tuple, size of series chunk used during conversion, default = 'auto' String interpret...
python
def toimages(self, chunk_size='auto'): """ Converts to images data. This method is equivalent to series.toblocks(size).toimages(). Parameters ---------- chunk_size : str or tuple, size of series chunk used during conversion, default = 'auto' String interpret...
[ "def", "toimages", "(", "self", ",", "chunk_size", "=", "'auto'", ")", ":", "from", "thunder", ".", "images", ".", "images", "import", "Images", "if", "chunk_size", "is", "'auto'", ":", "chunk_size", "=", "str", "(", "max", "(", "[", "int", "(", "1e5",...
Converts to images data. This method is equivalent to series.toblocks(size).toimages(). Parameters ---------- chunk_size : str or tuple, size of series chunk used during conversion, default = 'auto' String interpreted as memory size (in kilobytes, e.g. '64'). Th...
[ "Converts", "to", "images", "data", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L1083-L1108
12,342
thunder-project/thunder
thunder/series/series.py
Series.tobinary
def tobinary(self, path, prefix='series', overwrite=False, credentials=None): """ Write data to binary files. Parameters ---------- path : string path or URI to directory to be created Output files will be written underneath path. Directory will be create...
python
def tobinary(self, path, prefix='series', overwrite=False, credentials=None): """ Write data to binary files. Parameters ---------- path : string path or URI to directory to be created Output files will be written underneath path. Directory will be create...
[ "def", "tobinary", "(", "self", ",", "path", ",", "prefix", "=", "'series'", ",", "overwrite", "=", "False", ",", "credentials", "=", "None", ")", ":", "from", "thunder", ".", "series", ".", "writers", "import", "tobinary", "tobinary", "(", "self", ",", ...
Write data to binary files. Parameters ---------- path : string path or URI to directory to be created Output files will be written underneath path. Directory will be created as a result of this call. prefix : str, optional, default = 'series' String...
[ "Write", "data", "to", "binary", "files", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/series/series.py#L1110-L1128
12,343
thunder-project/thunder
thunder/readers.py
addextension
def addextension(path, ext=None): """ Helper function for handling of paths given separately passed file extensions. """ if ext: if '*' in path: return path elif os.path.splitext(path)[1]: return path else: if not ext.startswith('.'): ...
python
def addextension(path, ext=None): """ Helper function for handling of paths given separately passed file extensions. """ if ext: if '*' in path: return path elif os.path.splitext(path)[1]: return path else: if not ext.startswith('.'): ...
[ "def", "addextension", "(", "path", ",", "ext", "=", "None", ")", ":", "if", "ext", ":", "if", "'*'", "in", "path", ":", "return", "path", "elif", "os", ".", "path", ".", "splitext", "(", "path", ")", "[", "1", "]", ":", "return", "path", "else",...
Helper function for handling of paths given separately passed file extensions.
[ "Helper", "function", "for", "handling", "of", "paths", "given", "separately", "passed", "file", "extensions", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L21-L40
12,344
thunder-project/thunder
thunder/readers.py
select
def select(files, start, stop): """ Helper function for handling start and stop indices """ if start or stop: if start is None: start = 0 if stop is None: stop = len(files) files = files[start:stop] return files
python
def select(files, start, stop): """ Helper function for handling start and stop indices """ if start or stop: if start is None: start = 0 if stop is None: stop = len(files) files = files[start:stop] return files
[ "def", "select", "(", "files", ",", "start", ",", "stop", ")", ":", "if", "start", "or", "stop", ":", "if", "start", "is", "None", ":", "start", "=", "0", "if", "stop", "is", "None", ":", "stop", "=", "len", "(", "files", ")", "files", "=", "fi...
Helper function for handling start and stop indices
[ "Helper", "function", "for", "handling", "start", "and", "stop", "indices" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L42-L52
12,345
thunder-project/thunder
thunder/readers.py
listrecursive
def listrecursive(path, ext=None): """ List files recurisvely """ filenames = set() for root, dirs, files in os.walk(path): if ext: if ext == 'tif' or ext == 'tiff': tmp = fnmatch.filter(files, '*.' + 'tiff') files = tmp + fnmatch.filter(files, '*....
python
def listrecursive(path, ext=None): """ List files recurisvely """ filenames = set() for root, dirs, files in os.walk(path): if ext: if ext == 'tif' or ext == 'tiff': tmp = fnmatch.filter(files, '*.' + 'tiff') files = tmp + fnmatch.filter(files, '*....
[ "def", "listrecursive", "(", "path", ",", "ext", "=", "None", ")", ":", "filenames", "=", "set", "(", ")", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "if", "ext", ":", "if", "ext", "==", "'tif'", "...
List files recurisvely
[ "List", "files", "recurisvely" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L72-L88
12,346
thunder-project/thunder
thunder/readers.py
listflat
def listflat(path, ext=None): """ List files without recursion """ if os.path.isdir(path): if ext: if ext == 'tif' or ext == 'tiff': files = glob.glob(os.path.join(path, '*.tif')) files = files + glob.glob(os.path.join(path, '*.tiff')) else...
python
def listflat(path, ext=None): """ List files without recursion """ if os.path.isdir(path): if ext: if ext == 'tif' or ext == 'tiff': files = glob.glob(os.path.join(path, '*.tif')) files = files + glob.glob(os.path.join(path, '*.tiff')) else...
[ "def", "listflat", "(", "path", ",", "ext", "=", "None", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "if", "ext", ":", "if", "ext", "==", "'tif'", "or", "ext", "==", "'tiff'", ":", "files", "=", "glob", ".", "glob", ...
List files without recursion
[ "List", "files", "without", "recursion" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L90-L107
12,347
thunder-project/thunder
thunder/readers.py
normalize_scheme
def normalize_scheme(path, ext): """ Normalize scheme for paths related to hdfs """ path = addextension(path, ext) parsed = urlparse(path) if parsed.scheme: # this appears to already be a fully-qualified URI return path else: # this looks like a local path spec ...
python
def normalize_scheme(path, ext): """ Normalize scheme for paths related to hdfs """ path = addextension(path, ext) parsed = urlparse(path) if parsed.scheme: # this appears to already be a fully-qualified URI return path else: # this looks like a local path spec ...
[ "def", "normalize_scheme", "(", "path", ",", "ext", ")", ":", "path", "=", "addextension", "(", "path", ",", "ext", ")", "parsed", "=", "urlparse", "(", "path", ")", "if", "parsed", ".", "scheme", ":", "# this appears to already be a fully-qualified URI", "ret...
Normalize scheme for paths related to hdfs
[ "Normalize", "scheme", "for", "paths", "related", "to", "hdfs" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L620-L638
12,348
thunder-project/thunder
thunder/readers.py
LocalParallelReader.list
def list(path, ext=None, start=None, stop=None, recursive=False): """ Get sorted list of file paths matching path and extension """ files = listflat(path, ext) if not recursive else listrecursive(path, ext) if len(files) < 1: raise FileNotFoundError('Cannot find files...
python
def list(path, ext=None, start=None, stop=None, recursive=False): """ Get sorted list of file paths matching path and extension """ files = listflat(path, ext) if not recursive else listrecursive(path, ext) if len(files) < 1: raise FileNotFoundError('Cannot find files...
[ "def", "list", "(", "path", ",", "ext", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "recursive", "=", "False", ")", ":", "files", "=", "listflat", "(", "path", ",", "ext", ")", "if", "not", "recursive", "else", "listrecur...
Get sorted list of file paths matching path and extension
[ "Get", "sorted", "list", "of", "file", "paths", "matching", "path", "and", "extension" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L133-L143
12,349
thunder-project/thunder
thunder/readers.py
LocalParallelReader.read
def read(self, path, ext=None, start=None, stop=None, recursive=False, npartitions=None): """ Sets up Spark RDD across files specified by dataPath on local filesystem. Returns RDD of <integer file index, string buffer> k/v pairs. """ path = uri_to_path(path) files = self...
python
def read(self, path, ext=None, start=None, stop=None, recursive=False, npartitions=None): """ Sets up Spark RDD across files specified by dataPath on local filesystem. Returns RDD of <integer file index, string buffer> k/v pairs. """ path = uri_to_path(path) files = self...
[ "def", "read", "(", "self", ",", "path", ",", "ext", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "recursive", "=", "False", ",", "npartitions", "=", "None", ")", ":", "path", "=", "uri_to_path", "(", "path", ")", "files",...
Sets up Spark RDD across files specified by dataPath on local filesystem. Returns RDD of <integer file index, string buffer> k/v pairs.
[ "Sets", "up", "Spark", "RDD", "across", "files", "specified", "by", "dataPath", "on", "local", "filesystem", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L145-L162
12,350
thunder-project/thunder
thunder/readers.py
LocalFileReader.list
def list(path, filename=None, start=None, stop=None, recursive=False, directories=False): """ List files specified by dataPath. Datapath may include a single wildcard ('*') in the filename specifier. Returns sorted list of absolute path strings. """ path = uri_to_path(p...
python
def list(path, filename=None, start=None, stop=None, recursive=False, directories=False): """ List files specified by dataPath. Datapath may include a single wildcard ('*') in the filename specifier. Returns sorted list of absolute path strings. """ path = uri_to_path(p...
[ "def", "list", "(", "path", ",", "filename", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "recursive", "=", "False", ",", "directories", "=", "False", ")", ":", "path", "=", "uri_to_path", "(", "path", ")", "if", "not", "f...
List files specified by dataPath. Datapath may include a single wildcard ('*') in the filename specifier. Returns sorted list of absolute path strings.
[ "List", "files", "specified", "by", "dataPath", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L173-L202
12,351
thunder-project/thunder
thunder/readers.py
BotoClient.parse_query
def parse_query(query, delim='/'): """ Parse a boto query """ key = '' prefix = '' postfix = '' parsed = urlparse(query) query = parsed.path.lstrip(delim) bucket = parsed.netloc if not parsed.scheme.lower() in ('', "gs", "s3", "s3n"): ...
python
def parse_query(query, delim='/'): """ Parse a boto query """ key = '' prefix = '' postfix = '' parsed = urlparse(query) query = parsed.path.lstrip(delim) bucket = parsed.netloc if not parsed.scheme.lower() in ('', "gs", "s3", "s3n"): ...
[ "def", "parse_query", "(", "query", ",", "delim", "=", "'/'", ")", ":", "key", "=", "''", "prefix", "=", "''", "postfix", "=", "''", "parsed", "=", "urlparse", "(", "query", ")", "query", "=", "parsed", ".", "path", ".", "lstrip", "(", "delim", ")"...
Parse a boto query
[ "Parse", "a", "boto", "query" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L233-L278
12,352
thunder-project/thunder
thunder/readers.py
BotoClient.retrieve_keys
def retrieve_keys(bucket, key, prefix='', postfix='', delim='/', directories=False, recursive=False): """ Retrieve keys from a bucket """ if key and prefix: assert key.endswith(delim) key += prefix # check whether key is a directory ...
python
def retrieve_keys(bucket, key, prefix='', postfix='', delim='/', directories=False, recursive=False): """ Retrieve keys from a bucket """ if key and prefix: assert key.endswith(delim) key += prefix # check whether key is a directory ...
[ "def", "retrieve_keys", "(", "bucket", ",", "key", ",", "prefix", "=", "''", ",", "postfix", "=", "''", ",", "delim", "=", "'/'", ",", "directories", "=", "False", ",", "recursive", "=", "False", ")", ":", "if", "key", "and", "prefix", ":", "assert",...
Retrieve keys from a bucket
[ "Retrieve", "keys", "from", "a", "bucket" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L291-L316
12,353
thunder-project/thunder
thunder/readers.py
BotoParallelReader.getfiles
def getfiles(self, path, ext=None, start=None, stop=None, recursive=False): """ Get scheme, bucket, and keys for a set of files """ from .utils import connection_with_anon, connection_with_gs parse = BotoClient.parse_query(path) scheme = parse[0] bucket_name = p...
python
def getfiles(self, path, ext=None, start=None, stop=None, recursive=False): """ Get scheme, bucket, and keys for a set of files """ from .utils import connection_with_anon, connection_with_gs parse = BotoClient.parse_query(path) scheme = parse[0] bucket_name = p...
[ "def", "getfiles", "(", "self", ",", "path", ",", "ext", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "recursive", "=", "False", ")", ":", "from", ".", "utils", "import", "connection_with_anon", ",", "connection_with_gs", "parse...
Get scheme, bucket, and keys for a set of files
[ "Get", "scheme", "bucket", "and", "keys", "for", "a", "set", "of", "files" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L328-L361
12,354
thunder-project/thunder
thunder/readers.py
BotoParallelReader.list
def list(self, dataPath, ext=None, start=None, stop=None, recursive=False): """ List files from remote storage """ scheme, bucket_name, keylist = self.getfiles( dataPath, ext=ext, start=start, stop=stop, recursive=recursive) return ["%s:///%s/%s" % (scheme, bucket_na...
python
def list(self, dataPath, ext=None, start=None, stop=None, recursive=False): """ List files from remote storage """ scheme, bucket_name, keylist = self.getfiles( dataPath, ext=ext, start=start, stop=stop, recursive=recursive) return ["%s:///%s/%s" % (scheme, bucket_na...
[ "def", "list", "(", "self", ",", "dataPath", ",", "ext", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "recursive", "=", "False", ")", ":", "scheme", ",", "bucket_name", ",", "keylist", "=", "self", ".", "getfiles", "(", "d...
List files from remote storage
[ "List", "files", "from", "remote", "storage" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L363-L370
12,355
thunder-project/thunder
thunder/readers.py
BotoParallelReader.read
def read(self, path, ext=None, start=None, stop=None, recursive=False, npartitions=None): """ Sets up Spark RDD across S3 or GS objects specified by dataPath. Returns RDD of <string bucket keyname, string buffer> k/v pairs. """ from .utils import connection_with_anon, connection...
python
def read(self, path, ext=None, start=None, stop=None, recursive=False, npartitions=None): """ Sets up Spark RDD across S3 or GS objects specified by dataPath. Returns RDD of <string bucket keyname, string buffer> k/v pairs. """ from .utils import connection_with_anon, connection...
[ "def", "read", "(", "self", ",", "path", ",", "ext", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "recursive", "=", "False", ",", "npartitions", "=", "None", ")", ":", "from", ".", "utils", "import", "connection_with_anon", ...
Sets up Spark RDD across S3 or GS objects specified by dataPath. Returns RDD of <string bucket keyname, string buffer> k/v pairs.
[ "Sets", "up", "Spark", "RDD", "across", "S3", "or", "GS", "objects", "specified", "by", "dataPath", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L372-L430
12,356
thunder-project/thunder
thunder/readers.py
BotoFileReader.getkeys
def getkeys(self, path, filename=None, directories=False, recursive=False): """ Get matching keys for a path """ from .utils import connection_with_anon, connection_with_gs parse = BotoClient.parse_query(path) scheme = parse[0] bucket_name = parse[1] key...
python
def getkeys(self, path, filename=None, directories=False, recursive=False): """ Get matching keys for a path """ from .utils import connection_with_anon, connection_with_gs parse = BotoClient.parse_query(path) scheme = parse[0] bucket_name = parse[1] key...
[ "def", "getkeys", "(", "self", ",", "path", ",", "filename", "=", "None", ",", "directories", "=", "False", ",", "recursive", "=", "False", ")", ":", "from", ".", "utils", "import", "connection_with_anon", ",", "connection_with_gs", "parse", "=", "BotoClient...
Get matching keys for a path
[ "Get", "matching", "keys", "for", "a", "path" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L437-L472
12,357
thunder-project/thunder
thunder/readers.py
BotoFileReader.getkey
def getkey(self, path, filename=None): """ Get single matching key for a path """ scheme, keys = self.getkeys(path, filename=filename) try: key = next(keys) except StopIteration: raise FileNotFoundError("Could not find object for: '%s'" % path) ...
python
def getkey(self, path, filename=None): """ Get single matching key for a path """ scheme, keys = self.getkeys(path, filename=filename) try: key = next(keys) except StopIteration: raise FileNotFoundError("Could not find object for: '%s'" % path) ...
[ "def", "getkey", "(", "self", ",", "path", ",", "filename", "=", "None", ")", ":", "scheme", ",", "keys", "=", "self", ".", "getkeys", "(", "path", ",", "filename", "=", "filename", ")", "try", ":", "key", "=", "next", "(", "keys", ")", "except", ...
Get single matching key for a path
[ "Get", "single", "matching", "key", "for", "a", "path" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L474-L492
12,358
thunder-project/thunder
thunder/readers.py
BotoFileReader.list
def list(self, path, filename=None, start=None, stop=None, recursive=False, directories=False): """ List objects specified by path. Returns sorted list of 'gs://' or 's3n://' URIs. """ storageScheme, keys = self.getkeys( path, filename=filename, directories=directori...
python
def list(self, path, filename=None, start=None, stop=None, recursive=False, directories=False): """ List objects specified by path. Returns sorted list of 'gs://' or 's3n://' URIs. """ storageScheme, keys = self.getkeys( path, filename=filename, directories=directori...
[ "def", "list", "(", "self", ",", "path", ",", "filename", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "recursive", "=", "False", ",", "directories", "=", "False", ")", ":", "storageScheme", ",", "keys", "=", "self", ".", ...
List objects specified by path. Returns sorted list of 'gs://' or 's3n://' URIs.
[ "List", "objects", "specified", "by", "path", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L494-L505
12,359
thunder-project/thunder
thunder/readers.py
BotoFileReader.read
def read(self, path, filename=None, offset=None, size=-1): """ Read a file specified by path. """ storageScheme, key = self.getkey(path, filename=filename) if offset or (size > -1): if not offset: offset = 0 if size > -1: s...
python
def read(self, path, filename=None, offset=None, size=-1): """ Read a file specified by path. """ storageScheme, key = self.getkey(path, filename=filename) if offset or (size > -1): if not offset: offset = 0 if size > -1: s...
[ "def", "read", "(", "self", ",", "path", ",", "filename", "=", "None", ",", "offset", "=", "None", ",", "size", "=", "-", "1", ")", ":", "storageScheme", ",", "key", "=", "self", ".", "getkey", "(", "path", ",", "filename", "=", "filename", ")", ...
Read a file specified by path.
[ "Read", "a", "file", "specified", "by", "path", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L507-L523
12,360
thunder-project/thunder
thunder/readers.py
BotoFileReader.open
def open(self, path, filename=None): """ Open a file specified by path. """ scheme, key = self.getkey(path, filename=filename) return BotoReadFileHandle(scheme, key)
python
def open(self, path, filename=None): """ Open a file specified by path. """ scheme, key = self.getkey(path, filename=filename) return BotoReadFileHandle(scheme, key)
[ "def", "open", "(", "self", ",", "path", ",", "filename", "=", "None", ")", ":", "scheme", ",", "key", "=", "self", ".", "getkey", "(", "path", ",", "filename", "=", "filename", ")", "return", "BotoReadFileHandle", "(", "scheme", ",", "key", ")" ]
Open a file specified by path.
[ "Open", "a", "file", "specified", "by", "path", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/readers.py#L525-L530
12,361
thunder-project/thunder
thunder/utils.py
check_path
def check_path(path, credentials=None): """ Check that specified output path does not already exist The ValueError message will suggest calling with overwrite=True; this function is expected to be called from the various output methods that accept an 'overwrite' keyword argument. """ from t...
python
def check_path(path, credentials=None): """ Check that specified output path does not already exist The ValueError message will suggest calling with overwrite=True; this function is expected to be called from the various output methods that accept an 'overwrite' keyword argument. """ from t...
[ "def", "check_path", "(", "path", ",", "credentials", "=", "None", ")", ":", "from", "thunder", ".", "readers", "import", "get_file_reader", "reader", "=", "get_file_reader", "(", "path", ")", "(", "credentials", "=", "credentials", ")", "existing", "=", "re...
Check that specified output path does not already exist The ValueError message will suggest calling with overwrite=True; this function is expected to be called from the various output methods that accept an 'overwrite' keyword argument.
[ "Check", "that", "specified", "output", "path", "does", "not", "already", "exist" ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/utils.py#L18-L31
12,362
thunder-project/thunder
thunder/utils.py
connection_with_anon
def connection_with_anon(credentials, anon=True): """ Connect to S3 with automatic handling for anonymous access. Parameters ---------- credentials : dict AWS access key ('access') and secret access key ('secret') anon : boolean, optional, default = True Whether to make an anon...
python
def connection_with_anon(credentials, anon=True): """ Connect to S3 with automatic handling for anonymous access. Parameters ---------- credentials : dict AWS access key ('access') and secret access key ('secret') anon : boolean, optional, default = True Whether to make an anon...
[ "def", "connection_with_anon", "(", "credentials", ",", "anon", "=", "True", ")", ":", "from", "boto", ".", "s3", ".", "connection", "import", "S3Connection", "from", "boto", ".", "exception", "import", "NoAuthHandlerFound", "try", ":", "conn", "=", "S3Connect...
Connect to S3 with automatic handling for anonymous access. Parameters ---------- credentials : dict AWS access key ('access') and secret access key ('secret') anon : boolean, optional, default = True Whether to make an anonymous connection if credentials fail to authenticate
[ "Connect", "to", "S3", "with", "automatic", "handling", "for", "anonymous", "access", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/utils.py#L33-L58
12,363
thunder-project/thunder
thunder/writers.py
BotoWriter.activate
def activate(self, path, isdirectory): """ Set up a boto connection. """ from .utils import connection_with_anon, connection_with_gs parsed = BotoClient.parse_query(path) scheme = parsed[0] bucket_name = parsed[1] key = parsed[2] if scheme == 's...
python
def activate(self, path, isdirectory): """ Set up a boto connection. """ from .utils import connection_with_anon, connection_with_gs parsed = BotoClient.parse_query(path) scheme = parsed[0] bucket_name = parsed[1] key = parsed[2] if scheme == 's...
[ "def", "activate", "(", "self", ",", "path", ",", "isdirectory", ")", ":", "from", ".", "utils", "import", "connection_with_anon", ",", "connection_with_gs", "parsed", "=", "BotoClient", ".", "parse_query", "(", "path", ")", "scheme", "=", "parsed", "[", "0"...
Set up a boto connection.
[ "Set", "up", "a", "boto", "connection", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/writers.py#L50-L78
12,364
thunder-project/thunder
thunder/images/writers.py
topng
def topng(images, path, prefix="image", overwrite=False, credentials=None): """ Write out PNG files for 2d image data. See also -------- thunder.data.images.topng """ value_shape = images.value_shape if not len(value_shape) in [2, 3]: raise ValueError("Only 2D or 3D images can b...
python
def topng(images, path, prefix="image", overwrite=False, credentials=None): """ Write out PNG files for 2d image data. See also -------- thunder.data.images.topng """ value_shape = images.value_shape if not len(value_shape) in [2, 3]: raise ValueError("Only 2D or 3D images can b...
[ "def", "topng", "(", "images", ",", "path", ",", "prefix", "=", "\"image\"", ",", "overwrite", "=", "False", ",", "credentials", "=", "None", ")", ":", "value_shape", "=", "images", ".", "value_shape", "if", "not", "len", "(", "value_shape", ")", "in", ...
Write out PNG files for 2d image data. See also -------- thunder.data.images.topng
[ "Write", "out", "PNG", "files", "for", "2d", "image", "data", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/images/writers.py#L4-L29
12,365
thunder-project/thunder
thunder/images/writers.py
tobinary
def tobinary(images, path, prefix="image", overwrite=False, credentials=None): """ Write out images as binary files. See also -------- thunder.data.images.tobinary """ from thunder.writers import get_parallel_writer def tobuffer(kv): key, img = kv fname = prefix + "-" +...
python
def tobinary(images, path, prefix="image", overwrite=False, credentials=None): """ Write out images as binary files. See also -------- thunder.data.images.tobinary """ from thunder.writers import get_parallel_writer def tobuffer(kv): key, img = kv fname = prefix + "-" +...
[ "def", "tobinary", "(", "images", ",", "path", ",", "prefix", "=", "\"image\"", ",", "overwrite", "=", "False", ",", "credentials", "=", "None", ")", ":", "from", "thunder", ".", "writers", "import", "get_parallel_writer", "def", "tobuffer", "(", "kv", ")"...
Write out images as binary files. See also -------- thunder.data.images.tobinary
[ "Write", "out", "images", "as", "binary", "files", "." ]
967ff8f3e7c2fabe1705743d95eb2746d4329786
https://github.com/thunder-project/thunder/blob/967ff8f3e7c2fabe1705743d95eb2746d4329786/thunder/images/writers.py#L58-L75
12,366
lidaobing/python-lunardate
lunardate.py
yearInfo2yearDay
def yearInfo2yearDay(yearInfo): '''calculate the days in a lunar year from the lunar year's info >>> yearInfo2yearDay(0) # no leap month, and every month has 29 days. 348 >>> yearInfo2yearDay(1) # 1 leap month, and every month has 29 days. 377 >>> yearInfo2yearDay((2**12-1)*16) # no leap month,...
python
def yearInfo2yearDay(yearInfo): '''calculate the days in a lunar year from the lunar year's info >>> yearInfo2yearDay(0) # no leap month, and every month has 29 days. 348 >>> yearInfo2yearDay(1) # 1 leap month, and every month has 29 days. 377 >>> yearInfo2yearDay((2**12-1)*16) # no leap month,...
[ "def", "yearInfo2yearDay", "(", "yearInfo", ")", ":", "yearInfo", "=", "int", "(", "yearInfo", ")", "res", "=", "29", "*", "12", "leap", "=", "False", "if", "yearInfo", "%", "16", "!=", "0", ":", "leap", "=", "True", "res", "+=", "29", "yearInfo", ...
calculate the days in a lunar year from the lunar year's info >>> yearInfo2yearDay(0) # no leap month, and every month has 29 days. 348 >>> yearInfo2yearDay(1) # 1 leap month, and every month has 29 days. 377 >>> yearInfo2yearDay((2**12-1)*16) # no leap month, and every month has 30 days. 360 ...
[ "calculate", "the", "days", "in", "a", "lunar", "year", "from", "the", "lunar", "year", "s", "info" ]
261334a27d772489c9fc70b8ecef129ba3c13118
https://github.com/lidaobing/python-lunardate/blob/261334a27d772489c9fc70b8ecef129ba3c13118/lunardate.py#L367-L397
12,367
plone/plone.app.mosaic
src/plone/app/mosaic/browser/upload.py
MosaicUploadView.cleanupFilename
def cleanupFilename(self, name): """Generate a unique id which doesn't match the system generated ids""" context = self.context id = '' name = name.replace('\\', '/') # Fixup Windows filenames name = name.split('/')[-1] # Throw away any path part. for c in name: ...
python
def cleanupFilename(self, name): """Generate a unique id which doesn't match the system generated ids""" context = self.context id = '' name = name.replace('\\', '/') # Fixup Windows filenames name = name.split('/')[-1] # Throw away any path part. for c in name: ...
[ "def", "cleanupFilename", "(", "self", ",", "name", ")", ":", "context", "=", "self", ".", "context", "id", "=", "''", "name", "=", "name", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "# Fixup Windows filenames", "name", "=", "name", ".", "split", ...
Generate a unique id which doesn't match the system generated ids
[ "Generate", "a", "unique", "id", "which", "doesn", "t", "match", "the", "system", "generated", "ids" ]
73b6acb18905025a76b239c86de9543ed9350991
https://github.com/plone/plone.app.mosaic/blob/73b6acb18905025a76b239c86de9543ed9350991/src/plone/app/mosaic/browser/upload.py#L80-L106
12,368
plone/plone.app.mosaic
src/plone/app/mosaic/browser/main_template.py
parse_data_slots
def parse_data_slots(value): """Parse data-slots value into slots used to wrap node, prepend to node or append to node. >>> parse_data_slots('') ([], [], []) >>> parse_data_slots('foo bar') (['foo', 'bar'], [], []) >>> parse_data_slots('foo bar > foobar') (['foo', 'b...
python
def parse_data_slots(value): """Parse data-slots value into slots used to wrap node, prepend to node or append to node. >>> parse_data_slots('') ([], [], []) >>> parse_data_slots('foo bar') (['foo', 'bar'], [], []) >>> parse_data_slots('foo bar > foobar') (['foo', 'b...
[ "def", "parse_data_slots", "(", "value", ")", ":", "value", "=", "unquote", "(", "value", ")", "if", "'>'", "in", "value", ":", "wrappers", ",", "children", "=", "value", ".", "split", "(", "'>'", ",", "1", ")", "else", ":", "wrappers", "=", "value",...
Parse data-slots value into slots used to wrap node, prepend to node or append to node. >>> parse_data_slots('') ([], [], []) >>> parse_data_slots('foo bar') (['foo', 'bar'], [], []) >>> parse_data_slots('foo bar > foobar') (['foo', 'bar'], ['foobar'], []) >>> pa...
[ "Parse", "data", "-", "slots", "value", "into", "slots", "used", "to", "wrap", "node", "prepend", "to", "node", "or", "append", "to", "node", "." ]
73b6acb18905025a76b239c86de9543ed9350991
https://github.com/plone/plone.app.mosaic/blob/73b6acb18905025a76b239c86de9543ed9350991/src/plone/app/mosaic/browser/main_template.py#L65-L107
12,369
plone/plone.app.mosaic
src/plone/app/mosaic/browser/main_template.py
cook_layout
def cook_layout(layout, ajax): """Return main_template compatible layout""" # Fix XHTML layouts with CR[+LF] line endings layout = re.sub('\r', '\n', re.sub('\r\n', '\n', layout)) # Parse layout if isinstance(layout, six.text_type): result = getHTMLSerializer([layout.encode('utf-8')], encod...
python
def cook_layout(layout, ajax): """Return main_template compatible layout""" # Fix XHTML layouts with CR[+LF] line endings layout = re.sub('\r', '\n', re.sub('\r\n', '\n', layout)) # Parse layout if isinstance(layout, six.text_type): result = getHTMLSerializer([layout.encode('utf-8')], encod...
[ "def", "cook_layout", "(", "layout", ",", "ajax", ")", ":", "# Fix XHTML layouts with CR[+LF] line endings", "layout", "=", "re", ".", "sub", "(", "'\\r'", ",", "'\\n'", ",", "re", ".", "sub", "(", "'\\r\\n'", ",", "'\\n'", ",", "layout", ")", ")", "# Pars...
Return main_template compatible layout
[ "Return", "main_template", "compatible", "layout" ]
73b6acb18905025a76b239c86de9543ed9350991
https://github.com/plone/plone.app.mosaic/blob/73b6acb18905025a76b239c86de9543ed9350991/src/plone/app/mosaic/browser/main_template.py#L138-L179
12,370
plone/plone.app.mosaic
src/plone/app/mosaic/browser/editor.py
ManageLayoutView.existing
def existing(self): """ find existing content assigned to this layout""" catalog = api.portal.get_tool('portal_catalog') results = [] layout_path = self._get_layout_path( self.request.form.get('layout', '') ) for brain in catalog(layout=layout_path): ...
python
def existing(self): """ find existing content assigned to this layout""" catalog = api.portal.get_tool('portal_catalog') results = [] layout_path = self._get_layout_path( self.request.form.get('layout', '') ) for brain in catalog(layout=layout_path): ...
[ "def", "existing", "(", "self", ")", ":", "catalog", "=", "api", ".", "portal", ".", "get_tool", "(", "'portal_catalog'", ")", "results", "=", "[", "]", "layout_path", "=", "self", ".", "_get_layout_path", "(", "self", ".", "request", ".", "form", ".", ...
find existing content assigned to this layout
[ "find", "existing", "content", "assigned", "to", "this", "layout" ]
73b6acb18905025a76b239c86de9543ed9350991
https://github.com/plone/plone.app.mosaic/blob/73b6acb18905025a76b239c86de9543ed9350991/src/plone/app/mosaic/browser/editor.py#L127-L142
12,371
sergiocorreia/panflute
panflute/io.py
load_reader_options
def load_reader_options(): """ Retrieve Pandoc Reader options from the environment """ options = os.environ['PANDOC_READER_OPTIONS'] options = json.loads(options, object_pairs_hook=OrderedDict) return options
python
def load_reader_options(): """ Retrieve Pandoc Reader options from the environment """ options = os.environ['PANDOC_READER_OPTIONS'] options = json.loads(options, object_pairs_hook=OrderedDict) return options
[ "def", "load_reader_options", "(", ")", ":", "options", "=", "os", ".", "environ", "[", "'PANDOC_READER_OPTIONS'", "]", "options", "=", "json", ".", "loads", "(", "options", ",", "object_pairs_hook", "=", "OrderedDict", ")", "return", "options" ]
Retrieve Pandoc Reader options from the environment
[ "Retrieve", "Pandoc", "Reader", "options", "from", "the", "environment" ]
65c2d570c26a190deb600cab5e2ad8a828a3302e
https://github.com/sergiocorreia/panflute/blob/65c2d570c26a190deb600cab5e2ad8a828a3302e/panflute/io.py#L263-L269
12,372
sergiocorreia/panflute
panflute/tools.py
yaml_filter
def yaml_filter(element, doc, tag=None, function=None, tags=None, strict_yaml=False): ''' Convenience function for parsing code blocks with YAML options This function is useful to create a filter that applies to code blocks that have specific classes. It is used as an argument of `...
python
def yaml_filter(element, doc, tag=None, function=None, tags=None, strict_yaml=False): ''' Convenience function for parsing code blocks with YAML options This function is useful to create a filter that applies to code blocks that have specific classes. It is used as an argument of `...
[ "def", "yaml_filter", "(", "element", ",", "doc", ",", "tag", "=", "None", ",", "function", "=", "None", ",", "tags", "=", "None", ",", "strict_yaml", "=", "False", ")", ":", "# Allow for either tag+function or a dict {tag: function}", "assert", "(", "tag", "i...
Convenience function for parsing code blocks with YAML options This function is useful to create a filter that applies to code blocks that have specific classes. It is used as an argument of ``run_filter``, with two additional options: ``tag`` and ``function``. Using this is equivalent to having ...
[ "Convenience", "function", "for", "parsing", "code", "blocks", "with", "YAML", "options" ]
65c2d570c26a190deb600cab5e2ad8a828a3302e
https://github.com/sergiocorreia/panflute/blob/65c2d570c26a190deb600cab5e2ad8a828a3302e/panflute/tools.py#L44-L158
12,373
sergiocorreia/panflute
panflute/base.py
Element._set_content
def _set_content(self, value, oktypes): """ Similar to content.setter but when there are no existing oktypes """ if value is None: value = [] self._content = ListContainer(*value, oktypes=oktypes, parent=self)
python
def _set_content(self, value, oktypes): """ Similar to content.setter but when there are no existing oktypes """ if value is None: value = [] self._content = ListContainer(*value, oktypes=oktypes, parent=self)
[ "def", "_set_content", "(", "self", ",", "value", ",", "oktypes", ")", ":", "if", "value", "is", "None", ":", "value", "=", "[", "]", "self", ".", "_content", "=", "ListContainer", "(", "*", "value", ",", "oktypes", "=", "oktypes", ",", "parent", "="...
Similar to content.setter but when there are no existing oktypes
[ "Similar", "to", "content", ".", "setter", "but", "when", "there", "are", "no", "existing", "oktypes" ]
65c2d570c26a190deb600cab5e2ad8a828a3302e
https://github.com/sergiocorreia/panflute/blob/65c2d570c26a190deb600cab5e2ad8a828a3302e/panflute/base.py#L123-L129
12,374
sergiocorreia/panflute
panflute/base.py
Element.offset
def offset(self, n): """ Return a sibling element offset by n :rtype: :class:`Element` | ``None`` """ idx = self.index if idx is not None: sibling = idx + n container = self.container if 0 <= sibling < len(container): ...
python
def offset(self, n): """ Return a sibling element offset by n :rtype: :class:`Element` | ``None`` """ idx = self.index if idx is not None: sibling = idx + n container = self.container if 0 <= sibling < len(container): ...
[ "def", "offset", "(", "self", ",", "n", ")", ":", "idx", "=", "self", ".", "index", "if", "idx", "is", "not", "None", ":", "sibling", "=", "idx", "+", "n", "container", "=", "self", ".", "container", "if", "0", "<=", "sibling", "<", "len", "(", ...
Return a sibling element offset by n :rtype: :class:`Element` | ``None``
[ "Return", "a", "sibling", "element", "offset", "by", "n" ]
65c2d570c26a190deb600cab5e2ad8a828a3302e
https://github.com/sergiocorreia/panflute/blob/65c2d570c26a190deb600cab5e2ad8a828a3302e/panflute/base.py#L166-L178
12,375
laike9m/pdir2
pdir/api.py
PrettyDir.search
def search(self, term: str, case_sensitive: bool = False) -> 'PrettyDir': """Searches for names that match some pattern. Args: term: String used to match names. A name is returned if it matches the whole search term. case_sensitive: Boolean to match case or not, de...
python
def search(self, term: str, case_sensitive: bool = False) -> 'PrettyDir': """Searches for names that match some pattern. Args: term: String used to match names. A name is returned if it matches the whole search term. case_sensitive: Boolean to match case or not, de...
[ "def", "search", "(", "self", ",", "term", ":", "str", ",", "case_sensitive", ":", "bool", "=", "False", ")", "->", "'PrettyDir'", ":", "if", "case_sensitive", ":", "return", "PrettyDir", "(", "self", ".", "obj", ",", "[", "pattr", "for", "pattr", "in"...
Searches for names that match some pattern. Args: term: String used to match names. A name is returned if it matches the whole search term. case_sensitive: Boolean to match case or not, default is False (case insensitive). Return: A Prett...
[ "Searches", "for", "names", "that", "match", "some", "pattern", "." ]
c4550523fe9b54bf9b755ffa28900a5e9f493d02
https://github.com/laike9m/pdir2/blob/c4550523fe9b54bf9b755ffa28900a5e9f493d02/pdir/api.py#L74-L94
12,376
laike9m/pdir2
pdir/api.py
PrettyDir.properties
def properties(self) -> 'PrettyDir': """Returns all properties of the inspected object. Note that "properties" can mean "variables". """ return PrettyDir( self.obj, [ pattr for pattr in self.pattrs if category_match...
python
def properties(self) -> 'PrettyDir': """Returns all properties of the inspected object. Note that "properties" can mean "variables". """ return PrettyDir( self.obj, [ pattr for pattr in self.pattrs if category_match...
[ "def", "properties", "(", "self", ")", "->", "'PrettyDir'", ":", "return", "PrettyDir", "(", "self", ".", "obj", ",", "[", "pattr", "for", "pattr", "in", "self", ".", "pattrs", "if", "category_match", "(", "pattr", ".", "category", ",", "AttrCategory", "...
Returns all properties of the inspected object. Note that "properties" can mean "variables".
[ "Returns", "all", "properties", "of", "the", "inspected", "object", "." ]
c4550523fe9b54bf9b755ffa28900a5e9f493d02
https://github.com/laike9m/pdir2/blob/c4550523fe9b54bf9b755ffa28900a5e9f493d02/pdir/api.py#L104-L116
12,377
laike9m/pdir2
pdir/api.py
PrettyDir.methods
def methods(self) -> 'PrettyDir': """Returns all methods of the inspected object. Note that "methods" can mean "functions" when inspecting a module. """ return PrettyDir( self.obj, [ pattr for pattr in self.pattrs i...
python
def methods(self) -> 'PrettyDir': """Returns all methods of the inspected object. Note that "methods" can mean "functions" when inspecting a module. """ return PrettyDir( self.obj, [ pattr for pattr in self.pattrs i...
[ "def", "methods", "(", "self", ")", "->", "'PrettyDir'", ":", "return", "PrettyDir", "(", "self", ".", "obj", ",", "[", "pattr", "for", "pattr", "in", "self", ".", "pattrs", "if", "category_match", "(", "pattr", ".", "category", ",", "AttrCategory", ".",...
Returns all methods of the inspected object. Note that "methods" can mean "functions" when inspecting a module.
[ "Returns", "all", "methods", "of", "the", "inspected", "object", "." ]
c4550523fe9b54bf9b755ffa28900a5e9f493d02
https://github.com/laike9m/pdir2/blob/c4550523fe9b54bf9b755ffa28900a5e9f493d02/pdir/api.py#L119-L131
12,378
laike9m/pdir2
pdir/api.py
PrettyDir.public
def public(self) -> 'PrettyDir': """Returns public attributes of the inspected object.""" return PrettyDir( self.obj, [pattr for pattr in self.pattrs if not pattr.name.startswith('_')] )
python
def public(self) -> 'PrettyDir': """Returns public attributes of the inspected object.""" return PrettyDir( self.obj, [pattr for pattr in self.pattrs if not pattr.name.startswith('_')] )
[ "def", "public", "(", "self", ")", "->", "'PrettyDir'", ":", "return", "PrettyDir", "(", "self", ".", "obj", ",", "[", "pattr", "for", "pattr", "in", "self", ".", "pattrs", "if", "not", "pattr", ".", "name", ".", "startswith", "(", "'_'", ")", "]", ...
Returns public attributes of the inspected object.
[ "Returns", "public", "attributes", "of", "the", "inspected", "object", "." ]
c4550523fe9b54bf9b755ffa28900a5e9f493d02
https://github.com/laike9m/pdir2/blob/c4550523fe9b54bf9b755ffa28900a5e9f493d02/pdir/api.py#L134-L138
12,379
laike9m/pdir2
pdir/api.py
PrettyDir.own
def own(self) -> 'PrettyDir': """Returns attributes that are not inhterited from parent classes. Now we only use a simple judgement, it is expected that many attributes not get returned, especially invoked on a module. For instance, there's no way to distinguish between properties that...
python
def own(self) -> 'PrettyDir': """Returns attributes that are not inhterited from parent classes. Now we only use a simple judgement, it is expected that many attributes not get returned, especially invoked on a module. For instance, there's no way to distinguish between properties that...
[ "def", "own", "(", "self", ")", "->", "'PrettyDir'", ":", "return", "PrettyDir", "(", "self", ".", "obj", ",", "[", "pattr", "for", "pattr", "in", "self", ".", "pattrs", "if", "pattr", ".", "name", "in", "type", "(", "self", ".", "obj", ")", ".", ...
Returns attributes that are not inhterited from parent classes. Now we only use a simple judgement, it is expected that many attributes not get returned, especially invoked on a module. For instance, there's no way to distinguish between properties that are initialized in instance clas...
[ "Returns", "attributes", "that", "are", "not", "inhterited", "from", "parent", "classes", "." ]
c4550523fe9b54bf9b755ffa28900a5e9f493d02
https://github.com/laike9m/pdir2/blob/c4550523fe9b54bf9b755ffa28900a5e9f493d02/pdir/api.py#L141-L159
12,380
laike9m/pdir2
pdir/api.py
PrettyAttribute.get_oneline_doc
def get_oneline_doc(self) -> str: """ Doc doesn't necessarily mean doctring. It could be anything that should be put after the attr's name as an explanation. """ attr = self.attr_obj if self.display_group == AttrCategory.DESCRIPTOR: if isinstance(attr, propert...
python
def get_oneline_doc(self) -> str: """ Doc doesn't necessarily mean doctring. It could be anything that should be put after the attr's name as an explanation. """ attr = self.attr_obj if self.display_group == AttrCategory.DESCRIPTOR: if isinstance(attr, propert...
[ "def", "get_oneline_doc", "(", "self", ")", "->", "str", ":", "attr", "=", "self", ".", "attr_obj", "if", "self", ".", "display_group", "==", "AttrCategory", ".", "DESCRIPTOR", ":", "if", "isinstance", "(", "attr", ",", "property", ")", ":", "doc_list", ...
Doc doesn't necessarily mean doctring. It could be anything that should be put after the attr's name as an explanation.
[ "Doc", "doesn", "t", "necessarily", "mean", "doctring", ".", "It", "could", "be", "anything", "that", "should", "be", "put", "after", "the", "attr", "s", "name", "as", "an", "explanation", "." ]
c4550523fe9b54bf9b755ffa28900a5e9f493d02
https://github.com/laike9m/pdir2/blob/c4550523fe9b54bf9b755ffa28900a5e9f493d02/pdir/api.py#L183-L212
12,381
laike9m/pdir2
pdir/format.py
format_pattrs
def format_pattrs(pattrs: List['api.PrettyAttribute']) -> str: """Generates repr string given a list of pattrs.""" output = [] pattrs.sort( key=lambda x: ( _FORMATTER[x.display_group].display_index, x.display_group, x.name, ) ) for display_group, g...
python
def format_pattrs(pattrs: List['api.PrettyAttribute']) -> str: """Generates repr string given a list of pattrs.""" output = [] pattrs.sort( key=lambda x: ( _FORMATTER[x.display_group].display_index, x.display_group, x.name, ) ) for display_group, g...
[ "def", "format_pattrs", "(", "pattrs", ":", "List", "[", "'api.PrettyAttribute'", "]", ")", "->", "str", ":", "output", "=", "[", "]", "pattrs", ".", "sort", "(", "key", "=", "lambda", "x", ":", "(", "_FORMATTER", "[", "x", ".", "display_group", "]", ...
Generates repr string given a list of pattrs.
[ "Generates", "repr", "string", "given", "a", "list", "of", "pattrs", "." ]
c4550523fe9b54bf9b755ffa28900a5e9f493d02
https://github.com/laike9m/pdir2/blob/c4550523fe9b54bf9b755ffa28900a5e9f493d02/pdir/format.py#L14-L29
12,382
laike9m/pdir2
pdir/_internal_utils.py
get_attr_from_dict
def get_attr_from_dict(inspected_obj: Any, attr_name: str) -> Any: """Ensures we get descriptor object instead of its return value. """ if inspect.isclass(inspected_obj): obj_list = [inspected_obj] + list(inspected_obj.__mro__) else: obj_list = [inspected_obj] + list(inspected_obj.__clas...
python
def get_attr_from_dict(inspected_obj: Any, attr_name: str) -> Any: """Ensures we get descriptor object instead of its return value. """ if inspect.isclass(inspected_obj): obj_list = [inspected_obj] + list(inspected_obj.__mro__) else: obj_list = [inspected_obj] + list(inspected_obj.__clas...
[ "def", "get_attr_from_dict", "(", "inspected_obj", ":", "Any", ",", "attr_name", ":", "str", ")", "->", "Any", ":", "if", "inspect", ".", "isclass", "(", "inspected_obj", ")", ":", "obj_list", "=", "[", "inspected_obj", "]", "+", "list", "(", "inspected_ob...
Ensures we get descriptor object instead of its return value.
[ "Ensures", "we", "get", "descriptor", "object", "instead", "of", "its", "return", "value", "." ]
c4550523fe9b54bf9b755ffa28900a5e9f493d02
https://github.com/laike9m/pdir2/blob/c4550523fe9b54bf9b755ffa28900a5e9f493d02/pdir/_internal_utils.py#L9-L22
12,383
laike9m/pdir2
pdir/attr_category.py
attr_category_postprocess
def attr_category_postprocess(get_attr_category_func): """Unifies attr_category to a tuple, add AttrCategory.SLOT if needed.""" @functools.wraps(get_attr_category_func) def wrapped( name: str, attr: Any, obj: Any ) -> Tuple[AttrCategory, ...]: category = get_attr_category_func(name, attr...
python
def attr_category_postprocess(get_attr_category_func): """Unifies attr_category to a tuple, add AttrCategory.SLOT if needed.""" @functools.wraps(get_attr_category_func) def wrapped( name: str, attr: Any, obj: Any ) -> Tuple[AttrCategory, ...]: category = get_attr_category_func(name, attr...
[ "def", "attr_category_postprocess", "(", "get_attr_category_func", ")", ":", "@", "functools", ".", "wraps", "(", "get_attr_category_func", ")", "def", "wrapped", "(", "name", ":", "str", ",", "attr", ":", "Any", ",", "obj", ":", "Any", ")", "->", "Tuple", ...
Unifies attr_category to a tuple, add AttrCategory.SLOT if needed.
[ "Unifies", "attr_category", "to", "a", "tuple", "add", "AttrCategory", ".", "SLOT", "if", "needed", "." ]
c4550523fe9b54bf9b755ffa28900a5e9f493d02
https://github.com/laike9m/pdir2/blob/c4550523fe9b54bf9b755ffa28900a5e9f493d02/pdir/attr_category.py#L216-L230
12,384
mattloper/chumpy
chumpy/monitor.py
get_peak_mem
def get_peak_mem(): ''' this returns peak memory use since process starts till the moment its called ''' import resource rusage_denom = 1024. if sys.platform == 'darwin': # ... it seems that in OSX the output is different units ... rusage_denom = rusage_denom * rusage_denom m...
python
def get_peak_mem(): ''' this returns peak memory use since process starts till the moment its called ''' import resource rusage_denom = 1024. if sys.platform == 'darwin': # ... it seems that in OSX the output is different units ... rusage_denom = rusage_denom * rusage_denom m...
[ "def", "get_peak_mem", "(", ")", ":", "import", "resource", "rusage_denom", "=", "1024.", "if", "sys", ".", "platform", "==", "'darwin'", ":", "# ... it seems that in OSX the output is different units ...", "rusage_denom", "=", "rusage_denom", "*", "rusage_denom", "mem"...
this returns peak memory use since process starts till the moment its called
[ "this", "returns", "peak", "memory", "use", "since", "process", "starts", "till", "the", "moment", "its", "called" ]
a3cfdb1be3c8265c369c507b22f6f3f89414c772
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/monitor.py#L26-L36
12,385
mattloper/chumpy
chumpy/utils.py
dfs_do_func_on_graph
def dfs_do_func_on_graph(node, func, *args, **kwargs): ''' invoke func on each node of the dr graph ''' for _node in node.tree_iterator(): func(_node, *args, **kwargs)
python
def dfs_do_func_on_graph(node, func, *args, **kwargs): ''' invoke func on each node of the dr graph ''' for _node in node.tree_iterator(): func(_node, *args, **kwargs)
[ "def", "dfs_do_func_on_graph", "(", "node", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "_node", "in", "node", ".", "tree_iterator", "(", ")", ":", "func", "(", "_node", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
invoke func on each node of the dr graph
[ "invoke", "func", "on", "each", "node", "of", "the", "dr", "graph" ]
a3cfdb1be3c8265c369c507b22f6f3f89414c772
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/utils.py#L36-L41
12,386
mattloper/chumpy
chumpy/utils.py
sparse_is_desireable
def sparse_is_desireable(lhs, rhs): ''' Examines a pair of matrices and determines if the result of their multiplication should be sparse or not. ''' return False if len(lhs.shape) == 1: return False else: lhs_rows, lhs_cols = lhs.shape if len(rhs.shape) == 1: rhs_ro...
python
def sparse_is_desireable(lhs, rhs): ''' Examines a pair of matrices and determines if the result of their multiplication should be sparse or not. ''' return False if len(lhs.shape) == 1: return False else: lhs_rows, lhs_cols = lhs.shape if len(rhs.shape) == 1: rhs_ro...
[ "def", "sparse_is_desireable", "(", "lhs", ",", "rhs", ")", ":", "return", "False", "if", "len", "(", "lhs", ".", "shape", ")", "==", "1", ":", "return", "False", "else", ":", "lhs_rows", ",", "lhs_cols", "=", "lhs", ".", "shape", "if", "len", "(", ...
Examines a pair of matrices and determines if the result of their multiplication should be sparse or not.
[ "Examines", "a", "pair", "of", "matrices", "and", "determines", "if", "the", "result", "of", "their", "multiplication", "should", "be", "sparse", "or", "not", "." ]
a3cfdb1be3c8265c369c507b22f6f3f89414c772
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/utils.py#L44-L78
12,387
mattloper/chumpy
chumpy/utils.py
convert_inputs_to_sparse_if_necessary
def convert_inputs_to_sparse_if_necessary(lhs, rhs): ''' This function checks to see if a sparse output is desireable given the inputs and if so, casts the inputs to sparse in order to make it so. ''' if not sp.issparse(lhs) or not sp.issparse(rhs): if sparse_is_desireable(lhs, rhs): ...
python
def convert_inputs_to_sparse_if_necessary(lhs, rhs): ''' This function checks to see if a sparse output is desireable given the inputs and if so, casts the inputs to sparse in order to make it so. ''' if not sp.issparse(lhs) or not sp.issparse(rhs): if sparse_is_desireable(lhs, rhs): ...
[ "def", "convert_inputs_to_sparse_if_necessary", "(", "lhs", ",", "rhs", ")", ":", "if", "not", "sp", ".", "issparse", "(", "lhs", ")", "or", "not", "sp", ".", "issparse", "(", "rhs", ")", ":", "if", "sparse_is_desireable", "(", "lhs", ",", "rhs", ")", ...
This function checks to see if a sparse output is desireable given the inputs and if so, casts the inputs to sparse in order to make it so.
[ "This", "function", "checks", "to", "see", "if", "a", "sparse", "output", "is", "desireable", "given", "the", "inputs", "and", "if", "so", "casts", "the", "inputs", "to", "sparse", "in", "order", "to", "make", "it", "so", "." ]
a3cfdb1be3c8265c369c507b22f6f3f89414c772
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/utils.py#L81-L93
12,388
mattloper/chumpy
chumpy/optimization_internal.py
ChInputsStacked.dr_wrt
def dr_wrt(self, wrt, profiler=None): ''' Loop over free variables and delete cache for the whole tree after finished each one ''' if wrt is self.x: jacs = [] for fvi, freevar in enumerate(self.free_variables): tm = timer() if isins...
python
def dr_wrt(self, wrt, profiler=None): ''' Loop over free variables and delete cache for the whole tree after finished each one ''' if wrt is self.x: jacs = [] for fvi, freevar in enumerate(self.free_variables): tm = timer() if isins...
[ "def", "dr_wrt", "(", "self", ",", "wrt", ",", "profiler", "=", "None", ")", ":", "if", "wrt", "is", "self", ".", "x", ":", "jacs", "=", "[", "]", "for", "fvi", ",", "freevar", "in", "enumerate", "(", "self", ".", "free_variables", ")", ":", "tm"...
Loop over free variables and delete cache for the whole tree after finished each one
[ "Loop", "over", "free", "variables", "and", "delete", "cache", "for", "the", "whole", "tree", "after", "finished", "each", "one" ]
a3cfdb1be3c8265c369c507b22f6f3f89414c772
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/optimization_internal.py#L34-L71
12,389
mattloper/chumpy
chumpy/optimization_internal.py
ChInputsStacked.J
def J(self): ''' Compute Jacobian. Analyze dr graph first to disable unnecessary caching ''' result = self.dr_wrt(self.x, profiler=self.profiler).copy() if self.profiler: self.profiler.harvest() return np.atleast_2d(result) if not sp.issparse(result) else resu...
python
def J(self): ''' Compute Jacobian. Analyze dr graph first to disable unnecessary caching ''' result = self.dr_wrt(self.x, profiler=self.profiler).copy() if self.profiler: self.profiler.harvest() return np.atleast_2d(result) if not sp.issparse(result) else resu...
[ "def", "J", "(", "self", ")", ":", "result", "=", "self", ".", "dr_wrt", "(", "self", ".", "x", ",", "profiler", "=", "self", ".", "profiler", ")", ".", "copy", "(", ")", "if", "self", ".", "profiler", ":", "self", ".", "profiler", ".", "harvest"...
Compute Jacobian. Analyze dr graph first to disable unnecessary caching
[ "Compute", "Jacobian", ".", "Analyze", "dr", "graph", "first", "to", "disable", "unnecessary", "caching" ]
a3cfdb1be3c8265c369c507b22f6f3f89414c772
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/optimization_internal.py#L101-L108
12,390
mattloper/chumpy
chumpy/ch.py
Ch.sid
def sid(self): """Semantic id.""" pnames = list(self.terms)+list(self.dterms) pnames.sort() return (self.__class__, tuple([(k, id(self.__dict__[k])) for k in pnames if k in self.__dict__]))
python
def sid(self): """Semantic id.""" pnames = list(self.terms)+list(self.dterms) pnames.sort() return (self.__class__, tuple([(k, id(self.__dict__[k])) for k in pnames if k in self.__dict__]))
[ "def", "sid", "(", "self", ")", ":", "pnames", "=", "list", "(", "self", ".", "terms", ")", "+", "list", "(", "self", ".", "dterms", ")", "pnames", ".", "sort", "(", ")", "return", "(", "self", ".", "__class__", ",", "tuple", "(", "[", "(", "k"...
Semantic id.
[ "Semantic", "id", "." ]
a3cfdb1be3c8265c369c507b22f6f3f89414c772
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/ch.py#L185-L189
12,391
mattloper/chumpy
chumpy/ch.py
Ch.compute_dr_wrt
def compute_dr_wrt(self,wrt): """Default method for objects that just contain a number or ndarray""" if wrt is self: # special base case return sp.eye(self.x.size, self.x.size) #return np.array([[1]]) return None
python
def compute_dr_wrt(self,wrt): """Default method for objects that just contain a number or ndarray""" if wrt is self: # special base case return sp.eye(self.x.size, self.x.size) #return np.array([[1]]) return None
[ "def", "compute_dr_wrt", "(", "self", ",", "wrt", ")", ":", "if", "wrt", "is", "self", ":", "# special base case ", "return", "sp", ".", "eye", "(", "self", ".", "x", ".", "size", ",", "self", ".", "x", ".", "size", ")", "#return np.array([[1]])", "re...
Default method for objects that just contain a number or ndarray
[ "Default", "method", "for", "objects", "that", "just", "contain", "a", "number", "or", "ndarray" ]
a3cfdb1be3c8265c369c507b22f6f3f89414c772
https://github.com/mattloper/chumpy/blob/a3cfdb1be3c8265c369c507b22f6f3f89414c772/chumpy/ch.py#L275-L280
12,392
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.get_ubuntu_release_from_sentry
def get_ubuntu_release_from_sentry(self, sentry_unit): """Get Ubuntu release codename from sentry unit. :param sentry_unit: amulet sentry/service unit pointer :returns: list of strings - release codename, failure message """ msg = None cmd = 'lsb_release -cs' rel...
python
def get_ubuntu_release_from_sentry(self, sentry_unit): """Get Ubuntu release codename from sentry unit. :param sentry_unit: amulet sentry/service unit pointer :returns: list of strings - release codename, failure message """ msg = None cmd = 'lsb_release -cs' rel...
[ "def", "get_ubuntu_release_from_sentry", "(", "self", ",", "sentry_unit", ")", ":", "msg", "=", "None", "cmd", "=", "'lsb_release -cs'", "release", ",", "code", "=", "sentry_unit", ".", "run", "(", "cmd", ")", "if", "code", "==", "0", ":", "self", ".", "...
Get Ubuntu release codename from sentry unit. :param sentry_unit: amulet sentry/service unit pointer :returns: list of strings - release codename, failure message
[ "Get", "Ubuntu", "release", "codename", "from", "sentry", "unit", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L83-L102
12,393
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.validate_services
def validate_services(self, commands): """Validate that lists of commands succeed on service units. Can be used to verify system services are running on the corresponding service units. :param commands: dict with sentry keys and arbitrary command list vals :returns: None ...
python
def validate_services(self, commands): """Validate that lists of commands succeed on service units. Can be used to verify system services are running on the corresponding service units. :param commands: dict with sentry keys and arbitrary command list vals :returns: None ...
[ "def", "validate_services", "(", "self", ",", "commands", ")", ":", "self", ".", "log", ".", "debug", "(", "'Checking status of system services...'", ")", "# /!\\ DEPRECATION WARNING (beisner):", "# New and existing tests should be rewritten to use", "# validate_services_by_name(...
Validate that lists of commands succeed on service units. Can be used to verify system services are running on the corresponding service units. :param commands: dict with sentry keys and arbitrary command list vals :returns: None if successful, Failure string message otherwise
[ "Validate", "that", "lists", "of", "commands", "succeed", "on", "service", "units", ".", "Can", "be", "used", "to", "verify", "system", "services", "are", "running", "on", "the", "corresponding", "service", "units", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L104-L129
12,394
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.validate_services_by_name
def validate_services_by_name(self, sentry_services): """Validate system service status by service name, automatically detecting init system based on Ubuntu release codename. :param sentry_services: dict with sentry keys and svc list values :returns: None if successful, Failure strin...
python
def validate_services_by_name(self, sentry_services): """Validate system service status by service name, automatically detecting init system based on Ubuntu release codename. :param sentry_services: dict with sentry keys and svc list values :returns: None if successful, Failure strin...
[ "def", "validate_services_by_name", "(", "self", ",", "sentry_services", ")", ":", "self", ".", "log", ".", "debug", "(", "'Checking status of system services...'", ")", "# Point at which systemd became a thing", "systemd_switch", "=", "self", ".", "ubuntu_releases", ".",...
Validate system service status by service name, automatically detecting init system based on Ubuntu release codename. :param sentry_services: dict with sentry keys and svc list values :returns: None if successful, Failure string message otherwise
[ "Validate", "system", "service", "status", "by", "service", "name", "automatically", "detecting", "init", "system", "based", "on", "Ubuntu", "release", "codename", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L131-L169
12,395
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils._get_config
def _get_config(self, unit, filename): """Get a ConfigParser object for parsing a unit's config file.""" file_contents = unit.file_contents(filename) # NOTE(beisner): by default, ConfigParser does not handle options # with no value, such as the flags used in the mysql my.cnf file. ...
python
def _get_config(self, unit, filename): """Get a ConfigParser object for parsing a unit's config file.""" file_contents = unit.file_contents(filename) # NOTE(beisner): by default, ConfigParser does not handle options # with no value, such as the flags used in the mysql my.cnf file. ...
[ "def", "_get_config", "(", "self", ",", "unit", ",", "filename", ")", ":", "file_contents", "=", "unit", ".", "file_contents", "(", "filename", ")", "# NOTE(beisner): by default, ConfigParser does not handle options", "# with no value, such as the flags used in the mysql my.cn...
Get a ConfigParser object for parsing a unit's config file.
[ "Get", "a", "ConfigParser", "object", "for", "parsing", "a", "unit", "s", "config", "file", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L171-L180
12,396
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.validate_config_data
def validate_config_data(self, sentry_unit, config_file, section, expected): """Validate config file data. Verify that the specified section of the config file contains the expected option key:value pairs. Compare expected dictionary data vs actual...
python
def validate_config_data(self, sentry_unit, config_file, section, expected): """Validate config file data. Verify that the specified section of the config file contains the expected option key:value pairs. Compare expected dictionary data vs actual...
[ "def", "validate_config_data", "(", "self", ",", "sentry_unit", ",", "config_file", ",", "section", ",", "expected", ")", ":", "self", ".", "log", ".", "debug", "(", "'Validating config file data ({} in {} on {})'", "'...'", ".", "format", "(", "section", ",", "...
Validate config file data. Verify that the specified section of the config file contains the expected option key:value pairs. Compare expected dictionary data vs actual dictionary data. The values in the 'expected' dictionary can be strings, bools, ints, longs, o...
[ "Validate", "config", "file", "data", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L182-L219
12,397
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils._validate_dict_data
def _validate_dict_data(self, expected, actual): """Validate dictionary data. Compare expected dictionary data vs actual dictionary data. The values in the 'expected' dictionary can be strings, bools, ints, longs, or can be a function that evaluates a variable and returns a ...
python
def _validate_dict_data(self, expected, actual): """Validate dictionary data. Compare expected dictionary data vs actual dictionary data. The values in the 'expected' dictionary can be strings, bools, ints, longs, or can be a function that evaluates a variable and returns a ...
[ "def", "_validate_dict_data", "(", "self", ",", "expected", ",", "actual", ")", ":", "self", ".", "log", ".", "debug", "(", "'actual: {}'", ".", "format", "(", "repr", "(", "actual", ")", ")", ")", "self", ".", "log", ".", "debug", "(", "'expected: {}'...
Validate dictionary data. Compare expected dictionary data vs actual dictionary data. The values in the 'expected' dictionary can be strings, bools, ints, longs, or can be a function that evaluates a variable and returns a bool.
[ "Validate", "dictionary", "data", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L221-L245
12,398
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils.validate_relation_data
def validate_relation_data(self, sentry_unit, relation, expected): """Validate actual relation data based on expected relation data.""" actual = sentry_unit.relation(relation[0], relation[1]) return self._validate_dict_data(expected, actual)
python
def validate_relation_data(self, sentry_unit, relation, expected): """Validate actual relation data based on expected relation data.""" actual = sentry_unit.relation(relation[0], relation[1]) return self._validate_dict_data(expected, actual)
[ "def", "validate_relation_data", "(", "self", ",", "sentry_unit", ",", "relation", ",", "expected", ")", ":", "actual", "=", "sentry_unit", ".", "relation", "(", "relation", "[", "0", "]", ",", "relation", "[", "1", "]", ")", "return", "self", ".", "_val...
Validate actual relation data based on expected relation data.
[ "Validate", "actual", "relation", "data", "based", "on", "expected", "relation", "data", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L247-L250
12,399
juju/charm-helpers
charmhelpers/contrib/amulet/utils.py
AmuletUtils._validate_list_data
def _validate_list_data(self, expected, actual): """Compare expected list vs actual list data.""" for e in expected: if e not in actual: return "expected item {} not found in actual list".format(e) return None
python
def _validate_list_data(self, expected, actual): """Compare expected list vs actual list data.""" for e in expected: if e not in actual: return "expected item {} not found in actual list".format(e) return None
[ "def", "_validate_list_data", "(", "self", ",", "expected", ",", "actual", ")", ":", "for", "e", "in", "expected", ":", "if", "e", "not", "in", "actual", ":", "return", "\"expected item {} not found in actual list\"", ".", "format", "(", "e", ")", "return", ...
Compare expected list vs actual list data.
[ "Compare", "expected", "list", "vs", "actual", "list", "data", "." ]
aa785c40c3b7a8c69dbfbc7921d6b9f30142e171
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/amulet/utils.py#L252-L257