本文整理匯總了Python中param.Integer方法的典型用法代碼示例。如果您正苦於以下問題:Python param.Integer方法的具體用法?Python param.Integer怎麽用?Python param.Integer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類param
的用法示例。
在下文中一共展示了param.Integer方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def __init__(self, varr, match_dict, framerate=30):
if isinstance(varr, list):
varr = xr.merge(varr)
self.varr = varr
self.varr_hv = hv.Dataset(varr)
vh = self.varr_hv.range('height')
vw = self.varr_hv.range('width')
frange = self.varr_hv.range('frame')
self._h = int(vh[1] - vh[0] + 1)
self._w = int(vw[1] - vw[0] + 1)
self.match = match_dict
self.framerate = framerate
CStream = Stream.define(
'CStream', f=param.Integer(default=int(frange[0]), bounds=frange))
self.stream = CStream()
self.widgets = self._widgets()
示例2: compute_zoom_level
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def compute_zoom_level(bounds, domain, levels):
"""
Computes a zoom level given a bounds polygon, a polygon of the
overall domain and the number of zoom levels to divide the data
into.
Parameters
----------
bounds: shapely.geometry.Polygon
Polygon representing the area of the current viewport
domain: shapely.geometry.Polygon
Polygon representing the overall bounding region of the data
levels: int
Number of zoom levels to divide the domain into
Returns
-------
zoom_level: int
Integer zoom level
"""
area_fraction = min(bounds.area/domain.area, 1)
return int(min(round(np.log2(1/area_fraction)), levels))
示例3: define
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def define(cls, name, **kwargs):
"""
Utility to quickly and easily declare Stream classes. Designed
for interactive use such as notebooks and shouldn't replace
parameterized class definitions in source code that is imported.
Takes a stream class name and a set of keywords where each
keyword becomes a parameter. If the value is already a
parameter, it is simply used otherwise the appropriate parameter
type is inferred and declared, using the value as the default.
Supported types: bool, int, float, str, dict, tuple and list
"""
params = {'name': param.String(default=name)}
for k, v in kwargs.items():
kws = dict(default=v, constant=True)
if isinstance(v, param.Parameter):
params[k] = v
elif isinstance(v, bool):
params[k] = param.Boolean(**kws)
elif isinstance(v, int):
params[k] = param.Integer(**kws)
elif isinstance(v, float):
params[k] = param.Number(**kws)
elif isinstance(v, str):
params[k] = param.String(**kws)
elif isinstance(v, dict):
params[k] = param.Dict(**kws)
elif isinstance(v, tuple):
params[k] = param.Tuple(**kws)
elif isinstance(v, list):
params[k] = param.List(**kws)
elif isinstance(v, np.ndarray):
params[k] = param.Array(**kws)
else:
params[k] = param.Parameter(**kws)
# Dynamic class creation using type
return type(name, (Stream,), params)
示例4: setUp
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def setUp(self):
self.XY = Stream.define('XY', x=0.0, y=5.0)
self.TypesTest = Stream.define('TypesTest',
t=True,
u=0,
v=1.2,
w= (1,'a'),
x='string',
y= [],
z = np.array([1,2,3]))
test_param = param.Integer(default=42, doc='Test docstring')
self.ExplicitTest = Stream.define('ExplicitTest',
test=test_param)
示例5: test_custom_types
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def test_custom_types(self):
self.assertEqual(isinstance(self.TypesTest.param['t'], param.Boolean),True)
self.assertEqual(isinstance(self.TypesTest.param['u'], param.Integer),True)
self.assertEqual(isinstance(self.TypesTest.param['v'], param.Number),True)
self.assertEqual(isinstance(self.TypesTest.param['w'], param.Tuple),True)
self.assertEqual(isinstance(self.TypesTest.param['x'], param.String),True)
self.assertEqual(isinstance(self.TypesTest.param['y'], param.List),True)
self.assertEqual(isinstance(self.TypesTest.param['z'], param.Array),True)
示例6: test_explicit_parameter
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def test_explicit_parameter(self):
self.assertEqual(isinstance(self.ExplicitTest.param['test'], param.Integer),True)
self.assertEqual(self.ExplicitTest.param['test'].default,42)
self.assertEqual(self.ExplicitTest.param['test'].doc, 'Test docstring')
示例7: test_integer_param
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def test_integer_param(document, comm):
class Test(param.Parameterized):
a = param.Integer(default=2, bounds=(0, 5))
test = Test()
test_pane = Pane(test)
model = test_pane.get_root(document, comm=comm)
slider = model.children[1]
assert isinstance(slider, Slider)
assert slider.value == 2
assert slider.start == 0
assert slider.end == 5
assert slider.step == 1
assert slider.disabled == False
# Check changing param value updates widget
test.a = 3
assert slider.value == 3
# Check changing param attribute updates widget
a_param = test.param['a']
a_param.bounds = (1, 6)
assert slider.start == 1
assert slider.end == 6
a_param.constant = True
assert slider.disabled == True
# Ensure cleanup works
test_pane._cleanup(model)
a_param.constant = False
a_param.bounds = (-1, 7)
test.a = 1
assert slider.value == 3
assert slider.start == 1
assert slider.end == 6
assert slider.disabled == True
示例8: test_explicit_params
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def test_explicit_params(document, comm):
class Test(param.Parameterized):
a = param.Boolean(default=False)
b = param.Integer(default=1)
test = Test()
test_pane = Pane(test, parameters=['a'])
model = test_pane.get_root(document, comm=comm)
assert len(model.children) == 2
assert isinstance(model.children[1], CheckboxGroup)
示例9: test_jsoninit_class_from_env_var
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def test_jsoninit_class_from_env_var():
os.environ['PARAM_JSON_INIT'] = '{"a": 1}'
json_init = JSONInit()
class Test(param.Parameterized):
a = param.Integer()
json_init(Test)
assert Test.a == 1
del os.environ['PARAM_JSON_INIT']
示例10: test_jsoninit_instance_from_env_var
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def test_jsoninit_instance_from_env_var():
os.environ['PARAM_JSON_INIT'] = '{"a": 2}'
json_init = JSONInit()
class Test(param.Parameterized):
a = param.Integer()
test = Test()
json_init(test)
assert test.a == 2
del os.environ['PARAM_JSON_INIT']
示例11: __init__
# 需要導入模塊: import param [as 別名]
# 或者: from param import Integer [as 別名]
def __init__(self, varr, marr=None, framerate=30):
if isinstance(varr, list):
varr = xr.merge(varr)
self.varr = hv.Dataset(varr)
if marr is not None:
self.marr = hv.Dataset(marr)
else:
self.marr = None
self.framerate = framerate
CStream = Stream.define(
'CStream',
f=param.Integer(default=0, bounds=self.varr.range('frame')))
self.stream = CStream()
self.widgets = self._widgets()