get_close

  • full name: tenpy.tools.misc.get_close

  • parent module: tenpy.tools.misc

  • type: function

tenpy.tools.misc.get_close(values, target, default=None, eps=1e-13)[source]

Iterate through values and return first entry closer than eps.

Parameters:
  • values (iterable of float) – Values to compare to.

  • target (float) – Value to find.

  • default – Returned if no value close to target is found.

  • eps (float) – Tolerance what counts as “close”, namely everything with abs(val-target) < eps.

Returns:

value – An entry of values, if one close to target is found, otherwise default.

Return type:

float