alhambra.fastreduceD#

Module Contents#

Classes#

FTile

FTilesArray

TileWithUse

Base class for protocol classes.

FGlueList

FTileList

_FastTileSet

Functions#

_fdg(dir, gs1, gs2)

_ffakedouble_n(…)

_ffakesingle(→ Sequence[FTile])

ptins(→ list[list[numpy.ndarray[Any, ...)

Calculate potential tile attachments to input neighborhoods

gmatch(fts, g1, g2[, equiv])

gcomp(fts, g1, g2[, equiv])

findmovetiles(fts, tilei, direction, allin, allout)

_2go_moveandfill(→ TMap)

_2go_findtrialmoves(fts, tilei, direction[, equiv])

_2go_checkandmove(fts, ct, x, y, i, tmap[, exclude, equiv])

is_2go_nn(…)

gen_2go_maps(→ dict[int, TMap])

gen_2go_profile(fts[, equiv, tmaps, also22go])

is_2go_equiv(fts[, equiv, tmaps, origsens])

is_22go_equiv(fts[, equiv, ins2go, orig22go])

fta_to_ft(stiles, un[, sel])

isatamequiv(fts, equiv[, initptins])

tilemerge(fts, equiv, t1, t2[, preserveuse])

_findpotentialtilemerges(fts, equiv)

_findpotentialgluemerges(fts, equiv)

_recfix(fts, equiv, tp, initptins[, check2go, tmaps, ...])

_tilereduce(fts[, equiv, check2go, initptins, ...])

_gluereduce(fts[, equiv, check2go, check22go, ...])

_single_reduce_tiles(p)

_single_reduce_ends(p)

reduce_tiles(tileset[, preserve, tries, threads, ...])

Apply tile reduction algorithm, preserving some set of properties, and using a multiprocessing pool.

reduce_ends(tileset[, preserve, tries, threads, ...])

Apply end reduction algorithm, preserving some set of properties, and using a multiprocessing pool.

Attributes#

TMap

TAU

other

uU

uN

uI

uO

uB

uP

invertuse

usedict

Equiv

RSEL

FTI

FTS

HSEL

VSEL

directions

alhambra.fastreduceD.TMap[source]#
class alhambra.fastreduceD.FTile[source]#
name: str[source]#
used: bool[source]#
glues: numpy.typing.NDArray[numpy.int64][source]#
use: numpy.typing.NDArray[numpy.int64][source]#
color: Any[source]#
structure: Type[alhambra.tiles.Tile][source]#
dfake: int[source]#
sfake: int[source]#
class alhambra.fastreduceD.FTilesArray[source]#
color: Any[source]#
use: numpy.ndarray[Any, numpy.dtype[numpy.int64]][source]#
glues: numpy.ndarray[Any, numpy.dtype[numpy.int64]][source]#
name: numpy.ndarray[Any, numpy.dtype[numpy.str0]][source]#
used: numpy.ndarray[Any, numpy.dtype[numpy.bool8]][source]#
structure: numpy.ndarray[Any, numpy.dtype[numpy.str0]][source]#
dfake: numpy.ndarray[Any, numpy.dtype[numpy.int64]][source]#
sfake: numpy.ndarray[Any, numpy.dtype[numpy.int64]][source]#
__len__() int[source]#
classmethod from_ftiles(ftiles: Iterable[FTile]) FTilesArray[source]#
alhambra.fastreduceD.TAU = 2[source]#
alhambra.fastreduceD.other = [2, 3, 0, 1][source]#
class alhambra.fastreduceD.TileWithUse[source]#

Bases: Protocol

Base class for protocol classes.

Protocol classes are defined as:

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example:

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...
property use: list[int][source]#
alhambra.fastreduceD.uU = 0[source]#
alhambra.fastreduceD.uN = 1[source]#
alhambra.fastreduceD.uI = 2[source]#
alhambra.fastreduceD.uO = 3[source]#
alhambra.fastreduceD.uB = 4[source]#
alhambra.fastreduceD.uP = 5[source]#
alhambra.fastreduceD.invertuse = [0, 1, 3, 2, 4, 5][source]#
alhambra.fastreduceD.usedict[source]#
alhambra.fastreduceD.Equiv[source]#
class alhambra.fastreduceD.FGlueList(glues: alhambra.glues.GlueList[alhambra.glues.Glue])[source]#
blankequiv() Equiv[source]#
iseq(equiv: Equiv, a: int, b: int) bool[source]#
domerge(equiv: Equiv, a: int, b: int, preserveuse: bool = False) Equiv[source]#
class alhambra.fastreduceD.FTileList(tiles: alhambra.tiles.TileList[alhambra.tiles.Tile], gluelist: FGlueList)[source]#
stiles: FTilesArray[source]#
htiles: FTilesArray[source]#
vtiles: FTilesArray[source]#
alhambra.fastreduceD.RSEL = (2, 3, 0, 1)[source]#
alhambra.fastreduceD.FTI = (1, 0, 1, 0)[source]#
alhambra.fastreduceD.FTS = ()[source]#
alhambra.fastreduceD._fdg(dir, gs1, gs2)[source]#
alhambra.fastreduceD._ffakedouble_n(tn: int, sta, gluelist: FGlueList, outputonly: bool = True, *, dir4: Literal[True], equiv=None) tuple[list[FTile], list[FTile], list[FTile], list[FTile]][source]#
alhambra.fastreduceD._ffakedouble_n(tn: int, sta, gluelist: FGlueList, outputonly: bool = True, *, dir4: Literal[False] = False, equiv=None) tuple[list[FTile], list[FTile]]
alhambra.fastreduceD.HSEL = ((1, 0, 5, 6), (2, 3, 4, 0))[source]#
alhambra.fastreduceD.VSEL = ((1, 2, 0, 6), (0, 3, 4, 5))[source]#
alhambra.fastreduceD._ffakesingle(ftile: FTile, gluelist: FGlueList) Sequence[FTile][source]#
class alhambra.fastreduceD._FastTileSet(tilesystem: alhambra.tilesets.TileSet)[source]#
gluelist: FGlueList[source]#
tilelist: FTileList[source]#
applyequiv(ts: alhambra.tilesets.TileSet, equiv) alhambra.tilesets.TileSet[source]#
togluemergespec(ts, equiv)[source]#
alhambra.fastreduceD.ptins(fts: _FastTileSet, equiv: Equiv | None = None, tau=2) list[list[numpy.ndarray[Any, numpy.dtype[numpy.int64]]]][source]#

Calculate potential tile attachments to input neighborhoods

alhambra.fastreduceD.gmatch(fts, g1, g2, equiv=None)[source]#
alhambra.fastreduceD.gcomp(fts, g1, g2, equiv=None)[source]#
alhambra.fastreduceD.findmovetiles(fts, tilei, direction, allin, allout)[source]#
alhambra.fastreduceD._2go_moveandfill(fts: _FastTileSet, t: int, i: int, allin=True, allout=True, pdir=None, x=0, y=0, old_d=None) TMap[source]#
alhambra.fastreduceD._2go_findtrialmoves(fts: _FastTileSet, tilei, direction, equiv=None)[source]#
alhambra.fastreduceD.directions = [(0,), (1, 0), (0, 1), ()][source]#
alhambra.fastreduceD._2go_checkandmove(fts, ct, x, y, i, tmap: TMap, exclude=tuple(), equiv=None)[source]#
alhambra.fastreduceD.is_2go_nn(fts: _FastTileSet, tn: int, un: int, equiv: numpy.ndarray[Any, numpy.dtype[numpy.int64]], tau: int = 2, tmaps: dict[int, TMap] | None = None, *, retall: Literal[True], also22go: bool = False) tuple[bool, tuple[Any, Any] | None][source]#
alhambra.fastreduceD.is_2go_nn(fts: _FastTileSet, tn: int, un: int, equiv: numpy.ndarray[Any, numpy.dtype[numpy.int64]], tau: int = 2, tmaps: dict[int, TMap] | None = None, *, retall: Literal[False] = False, also22go: bool = False) bool
alhambra.fastreduceD.gen_2go_maps(fts: _FastTileSet) dict[int, TMap][source]#
alhambra.fastreduceD.gen_2go_profile(fts: _FastTileSet, equiv=None, tmaps=None, also22go: bool = False)[source]#
alhambra.fastreduceD.is_2go_equiv(fts: _FastTileSet, equiv: Equiv | None = None, tmaps=None, origsens=None)[source]#
alhambra.fastreduceD.is_22go_equiv(fts, equiv=None, ins2go=None, orig22go=None)[source]#
alhambra.fastreduceD.fta_to_ft(stiles, un, sel=None)[source]#
alhambra.fastreduceD.isatamequiv(fts, equiv, initptins=None)[source]#
alhambra.fastreduceD.tilemerge(fts, equiv, t1, t2, preserveuse=False)[source]#
alhambra.fastreduceD._findpotentialtilemerges(fts, equiv)[source]#
alhambra.fastreduceD._findpotentialgluemerges(fts, equiv)[source]#
alhambra.fastreduceD._recfix(fts, equiv, tp, initptins, check2go=False, tmaps=None, orig2go=None, orig22go=None, check22go=False, checkld=False, chain=None, preserveuse=False)[source]#
alhambra.fastreduceD._tilereduce(fts, equiv=None, check2go=False, initptins=None, check22go=False, checkld=False, preserveuse=False)[source]#
alhambra.fastreduceD._gluereduce(fts: _FastTileSet, equiv: Equiv | None = None, check2go: bool = False, check22go: bool = False, checkld: bool = False, initptins=None, preserveuse: bool = False)[source]#
alhambra.fastreduceD._single_reduce_tiles(p)[source]#
alhambra.fastreduceD._single_reduce_ends(p)[source]#
alhambra.fastreduceD.reduce_tiles(tileset, preserve=('s22', 'ld'), tries=10, threads=1, returntype='equiv', best=1, key=None, initequiv=None)[source]#

Apply tile reduction algorithm, preserving some set of properties, and using a multiprocessing pool.

Parameters:
  • tileset (TileSet) – The system to reduce.

  • preserve (a tuple or list of strings, optional) – The properties to preserve. Currently supported are ‘s1’ for first order sensitivity, ‘s2’ for second order sensitivity, ‘s22’ for two-by-two sensitivity, ‘ld’ for small lattice defects, and ‘gs’ for glue sense (to avoid spurious hierarchical attachment). Default is currently (‘s22’, ‘ld’).

  • tries (int, optional) – The number of times to run the algorithm.

  • threads (int, optional) – The number of threads to use (using multiprocessing).

  • returntype ('TileSet' or 'equiv' (default 'equiv')) – The type of object to return. If ‘equiv’, returns an array of glue equivalences (or list, if best != 1) that can be applied to the tileset with apply_equiv, or used for further reduction. If ‘TileSet’, return a TileSet with the equiv already applied (or a list, if best != 1).

  • best (int or None, optional) – The number of systems to return. If 1, the result will be returned directly; if k > 1, a list will be returned of the best k results (per cmp); if k = None, a list of all results will be returned, sorted by cmp. (default 1)

  • key (function (ts, equiv1, equiv2) -> some number/comparable) – A comparison function for equivs, to sort the results. FIXME: documentation needed. Default (if None) here is to sort by number of glues in the system, regardless of number of tiles.

  • initequiv (equiv) – If provided, the equivalence array to start from. If None, start from the tileset without any merged glues.

Returns:

reduced – The reduced system/systems

Return type:

single TileSet

alhambra.fastreduceD.reduce_ends(tileset, preserve=('s22', 'ld'), tries=10, threads=1, returntype='equiv', best=1, key=None, initequiv=None)[source]#

Apply end reduction algorithm, preserving some set of properties, and using a multiprocessing pool.

Parameters:
  • tileset (TileSet) – The system to reduce.

  • preserve (a tuple or list of strings, optional) – The properties to preserve. Currently supported are ‘s1’ for first order sensitivity, ‘s2’ for second order sensitivity, ‘s22’ for two-by-two sensitivity, ‘ld’ for small lattice defects, and ‘gs’ for glue sense (to avoid spurious hierarchical attachment). Default is currently (‘s22’, ‘ld’).

  • tries (int, optional) – The number of times to run the algorithm.

  • threads (int, optional) – The number of threads to use (using multiprocessing).

  • returntype ('TileSet' or 'equiv' (default 'equiv')) – The type of object to return. If ‘equiv’, returns an array of glue equivalences (or list, if best != 1) that can be applied to the tileset with apply_equiv, or used for further reduction. If ‘TileSet’, return a TileSet with the equiv already applied (or a list, if best != 1).

  • best (int or None, optional) – The number of systems to return. If 1, the result will be returned directly; if k > 1, a list will be returned of the best k results (per cmp); if k = None, a list of all results will be returned, sorted by cmp. (default 1)

  • key (function (ts, equiv1, equiv2) -> some number/comparable) – A comparison function for equivs, to sort the results. FIXME: documentation needed. Default (if None) here is to sort by number of glues in the system, regardless of number of tiles.

  • initequiv (equiv) – If provided, the equivalence array to start from. If None, start from the tileset without any merged glues.

Returns:

reduced – The reduced system/systems

Return type:

single TileSet