gpflow.experimental.check_shapes.checker#

Class responsible for remembering and checking shapes.

Classes#

gpflow.experimental.check_shapes.checker.FunctionCallContext#

class gpflow.experimental.check_shapes.checker.FunctionCallContext(func, path_and_line=None)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

An error occured inside a function that was called.

Normally print should be called from within the called function: func. If that is impossible, first call precompute from within func.

Parameters
  • func (Callable[..., Any]) –

  • path_and_line (Optional[str]) –

precompute()[source]#

Precompute the values to print.

This is useful to capture the position of the stack of the relevant call, if this object is saved for later use.

Return type

FunctionCallContext

Returns

A new instance with precomptued values.

print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.checker.NoteContext#

class gpflow.experimental.check_shapes.checker.NoteContext(note)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

An error occurred in a context where a user has added a note.

Parameters

note (ParsedNoteSpec) –

print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.checker.ParsedDimensionSpec#

class gpflow.experimental.check_shapes.checker.ParsedDimensionSpec(constant, variable_name, variable_rank, broadcastable)[source]#

Bases: object

Parameters
  • constant (Optional[int]) –

  • variable_name (Optional[str]) –

  • variable_rank (bool) –

  • broadcastable (bool) –

gpflow.experimental.check_shapes.checker.ParsedShapeSpec#

class gpflow.experimental.check_shapes.checker.ParsedShapeSpec(dims)[source]#

Bases: object

Parameters

dims (Tuple[ParsedDimensionSpec, ...]) –

gpflow.experimental.check_shapes.checker.ParsedTensorSpec#

class gpflow.experimental.check_shapes.checker.ParsedTensorSpec(shape, note)[source]#

Bases: object

Parameters

gpflow.experimental.check_shapes.checker.ShapeContext#

class gpflow.experimental.check_shapes.checker.ShapeContext(expected, actual)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

An error occurred in the context of the shapes of function arguments.

Parameters
  • expected (ParsedShapeSpec) –

  • actual (Optional[Tuple[Optional[int], ...]]) –

print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.checker.ShapeMismatchError#

class gpflow.experimental.check_shapes.checker.ShapeMismatchError(context)[source]#

Bases: gpflow.experimental.check_shapes.exceptions.CheckShapesError

Error raised if a function is called with tensors of the wrong shape.

Parameters

context (ErrorContext) –

gpflow.experimental.check_shapes.checker.TensorSpecContext#

class gpflow.experimental.check_shapes.checker.TensorSpecContext(spec)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

An error occurred in the context of a tensor specification.

Parameters

spec (ParsedTensorSpec) –

print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.checker.VariableContext#

class gpflow.experimental.check_shapes.checker.VariableContext(variable_name)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

An error occurred in the context of a shape specification variable.

Parameters

variable_name (str) –

print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.checker.VariableTypeError#

class gpflow.experimental.check_shapes.checker.VariableTypeError(context)[source]#

Bases: gpflow.experimental.check_shapes.exceptions.CheckShapesError

Error raised if a variable is used both as a rank-1 and a variable-rank variable.

Parameters

context (ErrorContext) –

Functions#

gpflow.experimental.check_shapes.checker.parse_tensor_spec#

gpflow.experimental.check_shapes.checker.parse_tensor_spec(tensor_spec, context)[source]#

Parse a check_shapes tensor specification.

Parameters
Return type

ParsedTensorSpec