Skip to content

pydvl.utils.status

Status

Bases: Enum

Status of a computation.

Statuses can be combined using bitwise or (|) and bitwise and (&) to get the status of a combined computation. For example, if we have two computations, one that has converged and one that has failed, then the combined status is Status.Converged | Status.Failed == Status.Converged, but Status.Converged & Status.Failed == Status.Failed.

OR

The result of bitwise or-ing two valuation statuses with | is given by the following table:

P C F
P P C P
C C C C
F P C F

where P = Pending, C = Converged, F = Failed.

AND

The result of bitwise and-ing two valuation statuses with & is given by the following table:

P C F
P P P F
C P C F
F F F F

where P = Pending, C = Converged, F = Failed.

NOT

The result of bitwise negation of a Status with ~ is Failed if the status is Converged, or Converged otherwise:

~P == C, ~C == F, ~F == C

Boolean casting

A Status evaluates to True iff it's Converged or Failed:

bool(Status.Pending) == False
bool(Status.Converged) == True
bool(Status.Failed) == True

Warning

These truth values are inconsistent with the usual boolean operations. In particular the XOR of two instances of Status is not the same as the XOR of their boolean values.