deep copy not working in _match_dims ?
The _match_dims(poly1, poly2, copy=None)
in canonical_polynomial.py doesnt seem to be doing deep copy of the polynomial correctly. It is altering the multi index of the input polynomial.
Minimal code to reproduce the issue:
mi1 = mp.MultiIndex.from_degree(3, 2, 2.0)
coeffs1 = np.array([1, 2, 0, 4, 3, 0, 5, 0, 0, 0, 0])
mi2 = mp.MultiIndex.from_degree(2, 2, 2.0)
mi2_exponents = mi2.exponents.copy()
coeffs2 = np.array([1, 2, 0, 3, 4, 0])
can_poly_1 = mp.CanonicalPolynomial(coeffs1, mi1)
can_poly_2 = mp.CanonicalPolynomial(coeffs2, mi2)
res = can_poly_1 + can_poly_2
assert can_poly_2.multi_index.exponents == mi2_exponents
Expected behavior: the input polynomials and their multi index set remain unaffected after addition.