mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-17 11:25:55 +08:00
BUG: Fix >= comparison for Cythonized Security object
The >= comparison for the Cythonized Security object was actually doing <=. Fix this and add unit tests for all the Security object rich comparison operators.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
from unittest import TestCase
|
||||
from zipline.assets._securities import Security
|
||||
|
||||
|
||||
class TestSecurityRichCmp(TestCase):
|
||||
def test_lt(self):
|
||||
self.assertTrue(Security(3) < Security(4))
|
||||
self.assertFalse(Security(4) < Security(4))
|
||||
self.assertFalse(Security(5) < Security(4))
|
||||
|
||||
def test_le(self):
|
||||
self.assertTrue(Security(3) <= Security(4))
|
||||
self.assertTrue(Security(4) <= Security(4))
|
||||
self.assertFalse(Security(5) <= Security(4))
|
||||
|
||||
def test_eq(self):
|
||||
self.assertFalse(Security(3) == Security(4))
|
||||
self.assertTrue(Security(4) == Security(4))
|
||||
self.assertFalse(Security(5) == Security(4))
|
||||
|
||||
def test_ge(self):
|
||||
self.assertFalse(Security(3) >= Security(4))
|
||||
self.assertTrue(Security(4) >= Security(4))
|
||||
self.assertTrue(Security(5) >= Security(4))
|
||||
|
||||
def test_gt(self):
|
||||
self.assertFalse(Security(3) > Security(4))
|
||||
self.assertFalse(Security(4) > Security(4))
|
||||
self.assertTrue(Security(5) > Security(4))
|
||||
@@ -120,7 +120,7 @@ cdef class Security:
|
||||
return compared == 1
|
||||
elif op == 5:
|
||||
# >=
|
||||
return compared == -1 or compared == 0
|
||||
return compared == 1 or compared == 0
|
||||
|
||||
def __str__(self):
|
||||
if self.symbol:
|
||||
|
||||
Reference in New Issue
Block a user