Repository navigation
Table > value should not work - #828
Conversation
|
That's a generic property of Do you think we should overload all the comparisons to allow raising an exception? |
|
I think it would be safest to disable comparisons, just because the whole |
|
Interestingly this is not an issue in Python 3: Pull request will follow for Python 2 |
|
The attached code disables inequality comparisons for Python 2 (they already are in Python 3). Note that Numpy structured arrays also have this 'feature': but I think it will just lead to confusion. |
There was a problem hiding this comment.
@astrofrog: As you say this is already disabled on Python 3, is there any benefit to only defining these functions on Python 2?
There was a problem hiding this comment.
Good point - how would I go about doing this?
|
@taldcroft @mdboom - does this look better? |
|
Looks fine to me. |
|
I changed my mind on So I think the |
|
…not allowed on tables
… Also disable equality comparison.
|
Looks good to me, and I agree with @taldcroft about |
|
Ok, great! The above commits implement what @taldcroft was suggesting, so I think this is good to merge. However, I'll let @taldcroft check first. |
There was a problem hiding this comment.
Can you add tests for comparing to a numpy structured array on the left and right sides? I assume this will work, but am not 100% sure.
t2._data == t
t2 == t._data
|
@taldcroft - you're not going to believe this, it looks like there's a bug in Working on a workaround... |
|
@astrofrog - why am I not surprised... |
|
Well here's the best I can do. I'm stuck at the very last line in the |
|
Also, |
There was a problem hiding this comment.
By the way this is needed because it won't work if you compare a masked to non-masked structured array.
|
Failures on Python 2? That's what happens when you develop only in Python 3... |
|
It seems like there must be a way to simplify the logic in |
|
Will try and simplify things :) What do you think we should do about the failing test? |
|
About the failed test, I would say to write this case as a known bug and leave it at that for now (and probably put in an astropy issue just so it doesn't get forgotten). |
|
I tried simplifying the logic, but it's much more readable in its present form. @taldcroft - if the tests pass, is this good to merge? |
|
Yes, good to merge. |
…arisons Table > value should not work
…arisons Table > value should not work Conflicts: astropy/table/table.py astropy/table/tests/test_table.py
In Python 2, the following works:
but I think it shouldn't, and indeed doesn't in Python 3:
The Python 2 behavior led me to confusion when I did
t[t > 0.2]by mistake, when I meantt[t['RA'] > 0.2].