Add trigonometric functions to sqlite backend
issue9996 review333731002
This commit is contained in:
1 parent
2ba3e1bdb6
commit
6fec6444fc
3 files changed
+21
No files matched your search
@@ -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
|
||||
|
||||
@@ -375,6 +375,17 @@ class Database(DatabaseInterface):
|
||||
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)
|
||||
|
||||
@@ -110,6 +110,15 @@ class BackendTestCase(unittest.TestCase):
|
||||
(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'),
|
||||
|
||||
Reference in new issue
Block a user