otp.Operation.float.cmp#
- cmp(other, eps)#
Compare two double values between themselves according to
epsrelative difference.This function returns 0 if column = other, 1 if column > other, and -1 if column < other. Two numbers are considered to be equal if both of them are NaN or
abs(column - other) / (abs(column) + abs(other)) < eps. In other words,epsrepresents a relative difference (percentage) between the two numbers, not an absolute difference.- Parameters
- Returns
result – 0 if column == other, 1 if column > other, and -1 if column < other.
- Return type
Examples
>>> data = otp.Ticks(X=[1, 2.17, 10.31841, 3.141593, 6], ... OTHER=[1.01, 2.1, 10.32841, 3.14, 5], ... EPS=[0, 1, 0.1, 0.001, 0.001]) >>> data["Y"] = data["X"].float.cmp(data["OTHER"], data["EPS"]) >>> otp.run(data) Time X OTHER EPS Y 0 2003-12-01 00:00:00.000 1.000000 1.01000 0.000 -1.0 1 2003-12-01 00:00:00.001 2.170000 2.10000 1.000 0.0 2 2003-12-01 00:00:00.002 10.318410 10.32841 0.100 0.0 3 2003-12-01 00:00:00.003 3.141593 3.14000 0.001 0.0 4 2003-12-01 00:00:00.004 6.000000 5.00000 0.001 1.0
See also