mosaicperm.tilings.Tiling

class mosaicperm.tilings.Tiling(tiles: list, check_valid: bool = False)[source]

A class to store tilings used in mosaic tests.

Parameters:
tileslist

List of tuples of two integer np.arrays. E.g., tile i of an array is data[tile[i][0]][:, tile[i][1]].

check_validbool

If True, runs check_valid_tiling() during initialization.

Raises:
ValueErrorIf tiles does not define a partition of the cartesian

product of {0, ..., n} x {0, ..., k} for some integers n and k.

Notes

This class thinly wraps python list.

Examples

>>> import numpy as np
>>> import mosaicperm as mp
>>> 
>>> # a valid tiling of {0, 1} x {0, 1, 2, 3}
>>> tiles0 = [
...     (np.array([0]), np.array([0, 2])),
...     (np.array([0]), np.array([1, 3])),
...     (np.array([1]), np.array([0, 1])),
...     (np.array([1]), np.array([2, 3])),
... ]
>>> tiling = mp.tilings.Tiling(tiles0, check_valid=True)
>>> # an invalid tiling due to repeats
>>> tiles1 = [
...     (np.array([0, 2]), np.array([0, 1])),
...     (np.array([1]), np.array([0, 1])),
...     (np.array([0]), np.array([1])),
... ]
>>> tiling = mp.tilings.Tiling(tiles1, check_valid=True)
Traceback (most recent call last):
        ...
ValueError: Tile 2 is not disjoint from tiles 0-1.

Methods

append(object, /)

Append object to the end of the list.

clear(/)

Remove all items from list.

copy(/)

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

index(value[, start, stop])

Return first index of value.

insert(index, object, /)

Insert object before index.

load(filename, **kwargs)

Loads a tiling from a .npy file.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

reverse(/)

Reverse IN PLACE.

save(filename)

Saves the tiling to filename.npy.

sort(*[, key, reverse])

Sort the list in ascending order and return None.