diff --git a/linopy/expressions.py b/linopy/expressions.py index a15e2233..3dad78af 100644 --- a/linopy/expressions.py +++ b/linopy/expressions.py @@ -432,11 +432,11 @@ def __mul__(self, other): ds = ds.assign(const=other.const) return merge(self, ds, dim=FACTOR_DIM, cls=QuadraticExpression) else: - coeffs = self.coeffs * as_dataarray( - other, coords=self.coords, dims=self.coord_dims - ) + multiplyer = as_dataarray(other, coords=self.coords, dims=self.coord_dims) + coeffs = self.coeffs * multiplyer assert set(coeffs.shape) == set(self.coeffs.shape) - return self.assign(coeffs=coeffs) + const = self.const * multiplyer + return self.assign(coeffs=coeffs, const=const) def __rmul__(self, other): """