changeset caadf76bf505 in trytond:default details: https://hg.tryton.org/trytond?cmd=changeset;node=caadf76bf505 description: Add trigonometric functions to sqlite backend
issue9996 review333731002 diffstat: CHANGELOG | 1 + trytond/backend/sqlite/database.py | 11 +++++++++++ trytond/tests/test_backend.py | 9 +++++++++ 3 files changed, 21 insertions(+), 0 deletions(-) diffs (48 lines): diff -r ef88d61b9594 -r caadf76bf505 CHANGELOG --- a/CHANGELOG Fri Feb 05 00:21:10 2021 +0100 +++ b/CHANGELOG Sat Feb 06 10:47:06 2021 +0000 @@ -1,3 +1,4 @@ +* Add trigonometric functions to sqlite backend * Allow skipping user warnings globally * Add validate option to trytond-admin * Refresh pool of other processes diff -r ef88d61b9594 -r caadf76bf505 trytond/backend/sqlite/database.py --- a/trytond/backend/sqlite/database.py Fri Feb 05 00:21:10 2021 +0100 +++ b/trytond/backend/sqlite/database.py Sat Feb 06 10:47:06 2021 +0000 @@ -375,6 +375,17 @@ self._conn.create_function('trunc', 1, math.trunc) self._conn.create_function('trunc', 2, trunc) + # Trigonomentric functions + self._conn.create_function('acos', 1, math.acos) + self._conn.create_function('asin', 1, math.asin) + self._conn.create_function('atan', 1, math.atan) + self._conn.create_function('atan2', 2, math.atan2) + self._conn.create_function('cos', 1, math.cos) + self._conn.create_function( + 'cot', 1, lambda x: 1 / math.tan(x) if x else math.inf) + self._conn.create_function('sin', 1, math.sin) + self._conn.create_function('tan', 1, math.tan) + # Random functions self._conn.create_function('random', 0, random.random) self._conn.create_function('setseed', 1, random.seed) diff -r ef88d61b9594 -r caadf76bf505 trytond/tests/test_backend.py --- a/trytond/tests/test_backend.py Fri Feb 05 00:21:10 2021 +0100 +++ b/trytond/tests/test_backend.py Sat Feb 06 10:47:06 2021 +0000 @@ -110,6 +110,15 @@ (functions.Sqrt(2.), 1.4142135623731), (functions.Trunc(42.8), 42), (functions.Trunc(42.4348, 2), 42.43), + (functions.Acos(0.5), 1.0471975511965979), + (functions.Asin(0.5), 0.5235987755982989), + (functions.Atan(0.5), 0.4636476090008061), + (functions.Atan2(0.5, 0.5), 0.7853981633974483), + (functions.Cos(1), 0.5403023058681398), + (functions.Cot(0), math.inf), + (functions.Cot(1), 0.6420926159343306), + (functions.Sin(1), 0.8414709848078965), + (functions.Tan(1), 1.5574077246549023), (functions.CharLength('jose'), 4), (functions.Lower('TOM'), 'tom'), (functions.Overlay('Txxxxas', 'hom', 2, 4), 'Thomas'),