httk.core.vectors.vector module

class httk.core.vectors.vector.MutableVector[source]

Bases: object

class httk.core.vectors.vector.Scalar[source]

Bases: httk.core.vectors.vector.Vector

Baseclass for scalars

class httk.core.vectors.vector.Vector[source]

Bases: object

Defines the general Vector API

classmethod chain_vecs(vecs)[source]

Optimized chaining of Vectors.

vecs: a list (or tuple) of vectors.

Returns the same thing as
Vector.create(vecs, chain=True)
i.e., removes outermost dimension and chain the sub-sequences. If input=[[1 2 3],[4,5,6]], then
Vector.chain(input) -> [1,2,3,4,5,6]

Subclasses may add requirements on the vectors to use this method over <subclass>.create

classmethod create(data, chain=False)[source]

Create a Vector from various types of sequenced data.

Will return a suitable Vector subclass for the type of data given

classmethod eye(dims)[source]

Create a diagonal one-matrix with the given dimensions

ged_prestacked(other)[source]
ged_stackedinsert(pos, other)[source]
get_append(other)[source]
get_extend(other)[source]
get_insert(pos, other)[source]
get_prepend(other)[source]
get_prextend(other)[source]
get_stacked(other)[source]
classmethod random(dims, minval=-100, maxval=100)[source]

Create a zero matrix with the given dimensions

classmethod stack_vecs(vecs)[source]

Optimized stacking of FracVectors.

vecs = a list (or tuple) of fracvectors.

Returns the same thing as:

Vector.create(vecs)

Subclasses may add requirements on the vectors to use this method over <subclass>.create

classmethod use(old)[source]

Make sure variable is a FracVector, and if not, convert it.

classmethod zeros(dims)[source]

Create a zero matrix with the given dimensions

httk.core.vectors.vector.main()[source]
httk.core.vectors.vector.nested_map_fractions_list(op, *ls)[source]

Map an operator over a nested list, but checks every element for a method to_fractions() and uses this to further convert objects into lists of Fraction.

httk.core.vectors.vector.nested_map_list(op, *ls)[source]

Map an operator over a nested list. (i.e., the same as the built-in map(), but works recursively on a nested list)

httk.core.vectors.vector.nested_reduce(op, l, initializer=None)[source]

Same as built-in reduce, but operates on a nested tuple/list/sequence.

httk.core.vectors.vector.nested_reduce_fractions(op, l, initializer=None)[source]

Same as built-in reduce, but operates on a nested tuple/list/sequence. Also checks every element for a method to_fractions() and uses this to further convert such elements to lists of fractions.

httk.core.vectors.vector.nested_reduce_levels(op, l, level=1, initializer=None)[source]

Same as built-in reduce, but operates on a nested tuple/list/sequence.

httk.core.vectors.vector.tuple_eye(dims, onepos=0)[source]

Create a matrix with the given dimensions and 1 on the diagonal

httk.core.vectors.vector.tuple_index(dims, uppidx=())[source]

Create a nested tuple where every element is a tuple indicating the position of that tuple

httk.core.vectors.vector.tuple_random(dims, minval, maxval)[source]

Create a nested tuple with the given dimensions filled with random numbers between minval and maxval

httk.core.vectors.vector.tuple_slice(l, key)[source]

Given a python slice (i.e., what you get to __getitem__ when you write A[3:2]), cut out the relevant nested tuple.

httk.core.vectors.vector.tuple_zeros(dims)[source]

Create a netsted tuple with the given dimensions filled with zeroes