Caffe2 - Python API
A deep learning, cross platform ML framework
Public Member Functions | Public Attributes | List of all members
verify.Errors Class Reference
Inheritance diagram for verify.Errors:

Public Member Functions

def __init__ (self, msg, rtol=1e-3, atol=1e-5)
 
def requireAlmostEqual (self, x, y, msg=None)
 
def checkAlmostEqual (self, x, y, msg=None)
 
def almostEqualAndThen (self, x, y, msg, k)
 
def requireEqual (self, x, y, msg=None)
 
def checkEqual (self, x, y, msg=None)
 
def equalAndThen (self, x, y, msg, k)
 
def requireMultiLineEqual (self, x, y, msg=None)
 
def multiLineEqualAndThen (self, x, y, msg, k)
 
def addErr (self, msg)
 
def fail (self)
 
def failWith (self, msg)
 
def failIfErrs (self)
 
def recover (parent_self)
 
def addErrCtxt (parent_self, msg)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_value, traceback)
 

Public Attributes

 msg
 
 errors
 
 context
 
 rtol
 
 atol
 
 exc_class
 

Detailed Description

An error-collecting object which supports error recovery.

It is intended to be used like a context manager:

>>> with Errors("Top-level error message") as errs:
>>>     ...

Definition at line 22 of file verify.py.

Member Function Documentation

def verify.Errors.addErr (   self,
  msg 
)
Add an error to the error context, but continue executing.

Definition at line 143 of file verify.py.

def verify.Errors.addErrCtxt (   parent_self,
  msg 
)
Returns a context manager which encloses a fragment of code with
an extra contextual message, e.g., where an error occurred, or a hint
applicable to all errors in the area.  Example usage:

>>> with errs.addErrCtx("Some text"):
>>>     ...

Definition at line 196 of file verify.py.

def verify.Errors.almostEqualAndThen (   self,
  x,
  y,
  msg,
  k 
)
Helper for implementing 'requireAlmostEqual' and 'checkAlmostEqual'.
Upon failure, invokes continuation 'k' with the error message.

At the moment, only tests on 'numpy.ndarray' are supported.

Definition at line 62 of file verify.py.

def verify.Errors.checkAlmostEqual (   self,
  x,
  y,
  msg = None 
)
Test that x and y are nearly equal (equal within self.rtol
precision), but continue execution even if they are not equal.

To prevent error cascades, you should remember to call 'failIfErrs'
at some later point in time.

Definition at line 52 of file verify.py.

def verify.Errors.checkEqual (   self,
  x,
  y,
  msg = None 
)
Test that x and y are equal, but continue execution even if they are not equal.

To prevent error cascades, you should remember to call 'failIfErrs'
at some later point in time.

Definition at line 84 of file verify.py.

def verify.Errors.equalAndThen (   self,
  x,
  y,
  msg,
  k 
)
Helper for implementing 'requireEqual' and 'checkEqual'.  Upon failure,
invokes continuation 'k' with the error message.

Definition at line 94 of file verify.py.

def verify.Errors.fail (   self)
Immediately fail and short-circuit to the next recovery context.

NB: It is an error to 'fail' without having added any errors to
the error context.

Definition at line 154 of file verify.py.

def verify.Errors.failIfErrs (   self)
If there are any errors in the error context, short-circuit.

This is used to prevent error cascades.

Definition at line 170 of file verify.py.

def verify.Errors.failWith (   self,
  msg 
)
Add an error to the error context, and then short-circuit.

Definition at line 163 of file verify.py.

def verify.Errors.multiLineEqualAndThen (   self,
  x,
  y,
  msg,
  k 
)
Helper for implementing 'requireMultiLineEqual'.  Upon failure,
invokes continuation 'k' with the error message.

Definition at line 132 of file verify.py.

def verify.Errors.recover (   parent_self)
Returns a context manager which can be used to recover in case of
an error.  Example usage:

>>> with errs.recover():
>>>     ...

Definition at line 179 of file verify.py.

def verify.Errors.requireAlmostEqual (   self,
  x,
  y,
  msg = None 
)
Test that x and y are nearly equal (equal within self.rtol
precision); aborts execution if they are not.

Definition at line 45 of file verify.py.

def verify.Errors.requireEqual (   self,
  x,
  y,
  msg = None 
)
Test that x and y are equal; aborts execution if they are not.

Definition at line 78 of file verify.py.

def verify.Errors.requireMultiLineEqual (   self,
  x,
  y,
  msg = None 
)
Test that long, multi-line strings x and y are equal;
aborts execution if they are not.

Definition at line 125 of file verify.py.


The documentation for this class was generated from the following file: