Skip to content

Add containment check support to MultiIndexSet.

Damar Wicaksono requested to merge dev-128 into dev

An element of a multi-index set (i.e., a vector of exponents) can now be checked for containment in a MultiIndexSet instance via the in keyword (due to the implementation of __contains__()). If an element is in the set of exponents, True is returned; otherwise, False is returned.

While strictly speaking a one-dimensional NumPy integer array is supposed to represent an index element, the containment check is quite forgiving. Any TypeError or ValueError that may be raised during the check is suppressed and in those cases, False is returned instead.

Following a Python convention, only a single element is supposed to be checked using the keyword. Multiple elements may be checked simultaneously via a dedicated method already available (i.e., contains_these_exponents()) or a list comprehension.

If the dimension between an item differs with the MultiIndexSet instance differs then dimension expansion by right zero padding is first carried out such that the dimension matches.

This commit should resolve Issue #128 (closed).

Additional changes:

  • A new test suite related to containment check is added.
  • A new How-To Guide for containment check of MultiIndexSet instances is added. A guide demonstrating contains_these_exponents() method is already available and it is combined with the set comparison methods. The new guide specifically addresses containment check and the relevant sections have been removed from the previous guide.

Merge request reports