Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Transurgeon
Copy link
Collaborator

@Transurgeon Transurgeon commented Jan 9, 2025

Description

Please include a short summary of the change.
This PR aims to remove the error being raised when declaring more than one attribute for cvxpy expressions.
The tradeoff for being able to declare such expressions is that we disable projections onto the sets defined by the multiple attributes.
Issue link (if applicable):
#566

Type of change

  • New feature (backwards compatible)
  • New feature (breaking API changes)
  • Bug fix
  • Other (Documentation, CI, ...)

Contribution checklist

  • Add our license to new files.
  • Check that your code adheres to our coding style.
  • Write unittests.
  • Run the unittests and check that they’re passing.
  • Run the benchmarks to make sure your change doesn’t introduce a regression.

@CLAassistant
Copy link

CLAassistant commented Jan 9, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ Transurgeon
✅ SteveDiamond
❌ William Zijie Zhang


William Zijie Zhang seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@PTNobel
Copy link
Collaborator

PTNobel commented Jan 24, 2025

What's the plan for projecting onto multiple attributes?

@SteveDiamond
Copy link
Collaborator

What's the plan for projecting onto multiple attributes?

To start, projection will be disabled when there are multiple attributes. In the long run there may be a few combinations of attributes that are still worth projecting onto.

@Transurgeon Transurgeon marked this pull request as ready for review January 31, 2025 03:44
Copy link
Collaborator

@PTNobel PTNobel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good

@Transurgeon
Copy link
Collaborator Author

ok I had another look at this and was a bit more thoughtful with tests, cases like sparse integer, sparse bounded, and integer bounded variables all seem to work.

One thing that concerns me is people might want to pass sparse values as bounds (or only the nonzeros), so we will need to add a bit of code to cover that. But maybe we can do that in another PR if this seems fine for now?

@SteveDiamond
Copy link
Collaborator

ok I had another look at this and was a bit more thoughtful with tests, cases like sparse integer, sparse bounded, and integer bounded variables all seem to work.

One thing that concerns me is people might want to pass sparse values as bounds (or only the nonzeros), so we will need to add a bit of code to cover that. But maybe we can do that in another PR if this seems fine for now?

Yeah, we can worry about sparse bounds later.

Copy link
Collaborator

@SteveDiamond SteveDiamond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need tests for Parameters with multiple attributes.

@SteveDiamond
Copy link
Collaborator

I added tests for parameters with multiple attributes. These tests exposed an issue where parameter input validation doesn't work for multiple attributes. The issue is too complex to fix in this MR.

@Transurgeon
Copy link
Collaborator Author

I added tests for parameters with multiple attributes. These tests exposed an issue where parameter input validation doesn't work for multiple attributes. The issue is too complex to fix in this MR.

ok sounds good, should we add some expected to fail decorators to those tests? And add TODOs for later?

@SteveDiamond
Copy link
Collaborator

@Transurgeon I fixed the tests but one of the benchmarks is failing

Copy link
Collaborator Author

@Transurgeon Transurgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, should we approve and merge this? We can iterate on this for the other things we had in mind.
@PTNobel it would be nice to have your review on this as well, if you have time.

Copy link
Collaborator

@PTNobel PTNobel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. I'm curious for the story around the commented out tests.

@Transurgeon
Copy link
Collaborator Author

Transurgeon commented Apr 8, 2025

made a PR to fix the failing (and unrelated) test #2784 .
also based on a new comment in discussion #2664, I think we should also test if sparse complex variables work. However, I can't really think of a good test. copilot suggested something but I am not sure its making any sense.

@SteveDiamond
Copy link
Collaborator

made a PR to fix the failing (and unrelated) test #2784 . also based on a new comment in discussion #2664, I think we should also test if sparse complex variables work. However, I can't really think of a good test. copilot suggested something but I am not sure its making any sense.

I added complex + sparse tests. They actually caught a bug.

if self._value is None:
return None
val = np.zeros(self.shape)
val = np.zeros(self.shape, dtype=self._value.dtype)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh really nice catch!

@Transurgeon Transurgeon merged commit 46c874c into cvxpy:master Apr 10, 2025
7 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants