Skip to content

Commit da426d9

Browse files
committed
BF: round() in JS wasn't using our own version but Math.round()
1 parent bb1d06d commit da426d9

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

psychopy/experiment/components/settings/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ def writeInitCodeJS(self, buff, version, localDateTime, modular=True):
574574
"import * as util from './lib/util{version}.js';\n"
575575
"//some handy aliases as in the psychopy scripts;\n"
576576
"const {{ abs, sin, cos, PI: pi, sqrt }} = Math;\n"
577+
"const {{ round }} = util;\n"
577578
"\n").format(version=versionStr)
578579
buff.writeIndentedLines(code)
579580

psychopy/experiment/py2js_transpiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class pythonTransformer(ast.NodeTransformer):
4848
subtitutableOperations = []
4949

5050
# operations from the math python module or builtin operations that exist in JavaScript Math:
51-
directMathOperations = ['abs', 'min', 'max', 'round', 'ceil', 'fabs', 'floor', 'trunc', 'exp', 'log', 'log2', 'pow',
51+
directMathOperations = ['abs', 'min', 'max', 'ceil', 'fabs', 'floor', 'trunc', 'exp', 'log', 'log2', 'pow',
5252
'sqrt', 'acos', 'asin', 'atan2', 'cos', 'sin', 'tan', 'acosh', 'asinh', 'atanh', 'cosh',
5353
'sinh', 'tanh']
5454

0 commit comments

Comments
 (0)