LostTech.TensorFlow : API Documentation

Type TestCase

Namespace tensorflow.test

Parent PythonObjectContainer

Interfaces ITestCase

Base class for tests that need to test TensorFlow.

Methods

Properties

Public instance methods

object assertAllClose(object a, object b, double rtol, double atol, object msg)

Asserts that two structures of numpy arrays or Tensors, have near values.

`a` and `b` can be arbitrarily nested structures. A layer of a nested structure can be a `dict`, `namedtuple`, `tuple` or `list`.
Parameters
object a
The expected numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor), or any arbitrarily nested of structure of these.
object b
The actual numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor), or any arbitrarily nested of structure of these.
double rtol
relative tolerance.
double atol
absolute tolerance.
object msg
Optional message to report on failure.

object assertAllClose_dyn(object a, object b, ImplicitContainer<T> rtol, ImplicitContainer<T> atol, object msg)

Asserts that two structures of numpy arrays or Tensors, have near values.

`a` and `b` can be arbitrarily nested structures. A layer of a nested structure can be a `dict`, `namedtuple`, `tuple` or `list`.
Parameters
object a
The expected numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor), or any arbitrarily nested of structure of these.
object b
The actual numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor), or any arbitrarily nested of structure of these.
ImplicitContainer<T> rtol
relative tolerance.
ImplicitContainer<T> atol
absolute tolerance.
object msg
Optional message to report on failure.

object assertAllCloseAccordingToType(IEnumerable<object> a, IGraphNodeBase b, double rtol, double atol, double float_rtol, double float_atol, double half_rtol, double half_atol, double bfloat16_rtol, double bfloat16_atol, object msg)

Like assertAllClose, but also suitable for comparing fp16 arrays.

In particular, the tolerance is reduced to 1e-3 if at least one of the arguments is of type float16.
Parameters
IEnumerable<object> a
the expected numpy ndarray or anything can be converted to one.
IGraphNodeBase b
the actual numpy ndarray or anything can be converted to one.
double rtol
relative tolerance.
double atol
absolute tolerance.
double float_rtol
relative tolerance for float32.
double float_atol
absolute tolerance for float32.
double half_rtol
relative tolerance for float16.
double half_atol
absolute tolerance for float16.
double bfloat16_rtol
relative tolerance for bfloat16.
double bfloat16_atol
absolute tolerance for bfloat16.
object msg
Optional message to report on failure.

object assertAllCloseAccordingToType(IGraphNodeBase a, IEnumerable<object> b, double rtol, double atol, double float_rtol, double float_atol, double half_rtol, double half_atol, double bfloat16_rtol, double bfloat16_atol, object msg)

Like assertAllClose, but also suitable for comparing fp16 arrays.

In particular, the tolerance is reduced to 1e-3 if at least one of the arguments is of type float16.
Parameters
IGraphNodeBase a
the expected numpy ndarray or anything can be converted to one.
IEnumerable<object> b
the actual numpy ndarray or anything can be converted to one.
double rtol
relative tolerance.
double atol
absolute tolerance.
double float_rtol
relative tolerance for float32.
double float_atol
absolute tolerance for float32.
double half_rtol
relative tolerance for float16.
double half_atol
absolute tolerance for float16.
double bfloat16_rtol
relative tolerance for bfloat16.
double bfloat16_atol
absolute tolerance for bfloat16.
object msg
Optional message to report on failure.

object assertAllCloseAccordingToType(IGraphNodeBase a, ndarray b, double rtol, double atol, double float_rtol, double float_atol, double half_rtol, double half_atol, double bfloat16_rtol, double bfloat16_atol, object msg)

Like assertAllClose, but also suitable for comparing fp16 arrays.

In particular, the tolerance is reduced to 1e-3 if at least one of the arguments is of type float16.
Parameters
IGraphNodeBase a
the expected numpy ndarray or anything can be converted to one.
ndarray b
the actual numpy ndarray or anything can be converted to one.
double rtol
relative tolerance.
double atol
absolute tolerance.
double float_rtol
relative tolerance for float32.
double float_atol
absolute tolerance for float32.
double half_rtol
relative tolerance for float16.
double half_atol
absolute tolerance for float16.
double bfloat16_rtol
relative tolerance for bfloat16.
double bfloat16_atol
absolute tolerance for bfloat16.
object msg
Optional message to report on failure.

object assertAllCloseAccordingToType(IEnumerable<object> a, IEnumerable<object> b, double rtol, double atol, double float_rtol, double float_atol, double half_rtol, double half_atol, double bfloat16_rtol, double bfloat16_atol, object msg)

Like assertAllClose, but also suitable for comparing fp16 arrays.

In particular, the tolerance is reduced to 1e-3 if at least one of the arguments is of type float16.
Parameters
IEnumerable<object> a
the expected numpy ndarray or anything can be converted to one.
IEnumerable<object> b
the actual numpy ndarray or anything can be converted to one.
double rtol
relative tolerance.
double atol
absolute tolerance.
double float_rtol
relative tolerance for float32.
double float_atol
absolute tolerance for float32.
double half_rtol
relative tolerance for float16.
double half_atol
absolute tolerance for float16.
double bfloat16_rtol
relative tolerance for bfloat16.
double bfloat16_atol
absolute tolerance for bfloat16.
object msg
Optional message to report on failure.

object assertAllCloseAccordingToType(IEnumerable<object> a, ndarray b, double rtol, double atol, double float_rtol, double float_atol, double half_rtol, double half_atol, double bfloat16_rtol, double bfloat16_atol, object msg)

Like assertAllClose, but also suitable for comparing fp16 arrays.

In particular, the tolerance is reduced to 1e-3 if at least one of the arguments is of type float16.
Parameters
IEnumerable<object> a
the expected numpy ndarray or anything can be converted to one.
ndarray b
the actual numpy ndarray or anything can be converted to one.
double rtol
relative tolerance.
double atol
absolute tolerance.
double float_rtol
relative tolerance for float32.
double float_atol
absolute tolerance for float32.
double half_rtol
relative tolerance for float16.
double half_atol
absolute tolerance for float16.
double bfloat16_rtol
relative tolerance for bfloat16.
double bfloat16_atol
absolute tolerance for bfloat16.
object msg
Optional message to report on failure.

object assertAllCloseAccordingToType(ndarray a, IGraphNodeBase b, double rtol, double atol, double float_rtol, double float_atol, double half_rtol, double half_atol, double bfloat16_rtol, double bfloat16_atol, object msg)

Like assertAllClose, but also suitable for comparing fp16 arrays.

In particular, the tolerance is reduced to 1e-3 if at least one of the arguments is of type float16.
Parameters
ndarray a
the expected numpy ndarray or anything can be converted to one.
IGraphNodeBase b
the actual numpy ndarray or anything can be converted to one.
double rtol
relative tolerance.
double atol
absolute tolerance.
double float_rtol
relative tolerance for float32.
double float_atol
absolute tolerance for float32.
double half_rtol
relative tolerance for float16.
double half_atol
absolute tolerance for float16.
double bfloat16_rtol
relative tolerance for bfloat16.
double bfloat16_atol
absolute tolerance for bfloat16.
object msg
Optional message to report on failure.

object assertAllCloseAccordingToType(ndarray a, IEnumerable<object> b, double rtol, double atol, double float_rtol, double float_atol, double half_rtol, double half_atol, double bfloat16_rtol, double bfloat16_atol, object msg)

Like assertAllClose, but also suitable for comparing fp16 arrays.

In particular, the tolerance is reduced to 1e-3 if at least one of the arguments is of type float16.
Parameters
ndarray a
the expected numpy ndarray or anything can be converted to one.
IEnumerable<object> b
the actual numpy ndarray or anything can be converted to one.
double rtol
relative tolerance.
double atol
absolute tolerance.
double float_rtol
relative tolerance for float32.
double float_atol
absolute tolerance for float32.
double half_rtol
relative tolerance for float16.
double half_atol
absolute tolerance for float16.
double bfloat16_rtol
relative tolerance for bfloat16.
double bfloat16_atol
absolute tolerance for bfloat16.
object msg
Optional message to report on failure.

object assertAllCloseAccordingToType(ndarray a, ndarray b, double rtol, double atol, double float_rtol, double float_atol, double half_rtol, double half_atol, double bfloat16_rtol, double bfloat16_atol, object msg)

Like assertAllClose, but also suitable for comparing fp16 arrays.

In particular, the tolerance is reduced to 1e-3 if at least one of the arguments is of type float16.
Parameters
ndarray a
the expected numpy ndarray or anything can be converted to one.
ndarray b
the actual numpy ndarray or anything can be converted to one.
double rtol
relative tolerance.
double atol
absolute tolerance.
double float_rtol
relative tolerance for float32.
double float_atol
absolute tolerance for float32.
double half_rtol
relative tolerance for float16.
double half_atol
absolute tolerance for float16.
double bfloat16_rtol
relative tolerance for bfloat16.
double bfloat16_atol
absolute tolerance for bfloat16.
object msg
Optional message to report on failure.

object assertAllCloseAccordingToType(IGraphNodeBase a, IGraphNodeBase b, double rtol, double atol, double float_rtol, double float_atol, double half_rtol, double half_atol, double bfloat16_rtol, double bfloat16_atol, object msg)

Like assertAllClose, but also suitable for comparing fp16 arrays.

In particular, the tolerance is reduced to 1e-3 if at least one of the arguments is of type float16.
Parameters
IGraphNodeBase a
the expected numpy ndarray or anything can be converted to one.
IGraphNodeBase b
the actual numpy ndarray or anything can be converted to one.
double rtol
relative tolerance.
double atol
absolute tolerance.
double float_rtol
relative tolerance for float32.
double float_atol
absolute tolerance for float32.
double half_rtol
relative tolerance for float16.
double half_atol
absolute tolerance for float16.
double bfloat16_rtol
relative tolerance for bfloat16.
double bfloat16_atol
absolute tolerance for bfloat16.
object msg
Optional message to report on failure.

object assertAllCloseAccordingToType_dyn(object a, object b, ImplicitContainer<T> rtol, ImplicitContainer<T> atol, ImplicitContainer<T> float_rtol, ImplicitContainer<T> float_atol, ImplicitContainer<T> half_rtol, ImplicitContainer<T> half_atol, ImplicitContainer<T> bfloat16_rtol, ImplicitContainer<T> bfloat16_atol, object msg)

Like assertAllClose, but also suitable for comparing fp16 arrays.

In particular, the tolerance is reduced to 1e-3 if at least one of the arguments is of type float16.
Parameters
object a
the expected numpy ndarray or anything can be converted to one.
object b
the actual numpy ndarray or anything can be converted to one.
ImplicitContainer<T> rtol
relative tolerance.
ImplicitContainer<T> atol
absolute tolerance.
ImplicitContainer<T> float_rtol
relative tolerance for float32.
ImplicitContainer<T> float_atol
absolute tolerance for float32.
ImplicitContainer<T> half_rtol
relative tolerance for float16.
ImplicitContainer<T> half_atol
absolute tolerance for float16.
ImplicitContainer<T> bfloat16_rtol
relative tolerance for bfloat16.
ImplicitContainer<T> bfloat16_atol
absolute tolerance for bfloat16.
object msg
Optional message to report on failure.

object assertAllEqual(IGraphNodeBase a, IEnumerable<object> b, string msg)

Asserts that two numpy arrays or Tensors have the same values.
Parameters
IGraphNodeBase a
the expected numpy ndarray or anything can be converted to one.
IEnumerable<object> b
the actual numpy ndarray or anything can be converted to one.
string msg
Optional message to report on failure.

object assertAllEqual(IGraphNodeBase a, IGraphNodeBase b, string msg)

Asserts that two numpy arrays or Tensors have the same values.
Parameters
IGraphNodeBase a
the expected numpy ndarray or anything can be converted to one.
IGraphNodeBase b
the actual numpy ndarray or anything can be converted to one.
string msg
Optional message to report on failure.

object assertAllEqual(IEnumerable<object> a, IGraphNodeBase b, string msg)

Asserts that two numpy arrays or Tensors have the same values.
Parameters
IEnumerable<object> a
the expected numpy ndarray or anything can be converted to one.
IGraphNodeBase b
the actual numpy ndarray or anything can be converted to one.
string msg
Optional message to report on failure.

object assertAllEqual(IEnumerable<object> a, IEnumerable<object> b, string msg)

Asserts that two numpy arrays or Tensors have the same values.
Parameters
IEnumerable<object> a
the expected numpy ndarray or anything can be converted to one.
IEnumerable<object> b
the actual numpy ndarray or anything can be converted to one.
string msg
Optional message to report on failure.

object assertAllEqual(ndarray a, ndarray b, string msg)

Asserts that two numpy arrays or Tensors have the same values.
Parameters
ndarray a
the expected numpy ndarray or anything can be converted to one.
ndarray b
the actual numpy ndarray or anything can be converted to one.
string msg
Optional message to report on failure.

object assertAllEqual(ndarray a, IEnumerable<object> b, string msg)

Asserts that two numpy arrays or Tensors have the same values.
Parameters
ndarray a
the expected numpy ndarray or anything can be converted to one.
IEnumerable<object> b
the actual numpy ndarray or anything can be converted to one.
string msg
Optional message to report on failure.

object assertAllEqual(ndarray a, IGraphNodeBase b, string msg)

Asserts that two numpy arrays or Tensors have the same values.
Parameters
ndarray a
the expected numpy ndarray or anything can be converted to one.
IGraphNodeBase b
the actual numpy ndarray or anything can be converted to one.
string msg
Optional message to report on failure.

object assertAllEqual(IEnumerable<object> a, ndarray b, string msg)

Asserts that two numpy arrays or Tensors have the same values.
Parameters
IEnumerable<object> a
the expected numpy ndarray or anything can be converted to one.
ndarray b
the actual numpy ndarray or anything can be converted to one.
string msg
Optional message to report on failure.

object assertAllEqual(IGraphNodeBase a, ndarray b, string msg)

Asserts that two numpy arrays or Tensors have the same values.
Parameters
IGraphNodeBase a
the expected numpy ndarray or anything can be converted to one.
ndarray b
the actual numpy ndarray or anything can be converted to one.
string msg
Optional message to report on failure.

object assertAllEqual_dyn(object a, object b, object msg)

Asserts that two numpy arrays or Tensors have the same values.
Parameters
object a
the expected numpy ndarray or anything can be converted to one.
object b
the actual numpy ndarray or anything can be converted to one.
object msg
Optional message to report on failure.

object assertAllGreater(ndarray a, object comparison_target)

Assert element values are all greater than a target value.
Parameters
ndarray a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllGreater(IEnumerable<object> a, object comparison_target)

Assert element values are all greater than a target value.
Parameters
IEnumerable<object> a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllGreater(IGraphNodeBase a, object comparison_target)

Assert element values are all greater than a target value.
Parameters
IGraphNodeBase a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllGreater_dyn(object a, object comparison_target)

Assert element values are all greater than a target value.
Parameters
object a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllGreaterEqual(IGraphNodeBase a, object comparison_target)

Assert element values are all greater than or equal to a target value.
Parameters
IGraphNodeBase a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllGreaterEqual(ndarray a, object comparison_target)

Assert element values are all greater than or equal to a target value.
Parameters
ndarray a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllGreaterEqual(IEnumerable<object> a, object comparison_target)

Assert element values are all greater than or equal to a target value.
Parameters
IEnumerable<object> a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllGreaterEqual_dyn(object a, object comparison_target)

Assert element values are all greater than or equal to a target value.
Parameters
object a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllInRange(ndarray target, object lower_bound, object upper_bound, bool open_lower_bound, bool open_upper_bound)

Assert that elements in a Tensor are all in a given range.
Parameters
ndarray target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object lower_bound
lower bound of the range
object upper_bound
upper bound of the range
bool open_lower_bound
(`bool`) whether the lower bound is open (i.e., > rather than the default >=)
bool open_upper_bound
(`bool`) whether the upper bound is open (i.e., < rather than the default <=)

object assertAllInRange(IEnumerable<object> target, object lower_bound, object upper_bound, bool open_lower_bound, bool open_upper_bound)

Assert that elements in a Tensor are all in a given range.
Parameters
IEnumerable<object> target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object lower_bound
lower bound of the range
object upper_bound
upper bound of the range
bool open_lower_bound
(`bool`) whether the lower bound is open (i.e., > rather than the default >=)
bool open_upper_bound
(`bool`) whether the upper bound is open (i.e., < rather than the default <=)

object assertAllInRange(IGraphNodeBase target, object lower_bound, object upper_bound, bool open_lower_bound, bool open_upper_bound)

Assert that elements in a Tensor are all in a given range.
Parameters
IGraphNodeBase target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object lower_bound
lower bound of the range
object upper_bound
upper bound of the range
bool open_lower_bound
(`bool`) whether the lower bound is open (i.e., > rather than the default >=)
bool open_upper_bound
(`bool`) whether the upper bound is open (i.e., < rather than the default <=)

object assertAllInRange_dyn(object target, object lower_bound, object upper_bound, ImplicitContainer<T> open_lower_bound, ImplicitContainer<T> open_upper_bound)

Assert that elements in a Tensor are all in a given range.
Parameters
object target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object lower_bound
lower bound of the range
object upper_bound
upper bound of the range
ImplicitContainer<T> open_lower_bound
(`bool`) whether the lower bound is open (i.e., > rather than the default >=)
ImplicitContainer<T> open_upper_bound
(`bool`) whether the upper bound is open (i.e., < rather than the default <=)

object assertAllInSet(ndarray target, object expected_set)

Assert that elements of a Tensor are all in a given closed set.
Parameters
ndarray target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object expected_set
(`list`, `tuple` or `set`) The closed set that the elements of the value of `target` are expected to fall into.

object assertAllInSet(IEnumerable<object> target, object expected_set)

Assert that elements of a Tensor are all in a given closed set.
Parameters
IEnumerable<object> target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object expected_set
(`list`, `tuple` or `set`) The closed set that the elements of the value of `target` are expected to fall into.

object assertAllInSet(IGraphNodeBase target, object expected_set)

Assert that elements of a Tensor are all in a given closed set.
Parameters
IGraphNodeBase target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object expected_set
(`list`, `tuple` or `set`) The closed set that the elements of the value of `target` are expected to fall into.

object assertAllInSet_dyn(object target, object expected_set)

Assert that elements of a Tensor are all in a given closed set.
Parameters
object target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object expected_set
(`list`, `tuple` or `set`) The closed set that the elements of the value of `target` are expected to fall into.

object assertAllLess(IGraphNodeBase a, object comparison_target)

Assert element values are all less than a target value.
Parameters
IGraphNodeBase a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllLess(IEnumerable<object> a, object comparison_target)

Assert element values are all less than a target value.
Parameters
IEnumerable<object> a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllLess(ndarray a, object comparison_target)

Assert element values are all less than a target value.
Parameters
ndarray a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllLess_dyn(object a, object comparison_target)

Assert element values are all less than a target value.
Parameters
object a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllLessEqual(IGraphNodeBase a, object comparison_target)

Assert element values are all less than or equal to a target value.
Parameters
IGraphNodeBase a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllLessEqual(IEnumerable<object> a, object comparison_target)

Assert element values are all less than or equal to a target value.
Parameters
IEnumerable<object> a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllLessEqual(ndarray a, object comparison_target)

Assert element values are all less than or equal to a target value.
Parameters
ndarray a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertAllLessEqual_dyn(object a, object comparison_target)

Assert element values are all less than or equal to a target value.
Parameters
object a
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object comparison_target
The target value of comparison.

object assertArrayNear_dyn(object farray1, object farray2, object err, object msg)

Asserts that two float arrays are near each other.

Checks that for all elements of farray1 and farray2 |f1 - f2| < err. Asserts a test failure if not.
Parameters
object farray1
a list of float values.
object farray2
a list of float values.
object err
a float value.
object msg
Optional message to report on failure.

void assertDeviceEqual(string device1, string device2, object msg)

Asserts that the two given devices are the same.
Parameters
string device1
A string device name or TensorFlow `DeviceSpec` object.
string device2
A string device name or TensorFlow `DeviceSpec` object.
object msg
Optional message to report on failure.

object assertDeviceEqual_dyn(object device1, object device2, object msg)

Asserts that the two given devices are the same.
Parameters
object device1
A string device name or TensorFlow `DeviceSpec` object.
object device2
A string device name or TensorFlow `DeviceSpec` object.
object msg
Optional message to report on failure.

object assertDTypeEqual(IEnumerable<object> target, object expected_dtype)

Assert ndarray data type is equal to expected.
Parameters
IEnumerable<object> target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object expected_dtype
Expected data type.

object assertDTypeEqual(IGraphNodeBase target, object expected_dtype)

Assert ndarray data type is equal to expected.
Parameters
IGraphNodeBase target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object expected_dtype
Expected data type.

object assertDTypeEqual(ndarray target, object expected_dtype)

Assert ndarray data type is equal to expected.
Parameters
ndarray target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object expected_dtype
Expected data type.

object assertDTypeEqual_dyn(object target, object expected_dtype)

Assert ndarray data type is equal to expected.
Parameters
object target
The numpy `ndarray`, or anything that can be converted into a numpy `ndarray` (including Tensor).
object expected_dtype
Expected data type.

object assertNDArrayNear_dyn(object ndarray1, object ndarray2, object err, object msg)

Asserts that two numpy arrays have near values.
Parameters
object ndarray1
a numpy ndarray.
object ndarray2
a numpy ndarray.
object err
a float. The maximum absolute difference allowed.
object msg
Optional message to report on failure.

object assertNear_dyn(object f1, object f2, object err, object msg)

Asserts that two floats are near each other.

Checks that |f1 - f2| < err and asserts a test failure if not.
Parameters
object f1
A float value.
object f2
A float value.
object err
A float value.
object msg
An optional string message to append to the failure message.

object assertNotAllClose(object a, object b, IDictionary<string, object> kwargs)

Assert that two numpy arrays, or Tensors, do not have near values.
Parameters
object a
the first value to compare.
object b
the second value to compare.
IDictionary<string, object> kwargs
additional keyword arguments to be passed to the underlying `assertAllClose` call.

object assertNotAllClose_dyn(object a, object b, IDictionary<string, object> kwargs)

Assert that two numpy arrays, or Tensors, do not have near values.
Parameters
object a
the first value to compare.
object b
the second value to compare.
IDictionary<string, object> kwargs
additional keyword arguments to be passed to the underlying `assertAllClose` call.

object assertNotAllEqual(object a, object b, object msg)

Asserts that two numpy arrays or Tensors do not have the same values.
Parameters
object a
the expected numpy ndarray or anything can be converted to one.
object b
the actual numpy ndarray or anything can be converted to one.
object msg
Optional message to report on failure.

object assertNotAllEqual_dyn(object a, object b, object msg)

Asserts that two numpy arrays or Tensors do not have the same values.
Parameters
object a
the expected numpy ndarray or anything can be converted to one.
object b
the actual numpy ndarray or anything can be converted to one.
object msg
Optional message to report on failure.

void assertProtoEquals(object expected_message_maybe_ascii, TreeEnsemble message, object msg)

Asserts that message is same as parsed expected_message_ascii.

Creates another prototype of message, reads the ascii message into it and then compares them using self._AssertProtoEqual().
Parameters
object expected_message_maybe_ascii
proto message in original or ascii form.
TreeEnsemble message
the message to validate.
object msg
Optional message to report on failure.

object assertProtoEquals_dyn(object expected_message_maybe_ascii, object message, object msg)

Asserts that message is same as parsed expected_message_ascii.

Creates another prototype of message, reads the ascii message into it and then compares them using self._AssertProtoEqual().
Parameters
object expected_message_maybe_ascii
proto message in original or ascii form.
object message
the message to validate.
object msg
Optional message to report on failure.

void assertProtoEqualsVersion(string expected, object actual, ImplicitContainer<T> producer, ImplicitContainer<T> min_consumer, object msg)

object assertProtoEqualsVersion_dyn(object expected, object actual, ImplicitContainer<T> producer, ImplicitContainer<T> min_consumer, object msg)

object assertRaisesOpError(string expected_err_re_or_predicate)

object assertRaisesOpError(object expected_err_re_or_predicate)

object assertRaisesOpError_dyn(object expected_err_re_or_predicate)

IContextManager<T> assertRaisesWithPredicateMatch(object exception_type, object expected_err_re_or_predicate)

Returns a context manager to enclose code expected to raise an exception.

If the exception is an OpError, the op stack is also included in the message predicate search.
Parameters
object exception_type
The expected type of exception that should be raised.
object expected_err_re_or_predicate
If this is callable, it should be a function of one argument that inspects the passed-in exception and returns True (success) or False (please fail the test). Otherwise, the error message is expected to match this regular expression partially.
Returns
IContextManager<T>
A context manager to surround code that is expected to raise an exception.

IContextManager<T> assertRaisesWithPredicateMatch(Exception exception_type, PythonFunctionContainer expected_err_re_or_predicate)

Returns a context manager to enclose code expected to raise an exception.

If the exception is an OpError, the op stack is also included in the message predicate search.
Parameters
Exception exception_type
The expected type of exception that should be raised.
PythonFunctionContainer expected_err_re_or_predicate
If this is callable, it should be a function of one argument that inspects the passed-in exception and returns True (success) or False (please fail the test). Otherwise, the error message is expected to match this regular expression partially.
Returns
IContextManager<T>
A context manager to surround code that is expected to raise an exception.

IContextManager<T> assertRaisesWithPredicateMatch(object exception_type, PythonFunctionContainer expected_err_re_or_predicate)

Returns a context manager to enclose code expected to raise an exception.

If the exception is an OpError, the op stack is also included in the message predicate search.
Parameters
object exception_type
The expected type of exception that should be raised.
PythonFunctionContainer expected_err_re_or_predicate
If this is callable, it should be a function of one argument that inspects the passed-in exception and returns True (success) or False (please fail the test). Otherwise, the error message is expected to match this regular expression partially.
Returns
IContextManager<T>
A context manager to surround code that is expected to raise an exception.

IContextManager<T> assertRaisesWithPredicateMatch(Exception exception_type, object expected_err_re_or_predicate)

Returns a context manager to enclose code expected to raise an exception.

If the exception is an OpError, the op stack is also included in the message predicate search.
Parameters
Exception exception_type
The expected type of exception that should be raised.
object expected_err_re_or_predicate
If this is callable, it should be a function of one argument that inspects the passed-in exception and returns True (success) or False (please fail the test). Otherwise, the error message is expected to match this regular expression partially.
Returns
IContextManager<T>
A context manager to surround code that is expected to raise an exception.

object assertRaisesWithPredicateMatch_dyn(object exception_type, object expected_err_re_or_predicate)

Returns a context manager to enclose code expected to raise an exception.

If the exception is an OpError, the op stack is also included in the message predicate search.
Parameters
object exception_type
The expected type of exception that should be raised.
object expected_err_re_or_predicate
If this is callable, it should be a function of one argument that inspects the passed-in exception and returns True (success) or False (please fail the test). Otherwise, the error message is expected to match this regular expression partially.
Returns
object
A context manager to surround code that is expected to raise an exception.

void assertShapeEqual(Complex np_array, IGraphNodeBase tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
Complex np_array
A Numpy ndarray or Numpy scalar.
IGraphNodeBase tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(ndarray np_array, ValueTuple<PythonClassContainer, PythonClassContainer> tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
ndarray np_array
A Numpy ndarray or Numpy scalar.
ValueTuple<PythonClassContainer, PythonClassContainer> tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(ndarray np_array, IEnumerable<object> tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
ndarray np_array
A Numpy ndarray or Numpy scalar.
IEnumerable<object> tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(Complex np_array, IndexedSlices tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
Complex np_array
A Numpy ndarray or Numpy scalar.
IndexedSlices tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(ndarray np_array, IGraphNodeBase tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
ndarray np_array
A Numpy ndarray or Numpy scalar.
IGraphNodeBase tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(ndarray np_array, IndexedSlices tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
ndarray np_array
A Numpy ndarray or Numpy scalar.
IndexedSlices tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(IEnumerable<ndarray> np_array, ValueTuple<PythonClassContainer, PythonClassContainer> tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
IEnumerable<ndarray> np_array
A Numpy ndarray or Numpy scalar.
ValueTuple<PythonClassContainer, PythonClassContainer> tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(IEnumerable<ndarray> np_array, IndexedSlices tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
IEnumerable<ndarray> np_array
A Numpy ndarray or Numpy scalar.
IndexedSlices tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(IEnumerable<ndarray> np_array, IGraphNodeBase tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
IEnumerable<ndarray> np_array
A Numpy ndarray or Numpy scalar.
IGraphNodeBase tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(Complex np_array, IEnumerable<object> tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
Complex np_array
A Numpy ndarray or Numpy scalar.
IEnumerable<object> tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(Complex np_array, ValueTuple<PythonClassContainer, PythonClassContainer> tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
Complex np_array
A Numpy ndarray or Numpy scalar.
ValueTuple<PythonClassContainer, PythonClassContainer> tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(object np_array, IGraphNodeBase tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
object np_array
A Numpy ndarray or Numpy scalar.
IGraphNodeBase tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(object np_array, IndexedSlices tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
object np_array
A Numpy ndarray or Numpy scalar.
IndexedSlices tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(object np_array, ValueTuple<PythonClassContainer, PythonClassContainer> tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
object np_array
A Numpy ndarray or Numpy scalar.
ValueTuple<PythonClassContainer, PythonClassContainer> tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(object np_array, IEnumerable<object> tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
object np_array
A Numpy ndarray or Numpy scalar.
IEnumerable<object> tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertShapeEqual(IEnumerable<ndarray> np_array, IEnumerable<object> tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
IEnumerable<ndarray> np_array
A Numpy ndarray or Numpy scalar.
IEnumerable<object> tf_tensor
A Tensor.
object msg
Optional message to report on failure.

object assertShapeEqual_dyn(object np_array, object tf_tensor, object msg)

Asserts that a Numpy ndarray and a TensorFlow tensor have the same shape.
Parameters
object np_array
A Numpy ndarray or Numpy scalar.
object tf_tensor
A Tensor.
object msg
Optional message to report on failure.

void assertStartsWith(string actual, string expected_start, object msg)

Assert that actual.startswith(expected_start) is True.
Parameters
string actual
str
string expected_start
str
object msg
Optional message to report on failure.

void assertStartsWith(object actual, string expected_start, object msg)

Assert that actual.startswith(expected_start) is True.
Parameters
object actual
str
string expected_start
str
object msg
Optional message to report on failure.

object assertStartsWith_dyn(object actual, object expected_start, object msg)

Assert that actual.startswith(expected_start) is True.
Parameters
object actual
str
object expected_start
str
object msg
Optional message to report on failure.

IContextManager<T> cached_session(Graph graph, object config, bool use_gpu, bool force_gpu)

Returns a TensorFlow Session for use in executing tests.

This method behaves differently than self.session(): for performance reasons `cached_session` will by default reuse the same session within the same test. The session returned by this function will only be closed at the end of the test (in the TearDown function).

Use the `use_gpu` and `force_gpu` options to control where ops are run. If `force_gpu` is True, all ops are pinned to `/device:GPU:0`. Otherwise, if `use_gpu` is True, TensorFlow tries to run as many ops on the GPU as possible. If both `force_gpu and `use_gpu` are False, all ops are pinned to the CPU.

Example:
Parameters
Graph graph
Optional graph to use during the returned session.
object config
An optional config_pb2.ConfigProto to use to configure the session.
bool use_gpu
If True, attempt to run as many ops as possible on GPU.
bool force_gpu
If True, pin all ops to `/device:GPU:0`.
Show Example
class MyOperatorTest(test_util.TensorFlowTestCase):
              def testMyOperator(self):
                with self.cached_session(use_gpu=True) as sess:
                  valid_input = [1.0, 2.0, 3.0, 4.0, 5.0]
                  result = MyOperator(valid_input).eval()
                  self.assertEqual(result, [1.0, 2.0, 3.0, 5.0, 8.0]
                  invalid_input = [-1.0, 2.0, 7.0]
                  with self.assertRaisesOpError("negative input not supported"):
                    MyOperator(invalid_input).eval() 

object cached_session_dyn(object graph, object config, ImplicitContainer<T> use_gpu, ImplicitContainer<T> force_gpu)

Returns a TensorFlow Session for use in executing tests.

This method behaves differently than self.session(): for performance reasons `cached_session` will by default reuse the same session within the same test. The session returned by this function will only be closed at the end of the test (in the TearDown function).

Use the `use_gpu` and `force_gpu` options to control where ops are run. If `force_gpu` is True, all ops are pinned to `/device:GPU:0`. Otherwise, if `use_gpu` is True, TensorFlow tries to run as many ops on the GPU as possible. If both `force_gpu and `use_gpu` are False, all ops are pinned to the CPU.

Example:
Parameters
object graph
Optional graph to use during the returned session.
object config
An optional config_pb2.ConfigProto to use to configure the session.
ImplicitContainer<T> use_gpu
If True, attempt to run as many ops as possible on GPU.
ImplicitContainer<T> force_gpu
If True, pin all ops to `/device:GPU:0`.
Show Example
class MyOperatorTest(test_util.TensorFlowTestCase):
              def testMyOperator(self):
                with self.cached_session(use_gpu=True) as sess:
                  valid_input = [1.0, 2.0, 3.0, 4.0, 5.0]
                  result = MyOperator(valid_input).eval()
                  self.assertEqual(result, [1.0, 2.0, 3.0, 5.0, 8.0]
                  invalid_input = [-1.0, 2.0, 7.0]
                  with self.assertRaisesOpError("negative input not supported"):
                    MyOperator(invalid_input).eval() 

IContextManager<T> captureWritesToStream(PythonClassContainer stream)

A context manager that captures the writes to a given stream.

This context manager captures all writes to a given stream inside of a `CapturedWrites` object. When this context manager is created, it yields the `CapturedWrites` object. The captured contents can be accessed by calling `.contents()` on the `CapturedWrites`.

For this function to work, the stream must have a file descriptor that can be modified using `os.dup` and `os.dup2`, and the stream must support a `.flush()` method. The default python sys.stdout and sys.stderr are examples of this. Note that this does not work in Colab or Jupyter notebooks, because those use alternate stdout streams.

Example:
Parameters
PythonClassContainer stream
The stream whose writes should be captured. This stream must have a file descriptor, support writing via using that file descriptor, and must have a `.flush()` method.
Show Example
class MyOperatorTest(test_util.TensorFlowTestCase):
              def testMyOperator(self):
                input = [1.0, 2.0, 3.0, 4.0, 5.0]
                with self.captureWritesToStream(sys.stdout) as captured:
                  result = MyOperator(input).eval()
                self.assertStartsWith(captured.contents(), "This was printed.") 

object captureWritesToStream_dyn(object stream)

A context manager that captures the writes to a given stream.

This context manager captures all writes to a given stream inside of a `CapturedWrites` object. When this context manager is created, it yields the `CapturedWrites` object. The captured contents can be accessed by calling `.contents()` on the `CapturedWrites`.

For this function to work, the stream must have a file descriptor that can be modified using `os.dup` and `os.dup2`, and the stream must support a `.flush()` method. The default python sys.stdout and sys.stderr are examples of this. Note that this does not work in Colab or Jupyter notebooks, because those use alternate stdout streams.

Example:
Parameters
object stream
The stream whose writes should be captured. This stream must have a file descriptor, support writing via using that file descriptor, and must have a `.flush()` method.
Show Example
class MyOperatorTest(test_util.TensorFlowTestCase):
              def testMyOperator(self):
                input = [1.0, 2.0, 3.0, 4.0, 5.0]
                with self.captureWritesToStream(sys.stdout) as captured:
                  result = MyOperator(input).eval()
                self.assertStartsWith(captured.contents(), "This was printed.") 

TestCase._CheckedThread checkedThread(PythonFunctionContainer target, Nullable<ValueTuple<object, Session>> args, IDictionary<string, object> kwargs)

Returns a Thread wrapper that asserts 'target' completes successfully.

This method should be used to create all threads in test cases, as otherwise there is a risk that a thread will silently fail, and/or assertions made in the thread will not be respected.
Parameters
PythonFunctionContainer target
A callable object to be executed in the thread.
Nullable<ValueTuple<object, Session>> args
The argument tuple for the target invocation. Defaults to ().
IDictionary<string, object> kwargs
A dictionary of keyword arguments for the target invocation. Defaults to {}.
Returns
TestCase._CheckedThread
A wrapper for threading.Thread that supports start() and join() methods.

object checkedThread_dyn(object target, object args, object kwargs)

Returns a Thread wrapper that asserts 'target' completes successfully.

This method should be used to create all threads in test cases, as otherwise there is a risk that a thread will silently fail, and/or assertions made in the thread will not be respected.
Parameters
object target
A callable object to be executed in the thread.
object args
The argument tuple for the target invocation. Defaults to ().
object kwargs
A dictionary of keyword arguments for the target invocation. Defaults to {}.
Returns
object
A wrapper for threading.Thread that supports start() and join() methods.

object evaluate(PythonFunctionContainer tensors)

Evaluates tensors and returns numpy values.
Parameters
PythonFunctionContainer tensors
A Tensor or a nested list/tuple of Tensors.
Returns
object
tensors numpy values.

string get_temp_dir()

Returns a unique temporary directory for the test to use.

If you call this method multiple times during in a test, it will return the same folder. However, across different runs the directories will be different. This will ensure that across different runs tests will not be able to pollute each others environment. If you need multiple unique directories within a single test, you should use tempfile.mkdtemp as follows: tempfile.mkdtemp(dir=self.get_temp_dir()):
Returns
string
string, the path to the unique temporary directory created for this test.

object get_temp_dir_dyn()

Returns a unique temporary directory for the test to use.

If you call this method multiple times during in a test, it will return the same folder. However, across different runs the directories will be different. This will ensure that across different runs tests will not be able to pollute each others environment. If you need multiple unique directories within a single test, you should use tempfile.mkdtemp as follows: tempfile.mkdtemp(dir=self.get_temp_dir()):
Returns
object
string, the path to the unique temporary directory created for this test.

IContextManager<T> session(Graph graph, object config, bool use_gpu, bool force_gpu)

Returns a TensorFlow Session for use in executing tests.

Note that this will set this session and the graph as global defaults.

Use the `use_gpu` and `force_gpu` options to control where ops are run. If `force_gpu` is True, all ops are pinned to `/device:GPU:0`. Otherwise, if `use_gpu` is True, TensorFlow tries to run as many ops on the GPU as possible. If both `force_gpu and `use_gpu` are False, all ops are pinned to the CPU.

Example:
Parameters
Graph graph
Optional graph to use during the returned session.
object config
An optional config_pb2.ConfigProto to use to configure the session.
bool use_gpu
If True, attempt to run as many ops as possible on GPU.
bool force_gpu
If True, pin all ops to `/device:GPU:0`.
Show Example
class MyOperatorTest(test_util.TensorFlowTestCase):
              def testMyOperator(self):
                with self.session(use_gpu=True):
                  valid_input = [1.0, 2.0, 3.0, 4.0, 5.0]
                  result = MyOperator(valid_input).eval()
                  self.assertEqual(result, [1.0, 2.0, 3.0, 5.0, 8.0]
                  invalid_input = [-1.0, 2.0, 7.0]
                  with self.assertRaisesOpError("negative input not supported"):
                    MyOperator(invalid_input).eval() 

object session_dyn(object graph, object config, ImplicitContainer<T> use_gpu, ImplicitContainer<T> force_gpu)

Returns a TensorFlow Session for use in executing tests.

Note that this will set this session and the graph as global defaults.

Use the `use_gpu` and `force_gpu` options to control where ops are run. If `force_gpu` is True, all ops are pinned to `/device:GPU:0`. Otherwise, if `use_gpu` is True, TensorFlow tries to run as many ops on the GPU as possible. If both `force_gpu and `use_gpu` are False, all ops are pinned to the CPU.

Example:
Parameters
object graph
Optional graph to use during the returned session.
object config
An optional config_pb2.ConfigProto to use to configure the session.
ImplicitContainer<T> use_gpu
If True, attempt to run as many ops as possible on GPU.
ImplicitContainer<T> force_gpu
If True, pin all ops to `/device:GPU:0`.
Show Example
class MyOperatorTest(test_util.TensorFlowTestCase):
              def testMyOperator(self):
                with self.session(use_gpu=True):
                  valid_input = [1.0, 2.0, 3.0, 4.0, 5.0]
                  result = MyOperator(valid_input).eval()
                  self.assertEqual(result, [1.0, 2.0, 3.0, 5.0, 8.0]
                  invalid_input = [-1.0, 2.0, 7.0]
                  with self.assertRaisesOpError("negative input not supported"):
                    MyOperator(invalid_input).eval() 

IContextManager<T> test_session(Graph graph, object config, bool use_gpu, bool force_gpu)

Use cached_session instead. (deprecated)

Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use `self.session()` or `self.cached_session()` instead.

object test_session_dyn(object graph, object config, ImplicitContainer<T> use_gpu, ImplicitContainer<T> force_gpu)

Use cached_session instead. (deprecated)

Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use `self.session()` or `self.cached_session()` instead.

Public properties

object assertItemsEqual get; set;

An unordered sequence comparison asserting that the same elements, regardless of order. If the same element occurs more than once, it verifies that the elements occur the same number of times.

self.assertEqual(Counter(list(first)), Counter(list(second)))

Example: - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal.

object assertItemsEqual_dyn get; set;

An unordered sequence comparison asserting that the same elements, regardless of order. If the same element occurs more than once, it verifies that the elements occur the same number of times.

self.assertEqual(Counter(list(first)), Counter(list(second)))

Example: - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal.

object assertRaisesRegexp_dyn get; set;

Asserts that the message in a raised exception matches a regex.

object PythonObject get;