Hello, this is a tiny fix that I found while playing with this great package.
Description
Selecting an unknown/uninstalled solver fails at indexing of available solvers. This is because avail_solvers is represented as a set, which do not implements __getitem__.
Example Traceback from pytest:
# first try to use selected solver
if solver:
if solver in avail_solvers:
return solver
else:
> logging.warning('Selected solver ' + solver + ' not available. Using ' + avai
l_solvers[0] + " instead.")
E TypeError: 'set' object is not subscriptable
../.virtualenvs/isofba/lib/python3.9/site-packages/straindesign/lptools.py:83: TypeError
Fix implementation
This PR converts avail_solvers into a list previous to the index operation. Additionally, a test was added to check that asking for a non-existing solver selects an existing one properly without raising.
Note that sets are unordered. Usually, you'd get the same solver by converting first to a list; but that is not guaranteed, it may change with the python implementation. Alternatively, one could just raise if the solver is not available.
Hello, this is a tiny fix that I found while playing with this great package.
Description
Selecting an unknown/uninstalled solver fails at indexing of available solvers. This is because
avail_solvers
is represented as a set, which do not implements__getitem__
.Example Traceback from pytest:
Fix implementation
This PR converts
avail_solvers
into a list previous to the index operation. Additionally, a test was added to check that asking for a non-existing solver selects an existing one properly without raising.Note that sets are unordered. Usually, you'd get the same solver by converting first to a list; but that is not guaranteed, it may change with the python implementation. Alternatively, one could just raise if the solver is not available.