[X] make format && make documentation has been run.
What's changed
Fixes #100. Previously, in #205, we downgraded one line of enums.py. The reason for this line was previously unclear, but notably, it always runs: it takes the array variable, determines whether it equals 0 (which yields True or False), then determines whether the resulting value is a Boolean, which it always is.
This was construed as a means of checking whether or not an array is of Boolean type in the comments, but what this piece of code actually does is converts all arrays passed into the function to Numpy's Unicode-string type. However, that is ambiguous due to how it's written, as well as Numpy's own confusing syntax. I believe this code also raises a FutureWarning because it takes a Numpy ndarray type and compares it with a Python type, in this case, a number.
In order to silence the warning and clean up the code, this PR instead determines whether the inbound array is of dtype "S," which confusingly stands for "bytewise-string." If so, it converts it to "str" type, which yields a dtype "U," or "Unicode-string," array.
Tests
This was tested via a Jupyter notebook with a sample policyengine-uk setup that mirrors Nikhil's in #203. That said, it has not been tested with policyengine-us.
make format && make documentation
has been run.What's changed
Fixes #100. Previously, in #205, we downgraded one line of
enums.py
. The reason for this line was previously unclear, but notably, it always runs: it takes thearray
variable, determines whether it equals 0 (which yieldsTrue
orFalse
), then determines whether the resulting value is a Boolean, which it always is.This was construed as a means of checking whether or not an array is of Boolean type in the comments, but what this piece of code actually does is converts all arrays passed into the function to Numpy's Unicode-string type. However, that is ambiguous due to how it's written, as well as Numpy's own confusing syntax. I believe this code also raises a
FutureWarning
because it takes a Numpyndarray
type and compares it with a Python type, in this case, a number.In order to silence the warning and clean up the code, this PR instead determines whether the inbound array is of dtype "S," which confusingly stands for "bytewise-string." If so, it converts it to "str" type, which yields a dtype "U," or "Unicode-string," array.
Tests
This was tested via a Jupyter notebook with a sample
policyengine-uk
setup that mirrors Nikhil's in #203. That said, it has not been tested withpolicyengine-us
.