Fix rich comparisons for datetime objects#53
Conversation
…ch comparison to work
|
The python 2.7 Travis tests are failing. We can't merge until this is fixed. |
|
This was alluded to in the description and I am still trying to work out the best way of dealing with it. At present the only way I have is to add This solves the original problem for Python 3 and allows the code to behave as before for Python 2, but in Python 2 code the original problem will still exist. As far as I can tell there is no way in Python 2 to separate objects that should be comparable to cftime.datatime objects and those that shouldn't be without being explicit (e.g. the way datetime objects are handled), or prescribing a structure on those objects that want to be comparable. Would this be acceptable? |
…ixes the problem for Python3 but leaves the problem for Python2.
|
I'm OK with this. @jhamman? |
|
I'm also fine with this but would appreciate a test to validate the expected behavior. |
|
I can merge this as soon as a test is added |
|
I'm going to go ahead and merge this, without a test for now. |
As identified in #11, rich comparisons for
cftime.datetimeobjects with other unknown objects do not work as cftime raises aTypeErrorinstead of returningNotImplemented. This pull request is to fix this.While this works in Python 3, it should be noted that Python 2 is more problematic. The unit test
not_comparable_4intest_richcmpwill fail ascftime.datetimeobjects are treated as comparable with integer zero and so theTypeErroris not raised when it is expected.