python类min_scalar_type()的实例源码

inference.py 文件源码 项目:SERT 作者: cvangysel 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def create(predict_fn, word_representations,
           batch_size, window_size, vocabulary_size,
           result_callback):
    assert result_callback is not None

    instance_dtype = np.min_scalar_type(vocabulary_size - 1)
    logging.info('Instance elements will be stored using %s.', instance_dtype)

    if result_callback.should_average_input():
        batcher = EmbeddingMapper(
            predict_fn,
            word_representations,
            result_callback)
    else:
        batcher = WordBatcher(
            predict_fn,
            batch_size, window_size,
            instance_dtype,
            result_callback)

    return batcher
test_multiarray.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_usigned_shortshort(self):
        dt = np.min_scalar_type(2**8-1)
        wanted = np.dtype('uint8')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_usigned_short(self):
        dt = np.min_scalar_type(2**16-1)
        wanted = np.dtype('uint16')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_usigned_int(self):
        dt = np.min_scalar_type(2**32-1)
        wanted = np.dtype('uint32')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_usigned_longlong(self):
        dt = np.min_scalar_type(2**63-1)
        wanted = np.dtype('uint64')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_object(self):
        dt = np.min_scalar_type(2**64)
        wanted = np.dtype('O')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_usigned_shortshort(self):
        dt = np.min_scalar_type(2**8-1)
        wanted = np.dtype('uint8')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_usigned_short(self):
        dt = np.min_scalar_type(2**16-1)
        wanted = np.dtype('uint16')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_usigned_int(self):
        dt = np.min_scalar_type(2**32-1)
        wanted = np.dtype('uint32')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_usigned_longlong(self):
        dt = np.min_scalar_type(2**63-1)
        wanted = np.dtype('uint64')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_object(self):
        dt = np.min_scalar_type(2**64)
        wanted = np.dtype('O')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_usigned_shortshort(self):
        dt = np.min_scalar_type(2**8-1)
        wanted = np.dtype('uint8')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_usigned_short(self):
        dt = np.min_scalar_type(2**16-1)
        wanted = np.dtype('uint16')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_usigned_int(self):
        dt = np.min_scalar_type(2**32-1)
        wanted = np.dtype('uint32')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_usigned_longlong(self):
        dt = np.min_scalar_type(2**63-1)
        wanted = np.dtype('uint64')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_object(self):
        dt = np.min_scalar_type(2**64)
        wanted = np.dtype('O')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_usigned_shortshort(self):
        dt = np.min_scalar_type(2**8-1)
        wanted = np.dtype('uint8')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_usigned_short(self):
        dt = np.min_scalar_type(2**16-1)
        wanted = np.dtype('uint16')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_usigned_int(self):
        dt = np.min_scalar_type(2**32-1)
        wanted = np.dtype('uint32')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def test_usigned_longlong(self):
        dt = np.min_scalar_type(2**63-1)
        wanted = np.dtype('uint64')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_object(self):
        dt = np.min_scalar_type(2**64)
        wanted = np.dtype('O')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_usigned_shortshort(self):
        dt = np.min_scalar_type(2**8-1)
        wanted = np.dtype('uint8')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_usigned_short(self):
        dt = np.min_scalar_type(2**16-1)
        wanted = np.dtype('uint16')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_usigned_int(self):
        dt = np.min_scalar_type(2**32-1)
        wanted = np.dtype('uint32')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_usigned_longlong(self):
        dt = np.min_scalar_type(2**63-1)
        wanted = np.dtype('uint64')
        assert_equal(wanted, dt)
test_multiarray.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_object(self):
        dt = np.min_scalar_type(2**64)
        wanted = np.dtype('O')
        assert_equal(wanted, dt)
core.py 文件源码 项目:sparse 作者: mrocklin 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _linear_loc(coords, shape, signed=False):
        n = reduce(operator.mul, shape, 1)
        if signed:
            n = -n
        dtype = np.min_scalar_type(n)
        out = np.zeros(coords.shape[1], dtype=dtype)
        tmp = np.zeros(coords.shape[1], dtype=dtype)
        strides = 1
        for i, d in enumerate(shape[::-1]):
            # out += self.coords[-(i + 1), :].astype(dtype) * strides
            np.multiply(coords[-(i + 1), :], strides, out=tmp, dtype=dtype)
            np.add(tmp, out, out=out)
            strides *= d
        return out
core.py 文件源码 项目:sparse 作者: mrocklin 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def reshape(self, shape):
        if self.shape == shape:
            return self
        if any(d == -1 for d in shape):
            extra = int(np.prod(self.shape) /
                        np.prod([d for d in shape if d != -1]))
            shape = tuple([d if d != -1 else extra for d in shape])

        if self.shape == shape:
            return self

        if self._cache is not None:
            for sh, value in self._cache['reshape']:
                if sh == shape:
                    return value

        # TODO: this np.prod(self.shape) enforces a 2**64 limit to array size
        linear_loc = self.linear_loc()

        coords = np.empty((len(shape), self.nnz), dtype=np.min_scalar_type(max(shape)))
        strides = 1
        for i, d in enumerate(shape[::-1]):
            coords[-(i + 1), :] = (linear_loc // strides) % d
            strides *= d

        result = COO(coords, self.data, shape,
                     has_duplicates=self.has_duplicates,
                     sorted=self.sorted, cache=self._cache is not None)

        if self._cache is not None:
            self._cache['reshape'].append((shape, result))
        return result
rasters.py 文件源码 项目:pandarus 作者: cmutel 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def rasterize_pctcover_geom(geom, shape, affine, scale=None, all_touched=False):
    """
    Parameters
    ----------
    geom: GeoJSON geometry
    shape: desired shape
    affine: desired transform
    scale: scale at which to generate percent cover estimate

    Returns
    -------
    ndarray: float32
    """
    if scale is None:
        scale = 10

    min_dtype = min_scalar_type(scale ** 2)

    new_affine = Affine(affine[0]/scale, 0, affine[2],
                        0, affine[4]/scale, affine[5])

    new_shape = (shape[0] * scale, shape[1] * scale)

    rv_array = rasterize_geom(geom, new_shape, new_affine, all_touched=all_touched)

    rv_array = rebin_sum(rv_array, shape, min_dtype)

    return rv_array.astype('float32') / (scale**2)
test_multiarray.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_usigned_shortshort(self):
        dt = np.min_scalar_type(2**8-1)
        wanted = np.dtype('uint8')
        assert_equal(wanted, dt)


问题


面经


文章

微信
公众号

扫码关注公众号