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


Python numpy.int_方法代码示例

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


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

示例1: draw_lane_fit

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def draw_lane_fit(undist, warped ,Minv, left_fitx, right_fitx, ploty):
	# Drawing
	# Create an image to draw the lines on
	warp_zero = np.zeros_like(warped).astype(np.uint8)
	color_warp = np.dstack((warp_zero, warp_zero, warp_zero))

	# Recast the x and y points into usable format for cv2.fillPoly()
	pts_left = np.array([np.transpose(np.vstack([left_fitx, ploty]))])
	pts_right = np.array([np.flipud(np.transpose(np.vstack([right_fitx, ploty])))])
	pts = np.hstack((pts_left, pts_right))

	# Draw the lane onto the warped blank image
	cv2.fillPoly(color_warp, np.int_([pts]), (0,255,0))

	# Warp the blank back to original image space using inverse perspective matrix(Minv)
	newwarp = cv2.warpPerspective(color_warp, Minv, (undist.shape[1], undist.shape[0]))
	# Combine the result with the original image
	result = cv2.addWeighted(undist, 1, newwarp, 0.3, 0)

	return result 
开发者ID:ChengZhongShen,项目名称:Advanced_Lane_Lines,代码行数:22,代码来源:image_process.py

示例2: _unsigned_subtract

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def _unsigned_subtract(a, b):
    """
    Subtract two values where a >= b, and produce an unsigned result

    This is needed when finding the difference between the upper and lower
    bound of an int16 histogram
    """
    # coerce to a single type
    signed_to_unsigned = {
        np.byte: np.ubyte,
        np.short: np.ushort,
        np.intc: np.uintc,
        np.int_: np.uint,
        np.longlong: np.ulonglong
    }
    dt = np.result_type(a, b)
    try:
        dt = signed_to_unsigned[dt.type]
    except KeyError:
        return np.subtract(a, b, dtype=dt)
    else:
        # we know the inputs are integers, and we are deliberately casting
        # signed to unsigned
        return np.subtract(a, b, casting='unsafe', dtype=dt) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:histograms.py

示例3: test_allclose

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def test_allclose(self):
        # Tests allclose on arrays
        a = np.random.rand(10)
        b = a + np.random.rand(10) * 1e-8
        assert_(allclose(a, b))
        # Test allclose w/ infs
        a[0] = np.inf
        assert_(not allclose(a, b))
        b[0] = np.inf
        assert_(allclose(a, b))
        # Test allclose w/ masked
        a = masked_array(a)
        a[-1] = masked
        assert_(allclose(a, b, masked_equal=True))
        assert_(not allclose(a, b, masked_equal=False))
        # Test comparison w/ scalar
        a *= 1e-8
        a[0] = 0
        assert_(allclose(a, 0, masked_equal=True))

        # Test that the function works for MIN_INT integer typed arrays
        a = masked_array([np.iinfo(np.int_).min], dtype=np.int_)
        assert_(allclose(a, a)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:25,代码来源:test_core.py

示例4: test_0_size

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def test_0_size(self):
        # Check that all kinds of 0-sized arrays work
        class ArraySubclass(np.ndarray):
            pass
        a = np.zeros((0, 1, 1), dtype=np.int_).view(ArraySubclass)
        res = linalg.eigvals(a)
        assert_(res.dtype.type is np.float64)
        assert_equal((0, 1), res.shape)
        # This is just for documentation, it might make sense to change:
        assert_(isinstance(res, np.ndarray))

        a = np.zeros((0, 0), dtype=np.complex64).view(ArraySubclass)
        res = linalg.eigvals(a)
        assert_(res.dtype.type is np.complex64)
        assert_equal((0,), res.shape)
        # This is just for documentation, it might make sense to change:
        assert_(isinstance(res, np.ndarray)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:19,代码来源:test_linalg.py

示例5: test_no_seq_repeat_basic_array_like

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def test_no_seq_repeat_basic_array_like(self):
        # Test that an array-like which does not know how to be multiplied
        # does not attempt sequence repeat (raise TypeError).
        # See also gh-7428.
        class ArrayLike(object):
            def __init__(self, arr):
                self.arr = arr
            def __array__(self):
                return self.arr

        # Test for simple ArrayLike above and memoryviews (original report)
        for arr_like in (ArrayLike(np.ones(3)), memoryview(np.ones(3))):
            assert_array_equal(arr_like * np.float32(3.), np.full(3, 3.))
            assert_array_equal(np.float32(3.) * arr_like, np.full(3, 3.))
            assert_array_equal(arr_like * np.int_(3), np.full(3, 3))
            assert_array_equal(np.int_(3) * arr_like, np.full(3, 3)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:test_scalarmath.py

示例6: test_dti_business_getitem

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def test_dti_business_getitem(self):
        rng = pd.bdate_range(START, END)
        smaller = rng[:5]
        exp = DatetimeIndex(rng.view(np.ndarray)[:5])
        tm.assert_index_equal(smaller, exp)

        assert smaller.freq == rng.freq

        sliced = rng[::5]
        assert sliced.freq == BDay() * 5

        fancy_indexed = rng[[4, 3, 2, 1, 0]]
        assert len(fancy_indexed) == 5
        assert isinstance(fancy_indexed, DatetimeIndex)
        assert fancy_indexed.freq is None

        # 32-bit vs. 64-bit platforms
        assert rng[4] == rng[np.int_(4)] 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_indexing.py

示例7: test_dti_custom_getitem

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def test_dti_custom_getitem(self):
        rng = pd.bdate_range(START, END, freq='C')
        smaller = rng[:5]
        exp = DatetimeIndex(rng.view(np.ndarray)[:5])
        tm.assert_index_equal(smaller, exp)
        assert smaller.freq == rng.freq

        sliced = rng[::5]
        assert sliced.freq == CDay() * 5

        fancy_indexed = rng[[4, 3, 2, 1, 0]]
        assert len(fancy_indexed) == 5
        assert isinstance(fancy_indexed, DatetimeIndex)
        assert fancy_indexed.freq is None

        # 32-bit vs. 64-bit platforms
        assert rng[4] == rng[np.int_(4)] 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:19,代码来源:test_indexing.py

示例8: boundary_conditions

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def boundary_conditions(self, bc):
        global bc_choices
        if bc in list(bc_choices.keys()):
            bc = [bc_choices[bc]] * self.dim
            self.bc_shift = None
        else:
            bc = list(bc)  # we modify entries...
            self.bc_shift = np.zeros(self.dim - 1, np.int_)
            for i, bc_i in enumerate(bc):
                if isinstance(bc_i, int):
                    if i == 0:
                        raise ValueError("Invalid bc: first entry can't be a shift")
                    self.bc_shift[i - 1] = bc_i
                    bc[i] = bc_choices['periodic']
                else:
                    bc[i] = bc_choices[bc_i]
            if not np.any(self.bc_shift != 0):
                self.bc_shift = None
        self.bc = np.array(bc) 
开发者ID:tenpy,项目名称:tenpy,代码行数:21,代码来源:lattice.py

示例9: testLinspaceExecution

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def testLinspaceExecution(self):
        a = linspace(2.0, 9.0, num=11, chunk_size=3)

        res = self.executor.execute_tensor(a, concat=True)[0]
        expected = np.linspace(2.0, 9.0, num=11)
        np.testing.assert_allclose(res, expected)

        a = linspace(2.0, 9.0, num=11, endpoint=False, chunk_size=3)

        res = self.executor.execute_tensor(a, concat=True)[0]
        expected = np.linspace(2.0, 9.0, num=11, endpoint=False)
        np.testing.assert_allclose(res, expected)

        a = linspace(2.0, 9.0, num=11, chunk_size=3, dtype=int)

        res = self.executor.execute_tensor(a, concat=True)[0]
        self.assertEqual(res.dtype, np.int_) 
开发者ID:mars-project,项目名称:mars,代码行数:19,代码来源:test_datasource_execute.py

示例10: _unsigned_subtract

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def _unsigned_subtract(a, b):
    """
    Subtract two values where a >= b, and produce an unsigned result

    This is needed when finding the difference between the upper and lower
    bound of an int16 histogram
    """
    # coerce to a single type
    signed_to_unsigned = {
        np.byte: np.ubyte,
        np.short: np.ushort,
        np.intc: np.uintc,
        np.int_: np.uint,
        np.longlong: np.ulonglong
    }
    dt = np.result_type(a, b)
    try:
        dt = signed_to_unsigned[dt.type]
    except KeyError:  # pragma: no cover
        return np.subtract(a, b, dtype=dt)
    else:
        # we know the inputs are integers, and we are deliberately casting
        # signed to unsigned
        return np.subtract(a, b, casting='unsafe', dtype=dt) 
开发者ID:mars-project,项目名称:mars,代码行数:26,代码来源:histogram.py

示例11: initialize

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def initialize(self):
        self.pcoord_ndim = 1
        self.pcoord_dtype = numpy.float32
        self.pcoord_len = 5
        self.bin_mapper = RectilinearBinMapper([ list(numpy.arange(0.0, 10.1, 0.1)) ] )
        self.bin_target_counts = numpy.empty((self.bin_mapper.nbins,), numpy.int_)
        self.bin_target_counts[...] = 10
        self.test_variable_2 = "And I'm the second one"

# YAML Front end tests

# Implemented basic tests
#  - returns the correct system 
#    given a system driver
#  - returns the correct system
#    given a yaml system
#  - returns the correct system
#    given both

# A class to test both paths at the same time
# if it works we assure we can load the driver
# AND overwrite it properly 
开发者ID:westpa,项目名称:westpa,代码行数:24,代码来源:testyamlfe.py

示例12: test_allclose

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def test_allclose(self):
        # Tests allclose on arrays
        a = np.random.rand(10)
        b = a + np.random.rand(10) * 1e-8
        self.assertTrue(allclose(a, b))
        # Test allclose w/ infs
        a[0] = np.inf
        self.assertTrue(not allclose(a, b))
        b[0] = np.inf
        self.assertTrue(allclose(a, b))
        # Test allclose w/ masked
        a = masked_array(a)
        a[-1] = masked
        self.assertTrue(allclose(a, b, masked_equal=True))
        self.assertTrue(not allclose(a, b, masked_equal=False))
        # Test comparison w/ scalar
        a *= 1e-8
        a[0] = 0
        self.assertTrue(allclose(a, 0, masked_equal=True))

        # Test that the function works for MIN_INT integer typed arrays
        a = masked_array([np.iinfo(np.int_).min], dtype=np.int_)
        self.assertTrue(allclose(a, a)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:25,代码来源:test_core.py

示例13: test_empty_tuple_index

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def test_empty_tuple_index(self):
        # Empty tuple index creates a view
        a = np.array([1, 2, 3])
        assert_equal(a[()], a)
        assert_(a[()].base is a)
        a = np.array(0)
        assert_(isinstance(a[()], np.int_))

        # Regression, it needs to fall through integer and fancy indexing
        # cases, so need the with statement to ignore the non-integer error.
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore', '', DeprecationWarning)
            a = np.array([1.])
            assert_(isinstance(a[0.], np.float_))

            a = np.array([np.array(1)], dtype=object)
            assert_(isinstance(a[0.], np.ndarray)) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:19,代码来源:test_indexing.py

示例14: test_observation_detection

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def test_observation_detection(self):
        r"""Test observation_detection method.

        Approach: Ensure that all outputs are set as expected
        """

        exclude_mods = []
        exclude_mod_type = 'sotoSS'

        for mod in self.allmods:
            if mod.__name__ in exclude_mods:
                continue
            if 'observation_detection' in mod.__dict__ or exclude_mod_type in mod.__name__:

                spec = copy.deepcopy(self.spec)
                if 'tieredScheduler' in mod.__name__:
                    self.script = resource_path('test-scripts/simplest_occ.json')
                    with open(self.script) as f:
                        spec = json.loads(f.read())
                    spec['occHIPs'] = resource_path('SurveySimulation/top100stars.txt')

                with RedirectStreams(stdout=self.dev_null):
                    sim = mod(**spec)

                    #default settings should create dummy planet around first star
                    sInd = 0
                    pInds = np.where(sim.SimulatedUniverse.plan2star == sInd)[0]
                    detected, fZ, systemParams, SNR, FA = \
                            sim.observation_detection(sInd,1.0*u.d,\
                            sim.OpticalSystem.observingModes[0])
                
                self.assertEqual(len(detected),len(pInds),\
                        'len(detected) != len(pInds) for %s'%mod.__name__)
                self.assertIsInstance(detected[0],(int,np.int32,np.int64,np.int_),\
                        'detected elements not ints for %s'%mod.__name__)
                for s in SNR[detected == 1]:
                    self.assertGreaterEqual(s,sim.OpticalSystem.observingModes[0]['SNR'],\
                        'detection SNR < mode requirement for %s'%mod.__name__)
                self.assertIsInstance(FA, bool,\
                        'False Alarm not boolean for %s'%mod.__name__) 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:42,代码来源:test_SurveySimulation.py

示例15: is_integer

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import int_ [as 别名]
def is_integer(rho):
    """
    checks if numpy array is an integer vector

    Parameters
    ----------
    rho

    Returns
    -------

    """
    return np.array_equal(rho, np.require(rho, dtype=np.int_)) 
开发者ID:ustunb,项目名称:risk-slim,代码行数:15,代码来源:helper_functions.py


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