flins.space package

Submodules

flins.space.grids module

Be a spatial divider, not a uniter

Support the calculation of adjacency, distance, and mirroring on hexagonal grids with various shapes.

class flins.space.grids.Grid[source]

Bases: flins.base.Base

abstract property all_entries

Return all entries in the grid

abstract distance(loc1, loc2)[source]

The distance between the locs on this grid

abstract entry(loc)[source]

Give the grid entry at the passed loc

abstract mirror(loc)[source]

Return loc, mirrored across boundaries if outside the grid

abstract neighbors(loc)[source]

Return the coordinates of neighbors

abstract validate(loc)[source]

Is loc valid within the grid’s coordinate system?

abstract within(loc)[source]

Is loc within the grid?

class flins.space.grids.HexGrid(n, mirror=True)[source]

Bases: flins.space.grids.Grid

A world that is in a hexagonal shape with a radius of n hexes

Create a hexagonal grid that we’ll use as a model of tracts

Parameters
  • n (int) – radius of the world. 0 is a single tract, 1 is seven and so on

  • mirror (bool (True)) – whether to mirror when calculating neighbors and distances

property all_entries

All entries in the grid

distance(loc1, loc2)[source]

Return the distance between two locations, potentially mirroring

entry(loc)[source]

Give the grid entry at that location

mirror(loc)[source]

Return the location, mirrored across the boundary if needed

Use pre-calculated mirrored centers if given, else calculate them. Reference here: https://gamedev.stackexchange.com/questions/137603

neighbors(loc: tuple)[source]

Return neighboring coordinates, mirroring if desired

to_array_indices(loc)[source]

Convert cube coordinates to array location

validate(loc)[source]

Is the passed loc a valid one in cube coords?

within(loc)[source]

Is the passed loc within the non-mirrored grid?

class flins.space.grids.RectGrid(size, mirror=True)[source]

Bases: flins.space.grids.Grid

A rectangular grid of n-by-m hexs

Create a rectangular grid that we’ll use as a model of tracts

Parameters
  • size (tuple (n, m)) – size of the world, n rows and m columns

  • mirror (bool (True)) – whether to mirror when calculating neighbors and distances

property all_entries

Return all entries in the grid

distance(loc1, loc2)[source]

The distance between the locs on this grid

entry(loc)[source]

Give the grid entry at the passed loc

mirror(loc)[source]

Return loc, mirrored across boundaries if outside the grid

neighbors(loc)[source]

Return the coordinates of neighbors

static to_array_indices(loc)[source]

Convert to array indices from cube location

validate(loc)[source]

Is loc valid within the grid’s coordinate system?

within(loc)[source]

Is loc within the non-mirrored grid?

flins.space.space module

Space is the place we store stuff.

A space accounts for the interactions of tracts that are arranged according to some grid layout.

class flins.space.space.Space(kind, size, span=None, mirror=True)[source]

Bases: flins.base.Base

A spatial region of filaments/crosslinkers

Each Space is connected to neighbors in a hexagonal grid that gives many of the properties of 3D space but with easier mechanics.

A generic template for :Parameters: * kind (“hex” or “rect”) – overall shape of the space

  • size (int or tuple) – Radius or x/y size of space

  • span (None or float) – Length of the tracts in x dimension, optional

  • tracts (None or list) – List of tracts

property all_tracts

Give all the tracts back

neighbors(loc)[source]

Give me the neighbors to the specified location

tract(loc)[source]

Single tract at a given location

Parameters
  • loc (tuple) – coordinates for the tract we want

  • mirror (boolean (True)) – Whether or not to mirror across tractspace edges

Returns

Return type

tract or None

flins.space.tract module

Just a slice of the cake^h^h^h^h space.

Tracts are sections of space that extend in a long direction and have adjacent neighboring tracts that also extend in a long direction.

class flins.space.tract.Tract(loc, space)[source]

Bases: flins.base.Base

A single tract in a Space

A single tract in a space

add_mol(kind, mol)[source]

Add a molecule to our lists and dicts thereof

nearest_binding_site(x)[source]

The nearest reachable actin binding site

property neighbors

Who are your neighbors? We don’t want to calculate this each time, but we can’t populate it on creation as there are neighbors that haven’t yet been created. So we populate this list on the first call and then reference the stored version thereafter.

property reachable

Reachable tracts from here. Neighbors and self.

See neighbors documentation for creation method.

Module contents