Skip to content

Conversation

@RobbieKiwi
Copy link
Contributor

@RobbieKiwi RobbieKiwi commented Jan 24, 2026

Closes #464

Changes proposed in this Pull Request

Add an example to the docs of LinearExpression.where(..., drop=True)
Add new properties to base expression BaseExpression.variable_names and BaseExpression.nvar

Not addressed / further ideas

In the issue mentioned, I think the reporter wanted to see the unused terms in LinearExpression.repr. After having a bit of a look at it, I think this is impossible because the term dim has no coordinate names. There seems to no way to know what variable originally belonged in a position of the term dim if the original variable has been completely masked (replaced with -1).

Maybe when drop is True we could also run .simplify to get rid of any empty positions in the term dim?
Currently drop=True will drop unused index positions along all dimensions apart from the term dim, it might make more sense to drop on all dims?

Checklist

  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

@RobbieKiwi RobbieKiwi changed the title Feature/sparsity and repr Feature/example of drop=True Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add example of using where with drop = True

1 participant