本文整理汇总了Python中hyperspy.component.Parameter._id_name方法的典型用法代码示例。如果您正苦于以下问题:Python Parameter._id_name方法的具体用法?Python Parameter._id_name怎么用?Python Parameter._id_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hyperspy.component.Parameter
的用法示例。
在下文中一共展示了Parameter._id_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid_name
# 需要导入模块: from hyperspy.component import Parameter [as 别名]
# 或者: from hyperspy.component.Parameter import _id_name [as 别名]
def test_invalid_name(self):
d = self.par.as_dictionary()
d['_id_name'] = 'otherone'
p = Parameter()
p._id_name = 'newone'
with pytest.raises(ValueError):
_id = p._load_dictionary(d)
示例2: test_load_dictionary
# 需要导入模块: from hyperspy.component import Parameter [as 别名]
# 或者: from hyperspy.component.Parameter import _id_name [as 别名]
def test_load_dictionary(self):
d = self.par.as_dictionary()
p = Parameter()
p._id_name = 'newone'
_id = p._load_dictionary(d)
nt.assert_equal(_id, id(self.par))
nt.assert_true(p.name == self.par.name)
nt.assert_true(p._id_name == self.par._id_name)
nt.assert_true(p.map['values'][0] == 1)
nt.assert_true(p.map['std'][0] == 0.1)
nt.assert_true(p.map['is_set'][0])
nt.assert_true(p.value == self.par.value)
nt.assert_true(p.std == self.par.std)
nt.assert_true(p.free == self.par.free)
nt.assert_true(p._bounds == self.par._bounds)
rn = np.random.random()
nt.assert_equal(p.twin_function(rn), self.par.twin_function(rn))
nt.assert_equal(
p.twin_inverse_function(rn),
self.par.twin_inverse_function(rn))
示例3: test_load_dictionary
# 需要导入模块: from hyperspy.component import Parameter [as 别名]
# 或者: from hyperspy.component.Parameter import _id_name [as 别名]
def test_load_dictionary(self):
d = self.par.as_dictionary()
p = Parameter()
p._id_name = 'newone'
_id = p._load_dictionary(d)
assert _id == id(self.par)
assert p.name == self.par.name
assert p._id_name == self.par._id_name
np.testing.assert_equal(p.map['values'][0], 1)
np.testing.assert_equal(p.map['std'][0], 0.1)
assert p.map['is_set'][0]
np.testing.assert_equal(p.value, self.par.value)
np.testing.assert_equal(p.std, self.par.std)
np.testing.assert_equal(p.free, self.par.free)
np.testing.assert_equal(p._bounds, self.par._bounds)
rn = np.random.random()
np.testing.assert_equal(
p.twin_function(rn),
self.par.twin_function(rn))
np.testing.assert_equal(
p.twin_inverse_function(rn),
self.par.twin_inverse_function(rn))
示例4: test_invalid_name
# 需要导入模块: from hyperspy.component import Parameter [as 别名]
# 或者: from hyperspy.component.Parameter import _id_name [as 别名]
def test_invalid_name(self):
d = self.par.as_dictionary()
d['_id_name'] = 'otherone'
p = Parameter()
p._id_name = 'newone'
_id = p._load_dictionary(d)