• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python numpy.iinfo函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: add_noise

def add_noise(sim):
    det_left = sim.outarr[:, :sim.nxpix]
    det_mid = sim.outarr[:, sim.nxpix:2*sim.nxpix]
    det_right = sim.outarr[:, 2*sim.nxpix:3*sim.nxpix]
    shape = det_left.shape

    det_left += det_bias(sim.dl_bias, det="left")
    det_mid += det_bias(sim.dm_bias, det="middle")
    det_right += det_bias(sim.dr_bias, det="right")

    det_left += readout_noise(sim.dl_ron, shape, det="left")
    det_mid += readout_noise(sim.dm_ron, shape, det="middle")
    det_right += readout_noise(sim.dr_ron, shape, det="right")

    det_left += dark_current(sim.dl_dc, sim.tobs, shape, det="left")
    det_mid += dark_current(sim.dm_dc, sim.tobs, shape, det="middle")
    det_right += dark_current(sim.dr_dc, sim.tobs, shape, det="right")

    sim.outarr = gain(sim.outarr, sim.inv_gain)

    if sim.outarr.max() > np.iinfo(np.uint16).max:
        log.info("Clipping array values larger than %s.", np.iinfo(np.uint16).max)
        sim.outarr[sim.outarr > np.iinfo(np.uint16).max] = np.iinfo(np.uint16).max
    sim.outarr = np.asarray(sim.outarr, dtype=np.uint16)    
    log.info("Converting image array back to %s.", sim.outarr.dtype)
    
开发者ID:jgrunhut,项目名称:crifors,代码行数:25,代码来源:noise.py


示例2: test_implementation_limits

    def test_implementation_limits(self):
        min_td = Timedelta(Timedelta.min)
        max_td = Timedelta(Timedelta.max)

        # GH 12727
        # timedelta limits correspond to int64 boundaries
        assert min_td.value == np.iinfo(np.int64).min + 1
        assert max_td.value == np.iinfo(np.int64).max

        # Beyond lower limit, a NAT before the Overflow
        assert (min_td - Timedelta(1, 'ns')) is NaT

        with pytest.raises(OverflowError):
            min_td - Timedelta(2, 'ns')

        with pytest.raises(OverflowError):
            max_td + Timedelta(1, 'ns')

        # Same tests using the internal nanosecond values
        td = Timedelta(min_td.value - 1, 'ns')
        assert td is NaT

        with pytest.raises(OverflowError):
            Timedelta(min_td.value - 2, 'ns')

        with pytest.raises(OverflowError):
            Timedelta(max_td.value + 1, 'ns')
开发者ID:Itay4,项目名称:pandas,代码行数:27,代码来源:test_timedelta.py


示例3: able_int_type

def able_int_type(values):
    """ Find the smallest integer numpy type to contain sequence `values`

    Prefers uint to int if minimum is >= 0

    Parameters
    ----------
    values : sequence
        sequence of integer values

    Returns
    -------
    itype : None or numpy type
        numpy integer type or None if no integer type holds all `values`

    Examples
    --------
    >>> able_int_type([0, 1]) == np.uint8
    True
    >>> able_int_type([-1, 1]) == np.int8
    True
    """
    if any([v % 1 for v in values]):
        return None
    mn = min(values)
    mx = max(values)
    if mn >= 0:
        for ityp in np.sctypes['uint']:
            if mx <= np.iinfo(ityp).max:
                return ityp
    for ityp in np.sctypes['int']:
        info = np.iinfo(ityp)
        if mn >= info.min and mx <= info.max:
            return ityp
    return None
开发者ID:Eric89GXL,项目名称:nibabel,代码行数:35,代码来源:casting.py


示例4: testInfNan

  def testInfNan(self):
    i4 = np.iinfo(np.int32)
    i8 = np.iinfo(np.int64)

    self._compare(np.inf, np.float32, np.inf, False)
    self._compare(np.inf, np.float64, np.inf, False)
    if sys.byteorder == "big":
      self._compare(np.inf, np.int32, i4.max, False)
      self._compare(np.inf, np.int64, i8.max, False)
    else:
      # np.float64("np.inf").astype(np.int32) is negative on x86 but positive on ppc64le
      # Numpy link to relevant discussion - https://github.com/numpy/numpy/issues/9040
      # Tensorflow link to relevant discussion - https://github.com/tensorflow/tensorflow/issues/9360
      if platform.machine() == "ppc64le":
        self._compare(-np.inf, np.int32, i4.min, False)
        self._compare(-np.inf, np.int64, i8.min, False)
      else:
        self._compare(np.inf, np.int32, i4.min, False)
        self._compare(np.inf, np.int64, i8.min, False)
    self._compare(-np.inf, np.float32, -np.inf, False)
    self._compare(-np.inf, np.float64, -np.inf, False)
    self._compare(-np.inf, np.int32, i4.min, False)
    self._compare(-np.inf, np.int64, i8.min, False)
    self.assertAllEqual(np.isnan(self._cast(np.nan, np.float32, False)), True)
    self.assertAllEqual(np.isnan(self._cast(np.nan, np.float64, False)), True)
    self._compare(np.nan, np.int32, i4.min, False)
    self._compare(np.nan, np.int64, i8.min, False)

    self._compare(np.inf, np.float32, np.inf, True)
    self._compare(np.inf, np.float64, np.inf, True)
    self._compare(-np.inf, np.float32, -np.inf, True)
    self._compare(-np.inf, np.float64, -np.inf, True)
    self.assertAllEqual(np.isnan(self._cast(np.nan, np.float32, True)), True)
    self.assertAllEqual(np.isnan(self._cast(np.nan, np.float64, True)), True)
开发者ID:bunbutter,项目名称:tensorflow,代码行数:34,代码来源:cast_op_test.py


示例5: initBuffers

    def initBuffers(self,puzzle):
        #define lengths buffer and copy to the GPU
        #as we will not read from this buffer later, mapping is not required
        self.lengths = np.full(self.simulations,np.iinfo(np.int16).max,dtype=np.int16)
        self.lengthsBuffer = cl.Buffer(self.context, cl.mem_flags.READ_WRITE | cl.mem_flags.COPY_HOST_PTR, hostbuf=self.lengths)
         
        #define buffer for aggregated lengths for each workgroup
        self.groupLengths = np.full(self.workGroups,np.iinfo(np.int16).max,dtype=np.int16)
        self.groupLengthsBuffer = cl.Buffer(self.context, cl.mem_flags.READ_WRITE | cl.mem_flags.USE_HOST_PTR, hostbuf=self.groupLengths)
        
        #map group lengths buffer
        cl.enqueue_map_buffer(self.queue,self.groupLengthsBuffer,cl.map_flags.READ,0,self.groupLengths.shape,self.groupLengths.dtype)
        
        #get the input puzzle ready for the kernel; convert to 8 bit int (char)
        p = np.array(puzzle['puzzle']).astype(np.int8)
        #subtract 1 so that -1 denotes a gap and 0 denotes a square to be filled
        p = p - np.ones_like(p,dtype=p.dtype)
        
        #copy the puzzle, one for each simulation
        self.puzzles = np.zeros((self.simulations,self.height,self.width),dtype=p.dtype)
        self.puzzles[:,0:self.height,0:self.width] = p
    
        #define puzzles buffer and copy data (we do not need to worry about getting data out of this buffer, so mapping isn't required)
        #this buffer contains the input puzzles, one for each invocation (the puzzle is too large to hold in local or shared memory)
        self.puzzlesFlattened = self.puzzles.ravel()
        self.puzzlesBuffer = cl.Buffer(self.context, cl.mem_flags.READ_WRITE | cl.mem_flags.COPY_HOST_PTR, hostbuf=self.puzzlesFlattened)
        
        #define output buffer for best solutions aggregated across workgroups
        self.solutions = self.puzzles[0:self.workGroups]
        self.solutionsFlattened = self.solutions.ravel()
        self.solutionsBuffer = cl.Buffer(self.context, cl.mem_flags.READ_WRITE | cl.mem_flags.USE_HOST_PTR, hostbuf=self.solutionsFlattened)

        #map solutions buffer
        cl.enqueue_map_buffer(self.queue,self.solutionsBuffer,cl.map_flags.READ,0,self.solutionsFlattened.shape,self.solutions.dtype)
开发者ID:ohlord,项目名称:cimpress,代码行数:34,代码来源:CLSolve.py


示例6: _random_integers

def _random_integers(size, dtype):
    # We do not generate integers outside the int64 range
    platform_int_info = np.iinfo('int_')
    iinfo = np.iinfo(dtype)
    return np.random.randint(max(iinfo.min, platform_int_info.min),
                             min(iinfo.max, platform_int_info.max),
                             size=size).astype(dtype)
开发者ID:marklavrynenko-original,项目名称:arrow,代码行数:7,代码来源:test_parquet.py


示例7: test_implementation_limits

    def test_implementation_limits(self):
        min_td = Timedelta(Timedelta.min)
        max_td = Timedelta(Timedelta.max)

        # GH 12727
        # timedelta limits correspond to int64 boundaries
        self.assertTrue(min_td.value == np.iinfo(np.int64).min + 1)
        self.assertTrue(max_td.value == np.iinfo(np.int64).max)

        # Beyond lower limit, a NAT before the Overflow
        self.assertIsInstance(min_td - Timedelta(1, 'ns'),
                              pd.tslib.NaTType)

        with tm.assertRaises(OverflowError):
            min_td - Timedelta(2, 'ns')

        with tm.assertRaises(OverflowError):
            max_td + Timedelta(1, 'ns')

        # Same tests using the internal nanosecond values
        td = Timedelta(min_td.value - 1, 'ns')
        self.assertIsInstance(td, pd.tslib.NaTType)

        with tm.assertRaises(OverflowError):
            Timedelta(min_td.value - 2, 'ns')

        with tm.assertRaises(OverflowError):
            Timedelta(max_td.value + 1, 'ns')
开发者ID:ivannz,项目名称:pandas,代码行数:28,代码来源:test_timedelta.py


示例8: _range_scale

 def _range_scale(self):
     """ Calculate scaling, intercept based on data range and output type """
     mn, mx = self.finite_range() # Values of self.array.dtype type
     out_dtype = self._out_dtype
     if mx == mn: # Only one number in array
         self.inter = mn
         return
     # Straight mx-mn can overflow.
     if mn.dtype.kind == 'f': # Already floats
         # float64 and below cast correctly to longdouble.  Longdouble needs
         # no casting
         mn2mx = np.diff(np.array([mn, mx], dtype=np.longdouble))
     else: # max possible (u)int range is 2**64-1 (int64, uint64)
         # int_to_float covers this range.  On windows longdouble is the same
         # as double so mn2mx will be 2**64 - thus overestimating slope
         # slightly.  Casting to int needed to allow mx-mn to be larger than
         # the largest (u)int value
         mn2mx = int_to_float(as_int(mx) - as_int(mn), np.longdouble)
     if out_dtype.kind == 'f':
         # Type range, these are also floats
         info = type_info(out_dtype)
         t_mn_mx = info['min'], info['max']
     else:
         t_mn_mx = np.iinfo(out_dtype).min, np.iinfo(out_dtype).max
         t_mn_mx= [int_to_float(v, np.longdouble) for v in t_mn_mx]
     # We want maximum precision for the calculations. Casting will
     # not lose precision because min/max are of fp type.
     assert [v.dtype.kind for v in t_mn_mx] == ['f', 'f']
     scaled_mn2mx = np.diff(np.array(t_mn_mx, dtype = np.longdouble))
     slope = mn2mx / scaled_mn2mx
     self.inter = mn - t_mn_mx[0] * slope
     self.slope = slope
     if not np.all(np.isfinite([self.slope, self.inter])):
         raise ScalingError("Slope / inter not both finite")
开发者ID:FNNDSC,项目名称:nibabel,代码行数:34,代码来源:arraywriters.py


示例9: testInfNan

  def testInfNan(self):
    i4 = np.iinfo(np.int32)
    i8 = np.iinfo(np.int64)

    self._compare(np.inf, np.float32, np.inf, False)
    self._compare(np.inf, np.float64, np.inf, False)
    if sys.byteorder == "big":  
      self._compare(np.inf, np.int32, i4.max, False)  
      self._compare(np.inf, np.int64, i8.max, False)  
    else:  
      self._compare(np.inf, np.int32, i4.min, False)  
      self._compare(np.inf, np.int64, i8.min, False)  
    self._compare(-np.inf, np.float32, -np.inf, False)
    self._compare(-np.inf, np.float64, -np.inf, False)
    self._compare(-np.inf, np.int32, i4.min, False)
    self._compare(-np.inf, np.int64, i8.min, False)
    self.assertAllEqual(np.isnan(self._cast(np.nan, np.float32, False)), True)
    self.assertAllEqual(np.isnan(self._cast(np.nan, np.float64, False)), True)
    self._compare(np.nan, np.int32, i4.min, False)
    self._compare(np.nan, np.int64, i8.min, False)

    self._compare(np.inf, np.float32, np.inf, True)
    self._compare(np.inf, np.float64, np.inf, True)
    self._compare(-np.inf, np.float32, -np.inf, True)
    self._compare(-np.inf, np.float64, -np.inf, True)
    self.assertAllEqual(np.isnan(self._cast(np.nan, np.float32, True)), True)
    self.assertAllEqual(np.isnan(self._cast(np.nan, np.float64, True)), True)
开发者ID:AlbertXiebnu,项目名称:tensorflow,代码行数:27,代码来源:cast_op_test.py


示例10: __init__

 def __init__(self, name, unit='s', nullable=True):
     min_val, max_val = np.iinfo('int64').min, np.iinfo('int64').max,
     super(DurationIntervalType, self).__init__(
             name, True, 64, nullable=nullable,
             min_value=min_val,
             max_value=max_val)
     self.unit = unit
开发者ID:rok,项目名称:arrow,代码行数:7,代码来源:integration_test.py


示例11: iter_raw_buffers

    def iter_raw_buffers(self):
        """Return an iterator over raw buffers.

        Returns
        -------
        raw_buffer : generator
            Generator for iteration over raw buffers.
        """
        # self.tmax_samp should be included
        iter_times = list(zip(
            list(range(self.tmin_samp, self.tmax_samp, self.buffer_size)),
            list(range(self.tmin_samp + self.buffer_size,
                       self.tmax_samp + 1, self.buffer_size))))
        last_iter_sample = iter_times[-1][1] if iter_times else self.tmin_samp
        if last_iter_sample < self.tmax_samp + 1:
            iter_times.append((last_iter_sample, self.tmax_samp + 1))

        for ii, (start, stop) in enumerate(iter_times):

            # wait for correct number of samples to be available
            self.ft_client.wait(stop, np.iinfo(np.uint32).max,
                                np.iinfo(np.uint32).max)

            # get the samples (stop index is inclusive)
            raw_buffer = self.ft_client.getData([start, stop - 1]).transpose()

            yield raw_buffer
开发者ID:emilymuller1991,项目名称:mne-python,代码行数:27,代码来源:fieldtrip_client.py


示例12: getGDALRasterType

 def getGDALRasterType(self):
     '''
     Gets the output raster type
     '''
     index = self.numberComboBox.currentIndex()
     if index == 0:
         min = numpy.iinfo(numpy.uint8).min
         max = numpy.iinfo(numpy.uint8).max
         return (osgeo.gdal.GDT_Byte, min, max)
     elif index == 1:
         min = numpy.iinfo(numpy.uint16).min
         max = numpy.iinfo(numpy.uint16).max
         return (osgeo.gdal.GDT_UInt16, min, max)
     elif index == 2:
         min = numpy.iinfo(numpy.int16).min
         max = numpy.iinfo(numpy.int16).max
         return (osgeo.gdal.GDT_Int16, min, max)
     elif index == 3:
         min = numpy.iinfo(numpy.uint32).min
         max = numpy.iinfo(numpy.uint32).max
         return (osgeo.gdal.GDT_UInt32, min, max)
     elif index == 4:
         min = numpy.iinfo(numpy.int32).min
         max = numpy.iinfo(numpy.int32).max
         return (osgeo.gdal.GDT_Int32, min, max)
     elif index == 5:
         min = numpy.finfo(numpy.float32).min
         max = numpy.finfo(numpy.float32).max
         return (osgeo.gdal.GDT_Float32, min, max)
     elif index == 6:
         min = numpy.finfo(numpy.float64).min
         max = numpy.finfo(numpy.float64).max
         return (osgeo.gdal.GDT_Float64, min, max)
开发者ID:lcoandrade,项目名称:DsgTools,代码行数:33,代码来源:processingTools.py


示例13: munchetal_filter

    def munchetal_filter(im, wlevel, sigma, wname='db15'):
        # Wavelet decomposition:
        coeffs = pywt.wavedec2(im.astype(np.float32), wname, level=wlevel)
        coeffsFlt = [coeffs[0]]
        # FFT transform of horizontal frequency bands:
        for i in range(1, wlevel + 1):
            # FFT:
            fcV = np.fft.fftshift(np.fft.fft(coeffs[i][1], axis=0))
            my, mx = fcV.shape
            # Damping of vertical stripes:
            damp = 1 - np.exp(-(np.arange(-np.floor(my / 2.), -np.floor(my / 2.) + my) ** 2) / (2 * (sigma ** 2)))
            dampprime = np.kron(np.ones((1, mx)), damp.reshape((damp.shape[0], 1)))
            fcV = fcV * dampprime
            # Inverse FFT:
            fcVflt = np.real(np.fft.ifft(np.fft.ifftshift(fcV), axis=0))
            cVHDtup = (coeffs[i][0], fcVflt, coeffs[i][2])
            coeffsFlt.append(cVHDtup)

        # Get wavelet reconstruction:
        im_f = np.real(pywt.waverec2(coeffsFlt, wname))
        # Return image according to input type:
        if (im.dtype == 'uint16'):
            # Check extrema for uint16 images:
            im_f[im_f < np.iinfo(np.uint16).min] = np.iinfo(np.uint16).min
            im_f[im_f > np.iinfo(np.uint16).max] = np.iinfo(np.uint16).max
            # Return filtered image (an additional row and/or column might be present):
            return im_f[0:im.shape[0], 0:im.shape[1]].astype(np.uint16)
        else:
            return im_f[0:im.shape[0], 0:im.shape[1]]
开发者ID:pierrepaleo,项目名称:portal,代码行数:29,代码来源:rings.py


示例14: clean

def clean(data):

  data_wso = data.astype(np.int)

  masked = np.ma.array(data_wso)
  masked[:,np.arange(0,2592,16)] = np.ma.masked


  #Set the mean of each spectra to zero
  #med_col = np.mean(masked,axis=1)
  med_col = np.min((\
   np.mean(masked[:,:2592/5],axis=1),\
   np.mean(masked[:,-2592/5:],axis=1)),\
   axis=0)

  data_wso = data_wso - med_col[:,np.newaxis]

  #Shift the mean to 128
  data_wso = data_wso + 128

  #Set the right proprieties to the data
  data_wso[:,np.arange(0,2592,16)] = 0
  dtype_min = np.iinfo(data.dtype).min
  dtype_max = np.iinfo(data.dtype).max
  np.clip(data_wso, dtype_min, dtype_max, out=data_wso)
  data_wso = np.around(data_wso)
  data = data_wso.astype(data.dtype)

  return data
开发者ID:danielemichilli,项目名称:LSPs,代码行数:29,代码来源:Utilities.py


示例15: _iu2iu

 def _iu2iu(self):
     # (u)int to (u)int
     mn, mx = [as_int(v) for v in self.finite_range()]
     # range may be greater than the largest integer for this type.
     # as_int needed to work round numpy 1.4.1 int casting bug
     out_dtype = self._out_dtype
     t_min, t_max = np.iinfo(out_dtype).min, np.iinfo(out_dtype).max
     type_range = as_int(t_max) - as_int(t_min)
     mn2mx = mx - mn
     if mn2mx <= type_range: # might offset be enough?
         if t_min == 0: # uint output - take min to 0
             # decrease offset with floor_exact, meaning mn >= t_min after
             # subtraction.  But we may have pushed the data over t_max,
             # which we check below
             inter = floor_exact(mn - t_min, self.scaler_dtype)
         else: # int output - take midpoint to 0
             # ceil below increases inter, pushing scale up to 0.5 towards
             # -inf, because ints have abs min == abs max + 1
             midpoint = mn + as_int(np.ceil(mn2mx / 2.0))
             # Floor exact decreases inter, so pulling scaled values more
             # positive. This may make mx - inter > t_max
             inter = floor_exact(midpoint, self.scaler_dtype)
         # Need to check still in range after floor_exact-ing
         int_inter = as_int(inter)
         assert mn - int_inter >= t_min
         if mx - int_inter <= t_max:
             self.inter = inter
             return
     # Try slope options (sign flip) and then range scaling
     super(SlopeInterArrayWriter, self)._iu2iu()
开发者ID:Jan-Schreiber,项目名称:nibabel,代码行数:30,代码来源:arraywriters.py


示例16: construct_lookup_variables

  def construct_lookup_variables(self):
    # Materialize negatives for fast lookup sampling.
    start_time = timeit.default_timer()
    inner_bounds = np.argwhere(self._train_pos_users[1:] -
                               self._train_pos_users[:-1])[:, 0] + 1
    (upper_bound,) = self._train_pos_users.shape
    index_bounds = [0] + inner_bounds.tolist() + [upper_bound]
    self._negative_table = np.zeros(shape=(self._num_users, self._num_items),
                                    dtype=rconst.ITEM_DTYPE)

    # Set the table to the max value to make sure the embedding lookup will fail
    # if we go out of bounds, rather than just overloading item zero.
    self._negative_table += np.iinfo(rconst.ITEM_DTYPE).max
    assert self._num_items < np.iinfo(rconst.ITEM_DTYPE).max

    # Reuse arange during generation. np.delete will make a copy.
    full_set = np.arange(self._num_items, dtype=rconst.ITEM_DTYPE)

    self._per_user_neg_count = np.zeros(
        shape=(self._num_users,), dtype=np.int32)

    # Threading does not improve this loop. For some reason, the np.delete
    # call does not parallelize well. Multiprocessing incurs too much
    # serialization overhead to be worthwhile.
    for i in range(self._num_users):
      positives = self._train_pos_items[index_bounds[i]:index_bounds[i+1]]
      negatives = np.delete(full_set, positives)
      self._per_user_neg_count[i] = self._num_items - positives.shape[0]
      self._negative_table[i, :self._per_user_neg_count[i]] = negatives

    logging.info("Negative sample table built. Time: {:.1f} seconds".format(
        timeit.default_timer() - start_time))
开发者ID:rder96,项目名称:models,代码行数:32,代码来源:data_pipeline.py


示例17: test_absolute_ufunc

 def test_absolute_ufunc(self, flags=enable_pyobj_flags):
     self.unary_ufunc_test('absolute', flags=flags,
         additional_inputs = [(np.iinfo(np.uint32).max, types.uint32),
                              (np.iinfo(np.uint64).max, types.uint64),
                              (np.finfo(np.float32).min, types.float32),
                              (np.finfo(np.float64).min, types.float64)
                              ])
开发者ID:Bengt,项目名称:numba,代码行数:7,代码来源:test_ufuncs.py


示例18: test1DDataRandom

    def test1DDataRandom(self):
        """Test pixmap generation for 1D data of different size and types."""
        self._log("TestLog10Colormap.test1DDataRandom")
        for cmapName, colormap in self.COLORMAPS.items():
            for size in self.SIZES:
                for dtype in self.DTYPES:
                    for start, end in self.RANGES:
                        try:
                            dtypeMax = np.iinfo(dtype).max
                            dtypeMin = np.iinfo(dtype).min
                        except ValueError:
                            dtypeMax = np.finfo(dtype).max
                            dtypeMin = np.finfo(dtype).min
                        if dtypeMin < 0:
                            data = np.asarray(-dtypeMax/2. +
                                              np.random.rand(size) * dtypeMax,
                                              dtype=dtype)
                        else:
                            data = np.asarray(np.random.rand(size) * dtypeMax,
                                              dtype=dtype)

                        duration = self._testColormap(data, colormap,
                                                      start, end,
                                                      isLog10=True)

                        self._log('1D Random', cmapName, dtype, size,
                                  (start, end), duration)
开发者ID:dnaudet,项目名称:pymca,代码行数:27,代码来源:testColormap.py


示例19: __init__

    def __init__(self, vocabulary, fixed_length, custom_wordgen=None,
                 ignore_sentences_with_only_custom=False, masking_value=0,
                 unknown_value=1):
        """ Needs a dictionary as input for the vocabulary.
        """

        if len(vocabulary) > np.iinfo('uint16').max:
            raise ValueError('Dictionary is too big ({} tokens) for the numpy '
                             'datatypes used (max limit={}). Reduce vocabulary'
                             ' or adjust code accordingly!'
                             .format(len(vocabulary), np.iinfo('uint16').max))

        # Shouldn't be able to modify the given vocabulary
        self.vocabulary = deepcopy(vocabulary)
        self.fixed_length = fixed_length
        self.ignore_sentences_with_only_custom = ignore_sentences_with_only_custom
        self.masking_value = masking_value
        self.unknown_value = unknown_value

        # Initialized with an empty stream of sentences that must then be fed
        # to the generator at a later point for reusability.
        # A custom word generator can be used for domain-specific filtering etc
        if custom_wordgen is not None:
            assert custom_wordgen.stream is None
            self.wordgen = custom_wordgen
            self.uses_custom_wordgen = True
        else:
            self.wordgen = WordGenerator(None, allow_unicode_text=True,
                                         ignore_emojis=False,
                                         remove_variation_selectors=True,
                                         break_replacement=True)
            self.uses_custom_wordgen = False
开发者ID:cclauss,项目名称:torchMoji,代码行数:32,代码来源:sentence_tokenizer.py


示例20: checkTypeConversionNecessary

    def checkTypeConversionNecessary(self, inputType = None, outputType = None):
        if inputType is None:
            if hasattr(self, "inputType"):
                inputType = self.inputType
            else:
                return False
        if outputType is None:
            outputType = self.getOutputDType()

        t = inputType
        limits = []
        try:
            limits.append(numpy.iinfo(t).min)
            limits.append(numpy.iinfo(t).max)
        except:
            limits.append(numpy.finfo(t).min)
            limits.append(numpy.finfo(t).max)

        try:
            if not numpy.all(numpy.array(limits, dtype = outputType) == limits):
                self.normalizationComboBox.setCurrentIndex(1)
                return True #outputtype is too small to hold the limits,
                         #renormalization has to be done beforehand
        except:
            self.normalizationComboBox.setCurrentIndex(1)
            return True #outputtype is too small to hold the limits,
                     #renormalization has to be done beforehand
        return False
开发者ID:lfiaschi,项目名称:volumina,代码行数:28,代码来源:exportDlg.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python numpy.imag函数代码示例发布时间:2022-05-27
下一篇:
Python numpy.identity函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap