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

Replace != None with is not None in Python bindings #375

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions bindings/python/proxsuite/torch/qplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ def backward(ctx, dl_dzhat, dl_dlams, dl_dnus):
for i in range(nBatch):
rhs = np.zeros(n_tot)
rhs[:dim] = dl_dzhat[i]
if dl_dlams != None:
if dl_dlams is not None:
rhs[dim : dim + neq] = dl_dlams[i]
if dl_dnus != None:
if dl_dnus is not None:
rhs[dim + neq :] = dl_dnus[i]
vector_of_loss_derivatives.append(rhs)

Expand All @@ -213,9 +213,9 @@ def backward(ctx, dl_dzhat, dl_dlams, dl_dnus):
for i in range(nBatch):
rhs = np.zeros(n_tot)
rhs[:dim] = dl_dzhat[i].cpu()
if dl_dlams != None:
if dl_dlams is not None:
rhs[dim : dim + neq] = dl_dlams[i].cpu()
if dl_dnus != None:
if dl_dnus is not None:
rhs[dim + neq :] = dl_dnus[i].cpu()
qpi = ctx.vector_of_qps.get(i)
proxsuite.proxqp.dense.compute_backward(
Expand Down Expand Up @@ -473,13 +473,13 @@ def backward(ctx, dl_dzhat, dl_dlams, dl_dnus, dl_ds_e, dl_ds_i):

rhs = np.zeros(kkt.shape[0])
rhs[:dim] = -dl_dzhat[i]
if dl_dlams != None:
if dl_dlams is not None:
if n_eq != 0:
rhs[dim : dim + n_eq] = -dl_dlams[i]
active_set = None
if n_in != 0:
active_set = -z_i[:n_in_sol] + z_i[n_in_sol:] >= 0
if dl_dnus != None:
if dl_dnus is not None:
if n_in != 0:
# we must convert dl_dnus to a uni sided version
# to do so we reconstitute the active set
Expand All @@ -489,10 +489,10 @@ def backward(ctx, dl_dzhat, dl_dlams, dl_dnus, dl_ds_e, dl_ds_i):
rhs[dim + n_eq + n_in_sol : dim + n_eq + n_in][active_set] = (
-dl_dnus[i][active_set]
)
if dl_ds_e != None:
if dl_ds_e is not None:
if dl_ds_e.shape[0] != 0:
rhs[dim + n_eq + n_in : dim + 2 * n_eq + n_in] = -dl_ds_e[i]
if dl_ds_i != None:
if dl_ds_i is not None:
if dl_ds_i.shape[0] != 0:
# we must convert dl_dnus to a uni sided version
# to do so we reconstitute the active set
Expand Down
Loading