pylab_ml.common.common.check

check(msg, target, actual, tolerance=0, mask=None)[source]

Compare target with the acutal value with optional tolerance and mask. The target can be a string with mask information, e.g. “0x1X3” or “0b1x0”, where ‘X’ or ‘x’ indicates a masked bit that will not be compared.

Parameters:
  • msg (A message to display with the comparison result.)

  • target (The target value:) – if str and start with 0x than each X is a 4bit mask. if str and start with 0b than each x is a 1bit mask.

  • actual (The actual value to compare with the target.)

  • tolerance (The tolerance for comparing the target and actual values. Default is 0, which means an exact match is required.)

  • mask (An optional mask to apply to the target and actual values before comparing. If provided, the comparison will only consider the bits where the mask has a value of 1.)

Returns:

error – True: target = actual value. False: target != actual value.

Return type:

bool