Skip to content

Commit

Permalink
BF: round() in JS wasn't using our own version but Math.round()
Browse files Browse the repository at this point in the history
  • Loading branch information
peircej committed Oct 6, 2020
1 parent bb1d06d commit da426d9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions psychopy/experiment/components/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ def writeInitCodeJS(self, buff, version, localDateTime, modular=True):
"import * as util from './lib/util{version}.js';\n"
"//some handy aliases as in the psychopy scripts;\n"
"const {{ abs, sin, cos, PI: pi, sqrt }} = Math;\n"
"const {{ round }} = util;\n"
"\n").format(version=versionStr)
buff.writeIndentedLines(code)

Expand Down
2 changes: 1 addition & 1 deletion psychopy/experiment/py2js_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class pythonTransformer(ast.NodeTransformer):
subtitutableOperations = []

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

Expand Down

0 comments on commit da426d9

Please sign in to comment.