Python operator.isNumberType() Examples
The following are 23
code examples of operator.isNumberType().
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_bool.py From ironpython2 with Apache License 2.0 | 7 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #2
Source File: test_bool.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #3
Source File: test_bool.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #4
Source File: Image.py From keras-lambda with MIT License | 5 votes |
def _getscaleoffset(expr): stub = ["stub"] data = expr(_E(stub)).data try: (a, b, c) = data # simplified syntax if (a is stub and b == "__mul__" and isNumberType(c)): return c, 0.0 if (a is stub and b == "__add__" and isNumberType(c)): return 1.0, c except TypeError: pass try: ((a, b, c), d, e) = data # full syntax if (a is stub and b == "__mul__" and isNumberType(c) and d == "__add__" and isNumberType(e)): return c, e except TypeError: pass raise ValueError("illegal expression") # -------------------------------------------------------------------- # Implementation wrapper ## # This class represents an image object. To create Image objects, use # the appropriate factory functions. There's hardly ever any reason # to call the Image constructor directly. # # @see #open # @see #new # @see #fromstring
Example #5
Source File: test_operator.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_isNumberType(self): self.assertRaises(TypeError, operator.isNumberType) self.assertTrue(operator.isNumberType(8)) self.assertTrue(operator.isNumberType(8j)) self.assertTrue(operator.isNumberType(8L)) self.assertTrue(operator.isNumberType(8.3)) self.assertFalse(operator.isNumberType(dir()))
Example #6
Source File: test_operator.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_isNumberType(self): self.failUnlessRaises(TypeError, operator.isNumberType) self.failUnless(operator.isNumberType(8)) self.failUnless(operator.isNumberType(8j)) self.failUnless(operator.isNumberType(8L)) self.failUnless(operator.isNumberType(8.3)) self.failIf(operator.isNumberType(dir()))
Example #7
Source File: test_operator_jy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_isNumberType(self): for obj, isNumberType, _, _ in self.tests: self.assert_istype(operator.isNumberType, obj, isNumberType)
Example #8
Source File: test_operator_jy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def __float__(self): return 1.0 # obj, isNumberType, isMappingType, isSequenceType
Example #9
Source File: test_operator.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_isNumberType(self): self.failUnlessRaises(TypeError, operator.isNumberType) self.failUnless(operator.isNumberType(8)) self.failUnless(operator.isNumberType(8j)) self.failUnless(operator.isNumberType(8L)) self.failUnless(operator.isNumberType(8.3)) self.failIf(operator.isNumberType(dir()))
Example #10
Source File: test_operator_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_isNumberType(self): for obj, isNumberType, _, _ in self.tests: self.assert_istype(operator.isNumberType, obj, isNumberType)
Example #11
Source File: test_operator_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def __float__(self): return 1.0 # obj, isNumberType, isMappingType, isSequenceType
Example #12
Source File: Image.py From CNCGToolKit with MIT License | 5 votes |
def _getscaleoffset(expr): stub = ["stub"] data = expr(_E(stub)).data try: (a, b, c) = data # simplified syntax if (a is stub and b == "__mul__" and isNumberType(c)): return c, 0.0 if (a is stub and b == "__add__" and isNumberType(c)): return 1.0, c except TypeError: pass try: ((a, b, c), d, e) = data # full syntax if (a is stub and b == "__mul__" and isNumberType(c) and d == "__add__" and isNumberType(e)): return c, e except TypeError: pass raise ValueError("illegal expression") # -------------------------------------------------------------------- # Implementation wrapper ## # This class represents an image object. To create Image objects, use # the appropriate factory functions. There's hardly ever any reason # to call the Image constructor directly. # # @see #open # @see #new # @see #fromstring
Example #13
Source File: test_bool.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #14
Source File: test_operator.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_isNumberType(self): self.failUnlessRaises(TypeError, operator.isNumberType) self.failUnless(operator.isNumberType(8)) self.failUnless(operator.isNumberType(8j)) self.failUnless(operator.isNumberType(8L)) self.failUnless(operator.isNumberType(8.3)) self.failIf(operator.isNumberType(dir()))
Example #15
Source File: test_operator_jy.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_isNumberType(self): for obj, isNumberType, _, _ in self.tests: self.assert_istype(operator.isNumberType, obj, isNumberType)
Example #16
Source File: test_operator_jy.py From medicare-demo with Apache License 2.0 | 5 votes |
def __float__(self): return 1.0 # obj, isNumberType, isMappingType, isSequenceType
Example #17
Source File: test_bool.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #18
Source File: test_operator.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_isNumberType(self): self.assertRaises(TypeError, operator.isNumberType) self.assertTrue(operator.isNumberType(8)) self.assertTrue(operator.isNumberType(8j)) self.assertTrue(operator.isNumberType(8L)) self.assertTrue(operator.isNumberType(8.3)) self.assertFalse(operator.isNumberType(dir()))
Example #19
Source File: Image.py From mxnet-lambda with Apache License 2.0 | 5 votes |
def _getscaleoffset(expr): stub = ["stub"] data = expr(_E(stub)).data try: (a, b, c) = data # simplified syntax if (a is stub and b == "__mul__" and isNumberType(c)): return c, 0.0 if (a is stub and b == "__add__" and isNumberType(c)): return 1.0, c except TypeError: pass try: ((a, b, c), d, e) = data # full syntax if (a is stub and b == "__mul__" and isNumberType(c) and d == "__add__" and isNumberType(e)): return c, e except TypeError: pass raise ValueError("illegal expression") # -------------------------------------------------------------------- # Implementation wrapper ## # This class represents an image object. To create Image objects, use # the appropriate factory functions. There's hardly ever any reason # to call the Image constructor directly. # # @see #open # @see #new # @see #fromstring
Example #20
Source File: test_bool.py From oss-ftp with MIT License | 5 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #21
Source File: test_operator.py From oss-ftp with MIT License | 5 votes |
def test_isNumberType(self): self.assertRaises(TypeError, operator.isNumberType) self.assertTrue(operator.isNumberType(8)) self.assertTrue(operator.isNumberType(8j)) self.assertTrue(operator.isNumberType(8L)) self.assertTrue(operator.isNumberType(8.3)) self.assertFalse(operator.isNumberType(dir()))
Example #22
Source File: test_bool.py From BinderFilter with MIT License | 5 votes |
def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) with test_support.check_py3k_warnings(): self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True)
Example #23
Source File: test_operator.py From BinderFilter with MIT License | 5 votes |
def test_isNumberType(self): self.assertRaises(TypeError, operator.isNumberType) self.assertTrue(operator.isNumberType(8)) self.assertTrue(operator.isNumberType(8j)) self.assertTrue(operator.isNumberType(8L)) self.assertTrue(operator.isNumberType(8.3)) self.assertFalse(operator.isNumberType(dir()))