Skip to content

Commit 8a56d7b

Browse files
author
AllenBaranov
committed
Fixed rounding bug where floating point precision caused incorrect rounding down
1 parent 3a5b0b8 commit 8a56d7b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sigllm/primitives/transformation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ def transform(self, X):
158158
sign = 1 * (X >= 0) - 1 * (X < 0)
159159
values = np.abs(X)
160160

161-
values = sign * (values * 10**self.decimal).astype(int)
161+
values = sign * (values * 10**self.decimal)
162+
values = np.where(np.abs(values - np.rint(values)) < 1e-8, np.rint(values), np.floor(values))
163+
values = values.astype(int)
162164

163165
return values, self.minimum, self.decimal
164166

0 commit comments

Comments
 (0)