Skip to content

PointScale

The PointScale class maps categorical values to discrete points within the output range, with specified padding at both ends.

pydreamplet.scales.PointScale

PointScale(
    domain: list[Any],
    output_range: tuple[float, float],
    padding: float = 0.5
)

Parameters

  • domain (list[Any]): A list of categorical values (distinct).
  • output_range (tuple[float, float]): The numeric output range.
  • padding (float, optional): The amount of padding on each end (default: 0.5).
point = PointScale(["X", "Y", "Z"], (0, 100))
print(point.map("Y"))  # Outputs the point corresponding to "Y"

map

map(value: Any) -> float | None

Maps a categorical value to a discrete point; returns None if the value is not in the domain.

domain

Get or set the list of categories.

output_range

Get or set the numeric output range.

padding

Get or set the padding value.