本文整理汇总了Python中numpy.issubclass_函数的典型用法代码示例。如果您正苦于以下问题:Python issubclass_函数的具体用法?Python issubclass_怎么用?Python issubclass_使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了issubclass_函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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)
示例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
示例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)
示例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)
示例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
示例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)
示例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")
示例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
示例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
示例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)
示例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
示例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,))
示例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)
示例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