-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not all types could be used in IntervalDict #29
Comments
The problem is that I cannot rely on import portion as P
d = P.IntervalDict()
d[1] = []
d[2] = []
d.find([]) ... with the current implementation relying on |
Could you avoid comparing dict's values at all? |
Not easily. I need to compare values so I can merge intervals associated to the same value, and limit the space required to store the The thing is that if you have While I understand that it's a shame we cannot store dataframes along with intervals, I would say that the problem comes from One possibility would be to allow the creation of an |
Another approach to solving this - remove that contract :) I also could suggest to have some parameter in IntervalDict constructor, which determines if intervals should be merged on the fly. |
I would like to keep this contract, since it means that all intervals related to a given value are merged together. Consider for example the following d[P.closed(0, 1] = 'a'
d[P.closed(1, 2)] = 'a' If we ask for I'm currently more and more considering adding an |
I wouldn't say it's surprising :) It depends on what problem you're solving with this IntervalDict. Anyway you should be ready that single
Re other use cases - these must be some specific 3rd-party libs that overrides __eq__. |
If there was no alternative solution, I would implement I guess there are other libraries that do no follow Python's expectations for What I am also afraid of is that it opens the door to other similar changes. For example, one could argue that it would be nice to have the possibility to override/define the comparison functions ( Of course,I'm not saying that I'm not going to do anything about this issue :-) I just want to take the time to think carefully about the possibilities and alternatives, as well as the long term implications on the code (esp. since |
No hurry :) Still it's great library that I'm using now on small project. Thanks! |
I discussed with some friends about this issue, since I couldn't decide what's the best way to address it. We concluded that it's probably better to stick with the current implementation, and to suggest to wrap/unwrap objects on-the-fly when they do not comply with Python's expected behaviour for It is very very likely that we will release a new implementation of Considering the use of dataframes in the context of intervals, we're currently looking at the possibility to implement our |
portion/portion/dict.py
Line 255 in f87365a
I use IntervalDict to store pandas DataFrame. Because of this line #255 setting element to IntervalDict fails - DataFrame can't be compared to just any other object.
As a workaround I assign tuple (id(dataframe), dataframe), which prevents comparing DataFrame. But that's awkward.
Thanks!
The text was updated successfully, but these errors were encountered: