cf.Field.equals

Field.equals(other, rtol=None, atol=None)

Return True if the variable is congruent to another variable in that

  1. They have identical data. Pointers to data on disk may be converted to numpy arrays in memory if required.
  2. They have identical reserved public attributes.
  3. They have identical public attributes.

Equality of numbers is to within a tolerance. Refer to cf for details.

Parameters:
  • other (object) – The variable to compare against for equality.
  • atol (None or float) – Optional. If None then use the default method for setting the absolute tolerance for numerical equality (refer to cf for details). If a number then set the absolute tolerance to this value for all such comparisons.
  • rtol (None or float) – Optional. If None then use the default method for setting the relative tolerance for numerical equality (refer to cf for details). If a number then set the relative tolerance to this value for all such comparisons.
Returns:

True if the two objects are congruent, False otherwise.

Examples

>>> y = x
>>> x.equals(y)
True
>>> y = x + 1
>>> x.equals(y)
False
>>> y -= 1
>>> x.equals(y)
True
>>> x.setattr('name', 'name0')
>>> y.setattr('name', 'name1')
>>> x.equals(y)
False

Previous topic

cf.Field.dump

Next topic

cf.Field.expand_dims

This Page