partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
BoltArrayLocal.concatenate
Join this array with another array. Paramters --------- arry : ndarray or BoltArrayLocal Another array to concatenate with axis : int, optional, default=0 The axis along which arrays will be joined. Returns ------- BoltArrayLocal
bolt/local/array.py
def concatenate(self, arry, axis=0): """ Join this array with another array. Paramters --------- arry : ndarray or BoltArrayLocal Another array to concatenate with axis : int, optional, default=0 The axis along which arrays will be joined. ...
def concatenate(self, arry, axis=0): """ Join this array with another array. Paramters --------- arry : ndarray or BoltArrayLocal Another array to concatenate with axis : int, optional, default=0 The axis along which arrays will be joined. ...
[ "Join", "this", "array", "with", "another", "array", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/local/array.py#L172-L192
[ "def", "concatenate", "(", "self", ",", "arry", ",", "axis", "=", "0", ")", ":", "if", "isinstance", "(", "arry", ",", "ndarray", ")", ":", "from", "bolt", "import", "concatenate", "return", "concatenate", "(", "(", "self", ",", "arry", ")", ",", "ax...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArrayLocal.tospark
Converts a BoltArrayLocal into a BoltArraySpark Parameters ---------- sc : SparkContext The SparkContext which will be used to create the BoltArraySpark axis : tuple or int, optional, default=0 The axis (or axes) across which this array will be parallelized ...
bolt/local/array.py
def tospark(self, sc, axis=0): """ Converts a BoltArrayLocal into a BoltArraySpark Parameters ---------- sc : SparkContext The SparkContext which will be used to create the BoltArraySpark axis : tuple or int, optional, default=0 The axis (or axes...
def tospark(self, sc, axis=0): """ Converts a BoltArrayLocal into a BoltArraySpark Parameters ---------- sc : SparkContext The SparkContext which will be used to create the BoltArraySpark axis : tuple or int, optional, default=0 The axis (or axes...
[ "Converts", "a", "BoltArrayLocal", "into", "a", "BoltArraySpark" ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/local/array.py#L204-L221
[ "def", "tospark", "(", "self", ",", "sc", ",", "axis", "=", "0", ")", ":", "from", "bolt", "import", "array", "return", "array", "(", "self", ".", "toarray", "(", ")", ",", "sc", ",", "axis", "=", "axis", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArrayLocal.tordd
Converts a BoltArrayLocal into an RDD Parameters ---------- sc : SparkContext The SparkContext which will be used to create the BoltArraySpark axis : tuple or int, optional, default=0 The axis (or axes) across which this array will be parallelized Retur...
bolt/local/array.py
def tordd(self, sc, axis=0): """ Converts a BoltArrayLocal into an RDD Parameters ---------- sc : SparkContext The SparkContext which will be used to create the BoltArraySpark axis : tuple or int, optional, default=0 The axis (or axes) across whi...
def tordd(self, sc, axis=0): """ Converts a BoltArrayLocal into an RDD Parameters ---------- sc : SparkContext The SparkContext which will be used to create the BoltArraySpark axis : tuple or int, optional, default=0 The axis (or axes) across whi...
[ "Converts", "a", "BoltArrayLocal", "into", "an", "RDD" ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/local/array.py#L223-L240
[ "def", "tordd", "(", "self", ",", "sc", ",", "axis", "=", "0", ")", ":", "from", "bolt", "import", "array", "return", "array", "(", "self", ".", "toarray", "(", ")", ",", "sc", ",", "axis", "=", "axis", ")", ".", "tordd", "(", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
StackedArray.stack
Make an intermediate RDD where all records are combined into a list of keys and larger ndarray along a new 0th dimension.
bolt/spark/stack.py
def stack(self, size): """ Make an intermediate RDD where all records are combined into a list of keys and larger ndarray along a new 0th dimension. """ def tostacks(partition): keys = [] arrs = [] for key, arr in partition: key...
def stack(self, size): """ Make an intermediate RDD where all records are combined into a list of keys and larger ndarray along a new 0th dimension. """ def tostacks(partition): keys = [] arrs = [] for key, arr in partition: key...
[ "Make", "an", "intermediate", "RDD", "where", "all", "records", "are", "combined", "into", "a", "list", "of", "keys", "and", "larger", "ndarray", "along", "a", "new", "0th", "dimension", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/stack.py#L50-L68
[ "def", "stack", "(", "self", ",", "size", ")", ":", "def", "tostacks", "(", "partition", ")", ":", "keys", "=", "[", "]", "arrs", "=", "[", "]", "for", "key", ",", "arr", "in", "partition", ":", "keys", ".", "append", "(", "key", ")", "arrs", "...
9cd7104aa085498da3097b72696184b9d3651c51
test
StackedArray.unstack
Unstack array and return a new BoltArraySpark via flatMap().
bolt/spark/stack.py
def unstack(self): """ Unstack array and return a new BoltArraySpark via flatMap(). """ from bolt.spark.array import BoltArraySpark if self._rekeyed: rdd = self._rdd else: rdd = self._rdd.flatMap(lambda kv: zip(kv[0], list(kv[1]))) return...
def unstack(self): """ Unstack array and return a new BoltArraySpark via flatMap(). """ from bolt.spark.array import BoltArraySpark if self._rekeyed: rdd = self._rdd else: rdd = self._rdd.flatMap(lambda kv: zip(kv[0], list(kv[1]))) return...
[ "Unstack", "array", "and", "return", "a", "new", "BoltArraySpark", "via", "flatMap", "()", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/stack.py#L70-L81
[ "def", "unstack", "(", "self", ")", ":", "from", "bolt", ".", "spark", ".", "array", "import", "BoltArraySpark", "if", "self", ".", "_rekeyed", ":", "rdd", "=", "self", ".", "_rdd", "else", ":", "rdd", "=", "self", ".", "_rdd", ".", "flatMap", "(", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
StackedArray.map
Apply a function on each subarray. Parameters ---------- func : function This is applied to each value in the intermediate RDD. Returns ------- StackedArray
bolt/spark/stack.py
def map(self, func): """ Apply a function on each subarray. Parameters ---------- func : function This is applied to each value in the intermediate RDD. Returns ------- StackedArray """ vshape = self.shape[self.split:] ...
def map(self, func): """ Apply a function on each subarray. Parameters ---------- func : function This is applied to each value in the intermediate RDD. Returns ------- StackedArray """ vshape = self.shape[self.split:] ...
[ "Apply", "a", "function", "on", "each", "subarray", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/stack.py#L83-L136
[ "def", "map", "(", "self", ",", "func", ")", ":", "vshape", "=", "self", ".", "shape", "[", "self", ".", "split", ":", "]", "x", "=", "self", ".", "_rdd", ".", "values", "(", ")", ".", "first", "(", ")", "if", "x", ".", "shape", "==", "vshape...
9cd7104aa085498da3097b72696184b9d3651c51
test
ChunkedArray._chunk
Split values of distributed array into chunks. Transforms an underlying pair RDD of (key, value) into records of the form: (key, chunk id), (chunked value). Here, chunk id is a tuple identifying the chunk and chunked value is a subset of the data from each original value, that h...
bolt/spark/chunk.py
def _chunk(self, size="150", axis=None, padding=None): """ Split values of distributed array into chunks. Transforms an underlying pair RDD of (key, value) into records of the form: (key, chunk id), (chunked value). Here, chunk id is a tuple identifying the chunk and chu...
def _chunk(self, size="150", axis=None, padding=None): """ Split values of distributed array into chunks. Transforms an underlying pair RDD of (key, value) into records of the form: (key, chunk id), (chunked value). Here, chunk id is a tuple identifying the chunk and chu...
[ "Split", "values", "of", "distributed", "array", "into", "chunks", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L87-L144
[ "def", "_chunk", "(", "self", ",", "size", "=", "\"150\"", ",", "axis", "=", "None", ",", "padding", "=", "None", ")", ":", "if", "self", ".", "split", "==", "len", "(", "self", ".", "shape", ")", "and", "padding", "is", "None", ":", "self", ".",...
9cd7104aa085498da3097b72696184b9d3651c51
test
ChunkedArray.unchunk
Convert a chunked array back into a full array with (key,value) pairs where key is a tuple of indices, and value is an ndarray.
bolt/spark/chunk.py
def unchunk(self): """ Convert a chunked array back into a full array with (key,value) pairs where key is a tuple of indices, and value is an ndarray. """ plan, padding, vshape, split = self.plan, self.padding, self.vshape, self.split nchunks = self.getnumber(plan, vshape...
def unchunk(self): """ Convert a chunked array back into a full array with (key,value) pairs where key is a tuple of indices, and value is an ndarray. """ plan, padding, vshape, split = self.plan, self.padding, self.vshape, self.split nchunks = self.getnumber(plan, vshape...
[ "Convert", "a", "chunked", "array", "back", "into", "a", "full", "array", "with", "(", "key", "value", ")", "pairs", "where", "key", "is", "a", "tuple", "of", "indices", "and", "value", "is", "an", "ndarray", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L146-L200
[ "def", "unchunk", "(", "self", ")", ":", "plan", ",", "padding", ",", "vshape", ",", "split", "=", "self", ".", "plan", ",", "self", ".", "padding", ",", "self", ".", "vshape", ",", "self", ".", "split", "nchunks", "=", "self", ".", "getnumber", "(...
9cd7104aa085498da3097b72696184b9d3651c51
test
ChunkedArray.keys_to_values
Move indices in the keys into the values. Padding on these new value-dimensions is not currently supported and is set to 0. Parameters ---------- axes : tuple Axes from keys to move to values. size : tuple, optional, default=None Size of chunks for the ...
bolt/spark/chunk.py
def keys_to_values(self, axes, size=None): """ Move indices in the keys into the values. Padding on these new value-dimensions is not currently supported and is set to 0. Parameters ---------- axes : tuple Axes from keys to move to values. size : tu...
def keys_to_values(self, axes, size=None): """ Move indices in the keys into the values. Padding on these new value-dimensions is not currently supported and is set to 0. Parameters ---------- axes : tuple Axes from keys to move to values. size : tu...
[ "Move", "indices", "in", "the", "keys", "into", "the", "values", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L202-L289
[ "def", "keys_to_values", "(", "self", ",", "axes", ",", "size", "=", "None", ")", ":", "if", "len", "(", "axes", ")", "==", "0", ":", "return", "self", "kmask", "=", "self", ".", "kmask", "(", "axes", ")", "if", "size", "is", "None", ":", "size",...
9cd7104aa085498da3097b72696184b9d3651c51
test
ChunkedArray.map
Apply an array -> array function on each subarray. The function can change the shape of the subarray, but only along dimensions that are not chunked. Parameters ---------- func : function Function of a single subarray to apply value_shape: Known...
bolt/spark/chunk.py
def map(self, func, value_shape=None, dtype=None): """ Apply an array -> array function on each subarray. The function can change the shape of the subarray, but only along dimensions that are not chunked. Parameters ---------- func : function Functio...
def map(self, func, value_shape=None, dtype=None): """ Apply an array -> array function on each subarray. The function can change the shape of the subarray, but only along dimensions that are not chunked. Parameters ---------- func : function Functio...
[ "Apply", "an", "array", "-", ">", "array", "function", "on", "each", "subarray", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L349-L413
[ "def", "map", "(", "self", ",", "func", ",", "value_shape", "=", "None", ",", "dtype", "=", "None", ")", ":", "if", "value_shape", "is", "None", "or", "dtype", "is", "None", ":", "# try to compute the size of each mapped element by applying func to a random array", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
ChunkedArray.map_generic
Apply a generic array -> object to each subarray The resulting object is a BoltArraySpark of dtype object where the blocked dimensions are replaced with indices indication block ID.
bolt/spark/chunk.py
def map_generic(self, func): """ Apply a generic array -> object to each subarray The resulting object is a BoltArraySpark of dtype object where the blocked dimensions are replaced with indices indication block ID. """ def process_record(val): newval = empty(...
def map_generic(self, func): """ Apply a generic array -> object to each subarray The resulting object is a BoltArraySpark of dtype object where the blocked dimensions are replaced with indices indication block ID. """ def process_record(val): newval = empty(...
[ "Apply", "a", "generic", "array", "-", ">", "object", "to", "each", "subarray" ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L415-L432
[ "def", "map_generic", "(", "self", ",", "func", ")", ":", "def", "process_record", "(", "val", ")", ":", "newval", "=", "empty", "(", "1", ",", "dtype", "=", "\"object\"", ")", "newval", "[", "0", "]", "=", "func", "(", "val", ")", "return", "newva...
9cd7104aa085498da3097b72696184b9d3651c51
test
ChunkedArray.getplan
Identify a plan for chunking values along each dimension. Generates an ndarray with the size (in number of elements) of chunks in each dimension. If provided, will estimate chunks for only a subset of axes, leaving all others to the full size of the axis. Parameters ---------- ...
bolt/spark/chunk.py
def getplan(self, size="150", axes=None, padding=None): """ Identify a plan for chunking values along each dimension. Generates an ndarray with the size (in number of elements) of chunks in each dimension. If provided, will estimate chunks for only a subset of axes, leaving all ...
def getplan(self, size="150", axes=None, padding=None): """ Identify a plan for chunking values along each dimension. Generates an ndarray with the size (in number of elements) of chunks in each dimension. If provided, will estimate chunks for only a subset of axes, leaving all ...
[ "Identify", "a", "plan", "for", "chunking", "values", "along", "each", "dimension", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L434-L512
[ "def", "getplan", "(", "self", ",", "size", "=", "\"150\"", ",", "axes", "=", "None", ",", "padding", "=", "None", ")", ":", "from", "numpy", "import", "dtype", "as", "gettype", "# initialize with all elements in one chunk", "plan", "=", "self", ".", "vshape...
9cd7104aa085498da3097b72696184b9d3651c51
test
ChunkedArray.removepad
Remove the padding from chunks. Given a chunk and its corresponding index, use the plan and padding to remove any padding from the chunk along with specified axes. Parameters ---------- idx: tuple or array-like The chunk index, indicating which chunk this is. ...
bolt/spark/chunk.py
def removepad(idx, value, number, padding, axes=None): """ Remove the padding from chunks. Given a chunk and its corresponding index, use the plan and padding to remove any padding from the chunk along with specified axes. Parameters ---------- idx: tuple or arr...
def removepad(idx, value, number, padding, axes=None): """ Remove the padding from chunks. Given a chunk and its corresponding index, use the plan and padding to remove any padding from the chunk along with specified axes. Parameters ---------- idx: tuple or arr...
[ "Remove", "the", "padding", "from", "chunks", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L515-L550
[ "def", "removepad", "(", "idx", ",", "value", ",", "number", ",", "padding", ",", "axes", "=", "None", ")", ":", "if", "axes", "is", "None", ":", "axes", "=", "range", "(", "len", "(", "number", ")", ")", "mask", "=", "len", "(", "number", ")", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
ChunkedArray.getnumber
Obtain number of chunks for the given dimensions and chunk sizes. Given a plan for the number of chunks along each dimension, calculate the number of chunks that this will lead to. Parameters ---------- plan: tuple or array-like Size of chunks (in number of elements...
bolt/spark/chunk.py
def getnumber(plan, shape): """ Obtain number of chunks for the given dimensions and chunk sizes. Given a plan for the number of chunks along each dimension, calculate the number of chunks that this will lead to. Parameters ---------- plan: tuple or array-like ...
def getnumber(plan, shape): """ Obtain number of chunks for the given dimensions and chunk sizes. Given a plan for the number of chunks along each dimension, calculate the number of chunks that this will lead to. Parameters ---------- plan: tuple or array-like ...
[ "Obtain", "number", "of", "chunks", "for", "the", "given", "dimensions", "and", "chunk", "sizes", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L553-L572
[ "def", "getnumber", "(", "plan", ",", "shape", ")", ":", "nchunks", "=", "[", "]", "for", "size", ",", "d", "in", "zip", "(", "plan", ",", "shape", ")", ":", "nchunks", ".", "append", "(", "int", "(", "ceil", "(", "1.0", "*", "d", "/", "size", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
ChunkedArray.getslices
Obtain slices for the given dimensions, padding, and chunks. Given a plan for the number of chunks along each dimension and the amount of padding, calculate a list of slices required to generate those chunks. Parameters ---------- plan: tuple or array-like Size of c...
bolt/spark/chunk.py
def getslices(plan, padding, shape): """ Obtain slices for the given dimensions, padding, and chunks. Given a plan for the number of chunks along each dimension and the amount of padding, calculate a list of slices required to generate those chunks. Parameters ---------...
def getslices(plan, padding, shape): """ Obtain slices for the given dimensions, padding, and chunks. Given a plan for the number of chunks along each dimension and the amount of padding, calculate a list of slices required to generate those chunks. Parameters ---------...
[ "Obtain", "slices", "for", "the", "given", "dimensions", "padding", "and", "chunks", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L575-L618
[ "def", "getslices", "(", "plan", ",", "padding", ",", "shape", ")", ":", "slices", "=", "[", "]", "for", "size", ",", "pad", ",", "d", "in", "zip", "(", "plan", ",", "padding", ",", "shape", ")", ":", "nchunks", "=", "int", "(", "floor", "(", "...
9cd7104aa085498da3097b72696184b9d3651c51
test
ChunkedArray.getmask
Obtain a binary mask by setting a subset of entries to true. Parameters ---------- inds : array-like Which indices to set as true. n : int The length of the target mask.
bolt/spark/chunk.py
def getmask(inds, n): """ Obtain a binary mask by setting a subset of entries to true. Parameters ---------- inds : array-like Which indices to set as true. n : int The length of the target mask. """ inds = asarray(inds, 'int') ...
def getmask(inds, n): """ Obtain a binary mask by setting a subset of entries to true. Parameters ---------- inds : array-like Which indices to set as true. n : int The length of the target mask. """ inds = asarray(inds, 'int') ...
[ "Obtain", "a", "binary", "mask", "by", "setting", "a", "subset", "of", "entries", "to", "true", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/chunk.py#L621-L636
[ "def", "getmask", "(", "inds", ",", "n", ")", ":", "inds", "=", "asarray", "(", "inds", ",", "'int'", ")", "mask", "=", "zeros", "(", "n", ",", "dtype", "=", "bool", ")", "mask", "[", "inds", "]", "=", "True", "return", "mask" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.repartition
Repartitions the underlying RDD Parameters ---------- npartitions : int Number of partitions to repartion the underlying RDD to
bolt/spark/array.py
def repartition(self, npartitions): """ Repartitions the underlying RDD Parameters ---------- npartitions : int Number of partitions to repartion the underlying RDD to """ rdd = self._rdd.repartition(npartitions) return self._constructor(rdd,...
def repartition(self, npartitions): """ Repartitions the underlying RDD Parameters ---------- npartitions : int Number of partitions to repartion the underlying RDD to """ rdd = self._rdd.repartition(npartitions) return self._constructor(rdd,...
[ "Repartitions", "the", "underlying", "RDD" ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L49-L60
[ "def", "repartition", "(", "self", ",", "npartitions", ")", ":", "rdd", "=", "self", ".", "_rdd", ".", "repartition", "(", "npartitions", ")", "return", "self", ".", "_constructor", "(", "rdd", ",", "ordered", "=", "False", ")", ".", "__finalize__", "(",...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.stack
Aggregates records of a distributed array. Stacking should improve the performance of vectorized operations, but the resulting StackedArray object only exposes a restricted set of operations (e.g. map, reduce). The unstack method can be used to restore the full bolt array. Para...
bolt/spark/array.py
def stack(self, size=None): """ Aggregates records of a distributed array. Stacking should improve the performance of vectorized operations, but the resulting StackedArray object only exposes a restricted set of operations (e.g. map, reduce). The unstack method can be used ...
def stack(self, size=None): """ Aggregates records of a distributed array. Stacking should improve the performance of vectorized operations, but the resulting StackedArray object only exposes a restricted set of operations (e.g. map, reduce). The unstack method can be used ...
[ "Aggregates", "records", "of", "a", "distributed", "array", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L62-L83
[ "def", "stack", "(", "self", ",", "size", "=", "None", ")", ":", "stk", "=", "StackedArray", "(", "self", ".", "_rdd", ",", "shape", "=", "self", ".", "shape", ",", "split", "=", "self", ".", "split", ")", "return", "stk", ".", "stack", "(", "siz...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark._align
Align spark bolt array so that axes for iteration are in the keys. This operation is applied before most functional operators. It ensures that the specified axes are valid, and swaps key/value axes so that functional operators can be applied over the correct records. Parameters...
bolt/spark/array.py
def _align(self, axis): """ Align spark bolt array so that axes for iteration are in the keys. This operation is applied before most functional operators. It ensures that the specified axes are valid, and swaps key/value axes so that functional operators can be applied o...
def _align(self, axis): """ Align spark bolt array so that axes for iteration are in the keys. This operation is applied before most functional operators. It ensures that the specified axes are valid, and swaps key/value axes so that functional operators can be applied o...
[ "Align", "spark", "bolt", "array", "so", "that", "axes", "for", "iteration", "are", "in", "the", "keys", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L85-L115
[ "def", "_align", "(", "self", ",", "axis", ")", ":", "# ensure that the specified axes are valid", "inshape", "(", "self", ".", "shape", ",", "axis", ")", "# find the value axes that should be moved into the keys (axis >= split)", "tokeys", "=", "[", "(", "a", "-", "s...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.first
Return the first element of an array
bolt/spark/array.py
def first(self): """ Return the first element of an array """ from bolt.local.array import BoltArrayLocal rdd = self._rdd if self._ordered else self._rdd.sortByKey() return BoltArrayLocal(rdd.values().first())
def first(self): """ Return the first element of an array """ from bolt.local.array import BoltArrayLocal rdd = self._rdd if self._ordered else self._rdd.sortByKey() return BoltArrayLocal(rdd.values().first())
[ "Return", "the", "first", "element", "of", "an", "array" ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L117-L123
[ "def", "first", "(", "self", ")", ":", "from", "bolt", ".", "local", ".", "array", "import", "BoltArrayLocal", "rdd", "=", "self", ".", "_rdd", "if", "self", ".", "_ordered", "else", "self", ".", "_rdd", ".", "sortByKey", "(", ")", "return", "BoltArray...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.map
Apply a function across an axis. Array will be aligned so that the desired set of axes are in the keys, which may incur a swap. Parameters ---------- func : function Function of a single array to apply. If with_keys=True, function should be of a (tuple, ...
bolt/spark/array.py
def map(self, func, axis=(0,), value_shape=None, dtype=None, with_keys=False): """ Apply a function across an axis. Array will be aligned so that the desired set of axes are in the keys, which may incur a swap. Parameters ---------- func : function F...
def map(self, func, axis=(0,), value_shape=None, dtype=None, with_keys=False): """ Apply a function across an axis. Array will be aligned so that the desired set of axes are in the keys, which may incur a swap. Parameters ---------- func : function F...
[ "Apply", "a", "function", "across", "an", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L125-L191
[ "def", "map", "(", "self", ",", "func", ",", "axis", "=", "(", "0", ",", ")", ",", "value_shape", "=", "None", ",", "dtype", "=", "None", ",", "with_keys", "=", "False", ")", ":", "axis", "=", "tupleize", "(", "axis", ")", "swapped", "=", "self",...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.filter
Filter array along an axis. Applies a function which should evaluate to boolean, along a single axis or multiple axes. Array will be aligned so that the desired set of axes are in the keys, which may incur a swap. Parameters ---------- func : function ...
bolt/spark/array.py
def filter(self, func, axis=(0,), sort=False): """ Filter array along an axis. Applies a function which should evaluate to boolean, along a single axis or multiple axes. Array will be aligned so that the desired set of axes are in the keys, which may incur a swap. ...
def filter(self, func, axis=(0,), sort=False): """ Filter array along an axis. Applies a function which should evaluate to boolean, along a single axis or multiple axes. Array will be aligned so that the desired set of axes are in the keys, which may incur a swap. ...
[ "Filter", "array", "along", "an", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L193-L241
[ "def", "filter", "(", "self", ",", "func", ",", "axis", "=", "(", "0", ",", ")", ",", "sort", "=", "False", ")", ":", "axis", "=", "tupleize", "(", "axis", ")", "swapped", "=", "self", ".", "_align", "(", "axis", ")", "def", "f", "(", "record",...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.reduce
Reduce an array along an axis. Applies a commutative/associative function of two arguments cumulatively to all arrays along an axis. Array will be aligned so that the desired set of axes are in the keys, which may incur a swap. Parameters ---------- func : funct...
bolt/spark/array.py
def reduce(self, func, axis=(0,), keepdims=False): """ Reduce an array along an axis. Applies a commutative/associative function of two arguments cumulatively to all arrays along an axis. Array will be aligned so that the desired set of axes are in the keys, which may in...
def reduce(self, func, axis=(0,), keepdims=False): """ Reduce an array along an axis. Applies a commutative/associative function of two arguments cumulatively to all arrays along an axis. Array will be aligned so that the desired set of axes are in the keys, which may in...
[ "Reduce", "an", "array", "along", "an", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L243-L282
[ "def", "reduce", "(", "self", ",", "func", ",", "axis", "=", "(", "0", ",", ")", ",", "keepdims", "=", "False", ")", ":", "from", "bolt", ".", "local", ".", "array", "import", "BoltArrayLocal", "from", "numpy", "import", "ndarray", "axis", "=", "tupl...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark._stat
Compute a statistic over an axis. Can provide either a function (for use in a reduce) or a name (for use by a stat counter). Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all a...
bolt/spark/array.py
def _stat(self, axis=None, func=None, name=None, keepdims=False): """ Compute a statistic over an axis. Can provide either a function (for use in a reduce) or a name (for use by a stat counter). Parameters ---------- axis : tuple or int, optional, default=None ...
def _stat(self, axis=None, func=None, name=None, keepdims=False): """ Compute a statistic over an axis. Can provide either a function (for use in a reduce) or a name (for use by a stat counter). Parameters ---------- axis : tuple or int, optional, default=None ...
[ "Compute", "a", "statistic", "over", "an", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L284-L334
[ "def", "_stat", "(", "self", ",", "axis", "=", "None", ",", "func", "=", "None", ",", "name", "=", "None", ",", "keepdims", "=", "False", ")", ":", "if", "axis", "is", "None", ":", "axis", "=", "list", "(", "range", "(", "len", "(", "self", "."...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.mean
Return the mean of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boolean, optional, default=False Keep axis remaining aft...
bolt/spark/array.py
def mean(self, axis=None, keepdims=False): """ Return the mean of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boole...
def mean(self, axis=None, keepdims=False): """ Return the mean of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boole...
[ "Return", "the", "mean", "of", "the", "array", "over", "the", "given", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L336-L349
[ "def", "mean", "(", "self", ",", "axis", "=", "None", ",", "keepdims", "=", "False", ")", ":", "return", "self", ".", "_stat", "(", "axis", ",", "name", "=", "'mean'", ",", "keepdims", "=", "keepdims", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.var
Return the variance of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boolean, optional, default=False Keep axis remaining...
bolt/spark/array.py
def var(self, axis=None, keepdims=False): """ Return the variance of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : bo...
def var(self, axis=None, keepdims=False): """ Return the variance of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : bo...
[ "Return", "the", "variance", "of", "the", "array", "over", "the", "given", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L351-L364
[ "def", "var", "(", "self", ",", "axis", "=", "None", ",", "keepdims", "=", "False", ")", ":", "return", "self", ".", "_stat", "(", "axis", ",", "name", "=", "'variance'", ",", "keepdims", "=", "keepdims", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.std
Return the standard deviation of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boolean, optional, default=False Keep axis...
bolt/spark/array.py
def std(self, axis=None, keepdims=False): """ Return the standard deviation of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes kee...
def std(self, axis=None, keepdims=False): """ Return the standard deviation of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes kee...
[ "Return", "the", "standard", "deviation", "of", "the", "array", "over", "the", "given", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L366-L379
[ "def", "std", "(", "self", ",", "axis", "=", "None", ",", "keepdims", "=", "False", ")", ":", "return", "self", ".", "_stat", "(", "axis", ",", "name", "=", "'stdev'", ",", "keepdims", "=", "keepdims", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.sum
Return the sum of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boolean, optional, default=False Keep axis remaining afte...
bolt/spark/array.py
def sum(self, axis=None, keepdims=False): """ Return the sum of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boolean...
def sum(self, axis=None, keepdims=False): """ Return the sum of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boolean...
[ "Return", "the", "sum", "of", "the", "array", "over", "the", "given", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L381-L395
[ "def", "sum", "(", "self", ",", "axis", "=", "None", ",", "keepdims", "=", "False", ")", ":", "from", "operator", "import", "add", "return", "self", ".", "_stat", "(", "axis", ",", "func", "=", "add", ",", "keepdims", "=", "keepdims", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.max
Return the maximum of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boolean, optional, default=False Keep axis remaining ...
bolt/spark/array.py
def max(self, axis=None, keepdims=False): """ Return the maximum of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boo...
def max(self, axis=None, keepdims=False): """ Return the maximum of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boo...
[ "Return", "the", "maximum", "of", "the", "array", "over", "the", "given", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L397-L411
[ "def", "max", "(", "self", ",", "axis", "=", "None", ",", "keepdims", "=", "False", ")", ":", "from", "numpy", "import", "maximum", "return", "self", ".", "_stat", "(", "axis", ",", "func", "=", "maximum", ",", "keepdims", "=", "keepdims", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.min
Return the minimum of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boolean, optional, default=False Keep axis remaining ...
bolt/spark/array.py
def min(self, axis=None, keepdims=False): """ Return the minimum of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boo...
def min(self, axis=None, keepdims=False): """ Return the minimum of the array over the given axis. Parameters ---------- axis : tuple or int, optional, default=None Axis to compute statistic over, if None will compute over all axes keepdims : boo...
[ "Return", "the", "minimum", "of", "the", "array", "over", "the", "given", "axis", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L413-L427
[ "def", "min", "(", "self", ",", "axis", "=", "None", ",", "keepdims", "=", "False", ")", ":", "from", "numpy", "import", "minimum", "return", "self", ".", "_stat", "(", "axis", ",", "func", "=", "minimum", ",", "keepdims", "=", "keepdims", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.concatenate
Join this array with another array. Paramters --------- arry : ndarray, BoltArrayLocal, or BoltArraySpark Another array to concatenate with axis : int, optional, default=0 The axis along which arrays will be joined. Returns ------- BoltA...
bolt/spark/array.py
def concatenate(self, arry, axis=0): """ Join this array with another array. Paramters --------- arry : ndarray, BoltArrayLocal, or BoltArraySpark Another array to concatenate with axis : int, optional, default=0 The axis along which arrays will ...
def concatenate(self, arry, axis=0): """ Join this array with another array. Paramters --------- arry : ndarray, BoltArrayLocal, or BoltArraySpark Another array to concatenate with axis : int, optional, default=0 The axis along which arrays will ...
[ "Join", "this", "array", "with", "another", "array", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L429-L478
[ "def", "concatenate", "(", "self", ",", "arry", ",", "axis", "=", "0", ")", ":", "if", "isinstance", "(", "arry", ",", "ndarray", ")", ":", "from", "bolt", ".", "spark", ".", "construct", "import", "ConstructSpark", "arry", "=", "ConstructSpark", ".", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark._getbasic
Basic indexing (for slices or ints).
bolt/spark/array.py
def _getbasic(self, index): """ Basic indexing (for slices or ints). """ key_slices = index[0:self.split] value_slices = index[self.split:] def key_check(key): def inrange(k, s): if s.step > 0: return s.start <= k < s.stop ...
def _getbasic(self, index): """ Basic indexing (for slices or ints). """ key_slices = index[0:self.split] value_slices = index[self.split:] def key_check(key): def inrange(k, s): if s.step > 0: return s.start <= k < s.stop ...
[ "Basic", "indexing", "(", "for", "slices", "or", "ints", ")", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L480-L512
[ "def", "_getbasic", "(", "self", ",", "index", ")", ":", "key_slices", "=", "index", "[", "0", ":", "self", ".", "split", "]", "value_slices", "=", "index", "[", "self", ".", "split", ":", "]", "def", "key_check", "(", "key", ")", ":", "def", "inra...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark._getadvanced
Advanced indexing (for sets, lists, or ndarrays).
bolt/spark/array.py
def _getadvanced(self, index): """ Advanced indexing (for sets, lists, or ndarrays). """ index = [asarray(i) for i in index] shape = index[0].shape if not all([i.shape == shape for i in index]): raise ValueError("shape mismatch: indexing arrays could not be br...
def _getadvanced(self, index): """ Advanced indexing (for sets, lists, or ndarrays). """ index = [asarray(i) for i in index] shape = index[0].shape if not all([i.shape == shape for i in index]): raise ValueError("shape mismatch: indexing arrays could not be br...
[ "Advanced", "indexing", "(", "for", "sets", "lists", "or", "ndarrays", ")", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L514-L556
[ "def", "_getadvanced", "(", "self", ",", "index", ")", ":", "index", "=", "[", "asarray", "(", "i", ")", "for", "i", "in", "index", "]", "shape", "=", "index", "[", "0", "]", ".", "shape", "if", "not", "all", "(", "[", "i", ".", "shape", "==", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark._getmixed
Mixed indexing (combines basic and advanced indexes) Assumes that only a single advanced index is used, due to the complicated behavior needed to be compatible with NumPy otherwise.
bolt/spark/array.py
def _getmixed(self, index): """ Mixed indexing (combines basic and advanced indexes) Assumes that only a single advanced index is used, due to the complicated behavior needed to be compatible with NumPy otherwise. """ # find the single advanced index loc = where(...
def _getmixed(self, index): """ Mixed indexing (combines basic and advanced indexes) Assumes that only a single advanced index is used, due to the complicated behavior needed to be compatible with NumPy otherwise. """ # find the single advanced index loc = where(...
[ "Mixed", "indexing", "(", "combines", "basic", "and", "advanced", "indexes", ")" ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L558-L593
[ "def", "_getmixed", "(", "self", ",", "index", ")", ":", "# find the single advanced index", "loc", "=", "where", "(", "[", "isinstance", "(", "i", ",", "(", "tuple", ",", "list", ",", "ndarray", ")", ")", "for", "i", "in", "index", "]", ")", "[", "0...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.chunk
Chunks records of a distributed array. Chunking breaks arrays into subarrays, using an specified size of chunks along each value dimension. Can alternatively specify an average chunk byte size (in kilobytes) and the size of chunks (as ints) will be computed automatically. Param...
bolt/spark/array.py
def chunk(self, size="150", axis=None, padding=None): """ Chunks records of a distributed array. Chunking breaks arrays into subarrays, using an specified size of chunks along each value dimension. Can alternatively specify an average chunk byte size (in kilobytes) and the size ...
def chunk(self, size="150", axis=None, padding=None): """ Chunks records of a distributed array. Chunking breaks arrays into subarrays, using an specified size of chunks along each value dimension. Can alternatively specify an average chunk byte size (in kilobytes) and the size ...
[ "Chunks", "records", "of", "a", "distributed", "array", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L678-L714
[ "def", "chunk", "(", "self", ",", "size", "=", "\"150\"", ",", "axis", "=", "None", ",", "padding", "=", "None", ")", ":", "if", "type", "(", "size", ")", "is", "not", "str", ":", "size", "=", "tupleize", "(", "(", "size", ")", ")", "axis", "="...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.swap
Swap axes from keys to values. This is the core operation underlying shape manipulation on the Spark bolt array. It exchanges an arbitrary set of axes between the keys and the valeus. If either is None, will only move axes in one direction (from keys to values, or values to keys). ...
bolt/spark/array.py
def swap(self, kaxes, vaxes, size="150"): """ Swap axes from keys to values. This is the core operation underlying shape manipulation on the Spark bolt array. It exchanges an arbitrary set of axes between the keys and the valeus. If either is None, will only move axes in...
def swap(self, kaxes, vaxes, size="150"): """ Swap axes from keys to values. This is the core operation underlying shape manipulation on the Spark bolt array. It exchanges an arbitrary set of axes between the keys and the valeus. If either is None, will only move axes in...
[ "Swap", "axes", "from", "keys", "to", "values", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L716-L763
[ "def", "swap", "(", "self", ",", "kaxes", ",", "vaxes", ",", "size", "=", "\"150\"", ")", ":", "kaxes", "=", "asarray", "(", "tupleize", "(", "kaxes", ")", ",", "'int'", ")", "vaxes", "=", "asarray", "(", "tupleize", "(", "vaxes", ")", ",", "'int'"...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.transpose
Return an array with the axes transposed. This operation will incur a swap unless the desiured permutation can be obtained only by transpoing the keys or the values. Parameters ---------- axes : None, tuple of ints, or n ints If None, will reverse axis order...
bolt/spark/array.py
def transpose(self, *axes): """ Return an array with the axes transposed. This operation will incur a swap unless the desiured permutation can be obtained only by transpoing the keys or the values. Parameters ---------- axes : None, tuple of ints, or n i...
def transpose(self, *axes): """ Return an array with the axes transposed. This operation will incur a swap unless the desiured permutation can be obtained only by transpoing the keys or the values. Parameters ---------- axes : None, tuple of ints, or n i...
[ "Return", "an", "array", "with", "the", "axes", "transposed", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L765-L808
[ "def", "transpose", "(", "self", ",", "*", "axes", ")", ":", "if", "len", "(", "axes", ")", "==", "0", ":", "p", "=", "arange", "(", "self", ".", "ndim", "-", "1", ",", "-", "1", ",", "-", "1", ")", "else", ":", "p", "=", "asarray", "(", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.swapaxes
Return the array with two axes interchanged. Parameters ---------- axis1 : int The first axis to swap axis2 : int The second axis to swap
bolt/spark/array.py
def swapaxes(self, axis1, axis2): """ Return the array with two axes interchanged. Parameters ---------- axis1 : int The first axis to swap axis2 : int The second axis to swap """ p = list(range(self.ndim)) p[axis1] = axis...
def swapaxes(self, axis1, axis2): """ Return the array with two axes interchanged. Parameters ---------- axis1 : int The first axis to swap axis2 : int The second axis to swap """ p = list(range(self.ndim)) p[axis1] = axis...
[ "Return", "the", "array", "with", "two", "axes", "interchanged", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L817-L833
[ "def", "swapaxes", "(", "self", ",", "axis1", ",", "axis2", ")", ":", "p", "=", "list", "(", "range", "(", "self", ".", "ndim", ")", ")", "p", "[", "axis1", "]", "=", "axis2", "p", "[", "axis2", "]", "=", "axis1", "return", "self", ".", "transp...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.reshape
Return an array with the same data but a new shape. Currently only supports reshaping that independently reshapes the keys, or the values, or both. Parameters ---------- shape : tuple of ints, or n ints New shape
bolt/spark/array.py
def reshape(self, *shape): """ Return an array with the same data but a new shape. Currently only supports reshaping that independently reshapes the keys, or the values, or both. Parameters ---------- shape : tuple of ints, or n ints New shape ...
def reshape(self, *shape): """ Return an array with the same data but a new shape. Currently only supports reshaping that independently reshapes the keys, or the values, or both. Parameters ---------- shape : tuple of ints, or n ints New shape ...
[ "Return", "an", "array", "with", "the", "same", "data", "but", "a", "new", "shape", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L835-L859
[ "def", "reshape", "(", "self", ",", "*", "shape", ")", ":", "new", "=", "argpack", "(", "shape", ")", "isreshapeable", "(", "new", ",", "self", ".", "shape", ")", "if", "new", "==", "self", ".", "shape", ":", "return", "self", "i", "=", "self", "...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark._reshapebasic
Check if the requested reshape can be broken into independant reshapes on the keys and values. If it can, returns the index in the new shape separating keys from values, otherwise returns -1
bolt/spark/array.py
def _reshapebasic(self, shape): """ Check if the requested reshape can be broken into independant reshapes on the keys and values. If it can, returns the index in the new shape separating keys from values, otherwise returns -1 """ new = tupleize(shape) old_key_siz...
def _reshapebasic(self, shape): """ Check if the requested reshape can be broken into independant reshapes on the keys and values. If it can, returns the index in the new shape separating keys from values, otherwise returns -1 """ new = tupleize(shape) old_key_siz...
[ "Check", "if", "the", "requested", "reshape", "can", "be", "broken", "into", "independant", "reshapes", "on", "the", "keys", "and", "values", ".", "If", "it", "can", "returns", "the", "index", "in", "the", "new", "shape", "separating", "keys", "from", "val...
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L861-L877
[ "def", "_reshapebasic", "(", "self", ",", "shape", ")", ":", "new", "=", "tupleize", "(", "shape", ")", "old_key_size", "=", "prod", "(", "self", ".", "keys", ".", "shape", ")", "old_value_size", "=", "prod", "(", "self", ".", "values", ".", "shape", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.squeeze
Remove one or more single-dimensional axes from the array. Parameters ---------- axis : tuple or int One or more singleton axes to remove.
bolt/spark/array.py
def squeeze(self, axis=None): """ Remove one or more single-dimensional axes from the array. Parameters ---------- axis : tuple or int One or more singleton axes to remove. """ if not any([d == 1 for d in self.shape]): return self ...
def squeeze(self, axis=None): """ Remove one or more single-dimensional axes from the array. Parameters ---------- axis : tuple or int One or more singleton axes to remove. """ if not any([d == 1 for d in self.shape]): return self ...
[ "Remove", "one", "or", "more", "single", "-", "dimensional", "axes", "from", "the", "array", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L879-L918
[ "def", "squeeze", "(", "self", ",", "axis", "=", "None", ")", ":", "if", "not", "any", "(", "[", "d", "==", "1", "for", "d", "in", "self", ".", "shape", "]", ")", ":", "return", "self", "if", "axis", "is", "None", ":", "drop", "=", "where", "...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.astype
Cast the array to a specified type. Parameters ---------- dtype : str or dtype Typecode or data-type to cast the array to (see numpy)
bolt/spark/array.py
def astype(self, dtype, casting='unsafe'): """ Cast the array to a specified type. Parameters ---------- dtype : str or dtype Typecode or data-type to cast the array to (see numpy) """ rdd = self._rdd.mapValues(lambda v: v.astype(dtype, 'K', casting))...
def astype(self, dtype, casting='unsafe'): """ Cast the array to a specified type. Parameters ---------- dtype : str or dtype Typecode or data-type to cast the array to (see numpy) """ rdd = self._rdd.mapValues(lambda v: v.astype(dtype, 'K', casting))...
[ "Cast", "the", "array", "to", "a", "specified", "type", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L920-L930
[ "def", "astype", "(", "self", ",", "dtype", ",", "casting", "=", "'unsafe'", ")", ":", "rdd", "=", "self", ".", "_rdd", ".", "mapValues", "(", "lambda", "v", ":", "v", ".", "astype", "(", "dtype", ",", "'K'", ",", "casting", ")", ")", "return", "...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.clip
Clip values above and below. Parameters ---------- min : scalar or array-like Minimum value. If array, will be broadcasted max : scalar or array-like Maximum value. If array, will be broadcasted.
bolt/spark/array.py
def clip(self, min=None, max=None): """ Clip values above and below. Parameters ---------- min : scalar or array-like Minimum value. If array, will be broadcasted max : scalar or array-like Maximum value. If array, will be broadcasted. ""...
def clip(self, min=None, max=None): """ Clip values above and below. Parameters ---------- min : scalar or array-like Minimum value. If array, will be broadcasted max : scalar or array-like Maximum value. If array, will be broadcasted. ""...
[ "Clip", "values", "above", "and", "below", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L932-L945
[ "def", "clip", "(", "self", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "rdd", "=", "self", ".", "_rdd", ".", "mapValues", "(", "lambda", "v", ":", "v", ".", "clip", "(", "min", "=", "min", ",", "max", "=", "max", ")", ")", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
BoltArraySpark.toarray
Returns the contents as a local array. Will likely cause memory problems for large objects.
bolt/spark/array.py
def toarray(self): """ Returns the contents as a local array. Will likely cause memory problems for large objects. """ rdd = self._rdd if self._ordered else self._rdd.sortByKey() x = rdd.values().collect() return asarray(x).reshape(self.shape)
def toarray(self): """ Returns the contents as a local array. Will likely cause memory problems for large objects. """ rdd = self._rdd if self._ordered else self._rdd.sortByKey() x = rdd.values().collect() return asarray(x).reshape(self.shape)
[ "Returns", "the", "contents", "as", "a", "local", "array", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/array.py#L1006-L1014
[ "def", "toarray", "(", "self", ")", ":", "rdd", "=", "self", ".", "_rdd", "if", "self", ".", "_ordered", "else", "self", ".", "_rdd", ".", "sortByKey", "(", ")", "x", "=", "rdd", ".", "values", "(", ")", ".", "collect", "(", ")", "return", "asarr...
9cd7104aa085498da3097b72696184b9d3651c51
test
tupleize
Coerce singletons and lists and ndarrays to tuples. Parameters ---------- arg : tuple, list, ndarray, or singleton Item to coerce
bolt/utils.py
def tupleize(arg): """ Coerce singletons and lists and ndarrays to tuples. Parameters ---------- arg : tuple, list, ndarray, or singleton Item to coerce """ if arg is None: return None if not isinstance(arg, (tuple, list, ndarray, Iterable)): return tuple((arg,))...
def tupleize(arg): """ Coerce singletons and lists and ndarrays to tuples. Parameters ---------- arg : tuple, list, ndarray, or singleton Item to coerce """ if arg is None: return None if not isinstance(arg, (tuple, list, ndarray, Iterable)): return tuple((arg,))...
[ "Coerce", "singletons", "and", "lists", "and", "ndarrays", "to", "tuples", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L5-L23
[ "def", "tupleize", "(", "arg", ")", ":", "if", "arg", "is", "None", ":", "return", "None", "if", "not", "isinstance", "(", "arg", ",", "(", "tuple", ",", "list", ",", "ndarray", ",", "Iterable", ")", ")", ":", "return", "tuple", "(", "(", "arg", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
argpack
Coerce a list of arguments to a tuple. Parameters ---------- args : tuple or nested tuple Pack arguments into a tuple, converting ((,...),) or (,) -> (,)
bolt/utils.py
def argpack(args): """ Coerce a list of arguments to a tuple. Parameters ---------- args : tuple or nested tuple Pack arguments into a tuple, converting ((,...),) or (,) -> (,) """ if isinstance(args[0], (tuple, list, ndarray)): return tupleize(args[0]) elif isinstance(a...
def argpack(args): """ Coerce a list of arguments to a tuple. Parameters ---------- args : tuple or nested tuple Pack arguments into a tuple, converting ((,...),) or (,) -> (,) """ if isinstance(args[0], (tuple, list, ndarray)): return tupleize(args[0]) elif isinstance(a...
[ "Coerce", "a", "list", "of", "arguments", "to", "a", "tuple", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L25-L40
[ "def", "argpack", "(", "args", ")", ":", "if", "isinstance", "(", "args", "[", "0", "]", ",", "(", "tuple", ",", "list", ",", "ndarray", ")", ")", ":", "return", "tupleize", "(", "args", "[", "0", "]", ")", "elif", "isinstance", "(", "args", "[",...
9cd7104aa085498da3097b72696184b9d3651c51
test
inshape
Checks to see if a list of axes are contained within an array shape. Parameters ---------- shape : tuple[int] the shape of a BoltArray axes : tuple[int] the axes to check against shape
bolt/utils.py
def inshape(shape, axes): """ Checks to see if a list of axes are contained within an array shape. Parameters ---------- shape : tuple[int] the shape of a BoltArray axes : tuple[int] the axes to check against shape """ valid = all([(axis < len(shape)) and (axis >= 0) fo...
def inshape(shape, axes): """ Checks to see if a list of axes are contained within an array shape. Parameters ---------- shape : tuple[int] the shape of a BoltArray axes : tuple[int] the axes to check against shape """ valid = all([(axis < len(shape)) and (axis >= 0) fo...
[ "Checks", "to", "see", "if", "a", "list", "of", "axes", "are", "contained", "within", "an", "array", "shape", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L42-L56
[ "def", "inshape", "(", "shape", ",", "axes", ")", ":", "valid", "=", "all", "(", "[", "(", "axis", "<", "len", "(", "shape", ")", ")", "and", "(", "axis", ">=", "0", ")", "for", "axis", "in", "axes", "]", ")", "if", "not", "valid", ":", "rais...
9cd7104aa085498da3097b72696184b9d3651c51
test
allclose
Test that a and b are close and match in shape. Parameters ---------- a : ndarray First array to check b : ndarray First array to check
bolt/utils.py
def allclose(a, b): """ Test that a and b are close and match in shape. Parameters ---------- a : ndarray First array to check b : ndarray First array to check """ from numpy import allclose return (a.shape == b.shape) and allclose(a, b)
def allclose(a, b): """ Test that a and b are close and match in shape. Parameters ---------- a : ndarray First array to check b : ndarray First array to check """ from numpy import allclose return (a.shape == b.shape) and allclose(a, b)
[ "Test", "that", "a", "and", "b", "are", "close", "and", "match", "in", "shape", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L58-L71
[ "def", "allclose", "(", "a", ",", "b", ")", ":", "from", "numpy", "import", "allclose", "return", "(", "a", ".", "shape", "==", "b", ".", "shape", ")", "and", "allclose", "(", "a", ",", "b", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
listify
Flatten lists of indices and ensure bounded by a known dim. Parameters ---------- lst : list List of integer indices dim : tuple Bounds for indices
bolt/utils.py
def listify(lst, dim): """ Flatten lists of indices and ensure bounded by a known dim. Parameters ---------- lst : list List of integer indices dim : tuple Bounds for indices """ if not all([l.dtype == int for l in lst]): raise ValueError("indices must be intege...
def listify(lst, dim): """ Flatten lists of indices and ensure bounded by a known dim. Parameters ---------- lst : list List of integer indices dim : tuple Bounds for indices """ if not all([l.dtype == int for l in lst]): raise ValueError("indices must be intege...
[ "Flatten", "lists", "of", "indices", "and", "ensure", "bounded", "by", "a", "known", "dim", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L85-L103
[ "def", "listify", "(", "lst", ",", "dim", ")", ":", "if", "not", "all", "(", "[", "l", ".", "dtype", "==", "int", "for", "l", "in", "lst", "]", ")", ":", "raise", "ValueError", "(", "\"indices must be integers\"", ")", "if", "npany", "(", "asarray", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
slicify
Force a slice to have defined start, stop, and step from a known dim. Start and stop will always be positive. Step may be negative. There is an exception where a negative step overflows the stop needs to have the default value set to -1. This is the only case of a negative start/stop value. Parame...
bolt/utils.py
def slicify(slc, dim): """ Force a slice to have defined start, stop, and step from a known dim. Start and stop will always be positive. Step may be negative. There is an exception where a negative step overflows the stop needs to have the default value set to -1. This is the only case of a negativ...
def slicify(slc, dim): """ Force a slice to have defined start, stop, and step from a known dim. Start and stop will always be positive. Step may be negative. There is an exception where a negative step overflows the stop needs to have the default value set to -1. This is the only case of a negativ...
[ "Force", "a", "slice", "to", "have", "defined", "start", "stop", "and", "step", "from", "a", "known", "dim", ".", "Start", "and", "stop", "will", "always", "be", "positive", ".", "Step", "may", "be", "negative", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L105-L147
[ "def", "slicify", "(", "slc", ",", "dim", ")", ":", "if", "isinstance", "(", "slc", ",", "slice", ")", ":", "# default limits", "start", "=", "0", "if", "slc", ".", "start", "is", "None", "else", "slc", ".", "start", "stop", "=", "dim", "if", "slc"...
9cd7104aa085498da3097b72696184b9d3651c51
test
istransposeable
Check to see if a proposed tuple of axes is a valid permutation of an old set of axes. Checks length, axis repetion, and bounds. Parameters ---------- new : tuple tuple of proposed axes old : tuple tuple of old axes
bolt/utils.py
def istransposeable(new, old): """ Check to see if a proposed tuple of axes is a valid permutation of an old set of axes. Checks length, axis repetion, and bounds. Parameters ---------- new : tuple tuple of proposed axes old : tuple tuple of old axes """ new, old =...
def istransposeable(new, old): """ Check to see if a proposed tuple of axes is a valid permutation of an old set of axes. Checks length, axis repetion, and bounds. Parameters ---------- new : tuple tuple of proposed axes old : tuple tuple of old axes """ new, old =...
[ "Check", "to", "see", "if", "a", "proposed", "tuple", "of", "axes", "is", "a", "valid", "permutation", "of", "an", "old", "set", "of", "axes", ".", "Checks", "length", "axis", "repetion", "and", "bounds", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L149-L172
[ "def", "istransposeable", "(", "new", ",", "old", ")", ":", "new", ",", "old", "=", "tupleize", "(", "new", ")", ",", "tupleize", "(", "old", ")", "if", "not", "len", "(", "new", ")", "==", "len", "(", "old", ")", ":", "raise", "ValueError", "(",...
9cd7104aa085498da3097b72696184b9d3651c51
test
isreshapeable
Check to see if a proposed tuple of axes is a valid reshaping of the old axes by ensuring that they can be factored. Parameters ---------- new : tuple tuple of proposed axes old : tuple tuple of old axes
bolt/utils.py
def isreshapeable(new, old): """ Check to see if a proposed tuple of axes is a valid reshaping of the old axes by ensuring that they can be factored. Parameters ---------- new : tuple tuple of proposed axes old : tuple tuple of old axes """ new, old = tupleize(new)...
def isreshapeable(new, old): """ Check to see if a proposed tuple of axes is a valid reshaping of the old axes by ensuring that they can be factored. Parameters ---------- new : tuple tuple of proposed axes old : tuple tuple of old axes """ new, old = tupleize(new)...
[ "Check", "to", "see", "if", "a", "proposed", "tuple", "of", "axes", "is", "a", "valid", "reshaping", "of", "the", "old", "axes", "by", "ensuring", "that", "they", "can", "be", "factored", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L174-L191
[ "def", "isreshapeable", "(", "new", ",", "old", ")", ":", "new", ",", "old", "=", "tupleize", "(", "new", ")", ",", "tupleize", "(", "old", ")", "if", "not", "prod", "(", "new", ")", "==", "prod", "(", "old", ")", ":", "raise", "ValueError", "(",...
9cd7104aa085498da3097b72696184b9d3651c51
test
allstack
If an ndarray has been split into multiple chunks by splitting it along each axis at a number of locations, this function rebuilds the original array from chunks. Parameters ---------- vals : nested lists of ndarrays each level of nesting of the lists representing a dimension of the...
bolt/utils.py
def allstack(vals, depth=0): """ If an ndarray has been split into multiple chunks by splitting it along each axis at a number of locations, this function rebuilds the original array from chunks. Parameters ---------- vals : nested lists of ndarrays each level of nesting of the list...
def allstack(vals, depth=0): """ If an ndarray has been split into multiple chunks by splitting it along each axis at a number of locations, this function rebuilds the original array from chunks. Parameters ---------- vals : nested lists of ndarrays each level of nesting of the list...
[ "If", "an", "ndarray", "has", "been", "split", "into", "multiple", "chunks", "by", "splitting", "it", "along", "each", "axis", "at", "a", "number", "of", "locations", "this", "function", "rebuilds", "the", "original", "array", "from", "chunks", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L193-L208
[ "def", "allstack", "(", "vals", ",", "depth", "=", "0", ")", ":", "if", "type", "(", "vals", "[", "0", "]", ")", "is", "ndarray", ":", "return", "concatenate", "(", "vals", ",", "axis", "=", "depth", ")", "else", ":", "return", "concatenate", "(", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
iterexpand
Expand dimensions by iteratively append empty axes. Parameters ---------- arry : ndarray The original array extra : int The number of empty axes to append
bolt/utils.py
def iterexpand(arry, extra): """ Expand dimensions by iteratively append empty axes. Parameters ---------- arry : ndarray The original array extra : int The number of empty axes to append """ for d in range(arry.ndim, arry.ndim+extra): arry = expand_dims(arry, a...
def iterexpand(arry, extra): """ Expand dimensions by iteratively append empty axes. Parameters ---------- arry : ndarray The original array extra : int The number of empty axes to append """ for d in range(arry.ndim, arry.ndim+extra): arry = expand_dims(arry, a...
[ "Expand", "dimensions", "by", "iteratively", "append", "empty", "axes", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L210-L224
[ "def", "iterexpand", "(", "arry", ",", "extra", ")", ":", "for", "d", "in", "range", "(", "arry", ".", "ndim", ",", "arry", ".", "ndim", "+", "extra", ")", ":", "arry", "=", "expand_dims", "(", "arry", ",", "axis", "=", "d", ")", "return", "arry"...
9cd7104aa085498da3097b72696184b9d3651c51
test
zip_with_index
Alternate version of Spark's zipWithIndex that eagerly returns count.
bolt/spark/utils.py
def zip_with_index(rdd): """ Alternate version of Spark's zipWithIndex that eagerly returns count. """ starts = [0] if rdd.getNumPartitions() > 1: nums = rdd.mapPartitions(lambda it: [sum(1 for _ in it)]).collect() count = sum(nums) for i in range(len(nums) - 1): ...
def zip_with_index(rdd): """ Alternate version of Spark's zipWithIndex that eagerly returns count. """ starts = [0] if rdd.getNumPartitions() > 1: nums = rdd.mapPartitions(lambda it: [sum(1 for _ in it)]).collect() count = sum(nums) for i in range(len(nums) - 1): ...
[ "Alternate", "version", "of", "Spark", "s", "zipWithIndex", "that", "eagerly", "returns", "count", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/utils.py#L14-L31
[ "def", "zip_with_index", "(", "rdd", ")", ":", "starts", "=", "[", "0", "]", "if", "rdd", ".", "getNumPartitions", "(", ")", ">", "1", ":", "nums", "=", "rdd", ".", "mapPartitions", "(", "lambda", "it", ":", "[", "sum", "(", "1", "for", "_", "in"...
9cd7104aa085498da3097b72696184b9d3651c51
test
wrapped
Decorator to append routed docstrings
bolt/factory.py
def wrapped(f): """ Decorator to append routed docstrings """ import inspect def extract(func): append = "" args = inspect.getargspec(func) for i, a in enumerate(args.args): if i < (len(args) - len(args.defaults)): append += str(a) + ", " ...
def wrapped(f): """ Decorator to append routed docstrings """ import inspect def extract(func): append = "" args = inspect.getargspec(func) for i, a in enumerate(args.args): if i < (len(args) - len(args.defaults)): append += str(a) + ", " ...
[ "Decorator", "to", "append", "routed", "docstrings" ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/factory.py#L9-L35
[ "def", "wrapped", "(", "f", ")", ":", "import", "inspect", "def", "extract", "(", "func", ")", ":", "append", "=", "\"\"", "args", "=", "inspect", ".", "getargspec", "(", "func", ")", "for", "i", ",", "a", "in", "enumerate", "(", "args", ".", "args...
9cd7104aa085498da3097b72696184b9d3651c51
test
lookup
Use arguments to route constructor. Applies a series of checks on arguments to identify constructor, starting with known keyword arguments, and then applying constructor-specific checks
bolt/factory.py
def lookup(*args, **kwargs): """ Use arguments to route constructor. Applies a series of checks on arguments to identify constructor, starting with known keyword arguments, and then applying constructor-specific checks """ if 'mode' in kwargs: mode = kwargs['mode'] if mode n...
def lookup(*args, **kwargs): """ Use arguments to route constructor. Applies a series of checks on arguments to identify constructor, starting with known keyword arguments, and then applying constructor-specific checks """ if 'mode' in kwargs: mode = kwargs['mode'] if mode n...
[ "Use", "arguments", "to", "route", "constructor", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/factory.py#L37-L55
[ "def", "lookup", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'mode'", "in", "kwargs", ":", "mode", "=", "kwargs", "[", "'mode'", "]", "if", "mode", "not", "in", "constructors", ":", "raise", "ValueError", "(", "'Mode %s not supported'", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
Keys.reshape
Reshape just the keys of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- shape : tuple New proposed axes.
bolt/spark/shapes.py
def reshape(self, *shape): """ Reshape just the keys of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- shape : tuple New proposed axes. """ new = argpack(shape) old = self.shape isreshapeable(new, old...
def reshape(self, *shape): """ Reshape just the keys of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- shape : tuple New proposed axes. """ new = argpack(shape) old = self.shape isreshapeable(new, old...
[ "Reshape", "just", "the", "keys", "of", "a", "BoltArraySpark", "returning", "a", "new", "BoltArraySpark", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/shapes.py#L40-L64
[ "def", "reshape", "(", "self", ",", "*", "shape", ")", ":", "new", "=", "argpack", "(", "shape", ")", "old", "=", "self", ".", "shape", "isreshapeable", "(", "new", ",", "old", ")", "if", "new", "==", "old", ":", "return", "self", ".", "_barray", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
Keys.transpose
Transpose just the keys of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- axes : tuple New proposed axes.
bolt/spark/shapes.py
def transpose(self, *axes): """ Transpose just the keys of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- axes : tuple New proposed axes. """ new = argpack(axes) old = range(self.ndim) istransposeable(...
def transpose(self, *axes): """ Transpose just the keys of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- axes : tuple New proposed axes. """ new = argpack(axes) old = range(self.ndim) istransposeable(...
[ "Transpose", "just", "the", "keys", "of", "a", "BoltArraySpark", "returning", "a", "new", "BoltArraySpark", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/shapes.py#L66-L89
[ "def", "transpose", "(", "self", ",", "*", "axes", ")", ":", "new", "=", "argpack", "(", "axes", ")", "old", "=", "range", "(", "self", ".", "ndim", ")", "istransposeable", "(", "new", ",", "old", ")", "if", "new", "==", "old", ":", "return", "se...
9cd7104aa085498da3097b72696184b9d3651c51
test
Values.reshape
Reshape just the values of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- shape : tuple New proposed axes.
bolt/spark/shapes.py
def reshape(self, *shape): """ Reshape just the values of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- shape : tuple New proposed axes. """ new = argpack(shape) old = self.shape isreshapeable(new, o...
def reshape(self, *shape): """ Reshape just the values of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- shape : tuple New proposed axes. """ new = argpack(shape) old = self.shape isreshapeable(new, o...
[ "Reshape", "just", "the", "values", "of", "a", "BoltArraySpark", "returning", "a", "new", "BoltArraySpark", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/shapes.py#L111-L134
[ "def", "reshape", "(", "self", ",", "*", "shape", ")", ":", "new", "=", "argpack", "(", "shape", ")", "old", "=", "self", ".", "shape", "isreshapeable", "(", "new", ",", "old", ")", "if", "new", "==", "old", ":", "return", "self", ".", "_barray", ...
9cd7104aa085498da3097b72696184b9d3651c51
test
Values.transpose
Transpose just the values of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- axes : tuple New proposed axes.
bolt/spark/shapes.py
def transpose(self, *axes): """ Transpose just the values of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- axes : tuple New proposed axes. """ new = argpack(axes) old = range(self.ndim) istransposeabl...
def transpose(self, *axes): """ Transpose just the values of a BoltArraySpark, returning a new BoltArraySpark. Parameters ---------- axes : tuple New proposed axes. """ new = argpack(axes) old = range(self.ndim) istransposeabl...
[ "Transpose", "just", "the", "values", "of", "a", "BoltArraySpark", "returning", "a", "new", "BoltArraySpark", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/spark/shapes.py#L136-L159
[ "def", "transpose", "(", "self", ",", "*", "axes", ")", ":", "new", "=", "argpack", "(", "axes", ")", "old", "=", "range", "(", "self", ".", "ndim", ")", "istransposeable", "(", "new", ",", "old", ")", "if", "new", "==", "old", ":", "return", "se...
9cd7104aa085498da3097b72696184b9d3651c51
test
ConstructLocal.ones
Create a local bolt array of ones. Parameters ---------- shape : tuple Dimensions of the desired array dtype : data-type, optional, default=float64 The desired data-type for the array. (see numpy) order : {'C', 'F', 'A'}, optional, default='C' ...
bolt/local/construct.py
def ones(shape, dtype=float64, order='C'): """ Create a local bolt array of ones. Parameters ---------- shape : tuple Dimensions of the desired array dtype : data-type, optional, default=float64 The desired data-type for the array. (see numpy) ...
def ones(shape, dtype=float64, order='C'): """ Create a local bolt array of ones. Parameters ---------- shape : tuple Dimensions of the desired array dtype : data-type, optional, default=float64 The desired data-type for the array. (see numpy) ...
[ "Create", "a", "local", "bolt", "array", "of", "ones", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/local/construct.py#L35-L55
[ "def", "ones", "(", "shape", ",", "dtype", "=", "float64", ",", "order", "=", "'C'", ")", ":", "from", "numpy", "import", "ones", "return", "ConstructLocal", ".", "_wrap", "(", "ones", ",", "shape", ",", "dtype", ",", "order", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
ConstructLocal.zeros
Create a local bolt array of zeros. Parameters ---------- shape : tuple Dimensions of the desired array. dtype : data-type, optional, default=float64 The desired data-type for the array. (see numpy) order : {'C', 'F', 'A'}, optional, default='C' ...
bolt/local/construct.py
def zeros(shape, dtype=float64, order='C'): """ Create a local bolt array of zeros. Parameters ---------- shape : tuple Dimensions of the desired array. dtype : data-type, optional, default=float64 The desired data-type for the array. (see numpy)...
def zeros(shape, dtype=float64, order='C'): """ Create a local bolt array of zeros. Parameters ---------- shape : tuple Dimensions of the desired array. dtype : data-type, optional, default=float64 The desired data-type for the array. (see numpy)...
[ "Create", "a", "local", "bolt", "array", "of", "zeros", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/local/construct.py#L58-L78
[ "def", "zeros", "(", "shape", ",", "dtype", "=", "float64", ",", "order", "=", "'C'", ")", ":", "from", "numpy", "import", "zeros", "return", "ConstructLocal", ".", "_wrap", "(", "zeros", ",", "shape", ",", "dtype", ",", "order", ")" ]
9cd7104aa085498da3097b72696184b9d3651c51
test
ConstructLocal.concatenate
Join a sequence of arrays together. Parameters ---------- arrays : tuple A sequence of array-like e.g. (a1, a2, ...) axis : int, optional, default=0 The axis along which the arrays will be joined. Returns ------- BoltArrayLocal
bolt/local/construct.py
def concatenate(arrays, axis=0): """ Join a sequence of arrays together. Parameters ---------- arrays : tuple A sequence of array-like e.g. (a1, a2, ...) axis : int, optional, default=0 The axis along which the arrays will be joined. Ret...
def concatenate(arrays, axis=0): """ Join a sequence of arrays together. Parameters ---------- arrays : tuple A sequence of array-like e.g. (a1, a2, ...) axis : int, optional, default=0 The axis along which the arrays will be joined. Ret...
[ "Join", "a", "sequence", "of", "arrays", "together", "." ]
bolt-project/bolt
python
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/local/construct.py#L85-L105
[ "def", "concatenate", "(", "arrays", ",", "axis", "=", "0", ")", ":", "if", "not", "isinstance", "(", "arrays", ",", "tuple", ")", ":", "raise", "ValueError", "(", "\"data type not understood\"", ")", "arrays", "=", "tuple", "(", "[", "asarray", "(", "a"...
9cd7104aa085498da3097b72696184b9d3651c51
test
plfit_lsq
Returns A and B in y=Ax^B http://mathworld.wolfram.com/LeastSquaresFittingPowerLaw.html
plfit/plfit_v1.py
def plfit_lsq(x,y): """ Returns A and B in y=Ax^B http://mathworld.wolfram.com/LeastSquaresFittingPowerLaw.html """ n = len(x) btop = n * (log(x)*log(y)).sum() - (log(x)).sum()*(log(y)).sum() bbottom = n*(log(x)**2).sum() - (log(x).sum())**2 b = btop / bbottom a = ( log(y).sum() - b ...
def plfit_lsq(x,y): """ Returns A and B in y=Ax^B http://mathworld.wolfram.com/LeastSquaresFittingPowerLaw.html """ n = len(x) btop = n * (log(x)*log(y)).sum() - (log(x)).sum()*(log(y)).sum() bbottom = n*(log(x)**2).sum() - (log(x).sum())**2 b = btop / bbottom a = ( log(y).sum() - b ...
[ "Returns", "A", "and", "B", "in", "y", "=", "Ax^B", "http", ":", "//", "mathworld", ".", "wolfram", ".", "com", "/", "LeastSquaresFittingPowerLaw", ".", "html" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit_v1.py#L18-L30
[ "def", "plfit_lsq", "(", "x", ",", "y", ")", ":", "n", "=", "len", "(", "x", ")", "btop", "=", "n", "*", "(", "log", "(", "x", ")", "*", "log", "(", "y", ")", ")", ".", "sum", "(", ")", "-", "(", "log", "(", "x", ")", ")", ".", "sum",...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit
A Python implementation of the Matlab code http://www.santafe.edu/~aaronc/powerlaws/plfit.m from http://www.santafe.edu/~aaronc/powerlaws/ See A. Clauset, C.R. Shalizi, and M.E.J. Newman, "Power-law distributions in empirical data" SIAM Review, to appear (2009). (arXiv:0706.1062) http://arxiv.org/abs/0...
plfit/plfit_v1.py
def plfit(x,nosmall=False,finite=False): """ A Python implementation of the Matlab code http://www.santafe.edu/~aaronc/powerlaws/plfit.m from http://www.santafe.edu/~aaronc/powerlaws/ See A. Clauset, C.R. Shalizi, and M.E.J. Newman, "Power-law distributions in empirical data" SIAM Review, to appear...
def plfit(x,nosmall=False,finite=False): """ A Python implementation of the Matlab code http://www.santafe.edu/~aaronc/powerlaws/plfit.m from http://www.santafe.edu/~aaronc/powerlaws/ See A. Clauset, C.R. Shalizi, and M.E.J. Newman, "Power-law distributions in empirical data" SIAM Review, to appear...
[ "A", "Python", "implementation", "of", "the", "Matlab", "code", "http", ":", "//", "www", ".", "santafe", ".", "edu", "/", "~aaronc", "/", "powerlaws", "/", "plfit", ".", "m", "from", "http", ":", "//", "www", ".", "santafe", ".", "edu", "/", "~aaron...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit_v1.py#L33-L77
[ "def", "plfit", "(", "x", ",", "nosmall", "=", "False", ",", "finite", "=", "False", ")", ":", "xmins", "=", "unique", "(", "x", ")", "xmins", "=", "xmins", "[", "1", ":", "-", "1", "]", "dat", "=", "xmins", "*", "0", "z", "=", "sort", "(", ...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plotcdf
Plots CDF and powerlaw
plfit/plfit_v1.py
def plotcdf(x,xmin,alpha): """ Plots CDF and powerlaw """ x=sort(x) n=len(x) xcdf = arange(n,0,-1,dtype='float')/float(n) q = x[x>=xmin] fcdf = (q/xmin)**(1-alpha) nc = xcdf[argmax(x>=xmin)] fcdf_norm = nc*fcdf loglog(x,xcdf) loglog(q,fcdf_norm)
def plotcdf(x,xmin,alpha): """ Plots CDF and powerlaw """ x=sort(x) n=len(x) xcdf = arange(n,0,-1,dtype='float')/float(n) q = x[x>=xmin] fcdf = (q/xmin)**(1-alpha) nc = xcdf[argmax(x>=xmin)] fcdf_norm = nc*fcdf loglog(x,xcdf) loglog(q,fcdf_norm)
[ "Plots", "CDF", "and", "powerlaw" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit_v1.py#L79-L94
[ "def", "plotcdf", "(", "x", ",", "xmin", ",", "alpha", ")", ":", "x", "=", "sort", "(", "x", ")", "n", "=", "len", "(", "x", ")", "xcdf", "=", "arange", "(", "n", ",", "0", ",", "-", "1", ",", "dtype", "=", "'float'", ")", "/", "float", "...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plotpdf
Plots PDF and powerlaw....
plfit/plfit_v1.py
def plotpdf(x,xmin,alpha,nbins=30,dolog=False): """ Plots PDF and powerlaw.... """ x=sort(x) n=len(x) if dolog: hb = hist(x,bins=logspace(log10(min(x)),log10(max(x)),nbins),log=True) alpha += 1 else: hb = hist(x,bins=linspace((min(x)),(max(x)),nbins)) h,b=hb[0],...
def plotpdf(x,xmin,alpha,nbins=30,dolog=False): """ Plots PDF and powerlaw.... """ x=sort(x) n=len(x) if dolog: hb = hist(x,bins=logspace(log10(min(x)),log10(max(x)),nbins),log=True) alpha += 1 else: hb = hist(x,bins=linspace((min(x)),(max(x)),nbins)) h,b=hb[0],...
[ "Plots", "PDF", "and", "powerlaw", "...." ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit_v1.py#L96-L121
[ "def", "plotpdf", "(", "x", ",", "xmin", ",", "alpha", ",", "nbins", "=", "30", ",", "dolog", "=", "False", ")", ":", "x", "=", "sort", "(", "x", ")", "n", "=", "len", "(", "x", ")", "if", "dolog", ":", "hb", "=", "hist", "(", "x", ",", "...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plexp
CDF(x) for the piecewise distribution exponential x<xmin, powerlaw x>=xmin This is the CDF version of the distributions drawn in fig 3.4a of Clauset et al.
plfit/plfit_py.py
def plexp(x,xm=1,a=2.5): """ CDF(x) for the piecewise distribution exponential x<xmin, powerlaw x>=xmin This is the CDF version of the distributions drawn in fig 3.4a of Clauset et al. """ C = 1/(-xm/(1 - a) - xm/a + math.exp(a)*xm/a) Ppl = lambda X: 1+C*(xm/(1-a)*(X/xm)**(1-a)) Pexp = lamb...
def plexp(x,xm=1,a=2.5): """ CDF(x) for the piecewise distribution exponential x<xmin, powerlaw x>=xmin This is the CDF version of the distributions drawn in fig 3.4a of Clauset et al. """ C = 1/(-xm/(1 - a) - xm/a + math.exp(a)*xm/a) Ppl = lambda X: 1+C*(xm/(1-a)*(X/xm)**(1-a)) Pexp = lamb...
[ "CDF", "(", "x", ")", "for", "the", "piecewise", "distribution", "exponential", "x<xmin", "powerlaw", "x", ">", "=", "xmin", "This", "is", "the", "CDF", "version", "of", "the", "distributions", "drawn", "in", "fig", "3", ".", "4a", "of", "Clauset", "et",...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit_py.py#L192-L203
[ "def", "plexp", "(", "x", ",", "xm", "=", "1", ",", "a", "=", "2.5", ")", ":", "C", "=", "1", "/", "(", "-", "xm", "/", "(", "1", "-", "a", ")", "-", "xm", "/", "a", "+", "math", ".", "exp", "(", "a", ")", "*", "xm", "/", "a", ")", ...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plexp_inv
Inverse CDF for a piecewise PDF as defined in eqn. 3.10 of Clauset et al.
plfit/plfit_py.py
def plexp_inv(P,xm,a): """ Inverse CDF for a piecewise PDF as defined in eqn. 3.10 of Clauset et al. """ C = 1/(-xm/(1 - a) - xm/a + math.exp(a)*xm/a) Pxm = 1+C*(xm/(1-a)) pp = P x = xm*(pp-1)*(1-a)/(C*xm)**(1/(1-a)) if pp >= Pxm else (math.log( ((C*xm/a)*math.exp(a)-pp)/(C*xm/a)) - a...
def plexp_inv(P,xm,a): """ Inverse CDF for a piecewise PDF as defined in eqn. 3.10 of Clauset et al. """ C = 1/(-xm/(1 - a) - xm/a + math.exp(a)*xm/a) Pxm = 1+C*(xm/(1-a)) pp = P x = xm*(pp-1)*(1-a)/(C*xm)**(1/(1-a)) if pp >= Pxm else (math.log( ((C*xm/a)*math.exp(a)-pp)/(C*xm/a)) - a...
[ "Inverse", "CDF", "for", "a", "piecewise", "PDF", "as", "defined", "in", "eqn", ".", "3", ".", "10", "of", "Clauset", "et", "al", "." ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit_py.py#L205-L218
[ "def", "plexp_inv", "(", "P", ",", "xm", ",", "a", ")", ":", "C", "=", "1", "/", "(", "-", "xm", "/", "(", "1", "-", "a", ")", "-", "xm", "/", "a", "+", "math", ".", "exp", "(", "a", ")", "*", "xm", "/", "a", ")", "Pxm", "=", "1", "...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.alpha_
Create a mappable function alpha to apply to each xmin in a list of xmins. This is essentially the slow version of fplfit/cplfit, though I bet it could be speeded up with a clever use of parellel_map. Not intended to be used by users.
plfit/plfit_py.py
def alpha_(self,x): """ Create a mappable function alpha to apply to each xmin in a list of xmins. This is essentially the slow version of fplfit/cplfit, though I bet it could be speeded up with a clever use of parellel_map. Not intended to be used by users.""" def alpha(xmin,x=x): ...
def alpha_(self,x): """ Create a mappable function alpha to apply to each xmin in a list of xmins. This is essentially the slow version of fplfit/cplfit, though I bet it could be speeded up with a clever use of parellel_map. Not intended to be used by users.""" def alpha(xmin,x=x): ...
[ "Create", "a", "mappable", "function", "alpha", "to", "apply", "to", "each", "xmin", "in", "a", "list", "of", "xmins", ".", "This", "is", "essentially", "the", "slow", "version", "of", "fplfit", "/", "cplfit", "though", "I", "bet", "it", "could", "be", ...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit_py.py#L54-L71
[ "def", "alpha_", "(", "self", ",", "x", ")", ":", "def", "alpha", "(", "xmin", ",", "x", "=", "x", ")", ":", "\"\"\"\n given a sorted data set and a minimum, returns power law MLE fit\n data is passed as a keyword parameter so that it can be vectorized\n ...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.plfit
A pure-Python implementation of the Matlab code http://www.santafe.edu/~aaronc/powerlaws/plfit.m from http://www.santafe.edu/~aaronc/powerlaws/ See A. Clauset, C.R. Shalizi, and M.E.J. Newman, "Power-law distributions in empirical data" SIAM Review, 51, 661-703 (2009). (arXiv:0706.1062) ...
plfit/plfit_py.py
def plfit(self,nosmall=True,finite=False,quiet=False,silent=False, xmin=None, verbose=False): """ A pure-Python implementation of the Matlab code http://www.santafe.edu/~aaronc/powerlaws/plfit.m from http://www.santafe.edu/~aaronc/powerlaws/ See A. Clauset, C.R. Shalizi, a...
def plfit(self,nosmall=True,finite=False,quiet=False,silent=False, xmin=None, verbose=False): """ A pure-Python implementation of the Matlab code http://www.santafe.edu/~aaronc/powerlaws/plfit.m from http://www.santafe.edu/~aaronc/powerlaws/ See A. Clauset, C.R. Shalizi, a...
[ "A", "pure", "-", "Python", "implementation", "of", "the", "Matlab", "code", "http", ":", "//", "www", ".", "santafe", ".", "edu", "/", "~aaronc", "/", "powerlaws", "/", "plfit", ".", "m", "from", "http", ":", "//", "www", ".", "santafe", ".", "edu",...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit_py.py#L94-L189
[ "def", "plfit", "(", "self", ",", "nosmall", "=", "True", ",", "finite", "=", "False", ",", "quiet", "=", "False", ",", "silent", "=", "False", ",", "xmin", "=", "None", ",", "verbose", "=", "False", ")", ":", "x", "=", "self", ".", "data", "z", ...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
alpha_gen
Create a mappable function alpha to apply to each xmin in a list of xmins. This is essentially the slow version of fplfit/cplfit, though I bet it could be speeded up with a clever use of parellel_map. Not intended to be used by users. Docstring for the generated alpha function:: Given a sorted da...
plfit/plfit.py
def alpha_gen(x): """ Create a mappable function alpha to apply to each xmin in a list of xmins. This is essentially the slow version of fplfit/cplfit, though I bet it could be speeded up with a clever use of parellel_map. Not intended to be used by users. Docstring for the generated alpha function:: ...
def alpha_gen(x): """ Create a mappable function alpha to apply to each xmin in a list of xmins. This is essentially the slow version of fplfit/cplfit, though I bet it could be speeded up with a clever use of parellel_map. Not intended to be used by users. Docstring for the generated alpha function:: ...
[ "Create", "a", "mappable", "function", "alpha", "to", "apply", "to", "each", "xmin", "in", "a", "list", "of", "xmins", ".", "This", "is", "essentially", "the", "slow", "version", "of", "fplfit", "/", "cplfit", "though", "I", "bet", "it", "could", "be", ...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L53-L79
[ "def", "alpha_gen", "(", "x", ")", ":", "def", "alpha_", "(", "xmin", ",", "x", "=", "x", ")", ":", "\"\"\"\n Given a sorted data set and a minimum, returns power law MLE fit\n data is passed as a keyword parameter so that it can be vectorized\n\n If there is onl...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plexp_cdf
CDF(x) for the piecewise distribution exponential x<xmin, powerlaw x>=xmin This is the CDF version of the distributions drawn in fig 3.4a of Clauset et al. The constant "C" normalizes the PDF
plfit/plfit.py
def plexp_cdf(x,xmin=1,alpha=2.5, pl_only=False, exp_only=False): """ CDF(x) for the piecewise distribution exponential x<xmin, powerlaw x>=xmin This is the CDF version of the distributions drawn in fig 3.4a of Clauset et al. The constant "C" normalizes the PDF """ x = np.array(x) C = 1/(-x...
def plexp_cdf(x,xmin=1,alpha=2.5, pl_only=False, exp_only=False): """ CDF(x) for the piecewise distribution exponential x<xmin, powerlaw x>=xmin This is the CDF version of the distributions drawn in fig 3.4a of Clauset et al. The constant "C" normalizes the PDF """ x = np.array(x) C = 1/(-x...
[ "CDF", "(", "x", ")", "for", "the", "piecewise", "distribution", "exponential", "x<xmin", "powerlaw", "x", ">", "=", "xmin", "This", "is", "the", "CDF", "version", "of", "the", "distributions", "drawn", "in", "fig", "3", ".", "4a", "of", "Clauset", "et",...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L796-L815
[ "def", "plexp_cdf", "(", "x", ",", "xmin", "=", "1", ",", "alpha", "=", "2.5", ",", "pl_only", "=", "False", ",", "exp_only", "=", "False", ")", ":", "x", "=", "np", ".", "array", "(", "x", ")", "C", "=", "1", "/", "(", "-", "xmin", "/", "(...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plexp_inv
Inverse CDF for a piecewise PDF as defined in eqn. 3.10 of Clauset et al. (previous version was incorrect and lead to weird discontinuities in the distribution function)
plfit/plfit.py
def plexp_inv(P, xmin, alpha, guess=1.): """ Inverse CDF for a piecewise PDF as defined in eqn. 3.10 of Clauset et al. (previous version was incorrect and lead to weird discontinuities in the distribution function) """ def equation(x,prob): return plexp_cdf(x, xmin, alpha)-prob ...
def plexp_inv(P, xmin, alpha, guess=1.): """ Inverse CDF for a piecewise PDF as defined in eqn. 3.10 of Clauset et al. (previous version was incorrect and lead to weird discontinuities in the distribution function) """ def equation(x,prob): return plexp_cdf(x, xmin, alpha)-prob ...
[ "Inverse", "CDF", "for", "a", "piecewise", "PDF", "as", "defined", "in", "eqn", ".", "3", ".", "10", "of", "Clauset", "et", "al", "." ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L841-L855
[ "def", "plexp_inv", "(", "P", ",", "xmin", ",", "alpha", ",", "guess", "=", "1.", ")", ":", "def", "equation", "(", "x", ",", "prob", ")", ":", "return", "plexp_cdf", "(", "x", ",", "xmin", ",", "alpha", ")", "-", "prob", "# http://stackoverflow.com/...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
discrete_likelihood
Equation B.8 in Clauset Given a data set, an xmin value, and an alpha "scaling parameter", computes the log-likelihood (the value to be maximized)
plfit/plfit.py
def discrete_likelihood(data, xmin, alpha): """ Equation B.8 in Clauset Given a data set, an xmin value, and an alpha "scaling parameter", computes the log-likelihood (the value to be maximized) """ if not scipyOK: raise ImportError("Can't import scipy. Need scipy for zeta function.") ...
def discrete_likelihood(data, xmin, alpha): """ Equation B.8 in Clauset Given a data set, an xmin value, and an alpha "scaling parameter", computes the log-likelihood (the value to be maximized) """ if not scipyOK: raise ImportError("Can't import scipy. Need scipy for zeta function.") ...
[ "Equation", "B", ".", "8", "in", "Clauset" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L922-L942
[ "def", "discrete_likelihood", "(", "data", ",", "xmin", ",", "alpha", ")", ":", "if", "not", "scipyOK", ":", "raise", "ImportError", "(", "\"Can't import scipy. Need scipy for zeta function.\"", ")", "from", "scipy", ".", "special", "import", "zeta", "as", "zeta"...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
discrete_likelihood_vector
Compute the likelihood for all "scaling parameters" in the range (alpharange) for a given xmin. This is only part of the discrete value likelihood maximization problem as described in Clauset et al (Equation B.8) *alpharange* [ 2-tuple ] Two floats specifying the upper and lower limits of the ...
plfit/plfit.py
def discrete_likelihood_vector(data, xmin, alpharange=(1.5,3.5), n_alpha=201): """ Compute the likelihood for all "scaling parameters" in the range (alpharange) for a given xmin. This is only part of the discrete value likelihood maximization problem as described in Clauset et al (Equation B.8) ...
def discrete_likelihood_vector(data, xmin, alpharange=(1.5,3.5), n_alpha=201): """ Compute the likelihood for all "scaling parameters" in the range (alpharange) for a given xmin. This is only part of the discrete value likelihood maximization problem as described in Clauset et al (Equation B.8) ...
[ "Compute", "the", "likelihood", "for", "all", "scaling", "parameters", "in", "the", "range", "(", "alpharange", ")", "for", "a", "given", "xmin", ".", "This", "is", "only", "part", "of", "the", "discrete", "value", "likelihood", "maximization", "problem", "a...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L944-L972
[ "def", "discrete_likelihood_vector", "(", "data", ",", "xmin", ",", "alpharange", "=", "(", "1.5", ",", "3.5", ")", ",", "n_alpha", "=", "201", ")", ":", "from", "scipy", ".", "special", "import", "zeta", "as", "zeta", "zz", "=", "data", "[", "data", ...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
discrete_max_likelihood_arg
Returns the *argument* of the max of the likelihood of the data given an input xmin
plfit/plfit.py
def discrete_max_likelihood_arg(data, xmin, alpharange=(1.5,3.5), n_alpha=201): """ Returns the *argument* of the max of the likelihood of the data given an input xmin """ likelihoods = discrete_likelihood_vector(data, xmin, alpharange=alpharange, n_alpha=n_alpha) Largmax = np.argmax(likelihoods) ...
def discrete_max_likelihood_arg(data, xmin, alpharange=(1.5,3.5), n_alpha=201): """ Returns the *argument* of the max of the likelihood of the data given an input xmin """ likelihoods = discrete_likelihood_vector(data, xmin, alpharange=alpharange, n_alpha=n_alpha) Largmax = np.argmax(likelihoods) ...
[ "Returns", "the", "*", "argument", "*", "of", "the", "max", "of", "the", "likelihood", "of", "the", "data", "given", "an", "input", "xmin" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L974-L980
[ "def", "discrete_max_likelihood_arg", "(", "data", ",", "xmin", ",", "alpharange", "=", "(", "1.5", ",", "3.5", ")", ",", "n_alpha", "=", "201", ")", ":", "likelihoods", "=", "discrete_likelihood_vector", "(", "data", ",", "xmin", ",", "alpharange", "=", "...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
discrete_max_likelihood
Returns the *argument* of the max of the likelihood of the data given an input xmin
plfit/plfit.py
def discrete_max_likelihood(data, xmin, alpharange=(1.5,3.5), n_alpha=201): """ Returns the *argument* of the max of the likelihood of the data given an input xmin """ likelihoods = discrete_likelihood_vector(data, xmin, alpharange=alpharange, n_alpha=n_alpha) Lmax = np.max(likelihoods) return L...
def discrete_max_likelihood(data, xmin, alpharange=(1.5,3.5), n_alpha=201): """ Returns the *argument* of the max of the likelihood of the data given an input xmin """ likelihoods = discrete_likelihood_vector(data, xmin, alpharange=alpharange, n_alpha=n_alpha) Lmax = np.max(likelihoods) return L...
[ "Returns", "the", "*", "argument", "*", "of", "the", "max", "of", "the", "likelihood", "of", "the", "data", "given", "an", "input", "xmin" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L982-L988
[ "def", "discrete_max_likelihood", "(", "data", ",", "xmin", ",", "alpharange", "=", "(", "1.5", ",", "3.5", ")", ",", "n_alpha", "=", "201", ")", ":", "likelihoods", "=", "discrete_likelihood_vector", "(", "data", ",", "xmin", ",", "alpharange", "=", "alph...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
most_likely_alpha
Return the most likely alpha for the data given an xmin
plfit/plfit.py
def most_likely_alpha(data, xmin, alpharange=(1.5,3.5), n_alpha=201): """ Return the most likely alpha for the data given an xmin """ alpha_vector = np.linspace(alpharange[0],alpharange[1],n_alpha) return alpha_vector[discrete_max_likelihood_arg(data, xmin, ...
def most_likely_alpha(data, xmin, alpharange=(1.5,3.5), n_alpha=201): """ Return the most likely alpha for the data given an xmin """ alpha_vector = np.linspace(alpharange[0],alpharange[1],n_alpha) return alpha_vector[discrete_max_likelihood_arg(data, xmin, ...
[ "Return", "the", "most", "likely", "alpha", "for", "the", "data", "given", "an", "xmin" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L990-L997
[ "def", "most_likely_alpha", "(", "data", ",", "xmin", ",", "alpharange", "=", "(", "1.5", ",", "3.5", ")", ",", "n_alpha", "=", "201", ")", ":", "alpha_vector", "=", "np", ".", "linspace", "(", "alpharange", "[", "0", "]", ",", "alpharange", "[", "1"...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
discrete_alpha_mle
Equation B.17 of Clauset et al 2009 The Maximum Likelihood Estimator of the "scaling parameter" alpha in the discrete case is similar to that in the continuous case
plfit/plfit.py
def discrete_alpha_mle(data, xmin): """ Equation B.17 of Clauset et al 2009 The Maximum Likelihood Estimator of the "scaling parameter" alpha in the discrete case is similar to that in the continuous case """ # boolean indices of positive data gexmin = (data>=xmin) nn = gexmin.sum() ...
def discrete_alpha_mle(data, xmin): """ Equation B.17 of Clauset et al 2009 The Maximum Likelihood Estimator of the "scaling parameter" alpha in the discrete case is similar to that in the continuous case """ # boolean indices of positive data gexmin = (data>=xmin) nn = gexmin.sum() ...
[ "Equation", "B", ".", "17", "of", "Clauset", "et", "al", "2009" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L999-L1013
[ "def", "discrete_alpha_mle", "(", "data", ",", "xmin", ")", ":", "# boolean indices of positive data", "gexmin", "=", "(", "data", ">=", "xmin", ")", "nn", "=", "gexmin", ".", "sum", "(", ")", "if", "nn", "<", "2", ":", "return", "0", "xx", "=", "data"...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
discrete_best_alpha
Use the maximum L to determine the most likely value of alpha *alpharangemults* [ 2-tuple ] Pair of values indicating multiplicative factors above and below the approximate alpha from the MLE alpha to use when determining the "exact" alpha (by directly maximizing the likelihood function)
plfit/plfit.py
def discrete_best_alpha(data, alpharangemults=(0.9,1.1), n_alpha=201, approximate=True, verbose=True): """ Use the maximum L to determine the most likely value of alpha *alpharangemults* [ 2-tuple ] Pair of values indicating multiplicative factors above and below the approximate alpha from ...
def discrete_best_alpha(data, alpharangemults=(0.9,1.1), n_alpha=201, approximate=True, verbose=True): """ Use the maximum L to determine the most likely value of alpha *alpharangemults* [ 2-tuple ] Pair of values indicating multiplicative factors above and below the approximate alpha from ...
[ "Use", "the", "maximum", "L", "to", "determine", "the", "most", "likely", "value", "of", "alpha" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L1015-L1045
[ "def", "discrete_best_alpha", "(", "data", ",", "alpharangemults", "=", "(", "0.9", ",", "1.1", ")", ",", "n_alpha", "=", "201", ",", "approximate", "=", "True", ",", "verbose", "=", "True", ")", ":", "xmins", "=", "np", ".", "unique", "(", "data", "...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
discrete_ksD
given a sorted data set, a minimum, and an alpha, returns the power law ks-test D value w/data The returned value is the "D" parameter in the ks test (this is implemented differently from the continuous version because there are potentially multiple identical points that need comparison to the power ...
plfit/plfit.py
def discrete_ksD(data, xmin, alpha): """ given a sorted data set, a minimum, and an alpha, returns the power law ks-test D value w/data The returned value is the "D" parameter in the ks test (this is implemented differently from the continuous version because there are potentially multiple ide...
def discrete_ksD(data, xmin, alpha): """ given a sorted data set, a minimum, and an alpha, returns the power law ks-test D value w/data The returned value is the "D" parameter in the ks test (this is implemented differently from the continuous version because there are potentially multiple ide...
[ "given", "a", "sorted", "data", "set", "a", "minimum", "and", "an", "alpha", "returns", "the", "power", "law", "ks", "-", "test", "D", "value", "w", "/", "data" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L1048-L1069
[ "def", "discrete_ksD", "(", "data", ",", "xmin", ",", "alpha", ")", ":", "zz", "=", "np", ".", "sort", "(", "data", "[", "data", ">=", "xmin", "]", ")", "nn", "=", "float", "(", "len", "(", "zz", ")", ")", "if", "nn", "<", "2", ":", "return",...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.plfit
A Python implementation of the Matlab code http://www.santafe.edu/~aaronc/powerlaws/plfit.m from http://www.santafe.edu/~aaronc/powerlaws/ See A. Clauset, C.R. Shalizi, and M.E.J. Newman, "Power-law distributions in empirical data" SIAM Review, 51, 661-703 (2009). (arXiv:0706.1062) ...
plfit/plfit.py
def plfit(self, nosmall=True, finite=False, quiet=False, silent=False, usefortran=False, usecy=False, xmin=None, verbose=False, discrete=None, discrete_approx=True, discrete_n_alpha=1000, skip_consistency_check=False): """ A Python implementation of the Matlab c...
def plfit(self, nosmall=True, finite=False, quiet=False, silent=False, usefortran=False, usecy=False, xmin=None, verbose=False, discrete=None, discrete_approx=True, discrete_n_alpha=1000, skip_consistency_check=False): """ A Python implementation of the Matlab c...
[ "A", "Python", "implementation", "of", "the", "Matlab", "code", "http", ":", "//", "www", ".", "santafe", ".", "edu", "/", "~aaronc", "/", "powerlaws", "/", "plfit", ".", "m", "from", "http", ":", "//", "www", ".", "santafe", ".", "edu", "/", "~aaron...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L159-L394
[ "def", "plfit", "(", "self", ",", "nosmall", "=", "True", ",", "finite", "=", "False", ",", "quiet", "=", "False", ",", "silent", "=", "False", ",", "usefortran", "=", "False", ",", "usecy", "=", "False", ",", "xmin", "=", "None", ",", "verbose", "...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.discrete_best_alpha
Use the maximum likelihood to determine the most likely value of alpha *alpharangemults* [ 2-tuple ] Pair of values indicating multiplicative factors above and below the approximate alpha from the MLE alpha to use when determining the "exact" alpha (by directly maximizing th...
plfit/plfit.py
def discrete_best_alpha(self, alpharangemults=(0.9,1.1), n_alpha=201, approximate=True, verbose=True, finite=True): """ Use the maximum likelihood to determine the most likely value of alpha *alpharangemults* [ 2-tuple ] Pair of values indicating multipli...
def discrete_best_alpha(self, alpharangemults=(0.9,1.1), n_alpha=201, approximate=True, verbose=True, finite=True): """ Use the maximum likelihood to determine the most likely value of alpha *alpharangemults* [ 2-tuple ] Pair of values indicating multipli...
[ "Use", "the", "maximum", "likelihood", "to", "determine", "the", "most", "likely", "value", "of", "alpha" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L397-L453
[ "def", "discrete_best_alpha", "(", "self", ",", "alpharangemults", "=", "(", "0.9", ",", "1.1", ")", ",", "n_alpha", "=", "201", ",", "approximate", "=", "True", ",", "verbose", "=", "True", ",", "finite", "=", "True", ")", ":", "data", "=", "self", ...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.xminvsks
Plot xmin versus the ks value for derived alpha. This plot can be used as a diagnostic of whether you have derived the 'best' fit: if there are multiple local minima, your data set may be well suited to a broken powerlaw or a different function.
plfit/plfit.py
def xminvsks(self, **kwargs): """ Plot xmin versus the ks value for derived alpha. This plot can be used as a diagnostic of whether you have derived the 'best' fit: if there are multiple local minima, your data set may be well suited to a broken powerlaw or a different function....
def xminvsks(self, **kwargs): """ Plot xmin versus the ks value for derived alpha. This plot can be used as a diagnostic of whether you have derived the 'best' fit: if there are multiple local minima, your data set may be well suited to a broken powerlaw or a different function....
[ "Plot", "xmin", "versus", "the", "ks", "value", "for", "derived", "alpha", ".", "This", "plot", "can", "be", "used", "as", "a", "diagnostic", "of", "whether", "you", "have", "derived", "the", "best", "fit", ":", "if", "there", "are", "multiple", "local",...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L455-L472
[ "def", "xminvsks", "(", "self", ",", "*", "*", "kwargs", ")", ":", "pylab", ".", "plot", "(", "self", ".", "_xmins", ",", "self", ".", "_xmin_kstest", ",", "'.'", ")", "pylab", ".", "plot", "(", "self", ".", "_xmin", ",", "self", ".", "_ks", ",",...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.alphavsks
Plot alpha versus the ks value for derived alpha. This plot can be used as a diagnostic of whether you have derived the 'best' fit: if there are multiple local minima, your data set may be well suited to a broken powerlaw or a different function.
plfit/plfit.py
def alphavsks(self,autozoom=True,**kwargs): """ Plot alpha versus the ks value for derived alpha. This plot can be used as a diagnostic of whether you have derived the 'best' fit: if there are multiple local minima, your data set may be well suited to a broken powerlaw or a diff...
def alphavsks(self,autozoom=True,**kwargs): """ Plot alpha versus the ks value for derived alpha. This plot can be used as a diagnostic of whether you have derived the 'best' fit: if there are multiple local minima, your data set may be well suited to a broken powerlaw or a diff...
[ "Plot", "alpha", "versus", "the", "ks", "value", "for", "derived", "alpha", ".", "This", "plot", "can", "be", "used", "as", "a", "diagnostic", "of", "whether", "you", "have", "derived", "the", "best", "fit", ":", "if", "there", "are", "multiple", "local"...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L474-L493
[ "def", "alphavsks", "(", "self", ",", "autozoom", "=", "True", ",", "*", "*", "kwargs", ")", ":", "pylab", ".", "plot", "(", "self", ".", "_alpha_values", ",", "self", ".", "_xmin_kstest", ",", "'.'", ")", "pylab", ".", "errorbar", "(", "self", ".", ...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.plotcdf
Plots CDF and powerlaw
plfit/plfit.py
def plotcdf(self, x=None, xmin=None, alpha=None, pointcolor='k', dolog=True, zoom=True, pointmarker='+', **kwargs): """ Plots CDF and powerlaw """ if x is None: x=self.data if xmin is None: xmin=self._xmin if alpha is None: alpha=self._alpha x=np....
def plotcdf(self, x=None, xmin=None, alpha=None, pointcolor='k', dolog=True, zoom=True, pointmarker='+', **kwargs): """ Plots CDF and powerlaw """ if x is None: x=self.data if xmin is None: xmin=self._xmin if alpha is None: alpha=self._alpha x=np....
[ "Plots", "CDF", "and", "powerlaw" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L495-L532
[ "def", "plotcdf", "(", "self", ",", "x", "=", "None", ",", "xmin", "=", "None", ",", "alpha", "=", "None", ",", "pointcolor", "=", "'k'", ",", "dolog", "=", "True", ",", "zoom", "=", "True", ",", "pointmarker", "=", "'+'", ",", "*", "*", "kwargs"...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.plotpdf
Plots PDF and powerlaw. kwargs is passed to pylab.hist and pylab.plot
plfit/plfit.py
def plotpdf(self, x=None, xmin=None, alpha=None, nbins=50, dolog=True, dnds=False, drawstyle='steps-post', histcolor='k', plcolor='r', fill=False, dohist=True, **kwargs): """ Plots PDF and powerlaw. kwargs is passed to pylab.hist and pylab.plot """ ...
def plotpdf(self, x=None, xmin=None, alpha=None, nbins=50, dolog=True, dnds=False, drawstyle='steps-post', histcolor='k', plcolor='r', fill=False, dohist=True, **kwargs): """ Plots PDF and powerlaw. kwargs is passed to pylab.hist and pylab.plot """ ...
[ "Plots", "PDF", "and", "powerlaw", "." ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L534-L607
[ "def", "plotpdf", "(", "self", ",", "x", "=", "None", ",", "xmin", "=", "None", ",", "alpha", "=", "None", ",", "nbins", "=", "50", ",", "dolog", "=", "True", ",", "dnds", "=", "False", ",", "drawstyle", "=", "'steps-post'", ",", "histcolor", "=", ...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.plotppf
Plots the power-law-predicted value on the Y-axis against the real values along the X-axis. Can be used as a diagnostic of the fit quality.
plfit/plfit.py
def plotppf(self,x=None,xmin=None,alpha=None,dolog=True,**kwargs): """ Plots the power-law-predicted value on the Y-axis against the real values along the X-axis. Can be used as a diagnostic of the fit quality. """ if not(xmin): xmin=self._xmin if not(alpha): alp...
def plotppf(self,x=None,xmin=None,alpha=None,dolog=True,**kwargs): """ Plots the power-law-predicted value on the Y-axis against the real values along the X-axis. Can be used as a diagnostic of the fit quality. """ if not(xmin): xmin=self._xmin if not(alpha): alp...
[ "Plots", "the", "power", "-", "law", "-", "predicted", "value", "on", "the", "Y", "-", "axis", "against", "the", "real", "values", "along", "the", "X", "-", "axis", ".", "Can", "be", "used", "as", "a", "diagnostic", "of", "the", "fit", "quality", "."...
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L609-L635
[ "def", "plotppf", "(", "self", ",", "x", "=", "None", ",", "xmin", "=", "None", ",", "alpha", "=", "None", ",", "dolog", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "not", "(", "xmin", ")", ":", "xmin", "=", "self", ".", "_xmin", "i...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.lognormal
Use the maximum likelihood estimator for a lognormal distribution to produce the best-fit lognormal parameters
plfit/plfit.py
def lognormal(self,doprint=True): """ Use the maximum likelihood estimator for a lognormal distribution to produce the best-fit lognormal parameters """ # N = float(self.data.shape[0]) # mu = log(self.data).sum() / N # sigmasquared = ( ( log(self.data) - mu )**2 )...
def lognormal(self,doprint=True): """ Use the maximum likelihood estimator for a lognormal distribution to produce the best-fit lognormal parameters """ # N = float(self.data.shape[0]) # mu = log(self.data).sum() / N # sigmasquared = ( ( log(self.data) - mu )**2 )...
[ "Use", "the", "maximum", "likelihood", "estimator", "for", "a", "lognormal", "distribution", "to", "produce", "the", "best", "-", "fit", "lognormal", "parameters" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L709-L751
[ "def", "lognormal", "(", "self", ",", "doprint", "=", "True", ")", ":", "# N = float(self.data.shape[0])", "# mu = log(self.data).sum() / N", "# sigmasquared = ( ( log(self.data) - mu )**2 ).sum() / N", "# self.lognormal_mu = mu", "# self.lognormal_sigma = np.sqrt(sigmasquared)", "# se...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.plot_lognormal_pdf
Plot the fitted lognormal distribution
plfit/plfit.py
def plot_lognormal_pdf(self,**kwargs): """ Plot the fitted lognormal distribution """ if not hasattr(self,'lognormal_dist'): return normalized_pdf = self.lognormal_dist.pdf(self.data)/self.lognormal_dist.pdf(self.data).max() minY,maxY = pylab.gca().get_ylim()...
def plot_lognormal_pdf(self,**kwargs): """ Plot the fitted lognormal distribution """ if not hasattr(self,'lognormal_dist'): return normalized_pdf = self.lognormal_dist.pdf(self.data)/self.lognormal_dist.pdf(self.data).max() minY,maxY = pylab.gca().get_ylim()...
[ "Plot", "the", "fitted", "lognormal", "distribution" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L753-L762
[ "def", "plot_lognormal_pdf", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'lognormal_dist'", ")", ":", "return", "normalized_pdf", "=", "self", ".", "lognormal_dist", ".", "pdf", "(", "self", ".", "data", ")"...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
plfit.plot_lognormal_cdf
Plot the fitted lognormal distribution
plfit/plfit.py
def plot_lognormal_cdf(self,**kwargs): """ Plot the fitted lognormal distribution """ if not hasattr(self,'lognormal_dist'): return x=np.sort(self.data) n=len(x) xcdf = np.arange(n,0,-1,dtype='float')/float(n) lcdf = self.lognormal_dist.sf(x) ...
def plot_lognormal_cdf(self,**kwargs): """ Plot the fitted lognormal distribution """ if not hasattr(self,'lognormal_dist'): return x=np.sort(self.data) n=len(x) xcdf = np.arange(n,0,-1,dtype='float')/float(n) lcdf = self.lognormal_dist.sf(x) ...
[ "Plot", "the", "fitted", "lognormal", "distribution" ]
keflavich/plfit
python
https://github.com/keflavich/plfit/blob/7dafa6302b427ba8c89651148e3e9d29add436c3/plfit/plfit.py#L764-L779
[ "def", "plot_lognormal_cdf", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'lognormal_dist'", ")", ":", "return", "x", "=", "np", ".", "sort", "(", "self", ".", "data", ")", "n", "=", "len", "(", "x", ...
7dafa6302b427ba8c89651148e3e9d29add436c3
test
sanitize_turbo
Sanitizes HTML, removing not allowed tags and attributes. :param str|unicode html: :param list allowed_tags: List of allowed tags. :param dict allowed_attrs: Dictionary with attributes allowed for tags. :rtype: unicode
yaturbo/toolbox.py
def sanitize_turbo(html, allowed_tags=TURBO_ALLOWED_TAGS, allowed_attrs=TURBO_ALLOWED_ATTRS): """Sanitizes HTML, removing not allowed tags and attributes. :param str|unicode html: :param list allowed_tags: List of allowed tags. :param dict allowed_attrs: Dictionary with attributes allowed for tags. ...
def sanitize_turbo(html, allowed_tags=TURBO_ALLOWED_TAGS, allowed_attrs=TURBO_ALLOWED_ATTRS): """Sanitizes HTML, removing not allowed tags and attributes. :param str|unicode html: :param list allowed_tags: List of allowed tags. :param dict allowed_attrs: Dictionary with attributes allowed for tags. ...
[ "Sanitizes", "HTML", "removing", "not", "allowed", "tags", "and", "attributes", "." ]
idlesign/django-yaturbo
python
https://github.com/idlesign/django-yaturbo/blob/a5ac9053bb800ea8082dc0615b93398917c3290a/yaturbo/toolbox.py#L18-L28
[ "def", "sanitize_turbo", "(", "html", ",", "allowed_tags", "=", "TURBO_ALLOWED_TAGS", ",", "allowed_attrs", "=", "TURBO_ALLOWED_ATTRS", ")", ":", "return", "clean", "(", "html", ",", "tags", "=", "allowed_tags", ",", "attributes", "=", "allowed_attrs", ",", "str...
a5ac9053bb800ea8082dc0615b93398917c3290a
test
YandexTurboFeed.configure_analytics_yandex
Configure Yandex Metrika analytics counter. :param str|unicode ident: Metrika counter ID. :param dict params: Additional params.
yaturbo/toolbox.py
def configure_analytics_yandex(self, ident, params=None): """Configure Yandex Metrika analytics counter. :param str|unicode ident: Metrika counter ID. :param dict params: Additional params. """ params = params or {} data = { 'type': 'Yandex', '...
def configure_analytics_yandex(self, ident, params=None): """Configure Yandex Metrika analytics counter. :param str|unicode ident: Metrika counter ID. :param dict params: Additional params. """ params = params or {} data = { 'type': 'Yandex', '...
[ "Configure", "Yandex", "Metrika", "analytics", "counter", "." ]
idlesign/django-yaturbo
python
https://github.com/idlesign/django-yaturbo/blob/a5ac9053bb800ea8082dc0615b93398917c3290a/yaturbo/toolbox.py#L170-L188
[ "def", "configure_analytics_yandex", "(", "self", ",", "ident", ",", "params", "=", "None", ")", ":", "params", "=", "params", "or", "{", "}", "data", "=", "{", "'type'", ":", "'Yandex'", ",", "'id'", ":", "ident", ",", "}", "if", "params", ":", "dat...
a5ac9053bb800ea8082dc0615b93398917c3290a
test
LabelWidget.tag_list
Generates a list of tags identifying those previously selected. Returns a list of tuples of the form (<tag name>, <CSS class name>). Uses the string names rather than the tags themselves in order to work with tag lists built from forms not fully submitted.
taggit_labels/widgets.py
def tag_list(self, tags): """ Generates a list of tags identifying those previously selected. Returns a list of tuples of the form (<tag name>, <CSS class name>). Uses the string names rather than the tags themselves in order to work with tag lists built from forms not fully su...
def tag_list(self, tags): """ Generates a list of tags identifying those previously selected. Returns a list of tuples of the form (<tag name>, <CSS class name>). Uses the string names rather than the tags themselves in order to work with tag lists built from forms not fully su...
[ "Generates", "a", "list", "of", "tags", "identifying", "those", "previously", "selected", "." ]
bennylope/django-taggit-labels
python
https://github.com/bennylope/django-taggit-labels/blob/7afef34125653e958dc5dba0280904a0714aa808/taggit_labels/widgets.py#L33-L45
[ "def", "tag_list", "(", "self", ",", "tags", ")", ":", "return", "[", "(", "tag", ".", "name", ",", "\"selected taggit-tag\"", "if", "tag", ".", "name", "in", "tags", "else", "\"taggit-tag\"", ")", "for", "tag", "in", "self", ".", "model", ".", "object...
7afef34125653e958dc5dba0280904a0714aa808
test
Sphere.gcd
Calculate the great circle distance between two points on the earth (specified in decimal degrees)
localization/geometry.py
def gcd(self, lon1, lat1, lon2, lat2): """ Calculate the great circle distance between two points on the earth (specified in decimal degrees) """ # convert decimal degrees to radians lon1, lat1, lon2, lat2 = map(math.radians, [lon1, lat1, lon2, lat2]) # haversine...
def gcd(self, lon1, lat1, lon2, lat2): """ Calculate the great circle distance between two points on the earth (specified in decimal degrees) """ # convert decimal degrees to radians lon1, lat1, lon2, lat2 = map(math.radians, [lon1, lat1, lon2, lat2]) # haversine...
[ "Calculate", "the", "great", "circle", "distance", "between", "two", "points", "on", "the", "earth", "(", "specified", "in", "decimal", "degrees", ")" ]
kamalshadi/Localization
python
https://github.com/kamalshadi/Localization/blob/f99470712c65a48896f6e4095181a1a3c9545d43/localization/geometry.py#L634-L649
[ "def", "gcd", "(", "self", ",", "lon1", ",", "lat1", ",", "lon2", ",", "lat2", ")", ":", "# convert decimal degrees to radians", "lon1", ",", "lat1", ",", "lon2", ",", "lat2", "=", "map", "(", "math", ".", "radians", ",", "[", "lon1", ",", "lat1", ",...
f99470712c65a48896f6e4095181a1a3c9545d43
test
SSHKey.hash_md5
Calculate md5 fingerprint. Shamelessly copied from http://stackoverflow.com/questions/6682815/deriving-an-ssh-fingerprint-from-a-public-key-in-python For specification, see RFC4716, section 4.
sshpubkeys/keys.py
def hash_md5(self): """Calculate md5 fingerprint. Shamelessly copied from http://stackoverflow.com/questions/6682815/deriving-an-ssh-fingerprint-from-a-public-key-in-python For specification, see RFC4716, section 4.""" fp_plain = hashlib.md5(self._decoded_key).hexdigest() retur...
def hash_md5(self): """Calculate md5 fingerprint. Shamelessly copied from http://stackoverflow.com/questions/6682815/deriving-an-ssh-fingerprint-from-a-public-key-in-python For specification, see RFC4716, section 4.""" fp_plain = hashlib.md5(self._decoded_key).hexdigest() retur...
[ "Calculate", "md5", "fingerprint", "." ]
ojarva/python-sshpubkeys
python
https://github.com/ojarva/python-sshpubkeys/blob/86dc1ab27ce82dcc091ce127416cc3ee219e9bec/sshpubkeys/keys.py#L149-L156
[ "def", "hash_md5", "(", "self", ")", ":", "fp_plain", "=", "hashlib", ".", "md5", "(", "self", ".", "_decoded_key", ")", ".", "hexdigest", "(", ")", "return", "\"MD5:\"", "+", "':'", ".", "join", "(", "a", "+", "b", "for", "a", ",", "b", "in", "z...
86dc1ab27ce82dcc091ce127416cc3ee219e9bec
test
SSHKey.hash_sha256
Calculate sha256 fingerprint.
sshpubkeys/keys.py
def hash_sha256(self): """Calculate sha256 fingerprint.""" fp_plain = hashlib.sha256(self._decoded_key).digest() return (b"SHA256:" + base64.b64encode(fp_plain).replace(b"=", b"")).decode("utf-8")
def hash_sha256(self): """Calculate sha256 fingerprint.""" fp_plain = hashlib.sha256(self._decoded_key).digest() return (b"SHA256:" + base64.b64encode(fp_plain).replace(b"=", b"")).decode("utf-8")
[ "Calculate", "sha256", "fingerprint", "." ]
ojarva/python-sshpubkeys
python
https://github.com/ojarva/python-sshpubkeys/blob/86dc1ab27ce82dcc091ce127416cc3ee219e9bec/sshpubkeys/keys.py#L158-L161
[ "def", "hash_sha256", "(", "self", ")", ":", "fp_plain", "=", "hashlib", ".", "sha256", "(", "self", ".", "_decoded_key", ")", ".", "digest", "(", ")", "return", "(", "b\"SHA256:\"", "+", "base64", ".", "b64encode", "(", "fp_plain", ")", ".", "replace", ...
86dc1ab27ce82dcc091ce127416cc3ee219e9bec
test
SSHKey.hash_sha512
Calculates sha512 fingerprint.
sshpubkeys/keys.py
def hash_sha512(self): """Calculates sha512 fingerprint.""" fp_plain = hashlib.sha512(self._decoded_key).digest() return (b"SHA512:" + base64.b64encode(fp_plain).replace(b"=", b"")).decode("utf-8")
def hash_sha512(self): """Calculates sha512 fingerprint.""" fp_plain = hashlib.sha512(self._decoded_key).digest() return (b"SHA512:" + base64.b64encode(fp_plain).replace(b"=", b"")).decode("utf-8")
[ "Calculates", "sha512", "fingerprint", "." ]
ojarva/python-sshpubkeys
python
https://github.com/ojarva/python-sshpubkeys/blob/86dc1ab27ce82dcc091ce127416cc3ee219e9bec/sshpubkeys/keys.py#L163-L166
[ "def", "hash_sha512", "(", "self", ")", ":", "fp_plain", "=", "hashlib", ".", "sha512", "(", "self", ".", "_decoded_key", ")", ".", "digest", "(", ")", "return", "(", "b\"SHA512:\"", "+", "base64", ".", "b64encode", "(", "fp_plain", ")", ".", "replace", ...
86dc1ab27ce82dcc091ce127416cc3ee219e9bec