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


Python numpy.uintp方法代码示例

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


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

示例1: test_same_kind_index_casting

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def test_same_kind_index_casting(self):
        # Indexes should be cast with same-kind and not safe, even if that
        # is somewhat unsafe. So test various different code paths.
        index = np.arange(5)
        u_index = index.astype(np.uintp)
        arr = np.arange(10)

        assert_array_equal(arr[index], arr[u_index])
        arr[u_index] = np.arange(5)
        assert_array_equal(arr, np.arange(10))

        arr = np.arange(10).reshape(5, 2)
        assert_array_equal(arr[index], arr[u_index])

        arr[u_index] = np.arange(5)[:,None]
        assert_array_equal(arr, np.arange(5)[:,None].repeat(2, axis=1))

        arr = np.arange(25).reshape(5, 5)
        assert_array_equal(arr[u_index, u_index], arr[index, index]) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:test_indexing.py

示例2: test_same_kind_index_casting

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def test_same_kind_index_casting(self):
        # Indexes should be cast with same-kind and not safe, even if
        # that is somewhat unsafe. So test various different code paths.
        index = np.arange(5)
        u_index = index.astype(np.uintp)
        arr = np.arange(10)

        assert_array_equal(arr[index], arr[u_index])
        arr[u_index] = np.arange(5)
        assert_array_equal(arr, np.arange(10))

        arr = np.arange(10).reshape(5, 2)
        assert_array_equal(arr[index], arr[u_index])

        arr[u_index] = np.arange(5)[:,None]
        assert_array_equal(arr, np.arange(5)[:,None].repeat(2, axis=1))

        arr = np.arange(25).reshape(5, 5)
        assert_array_equal(arr[u_index, u_index], arr[index, index]) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:21,代码来源:test_indexing.py

示例3: __init__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def __init__(self, filters, strides, pad_top, pad_left, bias, image_shape, input_names, output_name, output_shape):
        """
        collects the information needed for the conv_handle_intermediate_relu_layer transformer and brings it into the required shape
        
        Arguments
        ---------
        filters : numpy.ndarray
            the actual 4D filter of the convolutional layer
        strides : numpy.ndarray
            1D with to elements, stride in height and width direction
        bias : numpy.ndarray
            the bias of the layer
        image_shape : numpy.ndarray
            1D array of ints with 3 entries [height, width, channels] representing the shape of the of the image that is passed to the conv-layer
        """
        self.image_shape = np.ascontiguousarray(image_shape, dtype=np.uintp)
        self.filters     = np.ascontiguousarray(filters, dtype=np.double)
        self.strides     = np.ascontiguousarray(strides, dtype=np.uintp)
        self.bias        = np.ascontiguousarray(bias, dtype=np.double)
        self.out_size    = (c_size_t * 3)(output_shape[1], output_shape[2], output_shape[3]) 
        self.pad_top     = pad_top
        self.pad_left    = pad_left
        add_input_output_information_deeppoly(self, input_names, output_name, output_shape) 
开发者ID:eth-sri,项目名称:eran,代码行数:25,代码来源:deeppoly_nodes.py

示例4: update_relu_expr_bounds

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def update_relu_expr_bounds(man, element, layerno, lower_bound_expr, upper_bound_expr, lbi, ubi):
    for var in upper_bound_expr.keys():
        uexpr = upper_bound_expr[var].expr
        varsid = upper_bound_expr[var].varsid
        bound = upper_bound_expr[var].bound
        k = len(varsid)
        varsid = np.ascontiguousarray(varsid, dtype=np.uintp)
        for j in range(k):
            nnz_u = 0
            for l in range(k):
                if uexpr[l+1] != 0:
                    nnz_u+=1
            #if nnz_l > 1:
                #lexpr = np.ascontiguousarray(lexpr, dtype=np.double)
                #update_relu_lower_bound_for_neuron(man, element, layerno, varsid[j], lexpr, varsid, k)
            if nnz_u > 1 and bound < 2*ubi[var]:
                uexpr = np.ascontiguousarray(uexpr, dtype=np.double)
                update_relu_upper_bound_for_neuron(man, element, layerno, varsid[j], uexpr, varsid, k) 
开发者ID:eth-sri,项目名称:eran,代码行数:20,代码来源:refine_relu.py

示例5: _numpy2cells

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def _numpy2cells(cells):
        if cells.ndim == 1:
            offset = 0
            n_cells = 0
            while offset < cells.size:
                offset += cells[offset] + 1
                n_cells += 1
            vtk_cells = cells
        else:
            n_cells, n_points_cell = cells.shape
            vtk_cells = np.empty((n_cells, n_points_cell + 1),
                                 dtype=np.uintp)
            vtk_cells[:, 0] = n_points_cell
            vtk_cells[:, 1:] = cells
            vtk_cells = vtk_cells.ravel()

        # cells = dsa.numpyTovtkDataArray(vtk_cells, array_type=VTK_ID_TYPE)
        ca = BSCellArray()
        ca.SetCells(n_cells, vtk_cells)
        return ca.VTKObject 
开发者ID:MICA-MNI,项目名称:BrainSpace,代码行数:22,代码来源:data_object.py

示例6: test_round_trip

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def test_round_trip():
    scaling_type = np.float32
    rng = np.random.RandomState(20111121)
    N = 10000
    sd_10s = range(-20, 51, 5)
    iuint_types = np.sctypes['int'] + np.sctypes['uint']
    # Remove intp types, which cannot be set into nifti header datatype
    iuint_types.remove(np.intp)
    iuint_types.remove(np.uintp)
    f_types = [np.float32, np.float64]
    # Expanding standard deviations
    for i, sd_10 in enumerate(sd_10s):
        sd = 10.0**sd_10
        V_in = rng.normal(0, sd, size=(N,1))
        for j, in_type in enumerate(f_types):
            for k, out_type in enumerate(iuint_types):
                check_arr(sd_10, V_in, in_type, out_type, scaling_type)
    # Spread integers across range
    for i, sd in enumerate(np.linspace(0.05, 0.5, 5)):
        for j, in_type in enumerate(iuint_types):
            info = np.iinfo(in_type)
            mn, mx = info.min, info.max
            type_range = mx - mn
            center = type_range / 2.0 + mn
            # float(sd) because type_range can be type 'long'
            width = type_range * float(sd)
            V_in = rng.normal(center, width, size=(N,1))
            for k, out_type in enumerate(iuint_types):
                check_arr(sd, V_in, in_type, out_type, scaling_type) 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:31,代码来源:test_round_trip.py

示例7: test_equivalent_dtype_hashing

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def test_equivalent_dtype_hashing(self):
        # Make sure equivalent dtypes with different type num hash equal
        uintp = np.dtype(np.uintp)
        if uintp.itemsize == 4:
            left = uintp
            right = np.dtype(np.uint32)
        else:
            left = uintp
            right = np.dtype(np.ulonglong)
        assert_(left == right)
        assert_(hash(left) == hash(right)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,代码来源:test_dtype.py

示例8: test_void_pointer

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def test_void_pointer(self):
        self.check(ctypes.c_void_p, np.uintp) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:test_dtype.py

示例9: get_children

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def get_children(self, segment):
        '''Return all segments which have the given segment as a parent'''

        if segment.n_iter == self.current_iteration: return []
        
        # Examine the segment index from the following iteration to see who has this segment
        # as a parent.  We don't need to worry about the number of parents each segment
        # has, since each has at least one, and indexing on the offset into the parents array 
        # gives the primary parent ID
        
        with self.lock:
            iter_group = self.get_iter_group(segment.n_iter+1)
            seg_index = iter_group['seg_index'][...]
    
            # This is one of the slowest pieces of code I've ever written...
            #seg_index = iter_group['seg_index'][...]
            #seg_ids = [seg_id for (seg_id,row) in enumerate(seg_index) 
            #           if all_parent_ids[row['parents_offset']] == segment.seg_id]
            #return self.get_segments_by_id(segment.n_iter+1, seg_ids)
            if self.we_h5file_version < 5:
                parents = iter_group['parents'][seg_index['parent_offsets']] 
            else:
                parents = seg_index['parent_id']
            all_seg_ids = numpy.arange(seg_index.len(), dtype=numpy.uintp)
            seg_ids = all_seg_ids[parents == segment.seg_id]
            # the above will return a scalar if only one is found, so convert
            # to a list if necessary
            try:
                len(seg_ids)
            except TypeError:
                seg_ids = [seg_ids]
            
            return self.get_segments(segment.n_iter+1, seg_ids)

    # The following are dictated by the SimManager interface 
开发者ID:westpa,项目名称:westpa,代码行数:37,代码来源:data_manager.py

示例10: get_xpp

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def get_xpp(self):
        """
        helper function to get pointers to the rows of self.weights.
        
        Return
        ------
        output : numpy.ndarray
            pointers to the rows of the matrix
        """
        return (self.weights.__array_interface__['data'][0]+ np.arange(self.weights.shape[0])*self.weights.strides[0]).astype(np.uintp) 
开发者ID:eth-sri,项目名称:eran,代码行数:12,代码来源:deeppoly_nodes.py

示例11: __init__

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def __init__(self, image_shape, filters, strides, pad_top, pad_left, input_names, output_name, output_shape):
        """
        Arguments
        ---------
        image_shape : numpy.ndarray
            of shape [height, width, channels]
        filters : numpy.ndarray
            the 4D array with the filter weights
        strides : numpy.ndarray
            of shape [height, width]
        padding : str
            type of padding, either 'VALID' or 'SAME'
        input_names : iterable
            iterable with the name of the second addend
        output_name : str
            name of this node's output
        output_shape : iterable
            iterable of ints with the shape of the output of this node
        """
        add_input_output_information(self, input_names, output_name, output_shape)
        self.image_size = np.ascontiguousarray(image_shape, dtype=np.uintp)
        self.filters    = np.ascontiguousarray(filters, dtype=np.double)
        self.strides    = np.ascontiguousarray(strides, dtype=np.uintp)
        self.output_shape = (c_size_t * 3)(output_shape[1], output_shape[2], output_shape[3])
        self.pad_top    = pad_top
        self.pad_left   = pad_left 
开发者ID:eth-sri,项目名称:eran,代码行数:28,代码来源:deepzono_nodes.py

示例12: test_map_coordinates_dts

# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import uintp [as 别名]
def test_map_coordinates_dts():
    # check that ndimage accepts different data types for interpolation
    data = np.array([[4, 1, 3, 2],
                     [7, 6, 8, 5],
                     [3, 5, 3, 6]])
    shifted_data = np.array([[0, 0, 0, 0],
                             [0, 4, 1, 3],
                             [0, 7, 6, 8]])
    idx = np.indices(data.shape)
    dts = (np.uint8, np.uint16, np.uint32, np.uint64,
           np.int8, np.int16, np.int32, np.int64,
           np.intp, np.uintp, np.float32, np.float64)
    for order in range(0, 6):
        for data_dt in dts:
            these_data = data.astype(data_dt)
            for coord_dt in dts:
                # affine mapping
                mat = np.eye(2, dtype=coord_dt)
                off = np.zeros((2,), dtype=coord_dt)
                out = ndimage.affine_transform(these_data, mat, off)
                assert_array_almost_equal(these_data, out)
                # map coordinates
                coords_m1 = idx.astype(coord_dt) - 1
                coords_p10 = idx.astype(coord_dt) + 10
                out = ndimage.map_coordinates(these_data, coords_m1, order=order)
                assert_array_almost_equal(out, shifted_data)
                # check constant fill works
                out = ndimage.map_coordinates(these_data, coords_p10, order=order)
                assert_array_almost_equal(out, np.zeros((3,4)))
            # check shift and zoom
            out = ndimage.shift(these_data, 1)
            assert_array_almost_equal(out, shifted_data)
            out = ndimage.zoom(these_data, 1)
            assert_array_almost_equal(these_data, out) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:36,代码来源:test_datatypes.py


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