Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

besselk does not implement derivative and does not raise an error when called with derivative #734

Open
electroflow opened this issue Oct 26, 2023 · 3 comments
Labels
enhancement new feature requests (or implementation)
Milestone

Comments

@electroflow
Copy link

Thank you for your very useful software package!

for funcname in ["besseli", "besselj", "besselk", "bessely"]:
    print(funcname, getattr(mpmath, funcname)(1, 1, derivative = 0),  getattr(mpmath, funcname)(1, 1, derivative = 1))

outputs

besseli 0.565159103992485 0.700906773759523
besselj 0.440050585744934 0.325147100813033
besselk 0.601907230197235 0.601907230197235
bessely -0.781212821300289 0.869469785515966

No warning or error message is raised that the derivative is not implemented for besselk. I think at least an error should be raised that the derivative is not implemented, this silent defaulting to derivative = 0 cost me a significant amount of debugging time.

@WarrenWeckesser
Copy link
Contributor

It looks like all those functions ignore unknown keyword parameters (and for some reason besselk doesn't implement the derivative parameter). Ideally, the following call should raise a TypeError (something like TypeError: 'foo' is an invalid keyword argument for besselj()):

In [15]: mp.besselj(3, 1.5, foo=999)
Out[15]: mpf('0.060963951141139631')

@skirpichev skirpichev added the bug an unexpected problem or unintended behavior label Oct 27, 2023
@skirpichev
Copy link
Collaborator

Many functions, esp. using functions from hypergeometric.py have **kwargs. And they don't check keyword parameter names. Proper fix could be using explicit keyword arguments. But that's not an easy and simple change, see e.g. sympy/sympy#14030.

Meanwhile, I'll mark this as a bug. As a partial solution, we could raise NotImplementedError.

skirpichev added a commit to skirpichev/mpmath that referenced this issue Oct 27, 2023
@skirpichev
Copy link
Collaborator

Ok, now we have NotImplementedError

@skirpichev skirpichev added enhancement new feature requests (or implementation) and removed bug an unexpected problem or unintended behavior labels Nov 2, 2023
@skirpichev skirpichev added this to the 1.4 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new feature requests (or implementation)
Projects
None yet
Development

No branches or pull requests

3 participants