-
Notifications
You must be signed in to change notification settings - Fork 69
Description
Apologies to jump into an issue but I have some thoughts that are related to sparsity so thought I'd add to this discussion rather than create a new one for now.
I've just started using linopy (and not from a linear programming background either but have used xarray extensively in other contexts) and came across behaviour which I found unintuitive - which is the default behaviour of
LinearExpression.where. I found I needed to passdrop=Trueto get rid of "null" terms in the equations (i.e. significantly reduce the size of the_termdimension)... but my intuition as a new user would have expected this to be the default.So the question / discussion point is what are the reasons for
drop=Truenot being default inLinearExpression.where(and presumablyVariable.whereas well but I've not thought about that so much yet). Are there situations where a user would want to keep entirely null terms in their equations? Or is it simply to align with the xarray defaults?EDIT
On further thought I see why
drop=Falseremains the default, because now in application code I need to deal with the case ofdrop=Trueresulting in misaligned / missing coordinates relative to other data. However, I think the documentation would benefit from a small example of usingdrop=True. Happy to open a PR if that is of interest?Perhaps also some indication in the
__repr__ofLinearExpressionof the sparsity. I think most of my confusion came from the fact that the__repr__hides all thenancoeffs, but they are still present in the_termsdimension of the underlaying data.
Originally posted by @ollie-bell in #248