Modify __repr__ and __str__ of MultiIndexSet.
The dunder methods __repr__()
and __str__()
of the MultiIndexSet
class are revised. Following a Python best-practice, __repr__()
now
includes the information on lp-degree as the minimum required information to reproduce the instance. __str__()
now includes information regarding the spatial dimension (m
), polynomial degree (n
), and lp-degree (p
) to be more user-friendly.
This MR should resolve Issue #133 (closed).
Additionally, the test suite is updated with the tests for the string representation of the MultiIndexSet
instances (both repr()
and str()
).
The outputs for both repr()
and str()
are now:
>>> import minterpy as mp
>>> mi = mp.MultiIndexSet.from_degree(6, 9, 2)
>>> print(mi) # calls print(__str__())
MultiIndexSet(m=6, n=9, p=2.0)
[[0 0 0 0 0 0]
[1 0 0 0 0 0]
[2 0 0 0 0 0]
...
[0 0 1 0 4 8]
[0 0 0 1 4 8]
[0 0 0 0 0 9]]
>>> mi # calls print(__repr__())
MultiIndexSet(
array([[0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0],
[2, 0, 0, 0, 0, 0],
...,
[0, 0, 1, 0, 4, 8],
[0, 0, 0, 1, 4, 8],
[0, 0, 0, 0, 0, 9]]),
lp_degree=2.0
)