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

genlaguerre poly1d-object doesn't respect 'monic' option at evaluation #7247

Closed
oestfeldt opened this issue Apr 2, 2017 · 1 comment
Closed
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.special
Milestone

Comments

@oestfeldt
Copy link

Using Python 3.6 with Anaconda. Fresh install 2 weeks ago.

I'm using the funciton scipy.special.genlaguerre to generate the generalized laguerre polynomials. The function has the option 'monic' which scales the parameters, such that the leading parameter equals 1.

The returned poly1d-object print correctly scaled, but evaluating the function does not correspond to the printed object. The default function (non-scaled) is always returned.

MWE:
from scipy.special import genlaguerre

gl1 = genlaguerre(1,1,monic=False)
gl2 = genlaguerre(1,1,monic=True)

print(gl1)
print(gl2)

print(gl1(0))
print(gl2(0))

Output:

-1 x + 2

1 x - 2
2.0
2.0

@person142
Copy link
Member

person142 commented Apr 2, 2017

Problem is here:

https://github.com/scipy/scipy/blob/master/scipy/special/orthogonal.py#L130

In particular, in this block of code:

mu = sqrt(hn)
if monic:
    evf = eval_func
    if evf:
        eval_func = lambda x: evf(x) / kn
    mu = mu / abs(kn)
    kn = 1.0

It scales eval_func by kn, which is correct--but then it redefines kn = 1.0, which undoes the scaling.

@person142 person142 added defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.special labels Apr 2, 2017
@person142 person142 modified the milestone: 1.0 Apr 2, 2017
@pv pv closed this as completed Apr 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.special
Projects
None yet
Development

No branches or pull requests

3 participants