Python operator.ior() Examples
The following are 26
code examples of operator.ior().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
operator
, or try the search function
.
Example #1
Source File: test_intbv.py From myhdl with GNU Lesser General Public License v2.1 | 5 votes |
def testIOr(self): self.augmentedAssignCheck(operator.ior)
Example #2
Source File: bitstring.py From plugin.video.vvvvid with GNU General Public License v2.0 | 5 votes |
def _ior(self, bs): return self._inplace_logical_helper(bs, operator.ior)
Example #3
Source File: bitstring.py From bitstring with MIT License | 5 votes |
def _ior(self, bs): return self._inplace_logical_helper(bs, operator.ior)
Example #4
Source File: objectproxy.py From CrossHair with MIT License | 5 votes |
def __ior__(self, other): return operator.ior(self._wrapped(), other)
Example #5
Source File: distributed.py From sdc with BSD 2-Clause "Simplified" License | 5 votes |
def _get_reduce_op(self, reduce_nodes): require(len(reduce_nodes) == 2) require(isinstance(reduce_nodes[0], ir.Assign)) require(isinstance(reduce_nodes[1], ir.Assign)) require(isinstance(reduce_nodes[0].value, ir.Expr)) require(isinstance(reduce_nodes[1].value, ir.Var)) rhs = reduce_nodes[0].value if rhs.op == 'inplace_binop': if rhs.fn in ('+=', operator.iadd): return Reduce_Type.Sum if rhs.fn in ('|=', operator.ior): return Reduce_Type.Or if rhs.fn in ('*=', operator.imul): return Reduce_Type.Prod if rhs.op == 'call': func = find_callname(self.state.func_ir, rhs, self.state.typemap) if func == ('min', 'builtins'): if isinstance(self.state.typemap[rhs.args[0].name], numba.core.typing.builtins.IndexValueType): return Reduce_Type.Argmin return Reduce_Type.Min if func == ('max', 'builtins'): if isinstance(self.state.typemap[rhs.args[0].name], numba.core.typing.builtins.IndexValueType): return Reduce_Type.Argmax return Reduce_Type.Max raise GuardException # pragma: no cover
Example #6
Source File: expr.py From owasp-pysec with Apache License 2.0 | 5 votes |
def __ior__(self, other): return Expression((self, other), operator.ior)
Example #7
Source File: tests_extensions.py From django-ca with GNU General Public License v3.0 | 5 votes |
def test_update_operator(self): # test |= operator self.assertSingleValueOperator(lambda s, o: operator.ior(s, o)) self.assertMultipleValuesOperator( lambda s, o: operator.ior(s, functools.reduce(operator.ior, [t.copy() for t in o])))
Example #8
Source File: light.py From homeassistant-zigate with MIT License | 5 votes |
def __init__(self, hass, device, endpoint): """Initialize the light.""" self._device = device self._endpoint = endpoint self._is_on = False self._brightness = 0 a = self._device.get_attribute(endpoint, 6, 0) if a: self._is_on = a.get('value', False) ieee = device.ieee or device.addr # compatibility entity_id = 'zigate_{}_{}'.format(ieee, endpoint) self.entity_id = ENTITY_ID_FORMAT.format(entity_id) import zigate supported_features = set() supported_features.add(SUPPORT_TRANSITION) for action_type in device.available_actions(endpoint)[endpoint]: if action_type == zigate.ACTIONS_LEVEL: supported_features.add(SUPPORT_BRIGHTNESS) elif action_type == zigate.ACTIONS_COLOR: supported_features.add(SUPPORT_COLOR) elif action_type == zigate.ACTIONS_TEMPERATURE: supported_features.add(SUPPORT_COLOR_TEMP) elif action_type == zigate.ACTIONS_HUE: supported_features.add(SUPPORT_HUE_COLOR) self._supported_features = reduce(ior, supported_features) hass.bus.listen('zigate.attribute_updated', self._handle_event)
Example #9
Source File: test_documents.py From torpy with Apache License 2.0 | 5 votes |
def object_hook(obj): _isoformat = obj.get('_isoformat') if _isoformat is not None: return datetime.datetime.fromisoformat(_isoformat) _bytes = obj.get('_bytes') if _bytes is not None: return bytes.fromhex(_bytes) _enum = obj.get('_enum') if _enum is not None: cls, flags = _enum.split('.') flags = map(lambda i: RouterFlags[i], flags.split('|')) return reduce(ior, flags) return obj
Example #10
Source File: test_ndarray_elementwise_op.py From cupy with MIT License | 5 votes |
def test_broadcasted_ior(self): self.check_array_broadcasted_op(operator.ior)
Example #11
Source File: test_ndarray_elementwise_op.py From cupy with MIT License | 5 votes |
def test_ior_array(self): self.check_array_array_op(operator.ior)
Example #12
Source File: regex.py From clist with Apache License 2.0 | 5 votes |
def get_iregex_filter(expression, *fields, mapping=None, logger=None, values=None): ret = Q() for dis in expression.split(' || '): cond = Q() for con in dis.split(' && '): r = con.strip() fs = fields suff = '__iregex' if ':' in r and mapping: k, v = r.split(':', 1) if k in mapping: mapped = mapping[k] try: fs = mapped['fields'] r = mapped['func'](v) if 'func' in mapped else v suff = mapped.get('suff', '') if callable(suff): suff = suff(r) except Exception as e: if logger: logger.error(f'Field "{k}" has error: {e}') continue if values is not None: values.setdefault(k, []).append(r) if isinstance(r, str): r = verify_regex(r, logger=logger) cond &= functools.reduce(operator.ior, (Q(**{f'{field}{suff}': r}) for field in fs)) ret |= cond return ret
Example #13
Source File: fabric_test.py From fabric-p4test with Apache License 2.0 | 5 votes |
def get_ins_mask(self, instructions): return reduce(ior, instructions)
Example #14
Source File: client.py From mars with Apache License 2.0 | 5 votes |
def unpin_data_keys(self, session_id, data_keys, token, devices=None): if not devices: devices = functools.reduce( operator.ior, self._manager_ref.get_data_locations(session_id, data_keys), set()) else: devices = self._normalize_devices(devices) for dev in devices: handler = self.get_storage_handler(dev) if not getattr(handler, '_spillable', False): continue handler.unpin_data_keys(session_id, data_keys, token)
Example #15
Source File: client.py From mars with Apache License 2.0 | 5 votes |
def pin_data_keys(self, session_id, data_keys, token, devices=None): if not devices: devices = functools.reduce( operator.ior, self._manager_ref.get_data_locations(session_id, data_keys), set()) else: devices = self._normalize_devices(devices) pinned = set() for dev in devices: handler = self.get_storage_handler(dev) if not getattr(handler, '_spillable', False): continue keys = handler.pin_data_keys(session_id, data_keys, token) pinned.update(keys) return list(pinned)
Example #16
Source File: client.py From mars with Apache License 2.0 | 5 votes |
def delete(self, session_id, data_keys, devices=None, _tell=False): if not devices: devices = functools.reduce( operator.ior, self._manager_ref.get_data_locations(session_id, data_keys), set()) else: devices = self._normalize_devices(devices) devices = self._normalize_devices(devices) for dev_type in devices: handler = self.get_storage_handler(dev_type) handler.delete(session_id, data_keys, _tell=_tell)
Example #17
Source File: test_Signal.py From myhdl with GNU Lesser General Public License v2.1 | 5 votes |
def testIOr(self): self.augmentedAssignCheck(operator.ior)
Example #18
Source File: qt_viewer_dock_widget.py From napari with BSD 3-Clause "New" or "Revised" License | 4 votes |
def __init__( self, qt_viewer, widget: QWidget, *, name: str = '', area: str = 'bottom', allowed_areas: Optional[List[str]] = None, shortcut=None, ): self.qt_viewer = qt_viewer super().__init__(name) self.name = name areas = { 'left': Qt.LeftDockWidgetArea, 'right': Qt.RightDockWidgetArea, 'top': Qt.TopDockWidgetArea, 'bottom': Qt.BottomDockWidgetArea, } if area not in areas: raise ValueError(f'area argument must be in {list(areas.keys())}') self.area = area self.qt_area = areas[area] self.shortcut = shortcut if allowed_areas: if not isinstance(allowed_areas, (list, tuple)): raise TypeError('`allowed_areas` must be a list or tuple') if not all(area in areas for area in allowed_areas): raise ValueError( f'all allowed_areas argument must be in {list(areas.keys())}' ) allowed_areas = reduce(ior, [areas[a] for a in allowed_areas]) else: allowed_areas = Qt.AllDockWidgetAreas self.setAllowedAreas(allowed_areas) self.setMinimumHeight(50) self.setMinimumWidth(50) self.setObjectName(name) self.widget = combine_widgets( widget, vertical=area in {'left', 'right'} ) self._features = self.features() self.dockLocationChanged.connect(self._set_title_orientation) # custom title bar self.title = QtCustomTitleBar(self) self.setTitleBarWidget(self.title) self.visibilityChanged.connect(self._on_visibility_changed)
Example #19
Source File: test_operator.py From oss-ftp with MIT License | 4 votes |
def test_inplace(self): class C(object): def __iadd__ (self, other): return "iadd" def __iand__ (self, other): return "iand" def __idiv__ (self, other): return "idiv" def __ifloordiv__(self, other): return "ifloordiv" def __ilshift__ (self, other): return "ilshift" def __imod__ (self, other): return "imod" def __imul__ (self, other): return "imul" def __ior__ (self, other): return "ior" def __ipow__ (self, other): return "ipow" def __irshift__ (self, other): return "irshift" def __isub__ (self, other): return "isub" def __itruediv__ (self, other): return "itruediv" def __ixor__ (self, other): return "ixor" def __getitem__(self, other): return 5 # so that C is a sequence c = C() self.assertEqual(operator.iadd (c, 5), "iadd") self.assertEqual(operator.iand (c, 5), "iand") self.assertEqual(operator.idiv (c, 5), "idiv") self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv") self.assertEqual(operator.ilshift (c, 5), "ilshift") self.assertEqual(operator.imod (c, 5), "imod") self.assertEqual(operator.imul (c, 5), "imul") self.assertEqual(operator.ior (c, 5), "ior") self.assertEqual(operator.ipow (c, 5), "ipow") self.assertEqual(operator.irshift (c, 5), "irshift") self.assertEqual(operator.isub (c, 5), "isub") self.assertEqual(operator.itruediv (c, 5), "itruediv") self.assertEqual(operator.ixor (c, 5), "ixor") self.assertEqual(operator.iconcat (c, c), "iadd") self.assertEqual(operator.irepeat (c, 5), "imul") self.assertEqual(operator.__iadd__ (c, 5), "iadd") self.assertEqual(operator.__iand__ (c, 5), "iand") self.assertEqual(operator.__idiv__ (c, 5), "idiv") self.assertEqual(operator.__ifloordiv__(c, 5), "ifloordiv") self.assertEqual(operator.__ilshift__ (c, 5), "ilshift") self.assertEqual(operator.__imod__ (c, 5), "imod") self.assertEqual(operator.__imul__ (c, 5), "imul") self.assertEqual(operator.__ior__ (c, 5), "ior") self.assertEqual(operator.__ipow__ (c, 5), "ipow") self.assertEqual(operator.__irshift__ (c, 5), "irshift") self.assertEqual(operator.__isub__ (c, 5), "isub") self.assertEqual(operator.__itruediv__ (c, 5), "itruediv") self.assertEqual(operator.__ixor__ (c, 5), "ixor") self.assertEqual(operator.__iconcat__ (c, c), "iadd") self.assertEqual(operator.__irepeat__ (c, 5), "imul")
Example #20
Source File: test_operator.py From BinderFilter with MIT License | 4 votes |
def test_inplace(self): class C(object): def __iadd__ (self, other): return "iadd" def __iand__ (self, other): return "iand" def __idiv__ (self, other): return "idiv" def __ifloordiv__(self, other): return "ifloordiv" def __ilshift__ (self, other): return "ilshift" def __imod__ (self, other): return "imod" def __imul__ (self, other): return "imul" def __ior__ (self, other): return "ior" def __ipow__ (self, other): return "ipow" def __irshift__ (self, other): return "irshift" def __isub__ (self, other): return "isub" def __itruediv__ (self, other): return "itruediv" def __ixor__ (self, other): return "ixor" def __getitem__(self, other): return 5 # so that C is a sequence c = C() self.assertEqual(operator.iadd (c, 5), "iadd") self.assertEqual(operator.iand (c, 5), "iand") self.assertEqual(operator.idiv (c, 5), "idiv") self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv") self.assertEqual(operator.ilshift (c, 5), "ilshift") self.assertEqual(operator.imod (c, 5), "imod") self.assertEqual(operator.imul (c, 5), "imul") self.assertEqual(operator.ior (c, 5), "ior") self.assertEqual(operator.ipow (c, 5), "ipow") self.assertEqual(operator.irshift (c, 5), "irshift") self.assertEqual(operator.isub (c, 5), "isub") self.assertEqual(operator.itruediv (c, 5), "itruediv") self.assertEqual(operator.ixor (c, 5), "ixor") self.assertEqual(operator.iconcat (c, c), "iadd") self.assertEqual(operator.irepeat (c, 5), "imul") self.assertEqual(operator.__iadd__ (c, 5), "iadd") self.assertEqual(operator.__iand__ (c, 5), "iand") self.assertEqual(operator.__idiv__ (c, 5), "idiv") self.assertEqual(operator.__ifloordiv__(c, 5), "ifloordiv") self.assertEqual(operator.__ilshift__ (c, 5), "ilshift") self.assertEqual(operator.__imod__ (c, 5), "imod") self.assertEqual(operator.__imul__ (c, 5), "imul") self.assertEqual(operator.__ior__ (c, 5), "ior") self.assertEqual(operator.__ipow__ (c, 5), "ipow") self.assertEqual(operator.__irshift__ (c, 5), "irshift") self.assertEqual(operator.__isub__ (c, 5), "isub") self.assertEqual(operator.__itruediv__ (c, 5), "itruediv") self.assertEqual(operator.__ixor__ (c, 5), "ixor") self.assertEqual(operator.__iconcat__ (c, c), "iadd") self.assertEqual(operator.__irepeat__ (c, 5), "imul")
Example #21
Source File: test_operator.py From gcblue with BSD 3-Clause "New" or "Revised" License | 4 votes |
def test_inplace(self): class C(object): def __iadd__ (self, other): return "iadd" def __iand__ (self, other): return "iand" def __idiv__ (self, other): return "idiv" def __ifloordiv__(self, other): return "ifloordiv" def __ilshift__ (self, other): return "ilshift" def __imod__ (self, other): return "imod" def __imul__ (self, other): return "imul" def __ior__ (self, other): return "ior" def __ipow__ (self, other): return "ipow" def __irshift__ (self, other): return "irshift" def __isub__ (self, other): return "isub" def __itruediv__ (self, other): return "itruediv" def __ixor__ (self, other): return "ixor" def __getitem__(self, other): return 5 # so that C is a sequence c = C() self.assertEqual(operator.iadd (c, 5), "iadd") self.assertEqual(operator.iand (c, 5), "iand") self.assertEqual(operator.idiv (c, 5), "idiv") self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv") self.assertEqual(operator.ilshift (c, 5), "ilshift") self.assertEqual(operator.imod (c, 5), "imod") self.assertEqual(operator.imul (c, 5), "imul") self.assertEqual(operator.ior (c, 5), "ior") self.assertEqual(operator.ipow (c, 5), "ipow") self.assertEqual(operator.irshift (c, 5), "irshift") self.assertEqual(operator.isub (c, 5), "isub") self.assertEqual(operator.itruediv (c, 5), "itruediv") self.assertEqual(operator.ixor (c, 5), "ixor") self.assertEqual(operator.iconcat (c, c), "iadd") self.assertEqual(operator.irepeat (c, 5), "imul") self.assertEqual(operator.__iadd__ (c, 5), "iadd") self.assertEqual(operator.__iand__ (c, 5), "iand") self.assertEqual(operator.__idiv__ (c, 5), "idiv") self.assertEqual(operator.__ifloordiv__(c, 5), "ifloordiv") self.assertEqual(operator.__ilshift__ (c, 5), "ilshift") self.assertEqual(operator.__imod__ (c, 5), "imod") self.assertEqual(operator.__imul__ (c, 5), "imul") self.assertEqual(operator.__ior__ (c, 5), "ior") self.assertEqual(operator.__ipow__ (c, 5), "ipow") self.assertEqual(operator.__irshift__ (c, 5), "irshift") self.assertEqual(operator.__isub__ (c, 5), "isub") self.assertEqual(operator.__itruediv__ (c, 5), "itruediv") self.assertEqual(operator.__ixor__ (c, 5), "ixor") self.assertEqual(operator.__iconcat__ (c, c), "iadd") self.assertEqual(operator.__irepeat__ (c, 5), "imul")
Example #22
Source File: test_operator.py From medicare-demo with Apache License 2.0 | 4 votes |
def test_inplace(self): class C(object): def __iadd__ (self, other): return "iadd" def __iand__ (self, other): return "iand" def __idiv__ (self, other): return "idiv" def __ifloordiv__(self, other): return "ifloordiv" def __ilshift__ (self, other): return "ilshift" def __imod__ (self, other): return "imod" def __imul__ (self, other): return "imul" def __ior__ (self, other): return "ior" def __ipow__ (self, other): return "ipow" def __irshift__ (self, other): return "irshift" def __isub__ (self, other): return "isub" def __itruediv__ (self, other): return "itruediv" def __ixor__ (self, other): return "ixor" def __getitem__(self, other): return 5 # so that C is a sequence c = C() self.assertEqual(operator.iadd (c, 5), "iadd") self.assertEqual(operator.iand (c, 5), "iand") self.assertEqual(operator.idiv (c, 5), "idiv") self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv") self.assertEqual(operator.ilshift (c, 5), "ilshift") self.assertEqual(operator.imod (c, 5), "imod") self.assertEqual(operator.imul (c, 5), "imul") self.assertEqual(operator.ior (c, 5), "ior") self.assertEqual(operator.ipow (c, 5), "ipow") self.assertEqual(operator.irshift (c, 5), "irshift") self.assertEqual(operator.isub (c, 5), "isub") self.assertEqual(operator.itruediv (c, 5), "itruediv") self.assertEqual(operator.ixor (c, 5), "ixor") self.assertEqual(operator.iconcat (c, c), "iadd") self.assertEqual(operator.irepeat (c, 5), "imul") self.assertEqual(operator.__iadd__ (c, 5), "iadd") self.assertEqual(operator.__iand__ (c, 5), "iand") self.assertEqual(operator.__idiv__ (c, 5), "idiv") self.assertEqual(operator.__ifloordiv__(c, 5), "ifloordiv") self.assertEqual(operator.__ilshift__ (c, 5), "ilshift") self.assertEqual(operator.__imod__ (c, 5), "imod") self.assertEqual(operator.__imul__ (c, 5), "imul") self.assertEqual(operator.__ior__ (c, 5), "ior") self.assertEqual(operator.__ipow__ (c, 5), "ipow") self.assertEqual(operator.__irshift__ (c, 5), "irshift") self.assertEqual(operator.__isub__ (c, 5), "isub") self.assertEqual(operator.__itruediv__ (c, 5), "itruediv") self.assertEqual(operator.__ixor__ (c, 5), "ixor") self.assertEqual(operator.__iconcat__ (c, c), "iadd") self.assertEqual(operator.__irepeat__ (c, 5), "imul")
Example #23
Source File: OWGOBrowser.py From orange3-bioinformatics with GNU General Public License v3.0 | 4 votes |
def commit(self): if self.input_data is None or self.originalGraph is None or self.annotations is None: return if self.__state & State.Stale: return terms = set(self.selectedTerms) genes = reduce(operator.ior, (set(self.graph[term][0]) for term in terms), set()) evidences = [] for etype in go.evidence_types_ordered: if self.use_evidence_type[etype]: evidences.append(etype) all_terms = self.annotations.get_annotated_terms( genes, direct_annotation_only=self.selection_direct_annotation, evidence_codes=evidences ) if self.selection_disjoint > 0: count = defaultdict(int) for term in self.selectedTerms: for g in all_terms.get(term, []): count[g] += 1 ccount = 1 if self.selection_disjoint == 1 else len(self.selectedTerms) selected_genes = [gene for gene, c in count.items() if c == ccount and gene in genes] else: selected_genes = reduce(operator.ior, (set(all_terms.get(term, [])) for term in self.selectedTerms), set()) if self.use_attr_names: selected = [ column for column in self.input_data.domain.attributes if self.gene_id_attribute in column.attributes and str(column.attributes[self.gene_id_attribute]) in set(selected_genes) ] domain = Orange.data.Domain(selected, self.input_data.domain.class_vars, self.input_data.domain.metas) new_data = self.input_data.from_table(domain, self.input_data) self.send("Data on Selected Genes", new_data) else: selected_rows = [] for row_index, row in enumerate(self.input_data): gene_in_row = str(row[self.gene_id_column]) if gene_in_row in self.input_genes and gene_in_row in selected_genes: selected_rows.append(row_index) if selected_rows: selected = self.input_data[selected_rows] else: selected = None self.send("Data on Selected Genes", selected)
Example #24
Source File: test_operator.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 4 votes |
def test_inplace(self): class C(object): def __iadd__ (self, other): return "iadd" def __iand__ (self, other): return "iand" def __idiv__ (self, other): return "idiv" def __ifloordiv__(self, other): return "ifloordiv" def __ilshift__ (self, other): return "ilshift" def __imod__ (self, other): return "imod" def __imul__ (self, other): return "imul" def __ior__ (self, other): return "ior" def __ipow__ (self, other): return "ipow" def __irshift__ (self, other): return "irshift" def __isub__ (self, other): return "isub" def __itruediv__ (self, other): return "itruediv" def __ixor__ (self, other): return "ixor" def __getitem__(self, other): return 5 # so that C is a sequence c = C() self.assertEqual(operator.iadd (c, 5), "iadd") self.assertEqual(operator.iand (c, 5), "iand") self.assertEqual(operator.idiv (c, 5), "idiv") self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv") self.assertEqual(operator.ilshift (c, 5), "ilshift") self.assertEqual(operator.imod (c, 5), "imod") self.assertEqual(operator.imul (c, 5), "imul") self.assertEqual(operator.ior (c, 5), "ior") self.assertEqual(operator.ipow (c, 5), "ipow") self.assertEqual(operator.irshift (c, 5), "irshift") self.assertEqual(operator.isub (c, 5), "isub") self.assertEqual(operator.itruediv (c, 5), "itruediv") self.assertEqual(operator.ixor (c, 5), "ixor") self.assertEqual(operator.iconcat (c, c), "iadd") self.assertEqual(operator.irepeat (c, 5), "imul") self.assertEqual(operator.__iadd__ (c, 5), "iadd") self.assertEqual(operator.__iand__ (c, 5), "iand") self.assertEqual(operator.__idiv__ (c, 5), "idiv") self.assertEqual(operator.__ifloordiv__(c, 5), "ifloordiv") self.assertEqual(operator.__ilshift__ (c, 5), "ilshift") self.assertEqual(operator.__imod__ (c, 5), "imod") self.assertEqual(operator.__imul__ (c, 5), "imul") self.assertEqual(operator.__ior__ (c, 5), "ior") self.assertEqual(operator.__ipow__ (c, 5), "ipow") self.assertEqual(operator.__irshift__ (c, 5), "irshift") self.assertEqual(operator.__isub__ (c, 5), "isub") self.assertEqual(operator.__itruediv__ (c, 5), "itruediv") self.assertEqual(operator.__ixor__ (c, 5), "ixor") self.assertEqual(operator.__iconcat__ (c, c), "iadd") self.assertEqual(operator.__irepeat__ (c, 5), "imul")
Example #25
Source File: test_operator.py From CTFCrackTools with GNU General Public License v3.0 | 4 votes |
def test_inplace(self): class C(object): def __iadd__ (self, other): return "iadd" def __iand__ (self, other): return "iand" def __idiv__ (self, other): return "idiv" def __ifloordiv__(self, other): return "ifloordiv" def __ilshift__ (self, other): return "ilshift" def __imod__ (self, other): return "imod" def __imul__ (self, other): return "imul" def __ior__ (self, other): return "ior" def __ipow__ (self, other): return "ipow" def __irshift__ (self, other): return "irshift" def __isub__ (self, other): return "isub" def __itruediv__ (self, other): return "itruediv" def __ixor__ (self, other): return "ixor" def __getitem__(self, other): return 5 # so that C is a sequence c = C() self.assertEqual(operator.iadd (c, 5), "iadd") self.assertEqual(operator.iand (c, 5), "iand") self.assertEqual(operator.idiv (c, 5), "idiv") self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv") self.assertEqual(operator.ilshift (c, 5), "ilshift") self.assertEqual(operator.imod (c, 5), "imod") self.assertEqual(operator.imul (c, 5), "imul") self.assertEqual(operator.ior (c, 5), "ior") self.assertEqual(operator.ipow (c, 5), "ipow") self.assertEqual(operator.irshift (c, 5), "irshift") self.assertEqual(operator.isub (c, 5), "isub") self.assertEqual(operator.itruediv (c, 5), "itruediv") self.assertEqual(operator.ixor (c, 5), "ixor") self.assertEqual(operator.iconcat (c, c), "iadd") self.assertEqual(operator.irepeat (c, 5), "imul") self.assertEqual(operator.__iadd__ (c, 5), "iadd") self.assertEqual(operator.__iand__ (c, 5), "iand") self.assertEqual(operator.__idiv__ (c, 5), "idiv") self.assertEqual(operator.__ifloordiv__(c, 5), "ifloordiv") self.assertEqual(operator.__ilshift__ (c, 5), "ilshift") self.assertEqual(operator.__imod__ (c, 5), "imod") self.assertEqual(operator.__imul__ (c, 5), "imul") self.assertEqual(operator.__ior__ (c, 5), "ior") self.assertEqual(operator.__ipow__ (c, 5), "ipow") self.assertEqual(operator.__irshift__ (c, 5), "irshift") self.assertEqual(operator.__isub__ (c, 5), "isub") self.assertEqual(operator.__itruediv__ (c, 5), "itruediv") self.assertEqual(operator.__ixor__ (c, 5), "ixor") self.assertEqual(operator.__iconcat__ (c, c), "iadd") self.assertEqual(operator.__irepeat__ (c, 5), "imul")
Example #26
Source File: test_operator.py From ironpython2 with Apache License 2.0 | 3 votes |
def test_inplace(self): class C(object): def __iadd__ (self, other): return "iadd" def __iand__ (self, other): return "iand" def __idiv__ (self, other): return "idiv" def __ifloordiv__(self, other): return "ifloordiv" def __ilshift__ (self, other): return "ilshift" def __imod__ (self, other): return "imod" def __imul__ (self, other): return "imul" def __ior__ (self, other): return "ior" def __ipow__ (self, other): return "ipow" def __irshift__ (self, other): return "irshift" def __isub__ (self, other): return "isub" def __itruediv__ (self, other): return "itruediv" def __ixor__ (self, other): return "ixor" def __getitem__(self, other): return 5 # so that C is a sequence c = C() self.assertEqual(operator.iadd (c, 5), "iadd") self.assertEqual(operator.iand (c, 5), "iand") self.assertEqual(operator.idiv (c, 5), "idiv") self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv") self.assertEqual(operator.ilshift (c, 5), "ilshift") self.assertEqual(operator.imod (c, 5), "imod") self.assertEqual(operator.imul (c, 5), "imul") self.assertEqual(operator.ior (c, 5), "ior") self.assertEqual(operator.ipow (c, 5), "ipow") self.assertEqual(operator.irshift (c, 5), "irshift") self.assertEqual(operator.isub (c, 5), "isub") self.assertEqual(operator.itruediv (c, 5), "itruediv") self.assertEqual(operator.ixor (c, 5), "ixor") self.assertEqual(operator.iconcat (c, c), "iadd") self.assertEqual(operator.irepeat (c, 5), "imul") self.assertEqual(operator.__iadd__ (c, 5), "iadd") self.assertEqual(operator.__iand__ (c, 5), "iand") self.assertEqual(operator.__idiv__ (c, 5), "idiv") self.assertEqual(operator.__ifloordiv__(c, 5), "ifloordiv") self.assertEqual(operator.__ilshift__ (c, 5), "ilshift") self.assertEqual(operator.__imod__ (c, 5), "imod") self.assertEqual(operator.__imul__ (c, 5), "imul") self.assertEqual(operator.__ior__ (c, 5), "ior") self.assertEqual(operator.__ipow__ (c, 5), "ipow") self.assertEqual(operator.__irshift__ (c, 5), "irshift") self.assertEqual(operator.__isub__ (c, 5), "isub") self.assertEqual(operator.__itruediv__ (c, 5), "itruediv") self.assertEqual(operator.__ixor__ (c, 5), "ixor") self.assertEqual(operator.__iconcat__ (c, c), "iadd") self.assertEqual(operator.__irepeat__ (c, 5), "imul")