You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cmath.log() should take one or two arguments according to Toolbox. Ordinary math.log() can take two arguments.
import cmath
cmath.log(2+3j,10)
Last command
TypeError: function takes 1 positional arguments but 2 were given
A workaround is to define a new function: def log(z,a):return cmath.log(z)/cmath.log(a)
and that worked for log(z,a). cmath.log=log
could not be used to add the new version of the function to cmath, but that is perhaps normal for this version of MicroPython.
Screenshots
To Reproduce
Steps to reproduce the behavior:
Go to the Python app
Type:
import cmath
cmath.log(2+3j,10)
See error
Expected behavior
It should work as in CPython.
Environment
Epsilon version 23.2.1 and 23.2.5
The platform(s) on which the problem happens: online simulator (23.2.1) and actual device 23.2.5
The text was updated successfully, but these errors were encountered:
I am not sure I understand your comment. According to the Micropython documentation, cmath.log only takes one argument (math.log can indeed take two arguments, but this option is not listed for cmath.log).
Also, about the toolbox. On other graphing calculators (unlike in micropython) log is reserved for base 10 logarithm and ln is reserved for base e logarithm. These two have dedicated buttons on the Numworks, too. This is why there is a general base log option in the toolbox. As an IB high school teacher I would not like to see this changed (but maybe I misunderstood your comment).
You see the menu for cmath above. In that log(z, a) has two arguments, but that doesn't work in practice when using cmath (it works when using math). If you in Python shell select from cmath import * and select log(z, a) from the cmath menu you get log(,) on the command line. If you do e.g. log(2,3) you get an error message. log(2) works. I guess the error is in the menu and not in MicroPython, but MicroPython for NumWorks could change if they want it to fit the menu, otherwise they should change the menu.
In Python shell when you press the key ln you get log() (i.e. log to base e) and when you press log you get log10(); this part works as expected.
Describe the bug
cmath.log()
should take one or two arguments according to Toolbox. Ordinarymath.log()
can take two arguments.A workaround is to define a new function:
def log(z,a):return cmath.log(z)/cmath.log(a)
and that worked for
log(z,a)
.cmath.log=log
could not be used to add the new version of the function to
cmath
, but that is perhaps normal for this version of MicroPython.Screenshots
To Reproduce
Steps to reproduce the behavior:
import cmath
cmath.log(2+3j,10)
Expected behavior
It should work as in CPython.
Environment
The text was updated successfully, but these errors were encountered: