httk.core.vectors.vector module¶
- class httk.core.vectors.vector.Vector[source]¶
Bases:
objectDefines 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 random(dims, minval=-100, maxval=100)[source]¶
Create a zero matrix with the given dimensions
- 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