本文整理匯總了Python中hyperspy.component.Parameter.disconnect方法的典型用法代碼示例。如果您正苦於以下問題:Python Parameter.disconnect方法的具體用法?Python Parameter.disconnect怎麽用?Python Parameter.disconnect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hyperspy.component.Parameter
的用法示例。
在下文中一共展示了Parameter.disconnect方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUp
# 需要導入模塊: from hyperspy.component import Parameter [as 別名]
# 或者: from hyperspy.component.Parameter import disconnect [as 別名]
class TestParameterLen1:
def setUp(self):
self.par = Parameter()
def test_set_value(self):
self.par.value = 2
assert_equal(self.par.value, 2)
@raises(ValueError)
def test_set_value_wrong_length(self):
self.par.value = (2, 2)
def test_set_value_bounded(self):
self.par.bmin = 1
self.par.bmax = 3
self.par.ext_bounded = True
assert_equal(self.par.value, 1)
self.par.value = 1.5
assert_equal(self.par.value, 1.5)
self.par.value = 0.5
assert_equal(self.par.value, 1)
self.par.value = 4
assert_equal(self.par.value, 3)
self.par.bmax = 2
assert_equal(self.par.value, 2)
self.par.value = 1.5
self.par.bmin = 1.6
assert_equal(self.par.value, 1.6)
def test_ext_force_positive(self):
self.par.ext_bounded = True
self.par.ext_force_positive = True
self.par.value = -1.5
assert_equal(self.par.value, 1.5)
self.par.bmax = 2
self.par.value = -3
assert_equal(self.par.value, 2)
def test_number_of_elements(self):
assert_equal(len(self.par), 1)
def test_default_value(self):
assert_equal(self.par.value, 0)
def test_connect_disconnect(self):
dummy = Dummy()
self.par.connect(dummy.add_one)
self.par.value = 1
assert_equal(dummy.value, 2)
# Setting the same value should not call the connected functions
self.par.value = 1
assert_equal(dummy.value, 2)
# After disconnecting dummy.value should not change
self.par.disconnect(dummy.add_one)
self.par.value = 2
assert_equal(dummy.value, 2)
def test_map_size0(self):
self.par._axes_manager = DummyAxesManager()
self.par._create_array()
self.par.value = 1
self.par.std = 0.1
self.par.store_current_value_in_array()
assert_equal(self.par.map['values'][0], 1)
assert_true(self.par.map['is_set'][0])
assert_equal(self.par.map['std'][0], 0.1)
def test_map_size1(self):
self.par._axes_manager = DummyAxesManager()
self.par._axes_manager.navigation_shape = [1, ]
self.par._create_array()
self.par.value = 1
self.par.std = 0.1
self.par.store_current_value_in_array()
assert_equal(self.par.map['values'][0], 1)
assert_true(self.par.map['is_set'][0])
assert_equal(self.par.map['std'][0], 0.1)
def test_map_size2(self):
self.par._axes_manager = DummyAxesManager()
self.par._axes_manager.navigation_shape = [2, ]
self.par._axes_manager.indices = (1,)
self.par._create_array()
self.par.value = 1
self.par.std = 0.1
self.par.store_current_value_in_array()
assert_equal(self.par.map['values'][1], 1)
assert_true(self.par.map['is_set'][1])
assert_equal(self.par.map['std'][1], 0.1)