Skip to content

Errors

Errors from BEAM’s computational core are raised as subclasses of BEAM.BeamError and of the built-in exception they correspond to, so both except BEAM.BeamError and the matching built-in (except ValueError, except MemoryError, …) catch them. A few argument checks made in Python, such as float() of a BoundedValue, raise the plain built-in (ValueError, TypeError). Catching the built-in always works; catch the BEAM classes when you want to tell refusals apart.

import BEAM
try:
model.entropy()
except BEAM.BudgetExceeded as err: # one specific refusal
print(err) # the message says what was needed
ExceptionMeansAlso a
BeamErrorBase of BEAM’s own refusals.Exception
BeamValueErrorAn argument BEAM cannot use.ValueError
InvalidSequenceA sequence BEAM cannot read: bad characters, empty, too long (for example in explain).ValueError
BeamTypeErrorAn argument of the wrong type.TypeError
NotFinalizedThe model cannot be used this way, for example save() after compact().RuntimeError
NoLivePathsNothing satisfies the condition asked for, so the conditional does not exist.RuntimeError
ModelMismatchTwo models cannot be combined: different alphabets, orders or shapes.RuntimeError
BudgetExceededRefused because it would exceed the memory budget (4 GiB unless you set one).MemoryError
OutOfMemoryThe machine could not supply the memory.MemoryError
ModelFileErrorA model file could not be read or written.OSError
LikelihoodPieceErrorOne piece of a repertoire likelihood could not be computed; the total is unaffected. SaddlepointDidNotConverge is one kind.RuntimeError
InternalErrorA bug in BEAM; please report it.RuntimeError

Queries (BeamQuery) add QueryError, ImpossibleCondition, UnsupportedQuery and QueryTooLarge; mixtures (Mixture) add MixtureError, IncompatibleMembers, UnsupportedOrder and MixtureTooLarge. ImpossibleCondition is also a NoLivePaths; UnsupportedQuery and UnsupportedOrder are BeamValueErrors; QueryTooLarge and MixtureTooLarge are BudgetExceeded; IncompatibleMembers is a ModelMismatch. All are importable from BEAM.

BudgetExceeded means BEAM declined because of the memory budget (4 GiB by default, set with BEAM.set_memory_budget); raise the budget, ask at a lower order, or ask a smaller question. OutOfMemory means the machine itself ran out, which a larger budget will not fix.

log_pseq never raises: a sequence it cannot read (empty, longer than max_length, or with a character outside the alphabet) scores -inf, a probability of zero. Every readable sequence, including one never seen, has a non-zero probability, and every length from 1 to max_length has some probability. What raises is a conditional on an impossible event, which does not exist.