Exemple #1
0
    def _compare_value(self, other, op):

        _rowid = Index(0)
        for rowid, val in zip(self._rowid, self._seq):
            try:
                if op(val, other):
                    _rowid.append(rowid)
            except:
                pass
        return self._datamatrix._selectrowid(_rowid)
Exemple #2
0
    def _compare_sequence(self, other, op):

        _rowid = Index(0)
        for rowid, val, ref in zip(self._rowid, self._seq,
                                   self._tosequence(other)):
            try:
                if op(val, ref):
                    _rowid.append(rowid)
            except:
                pass
        return self._datamatrix._selectrowid(_rowid)
Exemple #3
0
    def _compare_type(self, type_, op):

        _rowid = Index(0)
        if op is operator.eq:
            for rowid, val in zip(self._rowid, self._seq):
                if isinstance(val, type_):
                    _rowid.append(rowid)
        elif op is operator.ne:
            for rowid, val in zip(self._rowid, self._seq):
                if not isinstance(val, type_):
                    _rowid.append(rowid)
        else:
            raise TypeError('types can only be compared with == or !=')
        return self._datamatrix._selectrowid(_rowid)
Exemple #4
0
    def _compare_nan(self, other, op):

        _rowid = Index(0)
        if op is operator.eq:
            for rowid, val in zip(self._rowid, self._seq):
                if math.isnan(val):
                    _rowid.append(rowid)
        elif op is operator.ne:
            for rowid, val in zip(self._rowid, self._seq):
                if not math.isnan(val):
                    _rowid.append(rowid)
        else:
            raise TypeError('nans can only be compared with == or !=')
        return self._datamatrix._selectrowid(_rowid)
Exemple #5
0
    def _compare_set(self, other, op):

        if op == operator.__eq__:
            test = lambda val: any(val == v for v in other)
        elif op == operator.__ne__:
            test = lambda val: all(val != v for v in other)
        else:
            raise TypeError('sets can only be compared with == or !=')
        _rowid = Index(0)
        for rowid, val in zip(self._rowid, self._seq):
            try:
                if test(val):
                    _rowid.append(rowid)
            except:
                pass
        return self._datamatrix._selectrowid(_rowid)