You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the case, that I want to use a custom sort function when working with a SortedSet. The key provided by this function for each value may change, based on some external properties. I now ran into the problem, that when discarding keys from my Set, I get a ValueError:
File "/home/appuser/.pyenv/versions/3.11.7/lib/python3.11/site-packages/sortedcontainers/sortedlist.py", line 2031, in remove
raise ValueError('{0!r} not in list'.format(value))
To be honest, it took me several hours to figure out the cause of this which I believe is the fact, that the key values may change over time. I reproduced this with a simple example which uses random values:
File "/home/appuser/.pyenv/versions/3.11.7/lib/python3.11/site-packages/sortedcontainers/sortedlist.py", line 2031, in remove
raise ValueError('{0!r} not in list'.format(value))
ValueError: 0 not in list
I can somewhat understand that this may not be the exact use case intended for the sorted containers, and I could rebuild the whole SortedSet to work around this. However, it isn't really obvious to me why this happens when I just want to discard a value.
The text was updated successfully, but these errors were encountered:
I have the case, that I want to use a custom sort function when working with a SortedSet. The key provided by this function for each value may change, based on some external properties. I now ran into the problem, that when discarding keys from my Set, I get a ValueError:
To be honest, it took me several hours to figure out the cause of this which I believe is the fact, that the key values may change over time. I reproduced this with a simple example which uses random values:
I can somewhat understand that this may not be the exact use case intended for the sorted containers, and I could rebuild the whole SortedSet to work around this. However, it isn't really obvious to me why this happens when I just want to discard a value.
The text was updated successfully, but these errors were encountered: