Skip to content

Commit

Permalink
py: Replace "!= None" with "is not None"
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-caron committed Feb 11, 2025
1 parent 88aa809 commit e5ae489
Showing 1 changed file with 8 additions and 8 deletions.
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

0 comments on commit e5ae489

Please sign in to comment.