API - pytracks.grid Module¶
This module helps wrap data describing a Grid. Please see the examples included to learn how to use it.
Grid¶
-
class
pytracks.grid.Grid(cells)¶ Parameters: cells (Cell) – A list of Cellobjects to seed the currentGridwith.Encapsulates a set of
Cellobjects with helper methods to more easily manipulate them. Other features besides the internal methods are shown below.The
Cellobjects encapsulated can also be accessed by specifying an index:>>> c1 = Cell(1, 1, [1.4, 5.3]) >>> c2 = Cell(1, 2, [1.5, 5.0]) >>> c3 = Cell(1, 3, [1.0, 4.8]) >>> g = Grid([c1, c2, c3]) >>> g[0] <pytracks.grid.Cell object at 0x7f86b1704908> >>> c1 <pytracks.grid.Cell object at 0x7f86b1704908>
The number of
Cellobjects in the currentGridcan be measured by len():>>> len(g) 3
The
Gridclass has the ability to iterate over everyCellobject in the currentGrid:>>> for c in g: ... print(c.point) ... (1, 1) (1, 2) (1, 3)
Cell¶
-
class
pytracks.grid.Cell(x, y, data)¶ Parameters: - x (int) – The x coordinate of the cell.
- y (int) – The y coordinate of the cell.
- data (list) – The extra data describing the cell.
Wraps the data describing a single cell. Other features besides the internal methods are shown below.
The data encapsulated can also be accessed as if the current
Cellclass was the data list itself by specifying an index:>>> c = Cell(0, 10, [1.4, 5.3]) >>> c.data[1] 5.3 >>> c[1] 5.3
The amount of data stored in the current
Cellcan be measured by len():>>> len(c) 2
-
data¶ An array of the data specified to be included.