当前位置: 首页>>代码示例>>Python>>正文


Python operator.__and__方法代码示例

本文整理汇总了Python中operator.__and__方法的典型用法代码示例。如果您正苦于以下问题:Python operator.__and__方法的具体用法?Python operator.__and__怎么用?Python operator.__and__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在operator的用法示例。


在下文中一共展示了operator.__and__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __and__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def __and__(self, other):                                       
        '''
        Take a bitwise 'AND' of the bit vector on which the method is invoked with
        the argument bit vector.  Return the result as a new bit vector.  If the two
        bit vectors are not of the same size, pad the shorter one with zeros from the
        left.
        '''      
        if self.size < other.size:                                  
            bv1 = self._resize_pad_from_left(other.size - self.size)
            bv2 = other                                             
        elif self.size > other.size:                                
            bv1 = self                                              
            bv2 = other._resize_pad_from_left(self.size - other.size)
        else:                                                        
            bv1 = self                                               
            bv2 = other                                             
        res = BitVector( size = bv1.size )                          
        lpb = map(operator.__and__, bv1.vector, bv2.vector)         
        res.vector = array.array( 'H', lpb )                        
        return res 
开发者ID:francozappa,项目名称:knob,代码行数:22,代码来源:BitVector.py

示例2: shift_right_by_one

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def shift_right_by_one(self):                                    
        '''
        For a one-bit in-place right non-circular shift.  Note that bitvector size
        does not change.  The rightmost bit that moves past the last element of the
        bitvector is discarded and leftmost bit of the returned vector is set to
        zero.
        '''
        size = len(self.vector)                                      
        right_most_bits = list(map( operator.__and__, self.vector, [0x8000]*size ))         
        self.vector = list(map( operator.__and__, self.vector, [~0x8000]*size )) 
        right_most_bits.insert(0, 0)                                 
        right_most_bits.pop()                                        
        self.vector = list(map(operator.__lshift__, self.vector, [1]*size))    
        self.vector = list(map( operator.__or__, self.vector, \
                                   list(map(operator.__rshift__,right_most_bits, [15]*size))))
        self._setbit(0, 0) 
开发者ID:francozappa,项目名称:knob,代码行数:18,代码来源:BitVector.py

示例3: __init__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def __init__(self):
        Backend.__init__(self)
        # self._make_raw_ops(set(expression_operations) - set(expression_set_operations), op_module=BackendVSA)
        self._make_expr_ops(set(expression_set_operations), op_class=self)
        self._make_raw_ops(set(backend_operations_vsa_compliant), op_module=BackendVSA)

        self._op_raw['StridedInterval'] = BackendVSA.CreateStridedInterval
        self._op_raw['ValueSet'] = ValueSet.__init__
        self._op_raw['AbstractLocation'] = AbstractLocation.__init__
        self._op_raw['Reverse'] = BackendVSA.Reverse
        self._op_raw['If'] = self.If
        self._op_expr['BVV'] = self.BVV
        self._op_expr['BoolV'] = self.BoolV
        self._op_expr['BVS'] = self.BVS

        # reduceable
        self._op_raw['__add__'] = self._op_add
        self._op_raw['__sub__'] = self._op_sub
        self._op_raw['__mul__'] = self._op_mul
        self._op_raw['__or__'] = self._op_or
        self._op_raw['__xor__'] = self._op_xor
        self._op_raw['__and__'] = self._op_and
        self._op_raw['__mod__'] = self._op_mod 
开发者ID:angr,项目名称:claripy,代码行数:25,代码来源:backend_vsa.py

示例4: do_finalize

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def do_finalize(self):
        if self.tx_signals:
            for tx_sig in self.tx_signals:
                self.comb += [
                    # TX
                    tx_sig.eq(self.tx),
                ]

        if self.rx_signals:
            self.comb += [
                # RX
                self.rx.eq(reduce(operator.__and__, self.rx_signals))
            ]


# FIXME: Add a test for the shared UART 
开发者ID:timvideos,项目名称:HDMI2USB-litex-firmware,代码行数:18,代码来源:shared_uart.py

示例5: circular_rotate_left_by_one

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def circular_rotate_left_by_one(self):                         
        'For a one-bit in-place left circular shift'
        size = len(self.vector)                                    
        bitstring_leftmost_bit = self.vector[0] & 1                
        left_most_bits = list(map(operator.__and__, self.vector, [1]*size)) 
        left_most_bits.append(left_most_bits[0])                   
        del(left_most_bits[0])                                     
        self.vector = list(map(operator.__rshift__, self.vector, [1]*size)) 
        self.vector = list(map( operator.__or__, self.vector, \
                              list( map(operator.__lshift__, left_most_bits, [15]*size) )))   
                                                                   
        self._setbit(self.size -1, bitstring_leftmost_bit) 
开发者ID:francozappa,项目名称:knob,代码行数:14,代码来源:BitVector.py

示例6: circular_rotate_right_by_one

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def circular_rotate_right_by_one(self):                        
        'For a one-bit in-place right circular shift'
        size = len(self.vector)                                    
        bitstring_rightmost_bit = self[self.size - 1]              
        right_most_bits = list(map( operator.__and__,
                               self.vector, [0x8000]*size ))       
        self.vector = list(map( operator.__and__, self.vector, [~0x8000]*size ))
        right_most_bits.insert(0, bitstring_rightmost_bit)         
        right_most_bits.pop()                                      
        self.vector = list(map(operator.__lshift__, self.vector, [1]*size))
        self.vector = list(map( operator.__or__, self.vector, \
                                list(map(operator.__rshift__, right_most_bits, [15]*size))))  
                                                                   
        self._setbit(0, bitstring_rightmost_bit) 
开发者ID:francozappa,项目名称:knob,代码行数:16,代码来源:BitVector.py

示例7: shift_left_by_one

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def shift_left_by_one(self):                                
        '''
        For a one-bit in-place left non-circular shift.  Note that bitvector size
        does not change.  The leftmost bit that moves past the first element of the
        bitvector is discarded and rightmost bit of the returned vector is set to
        zero.
        '''
        size = len(self.vector)                                 
        left_most_bits = list(map(operator.__and__, self.vector, [1]*size))  
        left_most_bits.append(left_most_bits[0])                    
        del(left_most_bits[0])                                      
        self.vector = list(map(operator.__rshift__, self.vector, [1]*size)) 
        self.vector = list(map( operator.__or__, self.vector, \
                               list(map(operator.__lshift__, left_most_bits, [15]*size))))
        self._setbit(self.size -1, 0) 
开发者ID:francozappa,项目名称:knob,代码行数:17,代码来源:BitVector.py

示例8: do_compute

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def do_compute(self):
        def filter_df(df):
            se = pd.Series(index=df.index)
            for index, row in df.iterrows():

                if row.report_period == 'year':
                    mul = 4
                elif row.report_period == 'season3':
                    mul = 3
                elif row.report_period == 'half_year':
                    mul = 2
                else:
                    mul = 1

                filters = []
                for col in self.col_period_threshold:
                    col_se = eval(f'row.{col}')
                    filters.append(col_se >= mul * self.col_period_threshold[col])
                se[index] = list(accumulate(filters, func=operator.__and__))[-1]

            return se

        if self.col_period_threshold:
            self.factor_df = self.data_df.loc[lambda df: filter_df(df), :]

        self.factor_df = pd.DataFrame(index=self.data_df.index, columns=['count'], data=1)

        self.factor_df = self.factor_df.reset_index(level=1)

        self.factor_df = self.factor_df.groupby(level=0).rolling(window=self.window, on=self.time_field).count()

        self.factor_df = self.factor_df.reset_index(level=0, drop=True)
        self.factor_df = self.factor_df.set_index(self.time_field, append=True)

        self.factor_df = self.factor_df.loc[(slice(None), slice(self.start_timestamp, self.end_timestamp)), :]

        self.logger.info('factor:{},factor_df:\n{}'.format(self.factor_name, self.factor_df))

        self.result_df = self.factor_df.apply(lambda x: x >= self.count)

        self.logger.info('factor:{},result_df:\n{}'.format(self.factor_name, self.result_df)) 
开发者ID:zvtvz,项目名称:zvt,代码行数:43,代码来源:fundamental_factor.py

示例9: run

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def run(self):
        """

        """
        if self.filter_factors:
            musts = []
            for factor in self.filter_factors:
                df = factor.result_df

                if not pd_is_not_null(df):
                    raise Exception('no data for factor:{},{}'.format(factor.factor_name, factor))

                if len(df.columns) > 1:
                    s = df.agg("and", axis="columns")
                    s.name = 'score'
                    musts.append(s.to_frame(name='score'))
                else:
                    df.columns = ['score']
                    musts.append(df)

            self.filter_result = list(accumulate(musts, func=operator.__and__))[-1]

        if self.score_factors:
            scores = []
            for factor in self.score_factors:
                df = factor.result_df
                if not pd_is_not_null(df):
                    raise Exception('no data for factor:{},{}'.format(factor.factor_name, factor))

                if len(df.columns) > 1:
                    s = df.agg("mean", axis="columns")
                    s.name = 'score'
                    scores.append(s.to_frame(name='score'))
                else:
                    df.columns = ['score']
                    scores.append(df)
            self.score_result = list(accumulate(scores, func=operator.__add__))[-1]

        self.generate_targets() 
开发者ID:zvtvz,项目名称:zvt,代码行数:41,代码来源:target_selector.py

示例10: all

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def all(items):
        return reduce(operator.__and__, items)

# --- test if interpreter supports yield keyword --- 
开发者ID:Yukinoshita47,项目名称:Yuki-Chan-The-Auto-Pentest,代码行数:6,代码来源:compatibility.py

示例11: _op_and

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def _op_and(*args):
        return reduce(operator.__and__, args) 
开发者ID:angr,项目名称:claripy,代码行数:4,代码来源:backend_vsa.py

示例12: And

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def And(a, *args):
        return reduce(operator.__and__, args, a) 
开发者ID:angr,项目名称:claripy,代码行数:4,代码来源:backend_vsa.py

示例13: fromParams

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def fromParams(method, num_regs):
    isstatic = method.access & flags.ACC_STATIC
    full_ptypes = method.id.getSpacedParamTypes(isstatic)
    offset = num_regs - len(full_ptypes)

    prims = TreeList(scalars.INVALID, operator.__and__)
    arrs = TreeList(arrays.INVALID, arrays.merge)
    tainted = TreeList(False, operator.__or__)

    for i, desc in enumerate(full_ptypes):
        if desc is not None:
            prims[offset + i] = scalars.fromDesc(desc)
            arrs[offset + i] = arrays.fromDesc(desc)
    return TypeInfo(prims, arrs, tainted) 
开发者ID:HackingLab,项目名称:MobileSF,代码行数:16,代码来源:typeinference.py

示例14: propagateAnd

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def propagateAnd(x, y):
    return propagateBitwise(x, y, operator.__and__, False, True) 
开发者ID:xtiankisutsa,项目名称:MARA_Framework,代码行数:4,代码来源:bitwise_util.py

示例15: all

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __and__ [as 别名]
def all(items):
        return reduce(operator.__and__, items) 
开发者ID:tuwid,项目名称:darkc0de-old-stuff,代码行数:4,代码来源:compatibility.py


注:本文中的operator.__and__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。