str2d.space
- str2d.space(mn: float, mx: float, w: int) Tuple[ndarray, ndarray, ndarray] [source]
Return left, center, and right points of a space. Imagine an integer number of cells. I want to assign the left side of the left most cell to be mn and the right side of the right most cell to be mx. This function returns 3 arrays. The first array consists of the left side of each cell. The second array consists of the center of each cell. The third array consists of the right side of each cell.
Let’s imagine w=5 and mn=0 and mx=1. The space is divided into 5 cells.
mn=0 0.2 0.4 0.6 0.8 mx=1 │ │ │ │ │ │ ╭───────────┬───────────┬───────────┬───────────┬───────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ├─────┬─────┼─────┬─────┼─────┬─────┼─────┬─────┼─────┬─────┤ left 0.0 │ 0.2 │ 0.4 │ 0.6 │ 0.8 │ │ center 0.1 │ 0.3 │ 0.5 │ 0.7 │ 0.9 │ right 0.2 0.4 0.6 0.8 1.0
We can use these arrays to more accurately model x, y coordinates for ascii plots.
- Parameters:
mn (float) – The minimum value of the space.
mx (float) – The maximum value of the space.
w (int) – The number of cells.
- Returns:
The left, center, and right points of the space.
- Return type:
Tuple[np.ndarray, np.ndarray, np.ndarray]
- Raises:
ValueError – If w is less than 1.