-
Notifications
You must be signed in to change notification settings - Fork 767
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
False "not accessed" positive #1096
Comments
Indeed, removing: weights = iter(res.x)
c.weight = next(weights)
for g in c.groups:
g.weight = next(weights) suppresses the spurious report. If I also remove: if not res.success:
raise OptimizationError(res) the report is now for I think the problem has to do with the assignment to |
Here is a reproducible example: import numpy as np
import scipy as sp
def f():
weights = np.ones(10)
hess = np.eye(10)
res = sp.optimize.minimize(
lambda w: 0.5 * ((w - weights) ** 2).sum(),
weights,
jac=lambda w: w - weights,
hess=lambda w: hess,
)
weights = iter(res.x)
return weights |
Thanks for the bug report. This will be fixed in the next release. |
This issue has been fixed in version 2021.3.4, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202134-31-march-2021 |
Thanks! |
Environment data
Expected behaviour
In the following code fragment:
pylance is showing
"hess" is not accessed
for the. first line. The problem is related to the way I access the results ofminimize
: as an iterator onres.x
. This seems to make pylance believe I'm not using the result at all.Actual behaviour
Since I'm actually using the results of
minimize
andhess
is indeed part of the input ofminimize
, the error is spurious and should not be shown.The text was updated successfully, but these errors were encountered: