src.system.projection_entity.projection_value.ProjectionValue

class src.system.projection_entity.projection_value.ProjectionValue(init_t: date, init_value: Any, print_values: bool = True)

Stores values for a ProjectionEntity.

It can best be understood as a standard Python data type combined with a value history.

For example, imagine an integer that keeps track of its past values:

  • Like an integer, projection values support all standard numeric operators (e.g., +, -, /, *, etc…).

    The value used in these operations is the latest value from the value history.

  • However, unlike an integer, a value history can be read or written via the [] operator (like a dictionary).

Here is a code example:

my_projection_value = ProjectionValue(
    init_t=date(
        year=2023,
        month=3,
        day=16
    ),
    init_value=50.0
)  # Create a new ProjectionValue with a starting history of 50.0 on 3/16/2023.

new_value = my_projection_value + 25.0  # ProjectionValue's support math operands. The value of
                                        # new_value is 75.0, since my_project_value's latest value is 50.0.

my_projection_value[
    date(
        year=2023,
        month=4,
        day=16
    )
] = new_value           # ProjectionValue's logs a new entry in its history (75.0 on 4/16/2023). Since
                        # 4/16/2023 is the latest date in the history, 75.0 also becomes the latest value.

Inheritance Diagram

Inheritance diagram of ProjectionValue

Variables & Properties

history

Complete value history for this projection value.

latest_value

Latest value from the value history.

print_values

Boolean flag used to indicate whether this object should be printed.

Methods

__init__(init_t, init_value[, print_values])

Constructor method.

Details

__init__(init_t: date, init_value: Any, print_values: bool = True)

Constructor method.

Parameters:
  • init_t – Initial time step to index init_value in the value history.

  • init_value – Initial value to record in the value history.

  • print_values – Boolean flag to determine whether this projection value is printed.

property history: DataFrame

Complete value history for this projection value.

Returns:

Value history of this projection value.

property latest_value: Any

Latest value from the value history. For example, if the value history contains:

t

value

3/16/2023

0.04

4/16/2023

0.06

5/16/2023

0.08

This property will return 0.08, as 5/16/2023 is the “latest” date.

Returns:

Latest value from history.

property print_values: bool

Boolean flag used to indicate whether this object should be printed.

Returns:

Printing flag.