Instantiating NumberPartition with a list that contains at least one 0, i.e. [0, 3, 7, 9] will show a warning: Warning: Omitting zeros in the numbers list. Instantiate with keep0=True to keep 0 terms.
and remove the 0s from the list, unless the user specifically states to keep the zeros by instantiating NumberPartition with the keep0=True argument (False by default).
If keep0=True but the list does not contain any 0s, then the list remains unchanged.
If keep0=True and the list contains at least one 0, then no warning is displayed and the list remains unchanged.
Fixes #209
Checklist
[x] I have performed a self-review of my code.
[x] I have commented my code and used numpy-style docstrings
[x] I have made corresponding updates to the documentation.
[x] My changes generate no new warnings
[x] I have added/updated tests to make sure bugfix/feature works.
[x] New and existing unit tests pass locally with my changes.
Type of change
[ ] New feature (non-breaking change which adds functionality) [optimization]
How Has This Been Tested?
Tested locally by manually instantiating different cases of NumberPartition and changing the list arguments and keep0 to see the functionality outside unit tests.
Written unit tests for different cases that cover the code additions
Name the new unit-tests that you have added along with this change.
In test_problems.py, added a unit test test_number_partitioning_handles_0_in_numbers()
Description
0
, i.e.[0, 3, 7, 9]
will show a warning:Warning: Omitting zeros in the numbers list. Instantiate with keep0=True to keep 0 terms.
and remove the 0s from the list, unless the user specifically states to keep the zeros by instantiatingNumberPartition
with thekeep0=True
argument (False
by default).keep0=True
but the list does not contain any0
s, then the list remains unchanged.keep0=True
and the list contains at least one0
, then no warning is displayed and the list remains unchanged.Checklist
Type of change
How Has This Been Tested?
keep0
to see the functionality outside unit tests.Name the new unit-tests that you have added along with this change. In
test_problems.py
, added a unit testtest_number_partitioning_handles_0_in_numbers()