python类long()的实例源码

test_ufunc.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_matrix_multiply(self):
        self.compare_matrix_multiply_results(np.long)
        self.compare_matrix_multiply_results(np.double)
test_regression.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_signed_integer_division_overflow(self):
        # Ticket #1317.
        def test_type(t):
            min = np.array([np.iinfo(t).min])
            min //= -1

        with np.errstate(divide="ignore"):
            for t in (np.int8, np.int16, np.int32, np.int64, np.int, np.long):
                test_type(t)
test_regression.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_array_side_effect(self):
        # The second use of itemsize was throwing an exception because in
        # ctors.c, discover_itemsize was calling PyObject_Length without
        # checking the return code.  This failed to get the length of the
        # number 2, and the exception hung around until something checked
        # PyErr_Occurred() and returned an error.
        assert_equal(np.dtype('S10').itemsize, 10)
        np.array([['abc', 2], ['long   ', '0123456789']], dtype=np.string_)
        assert_equal(np.dtype('S10').itemsize, 10)
test_multiarray.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_sequence_long(self):
        assert_equal(np.array([long(4), long(4)]).dtype, np.long)
        assert_equal(np.array([long(4), 2**80]).dtype, np.object)
        assert_equal(np.array([long(4), 2**80, long(4)]).dtype, np.object)
        assert_equal(np.array([2**80, long(4)]).dtype, np.object)
test_ufunc.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_matrix_multiply(self):
        self.compare_matrix_multiply_results(np.long)
        self.compare_matrix_multiply_results(np.double)
test_numpy_mt19937.py 文件源码 项目:scipy-2017-cython-tutorial 作者: kwmsmith 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_random_integers_max_int(self):
        # Tests whether random_integers can generate the
        # maximum allowed Python int that can be converted
        # into a C long. Previous implementations of this
        # method have thrown an OverflowError when attempting
        # to generate this integer.
        with suppress_warnings() as sup:
            w = sup.record(DeprecationWarning)
            actual = mt19937.random_integers(np.iinfo('l').max,
                                             np.iinfo('l').max)
            assert_(len(w) == 1)

        desired = np.iinfo('l').max
        assert_equal(actual, desired)
test_regression.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def test_signed_integer_division_overflow(self):
        # Ticket #1317.
        def test_type(t):
            min = np.array([np.iinfo(t).min])
            min //= -1

        with np.errstate(divide="ignore"):
            for t in (np.int8, np.int16, np.int32, np.int64, np.int, np.long):
                test_type(t)
test_regression.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_array_side_effect(self):
        # The second use of itemsize was throwing an exception because in
        # ctors.c, discover_itemsize was calling PyObject_Length without
        # checking the return code.  This failed to get the length of the
        # number 2, and the exception hung around until something checked
        # PyErr_Occurred() and returned an error.
        assert_equal(np.dtype('S10').itemsize, 10)
        np.array([['abc', 2], ['long   ', '0123456789']], dtype=np.string_)
        assert_equal(np.dtype('S10').itemsize, 10)
test_multiarray.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_sequence_long(self):
        assert_equal(np.array([long(4), long(4)]).dtype, np.long)
        assert_equal(np.array([long(4), 2**80]).dtype, np.object)
        assert_equal(np.array([long(4), 2**80, long(4)]).dtype, np.object)
        assert_equal(np.array([2**80, long(4)]).dtype, np.object)
test_ufunc.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_matrix_multiply(self):
        self.compare_matrix_multiply_results(np.long)
        self.compare_matrix_multiply_results(np.double)
test_random.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def test_random_integers_max_int(self):
        # Tests whether random_integers can generate the
        # maximum allowed Python int that can be converted
        # into a C long. Previous implementations of this
        # method have thrown an OverflowError when attempting
        # to generate this integer.
        actual = np.random.random_integers(np.iinfo('l').max,
                                           np.iinfo('l').max)
        desired = np.iinfo('l').max
        np.testing.assert_equal(actual, desired)
test_regression.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_signed_integer_division_overflow(self):
        # Ticket #1317.
        def test_type(t):
            min = np.array([np.iinfo(t).min])
            min //= -1

        with np.errstate(divide="ignore"):
            for t in (np.int8, np.int16, np.int32, np.int64, np.int, np.long):
                test_type(t)
test_regression.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_array_side_effect(self):
        # The second use of itemsize was throwing an exception because in
        # ctors.c, discover_itemsize was calling PyObject_Length without
        # checking the return code.  This failed to get the length of the
        # number 2, and the exception hung around until something checked
        # PyErr_Occurred() and returned an error.
        assert_equal(np.dtype('S10').itemsize, 10)
        np.array([['abc', 2], ['long   ', '0123456789']], dtype=np.string_)
        assert_equal(np.dtype('S10').itemsize, 10)
test_multiarray.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def test_sequence_long(self):
        assert_equal(np.array([long(4), long(4)]).dtype, np.long)
        assert_equal(np.array([long(4), 2**80]).dtype, np.object)
        assert_equal(np.array([long(4), 2**80, long(4)]).dtype, np.object)
        assert_equal(np.array([2**80, long(4)]).dtype, np.object)
test_ufunc.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_matrix_multiply(self):
        self.compare_matrix_multiply_results(np.long)
        self.compare_matrix_multiply_results(np.double)
test_random.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_random_integers_max_int(self):
        # Tests whether random_integers can generate the
        # maximum allowed Python int that can be converted
        # into a C long. Previous implementations of this
        # method have thrown an OverflowError when attempting
        # to generate this integer.
        with suppress_warnings() as sup:
            w = sup.record(DeprecationWarning)
            actual = np.random.random_integers(np.iinfo('l').max,
                                               np.iinfo('l').max)
            assert_(len(w) == 1)

        desired = np.iinfo('l').max
        assert_equal(actual, desired)
utils.py 文件源码 项目:snape 作者: mbernico 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def assert_valid_percent(x, eq_lower=False, eq_upper=False):
    # these are all castable to float
    assert_is_type(x, (float, np.float, np.int, int, long, np.long))
    x = float(x)

    # test lower bound:
    if not ((eq_lower and 0. <= x) or ((not eq_lower) and 0. < x)):
        raise ValueError('Expected 0. %s x, but got x=%r'
                         % ('<=' if eq_lower else '<', x))
    if not ((eq_upper and x <= 1.) or ((not eq_upper) and x < 1.)):
        raise ValueError('Expected x %s 1., but got x=%r'
                         % ('<=' if eq_upper else '<', x))
    return x
utils.py 文件源码 项目:snape 作者: mbernico 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def get_random_state(random_state):
    # if it's a seed, return a new seeded RandomState
    if isinstance(random_state, (int, np.int, long, np.long, NoneType)):
        return RandomState(random_state)
    # if it's a RandomState, it's been initialized
    elif isinstance(random_state, RandomState):
        return random_state
    else:
        raise TypeError('cannot seed new RandomState with type=%s'
                        % type(random_state))
test_regression.py 文件源码 项目:Alfred 作者: jkachhadia 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def test_signed_integer_division_overflow(self):
        # Ticket #1317.
        def test_type(t):
            min = np.array([np.iinfo(t).min])
            min //= -1

        with np.errstate(divide="ignore"):
            for t in (np.int8, np.int16, np.int32, np.int64, np.int, np.long):
                test_type(t)
test_regression.py 文件源码 项目:Alfred 作者: jkachhadia 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_array_side_effect(self):
        # The second use of itemsize was throwing an exception because in
        # ctors.c, discover_itemsize was calling PyObject_Length without
        # checking the return code.  This failed to get the length of the
        # number 2, and the exception hung around until something checked
        # PyErr_Occurred() and returned an error.
        assert_equal(np.dtype('S10').itemsize, 10)
        np.array([['abc', 2], ['long   ', '0123456789']], dtype=np.string_)
        assert_equal(np.dtype('S10').itemsize, 10)


问题


面经


文章

微信
公众号

扫码关注公众号