-
Notifications
You must be signed in to change notification settings - Fork 122
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
Extend expression_manipulations.jl to some variables #579
Conversation
- Added docstrings. Still need to add to the documentation - Simplified the versions further - Added add_to_expression for variables, using Jacob's 1 * VarRef trick
One note: I simplified some of the indexing using |
Converting this to a draft as there's an issue with the methods which take GenericVariableRef. The methods work but then don't save the new expression in place of the variable. I'll look at a fix. |
We can't treat Variables and Expressions the same if we want all the functions to be in-place. Using a variable will work but we can't reassign the new expression to the original variable. We could consider other helper functions which take in variables and turn them into expressions. However, in many cases it'll be easier to use add_similar_to_expression!() with the variable as the second argument
I've removed the functions which worked on variables, rather than expressions. They don't work as in-place functions. We can perhaps add new functions in the future to help users go from variables -> expressions |
@lbonaldo @sambuddhac I think this should be ok for v0.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @RuaridhMacd for this PR. I just added a couple of small comments.
As pointed out in PR #562 and elsewhere, there are still some issues with the expression_manipulations functions. This PR tries to resolve the following:
@cfe316 has addressed issue number 4 in PR #562 but I also included a quick way of handling variables using the
1 *
dummy coefficient that he proposed.There are still some extensions we could make, in particular creating arrays using generic expressions and variables which don't use Float64 coefficients and constants or that have non-dense indices.
The SmallNewEngland cases worked for me with these changes but I'd definitely appreciate help checking for any edge cases.