mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-07 13:26:02 +03:00
Preserve previous behavior for None
This commit is contained in:
parent
40d7512ce6
commit
8c51fd4d89
|
@ -61,10 +61,10 @@ def test_issue1757():
|
||||||
doc = Doc(Vocab(), words=["a", "b", "c"])
|
doc = Doc(Vocab(), words=["a", "b", "c"])
|
||||||
assert not doc[0] < None
|
assert not doc[0] < None
|
||||||
assert not doc[0] is None
|
assert not doc[0] is None
|
||||||
assert not doc[0] == None
|
assert doc[0] >= None
|
||||||
assert not doc[:2] < None
|
assert not doc[:2] < None
|
||||||
assert not doc[:2] is None
|
assert not doc[:2] is None
|
||||||
assert not doc[:2] == None
|
assert doc[:2] >= None
|
||||||
assert not doc.vocab["a"] is None
|
assert not doc.vocab["a"] is None
|
||||||
assert not doc.vocab["a"] < None
|
assert not doc.vocab["a"] < None
|
||||||
|
|
||||||
|
|
|
@ -128,13 +128,13 @@ cdef class Span:
|
||||||
self._vector_norm = vector_norm
|
self._vector_norm = vector_norm
|
||||||
|
|
||||||
def __richcmp__(self, object other, int op):
|
def __richcmp__(self, object other, int op):
|
||||||
if not isinstance(other, Span):
|
|
||||||
return False
|
|
||||||
if other is None:
|
if other is None:
|
||||||
if op == 0 or op == 1 or op == 2:
|
if op == 0 or op == 1 or op == 2:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
if not isinstance(other, Span):
|
||||||
|
return False
|
||||||
cdef Span other_span = other
|
cdef Span other_span = other
|
||||||
self_tuple = (self.c.start_char, self.c.end_char, self.c.label, self.c.kb_id, self.id, self.doc)
|
self_tuple = (self.c.start_char, self.c.end_char, self.c.label, self.c.kb_id, self.id, self.doc)
|
||||||
other_tuple = (other_span.c.start_char, other_span.c.end_char, other_span.c.label, other_span.c.kb_id, other_span.id, other_span.doc)
|
other_tuple = (other_span.c.start_char, other_span.c.end_char, other_span.c.label, other_span.c.kb_id, other_span.id, other_span.doc)
|
||||||
|
|
|
@ -140,14 +140,14 @@ cdef class Token:
|
||||||
return self.__str__()
|
return self.__str__()
|
||||||
|
|
||||||
def __richcmp__(self, object other, int op):
|
def __richcmp__(self, object other, int op):
|
||||||
if not isinstance(other, Token):
|
|
||||||
return False
|
|
||||||
# http://cython.readthedocs.io/en/latest/src/userguide/special_methods.html
|
# http://cython.readthedocs.io/en/latest/src/userguide/special_methods.html
|
||||||
if other is None:
|
if other is None:
|
||||||
if op in (0, 1, 2):
|
if op in (0, 1, 2):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
if not isinstance(other, Token):
|
||||||
|
return False
|
||||||
cdef Token other_token = other
|
cdef Token other_token = other
|
||||||
cdef Doc my_doc = self.doc
|
cdef Doc my_doc = self.doc
|
||||||
cdef Doc other_doc = other_token.doc
|
cdef Doc other_doc = other_token.doc
|
||||||
|
|
Loading…
Reference in New Issue
Block a user