Skip to content

Variance in scipy.special.lambertw output depending on scipy version and installation source #2000

Closed
@kandersolar

Description

@kandersolar

Originally discovered in #1996 (comment)

It seems that scipy.special.lambertw can return slightly different values from 1.12.0, depending on how it is installed (with conda or from PyPI with pip). I observe this difference locally on Windows:

>>> import scipy
>>> argW = 6.588940213030326e-08
>>> scipy.special.lambertw(argW)
(6.588939778889038e-08+0j)  # v1.12.0 (PyPI)
(6.588939778889037e-08+0j)  # v1.12.0 (conda)

As an aside, mpmath says that the one ending in 8 is the more accurate of the two:

>>> import mpmath
>>> mpmath.mp.dps = 25
>>> mpmath.lambertw(argW)
mpf('0.0000000658893977888903808156892075')

The relevance is that the particular argW value above was (implicitly) used to generate negative values of v_oc using _lambertw_v_from_i for testing in test_singlediode.py::test_singlediode_lambert_negative_voc. The change from ...8 to ...7 means that the returned voltage is no longer negative and thus causes the test to fail.

Other information: scipy.special.lambertw was translated from cython to C++ for 1.12.0 in scipy/scipy#19435.

What should we do about it? I think the first step is to ask the scipy folks if the difference is considered a bug in scipy that they will address. I will ask the scipy maintainers about this. If they say it is not a bug, then I suppose we should identify alternative values of argW that result in negative Voc for both versions of the scipy calculation and edit our test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions