Skip to content

Fixed typing of arithmetic methods #454

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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

RobbieKiwi
Copy link

Closes #435.

Changes proposed in this Pull Request

Arithmetic methods now understand that data array is a valid type for addition/multiplication

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.

Copy link
Member

@lkstrp lkstrp left a comment

Choose a reason for hiding this comment

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

Thanks @RobbieKiwi, that was annoying. Could you also add the missing lines to the test and resolve the other mypy warnings?

@RobbieKiwi
Copy link
Author

Is there a reason why one of these should work and the other should give a type error?
x + x * y + 5
5 + x * y + x

@RobbieKiwi
Copy link
Author

RobbieKiwi commented May 6, 2025

@lkstrp I went down a bit of a rabbit hole with the typing in order to make sure the type checker could tell the difference between a LinearExpression and QuadraticExpression which involved breaking the inheritance between the two and making a base class. Could you please have another look?

Robbie Muir added 2 commits May 6, 2025 22:59
@FabianHofmann
Copy link
Collaborator

impressive work @RobbieKiwi ! @lkstrp or I will go through it soon! we'll make another release today but this will definitely go into the next one!

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.

mypy claims Variable +/* DataArray not supported
3 participants