Refactor `expand_dim()` method of the `MultiIndexSet` class
Following Issues #103 (closed) and #117 (closed), the method expand_dim()
of the MultiIndexSet
class shall also be refactored to include an inplace
parameter to have a more transparent behavior after expanding the dimension of an existing multi-index set instance. Currently, when this method is called, the modification happens strictly in-place; if a multi-index set is attached to an instance of a Grid
or one of the polynomial classes, then calling the method will change all the multi-index set attached to those instances. This may create unexpected behavior downstream.
Following the other two methods (i.e., add_exponents()
and make_complete()
), the default behavior should be that a new instance is created when the dimension is expanded. Only if inplace
is set to True
, the modification happens in-place.
dimension not-expanded | dimension expanded | |
---|---|---|
inplace=False |
return a shallow copy | return a new instance |
inplace=True |
instance unmodified | instance modified |
The dimension may not be expanded if the value of the dimension argument (i.e., m
in expand_dim(m)
) is the same as the dimension of the current multi-index set instance.
This issue is part of larger refactoring tasks in Issue #99 (closed).
Furthermore, this is part of refactoring the code in-line with Issue #116, where polynomials arithmetics (addition, subtraction, multiplication) becomes important. The expansion of multi-index set is used during addition, subtraction, and multiplication of two polynomials with differing spatial dimensions.