gpflow.experimental.check_shapes.error_contexts#
Infrastructure for describing the context of an error.
The MessageBuilder
is used to format / indent messages nicely.
The ErrorContext
is a reusable bit of information about where/why an error occurred that
can be written to a MessageBuilder
.
ErrorContext
s can be composed using the StackContext
and
ParallelContext
.
This allows reusable error messages in a consistent format.
Classes#
gpflow.experimental.check_shapes.error_contexts.LarkUnexpectedInputContext#
- class gpflow.experimental.check_shapes.error_contexts.LarkUnexpectedInputContext(text, error, terminal_descriptions)[source]#
Bases:
gpflow.experimental.check_shapes.error_contexts.ParserInputContext
An error was caused by an UnexpectedInput error from Lark.
- Parameters
text (
str
) –error (
UnexpectedInput
) –terminal_descriptions (
Mapping
[str
,str
]) –
- print(builder)[source]#
Print this context to the given MessageBuilder.
- Parameters
builder (
MessageBuilder
) –- Return type
None
gpflow.experimental.check_shapes.error_contexts.MessageBuilder#
- class gpflow.experimental.check_shapes.error_contexts.MessageBuilder(indent_str='')[source]#
Bases:
object
Utility for formatting nested text.
- Parameters
indent_str (
str
) –
- add_columned_line(*texts)[source]#
Write a line of several values, left-aligned within the current indentation level.
Inputs are converted to str`s using `str(text).
- Parameters
texts (
Any
) –- Return type
None
- add_line(text)[source]#
Write a line, indented at the current level.
Input is converted to a str using str(text).
- Parameters
text (
Any
) –- Return type
None
- indent()[source]#
Context manager for indenting text.
- Return type
Iterator
[MessageBuilder
]
gpflow.experimental.check_shapes.error_contexts.MultipleElementBoolContext#
- class gpflow.experimental.check_shapes.error_contexts.MultipleElementBoolContext(text, line, column)[source]#
Bases:
gpflow.experimental.check_shapes.error_contexts.ParserInputContext
An error was caused by trying to use a multi-element argument specification as a bool.
- Parameters
text (
str
) –line (
int
) –column (
int
) –
- print(builder)[source]#
Print this context to the given MessageBuilder.
- Parameters
builder (
MessageBuilder
) –- Return type
None
gpflow.experimental.check_shapes.error_contexts.ObjectTypeContext#
- class gpflow.experimental.check_shapes.error_contexts.ObjectTypeContext(obj)[source]#
Bases:
gpflow.experimental.check_shapes.error_contexts.ErrorContext
An error was caused by the type of an object.
- Parameters
obj (
Any
) –
- print(builder)[source]#
Print this context to the given MessageBuilder.
- Parameters
builder (
MessageBuilder
) –- Return type
None
gpflow.experimental.check_shapes.error_contexts.ParserInputContext#
- class gpflow.experimental.check_shapes.error_contexts.ParserInputContext(text)[source]#
Bases:
gpflow.experimental.check_shapes.error_contexts.ErrorContext
,abc.ABC
Abstract base class for contexts that relate to parser input.
- Parameters
text (
str
) –
gpflow.experimental.check_shapes.error_contexts.TrailingBroadcastVarrankContext#
- class gpflow.experimental.check_shapes.error_contexts.TrailingBroadcastVarrankContext(text, line, column, variable)[source]#
Bases:
gpflow.experimental.check_shapes.error_contexts.ParserInputContext
An error was caused by trying to broadcast a trailing variable-rank variable.
- Parameters
text (
str
) –line (
int
) –column (
int
) –variable (
Optional
[str
]) –
- print(builder)[source]#
Print this context to the given MessageBuilder.
- Parameters
builder (
MessageBuilder
) –- Return type
None