Stefan-Endres / shgo

Simplicial Homology Global Optimization
https://stefan-endres.github.io/shgo
MIT License
44 stars 12 forks source link

Avoid using `is` to check string equality #22

Closed alchemyst closed 3 years ago

alchemyst commented 6 years ago

There are a couple of places in the code where we use is to check for string equality, so

if a is 'teststring':
    # whatever

This is not guaranteed to work for all strings as it relies on an implementation detail in cpython (where small strings are cached. It should be taken away wherever it is used.

Stefan-Endres commented 3 years ago

Couldn't find any more instances of this after the refactoring in c5ef42f8bd6c37ec2f7d33135b241b06d4613900.

alchemyst commented 3 years ago

There are still some in _shgo_lib/_complex.py (see for instance here)

Stefan-Endres commented 3 years ago

Fixed with 9b206ee0bfe8bcc9bcaecad0ea508e609c0fc289