alhambra.sensitivitynew#

Module Contents#

Classes#

FakeSingle

Base class for a tile.

CounterSet

Dict subclass for counting hashable items. Sometimes called a bag

SetSet

set() -> new empty set object

PathSet

dict() -> new empty dictionary

Functions#

_fakesingle(tile)

_fakesingles(tiles)

sensitivity_classes(tileset[, count, _maxorder])

Attributes#

_rev

class alhambra.sensitivitynew.FakeSingle(edges: Iterable[alhambra.glues.Glue | str] | None = None, name: str | None = None, color: Color | None = None, stoic: float | None = None, note: str | dict[str, Any] | None = None, use: Sequence[alhambra.glues.Use | int | str] | None = None, fake: bool = False, uses: Sequence[Sequence[alhambra.glues.Use | int | str]] | None = None)[source]#

Bases: alhambra.tiles.Tile

Base class for a tile.

class alhambra.sensitivitynew.CounterSet(iterable=None, /, **kwds)[source]#

Bases: collections.Counter

Dict subclass for counting hashable items. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values.

>>> c = Counter('abcdeabcdabcaba')  # count elements from a string
>>> c.most_common(3)                # three most common elements
[('a', 5), ('b', 4), ('c', 3)]
>>> sorted(c)                       # list all unique elements
['a', 'b', 'c', 'd', 'e']
>>> ''.join(sorted(c.elements()))   # list elements with repetitions
'aaaaabbbbcccdde'
>>> sum(c.values())                 # total of all counts
15
>>> c['a']                          # count of letter 'a'
5
>>> for elem in 'shazam':           # update counts from an iterable
...     c[elem] += 1                # by adding 1 to each element's count
>>> c['a']                          # now there are seven 'a'
7
>>> del c['b']                      # remove all 'b'
>>> c['b']                          # now there are zero 'b'
0
>>> d = Counter('simsalabim')       # make another counter
>>> c.update(d)                     # add in the second counter
>>> c['a']                          # now there are nine 'a'
9
>>> c.clear()                       # empty the counter
>>> c
Counter()

Note: If a count is set to zero or reduced to zero, it will remain in the counter until the entry is deleted or the counter is cleared:

>>> c = Counter('aaabbc')
>>> c['b'] -= 2                     # reduce the count of 'b' by two
>>> c.most_common()                 # 'b' is still in, but its count is zero
[('a', 3), ('c', 1), ('b', 0)]
add(val, valthrowaway)[source]#
class alhambra.sensitivitynew.SetSet[source]#

Bases: set

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

add(val, valthrowaway)[source]#

Add an element to a set.

This has no effect if the element is already present.

class alhambra.sensitivitynew.PathSet[source]#

Bases: dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

add(key, val)[source]#
alhambra.sensitivitynew._fakesingle(tile: alhambra.tiles.Tile)[source]#
alhambra.sensitivitynew._fakesingles(tiles)[source]#
alhambra.sensitivitynew._rev = [2, 3, 0, 1][source]#
alhambra.sensitivitynew.sensitivity_classes(tileset, count=False, _maxorder=2)[source]#