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

Python numpy.issubclass_函数代码示例

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

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



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

示例1: alter_dndm

    def alter_dndm(self, val):
        """
        A model for empirical recalibration of the HMF.

        :type: None, str, or :class`WDMRecalibrateMF` subclass.
        """
        if not np.issubclass_(val, WDMRecalibrateMF) and val is not None and not np.issubclass_(val, basestring):
            raise TypeError("alter_dndm must be a WDMRecalibrateMF subclass, string, or None")
        else:
            return val
开发者ID:gjsun,项目名称:hmf,代码行数:10,代码来源:wdm.py


示例2: growth

 def growth(self):
     "The instantiated growth model"
     if np.issubclass_(self.growth_model, gf.GrowthFactor):
         return self.growth_model(self.cosmo, **self.growth_params)
     else:
         return get_model(self.growth_model, "hmf.growth_factor", cosmo=self.cosmo,
                          **self.growth_params)
开发者ID:mirochaj,项目名称:hmf,代码行数:7,代码来源:transfer.py


示例3: default

 def default(self, obj):
     if isinstance(obj, BaseP2GObject):
         mod_str = str(obj.__class__.__module__)
         mod_str = mod_str + "." if mod_str != __name__ else ""
         cls_str = str(obj.__class__.__name__)
         obj = obj.copy(as_dict=True)
         # object should now be a builtin dict
         obj["__class__"] = mod_str + cls_str
         return obj
         # return super(P2GJSONEncoder, self).encode(obj)
     elif isinstance(obj, datetime):
         return obj.isoformat()
     elif numpy.issubclass_(obj, numpy.number) or isinstance(obj, numpy.dtype):
         return dtype_to_str(obj)
     elif hasattr(obj, 'dtype'):
         if obj.size > 1:
             return obj.tolist()
         return int(obj) if numpy.issubdtype(obj, numpy.integer) else float(obj)
     else:
         try:
             return super(P2GJSONEncoder, self).default(obj)
         except TypeError as e:
             print("TypeError:", str(e), type(obj))
             print(obj)
             raise
开发者ID:davidh-ssec,项目名称:polar2grid,代码行数:25,代码来源:containers.py


示例4: __init__

    def __init__(self, *args, **kwargs):
        self.__enums = dict((f, t) for f, t in self._fields_
                            if issubclass_(t, Enum))
        for field, val in iteritems(self._defaults_):
            setattr(self, field, val)

        Structure.__init__(self, *args, **kwargs)
开发者ID:dougalsutherland,项目名称:sdm,代码行数:7,代码来源:sdm_ctypes.py


示例5: _wdm

 def _wdm(self):
     if issubclass_(self.wdm_transfer, WDM):
         return self.wdm_transfer(self.wdm_mass, self.omegac, self.h, self.mean_dens,
                                  **self.wdm_params)
     elif isinstance(self.wdm_transfer, basestring):
         return get_wdm(self.wdm_transfer, mx=self.wdm_mass, omegac=self.omegac,
                        h=self.h, rho_mean=self.mean_dens,
                        **self.wdm_params)
开发者ID:inonchiu,项目名称:hmf,代码行数:8,代码来源:wdm.py


示例6: replace_dim

 def replace_dim(self, olddim, newdim):
     if isinstance(olddim, string_types):
         olddim = self.dims_index(olddim)
         olddim = self.dims[olddim]
         if np.issubclass_(newdim, DimBase):
             newdim = newdim(olddim)
     self.dims = replace_dim(self.dims, olddim, newdim)
     return self.dims
开发者ID:arsenovic,项目名称:hftools,代码行数:8,代码来源:arrayobj.py


示例7: sd_bias

 def sd_bias(self):
     """A class containing relevant methods to calculate scale-dependent bias corrections"""
     if self.sd_bias_model is None:
         return None
     elif issubclass_(self.sd_bias_model, bias.ScaleDepBias):
         return self.sd_bias_model(self.corr_mm_base, **self.sd_bias_params)
     else:
         return get_model(self.sd_bias_model, "halomod.bias",
                          xi_dm=self.corr_mm_base, **self.sd_bias_params)
开发者ID:steven-murray,项目名称:halomod,代码行数:9,代码来源:halo_model.py


示例8: exclusion_model

    def exclusion_model(self, val):
        """A string identifier for the type of halo exclusion used (or None)"""
        if val is None:
            val = "NoExclusion"

        if issubclass_(val, Exclusion):
            return val
        else:
            return get_model_(val, "halomod.halo_exclusion")
开发者ID:steven-murray,项目名称:halomod,代码行数:9,代码来源:halo_model.py


示例9: profile_model

    def profile_model(self, val):
        """The halo density profile model"""
        if not isinstance(val, basestring) and not issubclass_(val, profiles.Profile):
            raise ValueError("profile_model must be a subclass of profiles.Profile")

        if isinstance(val, basestring):
            return get_model_(val, "halomod.profiles")
        else:
            return val
开发者ID:steven-murray,项目名称:halomod,代码行数:9,代码来源:halo_model.py


示例10: filter_model

    def filter_model(self, val):
        """
        A model for the window/filter function.

        :type: str or :class:`hmf.filters.Filter` subclass
        """
        if not issubclass_(val, Filter) and not isinstance(val, basestring):
            raise ValueError("filter must be a Filter or string, got %s" % type(val))
        return val
开发者ID:gjsun,项目名称:hmf,代码行数:9,代码来源:hmf.py


示例11: filter

 def filter(self):
     """
     Instantiated model for filter/window functions.
     """
     if issubclass_(self.filter_model, Filter):
         return self.filter_model(self.k,self._unnormalised_power, **self.filter_params)
     elif isinstance(self.filter_model, basestring):
         return get_model(self.filter_model, "hmf.filters", k=self.k,
                             power=self._unnormalised_power, **self.filter_params)
开发者ID:gjsun,项目名称:hmf,代码行数:9,代码来源:hmf.py


示例12: wdm_model

    def wdm_model(self, val):
        """
        A model for the WDM effect on the transfer function.

        :type: str or :class:`WDM` subclass
        """
        if not np.issubclass_(val, WDM) and not isinstance(val, basestring):
            raise ValueError("wdm_model must be a WDM subclass or string, got %s" % type(val))
        return val
开发者ID:gjsun,项目名称:hmf,代码行数:9,代码来源:wdm.py


示例13: str_to_dtype

def str_to_dtype(dtype_str):
    if numpy.issubclass_(dtype_str, numpy.number):
        # if they gave us a numpy dtype
        return dtype_str

    try:
        return str2dtype[dtype_str]
    except KeyError:
        raise ValueError("Not a valid data type string: %s" % (dtype_str,))
开发者ID:khunger,项目名称:polar2grid,代码行数:9,代码来源:dtype.py


示例14: transfer

 def transfer(self):
     """
     The instantiated transfer model
     """
     if np.issubclass_(self.transfer_model, tm.TransferComponent):
         return self.transfer_model(self.cosmo, **self.transfer_params)
     elif isinstance(self.transfer_model, str):
         return get_model(self.transfer_model, "hmf.transfer_models", cosmo=self.cosmo,
                          **self.transfer_params)
开发者ID:mirochaj,项目名称:hmf,代码行数:9,代码来源:transfer.py


示例15: growth_model

    def growth_model(self, val):
        """
        The model to use to calculate the growth function/growth rate.

        :type: str or `hmf.growth_factor.GrowthFactor` subclass
        """
        if not np.issubclass_(val, gf.GrowthFactor) and not isinstance(val, str):
            raise ValueError("growth_model must be a GrowthFactor or string, got %s" % type(val))
        return val
开发者ID:mirochaj,项目名称:hmf,代码行数:9,代码来源:transfer.py


示例16: hmf_model

    def hmf_model(self, val):
        """
        A model to use as the fitting function :math:`f(\sigma)`

        :type: str or `hmf.fitting_functions.FittingFunction` subclass
        """
        if not issubclass_(val, ff.FittingFunction) and not isinstance(val, basestring):
            raise ValueError("hmf_model must be a ff.FittingFunction or string, got %s" % type(val))
        return val
开发者ID:gjsun,项目名称:hmf,代码行数:9,代码来源:hmf.py


示例17: get_fill_value

    def get_fill_value(self, item, default_dtype=numpy.float32):
        """If the caller of `get_swath_data` doesn't force the output fill value then they need to know what it is now.
        Defaults version expects a 'data_type' attribute in the value returned from `file_type_info`.

            - Unsigned Integers: Highest valid integer (i.e. -1 converted to unsigned integer)
            - Signed Integers: -999
            - Float: NaN

        :raises: RuntimeError if unknown data type
        """
        data_type = self.get_data_type(item, default_dtype=default_dtype)
        if numpy.issubclass_(data_type, numpy.unsignedinteger):
            return data_type(-1)
        elif numpy.issubclass_(data_type, numpy.integer):
            return -999
        elif numpy.issubclass_(data_type, numpy.floating):
            return numpy.nan
        else:
            raise RuntimeError("Unknown data type for %s: %s" % (item, data_type))
开发者ID:khunger,项目名称:polar2grid,代码行数:19,代码来源:frontend_utils.py


示例18: _unnormalised_lnT

 def _unnormalised_lnT(self):
     """
     The un-normalised transfer function
     
     This wraps the individual transfer_fit methods to provide unified access.
     """
     if issubclass_(self.transfer_fit, GetTransfer):
         return self.transfer_fit(self).lnt(self.lnk)
     elif isinstance(self.transfer_fit, basestring):
         return get_transfer(self.transfer_fit, self).lnt(self.lnk)
开发者ID:inonchiu,项目名称:hmf,代码行数:10,代码来源:transfer.py


示例19: __init__

 def __init__(self, theta, phi, r, w=None, s=0.0, eps=1e-16):
     if np.issubclass_(w, float):
         w = ones(len(theta)) * w
     nt_, tt_, np_, tp_, c, fp, ier = dfitpack.spherfit_smth(theta, phi, r, w=w, s=s, eps=eps)
     if not ier in [0, -1, -2]:
         message = _spherefit_messages.get(ier, "ier=%s" % (ier))
         raise ValueError(message)
     self.fp = fp
     self.tck = tt_[:nt_], tp_[:np_], c[: (nt_ - 4) * (np_ - 4)]
     self.degrees = (3, 3)
开发者ID:7islands,项目名称:scipy,代码行数:10,代码来源:fitpack2.py


示例20: create_output_from_product

    def create_output_from_product(self, gridded_product, output_pattern=None,
                                   data_type=None, inc_by_one=None, fill_value=None, **kwargs):
        inc_by_one = inc_by_one or False
        data_type = data_type or gridded_product["data_type"]
        fill_value = fill_value or gridded_product["fill_value"]
        same_fill = numpy.isnan(fill_value) and numpy.isnan(gridded_product["fill_value"]) or fill_value == gridded_product["fill_value"]
        grid_def = gridded_product["grid_definition"]
        if not output_pattern:
            output_pattern = DEFAULT_OUTPUT_PATTERN
        if "{" in output_pattern:
            # format the filename
            of_kwargs = gridded_product.copy(as_dict=True)
            of_kwargs["data_type"] = data_type
            output_filename = self.create_output_filename(output_pattern,
                                                          grid_name=grid_def["grid_name"],
                                                          rows=grid_def["height"],
                                                          columns=grid_def["width"],
                                                          **of_kwargs)
        else:
            output_filename = output_pattern

        if os.path.isfile(output_filename):
            if not self.overwrite_existing:
                LOG.error("Geotiff file already exists: %s", output_filename)
                raise RuntimeError("Geotiff file already exists: %s" % (output_filename,))
            else:
                LOG.warning("Geotiff file already exists, will overwrite: %s", output_filename)

        # if we have a floating point data type, then scaling doesn't make much sense
        if data_type == gridded_product["data_type"] and same_fill:
            LOG.info("Saving product %s to binary file %s", gridded_product["product_name"], output_filename)
            shutil.copyfile(gridded_product["grid_data"], output_filename)
            return output_filename
        elif numpy.issubclass_(data_type, numpy.floating):
            # we didn't rescale any data, but we need to convert it
            data = gridded_product.get_data_array()
        else:
            try:
                LOG.debug("Scaling %s data to fit data type", gridded_product["product_name"])
                data = self.rescaler.rescale_product(gridded_product, data_type,
                                                     inc_by_one=inc_by_one, fill_value=fill_value)
                data = clip_to_data_type(data, data_type)
            except ValueError:
                if not self.keep_intermediate and os.path.isfile(output_filename):
                    os.remove(output_filename)
                raise

        LOG.info("Saving product %s to binary file %s", gridded_product["product_name"], output_filename)
        data = data.astype(data_type)
        fill_mask = gridded_product.get_data_mask()
        data[fill_mask] = fill_value
        data.tofile(output_filename)

        return output_filename
开发者ID:davidh-ssec,项目名称:polar2grid,代码行数:54,代码来源:binary.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python numpy.issubdtype函数代码示例发布时间:2022-05-27
下一篇:
Python numpy.isscalar函数代码示例发布时间: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