ArnaoutLab / diversity

Partitioned frequency- and similarity-sensitive diversity in Python
MIT License
6 stars 1 forks source link

3.11 stricter about not allowing mutable defaults #51

Closed chhotii-alex closed 1 year ago

chhotii-alex commented 1 year ago

Data classes are not supposed to allow mutable default values. Starting with Python 3.11, Python is stricter about this, checking for the hashability of default values (rather than checking against a list of types). Many of the tests are set up by creating data classes containing DataFrames or np.arrays, which are mutable and thus, in Python, not hashable. So, attempting to run pytest under Python 3.11 was generating lots of errors and no useful testing. Got around this by wrapping all the hand-crafted arrays and things with a field containing a lambda returning the thing.

Note that with this fix, we're still not passing all the pytest tests-- I'll open an issue for the other problem.