ImpactCategoriesModel

database_builder.ImpactCategoriesModel()

Model for defining impact categories with associated colors, field, unit, and bins.

Attributes

categories : list[str], default=["Minor", "Major", "Severe"]

List of impact category names.

colors : list[str], default=["#ffa500", "#ff0000", "#000000"]

List of colors corresponding to each category.

field : str

The database field name used for categorization.

unit : str

The unit of measurement for the field.

bins : list[float]

List of threshold values for binning the field values.

Methods

Name Description
validate_bins_length Validate that bins list length is one less than categories list length.
validate_colors_length Validate that colors list length matches categories list length.

validate_bins_length

database_builder.ImpactCategoriesModel.validate_bins_length(bins, info)

Validate that bins list length is one less than categories list length.

Parameters

bins : list[float]

List of bin threshold values.

info : Any

Field validation info containing all field values.

Returns

: list[float]

The validated bins list.

Raises

: ValueError

If bins length is not one less than categories length.

validate_colors_length

database_builder.ImpactCategoriesModel.validate_colors_length(colors, info)

Validate that colors list length matches categories list length.

Parameters

colors : list[str]

List of color values.

info : Any

Field validation info containing all field values.

Returns

: list[str]

The validated colors list.

Raises

: ValueError

If colors length doesn’t match categories length.

Back to top