Project-Platypus / Platypus

A Free and Open Source Python Library for Multiobjective Optimization
GNU General Public License v3.0
566 stars 153 forks source link

Make it clear that `platypus.Integer` uses gray code #201

Closed this-josh closed 1 year ago

this-josh commented 1 year ago

This is an issue related to #200. :

From reading through the test files, it seems that also.result[0].variables[0] is not a binary number, it is Gray code. Might I suggest this is made more clear as the word 'gray' doesn't appear at all in the docs and most people who see [True, False, True] will view it as binary.

Originally posted by @this-josh in https://github.com/Project-Platypus/Platypus/issues/200#issuecomment-1301853413

dhadka commented 1 year ago

This is called out in the Python docs - https://github.com/Project-Platypus/Platypus/blob/3fec9d1737f11b7fc763bbbfbb9b05d0e4d80dc4/platypus/types.py#L111-L122

Use the decode method to convert from the binary representation to the integer.

this-josh commented 1 year ago

This is not the docs, this is the docstring. You don't typically expect users to read through the code to find doc strings and if that is what you expect them to do I think it should be made explicit. For example integer is also not present in the docs, nor is decode. But as you point out the doc strings have been written, so I refer to my initial issue that this should all be made clearer in the docs