montepy.exceptions module#

Exceptions:

BrokenObjectLinkError(parent_type, ...)

Raised when the referenced object does not exist in the input file.

IllegalState(message)

Raised when an object can't be printed out due to an illegal state.

LineExpansionWarning

Warning for when a field or line expands that may damage user formatting.

LineOverRunWarning(message)

Raised when non-comment inputs exceed the allowed line length in an input.

MalformedInputError(input, message)

Raised when there is an error with the MCNP input not related to the parser.

NumberConflictError(message)

Raised when there is a conflict in number spaces

ParsingError(input, message, error_queue)

Raised when there is an error parsing the MCNP input at the SLY parsing layer.

ParticleTypeNotInCell(message)

Raised when data for importance data for a particle in the problem is not provided for a cell.

ParticleTypeNotInProblem(message)

Raised when data, such as cell importance or tally type, are set for a particle type not in the problem's mode.

ParticleTypeWarning(message)

Base class for incongruencies between particle types in problem mode, cell importances, and tallies

RedundantParameterSpecification(key, new_value)

Raised when multiple conflicting parameters are given.

SurfaceConstantsWarning(message)

Raised when the constants of a Surface are non-conform, but do not raise an error with MCNP.

UnknownElement(missing_val)

Raised when an undefined element is used.

UnsupportedFeature(message[, input, error_queue])

Raised when MCNP syntax that is not supported is found

Functions:

add_line_number_to_exception(error, broken_robot)

Adds additional context to an Exception raised by an MCNP_Object.

exception montepy.exceptions.BrokenObjectLinkError(parent_type, parent_number, child_type, child_number)#

Bases: MalformedInputError

Raised when the referenced object does not exist in the input file.

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.IllegalState(message)#

Bases: ValueError

Raised when an object can’t be printed out due to an illegal state.

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.LineExpansionWarning#

Bases: Warning

Warning for when a field or line expands that may damage user formatting.

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.LineOverRunWarning(message)#

Bases: UserWarning

Raised when non-comment inputs exceed the allowed line length in an input.

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.MalformedInputError(input, message)#

Bases: ValueError

Raised when there is an error with the MCNP input not related to the parser.

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.NumberConflictError(message)#

Bases: Exception

Raised when there is a conflict in number spaces

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.ParsingError(input, message, error_queue)#

Bases: MalformedInputError

Raised when there is an error parsing the MCNP input at the SLY parsing layer.

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.ParticleTypeNotInCell(message)#

Bases: ParticleTypeWarning

Raised when data for importance data for a particle in the problem is not provided for a cell.

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.ParticleTypeNotInProblem(message)#

Bases: ParticleTypeWarning

Raised when data, such as cell importance or tally type, are set for a particle type not in the problem’s mode.

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.ParticleTypeWarning(message)#

Bases: Warning

Base class for incongruencies between particle types in problem mode, cell importances, and tallies

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.RedundantParameterSpecification(key, new_value)#

Bases: ValueError

Raised when multiple conflicting parameters are given.

e.g., 1 0 -1 imp:n=5 imp:n=0

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.SurfaceConstantsWarning(message)#

Bases: UserWarning

Raised when the constants of a Surface are non-conform, but do not raise an error with MCNP.

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.UnknownElement(missing_val)#

Bases: ValueError

Raised when an undefined element is used.

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
exception montepy.exceptions.UnsupportedFeature(message, input=None, error_queue=None)#

Bases: ParsingError

Raised when MCNP syntax that is not supported is found

Methods:

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

Attributes:

add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args#
montepy.exceptions.add_line_number_to_exception(error, broken_robot)#

Adds additional context to an Exception raised by an MCNP_Object.

This will add the line, file name, and the input lines to the error.

Parameters:
  • error (Exception) – The error that was raised.

  • broken_robot (MCNP_Object) – The parent object that had the error raised.

Raises:

Exception – … that’s the whole point.