gpflow.experimental.check_shapes.argument_ref#

Code for (de)referencing arguments.

Classes#

gpflow.experimental.check_shapes.argument_ref.AllElementsRef#

class gpflow.experimental.check_shapes.argument_ref.AllElementsRef(source)[source]#

Bases: gpflow.experimental.check_shapes.argument_ref.DelegatingArgumentRef

A reference to all elements in a collection.

Parameters

source (ArgumentRef) –

map_value(value, context)[source]#

Map this value, from self.source to new value(s).

Parameters
Return type

Iterable[Tuple[Any, ErrorContext]]

gpflow.experimental.check_shapes.argument_ref.ArgumentContext#

class gpflow.experimental.check_shapes.argument_ref.ArgumentContext(name_or_index, value=<object object>)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

An error occurred in the context of an argument to a function.

Parameters
  • name_or_index (Union[str, int]) –

  • value (Any) –

print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.argument_ref.ArgumentRef#

class gpflow.experimental.check_shapes.argument_ref.ArgumentRef[source]#

Bases: abc.ABC

A reference to an argument.

abstract get(arg_map, context)[source]#

Get the value(s) of this argument from the given argument map.

Parameters
  • arg_map (Mapping[str, Any]) –

  • context (ErrorContext) –

Return type

Sequence[Tuple[Any, ErrorContext]]

abstract property is_result: bool#

Whether this is a reference to the function result.

Return type

bool

abstract property root_argument_name: str#

Name of the argument this reference eventually starts from.

Returns RESULT_TOKEN if this in an argument to the function result.

Return type

str

gpflow.experimental.check_shapes.argument_ref.ArgumentReferenceError#

class gpflow.experimental.check_shapes.argument_ref.ArgumentReferenceError(context)[source]#

Bases: gpflow.experimental.check_shapes.exceptions.CheckShapesError

Error raised if the argument to check the shape of could not be resolved.

Parameters

context (ErrorContext) –

gpflow.experimental.check_shapes.argument_ref.AttributeArgumentRef#

class gpflow.experimental.check_shapes.argument_ref.AttributeArgumentRef(source, attribute_name)[source]#

Bases: gpflow.experimental.check_shapes.argument_ref.DelegatingArgumentRef

A reference to an attribute on an argument.

Parameters
map_context(context)[source]#

Pre-map this error context from self.source.

The mapped value will both be used for error messages and passed to map_value above.

Parameters

context (ErrorContext) –

Return type

ErrorContext

map_value(value, context)[source]#

Map this value, from self.source to new value(s).

Parameters
Return type

Iterable[Tuple[Any, ErrorContext]]

gpflow.experimental.check_shapes.argument_ref.AttributeContext#

class gpflow.experimental.check_shapes.argument_ref.AttributeContext(name, value=<object object>)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

An error occurred in the context of an attribute on an object.

Parameters
  • name (str) –

  • value (Any) –

print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.argument_ref.DelegatingArgumentRef#

class gpflow.experimental.check_shapes.argument_ref.DelegatingArgumentRef(source)[source]#

Bases: gpflow.experimental.check_shapes.argument_ref.ArgumentRef

Abstract base class for ArgumentRefs that delegates to a source.

Parameters

source (ArgumentRef) –

get(arg_map, context)[source]#

Get the value(s) of this argument from the given argument map.

Parameters
  • arg_map (Mapping[str, Any]) –

  • context (ErrorContext) –

Return type

Sequence[Tuple[Any, ErrorContext]]

property is_result: bool#

Whether this is a reference to the function result.

Return type

bool

map_context(context)[source]#

Pre-map this error context from self.source.

The mapped value will both be used for error messages and passed to map_value above.

Parameters

context (ErrorContext) –

Return type

ErrorContext

abstract map_value(value, context)[source]#

Map this value, from self.source to new value(s).

Parameters
Return type

Iterable[Tuple[Any, ErrorContext]]

property root_argument_name: str#

Name of the argument this reference eventually starts from.

Returns RESULT_TOKEN if this in an argument to the function result.

Return type

str

gpflow.experimental.check_shapes.argument_ref.IndexArgumentRef#

class gpflow.experimental.check_shapes.argument_ref.IndexArgumentRef(source, index)[source]#

Bases: gpflow.experimental.check_shapes.argument_ref.DelegatingArgumentRef

A reference to an element in a list.

Parameters
map_context(context)[source]#

Pre-map this error context from self.source.

The mapped value will both be used for error messages and passed to map_value above.

Parameters

context (ErrorContext) –

Return type

ErrorContext

map_value(value, context)[source]#

Map this value, from self.source to new value(s).

Parameters
Return type

Iterable[Tuple[Any, ErrorContext]]

gpflow.experimental.check_shapes.argument_ref.IndexContext#

class gpflow.experimental.check_shapes.argument_ref.IndexContext(index, value=<object object>)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

An error occurred in the context of an index in a sequence.

Parameters
  • index (int) –

  • value (Any) –

print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.argument_ref.KeysRef#

class gpflow.experimental.check_shapes.argument_ref.KeysRef(source)[source]#

Bases: gpflow.experimental.check_shapes.argument_ref.DelegatingArgumentRef

A reference to all keys of a mapping.

Parameters

source (ArgumentRef) –

map_value(value, context)[source]#

Map this value, from self.source to new value(s).

Parameters
Return type

Iterable[Tuple[Any, ErrorContext]]

gpflow.experimental.check_shapes.argument_ref.MappingKeyContext#

class gpflow.experimental.check_shapes.argument_ref.MappingKeyContext(key)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

An error occurent in the context of a key in a map.

Parameters

key (Any) –

print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.argument_ref.MappingValueContext#

class gpflow.experimental.check_shapes.argument_ref.MappingValueContext(key, value=<object object>)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

An error occurent in the context of a value in a map.

Parameters
  • key (Any) –

  • value (Any) –

print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.argument_ref.RootArgumentRef#

class gpflow.experimental.check_shapes.argument_ref.RootArgumentRef(argument_name)[source]#

Bases: gpflow.experimental.check_shapes.argument_ref.ArgumentRef

A reference to a single argument.

Parameters

argument_name (str) –

get(arg_map, context)[source]#

Get the value(s) of this argument from the given argument map.

Parameters
  • arg_map (Mapping[str, Any]) –

  • context (ErrorContext) –

Return type

Sequence[Tuple[Any, ErrorContext]]

property is_result: bool#

Whether this is a reference to the function result.

Return type

bool

property root_argument_name: str#

Name of the argument this reference eventually starts from.

Returns RESULT_TOKEN if this in an argument to the function result.

Return type

str

gpflow.experimental.check_shapes.argument_ref.StackContext#

class gpflow.experimental.check_shapes.argument_ref.StackContext(parent, child)[source]#

Bases: gpflow.experimental.check_shapes.error_contexts.ErrorContext

Error context where one context is “inside” another one.

Parameters
print(builder)[source]#

Print this context to the given MessageBuilder.

Parameters

builder (MessageBuilder) –

Return type

None

gpflow.experimental.check_shapes.argument_ref.ValuesRef#

class gpflow.experimental.check_shapes.argument_ref.ValuesRef(source)[source]#

Bases: gpflow.experimental.check_shapes.argument_ref.DelegatingArgumentRef

A reference to all values of a mapping.

Parameters

source (ArgumentRef) –

map_value(value, context)[source]#

Map this value, from self.source to new value(s).

Parameters
Return type

Iterable[Tuple[Any, ErrorContext]]