lexarrayset

lexical array set operations

these operations are based upon the one dimensional array set operations from numpy.lib.arraysetops, but generalised to work for sets of m-tuples, where each element is stored as a row of a 2d m by n array, using numpy’s ‘lexsort’ lexical sorting function.

class cmepy.lexarrayset.LexArraySet(data, unique_data=False)

LexArraySet is an implementation of a set as a 2d array, where the members of the set are the rows of the array. The rows are ordered using lexical ordering.

difference(rhs)
las1.difference(las2) -> diff; diff’s rows are those of las1 not in las2
difference_update(rhs)
in place difference
intersection(rhs)
las1.intersection(las2) -> isect; isect’s rows common to las1, las2
intersection_update(rhs)
in place intersection
member(rhs)
las1.member(las2) -> mask; mask[i] True iff row i of las1 is in las2
shift(offset)

las.shift(offset) -> slas; where rows of slas are rows of las + offset

offset must be of compatible shape to the rows of las.

shift_update(shift)
in place shift
size
number of elements in set (equal to number of rows of the lexical array)
split(rhs)
las1.split(las2) -> (las1.intersect(las2), las1.difference(las2))
union(rhs)
las1.union(las2) -> u; u’s rows are union of rows in las1, las2
union_update(rhs)
in place union
cmepy.lexarrayset.create(data, unique_data=False)
returns a new LexArraySet for the given data
cmepy.lexarrayset.difference(las1, las2)
returns las1 difference las2
cmepy.lexarrayset.empty(dim)
returns an empty LexArraySet of dimension dim.
cmepy.lexarrayset.intersection(las1, las2)
intersection of las1 with las2
cmepy.lexarrayset.member(las1, las2)

vectorised set membership operation for lexical array sets las1, las2

returns a boolean array ‘mask’ such that

las1[:, mask] is the subset of rows of las1 that are also rows of las2

cmepy.lexarrayset.nonunique_member(arr1, las2)

vectorised set membership operation for lexical array arr1 and lexical array set las2

in general, the rows of array arr1 can be non-unique

returns a boolean array ‘mask’ such that arr1[:, mask] is the subset of rows of arr1 that are also rows of las2

cmepy.lexarrayset.shift(las, offset)
shifts all states in las by offset
cmepy.lexarrayset.split(las1, las2)
returns (las1 intersect las2, las1 difference las2)
cmepy.lexarrayset.union(las1, las2)
union of las1 with las2
cmepy.lexarrayset.unique(las, return_inverse=False)

returns a sorted vector of unique states

if the optional flag return_inverse is set to True, additionally returns an index vector used to inverse the unique operation and recover the original vector

Previous topic

lazy_dict

Next topic

measurement

This Page